summaryrefslogtreecommitdiff
path: root/gtk/gtkcellrendereraccel.c
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2018-03-07 14:27:27 +0100
committerCarlos Garnacho <carlosg@gnome.org>2018-04-05 19:26:54 +0200
commitcfdf4f650fef6d05bea8964d36f13a5ea0edea90 (patch)
tree3069bc87802a69376bf34931f151a2a15ae386dc /gtk/gtkcellrendereraccel.c
parentdf386f29ab255d2a1a8fc8fc31f54491f1738286 (diff)
downloadgtk+-cfdf4f650fef6d05bea8964d36f13a5ea0edea90.tar.gz
gtkcellrendereraccel: simplify grabbing code
Diffstat (limited to 'gtk/gtkcellrendereraccel.c')
-rw-r--r--gtk/gtkcellrendereraccel.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/gtk/gtkcellrendereraccel.c b/gtk/gtkcellrendereraccel.c
index 5a937ee4a7..e16ffac29c 100644
--- a/gtk/gtkcellrendereraccel.c
+++ b/gtk/gtkcellrendereraccel.c
@@ -95,7 +95,7 @@ struct _GtkCellRendererAccelPrivate
guint accel_key;
guint keycode;
- GdkDevice *grab_pointer;
+ GdkSeat *grab_seat;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkCellRendererAccel, gtk_cell_renderer_accel, GTK_TYPE_CELL_RENDERER_TEXT)
@@ -439,7 +439,7 @@ gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell,
GtkWidget *label;
GtkWidget *editable;
gboolean is_editable;
- GdkDevice *device, *pointer;
+ GdkSeat *seat = NULL;
GdkSurface *surface;
celltext = GTK_CELL_RENDERER_TEXT (cell);
@@ -454,24 +454,25 @@ gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell,
surface = gtk_widget_get_surface (gtk_widget_get_toplevel (widget));
if (event)
- device = gdk_event_get_device (event);
+ seat = gdk_event_get_seat (event);
else
- device = gtk_get_current_event_device ();
+ {
+ GdkDevice *device;
- if (!device || !surface)
- return NULL;
+ device = gtk_get_current_event_device ();
+ if (device)
+ seat = gdk_device_get_seat (device);
+ }
- if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
- pointer = gdk_device_get_associated_device (device);
- else
- pointer = device;
+ if (!seat || !surface)
+ return NULL;
- if (gdk_seat_grab (gdk_device_get_seat (pointer), surface,
+ if (gdk_seat_grab (seat, surface,
GDK_SEAT_CAPABILITY_ALL, FALSE,
NULL, event, NULL, NULL) != GDK_GRAB_SUCCESS)
return NULL;
- priv->grab_pointer = pointer;
+ priv->grab_seat = seat;
editable = gtk_cell_editable_widget_new (cell, priv->accel_mode, path);
@@ -498,10 +499,10 @@ gtk_cell_renderer_accel_ungrab (GtkCellRendererAccel *accel)
{
GtkCellRendererAccelPrivate *priv = accel->priv;
- if (priv->grab_pointer)
+ if (priv->grab_seat)
{
- gdk_seat_ungrab (gdk_device_get_seat (priv->grab_pointer));
- priv->grab_pointer = NULL;
+ gdk_seat_ungrab (priv->grab_seat);
+ priv->grab_seat = NULL;
}
}