Discussion:
ButtonRelease event when focus changed
Rokas Kupstys
2021-04-30 12:05:35 UTC
Permalink
Hello,

I am in this situation where i perform a drag operation which creates a
new window under mouse cursor and starts moving it _NET_WM_MOVERESIZE
atom, all without releasing mouse button. Problem is that neither window
receives ButtonRelease event once drag operation is done, and
application is stuck in a state where it thinks that left mouse button
is still pressed. I am trying to fix this in GLFW. From my tests it
seems that SDL does not have this problem and would send ButtonRlease
event to newly focused window. I can not quite figure out how to enable
this behavior though. Would anyone please advice what to do to make
ButtonRelease always be sent to focused window, even if that window was
not the one who received ButtonPress?

Thanks!
--
-- Rokas Kupstys

_______________________________________________
***@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: https://lists.x.org/mailman/listinfo/xorg
Your subscription address: %(user_address)s
Carsten Haitzler
2021-05-01 12:04:05 UTC
Permalink
On Fri, 30 Apr 2021 15:05:35 +0300 Rokas Kupstys <***@gmail.com> said:

in x, a button press implicitly grabs the mouse to that window you pressed on.
that's why you can press, drag out of the window far away and release the
mouse and the original window gets the motion events outside of the window and
the release.

what you need to do is ungrab the mouse pointer to release this implicit grab.
you will no longer have this implicit grab and you won't get the above "get
mouse moves + release when pointer is outside of the window". you can now
instead grab the pointer to the new target window to lock it in there for
events like the implicit grabs above to get the kind of behaviour your probably
expect.
Post by Rokas Kupstys
Hello,
I am in this situation where i perform a drag operation which creates a
new window under mouse cursor and starts moving it _NET_WM_MOVERESIZE
atom, all without releasing mouse button. Problem is that neither window
receives ButtonRelease event once drag operation is done, and
application is stuck in a state where it thinks that left mouse button
is still pressed. I am trying to fix this in GLFW. From my tests it
seems that SDL does not have this problem and would send ButtonRlease
event to newly focused window. I can not quite figure out how to enable
this behavior though. Would anyone please advice what to do to make
ButtonRelease always be sent to focused window, even if that window was
not the one who received ButtonPress?
Thanks!
--
-- Rokas Kupstys
_______________________________________________
Archives: http://lists.freedesktop.org/archives/xorg
Info: https://lists.x.org/mailman/listinfo/xorg
Your subscription address: %(user_address)s
--
------------- Codito, ergo sum - "I code, therefore I am" --------------
Carsten Haitzler - ***@rasterman.com

_______________________________________________
***@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: https://lists.x.org/mailman/listinfo/xorg
Your subscription address: %(user_address)s
Carsten Haitzler
2021-05-03 10:29:21 UTC
Permalink
ButtonPress             // sent to original window
MotionNotify            // drag operation leaves window and
creates a new window under mouse cursor XUngrabPointer
XSendEvent(_NET_WM_MOVERESIZE_MOVE)  // initiated drag on newly created window
// At this point mouse button is down and we are dragging a newly created
window // Releasing mouse button stops drag operation
If i understand correctly, i should XGrabPointer() newly created window
at this point, to get ButtonRelease event when drag operation ends,
right? Doing so breaks drag operation though, as it confines mouse
pointer movement to new window and breaks drag operation.
well move events are reported for the new window and not the old, so you need
to switch your logic to continue the drag with the new window id in mind...
-- Rokas Kupstys
Post by Carsten Haitzler
in x, a button press implicitly grabs the mouse to that window you pressed
on. that's why you can press, drag out of the window far away and release
the mouse and the original window gets the motion events outside of the
window and the release.
what you need to do is ungrab the mouse pointer to release this implicit
grab. you will no longer have this implicit grab and you won't get the
above "get mouse moves + release when pointer is outside of the window".
you can now instead grab the pointer to the new target window to lock it in
there for events like the implicit grabs above to get the kind of behaviour
your probably expect.
Post by Rokas Kupstys
Hello,
I am in this situation where i perform a drag operation which creates a
new window under mouse cursor and starts moving it _NET_WM_MOVERESIZE
atom, all without releasing mouse button. Problem is that neither window
receives ButtonRelease event once drag operation is done, and
application is stuck in a state where it thinks that left mouse button
is still pressed. I am trying to fix this in GLFW. From my tests it
seems that SDL does not have this problem and would send ButtonRlease
event to newly focused window. I can not quite figure out how to enable
this behavior though. Would anyone please advice what to do to make
ButtonRelease always be sent to focused window, even if that window was
not the one who received ButtonPress?
Thanks!
--
-- Rokas Kupstys
_______________________________________________
Archives: http://lists.freedesktop.org/archives/xorg
Info: https://lists.x.org/mailman/listinfo/xorg
Your subscription address: %(user_address)s
--
------------- Codito, ergo sum - "I code, therefore I am" --------------
Carsten Haitzler - ***@rasterman.com

_______________________________________________
***@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: https://lists.x.org/mailman/listinfo/xorg
Your subscription add
Loading...