summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/windows/qwindowssystemtrayicon.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Unify behavior of QSystemTrayIcon::geometry for hidden icons on WindowsOliver Wolff2024-04-101-0/+26
| | | | | | | | | | | | | | | | | | | | | When a system tray icon on Windows wasn't visible (hidden behind the ^ icon in the task bar) our previous implementation gave different results on Windows 10 and Windows 11. On Windows 10 the geometry returned the geometry of the ^ icon itself while we returned a geometry outside of the screen geometry on Windows 11 (that was what the Windows API gave us). We work around this problem by using version specific hacks to be able to check for the visibility of the system tray icon itself. If the icon is hidden we just return QRect(). [ChangeLog][Windows] The geometry of a hidden QSystemTrayIcon was unified over different Windows versions. It will always return QRect() now. Change-Id: Iee7dea184936a13a9221df9c421400ba304a4c38 Reviewed-by: Miguel Costa <miguel.costa@qt.io>
* Windows: clean up System Tray Icon message iconVolker Hilsheimer2024-02-281-1/+9
| | | | | | | | | | | | | | The handle is not owned by the Shell, we have to clear it up ourselves. The documentation is not clear about how long the handle needs to be kept alive, so store the icon when we create it as a member of the private, and clean it up when it need to be recreated, or when the QSystemTrayIcon instance gets destroyed. Fixes: QTBUG-96348 Fixes: QTBUG-62945 Pick-to: 6.7 6.6 6.5 6.2 5.15 Change-Id: I6f93f29a415cde2cfe4e1b296295783c15b4da4b Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* QWindowsSystemTrayIcon: use high-dpi icons for notificationsChristian Ehrlicher2024-01-091-14/+3
| | | | | | | | | | | Do not downscale the icon used for QSystemTrayIcon even though the msdn documentation states that SM_CXICON/SM_CYICON should be used as the size to avoid blurry icons in the notification. Pick-to: 6.7 6.6 Fixes: QTBUG-103825 Change-Id: I2d466e895254aa3c41682290cc7864632c57d5d7 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
* Fix setting SysTrayIcon visible after explicitly hiding itWladimir Leuschner2023-11-141-2/+0
| | | | | | | | | | | | After hiding the QSystemTrayIcon explicitly with .setVisible(false) resetting visibility with .setVisible(true) does not generate NIM_MODIFY message and thus preventing the tray icon from being visible again. Fixes: QTBUG-118133 Pick-to: 6.6 6.5 Change-Id: Ic2b1d0f293c92fec7ec697b2fe3d1da9fd0d0e44 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Timothée Keller <timothee.keller@qt.io>
* platform plugins: use string view types moreAnton Kudryavtsev2023-10-081-1/+3
| | | | | | | Change-Id: I793cfff1afca6b98a672615e33a19f8210e429dd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Windows: regenerate systray icon when screen resolution changesVolker Hilsheimer2022-12-081-1/+9
| | | | | | | | | | | | | | | | | | When the screen resolution or scale factor changes, then we have to recreate the system tray icon so that it doesn't get blurry. Such changes generate a WM_TASKBARCREATED message, which we already handle through a self-registered message ID to re-add the icon when the task bar/explorer crashed. So call updateIcon there to recreate the HICON before adding it again. For this to work, we have to actually store the QIcon in the already present (but so far unused) m_icon member, and reset that member before calling updateIcon, which would otherwise be a no-op. Fixes: QTBUG-108641 Pick-to: 6.4 6.2 Change-Id: If3dd042416b7f61bbb3b43f7d563e52b406136a2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Windows: bump NTDDI_VERSION to latest version and remove some duplicated codeYuhang Zhao2022-10-241-8/+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: Decouple screen change monitoring from top level QWindowsTor Arne Vestbø2022-06-181-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The WM_DISPLAYCHANGE message it sent when displays are added, removed, or update their properties such as the scale/DPI. We were processing this message as part of QWindowsContext::windowsProc(), which meant that we would only react to display changes if there was a QWindow on screen. Just creating a QGuiApplication was insufficient to pick up changes to screens after startup. In addition, despite being documented to post messages to child windows, WM_DISPLAYCHANGE only ends up in top level windows. Presumably it's the top level window's responsibility to post the message to child windows. As a result, if a QWindow was a native child window of a foreign window, such as in audio plugins being hosted in a DAW, we would again fail to pick up display changes. We solve both these cases by decoupling the WM_DISPLAYCHANGE handling from QWindowsContext::windowsProc(), by creating a dedicated window for listening to WM_DISPLAYCHANGE. This is similar to how we already handle tray icons, power notifications, clipboard, etc -- the only difference being that since purely HWND_MESSAGE windows do not receive WM_DISPLAYCHANGE it's an actual invisible WS_TILED window. This also lets us remove the workaround for QTBUG-79248, which was doing screen updates in response to WM_DPICHANGED when detecting that there were no QWindows. Task-number: QTBUG-103383 Task-number: QTBUG-79248 Fixes: QTBUG-102343 Pick-to: 6.4 Change-Id: I905d8253069ec339b193edf05c052d21361ca3e9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@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>
* Bump WINVER, _WIN32_WINNT and _WIN32_IE to _WIN32_WINNT_WIN10 (0x0A00)Yuhang Zhao2021-11-101-10/+4
| | | | | | | | | | | And bump NTDDI_VERSION to 0x0A00000B (NTDDI_WIN10_CO) at the same time, to unblock the developers from accessing the latest Windows APIs. Pick-to: 6.2 Change-Id: Ifbc28c8f8b073866871685c020301f5f20dc9591 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use QList instead of QVector in pluginsJarek Kobus2020-07-061-2/+2
| | | | | | Task-number: QTBUG-84469 Change-Id: Ic86f4a3000592a1c9ae62e4a83f4fe39832a6b24 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* qpa: Remove references to lighthouseTor Arne Vestbø2020-04-031-1/+0
| | | | | Change-Id: I37646113f626c878883cff49f4e186ec71bcfa15 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2020-02-291-1/+5
|\ | | | | | | Change-Id: I851c0328c3c38ea67b5ad115b205ac6a1262706e
| * Windows: Enable closing the system tray menu when clicking outside of itAndy Shaw2020-02-271-1/+5
| | | | | | | | | | | | | | | | | | | | In order for the system to close a menu when clicking outside of it or outside of the controlling window for the system tray then it needs to be at the foreground right before the menu is tracked. This makes it act like other system tray menus then. Change-Id: I663670c506cfd1e2ba59cd3e75b12e1f8ba17c33 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* | Windows QPA: Better disambiguate Window class namesFriedemann Kleint2020-01-251-1/+1
| | | | | | | | | | | | | | | | | | Use a standard prefix for Window class names containing version, build and namespace which should reduce conflicts. Task-number: QTBUG-81347 Change-Id: Ia7c20af71d364e362781f791a4e51b77d605c918 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* | Windows QPA: Use UTF-16 literals where possibleFriedemann Kleint2019-12-161-1/+1
|/ | | | | | | This should minimize diffs to Qt 6. Change-Id: Id74c0b4085085984bd51251765420718d16e9fc7 Reviewed-by: André de la Rocha <andre.rocha@qt.io>
* Windows QPA: Fix tray geometry not updatingFriedemann Kleint2019-12-051-0/+4
| | | | | | | | | | | | The application does not update its screens when there are no windows on which a WM_DPICHANGE could be received. Add a check for it to the tray window procedure and trigger an update from there if no top levels are present. Fixes: QTBUG-79248 Change-Id: I0b1c4db560662ecf2b473304942da373be6fdc73 Reviewed-by: André de la Rocha <andre.rocha@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* Quit application when QWindowsSystemTrayIcon receives WM_CLOSEJan Niklas Hasse2019-12-051-1/+5
| | | | | | | | | | | | When an application only has a trayicon and is killed by `taskkill /IM binary.exe` the trayicon's HWND will receive a WM_CLOSE message. If we don't handle this, the tray icon will close anyway, but the app still runs in the task manager. Fixes: QTBUG-43855 Change-Id: I5f82a068df9c40360bd565a2681e1b37ff114e44 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
* Windows QPA: Fix clang warnings about using typedefFriedemann Kleint2019-05-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Replace by using (except for function pointers). Change-Id: I0dfe03c22f9f87155003d13a6376381623df7217 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows/Direct2d QPA: Use nullptrFriedemann Kleint2019-01-281-2/+3
| | | | | Change-Id: I6ce01caa58de78e0eb61e243ee1e7b05cc1f5568 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows QPA: Move the code installing the filter for WM_TASKBARCREATEDFriedemann Kleint2019-01-241-6/+7
| | | | | | | | | | Previously, the code was in the constructor, where hwnd was 0 and ChangeWindowMessageFilterEx() failed. Move it into QWindowsSystemTrayIcon::ensureInstalled() after the creation of the message window. Change-Id: Iff4c6d6d6b11bdcace7514ad421c96c94e52bbba Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows QPA: Fix tray icon becoming visible before showFriedemann Kleint2019-01-241-1/+25
| | | | | | | | | Use the NIS_HIDDEN flag of the NOTIFYICONDATA structure to prevent it from becoming visible before show when calling NIM_ADD with the icon data. Fixes: QTBUG-73185 Change-Id: If5cc5a4930a889623a5cac84138185ad04765ece Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Windows QPA: Fix crash showing QSystemTrayIcon's context menu with ↵Friedemann Kleint2018-11-091-5/+13
| | | | | | | | | | | | PROCESS_DPI_UNAWARE The coordinates of the WM_CONTEXT message may be out of any screen in PROCESS_DPI_UNAWARE mode since hi-res coordinates are delivered in this case (Windows issue). Default to primary screen with check to prevent a crash. Fixes: QTBUG-67966 Change-Id: I1950360520e93cbf3509611b3057635769f6543a Reviewed-by: Andre de la Rocha <andre.rocha@qt.io>
* Merge remote-tracking branch 'origin/5.9' into 5.10Liang Qi2017-11-091-1/+1
| | | | | | | | | | | | Conflicts: src/gui/kernel/qwindow.cpp src/plugins/platforms/cocoa/qcocoawindow.mm src/plugins/platforms/windows/qwindowssystemtrayicon.cpp src/plugins/platforms/xcb/qxcbconnection_xi2.cpp tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp tests/auto/widgets/kernel/qaction/tst_qaction.cpp Change-Id: Ifa515dc0ece7eb1471b00c1214149629a7e6a233
* Native Windows file dialog: Observe Windows Explorer "Show hidden files" settingFriedemann Kleint2017-06-131-15/+2
| | | | | | | | | | Extract a helper function to read the setting and use that in file dialogs and tray icon. Task-number: QTBUG-60593 Change-Id: I03cf1e45611690a128bf2cc17eba5dff23b86969 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Windows QPA: Move system tray icon implementation into the pluginFriedemann Kleint2017-04-271-0/+456
The system tray icon implementation relied on QMenu. After the introduction of QPlatformSystemTrayIcon::contextMenuRequested(), the code can be moved into the plugin, making use of native menus when enabled or falling back to QMenu. This enables the SystemTrayIcon QML Type to work. [ChangeLog][QtGui][Windows] A native system tray icon is now available for SystemTrayIcon. Change-Id: I0fdbfb5cbb815c1ea6fb19305a9bceb9c5bcc034 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>