Commit 290de401 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson
Browse files

Move keyboard grab state tracking code to common code

parent e60af9d3
......@@ -69,7 +69,6 @@ gdk_get_use_xshm
gdk_set_use_xshm
#endif
gdk_keyboard_grab
gdk_keyboard_grab_info_libgtk_only
gdk_pointer_grab
#endif
#endif
......@@ -84,6 +83,7 @@ gdk_pointer_is_grabbed
gdk_pointer_ungrab
gdk_event_send_client_message
gdk_event_send_clientmessage_toall
gdk_keyboard_grab_info_libgtk_only
gdk_pointer_grab_info_libgtk_only
gdk_display_pointer_is_grabbed
#endif
......
......@@ -747,7 +747,7 @@ _gdk_display_set_has_pointer_grab (GdkDisplay *display,
guint32 time,
gboolean implicit)
{
GdkWindow *pointer_window, *src_toplevel, *dest_toplevel, *src_window;
GdkWindow *src_toplevel, *dest_toplevel, *src_window;
if (display->pointer_grab.window != NULL &&
display->pointer_grab.window != window)
......@@ -763,8 +763,6 @@ _gdk_display_set_has_pointer_grab (GdkDisplay *display,
*/
if (!implicit)
{
GdkScreen *screen;
GdkWindowObject *w;
int x, y;
GdkModifierType state;
......@@ -961,9 +959,70 @@ _gdk_display_unset_has_pointer_grab (GdkDisplay *display,
generate_grab_broken_event (old_grab_window,
FALSE, implicit,
NULL);
}
void
_gdk_display_set_has_keyboard_grab (GdkDisplay *display,
GdkWindow *window,
GdkWindow *native_window,
gboolean owner_events,
unsigned long serial,
guint32 time)
{
if (display->keyboard_grab.window != NULL &&
display->keyboard_grab.window != window)
generate_grab_broken_event (display->keyboard_grab.window,
TRUE, FALSE, window);
display->keyboard_grab.window = window;
display->keyboard_grab.native_window = native_window;
display->keyboard_grab.owner_events = owner_events;
display->keyboard_grab.serial = serial;
display->keyboard_grab.time = time;
}
void
_gdk_display_unset_has_keyboard_grab (GdkDisplay *display,
gboolean implicit)
{
if (implicit)
generate_grab_broken_event (display->keyboard_grab.window,
TRUE, FALSE, NULL);
display->keyboard_grab.window = NULL;
}
/**
* gdk_keyboard_grab_info_libgtk_only:
* @display: the display for which to get the grab information
* @grab_window: location to store current grab window
* @owner_events: location to store boolean indicating whether
* the @owner_events flag to gdk_keyboard_grab() was %TRUE.
*
* Determines information about the current keyboard grab.
* This is not public API and must not be used by applications.
*
* Return value: %TRUE if this application currently has the
* keyboard grabbed.
**/
gboolean
gdk_keyboard_grab_info_libgtk_only (GdkDisplay *display,
GdkWindow **grab_window,
gboolean *owner_events)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
if (display->keyboard_grab.window)
{
if (grab_window)
*grab_window = display->keyboard_grab.window;
if (owner_events)
*owner_events = display->keyboard_grab.owner_events;
return TRUE;
}
else
return FALSE;
}
/**
* gdk_pointer_grab_info_libgtk_only:
......
......@@ -466,8 +466,6 @@ char *_gdk_windowing_get_startup_notify_id (GAppLaunchContext *context,
void _gdk_windowing_launch_failed (GAppLaunchContext *context,
const char *startup_notify_id);
void _gdk_windowing_grab_broken (GdkDisplay *display);
void _gdk_display_set_has_pointer_grab (GdkDisplay *display,
GdkWindow *window,
GdkWindow *native_window,
......@@ -480,6 +478,12 @@ void _gdk_display_unset_has_pointer_grab (GdkDisplay *display,
gboolean implicit,
gboolean do_grab_one_pointer_release_event,
guint32 time);
void _gdk_display_set_has_keyboard_grab (GdkDisplay *display,
GdkWindow *window,
GdkWindow *native_window,
gboolean owner_events,
unsigned long serial,
guint32 time);
void _gdk_window_invalidate_for_expose (GdkWindow *window,
const GdkRegion *region);
......
......@@ -652,7 +652,7 @@ gdk_display_keyboard_ungrab (GdkDisplay *display,
if (time == GDK_CURRENT_TIME ||
display->keyboard_grab.time == GDK_CURRENT_TIME ||
!XSERVER_TIME_IS_LATER (display->keyboard_grab.time, time))
display->keyboard_grab.window = NULL;
_gdk_display_unset_has_keyboard_grab (display, FALSE);
}
/**
......
......@@ -355,73 +355,14 @@ gdk_keyboard_grab (GdkWindow * window,
return_val = AlreadyGrabbed;
if (return_val == GrabSuccess)
{
if (display->keyboard_grab.window != NULL &&
display->keyboard_grab.window != window)
generate_grab_broken_event (GDK_WINDOW (display->keyboard_grab.window),
TRUE, FALSE, window);
display->keyboard_grab.window = window;
display->keyboard_grab.native_window = native;
display->keyboard_grab.serial = serial;
display->keyboard_grab.owner_events = owner_events;
display->keyboard_grab.time = time;
}
_gdk_display_set_has_keyboard_grab (display,
window, native,
owner_events,
serial, time);
return gdk_x11_convert_grab_status (return_val);
}
void
_gdk_windowing_grab_broken (GdkDisplay *display)
{
/* TODO: Move to common code */
#if 0
GdkDisplayX11 *display_x11;
g_return_if_fail (display != NULL);
display_x11 = GDK_DISPLAY_X11 (display);
generate_grab_broken_event (GDK_WINDOW (display_x11->pointer_grab.window),
FALSE,
display_x11->pointer_grab.implicit,
NULL);
display_x11->pointer_grab.window = NULL;
#endif
}
/**
* gdk_keyboard_grab_info_libgtk_only:
* @display: the display for which to get the grab information
* @grab_window: location to store current grab window
* @owner_events: location to store boolean indicating whether
* the @owner_events flag to gdk_keyboard_grab() was %TRUE.
*
* Determines information about the current keyboard grab.
* This is not public API and must not be used by applications.
*
* Return value: %TRUE if this application currently has the
* keyboard grabbed.
**/
gboolean
gdk_keyboard_grab_info_libgtk_only (GdkDisplay *display,
GdkWindow **grab_window,
gboolean *owner_events)
{
g_return_val_if_fail (GDK_IS_DISPLAY (display), False);
if (display->keyboard_grab.window)
{
if (grab_window)
*grab_window = display->keyboard_grab.window;
if (owner_events)
*owner_events = display->keyboard_grab.owner_events;
return TRUE;
}
else
return FALSE;
}
/**
* _gdk_xgrab_check_unmap:
* @window: a #GdkWindow
......@@ -461,11 +402,7 @@ _gdk_xgrab_check_unmap (GdkWindow *window,
tmp = tmp->parent;
if (tmp)
{
generate_grab_broken_event (GDK_WINDOW (display->keyboard_grab.window),
TRUE, FALSE, NULL);
display->keyboard_grab.window = NULL;
}
_gdk_display_unset_has_keyboard_grab (display, TRUE);
}
}
......@@ -488,11 +425,7 @@ _gdk_xgrab_check_destroy (GdkWindow *window)
if (window == display->keyboard_grab.native_window &&
display->keyboard_grab.window != NULL)
{
generate_grab_broken_event (GDK_WINDOW (display->keyboard_grab.window),
TRUE, FALSE, NULL);
display->keyboard_grab.window = NULL;
}
_gdk_display_unset_has_keyboard_grab (display, TRUE);
}
#define GDK_ANY_BUTTON_MASK (GDK_BUTTON1_MASK | \
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment