[Interest] [QtGui] Clip cursor position

Nye kshegunov at gmail.com
Tue Dec 22 20:06:34 CET 2015


Hello Jan,
Maybe there was a misunderstanding, I had succeeded in restricting the
mouse cursor with my "installing an event filter to the application object"
approach, however I'm not happy with the results. When the mouse leaves the
desired area the pointer is moved on the screen by the X server, then, when
I change it back in my application to the clipped coordinates there is
"flicker" (or "jitter" for a lack of better description). This is what I'm
trying to avoid. For completeness, I coded your suggestion by putting a
QWindow object at the bottom of the screen and grabbing the mouse, but I
still (as expected) get the cursor jittering around the edges of my area.

Kind regards,
Konstantin.

On Tue, Dec 22, 2015 at 2:34 PM, Jan Dasselaar <jan at altus-escon.com> wrote:

> Hello Konstantin,
>
> I figured it would be possible to add an event filter to the overlay
> window to:
> a. restrict the mouse to the desired area
> b. dispatch other mouse event to widgets below.
>
> Won't be easy, but it seems not impossible.
>
> Regards,
> Jan
>
>
> On 22-12-2015 12:22, Nye wrote:
>
> Hello Jan,
> Thanks for the suggestion, but I'm not really convinced that this'd help,
> since installing an event filter on the application object is effectively
> doing the same thing as grabbing the mouse (at least while the mouse is
> over an application window). Additionally the "grabMouse" runs into the
> trouble that I'd have to manually dispatch the messages to their
> corresponding widgets and it doesn't really prevent the mouse from leaving
> an area (or widget/window), it just ensures that the particular widget will
> get all mouse events (whether or not they occur in its client area). In
> windows the API seems to allow the behavior I'm after (
> https://msdn.microsoft.com/en-us/library/windows/desktop/ms648383(v=vs.85).aspx)
> but I'm not sure if this is even possible for X11.
>
> Kind regards,
> Konstantin.
>
> On Tue, Dec 22, 2015 at 12:52 PM, Jan Dasselaar <jan at altus-escon.com>
> wrote:
>
>> Hello Nye,
>>
>> Maybe you can use the QWidget::grabMouse() function for that.
>> This in combination with an overlay widget (visible but fully
>> transparent) over your application.
>>
>> Regards,
>> Jan
>>
>>
>> On 22-12-2015 10:44, Nye wrote:
>>
>> Hello,
>> Is it possible to clip the mouse cursor to a specific area of the screen?
>> I've tried to limit the cursor movement by installing an event filter on
>> the application object and moving it back when its position got outside of
>> my target rectangle, but the results proved to be unsatisfactory, as there
>> is considerable "flicker". I then dig deeper and tried installing a window
>> system event handler on QWindowSystemInterfacePrivate by subclassing the
>> QWindowSystemEventHandler class available, reimplementing the sendEvent()
>> function, and plugging that in the appropriate place, but (as expected) the
>> behavior was only marginally better. I'm considering changing the
>> QPlatformWindow and trying to do it directly from there (actually from
>> QXcbWindow) but decided to ask first if there is actually a better way. Any
>> input is highly appreciated.
>>
>> Kind regards.
>>
>>
>> _______________________________________________
>> Interest mailing listInterest at qt-project.orghttp://lists.qt-project.org/mailman/listinfo/interest
>>
>>
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20151222/98a70b04/attachment.html>


More information about the Interest mailing list