diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-06-02 14:12:58 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-06-02 16:38:28 +1000 |
commit | 60a452d6cd571364622153190d1b50dd01a3479a (patch) | |
tree | 1fb3d83c424fa98cd8eea0fd4243e6e471c9c5dc | |
parent | 987456a7a785e78449f8d509f1cd9d92701b3eae (diff) |
Add XIGrabButtonWithConfine and XIGrabEnterWithConfine with XI 2.1inputproto-2.1-devel
Same as the XI 2.0 calls but they take a confine_to window.
Both the old call and the new call send the confine_to down the wire now
(None for XIGrabButton/XIGrabEnter).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | include/X11/extensions/XInput2.h | 28 | ||||
-rw-r--r-- | man/Makefile.am | 4 | ||||
-rw-r--r-- | man/XIGrabButton.txt | 25 | ||||
-rw-r--r-- | man/XIGrabEnter.txt | 24 | ||||
-rw-r--r-- | src/XIPassiveGrab.c | 51 |
5 files changed, 124 insertions, 8 deletions
diff --git a/include/X11/extensions/XInput2.h b/include/X11/extensions/XInput2.h index 1ae818b..ca666f0 100644 --- a/include/X11/extensions/XInput2.h +++ b/include/X11/extensions/XInput2.h @@ -442,6 +442,21 @@ extern int XIGrabButton( XIGrabModifiers *modifiers_inout ); +extern int XIGrabButtonWithConfine( + Display* display, + int deviceid, + int button, + Window grab_window, + Window confine_to, + Cursor cursor, + int grab_mode, + int paired_device_mode, + int owner_events, + XIEventMask *mask, + int num_modifiers, + XIGrabModifiers *modifiers_inout +); + extern int XIGrabKeycode( Display* display, int deviceid, @@ -468,6 +483,19 @@ extern int XIGrabEnter( XIGrabModifiers *modifiers_inout ); +extern int XIGrabEnterWithConfine( + Display* display, + int deviceid, + Window grab_window, + Window confine_to, + Cursor cursor, + int grab_mode, + int paired_device_mode, + int owner_events, + XIEventMask *mask, + int num_modifiers, + XIGrabModifiers *modifiers_inout +); extern int XIGrabFocusIn( Display* display, int deviceid, diff --git a/man/Makefile.am b/man/Makefile.am index ab5b5af..3026771 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -77,11 +77,13 @@ libman_xml = $(libman_txt:.txt=.xml) # The shadow man page contains a gtroff .so request to include the main man page XI2_shadows = \ XIUndefineCursor.man \ + XIGrabButtonWithConfine.man \ XIUngrabButton.man \ XIGrabDeviceWithConfine.man \ XIGrabKeycode.man \ XIUngrabKeycode.man \ XIUngrabDevice.man \ + XIGrabEnterWithConfine.man \ XIUngrabEnter.man \ XIGrabFocusIn.man \ XIUngrabFocusIn.man \ @@ -152,6 +154,8 @@ XIUngrabEnter.man XIGrabFocusIn.man XIUngrabFocusIn.man: XIGrabEnter.man XIGetSelectedEvents.man: XISelectEvents.man XIFreeDeviceInfo.man: XIQueryDevice.man XIGrabDeviceWithConfine.man: XIGrabDevice.man +XIGrabEnterWithConfine.man: XIGrabEnter.man +XIGrabButtonWithConfine.man: XIGrabButton.man # String replacements in MAN_SUBSTS now come from xorg-macros.m4 via configure # Unable to use __libmansuffix__ as underscores are lost in txt --> xml conversion diff --git a/man/XIGrabButton.txt b/man/XIGrabButton.txt index fb806af..c6b7f90 100644 --- a/man/XIGrabButton.txt +++ b/man/XIGrabButton.txt @@ -4,7 +4,7 @@ XIGRABBUTTON(libmansuffix) NAME ---- - XIGrabButton, XIUngrabButton, XIGrabKeycode, XIUngrabKeycode - + XIGrabButton, XIGrabButtonWithConfine, XIUngrabButton, XIGrabKeycode, XIUngrabKeycode - grab/ungrab buttons or keys SYNOPSIS @@ -24,6 +24,19 @@ SYNOPSIS int num_modifiers, XIGrabModifiers *modifiers_inout); + int XIGrabButtonWithConfine( Display *display, + int deviceid, + int button, + Window grab_window, + Window confine_to, + Cursor cursor, + int grab_mode, + int paired_device_mode, + Bool owner_events, + XIEventMask *mask, + int num_modifiers, + XIGrabModifiers *modifiers_inout); + int XIUngrabButton( Display *display, int deviceid, int button, @@ -98,6 +111,10 @@ SYNOPSIS GrabModeAsync. If deviceid specifies a floating slave device, this parameter is ignored. + confine_to + The window to confine this device to if it is a + master pointer. Can be None. + DESCRIPTION ----------- @@ -156,6 +173,12 @@ DESCRIPTION combination. XIGrabButton and XIGrabKeycode have no effect on an active grab. + If the server supports XI 2.1 and the device is a master + pointer and the confine_to is set to a window, the cursor will + be confined to this window for the duration of the grab. + XIGrabButtonWithConfine with confine_to of None is equivalent to + XIGrabButton. + On success, XIGrabButton and XIGrabKeycode return 0; If one or more modifier combinations could not be grabbed, XIGrabButton and XIGrabKeycode return the number of failed diff --git a/man/XIGrabEnter.txt b/man/XIGrabEnter.txt index f75a5ad..ac2be3f 100644 --- a/man/XIGrabEnter.txt +++ b/man/XIGrabEnter.txt @@ -4,7 +4,7 @@ XIGRABENTER(libmansuffix) NAME ---- - XIGrabEnter, XIUngrabEnter, XIGrabFocusIn, XIUngrabFocusIn - + XIGrabEnter, XIGrabEnterWithConfine, XIUngrabEnter, XIGrabFocusIn, XIUngrabFocusIn - grab/ungrab enter or focus in events. SYNOPSIS @@ -23,6 +23,18 @@ SYNOPSIS int num_modifiers, XIGrabModifiers *modifiers_inout); + int XIGrabEnter( Display *display, + int deviceid, + Window grab_window, + Window confine_to, + Cursor cursor, + int grab_mode, + int paired_device_mode, + Bool owner_events, + XIEventMask *mask, + int num_modifiers, + XIGrabModifiers *modifiers_inout); + int XIUngrabEnter( Display *display, int deviceid, Window grab_window @@ -85,6 +97,10 @@ SYNOPSIS GrabModeAsync. If deviceid specifies a floating slave device, this parameter is ignored. + confine_to + The window to confine this device to if it is a + master pointer. Can be None. + DESCRIPTION ----------- @@ -133,6 +149,12 @@ DESCRIPTION is a conflicting grab for any combination. XIGrabEnter and XIGrabFocusin have no effect on an active grab. + If the server supports XI 2.1 and the device is a master + pointer and the confine_to is set to a window, the cursor will + be confined to this window for the duration of the grab. + XIGrabButtonWithConfine with confine_to of None is equivalent to + XIGrabButton. + On success, XIGrabEnter and XIGrabFocusIn return 0; If one or more modifier combinations could not be grabbed, XIGrabEnter and XIGrabFocusIn return the number of failed diff --git a/src/XIPassiveGrab.c b/src/XIPassiveGrab.c index 34f1bf3..60a4e08 100644 --- a/src/XIPassiveGrab.c +++ b/src/XIPassiveGrab.c @@ -31,7 +31,7 @@ static int _XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail, - Window grab_window, Cursor cursor, + Window grab_window, Window confine_to, Cursor cursor, int grab_mode, int paired_device_mode, Bool owner_events, XIEventMask *mask, int num_modifiers, XIGrabModifiers *modifiers_inout) @@ -62,7 +62,7 @@ _XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail, req->mask_len = (mask->mask_len + 3)/4; req->grab_type = grabtype; - len = req->mask_len + num_modifiers; + len = req->mask_len + num_modifiers + 1 /* confine_to */; SetReqLen(req, len, len); buff = calloc(4, req->mask_len); @@ -70,6 +70,7 @@ _XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail, Data(dpy, buff, req->mask_len * 4); for (i = 0; i < num_modifiers; i++) Data(dpy, (char*)&modifiers_inout[i].modifiers, 4); + Data32(dpy, &confine_to, 4); free(buff); @@ -105,7 +106,26 @@ XIGrabButton(Display* dpy, int deviceid, int button, int num_modifiers, XIGrabModifiers *modifiers_inout) { return _XIPassiveGrabDevice(dpy, deviceid, XIGrabtypeButton, button, - grab_window, cursor, grab_mode, + grab_window, None, cursor, grab_mode, + paired_device_mode, owner_events, mask, + num_modifiers, modifiers_inout); +} + +int +XIGrabButtonWithConfine(Display* dpy, int deviceid, int button, + Window grab_window, Window confine_to, Cursor cursor, + int grab_mode, int paired_device_mode, + Bool owner_events, XIEventMask *mask, + int num_modifiers, XIGrabModifiers *modifiers_inout) +{ + XExtDisplayInfo *extinfo = XInput_find_display(dpy); + + LockDisplay(dpy); + if (_XiCheckExtInit(dpy, XInput_2_1, extinfo) == -1) + return (NoSuchExtension); + + return _XIPassiveGrabDevice(dpy, deviceid, XIGrabtypeButton, button, + grab_window, confine_to, cursor, grab_mode, paired_device_mode, owner_events, mask, num_modifiers, modifiers_inout); } @@ -117,7 +137,7 @@ XIGrabKeycode(Display* dpy, int deviceid, int keycode, int num_modifiers, XIGrabModifiers *modifiers_inout) { return _XIPassiveGrabDevice(dpy, deviceid, XIGrabtypeKeycode, keycode, - grab_window, None, grab_mode, paired_device_mode, + grab_window, None, None, grab_mode, paired_device_mode, owner_events, mask, num_modifiers, modifiers_inout); } @@ -129,18 +149,37 @@ XIGrabEnter(Display *dpy, int deviceid, Window grab_window, Cursor cursor, XIGrabModifiers *modifiers_inout) { return _XIPassiveGrabDevice(dpy, deviceid, XIGrabtypeEnter, 0, - grab_window, cursor, grab_mode, paired_device_mode, + grab_window, None, cursor, grab_mode, paired_device_mode, owner_events, mask, num_modifiers, modifiers_inout); } int +XIGrabEnterWithConfine(Display* dpy, int deviceid, + Window grab_window, Window confine_to, Cursor cursor, + int grab_mode, int paired_device_mode, + Bool owner_events, XIEventMask *mask, + int num_modifiers, XIGrabModifiers *modifiers_inout) +{ + XExtDisplayInfo *extinfo = XInput_find_display(dpy); + + LockDisplay(dpy); + if (_XiCheckExtInit(dpy, XInput_2_1, extinfo) == -1) + return (NoSuchExtension); + + return _XIPassiveGrabDevice(dpy, deviceid, XIGrabtypeEnter, 0, + grab_window, confine_to, cursor, grab_mode, + paired_device_mode, owner_events, mask, + num_modifiers, modifiers_inout); +} + +int XIGrabFocusIn(Display *dpy, int deviceid, Window grab_window, int grab_mode, int paired_device_mode, Bool owner_events, XIEventMask *mask, int num_modifiers, XIGrabModifiers *modifiers_inout) { return _XIPassiveGrabDevice(dpy, deviceid, XIGrabtypeFocusIn, 0, - grab_window, None, grab_mode, paired_device_mode, + grab_window, None, None, grab_mode, paired_device_mode, owner_events, mask, num_modifiers, modifiers_inout); } |