KX11Extras

Search for usage in LXR

#include <kx11extras.h>

Inheritance diagram for KX11Extras:

Public Types

enum  IconSource { NETWM = 1 , WMHints = 2 , ClassHint = 4 , XApp = 8 }
 
- Public Types inherited from QObject
typedef  QObjectList
 

Properties

bool compositingActive
 
- Properties inherited from QObject
 objectName
 

Signals

void activeWindowChanged (WId id)
 
void compositingChanged (bool enabled)
 
void currentDesktopChanged (int desktop)
 
void desktopNamesChanged ()
 
void numberOfDesktopsChanged (int num)
 
void stackingOrderChanged ()
 
void strutChanged ()
 
void windowAdded (WId id)
 
void windowChanged (WId id, NET::Properties properties, NET::Properties2 properties2)
 
void windowRemoved (WId id)
 
void workAreaChanged ()
 

Static Public Member Functions

static void activateWindow (WId win, long time=0)
 
static WId activeWindow ()
 
static void clearState (WId win, NET::States state)
 
static bool compositingActive ()
 
static int currentDesktop ()
 
static QString desktopName (int desktop)
 
static Q_INVOKABLE void forceActiveWindow (QWindow *window, long time=0)
 
static void forceActiveWindow (WId win, long time=0)
 
static bool hasWId (WId id)
 
static QPixmap icon (WId win, int width, int height, bool scale, int flags)
 
static QPixmap icon (WId win, int width, int height, bool scale, int flags, NETWinInfo *info)
 
static QPixmap icon (WId win, int width=-1, int height=-1, bool scale=false)
 
static bool mapViewport ()
 
static void minimizeWindow (WId win)
 
static int numberOfDesktops ()
 
static QString readNameProperty (WId window, unsigned long atom)
 
static KX11Extrasself ()
 
static void setCurrentDesktop (int desktop)
 
static void setDesktopName (int desktop, const QString &name)
 
static void setExtendedStrut (WId win, qreal left_width, qreal left_start, qreal left_end, qreal right_width, qreal right_start, qreal right_end, qreal top_width, qreal top_start, qreal top_end, qreal bottom_width, qreal bottom_start, qreal bottom_end)
 
static void setOnActivities (WId win, const QStringList &activities)
 
static void setOnAllDesktops (WId win, bool b)
 
static void setOnDesktop (WId win, int desktop)
 
static void setState (WId win, NET::States state)
 
static void setStrut (WId win, qreal left, qreal right, qreal top, qreal bottom)
 
static void setType (WId win, NET::WindowType windowType)
 
static QList< WId > stackingOrder ()
 
static void unminimizeWindow (WId win)
 
static QList< WId > windows ()
 
static QRect workArea (const QList< WId > &excludes, int desktop=-1)
 
static QRect workArea (int desktop=-1)
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Protected Member Functions

void connectNotify (const QMetaMethod &signal) override
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Detailed Description

A collection of functions to obtain information from and manipulate X11 windows.

These are generally not applicable to other window systems

Since
5.101

Definition at line 28 of file kx11extras.h.

Member Enumeration Documentation

◆ IconSource

Masks specifying from which sources to read an icon.

They are tried from the best until an icon is found.

  • NETWM from property from the window manager specification
  • WMHints from WMHints property
  • ClassHint load icon after getting name from the classhint
  • XApp load the standard X icon (last fallback)
Enumerator
NETWM 

read from property from the window manager specification

WMHints 

read from WMHints property

ClassHint 

load icon after getting name from the classhint

XApp 

load the standard X icon (last fallback)

Definition at line 217 of file kx11extras.h.

Property Documentation

◆ compositingActive

bool KX11Extras::compositingActive
read

Whether desktop compositing is active.

Definition at line 35 of file kx11extras.h.

Member Function Documentation

◆ activateWindow()

void KX11Extras::activateWindow ( WId win,
long time = 0 )
static

Requests that window win is activated.

There are two ways how to activate a window, by calling activateWindow() and forceActiveWindow(). Generally, applications shouldn't make attempts to explicitly activate their windows, and instead let the user to activate them. In the special cases where this may be needed, applications should use activateWindow(). Window manager may consider whether this request wouldn't result in focus stealing, which would be obtrusive, and may refuse the request.

The usage of forceActiveWindow() is meant only for pagers and similar tools, which represent direct user actions related to window manipulation. Except for rare cases, this request will be always honored, and normal applications are forbidden to use it.

In case of problems, consult the KWin README in the kdebase package (kdebase/kwin/README), or ask on the kwin@.nosp@m.kde..nosp@m.org mailing list.

Parameters
winthe id of the window to make active
timeX server timestamp of the user activity that caused this request

Definition at line 576 of file kx11extras.cpp.

◆ activeWindow()

WId KX11Extras::activeWindow ( )
static

