summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2022-05-02 16:47:18 +0200
committerJonas Ådahl <jadahl@gmail.com>2022-05-02 16:49:23 +0200
commit9addb14a834777d754a53a560c8e3489ec1313f6 (patch)
tree113ef9bb4c8f313199057bd2d7ec439023b1eca7
parenta47f81804deb6f2d6dbfcac29b44f77ea17186f4 (diff)
downloadgtk+-9addb14a834777d754a53a560c8e3489ec1313f6.tar.gz
x11: Trap errors happening when getting output properties
This is to avoid getting X11 errors (thus aborting/exiting with a failure) during rapid hotplugs, which may happen during e.g. CI testing.
-rw-r--r--gdk/x11/gdkscreen-x11.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
index 81499ba106..c2b7480c48 100644
--- a/gdk/x11/gdkscreen-x11.c
+++ b/gdk/x11/gdkscreen-x11.c
@@ -594,19 +594,6 @@ init_randr15 (GdkScreen *screen, gboolean *changed)
XRRFreeCrtcInfo (crtc);
}
- monitor = find_monitor_by_output (x11_display, output);
- if (monitor)
- monitor->remove = FALSE;
- else
- {
- monitor = g_object_new (GDK_TYPE_X11_MONITOR,
- "display", display,
- NULL);
- monitor->output = output;
- monitor->add = TRUE;
- g_ptr_array_add (x11_display->monitors, monitor);
- }
-
/* Fetch minimal manufacturer information (PNP ID) from EDID */
{
#define EDID_LENGTH 128
@@ -619,6 +606,7 @@ init_randr15 (GdkScreen *screen, gboolean *changed)
edid_atom = XInternAtom (disp, RR_PROPERTY_RANDR_EDID, FALSE);
+ gdk_x11_display_error_trap_push (display);
XRRGetOutputProperty (disp, output,
edid_atom,
0,
@@ -631,6 +619,11 @@ init_randr15 (GdkScreen *screen, gboolean *changed)
&nbytes,
&bytes_left,
&prop);
+ if (gdk_x11_display_error_trap_pop (display))
+ {
+ XRRFreeOutputInfo (output_info);
+ continue;
+ }
// Check partial EDID header (whole header: 00 ff ff ff ff ff ff 00)
if (nbytes >= EDID_LENGTH && prop[0] == 0x00 && prop[1] == 0xff)
@@ -651,6 +644,19 @@ init_randr15 (GdkScreen *screen, gboolean *changed)
#undef EDID_LENGTH
}
+ monitor = find_monitor_by_output (x11_display, output);
+ if (monitor)
+ monitor->remove = FALSE;
+ else
+ {
+ monitor = g_object_new (GDK_TYPE_X11_MONITOR,
+ "display", display,
+ NULL);
+ monitor->output = output;
+ monitor->add = TRUE;
+ g_ptr_array_add (x11_display->monitors, monitor);
+ }
+
gdk_monitor_get_geometry (GDK_MONITOR (monitor), &geometry);
name = g_strndup (output_info->name, output_info->nameLen);