From f798912cbd6de3591e5d8a75b476e7bd6b2568be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Wed, 30 Jan 2019 20:41:11 +0100 Subject: [PATCH] window: Move can_ping to a function and implement in X11 https://gitlab.gnome.org/GNOME/mutter/merge_requests/421 --- src/core/display.c | 2 +- src/core/window-private.h | 5 +++-- src/core/window.c | 7 ++++++- src/wayland/meta-window-wayland.c | 8 +++++++- src/x11/window-props.c | 4 ++-- src/x11/window-x11-private.h | 1 + src/x11/window-x11.c | 22 ++++++++++++++++++++++ src/x11/window-x11.h | 2 ++ 8 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/core/display.c b/src/core/display.c index 74e732905..2329e706d 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -1992,7 +1992,7 @@ meta_display_ping_window (MetaWindow *window, return; } - if (!window->can_ping) + if (!meta_window_can_ping (window)) return; ping_data = g_new (MetaPingData, 1); diff --git a/src/core/window-private.h b/src/core/window-private.h index ffbbf2982..b9f1fcea3 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -326,8 +326,6 @@ struct _MetaWindow /* whether net_wm_icon_geometry has been set */ guint icon_geometry_set : 1; - /* These are the flags from WM_PROTOCOLS */ - guint can_ping : 1; /* Globally active / No input */ guint input : 1; @@ -570,6 +568,7 @@ struct _MetaWindowClass ClutterInputDevice *source); gboolean (*is_focusable) (MetaWindow *window); gboolean (*is_stackable) (MetaWindow *window); + gboolean (*can_ping) (MetaWindow *window); gboolean (*are_updates_frozen) (MetaWindow *window); }; @@ -665,6 +664,8 @@ void meta_window_set_focused_internal (MetaWindow *window, gboolean meta_window_is_focusable (MetaWindow *window); +gboolean meta_window_can_ping (MetaWindow *window); + void meta_window_current_workspace_changed (MetaWindow *window); void meta_window_show_menu (MetaWindow *window, diff --git a/src/core/window.c b/src/core/window.c index 963ab625b..5f5269b7c 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -1079,7 +1079,6 @@ _meta_window_shared_new (MetaDisplay *display, window->initial_timestamp_set = FALSE; window->net_wm_user_time_set = FALSE; window->user_time_window = None; - window->can_ping = FALSE; window->input = TRUE; window->calc_placement = FALSE; window->shaken_loose = FALSE; @@ -8536,6 +8535,12 @@ meta_window_is_focusable (MetaWindow *window) return META_WINDOW_GET_CLASS (window)->is_focusable (window); } +gboolean +meta_window_can_ping (MetaWindow *window) +{ + return META_WINDOW_GET_CLASS (window)->can_ping (window); +} + gboolean meta_window_is_stackable (MetaWindow *window) { diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c index c4a888dcb..c7c3785d8 100644 --- a/src/wayland/meta-window-wayland.c +++ b/src/wayland/meta-window-wayland.c @@ -591,6 +591,12 @@ meta_window_wayland_is_focusable (MetaWindow *window) return window->input; } +static gboolean +meta_window_wayland_can_ping (MetaWindow *window) +{ + return TRUE; +} + static gboolean meta_window_wayland_is_stackable (MetaWindow *window) { @@ -626,6 +632,7 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass) window_class->shortcuts_inhibited = meta_window_wayland_shortcuts_inhibited; window_class->is_focusable = meta_window_wayland_is_focusable; window_class->is_stackable = meta_window_wayland_is_stackable; + window_class->can_ping = meta_window_wayland_can_ping; window_class->are_updates_frozen = meta_window_wayland_are_updates_frozen; } @@ -665,7 +672,6 @@ meta_window_wayland_new (MetaDisplay *display, WithdrawnState, META_COMP_EFFECT_CREATE, &attrs); - window->can_ping = TRUE; meta_x11_error_trap_pop (display->x11_display); /* pop the XSync()-reducing trap */ diff --git a/src/x11/window-props.c b/src/x11/window-props.c index dd194d9ea..45fe6f600 100644 --- a/src/x11/window-props.c +++ b/src/x11/window-props.c @@ -1531,8 +1531,8 @@ reload_wm_protocols (MetaWindow *window, { int i; - window->can_ping = FALSE; meta_window_x11_set_wm_take_focus (window, FALSE); + meta_window_x11_set_wm_ping (window, FALSE); meta_window_x11_set_wm_delete_window (window, FALSE); if (value->type == META_PROP_VALUE_INVALID) @@ -1549,7 +1549,7 @@ reload_wm_protocols (MetaWindow *window, meta_window_x11_set_wm_delete_window (window, TRUE); else if (value->v.atom_list.atoms[i] == window->display->x11_display->atom__NET_WM_PING) - window->can_ping = TRUE; + meta_window_x11_set_wm_ping (window, TRUE); ++i; } diff --git a/src/x11/window-x11-private.h b/src/x11/window-x11-private.h index 7a4a7b8f0..c582118c7 100644 --- a/src/x11/window-x11-private.h +++ b/src/x11/window-x11-private.h @@ -48,6 +48,7 @@ struct _MetaWindowX11Private guint wm_state_skip_taskbar : 1; guint wm_state_skip_pager : 1; guint wm_take_focus : 1; + guint wm_ping : 1; guint wm_delete_window : 1; /* Weird "_NET_WM_STATE_MODAL" flag */ diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 02920a805..6f3675cbc 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -682,6 +682,27 @@ meta_window_x11_unmanage (MetaWindow *window) } } +void +meta_window_x11_set_wm_ping (MetaWindow *window, + gboolean ping) +{ + MetaWindowX11 *window_x11 = META_WINDOW_X11 (window); + MetaWindowX11Private *priv = + meta_window_x11_get_instance_private (window_x11); + + priv->wm_ping = ping; +} + +static gboolean +meta_window_x11_can_ping (MetaWindow *window) +{ + MetaWindowX11 *window_x11 = META_WINDOW_X11 (window); + MetaWindowX11Private *priv = + meta_window_x11_get_instance_private (window_x11); + + return priv->wm_ping; +} + static void meta_window_x11_ping (MetaWindow *window, guint32 serial) @@ -1710,6 +1731,7 @@ meta_window_x11_class_init (MetaWindowX11Class *klass) window_class->shortcuts_inhibited = meta_window_x11_shortcuts_inhibited; window_class->is_focusable = meta_window_x11_is_focusable; window_class->is_stackable = meta_window_x11_is_stackable; + window_class->can_ping = meta_window_x11_can_ping; window_class->are_updates_frozen = meta_window_x11_are_updates_frozen; } diff --git a/src/x11/window-x11.h b/src/x11/window-x11.h index 4a2b33184..f3f3f1de1 100644 --- a/src/x11/window-x11.h +++ b/src/x11/window-x11.h @@ -53,6 +53,8 @@ void meta_window_x11_set_net_wm_state (MetaWindow *window); void meta_window_x11_set_wm_state (MetaWindow *window); void meta_window_x11_set_wm_take_focus (MetaWindow *window, gboolean take_focus); +void meta_window_x11_set_wm_ping (MetaWindow *window, + gboolean ping); void meta_window_x11_set_wm_delete_window (MetaWindow *window, gboolean delete_window); void meta_window_x11_set_allowed_actions_hint (MetaWindow *window);