summaryrefslogtreecommitdiff
path: root/mate-screenshot
diff options
context:
space:
mode:
authorZenWalker <[email protected]>2017-08-25 15:53:40 +0200
committerraveit65 <[email protected]>2017-08-29 21:59:03 +0200
commit9a5f07e008367db8676586551e71357443a2aa21 (patch)
tree8f1e2047ac0aa5fab63b274ca54c7648b8636372 /mate-screenshot
parent02c497e4982fafe7186b34f820cff7d637832cbb (diff)
downloadmate-utils-9a5f07e008367db8676586551e71357443a2aa21.tar.bz2
mate-utils-9a5f07e008367db8676586551e71357443a2aa21.tar.xz
avoid deprecated gdk_screen_get_active_window
make new function taken from: https://git.gnome.org/browse/gtk+/commit/?id=6b9e481e38571f73237f6b8a38cb4bc6987bc4ca with little changes adapted to work in screenshot-utils.c
Diffstat (limited to 'mate-screenshot')
-rw-r--r--mate-screenshot/src/screenshot-utils.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/mate-screenshot/src/screenshot-utils.c b/mate-screenshot/src/screenshot-utils.c
index 8001b502..e0a34e8d 100644
--- a/mate-screenshot/src/screenshot-utils.c
+++ b/mate-screenshot/src/screenshot-utils.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "screenshot-utils.h"
+#include <X11/Xatom.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <glib.h>
@@ -133,13 +134,55 @@ screenshot_release_lock (void)
}
static GdkWindow *
+screen_get_active_window (GdkScreen *screen)
+{
+ GdkWindow *ret = NULL;
+ Atom type_return;
+ gint format_return;
+ gulong nitems_return;
+ gulong bytes_after_return;
+ guchar *data = NULL;
+
+ if (!gdk_x11_screen_supports_net_wm_hint (screen,
+ gdk_atom_intern_static_string ("_NET_ACTIVE_WINDOW")))
+ return NULL;
+
+ if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen)),
+ RootWindow (GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen)),
+ GDK_SCREEN_XNUMBER (screen)),
+ gdk_x11_get_xatom_by_name_for_display (gdk_screen_get_display (screen),
+ "_NET_ACTIVE_WINDOW"),
+ 0, 1, False, XA_WINDOW, &type_return,
+ &format_return, &nitems_return,
+ &bytes_after_return, &data)
+ == Success)
+ {
+ if ((type_return == XA_WINDOW) && (format_return == 32) && (data))
+ {
+ Window window = *(Window *) data;
+
+ if (window != None)
+ {
+ ret = gdk_x11_window_foreign_new_for_display (gdk_screen_get_display (screen),
+ window);
+ }
+ }
+ }
+
+ if (data)
+ XFree (data);
+
+ return ret;
+}
+
+static GdkWindow *
screenshot_find_active_window (void)
{
GdkWindow *window;
GdkScreen *default_screen;
default_screen = gdk_screen_get_default ();
- window = gdk_screen_get_active_window (default_screen);
+ window = screen_get_active_window (default_screen);
return window;
}