mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
tests: Add "set_parent_exported" command
Add a "set_parent_exported" command to test the xdg-foreign support, so that we can add a test which uses the GDK API for exported window: `gdk_wayland_window_set_transient_for_exported()` That will allow to detect if transient is applied correctly between foreign windows and detect possible crashes such as issue !174. Related: https://gitlab.gnome.org/GNOME/mutter/issues/174
This commit is contained in:
parent
fa9e330f2c
commit
3d5784342d
@ -20,6 +20,7 @@
|
||||
#include <gio/gunixinputstream.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#include <gdk/gdkwayland.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -31,6 +32,19 @@ GHashTable *windows;
|
||||
|
||||
static void read_next_line (GDataInputStream *in);
|
||||
|
||||
static void
|
||||
window_export_handle_cb (GdkWindow *window,
|
||||
const char *handle_str,
|
||||
gpointer user_data)
|
||||
{
|
||||
GdkWindow *gdk_window = gtk_widget_get_window (GTK_WIDGET (user_data));
|
||||
|
||||
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);
|
||||
gdk_window_set_modal_hint (gdk_window, TRUE);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
lookup_window (const char *window_id)
|
||||
{
|
||||
@ -151,6 +165,35 @@ process_line (const char *line)
|
||||
gtk_window_set_transient_for (GTK_WINDOW (window),
|
||||
GTK_WINDOW (parent_window));
|
||||
}
|
||||
else if (strcmp (argv[0], "set_parent_exported") == 0)
|
||||
{
|
||||
if (argc != 3)
|
||||
{
|
||||
g_print ("usage: set_parent_exported <window-id> <parent-id>");
|
||||
goto out;
|
||||
}
|
||||
|
||||
GtkWidget *window = lookup_window (argv[1]);
|
||||
if (!window)
|
||||
{
|
||||
g_print ("unknown window %s", argv[1]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
GtkWidget *parent_window = lookup_window (argv[2]);
|
||||
if (!parent_window)
|
||||
{
|
||||
g_print ("unknown parent window %s", argv[2]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
GdkWindow *parent_gdk_window = gtk_widget_get_window (parent_window);
|
||||
if (!gdk_wayland_window_export_handle (parent_gdk_window,
|
||||
window_export_handle_cb,
|
||||
window,
|
||||
NULL))
|
||||
g_print ("Fail to export handle for window id %s", argv[2]);
|
||||
}
|
||||
else if (strcmp (argv[0], "show") == 0)
|
||||
{
|
||||
if (argc != 2)
|
||||
|
@ -423,7 +423,8 @@ test_case_do (TestCase *test,
|
||||
NULL))
|
||||
return FALSE;
|
||||
}
|
||||
else if (strcmp (argv[0], "set_parent") == 0)
|
||||
else if (strcmp (argv[0], "set_parent") == 0 ||
|
||||
strcmp (argv[0], "set_parent_exported") == 0)
|
||||
{
|
||||
if (argc != 3)
|
||||
BAD_COMMAND("usage: %s <client-id>/<window-id> <parent-window-id>",
|
||||
@ -435,7 +436,7 @@ test_case_do (TestCase *test,
|
||||
return FALSE;
|
||||
|
||||
if (!test_client_do (client, error,
|
||||
"set_parent", window_id,
|
||||
argv[0], window_id,
|
||||
argv[2],
|
||||
NULL))
|
||||
return FALSE;
|
||||
|
Loading…
Reference in New Issue
Block a user