Add a QApplication::queryKeyboardModifiers() method.
QApplication::keyboardModifiers returns the keyboard modifiers from the last keypress event in this process, as documented. However there are use cases for querying keyboard modifiers as they currently are, see QTBUG-11243. Merge-request: 585 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com> (cherry picked from commit 3b5354386225974ea6db78c12f32cb81e2d50104) Change-Id: I9b4e54ac79fc225e3ed8d2bcaba953a6eb59f0d2 Reviewed-on: http://codereview.qt.nokia.com/3581 Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
This commit is contained in:
parent
7347a5f99d
commit
d4d883de46
@ -3319,7 +3319,7 @@ bool QApplication::desktopSettingsAware()
|
||||
one of the above events. If no keys are being held Qt::NoModifier is
|
||||
returned.
|
||||
|
||||
\sa mouseButtons()
|
||||
\sa mouseButtons(), queryKeyboardModifiers()
|
||||
*/
|
||||
|
||||
Qt::KeyboardModifiers QApplication::keyboardModifiers()
|
||||
@ -3327,6 +3327,25 @@ Qt::KeyboardModifiers QApplication::keyboardModifiers()
|
||||
return QApplicationPrivate::modifier_buttons;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn Qt::KeyboardModifiers QApplication::queryKeyboardModifiers()
|
||||
|
||||
Queries and returns the state of the modifier keys on the keyboard.
|
||||
Unlike keyboardModifiers, this method returns the actual keys held
|
||||
on the input device at the time of calling the method.
|
||||
|
||||
It does not rely on the keypress events having been received by this
|
||||
process, which makes it possible to check the modifiers while moving
|
||||
a window, for instance. Note that in most cases, you should use
|
||||
keyboardModifiers(), which is faster and more accurate since it contains
|
||||
the state of the modifiers as they were when the currently processed
|
||||
event was received.
|
||||
|
||||
\sa keyboardModifiers()
|
||||
|
||||
\since 4.8
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns the current state of the buttons on the mouse. The current state is
|
||||
updated syncronously as the event queue is emptied of events that will
|
||||
|
@ -198,6 +198,7 @@ public:
|
||||
static void alert(QWidget *widget, int duration = 0);
|
||||
|
||||
static Qt::KeyboardModifiers keyboardModifiers();
|
||||
static Qt::KeyboardModifiers queryKeyboardModifiers();
|
||||
static Qt::MouseButtons mouseButtons();
|
||||
|
||||
static void setDesktopSettingsAware(bool);
|
||||
|
@ -1395,6 +1395,11 @@ void QApplication::restoreOverrideCursor()
|
||||
}
|
||||
#endif // QT_NO_CURSOR
|
||||
|
||||
Qt::KeyboardModifiers QApplication::queryKeyboardModifiers()
|
||||
{
|
||||
return qt_mac_get_modifiers(GetCurrentEventKeyModifiers());
|
||||
}
|
||||
|
||||
QWidget *QApplication::topLevelAt(const QPoint &p)
|
||||
{
|
||||
#ifndef QT_MAC_USE_COCOA
|
||||
|
@ -2707,6 +2707,11 @@ void QApplication::alert(QWidget *, int)
|
||||
{
|
||||
}
|
||||
|
||||
Qt::KeyboardModifiers QApplication::queryKeyboardModifiers()
|
||||
{
|
||||
return keyboardModifiers(); // TODO proper implementation
|
||||
}
|
||||
|
||||
int QApplication::qwsProcessEvent(QWSEvent* event)
|
||||
{
|
||||
Q_D(QApplication);
|
||||
|
@ -114,6 +114,8 @@ QWidget *qt_button_down = 0; // widget got last button-down
|
||||
|
||||
QSymbianControl *QSymbianControl::lastFocusedControl = 0;
|
||||
|
||||
static Qt::KeyboardModifiers app_keyboardModifiers = Qt::NoModifier;
|
||||
|
||||
QS60Data* qGlobalS60Data()
|
||||
{
|
||||
return qt_s60Data();
|
||||
@ -712,6 +714,7 @@ void QSymbianControl::HandlePointerEvent(const TPointerEvent& pEvent)
|
||||
Qt::MouseButton button;
|
||||
mapS60MouseEventTypeToQt(&type, &button, &pEvent);
|
||||
Qt::KeyboardModifiers modifiers = mapToQtModifiers(pEvent.iModifiers);
|
||||
app_keyboardModifiers = modifiers;
|
||||
|
||||
QPoint widgetPos = translatePointForFixedNativeOrientation(pEvent.iPosition);
|
||||
TPoint controlScreenPos = PositionRelativeToScreen();
|
||||
@ -2541,6 +2544,11 @@ void QApplication::setEffectEnabled(Qt::UIEffect /* effect */, bool /* enable */
|
||||
// TODO: Implement QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
|
||||
}
|
||||
|
||||
Qt::KeyboardModifiers QApplication::queryKeyboardModifiers()
|
||||
{
|
||||
return app_keyboardModifiers;
|
||||
}
|
||||
|
||||
TUint QApplicationPrivate::resolveS60ScanCode(TInt scanCode, TUint keysym)
|
||||
{
|
||||
if (!scanCode)
|
||||
|
@ -1319,6 +1319,11 @@ Qt::KeyboardModifiers qt_win_getKeyboardModifiers()
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
Qt::KeyboardModifiers QApplication::queryKeyboardModifiers()
|
||||
{
|
||||
return qt_win_getKeyboardModifiers();
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Routines to find a Qt widget from a screen position
|
||||
*****************************************************************************/
|
||||
|
@ -3061,6 +3061,21 @@ void QApplicationPrivate::_q_alertTimeOut()
|
||||
}
|
||||
}
|
||||
|
||||
Qt::KeyboardModifiers QApplication::queryKeyboardModifiers()
|
||||
{
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Special lookup functions for windows that have been reparented recently
|
||||
*****************************************************************************/
|
||||
|
@ -1112,21 +1112,6 @@ 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)
|
||||
{
|
||||
DEBUG("xdndHandleDrop");
|
||||
@ -1175,7 +1160,7 @@ void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive)
|
||||
|
||||
// Drop coming from another app? Update keyboard modifiers.
|
||||
if (!qt_xdnd_dragging) {
|
||||
QApplicationPrivate::modifier_buttons = currentKeyboardModifiers();
|
||||
QApplicationPrivate::modifier_buttons = QApplication::queryKeyboardModifiers();
|
||||
}
|
||||
|
||||
QDropEvent de(qt_xdnd_current_position, possible_actions, dropData,
|
||||
|
Loading…
Reference in New Issue
Block a user