[Xcb] [PATCH 04/19] Xephyr: xcb-ify pointer/keyboard grab
Julien Cristau
jcristau at debian.org
Wed Oct 20 10:11:46 PDT 2010
Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>
Signed-off-by: Julien Cristau <jcristau at debian.org>
---
hw/kdrive/ephyr/hostx.c | 51 +++++++++++++++++++++++++++++++---------------
1 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index f0ca6f0..44a9df4 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -1067,8 +1067,8 @@ hostx_get_event(EphyrHostXEvent *ev)
if (grabbed_screen != -1)
{
- XUngrabKeyboard (HostX.dpy, CurrentTime);
- XUngrabPointer (HostX.dpy, CurrentTime);
+ xcb_ungrab_keyboard(HostX.conn, XCB_TIME_CURRENT_TIME);
+ xcb_ungrab_pointer(HostX.conn, XCB_TIME_CURRENT_TIME);
grabbed_screen = -1;
hostx_set_win_title (host_screen->info,
"(ctrl+shift grabs mouse and keyboard)");
@@ -1076,25 +1076,42 @@ hostx_get_event(EphyrHostXEvent *ev)
else
{
/* Attempt grab */
- if (XGrabKeyboard (HostX.dpy, host_screen->win, True,
- GrabModeAsync,
- GrabModeAsync,
- CurrentTime) == 0)
- {
- if (XGrabPointer (HostX.dpy, host_screen->win, True,
- NoEventMask,
- GrabModeAsync,
- GrabModeAsync,
- host_screen->win, None, CurrentTime) == 0)
- {
+ xcb_grab_keyboard_cookie_t kbgrabc =
+ xcb_grab_keyboard(HostX.conn,
+ True,
+ host_screen->win,
+ XCB_TIME_CURRENT_TIME,
+ XCB_GRAB_MODE_ASYNC,
+ XCB_GRAB_MODE_ASYNC);
+ xcb_grab_keyboard_reply_t *kbgrabr;
+ xcb_grab_pointer_cookie_t pgrabc =
+ xcb_grab_pointer(HostX.conn,
+ True,
+ host_screen->win,
+ 0,
+ XCB_GRAB_MODE_ASYNC,
+ XCB_GRAB_MODE_ASYNC,
+ host_screen->win,
+ XCB_NONE,
+ XCB_TIME_CURRENT_TIME);
+ xcb_grab_pointer_reply_t *pgrabr;
+ kbgrabr = xcb_grab_keyboard_reply(HostX.conn, kbgrabc, NULL);
+ if (!kbgrabr || kbgrabr->status != XCB_GRAB_STATUS_SUCCESS) {
+ xcb_discard_reply(HostX.conn, pgrabc.sequence);
+ xcb_ungrab_pointer(HostX.conn, XCB_TIME_CURRENT_TIME);
+ } else {
+ pgrabr = xcb_grab_pointer_reply(HostX.conn, pgrabc, NULL);
+ if (!pgrabr || pgrabr->status != XCB_GRAB_STATUS_SUCCESS)
+ {
+ xcb_ungrab_keyboard(HostX.conn,
+ XCB_TIME_CURRENT_TIME);
+ } else {
grabbed_screen = host_screen->mynum;
hostx_set_win_title
(host_screen->info,
"(ctrl+shift releases mouse and keyboard)");
- }
- else /* Failed pointer grabm ungrab keyboard */
- XUngrabKeyboard (HostX.dpy, CurrentTime);
- }
+ }
+ }
}
}
--
1.7.1
More information about the Xcb
mailing list