Returns the currently active window, or 0 if no window is active.

Returns
the window id of the active window, or 0 if no window is active

Definition at line 565 of file kx11extras.cpp.

◆ activeWindowChanged

void KX11Extras::activeWindowChanged ( WId id)
signal

Hint that <Window> is active (= has focus) now.

Parameters
idthe id of the window that is active

◆ clearState()

void KX11Extras::clearState ( WId win,
NET::States state )
static

Clears the state of window win from state.

Possible values are or'ed combinations of NET::Modal, NET::Sticky, NET::MaxVert, NET::MaxHoriz, NET::Shaded, NET::SkipTaskbar, NET::SkipPager, NET::Hidden, NET::FullScreen, NET::KeepAbove, NET::KeepBelow, NET::SkipSwitcher

Parameters
winthe id of the window
statethe flags that will be cleared
Since
6.0

Definition at line 1181 of file kx11extras.cpp.

◆ compositingActive()

static bool KX11Extras::compositingActive ( )
static

Returns true if a compositing manager is running (i.e.

ARGB windows are supported, effects will be provided, etc.).

◆ compositingChanged

void KX11Extras::compositingChanged ( bool enabled)
signal

Compositing was enabled or disabled.

Note that this signal may be emitted before any compositing plugins have been initialized in the window manager.

If you need to check if a specific compositing plugin such as the blur effect is enabled, you should track that separately rather than test for it in a slot connected to this signal.

◆ connectNotify()

void KX11Extras::connectNotify ( const QMetaMethod & signal)
overrideprotectedvirtual

Reimplemented from QObject.

Definition at line 1147 of file kx11extras.cpp.

◆ currentDesktop()

int KX11Extras::currentDesktop ( )
static

Returns the current virtual desktop.

Returns
the current virtual desktop

Definition at line 614 of file kx11extras.cpp.

◆ currentDesktopChanged

void KX11Extras::currentDesktopChanged ( int desktop)
signal

Switched to another virtual desktop.

Parameters
desktopthe number of the new desktop

◆ desktopName()

QString KX11Extras::desktopName ( int desktop)
static

Returns the name of the specified desktop.

Parameters
desktopthe number of the desktop
Returns
the name of the desktop

Definition at line 981 of file kx11extras.cpp.

◆ desktopNamesChanged

void KX11Extras::desktopNamesChanged ( )
signal

Desktops have been renamed.

◆ forceActiveWindow() [1/2]

void KX11Extras::forceActiveWindow ( QWindow * window,
long time = 0 )
static

Sets window win to be the active window.

Note that this should be called only in special cases, applications shouldn't force themselves or other windows to be the active window. Generally, this call should used only by pagers and similar tools. See the explanation in the description of activateWindow().

Parameters
winthe window to make active
timeX server timestamp of the user activity that caused this request
Since
6.0

Definition at line 596 of file kx11extras.cpp.

◆ forceActiveWindow() [2/2]

void KX11Extras::forceActiveWindow ( WId win,
long time = 0 )
static

Sets window win to be the active window.

Note that this should be called only in special cases, applications shouldn't force themselves or other windows to be the active window. Generally, this call should used only by pagers and similar tools. See the explanation in description of activateWindow().

Parameters
winthe id of the window to make active
timeX server timestamp of the user activity that caused this request

Definition at line 586 of file kx11extras.cpp.

◆ hasWId()

bool KX11Extras::hasWId ( WId id)
static

Test to see if id still managed at present.

Parameters
idthe window id to test
Returns
true if the window id is still managed

Definition at line 552 of file kx11extras.cpp.

◆ icon() [1/3]

QPixmap KX11Extras::icon ( WId win,
int width,
int height,
bool scale,
int flags )
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Overloaded variant that allows specifying from which sources the icon should be read.

You should usually prefer the simpler variant which tries all possibilities to get an icon.

Parameters
winthe id of the window
widththe desired width, or -1
heightthe desired height, or -1
scaleif true the icon will be scaled to the desired size. Otherwise the icon will not be modified.
flagsOR-ed flags from the IconSource enum

Definition at line 838 of file kx11extras.cpp.

◆ icon() [2/3]

QPixmap KX11Extras::icon ( WId win,
int width,
int height,
bool scale,
int flags,
NETWinInfo * info )
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Overloaded variant that allows passing in the NETWinInfo to use for reading the information.

This variant is only useful on the X11 platform, other platforms do not use NETWinInfo and delegate to the variant without NETWinInfo. Though if compiled with X11 support the X11 variant is used on other platforms if info is not nullptr. This can be used by applications using e.g. platform wayland but also connecting to an XServer.

The NETWinInfo must be constructed with property NET::WMIcon in order to use the IconSource flag NETWM. NET::WM2IconPixmap for IconSource flag WMHints and NET::WM2WindowClass for IconSource flag ClassHint.

