summaryrefslogtreecommitdiff
path: root/mate-screenshot/src/screenshot-utils.c
diff options
context:
space:
mode:
authorOz N Tiram <[email protected]>2016-06-18 16:23:32 +0200
committerraveit65 <[email protected]>2016-06-20 10:24:10 +0200
commit30c99286eda160f95fd7f17ba4e82e2e368fc6eb (patch)
treec8866f08567baa661114617a3b7a9c1e65b23023 /mate-screenshot/src/screenshot-utils.c
parent26a3d2bc96278d43fdb913c1b3430cd9be4c4663 (diff)
downloadmate-utils-30c99286eda160f95fd7f17ba4e82e2e368fc6eb.tar.bz2
mate-utils-30c99286eda160f95fd7f17ba4e82e2e368fc6eb.tar.xz
Some more fixes for gtk+3
* remove deprecated calls to: - gdk_keyboard_grab - gdk_pointer_grab - gdk_keyboard_ungrab - gdk_pointer_ungrab GTK+3 Replace on_preview_expose_event This method used many deprecated calles. This method was replaced with on_preview_draw, code taken directly from current gnome-screenshot
Diffstat (limited to 'mate-screenshot/src/screenshot-utils.c')
-rw-r--r--mate-screenshot/src/screenshot-utils.c50
1 files changed, 49 insertions, 1 deletions
diff --git a/mate-screenshot/src/screenshot-utils.c b/mate-screenshot/src/screenshot-utils.c
index 9d5d8af7..0efd43b8 100644
--- a/mate-screenshot/src/screenshot-utils.c
+++ b/mate-screenshot/src/screenshot-utils.c
@@ -500,6 +500,11 @@ void
screenshot_select_area_async (SelectAreaCallback callback)
{
GdkCursor *cursor;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkDeviceManager *manager;
+ GdkDevice *pointer, *keyboard;
+ GdkGrabStatus res;
+#endif
select_area_filter_data data;
GdkRectangle *rectangle;
CallbackData *cb_data;
@@ -521,6 +526,39 @@ screenshot_select_area_async (SelectAreaCallback callback)
cursor = gdk_cursor_new (GDK_CROSSHAIR);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ manager = gdk_display_get_device_manager (gdk_display_get_default ());
+ pointer = gdk_device_manager_get_client_pointer (manager);
+ keyboard = gdk_device_get_associated_device (pointer);
+
+
+ res = gdk_device_grab (pointer, gtk_widget_get_window (data.window),
+ GDK_OWNERSHIP_NONE, FALSE,
+ GDK_POINTER_MOTION_MASK |
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK,
+ cursor, GDK_CURRENT_TIME);
+
+ if (res != GDK_GRAB_SUCCESS)
+ {
+ g_object_unref (cursor);
+ goto out;
+ }
+
+ res = gdk_device_grab (keyboard, gtk_widget_get_window (data.window),
+ GDK_OWNERSHIP_NONE, FALSE,
+ GDK_KEY_PRESS_MASK |
+ GDK_KEY_RELEASE_MASK,
+ NULL, GDK_CURRENT_TIME);
+ if (res != GDK_GRAB_SUCCESS)
+ {
+ gdk_device_ungrab (pointer, GDK_CURRENT_TIME);
+ g_object_unref (cursor);
+ goto out;
+ }
+
+#else
+
if (gdk_pointer_grab (gtk_widget_get_window (data.window), FALSE,
GDK_POINTER_MOTION_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_RELEASE_MASK,
NULL, cursor,
@@ -537,14 +575,24 @@ screenshot_select_area_async (SelectAreaCallback callback)
goto out;
}
+#endif
+
gtk_main ();
+#if GTK_CHECK_VERSION (3, 0, 0)
+
+ gdk_device_ungrab (keyboard, GDK_CURRENT_TIME);
+ gdk_device_ungrab (pointer, GDK_CURRENT_TIME);
+
+#else
+
gdk_keyboard_ungrab (GDK_CURRENT_TIME);
gdk_pointer_ungrab (GDK_CURRENT_TIME);
+#endif
+
gtk_widget_destroy (data.window);
gdk_cursor_unref (cursor);
-
gdk_flush ();
out: