KWindowSystem Class
Convenience access to certain properties and features of window systems. More...
Header: | #include <KWindowSystem> |
CMake: | find_package(KF6 REQUIRED COMPONENTS KWindowSystem) target_link_libraries(mytarget PRIVATE KF6::KWindowSystem) |
In QML: | KWindowSystem |
Inherits: | QObject |
Public Types
(since 5.25) enum class | Platform { Unknown, X11, Wayland } |
Properties
- isPlatformX11 : const bool
- isPlatformWayland : const bool
- showingDesktop : bool
Signals
void | showingDesktopChanged(bool showing) |
Static Public Members
(since 5.89) void | activateWindow(QWindow *window, long time = 0) |
(since 5.25) bool | isPlatformX11() |
(since 5.25) bool | isPlatformWayland() |
(since 5.25) KWindowSystem::Platform | platform() |
(since 5.83) void | setCurrentXdgActivationToken(const QString &token) |
void | setMainWindow(QWindow *subwindow, WId mainwindow) |
(since 6.0) void | setMainWindow(QWindow *subwindow, const QString &mainwindow) |
(since 5.7.0) void | setShowingDesktop(bool showing) |
bool | showingDesktop() |
(since 5.91) void | updateStartupId(QWindow *window) |
Detailed Description
Member Type Documentation
[since 5.25]
enum class KWindowSystem::Platform
Enum describing the windowing system platform used by the QGuiApplication.
Constant | Value | Description |
---|---|---|
KWindowSystem::Platform::Unknown | 0 | A platform unknown to the application is used |
KWindowSystem::Platform::X11 | 1 | The X11 window system. |
KWindowSystem::Platform::Wayland | 2 | The Wayland window system. |
This enum was introduced in 5.25.
See also platform().
Property Documentation
[read-only]
isPlatformX11 : const bool
Access functions:
bool | isPlatformX11() |
[read-only]
isPlatformWayland : const bool
Access functions:
bool | isPlatformWayland() |
showingDesktop : bool
This property holds whether "show desktop" is currently active.
Access functions:
bool | showingDesktop() |
void | setShowingDesktop(bool showing) |
Notifier signal:
void | showingDesktopChanged(bool showing) |
Member Function Documentation
[static invokable, since 5.89]
void KWindowSystem::activateWindow(QWindow *window, long time = 0)
Requests that window window is activated.
Applications shouldn't make attempts to explicitly activate their windows, and instead let the user activate them. In the special cases where this may be needed, applications can use activateWindow(). The window manager may consider whether this request wouldn't result in focus stealing, which would be obtrusive, and may refuse the request.
In case of problems, consult KWin's README.md file, or ask on the kwin@kde.org mailing list.
window the window to make active time X server timestamp of the user activity that caused this request
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
This function was introduced in 5.89.
[static, since 5.25]
bool KWindowSystem::isPlatformX11()
Returns whether the Platform is X11.
Note: Getter function for property isPlatformX11.
This function was introduced in 5.25.
See also platform and isPlatformWayland.
[static, since 5.25]
bool KWindowSystem::isPlatformWayland()
Returns whether the Platform is Wayland.
Note: Getter function for property isPlatformWayland.
This function was introduced in 5.25.
See also platform and isPlatformX11.
[static, since 5.25]
KWindowSystem::Platform KWindowSystem::platform()
Returns the Platform used by the QGuiApplication. The Platform gets resolved the first time the method is invoked and cached for further usages. Returns The Platform used by the QGuiApplication.
This function was introduced in 5.25.
[static invokable, since 5.83]
void KWindowSystem::setCurrentXdgActivationToken(const QString &token)
Sets the token that will be used when activateWindow is called next
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
This function was introduced in 5.83.
[static]
void KWindowSystem::setMainWindow(QWindow *subwindow, WId mainwindow)
Sets the parent window of subwindow to be mainwindow. This overrides the parent set the usual way as the QWidget or QWindow parent, but only for the window manager - e.g. stacking order and window grouping will be affected, but features like automatic deletion of children when the parent is deleted are unaffected and normally use the QObject parent.
This function should be used before a dialog is shown for a window that belongs to another application.
On Wayland, use the QString overload to provide an XDG Foreign token.
[static, since 6.0]
void KWindowSystem::setMainWindow(QWindow *subwindow, const QString &mainwindow)
Sets the parent window of subwindow to be mainwindow.
This function should be used before a dialog is shown for a window that belongs to another application.
subwindow the sub window mainwindow The main window ID or XDG Foreign token
This function was introduced in 6.0.
[static, since 5.7.0]
void KWindowSystem::setShowingDesktop(bool showing)
Sets the state of the "showing desktop" mode of the window manager. If on, windows are hidden and desktop background is shown and focused.
showing if true, the window manager is put in "showing desktop" mode. If false, the window manager is put out of that mode.
Note: Setter function for property showingDesktop.
This function was introduced in 5.7.0.
See also showingDesktop().
[static]
bool KWindowSystem::showingDesktop()
Returns the state of showing the desktop.
Note: Getter function for property showingDesktop.
See also setShowingDesktop().
[signal]
void KWindowSystem::showingDesktopChanged(bool showing)
The state of showing the desktop has changed.
Note: Notifier signal for property showingDesktop.
[static, since 5.91]
void KWindowSystem::updateStartupId(QWindow *window)
Updates the platform-specific startup id, if any.
This method is to be called when a running application instance is reused for handling the request to start this application. A typical use would be in the handler of the KDBusService activation signal.
For X11, this updates the id for the Startup Notification protocol, taking the id from QX11Info::nextStartupId(), if not empty. For Wayland, this updates the token for the XDG Activation protocol, taking the token from the "XDG_ACTIVATION_TOKEN" environment variable and then unsetting it, if not empty.
window the main window (needed by X11 platform)
This function was introduced in 5.91.