KWindowInfo
#include <kwindowinfo.h>
Detailed Description
This class provides information about a given X11 window.
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 KX11Extras 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 xserver and avoid excess roundtrips.
KWindowInfo does nothing when running outside of X11.
Example usage of this class illustrated by monitoring a QWidget for change of the demands attention window state:
Definition at line 59 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 55 of file kwindowinfo.cpp.
◆ ~KWindowInfo()
KWindowInfo::~KWindowInfo | ( | ) |
Definition at line 126 of file kwindowinfo.cpp.
◆ KWindowInfo() [2/2]
KWindowInfo::KWindowInfo | ( | const KWindowInfo & | other | ) |
Copy constructor.
Definition at line 121 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.
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 530 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 417 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 578 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 567 of file kwindowinfo.cpp.
◆ clientMachine()
QByteArray KWindowInfo::clientMachine | ( | ) | const |
Returns the WM_CLIENT_MACHINE property for the window.
Requires NET::WM2ClientMachine passed as properties2 parameter to the constructor.
Definition at line 508 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 400 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 545 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 219 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 442 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 431 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 464 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 556 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 175 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 342 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 193 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 359 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 365 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 208 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 300 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 382 of file kwindowinfo.cpp.
◆ operator=()
KWindowInfo & KWindowInfo::operator= | ( | const KWindowInfo & | other | ) |
Assignment operator.
Definition at line 130 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 589 of file kwindowinfo.cpp.
◆ state()
NET::States 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 164 of file kwindowinfo.cpp.
◆ transientFor()
WId KWindowInfo::transientFor | ( | ) | const |
Returns the window identifier of the main window this window belongs to.
This is the value of the WM_TRANSIENT_FOR X11 property.
Requires NET::WM2TransientFor passed as properties2 parameter to the constructor.
Definition at line 453 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.
- 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 138 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 311 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 331 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 278 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 289 of file kwindowinfo.cpp.
◆ win()
WId KWindowInfo::win | ( | ) | const |
Returns the window identifier.
Definition at line 153 of file kwindowinfo.cpp.
◆ windowClassClass()
QByteArray KWindowInfo::windowClassClass | ( | ) | const |
Returns the class component of the WM_CLASS X11 property for the window.
Requires NET::WM2WindowClass passed as properties2 parameter to the constructor.
Definition at line 475 of file kwindowinfo.cpp.
◆ windowClassName()
QByteArray KWindowInfo::windowClassName | ( | ) | const |
Returns the name component of the WM_CLASS X11 property for the window.
Requires NET::WM2WindowClass passed as properties2 parameter to the constructor.
Definition at line 486 of file kwindowinfo.cpp.
◆ windowRole()
QByteArray KWindowInfo::windowRole | ( | ) | const |
Returns the WM_WINDOW_ROLE X11 property for the window.
Requires NET::WM2WindowRole passed as properties2 parameter to the constructor.
Definition at line 497 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 256 of file kwindowinfo.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:06:21 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.