KWindowInfo
#include <kwindowinfo.h>
Detailed Description
This class provides information about a given window in the platform specific windowing system.
It provides the information for the current state when a KWindowInfo instance gets created. The instance does not get updated when the window changes. To get update about window changes connect to the windowChanged signal of KWindowSystem and create a new KWindowInfo instance to reflect the current state.
KWindowInfo does not encapsulate all information about the window. One needs to request which information is required by passing the appropriate NET::Property and NET::Property2 flags to the constructor. Please refer to the documentation of the methods to see which flags are required. This is done to limit the interaction with the underlying windowing system as fetching the information can cause several context switches and roundtrips to a server instance (e.g. when using the X11 platform).
Please note that KWindowInfo is an abstraction of the underlying windowing system inspired by the X11 platform. Thus not all concepts apply to all platforms and some methods might return a default value for some platforms.
Example usage of this class illustrated by monitoring a QWidget for change of the demands attention window state:
Definition at line 62 of file kwindowinfo.h.
Constructor & Destructor Documentation
◆ KWindowInfo() [1/2]
KWindowInfo::KWindowInfo | ( | WId | window, |
NET::Properties | properties, | ||
NET::Properties2 | properties2 = NET::Properties2() |
||
) |
Reads all the info about the given window.
Only the information requested through the properties
and properties2
parameters are fetched. Refer to the methods you are interested in to see which flags to pass.
- Parameters
-
window The platform specific window identifier properties Bitmask of NET::Property properties2 Bitmask of NET::Property2
Definition at line 257 of file kwindowinfo.cpp.
◆ KWindowInfo() [2/2]
KWindowInfo::KWindowInfo | ( | const KWindowInfo & | other | ) |
Copy constructor.
Definition at line 262 of file kwindowinfo.cpp.
Member Function Documentation
◆ actionSupported()
bool KWindowInfo::actionSupported | ( | NET::Action | action | ) | const |
Returns true if the given action is currently supported for the window.
On platform X11 the supported actions are set by the window manager and can differ depending on the window manager. Requires NET::WM2AllowedActions passed as properties2 parameter to the constructor.
Definition at line 423 of file kwindowinfo.cpp.
◆ activities()
QStringList KWindowInfo::activities | ( | ) | const |
Returns the list of activity UUIDs this window belongs to.
The Plasma workspace allows the user to separate her work into different activities, by assigning windows, documents etc. to the specific ones. An activity is an abstract concept whose meaning can differ from one user to another. Typical examples of activities are "developing a KDE project", "studying the 19th century art", "composing music", "lazing on a Sunday afternoon" etc.
If the list is empty, or contains a null UUID, the window is on all activities.
Requires NET::WM2Activities passed as properties parameter to the constructor.
- Note
- Activities are only supported on Plasma Workspace on X11
- Since
- 5.0
Definition at line 378 of file kwindowinfo.cpp.
◆ applicationMenuObjectPath()
QByteArray KWindowInfo::applicationMenuObjectPath | ( | ) | const |
Returns object path of a window's application menu if present.
Requires NET::WMPid passed as properties parameter to the constructor.
- Since
- 5.69
Definition at line 452 of file kwindowinfo.cpp.
◆ applicationMenuServiceName()
QByteArray KWindowInfo::applicationMenuServiceName | ( | ) | const |
Returns service name of a window's application menu if present.
Requires NET::WMPid passed as properties parameter to the constructor.
- Since
- 5.69
Definition at line 444 of file kwindowinfo.cpp.
◆ clientMachine()
QByteArray KWindowInfo::clientMachine | ( | ) | const |
Returns the client machine for the window.
On platform X11 this is the value of the WM_CLIENT_MACHINE property. Requires NET::WM2ClientMachine passed as properties2 parameter to the constructor.
Definition at line 418 of file kwindowinfo.cpp.
◆ desktop()
int KWindowInfo::desktop | ( | ) | const |
Returns the virtual desktop this window is on.
If the window is on all desktops NET::OnAllDesktops is returned. You should prefer using isOnDesktop(). Requires NET::WMDesktop passed as properties parameter to the constructor.
- See also
- isOnDesktop()
Definition at line 373 of file kwindowinfo.cpp.
◆ desktopFileName()
QByteArray KWindowInfo::desktopFileName | ( | ) | const |
Returns the desktop file name of the window's application if present.
This is either the base name without full path and without file extension of the desktop file for the window's application (e.g. "org.kde.foo").
If the application's desktop file name is not at a standard location it should be the full path to the desktop file name (e.g. "/opt/kde/share/org.kde.foo.desktop").
Requires NET::WM2DesktopFileName passed as properties2 parameter to the constructor.
- Since
- 5.29
Definition at line 428 of file kwindowinfo.cpp.
◆ extendedStrut()
NETExtendedStrut KWindowInfo::extendedStrut | ( | ) | const |
Returns the window extended (partial) strut.
Requires NET::WM2ExtendedStrut passed as properties2 parameter to the constructor.
Definition at line 314 of file kwindowinfo.cpp.
◆ frameGeometry()
QRect KWindowInfo::frameGeometry | ( | ) | const |
Returns the frame geometry of the window, i.e.
including the window decoration.
Requires NET::WMFrameExtents passed as properties parameter to the constructor.
Definition at line 388 of file kwindowinfo.cpp.
◆ geometry()
QRect KWindowInfo::geometry | ( | ) | const |
Returns the position and size of the window contents.
Requires NET::WMGeometry passed as properties parameter to the constructor.
Definition at line 383 of file kwindowinfo.cpp.
◆ groupLeader()
WId KWindowInfo::groupLeader | ( | ) | const |
Returns the leader window for the group the window is in, if any.
Requires NET::WM2GroupLeader passed as properties2 parameter to the constructor.
Definition at line 398 of file kwindowinfo.cpp.
◆ gtkApplicationId()
QByteArray KWindowInfo::gtkApplicationId | ( | ) | const |
Returns the GTK application id of the window if present.
This is comparable to desktopFileName.
Requires NET::WM2GTKApplicationId passed as properties2 parameter to the constructor.
- Since
- 5.91
Definition at line 436 of file kwindowinfo.cpp.
◆ hasState()
bool KWindowInfo::hasState | ( | NET::States | s | ) | const |
Returns true if the window has the given state flag set.
Requires NET::WMState passed as properties parameter to the constructor.
- See also
- NET::State
Definition at line 299 of file kwindowinfo.cpp.
◆ iconName()
QString KWindowInfo::iconName | ( | ) | const |
Returns the name of the window that should be shown in taskbar.
Note that this has nothing to do with normal icons but with an "iconic" representation of the window. Requires NET::WMIconName passed as properties parameter to the constructor.
Definition at line 349 of file kwindowinfo.cpp.
◆ isMinimized()
bool KWindowInfo::isMinimized | ( | ) | const |
Returns true if the window is minimized.
Note that it is true only if the window is truly minimized, not shaded or on another virtual desktops, which makes it different from mappingState() == NET::Iconic or QWidget::isMinimized(). Requires NET::WMState and NET::XAWMState passed as properties parameter to the constructor.
Definition at line 304 of file kwindowinfo.cpp.
◆ isOnCurrentDesktop()
bool KWindowInfo::isOnCurrentDesktop | ( | ) | const |
Returns true if the window is on the currently active virtual desktop.
Requires NET::WMDesktop passed as properties parameter to the constructor.
Definition at line 354 of file kwindowinfo.cpp.
◆ isOnDesktop()
bool KWindowInfo::isOnDesktop | ( | int | desktop | ) | const |
Returns true if the window is on the given virtual desktop.
Requires NET::WMDesktop passed as properties parameter to the constructor.
Definition at line 363 of file kwindowinfo.cpp.
◆ mappingState()
NET::MappingState KWindowInfo::mappingState | ( | ) | const |
Returns the mapping state of the window.
Note that it's very likely that you don't want to use this function, and use isOnDesktop(), isMinimized() etc. instead. Requires NET::XAWMState passed as properties parameter to the constructor.
- See also
- NET::MappingState
- isOnDesktop()
- isMinimzed()
Definition at line 309 of file kwindowinfo.cpp.
◆ name()
QString KWindowInfo::name | ( | ) | const |
Returns the name of the window, as specified by the application.
The difference to visibleName() is that this is the name provided by the application without any modifications by the window manager. You should often use visibleName() instead. Requires NET::WMName passed as properties parameter to the constructor.
- See also
- visibleName()
Definition at line 334 of file kwindowinfo.cpp.
◆ onAllDesktops()
bool KWindowInfo::onAllDesktops | ( | ) | const |
Returns true if the window is on all desktops.
A window is on all desktops if desktop() returns NET::OnAllDesktops. Requires NET::WMDesktop passed as properties parameter to the constructor.
- See also
- desktop()
Definition at line 368 of file kwindowinfo.cpp.
◆ operator=()
KWindowInfo & KWindowInfo::operator= | ( | const KWindowInfo & | other | ) |
Assignment operator.
Definition at line 271 of file kwindowinfo.cpp.
◆ pid()
int KWindowInfo::pid | ( | ) | const |
Returns the process ID of the window's application if present.
Requires NET::WMPid passed as properties parameter to the constructor.
- Since
- 5.29
Definition at line 460 of file kwindowinfo.cpp.
◆ state()
unsigned long KWindowInfo::state | ( | ) | const |
Returns the window's state flags.
Requires NET::WMState passed as properties parameter to the constructor.
- See also
- NET::State
Definition at line 294 of file kwindowinfo.cpp.
◆ transientFor()
WId KWindowInfo::transientFor | ( | ) | const |
Returns the window identifier of the main window this window belongs to.
On platform X11 this is the value of the WM_TRANSIENT_FOR property.
Requires NET::WM2TransientFor passed as properties2 parameter to the constructor.
Definition at line 393 of file kwindowinfo.cpp.
◆ valid()
bool KWindowInfo::valid | ( | bool | withdrawn_is_valid = false | ) | const |
Returns false if this window info is not valid.
In case the window does not exist false
is returned. Also if there is no appropriate implementation for KWindowInfo on the current windowing system platform this method returns false
. In that case all methods return a default value and thus it is recommended to check whether valid returns true
.
- Parameters
-
withdrawn_is_valid if true, windows in the withdrawn state (i.e. not managed) are also considered. This is usually not the case.
Definition at line 284 of file kwindowinfo.cpp.
◆ visibleIconName()
QString KWindowInfo::visibleIconName | ( | ) | const |
Returns the visible name of the window that should be shown in a taskbar.
Note that this has nothing to do with normal icons but with an "iconic" representation of the window. Requires NET::WMVisibleIconName passed as properties parameter to the constructor.
Definition at line 339 of file kwindowinfo.cpp.
◆ visibleIconNameWithState()
QString KWindowInfo::visibleIconNameWithState | ( | ) | const |
Returns a visible icon name with state.
This is a simple convenience function that returns the visible iconic name but with parentheses around minimized windows. Note that this has nothing to do with normal icons. Requires NET::WMVisibleIconName, NET::WMState and NET::XAWMState passed as properties parameter to the constructor.
- Returns
- the window iconic name with state
- See also
- visibleIconName()
Definition at line 344 of file kwindowinfo.cpp.
◆ visibleName()
QString KWindowInfo::visibleName | ( | ) | const |
Returns the visible name of the window.
The visible name differs from the name by including possible <2> appended when there are two or more windows with the same name. Requires NET::WMVisibleName passed as properties parameter to the constructor.
- See also
- name()
Definition at line 324 of file kwindowinfo.cpp.
◆ visibleNameWithState()
QString KWindowInfo::visibleNameWithState | ( | ) | const |
Returns a visible name with state.
This is a simple convenience function that returns the visible name but with parentheses around minimized windows. Requires NET::WMVisibleName, NET::WMState and NET::XAWMState passed as properties parameter to the constructor.
- Returns
- the window name with state
- See also
- visibleName()
Definition at line 329 of file kwindowinfo.cpp.
◆ win()
WId KWindowInfo::win | ( | ) | const |
Returns the window identifier.
Definition at line 289 of file kwindowinfo.cpp.
◆ windowClassClass()
QByteArray KWindowInfo::windowClassClass | ( | ) | const |
Returns the class component of the window class for the window.
On platform X11 this is part of the WM_CLASS property. Requires NET::WM2WindowClass passed as properties2 parameter to the constructor.
Definition at line 403 of file kwindowinfo.cpp.
◆ windowClassName()
QByteArray KWindowInfo::windowClassName | ( | ) | const |
Returns the name component of the window class for the window.
On platform X11 this is part of the WM_CLASS property. Requires NET::WM2WindowClass passed as properties2 parameter to the constructor.
Definition at line 408 of file kwindowinfo.cpp.
◆ windowRole()
QByteArray KWindowInfo::windowRole | ( | ) | const |
Returns the window role for the window.
On platform X11 this is the value of the WM_WINDOW_ROLE property. Requires NET::WM2WindowRole passed as properties2 parameter to the constructor.
Definition at line 413 of file kwindowinfo.cpp.
◆ windowType()
NET::WindowType KWindowInfo::windowType | ( | NET::WindowTypes | supported_types | ) | const |
Returns the window type of this window.
The argument should be all window types your application supports. Requires NET::WMWindowType passed as properties parameter to the constructor.
- See also
- NET::WindowType
- NET::WindowTypeMask
Definition at line 319 of file kwindowinfo.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Sep 21 2023 04:13:31 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.