summaryrefslogtreecommitdiff
path: root/gdk/gdkinputxfree.h
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@gtk.org>1998-09-05 21:22:51 +0000
committerOwen Taylor <otaylor@src.gnome.org>1998-09-05 21:22:51 +0000
commit51021f88c5cd7b202b15b8cc81010502dd7e082d (patch)
tree43b17f136ecf321c8e4bbd06c61c377bf1cb9692 /gdk/gdkinputxfree.h
parent78dbc1efdb39a1f70ea0782f1042187695a79bf7 (diff)
downloadgdk-pixbuf-51021f88c5cd7b202b15b8cc81010502dd7e082d.tar.gz
When the pointer is grabbed on an input window, either explicitely, or
Sat Sep 5 16:01:19 1998 Owen Taylor <otaylor@gtk.org> * gdk/gdkinputxfree.h gdk/gdk.c gdk/gdkinputgxi.h: When the pointer is grabbed on an input window, either explicitely, or through press-grab, and then grabbed on a non-input window, ungrab the devices.
Diffstat (limited to 'gdk/gdkinputxfree.h')
-rw-r--r--gdk/gdkinputxfree.h78
1 files changed, 51 insertions, 27 deletions
diff --git a/gdk/gdkinputxfree.h b/gdk/gdkinputxfree.h
index c0411a4fe..997fdd207 100644
--- a/gdk/gdkinputxfree.h
+++ b/gdk/gdkinputxfree.h
@@ -257,6 +257,7 @@ gdk_input_xfree_grab_pointer (GdkWindow * window,
guint32 time)
{
GdkInputWindow *input_window, *new_window;
+ gboolean need_ungrab;
GdkDevicePrivate *gdkdev;
GList *tmp_list;
XEventClass event_classes[GDK_MAX_DEVICE_CLASSES];
@@ -265,47 +266,70 @@ gdk_input_xfree_grab_pointer (GdkWindow * window,
tmp_list = gdk_input_windows;
new_window = NULL;
+ need_ungrab = FALSE;
+
while (tmp_list)
{
input_window = (GdkInputWindow *)tmp_list->data;
- if (input_window->grabbed)
- return AlreadyGrabbed;
if (input_window->window == window)
new_window = input_window;
-
+ else if (input_window->grabbed)
+ {
+ input_window->grabbed = FALSE;
+ need_ungrab = TRUE;
+ }
+
tmp_list = tmp_list->next;
}
-
- g_return_val_if_fail (new_window != NULL, Success); /* shouldn't happen */
-
- new_window->grabbed = TRUE;
- tmp_list = gdk_input_devices;
- while (tmp_list)
+ if (new_window)
{
- gdkdev = (GdkDevicePrivate *)tmp_list->data;
- if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
- gdkdev->xdevice)
+ new_window->grabbed = TRUE;
+
+ tmp_list = gdk_input_devices;
+ while (tmp_list)
+ {
+ gdkdev = (GdkDevicePrivate *)tmp_list->data;
+ if (gdkdev->info.deviceid != GDK_CORE_POINTER &&
+ gdkdev->xdevice)
+ {
+ gdk_input_common_find_events (window, gdkdev,
+ event_mask,
+ event_classes, &num_classes);
+
+ result = XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
+ GDK_WINDOW_XWINDOW (window),
+ owner_events, num_classes, event_classes,
+ GrabModeAsync, GrabModeAsync, time);
+
+ /* FIXME: if failure occurs on something other than the first
+ device, things will be badly inconsistent */
+ if (result != Success)
+ return result;
+ }
+ tmp_list = tmp_list->next;
+ }
+ }
+ else
+ {
+ tmp_list = gdk_input_devices;
+ while (tmp_list)
{
- gdk_input_common_find_events (window, gdkdev,
- event_mask,
- event_classes, &num_classes);
-
- result = XGrabDevice( GDK_DISPLAY(), gdkdev->xdevice,
- GDK_WINDOW_XWINDOW (window),
- owner_events, num_classes, event_classes,
- GrabModeAsync, GrabModeAsync, time);
-
- /* FIXME: if failure occurs on something other than the first
- device, things will be badly inconsistent */
- if (result != Success)
- return result;
+ gdkdev = (GdkDevicePrivate *)tmp_list->data;
+ if (gdkdev->info.deviceid != GDK_CORE_POINTER && gdkdev->xdevice &&
+ ((gdkdev->button_state != 0) || need_ungrab))
+ {
+ XUngrabDevice( gdk_display, gdkdev->xdevice, time);
+ gdkdev->button_state = 0;
+ }
+
+ tmp_list = tmp_list->next;
}
- tmp_list = tmp_list->next;
}
-
+
return Success;
+
}
static void