File indexing completed on 2024-04-28 15:32:31

0001 /*
0002     SPDX-FileCopyrightText: 2000 Troll Tech AS
0003     SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
0004 
0005     SPDX-License-Identifier: MIT
0006 */
0007 
0008 #ifndef netwm_h
0009 #define netwm_h
0010 
0011 #include <QSize>
0012 #include <config-kwindowsystem.h>
0013 #include <kwindowsystem_export.h>
0014 #if KWINDOWSYSTEM_HAVE_X11
0015 #include <vector>
0016 #include <xcb/xcb.h>
0017 
0018 #include "netwm_def.h"
0019 
0020 #define KDE_ALL_ACTIVITIES_UUID "00000000-0000-0000-0000-000000000000"
0021 
0022 // forward declaration
0023 struct NETRootInfoPrivate;
0024 struct NETWinInfoPrivate;
0025 template<class Z>
0026 class NETRArray;
0027 
0028 /**
0029    Common API for root window properties/protocols.
0030 
0031    The NETRootInfo class provides a common API for clients and window managers
0032    to set/read/change properties on the root window as defined by the NET Window
0033    Manager Specification..
0034 
0035    @author Bradley T. Hughes <bhughes@trolltech.com>
0036    @see NET
0037    @see NETWinInfo
0038  **/
0039 
0040 class KWINDOWSYSTEM_EXPORT NETRootInfo : public NET
0041 {
0042 public:
0043     /**
0044         Indexes for the properties array.
0045     **/
0046     // update also NETRootInfoPrivate::properties[] size when extending this
0047     enum {
0048         PROTOCOLS,
0049         WINDOW_TYPES,
0050         STATES,
0051         PROTOCOLS2,
0052         ACTIONS,
0053         PROPERTIES_SIZE,
0054     };
0055 
0056     /**
0057        Window Managers should use this constructor to create a NETRootInfo object,
0058        which will be used to set/update information stored on the rootWindow.
0059        The application role is automatically set to WindowManager
0060        when using this constructor.
0061 
0062        @param connection XCB connection
0063 
0064        @param supportWindow The Window id of the supportWindow.  The supportWindow
0065        must be created by the window manager as a child of the rootWindow.  The
0066        supportWindow must not be destroyed until the Window Manager exits.
0067 
0068        @param wmName A string which should be the window manager's name (ie. "KWin"
0069        or "Blackbox").
0070 
0071        @param properties The properties the window manager supports
0072 
0073        @param windowTypes The window types the window manager supports
0074 
0075        @param states The states the window manager supports
0076 
0077        @param properties2 The properties2 the window manager supports
0078 
0079        @param actions The actions the window manager supports
0080 
0081        @param screen For Window Managers that support multiple screen (ie.
0082        "multiheaded") displays, the screen number may be explicitly defined.  If
0083        this argument is omitted, the default screen will be used.
0084 
0085        @param doActivate true to activate the window
0086     **/
0087     NETRootInfo(xcb_connection_t *connection,
0088                 xcb_window_t supportWindow,
0089                 const char *wmName,
0090                 NET::Properties properties,
0091                 NET::WindowTypes windowTypes,
0092                 NET::States states,
0093                 NET::Properties2 properties2,
0094                 NET::Actions actions,
0095                 int screen = -1,
0096                 bool doActivate = true);
0097 
0098     /**
0099        Clients should use this constructor to create a NETRootInfo object, which
0100        will be used to query information set on the root window. The application
0101        role is automatically set to Client when using this constructor.
0102 
0103        @param connection XCB connection
0104 
0105        @param properties The properties the client is interested in.
0106 
0107        @param properties2 The properties2 the client is interested in.
0108 
0109        @param properties_size The number of elements in the properties array.
0110 
0111        @param screen For Clients that support multiple screen (ie. "multiheaded")
0112        displays, the screen number may be explicitly defined. If this argument is
0113        omitted, the default screen will be used.
0114 
0115        @param doActivate true to call activate() to do an initial data read/update
0116        of the query information.
0117     **/
0118     NETRootInfo(xcb_connection_t *connection,
0119                 NET::Properties properties,
0120                 NET::Properties2 properties2 = NET::Properties2(),
0121                 int screen = -1,
0122                 bool doActivate = true);
0123 
0124     /**
0125        Creates a shared copy of the specified NETRootInfo object.
0126 
0127        @param rootinfo the NETRootInfo object to copy
0128     **/
0129     NETRootInfo(const NETRootInfo &rootinfo);
0130 
0131     /**
0132        Destroys the NETRootInfo object.
0133     **/
0134     virtual ~NETRootInfo();
0135 
0136     /**
0137        Returns the xcb connection used.
0138 
0139        @return the XCB connection
0140     **/
0141     xcb_connection_t *xcbConnection() const;
0142 
0143     /**
0144        Returns the Window id of the rootWindow.
0145 
0146        @return the id of the root window
0147     **/
0148     xcb_window_t rootWindow() const;
0149 
0150     /**
0151        Returns the Window id of the supportWindow.
0152 
0153        @return the id of the support window
0154     **/
0155     xcb_window_t supportWindow() const;
0156 
0157     /**
0158        Returns the name of the Window Manager.
0159 
0160        @return the name of the window manager
0161     **/
0162     const char *wmName() const;
0163 
0164     /**
0165       Sets the given property if on is true, and clears the property otherwise.
0166       In WindowManager mode this function updates _NET_SUPPORTED.
0167       In Client mode this function does nothing.
0168 
0169       @since 4.4
0170      **/
0171     void setSupported(NET::Property property, bool on = true);
0172 
0173     /**
0174       @overload
0175       @since 4.4
0176      **/
0177     void setSupported(NET::Property2 property, bool on = true);
0178 
0179     /**
0180       @overload
0181       @since 4.4
0182      **/
0183     void setSupported(NET::WindowTypeMask property, bool on = true);
0184 
0185     /**
0186       @overload
0187       @since 4.4
0188      **/
0189     void setSupported(NET::State property, bool on = true);
0190 
0191     /**
0192       @overload
0193       @since 4.4
0194      **/
0195     void setSupported(NET::Action property, bool on = true);
0196 
0197     /**
0198        Returns true if the given property is supported by the window
0199        manager. Note that for Client mode, NET::Supported needs
0200        to be passed in the properties argument for this to work.
0201     **/
0202     bool isSupported(NET::Property property) const;
0203     /**
0204        @overload
0205     **/
0206     bool isSupported(NET::Property2 property) const;
0207     /**
0208        @overload
0209     **/
0210     bool isSupported(NET::WindowTypeMask type) const;
0211     /**
0212        @overload
0213     **/
0214     bool isSupported(NET::State state) const;
0215 
0216     /**
0217        @overload
0218     **/
0219     bool isSupported(NET::Action action) const;
0220 
0221     /**
0222        In the Window Manager mode, this is equivalent to the properties
0223        argument passed to the constructor. In the Client mode, if
0224        NET::Supported was passed in the properties argument, the returned
0225        value are all properties supported by the Window Manager. Other supported
0226        protocols and properties are returned by the specific methods.
0227        @see supportedProperties2()
0228        @see supportedStates()
0229        @see supportedWindowTypes()
0230        @see supportedActions()
0231     **/
0232     NET::Properties supportedProperties() const;
0233     /**
0234      * In the Window Manager mode, this is equivalent to the properties2
0235      * argument passed to the constructor. In the Client mode, if
0236      * NET::Supported was passed in the properties argument, the returned
0237      * value are all properties2 supported by the Window Manager. Other supported
0238      * protocols and properties are returned by the specific methods.
0239      * @see supportedProperties()
0240      * @see supportedStates()
0241      * @see supportedWindowTypes()
0242      * @see supportedActions()
0243      * @since 5.0
0244      **/
0245     NET::Properties2 supportedProperties2() const;
0246     /**
0247      * In the Window Manager mode, this is equivalent to the states
0248      * argument passed to the constructor. In the Client mode, if
0249      * NET::Supported was passed in the properties argument, the returned
0250      * value are all states supported by the Window Manager. Other supported
0251      * protocols and properties are returned by the specific methods.
0252      * @see supportedProperties()
0253        @see supportedProperties2()
0254      * @see supportedWindowTypes()
0255      * @see supportedActions()
0256      * @since 5.0
0257      **/
0258     NET::States supportedStates() const;
0259     /**
0260      * In the Window Manager mode, this is equivalent to the windowTypes
0261      * argument passed to the constructor. In the Client mode, if
0262      * NET::Supported was passed in the properties argument, the returned
0263      * value are all window types supported by the Window Manager. Other supported
0264      * protocols and properties are returned by the specific methods.
0265      * @see supportedProperties()
0266        @see supportedProperties2()
0267      * @see supportedStates()
0268      * @see supportedActions()
0269      * @since 5.0
0270      **/
0271     NET::WindowTypes supportedWindowTypes() const;
0272     /**
0273      * In the Window Manager mode, this is equivalent to the actions
0274      * argument passed to the constructor. In the Client mode, if
0275      * NET::Supported was passed in the properties argument, the returned
0276      * value are all actions supported by the Window Manager. Other supported
0277      * protocols and properties are returned by the specific methods.
0278      * @see supportedProperties()
0279        @see supportedProperties2()
0280      * @see supportedStates()
0281      * @see supportedWindowTypes()
0282      * @since 5.0
0283      **/
0284     NET::Actions supportedActions() const;
0285 
0286     /**
0287      * @returns the properties argument passed to the constructor.
0288      * @see passedProperties2()
0289      * @see passedStates()
0290      * @see passedWindowTypes()
0291      * @see passedActions()
0292      **/
0293     NET::Properties passedProperties() const;
0294     /**
0295      * @returns the properties2 argument passed to the constructor.
0296      * @see passedProperties()
0297      * @see passedStates()
0298      * @see passedWindowTypes()
0299      * @see passedActions()
0300      * @since 5.0
0301      **/
0302     NET::Properties2 passedProperties2() const;
0303     /**
0304      * @returns the states argument passed to the constructor.
0305      * @see passedProperties()
0306      * @see passedProperties2()
0307      * @see passedWindowTypes()
0308      * @see passedActions()
0309      * @since 5.0
0310      **/
0311     NET::States passedStates() const;
0312     /**
0313      * @returns the windowTypes argument passed to the constructor.
0314      * @see passedProperties()
0315      * @see passedProperties2()
0316      * @see passedStates()
0317      * @see passedActions()
0318      * @since 5.0
0319      **/
0320     NET::WindowTypes passedWindowTypes() const;
0321     /**
0322      * @returns the actions argument passed to the constructor.
0323      * @see passedProperties()
0324      * @see passedProperties2()
0325      * @see passedStates()
0326      * @see passedWindowTypes()
0327      * @since 5.0
0328      **/
0329     NET::Actions passedActions() const;
0330 
0331     /**
0332        Returns an array of Window id's, which contain all managed windows.
0333 
0334        @return the array of Window id's
0335 
0336        @see clientListCount()
0337     **/
0338     const xcb_window_t *clientList() const;
0339 
0340     /**
0341        Returns the number of managed windows in clientList array.
0342 
0343        @return the number of managed windows in the clientList array
0344 
0345        @see clientList()
0346     **/
0347     int clientListCount() const;
0348 
0349     /**
0350        Returns an array of Window id's, which contain all managed windows in
0351        stacking order.
0352 
0353        @return the array of Window id's in stacking order
0354 
0355        @see clientListStackingCount()
0356     **/
0357     const xcb_window_t *clientListStacking() const;
0358 
0359     /**
0360        Returns the number of managed windows in the clientListStacking array.
0361 
0362        @return the number of Window id's in the client list
0363 
0364        @see clientListStacking()
0365     **/
0366     int clientListStackingCount() const;
0367 
0368     /**
0369        Returns the desktop geometry size.
0370 
0371        NOTE: KDE uses virtual desktops and does not directly support
0372        viewport in any way. You should use calls for virtual desktops,
0373        viewport is mapped to them if needed.
0374 
0375        @return the size of the desktop
0376     **/
0377     NETSize desktopGeometry() const;
0378 
0379     /**
0380        Returns the viewport of the specified desktop.
0381 
0382        NOTE: KDE uses virtual desktops and does not directly support
0383        viewport in any way. You should use calls for virtual desktops,
0384        viewport is mapped to them if needed.
0385 
0386        @param desktop the number of the desktop
0387 
0388        @return the position of the desktop's viewport
0389     **/
0390     NETPoint desktopViewport(int desktop) const;
0391 
0392     /**
0393        Returns the workArea for the specified desktop.
0394 
0395        @param desktop the number of the desktop
0396 
0397        @return the size of the work area
0398     **/
0399     NETRect workArea(int desktop) const;
0400 
0401     /**
0402        Returns the name for the specified desktop.
0403 
0404        @param desktop the number of the desktop
0405 
0406        @return the name of the desktop
0407     **/
0408     const char *desktopName(int desktop) const;
0409 
0410     /**
0411        Returns an array of Window id's, which contain the virtual root windows.
0412 
0413        @return the array of Window id's
0414 
0415        @see virtualRootsCount()
0416     **/
0417     const xcb_window_t *virtualRoots() const;
0418 
0419     /**
0420        Returns the number of window in the virtualRoots array.
0421 
0422        @return the number of Window id's in the virtual root array
0423 
0424        @see virtualRoots()
0425     **/
0426     int virtualRootsCount() const;
0427 
0428     /**
0429        Returns the desktop layout orientation.
0430     **/
0431     NET::Orientation desktopLayoutOrientation() const;
0432 
0433     /**
0434        Returns the desktop layout number of columns and rows. Note that
0435        either may be 0 (see _NET_DESKTOP_LAYOUT).
0436     **/
0437     QSize desktopLayoutColumnsRows() const;
0438 
0439     /**
0440        Returns the desktop layout starting corner.
0441     **/
0442     NET::DesktopLayoutCorner desktopLayoutCorner() const;
0443 
0444     /**
0445        Returns the number of desktops.
0446 
0447        NOTE: KDE uses virtual desktops and does not directly support
0448        viewport in any way. They are however mapped to virtual desktops
0449        if needed.
0450 
0451        @param ignore_viewport if false, viewport is mapped to virtual desktops
0452 
0453        @return the number of desktops
0454     **/
0455     int numberOfDesktops(bool ignore_viewport = false) const;
0456 
0457     /**
0458        Returns the current desktop.
0459 
0460        NOTE: KDE uses virtual desktops and does not directly support
0461        viewport in any way. They are however mapped to virtual desktops
0462        if needed.
0463 
0464        @param ignore_viewport if false, viewport is mapped to virtual desktops
0465 
0466        @return the number of the current desktop
0467     **/
0468     int currentDesktop(bool ignore_viewport = false) const;
0469 
0470     /**
0471        Returns the active (focused) window.
0472 
0473        @return the id of the active window
0474     **/
0475     xcb_window_t activeWindow() const;
0476 
0477     /**
0478        Window Managers must call this after creating the NETRootInfo object, and
0479        before using any other method in the class.  This method sets initial data
0480        on the root window and does other post-construction duties.
0481 
0482        Clients must also call this after creating the object to do an initial
0483        data read/update.
0484     **/
0485     void activate();
0486 
0487     /**
0488        Sets the list of managed windows on the Root/Desktop window.
0489 
0490        @param windows The array of Window id's
0491 
0492        @param count The number of windows in the array
0493     **/
0494     void setClientList(const xcb_window_t *windows, unsigned int count);
0495 
0496     /**
0497        Sets the list of managed windows in stacking order on the Root/Desktop
0498        window.
0499 
0500        @param windows The array of Window id's
0501 
0502        @param count The number of windows in the array.
0503     **/
0504     void setClientListStacking(const xcb_window_t *windows, unsigned int count);
0505 
0506     /**
0507        Sets the current desktop to the specified desktop.
0508 
0509        NOTE: KDE uses virtual desktops and does not directly support
0510        viewport in any way. It is however mapped to virtual desktops
0511        if needed.
0512 
0513        @param desktop the number of the desktop
0514        @param ignore_viewport if false, viewport is mapped to virtual desktops
0515     **/
0516     void setCurrentDesktop(int desktop, bool ignore_viewport = false);
0517 
0518     /**
0519        Sets the desktop geometry to the specified geometry.
0520 
0521        NOTE: KDE uses virtual desktops and does not directly support
0522        viewport in any way. You should use calls for virtual desktops,
0523        viewport is mapped to them if needed.
0524 
0525        @param geometry the new size of the desktop
0526     **/
0527     void setDesktopGeometry(const NETSize &geometry);
0528 
0529     /**
0530        Sets the viewport for the current desktop to the specified point.
0531 
0532        NOTE: KDE uses virtual desktops and does not directly support
0533        viewport in any way. You should use calls for virtual desktops,
0534        viewport is mapped to them if needed.
0535 
0536        @param desktop the number of the desktop
0537 
0538        @param viewport the new position of the desktop's viewport
0539     **/
0540     void setDesktopViewport(int desktop, const NETPoint &viewport);
0541 
0542     /**
0543        Sets the number of desktops to the specified number.
0544 
0545        NOTE: KDE uses virtual desktops and does not directly support
0546        viewport in any way. Viewport is mapped to virtual desktops
0547        if needed, but not for this call.
0548 
0549        @param numberOfDesktops the number of desktops
0550     **/
0551     void setNumberOfDesktops(int numberOfDesktops);
0552 
0553     /**
0554        Sets the name of the specified desktop.
0555 
0556        NOTE: KDE uses virtual desktops and does not directly support
0557        viewport in any way. Viewport is mapped to virtual desktops
0558        if needed, but not for this call.
0559 
0560        @param desktop the number of the desktop
0561 
0562        @param desktopName the new name of the desktop
0563     **/
0564     void setDesktopName(int desktop, const char *desktopName);
0565 
0566     /**
0567        Requests that the specified window becomes the active (focused) one.
0568 
0569        @param window the id of the new active window
0570        @param src whether the request comes from normal application
0571           or from a pager or similar tool
0572        @param timestamp X server timestamp of the user action that
0573           caused the request
0574        @param active_window active window of the requesting application, if any
0575     **/
0576     void setActiveWindow(xcb_window_t window, NET::RequestSource src, xcb_timestamp_t timestamp, xcb_window_t active_window);
0577 
0578     /**
0579        Sets the active (focused) window the specified window. This should
0580        be used only in the window manager mode.
0581 
0582        @param window the if of the new active window
0583     **/
0584     void setActiveWindow(xcb_window_t window);
0585 
0586     /**
0587        Sets the workarea for the specified desktop
0588 
0589        @param desktop the number of the desktop
0590 
0591        @param workArea the new work area of the desktop
0592     **/
0593     void setWorkArea(int desktop, const NETRect &workArea);
0594 
0595     /**
0596        Sets the list of virtual root windows on the root window.
0597 
0598        @param windows The array of Window id's
0599 
0600        @param count The number of windows in the array.
0601     **/
0602     void setVirtualRoots(const xcb_window_t *windows, unsigned int count);
0603 
0604     /**
0605        Sets the desktop layout. This is set by the pager. When setting, the pager must
0606        own the _NET_DESKTOP_LAYOUT_Sn manager selection. See _NET_DESKTOP_LAYOUT for details.
0607     **/
0608     void setDesktopLayout(NET::Orientation orientation, int columns, int rows, NET::DesktopLayoutCorner corner);
0609 
0610     /**
0611      * Sets the _NET_SHOWING_DESKTOP status (whether desktop is being shown).
0612      */
0613     void setShowingDesktop(bool showing);
0614     /**
0615      * Returns the status of _NET_SHOWING_DESKTOP.
0616      */
0617     bool showingDesktop() const;
0618 
0619     /**
0620        Assignment operator.  Ensures that the shared data reference counts are
0621        correct.
0622     **/
0623     const NETRootInfo &operator=(const NETRootInfo &rootinfo);
0624 
0625     /**
0626        Clients (such as pagers/taskbars) that wish to close a window should call
0627        this function.  This will send a request to the Window Manager, which
0628        usually can usually decide how to react to such requests.
0629 
0630        @param window the id of the window to close
0631     **/
0632     void closeWindowRequest(xcb_window_t window);
0633 
0634     /**
0635        Clients (such as pagers/taskbars) that wish to start a WMMoveResize
0636        (where the window manager controls the resize/movement,
0637        i.e. _NET_WM_MOVERESIZE) should call this function.
0638        This will send a request to the Window Manager.
0639 
0640        @param window The client window that would be resized/moved.
0641 
0642        @param x_root X position of the cursor relative to the root window.
0643 
0644        @param y_root Y position of the cursor relative to the root window.
0645 
0646        @param direction One of NET::Direction (see base class documentation for
0647        a description of the different directions).
0648     **/
0649     void moveResizeRequest(xcb_window_t window, int x_root, int y_root, Direction direction);
0650 
0651     /**
0652        Clients (such as pagers/taskbars) that wish to move/resize a window
0653        using WM2MoveResizeWindow (_NET_MOVERESIZE_WINDOW) should call this function.
0654        This will send a request to the Window Manager. See _NET_MOVERESIZE_WINDOW
0655        description for details.
0656 
0657        @param window The client window that would be resized/moved.
0658        @param flags Flags specifying the operation (see _NET_MOVERESIZE_WINDOW description)
0659        @param x Requested X position for the window
0660        @param y Requested Y position for the window
0661        @param width Requested width for the window
0662        @param height Requested height for the window
0663     **/
0664     void moveResizeWindowRequest(xcb_window_t window, int flags, int x, int y, int width, int height);
0665 
0666     /**
0667        Clients that wish to show the window menu using WM2GTKShowWindowMenu
0668        (_GTK_SHOW_WINDOW_MENU) should call this function.
0669        This will send a request to the Window Manager. See _GTK_SHOW_WINDOW_MENU
0670        description for details.
0671 
0672        @param window The client window that would be resized/moved.
0673        @param device_id GTK device id
0674        @param x Requested X position for the menu relative to the root window
0675        @param y Requested Y position for the menu relative to the root window
0676     **/
0677     void showWindowMenuRequest(xcb_window_t window, int device_id, int x_root, int y_root);
0678 
0679     /**
0680        Sends the _NET_RESTACK_WINDOW request.
0681     **/
0682     void restackRequest(xcb_window_t window, RequestSource source, xcb_window_t above, int detail, xcb_timestamp_t timestamp);
0683 
0684     /**
0685       Sends a ping with the given timestamp to the window, using
0686       the _NET_WM_PING protocol.
0687     */
0688     void sendPing(xcb_window_t window, xcb_timestamp_t timestamp);
0689 
0690 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
0691     /**
0692        This function takes the passed XEvent and returns an OR'ed list of
0693        NETRootInfo properties that have changed in the properties argument.
0694        The new information will be read immediately by the class.
0695        The elements of the properties argument are as they would be passed
0696        to the constructor, if the array is not large enough,
0697        changed properties that don't fit in it won't be listed there
0698        (they'll be updated in the class though).
0699 
0700        @param event the event
0701        @param properties properties that changed
0702        @param properties_size size of the passed properties array
0703        @deprecated since 5.0 use event(xcb_generic_event_t*, NET::Properties*, NET::Properties2*)
0704 
0705     **/
0706     KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use NETRootInfo::event(xcb_generic_event_t*, NET::Properties*, NET::Properties2*)")
0707     void event(xcb_generic_event_t *event, unsigned long *properties, int properties_size);
0708 #endif
0709     /**
0710      * This function takes the passed xcb_generic_event_t and returns the updated properties in the passed in arguments.
0711      *
0712      * The new information will be read immediately by the class. It is possible to pass in a
0713      * null pointer in the arguments. In that case the passed in argument will obviously not
0714      * be updated, but the class will process the information nevertheless.
0715      *
0716      * @param event the event
0717      * @param properties The NET::Properties that changed
0718      * @param properties2 The NET::Properties2 that changed
0719      * @since 5.0
0720      **/
0721     void event(xcb_generic_event_t *event, NET::Properties *properties, NET::Properties2 *properties2 = nullptr);
0722 
0723     /**
0724        This function takes the passed XEvent and returns an OR'ed list of
0725        NETRootInfo properties that have changed.  The new information will be
0726        read immediately by the class. This overloaded version returns
0727        only a single mask, and therefore cannot check state of all properties
0728        like the other variant.
0729 
0730        @param event the event
0731 
0732        @return the properties
0733     **/
0734     NET::Properties event(xcb_generic_event_t *event);
0735 
0736 protected:
0737     /**
0738        A Client should subclass NETRootInfo and reimplement this function when
0739        it wants to know when a window has been added.
0740 
0741        @param window the id of the window to add
0742     **/
0743     virtual void addClient(xcb_window_t window)
0744     {
0745         Q_UNUSED(window);
0746     }
0747 
0748     /**
0749        A Client should subclass NETRootInfo and reimplement this function when
0750        it wants to know when a window has been removed.
0751 
0752        @param window the id of the window to remove
0753     **/
0754     virtual void removeClient(xcb_window_t window)
0755     {
0756         Q_UNUSED(window);
0757     }
0758 
0759     /**
0760        A Window Manager should subclass NETRootInfo and reimplement this function
0761        when it wants to know when a Client made a request to change the number
0762        of desktops.
0763 
0764        @param numberOfDesktops the new number of desktops
0765     **/
0766     virtual void changeNumberOfDesktops(int numberOfDesktops)
0767     {
0768         Q_UNUSED(numberOfDesktops);
0769     }
0770 
0771     /**
0772        A Window Manager should subclass NETRootInfo and reimplement this function
0773        when it wants to know when a Client made a request to change the specified
0774        desktop geometry.
0775 
0776        @param desktop the number of the desktop
0777 
0778        @param geom the new size
0779     **/
0780     virtual void changeDesktopGeometry(int desktop, const NETSize &geom)
0781     {
0782         Q_UNUSED(desktop);
0783         Q_UNUSED(geom);
0784     }
0785 
0786     /**
0787        A Window Manager should subclass NETRootInfo and reimplement this function
0788        when it wants to know when a Client made a request to change the specified
0789        desktop viewport.
0790 
0791        @param desktop the number of the desktop
0792 
0793        @param viewport the new position of the viewport
0794     **/
0795     virtual void changeDesktopViewport(int desktop, const NETPoint &viewport)
0796     {
0797         Q_UNUSED(desktop);
0798         Q_UNUSED(viewport);
0799     }
0800 
0801     /**
0802        A Window Manager should subclass NETRootInfo and reimplement this function
0803        when it wants to know when a Client made a request to change the current
0804        desktop.
0805 
0806        @param desktop the number of the desktop
0807     **/
0808     virtual void changeCurrentDesktop(int desktop)
0809     {
0810         Q_UNUSED(desktop);
0811     }
0812 
0813     /**
0814        A Window Manager should subclass NETRootInfo and reimplement this function
0815        when it wants to know when a Client made a request to close a window.
0816 
0817        @param window the id of the window to close
0818     **/
0819     virtual void closeWindow(xcb_window_t window)
0820     {
0821         Q_UNUSED(window);
0822     }
0823 
0824     /**
0825        A Window Manager should subclass NETRootInfo and reimplement this function
0826        when it wants to know when a Client made a request to start a move/resize.
0827 
0828        @param window The window that wants to move/resize
0829 
0830        @param x_root X position of the cursor relative to the root window.
0831 
0832        @param y_root Y position of the cursor relative to the root window.
0833 
0834        @param direction One of NET::Direction (see base class documentation for
0835        a description of the different directions).
0836     **/
0837     virtual void moveResize(xcb_window_t window, int x_root, int y_root, unsigned long direction)
0838     {
0839         Q_UNUSED(window);
0840         Q_UNUSED(x_root);
0841         Q_UNUSED(y_root);
0842         Q_UNUSED(direction);
0843     }
0844 
0845     /**
0846        A Window Manager should subclass NETRootInfo and reimplement this function
0847        when it wants to receive replies to the _NET_WM_PING protocol.
0848        @param window the window from which the reply came
0849        @param timestamp timestamp of the ping
0850      */
0851     virtual void gotPing(xcb_window_t window, xcb_timestamp_t timestamp)
0852     {
0853         Q_UNUSED(window);
0854         Q_UNUSED(timestamp);
0855     }
0856     /**
0857        A Window Manager should subclass NETRootInfo and reimplement this function
0858        when it wants to know when a Client made a request to change the active
0859        (focused) window.
0860 
0861        @param window the id of the window to activate
0862        @param src the source from which the request came
0863        @param timestamp the timestamp of the user action causing this request
0864        @param active_window active window of the requesting application, if any
0865     **/
0866     virtual void changeActiveWindow(xcb_window_t window, NET::RequestSource src, xcb_timestamp_t timestamp, xcb_window_t active_window)
0867     {
0868         Q_UNUSED(window);
0869         Q_UNUSED(src);
0870         Q_UNUSED(timestamp);
0871         Q_UNUSED(active_window);
0872     }
0873 
0874     /**
0875        A Window Manager should subclass NETRootInfo and reimplement this function
0876        when it wants to know when a pager made a request to move/resize a window.
0877        See _NET_MOVERESIZE_WINDOW for details.
0878 
0879        @param window the id of the window to more/resize
0880        @param flags Flags specifying the operation (see _NET_MOVERESIZE_WINDOW description)
0881        @param x Requested X position for the window
0882        @param y Requested Y position for the window
0883        @param width Requested width for the window
0884        @param height Requested height for the window
0885     **/
0886     virtual void moveResizeWindow(xcb_window_t window, int flags, int x, int y, int width, int height)
0887     {
0888         Q_UNUSED(window);
0889         Q_UNUSED(flags);
0890         Q_UNUSED(x);
0891         Q_UNUSED(y);
0892         Q_UNUSED(width);
0893         Q_UNUSED(height);
0894     }
0895 
0896     /**
0897        A Window Manager should subclass NETRootInfo and reimplement this function
0898        when it wants to know when a Client made a request to restack a window.
0899        See _NET_RESTACK_WINDOW for details.
0900 
0901        @param window the id of the window to restack
0902        @param source the source of the request
0903        @param above other window in the restack request
0904        @param detail restack detail
0905        @param timestamp the timestamp of the request
0906     **/
0907     virtual void restackWindow(xcb_window_t window, RequestSource source, xcb_window_t above, int detail, xcb_timestamp_t timestamp)
0908     {
0909         Q_UNUSED(window);
0910         Q_UNUSED(source);
0911         Q_UNUSED(above);
0912         Q_UNUSED(detail);
0913         Q_UNUSED(timestamp);
0914     }
0915 
0916     /**
0917        A Window Manager should subclass NETRootInfo and reimplement this function
0918        when it wants to know when a pager made a request to change showing the desktop.
0919        See _NET_SHOWING_DESKTOP for details.
0920 
0921        @param showing whether to activate the showing desktop mode
0922     **/
0923     virtual void changeShowingDesktop(bool showing)
0924     {
0925         Q_UNUSED(showing);
0926     }
0927 
0928     /**
0929        A Window Manager should subclass NETRootInfo and reimplement this function
0930        when it wants to know when a Client made a request to show a window menu.
0931 
0932        @param window The window that wants to move/resize
0933        @param device_id GTK device id.
0934        @param x_root X position of the cursor relative to the root window.
0935        @param y_root Y position of the cursor relative to the root window.
0936     **/
0937     virtual void showWindowMenu(xcb_window_t window, int device_id, int x_root, int y_root)
0938     {
0939         Q_UNUSED(window);
0940         Q_UNUSED(device_id);
0941         Q_UNUSED(x_root);
0942         Q_UNUSED(y_root);
0943     }
0944 
0945 private:
0946     void update(NET::Properties properties, NET::Properties2 properties2);
0947     void setSupported();
0948     void setDefaultProperties();
0949     void updateSupportedProperties(xcb_atom_t atom);
0950 
0951 protected:
0952     /** Virtual hook, used to add new "virtual" functions while maintaining
0953     binary compatibility. Unused in this class.
0954     */
0955     virtual void virtual_hook(int id, void *data);
0956 
0957 private:
0958     NETRootInfoPrivate *p; // krazy:exclude=dpointer (implicitly shared)
0959 };
0960 
0961 /**
0962    Common API for application window properties/protocols.
0963 
0964    The NETWinInfo class provides a common API for clients and window managers to
0965    set/read/change properties on an application window as defined by the NET
0966    Window Manager Specification.
0967 
0968    @author Bradley T. Hughes <bhughes@trolltech.com>
0969    @see NET
0970    @see NETRootInfo
0971    @see http://www.freedesktop.org/standards/wm-spec/
0972  **/
0973 
0974 class KWINDOWSYSTEM_EXPORT NETWinInfo : public NET
0975 {
0976 public:
0977     /**
0978         Indexes for the properties array.
0979     **/
0980     // update also NETWinInfoPrivate::properties[] size when extending this
0981     enum {
0982         PROTOCOLS,
0983         PROTOCOLS2,
0984         PROPERTIES_SIZE,
0985     };
0986     /**
0987        Create a NETWinInfo object, which will be used to set/read/change
0988        information stored on an application window.
0989 
0990        @param connection XCB connection
0991 
0992        @param window The Window id of the application window.
0993 
0994        @param rootWindow The Window id of the root window.
0995 
0996        @param properties The NET::Properties flags
0997 
0998        @param properties2 The NET::Properties2 flags
0999 
1000        @param role Select the application role.  If this argument is omitted,
1001        the role will default to Client.
1002     **/
1003     NETWinInfo(xcb_connection_t *connection,
1004                xcb_window_t window,
1005                xcb_window_t rootWindow,
1006                NET::Properties properties,
1007                NET::Properties2 properties2,
1008                Role role = Client);
1009 
1010 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
1011     /**
1012         This constructor differs from the above one only in the way it accepts
1013         the list of properties the client is interested in.
1014         @deprecated since 5.0 use above ctor
1015     **/
1016     KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use NETWinInfo(xcb_connection_t *, xcb_window_t, xcb_window_t, NET::Properties, NET::Properties2, Role")
1017     NETWinInfo(xcb_connection_t *connection, xcb_window_t window, xcb_window_t rootWindow, NET::Properties properties, Role role = Client);
1018 #endif
1019 
1020     /**
1021        Creates a shared copy of the specified NETWinInfo object.
1022 
1023        @param wininfo the NETWinInfo to copy
1024     **/
1025     NETWinInfo(const NETWinInfo &wininfo);
1026 
1027     /**
1028        Destroys the NETWinInfo object.
1029     **/
1030     virtual ~NETWinInfo();
1031 
1032     /**
1033        Assignment operator.  Ensures that the shared data reference counts are
1034        correct.
1035     **/
1036     const NETWinInfo &operator=(const NETWinInfo &wintinfo);
1037 
1038     /**
1039        Returns the xcb connection used.
1040 
1041        @return the XCB connection
1042     **/
1043     xcb_connection_t *xcbConnection() const;
1044 
1045     /**
1046        Returns true if the window has any window type set, even if the type
1047        itself is not known to this implementation. Presence of a window type
1048        as specified by the NETWM spec is considered as the window supporting
1049        this specification.
1050        @return true if the window has support for the NETWM spec
1051     **/
1052     bool hasNETSupport() const;
1053 
1054     /**
1055        @returns the properties argument passed to the constructor.
1056        @see passedProperties2()
1057     **/
1058     NET::Properties passedProperties() const;
1059     /**
1060      * @returns the properties2 argument passed to the constructor.
1061      * @see passedProperties()
1062      * @since 5.0
1063      **/
1064     NET::Properties2 passedProperties2() const;
1065 
1066     /**
1067        Returns the icon geometry.
1068 
1069        @return the geometry of the icon
1070     **/
1071     NETRect iconGeometry() const;
1072 
1073     /**
1074        Returns the state of the window (see the NET base class documentation for a
1075        description of the various states).
1076 
1077        @return the state of the window
1078     **/
1079     NET::States state() const;
1080 
1081     /**
1082        Returns the extended (partial) strut specified by this client.
1083        See _NET_WM_STRUT_PARTIAL in the spec.
1084     **/
1085     NETExtendedStrut extendedStrut() const;
1086 
1087     // Still used internally, e.g. by KWindowSystem::strutChanged() logic
1088     /**
1089        @deprecated use strutPartial()
1090        Returns the strut specified by this client.
1091 
1092        @return the strut of the window
1093     **/
1094     NETStrut strut() const;
1095 
1096     /**
1097        Returns the window type for this client (see the NET base class
1098        documentation for a description of the various window types).
1099        Since clients may specify several windows types for a window
1100        in order to support backwards compatibility and extensions
1101        not available in the NETWM spec, you should specify all
1102        window types you application supports (see the NET::WindowTypeMask
1103        mask values for various window types). This method will
1104        return the first window type that is listed in the supported types,
1105        or NET::Unknown if none of the window types is supported.
1106 
1107        @return the type of the window
1108     **/
1109     WindowType windowType(WindowTypes supported_types) const;
1110 
1111     /**
1112       This function returns false if the window has not window type
1113       specified at all. Used by KWindowInfo::windowType() to return either
1114       NET::Normal or NET::Dialog as appropriate as a fallback.
1115     **/
1116     bool hasWindowType() const;
1117 
1118     /**
1119        Returns the name of the window in UTF-8 format.
1120 
1121        @return the name of the window
1122     **/
1123     const char *name() const;
1124 
1125     /**
1126        Returns the visible name as set by the window manager in UTF-8 format.
1127 
1128        @return the visible name of the window
1129     **/
1130     const char *visibleName() const;
1131 
1132     /**
1133        Returns the iconic name of the window in UTF-8 format. Note that this has
1134        nothing to do with icons, but it's for "iconic"
1135        representations of the window (taskbars etc.), that should be shown
1136        when the window is in iconic state. See description of _NET_WM_ICON_NAME
1137        for details.
1138 
1139        @return the iconic name
1140     **/
1141     const char *iconName() const;
1142 
1143     /**
1144        Returns the visible iconic name as set by the window manager in UTF-8 format.
1145        Note that this has nothing to do with icons, but it's for "iconic"
1146        representations of the window (taskbars etc.), that should be shown
1147        when the window is in iconic state. See description of _NET_WM_VISIBLE_ICON_NAME
1148        for details.
1149 
1150        @return the visible iconic name
1151     **/
1152     const char *visibleIconName() const;
1153 
1154     /**
1155        Returns the desktop where the window is residing.
1156 
1157        NOTE: KDE uses virtual desktops and does not directly support
1158        viewport in any way. It is however mapped to virtual desktops
1159        if needed.
1160 
1161        @param ignore_viewport if false, viewport is mapped to virtual desktops
1162 
1163        @return the number of the window's desktop
1164 
1165        @see OnAllDesktops()
1166     **/
1167     int desktop(bool ignore_viewport = false) const;
1168 
1169     /**
1170        Returns the process id for the client window.
1171 
1172        @return the process id of the window
1173     **/
1174     int pid() const;
1175 
1176     /**
1177        Returns whether or not this client handles icons.
1178 
1179        @return true if this client handles icons, false otherwise
1180     **/
1181     bool handledIcons() const;
1182 
1183     /**
1184        Returns the mapping state for the window (see the NET base class
1185        documentation for a description of mapping state).
1186 
1187        @return the mapping state
1188     **/
1189     MappingState mappingState() const;
1190 
1191     /**
1192        Set icons for the application window.  If replace is True, then
1193        the specified icon is defined to be the only icon.  If replace is False,
1194        then the specified icon is added to a list of icons.
1195 
1196        @param icon the new icon
1197 
1198        @param replace true to replace, false to append to the list of icons
1199     **/
1200     void setIcon(NETIcon icon, bool replace = true);
1201 
1202     /**
1203        Set the icon geometry for the application window.
1204 
1205        @param geometry the new icon geometry
1206     **/
1207     void setIconGeometry(NETRect geometry);
1208 
1209     /**
1210        Set the extended (partial) strut for the application window.
1211 
1212        @param extended_strut the new strut
1213     **/
1214     void setExtendedStrut(const NETExtendedStrut &extended_strut);
1215 
1216     // Still used internally, e.g. by KWindowSystem::strutChanged() logic
1217     /**
1218        @deprecated use setExtendedStrut()
1219        Set the strut for the application window.
1220 
1221        @param strut the new strut
1222     **/
1223     void setStrut(NETStrut strut);
1224 
1225     /**
1226        Set the state for the application window (see the NET base class documentation
1227        for a description of window state).
1228 
1229        @param state the name state
1230 
1231        @param mask the mask for the state
1232     **/
1233     void setState(NET::States state, NET::States mask);
1234 
1235     /**
1236        Sets the window type for this client (see the NET base class
1237        documentation for a description of the various window types).
1238 
1239        @param type the window type
1240     **/
1241     void setWindowType(WindowType type);
1242 
1243     /**
1244        Sets the name for the application window.
1245 
1246        @param name the new name of the window
1247     **/
1248     void setName(const char *name);
1249 
1250     /**
1251        For Window Managers only:  set the visible name ( i.e. xterm, xterm <2>,
1252        xterm <3>, ... )
1253 
1254        @param visibleName the new visible name
1255     **/
1256     void setVisibleName(const char *visibleName);
1257 
1258     /**
1259        Sets the iconic name for the application window.
1260 
1261        @param name the new iconic name
1262     **/
1263     void setIconName(const char *name);
1264 
1265     /**
1266        For Window Managers only: set the visible iconic name ( i.e. xterm, xterm <2>,
1267        xterm <3>, ... )
1268 
1269        @param name the new visible iconic name
1270     **/
1271     void setVisibleIconName(const char *name);
1272 
1273     /**
1274        Set which window the desktop is (should be) on.
1275 
1276        NOTE: KDE uses virtual desktops and does not directly support
1277        viewport in any way. It is however mapped to virtual desktops
1278        if needed.
1279 
1280        @param desktop the number of the new desktop
1281        @param ignore_viewport if false, viewport is mapped to virtual desktops
1282 
1283        @see OnAllDesktops()
1284     **/
1285     void setDesktop(int desktop, bool ignore_viewport = false);
1286 
1287     /**
1288        Set the application window's process id.
1289 
1290        @param pid the window's process id
1291     **/
1292     void setPid(int pid);
1293 
1294     /**
1295        Set whether this application window handles icons.
1296 
1297        @param handled true if the window handles icons, false otherwise
1298     **/
1299     void setHandledIcons(bool handled);
1300 
1301     /**
1302        Set the frame decoration strut, i.e. the width of the decoration borders.
1303 
1304        @param strut the new strut
1305     **/
1306     void setFrameExtents(NETStrut strut);
1307 
1308     /**
1309        Returns the frame decoration strut, i.e. the width of the decoration borders.
1310 
1311        @since 4.3
1312     **/
1313     NETStrut frameExtents() const;
1314 
1315     /**
1316        Sets the window frame overlap strut, i.e. how far the window frame extends
1317        behind the client area on each side.
1318 
1319        Set the strut values to -1 if you want the window frame to cover the whole
1320        client area.
1321 
1322        The default values are 0.
1323 
1324        @since 4.4
1325     **/
1326     void setFrameOverlap(NETStrut strut);
1327 
1328     /**
1329        Returns the frame overlap strut, i.e. how far the window frame extends
1330        behind the client area on each side.
1331 
1332        @since 4.4
1333     **/
1334     NETStrut frameOverlap() const;
1335 
1336     /**
1337        Sets the extents of the drop-shadow drawn by the client.
1338 
1339        @since 5.65
1340     **/
1341     void setGtkFrameExtents(NETStrut strut);
1342 
1343     /**
1344        Returns the extents of the drop-shadow drawn by a GTK client.
1345 
1346        @since 5.65
1347     **/
1348     NETStrut gtkFrameExtents() const;
1349 
1350     /**
1351        Returns an icon.  If width and height are passed, the icon returned will be
1352        the closest it can find (the next biggest).  If width and height are omitted,
1353        then the largest icon in the list is returned.
1354 
1355        @param width the preferred width for the icon, -1 to ignore
1356 
1357        @param height the preferred height for the icon, -1 to ignore
1358 
1359        @return the icon
1360     **/
1361     NETIcon icon(int width = -1, int height = -1) const;
1362 
1363     /**
1364       Returns a list of provided icon sizes. Each size is pair width,height, terminated
1365       with pair 0,0.
1366       @since 4.3
1367     **/
1368     const int *iconSizes() const;
1369 
1370     /**
1371      * Sets user timestamp @p time on the window (property _NET_WM_USER_TIME).
1372      * The timestamp is expressed as XServer time. If a window
1373      * is shown with user timestamp older than the time of the last
1374      * user action, it won't be activated after being shown, with the special
1375      * value 0 meaning not to activate the window after being shown.
1376      */
1377     void setUserTime(xcb_timestamp_t time);
1378 
1379     /**
1380      * Returns the time of last user action on the window, or -1 if not set.
1381      */
1382     xcb_timestamp_t userTime() const;
1383 
1384     /**
1385      * Sets the startup notification id @p id on the window.
1386      */
1387     void setStartupId(const char *startup_id);
1388 
1389     /**
1390      * Returns the startup notification id of the window.
1391      */
1392     const char *startupId() const;
1393 
1394     /**
1395      * Sets opacity (0 = transparent, 0xffffffff = opaque ) on the window.
1396      */
1397     void setOpacity(unsigned long opacity);
1398     /**
1399      * Sets opacity (0 = transparent, 1 = opaque) on the window.
1400      */
1401     void setOpacityF(qreal opacity);
1402 
1403     /**
1404      * Returns the opacity of the window.
1405      */
1406     unsigned long opacity() const;
1407     /**
1408      * Returns the opacity of the window.
1409      */
1410     qreal opacityF() const;
1411 
1412     /**
1413      * Sets actions that the window manager allows for the window.
1414      */
1415     void setAllowedActions(NET::Actions actions);
1416 
1417     /**
1418      * Returns actions that the window manager allows for the window.
1419      */
1420     NET::Actions allowedActions() const;
1421 
1422     /**
1423      * Returns the WM_TRANSIENT_FOR property for the window, i.e. the mainwindow
1424      * for this window.
1425      */
1426     xcb_window_t transientFor() const;
1427 
1428     /**
1429      * Returns the leader window for the group the window is in, if any.
1430      */
1431     xcb_window_t groupLeader() const;
1432 
1433     /**
1434      * Returns whether the UrgencyHint is set in the WM_HINTS.flags.
1435      * See ICCCM 4.1.2.4.
1436      *
1437      * @since 5.3
1438      **/
1439     bool urgency() const;
1440 
1441     /**
1442      * Returns whether the Input flag is set in WM_HINTS.
1443      * See ICCCM 4.1.2.4 and 4.1.7.
1444      *
1445      * The default value is @c true in case the Client is mapped without a WM_HINTS property.
1446      *
1447      * @since 5.3
1448      **/
1449     bool input() const;
1450 
1451     /**
1452      * Returns the initial mapping state as set in WM_HINTS.
1453      * See ICCCM 4.1.2.4 and 4.1.4.
1454      *
1455      * The default value if @c Withdrawn in case the Client is mapped without
1456      * a WM_HINTS property or without the initial state hint set.
1457      *
1458      * @since 5.5
1459      **/
1460     MappingState initialMappingState() const;
1461 
1462     /**
1463      * Returns the icon pixmap as set in WM_HINTS.
1464      * See ICCCM 4.1.2.4.
1465      *
1466      * The default value is @c XCB_PIXMAP_NONE.
1467      *
1468      * Using the ICCCM variant for the icon is deprecated and only
1469      * offers a limited functionality compared to {@link icon}.
1470      * Only use this variant as a fallback.
1471      *
1472      * @see icccmIconPixmapMask
1473      * @see icon
1474      * @since 5.7
1475      **/
1476     xcb_pixmap_t icccmIconPixmap() const;
1477 
1478     /**
1479      * Returns the mask for the icon pixmap as set in WM_HINTS.
1480      * See ICCCM 4.1.2.4.
1481      *
1482      * The default value is @c XCB_PIXMAP_NONE.
1483      *
1484      * @see icccmIconPixmap
1485      * @since 5.7
1486      **/
1487     xcb_pixmap_t icccmIconPixmapMask() const;
1488 
1489     /**
1490      * Returns the class component of the window class for the window
1491      * (i.e. WM_CLASS property).
1492      */
1493     const char *windowClassClass() const;
1494 
1495     /**
1496      * Returns the name component of the window class for the window
1497      * (i.e. WM_CLASS property).
1498      */
1499     const char *windowClassName() const;
1500 
1501     /**
1502      * Returns the window role for the window (i.e. WM_WINDOW_ROLE property).
1503      */
1504     const char *windowRole() const;
1505 
1506     /**
1507      * Returns the client machine for the window (i.e. WM_CLIENT_MACHINE property).
1508      */
1509     const char *clientMachine() const;
1510 
1511     /**
1512      * returns a comma-separated list of the activities the window is associated with.
1513      * FIXME this might be better as a NETRArray ?
1514      * @since 4.6
1515      */
1516     const char *activities() const;
1517 
1518     /**
1519      * Sets the comma-separated list of activities the window is associated with.
1520      * @since 5.1
1521      */
1522     void setActivities(const char *activities);
1523 
1524     /**
1525      * Sets whether the client wishes to block compositing (for better performance)
1526      * @since 4.7
1527      */
1528     void setBlockingCompositing(bool active);
1529 
1530     /**
1531      * Returns whether the client wishes to block compositing (for better performance)
1532      * @since 4.7
1533      */
1534     bool isBlockingCompositing() const;
1535 
1536     /**
1537        Places the window frame geometry in frame, and the application window
1538        geometry in window.  Both geometries are relative to the root window.
1539 
1540        @param frame the geometry for the frame
1541 
1542        @param window the geometry for the window
1543     **/
1544     void kdeGeometry(NETRect &frame, NETRect &window);
1545 
1546     /**
1547        Sets the desired multiple-monitor topology (4 monitor indices indicating
1548        the top, bottom, left, and right edges of the window) when the fullscreen
1549        state is enabled. The indices are from the set returned by the Xinerama
1550        extension.
1551        See _NET_WM_FULLSCREEN_MONITORS for details.
1552 
1553        @param topology A struct that models the desired monitor topology, namely:
1554        top is the monitor whose top edge defines the top edge of the
1555        fullscreen window, bottom is the monitor whose bottom edge defines
1556        the bottom edge of the fullscreen window, left is the monitor whose
1557        left edge defines the left edge of the fullscreen window, and right
1558        is the monitor whose right edge defines the right edge of the fullscreen
1559        window.
1560 
1561     **/
1562     void setFullscreenMonitors(NETFullscreenMonitors topology);
1563 
1564     /**
1565        Returns the desired fullscreen monitor topology for this client, should
1566        it be in fullscreen state.
1567        See _NET_WM_FULLSCREEN_MONITORS in the spec.
1568     **/
1569     NETFullscreenMonitors fullscreenMonitors() const;
1570 
1571 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
1572     /**
1573        This function takes the passed XEvent and returns an OR'ed list of
1574        NETWinInfo properties that have changed in the properties argument.
1575        The new information will be read immediately by the class.
1576        The elements of the properties argument are as they would be passed
1577        to the constructor, if the array is not large enough,
1578        changed properties that don't fit in it won't be listed there
1579        (they'll be updated in the class though).
1580 
1581        @param event the event
1582        @param properties properties that changed
1583        @param properties_size size of the passed properties array
1584        @deprecated since 5.0 use event(xcb_generic_event_t*, NET::Properties*, NET::Properties2*)
1585     **/
1586     KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use NETWinInfo::event(xcb_generic_event_t*, NET::Properties*, NET::Properties2*)")
1587     void event(xcb_generic_event_t *event, unsigned long *properties, int properties_size);
1588 #endif
1589     /**
1590      * This function takes the passed in xcb_generic_event_t and returns the updated properties
1591      * in the passed in arguments.
1592      *
1593      * The new information will be read immediately by the class. It is possible to pass in a
1594      * null pointer in the arguments. In that case the passed in
1595      * argument will obviously not be updated, but the class will process the information
1596      * nevertheless.
1597      *
1598      * @param event the event
1599      * @param properties The NET::Properties that changed
1600      * @param properties2 The NET::Properties2 that changed
1601      * @since 5.0
1602      **/
1603     void event(xcb_generic_event_t *event, NET::Properties *properties, NET::Properties2 *properties2 = nullptr);
1604 
1605     /**
1606        This function takes the pass XEvent and returns an OR'ed list of NETWinInfo
1607        properties that have changed.  The new information will be read
1608        immediately by the class. This overloaded version returns
1609        only a single mask, and therefore cannot check state of all properties
1610        like the other variant.
1611 
1612        @param event the event
1613 
1614        @return the properties
1615     **/
1616     NET::Properties event(xcb_generic_event_t *event);
1617 
1618     /**
1619      * @returns The window manager protocols this Client supports.
1620      * @since 5.3
1621      **/
1622     NET::Protocols protocols() const;
1623 
1624     /**
1625      * @returns @c true if the Client supports the @p protocol.
1626      * @param protocol The window manager protocol to test for
1627      * @since 5.3
1628      **/
1629     bool supportsProtocol(NET::Protocol protocol) const;
1630 
1631     /**
1632      * @returns The opaque region as specified by the Client.
1633      * @since 5.7
1634      **/
1635     std::vector<NETRect> opaqueRegion() const;
1636 
1637     /**
1638      * Sets the @p name as the desktop file name.
1639      *
1640      * This is either the base name without full path and without file extension of the
1641      * desktop file for the window's application (e.g. "org.kde.foo").
1642      *
1643      * If the application's desktop file name is not at a standard location it should be
1644      * the full path to the desktop file name (e.g. "/opt/kde/share/org.kde.foo.desktop").
1645      *
1646      * If the window does not know the desktop file name, it should not set the name at all.
1647      *
1648      * @since 5.28
1649      **/
1650     void setDesktopFileName(const char *name);
1651 
1652     /**
1653      * @returns The desktop file name of the window's application if present.
1654      * @since 5.28
1655      * @see setDesktopFileName
1656      **/
1657     const char *desktopFileName() const;
1658 
1659     /**
1660      * @returns The GTK application id of the window if present.
1661      * @since 5.91
1662      **/
1663     const char *gtkApplicationId() const;
1664 
1665     /**
1666      * Sets the @p name as the D-BUS service name for the application menu.
1667      * @since 5.69
1668      **/
1669     void setAppMenuServiceName(const char *name);
1670 
1671     /**
1672      * Sets the @p name as the D-BUS object path for the application menu.
1673      * @since 5.69
1674      **/
1675     void setAppMenuObjectPath(const char *path);
1676 
1677     /**
1678      * @returns The menu service name of the window's application if present.
1679      * @since 5.69
1680      **/
1681     const char *appMenuServiceName() const;
1682 
1683     /**
1684      * @returns The menu object path of the window's application if present.
1685      * @since 5.69
1686      **/
1687     const char *appMenuObjectPath() const;
1688 
1689     /**
1690        Sentinel value to indicate that the client wishes to be visible on
1691        all desktops.
1692 
1693        @return the value to be on all desktops
1694     **/
1695     static const int OnAllDesktops;
1696 
1697 protected:
1698     /**
1699        A Window Manager should subclass NETWinInfo and reimplement this function when
1700        it wants to know when a Client made a request to change desktops (ie. move to
1701        another desktop).
1702 
1703        @param desktop the number of the desktop
1704     **/
1705     virtual void changeDesktop(int desktop)
1706     {
1707         Q_UNUSED(desktop);
1708     }
1709 
1710     /**
1711        A Window Manager should subclass NETWinInfo and reimplement this function when
1712        it wants to know when a Client made a request to change state (ie. to
1713        Shade / Unshade).
1714 
1715        @param state the new state
1716 
1717        @param mask the mask for the state
1718     **/
1719     virtual void changeState(NET::States state, NET::States mask)
1720     {
1721         Q_UNUSED(state);
1722         Q_UNUSED(mask);
1723     }
1724 
1725     /**
1726        A Window Manager should subclass NETWinInfo2 and reimplement this function
1727        when it wants to know when a Client made a request to change the
1728        fullscreen monitor topology for its fullscreen state.
1729 
1730        @param topology A structure (top, bottom, left, right) representing the
1731        fullscreen monitor topology.
1732     **/
1733     virtual void changeFullscreenMonitors(NETFullscreenMonitors topology)
1734     {
1735         Q_UNUSED(topology);
1736     }
1737 
1738 private:
1739     void update(NET::Properties dirtyProperties, NET::Properties2 dirtyProperties2 = NET::Properties2());
1740     void updateWMState();
1741     void setIconInternal(NETRArray<NETIcon> &icons, int &icon_count, xcb_atom_t property, NETIcon icon, bool replace);
1742     NETIcon iconInternal(NETRArray<NETIcon> &icons, int icon_count, int width, int height) const;
1743 
1744 protected:
1745     /** Virtual hook, used to add new "virtual" functions while maintaining
1746     binary compatibility. Unused in this class.
1747     */
1748     virtual void virtual_hook(int id, void *data);
1749 
1750 private:
1751     NETWinInfoPrivate *p; // krazy:exclude=dpointer (implicitly shared)
1752 };
1753 
1754 //#define KWIN_FOCUS
1755 
1756 #endif
1757 #endif // netwm_h