cwindowx11motif

XtGrabPointer does not confine to widget window area


I'm writing an Xt/Xm application and trying to emulate the effect of the Win32 ClipCursor on a widget.

However, the following fails to constrain the pointer to the specified widget area in confine_to

unsigned mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask | EnterWindowMask | LeaveWindowMask;

XtGrabPointer(widget, True, mask, GrabModeAsync, GrabModeAsync, XtWindow(widget), None, CurrentTime);

There doesn't appear to be any X/Xt error output in the console.

Is XtWindow of a widget not appropriate for use in the confining of the pointer in this call? Or are my event masks/grab modes not set correctly for what I want here. (Or some other issue I'm not thinking of).

The widget in question is an XmDrawingArea, which has an XmCR_INPUT handler set as well as an XtAddEventHandler for PointerMotionMask (i.e. not using translations to enable motion input).


Solution

  • There was a logic issue elsewhere in my program causing ungrab to be called after every grab call. Resolving that has resolved my issue.