From 5688856331109e77d7362f5665fb178d1c269a39 Mon Sep 17 00:00:00 2001 From: lukefromdc Date: Wed, 17 May 2023 23:00:54 -0400 Subject: Initial wayland support --- src/caja-application.c | 48 +++++++++++++++++++++++++++--------------------- src/caja-main.c | 2 -- src/caja-window.c | 6 ++---- 3 files changed, 29 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/caja-application.c b/src/caja-application.c index 5f7a8ac4..1467e421 100644 --- a/src/caja-application.c +++ b/src/caja-application.c @@ -634,38 +634,44 @@ selection_get_cb (GtkWidget *widget, static GtkWidget * get_desktop_manager_selection (GdkDisplay *display) { - char selection_name[32]; - GdkAtom selection_atom; - Window selection_owner; - GtkWidget *selection_widget; - - g_snprintf (selection_name, sizeof (selection_name), "_NET_DESKTOP_MANAGER_S0"); - selection_atom = gdk_atom_intern (selection_name, FALSE); - - selection_owner = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), + /*FIXME: for Wayland we need a new desktop canvas anyway + *so when that is ready we will need to add a wayland code + *path here to support it + */ + if (GDK_IS_X11_DISPLAY (display)){ + char selection_name[32]; + GdkAtom selection_atom; + Window selection_owner; + GtkWidget *selection_widget; + + g_snprintf (selection_name, sizeof (selection_name), "_NET_DESKTOP_MANAGER_S0"); + selection_atom = gdk_atom_intern (selection_name, FALSE); + + selection_owner = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display), gdk_x11_atom_to_xatom_for_display (display, selection_atom)); - if (selection_owner != None) - { + if (selection_owner != None) + { return NULL; - } + } - selection_widget = gtk_invisible_new_for_screen (gdk_display_get_default_screen (display)); - /* We need this for gdk_x11_get_server_time() */ - gtk_widget_add_events (selection_widget, GDK_PROPERTY_CHANGE_MASK); + selection_widget = gtk_invisible_new_for_screen (gdk_display_get_default_screen (display)); + /* We need this for gdk_x11_get_server_time() */ + gtk_widget_add_events (selection_widget, GDK_PROPERTY_CHANGE_MASK); - if (gtk_selection_owner_set_for_display (display, + if (gtk_selection_owner_set_for_display (display, selection_widget, selection_atom, gdk_x11_get_server_time (gtk_widget_get_window (selection_widget)))) - { + { - g_signal_connect (selection_widget, "selection_get", + g_signal_connect (selection_widget, "selection_get", G_CALLBACK (selection_get_cb), NULL); - return selection_widget; - } + return selection_widget; + } - gtk_widget_destroy (selection_widget); + gtk_widget_destroy (selection_widget); + } return NULL; } diff --git a/src/caja-main.c b/src/caja-main.c index 75ccbdf5..11871257 100644 --- a/src/caja-main.c +++ b/src/caja-main.c @@ -250,8 +250,6 @@ main (int argc, char *argv[]) g_set_prgname ("caja"); - gdk_set_allowed_backends ("x11"); - if (g_file_test (DATADIR "/applications/caja.desktop", G_FILE_TEST_EXISTS)) { egg_set_desktop_file (DATADIR "/applications/caja.desktop"); } diff --git a/src/caja-window.c b/src/caja-window.c index 2417e07c..a67a5ee4 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -591,8 +591,7 @@ caja_window_zoom_to_default (CajaWindow *window) static guint get_max_forced_height (GdkScreen *screen) { - gint scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen)); - return (HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale * 90) / 100; + return (gdk_screen_get_height (screen) * 90) / 100; } /* Code should never force the window wider than this size. @@ -601,8 +600,7 @@ get_max_forced_height (GdkScreen *screen) static guint get_max_forced_width (GdkScreen *screen) { - gint scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen)); - return (WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale * 90) / 100; + return (gdk_screen_get_width (screen) * 90) / 100; } /* This must be called when construction of CajaWindow is finished, -- cgit v1.2.1