KWindowSystem

netwm.h
1 /*
2  SPDX-FileCopyrightText: 2000 Troll Tech AS
3  SPDX-FileCopyrightText: 2003 Lubos Lunak <[email protected]>
4 
5  SPDX-License-Identifier: MIT
6 */
7 
8 #ifndef netwm_h
9 #define netwm_h
10 
11 #include <kwindowsystem_export.h>
12 #include <QSize>
13 #include <config-kwindowsystem.h>
14 #if KWINDOWSYSTEM_HAVE_X11
15 #include <xcb/xcb.h>
16 #include <vector>
17 
18 #include "netwm_def.h"
19 
20 #define KDE_ALL_ACTIVITIES_UUID "00000000-0000-0000-0000-000000000000"
21 
22 // forward declaration
23 struct NETRootInfoPrivate;
24 struct NETWinInfoPrivate;
25 template <class Z> class NETRArray;
26 
39 class KWINDOWSYSTEM_EXPORT NETRootInfo : public NET
40 {
41 public:
45  // update also NETRootInfoPrivate::properties[] size when extending this
46  enum { PROTOCOLS, WINDOW_TYPES, STATES, PROTOCOLS2, ACTIONS,
47  PROPERTIES_SIZE
48  };
49 
81  NETRootInfo(xcb_connection_t *connection, xcb_window_t supportWindow, const char *wmName,
82  NET::Properties properties, NET::WindowTypes windowTypes, NET::States states,
83  NET::Properties2 properties2, NET::Actions actions,
84  int screen = -1, bool doActivate = true);
85 
106  NETRootInfo(xcb_connection_t *connection, NET::Properties properties, NET::Properties2 properties2 = NET::Properties2(),
107  int screen = -1, bool doActivate = true);
108 
109 
115  NETRootInfo(const NETRootInfo &rootinfo);
116 
120  virtual ~NETRootInfo();
121 
127  xcb_connection_t *xcbConnection() const;
128 
134  xcb_window_t rootWindow() const;
135 
141  xcb_window_t supportWindow() const;
142 
148  const char *wmName() const;
149 
157  void setSupported(NET::Property property, bool on = true);
158 
163  void setSupported(NET::Property2 property, bool on = true);
164 
169  void setSupported(NET::WindowTypeMask property, bool on = true);
170 
175  void setSupported(NET::State property, bool on = true);
176 
181  void setSupported(NET::Action property, bool on = true);
182 
188  bool isSupported(NET::Property property) const;
192  bool isSupported(NET::Property2 property) const;
196  bool isSupported(NET::WindowTypeMask type) const;
200  bool isSupported(NET::State state) const;
201 
205  bool isSupported(NET::Action action) const;
206 
218  NET::Properties supportedProperties() const;
231  NET::Properties2 supportedProperties2() const;
244  NET::States supportedStates() const;
257  NET::WindowTypes supportedWindowTypes() const;
270  NET::Actions supportedActions() const;
271 
279  NET::Properties passedProperties() const;
288  NET::Properties2 passedProperties2() const;
297  NET::States passedStates() const;
306  NET::WindowTypes passedWindowTypes() const;
315  NET::Actions passedActions() const;
316 
324  const xcb_window_t *clientList() const;
325 
333  int clientListCount() const;
334 
343  const xcb_window_t *clientListStacking() const;
344 
352  int clientListStackingCount() const;
353 
363  NETSize desktopGeometry() const;
364 
376  NETPoint desktopViewport(int desktop) const;
377 
385  NETRect workArea(int desktop) const;
386 
394  const char *desktopName(int desktop) const;
395 
403  const xcb_window_t *virtualRoots() const;
404 
412  int virtualRootsCount() const;
413 
417  NET::Orientation desktopLayoutOrientation() const;
418 
423  QSize desktopLayoutColumnsRows() const;
424 
428  NET::DesktopLayoutCorner desktopLayoutCorner() const;
429 
441  int numberOfDesktops(bool ignore_viewport = false) const;
442 
454  int currentDesktop(bool ignore_viewport = false) const;
455 
461  xcb_window_t activeWindow() const;
462 
471  void activate();
472 
480  void setClientList(const xcb_window_t *windows, unsigned int count);
481 
490  void setClientListStacking(const xcb_window_t *windows, unsigned int count);
491 
502  void setCurrentDesktop(int desktop, bool ignore_viewport = false);
503 
513  void setDesktopGeometry(const NETSize &geometry);
514 
526  void setDesktopViewport(int desktop, const NETPoint &viewport);
527 
537  void setNumberOfDesktops(int numberOfDesktops);
538 
550  void setDesktopName(int desktop, const char *desktopName);
551 
562  void setActiveWindow(xcb_window_t window, NET::RequestSource src,
563  xcb_timestamp_t timestamp, xcb_window_t active_window);
564 
571  void setActiveWindow(xcb_window_t window);
572 
580  void setWorkArea(int desktop, const NETRect &workArea);
581 
589  void setVirtualRoots(const xcb_window_t *windows, unsigned int count);
590 
595  void setDesktopLayout(NET::Orientation orientation, int columns, int rows,
596  NET::DesktopLayoutCorner corner);
597 
601  void setShowingDesktop(bool showing);
605  bool showingDesktop() const;
606 
611  const NETRootInfo &operator=(const NETRootInfo &rootinfo);
612 
620  void closeWindowRequest(xcb_window_t window);
621 
637  void moveResizeRequest(xcb_window_t window, int x_root, int y_root,
638  Direction direction);
639 
653  void moveResizeWindowRequest(xcb_window_t window, int flags, int x, int y, int width, int height);
654 
658  void restackRequest(xcb_window_t window, RequestSource source, xcb_window_t above, int detail, xcb_timestamp_t timestamp);
659 
664  void sendPing(xcb_window_t window, xcb_timestamp_t timestamp);
665 
666 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
667 
682  KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use NETRootInfo::event(xcb_generic_event_t*, NET::Properties*, NET::Properties2*)")
683  void event(xcb_generic_event_t *event, unsigned long *properties, int properties_size);
684 #endif
685 
697  void event(xcb_generic_event_t *event, NET::Properties *properties, NET::Properties2 *properties2 = nullptr);
698 
710  NET::Properties event(xcb_generic_event_t *event);
711 
712 protected:
719  virtual void addClient(xcb_window_t window)
720  {
721  Q_UNUSED(window);
722  }
723 
730  virtual void removeClient(xcb_window_t window)
731  {
732  Q_UNUSED(window);
733  }
734 
742  virtual void changeNumberOfDesktops(int numberOfDesktops)
743  {
744  Q_UNUSED(numberOfDesktops);
745  }
746 
756  virtual void changeDesktopGeometry(int desktop, const NETSize &geom)
757  {
758  Q_UNUSED(desktop);
759  Q_UNUSED(geom);
760  }
761 
771  virtual void changeDesktopViewport(int desktop, const NETPoint &viewport)
772  {
773  Q_UNUSED(desktop);
774  Q_UNUSED(viewport);
775  }
776 
784  virtual void changeCurrentDesktop(int desktop)
785  {
786  Q_UNUSED(desktop);
787  }
788 
795  virtual void closeWindow(xcb_window_t window)
796  {
797  Q_UNUSED(window);
798  }
799 
813  virtual void moveResize(xcb_window_t window, int x_root, int y_root,
814  unsigned long direction)
815  {
816  Q_UNUSED(window);
817  Q_UNUSED(x_root);
818  Q_UNUSED(y_root);
819  Q_UNUSED(direction);
820  }
821 
828  virtual void gotPing(xcb_window_t window, xcb_timestamp_t timestamp)
829  {
830  Q_UNUSED(window);
831  Q_UNUSED(timestamp);
832  }
843  virtual void changeActiveWindow(xcb_window_t window, NET::RequestSource src,
844  xcb_timestamp_t timestamp, xcb_window_t active_window)
845  {
846  Q_UNUSED(window);
847  Q_UNUSED(src);
848  Q_UNUSED(timestamp);
849  Q_UNUSED(active_window);
850  }
851 
864  virtual void moveResizeWindow(xcb_window_t window, int flags, int x, int y, int width, int height)
865  {
866  Q_UNUSED(window);
867  Q_UNUSED(flags);
868  Q_UNUSED(x);
869  Q_UNUSED(y);
870  Q_UNUSED(width);
871  Q_UNUSED(height);
872  }
873 
885  virtual void restackWindow(xcb_window_t window, RequestSource source,
886  xcb_window_t above, int detail, xcb_timestamp_t timestamp)
887  {
888  Q_UNUSED(window);
889  Q_UNUSED(source);
890  Q_UNUSED(above);
891  Q_UNUSED(detail);
892  Q_UNUSED(timestamp);
893  }
894 
902  virtual void changeShowingDesktop(bool showing)
903  {
904  Q_UNUSED(showing);
905  }
906 
907 private:
908  void update(NET::Properties properties, NET::Properties2 properties2);
909  void setSupported();
910  void setDefaultProperties();
911  void updateSupportedProperties(xcb_atom_t atom);
912 
913 protected:
917  virtual void virtual_hook(int id, void *data);
918 private:
919  NETRootInfoPrivate *p; // krazy:exclude=dpointer (implicitly shared)
920 };
921 
935 class KWINDOWSYSTEM_EXPORT NETWinInfo : public NET
936 {
937 public:
941  // update also NETWinInfoPrivate::properties[] size when extending this
942  enum { PROTOCOLS, PROTOCOLS2,
943  PROPERTIES_SIZE
944  };
962  NETWinInfo(xcb_connection_t *connection, xcb_window_t window, xcb_window_t rootWindow,
963  NET::Properties properties, NET::Properties2 properties2,
964  Role role = Client);
965 
966 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
967 
972  KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use NETWinInfo(xcb_connection_t *, xcb_window_t, xcb_window_t, NET::Properties, NET::Properties2, Role")
973  NETWinInfo(xcb_connection_t *connection, xcb_window_t window,
974  xcb_window_t rootWindow, NET::Properties properties,
975  Role role = Client);
976 #endif
977 
983  NETWinInfo(const NETWinInfo &wininfo);
984 
988  virtual ~NETWinInfo();
989 
994  const NETWinInfo &operator=(const NETWinInfo &wintinfo);
995 
1001  xcb_connection_t *xcbConnection() const;
1002 
1010  bool hasNETSupport() const;
1011 
1016  NET::Properties passedProperties() const;
1022  NET::Properties2 passedProperties2() const;
1023 
1029  NETRect iconGeometry() const;
1030 
1037  NET::States state() const;
1038 
1043  NETExtendedStrut extendedStrut() const;
1044 
1045  // Still used internally, e.g. by KWindowSystem::strutChanged() logic
1052  NETStrut strut() const;
1053 
1067  WindowType windowType(WindowTypes supported_types) const;
1068 
1074  bool hasWindowType() const;
1075 
1081  const char *name() const;
1082 
1088  const char *visibleName() const;
1089 
1099  const char *iconName() const;
1100 
1110  const char *visibleIconName() const;
1111 
1125  int desktop(bool ignore_viewport = false) const;
1126 
1132  int pid() const;
1133 
1139  bool handledIcons() const;
1140 
1147  MappingState mappingState() const;
1148 
1158  void setIcon(NETIcon icon, bool replace = true);
1159 
1165  void setIconGeometry(NETRect geometry);
1166 
1172  void setExtendedStrut(const NETExtendedStrut &extended_strut);
1173 
1174  // Still used internally, e.g. by KWindowSystem::strutChanged() logic
1181  void setStrut(NETStrut strut);
1182 
1191  void setState(NET::States state, NET::States mask);
1192 
1199  void setWindowType(WindowType type);
1200 
1206  void setName(const char *name);
1207 
1214  void setVisibleName(const char *visibleName);
1215 
1221  void setIconName(const char *name);
1222 
1229  void setVisibleIconName(const char *name);
1230 
1243  void setDesktop(int desktop, bool ignore_viewport = false);
1244 
1250  void setPid(int pid);
1251 
1257  void setHandledIcons(bool handled);
1258 
1264  void setFrameExtents(NETStrut strut);
1265 
1271  NETStrut frameExtents() const;
1272 
1284  void setFrameOverlap(NETStrut strut);
1285 
1292  NETStrut frameOverlap() const;
1293 
1299  void setGtkFrameExtents(NETStrut strut);
1300 
1306  NETStrut gtkFrameExtents() const;
1307 
1319  NETIcon icon(int width = -1, int height = -1) const;
1320 
1326  const int *iconSizes() const;
1327 
1335  void setUserTime(xcb_timestamp_t time);
1336 
1340  xcb_timestamp_t userTime() const;
1341 
1345  void setStartupId(const char *startup_id);
1346 
1350  const char *startupId() const;
1351 
1355  void setOpacity(unsigned long opacity);
1356 
1360  unsigned long opacity() const;
1361 
1365  void setAllowedActions(NET::Actions actions);
1366 
1370  NET::Actions allowedActions() const;
1371 
1376  xcb_window_t transientFor() const;
1377 
1381  xcb_window_t groupLeader() const;
1382 
1389  bool urgency() const;
1390 
1399  bool input() const;
1400 
1410  MappingState initialMappingState() const;
1411 
1426  xcb_pixmap_t icccmIconPixmap() const;
1427 
1437  xcb_pixmap_t icccmIconPixmapMask() const;
1438 
1443  const char *windowClassClass() const;
1444 
1449  const char *windowClassName() const;
1450 
1454  const char *windowRole() const;
1455 
1459  const char *clientMachine() const;
1460 
1466  const char *activities() const;
1467 
1472  void setActivities(const char *activities);
1473 
1478  void setBlockingCompositing(bool active);
1479 
1484  bool isBlockingCompositing() const;
1485 
1494  void kdeGeometry(NETRect &frame, NETRect &window);
1495 
1512  void setFullscreenMonitors(NETFullscreenMonitors topology);
1513 
1519  NETFullscreenMonitors fullscreenMonitors() const;
1520 
1521 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
1522 
1536  KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use NETWinInfo::event(xcb_generic_event_t*, NET::Properties*, NET::Properties2*)")
1537  void event(xcb_generic_event_t *event, unsigned long *properties, int properties_size);
1538 #endif
1539 
1553  void event(xcb_generic_event_t *event, NET::Properties *properties, NET::Properties2 *properties2 = nullptr);
1554 
1566  NET::Properties event(xcb_generic_event_t *event);
1567 
1572  NET::Protocols protocols() const;
1573 
1579  bool supportsProtocol(NET::Protocol protocol) const;
1580 
1585  std::vector<NETRect> opaqueRegion() const;
1586 
1600  void setDesktopFileName(const char *name);
1601 
1607  const char *desktopFileName() const;
1608 
1613  void setAppMenuServiceName(const char *name);
1614 
1619  void setAppMenuObjectPath(const char *path);
1620 
1625  const char *appMenuServiceName() const;
1626 
1631  const char *appMenuObjectPath() const;
1632 
1639  static const int OnAllDesktops;
1640 
1641 protected:
1649  virtual void changeDesktop(int desktop)
1650  {
1651  Q_UNUSED(desktop);
1652  }
1653 
1663  virtual void changeState(NET::States state, NET::States mask)
1664  {
1665  Q_UNUSED(state);
1666  Q_UNUSED(mask);
1667  }
1668 
1678  {
1679  Q_UNUSED(topology);
1680  }
1681 
1682 private:
1683  void update(NET::Properties dirtyProperties, NET::Properties2 dirtyProperties2 = NET::Properties2());
1684  void updateWMState();
1685  void setIconInternal(NETRArray<NETIcon> &icons, int &icon_count, xcb_atom_t property, NETIcon icon, bool replace);
1686  NETIcon iconInternal(NETRArray<NETIcon> &icons, int icon_count, int width, int height) const;
1687 
1688 protected:
1692  virtual void virtual_hook(int id, void *data);
1693 private:
1694  NETWinInfoPrivate *p; // krazy:exclude=dpointer (implicitly shared)
1695 };
1696 
1697 //#define KWIN_FOCUS
1698 
1699 #endif
1700 #endif // netwm_h
Simple icon class for NET classes.
Definition: netwm_def.h:102
Protocol
Protocols supported by the client.
Definition: netwm_def.h:805
virtual void changeFullscreenMonitors(NETFullscreenMonitors topology)
A Window Manager should subclass NETWinInfo2 and reimplement this function when it wants to know when...
Definition: netwm.h:1677
Property2
Supported properties.
Definition: netwm_def.h:716
Simple multiple monitor topology class for NET classes.
Definition: netwm_def.h:212
State
Window state.
Definition: netwm_def.h:427
Partial strut class for NET classes.
Definition: netwm_def.h:132
virtual void moveResize(xcb_window_t window, int x_root, int y_root, unsigned long direction)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:813
Common API for root window properties/protocols.
Definition: netwm.h:39
Orientation
Orientation.
Definition: netwm_def.h:783
Direction
Direction for WMMoveResize.
Definition: netwm_def.h:532
MappingState
Client window mapping state.
Definition: netwm_def.h:553
Role
Application role.
Definition: netwm_def.h:271
WindowType
Window type.
Definition: netwm_def.h:286
QCA_EXPORT bool isSupported(const char *features, const QString &provider=QString())
Property
Supported properties.
Definition: netwm_def.h:638
virtual void changeDesktopGeometry(int desktop, const NETSize &geom)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:756
Simple point class for NET classes.
Definition: netwm_def.h:26
virtual void changeDesktop(int desktop)
A Window Manager should subclass NETWinInfo and reimplement this function when it wants to know when ...
Definition: netwm.h:1649
virtual void changeDesktopViewport(int desktop, const NETPoint &viewport)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:771
virtual void gotPing(xcb_window_t window, xcb_timestamp_t timestamp)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to receive r...
Definition: netwm.h:828
virtual void changeNumberOfDesktops(int numberOfDesktops)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:742
Simple rectangle class for NET classes.
Definition: netwm_def.h:75
virtual void changeState(NET::States state, NET::States mask)
A Window Manager should subclass NETWinInfo and reimplement this function when it wants to know when ...
Definition: netwm.h:1663
virtual void closeWindow(xcb_window_t window)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:795
Base namespace class.
Definition: netwm_def.h:263
virtual void changeCurrentDesktop(int desktop)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:784
static const int OnAllDesktops
Sentinel value to indicate that the client wishes to be visible on all desktops.
Definition: netwm.h:1639
virtual void restackWindow(xcb_window_t window, RequestSource source, xcb_window_t above, int detail, xcb_timestamp_t timestamp)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:885
Action
Actions that can be done with a window (_NET_WM_ALLOWED_ACTIONS).
Definition: netwm_def.h:574
Common API for application window properties/protocols.
Definition: netwm.h:935
virtual void removeClient(xcb_window_t window)
A Client should subclass NETRootInfo and reimplement this function when it wants to know when a windo...
Definition: netwm.h:730
WindowTypeMask
Values for WindowType when they should be OR&#39;ed together, e.g.
Definition: netwm_def.h:378
DesktopLayoutCorner
Starting corner for desktop layout.
Definition: netwm_def.h:791
virtual void addClient(xcb_window_t window)
A Client should subclass NETRootInfo and reimplement this function when it wants to know when a windo...
Definition: netwm.h:719
virtual void changeActiveWindow(xcb_window_t window, NET::RequestSource src, xcb_timestamp_t timestamp, xcb_window_t active_window)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:843
RequestSource
Source of the request.
Definition: netwm_def.h:765
Simple size class for NET classes.
Definition: netwm_def.h:52
virtual void moveResizeWindow(xcb_window_t window, int flags, int x, int y, int width, int height)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:864
virtual void changeShowingDesktop(bool showing)
A Window Manager should subclass NETRootInfo and reimplement this function when it wants to know when...
Definition: netwm.h:902
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Jul 11 2020 22:39:48 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.