# class KWindowSystem

###

Module | kdeui
Namespace |
Class | KWindowSystem
Inherits | QObject,NET

Convenience access to certain properties and features of the window manager.

The class KWindowSystem provides information about the state of the window manager and allows asking the window manager to change them using a more high-level interface than the NETWinInfo/NETRootInfo lowlevel classes.

Because of limitiations of the way Qt is implemented on Mac OSX, the WId's returned by methods in this class are not compatible with those expected by other Qt methods. So while it should be fine to pass WId's retrieved by for example calling the winId method on a QWidget to methods in this class the reverse is not true. You should never pass a WId obtained from this class to a Qt method accepting a WId parameter.

Class for interaction with the window manager. Author Matthias Ettrich (ettrich@kde.org)

### enums

- IconSource { NETWM, WMHints, ClassHint, XApp }

enum details

### methods

- KWindowSystem ( )

  returns ctor
  Not implemented

- activateWindow (win, time)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  time | long | 0

  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@kde.org mailing list.

  win - the id of the window to make active

  time - X server timestamp of the user activity that caused this request

- activeWindow ( )

  returns WId
  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

- activeWindowChanged (id)

  returns Nothing
  SIGNAL ("activeWindowChanged (WId)")

  Argument | Type | Default
  --- | --- | ---
  id | WId |

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

  id - the id of the window that is active

- allowedActionsSupported ( )

  returns bool
  static

  Returns true if the WM announces which actions it allows for windows.

- clearState (win, state)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  state | unsigned long |

  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.StaysOnTop

  win - the id of the window

  state - the flags that will be cleared

- compositingActive ( )

  returns bool
  static

  Returns true if a compositing manager is running (i.e. ARGB windows are supported, effects will be provided, etc.).

- connectNotify (signal)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  signal | char |

- constrainViewportRelativePosition (pos)

  returns QPoint
  static

  Argument | Type | Default
  --- | --- | ---
  pos | QPoint |

  Internal @since 4.0.1 Checks the relative difference used to move a window will still be inside valid desktop area.

- currentDesktop ( )

  returns int
  static

  Returns the current virtual desktop. Returns the current virtual desktop

- currentDesktopChanged (desktop)

  returns Nothing
  SIGNAL ("currentDesktopChanged (int)")

  Argument | Type | Default
  --- | --- | ---
  desktop | int |

  Switched to another virtual desktop.

  desktop - the number of the new desktop

- demandAttention (win, set)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  set | bool | 1

  When application finishes some operation and wants to notify the user about it, it can call demandAttention(). Instead of activating the window, which could be obtrusive, the window will be marked specially as demanding user's attention. See also explanation in description of activateWindow().

  Note that it's usually better to use KNotifyClient.

- desktopName (desktop)

  returns QString
  static

  Argument | Type | Default
  --- | --- | ---
  desktop | int |

  Returns the name of the specified desktop.

  desktop - the number of the desktop Returns the name of the desktop

- desktopNamesChanged ( )

  returns Nothing
  SIGNAL ("desktopNamesChanged ()")

  Desktops have been renamed.

- desktopToViewport (desktop, absolute)

  returns QPoint
  static

  Argument | Type | Default
  --- | --- | ---
  desktop | int |
  absolute | bool |

  Internal Returns topleft corner of the viewport area for the given mapped virtual desktop.

- doNotManage (title)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  title | QString |

  Informs kwin via dbus to not manage a window with the specified title.

  Useful for swallowing legacy applications, for example java applets.

  title - the title of the window

- forceActiveWindow (win, time)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  time | long | 0

  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().

  win - the id of the window to make active

  time - X server timestamp of the user activity that caused this request

- groupLeader (window)

  returns WId
  static

  Argument | Type | Default
  --- | --- | ---
  window | WId |

  Returns the leader window for the group the given window is in, if any.

  window - the id of the window

- hasWId (id)

  returns bool
  static

  Argument | Type | Default
  --- | --- | ---
  id | WId |

  Test to see if id still managed at present.

  id - the window id to test Returns true if the window id is still managed

- icccmCompliantMappingState ( )

  returns bool
  static

  Internal Returns true if the WM uses IconicState also for windows on inactive virtual desktops.

- icon (win, width, height, scale)

  returns QPixmap
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  width | int | -1
  height | int | -1
  scale | bool | 0

  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.

  win - the id of the window

  width - the desired width, or -1

  height - the desired height, or -1

  scale - if true the icon will be scaled to the desired size. Otherwise the icon will not be modified. Returns the icon of the window

- icon (win, width, height, scale, flags)

  returns QPixmap
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  width | int |
  height | int |
  scale | bool |
  flags | int |

  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.

  win - the id of the window

  width - the desired width, or -1

  height - the desired height, or -1

  scale - if true the icon will be scaled to the desired size. Otherwise the icon will not be modified.

  flags - OR-ed flags from the IconSource enum

- lowerWindow (win)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |

  Lowers the given window. This call is only for pagers and similar tools that represent direct user actions. Applications should not use it, they should keep using QWidget.lower() or XLowerWindow() if necessary.

- mapViewport ( )

  returns bool
  static

  Internal Returns true if viewports are mapped to virtual desktops.

- minimizeWindow (win, animation)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  animation | bool | 1

  Iconifies a window. Compatible to XIconifyWindow but has an additional parameter animation.

  win - the id of the window

  animation - true to show an animation

  See also deIconifyWindow()

- numberOfDesktops ( )

  returns int
  static

  Returns the number of virtual desktops. Returns the number of virtual desktops

- numberOfDesktopsChanged (num)

  returns Nothing
  SIGNAL ("numberOfDesktopsChanged (int)")

  Argument | Type | Default
  --- | --- | ---
  num | int |

  The number of desktops changed.

  num - the new number of desktops

- raiseWindow (win)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |

  Raises the given window. This call is only for pagers and similar tools that represent direct user actions. Applications should not use it, they should keep using QWidget.raise() or XRaiseWindow() if necessary.

- readNameProperty (window, atom)

  returns QString
  static

  Argument | Type | Default
  --- | --- | ---
  window | WId |
  atom | unsigned long |

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

- self ( )

  returns KWindowSystem
  static

  Access to the singleton instance. Useful mainly for connecting to signals.

- setCurrentDesktop (desktop)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  desktop | int |

  Convenience function to set the current desktop to desktop. See NETRootInfo.

  desktop - the number of the new desktop

- setDesktopName (desktop, name)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  desktop | int |
  name | QString |

  Sets the name of the specified desktop.

  desktop - the number of the desktop

  name - the new name for the desktop

- setExtendedStrut (win, left_width, left_start, left_end, right_width, right_start, right_end, top_width, top_start, top_end, bottom_width, bottom_start, bottom_end)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  left_width | int |
  left_start | int |
  left_end | int |
  right_width | int |
  right_start | int |
  right_end | int |
  top_width | int |
  top_start | int |
  top_end | int |
  bottom_width | int |
  bottom_start | int |
  bottom_end | int |

  Sets the strut of window win to 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 ).

  win - the id of the window

  left_width - width of the strut at the left edge

  left_start - starting y coordinate of the strut at the left edge

  left_end - ending y coordinate of the strut at the left edge

  right_width - width of the strut at the right edge

  right_start - starting y coordinate of the strut at the right edge

  right_end - ending y coordinate of the strut at the right edge

  top_width - width of the strut at the top edge

  top_start - starting x coordinate of the strut at the top edge

  top_end - ending x coordinate of the strut at the top edge

  bottom_width - width of the strut at the bottom edge

  bottom_start - starting x coordinate of the strut at the bottom edge

  bottom_end - ending x coordinate of the strut at the bottom edge

- setIcons (win, icon, miniIcon)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  icon | QPixmap |
  miniIcon | QPixmap |

  Sets an icon and a miniIcon on window win

  win - the id of the window

  icon - the new icon

  miniIcon - the new mini icon

- setMainWindow (subwindow, mainwindow)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  subwindow | QWidget |
  mainwindow | WId |

  Sets the parent window of subwindow to be mainwindow. This overrides the parent set the usual way as the QWidget 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 QWidget parent.

  This function should be used before a dialog is shown for a window that belongs to another application.

- setOnAllDesktops (win, b)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  b | bool |

  Sets window win to be present on all virtual desktops if @p is true. Otherwise the window lives only on one single desktop.

  win - the id of the window

  b - true to show the window on all desktops, false otherwise

- setOnDesktop (win, desktop)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  desktop | int |

  Moves window win to desktop desktop.

  win - the id of the window

  desktop - the number of the new desktop

- setState (win, state)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  state | unsigned long |

  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.StaysOnTop

  win - the id of the window

  state - the new flags that will be set

- setStrut (win, left, right, top, bottom)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  left | int |
  right | int |
  top | int |
  bottom | int |

  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.

  win - the id of the window

  left - the left strut

  right - the right strut

  top - the top strut

  bottom - the bottom strut

- setType (win, windowType)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  windowType | NET.WindowType |

  Sets the type of window win to windowType.

  win - the id of the window

  windowType - the type of the window (see NET.WindowType)

- setUserTime (win, time)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  time | long |

  Sets user timestamp time on window win. The timestamp is expressed as XServer time. If a window is shown with user timestamp older than the time of the last user action, it won't be activated after being shown. The most common case is the special value 0 which means not to activate the window after being shown.

