projects/guix·blob python-team · refs

78 lines · 2.9 KiB

1From 02baab07033f9db4c1d44e0df8379587ecec2e74 Mon Sep 17 00:00:00 2001
2From: Oliver Deja <[email protected]>
3Date: Mon, 30 Mar 2026 17:37:10 +0000
4Subject: [PATCH] x11: displays: Add hotplug event handling
5
6When handling the RRScreenChangeNotify event, auto resize if the
7preferred mode was selected and updated.
8
9Fixes: #142
10---
11 xfsettingsd/displays-x11.c | 51 ++++++++++++++++++++++++++++++++++++++
12 1 file changed, 51 insertions(+)
13
14diff --git a/xfsettingsd/displays-x11.c b/xfsettingsd/displays-x11.c
15index f96ce6a5..696b17f2 100644
16--- a/xfsettingsd/displays-x11.c
17+++ b/xfsettingsd/displays-x11.c
18@@ -616,6 +616,57 @@ screen_on_event (gpointer data)
19 xfconf_channel_set_string (channel, ACTIVE_PROFILE, DEFAULT_SCHEME_NAME);
20 }
21
22+ /* hotplup event handling: see https://gitlab.xfce.org/xfce/xfce4-settings/-/issues/142 */
23+ if (old_outputs->len == helper->outputs->len
24+ && helper->resources->timestamp < helper->resources->configTimestamp
25+ && edids_changed)
26+ {
27+ gboolean changed = FALSE;
28+
29+ for (guint n = 0; n < helper->outputs->len; ++n)
30+ {
31+ XfceRROutput *output = g_ptr_array_index (helper->outputs, n);
32+ XfceRROutput *old_output = g_ptr_array_index (old_outputs, n);
33+ XfceRRCrtc *crtc = xfce_displays_helper_x11_find_crtc_by_id (helper, output->info->crtc);
34+
35+ if (output->id != old_output->id)
36+ {
37+ xfsettings_dbg (XFSD_DEBUG_DISPLAYS, "Output identifiers or order changed, aborting.");
38+ break;
39+ }
40+
41+ if (crtc == NULL)
42+ continue;
43+
44+ /* if the new output has a new preferred mode and the crtc was configured in the previours preferred
45+ mode, reconfigure to use the new preferred mode */
46+ if (old_output->preferred_mode != output->preferred_mode && old_output->preferred_mode == crtc->mode)
47+ {
48+ for (gint m = 0; m < helper->resources->nmode; ++m)
49+ {
50+ if (output->preferred_mode == helper->resources->modes[m].id)
51+ {
52+ crtc->mode = helper->resources->modes[m].id;
53+ crtc->width = helper->resources->modes[m].width;
54+ crtc->height = helper->resources->modes[m].height;
55+ crtc->changed = TRUE;
56+ xfce_displays_helper_x11_set_outputs (crtc, output);
57+
58+ changed |= output->active;
59+ break;
60+ }
61+ }
62+ }
63+ }
64+
65+ if (changed)
66+ {
67+ xfce_displays_helper_x11_apply_all (helper);
68+ g_ptr_array_unref (old_outputs);
69+ return FALSE;
70+ }
71+ }
72+
73 if (old_outputs->len > helper->outputs->len || edids_changed)
74 {
75 gboolean changed = FALSE;
76--
77GitLab
78