diff options
author | Gatis Paeglis <gatis.paeglis@qt.io> | 2017-05-15 16:23:49 +0200 |
---|---|---|
committer | Gatis Paeglis <gatis.paeglis@qt.io> | 2018-05-04 10:44:15 +0000 |
commit | 10b3286313c78fa380b5fe676a7c14f3ae84f017 (patch) | |
tree | c42b5d2173c2b31775bfaa4185e9c59f55f22f0e /src/plugins/platforms/xcb/qxcbdrag.h | |
parent | bd52d9d73be83d5e4d2e16e45fe369dc79ae2117 (diff) |
qpa: improve API to support DnDs from other processes
... instead of using a hack of directly accessing QGuiApplication
members.
The current QPA API was bad for two reasons:
1) It expects platform plugin authors to know about
internals of Qt Gui, particularly that QGuiApplication
uses QGuiApplication::{mouseButtons,keyboardModifiers}
to construct QDragMoveEvent and QDropEvent events. Which
results in the second reason why this is bad.
2) Platform plugins should not directly access member
variables of QGuiApplication, just to make sure that
QDragMoveEvent and QDropEvent events contain correct state.
Platform plugins should instead use QWindowSystemInterface
to communicate with Qt Gui (which is also the solution here).
The solution is to extend QWindowSystemInterface::handle{Drag,Drop}
to require mouse/keyboard state. We already do this for
some of the other methods, so it is nothing extraordinary.
This type of interface is also _required_ to support
drag-n-drops from other processes. We can't use
QGuiApplication::{mouseButtons,keyboardModifiers} when the
drag originates from another process, instead we need to
query mouse/keyboard state from the system.
This patch fixes drag-n-drops from others processes on XCB
platform plugin.
Task-number: QTBUG-57168
Change-Id: I3f8b0d2f76e9a32ae157622fef801829d629921d
Reviewed-by: Mikhail Svetkin <mikhail.svetkin@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbdrag.h')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbdrag.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h index 31f1c47d83..138625476a 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.h +++ b/src/plugins/platforms/xcb/qxcbdrag.h @@ -78,14 +78,15 @@ public: void startDrag() override; void cancel() override; - void move(const QPoint &globalPos) override; - void drop(const QPoint &globalPos) override; + void move(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override; + void drop(const QPoint &globalPos, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override; void endDrag() override; void handleEnter(QPlatformWindow *window, const xcb_client_message_event_t *event, xcb_window_t proxy = 0); void handlePosition(QPlatformWindow *w, const xcb_client_message_event_t *event); void handleLeave(QPlatformWindow *w, const xcb_client_message_event_t *event); - void handleDrop(QPlatformWindow *, const xcb_client_message_event_t *event); + void handleDrop(QPlatformWindow *, const xcb_client_message_event_t *event, + Qt::MouseButtons b = 0, Qt::KeyboardModifiers mods = 0); void handleStatus(const xcb_client_message_event_t *event); void handleSelectionRequest(const xcb_selection_request_event_t *event); @@ -105,7 +106,8 @@ private: void init(); - void handle_xdnd_position(QPlatformWindow *w, const xcb_client_message_event_t *event); + void handle_xdnd_position(QPlatformWindow *w, const xcb_client_message_event_t *event, + Qt::MouseButtons b = 0, Qt::KeyboardModifiers mods = 0); void handle_xdnd_status(const xcb_client_message_event_t *event); void send_leave(); |