1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 05:22:40 +02:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Niels De Graef
0f42e416aa app: Stop using grabs in GimpDisplayShell
We don't need them and they're giving us deprecation warnings anyway, so
just remove them completely.
2023-05-24 12:34:32 +02:00
Niels De Graef
39c1e7baf7 app: Don't grab the pointer when doing scrolling
By doing `gimp_display_shell_pointer_grab()`, we actually prevent events
from a tablet coming through. There doesn't seem to be a reason to use
it and it's not regressing in functionality either, so let's just remove
it.

Fixes: https://gitlab.gnome.org/GNOME/gimp/-/issues/8016
2023-05-24 12:30:00 +02:00
5 changed files with 9 additions and 231 deletions

View File

@@ -101,8 +101,6 @@ libappdisplay_a_sources = \
gimpdisplayshell-draw.h \
gimpdisplayshell-expose.c \
gimpdisplayshell-expose.h \
gimpdisplayshell-grab.c \
gimpdisplayshell-grab.h \
gimpdisplayshell-handlers.c \
gimpdisplayshell-handlers.h \
gimpdisplayshell-filter.c \

View File

@@ -1,118 +0,0 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdisplayshell-grab.c
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "display-types.h"
#include "widgets/gimpdevices.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-grab.h"
static GdkDevice *
get_associated_pointer (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);
return 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,
GdkEventMask event_mask)
{
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_pointer == 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_pointer (device);
source_device = NULL;
}
status = gdk_device_grab (device,
gtk_widget_get_window (shell->canvas),
GDK_OWNERSHIP_APPLICATION,
FALSE, event_mask, NULL,
gdk_event_get_time (event));
if (status == GDK_GRAB_SUCCESS)
{
shell->grab_pointer = device;
shell->grab_pointer_source = source_device;
shell->grab_pointer_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_pointer_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_pointer != NULL);
gdk_device_ungrab (shell->grab_pointer, shell->grab_pointer_time);
shell->grab_pointer = NULL;
shell->grab_pointer_source = NULL;
shell->grab_pointer_time = 0;
}

View File

@@ -1,31 +0,0 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpdisplayshell-grab.h
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_DISPLAY_SHELL_GRAB_H__
#define __GIMP_DISPLAY_SHELL_GRAB_H__
gboolean gimp_display_shell_pointer_grab (GimpDisplayShell *shell,
const GdkEvent *event,
GdkEventMask event_mask);
void gimp_display_shell_pointer_ungrab (GimpDisplayShell *shell,
const GdkEvent *event);
#endif /* __GIMP_DISPLAY_SHELL_GRAB_H__ */

View File

