summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowswindow.cpp
Commit message (Collapse)AuthorAgeFilesLines
* ColorScheme: make QStyleHints::colorScheme writable for applicationsVolker Hilsheimer2 days1-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Applications can request the color scheme to be either explicitly light or dark, or to follow the system default by setting the scheme to Qt::ColorScheme::Unknown. Setting the color scheme will make the request to the QPlatformTheme implementation, which can then use the appropriate implementation to set the application's appearance so that both palette and window decoration follow the requested color scheme. This should trigger theme change and palette change events. A change to the effective scheme should then call back into QStyleHintsPrivate::updateColorScheme, which will emit the changed signal for the property. Implement this for macOS (Cocoa), iOS, Android, and Windows. On macOS, we have to use deprecated AppKit APIs; the replacements for those APIs are not suitable for this use case. On iOS, the setting is for each UIWindow, which we can update or initialize based on an explicitly requested scheme. On Android we can piggy-back on the logic added when dark theme support was introduced in b4a9bb1f6a40e6d504c1f48f0d9ea2b70ab1a9f0. On Windows, we have to fake a dark palette if the dark scheme is requested on a light system, as there is no API to read a dark palette. However, we also have to ignore any application preference if a high- contrast accessibility theme is selected by the user (we report the color scheme as unknown; there are both light and dark high-contrast themes), and read the system palette using the GetSysColor API, which is used for light mode. And we need to initialize windows with the correct frame if the application explicitly overrides the system color scheme. Add an auto-test to the QApplication test, as that gives us the most coverage to confirm that QStyleHints emits the changed signal, and that Theme- and PaletteChange events are received by the toplevel widget when the color scheme actually changes. This test has to be skipped on platforms where we cannot set the color scheme programmatically. Add the option to explicitly select the color scheme to the widget gallery example, and default it to dark mode. Fixes: QTBUG-124490 Change-Id: I7302993c0121284bf9d3b72e3149c6abbe6bd261 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Windows: simplify setting the dark borderVolker Hilsheimer9 days1-13/+0
| | | | | | | | | | | | | | | A round trip through querying the window attribute to avoid a call to the setter is overkill, we can assume that the setter won't do anything if the value of the attribute doesn't change. Also, don't check whether QWindowsIntegration::darkModeHandling is overridden before calling setDarkMode, which checks that flag already. The flag will be very rarely cleared (and we might want to remove support for this obscure mechanism soon). Task-number: QTBUG-124490 Change-Id: I7e027fd53f556200edfd127eaf5f2b97f027528e Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* ColorScheme: consolidate dark mode handling on Windows into ThemeVolker Hilsheimer2024-04-251-2/+3
| | | | | | | | | | | | | | | Move storage of whether dark mode is set into a static class member of QWindowsTheme, and remove QWindowsContext::isDarkMode; ask the theme instead using the colorScheme() implementation, which will return the stored value. Move the code handling settings changes into QWindowsTheme as well. Task-number: QTBUG-124490 Change-Id: I4795e80b6ab2c94701385dc84771e9ad5578cf32 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* QWindow: Persist foreign winId to support destroy/create cyclesTor Arne Vestbø2024-04-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | We used to set a private _q_foreignWinId property on QWindow when creating foreign windows, and this was the mechanism which we then passed the foreign winId to the platform plugin. With c585802e946d97e7d177ea334a162dc7bc286b84 this was removed, since we now were passing the winId through via explicit QPA APIs, and since 0c6911e5cde24c45d6f2c08b6e71064bdd1eccfa removed the ability to explicitly destroy() a foreign window. But when closing a QWindow, we destroy both the window itself, and all its children, including foreign windows. In this case we still want to support recreating the foreign window, for example when the parent window is shown again. To enable this we restore the _q_foreignWinId private property, but keep the limitation of not being able to explicitly destroy a foreign window. Pick-to: 6.7 6.5 Fixes: QTBUG-124160 Change-Id: Ia885ba9f043e64fb21eedd2b4c344679726f1b5c Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows QPA: Include custom margins in atypical marginsTimothée Keller2024-03-051-5/+6
| | | | | | | | | | | | When calculating atypical margins that are used with ExtendsContentIntoTitleBar, the margins were checked against systemmargins, and then custom margins were added later. Instead, add the custom margins immediately and take them into account during calculations. Pick-to: 6.7 6.6 6.5 Change-Id: I44af663c85b8bdf080d769e3b38431cbe5df64f3 Reviewed-by: David Faure <david.faure@kdab.com>
* windows: Remove workaround for delayed OpenGL initializationTor Arne Vestbø2024-03-011-22/+0
| | | | | | | | | | We no longer use QSurface::RasterGLSurface for composition, so the window will already be QSurface::OpenGLSurface during WindowCreationData::initialize. Pick-to: 6.7 6.6 6.5 Change-Id: I9b5ea0245ddf4a19d165bde9ad6fd48a98bfca4f Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows QPA: don't take dpi rounding policy into account when fullscreenTimothée Keller2024-01-161-10/+10
| | | | | | | | | | | With some HighDpiScaleFactorRoundingPolicy, going fullscreen can end up not filling the whole screen. In this case, ignore the rounding (only for the window size, not its content). Fixes: QTBUG-115954 Pick-to: 6.7 6.6 Change-Id: Ie87196358ef28dbe2fcbc180b1740ed9f784b4a0 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Fix Maximized frameless window painting wrong with WS_THICKFRAMEYansheng Zhu2023-12-211-12/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | In Qt versions greater than 6.4.2, when using Qt:FramelessWindowHint and WS_THICKFRAME simultaneously, and handling the WM_NCCALCSIZE message to draw a frameless window, the right and bottom sides may extend beyond the drawable boundaries. This is because in the previous commits, the calculation for margins was skipped for windows with Qt:FramelessWindowHint set. This is correct for non-maximized windows. However, when a window is maximized on Windows, its actual size is slightly larger than the drawable area to avoid users from dragging the border to resize the window. When window was maximized , the code for calculating geometry should remove the margins instead of skipping its calculation. The fixed code determines whether to skip the calculation of margins and frame by checking whether the window is maximized during the calculation [ChangeLog][QPA][Windows] Adding a check for the maximized state of the window during the calculation of margins. Margins calculation will not be skipped for maximized windows. Task-number: QTBUG-120196 Pick-to: 6.7 6.6 6.5 Change-Id: I63c8dbc8f65ff28cc581be261acfd3f675b027c4 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows QPA: don't override user-removed marginsTimothée Keller2023-12-181-5/+14
| | | | | | | | | | | When calculating margins, added a check to see if the window rect and the client rect are the same size. If they are, we return early, to avoid overwriting user-defined specific margins. Fixes: QTBUG-117704 Pick-to: 6.7 6.6 6.5 Change-Id: I9947feab4cb900293fb6be6cf09c56268f38d64a Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows: Improve hidpi style drawing and metricsMorten Sørvig2023-11-151-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follow-up change from enabling DPI awareness, which caused some style elements (for instance check boxes) to be rendered incorrectly on non-primary displays, when there is a difference in DPI between displays. Use two approaches to get system metrics and themes: * Use forDpi() API variants and query at 96 DPI for style metrics, that are in device independent pixels. These are metrics which are used for layout calculations. * Get theme metrics at the target display DPI, and scale to device independent pixels when needed. This is used for OpenThemeData(), since this theme is used for drawing as well and needs to be in device pixels. One approach is not used any more: * Get metrics for the main display, and scale by the ratio between the main and target display. Change the theme cache to cache themes per window handle (HWND). This is required since OpenThemeData() returns theme data for a specific DPI, which means we can no longer use a shared cache. Clear the cache on theme change, DPI change, and when the window is destroyed. This handles cache invalidation when the window is moved to a different screen, and also when the DPI for a screen is changed. Move the cache implementation to QWindowsStyleSupport in QtGui, where it can be accessed by both the style and windows platform plugins. Task-number: QTBUG-110681 Change-Id: I5a4ff3a3753762bad8a51d08e51e8013bc7816a1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jøger Hansegård <joger.hansegard@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix margin issue in wizard for windowsSanthosh Kumar2023-10-311-4/+4
| | | | | | | | | | | | | The patch set 8dbc4824895ea9f87d1f6406fe2d22336b6253ed extends support in calculating margins when ExtendsContentIntoTitleBar() is used. But this affects existing QWizard that sets custom margins through Aero style. This is because, the custom margins set by Aero style excludes top margin (titleBarSizeDp()) and excluding it once again cause slicing in the client window area. This patch set fixes it by considering top margin only when system margins is used in windows. Fixes: QTBUG-117428 Pick-to: 6.6 6.5 Change-Id: I6d6eefc691f26474257b58304dac169fba20b5e1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Timothée Keller <timothee.keller@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Windows QPA: remove SWP_NOCOPYBITS for plain movesTimothée Keller2023-10-171-4/+8
| | | | | | | | | | | | | The SWP_NOCOPYBITS flag helps suppress some jittering during resizes. At the moment this is called even for plain moves with no window resizing. Make sure that the window geometry has changed before applying the SWP_NOCOPYBITS flag Fixes: QTBUG-115992 Pick-to: 6.6 6.5 Change-Id: Ic0cb32d9eb3b557bf2b2ef5b6ba80d34e27c5c19 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Pavel Dubsky <pavel.dubsky@qt.io>
* Revert "Windows QPA: Move transient children with a window move"Timothée Keller2023-10-101-46/+0
| | | | | | | | | | | This reverts commit 530d092eae0579bbb88e95f853715cac214da636. Reason for revert: Moving transient children as a whole is too broad, and forces unrelated windows to have their position completely dependent on a transient parent. Fixes: QTBUG-117779 Pick-to: 6.6 6.5 Change-Id: I01312e26e95c8144c392eca33aec41f54aaa40b0 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Windows QPA: Adjust margins for Windows App SDK compatibilityTimothée Keller2023-09-131-3/+26
| | | | | | | | | | | | | | | If using the ExtendsContentIntoTitleBar() method from the Windows App SDK, the top margin becomes zero. The current approach does not account for this, since it relies on the AdjustWindowRectExForDpi function. Do a manual check after and correct if necessary, by comparing the window and client sizes. Fixes: QTBUG-113736 Pick-to: 6.6 6.5 Change-Id: I62e0338b3ff7af47f5525dcccd0f9acfe9691819 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Wladimir Leuschner <wladimir.leuschner@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Windows QPA: also consider child windows for setting WS_EX_LAYEREDTimothée Keller2023-08-141-2/+9
| | | | | | | | | | Child windows on Windows cannot have a frame, so checking only for Qt::FramelessWindowHint is not sufficient. Add an additional check to see if the window is a native child (has the WS_CHILD flag). Pick-to: 6.6 6.5 Change-Id: Ib5cbec0f6157da687a5585e12a6c4c6935919538 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Windows QPA: Move transient children with a window moveTimothée Keller2023-06-271-0/+46
| | | | | | | | | | | | When moving a window with keyboard shortcuts, popup menus currently do not follow along. Allow this to happen by accounting for a window's transient children, and moving them after the owning window has finished its move. Fixes: QTBUG-106483 Pick-to: 6.6 6.5 Change-Id: Id51a7c0163e4fdd2d139565f2bf500a3fc997488 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows QPA: Fix dpi change when changing screens with keyboardTimothée Keller2023-06-261-3/+3
| | | | | | | | | | | | | If moving a window from a screen to another using keyboard shortcuts, the screen change detection happens after the handleDpiChange() call which essentially makes Qt think the window stayed on the old monitor. Instead of checking against currentScreen DPI, check against savedDpi which should not have this problem. Task-number: QTBUG-106483 Pick-to: 6.6 6.5 Change-Id: Ic30dc1b16bbaf9306a086c8d3042f5341d3848c1 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows QPA: introduce a way to disable redirection surfaceYuhang Zhao2023-06-241-0/+4
| | | | | | | | | | | | | | | | | Why do we need this feature: to give user the possibility to explore different interesting graphics features (currently only compatible with D3D with the new FLIP model). Why do we need to modify QPA directly: touch this flag after the window has been created has no effect. It can only be used when we call CreateWindow(), so we can't add this flag through SetWindowLong(). However, Qt doesn't provide any public or private interface to control how Qt call CreateWindow(), and providing such interface is also dangerous. Using environment variable to control this behavior is the simplest solution and is commonly used inside Qt code base. Change-Id: I12440ed498d97cc17640e6c7498e42770b813737 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
* Windows QPA: Fix restore geometry after dragging from maximised - FixTimothée Keller2023-06-071-9/+16
| | | | | | | | | | | | | Small adjustment made to previous patch to fix the following issues: - restoreGeometry not being updated after moving the window from one screen to the other with keyboard shortcuts. - restoreGeometry's size not being changed when moving screens if WM_GETDPISCALEDSIZE isn't sent. Pick-to: 6.6 6.5 Task-number: QTBUG-112814 Change-Id: I9dd2340137ce57a731f8881d476e902323887e62 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows QPA: Fix restore geometry after dragging from maximisedTimothée Keller2023-04-251-0/+19
| | | | | | | | | | | | | Start tracking the window geometry before a mouse drag, so that we can revert back to that geometry when we restore from maximised. Previously, when dragging from maximised to maximised, the restore geometry would end up being the final drag place before snapping to maximised, instead of where the window was before the first maximised. Fixes: QTBUG-112814 Pick-to: 6.5 6.2 Change-Id: Ic2ddf29d6c4abdc9e8b0c5161b17aa6ee9474ea3 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows QPA: Handle DPI induced geometry change for frameless windowsTimothée Keller2023-04-251-0/+5
| | | | | | | | | | | Make a manual call to the geometry change handling function after a WM_DPICHANGED event if the window is frameless, since WM_SIZE and WM_MOVE will not be called. Fixes: QTBUG-109429 Pick-to: 6.5 Change-Id: I79b9f386fe120ee3d06d6490d3f31a7a5d7121b0 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Revert "Apply system background color for top level window"Vladimir Belyavsky2023-04-191-16/+1
| | | | | | | | | | | | | | | This reverts commit 2991c66b75612dfb11dbba166dd08b2376b42102. Reason for revert: it caused a regression with translucent Qt Quick windows. We need to find alternative way how to fix QTBUG-106583 taking into account QQuickWindow's own color property. Fixes: QTBUG-112473 Fixes: QTBUG-112537 Fixes: QTBUG-111969 Fixes: QTBUG-112524 Pick-to: 6.5 Change-Id: I34258f4c8b045b63c8462e325b09fff927684223 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* windows: Re-apply mask when DPI changes, to account for new scale factorVolker Hilsheimer2023-04-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | When the DPI of a window changes due to being moved to another screen, or the current screen reconfiguring, the mask we've set earlier is no longer correct, as the mask was set based on the original screen's scale factor and in relation to the former platform geometry of the window, which now has changed. Like the geometry of a QWindow, the mask is expressed by the user in the QtGui coordinate system, so it's the platform's job to transform this into the platform coordinate system and update it when needed. Add a manual test that users a QWidget and a Q(Raster)Window side by side. There's still an issue with the screen change being triggered to early, via QWindow::setGeometry, instead of when the window has actually moved to the new screen, resulting in the paint event flushing to a window and backingstore that is in the wrong state, but this requires further research to fix. Task-number: QTBUG-97642 Pick-to: 6.5 6.2 Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io> Change-Id: I7ab2d267fbaf6ac32b507d05a418eb025b354a0b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Windows QPA: Change handling of maximised frame/title-less windowsTimothée Keller2023-03-221-32/+35
| | | | | | | | | | | | | | So far, the framele/tite-less window maximising has been done by adjusting the MINMAXINFO to prevent them from covering the taskbar. It does not work when moving the windows from one screen to another using keyboard shortcuts, since the MINMAXINFO is that of the old monitor. This moves the adjustment to the WM_SIZE message that occurs after the window has been resized. Pick-to: 6.5 6.4 6.2 Change-Id: I0d36fe5d2e8eaa0739414835b8d99a0b2ed44cf6 Reviewed-by: Yuhang Zhao <yuhangzhao@deepin.org> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Add API in QWindowsPrivate to provide window paletteSanthosh Kumar2023-02-281-3/+5
| | | | | | | | | | | | | | | | The window uses default palette (QPalette()) to determine frame color (either light or dark). This doesn't work for quickcontrols as they depend quicktheme palettes and they don't overwrite default palettes. This patch add API in QWindowPrivate to provide palette for window and this can be overridden by quickcontrol windows to provide their corresponding palette. Fixes: QTBUG-111491 Pick-to: 6.5 Change-Id: I39eea20ee7c61ecf0279143c9784da35be15edd3 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Windows QPA: Rework how we activate the windowYuhang Zhao2023-02-081-31/+66
| | | | | | | | | | | | | | The new implementation has the following advantages compared to the old one: 0. Qt's default activation behavior is not changed, this patch only improves how we forcely activate the window. 1. Account for the special case that the foreground window maybe hangs. 2. Truly bring the window to front if the window is hidden or minimized. 3. Use early return to save many indentation. Change-Id: If51ad943fbc9771ebdddfa0e49732b12566ca2b6 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows QPA: also consider window flags when judging frameless or notYuhang Zhao2023-01-231-12/+36
| | | | | | | | | | | | It's possible that the window has the WS_THICKFRAME flag but the Qt::FramelessWindowHint is enabled at the same time. That usually indicates the user is customizing the window, but it will also confuse QPA's current logic. We can make the logic more roboust by reading the Qt window flags as well. Pick-to: 6.5 6.4 Change-Id: I9894e312a92ef7f5fc0aa93974f216b67fe2cf29 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows QPA: remove long-time dead codeYuhang Zhao2022-12-171-12/+1
| | | | | | | | | It has been commented out since at least 5.3 (the earliest version hosted on the GitHub mirror), so it seems this code is not used by anyone for more than 10 years. We can safely remove them. Change-Id: Ia475ce5a5fdd6db48f415b3647677a35c79bfc5d Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* HiDPI: fix wrong window size after DPI changeYuhang Zhao2022-12-141-1/+7
| | | | | | | | | | | | Current code doesn't take the custom margins into account, it will cause windows with custom margins have wrong size after DPI change. Amends commit 2cfca7fd1911cc82a22763152c04c65bc05bc19a Pick-to: 6.5 6.4 Change-Id: I80b01c030a63d02cf66f105785df7c3f590481b5 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Windows QPA: Always apply system background color for top level windowYuhang Zhao2022-12-051-3/+4
| | | | | | | | | | | | | | | This is a follow-up patch of commit 2991c66b75612dfb11dbba166dd08b2376b42102 We can unset the window background brush and always draw the background ourself. Qt always paint all pixels anyway when blt'ing the backingstore, so it should be safe to do this. Since a theme might not provide a palette (e.g. when desktop setting awareness is disabled), always use the default application palette. Change-Id: I4fdc2467b3cc3999dd1acfe9411cec077ca66bd3 Reviewed-by: Yuhang Zhao <2546789017@qq.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Windows: Reduce warning output when creating a new windowVolker Hilsheimer2022-12-051-4/+4
| | | | | | | | | | | | | | | | Amends f32aa06f4f925e9a14db1bf76918358480b98b6a, which called setDarkBorderToWindow with false when creating a window if windows is not running in dark mode. This generates warning messages on Windows 10. We don't have to call the setter at all unless we want dark mode frames, so skip it if we'd call it with 'false', as that is the default anyway. At the same time, use categorized logging for these messages; they are not the result of application developers doing something wrong, and are only interesting when analysing specific issues. Change-Id: If80028d71cc2cd9d6dd380976e00b736741287cb Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Windows: Reevaluate dark frames if the application palette changesVolker Hilsheimer2022-11-261-9/+14
| | | | | | | | | | | | | | | | | | | Since 5ea7e3a8111b2939f0c91b750aa1c62ab16ab715 we are using dark window frames if the default palette is dark, unless applications explicitly override dark frame support. If the palette changes during runtime, we didn't reevaluate that setting. Do that by handling ApplicationPaletteChange events in QWindowsWindow. We still have to respect an explicit opt-out. Simplify the code at the call sites of setDarkBorder(), we don't need to check all the time whether the application has opted out of dark frame support. Pick-to: 6.4 Task-number: QTBUG-72028 Change-Id: I94e7d33cd21f9656ca210b43e775f487abc25b54 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Apply system background color for top level windowSanthosh Kumar2022-11-151-1/+15
| | | | | | | | | | | | Repaint top level window with system background color when it shows up first time. The system background color will be affected by dark or light mode settings in windows Fixes: QTBUG-106583 Pick-to: 6.4 Change-Id: I9205335540e74e90bb068e30fc3d4db037fd580f Reviewed-by: Yuhang Zhao <2546789017@qq.com> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Windows: bump NTDDI_VERSION to latest version and remove some duplicated codeYuhang Zhao2022-10-241-3/+1
| | | | | | | | | | | | | | | We have NTDDI_WIN10_NI (0x0A00000C) in the Win11 SDK (10.0.22621) so bump the value in Qt (currently 0x0A00000B) to it. And when searching for _WIN32_WINNT/WINVER/NTDDI_VERSION throughout the whole qtbase codebase, I found some duplicated code, mostly leftovers from the legacy time. Replace them with our own windows header can achieve the same effect: we have defined all the necessary macros to unblock the latest features. And place the header at the top most place to include the macros as early as possible. Change-Id: I37d9ac40ca9748208c7b2e89f374eda362dbefd6 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows: Align QWindowsWindow logging category name with other platformsTor Arne Vestbø2022-08-161-36/+36
| | | | | | | Other platforms name it singular 'qt.qpa.window'. Change-Id: I668ed67e1686605fe5f77313c7a01c31fd574c32 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* QtBase: Windows: Replace some deprecated API usagesYuhang Zhao2022-08-031-7/+7
| | | | | | | | | | | | Microsoft recommends to use CoInitializeEx() and SetWindowLongPtr()/GetWindowLongPtr() in new code. Use COINIT_DISABLE_OLE1DDE to avoid overhead of initializing and using obsolete technology. Pick-to: 6.4 Change-Id: I9d16943e864d4487dd4f46fd9325579c298c52b9 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows: better handling of darkmode supportVolker Hilsheimer2022-07-191-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 43ef22045c6f4fbf76d5cfa4ca32160d919b9984 turned dark mode support on for both styling and window frames. However, the default palette and style support in Qt is too incomplete, resulting in unreadable UIs when using certain styles (e.g. fusion). Also the vista style is not supporting dark mode. If we don't turn on dark style support, then dark frame support doesn't look good either. However, many application developers have implement a dark theme themselves, and we should have a dark frame for those applications. So partially revert 43ef22045c6f4fbf76d5cfa4ca32160d919b9984 so that dark style support is disabled by default, and leave dark frame support on. However, only activate dark frames if the palette is dark, i.e. if the window background color in the default palette is darker than the text color (or if DarkModeStyle is explicitly turned on by running the application with -platform windows:darkmode=2). This way, dark-themed applications get a dark frame on dark Windows, and a light frame on light Windows; and light-themed applications (including default Qt applications) get a light frame all the time. Fixes: QTBUG-72028 Pick-to: 6.4 Change-Id: I61f1b1e43b2a4ba69848d5d8bec921c0790fe511 Reviewed-by: Marius Kittler <mariuskittler@gmx.de> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Revert "Windows QPA: Add MSWindowsNoRedirectionBitmap flag"Tor Arne Vestbø2022-07-141-4/+1
| | | | | | | | | | | | This reverts commit 417bb463526d3ec3d80d66b029c1064fde88391f. The API addition was premature, as it can potentially be handled by the platform plugin automatically, and if not, should possibly live in QSurfaceFormat instead. Change-Id: I5c7050ce9c50b6c6a93ddfa6d2e842db0b9eed0d Reviewed-by: Yuhang Zhao <2546789017@qq.com> Reviewed-by: André de la Rocha <andre.rocha@qt.io>
* Windows QPA: Add MSWindowsNoRedirectionBitmap flagYuhang Zhao2022-07-141-1/+4
| | | | | | | | | | | | This flag will be useful for windows that only use 3D graphics API to do the rendering, such as Qt Quick applications. As a drive-by, fix a typo in the above line. Pick-to: 6.4 Change-Id: Ic6edcb7610055693734a5d5aff5e906991d4b911 Reviewed-by: André de la Rocha <andre.rocha@qt.io>
* Windows: Fix OpenGL window's screenYuhang Zhao2022-07-061-4/+9
| | | | | | | | | | | | The "GpuDescription::detect().gpuSuitableScreen" is a device name like "\\.\DISPLAY1", not a user-friendly name. Amends commit qtbase/75f22702933bad4f0da2b63a94ea183021771e4c Pick-to: 6.4 Change-Id: I525ecd026f3ee3bc467834449ae023ebfa1138c1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Windows: Don't rely on top level QWindow to scale children on DPI changeTor Arne Vestbø2022-06-301-13/+9
| | | | | | | | | | | | | | | | | The native size of a QWindow on Windows is the logical size of the window times the window's device pixel ratio. We manage this relationship for top level windows via the WM_GETDPISCALEDSIZE message, and during WM_DPICHANGED we then applied the same scale to child windows. This is problematic in the case where a child window does not have a QWindow parent, so instead of scaling all children when the parent gets a WM_DPICHANGED message, we scale each individual child in the child's WM_DPICHANGED_AFTERPARENT message. Task-number: QTBUG-103383 Pick-to: 6.4 Change-Id: Ia0845aa19a3bb97b7bc9e7d9554ac02b95ca65a5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Windows: Avoid accidentally copying QWindowsScreenManagerTor Arne Vestbø2022-06-201-2/+2
| | | | | | Pick-to: 6.2 6.3 6.4 Change-Id: I60b219e9a3ea62a96c369ee910eacf06d61f4f71 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Windows QPA: Fix indentionYuhang Zhao2022-06-191-42/+42
| | | | | | | | | It seems this block of code was originally copied from elsewhere so the original indention is preserved. Pick-to: 6.4 Change-Id: I53ab8e58b4304dfc768bd6472255a6c2d0471d5e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Update window state in QWindowsWindow and QXcbWindow geometry settersAxel Spoerl2022-06-171-0/+4
| | | | | | | | | | | | | | | | | When QWidget::resize() is called on a maximized or minimized QWidget, the window state of the widget and the corresponding QWindow is not updated (i.e. remains maximized or minimized). This patch updates the window state to Qt:WindowNoState when setGeometry() is called in QWindowsWindow or QXcbWindow. A test is added in tst_QWidget. Fixes: QTBUG-104201 Pick-to: 6.4 Change-Id: I07491fb9293d13509573fc403750da0a50f6a785 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Windows QPA: Update screen on child window DPI changeMorten Sørvig2022-06-161-2/+12
| | | | | | | | | | | | | | | | | | | | | | Windows does not send WM_DPICHANGED to child windows, which means that the normal DPI change handling code does not run for QWindows which are embedded in a foreign, non-Qt, window. Add code which handles WM_DPICHANGED_AFTERPARENT. This event is sent to all child windows, but not the top-level window. Call checkForScreenChanged() here, similar to what the WM_DPICHANGED code does. This commit does not add code to resize the child window, since it is uncertain if this is the responsibility of the window which receives WM_DPICHANGED, or of each child window. Done-with: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Pick-to: 6.4 Task-number: QTBUG-103383 Change-Id: Icf85dd0afa806609dbbe0ffc36efbc5127962c39 Reviewed-by: <stefan.wastl@native-instruments.de> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Fix typos in docs and commentsKai Köhne2022-06-151-1/+1
| | | | | | | | | Found by codespell Pick-to: 6.4 Change-Id: Ie3e301a23830c773a2e9aff487c702a223d246eb Reviewed-by: Nicholas Bennett <nicholas.bennett@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-38/+2
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Windows QPA: Send screen change before geometry changeMorten Sørvig2022-05-101-3/+3
| | | | | | | | | | | | | | | | | | Fix bug where the device independent QWindow size was set incorrectly, due to usage of incorrect screen and scale factor. This could happen when a window's screen was set to QGuiApplication::primaryScreen() as a fallback, before QWindowsWindow::initialize() would determine the correct screen. By sending the screen change first we make sure that that QWindowSystemInterface::handleGeeometryChange() uses the correct screen for the window. Change-Id: I5520ae67a4db60903d38db856fc314c75a3c0219 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Piotr Srebrny <piotr.srebrny@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows: Fix pop-up windows being incorrectly moved to primary displayAndré de la Rocha2022-05-051-1/+1
| | | | | | | | | | | | Amends a previous workaround used with AMD graphic adapters, which under some circumstances could incorrectly move pop-up windows and cause issues with menus. Fixes: QTBUG-97533 Pick-to: 6.2 6.3 Change-Id: Icc83198913b0e78ae3d7c0679e46f8b46b7015bf Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Windows QPA: Add convenient overload to query window frameYuhang Zhao2022-03-011-0/+10
| | | | | | | | | | | | To be used in a later commit. As a drive-by, return early in the frameOnPrimaryScreen overload to avoid calling GetWindowLong in cases we don't need them. Pick-to: 6.3 6.2 Change-Id: Ia69f4acbbf3e044073f818f357e614d4c6680d21 Reviewed-by: André de la Rocha <andre.rocha@qt.io>