summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
Commit message (Collapse)AuthorAgeFilesLines
* Handle WM_GETDPISCALEDSIZEMorten Johan Sørvig2021-10-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By handling WM_GETDPISCALEDSIZE we can keep QWindow’s device independent size constant across DPI changes. This is done by scaling QPlatformWindow’s native size such that the change of scale factor and change of QPlatformWindow size cancels out. Qt now handles DPI change using two events: WM_GETDPISCALEDSIZE: Compute the new size for the window. WM_DPICHANGED: Apply the new DPI and window geometry. The reason for this complication is that Windows retains control over the window position during the DPI change, in order to e.g. accurately track the cursor position during a screen change. The default WM_GETDPISCALEDSIZE implementation (provided by Windows) scales the win32 window size linearly with the DPI change. We want to use linear scaling as well, however the win32 window size includes the margins, which do not change linearly as the DPI changes. Instead, scale the QPlatformWindow size, and then add the new margins. Pick-to: 6.2 Change-Id: I4f225be8fad56b1fa77e9e3cfd6538a206589d73 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix scrolling of QRasterBackingStore when operating on QRasterGLSurfaceTor Arne Vestbø2021-10-012-0/+13
| | | | | | | | | | | | We were to strict in what surface type we allowed scrolling for. The RasterGLSurface type is an odd one, used by widgets to compose GL and raster content, which means we still have a raster backingstore we can scroll. It's just the flush that's different. Pick-to: 6.2 Change-Id: Ia229c21c00ad38df9e87f4fc78e341e030ef228d Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Allocate synchronously delivered QWSI events on the stackVolker Hilsheimer2021-10-012-182/+134
| | | | | | | | | | | | | | | | | If we know at compile time that a window system interface event will be delivered synchronously, then we can allocate it on the stack avoid a new/delete. This is the case for a large number of events. Add a template helper class that is specialized for the three delivery types to allocate the event object on the stack if possible, and on the heap otherwise. We can use that factory in the event handler functions, via a helper function, to replace the heap-allocation and call to handleWindowSystemEvent. Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Change-Id: If92fc91ef07f3542a37dfb0fed20e15a3d19b8f0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Remove conditioning on Android embeddedEdward Welbourne2021-09-171-3/+3
| | | | | | | | It is no longer handled separately from Android. This effectively reverts commit 6d50f746fe05a7008b63818e77784dd0c99270a1 Change-Id: Ic2d75b8c5a09895810913311ab2fe3355d4d2983 Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
* Deduplicate maybeQuitOnLastWindowClosed handlingTor Arne Vestbø2021-09-174-42/+44
| | | | | | | | | | | | | | | | | | The functionality now lives in QGuiApplication, and is triggered by QGuiApplication and QApplication after dispatching the close event to the window. The slight difference between how a Qt GUI and Qt Widget app determines if a window should contribute to the close-on-quit behavior has been abstracted into a QWindowPrivate helper. The additional checks that were in place for skipping out of the whole maybeQuitOnLastWindowClosed machinery have been kept. Task-number: QTBUG-53286 Change-Id: I81bd474755f9adb3a2b082621e5ecaa1c4726808 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix QGuiApplication command line options documentation for X11Tor Arne Vestbø2021-09-171-3/+3
| | | | | | | Fixes: QTBUG-96600 Pick-to: 6.2 5.15 Change-Id: Ic3670b952d97270cce4f0a8df8bba79e934e4a6d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Add QPlatformTheme::Appearance for detecting light/dark modesMitch Curtis2021-09-172-0/+13
| | | | | | | | | And implement it on Windows and macOS. Fixes: QTBUG-83908 Fixes: QTBUG-94859 Change-Id: I7b0c062adf5d4dbaefa64c862ab8ab1348809d71 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Make the closeAllPopup helper virtual in QGuiApplicationVolker Hilsheimer2021-09-151-0/+1
| | | | | | | | | | | | | | QPA plugins might have to close popups for events that are not delivered to QWindow or QWidget instances. For instance, the Cocoa plugin has to explicilty close popups when the user clicks into the window frame. Expose this functionality through a virtual in QGuiApplicationPrivate, and move the QApplication implementation from a static helper into the override. Task-number: QTBUG-96450 Change-Id: I52be5710c8d7515b9ae2e4bbadb069df4b3ed546 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* doc: use \note in QKeyEvent documentationTor Arne Vestbø2021-09-151-8/+8
| | | | | | Pick-to: 6.2 Change-Id: I0924f5a540ab5e58f7830c1af099ce6e44287811 Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Use QHighDpi::toNativeWindowGeometry()Morten Sørvig2021-09-151-7/+1
| | | | | | | | | This function implements the isTopLevel() logic, which we now don’t have to duplicate at each call site. Change-Id: Ic8b857aa7cd3c3c23d5e950d9f50b66c81ba3ccf Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QPlatformWindow: fix isAncestorOf not breaking recursionRichard Moe Gustavsen2021-09-131-1/+1
| | | | | | | | | | | | The current implementation got stuck always asking for the parent of the same child This patch will make sure we actually walk up the parent chain. Pick-to: 6.2 6.2.0 6.1 5.15 Change-Id: I9f67f6305e0143526f53952a563d496e760ac2e7 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Expose the config and display for EGL-based QOpenGLContextsLaszlo Agocs2021-09-131-0/+3
| | | | | | | | | | | | | | | | ...in the native interface. Using OpenXR is impossible on some platforms (for example, Android) without knowing all three. The EGLContext alone is not enough, and EGL offers no way to query the EGLConfig a context was created with. https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#XR_KHR_opengl_es_enable Therefore, expose all three so libs/apps can use the new way to query these native resource without resorting to the old-style nativeResourceFor* queries. Change-Id: I7efb0a26b858150da55e711752af99426e744322 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Move QWINDOWSIZE_MAX to platform headersPaul Olav Tvete2021-09-102-2/+1
| | | | | | | | | | | QWINDOWSIZE_MAX is needed to implement platform plugins and Wayland shell integrations. Moving the #define from qwindow_p.h to qplatformwindow.h makes it available from a supported header file. This should not break anything, since qwindow_p.h includes qplatformwindow.h Change-Id: Ie003b1e9d6494695057d59aba5a17ad7fd51c654 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Always give Qt::SubWindows a default window state of Qt::WindowNoStateTor Arne Vestbø2021-09-101-0/+3
| | | | | | | | | | On platforms such as iOS, the default window state is Qt::WindowMaximized, so that calling show() will fill the entire screen. But sub-windows should not get this treatment, as their geometry is typically managed manually. Pick-to: 6.2 6.2.0 Change-Id: Ib17c2011a16baf6023fe368b94fa7f38e12bd777 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Use wayland platform plugin on GNOME wayland sessions by defaultJan Grulich2021-09-091-15/+1
| | | | | | | | | | | Qt wayland platform plugin has improved quite a lot and it is now pretty much usable on Gnome. It also improves user experience a lot on HiDPI displays. Pick-to: 6.2 Change-Id: I943e0bb969f384bdc3c603e290ce9c8358b70f63 Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Clear up QWindow::isActive() documentationTor Arne Vestbø2021-09-081-1/+3
| | | | | | | | | | The isActive function does not determine if a window should be active, but whether it is currently active. The way the documentation was phrased may have lead people to believe the former. Pick-to: 6.2 6.2.0 5.15 Change-Id: I05a4cb3d8784a2fefa24bdd42ea96cfdae22b9d1 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Fix segfault when closing widget and destroying window in QDialog::doneVolker Hilsheimer2021-09-061-3/+7
| | | | | | | | | | | | On OpenSUSE we seem to get an Enter event after or while the QWindow is closed, and that appears to reset the currentMouseWindow after we cleared it in QWindowPrivate::destroy. Apply a workaround similar to the focus_window to make sure that currentMouseWindow and currentMousePressWindow don't point to destroyed objects. Pick-to: 6.2 Change-Id: I61afdaa7d8d1d437058624012319460be2f2567f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* doc: Add the PixelScroll device capability (new in 6.2)Shawn Rutledge2021-09-041-0/+5
| | | | | | | | | | Followup to 69c833dae91d004b48f815e0156d6caeb4cdb491 Pick-to: 6.2 Task-number: QTBUG-72167 Task-number: QTBUG-87646 Change-Id: I4ac7cbacd6dc1407ad3b565674a6d6494ec8857f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Doc: add more notes about full screen windows on macOSVolker Hilsheimer2021-09-031-0/+3
| | | | | | | Fixes: QTBUG-68069 Pick-to: 6.2 5.15 Change-Id: I8fc99f708cfa19a9c8cc8d13f6889549c79dd3b3 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Doc: add note that hiding a window doesn't close a full screen spaceVolker Hilsheimer2021-09-031-0/+7
| | | | | | | Fixes: QTBUG-52450 Pick-to: 6.2 5.15 Change-Id: I3f819bac470b5a883a74fb58f6fa2d27740eaaf2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QWidget: close the QWindow in QWidget::closeVolker Hilsheimer2021-09-022-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | We want to close the window, end full screen mode on macOS, and free platform resources. This is all done by QWindow::close. QWindow::close closes the platform window, triggering a closeEvent to QWidgetWindow, which then calls QWidgetPrivate::close_helper. This way, closing a window via QWidget::close, QWindow::close, or interactively by the user are all equivalent. The QCloseEvent generated by the widget needs to be spontaneous for window-system generated events (i.e. the user clicked the close button), and non-spontaneous if the window closes because of a call to QWindow::close. To keep track of whether the event originated in an explicit call to QWindow::close, add a boolean to the QWindowPrivate. Add a test case that verifies that the window resources is destroyed, and that events are delivered as they should. Done-with: Morten Johan Sørvig <morten.sorvig@qt.io> Fixes: QTBUG-46701 Pick-to: 6.2 Change-Id: Iacb6a2c8d5e880b16b0c8f0c9257ed94bed36f5b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Port to QImage and QPixmap deviceIndependentSize()Morten Sørvig2021-09-011-3/+1
| | | | | | | | | Replace the “size() / devicePixelRatio()” pattern with a call to deviceIndependentSize(). Change-Id: I9d9359e80b9e6643e7395028cd43e3261d449ae7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix deprecation of QMouseEvent::source() and flags()Shawn Rutledge2021-08-272-1/+3
| | | | | | | | | | Amends 53496e67f0b78645c6080e9218c7a36bc5a9d76d: - move flags() out of the QT_DEPRECATED_SINCE block in the header - add QT_DEPRECATED_SINCE block around source() implementation Pick-to: 6.1 6.2 Change-Id: Id52fa6b04a13efbede3e6ac440060f90b283e773 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QFileDialog: Use static const QRegularExpressionWaqar Ahmed2021-08-181-1/+1
| | | | | | | This avoids rebuilding the same pattern. Caught by clazy. Change-Id: Ibd0f2063617df1a9e975f58e34df556d1983afff Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
* Properly scale gesture positions in hi-DPI casePovilas Kanapickas2021-08-121-3/+15
| | | | | | | | The local/global positions for gestures should be handled the same as for other events as they mean effectively the same thing. Change-Id: Ic5ad995607ecd3daf385a7c7be3b67cbae312e7b Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* QGuiApplication: move two static variables from DATA to BSSMarc Mutz2021-08-101-2/+2
| | | | | | | | | | | | | | | | | The {mouse,touch}DoubleXDistance variables were initialized to -1, which forces them into the DATA segments. But this value is completely unused, since these variables are also set in initThemeHints(), called from QGuiApplicationPrivate::init(), before their only user, QGuiApplicationPrivate::processMouseEvent(), can possibly execute. By changing the default value to 0, then, we allow the compiler to place these variables into the BSS segment. Change-Id: I86144559ee2410b844f70a4f2499c8d3140d14cf Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QInputDeviceManager: make QT_NO_KEYWORDS-cleanMarc Mutz2021-08-061-1/+1
| | | | | Change-Id: I1ba43c4dce82a8488e51c471fa3409fc08be1529 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Add native interface for X11 application, exposing display and connectionTor Arne Vestbø2021-08-063-0/+90
| | | | | | | | | | | | | | | | | | | | | The major use-case of the now private QX11Info from Qt X11 Extras was getting hold of the Xlib display and XCB connection, for example in KDE: https://lxr.kde.org/search?%21v=kf5-qt5&_filestring=&_string=QX11Info A new native interface for QGuiApplication has now been added that exposes these two properties, e.g.: if (auto *x11App = app.nativeInterface<QX11Application>()) qDebug() << x11App->display() << x11App->connection(); To avoid type clashes one of the enum values of QXcbNativeInterface's ResourceType had to be renamed. Pick-to: 6.2 Task-number: QTBUG-93633 Change-Id: I2e366a2bb88bd3965ac6172ad000ae32209f43e7 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QInputDeviceManager: ++explicit, ++out-of-line-dtorsMarc Mutz2021-08-062-1/+4
| | | | | | | | | It's private API, but exported, so de-inline the dtor to pin the vtable in QtCore instead of potentially duplicating it in every plugin that uses the class. Change-Id: Ia948985bb94677c8453a8e7be27a14085303aaf5 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Improve WM_DPICHANGED handlingMorten Johan Sørvig2021-08-061-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resize QPlatformWindow on DPI change, so that QWindow size can stay approximately constant. For example, a 100x100 QWindow at 100% scaling will have a 100x100 QPlatformWindow. If the scaling is changed to 200% then the QPlatformWindow is resized to 200x200, while the size of the QWindow stays at at 100x100. In practice the QWindow size will also change slightly, due to inaccuracies in how we adjust for the size of the non-client window area. This will be addressed in a later commit. We can get DPI change independently of screen change, so no resizing should happen in screen change events. Disable the resize code in QGuiApplication for Q_OS_WIN, and remove the WithinDpiChanged flag. The new flow for handling DPI change is: 1) Send screen change (if any), so that the correct screen will be used when calculating scale factors during the following resize. 2) Resize the native window, which will trigger geometry change events, possibly also for the QWindow. 3) Resize child windows; WM_DPICHANGED is sent to top-level windows only. Fixes: QTBUG-89294 Pick-to: 6.2 Change-Id: I0e2d44bae72d20ebdafc3d410db7be9964ad851b Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Register mouse devices on cocoaShawn Rutledge2021-08-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | It would have been nice to ensure that a device is registered already in mouseEnteredImpl(); but in that context, NSEvent.deviceID is always 0, and we can't find out anything else about the device. QWindowSystemInterface::handleEnterEvent() doesn't currently take a QPointingDevice either. In handleMouseEvent() and scrollWheel(), deviceID seems unique for each trackpad or Magic Mouse, but 0 for any plain USB mouse. There, the first mouse that the user interacts with becomes primaryPointingDevice(): its deviceID is assigned to systemID (except if deviceID == 0, we use 1 instead, to avoid the auto-incrementing device ID assignment in the QInputDevicePrivate ctor.) When scrolling occurs, we update the capabilities to have PixelScroll if theEvent.hasPreciseScrollingDeltas. So over time, QInputDevice::devices() should build up to a complete list, with capabilities() also distinguishing plain mice from those that have the PixelScroll capability. And in the common case that the user has only one Apple pointing device, it becomes primaryPointingDevice(). Pick-to: 6.2 Task-number: QTBUG-46412 Task-number: QTBUG-63363 Task-number: QTBUG-72167 Change-Id: Id9771b4dfd765e49023bd57d42a2aa4d0635a3b2 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Doc: Ensure deprecated APIs in Gui are documented as suchNico Vertriest2021-07-264-28/+57
| | | | | | | | | | | Added missing #if-ery and deprecation macros to a QFont constructor that was only documented as deprecated. Fixes: QTBUG-94521 Fixes: QTBUG-95310 Pick-to: 6.2 6.1 Change-Id: I3d0418a3f7dca191a9068cc22627fe4deb7c53c5 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QOpenGlContext: remove duplicated includeIvan Solovev2021-07-201-1/+0
| | | | | | | | Spotted during API review for 6.2 Pick-to: 6.2 Change-Id: Ib31020848ec6ffabc126c6984cc82547266d4a1d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use member function instead of template function to resolve native interfaceTor Arne Vestbø2021-07-176-23/+16
| | | | | | | | | | | | | | The use of a freestanding function is not needed now that the name doesn't alias the nativeInterface accessor function, and was just adding complexity to the machinery. People not familiar with the code will have an easier time following the flow through the helper member function, and we no longer need to declare our own export macros. Pick-to: 6.2 Change-Id: I17530b7e89939cfc19ab8ffaa076b7129ae02dcf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QClipboard: remove a useless default switch-case labelWenTao Song2021-07-161-2/+1
| | | | | | | | | | The switch condition expression has already dealt width all the conditions, so a `default` label is not necessary (it introduces a warning). Delete it. Fixes: QTBUG-95223 Change-Id: Iac3d9bb5d0b6fd8372d4dc16d920ce0a7b0511db Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Add note about precision of QNativeGestureEvent::delta; fix in Qt 7Shawn Rutledge2021-07-152-5/+19
| | | | | | | | | | | We keep QVector2D storage Qt 6 BC (to avoid making QNativeGestureEvent larger), but in Qt 7 we should return exactly the same value as given (for what it's worth, in spite of this being overkill for panning a reasonable distance). Change-Id: Iecbd4c9b60ad9ae5e0466c7027b038ddb85b8c8b Pick-to: 6.2 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Improve error reporting when requesting unsupported native interfaceTor Arne Vestbø2021-07-156-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By switching out the static_assert for an enable_if we end up producing a clearer error, at the call site: /qt/qtbase/examples/gui/rasterwindow/main.cpp:69:9: error: no matching member function for call to 'nativeInterface' app.nativeInterface<QNativeInterface::QCocoaGLContext>(); ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /qt/qtbase/src/gui/kernel/qguiapplication.h:176:5: note: candidate template ignored: requirement 'NativeInterface<QNativeInterface::QCocoaGLContext>::isCompatibleWith<QGuiApplication>' was not satisfied [with NativeInterface = QNativeInterface::QCocoaGLContext, TypeInfo = QNativeInterface::Private::NativeInterface<QNativeInterface::QCocoaGLContext>, BaseType = QGuiApplication] QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QGuiApplication) ^ By using SFINAE for the TypeInfo we can also ensure that it works for types that are not native interfaces, such as if the user tries to call nativeInterface<QString>(). Since we can no longer use decltype(*this) to resolve the base type we need to change QT_DECLARE_NATIVE_INTERFACE_ACCESSOR to take the type as an argument, as we do for other QT_DECLARE_FOO macros. Pick-to: 6.2 Change-Id: Ie3f7e01ab7c3eb3dcc2ef730834f268bb9e81e0c Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Rename QNativeGestureEvent::deltas() to delta(); clarify docsShawn Rutledge2021-07-146-24/+49
| | | | | | | | | | | | | | | | | In QPanGesture this is called delta(). OTOH we have QWheelEvent::pixelDeltas(). Delta is a vector, and there's only one (with two components). Native gestures hold incremental values: e.g. the pinch gesture event provides an incremental amount of either zooming or rotation (so most events have QNativeGestureEvent::value() very close to 0). It's the same with the pan gesture's delta(). Add better docs for swipe and pan gestures. Change-Id: Ia147c7c9a22e084c3700b1620dec46427d792bd1 Reviewed-by: Povilas Kanapickas <povilas@radix.lt> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Change QNativeGestureEvent::deltas() to QPointFShawn Rutledge2021-07-145-6/+6
| | | | | | | | | | | | | It came up during 6.2 API review that we prefer all floating-point API to be double-precision on 64-bit platforms, despite the awkwardness of representing a displacement vector with something called a "point". The docs for QPointF explicitly state "A QPointF object can also be used as a vector: Addition and subtraction are defined..." Amends 31f90e99b8f04d9a228c5a0b01319b3f112c1490 Change-Id: I01029661f2586640cbf846f49df164c176d17f7a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QColorTrcLut: hold in shared_ptrMarc Mutz2021-07-122-11/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | ... instead of raw pointers or QSharedPointer. Raw pointers are, of course, a no-no in modern code. In particular, when the result is then held in shared_ptr or QSharedPointer, make_shared or QSharedPointer::create() should be used to reduce number of memory allocations. Since this is private API, we're free to use std::shared_ptr, which does only half the atomic operations on copies, compared to QSharedPointer, so is more efficient. For either make_shared or QSharedPointer::create(), we need to work around the private ctor, which we do by inheriting a member-function local class from QColorTrcLut and make_shared'ing that. As a member-function-local class, it has access to the otherwise private parts of QColorTrcLut, including its default constructor. As a public subclass, shared_ptr has no problem performing the derived-to-base pointer adjustment in the return statement. This way, we can use make_shared even though our target's class' ctor is private. Change-Id: Icb11249b54cd5e544e692f6a0bf1f9dda1710454 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QGuiApplication: remove Windows-only variable from non-Windows buildsMarc Mutz2021-07-121-0/+2
| | | | | | | | ...lest some code tries to set it to no possible effect. Change-Id: I7aed05200c1abeda1d2f9d88ceb99a5ce6132dbf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Show positions in QDebug operator<<(dbg, QHoverEvent*)Shawn Rutledge2021-07-051-19/+30
| | | | | | | | | | In Qt 6, QHoverEvent is a QSinglePointEvent and carries more information than it did in Qt 5. Task-number: QTBUG-94971 Change-Id: I55b271e8741081ed9074f687b08f4111142a1bf0 Pick-to: 6.2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Consistent indentation for all Q_PROPERTYsAndreas Buhr2021-06-248-27/+55
| | | | | | | | Task-number: QTBUG-94407 Pick-to: 6.2 Change-Id: I8c97a0b2de2bed78456322be271724fc47479d83 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Migrate to autogenerated cpp exportsAlexey Edelev2021-06-242-14/+2
| | | | | | | | Use autogeneratedd cpp exports in the Gui module. Task-number: QTBUG-90492 Change-Id: Ifc5d3dd138ef9f86f6003ed9adb66a9eefdd64db Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Enable glyph cache workaround for Apple M-family of GPUsTor Arne Vestbø2021-06-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Without the workaround, and when using a Core GL profile, we hit a code path in QSGOpenGLDistanceFieldGlyphCache::resizeTexture() that produced corrupt glyphs on M1 hardware. We fix this by enabling the workaround, so that the user doesn't have to set QT_ENABLE_GLYPH_CACHE_WORKAROUND themselves. None-Core contexts do not have this problem, but the logic in QOpenGLContext does not account for recreated contexts with different formats, so we can't limit the workaround to Core formats only. With the unified memory architecture of the M1 hardware, the workaround should have limited negative effects. In Qt 6 this is not a problem, since Qt Declarative effectively always uses the workaround code-path, but it's worth recording the fact that we need the workaround. Fixes: QTBUG-89379 Pick-to: 6.2 6.1 5.15 5.12 Change-Id: Icfd8b8b23c0dcda3fea8663d81d0e225134eec5e Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Doc: Remove mentioning of Qt::MidButtonKai Köhne2021-06-171-1/+1
| | | | | | | | It's only Qt::MiddleButton in Qt 6. Pick-to: 6.1 6.2 Change-Id: Ia68bad910c617993e30e3ed1e117192469ec50eb Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Stop using mixed enum arithmeticGiuseppe D'Angelo2021-06-131-1/+1
| | | | | | | | | | | It's deprecated. Port some unnamed enumerations (used only to declare constants) to constexpr integers instead. Apply qToUnderlying as needed. Task-number: QTBUG-94059 Change-Id: Ifaa64ece966ce08df40dc71ffcfa7ac038110e0b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Deliver WindowActivate/Deactivate events to QWindowVolker Hilsheimer2021-06-111-1/+9
| | | | | | | | | | We need those events to trigger palette color group changes in QQuickItem without having to connect every item to yet another QWindow signal. Task-number: QTBUG-93752 Pick-to: 6.2 Change-Id: I8534808cdaab828e5876f8fda31567aeb1b4272a Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* macOS: allow Qt::AA_DontShowShortcutsInContextMenus overridesVolker Hilsheimer2021-06-072-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | Following the discussion in QTBUG-69452, the resulting change in cc33dd079796437bafed8f42de7fbf8f17d19ec8, and the documentation of QAction::shortcutVisibleInContextMenu, the intention is that the attribute allows the overriding of the platform default. However, QAction did ask both the attribute and the platform integration, making the override impossible. Instead, ask only the attribute, but default the value of the attribute to what the platform integration provides. [ChangeLog][QtGui][QAction] The shortcutVisibleInContextMenu property defaults to the value of the Qt::AA_DontShowShortcutsInContextMenus attribute, which in turn defaults to the platform integration. To override the default, set the application attribute after instantiating QApplication, or override the default for each QAction instance. Task-number: QTBUG-73990 Pick-to: 5.15 6.1 Change-Id: Iaba330913555d93d05efe1b3965a6aea39db5554 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Expose the native interfaces of QScreen/QWindowFriedemann Kleint2021-06-076-6/+63
| | | | | | | | Add the macros. Task-number: QTBUG-84220 Change-Id: Ica23b9e4d5c1ca072acb5356e6f2be28d5199fa6 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>