diff options
author | lukefromdc <[email protected]> | 2024-04-03 23:03:25 -0400 |
---|---|---|
committer | Luke from DC <[email protected]> | 2024-07-30 20:56:43 +0000 |
commit | 2704320a4451dbf28b0d687de9668b775743a121 (patch) | |
tree | 6b26d2a53ef87f831eed8837064945b810f52117 | |
parent | 95edc464496af666567a604378640155d6c33732 (diff) | |
download | mate-desktop-2704320a4451dbf28b0d687de9668b775743a121.tar.bz2 mate-desktop-2704320a4451dbf28b0d687de9668b775743a121.tar.xz |
*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
-rw-r--r-- | libmate-desktop/mate-bg.c | 22 |
1 files 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, |