- showingDesktop ( )

  returns bool
  static

  Returns the state of showing the desktop.

- showingDesktopChanged (showing)

  returns Nothing
  SIGNAL ("showingDesktopChanged (bool)")

  Argument | Type | Default
  --- | --- | ---
  showing | bool |

  The state of showing the desktop has changed.

- stackingOrder ( )

  returns QList<WId>
  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

- stackingOrderChanged ( )

  returns Nothing
  SIGNAL ("stackingOrderChanged ()")

  Emitted when the stacking order of the window changed. The new order can be obtained with stackingOrder().

- strutChanged ( )

  returns Nothing
  SIGNAL ("strutChanged ()")

  Something changed with the struts, may or may not have changed the work area. Usually just using the workAreaChanged() signal is sufficient.

- transientFor (window)

  returns WId
  static

  Argument | Type | Default
  --- | --- | ---
  window | WId |

  Returns the WM_TRANSIENT_FOR property for the given window, i.e. the mainwindow for this window.

  window - the id of the window

- unminimizeWindow (win, animation)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  animation | bool | 1

  DeIconifies a window. Compatible to XMapWindow but has an additional parameter animation.

  win - the id of the window

  animation - true to show an animation

  See also iconifyWindow()

- viewportToDesktop (pos)

  returns int
  static

  Argument | Type | Default
  --- | --- | ---
  pos | QPoint |

  Internal Returns mapped virtual desktop for the given position in the viewport.

- viewportWindowToDesktop (r)

  returns int
  static

  Argument | Type | Default
  --- | --- | ---
  r | QRect |

  Internal Returns mapped virtual desktop for the given window geometry.

- windowAdded (id)

  returns Nothing
  SIGNAL ("windowAdded (WId)")

  Argument | Type | Default
  --- | --- | ---
  id | WId |

  A window has been added.

  id - the id of the the window

- windowChanged (id)

  returns Nothing, unsigned long (properties)
  Not implemented SIGNAL ("windowChanged (WId, const unsigned long*)")

  Argument | Type | Default
  --- | --- | ---
  id | WId |

  The window changed.

  The properties parameter contains the NET properties that were modified (see netwm_def.h). First element are NET.Property values, second element are NET.Property2 values (i.e. the format is the same like for the NETWinInfo class constructor).

  id - the id of the window

  properties - the properties that were modified

- windowChanged (id, properties)

  returns Nothing
  SIGNAL ("windowChanged (WId, unsigned int)")

  Argument | Type | Default
  --- | --- | ---
  id | WId |
  properties | unsigned int |

  Deprecated The window changed.

  The unsigned int parameter contains the NET properties that were modified (see netwm_def.h).

  id - the id of the window

  properties - the properties that were modified

- windowChanged (id)

  returns Nothing
  SIGNAL ("windowChanged (WId)")

  Argument | Type | Default
  --- | --- | ---
  id | WId |

  The window changed somehow.

  id - the id of the window

- windowInfo (win, properties, properties2)

  returns KWindowInfo
  static

  Argument | Type | Default
  --- | --- | ---
  win | WId |
  properties | unsigned long |
  properties2 | unsigned long | 0

  Returns information about window win. It is recommended to check whether the returned info is valid by calling the valid() method.

  win - the id of the window

  properties - all properties that should be retrieved (see NET.Property enum for details). Unlisted properties cause related information to be invalid in the returned data, but make this function faster when not all data is needed.

  properties2 - additional properties (see NET.Property2 enum) Returns the window information

- windowRemoved (id)

  returns Nothing
  SIGNAL ("windowRemoved (WId)")

  Argument | Type | Default
  --- | --- | ---
  id | WId |

  A window has been removed.

  id - the id of the window that has been removed

- windows ( )

  returns QList<WId>
  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>.ConstIterator it;
      for ( it = KWindowSystem.windows().begin();
      it != KWindowSystem.windows().end(); ++it ) {
      ... do something here, (*it) is the current WId.
      }

  Returns the list of all toplevel windows

- workArea (desktop)

  returns QRect
  static

  Argument | Type | Default
  --- | --- | ---
  desktop | int | -1

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

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

- workArea (excludes, desktop)

  returns QRect
  static

  Argument | Type | Default
  --- | --- | ---
  excludes | QList<WId> |
  desktop | int | -1

  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.

  excludes - the list of clients whose struts will be excluded

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

- workAreaChanged ( )

  returns Nothing
  SIGNAL ("workAreaChanged ()")

  The workarea has changed.

### enums - detail

- IconSource { NETWM, WMHints, ClassHint, XApp }

  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)

| NETWM | - 1 | - |
| WMHints | - 2 | - |
| ClassHint | - 4 | - |
| XApp | - 8 | - |