From 03a40d3a46b078f6cf516e5a42ef2e11a5366a20 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 27 Jan 2015 16:58:53 +0100 Subject: Revert "Windows: Fix call of ToUnicode" This reverts commit dfe853bff90444edf92a993e391df853780c9e8d. When using cyrillic or other keyboard layouts, standard shortcuts like CTRL-C are still supposed to work as if the US keyboard layout were in effect. Task-number: QTBUG-44021 Task-number: QTBUG-35734 Change-Id: If6cd96a1e03e62900b293f8e304e523460e85810 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowskeymapper.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index d781cdbe9c..4b1d1112d5 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -537,16 +537,15 @@ static inline int toKeyOrUnicode(int vk, int scancode, unsigned char *kbdBuffer, Q_ASSERT(vk > 0 && vk < 256); int code = 0; QChar unicodeBuffer[5]; - // While key combinations containing alt and ctrl might trigger the third assignment of a key - // (for example "alt+ctrl+q" causes '@' on a German layout), ToUnicode often does not return the - // wanted character if only the ctrl modifier is used. Thus we unset this modifier temporarily - // if it is not used together with alt. - const unsigned char controlState = kbdBuffer[VK_MENU] ? 0 : kbdBuffer[VK_CONTROL]; - if (controlState) - kbdBuffer[VK_CONTROL] = 0; int res = ToUnicode(vk, scancode, kbdBuffer, reinterpret_cast(unicodeBuffer), 5, 0); - if (controlState) + // When Ctrl modifier is used ToUnicode does not return correct values. In order to assign the + // right key the control modifier is removed for just that function if the previous call failed. + if (res == 0 && kbdBuffer[VK_CONTROL]) { + const unsigned char controlState = kbdBuffer[VK_CONTROL]; + kbdBuffer[VK_CONTROL] = 0; + res = ToUnicode(vk, scancode, kbdBuffer, reinterpret_cast(unicodeBuffer), 5, 0); kbdBuffer[VK_CONTROL] = controlState; + } if (res) code = unicodeBuffer[0].toUpper().unicode(); -- cgit v1.2.3 From 4b707d3bde53dd6dd4c01a51c12f096faefbc5b2 Mon Sep 17 00:00:00 2001 From: Andreas Holzammer Date: Fri, 23 Jan 2015 13:50:07 +0100 Subject: WINCE: Fix special case for toplevel It looks like that WindowFromPoint does not return same handle each time, hence he then is in a endless loop. We don't need to look for a child in a loop here for Windows Embedded Compact. Task-number: QTBUG-44073 Change-Id: Ic42d56616b29f293d187111588fde3947c15659c Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowscontext.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index ffa7f82d8e..99ba5463bf 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -675,6 +675,8 @@ static inline bool findPlatformWindowHelper(const POINT &screenPoint, unsigned c #ifndef Q_OS_WINCE const HWND child = ChildWindowFromPointEx(*hwnd, point, cwexFlags); #else +// Under Windows CE we don't use ChildWindowFromPointEx as it's not available +// and ChildWindowFromPoint does not work properly. Q_UNUSED(cwexFlags) const HWND child = WindowFromPoint(point); #endif @@ -683,7 +685,13 @@ static inline bool findPlatformWindowHelper(const POINT &screenPoint, unsigned c if (QWindowsWindow *window = context->findPlatformWindow(child)) { *result = window; *hwnd = child; +#ifndef Q_OS_WINCE return true; +#else +// WindowFromPoint does not return same handle in two sequential calls, which leads +// to an endless loop, but calling WindowFromPoint once is good enough. + return false; +#endif } #ifndef Q_OS_WINCE // Does not have WS_EX_TRANSPARENT . // QTBUG-40555: despite CWP_SKIPINVISIBLE, it is possible to hit on invisible -- cgit v1.2.3 From 012a7ab91212db105fc43db9aa89b92d70052f1b Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Thu, 29 Jan 2015 13:33:30 +0100 Subject: WinRT: Fix access to style hint instead of theme hint You need to specify explicitly the styleHint enum instead of the theming one, which is where we want to forward to. This caused all clicks to be ignored in case there is a listener to pressAndHold as the hold period is reduced to 0 milliseconds. Task-number: QTBUG-44196 Change-Id: I30d1771b91b5fa358e896e8441ade965543d4613 Reviewed-by: Friedemann Kleint Reviewed-by: Andrew Knight --- src/plugins/platforms/winrt/qwinrttheme.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp index f64b47960a..e2857683f8 100644 --- a/src/plugins/platforms/winrt/qwinrttheme.cpp +++ b/src/plugins/platforms/winrt/qwinrttheme.cpp @@ -232,7 +232,7 @@ QVariant QWinRTTheme::styleHint(QPlatformIntegration::StyleHint hint) return false; case QPlatformIntegration::ShowIsMaximized: return false; - case MousePressAndHoldInterval: + case QPlatformIntegration::MousePressAndHoldInterval: return defaultThemeHint(MousePressAndHoldInterval); default: break; -- cgit v1.2.3 From 8e0f56280ab6fd869faf1650edd454883f4d035f Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 27 Jan 2015 16:36:10 +0100 Subject: Fix Qt over VNC with broken VisualInfo It appears some VNC servers reports incorrect masks in their visuals. This patch recognizes this unlikely set of masks and interprets it as RGB16 which VNC expects. Task-number: QTBUG-44147 Change-Id: Ia374edcd5f0a5ce0188157ac1d328f888cfa260c Reviewed-by: Shawn Rutledge Reviewed-by: Laszlo Agocs --- src/plugins/platforms/xcb/qxcbwindow.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 4fd71f1635..00942787d9 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -215,6 +215,18 @@ static inline QImage::Format imageFormatForVisual(int depth, quint32 red_mask, q break; } qWarning("Unsupported screen format: depth: %d, red_mask: %x, blue_mask: %x", depth, red_mask, blue_mask); + + switch (depth) { + case 24: + qWarning("Using RGB32 fallback, if this works your X11 server is reporting a bad screen format."); + return QImage::Format_RGB32; + case 16: + qWarning("Using RGB16 fallback, if this works your X11 server is reporting a bad screen format."); + return QImage::Format_RGB16; + default: + break; + } + return QImage::Format_Invalid; } -- cgit v1.2.3 From e67ebe8ba4f59a4554a47fa26e9c374b1022d36f Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 21 Aug 2014 10:45:27 +0200 Subject: Listen to XI2 deviceChanged events to reset last position Some drivers appears to reset their scroll positions when make the primary point. This patch listens for the device changed event and uses the information in it to update the position. Task-number: QTBUG-40829 Change-Id: If354dfde6300ceb2b81be14ea24594ab0658a6aa Reviewed-by: Alex Blasche --- src/plugins/platforms/xcb/qxcbconnection.h | 2 + src/plugins/platforms/xcb/qxcbconnection_xi2.cpp | 76 ++++++++++++++++++++---- 2 files changed, 68 insertions(+), 10 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 7286b6b89b..4d0596550c 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -506,6 +506,7 @@ private: XInput2TouchDeviceData *touchDeviceForId(int id); void xi2HandleEvent(xcb_ge_event_t *event); void xi2HandleHierachyEvent(void *event); + void xi2HandleDeviceChangedEvent(void *event); int m_xiOpCode, m_xiEventBase, m_xiErrorBase; #ifndef QT_NO_TABLETEVENT struct TabletData { @@ -539,6 +540,7 @@ private: Qt::Orientations legacyOrientations; QPointF lastScrollPosition; }; + void updateScrollingDevice(ScrollingDevice& scrollingDevice, int num_classes, void *classes); void xi2HandleScrollEvent(void *event, ScrollingDevice &scrollingDevice); QHash m_scrollingDevices; #endif // XCB_USE_XINPUT2 diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 90d323ed34..60ae062586 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -346,6 +346,7 @@ void QXcbConnection::xi2Select(xcb_window_t window) // Listen for hotplug events XIEventMask xiEventMask; bitMask = XI_HierarchyChangedMask; + bitMask |= XI_DeviceChangedMask; xiEventMask.deviceid = XIAllDevices; xiEventMask.mask_len = sizeof(bitMask); xiEventMask.mask = xiBitMask; @@ -464,6 +465,11 @@ void QXcbConnection::xi2HandleEvent(xcb_ge_event_t *event) xi2HandleHierachyEvent(xiEvent); return; } + if (xiEvent->evtype == XI_DeviceChanged) { + xi2HandleDeviceChangedEvent(xiEvent); + return; + } + #ifndef QT_NO_TABLETEVENT for (int i = 0; i < m_tabletData.count(); ++i) { if (m_tabletData.at(i).deviceId == xiEvent->deviceid) { @@ -624,6 +630,64 @@ void QXcbConnection::xi2HandleHierachyEvent(void *event) } } +void QXcbConnection::xi2HandleDeviceChangedEvent(void *event) +{ + xXIDeviceChangedEvent *xiEvent = reinterpret_cast(event); + + // ### If a slave device changes (XIDeviceChange), we should probably run setup on it again. + if (xiEvent->reason != XISlaveSwitch) + return; + +#ifdef XCB_USE_XINPUT21 + // This code handles broken scrolling device drivers that reset absolute positions + // when they are made active. Whenever a new slave device is made active the + // primary pointer sends a DeviceChanged event with XISlaveSwitch, and the new + // active slave in sourceid. + + QHash::iterator device = m_scrollingDevices.find(xiEvent->sourceid); + if (device == m_scrollingDevices.end()) + return; + + int nrDevices = 0; + XIDeviceInfo* xiDeviceInfo = XIQueryDevice(static_cast(m_xlib_display), xiEvent->sourceid, &nrDevices); + if (nrDevices <= 0) { + qCDebug(lcQpaXInputDevices, "scrolling device %d no longer present", xiEvent->sourceid); + return; + } + updateScrollingDevice(*device, xiDeviceInfo->num_classes, xiDeviceInfo->classes); + XIFreeDeviceInfo(xiDeviceInfo); +#endif +} + +void QXcbConnection::updateScrollingDevice(ScrollingDevice &scrollingDevice, int num_classes, void *classInfo) +{ +#ifdef XCB_USE_XINPUT21 + XIAnyClassInfo **classes = reinterpret_cast(classInfo); + QPointF lastScrollPosition; + if (lcQpaXInput().isDebugEnabled()) + lastScrollPosition = scrollingDevice.lastScrollPosition; + for (int c = 0; c < num_classes; ++c) { + if (classes[c]->type == XIValuatorClass) { + XIValuatorClassInfo *vci = reinterpret_cast(classes[c]); + const int valuatorAtom = qatom(vci->label); + if (valuatorAtom == QXcbAtom::RelHorizScroll || valuatorAtom == QXcbAtom::RelHorizWheel) + scrollingDevice.lastScrollPosition.setX(vci->value); + else if (valuatorAtom == QXcbAtom::RelVertScroll || valuatorAtom == QXcbAtom::RelVertWheel) + scrollingDevice.lastScrollPosition.setY(vci->value); + } + } + if (lcQpaXInput().isDebugEnabled() && lastScrollPosition != scrollingDevice.lastScrollPosition) + qCDebug(lcQpaXInput, "scrolling device %d moved from (%f, %f) to (%f, %f)", scrollingDevice.deviceId, + lastScrollPosition.x(), lastScrollPosition.y(), + scrollingDevice.lastScrollPosition.x(), + scrollingDevice.lastScrollPosition.y()); +#else + Q_UNUSED(scrollingDevice); + Q_UNUSED(num_classes); + Q_UNUSED(classInfo); +#endif +} + void QXcbConnection::handleEnterEvent(const xcb_enter_notify_event_t *) { #ifdef XCB_USE_XINPUT21 @@ -634,19 +698,11 @@ void QXcbConnection::handleEnterEvent(const xcb_enter_notify_event_t *) int nrDevices = 0; XIDeviceInfo* xiDeviceInfo = XIQueryDevice(static_cast(m_xlib_display), scrollingDevice.deviceId, &nrDevices); if (nrDevices <= 0) { + qCDebug(lcQpaXInputDevices, "scrolling device %d no longer present", scrollingDevice.deviceId); it = m_scrollingDevices.erase(it); continue; } - for (int c = 0; c < xiDeviceInfo->num_classes; ++c) { - if (xiDeviceInfo->classes[c]->type == XIValuatorClass) { - XIValuatorClassInfo *vci = reinterpret_cast(xiDeviceInfo->classes[c]); - const int valuatorAtom = qatom(vci->label); - if (valuatorAtom == QXcbAtom::RelHorizScroll || valuatorAtom == QXcbAtom::RelHorizWheel) - scrollingDevice.lastScrollPosition.setX(vci->value); - else if (valuatorAtom == QXcbAtom::RelVertScroll || valuatorAtom == QXcbAtom::RelVertWheel) - scrollingDevice.lastScrollPosition.setY(vci->value); - } - } + updateScrollingDevice(scrollingDevice, xiDeviceInfo->num_classes, xiDeviceInfo->classes); XIFreeDeviceInfo(xiDeviceInfo); ++it; } -- cgit v1.2.3 From c66f2433b197fdf6742aa096ee5090a3b5f12247 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 11 Feb 2015 13:32:34 +0100 Subject: Provide a native interface object from linuxfb Recent code in font support started to use the platformNativeInterface() return value without checking for null. Most platform plugins, with the notable exception of linuxfb and the minimal ones, provide an object. Start providing a dummy object from linuxfb too. This is more sensible then adding null checks everywhere. This will prevent crashing with linuxfb on startup. Task-number: QTBUG-44414 Change-Id: I48912132e1f8ad52e2a94c3d765dacc7b16f309a Reviewed-by: Andy Nichols --- src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp | 7 +++++++ src/plugins/platforms/linuxfb/qlinuxfbintegration.h | 4 ++++ 2 files changed, 11 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp index cb870847f2..777da98f47 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.cpp @@ -69,6 +69,8 @@ void QLinuxFbIntegration::initialize() m_inputContext = QPlatformInputContextFactory::create(); + m_nativeInterface.reset(new QPlatformNativeInterface); + m_vtHandler.reset(new QFbVtHandler); } @@ -113,4 +115,9 @@ QPlatformServices *QLinuxFbIntegration::services() const return m_services.data(); } +QPlatformNativeInterface *QLinuxFbIntegration::nativeInterface() const +{ + return m_nativeInterface.data(); +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h index cabd943921..83446105f8 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbintegration.h +++ b/src/plugins/platforms/linuxfb/qlinuxfbintegration.h @@ -35,6 +35,7 @@ #define QLINUXFBINTEGRATION_H #include +#include QT_BEGIN_NAMESPACE @@ -60,6 +61,8 @@ public: QPlatformServices *services() const Q_DECL_OVERRIDE; QPlatformInputContext *inputContext() const Q_DECL_OVERRIDE { return m_inputContext; } + QPlatformNativeInterface *nativeInterface() const Q_DECL_OVERRIDE; + QList screens() const; private: @@ -68,6 +71,7 @@ private: QScopedPointer m_fontDb; QScopedPointer m_services; QScopedPointer m_vtHandler; + QScopedPointer m_nativeInterface; }; QT_END_NAMESPACE -- cgit v1.2.3 From 6342c4a1836f76db43e09a89239d73eda44f414a Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Fri, 13 Feb 2015 12:30:33 +0100 Subject: iOS: only flush non-user input events from layoutSubviews MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change a4e1c15b1 will cause setGeometry to take immediate effect by doing a synchronuous layout and a flush. As a side-effect, the flush will also send posted touch events. So if the current setGeometry call comes from a touchMove, a touchEnd might be delivered before the touchMove returns. A crash in QToolBar drag-n-drop is seen from this. There drag data is deleted on mouse release (during the flush), while a mouse move is already handled on the stack. When the code returns to the move handler, drag-data has been deleted, and we have a crash. Since the root problem is that we flush events on a callback from the app, we can be more careful and precise by only flushing non-user input events from layoutSubviews. Change-Id: I3f5e025d774d21509ef837de9d7e85a1ac6e48cc Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/quiview.mm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index c4b92618b1..19b2668a95 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -146,8 +146,9 @@ QRect previousGeometry = requestedGeometry != actualGeometry ? requestedGeometry : qt_window_private(m_qioswindow->window())->geometry; - QWindowSystemInterface::handleGeometryChange(m_qioswindow->window(), actualGeometry, previousGeometry); - QWindowSystemInterface::flushWindowSystemEvents(); + QWindow *window = m_qioswindow->window(); + QWindowSystemInterface::handleGeometryChange(window, actualGeometry, previousGeometry); + QWindowSystemInterface::flushWindowSystemEvents(window->inherits("QWidgetWindow") ? QEventLoop::ExcludeUserInputEvents : QEventLoop::AllEvents); if (actualGeometry.size() != previousGeometry.size()) { // Trigger expose event on resize -- cgit v1.2.3 From 76de1ac0a4cd384f608a14b5d77a8cf3ef1ec868 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 9 Feb 2015 17:19:14 +0300 Subject: xcb: Update mouse buttons from MotionNotify events We don't receive ButtonRelease event after closing a popup by clicking outside of the client area. Thus the internal state of mouse buttons in the xcb plugin becomes outdated until we receive ButtonRelease event. This commit updates the internal state of mouse buttons from MotionNotify events. So when a user will move a mouse on the client area, the xcb plugin will send a mouse event with updated buttons to Qt Gui and QGuiApplication will detect the following mouse events correctly. Task-number: QTBUG-32609 Task-number: QTBUG-35065 Task-number: QTBUG-43776 Task-number: QTBUG-44166 Task-number: QTBUG-44231 Change-Id: Ica334dfbf04f7ef81db86b25262328fe5da11808 Reviewed-by: Allan Sandfeld Jensen Reviewed-by: Shawn Rutledge Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/qxcbconnection.cpp | 14 ++++++++++---- src/plugins/platforms/xcb/qxcbconnection.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 5510c3b1b4..77e4601485 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -818,6 +818,15 @@ void QXcbConnection::handleButtonRelease(xcb_generic_event_t *ev) qCDebug(lcQpaXInput, "xcb: released mouse button %d, button state %X", event->detail, static_cast(m_buttons)); } +void QXcbConnection::handleMotionNotify(xcb_generic_event_t *ev) +{ + xcb_motion_notify_event_t *event = (xcb_motion_notify_event_t *)ev; + + m_buttons = (m_buttons & ~0x7) | translateMouseButtons(event->state); + if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled())) + qDebug("xcb: moved mouse to %4d, %4d; button state %X", event->event_x, event->event_y, static_cast(m_buttons)); +} + #ifndef QT_NO_XKB namespace { typedef union { @@ -868,11 +877,8 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) handleButtonRelease(event); HANDLE_PLATFORM_WINDOW_EVENT(xcb_button_release_event_t, event, handleButtonReleaseEvent); case XCB_MOTION_NOTIFY: - if (Q_UNLIKELY(lcQpaXInput().isDebugEnabled())) { - xcb_motion_notify_event_t *mev = (xcb_motion_notify_event_t *)event; - qDebug("xcb: moved mouse to %4d, %4d; button state %X", mev->event_x, mev->event_y, static_cast(m_buttons)); - } m_keyboard->updateXKBStateFromCore(((xcb_motion_notify_event_t *)event)->state); + handleMotionNotify(event); HANDLE_PLATFORM_WINDOW_EVENT(xcb_motion_notify_event_t, event, handleMotionNotifyEvent); case XCB_CONFIGURE_NOTIFY: HANDLE_PLATFORM_WINDOW_EVENT(xcb_configure_notify_event_t, event, handleConfigureNotifyEvent); diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 4d0596550c..9a73006cec 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -496,6 +496,7 @@ private: void updateScreens(); void handleButtonPress(xcb_generic_event_t *event); void handleButtonRelease(xcb_generic_event_t *event); + void handleMotionNotify(xcb_generic_event_t *event); bool m_xi2Enabled; int m_xi2Minor; -- cgit v1.2.3 From cbece1e8c471322b0650dfb2a3f7b2258ff4c1c9 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 12 Feb 2015 09:19:25 +0100 Subject: Ensure the filedialog shows the initial filename Whenever the selection changes it will call panelSelectionDidChange even if the panel is not visible which causes it to overwrite our chosen initial file with "untitled". Therefore we only set the name when the panel is actually visible. Change-Id: I09f7ebabce5c2139a7f74b953391d39dfad65db2 Reviewed-by: Joerg Bornemann --- src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index 084b53af79..bec5602934 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -446,7 +446,7 @@ static QString strippedText(QString s) - (void)panelSelectionDidChange:(id)sender { Q_UNUSED(sender); - if (mHelper) { + if (mHelper && [mSavePanel isVisible]) { QString selection = QCFString::toQString([[mSavePanel URL] path]); if (selection != mCurrentSelection) { *mCurrentSelection = selection; -- cgit v1.2.3 From 8d6341a721d07e3cc30032bcc89f7e25cb00b9eb Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Mon, 16 Feb 2015 22:53:02 +0100 Subject: Call [ofono|nm]Registered delayed in constructor otherwise signals will be lost If we call them just in the constructor all the signals they sent out can't be connected and will be lost, particularly this means the QNetworkConfigurationManager doesn't see my ethernet connection and thus thinks i'm not online Change-Id: I1480f76338d6ae4fbed676f9fa40ada18ea431ad Reviewed-by: Alex Blasche --- src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp index f52b9d4b4d..0378ac7dac 100644 --- a/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp +++ b/src/plugins/bearer/networkmanager/qnetworkmanagerengine.cpp @@ -80,10 +80,10 @@ QNetworkManagerEngine::QNetworkManagerEngine(QObject *parent) this, SLOT(ofonoUnRegistered(QString))); if (QDBusConnection::systemBus().interface()->isServiceRegistered("org.ofono")) - ofonoRegistered(); + QMetaObject::invokeMethod(this, "ofonoRegistered", Qt::QueuedConnection); if (QDBusConnection::systemBus().interface()->isServiceRegistered(NM_DBUS_SERVICE)) - nmRegistered(); + QMetaObject::invokeMethod(this, "nmRegistered", Qt::QueuedConnection); } QNetworkManagerEngine::~QNetworkManagerEngine() -- cgit v1.2.3 From 02c5657a7d6d30c6e874e29a0adcc38b58a45b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Fri, 13 Feb 2015 12:18:33 +0100 Subject: Android: Fix local ref handling. We where allowing conversion from jobject to QJNIObject without taking ownership of the jobject. Since we are managing the JNI environment we should not allow conversions without having the option of taking ownership of the local ref. This is now done by making the conversions explicit, i.e., local refs are converted through QJNIObjectPrivate::fromLocalRef() and global refs through the QJNIObjectPrivate's jobject constructor. This change breaks SC, but the API is private and no usage have been found outside QtBase. Change-Id: I3175f171699ec3f8e65144aaebc6246bc6e5bb4d Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp b/src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp index 4beb2e581b..c6a013ebed 100644 --- a/src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp +++ b/src/plugins/bearer/android/src/wrappers/androidconnectivitymanager.cpp @@ -295,8 +295,7 @@ QList AndroidConnectivityManager::getAllNetworkInfo() const if (exceptionCheckAndClear(env)) break; - list << AndroidNetworkInfo(lref); - env->DeleteLocalRef(lref); + list << AndroidNetworkInfo(QJNIObjectPrivate::fromLocalRef(lref)); } return list; -- cgit v1.2.3 From dee1998d4e50d70fe212e46dd0b030337e7884cd Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Tue, 2 Dec 2014 14:02:52 +0200 Subject: direct2d: Optimize dashed [poly]line drawing Move the optimized dash drawing into stroke() in order to apply the optimization to polygons in addition to lines. In the case of polygons/polylines, a vertex patch is redrawn using the original dash brush in order to respect the joinStyle of the line. As the line correction code flows through both the optimized dashed path and the standard geometry code path, line adjustment is now also performed for normal geometry. Task-number: QTBUG-40604 Done-with: Louai Al-Khanji Done-with: Andrew Knight Change-Id: I668369b4aadb6a1bbbd4d621cb8ce1e3b19fbbc9 Reviewed-by: Louai Al-Khanji --- .../direct2d/qwindowsdirect2dpaintengine.cpp | 248 ++++++++++----------- .../direct2d/qwindowsdirect2dpaintengine.h | 3 - 2 files changed, 119 insertions(+), 132 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp index a86bb0ee04..bc996420a8 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.cpp @@ -68,8 +68,6 @@ enum { D2DDebugFillRectTag, D2DDebugDrawRectsTag, D2DDebugDrawRectFsTag, - D2DDebugDrawLinesTag, - D2DDebugDrawLineFsTag, D2DDebugDrawEllipseTag, D2DDebugDrawEllipseFTag, D2DDebugDrawImageTag, @@ -102,22 +100,28 @@ static inline ID2D1Factory1 *factory() return QWindowsDirect2DContext::instance()->d2dFactory(); } -static inline D2D1_MATRIX_3X2_F transformFromLine(const QLineF &line, qreal penWidth) +static inline D2D1_MATRIX_3X2_F transformFromLine(const QLineF &line, qreal penWidth, qreal dashOffset) { const qreal halfWidth = penWidth / 2; const qreal angle = -qDegreesToRadians(line.angle()); - QTransform transform = QTransform::fromTranslate(line.p1().x() + qSin(angle) * halfWidth, - line.p1().y() - qCos(angle) * halfWidth); + const qreal sinA = qSin(angle); + const qreal cosA = qCos(angle); + QTransform transform = QTransform::fromTranslate(line.p1().x() + dashOffset * cosA + sinA * halfWidth, + line.p1().y() + dashOffset * sinA - cosA * halfWidth); transform.rotateRadians(angle); return to_d2d_matrix_3x2_f(transform); } +static void adjustLine(QPointF *p1, QPointF *p2); +static bool isLinePositivelySloped(const QPointF &p1, const QPointF &p2); + class Direct2DPathGeometryWriter { public: Direct2DPathGeometryWriter() : m_inFigure(false) , m_roundCoordinates(false) + , m_adjustPositivelySlopedLines(false) { } @@ -152,6 +156,11 @@ public: m_roundCoordinates = enable; } + void setPositiveSlopeAdjustmentEnabled(bool enable) + { + m_adjustPositivelySlopedLines = enable; + } + bool isInFigure() const { return m_inFigure; @@ -164,11 +173,20 @@ public: m_sink->BeginFigure(adjusted(point), D2D1_FIGURE_BEGIN_FILLED); m_inFigure = true; + m_previousPoint = point; } void lineTo(const QPointF &point) { - m_sink->AddLine(adjusted(point)); + QPointF pt = point; + if (m_adjustPositivelySlopedLines && isLinePositivelySloped(m_previousPoint, point)) { + moveTo(m_previousPoint - QPointF(0, 1)); + pt -= QPointF(0, 1); + } + m_sink->AddLine(adjusted(pt)); + if (pt != point) + moveTo(point); + m_previousPoint = point; } void curveTo(const QPointF &p1, const QPointF &p2, const QPointF &p3) @@ -180,6 +198,7 @@ public: }; m_sink->AddBezier(segment); + m_previousPoint = p3; } void close() @@ -212,6 +231,8 @@ private: bool m_inFigure; bool m_roundCoordinates; + bool m_adjustPositivelySlopedLines; + QPointF m_previousPoint; }; struct D2DVectorPathCache { @@ -257,6 +278,7 @@ public: ComPtr brush; ComPtr strokeStyle; ComPtr dashBrush; + int dashLength; inline void reset() { emulate = false; @@ -264,6 +286,7 @@ public: brush.Reset(); strokeStyle.Reset(); dashBrush.Reset(); + dashLength = 0; } } pen; @@ -566,6 +589,7 @@ public: D2D1_BITMAP_BRUSH_PROPERTIES1 bitmapBrushProperties = D2D1::BitmapBrushProperties1( D2D1_EXTEND_MODE_WRAP, D2D1_EXTEND_MODE_CLAMP, D2D1_INTERPOLATION_MODE_LINEAR); hr = dc()->CreateBitmapBrush(bitmap.bitmap(), bitmapBrushProperties, &pen.dashBrush); + pen.dashLength = bitmap.size().width(); } else { hr = factory()->CreateStrokeStyle(props, NULL, 0, &pen.strokeStyle); } @@ -795,6 +819,8 @@ public: writer.setWindingFillEnabled(path.hasWindingFill()); writer.setAliasingEnabled(alias); + writer.setPositiveSlopeAdjustmentEnabled(path.shape() == QVectorPath::LinesHint + || path.shape() == QVectorPath::PolygonHint); const QPainterPath::ElementType *types = path.elements(); const int count = path.elementCount(); @@ -910,6 +936,90 @@ public: DWRITE_MEASURING_MODE_GDI_CLASSIC); } + void stroke(const QVectorPath &path) + { + Q_Q(QWindowsDirect2DPaintEngine); + + // Default path (no optimization) + if (!(path.shape() == QVectorPath::LinesHint || path.shape() == QVectorPath::PolygonHint) + || !pen.dashBrush || q->state()->renderHints.testFlag(QPainter::HighQualityAntialiasing)) { + ComPtr geometry = vectorPathToID2D1PathGeometry(path); + if (!geometry) { + qWarning("%s: Could not convert path to d2d geometry", __FUNCTION__); + return; + } + dc()->DrawGeometry(geometry.Get(), pen.brush.Get(), pen.qpen.widthF(), pen.strokeStyle.Get()); + return; + } + + // Optimized dash line drawing + const bool isPolygon = path.shape() == QVectorPath::PolygonHint && path.elementCount() >= 3; + const bool implicitClose = isPolygon && (path.hints() & QVectorPath::ImplicitClose); + const bool skipJoin = !isPolygon // Non-polygons don't require joins + || (pen.qpen.joinStyle() == Qt::MiterJoin && qFuzzyIsNull(pen.qpen.miterLimit())); + const qreal *points = path.points(); + const int lastElement = path.elementCount() - (implicitClose ? 1 : 2); + qreal dashOffset = 0; + QPointF jointStart; + ID2D1Brush *brush = pen.dashBrush ? pen.dashBrush.Get() : pen.brush.Get(); + for (int i = 0; i <= lastElement; ++i) { + QPointF p1(points[i * 2], points[i * 2 + 1]); + QPointF p2 = implicitClose && i == lastElement ? QPointF(points[0], points[1]) + : QPointF(points[i * 2 + 2], points[i * 2 + 3]); + if (!isPolygon) // Advance the count for lines + ++i; + + // Match raster engine output + if (p1 == p2 && pen.qpen.widthF() <= 1.0) { + q->fillRect(QRectF(p1, QSizeF(pen.qpen.widthF(), pen.qpen.widthF())), pen.qpen.brush()); + continue; + } + + if (!q->antiAliasingEnabled()) + adjustLine(&p1, &p2); + + q->adjustForAliasing(&p1); + q->adjustForAliasing(&p2); + + const QLineF line(p1, p2); + const qreal lineLength = line.length(); + if (pen.dashBrush) { + pen.dashBrush->SetTransform(transformFromLine(line, pen.qpen.widthF(), dashOffset)); + dashOffset = pen.dashLength - fmod(lineLength - dashOffset, pen.dashLength); + } + dc()->DrawLine(to_d2d_point_2f(p1), to_d2d_point_2f(p2), + brush, pen.qpen.widthF(), NULL); + + if (skipJoin) + continue; + + // Patch the join with the original brush + const qreal patchSegment = pen.dashBrush ? qBound(0.0, (pen.dashLength - dashOffset) / lineLength, 1.0) + : pen.qpen.widthF(); + if (i > 0) { + Direct2DPathGeometryWriter writer; + writer.begin(); + writer.moveTo(jointStart); + writer.lineTo(p1); + writer.lineTo(line.pointAt(patchSegment)); + writer.close(); + dc()->DrawGeometry(writer.geometry().Get(), pen.brush.Get(), pen.qpen.widthF(), pen.strokeStyle.Get()); + } + // Record the start position of the next joint + jointStart = line.pointAt(1 - patchSegment); + + if (implicitClose && i == lastElement) { // Close the polygon + Direct2DPathGeometryWriter writer; + writer.begin(); + writer.moveTo(jointStart); + writer.lineTo(p2); + writer.lineTo(QLineF(p2, QPointF(points[2], points[3])).pointAt(patchSegment)); + writer.close(); + dc()->DrawGeometry(writer.geometry().Get(), pen.brush.Get(), pen.qpen.widthF(), pen.strokeStyle.Get()); + } + } + } + ComPtr fontFaceFromFontEngine(QFontEngine *fe) { const QFontDef fontDef = fe->fontDef; @@ -1051,20 +1161,12 @@ void QWindowsDirect2DPaintEngine::setState(QPainterState *s) void QWindowsDirect2DPaintEngine::draw(const QVectorPath &path) { - Q_D(QWindowsDirect2DPaintEngine); - - ComPtr geometry = d->vectorPathToID2D1PathGeometry(path); - if (!geometry) { - qWarning("%s: Could not convert path to d2d geometry", __FUNCTION__); - return; - } - const QBrush &brush = state()->brush; if (qbrush_style(brush) != Qt::NoBrush) { if (emulationRequired(BrushEmulation)) rasterFill(path, brush); else - fill(geometry.Get(), brush); + fill(path, brush); } const QPen &pen = state()->pen; @@ -1072,7 +1174,7 @@ void QWindowsDirect2DPaintEngine::draw(const QVectorPath &path) if (emulationRequired(PenEmulation)) QPaintEngineEx::stroke(path, pen); else - stroke(geometry.Get(), pen); + stroke(path, pen); } } @@ -1102,18 +1204,6 @@ void QWindowsDirect2DPaintEngine::fill(const QVectorPath &path, const QBrush &br d->dc()->FillGeometry(geometry.Get(), d->brush.brush.Get()); } -void QWindowsDirect2DPaintEngine::fill(ID2D1Geometry *geometry, const QBrush &brush) -{ - Q_D(QWindowsDirect2DPaintEngine); - D2D_TAG(D2DDebugFillTag); - - ensureBrush(brush); - if (!d->brush.brush) - return; - - d->dc()->FillGeometry(geometry, d->brush.brush.Get()); -} - void QWindowsDirect2DPaintEngine::stroke(const QVectorPath &path, const QPen &pen) { Q_D(QWindowsDirect2DPaintEngine); @@ -1131,25 +1221,7 @@ void QWindowsDirect2DPaintEngine::stroke(const QVectorPath &path, const QPen &pe if (!d->pen.brush) return; - ComPtr geometry = d->vectorPathToID2D1PathGeometry(path); - if (!geometry) { - qWarning("%s: Could not convert path to d2d geometry", __FUNCTION__); - return; - } - - d->dc()->DrawGeometry(geometry.Get(), d->pen.brush.Get(), d->pen.qpen.widthF(), d->pen.strokeStyle.Get()); -} - -void QWindowsDirect2DPaintEngine::stroke(ID2D1Geometry *geometry, const QPen &pen) -{ - Q_D(QWindowsDirect2DPaintEngine); - D2D_TAG(D2DDebugFillTag); - - ensurePen(pen); - if (!d->pen.brush) - return; - - d->dc()->DrawGeometry(geometry, d->pen.brush.Get(), d->pen.qpen.widthF(), d->pen.strokeStyle.Get()); + d->stroke(path); } void QWindowsDirect2DPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op) @@ -1297,88 +1369,6 @@ static void adjustLine(QPointF *p1, QPointF *p2) } } -void QWindowsDirect2DPaintEngine::drawLines(const QLine *lines, int lineCount) -{ - Q_D(QWindowsDirect2DPaintEngine); - D2D_TAG(D2DDebugDrawLinesTag); - - ensurePen(); - - if (emulationRequired(PenEmulation)) { - QPaintEngineEx::drawLines(lines, lineCount); - } else if (d->pen.brush) { - for (int i = 0; i < lineCount; i++) { - QPointF p1 = lines[i].p1(); - QPointF p2 = lines[i].p2(); - - // Match raster engine output - if (p1 == p2 && d->pen.qpen.widthF() <= 1.0) { - fillRect(QRectF(p1, QSizeF(d->pen.qpen.widthF(), d->pen.qpen.widthF())), - d->pen.qpen.brush()); - continue; - } - - // Match raster engine output - if (!antiAliasingEnabled()) - adjustLine(&p1, &p2); - - adjustForAliasing(&p1); - adjustForAliasing(&p2); - - D2D1_POINT_2F d2d_p1 = to_d2d_point_2f(p1); - D2D1_POINT_2F d2d_p2 = to_d2d_point_2f(p2); - - if (!d->pen.dashBrush || state()->renderHints.testFlag(QPainter::HighQualityAntialiasing)) { - d->dc()->DrawLine(d2d_p1, d2d_p2, d->pen.brush.Get(), d->pen.qpen.widthF(), d->pen.strokeStyle.Get()); - } else { - d->pen.dashBrush->SetTransform(transformFromLine(lines[i], d->pen.qpen.widthF())); - d->dc()->DrawLine(d2d_p1, d2d_p2, d->pen.dashBrush.Get(), d->pen.qpen.widthF(), NULL); - } - } - } -} - -void QWindowsDirect2DPaintEngine::drawLines(const QLineF *lines, int lineCount) -{ - Q_D(QWindowsDirect2DPaintEngine); - D2D_TAG(D2DDebugDrawLineFsTag); - - ensurePen(); - - if (emulationRequired(PenEmulation)) { - QPaintEngineEx::drawLines(lines, lineCount); - } else if (d->pen.brush) { - for (int i = 0; i < lineCount; i++) { - QPointF p1 = lines[i].p1(); - QPointF p2 = lines[i].p2(); - - // Match raster engine output - if (p1 == p2 && d->pen.qpen.widthF() <= 1.0) { - fillRect(QRectF(p1, QSizeF(d->pen.qpen.widthF(), d->pen.qpen.widthF())), - d->pen.qpen.brush()); - continue; - } - - // Match raster engine output - if (!antiAliasingEnabled()) - adjustLine(&p1, &p2); - - adjustForAliasing(&p1); - adjustForAliasing(&p2); - - D2D1_POINT_2F d2d_p1 = to_d2d_point_2f(p1); - D2D1_POINT_2F d2d_p2 = to_d2d_point_2f(p2); - - if (!d->pen.dashBrush || state()->renderHints.testFlag(QPainter::HighQualityAntialiasing)) { - d->dc()->DrawLine(d2d_p1, d2d_p2, d->pen.brush.Get(), d->pen.qpen.widthF(), d->pen.strokeStyle.Get()); - } else { - d->pen.dashBrush->SetTransform(transformFromLine(lines[i], d->pen.qpen.widthF())); - d->dc()->DrawLine(d2d_p1, d2d_p2, d->pen.dashBrush.Get(), d->pen.qpen.widthF(), NULL); - } - } - } -} - void QWindowsDirect2DPaintEngine::drawEllipse(const QRectF &r) { Q_D(QWindowsDirect2DPaintEngine); diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.h b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.h index 39cbfdc6cb..c6b570887c 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.h +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dpaintengine.h @@ -92,9 +92,6 @@ public: void drawRects(const QRect *rects, int rectCount) Q_DECL_OVERRIDE; void drawRects(const QRectF *rects, int rectCount) Q_DECL_OVERRIDE; - void drawLines(const QLine *lines, int lineCount) Q_DECL_OVERRIDE; - void drawLines(const QLineF *lines, int lineCount) Q_DECL_OVERRIDE; - void drawEllipse(const QRectF &r) Q_DECL_OVERRIDE; void drawEllipse(const QRect &r) Q_DECL_OVERRIDE; -- cgit v1.2.3