@@ -66,7 +66,6 @@
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-autoscroll.h"
#include "gimpdisplayshell-cursor.h"
#include "gimpdisplayshell-grab.h"
#include "gimpdisplayshell-layer-select.h"
#include "gimpdisplayshell-rotate.h"
#include "gimpdisplayshell-scale.h"
@@ -399,10 +398,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (cevent->mode != GDK_CROSSING_NORMAL)
return TRUE;
/* ignore enter notify while we have a grab */
if (shell->grab_pointer)
return TRUE;
gimp_display_shell_proximity_in (shell);
update_sw_cursor = TRUE;
@@ -420,10 +415,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (cevent->mode != GDK_CROSSING_NORMAL)
return TRUE;
/* ignore leave notify while we have a grab */
if (shell->grab_pointer)
return TRUE;
gimp_display_shell_proximity_out (shell);
tool_manager_oper_update_active (gimp,
@@ -460,10 +451,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (G_UNLIKELY (! gtk_widget_has_focus (canvas)))
g_warning ("%s: FOCUS_IN but canvas has no focus", G_STRFUNC);
/* ignore focus changes while we have a grab */
if (shell->grab_pointer)
return TRUE;
/* press modifier keys when the canvas gets the focus */
gimp_display_shell_update_focus (shell, TRUE,
&image_coords, state);
@@ -473,10 +460,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (G_UNLIKELY (gtk_widget_has_focus (canvas)))
g_warning ("%s: FOCUS_OUT but canvas has focus", G_STRFUNC);
/* ignore focus changes while we have a grab */
if (shell->grab_pointer)
return TRUE;
/* release modifier keys when the canvas loses the focus */
gimp_display_shell_update_focus (shell, FALSE,
&image_coords, 0);
@@ -492,7 +475,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
/* ignore new mouse events */
if (gimp->busy ||
shell->mod_action != GIMP_MODIFIER_ACTION_NONE ||
shell->grab_pointer ||
shell->button1_release_pending)
return TRUE;
@@ -531,11 +513,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (bevent->button == 1)
{
if (! gimp_display_shell_pointer_grab (shell, event,
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK))
return TRUE;
if (gimp_display_shell_initialize_tool (shell,
&image_coords, state))
{
@@ -689,13 +666,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
if (bevent->button == 1)
{
/* If we don't have a grab, this is a release paired with
* a button press we intentionally ignored because we had
* a grab on another device at the time of the press
*/
if (! shell->grab_pointer || shell->mod_action != GIMP_MODIFIER_ACTION_NONE)
return TRUE;
if (active_tool &&
(! gimp_image_is_empty (image) ||
gimp_tool_control_get_handle_empty_image (active_tool->control)))
@@ -723,8 +693,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
else
gimp_display_shell_update_focus (shell, FALSE,
&image_coords, 0);
gimp_display_shell_pointer_ungrab (shell, event);
}
else
{
@@ -1202,11 +1170,6 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
{
shell->button1_release_pending = TRUE;
shell->space_release_pending = FALSE;
/* We need to ungrab the pointer in order to catch
* button release events.
*/
if (shell->grab_pointer)
gimp_display_shell_pointer_ungrab (shell, event);
}
else
{
@@ -1491,22 +1454,17 @@ gimp_display_shell_ruler_button_press (GtkWidget *widget,
gimp_display_shell_update_focus (shell, TRUE,
NULL, event->state);
if (gimp_display_shell_pointer_grab (shell, (GdkEvent *) event,
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK))
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_guide_tool_start_new (active_tool, display,
orientation);
}
return TRUE;
}
}
@@ -1613,24 +1571,6 @@ gimp_display_shell_check_device (GimpDisplayShell *shell,
if (device)
{
/* 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_pointer && (shell->grab_pointer != grab_device)) ||
(shell->grab_pointer_source && (shell->grab_pointer_source != device)))
{
GIMP_LOG (TOOL_EVENTS,
"ignoring pointer event from '%s' while waiting for event from '%s'\n",
gdk_device_get_name (device),
gdk_device_get_name (shell->grab_pointer_source));
return TRUE;
}
}
if (! gimp->busy && gimp_devices_check_change (gimp, device))
{
gimp_display_shell_check_device_cursor (shell);
@@ -1685,10 +1625,6 @@ gimp_display_shell_start_scrolling (GimpDisplayShell *shell,
mod_action = GIMP_MODIFIER_ACTION_ZOOMING;
}
gimp_display_shell_pointer_grab (shell, event,
GDK_POINTER_MOTION_MASK |
GDK_BUTTON_RELEASE_MASK);
shell->scroll_start_x = x;
shell->scroll_start_y = y;
shell->scroll_last_x = x;
@@ -1799,12 +1735,6 @@ gimp_display_shell_stop_scrolling (GimpDisplayShell *shell,
shell->scroll_last_x = 0;
shell->scroll_last_y = 0;
shell->rotate_drag_angle = 0.0;
/* We may have ungrabbed the pointer when space was released while
* mouse was down, to be able to catch a GDK_BUTTON_RELEASE event.
*/
if (shell->grab_pointer)
gimp_display_shell_pointer_ungrab (shell, event);
}
static void

View File

@@ -62,7 +62,6 @@ libappdisplay_sources = [
'gimpdisplayshell-expose.c',
'gimpdisplayshell-filter-dialog.c',
'gimpdisplayshell-filter.c',
'gimpdisplayshell-grab.c',
'gimpdisplayshell-handlers.c',
'gimpdisplayshell-items.c',
'gimpdisplayshell-layer-select.c',