LeechCraft 0.6.70-17609-g3dde4097dd
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
xwrapper.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <string>
12#include <QList>
13#include <QString>
14#include <QHash>
15#include <QObject>
16#include <QAbstractNativeEventFilter>
17#include <X11/Xdefs.h>
18#include "x11config.h"
19#include "winflags.h"
20
21class QIcon;
22class QWidget;
23class QRect;
24class QScreen;
25
26using Display = struct _XDisplay;
27using Window = unsigned long;
28
29using XEvent = union _XEvent;
30
31struct xcb_connection_t;
32
33namespace LC::Util
34{
35 class UTIL_X11_API XWrapper : public QObject
36 , public QAbstractNativeEventFilter
37 {
38 Q_OBJECT
39
40 xcb_connection_t *Conn_ = nullptr;
41 Display *Display_ = nullptr;
42 Window AppWin_ {};
43
44 QHash<QByteArray, Atom> Atoms_;
45
46 XWrapper ();
47 public:
48 enum class Layer
49 {
53 };
54
55 static XWrapper& Instance ();
56
57 xcb_connection_t* GetConnection () const;
58 Display* GetDisplay () const;
59 Window GetRootWindow () const;
60
61 bool nativeEventFilter (const QByteArray& eventType, void *message, qintptr *result) override;
62
63 void Sync ();
64
65 QList<Window> GetWindows ();
66 QString GetWindowTitle (Window);
67 QIcon GetWindowIcon (Window);
68 WinStateFlags GetWindowState (Window);
69 AllowedActionFlags GetWindowActions (Window);
70
71 Window GetActiveApp ();
72
73 bool IsLCWindow (Window);
74 bool ShouldShow (Window);
75
76 void Subscribe (Window);
77
78 void SetStrut (QWidget*, Qt::ToolBarArea);
79 void ClearStrut (QWidget*);
80 void SetStrut (Window wid,
81 ulong left, ulong right, ulong top, ulong bottom,
82 ulong leftStartY, ulong leftEndY,
83 ulong rightStartY, ulong rightEndY,
84 ulong topStartX, ulong topEndX,
85 ulong bottomStartX, ulong bottomEndX);
86
87 void RaiseWindow (Window);
88 void MinimizeWindow (Window);
89 void MaximizeWindow (Window);
90 void UnmaximizeWindow (Window);
91 void ShadeWindow (Window);
92 void UnshadeWindow (Window);
93 void MoveWindowTo (Window, Layer);
94 void CloseWindow (Window);
95
96 void ResizeWindow (Window, int, int);
97
98 int GetDesktopCount ();
99 int GetCurrentDesktop ();
100 void SetCurrentDesktop (int);
101 QStringList GetDesktopNames ();
102 QString GetDesktopName (int, const QString& = QString ());
103 int GetWindowDesktop (Window);
104 void MoveWindowToDesktop (Window, int);
105
106 QRect GetAvailableGeometry (QScreen&);
107 QRect GetAvailableGeometry (QWidget*);
108
117 Atom GetAtom (std::string_view str);
118 private:
119 template<typename T>
120 void HandlePropNotify (T);
121
122 template<typename Flag>
123 QFlags<Flag> GetFlagsList (Window wid, Atom property, const QHash<Atom, Flag>& atom2flag) const;
124
125 Window GetActiveWindow ();
126
127 bool GetWinProp (Window, Atom, ulong*, uchar**, Atom = static_cast<Atom> (0)) const;
128 bool GetRootWinProp (Atom, ulong*, uchar**, Atom = static_cast<Atom> (0)) const;
129 QList<Atom> GetWindowType (Window);
130
131 bool SendMessage (Window, Atom, ulong, ulong = 0, ulong = 0, ulong = 0, ulong = 0);
132 private slots:
133 void initialize ();
134 signals:
138
139 void windowNameChanged (ulong);
140 void windowIconChanged (ulong);
142 void windowStateChanged (ulong);
144 };
145}
void activeWindowChanged()
void windowIconChanged(ulong)
void windowNameChanged(ulong)
void windowDesktopChanged(ulong)
void windowActionsChanged(ulong)
void windowStateChanged(ulong)
#define UTIL_X11_API
Definition x11config.h:16
union _XEvent XEvent
Definition xwrapper.h:29
struct _XDisplay Display
Definition xwrapper.h:26
unsigned long Window
Definition xwrapper.h:27