From 751ef5abd2db67faab3e1fae85f4cbff07075c94 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Tue, 21 May 2024 23:40:39 +0200 Subject: [PATCH] window/x11: Add a is_ssd helper Would be useful for moving frame field to WindowX11 in the upcoming commits Part-of: --- src/core/constraints.c | 21 ++++++++++++++++++--- src/core/window.c | 8 ++++++-- src/x11/events.c | 2 +- src/x11/window-x11-private.h | 3 +++ src/x11/window-x11.c | 13 ++++++++++--- 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/src/core/constraints.c b/src/core/constraints.c index cbd7bc4d9..eb68a3cd9 100644 --- a/src/core/constraints.c +++ b/src/core/constraints.c @@ -91,7 +91,7 @@ constrain_whatever (MetaWindow *window, // we know we can return TRUE here because we exited early // if the constraint could not be satisfied; not that the // return value is heeded in this case... - return TRUE; + return TRUE; } ``` */ @@ -709,9 +709,14 @@ update_onscreen_requirements (MetaWindow *window, /* Update whether we want future constraint runs to require the * titlebar to be visible. */ - if (window->frame && window->decorated) +#ifdef HAVE_X11_CLIENT + if (window->client_type == META_WINDOW_CLIENT_TYPE_X11 && window->decorated) { MtkRectangle titlebar_rect, frame_rect; + MetaFrame *frame = meta_window_x11_get_frame (window); + + if (!frame) + return; meta_window_get_titlebar_rect (window, &titlebar_rect); meta_window_get_frame_rect (window, &frame_rect); @@ -730,6 +735,7 @@ update_onscreen_requirements (MetaWindow *window, window->desc, window->require_titlebar_visible ? "TRUE" : "FALSE"); } +#endif } static inline void @@ -1703,12 +1709,21 @@ constrain_to_single_monitor (MetaWindow *window, ConstraintPriority priority, gboolean check_only) { + /* a quirk for x11 clients that tries to move their windows + * by themselves when doing interactive moves. + */ + gboolean client_driven_interactive_move = TRUE; MetaMonitorManager *monitor_manager = meta_backend_get_monitor_manager (info->backend); if (priority > PRIORITY_ENTIRELY_VISIBLE_ON_SINGLE_MONITOR) return TRUE; +#ifdef HAVE_X11_CLIENT + if (window->client_type == META_WINDOW_CLIENT_TYPE_X11) + client_driven_interactive_move = meta_window_x11_get_frame (window) == NULL; +#endif + /* Exit early if we know the constraint won't apply--note that this constraint * is only meant for normal windows (e.g. we don't want docks to be shoved * "onscreen" by their own strut) and we can't apply it to frameless windows @@ -1718,7 +1733,7 @@ constrain_to_single_monitor (MetaWindow *window, window->type == META_WINDOW_DOCK || meta_monitor_manager_get_num_logical_monitors (monitor_manager) == 1 || !window->require_on_single_monitor || - !window->frame || + client_driven_interactive_move || info->is_user_action || meta_window_get_placement_rule (window)) return TRUE; diff --git a/src/core/window.c b/src/core/window.c index 363abb94c..0b3ea4e94 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -808,9 +808,11 @@ client_window_should_be_mapped (MetaWindow *window) } #endif +#ifdef HAVE_X11_CLIENT if (window->client_type == META_WINDOW_CLIENT_TYPE_X11 && - window->decorated && !window->frame) + window->decorated && !meta_window_x11_is_ssd (window)) return FALSE; +#endif return TRUE; } @@ -1701,9 +1703,11 @@ meta_window_is_showable (MetaWindow *window) return FALSE; #endif +#ifdef HAVE_X11_CLIENT if (window->client_type == META_WINDOW_CLIENT_TYPE_X11 && - window->decorated && !window->frame) + window->decorated && !meta_window_x11_is_ssd (window)) return FALSE; +#endif return TRUE; } diff --git a/src/x11/events.c b/src/x11/events.c index 2191230b8..cde691f99 100644 --- a/src/x11/events.c +++ b/src/x11/events.c @@ -1483,7 +1483,7 @@ handle_other_xevent (MetaX11Display *x11_display, window = meta_x11_display_lookup_x_window (x11_display, client_window); - if (window != NULL && window->decorated && !window->frame) + if (window != NULL && window->decorated && !meta_window_x11_is_ssd (window)) { meta_window_x11_set_frame_xwindow (window, event->xmaprequest.window); diff --git a/src/x11/window-x11-private.h b/src/x11/window-x11-private.h index 96bc05618..1c8f0f7c0 100644 --- a/src/x11/window-x11-private.h +++ b/src/x11/window-x11-private.h @@ -133,4 +133,7 @@ void meta_window_x11_group_leader_changed (MetaWindow *window); void meta_window_x11_set_frame_xwindow (MetaWindow *window, Window xframe); + +gboolean meta_window_x11_is_ssd (MetaWindow *window); + G_END_DECLS diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index f826cbb66..936678ebf 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -2035,6 +2035,13 @@ meta_window_x11_set_transient_for (MetaWindow *window, return TRUE; } +gboolean +meta_window_x11_is_ssd (MetaWindow *window) +{ + /* Will be updated in the next commits once frame field is moved to WindowX11 */ + return window->frame != NULL; +} + static void meta_window_x11_constructed (GObject *object) { @@ -2404,7 +2411,7 @@ meta_window_x11_update_input_region (MetaWindow *window) if (window->decorated) { - if (!window->frame) + if (!meta_window_x11_is_ssd (window)) { if (priv->input_region) meta_window_set_input_region (window, NULL); @@ -2689,7 +2696,7 @@ meta_window_move_resize_request (MetaWindow *window, window->type); } - if (window->decorated && !window->frame) + if (window->decorated && !meta_window_x11_is_ssd (window)) { width = new_width; height = new_height; @@ -3921,7 +3928,7 @@ meta_window_x11_new (MetaDisplay *display, "effect", effect, "attributes", &attrs, "xwindow", xwindow, - NULL); + NULL); } else #endif