Parameters
winthe id of the window
widththe desired width, or -1
heightthe desired height, or -1
scaleif true the icon will be scaled to the desired size. Otherwise the icon will not be modified.
flagsOR-ed flags from the IconSource enum
intothe NETWinInfo to use for reading properties.

Definition at line 845 of file kx11extras.cpp.

◆ icon() [3/3]

QPixmap KX11Extras::icon ( WId win,
int width = -1,
int height = -1,
bool scale = false )
static

Returns an icon for window win.

If width and height are specified, the best icon for the requested size is returned.

If scale is true, the icon is smooth-scaled to have exactly the requested size.

Parameters
winthe id of the window
widththe desired width, or -1
heightthe desired height, or -1
scaleif true the icon will be scaled to the desired size. Otherwise the icon will not be modified.
Returns
the icon of the window

Definition at line 749 of file kx11extras.cpp.

◆ mapViewport()

bool KX11Extras::mapViewport ( )
static

Returns true if viewports are mapped to virtual desktops.

Definition at line 1040 of file kx11extras.cpp.

◆ minimizeWindow()

void KX11Extras::minimizeWindow ( WId win)
static

Minimizes the window with id win.

On X11 this follows the protocol described in ICCCM section 4.1.4.

Parameters
winThe window to minimize
See also
unminimizeWindow()

Definition at line 868 of file kx11extras.cpp.

◆ numberOfDesktops()

int KX11Extras::numberOfDesktops ( )
static

Returns the number of virtual desktops.

Returns
the number of virtual desktops

Definition at line 636 of file kx11extras.cpp.

◆ numberOfDesktopsChanged

void KX11Extras::numberOfDesktopsChanged ( int num)
signal

The number of desktops changed.

Parameters
numthe new number of desktops

◆ readNameProperty()

QString KX11Extras::readNameProperty ( WId window,
unsigned long atom )
static

Function that reads and returns the contents of the given text property (WM_NAME, WM_ICON_NAME,...).

Definition at line 1015 of file kx11extras.cpp.

◆ self()

KX11Extras * KX11Extras::self ( )
static

Definition at line 539 of file kx11extras.cpp.

◆ setCurrentDesktop()

void KX11Extras::setCurrentDesktop ( int desktop)
static

Convenience function to set the current desktop to desktop.

See NETRootInfo.

Parameters
desktopthe number of the new desktop

Definition at line 658 of file kx11extras.cpp.

◆ setDesktopName()

void KX11Extras::setDesktopName ( int desktop,
const QString & name )
static

Sets the name of the specified desktop.

Parameters
desktopthe number of the desktop
namethe new name for the desktop

Definition at line 997 of file kx11extras.cpp.

◆ setExtendedStrut()

void KX11Extras::setExtendedStrut ( WId win,
qreal left_width,
qreal left_start,
qreal left_end,
qreal right_width,
qreal right_start,
qreal right_end,
qreal top_width,
qreal top_start,
qreal top_end,
qreal bottom_width,
qreal bottom_start,
qreal bottom_end )
static

Sets the strut of window win to left_width ranging from left_start to left_end on the left edge, and simiarly for the other edges.

For not reserving a strut, pass 0 as the width. E.g. to reserve 10x10 square in the topleft corner, use e.g. setExtendedStrut( w, 10, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0 ).

Parameters
winthe id of the window
left_widthwidth of the strut at the left edge
left_startstarting y coordinate of the strut at the left edge
left_endending y coordinate of the strut at the left edge
right_widthwidth of the strut at the right edge
right_startstarting y coordinate of the strut at the right edge
right_endending y coordinate of the strut at the right edge
top_widthwidth of the strut at the top edge
top_startstarting x coordinate of the strut at the top edge
top_endending x coordinate of the strut at the top edge
bottom_widthwidth of the strut at the bottom edge
bottom_startstarting x coordinate of the strut at the bottom edge
bottom_endending x coordinate of the strut at the bottom edge

Definition at line 1084 of file kx11extras.cpp.

◆ setOnActivities()

void KX11Extras::setOnActivities ( WId win,
const QStringList & activities )
static

Moves window win to activities activities.

Parameters
winthe id of the window
activitiesthe list of activity UUIDs
See also
KWindowInfo::activities

Definition at line 742 of file kx11extras.cpp.

◆ setOnAllDesktops()

void KX11Extras::setOnAllDesktops ( WId win,
bool b )
static

Sets window win to be present on all virtual desktops if is true.

Otherwise the window lives only on one single desktop.

Parameters
winthe id of the window
btrue to show the window on all desktops, false otherwise

Definition at line 676 of file kx11extras.cpp.

◆ setOnDesktop()

void KX11Extras::setOnDesktop ( WId win,
int desktop )
static

