Details
-
Task
-
Resolution: Won't Do
-
P2: Important
-
None
-
None
Description
The documentation of QGuiApplication::mouseButtons() states - "The current state is updated synchronously as the event queue is emptied of events that will spontaneously change the mouse state (QEvent::MouseButtonPress and QEvent::MouseButtonRelease events)". But internally we have been updating these state variables from various places to keep buttons returned by mouseButtons() in sync with the actual window system state. This is not the documented behavior.
Why remove? It is an easy to misuse API by:
Application developers:
The only place where the values of this API can be trusted is when using within mouse handling callbacks. In these callbacks we work with the state that was provided directly by the windowing system. Anywhere else it might not reflect what user wrongly expects. We might not always receive a matching mouse release for a press event (e.g. When dismissing a popup window on X11. Or when dnd enter Qt application with mouse button down, we update mouse_buttons and then dnd leaves Qt application and does a drop somewhere else) and hence mouseButtons() will be out-of-sync from users perspective, see
for example QTBUG-33161. BUT THIS IS NOT HOW THE API IS SUPPOSED TO BE USED. Since the only safe place to use this API is from mouse event handlers, we might as well deprecate it and pass down the button state if we are not already doing that everywhere where it matters.
Qt framework developers:
We see users complaining, we start adding hacks everywhere just to keep buttons in sync There are corner cases that can not be solved and adding this kind of hacks is never ending task.
Real mouse events, tablet mouse events, synthesized, etc: all go through QGuiApplication::processMouseEvent, and all share mouse_buttons. What if we want to support multiple mice in future? The API must go.
Motivation why this API is public is not clear. Could the same be achieved by a user by installing an event filter?
Attachments
Issue Links
- relates to
-
QTBUG-72560 Qt Gui Changes in Qt 6
- Closed
- resulted in
-
QTBUG-89711 QAbstractItemView::SelectionMode is not working
- Closed
For Gerrit Dashboard: QTBUG-73829 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
303552,4 | Deprecate QGuiApplication::mouseButtons/keyboardModifiers | dev | qt/qtbase | Status: ABANDONED | 0 | 0 |
306544,2 | Add keyboardModifiers member to QStyleOptionSlider, and use it for mac | dev | qt/qtbase | Status: MERGED | +2 | 0 |
306552,6 | Manage keyboard modifier state in QPlainTextEdit | dev | qt/qtbase | Status: MERGED | +2 | 0 |
306572,4 | Maintain keyboard modifier state in QAbstractSpinBox's input event handlers | dev | qt/qtbase | Status: MERGED | +2 | 0 |
306585,3 | Pass modifier and button information down the call stack | dev | qt/qtbase | Status: MERGED | +2 | 0 |
306595,6 | Keep track of mouse button state in QTabBar | dev | qt/qtbase | Status: MERGED | +2 | 0 |
306696,6 | Remove call to static QGuiApplication::keyboardModifiers method | dev | qt/qtbase | Status: MERGED | +2 | 0 |
306697,6 | Introduce QEvent::isInputEvent | dev | qt/qtbase | Status: MERGED | +2 | 0 |