flatpak/shared-modules/libcanberra/0001-gtk-Don-t-assume-all-GdkDisplays-are-GdkX11Displays-.patch
2024-03-07 20:28:57 -03:00

123 lines
5 KiB
Diff

From d6dd5cdf45c1aac6c0519c8a4f5f89321770fb53 Mon Sep 17 00:00:00 2001
From: Michael Meeks <michael.meeks@suse.com>
Date: Fri, 9 Nov 2012 16:16:40 +0000
Subject: [PATCH] gtk: Don't assume all GdkDisplays are GdkX11Displays:
broadway/wayland
Co-Authored-By: Bastien Nocera <hadess@hadess.net>
---
src/canberra-gtk-module.c | 15 +++++++++++++++
src/canberra-gtk.c | 28 ++++++++++++++++++++++------
2 files changed, 37 insertions(+), 6 deletions(-)
diff --git a/src/canberra-gtk-module.c b/src/canberra-gtk-module.c
index 67791f0..c1532ab 100644
--- a/src/canberra-gtk-module.c
+++ b/src/canberra-gtk-module.c
@@ -307,6 +307,11 @@ static gint window_get_desktop(GdkDisplay *d, GdkWindow *w) {
guchar *data = NULL;
gint ret = -1;
+#ifdef GDK_IS_X11_DISPLAY
+ if (!GDK_IS_X11_DISPLAY(d))
+ return 0;
+#endif
+
if (XGetWindowProperty(GDK_DISPLAY_XDISPLAY(d), GDK_WINDOW_XID(w),
gdk_x11_get_xatom_by_name_for_display(d, "_NET_WM_DESKTOP"),
0, G_MAXLONG, False, XA_CARDINAL, &type_return,
@@ -335,6 +340,11 @@ static gint display_get_desktop(GdkDisplay *d) {
guchar *data = NULL;
gint ret = -1;
+#ifdef GDK_IS_X11_DISPLAY
+ if (!GDK_IS_X11_DISPLAY(d))
+ return 0;
+#endif
+
if (XGetWindowProperty(GDK_DISPLAY_XDISPLAY(d), DefaultRootWindow(GDK_DISPLAY_XDISPLAY(d)),
gdk_x11_get_xatom_by_name_for_display(d, "_NET_CURRENT_DESKTOP"),
0, G_MAXLONG, False, XA_CARDINAL, &type_return,
@@ -365,6 +375,11 @@ static gboolean window_is_xembed(GdkDisplay *d, GdkWindow *w) {
gboolean ret = FALSE;
Atom xembed;
+#ifdef GDK_IS_X11_DISPLAY
+ if (!GDK_IS_X11_DISPLAY(d))
+ return FALSE;
+#endif
+
/* Gnome Panel applets are XEMBED windows. We need to make sure we
* ignore them */
diff --git a/src/canberra-gtk.c b/src/canberra-gtk.c
index 34446f5..47285f8 100644
--- a/src/canberra-gtk.c
+++ b/src/canberra-gtk.c
@@ -185,6 +185,11 @@ static gint window_get_desktop(GdkDisplay *d, GdkWindow *w) {
guchar *data = NULL;
gint ret = -1;
+#ifdef GDK_IS_X11_DISPLAY
+ if (!GDK_IS_X11_DISPLAY(d))
+ return 0;
+#endif
+
if (XGetWindowProperty(GDK_DISPLAY_XDISPLAY(d), GDK_WINDOW_XID(w),
gdk_x11_get_xatom_by_name_for_display(d, "_NET_WM_DESKTOP"),
0, G_MAXLONG, False, XA_CARDINAL, &type_return,
@@ -254,18 +259,28 @@ int ca_gtk_proplist_set_for_widget(ca_proplist *p, GtkWidget *widget) {
if (gtk_widget_get_realized(GTK_WIDGET(w))) {
GdkWindow *dw = NULL;
+#ifdef GDK_IS_X11_DISPLAY
GdkScreen *screen = NULL;
+#endif
GdkDisplay *display = NULL;
gint x = -1, y = -1, width = -1, height = -1, screen_width = -1, screen_height = -1;
- if ((dw = gtk_widget_get_window(GTK_WIDGET(w))))
- if ((ret = ca_proplist_setf(p, CA_PROP_WINDOW_X11_XID, "%lu", (unsigned long) GDK_WINDOW_XID(dw))) < 0)
- return ret;
+ if ((dw = gtk_widget_get_window(GTK_WIDGET(w)))) {
+#ifdef GDK_IS_X11_DISPLAY
+ if (GDK_IS_X11_DISPLAY(display)) {
+ if ((ret = ca_proplist_setf(p, CA_PROP_WINDOW_X11_XID, "%lu", (unsigned long) GDK_WINDOW_XID(dw))) < 0)
+ return ret;
+ }
+#endif
+ }
if ((display = gtk_widget_get_display(GTK_WIDGET(w)))) {
- if ((t = gdk_display_get_name(display)))
+#ifdef GDK_IS_X11_DISPLAY
+ if (GDK_IS_X11_DISPLAY(display) && (t = gdk_display_get_name(display))) {
if ((ret = ca_proplist_sets(p, CA_PROP_WINDOW_X11_DISPLAY, t)) < 0)
return ret;
+ }
+#endif
if (dw) {
gint desktop = window_get_desktop(display, dw);
@@ -276,7 +291,8 @@ int ca_gtk_proplist_set_for_widget(ca_proplist *p, GtkWidget *widget) {
}
}
- if ((screen = gtk_widget_get_screen(GTK_WIDGET(w)))) {
+#ifdef GDK_IS_X11_DISPLAY
+ if (GDK_IS_X11_DISPLAY(display) && (screen = gtk_widget_get_screen(GTK_WIDGET(w)))) {
if ((ret = ca_proplist_setf(p, CA_PROP_WINDOW_X11_SCREEN, "%i", gdk_screen_get_number(screen))) < 0)
return ret;
@@ -285,7 +301,7 @@ int ca_gtk_proplist_set_for_widget(ca_proplist *p, GtkWidget *widget) {
if ((ret = ca_proplist_setf(p, CA_PROP_WINDOW_X11_MONITOR, "%i", gdk_screen_get_monitor_at_window(screen, dw))) < 0)
return ret;
}
-
+#endif
/* FIXME, this might cause a round trip */
if (dw) {
--
2.34.1