[gtk+/client-side-windows: 166/284] Move keyboard grab info to common code
- From: Alexander Larsson <alexl src gnome org>
- To: svn-commits-list gnome org
- Subject: [gtk+/client-side-windows: 166/284] Move keyboard grab info to common code
- Date: Thu, 2 Apr 2009 14:13:40 -0400 (EDT)
commit e60af9d3157486fd5ca671ae63200de5024b9105
Author: Alexander Larsson <alexl redhat com>
Date: Fri Jan 23 15:05:44 2009 +0100
Move keyboard grab info to common code
This is the first stage in tracking keyboard grabs in the common code.
This lets us handle destroying or unmapping virtual window with a
keyboard grab.
---
gdk/gdkdisplay.h | 12 ++++++++++
gdk/x11/gdkdisplay-x11.c | 6 ++--
gdk/x11/gdkdisplay-x11.h | 12 ----------
gdk/x11/gdkevents-x11.c | 8 +++---
gdk/x11/gdkmain-x11.c | 52 +++++++++++++++++++++------------------------
5 files changed, 43 insertions(+), 47 deletions(-)
diff --git a/gdk/gdkdisplay.h b/gdk/gdkdisplay.h
index ce0f1da..4e1e7a3 100644
--- a/gdk/gdkdisplay.h
+++ b/gdk/gdkdisplay.h
@@ -58,6 +58,17 @@ typedef struct
GdkWindow *grab_one_pointer_release_event;
} GdkPointerGrabInfo;
+/* Tracks information about the keyboard grab on this display */
+typedef struct
+{
+ GdkWindow *window;
+ GdkWindow *native_window;
+ gulong serial;
+ gboolean owner_events;
+ guint32 time;
+} GdkKeyboardGrabInfo;
+
+
/* Tracks information about which window and position the pointer last was in.
* This is useful when we need to synthesize events later.
* Note that we track toplevel_under_pointer using enter/leave events,
@@ -102,6 +113,7 @@ struct _GdkDisplay
gint button_y[2];
GdkPointerGrabInfo pointer_grab;
+ GdkKeyboardGrabInfo keyboard_grab;
GdkPointerWindowInfo pointer_info;
};
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 37199c3..cbda734 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -650,9 +650,9 @@ gdk_display_keyboard_ungrab (GdkDisplay *display,
XFlush (xdisplay);
if (time == GDK_CURRENT_TIME ||
- display_x11->keyboard_xgrab_time == GDK_CURRENT_TIME ||
- !XSERVER_TIME_IS_LATER (display_x11->keyboard_xgrab_time, time))
- display_x11->keyboard_xgrab_window = NULL;
+ display->keyboard_grab.time == GDK_CURRENT_TIME ||
+ !XSERVER_TIME_IS_LATER (display->keyboard_grab.time, time))
+ display->keyboard_grab.window = NULL;
}
/**
diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h
index 619a1ad..e92418d 100644
--- a/gdk/x11/gdkdisplay-x11.h
+++ b/gdk/x11/gdkdisplay-x11.h
@@ -94,18 +94,6 @@ struct _GdkDisplayX11
* (grabs, properties etc.) Otherwise always TRUE. */
gboolean trusted_client;
- /* Information about current keyboard grabs held by this
- * client. If gdk_keyboard_xgrab_window
- * window is NULL, then the other associated fields are ignored
- * Pointer grab info is stored in GdkDisplay.
- */
-
- GdkWindowObject *keyboard_xgrab_window;
- GdkWindowObject *keyboard_xgrab_native_window;
- gulong keyboard_xgrab_serial;
- gboolean keyboard_xgrab_owner_events;
- guint32 keyboard_xgrab_time;
-
/* drag and drop information */
GdkDragContext *current_dest_drag;
diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c
index ebe8573..fb99540 100644
--- a/gdk/x11/gdkevents-x11.c
+++ b/gdk/x11/gdkevents-x11.c
@@ -984,17 +984,17 @@ gdk_event_translate (GdkDisplay *display,
if (/* Is key event */
(xevent->type == KeyPress || xevent->type == KeyRelease) &&
/* And we have a grab */
- display_x11->keyboard_xgrab_window != NULL &&
+ display->keyboard_grab.window != NULL &&
(
/* The window is not a descendant of the grabbed window */
- !is_parent_of ((GdkWindow *)display_x11->keyboard_xgrab_window, window) ||
+ !is_parent_of ((GdkWindow *)display->keyboard_grab.window, window) ||
/* Or owner event is false */
- !display_x11->keyboard_xgrab_owner_events
+ !display->keyboard_grab.owner_events
)
)
{
/* Report key event against grab window */
- window_private = display_x11->keyboard_xgrab_window;
+ window_private = display->keyboard_grab.window;
window = (GdkWindow *) window_private;
}
diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c
index 5be1101..e516f86 100644
--- a/gdk/x11/gdkmain-x11.c
+++ b/gdk/x11/gdkmain-x11.c
@@ -316,6 +316,7 @@ gdk_keyboard_grab (GdkWindow * window,
{
gint return_val;
unsigned long serial;
+ GdkDisplay *display;
GdkDisplayX11 *display_x11;
GdkWindow *native;
@@ -327,8 +328,9 @@ gdk_keyboard_grab (GdkWindow * window,
/* TODO: What do we do for offscreens and children? We need to proxy the grab somehow */
if (!GDK_IS_WINDOW_IMPL_X11 (GDK_WINDOW_OBJECT (native)->impl))
return GDK_GRAB_SUCCESS;
-
- display_x11 = GDK_DISPLAY_X11 (GDK_WINDOW_DISPLAY (native));
+
+ display = GDK_WINDOW_DISPLAY (native);
+ display_x11 = GDK_DISPLAY_X11 (display);
serial = NextRequest (GDK_WINDOW_XDISPLAY (native));
@@ -354,16 +356,16 @@ gdk_keyboard_grab (GdkWindow * window,
if (return_val == GrabSuccess)
{
- if (display_x11->keyboard_xgrab_window != NULL &&
- display_x11->keyboard_xgrab_window != (GdkWindowObject *)window)
- generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
+ 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_x11->keyboard_xgrab_window = (GdkWindowObject *)window;
- display_x11->keyboard_xgrab_native_window = (GdkWindowObject *)native;
- display_x11->keyboard_xgrab_serial = serial;
- display_x11->keyboard_xgrab_owner_events = owner_events;
- display_x11->keyboard_xgrab_time = time;
+ 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;
}
return gdk_x11_convert_grab_status (return_val);
@@ -405,18 +407,14 @@ gdk_keyboard_grab_info_libgtk_only (GdkDisplay *display,
GdkWindow **grab_window,
gboolean *owner_events)
{
- GdkDisplayX11 *display_x11;
-
g_return_val_if_fail (GDK_IS_DISPLAY (display), False);
- display_x11 = GDK_DISPLAY_X11 (display);
-
- if (display_x11->keyboard_xgrab_window)
+ if (display->keyboard_grab.window)
{
if (grab_window)
- *grab_window = (GdkWindow *)display_x11->keyboard_xgrab_window;
+ *grab_window = display->keyboard_grab.window;
if (owner_events)
- *owner_events = display_x11->keyboard_xgrab_owner_events;
+ *owner_events = display->keyboard_grab.owner_events;
return TRUE;
}
@@ -439,7 +437,6 @@ _gdk_xgrab_check_unmap (GdkWindow *window,
gulong serial)
{
GdkDisplay *display = gdk_drawable_get_display (window);
- GdkDisplayX11 *display_x11 = GDK_DISPLAY_X11 (display);
if (display->pointer_grab.window &&
serial >= display->pointer_grab.serial)
@@ -454,21 +451,20 @@ _gdk_xgrab_check_unmap (GdkWindow *window,
_gdk_display_unset_has_pointer_grab (display, TRUE, FALSE, GDK_CURRENT_TIME);
}
- if (display_x11->keyboard_xgrab_window &&
- serial >= display_x11->keyboard_xgrab_serial)
+ if (display->keyboard_grab.window &&
+ serial >= display->keyboard_grab.serial)
{
GdkWindowObject *private = GDK_WINDOW_OBJECT (window);
- GdkWindowObject *tmp = display_x11->keyboard_xgrab_window;
-
+ GdkWindowObject *tmp = GDK_WINDOW_OBJECT (display->keyboard_grab.window);
while (tmp && tmp != private)
tmp = tmp->parent;
if (tmp)
{
- generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
+ generate_grab_broken_event (GDK_WINDOW (display->keyboard_grab.window),
TRUE, FALSE, NULL);
- display_x11->keyboard_xgrab_window = NULL;
+ display->keyboard_grab.window = NULL;
}
}
}
@@ -490,12 +486,12 @@ _gdk_xgrab_check_destroy (GdkWindow *window)
display->pointer_grab.window != NULL)
_gdk_display_unset_has_pointer_grab (display, TRUE, FALSE, GDK_CURRENT_TIME);
- if ((GdkWindowObject *)window == display_x11->keyboard_xgrab_native_window &&
- display_x11->keyboard_xgrab_window != NULL)
+ if (window == display->keyboard_grab.native_window &&
+ display->keyboard_grab.window != NULL)
{
- generate_grab_broken_event (GDK_WINDOW (display_x11->keyboard_xgrab_window),
+ generate_grab_broken_event (GDK_WINDOW (display->keyboard_grab.window),
TRUE, FALSE, NULL);
- display_x11->keyboard_xgrab_window = NULL;
+ display->keyboard_grab.window = NULL;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]