summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormbkma <[email protected]>2020-04-02 15:29:23 +0200
committerraveit65 <[email protected]>2020-06-13 00:22:49 +0200
commit43ee3b27f218ab513a11a253b4b8161eeec9b0df (patch)
tree9a48e7e28715fa179b008f0d66bef79dbdde3d0e
parenta31a8facfba9693f7337631dfa305c64a5663e2e (diff)
downloadpluma-43ee3b27f218ab513a11a253b4b8161eeec9b0df.tar.bz2
pluma-43ee3b27f218ab513a11a253b4b8161eeec9b0df.tar.xz
add support for wayland
-rw-r--r--pluma/pluma-app.c13
-rw-r--r--pluma/pluma-utils.c230
-rw-r--r--pluma/pluma.c23
-rw-r--r--pluma/smclient/eggdesktopfile.c70
4 files changed, 184 insertions, 152 deletions
diff --git a/pluma/pluma-app.c b/pluma/pluma-app.c
index 82172a4f..1cffa77f 100644
--- a/pluma/pluma-app.c
+++ b/pluma/pluma-app.c
@@ -36,8 +36,8 @@
#include <unistd.h>
#include <glib/gi18n.h>
+#include <gdk/gdk.h>
#include <gdk/gdkx.h>
-
#include "pluma-app.h"
#include "pluma-prefs-manager-app.h"
#include "pluma-commands.h"
@@ -653,8 +653,15 @@ is_in_viewport (PlumaWindow *window,
x += vp_x;
y += vp_y;
- sc_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen));
- sc_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen));
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ {
+ sc_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen));
+ sc_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen));
+ }
+ else
+ {
+ return TRUE;
+ }
return x + width * .25 >= viewport_x &&
x + width * .75 <= viewport_x + sc_width &&
diff --git a/pluma/pluma-utils.c b/pluma/pluma-utils.c
index 5e4b7cfb..088a1786 100644
--- a/pluma/pluma-utils.c
+++ b/pluma/pluma-utils.c
@@ -52,12 +52,10 @@
#include "pluma-debug.h"
/* For the workspace/viewport stuff */
-#ifdef GDK_WINDOWING_X11
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
-#endif
#define STDIN_DELAY_MICROSECONDS 100000
@@ -846,42 +844,43 @@ pluma_utils_replace_home_dir_with_tilde (const gchar *uri)
guint
pluma_utils_get_current_workspace (GdkScreen *screen)
{
-#ifdef GDK_WINDOWING_X11
- GdkWindow *root_win;
- GdkDisplay *display;
- Atom type;
- gint format;
- gulong nitems;
- gulong bytes_after;
- guint *current_desktop;
- gint err, result;
- guint ret = 0;
-
- g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
-
- root_win = gdk_screen_get_root_window (screen);
- display = gdk_screen_get_display (screen);
-
- gdk_x11_display_error_trap_push (display);
- result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win),
- gdk_x11_get_xatom_by_name_for_display (display, "_NET_CURRENT_DESKTOP"),
- 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
- &bytes_after, (gpointer) &current_desktop);
- err = gdk_x11_display_error_trap_pop (display);
-
- if (err != Success || result != Success)
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ {
+ GdkWindow *root_win;
+ GdkDisplay *display;
+ Atom type;
+ gint format;
+ gulong nitems;
+ gulong bytes_after;
+ guint *current_desktop;
+ gint err, result;
+ guint ret = 0;
+
+ g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
+
+ root_win = gdk_screen_get_root_window (screen);
+ display = gdk_screen_get_display (screen);
+
+ gdk_x11_display_error_trap_push (display);
+ result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID(root_win),
+ gdk_x11_get_xatom_by_name_for_display (display, "_NET_CURRENT_DESKTOP"),
+ 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
+ &bytes_after, (gpointer) &current_desktop);
+ err = gdk_x11_display_error_trap_pop (display);
+
+ if (err != Success || result != Success)
+ return ret;
+
+ if (type == XA_CARDINAL && format == 32 && nitems > 0)
+ ret = current_desktop[0];
+
+ XFree (current_desktop);
return ret;
-
- if (type == XA_CARDINAL && format == 32 && nitems > 0)
- ret = current_desktop[0];
-
- XFree (current_desktop);
- return ret;
-#else
- /* FIXME: on mac etc proably there are native APIs
- * to get the current workspace etc */
- return 0;
-#endif
+ }
+ else
+ /* FIXME: on mac etc proably there are native APIs
+ * to get the current workspace etc */
+ return 0;
}
/**
@@ -896,43 +895,45 @@ pluma_utils_get_current_workspace (GdkScreen *screen)
guint
pluma_utils_get_window_workspace (GtkWindow *gtkwindow)
{
-#ifdef GDK_WINDOWING_X11
- GdkWindow *window;
- GdkDisplay *display;
- Atom type;
- gint format;
- gulong nitems;
- gulong bytes_after;
- guint *workspace;
- gint err, result;
- guint ret = PLUMA_ALL_WORKSPACES;
-
- g_return_val_if_fail (GTK_IS_WINDOW (gtkwindow), 0);
- g_return_val_if_fail (gtk_widget_get_realized (GTK_WIDGET (gtkwindow)), 0);
-
- window = gtk_widget_get_window (GTK_WIDGET (gtkwindow));
- display = gdk_window_get_display (window);
-
- gdk_x11_display_error_trap_push (display);
- result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
- gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
- 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
- &bytes_after, (gpointer) &workspace);
- err = gdk_x11_display_error_trap_pop (display);
-
- if (err != Success || result != Success)
- return ret;
- if (type == XA_CARDINAL && format == 32 && nitems > 0)
- ret = workspace[0];
-
- XFree (workspace);
- return ret;
-#else
- /* FIXME: on mac etc proably there are native APIs
- * to get the current workspace etc */
- return 0;
-#endif
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ {
+ GdkWindow *window;
+ GdkDisplay *display;
+ Atom type;
+ gint format;
+ gulong nitems;
+ gulong bytes_after;
+ guint *workspace;
+ gint err, result;
+ guint ret = PLUMA_ALL_WORKSPACES;
+
+ g_return_val_if_fail (GTK_IS_WINDOW (gtkwindow), 0);
+ g_return_val_if_fail (gtk_widget_get_realized (GTK_WIDGET (gtkwindow)), 0);
+
+ window = gtk_widget_get_window (GTK_WIDGET (gtkwindow));
+ display = gdk_window_get_display (window);
+
+ gdk_x11_display_error_trap_push (display);
+ result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (window),
+ gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"),
+ 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
+ &bytes_after, (gpointer) &workspace);
+ err = gdk_x11_display_error_trap_pop (display);
+
+ if (err != Success || result != Success)
+ return ret;
+
+ if (type == XA_CARDINAL && format == 32 && nitems > 0)
+ ret = workspace[0];
+
+ XFree (workspace);
+ return ret;
+ }
+ else
+ /* FIXME: on mac etc proably there are native APIs
+ * to get the current workspace etc */
+ return 0;
}
/**
@@ -949,51 +950,54 @@ pluma_utils_get_current_viewport (GdkScreen *screen,
gint *x,
gint *y)
{
-#ifdef GDK_WINDOWING_X11
- GdkWindow *root_win;
- GdkDisplay *display;
- Atom type;
- gint format;
- gulong nitems;
- gulong bytes_after;
- gulong *coordinates;
- gint err, result;
-
- g_return_if_fail (GDK_IS_SCREEN (screen));
- g_return_if_fail (x != NULL && y != NULL);
-
- /* Default values for the viewport origin */
- *x = 0;
- *y = 0;
-
- root_win = gdk_screen_get_root_window (screen);
- display = gdk_screen_get_display (screen);
-
- gdk_x11_display_error_trap_push (display);
- result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win),
- gdk_x11_get_xatom_by_name_for_display (display, "_NET_DESKTOP_VIEWPORT"),
- 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
- &bytes_after, (void*) &coordinates);
- err = gdk_x11_display_error_trap_pop (display);
-
- if (err != Success || result != Success)
- return;
-
- if (type != XA_CARDINAL || format != 32 || nitems < 2)
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
{
+ GdkWindow *root_win;
+ GdkDisplay *display;
+ Atom type;
+ gint format;
+ gulong nitems;
+ gulong bytes_after;
+ gulong *coordinates;
+ gint err, result;
+
+ g_return_if_fail (GDK_IS_SCREEN (screen));
+ g_return_if_fail (x != NULL && y != NULL);
+
+ /* Default values for the viewport origin */
+ *x = 0;
+ *y = 0;
+
+ root_win = gdk_screen_get_root_window (screen);
+ display = gdk_screen_get_display (screen);
+
+ gdk_x11_display_error_trap_push (display);
+ result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XID (root_win),
+ gdk_x11_get_xatom_by_name_for_display (display, "_NET_DESKTOP_VIEWPORT"),
+ 0, G_MAXLONG, False, XA_CARDINAL, &type, &format, &nitems,
+ &bytes_after, (void*) &coordinates);
+ err = gdk_x11_display_error_trap_pop (display);
+
+ if (err != Success || result != Success)
+ return;
+
+ if (type != XA_CARDINAL || format != 32 || nitems < 2)
+ {
+ XFree (coordinates);
+ return;
+ }
+
+ *x = coordinates[0];
+ *y = coordinates[1];
XFree (coordinates);
- return;
}
-
- *x = coordinates[0];
- *y = coordinates[1];
- XFree (coordinates);
-#else
+ else
/* FIXME: on mac etc proably there are native APIs
* to get the current workspace etc */
- *x = 0;
- *y = 0;
-#endif
+ {
+ *x = 0;
+ *y = 0;
+ }
}
static gboolean
diff --git a/pluma/pluma.c b/pluma/pluma.c
index e0f46e0f..c396429f 100644
--- a/pluma/pluma.c
+++ b/pluma/pluma.c
@@ -378,13 +378,16 @@ on_message_received (const char *message,
if (!gtk_widget_get_realized (GTK_WIDGET (window)))
gtk_widget_realize (GTK_WIDGET (window));
- if (startup_timestamp <= 0)
- startup_timestamp = gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (window)));
-
- gdk_x11_window_set_user_time (gtk_widget_get_window (GTK_WIDGET (window)),
- startup_timestamp);
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ {
+ if (startup_timestamp <= 0)
+ startup_timestamp = gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (window)));
- gtk_window_present (GTK_WINDOW (window));
+ gdk_x11_window_set_user_time (gtk_widget_get_window (GTK_WIDGET (window)), startup_timestamp);
+ gtk_window_present (GTK_WINDOW (window));
+ }
+ else
+ gtk_window_present_with_time (GTK_WINDOW (window), GPOINTER_TO_UINT (data));
out:
g_strfreev (commands);
@@ -421,7 +424,11 @@ send_bacon_message (void)
display = gdk_screen_get_display (screen);
display_name = gdk_display_get_name (display);
- screen_number = gdk_x11_screen_get_screen_number (screen);
+
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ screen_number = gdk_x11_screen_get_screen_number (screen);
+ else
+ screen_number = 0;
pluma_debug_message (DEBUG_APP, "Display: %s", display_name);
pluma_debug_message (DEBUG_APP, "Screen: %d", screen_number);
@@ -515,8 +522,6 @@ main (int argc, char *argv[])
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
- gdk_set_allowed_backends ("x11");
-
startup_timestamp = get_startup_timestamp();
/* Setup command line options */
diff --git a/pluma/smclient/eggdesktopfile.c b/pluma/smclient/eggdesktopfile.c
index 84e611f7..1da14251 100644
--- a/pluma/smclient/eggdesktopfile.c
+++ b/pluma/smclient/eggdesktopfile.c
@@ -31,8 +31,8 @@
#include <unistd.h>
#include <glib/gi18n.h>
-#include <gdk/gdkx.h>
#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
struct EggDesktopFile {
GKeyFile *key_file;
@@ -919,8 +919,7 @@ start_startup_notification (GdkDisplay *display,
{
static int sequence = 0;
char *startup_id;
- char *description, *wmclass;
- char *screen_str, *workspace_str;
+ char *wmclass;
if (g_key_file_has_key (desktop_file->key_file,
EGG_DESKTOP_FILE_GROUP,
@@ -944,8 +943,14 @@ start_startup_notification (GdkDisplay *display,
return NULL;
}
- if (launch_time == (guint32)-1)
- launch_time = gdk_x11_display_get_user_time (display);
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ {
+ if (launch_time == (guint32)-1)
+ launch_time = gdk_x11_display_get_user_time (display);
+ }
+ else if (launch_time == (guint32)-1)
+ launch_time = g_get_monotonic_time () / 1000;
+
startup_id = g_strdup_printf ("%s-%lu-%s-%s-%d_TIME%lu",
g_get_prgname (),
(unsigned long)getpid (),
@@ -954,25 +959,29 @@ start_startup_notification (GdkDisplay *display,
sequence++,
(unsigned long)launch_time);
- description = g_strdup_printf (_("Starting %s"), desktop_file->name);
- screen_str = g_strdup_printf ("%d", screen);
- workspace_str = workspace == -1 ? NULL : g_strdup_printf ("%d", workspace);
-
- gdk_x11_display_broadcast_startup_message (display, "new",
- "ID", startup_id,
- "NAME", desktop_file->name,
- "SCREEN", screen_str,
- "BIN", argv0,
- "ICON", desktop_file->icon,
- "DESKTOP", workspace_str,
- "DESCRIPTION", description,
- "WMCLASS", wmclass,
- NULL);
-
- g_free (description);
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ {
+ char *description = g_strdup_printf (_("Starting %s"), desktop_file->name);
+ char *screen_str = g_strdup_printf ("%d", screen);
+ char *workspace_str = workspace == -1 ? NULL : g_strdup_printf ("%d", workspace);
+
+ gdk_x11_display_broadcast_startup_message (display, "new",
+ "ID", startup_id,
+ "NAME", desktop_file->name,
+ "SCREEN", screen_str,
+ "BIN", argv0,
+ "ICON", desktop_file->icon,
+ "DESKTOP", workspace_str,
+ "DESCRIPTION", description,
+ "WMCLASS", wmclass,
+ NULL);
+
+ g_free (description);
+ g_free (screen_str);
+ g_free (workspace_str);
+ }
+
g_free (wmclass);
- g_free (screen_str);
- g_free (workspace_str);
return startup_id;
}
@@ -981,9 +990,12 @@ static void
end_startup_notification (GdkDisplay *display,
const char *startup_id)
{
- gdk_x11_display_broadcast_startup_message (display, "remove",
- "ID", startup_id,
- NULL);
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ {
+ gdk_x11_display_broadcast_startup_message (display, "remove",
+ "ID", startup_id,
+ NULL);
+ }
}
#define EGG_DESKTOP_FILE_SN_TIMEOUT_LENGTH (30 /* seconds */)
@@ -1184,7 +1196,11 @@ egg_desktop_file_launchv (EggDesktopFile *desktop_file,
display = gdk_display_get_default ();
screen = gdk_display_get_default_screen (display);
}
- screen_num = gdk_x11_screen_get_screen_number (screen);
+
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ screen_num = gdk_x11_screen_get_screen_number (screen);
+ else
+ screen_num = 0;
translated_documents = translate_document_list (desktop_file, documents);
docs = translated_documents;