diff --git a/0001-window-Add-adjust_fullscreen_monitor_rect-virtual-me.patch b/0001-window-Add-adjust_fullscreen_monitor_rect-virtual-me.patch new file mode 100644 index 0000000..dffb68f --- /dev/null +++ b/0001-window-Add-adjust_fullscreen_monitor_rect-virtual-me.patch @@ -0,0 +1,96 @@ +From fc3c5ee2c8bdcd01b1e87dbef429d49050d68527 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Thu, 22 Aug 2019 10:55:17 +0200 +Subject: [PATCH 1/2] window: Add adjust_fullscreen_monitor_rect virtual method + +Add an adjust_fullscreen_monitor_rect virtual method to MetaWindowClass +and call this from setup_constraint_info() if the window is fullscreen. + +This allows MetaWindowClass to adjust the monitor-rectangle used to size +the window when going fullscreen, which will be used in further commits +for a workaround related to fullscreen games under Xwayland. + +https://gitlab.gnome.org/GNOME/mutter/merge_requests/739 +--- + src/core/constraints.c | 12 +++++++----- + src/core/window-private.h | 5 +++++ + src/core/window.c | 10 ++++++++++ + 3 files changed, 22 insertions(+), 5 deletions(-) + +diff --git a/src/core/constraints.c b/src/core/constraints.c +index 117131b15..1b3676d20 100644 +--- a/src/core/constraints.c ++++ b/src/core/constraints.c +@@ -413,11 +413,7 @@ setup_constraint_info (ConstraintInfo *info, + logical_monitor, + &info->work_area_monitor); + +- if (!window->fullscreen || !meta_window_has_fullscreen_monitors (window)) +- { +- info->entire_monitor = logical_monitor->rect; +- } +- else ++ if (window->fullscreen && meta_window_has_fullscreen_monitors (window)) + { + info->entire_monitor = window->fullscreen_monitors.top->rect; + meta_rectangle_union (&info->entire_monitor, +@@ -430,6 +426,12 @@ setup_constraint_info (ConstraintInfo *info, + &window->fullscreen_monitors.right->rect, + &info->entire_monitor); + } ++ else ++ { ++ info->entire_monitor = logical_monitor->rect; ++ if (window->fullscreen) ++ meta_window_adjust_fullscreen_monitor_rect (window, &info->entire_monitor); ++ } + + cur_workspace = window->display->workspace_manager->active_workspace; + info->usable_screen_region = +diff --git a/src/core/window-private.h b/src/core/window-private.h +index dd89fdc90..09a3aaadd 100644 +--- a/src/core/window-private.h ++++ b/src/core/window-private.h +@@ -578,6 +578,8 @@ struct _MetaWindowClass + MetaWindowUpdateMonitorFlags flags); + void (*main_monitor_changed) (MetaWindow *window, + const MetaLogicalMonitor *old); ++ void (*adjust_fullscreen_monitor_rect) (MetaWindow *window, ++ MetaRectangle *monitor_rect); + void (*force_restore_shortcuts) (MetaWindow *window, + ClutterInputDevice *source); + gboolean (*shortcuts_inhibited) (MetaWindow *window, +@@ -649,6 +651,9 @@ void meta_window_update_fullscreen_monitors (MetaWindow *window, + + gboolean meta_window_has_fullscreen_monitors (MetaWindow *window); + ++void meta_window_adjust_fullscreen_monitor_rect (MetaWindow *window, ++ MetaRectangle *monitor_rect); ++ + void meta_window_resize_frame_with_gravity (MetaWindow *window, + gboolean user_op, + int w, +diff --git a/src/core/window.c b/src/core/window.c +index e276b1e59..a6680e04a 100644 +--- a/src/core/window.c ++++ b/src/core/window.c +@@ -3625,6 +3625,16 @@ meta_window_has_fullscreen_monitors (MetaWindow *window) + return window->fullscreen_monitors.top != NULL; + } + ++void ++meta_window_adjust_fullscreen_monitor_rect (MetaWindow *window, ++ MetaRectangle *monitor_rect) ++{ ++ MetaWindowClass *window_class = META_WINDOW_GET_CLASS (window); ++ ++ if (window_class->adjust_fullscreen_monitor_rect) ++ window_class->adjust_fullscreen_monitor_rect (window, monitor_rect); ++} ++ + void + meta_window_shade (MetaWindow *window, + guint32 timestamp) +-- +2.23.0 + diff --git a/0002-window-xwayland-Add-Xwayland-fullscreen-games-workar.patch b/0002-window-xwayland-Add-Xwayland-fullscreen-games-workar.patch new file mode 100644 index 0000000..0bf0f8a --- /dev/null +++ b/0002-window-xwayland-Add-Xwayland-fullscreen-games-workar.patch @@ -0,0 +1,176 @@ +From 7d2dd5dee5873fd817c010e73535701e1d647b27 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Tue, 3 Sep 2019 16:18:00 +0200 +Subject: [PATCH 2/2] window-xwayland: Add Xwayland fullscreen games workaround + +This is a workaround for X11 games which use randr to change the resolution +in combination with NET_WM_STATE_FULLSCREEN when going fullscreen. + +Newer versions of Xwayland support the randr part of this by supporting randr +resolution change emulation in combination with using WPviewport to scale the +app's window (at the emulated resolution) to fill the entire monitor. + +Apps using randr in combination with NET_WM_STATE_FULLSCREEN expect the +fullscreen window to have the size of the emulated randr resolution since +when running on regular Xorg the resolution will actually be changed and +after that going fullscreen through NET_WM_STATE_FULLSCREEN will size +the window to be equal to the new resolution. + +We need to emulate this behavior for these games to work correctly. + +Xwayland's emulated resolution is a per X11 client setting and Xwayland +will set a special _XWAYLAND_RANDR_EMU_MONITOR_RECTS property on the +toplevel windows of a client (and only those of that client), which has +changed the (emulated) resolution through a randr call. + +This commit checks for that property and if it is set adjusts the fullscreen +monitor rect for this window to match the emulated resolution. + +Here is a step-by-step of such an app going fullscreen: +1. App changes monitor resolution with randr. +2. Xwayland sets the _XWAYLAND_RANDR_EMU_MONITOR_RECTS property on all the + apps current and future windows. This property contains the origin of the + monitor for which the emulated resolution is set and the emulated + resolution. +3. App sets _NET_WM_FULLSCREEN. +4. We check the property and adjust the app's fullscreen size to match + the emulated resolution. +5. Xwayland sees a Window at monitor origin fully covering the emulated + monitor resolution. Xwayland sets a viewport making the emulated + resolution sized window cover the full actual monitor resolution. + +https://gitlab.gnome.org/GNOME/mutter/merge_requests/739 +--- + src/wayland/meta-window-xwayland.c | 89 ++++++++++++++++++++++++++++++ + src/x11/atomnames.h | 1 + + 2 files changed, 90 insertions(+) + +diff --git a/src/wayland/meta-window-xwayland.c b/src/wayland/meta-window-xwayland.c +index 6f073893a..9967f439a 100644 +--- a/src/wayland/meta-window-xwayland.c ++++ b/src/wayland/meta-window-xwayland.c +@@ -20,6 +20,7 @@ + + #include "x11/window-x11.h" + #include "x11/window-x11-private.h" ++#include "x11/xprops.h" + #include "wayland/meta-window-xwayland.h" + #include "wayland/meta-wayland.h" + +@@ -53,6 +54,93 @@ meta_window_xwayland_init (MetaWindowXwayland *window_xwayland) + { + } + ++/** ++ * meta_window_xwayland_adjust_fullscreen_monitor_rect: ++ * ++ * This function implements a workaround for X11 apps which use randr to change the ++ * the monitor resolution, followed by setting _NET_WM_FULLSCREEN to make the ++ * window-manager fullscreen them. ++ * ++ * Newer versions of Xwayland support the randr part of this by supporting randr ++ * resolution change emulation in combination with using WPviewport to scale the ++ * app's window (at the emulated resolution) to fill the entire monitor. ++ * ++ * Apps using randr in combination with NET_WM_STATE_FULLSCREEN expect the ++ * fullscreen window to have the size of the emulated randr resolution since ++ * when running on regular Xorg the resolution will actually be changed and ++ * after that going fullscreen through NET_WM_STATE_FULLSCREEN will size ++ * the window to be equal to the new resolution. ++ * ++ * We need to emulate this behavior for these apps to work correctly. ++ * ++ * Xwayland's emulated resolution is a per X11 client setting and Xwayland ++ * will set a special _XWAYLAND_RANDR_EMU_MONITOR_RECTS property on the ++ * toplevel windows of a client (and only those of that client), which has ++ * changed the (emulated) resolution through a randr call. ++ * ++ * Here we check for that property and if it is set we adjust the fullscreen ++ * monitor rect for this window to match the emulated resolution. ++ * ++ * Here is a step-by-step of such an app going fullscreen: ++ * 1. App changes monitor resolution with randr. ++ * 2. Xwayland sets the _XWAYLAND_RANDR_EMU_MONITOR_RECTS property on all the ++ * apps current and future windows. This property contains the origin of the ++ * monitor for which the emulated resolution is set and the emulated ++ * resolution. ++ * 3. App sets _NET_WM_FULLSCREEN. ++ * 4. We check the property and adjust the app's fullscreen size to match ++ * the emulated resolution. ++ * 5. Xwayland sees a Window at monitor origin fully covering the emulated ++ * monitor resolution. Xwayland sets a viewport making the emulated ++ * resolution sized window cover the full actual monitor resolution. ++ */ ++static void ++meta_window_xwayland_adjust_fullscreen_monitor_rect (MetaWindow *window, ++ MetaRectangle *fs_monitor_rect) ++{ ++ MetaX11Display *x11_display = window->display->x11_display; ++ MetaRectangle win_monitor_rect; ++ cairo_rectangle_int_t *rects; ++ uint32_t *list = NULL; ++ int i, n_items = 0; ++ ++ if (!window->monitor) ++ { ++ g_warning ("MetaWindow does not have a monitor"); ++ return; ++ } ++ ++ win_monitor_rect = meta_logical_monitor_get_layout (window->monitor); ++ ++ if (!meta_prop_get_cardinal_list (x11_display, ++ window->xwindow, ++ x11_display->atom__XWAYLAND_RANDR_EMU_MONITOR_RECTS, ++ &list, &n_items)) ++ return; ++ ++ if (n_items % 4) ++ { ++ meta_verbose ("_XWAYLAND_RANDR_EMU_MONITOR_RECTS on %s has %d values which is not a multiple of 4", ++ window->desc, n_items); ++ g_free (list); ++ return; ++ } ++ ++ rects = (cairo_rectangle_int_t *) list; ++ n_items = n_items / 4; ++ for (i = 0; i < n_items; i++) ++ { ++ if (rects[i].x == win_monitor_rect.x && rects[i].y == win_monitor_rect.y) ++ { ++ fs_monitor_rect->width = rects[i].width; ++ fs_monitor_rect->height = rects[i].height; ++ break; ++ } ++ } ++ ++ g_free (list); ++} ++ + static void + meta_window_xwayland_force_restore_shortcuts (MetaWindow *window, + ClutterInputDevice *source) +@@ -115,6 +203,7 @@ meta_window_xwayland_class_init (MetaWindowXwaylandClass *klass) + MetaWindowClass *window_class = META_WINDOW_CLASS (klass); + GObjectClass *gobject_class = G_OBJECT_CLASS (klass); + ++ window_class->adjust_fullscreen_monitor_rect = meta_window_xwayland_adjust_fullscreen_monitor_rect; + window_class->force_restore_shortcuts = meta_window_xwayland_force_restore_shortcuts; + window_class->shortcuts_inhibited = meta_window_xwayland_shortcuts_inhibited; + +diff --git a/src/x11/atomnames.h b/src/x11/atomnames.h +index b61f47ff4..4099d5d31 100644 +--- a/src/x11/atomnames.h ++++ b/src/x11/atomnames.h +@@ -81,6 +81,7 @@ item(ATOM_PAIR) + item(_XKB_RULES_NAMES) + item(WL_SURFACE_ID) + item(_XWAYLAND_MAY_GRAB_KEYBOARD) ++item(_XWAYLAND_RANDR_EMU_MONITOR_RECTS) + + /* Oddities: These are used, and we need atoms for them, + * but when we need all _NET_WM hints (i.e. when we're making +-- +2.23.0 + diff --git a/mutter.spec b/mutter.spec index c0e6c72..da01e32 100644 --- a/mutter.spec +++ b/mutter.spec @@ -8,7 +8,7 @@ Name: mutter Version: 3.34.1 -Release: 5%{?dist} +Release: 6%{?dist} Summary: Window and compositing manager based on Clutter License: GPLv2+ @@ -51,6 +51,11 @@ Patch12: 0001-x11-Translate-well-known-selection-atoms-to-mimetype.patch # https://gitlab.gnome.org/GNOME/mutter/issues/854 # https://bugzilla.redhat.com/show_bug.cgi?id=1758873#c28 Patch13: 0001-x11-Map-mimetypes-back-to-selection-atoms.patch +# https://gitlab.gnome.org/GNOME/mutter/merge_requests/739 +# Complements the backported Xwayland randr resolution change emulation support +# necessary for SDL2 apps to work correctly +Patch14: 0001-window-Add-adjust_fullscreen_monitor_rect-virtual-me.patch +Patch15: 0002-window-xwayland-Add-Xwayland-fullscreen-games-workar.patch BuildRequires: chrpath BuildRequires: pango-devel @@ -195,6 +200,10 @@ desktop-file-validate %{buildroot}/%{_datadir}/applications/%{name}.desktop %{_datadir}/mutter-%{mutter_api_version}/tests %changelog +* Mon Nov 4 2019 Hans de Goede - 3.34.1-6 +- Backport 2 patches which complement the backported Xwayland randr + resolution change emulation support (necessary for SDL2 apps) + * Tue Oct 29 2019 Florian Müllner - 3.34.1-5 - Enable sysprof support The required dependency was missing from rawhide when the feature