summaryrefslogtreecommitdiff
path: root/eel
diff options
context:
space:
mode:
authorErnestas Kulik <ernestask@src.gnome.org>2016-04-17 20:12:02 +0300
committerErnestas Kulik <ernestask@src.gnome.org>2016-05-03 12:57:29 +0300
commit225f2cf768c745fe13c9d7e90d340fd2a15d6c5b (patch)
treec7e8ea817760c3dd90b01d29c06561a483c658a9 /eel
parent3cc3e7575315f99665abd96e988762b06fec760b (diff)
downloadnautilus-225f2cf768c745fe13c9d7e90d340fd2a15d6c5b.tar.gz
eel-canvas: use GdkSeat operations
Some GdkDisplay operations have been deprecated in GDK 3.20. This commit replaces the deprecated code in eel_canvas_item_grab() and eel_canvas_item_ungrab() functions with new GdkSeat operations. https://bugzilla.gnome.org/show_bug.cgi?id=762235
Diffstat (limited to 'eel')
-rw-r--r--eel/eel-canvas.c83
-rw-r--r--eel/eel-canvas.h15
2 files changed, 46 insertions, 52 deletions
diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c
index 45f3665e4..0cd3b1ab2 100644
--- a/eel/eel-canvas.c
+++ b/eel/eel-canvas.c
@@ -311,7 +311,7 @@ eel_canvas_item_dispose (GObject *object)
item->canvas->need_repick = TRUE;
}
- eel_canvas_item_ungrab (item, GDK_CURRENT_TIME);
+ eel_canvas_item_ungrab (item);
if (item == item->canvas->focused_item)
item->canvas->focused_item = NULL;
@@ -824,34 +824,42 @@ eel_canvas_item_hide (EelCanvasItem *item)
}
+/*
+ * Prepare the window for grabbing, i.e. show it.
+ */
+static void
+seat_grab_prepare_window (GdkSeat *seat,
+ GdkWindow *window,
+ gpointer user_data)
+{
+ gdk_window_show (window);
+}
+
/**
* eel_canvas_item_grab:
* @item: A canvas item.
* @event_mask: Mask of events that will be sent to this item.
* @cursor: If non-NULL, the cursor that will be used while the grab is active.
- * @etime: The timestamp required for grabbing the mouse, or GDK_CURRENT_TIME.
+ * @event: The event, triggering the grab, if any.
*
* Specifies that all events that match the specified event mask should be sent
- * to the specified item, and also grabs the mouse by calling
- * gdk_pointer_grab(). The event mask is also used when grabbing the pointer.
+ * to the specified item, and also grabs the seat by calling gdk_seat_grab().
* If @cursor is not NULL, then that cursor is used while the grab is active.
- * The @etime parameter is the timestamp required for grabbing the mouse.
*
- * Return value: If an item was already grabbed, it returns %GDK_GRAB_ALREADY_GRABBED. If
+ * Return value: If an item was already grabbed, it returns %GDK_GRAB_ALREADY_GRABBED. If
* the specified item was hidden by calling eel_canvas_item_hide(), then it
- * returns %GDK_GRAB_NOT_VIEWABLE. Else, it returns the result of calling
- * gdk_pointer_grab().
+ * returns %GDK_GRAB_NOT_VIEWABLE. Else, it returns the result of calling
+ * gdk_seat_grab().
**/
GdkGrabStatus
eel_canvas_item_grab (EelCanvasItem *item,
GdkEventMask event_mask,
GdkCursor *cursor,
- guint32 timestamp)
+ const GdkEvent *event)
{
GdkGrabStatus retval;
GdkDisplay *display;
- GdkDeviceManager *manager;
- GdkDevice *device;
+ GdkSeat *seat;
g_return_val_if_fail (EEL_IS_CANVAS_ITEM (item), GDK_GRAB_NOT_VIEWABLE);
g_return_val_if_fail (gtk_widget_get_mapped (GTK_WIDGET (item->canvas)),
@@ -864,16 +872,16 @@ eel_canvas_item_grab (EelCanvasItem *item,
return GDK_GRAB_NOT_VIEWABLE;
display = gtk_widget_get_display (GTK_WIDGET (item->canvas));
- manager = gdk_display_get_device_manager (display);
- device = gdk_device_manager_get_client_pointer (manager);
+ seat = gdk_display_get_default_seat (display);
- retval = gdk_device_grab (device,
- gtk_layout_get_bin_window (GTK_LAYOUT (item->canvas)),
- GDK_OWNERSHIP_NONE,
- FALSE,
- event_mask,
- cursor,
- timestamp);
+ retval = gdk_seat_grab (seat,
+ gtk_layout_get_bin_window (GTK_LAYOUT (item->canvas)),
+ GDK_SEAT_CAPABILITY_ALL_POINTING,
+ FALSE,
+ cursor,
+ event,
+ seat_grab_prepare_window,
+ NULL);
if (retval != GDK_GRAB_SUCCESS)
return retval;
@@ -889,17 +897,15 @@ eel_canvas_item_grab (EelCanvasItem *item,
/**
* eel_canvas_item_ungrab:
* @item: A canvas item that holds a grab.
- * @etime: The timestamp for ungrabbing the mouse.
*
* Ungrabs the item, which must have been grabbed in the canvas, and ungrabs the
- * mouse.
+ * seat.
**/
void
-eel_canvas_item_ungrab (EelCanvasItem *item, guint32 etime)
+eel_canvas_item_ungrab (EelCanvasItem *item)
{
GdkDisplay *display;
- GdkDeviceManager *manager;
- GdkDevice *device;
+ GdkSeat *seat;
g_return_if_fail (EEL_IS_CANVAS_ITEM (item));
@@ -907,11 +913,10 @@ eel_canvas_item_ungrab (EelCanvasItem *item, guint32 etime)
return;
display = gtk_widget_get_display (GTK_WIDGET (item->canvas));
- manager = gdk_display_get_device_manager (display);
- device = gdk_device_manager_get_client_pointer (manager);
+ seat = gdk_display_get_default_seat (display);
item->canvas->grabbed_item = NULL;
- gdk_device_ungrab (device, etime);
+ gdk_seat_ungrab (seat);
}
/**
@@ -2034,7 +2039,7 @@ shutdown_transients (EelCanvas *canvas)
}
if (canvas->grabbed_item) {
- eel_canvas_item_ungrab (canvas->grabbed_item, GDK_CURRENT_TIME);
+ eel_canvas_item_ungrab (canvas->grabbed_item);
}
remove_idle (canvas);
@@ -2393,30 +2398,20 @@ emit_event (EelCanvas *canvas, GdkEvent *event)
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
eel_canvas_window_to_world (canvas,
- ev.crossing.x, ev.crossing.y,
- &ev.crossing.x, &ev.crossing.y);
+ ev.crossing.x, ev.crossing.y,
+ &ev.crossing.x, &ev.crossing.y);
break;
case GDK_MOTION_NOTIFY:
- eel_canvas_window_to_world (canvas,
- ev.motion.x, ev.motion.y,
- &ev.motion.x, &ev.motion.y);
- break;
-
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
+ case GDK_BUTTON_RELEASE:
eel_canvas_window_to_world (canvas,
- ev.motion.x, ev.motion.y,
- &ev.motion.x, &ev.motion.y);
+ ev.motion.x, ev.motion.y,
+ &ev.motion.x, &ev.motion.y);
break;
- case GDK_BUTTON_RELEASE:
- eel_canvas_window_to_world (canvas,
- ev.motion.x, ev.motion.y,
- &ev.motion.x, &ev.motion.y);
- break;
-
default:
break;
}
diff --git a/eel/eel-canvas.h b/eel/eel-canvas.h
index adff7f773..5758c1bde 100644
--- a/eel/eel-canvas.h
+++ b/eel/eel-canvas.h
@@ -239,20 +239,19 @@ void eel_canvas_item_show (EelCanvasItem *item);
*/
void eel_canvas_item_hide (EelCanvasItem *item);
-/* Grab the mouse for the specified item. Only the events in event_mask will be
- * reported. If cursor is non-NULL, it will be used during the duration of the
- * grab. Time is a proper X event time parameter. Returns the same values as
- * XGrabPointer().
+/* Grab the seat for the specified item. Only the events in event_mask will be
+ * reported. If cursor is non-NULL, it will be used during the duration of the
+ * grab. event is the event, triggering the grab. Returns the same values as gdk_seat_grab().
*/
GdkGrabStatus eel_canvas_item_grab (EelCanvasItem *item,
GdkEventMask event_mask,
GdkCursor *cursor,
- guint32 etime);
+ const GdkEvent* event);
-/* Ungrabs the mouse -- the specified item must be the same that was passed to
- * eel_canvas_item_grab(). Time is a proper X event time parameter.
+/* Ungrabs the seat -- the specified item must be the same that was passed to
+ * eel_canvas_item_grab().
*/
-void eel_canvas_item_ungrab (EelCanvasItem *item, guint32 etime);
+void eel_canvas_item_ungrab (EelCanvasItem *item);
/* These functions convert from a coordinate system to another. "w" is world
* coordinates and "i" is item coordinates.