Skip to content

Commit

Permalink
feat: Add Mutter with Xwayland fractional scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleGospo committed Apr 19, 2024
1 parent 266ab57 commit fe079bb
Show file tree
Hide file tree
Showing 7 changed files with 2,691 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
From 1d5c47f8970c2027de5f6fa49b84de73d55b419b Mon Sep 17 00:00:00 2001
From: Adam Williamson <[email protected]>
Date: Thu, 5 Oct 2023 13:09:46 -0700
Subject: [PATCH] Revert "x11: Use input region from frame window for decorated
windows"

This reverts commit d991961ae2a5c8cf2e58ff1072239f4902b0f767. It
seems to cause the broken mouse interaction bug reported in
https://bugzilla.redhat.com/show_bug.cgi?id=2239128 .

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3068
---
src/core/frame.c | 7 -------
src/x11/window-x11.c | 29 ++++++++++-------------------
2 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/src/core/frame.c b/src/core/frame.c
index 145f0b7bd7..1c90ce4231 100644
--- a/src/core/frame.c
+++ b/src/core/frame.c
@@ -35,7 +35,6 @@
#include "x11/window-props.h"

#include <X11/Xatom.h>
-#include <X11/extensions/shape.h>

#define EVENT_MASK (SubstructureRedirectMask | \
StructureNotifyMask | SubstructureNotifyMask | \
@@ -109,9 +108,6 @@ meta_window_x11_set_frame_xwindow (MetaWindow *window,
XChangeWindowAttributes (x11_display->xdisplay,
frame->xwindow, CWEventMask, &attrs);

- if (META_X11_DISPLAY_HAS_SHAPE (x11_display))
- XShapeSelectInput (x11_display->xdisplay, frame->xwindow, ShapeNotifyMask);
-
meta_x11_display_register_x_window (x11_display, &frame->xwindow, window);

if (window->mapped)
@@ -220,9 +216,6 @@ meta_window_destroy_frame (MetaWindow *window)
window->reparents_pending += 1;
}

- if (META_X11_DISPLAY_HAS_SHAPE (x11_display))
- XShapeSelectInput (x11_display->xdisplay, frame->xwindow, NoEventMask);
-
XDeleteProperty (x11_display->xdisplay,
meta_window_x11_get_xwindow (window),
x11_display->atom__MUTTER_NEEDS_FRAME);
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index 745c45db18..8edff883c9 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -2082,10 +2082,6 @@ meta_window_x11_constructed (GObject *object)
priv->keys_grabbed = FALSE;
priv->grab_on_frame = FALSE;

- g_signal_connect (window, "notify::decorated",
- G_CALLBACK (meta_window_x11_update_input_region),
- window);
-
G_OBJECT_CLASS (meta_window_x11_parent_class)->constructed (object);
}

@@ -2400,21 +2396,16 @@ meta_window_x11_update_input_region (MetaWindow *window)
g_autoptr (MtkRegion) region = NULL;
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
- Window xwindow;

+ /* Decorated windows don't have an input region, because
+ we don't shape the frame to match the client windows
+ (so the events are blocked by the frame anyway)
+ */
if (window->decorated)
{
- if (!window->frame)
- {
- if (priv->input_region)
- meta_window_set_input_region (window, NULL);
- return;
- }
- xwindow = window->frame->xwindow;
- }
- else
- {
- xwindow = priv->xwindow;
+ if (priv->input_region)
+ meta_window_set_input_region (window, NULL);
+ return;
}

if (META_X11_DISPLAY_HAS_SHAPE (x11_display))
@@ -2426,7 +2417,7 @@ meta_window_x11_update_input_region (MetaWindow *window)

mtk_x11_error_trap_push (x11_display->xdisplay);
rects = XShapeGetRectangles (x11_display->xdisplay,
- xwindow,
+ priv->xwindow,
ShapeInput,
&n_rects,
&ordering);
@@ -2480,8 +2471,8 @@ meta_window_x11_update_input_region (MetaWindow *window)

client_area.x = 0;
client_area.y = 0;
- client_area.width = window->buffer_rect.width;
- client_area.height = window->buffer_rect.height;
+ client_area.width = priv->client_rect.width;
+ client_area.height = priv->client_rect.height;

