summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2017-08-02 19:55:37 +0200
committerraveit65 <[email protected]>2017-08-15 10:52:56 +0200
commit976cbe77d23089794712f9402d7f082bcd7dde86 (patch)
tree02a5aad2c08eb375a00ab47704d0d647c6a80888
parentc92ca8b67d8209ed1bd33bbe566ea263fc22d597 (diff)
downloadmate-control-center-976cbe77d23089794712f9402d7f082bcd7dde86.tar.bz2
mate-control-center-976cbe77d23089794712f9402d7f082bcd7dde86.tar.xz
typing-break: avoid deprecated GDK pointer and keyboard types
-rw-r--r--typing-break/drw-break-window.c52
-rw-r--r--typing-break/drwright.c35
2 files changed, 78 insertions, 9 deletions
diff --git a/typing-break/drw-break-window.c b/typing-break/drw-break-window.c
index c4132db8..8c2a62fb 100644
--- a/typing-break/drw-break-window.c
+++ b/typing-break/drw-break-window.c
@@ -428,21 +428,57 @@ static gboolean
grab_on_window (GdkWindow *window,
guint32 activate_time)
{
- if ((gdk_pointer_grab (window, TRUE,
- GDK_BUTTON_PRESS_MASK |
- GDK_BUTTON_RELEASE_MASK |
- GDK_POINTER_MOTION_MASK,
- NULL, NULL, activate_time) == 0)) {
- if (gdk_keyboard_grab (window, TRUE,
- activate_time) == 0)
+ GdkDisplay *display;
+#if GTK_CHECK_VERSION (3, 20, 0)
+ GdkSeat *seat;
+#else
+ GdkDeviceManager *device_manager;
+ GdkDevice *pointer;
+ GdkDevice *keyboard;
+#endif
+
+ display = gdk_window_get_display (window);
+#if GTK_CHECK_VERSION (3, 20, 0)
+ seat = gdk_display_get_default_seat (display);
+
+ return (gdk_seat_grab (seat,
+ window,
+ GDK_SEAT_CAPABILITY_ALL,
+ TRUE,
+ NULL,
+ NULL,
+ NULL,
+ NULL) == GDK_GRAB_SUCCESS);
+#else
+ device_manager = gdk_display_get_device_manager (display);
+ pointer = gdk_device_manager_get_client_pointer (device_manager);
+ keyboard = gdk_device_get_associated_device (pointer);
+
+ if ((gdk_device_grab (pointer,
+ window,
+ GDK_OWNERSHIP_NONE,
+ TRUE,
+ GDK_BUTTON_PRESS_MASK |
+ GDK_BUTTON_RELEASE_MASK |
+ GDK_POINTER_MOTION_MASK,
+ NULL,
+ activate_time) == 0)) {
+ if (gdk_device_grab (keyboard,
+ window,
+ GDK_OWNERSHIP_NONE,
+ TRUE,
+ GDK_KEY_PRESS_MASK,
+ NULL,
+ activate_time) == 0)
return TRUE;
else {
- gdk_pointer_ungrab (activate_time);
+ gdk_device_ungrab (pointer, activate_time);
return FALSE;
}
}
return FALSE;
+#endif
}
static gboolean
diff --git a/typing-break/drwright.c b/typing-break/drwright.c
index 2a07f040..6cc6b248 100644
--- a/typing-break/drwright.c
+++ b/typing-break/drwright.c
@@ -322,9 +322,42 @@ static gboolean
grab_keyboard_on_window (GdkWindow *window,
guint32 activate_time)
{
+ GdkDisplay *display;
+#if GTK_CHECK_VERSION (3, 20, 0)
+ GdkSeat *seat;
+#else
+ GdkDeviceManager *device_manager;
+ GdkDevice *pointer;
+ GdkDevice *keyboard;
+#endif
GdkGrabStatus status;
- status = gdk_keyboard_grab (window, TRUE, activate_time);
+ display = gdk_window_get_display (window);
+#if GTK_CHECK_VERSION (3, 20, 0)
+ seat = gdk_display_get_default_seat (display);
+
+ status = gdk_seat_grab (seat,
+ window,
+ GDK_SEAT_CAPABILITY_KEYBOARD,
+ TRUE,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+#else
+ device_manager = gdk_display_get_device_manager (display);
+ pointer = gdk_device_manager_get_client_pointer (device_manager);
+ keyboard = gdk_device_get_associated_device (pointer);
+
+ status = gdk_device_grab (keyboard,
+ window,
+ GDK_OWNERSHIP_NONE,
+ TRUE,
+ GDK_KEY_PRESS_MASK,
+ NULL,
+ activate_time);
+#endif
+
if (status == GDK_GRAB_SUCCESS) {
return TRUE;
}