Move implicit grab tracking totally to common code

This commit is contained in:
Alexander Larsson 2009-02-02 14:57:08 +01:00 committed by Alexander Larsson
parent d6ad734c7f
commit 5be3f38535
6 changed files with 21 additions and 84 deletions

View File

@ -808,7 +808,6 @@ _gdk_display_add_pointer_grab (GdkDisplay *display,
info->event_mask = event_mask;
info->time = time;
info->implicit = implicit;
info->converted_implicit = FALSE;
/* Find the first grab that has a larger start time (if any) and insert
* before that. I.E we insert after already existing grabs with same

View File

@ -180,7 +180,6 @@ typedef struct
gboolean owner_events;
guint event_mask;
gboolean implicit;
gboolean converted_implicit;
guint32 time;
gboolean activated;

View File

@ -8305,6 +8305,12 @@ proxy_pointer_event (GdkDisplay *display,
return TRUE;
}
#define GDK_ANY_BUTTON_MASK (GDK_BUTTON1_MASK | \
GDK_BUTTON2_MASK | \
GDK_BUTTON3_MASK | \
GDK_BUTTON4_MASK | \
GDK_BUTTON5_MASK)
static gboolean
proxy_button_event (GdkEvent *source_event,
gulong serial)
@ -8319,7 +8325,6 @@ proxy_button_event (GdkEvent *source_event,
gdouble toplevel_x, toplevel_y;
GdkDisplay *display;
GdkWindowObject *w;
GdkPointerGrabInfo *grab;
type = source_event->any.type;
toplevel_window = source_event->any.window;
@ -8328,18 +8333,15 @@ proxy_button_event (GdkEvent *source_event,
time_ = gdk_event_get_time (source_event);
display = gdk_drawable_get_display (source_event->any.window);
grab = _gdk_display_get_active_pointer_grab (display);
if ((type == GDK_BUTTON_PRESS || type == GDK_SCROLL) &&
grab && grab->window == toplevel_window &&
grab->implicit && !grab->converted_implicit)
if (type == GDK_BUTTON_PRESS &&
_gdk_display_has_pointer_grab (display, serial) == NULL)
{
pointer_window =
_gdk_window_find_descendant_at (toplevel_window,
toplevel_x, toplevel_y,
NULL, NULL);
/* Find the actual event window, its what gets the grab */
/* Find the event window, that gets the grab */
w = (GdkWindowObject *)pointer_window;
while (w != NULL && w->parent->window_type != GDK_WINDOW_ROOT)
{
@ -8349,16 +8351,15 @@ proxy_button_event (GdkEvent *source_event,
}
pointer_window = (GdkWindow *)w;
if (pointer_window != NULL &&
pointer_window != toplevel_window)
{
g_object_ref (pointer_window);
g_object_unref (grab->window);
grab->window = pointer_window;
grab->event_mask = gdk_window_get_events (pointer_window);
}
grab->converted_implicit = TRUE;
_gdk_display_add_pointer_grab (display,
pointer_window,
toplevel_window,
FALSE,
gdk_window_get_events (pointer_window),
serial,
time_,
TRUE);
_gdk_display_pointer_grab_update (display, serial);
}
pointer_window = get_pointer_window (display, toplevel_window,
@ -8577,9 +8578,9 @@ _gdk_windowing_got_event (GdkDisplay *display,
button_release_grab =
_gdk_display_has_pointer_grab (display, serial);
if (button_release_grab &&
button_release_grab->grab_one_pointer_release_event)
button_release_grab->implicit &&
(event->button.state & GDK_ANY_BUTTON_MASK & ~(GDK_BUTTON1_MASK << (event->button.button - 1))) == 0)
{
button_release_grab->grab_one_pointer_release_event = FALSE;
button_release_grab->serial_end = serial;
button_release_grab->implicit_ungrab = TRUE;
_gdk_display_pointer_grab_update (display, serial);

View File

@ -1192,15 +1192,6 @@ gdk_event_translate (GdkDisplay *display,
set_user_time (window, event);
/* We treat button presses as scroll wheel events, so don't expose
* this grab to gtk, as it will be immediately released. If we do
* expose it there is a short time before we receive the Release
* where a client-side generated pointer motion event could be handled
* as if the grab was effect.
*/
if (!(xevent->xbutton.button == 4 || xevent->xbutton.button == 5 ||
xevent->xbutton.button == 6 || xevent->xbutton.button == 7))
_gdk_xgrab_check_button_event (window, xevent);
break;
case ButtonRelease:
@ -1241,8 +1232,6 @@ gdk_event_translate (GdkDisplay *display,
if (!set_screen_from_root (display, event, xevent->xbutton.root))
return_val = FALSE;
_gdk_xgrab_check_button_event (window, xevent);
break;
case MotionNotify:

View File

@ -436,55 +436,6 @@ _gdk_xgrab_check_destroy (GdkWindow *window)
_gdk_display_unset_has_keyboard_grab (display, TRUE);
}
#define GDK_ANY_BUTTON_MASK (GDK_BUTTON1_MASK | \
GDK_BUTTON2_MASK | \
GDK_BUTTON3_MASK | \
GDK_BUTTON4_MASK | \
GDK_BUTTON5_MASK)
/**
* _gdk_xgrab_check_button_event:
* @window: a #GdkWindow
* @event: an XEvent of type ButtonPress or ButtonRelease
*
* Checks to see if a button event starts or ends an implicit grab.
**/
void
_gdk_xgrab_check_button_event (GdkWindow *window,
XEvent *xevent)
{
GdkDisplay *display = gdk_drawable_get_display (window);
gulong serial = xevent->xany.serial;
GdkPointerGrabInfo *grab;
/* track implicit grabs for button presses */
switch (xevent->type)
{
case ButtonPress:
if (!_gdk_display_has_pointer_grab (display, serial))
{
_gdk_display_add_pointer_grab (display,
window,
window,
FALSE,
gdk_window_get_events (window),
serial,
xevent->xbutton.time,
TRUE);
}
break;
case ButtonRelease:
serial = serial;
grab = _gdk_display_has_pointer_grab (display, serial);
if (grab && grab->implicit &&
(xevent->xbutton.state & GDK_ANY_BUTTON_MASK & ~(GDK_BUTTON1_MASK << (xevent->xbutton.button - 1))) == 0)
grab->grab_one_pointer_release_event = TRUE;
break;
default:
g_assert_not_reached ();
}
}
void
_gdk_windowing_display_set_sm_client_id (GdkDisplay *display,
const gchar *sm_client_id)

View File

@ -164,8 +164,6 @@ void _gdk_x11_initialize_locale (void);
void _gdk_xgrab_check_unmap (GdkWindow *window,
gulong serial);
void _gdk_xgrab_check_destroy (GdkWindow *window);
void _gdk_xgrab_check_button_event (GdkWindow *window,
XEvent *xevent);
gboolean _gdk_x11_display_is_root_window (GdkDisplay *display,
Window xroot_window);