summaryrefslogtreecommitdiff
path: root/typing-break/drwright.c
diff options
context:
space:
mode:
Diffstat (limited to 'typing-break/drwright.c')
-rw-r--r--typing-break/drwright.c35
1 files changed, 34 insertions, 1 deletions
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;
}