2023-08-21 09:10:59 +02:00
|
|
|
Index: mutter-44.3/src/core/display.c
|
2021-10-22 11:27:36 +02:00
|
|
|
===================================================================
|
2023-08-21 09:10:59 +02:00
|
|
|
--- mutter-44.3.orig/src/core/display.c
|
|
|
|
+++ mutter-44.3/src/core/display.c
|
|
|
|
@@ -880,6 +880,8 @@ meta_display_new (MetaContext *context,
|
2021-04-23 11:50:01 +02:00
|
|
|
display->check_fullscreen_later = 0;
|
|
|
|
display->work_area_later = 0;
|
2016-08-26 14:00:22 +02:00
|
|
|
|
|
|
|
+ display->server_grab_count = 0;
|
2021-04-23 11:50:01 +02:00
|
|
|
+
|
2016-08-26 14:00:22 +02:00
|
|
|
display->mouse_mode = TRUE; /* Only relevant for mouse or sloppy focus */
|
|
|
|
display->allow_terminal_deactivation = TRUE; /* Only relevant for when a
|
2021-04-23 11:50:01 +02:00
|
|
|
terminal has the focus */
|
2023-08-21 09:10:59 +02:00
|
|
|
@@ -1208,6 +1210,50 @@ meta_grab_op_is_moving (MetaGrabOp op)
|
|
|
|
return !meta_grab_op_is_resizing (op);
|
2016-08-26 14:00:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
+/* Grab/ungrab routines taken from fvwm.
|
|
|
|
+ * Calling this function will cause X to ignore all other clients until
|
|
|
|
+ * you ungrab. This may not be quite as bad as it sounds, yet there is
|
|
|
|
+ * agreement that avoiding server grabs except when they are clearly needed
|
|
|
|
+ * is a good thing.
|
|
|
|
+ *
|
|
|
|
+ * If you do use such grabs, please clearly explain the necessity for their
|
|
|
|
+ * usage in a comment. Try to keep their scope extremely limited. In
|
|
|
|
+ * particular, try to avoid emitting any signals or notifications while
|
|
|
|
+ * a grab is active (if the signal receiver tries to block on an X request
|
|
|
|
+ * from another client at this point, you will have a deadlock).
|
|
|
|
+ */
|
|
|
|
+void
|
|
|
|
+meta_display_grab (MetaDisplay *display)
|
|
|
|
+{
|
|
|
|
+ if (display->server_grab_count == 0)
|
|
|
|
+ {
|
2021-04-23 11:50:01 +02:00
|
|
|
+ XGrabServer (display->x11_display->xdisplay);
|
2016-08-26 14:00:22 +02:00
|
|
|
+ }
|
|
|
|
+ display->server_grab_count += 1;
|
|
|
|
+ meta_verbose ("Grabbing display, grab count now %d\n",
|
|
|
|
+ display->server_grab_count);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void
|
|
|
|
+meta_display_ungrab (MetaDisplay *display)
|
|
|
|
+{
|
|
|
|
+ if (display->server_grab_count == 0)
|
|
|
|
+ meta_bug ("Ungrabbed non-grabbed server\n");
|
|
|
|
+
|
|
|
|
+ display->server_grab_count -= 1;
|
|
|
|
+ if (display->server_grab_count == 0)
|
|
|
|
+ {
|
|
|
|
+ /* FIXME we want to purge all pending "queued" stuff
|
|
|
|
+ * at this point, such as window hide/show
|
|
|
|
+ */
|
2021-04-23 11:50:01 +02:00
|
|
|
+ XUngrabServer (display->x11_display->xdisplay);
|
|
|
|
+ XFlush (display->x11_display->xdisplay);
|
2016-08-26 14:00:22 +02:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ meta_verbose ("Ungrabbing display, grab count now %d\n",
|
|
|
|
+ display->server_grab_count);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/**
|
2023-08-21 09:10:59 +02:00
|
|
|
* meta_display_windows_are_interactable:
|
|
|
|
* @op: A #MetaGrabOp
|
|
|
|
Index: mutter-44.3/src/core/display-private.h
|
2021-10-22 11:27:36 +02:00
|
|
|
===================================================================
|
2023-08-21 09:10:59 +02:00
|
|
|
--- mutter-44.3.orig/src/core/display-private.h
|
|
|
|
+++ mutter-44.3/src/core/display-private.h
|
|
|
|
@@ -105,6 +105,8 @@ struct _MetaDisplay
|
2021-04-23 11:50:01 +02:00
|
|
|
GHashTable *stamps;
|
|
|
|
GHashTable *wayland_windows;
|
2016-08-26 14:00:22 +02:00
|
|
|
|
2021-04-23 11:50:01 +02:00
|
|
|
+ int server_grab_count;
|
|
|
|
+
|
2023-08-21 09:10:59 +02:00
|
|
|
guint32 current_time;
|
|
|
|
|
|
|
|
/* We maintain a sequence counter, incremented for each #MetaWindow
|
|
|
|
@@ -189,6 +191,8 @@ struct _MetaDisplayClass
|
2016-08-26 14:00:22 +02:00
|
|
|
|
2021-10-22 11:27:36 +02:00
|
|
|
MetaDisplay * meta_display_new (MetaContext *context,
|
|
|
|
GError **error);
|
2021-04-23 11:50:01 +02:00
|
|
|
+void meta_display_grab (MetaDisplay *display);
|
|
|
|
+void meta_display_ungrab (MetaDisplay *display);
|
2016-08-26 14:00:22 +02:00
|
|
|
|
2021-04-23 11:50:01 +02:00
|
|
|
void meta_display_manage_all_xwindows (MetaDisplay *display);
|
|
|
|
void meta_display_unmanage_windows (MetaDisplay *display,
|
2023-08-21 09:10:59 +02:00
|
|
|
Index: mutter-44.3/src/core/keybindings.c
|
2021-10-22 11:27:36 +02:00
|
|
|
===================================================================
|
2023-08-21 09:10:59 +02:00
|
|
|
--- mutter-44.3.orig/src/core/keybindings.c
|
|
|
|
+++ mutter-44.3/src/core/keybindings.c
|
|
|
|
@@ -1257,6 +1257,9 @@ meta_display_grab_window_buttons (MetaDi
|
2016-08-26 14:00:22 +02:00
|
|
|
{
|
|
|
|
MetaKeyBindingManager *keys = &display->key_binding_manager;
|
|
|
|
|
|
|
|
+ if (display->server_grab_count > 0)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
/* Grab Alt + button1 for moving window.
|
|
|
|
* Grab Alt + button2 for resizing window.
|
|
|
|
* Grab Alt + button3 for popping up window menu.
|
2023-08-21 09:10:59 +02:00
|
|
|
@@ -1293,6 +1296,9 @@ meta_display_ungrab_window_buttons (Meta
|
2016-08-26 14:00:22 +02:00
|
|
|
{
|
|
|
|
MetaKeyBindingManager *keys = &display->key_binding_manager;
|
|
|
|
|
|
|
|
+ if (display->server_grab_count > 0)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
if (keys->window_grab_modifiers == 0)
|
|
|
|
return;
|
|
|
|
|
2023-08-21 09:10:59 +02:00
|
|
|
@@ -1323,6 +1329,9 @@ meta_display_grab_focus_window_button (M
|
2016-08-26 14:00:22 +02:00
|
|
|
{
|
|
|
|
MetaKeyBindingManager *keys = &display->key_binding_manager;
|
|
|
|
|
|
|
|
+ if (display->server_grab_count > 0)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
/* Grab button 1 for activating unfocused windows */
|
2021-04-23 11:50:01 +02:00
|
|
|
meta_verbose ("Grabbing unfocused window buttons for %s", window->desc);
|
2016-08-26 14:00:22 +02:00
|
|
|
|
2023-08-21 09:10:59 +02:00
|
|
|
@@ -1347,6 +1356,9 @@ meta_display_ungrab_focus_window_button
|
2016-08-26 14:00:22 +02:00
|
|
|
{
|
|
|
|
MetaKeyBindingManager *keys = &display->key_binding_manager;
|
|
|
|
|
|
|
|
+ if (display->server_grab_count > 0)
|
|
|
|
+ return;
|
|
|
|
+
|
2021-04-23 11:50:01 +02:00
|
|
|
meta_verbose ("Ungrabbing unfocused window buttons for %s", window->desc);
|
2016-08-26 14:00:22 +02:00
|
|
|
|
|
|
|
if (!window->have_focus_click_grab)
|
2023-08-21 09:10:59 +02:00
|
|
|
@@ -1601,6 +1613,9 @@ meta_window_grab_keys (MetaWindow *wind
|
2021-04-23 11:50:01 +02:00
|
|
|
if (meta_is_wayland_compositor ())
|
|
|
|
return;
|
2023-08-21 09:10:59 +02:00
|
|
|
|
2016-08-26 14:00:22 +02:00
|
|
|
+ if (display->server_grab_count > 0)
|
|
|
|
+ return;
|
2023-08-21 09:10:59 +02:00
|
|
|
+
|
|
|
|
if (window->type == META_WINDOW_DOCK
|
|
|
|
|| window->override_redirect)
|
|
|
|
{
|
|
|
|
@@ -1637,6 +1652,9 @@ meta_window_ungrab_keys (MetaWindow *wi
|
2016-08-26 14:00:22 +02:00
|
|
|
MetaDisplay *display = window->display;
|
|
|
|
MetaKeyBindingManager *keys = &display->key_binding_manager;
|
|
|
|
|
|
|
|
+ if (display->server_grab_count > 0)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
if (window->grab_on_frame &&
|
|
|
|
window->frame != NULL)
|
|
|
|
change_window_keygrabs (keys, window->frame->xwindow, FALSE);
|
2023-08-21 09:10:59 +02:00
|
|
|
Index: mutter-44.3/src/x11/meta-x11-display.c
|
2021-10-22 11:27:36 +02:00
|
|
|
===================================================================
|
2023-08-21 09:10:59 +02:00
|
|
|
--- mutter-44.3.orig/src/x11/meta-x11-display.c
|
|
|
|
+++ mutter-44.3/src/x11/meta-x11-display.c
|
|
|
|
@@ -2013,7 +2013,7 @@ meta_x11_display_set_input_focus_interna
|
2021-04-23 11:50:01 +02:00
|
|
|
* we know which is which by making two requests that the server will
|
|
|
|
* process at the same time.
|
|
|
|
*/
|
|
|
|
- XGrabServer (x11_display->xdisplay);
|
|
|
|
+ meta_display_grab(x11_display->display);
|
|
|
|
|
|
|
|
XSetInputFocus (x11_display->xdisplay,
|
|
|
|
xwindow,
|
2023-08-21 09:10:59 +02:00
|
|
|
@@ -2025,8 +2025,7 @@ meta_x11_display_set_input_focus_interna
|
2021-04-23 11:50:01 +02:00
|
|
|
x11_display->atom__MUTTER_FOCUS_SET,
|
|
|
|
XA_STRING, 8, PropModeAppend, NULL, 0);
|
|
|
|
|
|
|
|
- XUngrabServer (x11_display->xdisplay);
|
|
|
|
- XFlush (x11_display->xdisplay);
|
|
|
|
+ meta_display_ungrab(x11_display->display);
|
|
|
|
|
|
|
|
meta_x11_error_trap_pop (x11_display);
|
|
|
|
}
|
2023-08-21 09:10:59 +02:00
|
|
|
Index: mutter-44.3/src/x11/window-x11.c
|
2021-10-22 11:27:36 +02:00
|
|
|
===================================================================
|
2023-08-21 09:10:59 +02:00
|
|
|
--- mutter-44.3.orig/src/x11/window-x11.c
|
|
|
|
+++ mutter-44.3/src/x11/window-x11.c
|
|
|
|
@@ -548,6 +548,8 @@ meta_window_x11_manage (MetaWindow *wind
|
|
|
|
meta_sync_counter_init (&priv->sync_counter, window, window->xwindow);
|
2016-08-26 14:00:22 +02:00
|
|
|
meta_icon_cache_init (&priv->icon_cache);
|
|
|
|
|
|
|
|
+ meta_display_grab (display);
|
|
|
|
+
|
2021-04-23 11:50:01 +02:00
|
|
|
meta_x11_display_register_x_window (display->x11_display,
|
|
|
|
&window->xwindow,
|
|
|
|
window);
|
2023-08-21 09:10:59 +02:00
|
|
|
@@ -620,6 +622,13 @@ meta_window_x11_initialize_state (MetaWi
|
2016-08-26 14:00:22 +02:00
|
|
|
|
|
|
|
meta_window_x11_update_shape_region (window);
|
|
|
|
meta_window_x11_update_input_region (window);
|
|
|
|
+
|
|
|
|
+ meta_display_ungrab (display);
|
|
|
|
+
|
|
|
|
+ /* Perform operations prevented by grab */
|
|
|
|
+ if (window->frame)
|
|
|
|
+ meta_display_grab_window_buttons (display, window->frame->xwindow);
|
|
|
|
+ meta_window_grab_keys (window);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|