[gedit] Remove X11 workspace awareness
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] Remove X11 workspace awareness
- Date: Wed, 18 Mar 2020 17:22:02 +0000 (UTC)
commit d0728e7d0c3e7fdc58f03f0af4e0ce64eb7aef6e
Author: Sébastien Wilmet <swilmet gnome org>
Date: Wed Mar 18 17:44:52 2020 +0100
Remove X11 workspace awareness
Unfortunately workspaces information is currently not supported on
Wayland:
https://gitlab.gnome.org/GNOME/gtk/issues/2506
And X11 is deprecated. The X11-specific code in gedit prevents gedit
from being a native Wayland app.
Fixes https://gitlab.gnome.org/GNOME/gedit/issues/177
docs/reference/api-breaks.xml | 8 ++
docs/reference/gedit-sections.txt | 3 -
gedit/gedit-app.c | 71 +-------------
gedit/gedit-utils.c | 188 --------------------------------------
gedit/gedit-utils.h | 9 +-
5 files changed, 13 insertions(+), 266 deletions(-)
---
diff --git a/docs/reference/api-breaks.xml b/docs/reference/api-breaks.xml
index 8c337c106..8cb71d77c 100644
--- a/docs/reference/api-breaks.xml
+++ b/docs/reference/api-breaks.xml
@@ -43,6 +43,14 @@
<code>gedit-utils.h</code>.
</para>
</listitem>
+ <listitem>
+ <para>
+ The <code>gedit_utils_get_current_workspace()</code>,
+ <code>gedit_utils_get_window_workspace()</code> and
+ <code>gedit_utils_get_current_viewport()</code> functions have been
+ removed because workspaces information is not available on Wayland.
+ </para>
+ </listitem>
</itemizedlist>
</refsect1>
diff --git a/docs/reference/gedit-sections.txt b/docs/reference/gedit-sections.txt
index 289e71402..69f928a85 100644
--- a/docs/reference/gedit-sections.txt
+++ b/docs/reference/gedit-sections.txt
@@ -349,13 +349,10 @@ gedit_menu_extension_get_type
gedit_utils_menu_position_under_tree_view
gedit_utils_set_atk_name_description
gedit_warning
-gedit_utils_get_current_workspace
-gedit_utils_get_window_workspace
gedit_utils_basename_for_display
gedit_utils_decode_uri
gedit_utils_drop_get_uris
gedit_utils_get_compression_type_from_content_type
-gedit_utils_get_current_viewport
gedit_utils_is_valid_location
gedit_utils_location_get_dirname_for_display
gedit_utils_set_direct_save_filename
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index 836c177ab..82067b257 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -254,82 +254,19 @@ gedit_app_set_window_title_impl (GeditApp *app,
gtk_window_set_title (GTK_WINDOW (window), title);
}
-static gboolean
-is_in_viewport (GtkWindow *window,
- GdkScreen *screen,
- gint workspace,
- gint viewport_x,
- gint viewport_y)
-{
- GdkScreen *s;
- GdkDisplay *display;
- GdkMonitor *monitor;
- GdkWindow *gdkwindow;
- GdkRectangle geometry;
- const gchar *cur_name;
- const gchar *name;
- gint ws;
- gint x, y, width, height;
-
- /* Check for screen and display match */
- display = gdk_screen_get_display (screen);
- cur_name = gdk_display_get_name (display);
-
- s = gtk_window_get_screen (window);
- display = gdk_screen_get_display (s);
- name = gdk_display_get_name (display);
-
- if (strcmp (cur_name, name) != 0)
- {
- return FALSE;
- }
-
- /* Check for workspace match */
- ws = gedit_utils_get_window_workspace (window);
-
- if (ws != workspace && ws != GEDIT_ALL_WORKSPACES)
- {
- return FALSE;
- }
-
- /* Check for viewport match */
- gdkwindow = gtk_widget_get_window (GTK_WIDGET (window));
- gdk_window_get_position (gdkwindow, &x, &y);
- width = gdk_window_get_width (gdkwindow);
- height = gdk_window_get_height (gdkwindow);
-
- x += viewport_x;
- y += viewport_y;
-
- monitor = gdk_display_get_monitor_at_window(display, gdkwindow);
- gdk_monitor_get_geometry(monitor, &geometry);
-
- return x + width * .75 >= geometry.x &&
- x + width * .25 <= geometry.x + geometry.width &&
- y + height * .75 >= geometry.y &&
- y + height * .25 <= geometry.y + geometry.height;
-}
-
static GeditWindow *
get_active_window (GtkApplication *app)
{
- GdkScreen *screen;
- guint workspace;
- gint viewport_x, viewport_y;
- GList *windows, *l;
-
- screen = gdk_screen_get_default ();
-
- workspace = gedit_utils_get_current_workspace (screen);
- gedit_utils_get_current_viewport (screen, &viewport_x, &viewport_y);
+ GList *windows;
+ GList *l;
- /* Gtk documentation says the window list is always in MRU order */
+ /* Gtk documentation says the window list is always in MRU order. */
windows = gtk_application_get_windows (app);
for (l = windows; l != NULL; l = l->next)
{
GtkWindow *window = l->data;
- if (GEDIT_IS_WINDOW (window) && is_in_viewport (window, screen, workspace, viewport_x,
viewport_y))
+ if (GEDIT_IS_WINDOW (window))
{
return GEDIT_WINDOW (window);
}
diff --git a/gedit/gedit-utils.c b/gedit/gedit-utils.c
index 6993f900a..d7bbd2c44 100644
--- a/gedit/gedit-utils.c
+++ b/gedit/gedit-utils.c
@@ -21,17 +21,9 @@
*/
#include "gedit-utils.h"
-
#include <string.h>
#include <glib/gi18n.h>
#include <tepl/tepl.h>
-
-/* For the workspace/viewport stuff */
-#ifdef GDK_WINDOWING_X11
-#include <gdk/gdkx.h>
-#include <X11/Xatom.h>
-#endif
-
#include "gedit-debug.h"
gboolean
@@ -236,186 +228,6 @@ gedit_utils_location_get_dirname_for_display (GFile *location)
return res;
}
-/* the following two functions are courtesy of galeon */
-
-/**
- * gedit_utils_get_current_workspace:
- * @screen: a #GdkScreen
- *
- * Get the currently visible workspace for the #GdkScreen.
- *
- * If the X11 window property isn't found, 0 (the first workspace)
- * is returned.
- */
-guint
-gedit_utils_get_current_workspace (GdkScreen *screen)
-{
-#ifdef GDK_WINDOWING_X11
- GdkWindow *root_win;
- GdkDisplay *display;
- 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);
-
- if (GDK_IS_X11_DISPLAY (display))
- {
- Atom type;
- gint format;
- gulong nitems;
- gulong bytes_after;
- guint *current_desktop;
- gint err, result;
-
- 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) ¤t_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;
-#else
- /* FIXME: on mac etc proably there are native APIs
- * to get the current workspace etc */
- return 0;
-#endif
-}
-
-/**
- * gedit_utils_get_window_workspace:
- * @gtkwindow: a #GtkWindow.
- *
- * Get the workspace the window is on.
- *
- * This function gets the workspace that the #GtkWindow is visible on,
- * it returns GEDIT_ALL_WORKSPACES if the window is sticky, or if
- * the window manager doesn't support this function.
- *
- * Returns: the workspace the window is on.
- */
-guint
-gedit_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 = GEDIT_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);
-
- if (GDK_IS_X11_DISPLAY (display))
- {
- 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
-}
-
-/**
- * gedit_utils_get_current_viewport:
- * @screen: a #GdkScreen
- * @x: (out): x-axis point.
- * @y: (out): y-axis point.
- *
- * Get the currently visible viewport origin for the #GdkScreen.
- *
- * If the X11 window property isn't found, (0, 0) is returned.
- */
-void
-gedit_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);
-
- if (GDK_IS_X11_DISPLAY (display))
- {
- 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);
- }
-#else
- /* FIXME: on mac etc proably there are native APIs
- * to get the current workspace etc */
- *x = 0;
- *y = 0;
-#endif
-}
-
static gboolean
is_valid_scheme_character (gchar c)
{
diff --git a/gedit/gedit-utils.h b/gedit/gedit-utils.h
index 565b500d3..6f00ed675 100644
--- a/gedit/gedit-utils.h
+++ b/gedit/gedit-utils.h
@@ -27,8 +27,6 @@
G_BEGIN_DECLS
-enum { GEDIT_ALL_WORKSPACES = 0xffffffff };
-
gboolean gedit_utils_menu_position_under_tree_view (GtkTreeView *tree_view,
GdkRectangle *rect);
@@ -40,13 +38,8 @@ void gedit_warning (
...) G_GNUC_PRINTF(2, 3);
gchar *gedit_utils_location_get_dirname_for_display (GFile *location);
-guint gedit_utils_get_current_workspace (GdkScreen *screen);
-guint gedit_utils_get_window_workspace (GtkWindow *gtkwindow);
-void gedit_utils_get_current_viewport (GdkScreen *screen,
- gint *x,
- gint *y);
-gboolean gedit_utils_is_valid_location (GFile *location);
+gboolean gedit_utils_is_valid_location (GFile *location);
gchar *gedit_utils_basename_for_display (GFile *location);
gboolean gedit_utils_decode_uri (const gchar *uri,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]