From 1192002dd454bfa546d0f1373de4b3f59a4bb170 Mon Sep 17 00:00:00 2001 From: lukefromdc Date: Wed, 3 Apr 2024 23:03:25 -0400 Subject: Background thumbnail under wayland: only use gdk_x11 when in x11 *Avoid segfault on thumbnailing backgrounds under wayland by only using gdk_x11_screen_get_xscreen () when running under Xorg *Use gdk_monitor_get_geometry to get screen dimensions when running under wayland --- libmate-desktop/mate-bg.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/libmate-desktop/mate-bg.c b/libmate-desktop/mate-bg.c index 2c44b9e..8587dd4 100644 --- a/libmate-desktop/mate-bg.c +++ b/libmate-desktop/mate-bg.c @@ -2135,9 +2135,27 @@ scale_thumbnail (MateBGPlacement placement, if (get_thumb_annotations (thumb, &o_width, &o_height) || (filename && get_original_size (filename, &o_width, &o_height))) { + GdkDisplay *display; + int scr_height; + int scr_width; - int scr_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)); - int scr_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)); + display = gdk_screen_get_display (screen); + + /*Since we can use this in wayland, only use x11 specific code when in x11*/ + if (GDK_IS_X11_DISPLAY (gdk_screen_get_display (screen))) + { + scr_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)); + scr_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)); + } + else + { + GdkRectangle geometry = {0}; + GdkMonitor *monitor; + monitor = gdk_display_get_monitor (display, 0); + gdk_monitor_get_geometry (monitor, &geometry); + scr_height = geometry.width; + scr_width = geometry.height; + } int thumb_width = gdk_pixbuf_get_width (thumb); int thumb_height = gdk_pixbuf_get_height (thumb); double screen_to_dest = fit_factor (scr_width, scr_height, -- cgit v1.2.1