Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
9b2ee14eb1 | |||
0a8286e008 | |||
42fecdb60b | |||
f84ec95d2f | |||
4b4cf96de1 | |||
c413dd9078 | |||
95f3fe7bd5 | |||
443dd146e1 | |||
2d982b678e | |||
7cf61a392d | |||
e190efb7af | |||
711adcb36e | |||
b98ce96d09 | |||
b7ad1fb086 | |||
d812cecc44 | |||
965d74355a | |||
92b1359d04 | |||
c25fa19208 |
@ -90,6 +90,7 @@ float meta_logical_monitor_get_scale (MetaLogicalMonitor *logical_monitor);
|
||||
|
||||
MetaMonitorTransform meta_logical_monitor_get_transform (MetaLogicalMonitor *logical_monitor);
|
||||
|
||||
META_EXPORT_TEST
|
||||
MetaRectangle meta_logical_monitor_get_layout (MetaLogicalMonitor *logical_monitor);
|
||||
|
||||
META_EXPORT_TEST
|
||||
|
@ -3302,15 +3302,7 @@ handle_toggle_tiled (MetaDisplay *display,
|
||||
if ((META_WINDOW_TILED_LEFT (window) && mode == META_TILE_LEFT) ||
|
||||
(META_WINDOW_TILED_RIGHT (window) && mode == META_TILE_RIGHT))
|
||||
{
|
||||
window->tile_monitor_number = window->saved_maximize ? window->monitor->number
|
||||
: -1;
|
||||
window->tile_mode = window->saved_maximize ? META_TILE_MAXIMIZED
|
||||
: META_TILE_NONE;
|
||||
|
||||
if (window->saved_maximize)
|
||||
meta_window_maximize (window, META_MAXIMIZE_BOTH);
|
||||
else
|
||||
meta_window_unmaximize (window, META_MAXIMIZE_BOTH);
|
||||
meta_window_untile (window);
|
||||
}
|
||||
else if (meta_window_can_tile_side_by_side (window))
|
||||
{
|
||||
|
@ -656,6 +656,9 @@ void meta_window_unmanage (MetaWindow *window,
|
||||
void meta_window_unmanage_on_idle (MetaWindow *window);
|
||||
void meta_window_queue (MetaWindow *window,
|
||||
guint queuebits);
|
||||
META_EXPORT_TEST
|
||||
void meta_window_untile (MetaWindow *window);
|
||||
|
||||
META_EXPORT_TEST
|
||||
void meta_window_tile (MetaWindow *window,
|
||||
MetaTileMode mode);
|
||||
|
@ -3148,6 +3148,22 @@ update_edge_constraints (MetaWindow *window)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_untile (MetaWindow *window)
|
||||
{
|
||||
window->tile_monitor_number =
|
||||
window->saved_maximize ? window->monitor->number
|
||||
: -1;
|
||||
window->tile_mode =
|
||||
window->saved_maximize ? META_TILE_MAXIMIZED
|
||||
: META_TILE_NONE;
|
||||
|
||||
if (window->saved_maximize)
|
||||
meta_window_maximize (window, META_MAXIMIZE_BOTH);
|
||||
else
|
||||
meta_window_unmaximize (window, META_MAXIMIZE_BOTH);
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_tile (MetaWindow *window,
|
||||
MetaTileMode tile_mode)
|
||||
@ -3164,6 +3180,10 @@ meta_window_tile (MetaWindow *window,
|
||||
window->tile_monitor_number = -1;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
window->tile_monitor_number = window->monitor->number;
|
||||
}
|
||||
|
||||
if (window->tile_mode == META_TILE_MAXIMIZED)
|
||||
directions = META_MAXIMIZE_BOTH;
|
||||
|
@ -141,6 +141,11 @@ stacking_tests = [
|
||||
'override-redirect',
|
||||
'set-override-redirect-parent',
|
||||
'set-parent-exported',
|
||||
'restore-size',
|
||||
'unmaximize-new-size',
|
||||
'fullscreen-maximize',
|
||||
'restore-position',
|
||||
'default-size',
|
||||
]
|
||||
|
||||
foreach stacking_test: stacking_tests
|
||||
|
36
src/tests/stacking/default-size.metatest
Normal file
36
src/tests/stacking/default-size.metatest
Normal file
@ -0,0 +1,36 @@
|
||||
new_client x x11
|
||||
create x/1 csd
|
||||
|
||||
resize x/1 300 400
|
||||
show x/1
|
||||
wait
|
||||
|
||||
assert_size x/1 300 400
|
||||
|
||||
resize x/1 200 300
|
||||
wait
|
||||
assert_size x/1 200 300
|
||||
|
||||
hide x/1
|
||||
show x/1
|
||||
wait
|
||||
assert_size x/1 200 300
|
||||
|
||||
|
||||
new_client w wayland
|
||||
create w/1 csd
|
||||
|
||||
resize w/1 300 400
|
||||
show w/1
|
||||
wait
|
||||
|
||||
assert_size w/1 300 400
|
||||
|
||||
resize w/1 200 300
|
||||
wait_reconfigure
|
||||
assert_size w/1 200 300
|
||||
|
||||
hide w/1
|
||||
show w/1
|
||||
wait_reconfigure
|
||||
assert_size w/1 200 300
|
73
src/tests/stacking/fullscreen-maximize.metatest
Normal file
73
src/tests/stacking/fullscreen-maximize.metatest
Normal file
@ -0,0 +1,73 @@
|
||||
# Tests that the following works, both on Wayland and X11
|
||||
# 1. Create a window with a known size
|
||||
# 2. Maxmize window results in maximized size
|
||||
# 3. Fullscreen window results in fullscreen size
|
||||
# 4. Unfullscreen window results in maximized size
|
||||
# 5. Unmaximize window results in original size
|
||||
# 6. Toggling fullscreen ends up with original size
|
||||
|
||||
new_client w wayland
|
||||
create w/1 csd
|
||||
|
||||
resize w/1 500 400
|
||||
show w/1
|
||||
wait
|
||||
|
||||
assert_size w/1 500 400
|
||||
|
||||
maximize w/1
|
||||
wait_reconfigure
|
||||
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
|
||||
|
||||
fullscreen w/1
|
||||
wait_reconfigure
|
||||
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
|
||||
|
||||
unfullscreen w/1
|
||||
wait_reconfigure
|
||||
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
|
||||
|
||||
unmaximize w/1
|
||||
wait_reconfigure
|
||||
assert_size w/1 500 400
|
||||
|
||||
fullscreen w/1
|
||||
wait_reconfigure
|
||||
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
|
||||
|
||||
unfullscreen w/1
|
||||
wait_reconfigure
|
||||
assert_size w/1 500 400
|
||||
|
||||
new_client x x11
|
||||
create x/1 csd
|
||||
|
||||
resize x/1 500 400
|
||||
show x/1
|
||||
wait
|
||||
|
||||
assert_size x/1 500 400
|
||||
|
||||
maximize x/1
|
||||
wait_reconfigure
|
||||
assert_size x/1 MONITOR_WIDTH MONITOR_HEIGHT
|
||||
|
||||
fullscreen x/1
|
||||
wait_reconfigure
|
||||
assert_size x/1 MONITOR_WIDTH MONITOR_HEIGHT
|
||||
|
||||
unfullscreen x/1
|
||||
wait_reconfigure
|
||||
assert_size x/1 MONITOR_WIDTH MONITOR_HEIGHT
|
||||
|
||||
unmaximize x/1
|
||||
wait_reconfigure
|
||||
assert_size x/1 500 400
|
||||
|
||||
fullscreen x/1
|
||||
wait_reconfigure
|
||||
assert_size x/1 MONITOR_WIDTH MONITOR_HEIGHT
|
||||
|
||||
unfullscreen x/1
|
||||
wait_reconfigure
|
||||
assert_size x/1 500 400
|
73
src/tests/stacking/restore-position.metatest
Normal file
73
src/tests/stacking/restore-position.metatest
Normal file
@ -0,0 +1,73 @@
|
||||
# X11
|
||||
|
||||
new_client x x11
|
||||
create x/1 csd
|
||||
show x/1
|
||||
|
||||
move x/1 100 100
|
||||
assert_position x/1 100 100
|
||||
|
||||
maximize x/1
|
||||
wait_reconfigure
|
||||
assert_position x/1 0 0
|
||||
|
||||
unmaximize x/1
|
||||
wait_reconfigure
|
||||
assert_position x/1 100 100
|
||||
|
||||
tile x/1 left
|
||||
wait
|
||||
assert_position x/1 0 0
|
||||
|
||||
untile x/1
|
||||
wait
|
||||
assert_position x/1 100 100
|
||||
|
||||
tile x/1 left
|
||||
wait
|
||||
assert_position x/1 0 0
|
||||
|
||||
maximize x/1
|
||||
wait_reconfigure
|
||||
assert_position x/1 0 0
|
||||
|
||||
unmaximize x/1
|
||||
wait_reconfigure
|
||||
assert_position x/1 100 100
|
||||
|
||||
# Wayland
|
||||
|
||||
new_client w wayland
|
||||
create w/1 csd
|
||||
show w/1
|
||||
|
||||
move w/1 100 100
|
||||
assert_position w/1 100 100
|
||||
|
||||
maximize w/1
|
||||
wait_reconfigure
|
||||
assert_position w/1 0 0
|
||||
|
||||
unmaximize w/1
|
||||
wait_reconfigure
|
||||
assert_position w/1 100 100
|
||||
|
||||
tile w/1 left
|
||||
wait_reconfigure
|
||||
assert_position w/1 0 0
|
||||
|
||||
untile w/1
|
||||
wait
|
||||
assert_position w/1 100 100
|
||||
|
||||
tile w/1 left
|
||||
wait
|
||||
assert_position w/1 0 0
|
||||
|
||||
maximize w/1
|
||||
wait_reconfigure
|
||||
assert_position w/1 0 0
|
||||
|
||||
unmaximize w/1
|
||||
wait_reconfigure
|
||||
assert_position w/1 100 100
|
93
src/tests/stacking/restore-size.metatest
Normal file
93
src/tests/stacking/restore-size.metatest
Normal file
@ -0,0 +1,93 @@
|
||||
# Check that X11 clients restore to their right size after unmaximize
|
||||
# or untile
|
||||
|
||||
new_client x x11
|
||||
create x/1 csd
|
||||
|
||||
resize x/1 500 400
|
||||
maximize x/1
|
||||
show x/1
|
||||
|
||||
wait
|
||||
|
||||
assert_size x/1 MONITOR_WIDTH MONITOR_HEIGHT
|
||||
|
||||
unmaximize x/1
|
||||
wait
|
||||
|
||||
assert_size x/1 500 400
|
||||
|
||||
resize x/1 300 200
|
||||
maximize x/1
|
||||
wait
|
||||
unmaximize x/1
|
||||
wait
|
||||
|
||||
assert_size x/1 300 200
|
||||
|
||||
tile x/1 right
|
||||
wait
|
||||
assert_size x/1 MONITOR_WIDTH/2 MONITOR_HEIGHT
|
||||
|
||||
untile x/1
|
||||
wait
|
||||
assert_size x/1 300 200
|
||||
|
||||
tile x/1 left
|
||||
wait
|
||||
assert_size x/1 MONITOR_WIDTH/2 MONITOR_HEIGHT
|
||||
|
||||
maximize x/1
|
||||
wait_reconfigure
|
||||
assert_size x/1 MONITOR_WIDTH MONITOR_HEIGHT
|
||||
|
||||
unmaximize x/1
|
||||
wait_reconfigure
|
||||
assert_size x/1 300 200
|
||||
|
||||
# Check that Wayland clients restore to their right size after unmaximize
|
||||
# or untile
|
||||
|
||||
new_client w wayland
|
||||
create w/1 csd
|
||||
|
||||
resize w/1 150 300
|
||||
maximize w/1
|
||||
show w/1
|
||||
|
||||
wait
|
||||
|
||||
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
|
||||
|
||||
unmaximize w/1
|
||||
wait_reconfigure
|
||||
|
||||
assert_size w/1 150 300
|
||||
|
||||
resize w/1 300 200
|
||||
maximize w/1
|
||||
wait
|
||||
unmaximize w/1
|
||||
wait_reconfigure
|
||||
|
||||
assert_size w/1 300 200
|
||||
|
||||
tile w/1 right
|
||||
wait
|
||||
assert_size w/1 MONITOR_WIDTH/2 MONITOR_HEIGHT
|
||||
|
||||
untile w/1
|
||||
wait
|
||||
assert_size w/1 300 200
|
||||
|
||||
tile w/1 left
|
||||
wait
|
||||
assert_size w/1 MONITOR_WIDTH/2 MONITOR_HEIGHT
|
||||
|
||||
maximize w/1
|
||||
wait_reconfigure
|
||||
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
|
||||
|
||||
unmaximize w/1
|
||||
wait_reconfigure
|
||||
assert_size w/1 300 200
|
22
src/tests/stacking/unmaximize-new-size.metatest
Normal file
22
src/tests/stacking/unmaximize-new-size.metatest
Normal file
@ -0,0 +1,22 @@
|
||||
# This is only tested on Wayland since it's broken on X11
|
||||
|
||||
new_client w wayland
|
||||
create w/1 csd
|
||||
|
||||
resize w/1 500 400
|
||||
show w/1
|
||||
wait
|
||||
|
||||
assert_size w/1 500 400
|
||||
|
||||
maximize w/1
|
||||
wait_reconfigure
|
||||
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
|
||||
|
||||
resize w/1 300 500
|
||||
wait_reconfigure
|
||||
assert_size w/1 MONITOR_WIDTH MONITOR_HEIGHT
|
||||
|
||||
unmaximize w/1
|
||||
wait_reconfigure
|
||||
assert_size w/1 300 500
|
@ -48,7 +48,7 @@ window_export_handle_cb (GdkWindow *window,
|
||||
|
||||
if (!gdk_wayland_window_set_transient_for_exported (gdk_window,
|
||||
(gchar *) handle_str))
|
||||
g_print ("Fail to set transient_for exported window handle %s", handle_str);
|
||||
g_print ("Fail to set transient_for exported window handle %s\n", handle_str);
|
||||
gdk_window_set_modal_hint (gdk_window, TRUE);
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ lookup_window (const char *window_id)
|
||||
{
|
||||
GtkWidget *window = g_hash_table_lookup (windows, window_id);
|
||||
if (!window)
|
||||
g_print ("Window %s doesn't exist", window_id);
|
||||
g_print ("Window %s doesn't exist\n", window_id);
|
||||
|
||||
return window;
|
||||
}
|
||||
@ -242,6 +242,23 @@ handle_take_focus (GtkWidget *window,
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
calculate_titlebar_height (GtkWindow *window)
|
||||
{
|
||||
GtkWidget *titlebar;
|
||||
GdkWindow *gdk_window;
|
||||
|
||||
gdk_window = gtk_widget_get_window (GTK_WIDGET (window));
|
||||
if (gdk_window_get_state (gdk_window) & GDK_WINDOW_STATE_FULLSCREEN)
|
||||
return 0;
|
||||
|
||||
titlebar = gtk_window_get_titlebar (window);
|
||||
if (!titlebar)
|
||||
return 0;
|
||||
|
||||
return gtk_widget_get_allocated_height (titlebar);
|
||||
}
|
||||
|
||||
static void
|
||||
process_line (const char *line)
|
||||
{
|
||||
@ -251,14 +268,14 @@ process_line (const char *line)
|
||||
|
||||
if (!g_shell_parse_argv (line, &argc, &argv, &error))
|
||||
{
|
||||
g_print ("error parsing command: %s", error->message);
|
||||
g_print ("error parsing command: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (argc < 1)
|
||||
{
|
||||
g_print ("Empty command");
|
||||
g_print ("Empty command\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -268,13 +285,13 @@ process_line (const char *line)
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
g_print ("usage: create <id> [override|csd]");
|
||||
g_print ("usage: create <id> [override|csd]\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (g_hash_table_lookup (windows, argv[1]))
|
||||
{
|
||||
g_print ("window %s already exists", argv[1]);
|
||||
g_print ("window %s already exists\n", argv[1]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -290,7 +307,7 @@ process_line (const char *line)
|
||||
|
||||
if (override && csd)
|
||||
{
|
||||
g_print ("override and csd keywords are exclusie");
|
||||
g_print ("override and csd keywords are exclusive\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -334,21 +351,21 @@ process_line (const char *line)
|
||||
{
|
||||
if (argc != 3)
|
||||
{
|
||||
g_print ("usage: set_parent <window-id> <parent-id>");
|
||||
g_print ("usage: set_parent <window-id> <parent-id>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
GtkWidget *window = lookup_window (argv[1]);
|
||||
if (!window)
|
||||
{
|
||||
g_print ("unknown window %s", argv[1]);
|
||||
g_print ("unknown window %s\n", argv[1]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
GtkWidget *parent_window = lookup_window (argv[2]);
|
||||
if (!parent_window)
|
||||
{
|
||||
g_print ("unknown parent window %s", argv[2]);
|
||||
g_print ("unknown parent window %s\n", argv[2]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -359,21 +376,21 @@ process_line (const char *line)
|
||||
{
|
||||
if (argc != 3)
|
||||
{
|
||||
g_print ("usage: set_parent_exported <window-id> <parent-id>");
|
||||
g_print ("usage: set_parent_exported <window-id> <parent-id>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
GtkWidget *window = lookup_window (argv[1]);
|
||||
if (!window)
|
||||
{
|
||||
g_print ("unknown window %s", argv[1]);
|
||||
g_print ("unknown window %s\n", argv[1]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
GtkWidget *parent_window = lookup_window (argv[2]);
|
||||
if (!parent_window)
|
||||
{
|
||||
g_print ("unknown parent window %s", argv[2]);
|
||||
g_print ("unknown parent window %s\n", argv[2]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -382,27 +399,27 @@ process_line (const char *line)
|
||||
window_export_handle_cb,
|
||||
window,
|
||||
NULL))
|
||||
g_print ("Fail to export handle for window id %s", argv[2]);
|
||||
g_print ("Fail to export handle for window id %s\n", argv[2]);
|
||||
}
|
||||
else if (strcmp (argv[0], "accept_focus") == 0)
|
||||
{
|
||||
if (argc != 3)
|
||||
{
|
||||
g_print ("usage: %s <window-id> [true|false]", argv[0]);
|
||||
g_print ("usage: %s <window-id> [true|false]\n", argv[0]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
GtkWidget *window = lookup_window (argv[1]);
|
||||
if (!window)
|
||||
{
|
||||
g_print ("unknown window %s", argv[1]);
|
||||
g_print ("unknown window %s\n", argv[1]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!wayland &&
|
||||
window_has_x11_event_handler (window, handle_take_focus))
|
||||
{
|
||||
g_print ("Impossible to use %s for windows accepting take focus",
|
||||
g_print ("Impossible to use %s for windows accepting take focus\n",
|
||||
argv[1]);
|
||||
goto out;
|
||||
}
|
||||
@ -414,26 +431,26 @@ process_line (const char *line)
|
||||
{
|
||||
if (argc != 3)
|
||||
{
|
||||
g_print ("usage: %s <window-id> [true|false]", argv[0]);
|
||||
g_print ("usage: %s <window-id> [true|false]\n", argv[0]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
GtkWidget *window = lookup_window (argv[1]);
|
||||
if (!window)
|
||||
{
|
||||
g_print ("unknown window %s", argv[1]);
|
||||
g_print ("unknown window %s\n", argv[1]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (wayland)
|
||||
{
|
||||
g_print ("%s not supported under wayland", argv[0]);
|
||||
g_print ("%s not supported under wayland\n", argv[0]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (window_has_x11_event_handler (window, handle_take_focus))
|
||||
{
|
||||
g_print ("Impossible to change %s for windows accepting take focus",
|
||||
g_print ("Impossible to change %s for windows accepting take focus\n",
|
||||
argv[1]);
|
||||
goto out;
|
||||
}
|
||||
@ -473,32 +490,32 @@ process_line (const char *line)
|
||||
{
|
||||
if (argc != 3)
|
||||
{
|
||||
g_print ("usage: %s <window-id> [true|false]", argv[0]);
|
||||
g_print ("usage: %s <window-id> [true|false]\n", argv[0]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
GtkWidget *window = lookup_window (argv[1]);
|
||||
if (!window)
|
||||
{
|
||||
g_print ("unknown window %s", argv[1]);
|
||||
g_print ("unknown window %s\n", argv[1]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (wayland)
|
||||
{
|
||||
g_print ("%s not supported under wayland", argv[0]);
|
||||
g_print ("%s not supported under wayland\n", argv[0]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (gtk_window_get_accept_focus (GTK_WINDOW (window)))
|
||||
{
|
||||
g_print ("%s not supported for input windows", argv[0]);
|
||||
g_print ("%s not supported for input windows\n", argv[0]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!g_object_get_qdata (G_OBJECT (window), can_take_focus_quark))
|
||||
{
|
||||
g_print ("%s not supported for windows with no WM_TAKE_FOCUS set",
|
||||
g_print ("%s not supported for windows with no WM_TAKE_FOCUS set\n",
|
||||
argv[0]);
|
||||
goto out;
|
||||
}
|
||||
@ -512,7 +529,7 @@ process_line (const char *line)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
g_print ("usage: show <id>");
|
||||
g_print ("usage: show <id>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -527,7 +544,7 @@ process_line (const char *line)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
g_print ("usage: hide <id>");
|
||||
g_print ("usage: hide <id>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -541,7 +558,7 @@ process_line (const char *line)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
g_print ("usage: activate <id>");
|
||||
g_print ("usage: activate <id>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -555,7 +572,7 @@ process_line (const char *line)
|
||||
{
|
||||
if (argc != 4)
|
||||
{
|
||||
g_print ("usage: resize <id> <width> <height>");
|
||||
g_print ("usage: resize <id> <width> <height>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -565,13 +582,16 @@ process_line (const char *line)
|
||||
|
||||
int width = atoi (argv[2]);
|
||||
int height = atoi (argv[3]);
|
||||
gtk_window_resize (GTK_WINDOW (window), width, height);
|
||||
int titlebar_height = calculate_titlebar_height (GTK_WINDOW (window));
|
||||
gtk_window_resize (GTK_WINDOW (window),
|
||||
width,
|
||||
height - titlebar_height);
|
||||
}
|
||||
else if (strcmp (argv[0], "raise") == 0)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
g_print ("usage: raise <id>");
|
||||
g_print ("usage: raise <id>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -585,7 +605,7 @@ process_line (const char *line)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
g_print ("usage: lower <id>");
|
||||
g_print ("usage: lower <id>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -599,7 +619,7 @@ process_line (const char *line)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
g_print ("usage: destroy <id>");
|
||||
g_print ("usage: destroy <id>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -614,7 +634,7 @@ process_line (const char *line)
|
||||
{
|
||||
if (argc != 1)
|
||||
{
|
||||
g_print ("usage: destroy_all");
|
||||
g_print ("usage: destroy_all\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -631,7 +651,7 @@ process_line (const char *line)
|
||||
{
|
||||
if (argc != 1)
|
||||
{
|
||||
g_print ("usage: sync");
|
||||
g_print ("usage: sync\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -644,13 +664,13 @@ process_line (const char *line)
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
g_print ("usage: set_counter <counter> <value>");
|
||||
g_print ("usage: set_counter <counter> <value>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (wayland)
|
||||
{
|
||||
g_print ("usage: set_counter can only be used for X11");
|
||||
g_print ("usage: set_counter can only be used for X11\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -666,7 +686,7 @@ process_line (const char *line)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
g_print ("usage: minimize <id>");
|
||||
g_print ("usage: minimize <id>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -680,7 +700,7 @@ process_line (const char *line)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
g_print ("usage: unminimize <id>");
|
||||
g_print ("usage: unminimize <id>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -690,9 +710,95 @@ process_line (const char *line)
|
||||
|
||||
gtk_window_deiconify (GTK_WINDOW (window));
|
||||
}
|
||||
else if (strcmp (argv[0], "maximize") == 0)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
g_print ("usage: maximize <id>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
GtkWidget *window = lookup_window (argv[1]);
|
||||
if (!window)
|
||||
goto out;
|
||||
|
||||
gtk_window_maximize (GTK_WINDOW (window));
|
||||
}
|
||||
else if (strcmp (argv[0], "unmaximize") == 0)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
g_print ("usage: unmaximize <id>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
GtkWidget *window = lookup_window (argv[1]);
|
||||
if (!window)
|
||||
goto out;
|
||||
|
||||
gtk_window_unmaximize (GTK_WINDOW (window));
|
||||
}
|
||||
else if (strcmp (argv[0], "fullscreen") == 0)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
g_print ("usage: fullscreen <id>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
GtkWidget *window = lookup_window (argv[1]);
|
||||
if (!window)
|
||||
goto out;
|
||||
|
||||
gtk_window_fullscreen (GTK_WINDOW (window));
|
||||
}
|
||||
else if (strcmp (argv[0], "unfullscreen") == 0)
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
g_print ("usage: unfullscreen <id>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
GtkWidget *window = lookup_window (argv[1]);
|
||||
if (!window)
|
||||
goto out;
|
||||
|
||||
gtk_window_unfullscreen (GTK_WINDOW (window));
|
||||
}
|
||||
else if (strcmp (argv[0], "assert_size") == 0)
|
||||
{
|
||||
int expected_width;
|
||||
int expected_height;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
if (argc != 4)
|
||||
{
|
||||
g_print ("usage: assert_size <id> <width> <height>\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
GtkWidget *window = lookup_window (argv[1]);
|
||||
if (!window)
|
||||
goto out;
|
||||
|
||||
gtk_window_get_size (GTK_WINDOW (window), &width, &height);
|
||||
height += calculate_titlebar_height (GTK_WINDOW (window));
|
||||
|
||||
expected_width = atoi (argv[2]);
|
||||
expected_height = atoi (argv[3]);
|
||||
if (expected_width != width || expected_height != height)
|
||||
{
|
||||
g_print ("Expected size %dx%d didn't match actual size %dx%d\n",
|
||||
expected_width, expected_height,
|
||||
width, height);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_print ("Unknown command %s", argv[0]);
|
||||
g_print ("Unknown command %s\n", argv[0]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -770,6 +876,32 @@ main(int argc, char **argv)
|
||||
|
||||
gtk_init (NULL, NULL);
|
||||
|
||||
if (!wayland)
|
||||
{
|
||||
GdkScreen *screen;
|
||||
GtkCssProvider *provider;
|
||||
|
||||
screen = gdk_screen_get_default ();
|
||||
provider = gtk_css_provider_new ();
|
||||
static const char *no_decoration_css =
|
||||
"decoration {"
|
||||
" border-radius: 0 0 0 0;"
|
||||
" border-width: 0;"
|
||||
" box-shadow: 0 0 0 0 rgba(0, 0, 0, 0), 0 0 0 0 rgba(0, 0, 0, 0);"
|
||||
" margin: 0px;"
|
||||
"}";
|
||||
if (!gtk_css_provider_load_from_data (provider,
|
||||
no_decoration_css,
|
||||
strlen (no_decoration_css),
|
||||
&error))
|
||||
{
|
||||
g_printerr ("%s", error->message);
|
||||
return 1;
|
||||
}
|
||||
gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
}
|
||||
|
||||
windows = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, NULL);
|
||||
event_source_quark = g_quark_from_static_string ("event-source");
|
||||
|
@ -291,6 +291,30 @@ test_case_assert_focused (TestCase *test,
|
||||
return *error == NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
test_case_assert_size (TestCase *test,
|
||||
MetaWindow *window,
|
||||
int expected_width,
|
||||
int expected_height,
|
||||
GError **error)
|
||||
{
|
||||
MetaRectangle frame_rect;
|
||||
|
||||
meta_window_get_frame_rect (window, &frame_rect);
|
||||
|
||||
if (frame_rect.width != expected_width ||
|
||||
frame_rect.height != expected_height)
|
||||
{
|
||||
g_set_error (error, TEST_RUNNER_ERROR, TEST_RUNNER_ERROR_ASSERTION_FAILED,
|
||||
"Expected size %dx%d didn't match actual size %dx%d",
|
||||
expected_width, expected_height,
|
||||
frame_rect.width, frame_rect.height);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
test_case_check_xserver_stacking (TestCase *test,
|
||||
GError **error)
|
||||
@ -344,6 +368,55 @@ test_case_check_xserver_stacking (TestCase *test,
|
||||
return *error == NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
maybe_divide (const char *str,
|
||||
int value)
|
||||
{
|
||||
if (strstr (str, "/") == str)
|
||||
{
|
||||
int divisor;
|
||||
|
||||
str += 1;
|
||||
divisor = atoi (str);
|
||||
|
||||
value /= divisor;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static int
|
||||
parse_window_size (const char *size_str)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
MetaLogicalMonitor *logical_monitor =
|
||||
meta_monitor_manager_get_logical_monitors (monitor_manager)->data;
|
||||
MetaRectangle logical_monitor_layout =
|
||||
meta_logical_monitor_get_layout (logical_monitor);
|
||||
int value;
|
||||
|
||||
if (strstr (size_str, "MONITOR_WIDTH") == size_str)
|
||||
{
|
||||
value = logical_monitor_layout.width;
|
||||
size_str += strlen ("MONITOR_WIDTH");
|
||||
value = maybe_divide (size_str, value);
|
||||
}
|
||||
else if (strstr (size_str, "MONITOR_HEIGHT") == size_str)
|
||||
{
|
||||
value = logical_monitor_layout.height;
|
||||
size_str += strlen ("MONITOR_HEIGHT");
|
||||
value = maybe_divide (size_str, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
value = atoi (size_str);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
test_case_do (TestCase *test,
|
||||
int argc,
|
||||
@ -504,12 +577,96 @@ test_case_do (TestCase *test,
|
||||
|
||||
test_client_wait_for_window_shown (client, window);
|
||||
}
|
||||
else if (strcmp (argv[0], "resize") == 0)
|
||||
{
|
||||
if (argc != 4)
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> width height", argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
if (!test_client_do (client, error, argv[0], window_id,
|
||||
argv[2], argv[3], NULL))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strcmp (argv[0], "move") == 0)
|
||||
{
|
||||
if (argc != 4)
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> x y", argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
MetaWindow *window = test_client_find_window (client, window_id, error);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
meta_window_move_frame (window, TRUE, atoi (argv[2]), atoi (argv[3]));
|
||||
}
|
||||
else if (strcmp (argv[0], "tile") == 0)
|
||||
{
|
||||
if (argc != 3)
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> [right|left]", argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
MetaWindow *window = test_client_find_window (client, window_id, error);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
MetaTileMode tile_mode;
|
||||
if (strcmp (argv[2], "right") == 0)
|
||||
{
|
||||
tile_mode = META_TILE_RIGHT;
|
||||
}
|
||||
else if (strcmp (argv[2], "left") == 0)
|
||||
{
|
||||
tile_mode = META_TILE_LEFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_set_error (error,
|
||||
TEST_RUNNER_ERROR,
|
||||
TEST_RUNNER_ERROR_ASSERTION_FAILED,
|
||||
"Invalid tile mode '%s'", argv[2]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
meta_window_tile (window, tile_mode);
|
||||
}
|
||||
else if (strcmp (argv[0], "untile") == 0)
|
||||
{
|
||||
if (argc != 2)
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id>", argv[0]);
|
||||
|
||||
TestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
MetaWindow *window = test_client_find_window (client, window_id, error);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
meta_window_untile (window);
|
||||
}
|
||||
else if (strcmp (argv[0], "hide") == 0 ||
|
||||
strcmp (argv[0], "activate") == 0 ||
|
||||
strcmp (argv[0], "raise") == 0 ||
|
||||
strcmp (argv[0], "lower") == 0 ||
|
||||
strcmp (argv[0], "minimize") == 0 ||
|
||||
strcmp (argv[0], "unminimize") == 0 ||
|
||||
strcmp (argv[0], "maximize") == 0 ||
|
||||
strcmp (argv[0], "unmaximize") == 0 ||
|
||||
strcmp (argv[0], "fullscreen") == 0 ||
|
||||
strcmp (argv[0], "unfullscreen") == 0 ||
|
||||
strcmp (argv[0], "destroy") == 0)
|
||||
{
|
||||
if (argc != 2)
|
||||
@ -547,6 +704,24 @@ test_case_do (TestCase *test,
|
||||
if (!test_case_wait (test, error))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strcmp (argv[0], "wait_reconfigure") == 0)
|
||||
{
|
||||
if (argc != 1)
|
||||
BAD_COMMAND("usage: %s", argv[0]);
|
||||
|
||||
/*
|
||||
* Wait twice, so that we
|
||||
* 1) First wait for any requests to configure has been made
|
||||
* 2) Then wait for the new configuration has been applied
|
||||
*/
|
||||
|
||||
if (!test_case_wait (test, error))
|
||||
return FALSE;
|
||||
if (!test_case_dispatch (test, error))
|
||||
return FALSE;
|
||||
if (!test_case_wait (test, error))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strcmp (argv[0], "dispatch") == 0)
|
||||
{
|
||||
if (argc != 1)
|
||||
@ -582,6 +757,80 @@ test_case_do (TestCase *test,
|
||||
if (!test_case_assert_focused (test, argv[1], error))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strcmp (argv[0], "assert_size") == 0)
|
||||
{
|
||||
if (argc != 4)
|
||||
{
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> <width> <height>",
|
||||
argv[0]);
|
||||
}
|
||||
|
||||
TestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
MetaWindow *window = test_client_find_window (client, window_id, error);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
if (meta_window_get_frame (window))
|
||||
{
|
||||
g_set_error (error,
|
||||
TEST_RUNNER_ERROR,
|
||||
TEST_RUNNER_ERROR_ASSERTION_FAILED,
|
||||
"Can only assert size of CSD window");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int width = parse_window_size (argv[2]);
|
||||
int height = parse_window_size (argv[3]);
|
||||
g_autofree char *width_str = g_strdup_printf ("%d", width);
|
||||
g_autofree char *height_str = g_strdup_printf ("%d", height);
|
||||
|
||||
if (!test_client_do (client, error, argv[0],
|
||||
window_id,
|
||||
width_str,
|
||||
height_str,
|
||||
NULL))
|
||||
return FALSE;
|
||||
|
||||
if (!test_case_assert_size (test, window,
|
||||
width, height,
|
||||
error))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strcmp (argv[0], "assert_position") == 0)
|
||||
{
|
||||
if (argc != 4)
|
||||
{
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> <x> <y>",
|
||||
argv[0]);
|
||||
}
|
||||
|
||||
TestClient *client;
|
||||
const char *window_id;
|
||||
if (!test_case_parse_window_id (test, argv[1], &client, &window_id, error))
|
||||
return FALSE;
|
||||
|
||||
MetaWindow *window = test_client_find_window (client, window_id, error);
|
||||
if (!window)
|
||||
return FALSE;
|
||||
|
||||
MetaRectangle frame_rect;
|
||||
meta_window_get_frame_rect (window, &frame_rect);
|
||||
int x = atoi (argv[2]);
|
||||
int y = atoi (argv[3]);
|
||||
if (frame_rect.x != x || frame_rect.y != y)
|
||||
{
|
||||
g_set_error (error,
|
||||
TEST_RUNNER_ERROR,
|
||||
TEST_RUNNER_ERROR_ASSERTION_FAILED,
|
||||
"Expected window position (%d, %d) doesn't match (%d, %d)",
|
||||
x, y, frame_rect.x, frame_rect.y);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BAD_COMMAND("Unknown command %s", argv[0]);
|
||||
|
Reference in New Issue
Block a user