summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2010-05-26 09:43:39 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2010-05-26 09:54:27 (GMT)
commit058fa44c7aba859c3383f912da4f976c896f921d (patch)
treecf483079deee6cbc4ceb2d04ffa35dc9499d7782 /src
parentb14536650ace48c962e632ab287c347659091381 (diff)
downloadQt-058fa44c7aba859c3383f912da4f976c896f921d.zip
Qt-058fa44c7aba859c3383f912da4f976c896f921d.tar.gz
Qt-058fa44c7aba859c3383f912da4f976c896f921d.tar.bz2
Update the state of the keyboard modifiers on drop events.
In the case of drag-n-drop between processes we do not get key events for the pressed modifiers, so we need to update the state of the modifiers (using XQueryPointer) to get a correct value of QApplication::keyboardModifiers() and QDropEvent::keyboardModifiers() at drop time. This is necessary for fixing KDE bug 178679. Merge-request: 590 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com> Reviewed-by: Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qdnd_x11.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp
index 2b12317..92dd0a1 100644
--- a/src/gui/kernel/qdnd_x11.cpp
+++ b/src/gui/kernel/qdnd_x11.cpp
@@ -64,6 +64,7 @@
#include "qtextcodec.h"
#include "qdnd_p.h"
+#include "qapplication_p.h"
#include "qt_x11_p.h"
#include "qx11info_x11.h"
@@ -1111,7 +1112,20 @@ void qt_xdnd_send_leave()
waiting_for_status = false;
}
-
+// TODO: remove and use QApplication::currentKeyboardModifiers() in Qt 4.8.
+static Qt::KeyboardModifiers currentKeyboardModifiers()
+{
+ Window root;
+ Window child;
+ int root_x, root_y, win_x, win_y;
+ uint keybstate;
+ for (int i = 0; i < ScreenCount(X11->display); ++i) {
+ if (XQueryPointer(X11->display, QX11Info::appRootWindow(i), &root, &child,
+ &root_x, &root_y, &win_x, &win_y, &keybstate))
+ return X11->translateModifiers(keybstate & 0x00ff);
+ }
+ return 0;
+}
void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive)
{
@@ -1159,6 +1173,11 @@ void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive)
if (!dropData)
dropData = (manager->object) ? manager->dragPrivate()->data : manager->dropData;
+ // Drop coming from another app? Update keyboard modifiers.
+ if (!qt_xdnd_dragging) {
+ QApplicationPrivate::modifier_buttons = currentKeyboardModifiers();
+ }
+
QDropEvent de(qt_xdnd_current_position, possible_actions, dropData,
QApplication::mouseButtons(), QApplication::keyboardModifiers());
QApplication::sendEvent(qt_xdnd_current_widget, &de);