[PATCH] Added WithConfine functions.

Peter Hutterer peter.hutterer at who-t.net
Sun May 8 19:39:08 PDT 2011


On Thu, May 05, 2011 at 04:25:46PM +0200, Philipp Reh wrote:
> ---
>  include/X11/extensions/XInput2.h |   43 +++++++++++++++++++++++++++++++
>  src/XIGrabDevice.c               |   18 +++++++++++--
>  src/XIPassiveGrab.c              |   52 +++++++++++++++++++++++++++++--------
>  3 files changed, 98 insertions(+), 15 deletions(-)

As I think daniel mentioned on IRC, please prefix the patches with the
component if the component isn't the X server. Makes it easier to get a
grasp on them quick.

Patch itself is pretty much ok though as I said in the other email we can
re-use the request with extra data. For libXi, you still need the extra
function calls though (I'd personally name them XGrabDeviceConfineTo etc.,
but that's bikeshedding).
man page additions are missing though.

> diff --git a/include/X11/extensions/XInput2.h b/include/X11/extensions/XInput2.h
> index 3fcf083..f297801 100644
> --- a/include/X11/extensions/XInput2.h
> +++ b/include/X11/extensions/XInput2.h
> @@ -402,6 +402,19 @@ extern Status XIGrabDevice(
>       XIEventMask        *mask
>  );
>  
> +extern Status XIGrabDeviceWithConfine(
> +     Display*           dpy,
> +     int                deviceid,
> +     Window             grab_window,
> +     Window             confine_to,
> +     Time               time,
> +     Cursor             cursor,
> +     int                grab_mode,
> +     int                paired_device_mode,
> +     Bool               owner_events,
> +     XIEventMask        *mask
> +);
> +
>  extern Status XIUngrabDevice(
>       Display*           dpy,
>       int                deviceid,
> @@ -429,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,
> @@ -455,6 +483,20 @@ 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,
> @@ -466,6 +508,7 @@ extern int XIGrabFocusIn(
>      int                 num_modifiers,
>      XIGrabModifiers     *modifiers_inout
>  );
> +
>  extern Status XIUngrabButton(
>      Display*            display,
>      int                 deviceid,

this is an unnecessary hunk.

Cheers,
  Peter

> diff --git a/src/XIGrabDevice.c b/src/XIGrabDevice.c
> index 94feaee..e989ee0 100644
> --- a/src/XIGrabDevice.c
> +++ b/src/XIGrabDevice.c
> @@ -35,7 +35,18 @@ XIGrabDevice(Display* dpy, int deviceid, Window grab_window, Time time,
>               Cursor cursor, int grab_mode, int paired_device_mode,
>               Bool owner_events, XIEventMask *mask)
>  {
> -    xXIGrabDeviceReq *req;
> +    return XIGrabDeviceWithConfine(dpy, deviceid, grab_window, None, time,
> +                                   cursor, grab_mode, paired_device_mode,
> +                                   owner_events, mask);
> +}
> +
> +Status
> +XIGrabDeviceWithConfine(Display* dpy, int deviceid, Window grab_window,
> +                        Window confine_to, Time time, Cursor cursor,
> +                        int grab_mode, int paired_device_mode,
> +                        Bool owner_events, XIEventMask *mask)
> +{
> +    xXIGrabDeviceWithConfineReq *req;
>      xXIGrabDeviceReply reply;
>      char* buff;
>      int len;
> @@ -46,11 +57,12 @@ XIGrabDevice(Display* dpy, int deviceid, Window grab_window, Time time,
>      if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1)
>  	return (NoSuchExtension);
>  
> -    GetReq(XIGrabDevice, req);
> +    GetReq(XIGrabDeviceWithConfine, req);
>      req->reqType  = extinfo->codes->major_opcode;
> -    req->ReqType  = X_XIGrabDevice;
> +    req->ReqType  = X_XIGrabDeviceWithConfine;
>      req->deviceid = deviceid;
>      req->grab_window = grab_window;
> +    req->confine_to = confine_to;
>      req->time = time;
>      req->grab_mode = grab_mode;
>      req->paired_device_mode = paired_device_mode;
> diff --git a/src/XIPassiveGrab.c b/src/XIPassiveGrab.c
> index feef74b..3e10356 100644
> --- a/src/XIPassiveGrab.c
> +++ b/src/XIPassiveGrab.c
> @@ -31,12 +31,12 @@
>  
>  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)
>  {
> -    xXIPassiveGrabDeviceReq *req;
> +    xXIPassiveGrabDeviceWithConfineReq *req;
>      xXIPassiveGrabDeviceReply reply;
>      xXIGrabModifierInfo *failed_mods;
>      int len = 0, i;
> @@ -48,14 +48,15 @@ _XIPassiveGrabDevice(Display* dpy, int deviceid, int grabtype, int detail,
>      if (_XiCheckExtInit(dpy, XInput_2_0, extinfo) == -1)
>  	return -1;
>  
> -    GetReq(XIPassiveGrabDevice, req);
> +    GetReq(XIPassiveGrabDeviceWithConfine, req);
>      req->reqType = extinfo->codes->major_opcode;
> -    req->ReqType = X_XIPassiveGrabDevice;
> +    req->ReqType = X_XIPassiveGrabDeviceWithConfine;
>      req->deviceid = deviceid;
>      req->grab_mode = grab_mode;
>      req->paired_device_mode = paired_device_mode;
>      req->owner_events = owner_events;
>      req->grab_window = grab_window;
> +    req->confine_to = confine_to;
>      req->cursor = cursor;
>      req->detail = detail;
>      req->num_modifiers = num_modifiers;
> @@ -105,19 +106,33 @@ 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)
> +{
> +    return _XIPassiveGrabDevice(dpy, deviceid, XIGrabtypeButton, button,
> +                                grab_window, confine_to, cursor, grab_mode,
> +                                paired_device_mode, owner_events, mask,
> +                                num_modifiers, modifiers_inout);
> +}
> +
> +
> +int
>  XIGrabKeycode(Display* dpy, int deviceid, int keycode,
>               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, 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,9 +144,22 @@ 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,
> -                                owner_events, mask, num_modifiers,
> -                                modifiers_inout);
> +                                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)
> +{
> +    return _XIPassiveGrabDevice(dpy, deviceid, XIGrabtypeEnter, 0,
> +                                grab_window, confine_to, cursor, grab_mode,
> +                                paired_device_mode, owner_events, mask,
> +                                num_modifiers, modifiers_inout);
>  }
>  
>  int
> @@ -140,9 +168,9 @@ XIGrabFocusIn(Display *dpy, int deviceid, Window grab_window, int grab_mode,
>              int num_modifiers, XIGrabModifiers *modifiers_inout)
>  {
>      return _XIPassiveGrabDevice(dpy, deviceid, XIGrabtypeFocusIn, 0,
> -                                grab_window, None, grab_mode, paired_device_mode,
> -                                owner_events, mask, num_modifiers,
> -                                modifiers_inout);
> +                                grab_window, None, None, grab_mode,
> +                                paired_device_mode, owner_events, mask,
> +                                num_modifiers, modifiers_inout);
>  }
>  
>  static int
> -- 
> 1.7.5.rc3
> 


More information about the xorg-devel mailing list