1997-11-24 22:37:52 +00:00
|
|
|
/* GDK - The GIMP Drawing Kit
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 11:33:08 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1997-11-24 22:37:52 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
2000-07-26 11:33:08 +00:00
|
|
|
* Lesser General Public License for more details.
|
1997-11-24 22:37:52 +00:00
|
|
|
*
|
2000-07-26 11:33:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1998-04-13 02:02:47 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
1997-11-24 22:37:52 +00:00
|
|
|
*/
|
|
|
|
|
2008-06-22 14:28:52 +00:00
|
|
|
#include "config.h"
|
1999-11-08 20:14:59 +00:00
|
|
|
#include "gdkinputprivate.h"
|
2002-04-25 22:29:14 +00:00
|
|
|
#include "gdkdisplay-x11.h"
|
2005-03-16 03:17:27 +00:00
|
|
|
#include "gdkalias.h"
|
1999-11-08 20:14:59 +00:00
|
|
|
|
1999-02-24 07:37:18 +00:00
|
|
|
/*
|
2000-07-26 11:33:08 +00:00
|
|
|
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:37:18 +00:00
|
|
|
* file for a list of people on the GTK+ Team. See the ChangeLog
|
|
|
|
* files for a list of changes. These files are distributed with
|
2009-05-29 14:39:12 +00:00
|
|
|
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
1999-02-24 07:37:18 +00:00
|
|
|
*/
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
/* forward declarations */
|
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
static void gdk_input_check_proximity (GdkDisplay *display);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
void
|
2002-04-25 22:29:14 +00:00
|
|
|
_gdk_input_init(GdkDisplay *display)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
Start implementing display/screen closing scheme; keep a flag for whether
Thu Aug 1 11:26:03 2002 Owen Taylor <otaylor@redhat.com>
* gdk/gdkdisplay.[ch] gdk/gdkscreen.[ch] gdkinternals.h:
Start implementing display/screen closing scheme; keep a
flag for whether displays and screens are closed,
call g_object_run_dispose(). Remove public gdk_screen_close().
* gdk/x11/gdkdisplay-x11.c gdk/x11/gdkscreen-x11.c: Add
dispose() methods; move appropriate parts of the finalize
there.
* gdk/x11/gdkcolor-x11.c gdk/x11/gdkimage-x11.c
gdk/x11/gdkmain-x11.c gdk/x11/gdkpango-x11.c
gdk/x11/gdkpixmap-x11.c gdk/x11/gdkproperty-x11.c
gdk/x11/gdkselection-x11.c gdk/x11/gdkwindow-x11.c:
Start of making everything correctly ignore operations
when a display has been closed.
* gdk/x11/gdkwindow-x11.c (gdk_window_get_decorations):
Handle decorations == NULL.
* gdk/x11/gdkcolor-x11.c (gdk_colormap_remove):
Remove unnecessary hash table creation.
* gdk/x11/gdkinput.c gdk/x11/gdkinput-x11.c gdk/win32/gdkinput.c
Fix up gdk_device_get_history - handle events, n_events == NULL,
etc.
* gdk/x11/gdkproperty-x11.c (gdk_property_get):
Handle failure better.
* gdk/x11/gdkselection-x11.c (gdk_selection_property_get):
Handle failure better, handle data == NULL, move docs
here, remove an excess round trip by asking for
all selection data at once.
* gdk/gdkselection.c gdk/win32/{x11,win32}/gdkselection-{x11,win32}.c
gdk/{x11,win32}/gdkmain-{x11,win32}.c gdk/gdkdisplay.c: Move
gdk_text_property_to_text_list(), gdk_string_to_compound_text(),
gdk_display_set_sm_client_id() to display-independent part of GDK.
* gdk/Makefile.am (gdk_c_sources): Sort gdkdisplay/screen.[ch]
into the right place.
2002-08-01 15:28:40 +00:00
|
|
|
_gdk_init_input_core (display);
|
2009-05-29 14:39:12 +00:00
|
|
|
display->ignore_core_events = FALSE;
|
2002-08-02 20:22:49 +00:00
|
|
|
_gdk_input_common_init (display, FALSE);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
gboolean
|
|
|
|
gdk_device_set_mode (GdkDevice *device,
|
|
|
|
GdkInputMode mode)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
|
|
|
GList *tmp_list;
|
|
|
|
GdkDevicePrivate *gdkdev;
|
|
|
|
GdkInputWindow *input_window;
|
2002-04-25 22:29:14 +00:00
|
|
|
GdkDisplayX11 *display_impl;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
if (GDK_IS_CORE (device))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
gdkdev = (GdkDevicePrivate *)device;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
if (device->mode == mode)
|
1997-11-24 22:37:52 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
device->mode = mode;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
if (mode == GDK_MODE_WINDOW)
|
2009-05-29 14:39:12 +00:00
|
|
|
device->has_cursor = FALSE;
|
1997-11-24 22:37:52 +00:00
|
|
|
else if (mode == GDK_MODE_SCREEN)
|
2009-05-29 14:39:12 +00:00
|
|
|
device->has_cursor = TRUE;
|
|
|
|
|
|
|
|
display_impl = GDK_DISPLAY_X11 (gdkdev->display);
|
|
|
|
for (tmp_list = display_impl->input_windows; tmp_list; tmp_list = tmp_list->next)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2009-05-29 14:39:12 +00:00
|
|
|
input_window = (GdkInputWindow *)tmp_list->data;
|
|
|
|
_gdk_input_select_events (input_window->impl_window, gdkdev);
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-04-25 22:29:14 +00:00
|
|
|
gdk_input_check_proximity (GdkDisplay *display)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2002-04-25 22:29:14 +00:00
|
|
|
GdkDisplayX11 *display_impl = GDK_DISPLAY_X11 (display);
|
|
|
|
GList *tmp_list = display_impl->input_devices;
|
2009-05-29 14:39:12 +00:00
|
|
|
gint new_proximity = 0;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
while (tmp_list && !new_proximity)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
|
|
|
GdkDevicePrivate *gdkdev = (GdkDevicePrivate *)(tmp_list->data);
|
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
if (gdkdev->info.mode != GDK_MODE_DISABLED
|
2000-07-03 19:00:23 +00:00
|
|
|
&& !GDK_IS_CORE (gdkdev)
|
1997-11-24 22:37:52 +00:00
|
|
|
&& gdkdev->xdevice)
|
|
|
|
{
|
2002-04-25 22:29:14 +00:00
|
|
|
XDeviceState *state = XQueryDeviceState(display_impl->xdisplay,
|
1997-11-24 22:37:52 +00:00
|
|
|
gdkdev->xdevice);
|
|
|
|
XInputClass *xic;
|
|
|
|
int i;
|
2009-05-29 14:39:12 +00:00
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
xic = state->data;
|
|
|
|
for (i=0; i<state->num_classes; i++)
|
|
|
|
{
|
|
|
|
if (xic->class == ValuatorClass)
|
|
|
|
{
|
|
|
|
XValuatorState *xvs = (XValuatorState *)xic;
|
|
|
|
if ((xvs->mode & ProximityState) == InProximity)
|
|
|
|
{
|
|
|
|
new_proximity = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
xic = (XInputClass *)((char *)xic + xic->length);
|
|
|
|
}
|
1999-11-10 17:15:58 +00:00
|
|
|
|
|
|
|
XFreeDeviceState (state);
|
2009-05-29 14:39:12 +00:00
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
display->ignore_core_events = new_proximity;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2000-07-03 19:00:23 +00:00
|
|
|
void
|
|
|
|
_gdk_input_configure_event (XConfigureEvent *xevent,
|
|
|
|
GdkWindow *window)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2009-05-29 14:39:12 +00:00
|
|
|
GdkWindowObject *priv = (GdkWindowObject *)window;
|
1997-11-24 22:37:52 +00:00
|
|
|
GdkInputWindow *input_window;
|
|
|
|
gint root_x, root_y;
|
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
input_window = priv->input_window;
|
|
|
|
if (input_window != NULL)
|
|
|
|
{
|
|
|
|
_gdk_input_get_root_relative_geometry (window, &root_x, &root_y);
|
|
|
|
input_window->root_x = root_x;
|
|
|
|
input_window->root_y = root_y;
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
void
|
|
|
|
_gdk_input_crossing_event (GdkWindow *window,
|
|
|
|
gboolean enter)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2009-05-29 14:39:12 +00:00
|
|
|
GdkDisplay *display = GDK_WINDOW_DISPLAY (window);
|
|
|
|
GdkDisplayX11 *display_impl = GDK_DISPLAY_X11 (display);
|
|
|
|
GdkWindowObject *priv = (GdkWindowObject *)window;
|
1997-11-24 22:37:52 +00:00
|
|
|
GdkInputWindow *input_window;
|
|
|
|
gint root_x, root_y;
|
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
if (enter)
|
|
|
|
{
|
|
|
|
gdk_input_check_proximity(display);
|
|
|
|
|
|
|
|
input_window = priv->input_window;
|
|
|
|
if (input_window != NULL)
|
|
|
|
{
|
|
|
|
_gdk_input_get_root_relative_geometry (window, &root_x, &root_y);
|
|
|
|
input_window->root_x = root_x;
|
|
|
|
input_window->root_y = root_y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
display->ignore_core_events = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GdkEventType
|
|
|
|
get_input_event_type (GdkDevicePrivate *gdkdev,
|
|
|
|
XEvent *xevent,
|
|
|
|
int *core_x, int *core_y)
|
|
|
|
{
|
|
|
|
if (xevent->type == gdkdev->buttonpress_type)
|
|
|
|
{
|
|
|
|
XDeviceButtonEvent *xie = (XDeviceButtonEvent *)(xevent);
|
|
|
|
*core_x = xie->x;
|
|
|
|
*core_y = xie->y;
|
|
|
|
return GDK_BUTTON_PRESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xevent->type == gdkdev->buttonrelease_type)
|
|
|
|
{
|
|
|
|
XDeviceButtonEvent *xie = (XDeviceButtonEvent *)(xevent);
|
|
|
|
*core_x = xie->x;
|
|
|
|
*core_y = xie->y;
|
|
|
|
return GDK_BUTTON_RELEASE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xevent->type == gdkdev->keypress_type)
|
|
|
|
{
|
|
|
|
XDeviceKeyEvent *xie = (XDeviceKeyEvent *)(xevent);
|
|
|
|
*core_x = xie->x;
|
|
|
|
*core_y = xie->y;
|
|
|
|
return GDK_KEY_PRESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xevent->type == gdkdev->keyrelease_type)
|
|
|
|
{
|
|
|
|
XDeviceKeyEvent *xie = (XDeviceKeyEvent *)(xevent);
|
|
|
|
*core_x = xie->x;
|
|
|
|
*core_y = xie->y;
|
|
|
|
return GDK_KEY_RELEASE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (xevent->type == gdkdev->motionnotify_type)
|
|
|
|
{
|
|
|
|
XDeviceMotionEvent *xie = (XDeviceMotionEvent *)(xevent);
|
|
|
|
*core_x = xie->x;
|
|
|
|
*core_y = xie->y;
|
|
|
|
return GDK_MOTION_NOTIFY;
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
if (xevent->type == gdkdev->proximityin_type)
|
|
|
|
{
|
|
|
|
XProximityNotifyEvent *xie = (XProximityNotifyEvent *)(xevent);
|
|
|
|
*core_x = xie->x;
|
|
|
|
*core_y = xie->y;
|
|
|
|
return GDK_PROXIMITY_IN;
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
if (xevent->type == gdkdev->proximityout_type)
|
|
|
|
{
|
|
|
|
XProximityNotifyEvent *xie = (XProximityNotifyEvent *)(xevent);
|
|
|
|
*core_x = xie->x;
|
|
|
|
*core_y = xie->y;
|
|
|
|
return GDK_PROXIMITY_OUT;
|
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
*core_x = 0;
|
|
|
|
*core_y = 0;
|
|
|
|
return GDK_NOTHING;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
_gdk_input_other_event (GdkEvent *event,
|
|
|
|
XEvent *xevent,
|
|
|
|
GdkWindow *event_window)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2009-05-29 14:39:12 +00:00
|
|
|
GdkWindow *window;
|
|
|
|
GdkWindowObject *priv;
|
|
|
|
GdkInputWindow *iw;
|
1997-11-24 22:37:52 +00:00
|
|
|
GdkDevicePrivate *gdkdev;
|
|
|
|
gint return_val;
|
2009-05-29 14:39:12 +00:00
|
|
|
GdkEventType event_type;
|
|
|
|
int x, y;
|
|
|
|
GdkDisplay *display = GDK_WINDOW_DISPLAY (event_window);
|
|
|
|
GdkDisplayX11 *display_impl = GDK_DISPLAY_X11 (display);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
|
|
|
/* This is a sort of a hack, as there isn't any XDeviceAnyEvent -
|
|
|
|
but it's potentially faster than scanning through the types of
|
|
|
|
every device. If we were deceived, then it won't match any of
|
|
|
|
the types for the device anyways */
|
2009-05-29 14:39:12 +00:00
|
|
|
gdkdev = _gdk_input_find_device (display,
|
2002-08-02 20:22:49 +00:00
|
|
|
((XDeviceButtonEvent *)xevent)->deviceid);
|
2000-07-03 19:00:23 +00:00
|
|
|
if (!gdkdev)
|
2003-03-08 21:11:39 +00:00
|
|
|
return FALSE; /* we don't handle it - not an XInput event */
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
event_type = get_input_event_type (gdkdev, xevent, &x, &y);
|
|
|
|
if (event_type == GDK_NOTHING)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
window = _gdk_window_get_input_window_for_event (event_window,
|
|
|
|
event_type,
|
|
|
|
x, y,
|
|
|
|
xevent->xany.serial);
|
|
|
|
/* If we're not getting any event window its likely because we're outside the
|
|
|
|
window and there is no grab. We should still report according to the
|
|
|
|
implicit grab though. */
|
|
|
|
iw = ((GdkWindowObject *)event_window)->input_window;
|
|
|
|
if (window == NULL)
|
|
|
|
window = iw->button_down_window;
|
|
|
|
|
|
|
|
priv = (GdkWindowObject *)window;
|
|
|
|
if (window == NULL)
|
|
|
|
return FALSE;
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
if (gdkdev->info.mode == GDK_MODE_DISABLED ||
|
2009-05-29 14:39:12 +00:00
|
|
|
!(gdkdev->info.has_cursor || (priv->extension_events & GDK_ALL_DEVICES_MASK)))
|
1997-11-24 22:37:52 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
if (!display->ignore_core_events && priv->extension_events != 0)
|
|
|
|
gdk_input_check_proximity (GDK_WINDOW_DISPLAY (window));
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
return_val = _gdk_input_common_other_event (event, xevent, window, gdkdev);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
if (return_val && event->type == GDK_BUTTON_PRESS)
|
|
|
|
iw->button_down_window = window;
|
|
|
|
if (return_val && event->type == GDK_BUTTON_RELEASE)
|
|
|
|
iw->button_down_window = NULL;
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
if (return_val && event->type == GDK_PROXIMITY_OUT &&
|
|
|
|
display->ignore_core_events)
|
|
|
|
gdk_input_check_proximity (GDK_WINDOW_DISPLAY (window));
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
return return_val;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
gint
|
|
|
|
_gdk_input_grab_pointer (GdkWindow *window,
|
|
|
|
GdkWindow *native_window, /* This is the toplevel */
|
2000-07-03 19:00:23 +00:00
|
|
|
gint owner_events,
|
|
|
|
GdkEventMask event_mask,
|
|
|
|
GdkWindow * confine_to,
|
|
|
|
guint32 time)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2009-05-29 14:39:12 +00:00
|
|
|
GdkInputWindow *input_window;
|
|
|
|
GdkWindowObject *priv, *impl_window;
|
1998-09-05 21:22:51 +00:00
|
|
|
gboolean need_ungrab;
|
1997-11-24 22:37:52 +00:00
|
|
|
GdkDevicePrivate *gdkdev;
|
|
|
|
GList *tmp_list;
|
1997-12-18 02:17:14 +00:00
|
|
|
XEventClass event_classes[GDK_MAX_DEVICE_CLASSES];
|
1997-11-24 22:37:52 +00:00
|
|
|
gint num_classes;
|
1997-12-18 02:17:14 +00:00
|
|
|
gint result;
|
2002-04-25 22:29:14 +00:00
|
|
|
GdkDisplayX11 *display_impl = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (window));
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
tmp_list = display_impl->input_windows;
|
1998-09-05 21:22:51 +00:00
|
|
|
need_ungrab = FALSE;
|
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
input_window = (GdkInputWindow *)tmp_list->data;
|
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
if (input_window->grabbed)
|
1998-09-05 21:22:51 +00:00
|
|
|
{
|
|
|
|
input_window->grabbed = FALSE;
|
|
|
|
need_ungrab = TRUE;
|
2009-05-29 14:39:12 +00:00
|
|
|
break;
|
1998-09-05 21:22:51 +00:00
|
|
|
}
|
1997-11-24 22:37:52 +00:00
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
priv = (GdkWindowObject *)window;
|
|
|
|
impl_window = (GdkWindowObject *)_gdk_window_get_impl_window (window);
|
|
|
|
input_window = impl_window->input_window;
|
|
|
|
if (priv->extension_events)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2009-05-29 14:39:12 +00:00
|
|
|
g_assert (input_window != NULL);
|
|
|
|
input_window->grabbed = TRUE;
|
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
tmp_list = display_impl->input_devices;
|
1998-09-05 21:22:51 +00:00
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
2000-07-03 19:00:23 +00:00
|
|
|
if (!GDK_IS_CORE (gdkdev) && gdkdev->xdevice)
|
1998-09-05 21:22:51 +00:00
|
|
|
{
|
2009-05-29 14:39:12 +00:00
|
|
|
_gdk_input_common_find_events (gdkdev, event_mask,
|
2002-08-02 20:22:49 +00:00
|
|
|
event_classes, &num_classes);
|
2001-12-11 01:08:33 +00:00
|
|
|
#ifdef G_ENABLE_DEBUG
|
|
|
|
if (_gdk_debug_flags & GDK_DEBUG_NOGRABS)
|
|
|
|
result = GrabSuccess;
|
|
|
|
else
|
|
|
|
#endif
|
2002-04-25 22:29:14 +00:00
|
|
|
result = XGrabDevice (display_impl->xdisplay, gdkdev->xdevice,
|
2009-05-29 14:39:12 +00:00
|
|
|
GDK_WINDOW_XWINDOW (native_window),
|
2001-12-11 01:08:33 +00:00
|
|
|
owner_events, num_classes, event_classes,
|
|
|
|
GrabModeAsync, GrabModeAsync, time);
|
2009-05-29 14:39:12 +00:00
|
|
|
|
1998-09-05 21:22:51 +00:00
|
|
|
/* 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
|
2009-05-29 14:39:12 +00:00
|
|
|
{
|
2002-04-25 22:29:14 +00:00
|
|
|
tmp_list = display_impl->input_devices;
|
1998-09-05 21:22:51 +00:00
|
|
|
while (tmp_list)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
1998-09-05 21:22:51 +00:00
|
|
|
gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
2000-07-03 19:00:23 +00:00
|
|
|
if (!GDK_IS_CORE (gdkdev) && gdkdev->xdevice &&
|
1998-09-05 21:22:51 +00:00
|
|
|
((gdkdev->button_state != 0) || need_ungrab))
|
|
|
|
{
|
2002-04-25 22:29:14 +00:00
|
|
|
XUngrabDevice (display_impl->xdisplay, gdkdev->xdevice, time);
|
1998-09-05 21:22:51 +00:00
|
|
|
gdkdev->button_state = 0;
|
|
|
|
}
|
2009-05-29 14:39:12 +00:00
|
|
|
|
1998-09-05 21:22:51 +00:00
|
|
|
tmp_list = tmp_list->next;
|
1997-11-24 22:37:52 +00:00
|
|
|
}
|
|
|
|
}
|
1998-09-05 21:22:51 +00:00
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
return Success;
|
|
|
|
}
|
|
|
|
|
2009-05-29 14:39:12 +00:00
|
|
|
void
|
|
|
|
_gdk_input_ungrab_pointer (GdkDisplay *display,
|
2002-04-25 22:29:14 +00:00
|
|
|
guint32 time)
|
1997-11-24 22:37:52 +00:00
|
|
|
{
|
2000-07-06 16:20:45 +00:00
|
|
|
GdkInputWindow *input_window = NULL; /* Quiet GCC */
|
1997-11-24 22:37:52 +00:00
|
|
|
GdkDevicePrivate *gdkdev;
|
|
|
|
GList *tmp_list;
|
2002-04-25 22:29:14 +00:00
|
|
|
GdkDisplayX11 *display_impl = GDK_DISPLAY_X11 (display);
|
1997-11-24 22:37:52 +00:00
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
tmp_list = display_impl->input_windows;
|
1997-11-24 22:37:52 +00:00
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
input_window = (GdkInputWindow *)tmp_list->data;
|
|
|
|
if (input_window->grabbed)
|
|
|
|
break;
|
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tmp_list) /* we found a grabbed window */
|
|
|
|
{
|
|
|
|
input_window->grabbed = FALSE;
|
|
|
|
|
2002-04-25 22:29:14 +00:00
|
|
|
tmp_list = display_impl->input_devices;
|
1997-11-24 22:37:52 +00:00
|
|
|
while (tmp_list)
|
|
|
|
{
|
|
|
|
gdkdev = (GdkDevicePrivate *)tmp_list->data;
|
2000-07-03 19:00:23 +00:00
|
|
|
if (!GDK_IS_CORE (gdkdev) && gdkdev->xdevice)
|
2002-04-25 22:29:14 +00:00
|
|
|
XUngrabDevice( display_impl->xdisplay, gdkdev->xdevice, time);
|
1997-12-18 02:17:14 +00:00
|
|
|
|
1997-11-24 22:37:52 +00:00
|
|
|
tmp_list = tmp_list->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2000-07-03 19:00:23 +00:00
|
|
|
|
2005-04-10 01:01:18 +00:00
|
|
|
#define __GDK_INPUT_XFREE_C__
|
2005-03-16 04:35:33 +00:00
|
|
|
#include "gdkaliasdef.c"
|