summaryrefslogtreecommitdiff
path: root/eel
diff options
context:
space:
mode:
Diffstat (limited to 'eel')
-rw-r--r--eel/eel-canvas.c56
-rw-r--r--eel/eel-canvas.h7
2 files changed, 62 insertions, 1 deletions
diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c
index 55d983c8..1e45224d 100644
--- a/eel/eel-canvas.c
+++ b/eel/eel-canvas.c
@@ -341,12 +341,16 @@ eel_canvas_item_dispose (GObject *object)
item->canvas->need_repick = TRUE;
}
+#if GTK_CHECK_VERSION(3, 0, 0)
+ eel_canvas_item_ungrab (item, GDK_CURRENT_TIME);
+#else
if (item == item->canvas->grabbed_item)
{
GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (item->canvas));
item->canvas->grabbed_item = NULL;
gdk_display_pointer_ungrab (display, GDK_CURRENT_TIME);
}
+#endif
if (item == item->canvas->focused_item)
item->canvas->focused_item = NULL;
@@ -888,6 +892,40 @@ eel_canvas_item_hide (EelCanvasItem *item)
* returns %GDK_GRAB_NOT_VIEWABLE. Else, it returns the result of calling
* gdk_pointer_grab().
**/
+#if GTK_CHECK_VERSION(3, 0, 0)
+GdkGrabStatus
+eel_canvas_item_grab (EelCanvasItem *item,
+ GdkEventMask event_mask,
+ GdkCursor *cursor,
+ guint32 timestamp)
+{
+ GdkGrabStatus retval;
+ GdkDisplay *display;
+ GdkDeviceManager *manager;
+ GdkDevice *device;
+
+ 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)),
+ GDK_GRAB_NOT_VIEWABLE);
+
+ if (item->canvas->grabbed_item)
+ return GDK_GRAB_ALREADY_GRABBED;
+
+ if (!(item->flags & EEL_CANVAS_ITEM_MAPPED))
+ 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);
+
+ retval = gdk_device_grab (device,
+ gtk_layout_get_bin_window (GTK_LAYOUT (item->canvas)),
+ GDK_OWNERSHIP_NONE,
+ FALSE,
+ event_mask,
+ cursor,
+ timestamp);
+#else
int
eel_canvas_item_grab (EelCanvasItem *item, guint event_mask, GdkCursor *cursor, guint32 etime)
{
@@ -909,6 +947,7 @@ eel_canvas_item_grab (EelCanvasItem *item, guint event_mask, GdkCursor *cursor,
NULL,
cursor,
etime);
+#endif
if (retval != GDK_GRAB_SUCCESS)
return retval;
@@ -933,6 +972,10 @@ void
eel_canvas_item_ungrab (EelCanvasItem *item, guint32 etime)
{
GdkDisplay *display;
+#if GTK_CHECK_VERSION(3, 0, 0)
+ GdkDeviceManager *manager;
+ GdkDevice *device;
+#endif
g_return_if_fail (EEL_IS_CANVAS_ITEM (item));
@@ -940,11 +983,18 @@ eel_canvas_item_ungrab (EelCanvasItem *item, guint32 etime)
return;
display = gtk_widget_get_display (GTK_WIDGET (item->canvas));
+#if GTK_CHECK_VERSION(3, 0, 0)
+ manager = gdk_display_get_device_manager (display);
+ device = gdk_device_manager_get_client_pointer (manager);
+
+ item->canvas->grabbed_item = NULL;
+ gdk_device_ungrab (device, etime);
+#else
item->canvas->grabbed_item = NULL;
gdk_display_pointer_ungrab (display, etime);
+#endif
}
-
/**
* eel_canvas_item_w2i:
* @item: A canvas item.
@@ -2274,9 +2324,13 @@ shutdown_transients (EelCanvas *canvas)
if (canvas->grabbed_item)
{
+#if GTK_CHECK_VERSION(3, 0, 0)
+ eel_canvas_item_ungrab (canvas->grabbed_item, GDK_CURRENT_TIME);
+#else
GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (canvas));
canvas->grabbed_item = NULL;
gdk_display_pointer_ungrab (display, GDK_CURRENT_TIME);
+#endif
}
remove_idle (canvas);
diff --git a/eel/eel-canvas.h b/eel/eel-canvas.h
index 6aa227e0..f641087a 100644
--- a/eel/eel-canvas.h
+++ b/eel/eel-canvas.h
@@ -255,8 +255,15 @@ extern "C" {
* grab. Time is a proper X event time parameter. Returns the same values as
* XGrabPointer().
*/
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkGrabStatus eel_canvas_item_grab (EelCanvasItem *item,
+ GdkEventMask event_mask,
+ GdkCursor *cursor,
+ guint32 etime);
+#else
int eel_canvas_item_grab (EelCanvasItem *item, unsigned int event_mask,
GdkCursor *cursor, guint32 etime);
+#endif
/* 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.