Moves window win to desktop desktop.

Parameters
winthe id of the window
desktopthe number of the new desktop

Definition at line 696 of file kx11extras.cpp.

◆ setState()

void KX11Extras::setState ( WId win,
NET::States state )
static

Sets the state of window win to state.

Possible values are or'ed combinations of NET::Modal, NET::Sticky, NET::MaxVert, NET::MaxHoriz, NET::Shaded, NET::SkipTaskbar, NET::SkipPager, NET::Hidden, NET::FullScreen, NET::KeepAbove, NET::KeepBelow, NET::SkipSwitcher

Parameters
winthe id of the window
statethe new flags that will be set
Since
6.0

Definition at line 1174 of file kx11extras.cpp.

◆ setStrut()

void KX11Extras::setStrut ( WId win,
qreal left,
qreal right,
qreal top,
qreal bottom )
static

Convenience function for setExtendedStrut() that automatically makes struts as wide/high as the screen width/height.

Sets the strut of window win to left, right, top, bottom.

Parameters
winthe id of the window
leftthe left strut
rightthe right strut
topthe top strut
bottomthe bottom strut

Definition at line 1124 of file kx11extras.cpp.

◆ setType()

void KX11Extras::setType ( WId win,
NET::WindowType windowType )
static

Sets the type of window win to windowType.

Parameters
winthe id of the window
windowTypethe type of the window (see NET::WindowType)
Since
6.0

Definition at line 1167 of file kx11extras.cpp.

◆ stackingOrder()

QList< WId > KX11Extras::stackingOrder ( )
static

Returns the list of all toplevel windows currently managed by the window manager in the current stacking order (from lower to higher).

May be useful for pagers.

Returns
the list of all toplevel windows in stacking order

Definition at line 558 of file kx11extras.cpp.

◆ stackingOrderChanged

void KX11Extras::stackingOrderChanged ( )
signal

Emitted when the stacking order of the window changed.

The new order can be obtained with stackingOrder().

◆ strutChanged

void KX11Extras::strutChanged ( )
signal

Something changed with the struts, may or may not have changed the work area.

Usually just using the workAreaChanged() signal is sufficient.

◆ unminimizeWindow()

void KX11Extras::unminimizeWindow ( WId win)
static

Unminimizes the window with id win.

On X11 this follows the protocol described in ICCCM section 4.1.4.

Parameters
winThe window to unminimize
See also
minimizeWindow()

Definition at line 890 of file kx11extras.cpp.

◆ windowAdded

void KX11Extras::windowAdded ( WId id)
signal

A window has been added.

Parameters
idthe id of the window

◆ windowChanged

void KX11Extras::windowChanged ( WId id,
NET::Properties properties,
NET::Properties2 properties2 )
signal

The window changed.

Carries the NET::Properties and NET::Properties2 that were changed.

Parameters
idthe id of the window
propertiesthe properties that were modified
properties2the properties2 that were modified

◆ windowRemoved

void KX11Extras::windowRemoved ( WId id)
signal

A window has been removed.

Parameters
idthe id of the window that has been removed

◆ windows()

QList< WId > KX11Extras::windows ( )
static

Returns the list of all toplevel windows currently managed by the window manager in the order of creation.

Please do not rely on indexes of this list: Whenever you enter Qt's event loop in your application, it may happen that entries are removed or added. Your module should perhaps work on a copy of this list and verify a window with hasWId() before any operations.

Iteration over this list can be done easily with

QList<WId> windows = KWindowSystem::windows();
for (auto it = windows.cbegin(), end = windows.cend(); it != end; ++it) {
... do something here, (*it) is the current WId.
}
static QList< WId > windows()
Returns the list of all toplevel windows currently managed by the window manager in the order of crea...
const_iterator cbegin() const const
const_iterator cend() const const
Returns
the list of all toplevel windows

Definition at line 545 of file kx11extras.cpp.

◆ workArea() [1/2]

QRect KX11Extras::workArea ( const QList< WId > & excludes,
int desktop = -1 )
static

Returns the workarea for the specified desktop, or the current work area if no desktop has been specified.

Excludes struts of clients in the exclude List.

Parameters
excludesthe list of clients whose struts will be excluded
desktopthe number of the desktop to check, -1 for the current desktop
Returns
the size and position of the desktop

Definition at line 913 of file kx11extras.cpp.

◆ workArea() [2/2]

QRect KX11Extras::workArea ( int desktop = -1)
static

Returns the workarea for the specified desktop, or the current work area if no desktop has been specified.

Parameters
desktopthe number of the desktop to check, -1 for the current desktop
Returns
the size and position of the desktop

Definition at line 896 of file kx11extras.cpp.

◆ workAreaChanged

void KX11Extras::workAreaChanged ( )
signal

The workarea has changed.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:10:18 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.