[gimp/nieldg/remove-keyboard-grab: 13/13] app/display: Remove keyboard grab
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/nieldg/remove-keyboard-grab: 13/13] app/display: Remove keyboard grab
- Date: Mon, 28 Mar 2022 12:51:57 +0000 (UTC)
commit 186598b38708b74b4a8f05955efa37eadc3c4237
Author: Niels De Graef <nielsdegraef gmail com>
Date: Tue Dec 14 22:36:43 2021 +0100
app/display: Remove keyboard grab
Remove `gimp_display_shell_keyboard_grab()` and ...ungrab(), as there
doesn't seem to be any good reason to grab the keyboard away from the
compositor. More annoyingly, in some systems it will pop up a dialog
on each first click whether the user is okay with inhibiting shortcuts.
app/display/gimpdisplayshell-grab.c | 88 ------------------------------
app/display/gimpdisplayshell-grab.h | 5 --
app/display/gimpdisplayshell-tool-events.c | 52 +++---------------
app/display/gimpdisplayshell.h | 4 --
4 files changed, 9 insertions(+), 140 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-grab.c b/app/display/gimpdisplayshell-grab.c
index 8130e4280a..09a45e21ae 100644
--- a/app/display/gimpdisplayshell-grab.c
+++ b/app/display/gimpdisplayshell-grab.c
@@ -59,34 +59,6 @@ get_associated_pointer (GdkDevice *device)
return device;
}
-static GdkDevice *
-get_associated_keyboard (GdkDevice *device)
-{
- switch (gdk_device_get_device_type (device))
- {
- case GDK_DEVICE_TYPE_SLAVE:
- device = gdk_device_get_associated_device (device);
- break;
-
- case GDK_DEVICE_TYPE_FLOATING:
- {
- GdkDisplay *display = gdk_device_get_display (device);
- GdkSeat *seat = gdk_display_get_default_seat (display);
-
- device = gdk_seat_get_pointer (seat);
- }
- break;
-
- default:
- break;
- }
-
- if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
- device = gdk_device_get_associated_device (device);
-
- return device;
-}
-
gboolean
gimp_display_shell_pointer_grab (GimpDisplayShell *shell,
const GdkEvent *event,
@@ -144,63 +116,3 @@ gimp_display_shell_pointer_ungrab (GimpDisplayShell *shell,
shell->grab_pointer_source = NULL;
shell->grab_pointer_time = 0;
}
-
-gboolean
-gimp_display_shell_keyboard_grab (GimpDisplayShell *shell,
- const GdkEvent *event)
-{
- GdkDevice *device;
- GdkDevice *source_device;
- GdkGrabStatus status;
-
- g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
- g_return_val_if_fail (event != NULL, FALSE);
- g_return_val_if_fail (shell->grab_keyboard == NULL, FALSE);
-
- source_device = gimp_devices_get_from_event (shell->display->gimp,
- event, &device);
-
- if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD)
- {
- device = get_associated_keyboard (device);
- source_device = NULL;
- }
-
- status = gdk_device_grab (device,
- gtk_widget_get_window (shell->canvas),
- GDK_OWNERSHIP_APPLICATION,
- FALSE,
- GDK_KEY_PRESS_MASK |
- GDK_KEY_RELEASE_MASK |
- GDK_FOCUS_CHANGE_MASK,
- NULL, gdk_event_get_time (event));
-
- if (status == GDK_GRAB_SUCCESS)
- {
- shell->grab_keyboard = device;
- shell->grab_keyboard_source = source_device;
- shell->grab_keyboard_time = gdk_event_get_time (event);
-
- return TRUE;
- }
-
- g_printerr ("%s: gdk_device_grab(%s) failed with status %d\n",
- G_STRFUNC, gdk_device_get_name (device), status);
-
- return FALSE;
-}
-
-void
-gimp_display_shell_keyboard_ungrab (GimpDisplayShell *shell,
- const GdkEvent *event)
-{
- g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
- g_return_if_fail (event != NULL);
- g_return_if_fail (shell->grab_keyboard != NULL);
-
- gdk_device_ungrab (shell->grab_keyboard, shell->grab_keyboard_time);
-
- shell->grab_keyboard = NULL;
- shell->grab_keyboard_source = NULL;
- shell->grab_keyboard_time = 0;
-}
diff --git a/app/display/gimpdisplayshell-grab.h b/app/display/gimpdisplayshell-grab.h
index 915cf34f49..580811bd79 100644
--- a/app/display/gimpdisplayshell-grab.h
+++ b/app/display/gimpdisplayshell-grab.h
@@ -27,10 +27,5 @@ gboolean gimp_display_shell_pointer_grab (GimpDisplayShell *shell,
void gimp_display_shell_pointer_ungrab (GimpDisplayShell *shell,
const GdkEvent *event);
-gboolean gimp_display_shell_keyboard_grab (GimpDisplayShell *shell,
- const GdkEvent *event);
-void gimp_display_shell_keyboard_ungrab (GimpDisplayShell *shell,
- const GdkEvent *event);
-
#endif /* __GIMP_DISPLAY_SHELL_GRAB_H__ */
diff --git a/app/display/gimpdisplayshell-tool-events.c b/app/display/gimpdisplayshell-tool-events.c
index e28e7199f7..767666712f 100644
--- a/app/display/gimpdisplayshell-tool-events.c
+++ b/app/display/gimpdisplayshell-tool-events.c
@@ -527,13 +527,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
GDK_BUTTON_RELEASE_MASK))
return TRUE;
- if (! shell->space_release_pending)
- if (! gimp_display_shell_keyboard_grab (shell, event))
- {
- gimp_display_shell_pointer_ungrab (shell, event);
- return TRUE;
- }
-
if (gimp_display_shell_initialize_tool (shell,
&image_coords, state))
{
@@ -665,9 +658,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (! shell->grab_pointer || shell->scrolling)
return TRUE;
- if (! shell->space_release_pending)
- gimp_display_shell_keyboard_ungrab (shell, event);
-
if (active_tool &&
(! gimp_image_is_empty (image) ||
gimp_tool_control_get_handle_empty_image (active_tool->control)))
@@ -1344,24 +1334,17 @@ gimp_display_shell_ruler_button_press (GtkWidget *widget,
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK))
{
- if (gimp_display_shell_keyboard_grab (shell, (GdkEvent *) event))
+ if (event->state & gimp_get_toggle_behavior_mask ())
{
- if (event->state & gimp_get_toggle_behavior_mask ())
- {
- gimp_sample_point_tool_start_new (active_tool, display);
- }
- else
- {
- gimp_guide_tool_start_new (active_tool, display,
- orientation);
- }
-
- return TRUE;
+ gimp_sample_point_tool_start_new (active_tool, display);
}
else
{
- gimp_display_shell_pointer_ungrab (shell, (GdkEvent *) event);
+ gimp_guide_tool_start_new (active_tool, display,
+ orientation);
}
+
+ return TRUE;
}
}
}
@@ -1472,21 +1455,9 @@ gimp_display_shell_check_device (GimpDisplayShell *shell,
/* While we have a grab, ignore all events from all other devices
* of the same type
*/
- if (event->type == GDK_KEY_PRESS ||
- event->type == GDK_KEY_RELEASE ||
- event->type == GDK_FOCUS_CHANGE)
- {
- if ((shell->grab_keyboard && (shell->grab_keyboard != grab_device)) ||
- (shell->grab_keyboard_source && (shell->grab_keyboard_source != device)))
- {
- GIMP_LOG (TOOL_EVENTS,
- "ignoring key event from '%s' while waiting for event from '%s'\n",
- gdk_device_get_name (device),
- gdk_device_get_name (shell->grab_keyboard_source));
- return TRUE;
- }
- }
- else
+ if (event->type != GDK_KEY_PRESS &&
+ event->type != GDK_KEY_RELEASE &&
+ event->type != GDK_FOCUS_CHANGE)
{
if ((shell->grab_pointer && (shell->grab_pointer != grab_device)) ||
(shell->grab_pointer_source && (shell->grab_pointer_source != device)))
@@ -1680,9 +1651,6 @@ gimp_display_shell_space_pressed (GimpDisplayShell *shell,
if (shell->space_release_pending || shell->scrolling)
return;
- if (! gimp_display_shell_keyboard_grab (shell, event))
- return;
-
switch (shell->display->config->space_bar_action)
{
case GIMP_SPACE_BAR_ACTION_NONE:
@@ -1780,8 +1748,6 @@ gimp_display_shell_released (GimpDisplayShell *shell,
break;
}
- gimp_display_shell_keyboard_ungrab (shell, event);
-
shell->space_release_pending = FALSE;
shell->button1_release_pending = FALSE;
}
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index f9bf6360f0..f26c792063 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -196,10 +196,6 @@ struct _GimpDisplayShell
GdkDevice *grab_pointer_source;
guint32 grab_pointer_time;
- GdkDevice *grab_keyboard;
- GdkDevice *grab_keyboard_source;
- guint32 grab_keyboard_time;
-
/* the state of gimp_display_shell_zoom_gesture_*() */
gdouble last_zoom_scale;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]