summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2021-04-08 13:02:28 -0700
committerAaron Plattner <aplattner@nvidia.com>2021-04-14 18:03:35 -0700
commitcf8efb58274d9a81ec00a5ec547e23a44557cc5b (patch)
tree5e12566bd32ed426e64eef1d84682da14cacf3b2
parentaa498dc27a47a527558ff6b9ff99e21693399ecb (diff)
downloadmutter-cf8efb58274d9a81ec00a5ec547e23a44557cc5b.tar.gz
x11: Skip sending redundant CTM change requests
The X server generates a property change notification whenever it processes a property change request, even if the value of the property is not changing. This triggers libgdk to probe all display outputs, which can be slow depending on which display driver and hardware are in use. #0 0x00007f8e4d5e91a0 in XRRUpdateConfiguration () at /usr/lib/libXrandr.so.2 #1 0x00007f8e505208da in _gdk_x11_screen_size_changed (screen=0x5566e4b7e080, event=0x7ffe0e44bd60) at ../gdk/x11/gdkscreen-x11.c:1199 #2 0x00007f8e505066d1 in gdk_x11_display_translate_event (translator=0x5566e4b5b110, display=0x5566e4b5b110, event=0x7f8dec001b20, xevent=0x7ffe0e44bd60) at ../gdk/x11/gdkdisplay-x11.c:1201 #3 0x00007f8e505135a0 in _gdk_x11_event_translator_translate (translator=0x5566e4b5b110, display=0x5566e4b5b110, xevent=0x7ffe0e44bd60) at ../gdk/x11/gdkeventtranslator.c:51 #4 0x00007f8e50512c97 in gdk_event_source_translate_event (event_source=0x5566e4b764a0, xevent=0x7ffe0e44bd60) at ../gdk/x11/gdkeventsource.c:243 #5 0x00007f8e50512f57 in _gdk_x11_display_queue_events (display=0x5566e4b5b110) at ../gdk/x11/gdkeventsource.c:341 #6 0x00007f8e50497644 in gdk_display_get_event (display=0x5566e4b5b110) at ../gdk/gdkdisplay.c:442 #7 0x00007f8e5051301f in gdk_event_source_dispatch (source=0x5566e4b764a0, callback=0x0, user_data=0x0) at ../gdk/x11/gdkeventsource.c:363 #8 0x00007f8e516ecf9c in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0 #9 0x00007f8e51740a49 in () at /usr/lib/libglib-2.0.so.0 #10 0x00007f8e516ec503 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0 #11 0x00007f8e508ef5fd in meta_run_main_loop () at ../src/core/main.c:928 #12 0x00007f8e508ef60e in meta_run () at ../src/core/main.c:943 #13 0x00005566e450842a in () #14 0x00007f8e50649b25 in __libc_start_main () at /usr/lib/libc.so.6 When GNOME is animating a display fade when the night light feature is toggled on or off, it sends a lot of change requests for the CTM property in the process, which triggers a lot of display probes from gdk. In the case of the night light feature, the CTM itself is not actually changing, so these requests are redundant. Fix this by caching the CTM value in the MetaOutputXrandr and skipping the server requests if it's not being changed. Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3978 Signed-off-by: Aaron Plattner <aplattner@nvidia.com> Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1816>
-rw-r--r--src/backends/x11/meta-output-xrandr.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/src/backends/x11/meta-output-xrandr.c b/src/backends/x11/meta-output-xrandr.c
index 6fc070fcc..7265624f4 100644
--- a/src/backends/x11/meta-output-xrandr.c
+++ b/src/backends/x11/meta-output-xrandr.c
@@ -50,6 +50,9 @@
struct _MetaOutputXrandr
{
MetaOutput parent;
+
+ gboolean ctm_initialized;
+ MetaOutputCtm ctm;
};
G_DEFINE_TYPE (MetaOutputXrandr, meta_output_xrandr, META_TYPE_OUTPUT)
@@ -198,19 +201,41 @@ meta_output_xrandr_change_backlight (MetaOutputXrandr *output_xrandr,
meta_output_set_backlight (output, normalize_backlight (output, hw_value));
}
+static gboolean
+ctm_is_equal (const MetaOutputCtm *ctm1,
+ const MetaOutputCtm *ctm2)
+{
+ int i;
+
+ for (i = 0; i < 9; i++)
+ {
+ if (ctm1->matrix[i] != ctm2->matrix[i])
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void
meta_output_xrandr_set_ctm (MetaOutputXrandr *output_xrandr,
const MetaOutputCtm *ctm)
{
- MetaOutput *output = META_OUTPUT (output_xrandr);
- Display *xdisplay = xdisplay_from_output (output);
- Atom ctm_atom = XInternAtom (xdisplay, "CTM", False);
+ if (!output_xrandr->ctm_initialized ||
+ !ctm_is_equal (ctm, &output_xrandr->ctm))
+ {
+ MetaOutput *output = META_OUTPUT (output_xrandr);
+ Display *xdisplay = xdisplay_from_output (output);
+ Atom ctm_atom = XInternAtom (xdisplay, "CTM", False);
- xcb_randr_change_output_property (XGetXCBConnection (xdisplay),
- (XID) meta_output_get_id (output),
- ctm_atom, XCB_ATOM_INTEGER, 32,
- XCB_PROP_MODE_REPLACE,
- 18, &ctm->matrix);
+ xcb_randr_change_output_property (XGetXCBConnection (xdisplay),
+ (XID) meta_output_get_id (output),
+ ctm_atom, XCB_ATOM_INTEGER, 32,
+ XCB_PROP_MODE_REPLACE,
+ 18, &ctm->matrix);
+
+ output_xrandr->ctm = *ctm;
+ output_xrandr->ctm_initialized = TRUE;
+ }
}
static gboolean