From 674430cea0edafc374552b4743e2da7d29143453 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 17 Nov 2016 14:59:34 +0100 Subject: Silence maybe_uninitialized warning with gcc -Og GCC produces false positives for maybe_uninitialized when compiling with -Og in these three places. Simply initialize the variables to silence it. This should be entirely cost-free for normal compilation. Change-Id: Iab778a6ba25993f78f190e928c1fcc2dbd8b2fcd Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- src/plugins/platforms/xcb/qxcbconnection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 9e275efa25..1af2cf9b89 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -417,7 +417,7 @@ void QXcbConnection::initializeScreens() qWarning("failed to get the current screen resources"); free(error); } else { - xcb_timestamp_t timestamp; + xcb_timestamp_t timestamp = 0; xcb_randr_output_t *outputs = Q_NULLPTR; int outputCount = xcb_randr_get_screen_resources_current_outputs_length(resources_current.data()); if (outputCount) { -- cgit v1.2.1 From 49f1b667fa810428f9d3b5451d616c6cd9f390ca Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 28 Nov 2016 15:14:46 +0300 Subject: platform plugins: Remove unused former overriders They were implied to override QPlatformIntegrationPlugin::keys() but it was removed before releasing Qt 5.0. Change-Id: Ia1f1ad27b7511b1141887f5dcde0dadeb2e5cabf Reviewed-by: Paul Olav Tvete --- src/plugins/platforms/mirclient/qmirclientplugin.cpp | 7 ------- src/plugins/platforms/mirclient/qmirclientplugin.h | 1 - src/plugins/platforms/winrt/main.cpp | 6 ------ 3 files changed, 14 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/mirclient/qmirclientplugin.cpp b/src/plugins/platforms/mirclient/qmirclientplugin.cpp index 201b68c304..6899d70f2e 100644 --- a/src/plugins/platforms/mirclient/qmirclientplugin.cpp +++ b/src/plugins/platforms/mirclient/qmirclientplugin.cpp @@ -41,13 +41,6 @@ #include "qmirclientplugin.h" #include "qmirclientintegration.h" -QStringList QMirClientIntegrationPlugin::keys() const -{ - QStringList list; - list << QStringLiteral("mirclient"); - return list; -} - QPlatformIntegration* QMirClientIntegrationPlugin::create(const QString &system, const QStringList &) { diff --git a/src/plugins/platforms/mirclient/qmirclientplugin.h b/src/plugins/platforms/mirclient/qmirclientplugin.h index 8b5da6e4f6..c91f2d1924 100644 --- a/src/plugins/platforms/mirclient/qmirclientplugin.h +++ b/src/plugins/platforms/mirclient/qmirclientplugin.h @@ -49,7 +49,6 @@ class QMirClientIntegrationPlugin : public QPlatformIntegrationPlugin Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "mirclient.json") public: - QStringList keys() const; QPlatformIntegration* create(const QString&, const QStringList&); }; diff --git a/src/plugins/platforms/winrt/main.cpp b/src/plugins/platforms/winrt/main.cpp index 5d0d9e94eb..222287b3ef 100644 --- a/src/plugins/platforms/winrt/main.cpp +++ b/src/plugins/platforms/winrt/main.cpp @@ -49,15 +49,9 @@ class QWinRTIntegrationPlugin : public QPlatformIntegrationPlugin Q_PLUGIN_METADATA(IID QPlatformIntegrationFactoryInterface_iid FILE "winrt.json") public: - QStringList keys() const; QPlatformIntegration *create(const QString&, const QStringList&) override; }; -QStringList QWinRTIntegrationPlugin::keys() const -{ - return QStringList(QStringLiteral("WinRT")); -} - QPlatformIntegration *QWinRTIntegrationPlugin::create(const QString& system, const QStringList& paramList) { Q_UNUSED(paramList); -- cgit v1.2.1 From dfaa32a9455f0449cf2a2d7b5d916f99d5119fdc Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Tue, 27 Dec 2016 07:47:30 +0200 Subject: windows: use lowercase #include MinGW's headers are lowercase, and MSVC is generally run on a case- insensitive file system. Including in the lowercase is the more compatible option. Change-Id: I288cecb77ddd8029bb3925e613a830dd9ce96a6c Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwin10helpers.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwin10helpers.cpp b/src/plugins/platforms/windows/qwin10helpers.cpp index 977bbfd11b..12cccd124b 100644 --- a/src/plugins/platforms/windows/qwin10helpers.cpp +++ b/src/plugins/platforms/windows/qwin10helpers.cpp @@ -57,7 +57,7 @@ #endif #ifdef HAS_UI_VIEW_SETTINGS_INTEROP -# include +# include #endif #ifndef HAS_UI_VIEW_SETTINGS_INTEROP -- cgit v1.2.1 From 73dafaf265a6c6a51611a093c2cc81a6d61767a9 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Thu, 22 Dec 2016 15:12:28 +0300 Subject: xcb: Ignore XI2 LMB mouse events from touch screens 157ee01a8d0be9a4dbac03883c9eaf3609fc1172 was trying to minimize some side effects of the bug in the evdev driver (https://bugs.freedesktop.org/show_bug.cgi?id=98188) by not changing mouse button state on motion. Unfortunately it resurrected bugs that were fixed by 76de1ac0a4cd384f608a14b5d77a8cf3ef1ec868. Filter out mouse events from touch screens instead. This change reverts 157ee01a8d0be9a4dbac03883c9eaf3609fc1172. Task-number: QTBUG-32609 Task-number: QTBUG-35065 Task-number: QTBUG-43776 Task-number: QTBUG-44166 Task-number: QTBUG-44231 Task-number: QTBUG-56156 Change-Id: Ie17710d94beabeb08681d669a9d8309be9b44e73 Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbconnection.h | 1 + src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 7 +++++++ src/plugins/platforms/xcb/qxcbwindow.cpp | 26 ++++++++++++------------ src/plugins/platforms/xcb/qxcbwindow.h | 1 - 4 files changed, 21 insertions(+), 14 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 60f0f487c5..a9208ffe09 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -517,6 +517,7 @@ public: #ifdef XCB_USE_XINPUT22 bool xi2MouseEvents() const; + bool isTouchScreen(int id) const; #endif protected: diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 0ace79a4f5..f4f56f25f1 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -1025,6 +1025,13 @@ Qt::MouseButton QXcbConnection::xiToQtMouseButton(uint32_t b) return Qt::NoButton; } +bool QXcbConnection::isTouchScreen(int id) const +{ + auto device = m_touchDevices.value(id); + return device && device->qtTouchDevice + && device->qtTouchDevice->type() == QTouchDevice::TouchScreen; +} + static QTabletEvent::TabletDevice toolIdToTabletDevice(quint32 toolId) { // keep in sync with wacom_intuos_inout() in Linux kernel driver wacom_wac.c switch (toolId) { diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index ff01fa019e..3204fab197 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2423,22 +2423,27 @@ static inline int fixed1616ToInt(FP1616 val) return int((qreal(val >> 16)) + (val & 0xFFFF) / (qreal)0xFFFF); } -void QXcbWindow::handleXIMouseButtonState(const xcb_ge_event_t *event) +// With XI 2.2+ press/release/motion comes here instead of the above handlers. +void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource source) { QXcbConnection *conn = connection(); - const xXIDeviceEvent *ev = reinterpret_cast(event); + xXIDeviceEvent *ev = reinterpret_cast(event); + if (ev->buttons_len > 0) { unsigned char *buttonMask = (unsigned char *) &ev[1]; + // There is a bug in the evdev driver which leads to receiving mouse events without + // XIPointerEmulated being set: https://bugs.freedesktop.org/show_bug.cgi?id=98188 + // Filter them out by other attributes: when their source device is a touch screen + // and the LMB is pressed. + if (XIMaskIsSet(buttonMask, 1) && conn->isTouchScreen(ev->sourceid)) { + if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) + qCDebug(lcQpaXInput, "XI2 mouse event from touch device %d was ignored", ev->sourceid); + return; + } for (int i = 1; i <= 15; ++i) conn->setButton(conn->translateMouseButton(i), XIMaskIsSet(buttonMask, i)); } -} -// With XI 2.2+ press/release/motion comes here instead of the above handlers. -void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource source) -{ - QXcbConnection *conn = connection(); - xXIDeviceEvent *ev = reinterpret_cast(event); const Qt::KeyboardModifiers modifiers = conn->keyboard()->translateModifiers(ev->mods.effective_mods); const int event_x = fixed1616ToInt(ev->event_x); const int event_y = fixed1616ToInt(ev->event_y); @@ -2458,23 +2463,18 @@ void QXcbWindow::handleXIMouseEvent(xcb_ge_event_t *event, Qt::MouseEventSource switch (ev->evtype) { case XI_ButtonPress: - handleXIMouseButtonState(event); if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) qCDebug(lcQpaXInputEvents, "XI2 mouse press, button %d, time %d, source %s", button, ev->time, sourceName); conn->setButton(button, true); handleButtonPressEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source); break; case XI_ButtonRelease: - handleXIMouseButtonState(event); if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) qCDebug(lcQpaXInputEvents, "XI2 mouse release, button %d, time %d, source %s", button, ev->time, sourceName); conn->setButton(button, false); handleButtonReleaseEvent(event_x, event_y, root_x, root_y, ev->detail, modifiers, ev->time, source); break; case XI_Motion: - // Here we do NOT call handleXIMouseButtonState because we don't expect button state change to be bundled with motion. - // When a touchscreen is pressed, an XI_Motion event occurs in which XIMaskIsSet says the left button is pressed, - // but we don't want QGuiApplicationPrivate::processMouseEvent() to react by generating a mouse press event. if (Q_UNLIKELY(lcQpaXInputEvents().isDebugEnabled())) qCDebug(lcQpaXInputEvents, "XI2 mouse motion %d,%d, time %d, source %s", event_x, event_y, ev->time, sourceName); handleMotionNotifyEvent(event_x, event_y, root_x, root_y, modifiers, ev->time, source); diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 089df8f3f6..cfa4964151 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -139,7 +139,6 @@ public: void handleFocusOutEvent(const xcb_focus_out_event_t *event) override; void handlePropertyNotifyEvent(const xcb_property_notify_event_t *event) override; #ifdef XCB_USE_XINPUT22 - void handleXIMouseButtonState(const xcb_ge_event_t *); void handleXIMouseEvent(xcb_ge_event_t *, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized) override; void handleXIEnterLeave(xcb_ge_event_t *) override; #endif -- cgit v1.2.1 From af5c8d04fb0c9ddda58925e4862e857c78a5e563 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 2 Jan 2017 08:10:57 +0100 Subject: Win: Account for windows which are WindowTransparentForInput Task-number: QTBUG-57864 Change-Id: I8793aaa3719fbcf97f95ae462135cbf6b5823097 Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowscontext.cpp | 11 +++++++++-- .../platforms/windows/qwindowsmousehandler.cpp | 21 +++++---------------- 2 files changed, 14 insertions(+), 18 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 1a03df6ac2..bb9ed730a3 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -990,11 +990,18 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, case QtWindows::MouseWheelEvent: case QtWindows::MouseEvent: case QtWindows::LeaveEvent: + { + QWindow *window = platformWindow->window(); + while (window->flags() & Qt::WindowTransparentForInput) + window = window->parent(); + if (!window) + return false; #if !defined(QT_NO_SESSIONMANAGER) - return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result); + return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateMouseEvent(window, hwnd, et, msg, result); #else - return d->m_mouseHandler.translateMouseEvent(platformWindow->window(), hwnd, et, msg, result); + return d->m_mouseHandler.translateMouseEvent(window, hwnd, et, msg, result); #endif + } case QtWindows::TouchEvent: #if !defined(QT_NO_SESSIONMANAGER) return platformSessionManager()->isInteractionBlocked() ? true : d->m_mouseHandler.translateTouchEvent(platformWindow->window(), hwnd, et, msg, result); diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index 3f6230172e..e4025fe60d 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -313,7 +313,8 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, // events, "click-through") can be considered as the window under mouse. QWindow *currentWindowUnderMouse = platformWindow->hasMouseCapture() ? QWindowsScreen::windowAt(globalPosition, CWP_SKIPINVISIBLE | CWP_SKIPTRANSPARENT) : window; - + while (currentWindowUnderMouse && currentWindowUnderMouse->flags() & Qt::WindowTransparentForInput) + currentWindowUnderMouse = currentWindowUnderMouse->parent(); // QTBUG-44332: When Qt is running at low integrity level and // a Qt Window is parented on a Window of a higher integrity process // using QWindow::fromWinId() (for example, Qt running in a browser plugin) @@ -432,22 +433,10 @@ static bool isValidWheelReceiver(QWindow *candidate) static void redirectWheelEvent(QWindow *window, const QPoint &globalPos, int delta, Qt::Orientation orientation, Qt::KeyboardModifiers mods) { - // Redirect wheel event to one of the following, in order of preference: - // 1) The window under mouse - // 2) The window receiving the event // If a window is blocked by modality, it can't get the event. - - QWindow *receiver = QWindowsScreen::windowAt(globalPos, CWP_SKIPINVISIBLE); - bool handleEvent = true; - if (!isValidWheelReceiver(receiver)) { - receiver = window; - if (!isValidWheelReceiver(receiver)) - handleEvent = false; - } - - if (handleEvent) { - QWindowSystemInterface::handleWheelEvent(receiver, - QWindowsGeometryHint::mapFromGlobal(receiver, globalPos), + if (isValidWheelReceiver(window)) { + QWindowSystemInterface::handleWheelEvent(window, + QWindowsGeometryHint::mapFromGlobal(window, globalPos), globalPos, delta, orientation, mods); } } -- cgit v1.2.1 From fafdb171e0c317ee8f871dc7b504d3713d5860eb Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 3 Jan 2017 18:00:05 +0100 Subject: Accessibility macOS: fix parentElement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Try to return the immediate parent first, nothing else makes sense. The original code relied on the window pointer usually being nullptr, which is not reliable. Make sure to check the validity of the handle returned, since it's possible to have the platform window being nullptr. It's not quite clear to me how to end up with a null window though. Task-number: QTBUG-52304 Change-Id: Id3e70cdab980fb0a86cebbb7c10d824d8a7dd80b Reviewed-by: Jan Arve Sæther --- .../platforms/cocoa/qcocoaaccessibilityelement.mm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 97bd402b73..982c98976b 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -235,19 +235,19 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of if (!iface || !iface->isValid()) return nil; - if (QWindow *window = iface->window()) { - QCocoaWindow *win = static_cast(window->handle()); - return qnsview_cast(win->view()); + if (QAccessibleInterface *parent = iface->parent()) { + QAccessible::Id parentId = QAccessible::uniqueId(parent); + return [QMacAccessibilityElement elementWithId: parentId]; } - QAccessibleInterface *parent = iface->parent(); - if (!parent) { - qWarning() << "INVALID PARENT FOR INTERFACE: " << iface; - return nil; + if (QWindow *window = iface->window()) { + QPlatformWindow *platformWindow = window->handle(); + if (platformWindow) { + QCocoaWindow *win = static_cast(platformWindow); + return qnsview_cast(win->view()); + } } - - QAccessible::Id parentId = QAccessible::uniqueId(parent); - return [QMacAccessibilityElement elementWithId: parentId]; + return nil; } -- cgit v1.2.1 From d330ae0da27f54ede10dabdc937bfb570ac244cb Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Wed, 4 Jan 2017 23:23:42 +0100 Subject: Accessibility macOS: check for valid interfaces MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are a few places that did not check if the returned interface is valid. Task-number: QTBUG-52536 Change-Id: I56ca0952fec0b44dfd4b3991aa94554e9c829642 Reviewed-by: Jan Arve Sæther --- src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 982c98976b..e743dd56bf 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -537,7 +537,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of - (void)accessibilityPerformAction:(NSString *)action { QAccessibleInterface *iface = QAccessible::accessibleInterface(axid); - if (iface) { + if (iface && iface->isValid()) { const QString qtAction = QCocoaAccessible::translateAction(action, iface); QAccessibleBridgeUtils::performEffectiveAction(iface, qtAction); } @@ -562,16 +562,16 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of int y = qt_mac_flipYCoordinate(point.y); QAccessibleInterface *childInterface = iface->childAt(point.x, y); // No child found, meaning we hit this element. - if (!childInterface) + if (!childInterface || !childInterface->isValid()) return NSAccessibilityUnignoredAncestor(self); // find the deepest child at the point QAccessibleInterface *childOfChildInterface = 0; do { childOfChildInterface = childInterface->childAt(point.x, y); - if (childOfChildInterface) + if (childOfChildInterface && childOfChildInterface->isValid()) childInterface = childOfChildInterface; - } while (childOfChildInterface); + } while (childOfChildInterface && childOfChildInterface->isValid()); QAccessible::Id childId = QAccessible::uniqueId(childInterface); // hit a child, forward to child accessible interface. @@ -590,7 +590,7 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of } QAccessibleInterface *childInterface = iface->focusChild(); - if (childInterface) { + if (childInterface && childInterface->isValid()) { QAccessible::Id childAxid = QAccessible::uniqueId(childInterface); QMacAccessibilityElement *accessibleElement = [QMacAccessibilityElement elementWithId:childAxid]; return NSAccessibilityUnignoredAncestor(accessibleElement); -- cgit v1.2.1 From 25b00c88b6fda2eecd9ff566ab44974136dabf51 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 10 Jan 2017 10:56:34 +0100 Subject: cocoa: Account for getting a keyboard using input methods correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a keyboard is using an input method then the layout for it needs to be retrieved with TISCopyInputMethodKeyboardLayoutOverride(). For cases where it is not using an input method this will return null and in that case we can use the original approach as before. Task-number: QTBUG-53804 Task-number: QTBUG-57934 Change-Id: I6283785bf002602113e208bb38d5eb2a9a7ceb36 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoakeymapper.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoakeymapper.mm b/src/plugins/platforms/cocoa/qcocoakeymapper.mm index e7952ae1f6..1ef7f11011 100644 --- a/src/plugins/platforms/cocoa/qcocoakeymapper.mm +++ b/src/plugins/platforms/cocoa/qcocoakeymapper.mm @@ -366,7 +366,9 @@ Qt::KeyboardModifiers QCocoaKeyMapper::queryKeyboardModifiers() bool QCocoaKeyMapper::updateKeyboard() { const UCKeyboardLayout *uchrData = 0; - QCFType source = TISCopyCurrentKeyboardInputSource(); + QCFType source = TISCopyInputMethodKeyboardLayoutOverride(); + if (!source) + source = TISCopyCurrentKeyboardInputSource(); if (keyboard_mode != NullMode && source == currentInputSource) { return false; } -- cgit v1.2.1 From 64666b9ee0a0dc0a356e825a519fde566bddd2c9 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 10 Jan 2017 08:50:57 +0100 Subject: Windows: Check if the fallback key matches the shift modifier case too There are some keyboard layouts where pressing shift will give something different to what the expected key would be. For example, on a French keyboard layout, pressing SHIFT+! gives 1 as opposed to SHIFT+1 giving ! on a US keyboard layout. Therefore it should check against both cases to ensure it does not end up adding a new entry. Task-number: QTBUG-57938 Change-Id: I11c52619c048b98500f2d79876bb912720af6e65 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowskeymapper.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index 00c4a6191e..b84b586f7c 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -703,7 +703,8 @@ void QWindowsKeyMapper::updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 quint32 fallbackKey = winceKeyBend(vk_key); if (!fallbackKey || fallbackKey == Qt::Key_unknown) { fallbackKey = 0; - if (vk_key != keyLayout[vk_key].qtKey[0] && vk_key < 0x5B && vk_key > 0x2F) + if (vk_key != keyLayout[vk_key].qtKey[0] && vk_key != keyLayout[vk_key].qtKey[1] + && vk_key < 0x5B && vk_key > 0x2F) fallbackKey = vk_key; } keyLayout[vk_key].qtKey[8] = fallbackKey; -- cgit v1.2.1 From c5332859c801c44f11269d7a4e65cdd43031784a Mon Sep 17 00:00:00 2001 From: Dmitry Chmerev Date: Tue, 10 Jan 2017 20:11:04 +0300 Subject: Fix QRect calculation in inputItemRectangle Because of QRect's width and height are caluculated values, they got spoiled after x and y values setting. This bug affects, in particular, Android software keyboard appearance: it could overlap focused input field. Change-Id: I27ccca27111219818722951fe6f463388d76c702 Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart (Woboq GmbH) Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroidinputcontext.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 12e85046f8..4ab8a9d060 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -354,10 +354,10 @@ static QRect inputItemRectangle() ? QHighDpiScaling::factor(window) : QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen()); if (pixelDensity != 1.0) { - rect.setX(rect.x() * pixelDensity); - rect.setY(rect.y() * pixelDensity); - rect.setWidth(rect.width() * pixelDensity); - rect.setHeight(rect.height() * pixelDensity); + rect.setRect(rect.x() * pixelDensity, + rect.y() * pixelDensity, + rect.width() * pixelDensity, + rect.height() * pixelDensity); } return rect; } -- cgit v1.2.1 From 63baad4a3d39feb53dc52a9ff2270f6d06bf34fa Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Tue, 10 Jan 2017 13:03:42 -0800 Subject: macOS: convey correct mouse coordinates on drag release Task-number: QTBUG-57129 Change-Id: I6eb60c35bfaf63199d0f637bf2d579fadab0a644 Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.mm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index a63bc4d570..ba91d3e40e 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -2193,7 +2193,8 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin } NSPoint windowPoint = [self.window convertRectFromScreen:NSMakeRect(screenPoint.x, screenPoint.y, 1, 1)].origin; - QPoint qtWindowPoint(windowPoint.x, windowPoint.y); + NSPoint nsViewPoint = [self convertPoint: windowPoint fromView: nil]; // NSView/QWindow coordinates + QPoint qtWindowPoint(nsViewPoint.x, nsViewPoint.y); QPoint qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y)); -- cgit v1.2.1 From 483ee17419a4f4bbdfa4369e703ef3a75b81531b Mon Sep 17 00:00:00 2001 From: Joni Poikelin Date: Fri, 2 Dec 2016 14:43:57 +0200 Subject: xcb: Fix colormap memory leak Change-Id: I54880c10dc089c2cd17184dcbab17fde3af6452c Reviewed-by: Louai Al-Khanji Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbwindow.cpp | 11 +++++++---- src/plugins/platforms/xcb/qxcbwindow.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 3204fab197..ffbe9a2325 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -315,6 +315,7 @@ static const char *wm_window_role_property_id = "_q_xcb_wm_window_role"; QXcbWindow::QXcbWindow(QWindow *window) : QPlatformWindow(window) , m_window(0) + , m_cmap(0) , m_syncCounter(0) , m_gravity(XCB_GRAVITY_STATIC) , m_mapped(false) @@ -443,7 +444,6 @@ void QXcbWindow::create() m_visualId = visual->visual_id; m_depth = platformScreen->depthOfVisual(m_visualId); m_imageFormat = imageFormatForVisual(m_depth, visual->red_mask, visual->blue_mask, &m_imageRgbSwap); - xcb_colormap_t colormap = 0; quint32 mask = XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL @@ -455,10 +455,10 @@ void QXcbWindow::create() static const bool haveOpenGL = QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL); if ((window()->supportsOpenGL() && haveOpenGL) || m_format.hasAlpha()) { - colormap = xcb_generate_id(xcb_connection()); + m_cmap = xcb_generate_id(xcb_connection()); Q_XCB_CALL(xcb_create_colormap(xcb_connection(), XCB_COLORMAP_ALLOC_NONE, - colormap, + m_cmap, xcb_parent_id, m_visualId)); @@ -472,7 +472,7 @@ void QXcbWindow::create() type == Qt::Popup || type == Qt::ToolTip || (window()->flags() & Qt::BypassWindowManagerHint), type == Qt::Popup || type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip || type == Qt::Drawer, defaultEventMask, - colormap + m_cmap }; m_window = xcb_generate_id(xcb_connection()); @@ -638,6 +638,9 @@ void QXcbWindow::destroy() Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window)); m_window = 0; } + if (m_cmap) { + xcb_free_colormap(xcb_connection(), m_cmap); + } m_mapped = false; if (m_pendingSyncRequest) diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index cfa4964151..d100120d46 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -234,6 +234,7 @@ protected: quint8 mode, quint8 detail, xcb_timestamp_t timestamp); xcb_window_t m_window; + xcb_colormap_t m_cmap; uint m_depth; QImage::Format m_imageFormat; -- cgit v1.2.1 From 21306bccc4fef8c78d550946ec4d7a5426eb5b0d Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Fri, 13 Jan 2017 17:29:17 +0900 Subject: Fix build without feature.tabletevent Change-Id: I13950e184453318671e4cac6dac844e76771f430 Reviewed-by: Lars Knoll --- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index f4f56f25f1..d91cbfe82d 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -1032,6 +1032,7 @@ bool QXcbConnection::isTouchScreen(int id) const && device->qtTouchDevice->type() == QTouchDevice::TouchScreen; } +#if QT_CONFIG(tabletevent) static QTabletEvent::TabletDevice toolIdToTabletDevice(quint32 toolId) { // keep in sync with wacom_intuos_inout() in Linux kernel driver wacom_wac.c switch (toolId) { @@ -1065,7 +1066,6 @@ static QTabletEvent::TabletDevice toolIdToTabletDevice(quint32 toolId) { return QTabletEvent::Stylus; // Safe default assumption if nonzero } -#ifndef QT_NO_TABLETEVENT bool QXcbConnection::xi2HandleTabletEvent(const void *event, TabletData *tabletData) { bool handled = true; -- cgit v1.2.1 From 23ba2f073cf163b379312d5086a880c7ec040209 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 12 Jan 2017 16:04:33 +0100 Subject: Windows QPA: Fix QScreen::grabWindow(0) for non-primary screens Previously, the code grabbed the client rectangle of GetDesktopWindow(), which is always the primary screen. Fix by using the geometry of the QPlatformScreen. In addition, subtract x, y from the effective size when sizes < 0 were passed in as does XCB. Task-number: QTBUG-58110 Change-Id: I6ed439d2e1da8affd0a1475717d5570017fb1f2b Reviewed-by: Oliver Wolff Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowsscreen.cpp | 28 +++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 23d43a95a5..7a885b462e 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -188,14 +188,30 @@ QWindowsScreen::QWindowsScreen(const QWindowsScreenData &data) : Q_GUI_EXPORT QPixmap qt_pixmapFromWinHBITMAP(HBITMAP bitmap, int hbitmapFormat = 0); -QPixmap QWindowsScreen::grabWindow(WId window, int x, int y, int width, int height) const +QPixmap QWindowsScreen::grabWindow(WId window, int xIn, int yIn, int width, int height) const { - RECT r; - HWND hwnd = window ? reinterpret_cast(window) : GetDesktopWindow(); - GetClientRect(hwnd, &r); + QSize windowSize; + int x = xIn; + int y = yIn; + HWND hwnd = reinterpret_cast(window); + if (hwnd) { + RECT r; + GetClientRect(hwnd, &r); + windowSize = QSize(r.right - r.left, r.bottom - r.top); + } else { + // Grab current screen. The client rectangle of GetDesktopWindow() is the + // primary screen, but it is possible to grab other screens from it. + hwnd = GetDesktopWindow(); + const QRect screenGeometry = geometry(); + windowSize = screenGeometry.size(); + x += screenGeometry.x(); + y += screenGeometry.y(); + } - if (width < 0) width = r.right - r.left; - if (height < 0) height = r.bottom - r.top; + if (width < 0) + width = windowSize.width() - xIn; + if (height < 0) + height = windowSize.height() - yIn; // Create and setup bitmap HDC display_dc = GetDC(0); -- cgit v1.2.1 From 88932d4339ea604a1bea8c09aef3945ac348df9c Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Wed, 18 Jan 2017 13:31:06 +0100 Subject: Android: transform input rectangle correctly QRect::setX/setY will change both position and size. In this case, the width and/or height of the input rectangle could end up negative. The correct functions to use are moveLeft/moveTop which will preserve the size when changing the position. Task-number: QTBUG-58179 Change-Id: I71a2e38958754dc53e062ad1c780e2337f72ec32 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/android/qandroidinputcontext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 12e85046f8..436e41bad5 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -354,8 +354,8 @@ static QRect inputItemRectangle() ? QHighDpiScaling::factor(window) : QHighDpiScaling::factor(QtAndroid::androidPlatformIntegration()->screen()); if (pixelDensity != 1.0) { - rect.setX(rect.x() * pixelDensity); - rect.setY(rect.y() * pixelDensity); + rect.moveLeft(rect.x() * pixelDensity); + rect.moveTop(rect.y() * pixelDensity); rect.setWidth(rect.width() * pixelDensity); rect.setHeight(rect.height() * pixelDensity); } -- cgit v1.2.1 From 49dc9aa409d727824f26b246054a22b5a7dd5980 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 17 Jan 2017 10:40:18 +0100 Subject: Windows QPA: Do not return QPlatformIntegration::ShowIsMaximized in tablet mode The hint is not appropriate for Windows 10 tablet mode as it affects only main windows. Dialogs should still show up in normal size. Partially reverts change d377f14fd5b4fe3ed64392c6b743bac395f9f891. Task-number: QTBUG-58227 Change-Id: If9cf4990eb40913904cd97e17a7622bc6cbe84ca Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/windows/qwindowsintegration.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index f49ad0e767..3f74fd5296 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -512,11 +512,6 @@ QVariant QWindowsIntegration::styleHint(QPlatformIntegration::StyleHint hint) co return QVariant(keyBoardAutoRepeatRateMS()); #endif case QPlatformIntegration::ShowIsMaximized: -#ifndef QT_NO_CLIPBOARD - return qt_windowsIsTabletMode(d->m_clipboard.clipboardViewer()); -#else - break; -#endif case QPlatformIntegration::StartDragTime: case QPlatformIntegration::StartDragDistance: case QPlatformIntegration::KeyboardInputInterval: -- cgit v1.2.1 From 3edeb5c909a4ec62440e2075b9d49ec256a1ba68 Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Wed, 18 Jan 2017 11:09:37 -0800 Subject: Cocoa: fix regression preventing windows from showing up The regression was introduced by 593ab638609 which fixed another bug related to window modality. To determine whether the window needs to be (made key and ordered front) or just (ordered front), instead of calling currentModalSession() which might change internal state of event dispatcher we just check if cocoaModalSessionStack is empty or not. Task-number: QTBUG-57991 Task-number: QTBUG-56166 Change-Id: I6c4f92860d8c93decd44e572af1690ed7be6f1f0 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 602da0a175..40666772c5 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -695,7 +695,7 @@ void QCocoaWindow::setVisible(bool visible) if (cocoaEventDispatcher) cocoaEventDispatcherPrivate = static_cast(QObjectPrivate::get(cocoaEventDispatcher)); - if (!(cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->currentModalSession())) + if (cocoaEventDispatcherPrivate && cocoaEventDispatcherPrivate->cocoaModalSessionStack.isEmpty()) [m_nsWindow makeKeyAndOrderFront:nil]; else [m_nsWindow orderFront:nil]; -- cgit v1.2.1 From 7780ee9e5f20f80ab9e053058d0b6d92586cf876 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Mon, 16 Jan 2017 13:26:09 +0100 Subject: Windows QPA: Call InvalidateRect() in WM_PAINT/GL Software rendering Bring back the call to InvalidateRect() removed by change 6086c81e4d999d88ce4d412 since it seems that GL Software rendering requires it (also for single buffer mode). Task-number: QTBUG-58178 Change-Id: I197a1b3c3906c4afa43943db30dbc07dfb656cc7 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowswindow.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index a9b061ad73..6894062d61 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -43,7 +43,7 @@ #include "qwindowsscreen.h" #include "qwindowsintegration.h" #include "qwindowsnativeinterface.h" -#include "qwindowsopenglcontext.h" +#include "qwindowsglcontext.h" #ifdef QT_NO_CURSOR # include "qwindowscursor.h" #endif @@ -1582,6 +1582,16 @@ bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message, return false; PAINTSTRUCT ps; +#if QT_CONFIG(dynamicgl) + // QTBUG-58178: GL software rendering needs InvalidateRect() to suppress + // artifacts while resizing. + if (testFlag(OpenGLSurface) + && QOpenGLStaticContext::opengl32.moduleIsNotOpengl32() + && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) { + InvalidateRect(hwnd, 0, false); + } +#endif // dynamicgl + BeginPaint(hwnd, &ps); // Observed painting problems with Aero style disabled (QTBUG-7865). -- cgit v1.2.1 From 4d49f94060e20c5e47a587cc630a40718d91e62c Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Thu, 19 Jan 2017 14:25:12 -0800 Subject: Cocoa: fix bug when left mouse button release event delivered as right The regression was introduced during refactoring by 820e69d6c and the initial change that added this logic is adc3ef97d. This condition had become redundant and wrong after refactoring because m_sendUpAsRightButton flag is set in the proper way in QNSView::mouseDown() which later calls QNSView::handleMouseEvent() anyway. Task-number: QTBUG-58219 Change-Id: I1951cf4067af6f0c1837c1c15b8a09dfe7939493 Reviewed-by: Timur Pocheptsov Reviewed-by: Pavol Markovic --- src/plugins/platforms/cocoa/qnsview.mm | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index ba91d3e40e..970ce9e785 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -853,9 +853,6 @@ static bool _q_dontOverrideCtrlLMB = false; if (masked) return false; - if (button == Qt::RightButton) - m_sendUpAsRightButton = true; - m_buttons |= button; [self handleMouseEvent:theEvent]; -- cgit v1.2.1 From 79352528a1726b4551ea4d9285dd2394dd0d43da Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 16 Nov 2016 10:53:44 +0100 Subject: Windows QPA: Prevent usage of child windows as transient parent When using foreign window integrations such as MFC/winmigrate, it is possible that a child window is found which can cause issues with modality. Loop up to top level. Task-number: QTSOLBUG-71 Task-number: QTBUG-57159 Change-Id: Ib36e0f8f4f6b1e22ba1240013871facef2c0c1ab Reviewed-by: Andy Shaw --- src/plugins/platforms/windows/qwindowswindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 6894062d61..b5522c1f90 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1273,6 +1273,12 @@ void QWindowsWindow::updateTransientParent() const if (const QWindowsWindow *tw = QWindowsWindow::windowsWindowOf(tp)) if (!tw->testFlag(WithinDestroy)) // Prevent destruction by parent window (QTBUG-35499, QTBUG-36666) newTransientParent = tw->handle(); + + // QTSOLBUG-71: When using the MFC/winmigrate solution, it is possible that a child + // window is found, which can cause issues with modality. Loop up to top level. + while (newTransientParent && (GetWindowLongPtr(newTransientParent, GWL_STYLE) & WS_CHILD) != 0) + newTransientParent = GetParent(newTransientParent); + if (newTransientParent != oldTransientParent) SetWindowLongPtr(m_data.hwnd, GWL_HWNDPARENT, LONG_PTR(newTransientParent)); } -- cgit v1.2.1 From dd52fd0024600d3beffc82d6da02b4239a62d725 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 17 Jan 2017 17:05:00 +0100 Subject: Ensure a pixel density of at least 1 for Qt::AA_EnableHighDpiScaling Very large 1080p TVs or any display which is running at an abnormally low resolution can have a DPI lower than 48, which means that qRound(dpi/96) will result in a 0 pixel density, causing critical issues for applications using Qt::AA_EnableHighDpiScaling. Make sure that we always have a pixel density of at least 1 to allow applications not having to worry about such displays. Task-number: QTBUG-56140 Change-Id: I1dafbf7794a99ae6f872984c0337d8ff0d1fc1c0 Reviewed-by: Shawn Rutledge Reviewed-by: Friedemann Kleint --- src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp | 2 +- src/plugins/platforms/windows/qwindowsscreen.cpp | 2 +- src/plugins/platforms/winrt/qwinrtscreen.cpp | 2 +- src/plugins/platforms/xcb/qxcbscreen.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp index 3e1e93f1e4..863a115b74 100644 --- a/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp +++ b/src/plugins/platforms/eglfs/api/qeglfsdeviceintegration.cpp @@ -226,7 +226,7 @@ QDpi QEglFSDeviceIntegration::logicalDpi() const qreal QEglFSDeviceIntegration::pixelDensity() const { - return qRound(logicalDpi().first / qreal(100)); + return qMax(1, qRound(logicalDpi().first / qreal(100))); } Qt::ScreenOrientation QEglFSDeviceIntegration::nativeOrientation() const diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index 7a885b462e..c70323c06f 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -265,7 +265,7 @@ qreal QWindowsScreen::pixelDensity() const // the pixel density since it is reflects the Windows UI scaling. // High DPI auto scaling should be disabled when the user chooses // small fonts on a High DPI monitor, resulting in lower logical DPI. - return qRound(logicalDpi().first / 96); + return qMax(1, qRound(logicalDpi().first / 96)); } /*! diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index f87ae9fd24..2a4b6c8907 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -647,7 +647,7 @@ QDpi QWinRTScreen::logicalDpi() const qreal QWinRTScreen::pixelDensity() const { Q_D(const QWinRTScreen); - return qRound(d->logicalDpi / 96); + return qMax(1, qRound(d->logicalDpi / 96)); } qreal QWinRTScreen::scaleFactor() const diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index a9675935f4..d8facdbb84 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -631,7 +631,7 @@ void QXcbScreen::updateGeometry(const QRect &geom, uint8_t rotation) m_sizeMillimeters = sizeInMillimeters(xGeometry.size(), virtualDpi()); qreal dpi = xGeometry.width() / physicalSize().width() * qreal(25.4); - m_pixelDensity = qRound(dpi/96); + m_pixelDensity = qMax(1, qRound(dpi/96)); m_geometry = QRect(xGeometry.topLeft(), xGeometry.size()); m_availableGeometry = xGeometry & m_virtualDesktop->workArea(); QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry); -- cgit v1.2.1 From 1b1686d194731d940a40112635647536ac8ee676 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 22 Nov 2016 15:35:24 +0100 Subject: Fix mouse extra button mapping on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously extra mouse buttons apart from left, right and middle buttons, were mapped incorrectly with an offset of -1. This resulted in the first extra button being recognized as the middle button, the second extra button as the first extra button, etc. Fix consists in using a binary shift with proper offset to create the corresponding Qt::MouseButton value. [ChangeLog][macOS] Fixed extra mouse buttons to be mapped to correct Qt::MouseButton values. Change-Id: I9e6084586cd4737a172b7706a805211f0edff749 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoahelpers.mm | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 01fbb7bad2..3ab6b641fa 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -281,16 +281,8 @@ NSRect qt_mac_flipRect(const QRect &rect) Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum) { - if (buttonNum == 0) - return Qt::LeftButton; - if (buttonNum == 1) - return Qt::RightButton; - if (buttonNum == 2) - return Qt::MiddleButton; - if (buttonNum >= 3 && buttonNum <= 31) { // handle XButton1 and higher via logical shift - return Qt::MouseButton(uint(Qt::MiddleButton) << (buttonNum - 3)); - } - // else error: buttonNum too high, or negative + if (buttonNum >= 0 && buttonNum <= 31) + return Qt::MouseButton(1 << buttonNum); return Qt::NoButton; } -- cgit v1.2.1 From 0c415793b9622eef2148fdd21a2f3c2394a78d99 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 25 May 2016 11:51:17 +0200 Subject: Windows QPA: More fine-grained suppression of geometry/state change events When switching windows from fullscreen to maximized, move and resize events are triggered when changing the window decorations, ending up in QWindowsWindow::handleResized(), QWindowsWindow::handleMoved() which then may call handleGeometryChange(). Change 917ef5787444403ce0f7f035e27b1740c7672e34 blocks the emission of events depending on flag WithinSetStyle from handleGeometryChange() for Windows CE. This has issues which become visible when switching from fullscreen to maximized repeatedly: - State change events are still sent from QWindowsWindow::handleResized(), QWindowsWindow::handleMoved() when changing the window style programmatically causing the maximized state to be lost after a few cycles(QTBUG-53368). - Geometry change events are actually needed on the desktop for proper redrawing (QTBUG-53577). Make this more fine-grained by suppressing all state changed events while WithinSetStyle is set and allowing geometry changes. Amends 917ef5787444403ce0f7f035e27b1740c7672e34. Task-number: QTBUG-53368 Task-number: QTBUG-53577 Change-Id: Icc8dc935cfc29b314aab2d6fac02c97174c79c3e Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowswindow.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 5edf40b886..fb69936772 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1488,18 +1488,22 @@ void QWindowsWindow::handleResized(int wParam) case SIZE_MAXHIDE: // Some other window affected. case SIZE_MAXSHOW: return; - case SIZE_MINIMIZED: - handleWindowStateChange(Qt::WindowMinimized); + case SIZE_MINIMIZED: // QTBUG-53577, prevent state change events during programmatic state change + if (!testFlag(WithinSetStyle)) + handleWindowStateChange(Qt::WindowMinimized); return; case SIZE_MAXIMIZED: - handleWindowStateChange(Qt::WindowMaximized); + if (!testFlag(WithinSetStyle)) + handleWindowStateChange(Qt::WindowMaximized); handleGeometryChange(); break; case SIZE_RESTORED: - if (isFullScreen_sys()) - handleWindowStateChange(Qt::WindowFullScreen); - else if (m_windowState != Qt::WindowNoState && !testFlag(MaximizeToFullScreen)) - handleWindowStateChange(Qt::WindowNoState); + if (!testFlag(WithinSetStyle)) { + if (isFullScreen_sys()) + handleWindowStateChange(Qt::WindowFullScreen); + else if (m_windowState != Qt::WindowNoState && !testFlag(MaximizeToFullScreen)) + handleWindowStateChange(Qt::WindowNoState); + } handleGeometryChange(); break; } @@ -1507,9 +1511,6 @@ void QWindowsWindow::handleResized(int wParam) void QWindowsWindow::handleGeometryChange() { - //Prevent recursive resizes for Windows CE - if (testFlag(WithinSetStyle)) - return; const QRect previousGeometry = m_data.geometry; m_data.geometry = geometry_sys(); QPlatformWindow::setGeometry(m_data.geometry); -- cgit v1.2.1 From b6967d0c11a6f559350c105973780445e253d6b3 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 13 Jan 2017 09:56:59 +0100 Subject: XCB QPA: Fix QScreen::grabWindow(0) to return the current screen Previously, the code queried the window to be grabbed for the geometry and thus returned the entire virtual desktop for multi screen setups. Use the QPlatformScreen's geometry in case of WID = 0. Task-number: QTBUG-58110 Change-Id: I3a9c0b0b3ea057f5e58f272f5c3fd40fafc073ba Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbscreen.cpp | 117 ++++++++++++++++--------------- 1 file changed, 59 insertions(+), 58 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index d8facdbb84..0ad9c97521 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -678,85 +678,88 @@ void QXcbScreen::updateRefreshRate(xcb_randr_mode_t mode) } } -QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height) const +static xcb_get_geometry_reply_t *getGeometryUnchecked(xcb_connection_t *connection, xcb_window_t window) +{ + const xcb_get_geometry_cookie_t geometry_cookie = xcb_get_geometry_unchecked(connection, window); + return xcb_get_geometry_reply(connection, geometry_cookie, NULL); +} + +static inline bool translate(xcb_connection_t *connection, xcb_window_t child, xcb_window_t parent, + int *x, int *y) +{ + const xcb_translate_coordinates_cookie_t translate_cookie = + xcb_translate_coordinates_unchecked(connection, child, parent, *x, *y); + xcb_translate_coordinates_reply_t *translate_reply = + xcb_translate_coordinates_reply(connection, translate_cookie, NULL); + if (!translate_reply) + return false; + *x = translate_reply->dst_x; + *y = translate_reply->dst_y; + free(translate_reply); + return true; +} + +QPixmap QXcbScreen::grabWindow(WId window, int xIn, int yIn, int width, int height) const { if (width == 0 || height == 0) return QPixmap(); - // TODO: handle multiple screens + int x = xIn; + int y = yIn; QXcbScreen *screen = const_cast(this); xcb_window_t root = screen->root(); - if (window == 0) - window = root; - - xcb_get_geometry_cookie_t geometry_cookie = xcb_get_geometry_unchecked(xcb_connection(), window); - - xcb_get_geometry_reply_t *reply = - xcb_get_geometry_reply(xcb_connection(), geometry_cookie, NULL); - - if (!reply) { + xcb_get_geometry_reply_t *rootReply = getGeometryUnchecked(xcb_connection(), root); + if (!rootReply) return QPixmap(); - } - - if (width < 0) - width = reply->width - x; - if (height < 0) - height = reply->height - y; - - geometry_cookie = xcb_get_geometry_unchecked(xcb_connection(), root); - xcb_get_geometry_reply_t *root_reply = - xcb_get_geometry_reply(xcb_connection(), geometry_cookie, NULL); - if (!root_reply) { - free(reply); - return QPixmap(); - } - - if (reply->depth == root_reply->depth) { - // if the depth of the specified window and the root window are the - // same, grab pixels from the root window (so that we get the any - // overlapping windows and window manager frames) - - // map x and y to the root window - xcb_translate_coordinates_cookie_t translate_cookie = - xcb_translate_coordinates_unchecked(xcb_connection(), window, root, x, y); + const quint8 rootDepth = rootReply->depth; + free(rootReply); - xcb_translate_coordinates_reply_t *translate_reply = - xcb_translate_coordinates_reply(xcb_connection(), translate_cookie, NULL); - - if (!translate_reply) { - free(reply); - free(root_reply); + QSize windowSize; + quint8 effectiveDepth = 0; + if (window) { + xcb_get_geometry_reply_t *windowReply = getGeometryUnchecked(xcb_connection(), window); + if (!windowReply) return QPixmap(); + windowSize = QSize(windowReply->width, windowReply->height); + effectiveDepth = windowReply->depth; + free(windowReply); + if (effectiveDepth == rootDepth) { + // if the depth of the specified window and the root window are the + // same, grab pixels from the root window (so that we get the any + // overlapping windows and window manager frames) + + // map x and y to the root window + if (!translate(xcb_connection(), window, root, &x, &y)) + return QPixmap(); + + window = root; } - - x = translate_reply->dst_x; - y = translate_reply->dst_y; - - window = root; - - free(translate_reply); - free(reply); - reply = root_reply; } else { - free(root_reply); - root_reply = 0; + window = root; + effectiveDepth = rootDepth; + windowSize = m_geometry.size(); + x += m_geometry.x(); + y += m_geometry.y(); } + if (width < 0) + width = windowSize.width() - xIn; + if (height < 0) + height = windowSize.height() - yIn; + xcb_get_window_attributes_reply_t *attributes_reply = xcb_get_window_attributes_reply(xcb_connection(), xcb_get_window_attributes_unchecked(xcb_connection(), window), NULL); - if (!attributes_reply) { - free(reply); + if (!attributes_reply) return QPixmap(); - } const xcb_visualtype_t *visual = screen->visualForId(attributes_reply->visual); free(attributes_reply); xcb_pixmap_t pixmap = xcb_generate_id(xcb_connection()); - xcb_create_pixmap(xcb_connection(), reply->depth, pixmap, window, width, height); + xcb_create_pixmap(xcb_connection(), effectiveDepth, pixmap, window, width, height); uint32_t gc_value_mask = XCB_GC_SUBWINDOW_MODE; uint32_t gc_value_list[] = { XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS }; @@ -766,9 +769,7 @@ QPixmap QXcbScreen::grabWindow(WId window, int x, int y, int width, int height) xcb_copy_area(xcb_connection(), window, pixmap, gc, x, y, 0, 0, width, height); - QPixmap result = qt_xcb_pixmapFromXPixmap(connection(), pixmap, width, height, reply->depth, visual); - - free(reply); + QPixmap result = qt_xcb_pixmapFromXPixmap(connection(), pixmap, width, height, effectiveDepth, visual); xcb_free_gc(xcb_connection(), gc); xcb_free_pixmap(xcb_connection(), pixmap); -- cgit v1.2.1 From d03ba0e895a3719ce527f3d7ee9262fb26065332 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 17 Nov 2016 15:01:59 +0100 Subject: Optimize debug builds when -Og is available Enables optimizing with -Og if GCC has the option available, this should produce faster debug binaries without compromising debugability. Is a privateConfig to limit it to the default Qt build. Includes two fixes for false positives of maybe_uninitialized triggered by -Og on gcc 4.9. Change-Id: I466d7a4070295714189024369312e6cbd36cfacf Reviewed-by: Oswald Buddenhagen --- .../eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp index 0a547b832f..64d0d9b515 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_x11/qeglfsx11integration.cpp @@ -114,7 +114,7 @@ void EventReader::run() { Qt::MouseButtons buttons; - xcb_generic_event_t *event; + xcb_generic_event_t *event = nullptr; while (running.load() && (event = xcb_wait_for_event(m_integration->connection()))) { uint response_type = event->response_type & ~0x80; switch (response_type) { -- cgit v1.2.1 From 1aea3c1229556d2a692194c615844579f315e3be Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 27 Jan 2017 13:11:04 +0100 Subject: XCB: Use member initialization Shorten or remove constructors accordingly. Change-Id: I9c8bcf512c922c3c72be8a965d9557589bc9874f Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/qxcbclipboard.cpp | 5 -- src/plugins/platforms/xcb/qxcbclipboard.h | 10 +-- src/plugins/platforms/xcb/qxcbconnection.cpp | 28 +----- src/plugins/platforms/xcb/qxcbconnection.h | 99 +++++++++++----------- src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 14 +-- src/plugins/platforms/xcb/qxcbkeyboard.cpp | 6 -- src/plugins/platforms/xcb/qxcbkeyboard.h | 14 +-- src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 3 +- src/plugins/platforms/xcb/qxcbnativeinterface.h | 2 +- src/plugins/platforms/xcb/qxcbscreen.cpp | 11 --- src/plugins/platforms/xcb/qxcbscreen.h | 30 +++---- .../platforms/xcb/qxcbsystemtraytracker.cpp | 1 - src/plugins/platforms/xcb/qxcbsystemtraytracker.h | 2 +- src/plugins/platforms/xcb/qxcbwindow.cpp | 16 ---- src/plugins/platforms/xcb/qxcbwindow.h | 42 ++++----- 15 files changed, 104 insertions(+), 179 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/xcb/qxcbclipboard.cpp b/src/plugins/platforms/xcb/qxcbclipboard.cpp index cee011bbdf..6a5d40267a 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.cpp +++ b/src/plugins/platforms/xcb/qxcbclipboard.cpp @@ -267,11 +267,6 @@ const int QXcbClipboard::clipboard_timeout = 5000; QXcbClipboard::QXcbClipboard(QXcbConnection *c) : QXcbObject(c), QPlatformClipboard() - , m_requestor(XCB_NONE) - , m_owner(XCB_NONE) - , m_incr_active(false) - , m_clipboard_closing(false) - , m_incr_receive_time(0) { Q_ASSERT(QClipboard::Clipboard == 0); Q_ASSERT(QClipboard::Selection == 1); diff --git a/src/plugins/platforms/xcb/qxcbclipboard.h b/src/plugins/platforms/xcb/qxcbclipboard.h index a0a4f4e5a1..bfeae13e10 100644 --- a/src/plugins/platforms/xcb/qxcbclipboard.h +++ b/src/plugins/platforms/xcb/qxcbclipboard.h @@ -102,14 +102,14 @@ private: QMimeData *m_clientClipboard[2]; xcb_timestamp_t m_timestamp[2]; - xcb_window_t m_requestor; - xcb_window_t m_owner; + xcb_window_t m_requestor = XCB_NONE; + xcb_window_t m_owner = XCB_NONE; static const int clipboard_timeout; - bool m_incr_active; - bool m_clipboard_closing; - xcb_timestamp_t m_incr_receive_time; + bool m_incr_active = false; + bool m_clipboard_closing = false; + xcb_timestamp_t m_incr_receive_time = 0; }; #endif // QT_NO_CLIPBOARD diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 915c29edcc..3444b21654 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -552,32 +552,10 @@ void QXcbConnection::initializeScreens() } QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGrabServer, xcb_visualid_t defaultVisualId, const char *displayName) - : m_connection(0) - , m_canGrabServer(canGrabServer) + : m_canGrabServer(canGrabServer) , m_defaultVisualId(defaultVisualId) - , m_primaryScreenNumber(0) , m_displayName(displayName ? QByteArray(displayName) : qgetenv("DISPLAY")) , m_nativeInterface(nativeInterface) -#ifdef XCB_USE_XLIB - , m_xlib_display(0) -#endif - , xfixes_first_event(0) - , xrandr_first_event(0) - , xkb_first_event(0) - , has_xinerama_extension(false) - , has_shape_extension(false) - , has_randr_extension(false) - , has_input_shape(false) - , has_xkb(false) - , m_buttons(0) - , m_focusWindow(0) - , m_mouseGrabber(0) - , m_mousePressWindow(0) - , m_clientLeader(0) - , m_systemTrayTracker(0) - , m_glIntegration(Q_NULLPTR) - , m_xiGrab(false) - , m_qtSelectionOwner(0) { #ifdef XCB_USE_XLIB Display *dpy = XOpenDisplay(m_displayName.constData()); @@ -618,9 +596,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra initializeAllAtoms(); - m_time = XCB_CURRENT_TIME; - m_netWmUserTime = XCB_CURRENT_TIME; - if (!qEnvironmentVariableIsSet("QT_XCB_NO_XRANDR")) initializeXRandr(); if (!has_randr_extension) @@ -630,7 +605,6 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra initializeXRender(); #if defined(XCB_USE_XINPUT2) - m_xi2Enabled = false; initializeXInput2(); #endif initializeXShape(); diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 19c076e888..7f0d5cf2cc 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -551,10 +551,9 @@ private: void destroyScreen(QXcbScreen *screen); void initializeScreens(); bool compressEvent(xcb_generic_event_t *event, int currentIndex, QXcbEventArray *eventqueue) const; - #ifdef XCB_USE_XINPUT2 - bool m_xi2Enabled; - int m_xi2Minor; + bool m_xi2Enabled = false; + int m_xi2Minor = 2; void initializeXInput2(); void finalizeXInput2(); void xi2SetupDevices(); @@ -568,20 +567,17 @@ private: #endif // XCB_USE_XINPUT22 #ifndef QT_NO_TABLETEVENT struct TabletData { - TabletData() : deviceId(0), pointerType(QTabletEvent::UnknownPointer), - tool(QTabletEvent::Stylus), buttons(0), serialId(0), inProximity(false) { } - int deviceId; - QTabletEvent::PointerType pointerType; - QTabletEvent::TabletDevice tool; - Qt::MouseButtons buttons; - qint64 serialId; - bool inProximity; + int deviceId = 0; + QTabletEvent::PointerType pointerType = QTabletEvent::UnknownPointer; + QTabletEvent::TabletDevice tool = QTabletEvent::Stylus; + Qt::MouseButtons buttons = 0; + qint64 serialId = 0; + bool inProximity = false; struct ValuatorClassInfo { - ValuatorClassInfo() : minVal(0.), maxVal(0.), curVal(0.) { } - double minVal; - double maxVal; - double curVal; - int number; + double minVal = 0; + double maxVal = 0; + double curVal = 0; + int number = -1; }; QHash valuatorInfo; }; @@ -593,12 +589,13 @@ private: TabletData *tabletDataForDevice(int id); #endif // !QT_NO_TABLETEVENT struct ScrollingDevice { - ScrollingDevice() : deviceId(0), verticalIndex(0), horizontalIndex(0), orientations(0), legacyOrientations(0) { } - int deviceId; - int verticalIndex, horizontalIndex; - double verticalIncrement, horizontalIncrement; - Qt::Orientations orientations; - Qt::Orientations legacyOrientations; + int deviceId = 0; + int verticalIndex = 0; + int horizontalIndex = 0; + double verticalIncrement = 0; + double horizontalIncrement = 0; + Qt::Orientations orientations = 0; + Qt::Orientations legacyOrientations = 0; QPointF lastScrollPosition; }; void updateScrollingDevice(ScrollingDevice& scrollingDevice, int num_classes, void *classes); @@ -609,36 +606,36 @@ private: static void xi2PrepareXIGenericDeviceEvent(xcb_ge_event_t *event); #endif - xcb_connection_t *m_connection; - const xcb_setup_t *m_setup; - bool m_canGrabServer; - xcb_visualid_t m_defaultVisualId; + xcb_connection_t *m_connection = nullptr; + const xcb_setup_t *m_setup = nullptr; + const bool m_canGrabServer; + const xcb_visualid_t m_defaultVisualId; QList m_virtualDesktops; QList m_screens; - int m_primaryScreenNumber; + int m_primaryScreenNumber = 0; xcb_atom_t m_allAtoms[QXcbAtom::NAtoms]; - xcb_timestamp_t m_time; - xcb_timestamp_t m_netWmUserTime; + xcb_timestamp_t m_time = XCB_CURRENT_TIME; + xcb_timestamp_t m_netWmUserTime = XCB_CURRENT_TIME; QByteArray m_displayName; - QXcbKeyboard *m_keyboard; + QXcbKeyboard *m_keyboard = nullptr; #ifndef QT_NO_CLIPBOARD - QXcbClipboard *m_clipboard; + QXcbClipboard *m_clipboard = nullptr; #endif #ifndef QT_NO_DRAGANDDROP - QXcbDrag *m_drag; + QXcbDrag *m_drag = nullptr; #endif QScopedPointer m_wmSupport; - QXcbNativeInterface *m_nativeInterface; + QXcbNativeInterface *m_nativeInterface = nullptr; #if defined(XCB_USE_XLIB) - void *m_xlib_display; + void *m_xlib_display = nullptr; #endif - QXcbEventReader *m_reader; + QXcbEventReader *m_reader = nullptr; #if defined(XCB_USE_XINPUT2) QHash m_touchDevices; #ifdef XCB_USE_XINPUT22 @@ -671,29 +668,29 @@ private: QVector m_peekFuncs; - uint32_t xfixes_first_event; - uint32_t xrandr_first_event; - uint32_t xkb_first_event; + uint32_t xfixes_first_event = 0; + uint32_t xrandr_first_event = 0; + uint32_t xkb_first_event = 0; - bool has_xinerama_extension; - bool has_shape_extension; - bool has_randr_extension; + bool has_xinerama_extension = false; + bool has_shape_extension = false; + bool has_randr_extension = false; bool has_input_shape; - bool has_xkb; + bool has_xkb = false; - Qt::MouseButtons m_buttons; + Qt::MouseButtons m_buttons = 0; - QXcbWindow *m_focusWindow; - QXcbWindow *m_mouseGrabber; - QXcbWindow *m_mousePressWindow; + QXcbWindow *m_focusWindow = nullptr; + QXcbWindow *m_mouseGrabber = nullptr; + QXcbWindow *m_mousePressWindow = nullptr; - xcb_window_t m_clientLeader; + xcb_window_t m_clientLeader = 0; QByteArray m_startupId; - QXcbSystemTrayTracker *m_systemTrayTracker; - QXcbGlIntegration *m_glIntegration; - bool m_xiGrab; + QXcbSystemTrayTracker *m_systemTrayTracker = nullptr; + QXcbGlIntegration *m_glIntegration = nullptr; + bool m_xiGrab = false; - xcb_window_t m_qtSelectionOwner; + xcb_window_t m_qtSelectionOwner = 0; friend class QXcbEventReader; }; diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index d91cbfe82d..acdcc996b7 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -52,14 +52,8 @@ #include struct XInput2TouchDeviceData { - XInput2TouchDeviceData() - : xiDeviceInfo(0) - , qtTouchDevice(0) - , providesTouchOrientation(false) - { - } - XIDeviceInfo *xiDeviceInfo; - QTouchDevice *qtTouchDevice; + XIDeviceInfo *xiDeviceInfo = nullptr; + QTouchDevice *qtTouchDevice = nullptr; QHash touchPoints; QHash pointPressedPosition; // in screen coordinates where each point was pressed @@ -67,7 +61,7 @@ struct XInput2TouchDeviceData { QPointF firstPressedPosition; // in screen coordinates where the first point was pressed QPointF firstPressedNormalPosition; // device coordinates (0 to 1, 0 to 1) where the first point was pressed QSizeF size; // device size in mm - bool providesTouchOrientation; + bool providesTouchOrientation = false; }; void QXcbConnection::initializeXInput2() @@ -80,7 +74,7 @@ void QXcbConnection::initializeXInput2() Display *xDisplay = static_cast(m_xlib_display); if (XQueryExtension(xDisplay, "XInputExtension", &m_xiOpCode, &m_xiEventBase, &m_xiErrorBase)) { int xiMajor = 2; - m_xi2Minor = 2; // try 2.2 first, needed for TouchBegin/Update/End + // try 2.2 first, needed for TouchBegin/Update/End if (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) == BadRequest) { m_xi2Minor = 1; // for smooth scrolling 2.1 is enough if (XIQueryVersion(xDisplay, &xiMajor, &m_xi2Minor) == BadRequest) { diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index a5aff7f11f..2e29c208c7 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -1136,12 +1136,6 @@ int QXcbKeyboard::keysymToQtKey(xcb_keysym_t keysym, Qt::KeyboardModifiers &modi QXcbKeyboard::QXcbKeyboard(QXcbConnection *connection) : QXcbObject(connection) - , m_autorepeat_code(0) - , xkb_context(0) - , xkb_keymap(0) - , xkb_state(0) - , latin_keymap(0) - , m_hasLatinLayout(false) { memset(&xkb_names, 0, sizeof(xkb_names)); #if QT_CONFIG(xkb) diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h index dfd2926435..74f9da0353 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.h +++ b/src/plugins/platforms/xcb/qxcbkeyboard.h @@ -106,14 +106,14 @@ protected: private: void updateXKBStateFromState(struct xkb_state *kb_state, quint16 state); - bool m_config; - xcb_keycode_t m_autorepeat_code; + bool m_config = false; + xcb_keycode_t m_autorepeat_code = 0; - struct xkb_context *xkb_context; - struct xkb_keymap *xkb_keymap; - struct xkb_state *xkb_state; + struct xkb_context *xkb_context = nullptr; + struct xkb_keymap *xkb_keymap = nullptr; + struct xkb_state *xkb_state = nullptr; struct xkb_rule_names xkb_names; - mutable struct xkb_keymap *latin_keymap; + mutable struct xkb_keymap *latin_keymap = nullptr; struct _mod_masks { uint alt; @@ -143,7 +143,7 @@ private: _mod_masks vmod_masks; int core_device_id; #endif - bool m_hasLatinLayout; + bool m_hasLatinLayout = false; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index b1575cbee4..725288633a 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -90,8 +90,7 @@ static int resourceType(const QByteArray &key) } QXcbNativeInterface::QXcbNativeInterface() : - m_genericEventFilterType(QByteArrayLiteral("xcb_generic_event_t")), - m_sysTraySelectionAtom(XCB_ATOM_NONE) + m_genericEventFilterType(QByteArrayLiteral("xcb_generic_event_t")) { } diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h index a830829311..4186d77f4d 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.h +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h @@ -129,7 +129,7 @@ private: const QByteArray m_genericEventFilterType; - xcb_atom_t m_sysTraySelectionAtom; + xcb_atom_t m_sysTraySelectionAtom = XCB_ATOM_NONE; static QXcbScreen *qPlatformScreenForWindow(QWindow *window); diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index a9675935f4..736b4852d8 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -59,7 +59,6 @@ QXcbVirtualDesktop::QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t : QXcbObject(connection) , m_screen(screen) , m_number(number) - , m_xSettings(Q_NULLPTR) { const QByteArray cmAtomName = "_NET_WM_CM_S" + QByteArray::number(m_number); m_net_wm_cm_atom = connection->internAtom(cmAtomName.constData()); @@ -175,20 +174,10 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe , m_virtualDesktop(virtualDesktop) , m_output(outputId) , m_crtc(output ? output->crtc : XCB_NONE) - , m_mode(XCB_NONE) - , m_primary(false) - , m_rotation(XCB_RANDR_ROTATION_ROTATE_0) , m_outputName(getOutputName(output)) , m_outputSizeMillimeters(output ? QSize(output->mm_width, output->mm_height) : QSize()) , m_virtualSize(virtualDesktop->size()) , m_virtualSizeMillimeters(virtualDesktop->physicalSize()) - , m_orientation(Qt::PrimaryOrientation) - , m_refreshRate(60) - , m_forcedDpi(-1) - , m_pixelDensity(1) - , m_hintStyle(QFontEngine::HintStyle(-1)) - , m_subpixelType(QFontEngine::SubpixelAntialiasingType(-1)) - , m_antialiasingEnabled(-1) { if (connection->hasXRandr()) { xcb_randr_select_input(xcb_connection(), screen()->root, true); diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index 627397fcaf..4163be2969 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -95,12 +95,12 @@ private: QRect getWorkArea() const; xcb_screen_t *m_screen; - int m_number; + const int m_number; QList m_screens; - QXcbXSettings *m_xSettings; - xcb_atom_t m_net_wm_cm_atom; - bool m_compositingActive; + QXcbXSettings *m_xSettings = nullptr; + xcb_atom_t m_net_wm_cm_atom = 0; + bool m_compositingActive = false; QRect m_workArea; }; @@ -186,9 +186,9 @@ private: QXcbVirtualDesktop *m_virtualDesktop; xcb_randr_output_t m_output; xcb_randr_crtc_t m_crtc; - xcb_randr_mode_t m_mode; - bool m_primary; - uint8_t m_rotation; + xcb_randr_mode_t m_mode = XCB_NONE; + bool m_primary = false; + uint8_t m_rotation = XCB_RANDR_ROTATION_ROTATE_0; QString m_outputName; QSizeF m_outputSizeMillimeters; @@ -197,18 +197,18 @@ private: QRect m_availableGeometry; QSize m_virtualSize; QSizeF m_virtualSizeMillimeters; - Qt::ScreenOrientation m_orientation; + Qt::ScreenOrientation m_orientation = Qt::PrimaryOrientation; QString m_windowManagerName; - bool m_syncRequestSupported; + bool m_syncRequestSupported = false; QMap m_visuals; QMap m_visualDepths; QXcbCursor *m_cursor; - int m_refreshRate; - int m_forcedDpi; - int m_pixelDensity; - QFontEngine::HintStyle m_hintStyle; - QFontEngine::SubpixelAntialiasingType m_subpixelType; - int m_antialiasingEnabled; + int m_refreshRate = 60; + int m_forcedDpi = -1; + int m_pixelDensity = 1; + QFontEngine::HintStyle m_hintStyle = QFontEngine::HintStyle(-1); + QFontEngine::SubpixelAntialiasingType m_subpixelType = QFontEngine::SubpixelAntialiasingType(-1); + int m_antialiasingEnabled = -1; }; #ifndef QT_NO_DEBUG_STREAM diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp index 5522af86de..fb0a4a3939 100644 --- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp +++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.cpp @@ -80,7 +80,6 @@ QXcbSystemTrayTracker::QXcbSystemTrayTracker(QXcbConnection *connection, , m_selection(selection) , m_trayAtom(trayAtom) , m_connection(connection) - , m_trayWindow(0) { } diff --git a/src/plugins/platforms/xcb/qxcbsystemtraytracker.h b/src/plugins/platforms/xcb/qxcbsystemtraytracker.h index a6131e6d0e..a95b9374e9 100644 --- a/src/plugins/platforms/xcb/qxcbsystemtraytracker.h +++ b/src/plugins/platforms/xcb/qxcbsystemtraytracker.h @@ -77,7 +77,7 @@ private: const xcb_atom_t m_selection; const xcb_atom_t m_trayAtom; QXcbConnection *m_connection; - xcb_window_t m_trayWindow; + xcb_window_t m_trayWindow = 0; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 2d52f5dd46..756806108e 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -314,22 +314,6 @@ static const char *wm_window_role_property_id = "_q_xcb_wm_window_role"; QXcbWindow::QXcbWindow(QWindow *window) : QPlatformWindow(window) - , m_window(0) - , m_cmap(0) - , m_syncCounter(0) - , m_gravity(XCB_GRAVITY_STATIC) - , m_mapped(false) - , m_transparent(false) - , m_usingSyncProtocol(false) - , m_deferredActivation(false) - , m_embedded(false) - , m_alertState(false) - , m_netWmUserTimeWindow(XCB_NONE) - , m_dirtyFrameMargins(false) - , m_lastWindowStateEvent(-1) - , m_syncState(NoSyncNeeded) - , m_pendingSyncRequest(0) - , m_currentBitmapCursor(XCB_CURSOR_NONE) { setConnection(xcbScreen()->connection()); } diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 680629c040..b4d947e700 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -233,48 +233,48 @@ protected: void handleLeaveNotifyEvent(int root_x, int root_y, quint8 mode, quint8 detail, xcb_timestamp_t timestamp); - xcb_window_t m_window; - xcb_colormap_t m_cmap; + xcb_window_t m_window = 0; + xcb_colormap_t m_cmap = 0; - uint m_depth; - QImage::Format m_imageFormat; - bool m_imageRgbSwap; + uint m_depth = 0; + QImage::Format m_imageFormat = QImage::Format_ARGB32_Premultiplied; + bool m_imageRgbSwap = false; xcb_sync_int64_t m_syncValue; - xcb_sync_counter_t m_syncCounter; + xcb_sync_counter_t m_syncCounter = 0; - Qt::WindowState m_windowState; + Qt::WindowState m_windowState = Qt::WindowNoState; - xcb_gravity_t m_gravity; + xcb_gravity_t m_gravity = XCB_GRAVITY_STATIC; - bool m_mapped; - bool m_transparent; - bool m_usingSyncProtocol; - bool m_deferredActivation; - bool m_embedded; - bool m_alertState; - xcb_window_t m_netWmUserTimeWindow; + bool m_mapped = false; + bool m_transparent = false; + bool m_usingSyncProtocol = false; + bool m_deferredActivation = false; + bool m_embedded = false; + bool m_alertState = false; + xcb_window_t m_netWmUserTimeWindow = XCB_NONE; QSurfaceFormat m_format; - mutable bool m_dirtyFrameMargins; + mutable bool m_dirtyFrameMargins = false; mutable QMargins m_frameMargins; QRegion m_exposeRegion; QSize m_oldWindowSize; - xcb_visualid_t m_visualId; - int m_lastWindowStateEvent; + xcb_visualid_t m_visualId = 0; + int m_lastWindowStateEvent = -1; enum SyncState { NoSyncNeeded, SyncReceived, SyncAndConfigureReceived }; - SyncState m_syncState; + SyncState m_syncState = NoSyncNeeded; - QXcbSyncWindowRequest *m_pendingSyncRequest; - xcb_cursor_t m_currentBitmapCursor; + QXcbSyncWindowRequest *m_pendingSyncRequest = nullptr; + xcb_cursor_t m_currentBitmapCursor = XCB_CURSOR_NONE; }; QT_END_NAMESPACE -- cgit v1.2.1