1
0
Fork 0

window: Move keys_grabbed to WindowX11

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3584>
This commit is contained in:
Bilal Elmoussaoui 2024-02-14 14:25:38 +01:00 committed by Marge Bot
parent b6802e1f00
commit de2a24b313
5 changed files with 21 additions and 9 deletions

View file

@ -46,7 +46,7 @@
#include "meta/prefs.h"
#include "mtk/mtk-x11.h"
#include "x11/meta-x11-display-private.h"
#include "x11/window-x11.h"
#include "x11/window-x11-private.h"
#ifdef HAVE_NATIVE_BACKEND
#include "backends/native/meta-backend-native.h"
@ -1601,20 +1601,22 @@ meta_window_grab_keys (MetaWindow *window)
{
MetaDisplay *display = window->display;
MetaKeyBindingManager *keys = &display->key_binding_manager;
MetaWindowX11Private *priv;
if (meta_is_wayland_compositor ())
return;
priv = meta_window_x11_get_private (META_WINDOW_X11 (window));
if (window->type == META_WINDOW_DOCK
|| window->override_redirect)
{
if (window->keys_grabbed)
if (priv->keys_grabbed)
change_window_keygrabs (keys, meta_window_x11_get_xwindow (window), FALSE);
window->keys_grabbed = FALSE;
priv->keys_grabbed = FALSE;
return;
}
if (window->keys_grabbed)
if (priv->keys_grabbed)
{
if (window->frame && !window->grab_on_frame)
change_window_keygrabs (keys, meta_window_x11_get_xwindow (window), FALSE);
@ -1629,14 +1631,21 @@ meta_window_grab_keys (MetaWindow *window)
meta_window_x11_get_toplevel_xwindow (window),
TRUE);
window->keys_grabbed = TRUE;
priv->keys_grabbed = TRUE;
window->grab_on_frame = window->frame != NULL;
}
void
meta_window_ungrab_keys (MetaWindow *window)
{
if (!meta_is_wayland_compositor () && window->keys_grabbed)
MetaWindowX11Private *priv;
if (meta_is_wayland_compositor ())
return;
priv = meta_window_x11_get_private (META_WINDOW_X11 (window));
if (priv->keys_grabbed)
{
MetaDisplay *display = window->display;
MetaKeyBindingManager *keys = &display->key_binding_manager;
@ -1647,7 +1656,7 @@ meta_window_ungrab_keys (MetaWindow *window)
else if (!window->grab_on_frame)
change_window_keygrabs (keys, meta_window_x11_get_xwindow (window), FALSE);
window->keys_grabbed = FALSE;
priv->keys_grabbed = FALSE;
}
}

View file

@ -507,7 +507,6 @@ struct _MetaWindow
guint constructing : 1;
/* Used by keybindings.c */
guint keys_grabbed : 1; /* normal keybindings grabbed */
guint grab_on_frame : 1; /* grabs are on the frame */
/* Set if the reason for unmanaging the window is that

View file

@ -1059,7 +1059,6 @@ meta_window_constructed (GObject *object)
window->placed = ((window->mapped && !window->hidden) || window->override_redirect);
window->denied_focus_and_not_transient = FALSE;
window->unmanaging = FALSE;
window->keys_grabbed = FALSE;
window->grab_on_frame = FALSE;
window->withdrawn = FALSE;
window->initial_workspace_set = FALSE;

View file

@ -91,6 +91,9 @@ struct _MetaWindowX11Private
MetaGroup *group;
MetaSyncCounter sync_counter;
/* Used by keybindings.c */
gboolean keys_grabbed; /* normal keybindings grabbed */
};
MetaWindowX11Private * meta_window_x11_get_private (MetaWindowX11 *window_x11);

View file

@ -2087,6 +2087,8 @@ meta_window_x11_constructed (GObject *object)
priv->border_width = attrs.border_width;
priv->xclient_leader = None;
priv->keys_grabbed = FALSE;
g_signal_connect (window, "notify::decorated",
G_CALLBACK (meta_window_x11_update_input_region),
window);