Description: fix crashes on Wayland Author: Moray Allan Last-Update: 2020-06-16 Index: matchbox-desktop-2.2+20200512/libtaku/xutil.c =================================================================== --- matchbox-desktop-2.2+20200512.orig/libtaku/xutil.c 2020-06-16 12:50:16.440963940 +0100 +++ matchbox-desktop-2.2+20200512/libtaku/xutil.c 2020-06-16 14:43:08.686751525 +0100 @@ -29,11 +29,15 @@ static void net_workarea_changed (WorkAreaFunc cb, GdkWindow *window) { + if (!GDK_IS_X11_DISPLAY (gdk_display_get_default())) + return; + Atom real_type; int result, xres, real_format; unsigned long items_read, items_left; long *coords; - Atom workarea_atom = gdk_x11_get_xatom_by_name ("_NET_WORKAREA"); + const gchar atom_name[] = "_NET_WORKAREA"; + Atom workarea_atom = gdk_x11_get_xatom_by_name (atom_name); gdk_error_trap_push (); result = XGetWindowProperty (gdk_x11_get_default_xdisplay (), GDK_ROOT_WINDOW (), @@ -84,7 +88,8 @@ gdk_window_set_events (root, gdk_window_get_events (root) | GDK_PROPERTY_CHANGE_MASK); - gdk_window_add_filter (root, workarea_property_filter, cb); + if (!GDK_IS_X11_DISPLAY (gdk_display_get_default())) + gdk_window_add_filter (root, workarea_property_filter, cb); net_workarea_changed (cb, root); } @@ -95,6 +100,9 @@ /* Note that this doesn't work if the WM doesn't support _NET_ACTIVE_WINDOW. However, that is pretty much given really. */ + if (!GDK_IS_X11_DISPLAY (gdk_display_get_default())) + return; + Atom atom_net_active = gdk_x11_get_xatom_by_name ("_NET_ACTIVE_WINDOW"); XClientMessageEvent ev; @@ -119,6 +127,9 @@ Window mb_single_instance_get_window (const char *bin_name) { + if (!GDK_IS_X11_DISPLAY (gdk_display_get_default())) + return None; + Atom atom_exec_map = gdk_x11_get_xatom_by_name ("_MB_CLIENT_EXEC_MAP"); Atom type; @@ -180,6 +191,9 @@ gboolean mb_single_instance_is_starting (const char *bin_name) { + if (!GDK_IS_X11_DISPLAY (gdk_display_get_default())) + return FALSE; + Atom atom_exec_map = gdk_x11_get_xatom_by_name ("_MB_CLIENT_STARTUP_LIST"); Atom type; Index: matchbox-desktop-2.2+20200512/src/main.c =================================================================== --- matchbox-desktop-2.2+20200512.orig/src/main.c 2020-06-15 16:44:36.000000000 +0100 +++ matchbox-desktop-2.2+20200512/src/main.c 2020-06-16 14:34:44.547118887 +0100 @@ -8,6 +8,7 @@ #include #include #include +#include #include "desktop.h" @@ -78,6 +79,11 @@ }; DesktopMode mode = MODE_DESKTOP; + if (1) { + Display *display; + display = gdk_display_get_default (); + } + g_set_application_name (_("Desktop")); option_context = g_option_context_new (NULL); Index: matchbox-desktop-2.2+20200512/libtaku/launcher-util.c =================================================================== --- matchbox-desktop-2.2+20200512.orig/libtaku/launcher-util.c 2020-06-15 16:44:36.000000000 +0100 +++ matchbox-desktop-2.2+20200512/libtaku/launcher-util.c 2020-06-16 14:50:40.718481207 +0100 @@ -237,7 +237,7 @@ SnDisplay *sn_dpy; Display *display; int screen; - + display = gdk_x11_display_get_xdisplay (gtk_widget_get_display (widget)); sn_dpy = sn_display_new (display, NULL, NULL); Index: matchbox-desktop-2.2+20200512/libtaku/taku-menu-desktop.c =================================================================== --- matchbox-desktop-2.2+20200512.orig/libtaku/taku-menu-desktop.c 2020-06-15 16:44:36.000000000 +0100 +++ matchbox-desktop-2.2+20200512/libtaku/taku-menu-desktop.c 2020-06-16 14:56:27.883804971 +0100 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "taku-menu.h" @@ -366,7 +367,11 @@ item->name = get_desktop_string (key_file, "Name"); item->description = get_desktop_string (key_file, "Comment"); item->icon_name = get_desktop_string (key_file, "Icon"); - item->use_sn = get_desktop_boolean (key_file, "StartupNotify", FALSE); + + if (GDK_IS_X11_DISPLAY (gdk_display_get_default())) + item->use_sn = get_desktop_boolean (key_file, "StartupNotify", FALSE); + else + item->use_sn = FALSE; item->single_instance = get_desktop_boolean (key_file, "X-MB-SingleInstance", FALSE) || get_desktop_boolean (key_file,