From b81ab124f594add4f14b7730257c5d7b2caa48e0 Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Fri, 11 Oct 2024 10:14:50 -0400 Subject: [PATCH] Guard against gdkx11 calls in a Wayland session. Fixes #3468 --- eel/eel-gtk-extensions.c | 5 +++++ src/nemo-main-application.c | 8 ++++++-- src/nemo-view.c | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c index 643a51726..9e3fa470b 100644 --- a/eel/eel-gtk-extensions.c +++ b/eel/eel-gtk-extensions.c @@ -375,6 +375,11 @@ eel_gtk_get_window_xid (GtkWindow *window) { g_return_val_if_fail (GTK_IS_WINDOW (window), 0); + if (eel_check_is_wayland ()) { + g_debug ("eel_gtk_get_window_xid: called on Wayland, returning 0"); + return 0; + } + GdkWindow *gdkw = gtk_widget_get_window (GTK_WIDGET (window)); g_return_val_if_fail (GDK_IS_X11_WINDOW (gdkw), 0); diff --git a/src/nemo-main-application.c b/src/nemo-main-application.c index 676bd9d0d..b0f42581a 100644 --- a/src/nemo-main-application.c +++ b/src/nemo-main-application.c @@ -445,8 +445,12 @@ open_tabs_in_existing_window (NemoMainApplication *application, /* Don't use `gtk_window_present()`, as the window manager will ignore this window's focus request and try * to just mark it urgent instead (flashing in the window list for example). */ - gtk_window_present_with_time (GTK_WINDOW (window), - gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (window)))); + if (eel_check_is_wayland ()) { + gtk_window_present (GTK_WINDOW (window)); + } else { + gtk_window_present_with_time (GTK_WINDOW (window), + gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (window)))); + } break; } diff --git a/src/nemo-view.c b/src/nemo-view.c index 988f67e4e..940f71ed7 100644 --- a/src/nemo-view.c +++ b/src/nemo-view.c @@ -1205,7 +1205,8 @@ nemo_view_preview_files (NemoView *view, uri = nemo_file_get_uri (files->data); toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view)); - xid = gdk_x11_window_get_xid (gtk_widget_get_window (toplevel)); + xid = eel_gtk_get_window_xid (GTK_WINDOW (toplevel)); + nemo_previewer_call_show_file (previewer, uri, xid, TRUE); g_free (uri);