/* The shape we get back from the client may have coordinates
* outside of the frame. The X SHAPE Extension requires that
--
2.43.2

145 changes: 145 additions & 0 deletions staging/mutter/0001-modified-3329.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
From e20ebeefa42997fe65008b11ef771c71b697273c Mon Sep 17 00:00:00 2001
From: Adam Williamson <[email protected]>
Date: Fri, 20 Oct 2023 22:12:23 -0700
Subject: [PATCH] modified 3329

Signed-off-by: Adam Williamson <[email protected]>
---
src/compositor/meta-compositor-x11.c | 2 ++
src/core/display.c | 34 ----------------------------
src/tests/x11-test.sh | 3 +++
src/x11/meta-x11-display.c | 30 +++++++++++++++++++++++-
4 files changed, 34 insertions(+), 35 deletions(-)

diff --git a/src/compositor/meta-compositor-x11.c b/src/compositor/meta-compositor-x11.c
index 1ad3327dd..ce7bc1945 100644
--- a/src/compositor/meta-compositor-x11.c
+++ b/src/compositor/meta-compositor-x11.c
@@ -188,6 +188,8 @@ meta_compositor_x11_manage (MetaCompositor *compositor,

compositor_x11->have_x11_sync_object = meta_sync_ring_init (xdisplay);

+ meta_x11_display_redirect_windows (x11_display, display);
+
return TRUE;
}

diff --git a/src/core/display.c b/src/core/display.c
index 0a191c0fb..b16e50e21 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -930,9 +930,6 @@ meta_display_new (MetaContext *context,
MetaDisplay *display;
MetaDisplayPrivate *priv;
guint32 timestamp;
-#ifdef HAVE_X11_CLIENT
- Window old_active_xwindow = None;
-#endif
MetaMonitorManager *monitor_manager;
MetaSettings *settings;
MetaInputCapture *input_capture;
@@ -1048,14 +1045,6 @@ meta_display_new (MetaContext *context,
display->last_focus_time = timestamp;
display->last_user_time = timestamp;

-#ifdef HAVE_X11
- if (!meta_is_wayland_compositor ())
- meta_prop_get_window (display->x11_display,
- display->x11_display->xroot,
- display->x11_display->atom__NET_ACTIVE_WINDOW,
- &old_active_xwindow);
-#endif
-
if (!meta_compositor_manage (display->compositor, error))
{
g_object_unref (display);
@@ -1076,30 +1065,7 @@ meta_display_new (MetaContext *context,
g_signal_connect (display->gesture_tracker, "state-changed",
G_CALLBACK (gesture_tracker_state_changed), display);

- /* We know that if mutter is running as a Wayland compositor,
- * we start out with no windows.
- */
-#ifdef HAVE_X11_CLIENT
- if (!meta_is_wayland_compositor ())
- meta_display_manage_all_xwindows (display);
-
- if (old_active_xwindow != None)
- {
- MetaWindow *old_active_window;
- old_active_window = meta_x11_display_lookup_x_window (display->x11_display,
- old_active_xwindow);
- if (old_active_window)
- meta_window_focus (old_active_window, timestamp);
- else
- meta_display_unset_input_focus (display, timestamp);
- }
- else
- {
- meta_display_unset_input_focus (display, timestamp);
- }
-#else
meta_display_unset_input_focus (display, timestamp);
-#endif

g_signal_connect (stage, "notify::is-grabbed",
G_CALLBACK (on_is_grabbed_changed), display);
diff --git a/src/tests/x11-test.sh b/src/tests/x11-test.sh
index 59e460fc3..d95b2460f 100755
--- a/src/tests/x11-test.sh
+++ b/src/tests/x11-test.sh
@@ -34,6 +34,9 @@ echo \# Launched with pid $MUTTER2_PID
MUTTER2_PID=$!
wait $MUTTER1_PID

+echo \# Waiting for the second mutter to finish loading
+gdbus wait --session org.gnome.Mutter.IdleMonitor
+
sleep 2

