File indexing completed on 2024-02-18 16:20:08

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 1999, 2000 Matthias Ettrich <ettrich@kde.org>
0006     SPDX-FileCopyrightText: 2003 Lubos Lunak <l.lunak@kde.org>
0007     SPDX-FileCopyrightText: 2009 Lucas Murray <lmurray@undefinedfire.com>
0008     SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
0009 
0010     SPDX-License-Identifier: GPL-2.0-or-later
0011 */
0012 #pragma once
0013 
0014 #include <NETWM>
0015 
0016 #include <memory>
0017 #include <xcb/xcb.h>
0018 
0019 namespace KWin
0020 {
0021 
0022 class Window;
0023 class RootInfoFilter;
0024 class X11Window;
0025 
0026 /**
0027  * NET WM Protocol handler class
0028  */
0029 class RootInfo : public NETRootInfo
0030 {
0031 public:
0032     static RootInfo *create();
0033     static void destroy();
0034 
0035     void setActiveClient(Window *client);
0036 
0037 protected:
0038     void changeNumberOfDesktops(int n) override;
0039     void changeCurrentDesktop(int d) override;
0040     void changeActiveWindow(xcb_window_t w, NET::RequestSource src, xcb_timestamp_t timestamp, xcb_window_t active_window) override;
0041     void closeWindow(xcb_window_t w) override;
0042     void moveResize(xcb_window_t w, int x_root, int y_root, unsigned long direction) override;
0043     void moveResizeWindow(xcb_window_t w, int flags, int x, int y, int width, int height) override;
0044     void showWindowMenu(xcb_window_t w, int device_id, int x_root, int y_root) override;
0045     void gotPing(xcb_window_t w, xcb_timestamp_t timestamp) override;
0046     void restackWindow(xcb_window_t w, RequestSource source, xcb_window_t above, int detail, xcb_timestamp_t timestamp) override;
0047     void changeShowingDesktop(bool showing) override;
0048 
0049 private:
0050     RootInfo(xcb_window_t w, const char *name, NET::Properties properties, NET::WindowTypes types,
0051              NET::States states, NET::Properties2 properties2, NET::Actions actions, int scr = -1);
0052     static std::unique_ptr<RootInfo> s_self;
0053     friend RootInfo *rootInfo();
0054 
0055     xcb_window_t m_activeWindow;
0056     std::unique_ptr<RootInfoFilter> m_eventFilter;
0057 };
0058 
0059 inline RootInfo *rootInfo()
0060 {
0061     return RootInfo::s_self.get();
0062 }
0063 
0064 /**
0065  * NET WM Protocol handler class
0066  */
0067 class WinInfo : public NETWinInfo
0068 {
0069 public:
0070     WinInfo(X11Window *c, xcb_window_t window,
0071             xcb_window_t rwin, NET::Properties properties, NET::Properties2 properties2);
0072     void changeDesktop(int desktop) override;
0073     void changeFullscreenMonitors(NETFullscreenMonitors topology) override;
0074     void changeState(NET::States state, NET::States mask) override;
0075     void disable();
0076 
0077 private:
0078     X11Window *m_client;
0079 };
0080 
0081 } // KWin