mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-15 14:50:06 +00:00
Move implicit grab tracking totally to common code
This commit is contained in:
parent
d6ad734c7f
commit
5be3f38535
@ -808,7 +808,6 @@ _gdk_display_add_pointer_grab (GdkDisplay *display,
|
|||||||
info->event_mask = event_mask;
|
info->event_mask = event_mask;
|
||||||
info->time = time;
|
info->time = time;
|
||||||
info->implicit = implicit;
|
info->implicit = implicit;
|
||||||
info->converted_implicit = FALSE;
|
|
||||||
|
|
||||||
/* Find the first grab that has a larger start time (if any) and insert
|
/* 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
|
* before that. I.E we insert after already existing grabs with same
|
||||||
|
@ -180,7 +180,6 @@ typedef struct
|
|||||||
gboolean owner_events;
|
gboolean owner_events;
|
||||||
guint event_mask;
|
guint event_mask;
|
||||||
gboolean implicit;
|
gboolean implicit;
|
||||||
gboolean converted_implicit;
|
|
||||||
guint32 time;
|
guint32 time;
|
||||||
|
|
||||||
gboolean activated;
|
gboolean activated;
|
||||||
|
@ -8305,6 +8305,12 @@ proxy_pointer_event (GdkDisplay *display,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define GDK_ANY_BUTTON_MASK (GDK_BUTTON1_MASK | \
|
||||||
|
GDK_BUTTON2_MASK | \
|
||||||
|
GDK_BUTTON3_MASK | \
|
||||||
|
GDK_BUTTON4_MASK | \
|
||||||
|
GDK_BUTTON5_MASK)
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
proxy_button_event (GdkEvent *source_event,
|
proxy_button_event (GdkEvent *source_event,
|
||||||
gulong serial)
|
gulong serial)
|
||||||
@ -8319,7 +8325,6 @@ proxy_button_event (GdkEvent *source_event,
|
|||||||
gdouble toplevel_x, toplevel_y;
|
gdouble toplevel_x, toplevel_y;
|
||||||
GdkDisplay *display;
|
GdkDisplay *display;
|
||||||
GdkWindowObject *w;
|
GdkWindowObject *w;
|
||||||
GdkPointerGrabInfo *grab;
|
|
||||||
|
|
||||||
type = source_event->any.type;
|
type = source_event->any.type;
|
||||||
toplevel_window = source_event->any.window;
|
toplevel_window = source_event->any.window;
|
||||||
@ -8328,18 +8333,15 @@ proxy_button_event (GdkEvent *source_event,
|
|||||||
time_ = gdk_event_get_time (source_event);
|
time_ = gdk_event_get_time (source_event);
|
||||||
display = gdk_drawable_get_display (source_event->any.window);
|
display = gdk_drawable_get_display (source_event->any.window);
|
||||||
|
|
||||||
grab = _gdk_display_get_active_pointer_grab (display);
|
if (type == GDK_BUTTON_PRESS &&
|
||||||
|
_gdk_display_has_pointer_grab (display, serial) == NULL)
|
||||||
if ((type == GDK_BUTTON_PRESS || type == GDK_SCROLL) &&
|
|
||||||
grab && grab->window == toplevel_window &&
|
|
||||||
grab->implicit && !grab->converted_implicit)
|
|
||||||
{
|
{
|
||||||
pointer_window =
|
pointer_window =
|
||||||
_gdk_window_find_descendant_at (toplevel_window,
|
_gdk_window_find_descendant_at (toplevel_window,
|
||||||
toplevel_x, toplevel_y,
|
toplevel_x, toplevel_y,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
|
||||||
/* Find the actual event window, its what gets the grab */
|
/* Find the event window, that gets the grab */
|
||||||
w = (GdkWindowObject *)pointer_window;
|
w = (GdkWindowObject *)pointer_window;
|
||||||
while (w != NULL && w->parent->window_type != GDK_WINDOW_ROOT)
|
while (w != NULL && w->parent->window_type != GDK_WINDOW_ROOT)
|
||||||
{
|
{
|
||||||
@ -8349,16 +8351,15 @@ proxy_button_event (GdkEvent *source_event,
|
|||||||
}
|
}
|
||||||
pointer_window = (GdkWindow *)w;
|
pointer_window = (GdkWindow *)w;
|
||||||
|
|
||||||
if (pointer_window != NULL &&
|
_gdk_display_add_pointer_grab (display,
|
||||||
pointer_window != toplevel_window)
|
pointer_window,
|
||||||
{
|
toplevel_window,
|
||||||
g_object_ref (pointer_window);
|
FALSE,
|
||||||
g_object_unref (grab->window);
|
gdk_window_get_events (pointer_window),
|
||||||
grab->window = pointer_window;
|
serial,
|
||||||
grab->event_mask = gdk_window_get_events (pointer_window);
|
time_,
|
||||||
}
|
TRUE);
|
||||||
|
_gdk_display_pointer_grab_update (display, serial);
|
||||||
grab->converted_implicit = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pointer_window = get_pointer_window (display, toplevel_window,
|
pointer_window = get_pointer_window (display, toplevel_window,
|
||||||
@ -8577,9 +8578,9 @@ _gdk_windowing_got_event (GdkDisplay *display,
|
|||||||
button_release_grab =
|
button_release_grab =
|
||||||
_gdk_display_has_pointer_grab (display, serial);
|
_gdk_display_has_pointer_grab (display, serial);
|
||||||
if (button_release_grab &&
|
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->serial_end = serial;
|
||||||
button_release_grab->implicit_ungrab = TRUE;
|
button_release_grab->implicit_ungrab = TRUE;
|
||||||
_gdk_display_pointer_grab_update (display, serial);
|
_gdk_display_pointer_grab_update (display, serial);
|
||||||
|
@ -1192,15 +1192,6 @@ gdk_event_translate (GdkDisplay *display,
|
|||||||
|
|
||||||
set_user_time (window, event);
|
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;
|
break;
|
||||||
|
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
@ -1241,8 +1232,6 @@ gdk_event_translate (GdkDisplay *display,
|
|||||||
if (!set_screen_from_root (display, event, xevent->xbutton.root))
|
if (!set_screen_from_root (display, event, xevent->xbutton.root))
|
||||||
return_val = FALSE;
|
return_val = FALSE;
|
||||||
|
|
||||||
_gdk_xgrab_check_button_event (window, xevent);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MotionNotify:
|
case MotionNotify:
|
||||||
|
@ -436,55 +436,6 @@ _gdk_xgrab_check_destroy (GdkWindow *window)
|
|||||||
_gdk_display_unset_has_keyboard_grab (display, TRUE);
|
_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
|
void
|
||||||
_gdk_windowing_display_set_sm_client_id (GdkDisplay *display,
|
_gdk_windowing_display_set_sm_client_id (GdkDisplay *display,
|
||||||
const gchar *sm_client_id)
|
const gchar *sm_client_id)
|
||||||
|
@ -164,8 +164,6 @@ void _gdk_x11_initialize_locale (void);
|
|||||||
void _gdk_xgrab_check_unmap (GdkWindow *window,
|
void _gdk_xgrab_check_unmap (GdkWindow *window,
|
||||||
gulong serial);
|
gulong serial);
|
||||||
void _gdk_xgrab_check_destroy (GdkWindow *window);
|
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,
|
gboolean _gdk_x11_display_is_root_window (GdkDisplay *display,
|
||||||
Window xroot_window);
|
Window xroot_window);
|
||||||
|
Loading…
Reference in New Issue
Block a user