echo \# Terminating clients > /dev/stderr
diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c
index 4e98203dd..4ca620410 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -300,8 +300,36 @@ static void
on_x11_display_opened (MetaX11Display *x11_display,
MetaDisplay *display)
{
+ Window old_active_xwindow = None;
+
+ if (!meta_is_wayland_compositor ())
+ {
+ meta_prop_get_window (display->x11_display,
+ display->x11_display->xroot,
+ display->x11_display->atom__NET_ACTIVE_WINDOW,
+ &old_active_xwindow);
+ }
+
+ if (meta_is_wayland_compositor ())
+ meta_x11_display_redirect_windows (x11_display, display);
+
+
meta_display_manage_all_xwindows (display);
- meta_x11_display_redirect_windows (x11_display, display);
+
+ if (old_active_xwindow != None)
+ {
+ MetaWindow *old_active_window;
+
+ old_active_window = meta_x11_display_lookup_x_window (x11_display,
+ old_active_xwindow);
+ if (old_active_window)
+ {
+ uint32_t timestamp;
+
+ timestamp = display->x11_display->timestamp;
+ meta_window_focus (old_active_window, timestamp);
+ }
+ }
}

static void
--
2.41.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 692546a9701a7b363e6190af441a95385c244907 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <[email protected]>
Date: Fri, 2 Dec 2022 22:49:41 +0100
Subject: [PATCH] place: Always center initial-setup/fedora-welcome

---
src/core/place.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/src/core/place.c b/src/core/place.c
index f9877dfc7..a69a3ebd1 100644
--- a/src/core/place.c
+++ b/src/core/place.c
@@ -321,6 +321,11 @@ window_place_centered (MetaWindow *window)

type = window->type;

+ if (g_strcmp0 (meta_window_get_wm_class (window), "org.gnome.InitialSetup") == 0 ||
+ g_strcmp0 (meta_window_get_wm_class (window), "org.fedoraproject.welcome-screen") == 0 ||
+ g_strcmp0 (meta_window_get_wm_class (window), "fedora-welcome") == 0)
+ return TRUE;
+
return (type == META_WINDOW_DIALOG ||
type == META_WINDOW_MODAL_DIALOG ||
type == META_WINDOW_SPLASHSCREEN ||
--
2.39.2

Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
From b3b5aa01c63aee1df079e0394b0e6372df1838d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <[email protected]>
Date: Fri, 12 May 2017 13:40:31 +0200
Subject: [PATCH] window-actor: Special-case shaped Java windows

OpenJDK wrongly assumes that shaping a window implies no shadows.
They got lucky until commit b975676c changed the fallback case,
but now their compliance tests are broken. Make them happy again
by special-casing shaped Java windows.
---
src/compositor/meta-window-actor-x11.c | 8 ++++++++
src/x11/window-x11-private.h | 2 ++
src/x11/window-x11.c | 9 +++++++++
3 files changed, 19 insertions(+)

diff --git a/src/compositor/meta-window-actor-x11.c b/src/compositor/meta-window-actor-x11.c
index 19827af331..7d5e46ac75 100644
--- a/src/compositor/meta-window-actor-x11.c
+++ b/src/compositor/meta-window-actor-x11.c
@@ -424,6 +424,14 @@ has_shadow (MetaWindowActorX11 *actor_x11)
*/
if (window->has_custom_frame_extents)
return FALSE;
+
+ /*
+ * OpenJDK wrongly assumes that shaping a window implies no compositor
+ * shadows; make its compliance tests happy to give it what it wants ...
+ */
+ if (g_strcmp0 (window->res_name, "sun-awt-X11-XWindowPeer") == 0 &&
+ meta_window_x11_is_shaped (window))
+ return FALSE;

/*
* Generate shadows for all other windows.
diff --git a/src/x11/window-x11-private.h b/src/x11/window-x11-private.h
index c947744ee5..cb862f0d72 100644
--- a/src/x11/window-x11-private.h
+++ b/src/x11/window-x11-private.h
@@ -125,6 +125,8 @@ gboolean meta_window_x11_has_pointer (MetaWindow *window);
gboolean meta_window_x11_same_application (MetaWindow *window,
MetaWindow *other_window);

+gboolean meta_window_x11_is_shaped (MetaWindow *window);
+
void meta_window_x11_shutdown_group (MetaWindow *window);

META_EXPORT
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index 745c45db18..83cdd2e420 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -2585,6 +2585,15 @@ meta_window_x11_update_shape_region (MetaWindow *window)
meta_window_set_shape_region (window, region);
}

+gboolean
+meta_window_x11_is_shaped (MetaWindow *window)
+{
+ MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
+ MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
+
+ return priv->shape_region != NULL;
+}
+
/* Generally meta_window_x11_same_application() is a better idea
* of "sameness", since it handles the case where multiple apps
* want to look like the same app or the same app wants to look
--
2.43.2

Loading

0 comments on commit fe079bb

Please sign in to comment.