From d4d883de469a87914748b41c69d80d9a890205e4 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 17 Aug 2011 13:14:57 +0200 Subject: 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 (cherry picked from commit 3b5354386225974ea6db78c12f32cb81e2d50104) Change-Id: I9b4e54ac79fc225e3ed8d2bcaba953a6eb59f0d2 Reviewed-on: http://codereview.qt.nokia.com/3581 Reviewed-by: Frederik Gladhorn --- src/gui/kernel/qapplication.cpp | 21 ++++++++++++++++++++- src/gui/kernel/qapplication.h | 1 + src/gui/kernel/qapplication_mac.mm | 5 +++++ src/gui/kernel/qapplication_qws.cpp | 5 +++++ src/gui/kernel/qapplication_s60.cpp | 8 ++++++++ src/gui/kernel/qapplication_win.cpp | 5 +++++ src/gui/kernel/qapplication_x11.cpp | 15 +++++++++++++++ src/gui/kernel/qdnd_x11.cpp | 17 +---------------- 8 files changed, 60 insertions(+), 17 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 9cd1b7bb09..593a3209a8 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -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 diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h index 01a246a0c6..15488490d1 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -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); diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index cb1f0cdbe4..e06756c86a 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -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 diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp index 14f779008c..428f558023 100644 --- a/src/gui/kernel/qapplication_qws.cpp +++ b/src/gui/kernel/qapplication_qws.cpp @@ -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); diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index f0739cdd9f..e277765eff 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -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) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index c34e75ffcc..756cb56b58 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -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 *****************************************************************************/ diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 8d5a0b8a50..311b147976 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -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 *****************************************************************************/ diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp index 750ddf892e..11e87e96f3 100644 --- a/src/gui/kernel/qdnd_x11.cpp +++ b/src/gui/kernel/qdnd_x11.cpp @@ -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, -- cgit v1.2.3 From 9a442b7b54883dbc2830486ca15802d15df46bad Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 14 Jul 2011 10:57:02 +0200 Subject: Add constants to QAccessible::Event enum. Reviewed-by: Gabi (cherry picked from commit 81036d4be6122dfcb55a4852bcc1037c7d8f7309) Change-Id: Id818d9c9e53ece0c93b89649db5aa31d59920426 Reviewed-on: http://codereview.qt.nokia.com/3031 Reviewed-by: Qt Sanity Bot Reviewed-by: Frederik Gladhorn --- src/gui/accessible/qaccessible.h | 68 ++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 34 deletions(-) (limited to 'src/gui') diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h index 16869bb926..24a6744643 100644 --- a/src/gui/accessible/qaccessible.h +++ b/src/gui/accessible/qaccessible.h @@ -84,40 +84,40 @@ public: MenuCommand = 0x0018, // Values from IAccessible2 - ActionChanged = 0x0101, - ActiveDescendantChanged, - AttributeChanged, - DocumentContentChanged, - DocumentLoadComplete, - DocumentLoadStopped, - DocumentReload, - HyperlinkEndIndexChanged, - HyperlinkNumberOfAnchorsChanged, - HyperlinkSelectedLinkChanged, - HypertextLinkActivated, - HypertextLinkSelected, - HyperlinkStartIndexChanged, - HypertextChanged, - HypertextNLinksChanged, - ObjectAttributeChanged, - PageChanged, - SectionChanged, - TableCaptionChanged, - TableColumnDescriptionChanged, - TableColumnHeaderChanged, - TableModelChanged, - TableRowDescriptionChanged, - TableRowHeaderChanged, - TableSummaryChanged, - TextAttributeChanged, - TextCaretMoved, - // TextChanged, deprecated, use TextUpdated - TextColumnChanged = TextCaretMoved + 2, - TextInserted, - TextRemoved, - TextUpdated, - TextSelectionChanged, - VisibleDataChanged, + ActionChanged = 0x0101, + ActiveDescendantChanged = 0x0102, + AttributeChanged = 0x0103, + DocumentContentChanged = 0x0104, + DocumentLoadComplete = 0x0105, + DocumentLoadStopped = 0x0106, + DocumentReload = 0x0107, + HyperlinkEndIndexChanged = 0x0108, + HyperlinkNumberOfAnchorsChanged = 0x0109, + HyperlinkSelectedLinkChanged = 0x010A, + HypertextLinkActivated = 0x010B, + HypertextLinkSelected = 0x010C, + HyperlinkStartIndexChanged = 0x010D, + HypertextChanged = 0x010E, + HypertextNLinksChanged = 0x010F, + ObjectAttributeChanged = 0x0110, + PageChanged = 0x0111, + SectionChanged = 0x0112, + TableCaptionChanged = 0x0113, + TableColumnDescriptionChanged = 0x0114, + TableColumnHeaderChanged = 0x0115, + TableModelChanged = 0x0116, + TableRowDescriptionChanged = 0x0117, + TableRowHeaderChanged = 0x0118, + TableSummaryChanged = 0x0119, + TextAttributeChanged = 0x011A, + TextCaretMoved = 0x011B, + // TextChanged = 0x011C, is deprecated in IA2, use TextUpdated + TextColumnChanged = 0x011D, + TextInserted = 0x011E, + TextRemoved = 0x011F, + TextUpdated = 0x0120, + TextSelectionChanged = 0x0121, + VisibleDataChanged = 0x0122, ObjectCreated = 0x8000, ObjectDestroyed = 0x8001, -- cgit v1.2.3 From e6cecd9ce01b1fcdf7d8038fa79cd60b10ab43bf Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 24 Aug 2011 09:13:45 +0200 Subject: Fix justification of RTL text Since the trailing space is included in the QScriptLine, it may affect the positions of preceding script items when the text is RTL. The best solution for this would be to disregard the trailing space in the layout process, or somehow make it have an advance of 0 so it doesn't affect the layout. However, to minimize the impact of the change, and to be consistent with previous work arounds such as bf992df6434fc37715f728ca09601c5567dd83c9, we simply include the trailing (visually leading) space in the justification pass for now. Task-number: QTBUG-20920 Reviewed-by: Lars (cherry picked from commit 1a8a36eb6b6df9e2550b5eaa4606f2d411fd4294) Change-Id: I94972ebaea2e1bdb09950523c43844351b304abe Reviewed-on: http://codereview.qt.nokia.com/3462 Reviewed-by: Eskil Abrahamsen Blomfeldt Reviewed-by: Qt Sanity Bot --- src/gui/text/qtextengine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index f7b7aa28a1..53cd2baa01 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2093,7 +2093,8 @@ void QTextEngine::justify(const QScriptLine &line) } } - QFixed need = line.width - line.textWidth; + QFixed leading = leadingSpaceWidth(line); + QFixed need = line.width - line.textWidth - leading; if (need < 0) { // line overflows already! const_cast(line).justified = true; -- cgit v1.2.3 From 22011ece4c48ddd7887d7527d558dfb95fd9ceb7 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 26 Aug 2011 08:07:20 +0200 Subject: Fix crash when fallback font is not #0 in multi font engine Easily reproducible by testing Chinese with the threaded renderer. The multi engine would then have a list of engines with a single item, but the glyphs might belong to e.g. engine 11. In that case, engine() would assert when it couldn't find the engine if the layout had been done in a different thread. We force the loading of the required engine if it's not already loaded. Note that this fix does not work on Mac, as loadEngine() will crash there, so the layout has to be done in the same thread as the rendering, since loading the engines is part of the layout process. Task-number: QTBUG-21112 Change-Id: I71cc396664e3b95fbb4815a90873457e1f89528e Reviewed-on: http://codereview.qt.nokia.com/3631 Reviewed-by: Qt Sanity Bot Reviewed-by: Jiang Jiang --- src/gui/text/qfontengine_p.h | 5 +++++ src/gui/text/qtextlayout.cpp | 2 ++ 2 files changed, 7 insertions(+) (limited to 'src/gui') diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h index 5f779e155a..e9a8d6f607 100644 --- a/src/gui/text/qfontengine_p.h +++ b/src/gui/text/qfontengine_p.h @@ -434,6 +434,11 @@ public: QFontEngine *engine(int at) const {Q_ASSERT(at < engines.size()); return engines.at(at); } + inline void ensureEngineAt(int at) + { + if (at >= engines.size() || engines.at(at) == 0) + loadEngine(at); + } protected: friend class QPSPrintEnginePrivate; diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 8c5e63da54..d253c02052 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -2305,6 +2305,7 @@ QList QTextLine::glyphRuns(int from, int length) const continue; QGlyphLayout subLayout = glyphLayout.mid(start, end - start); + multiFontEngine->ensureEngineAt(which); glyphRuns.append(glyphRunWithInfo(multiFontEngine->engine(which), subLayout, pos, flags, x, width)); for (int i = 0; i < subLayout.numGlyphs; i++) { @@ -2317,6 +2318,7 @@ QList QTextLine::glyphRuns(int from, int length) const } QGlyphLayout subLayout = glyphLayout.mid(start, end - start); + multiFontEngine->ensureEngineAt(which); QGlyphRun glyphRun = glyphRunWithInfo(multiFontEngine->engine(which), subLayout, pos, flags, x, width); if (!glyphRun.isEmpty()) -- cgit v1.2.3 From 8412020740e0d1669f32c9d66b500874d975a015 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 26 Aug 2011 10:33:20 +0200 Subject: Check if bridge plugin vector is still valid. Q_GLOBAL_STATIC may be destroyed and we still send ObjectDestroyed notifications. This only shows now that we actually send the Destroyed notifications. Change-Id: I3057556cdc897dab6adfc3274e4abc68473ffa7f Reviewed-on: http://codereview.qt.nokia.com/3657 Reviewed-by: Qt Sanity Bot Reviewed-by: Gabriel de Dietrich --- src/gui/accessible/qaccessible_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/accessible/qaccessible_unix.cpp b/src/gui/accessible/qaccessible_unix.cpp index 19fbe78301..1c1eb2ad05 100644 --- a/src/gui/accessible/qaccessible_unix.cpp +++ b/src/gui/accessible/qaccessible_unix.cpp @@ -96,7 +96,7 @@ void QAccessible::updateAccessibility(QObject *o, int who, Event reason) } initialize(); - if (bridges()->isEmpty()) + if (!bridges() || bridges()->isEmpty()) return; QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(o); -- cgit v1.2.3 From 420c4edb8aa8317afef864353a6fb5353d00ad60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Mill=C3=A1n=20Soto?= Date: Thu, 14 Jul 2011 14:25:57 +0200 Subject: Call QAccessible::updateAccessibility when setText is called on QLabel The method is called when the text of a label is changed and setAccessibleName has not been called on the label, as the text of the label acts as the accessible name of the label. Merge-request: 1301 Reviewed-by: Frederik Gladhorn (cherry picked from commit a1f2b68e97477440cf508e6d497eb5f5d9971971) Change-Id: Ic10f75e72ac3faa84777c444177b287b720a1dc2 Reviewed-on: http://codereview.qt.nokia.com/3040 Reviewed-by: Qt Sanity Bot Reviewed-by: Frederik Gladhorn --- src/gui/widgets/qlabel.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/gui') diff --git a/src/gui/widgets/qlabel.cpp b/src/gui/widgets/qlabel.cpp index 7a94f42125..ab88f38bbb 100644 --- a/src/gui/widgets/qlabel.cpp +++ b/src/gui/widgets/qlabel.cpp @@ -55,6 +55,10 @@ #include "private/qstylesheetstyle_p.h" #include +#ifndef QT_NO_ACCESSIBILITY +#include +#endif + QT_BEGIN_NAMESPACE /*! @@ -377,6 +381,11 @@ void QLabel::setText(const QString &text) #endif d->updateLabel(); + +#ifndef QT_NO_ACCESSIBILITY + if (accessibleName().isEmpty()) + QAccessible::updateAccessibility(this, 0, QAccessible::NameChanged); +#endif } QString QLabel::text() const -- cgit v1.2.3 From 5dd208b1f4e1780acf06e58291103adab0117f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Mill=C3=A1n=20Soto?= Date: Fri, 29 Jul 2011 10:35:54 -0700 Subject: Call QAccessible::updateAccessibility when a widget is deleted Merge-request: 1310 Reviewed-by: Frederik Gladhorn (cherry picked from commit df3f763920b1450733817596148e087d11c0c543) Change-Id: I74fb08104c5dc527f9e9ac88776e4aa2623a3385 Reviewed-on: http://codereview.qt.nokia.com/3041 Reviewed-by: Qt Sanity Bot Reviewed-by: Frederik Gladhorn --- src/gui/kernel/qwidget.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gui') diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 231fc261d7..8bfd078448 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1680,6 +1680,10 @@ QWidget::~QWidget() if (!d->children.isEmpty()) d->deleteChildren(); +#ifndef QT_NOACCESSIBILITY + QAccessible::updateAccessibility(this, 0, QAccessible::ObjectDestroyed); +#endif + QApplication::removePostedEvents(this); QT_TRY { -- cgit v1.2.3 From 3cdc2ea183c68640b4883ddfa2bbea8e24c5106b Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Fri, 29 Jul 2011 14:43:01 -0700 Subject: Fix typo for ifdef QT_NO_ACCESSIBILITY Reviewed-by: TrustMe (cherry picked from commit eaf3b5ff76e4866ef3597110c6e565305c3298ad) Change-Id: I21df13a24fc5d339c5fcbf38f151c0339e1c87a9 Reviewed-on: http://codereview.qt.nokia.com/3042 Reviewed-by: Qt Sanity Bot Reviewed-by: Frederik Gladhorn --- src/gui/kernel/qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 8bfd078448..72ff5e9df2 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1680,7 +1680,7 @@ QWidget::~QWidget() if (!d->children.isEmpty()) d->deleteChildren(); -#ifndef QT_NOACCESSIBILITY +#ifndef QT_NO_ACCESSIBILITY QAccessible::updateAccessibility(this, 0, QAccessible::ObjectDestroyed); #endif -- cgit v1.2.3