LeechCraft 0.6.70-19214-g121e5318a7
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 <optional>
12#include <string>
13#include <QList>
14#include <QString>
15#include <QHash>
16#include <QObject>
17#include <QAbstractNativeEventFilter>
18#include <X11/Xdefs.h>
19#include "x11config.h"
20#include "winflags.h"
21
22class QIcon;
23class QWidget;
24class QRect;
25class QScreen;
26
27using Display = struct _XDisplay;
28using Window = unsigned long;
29
30using XEvent = union _XEvent;
31
32struct xcb_connection_t;
33
34namespace LC::Util
35{
36 class UTIL_X11_API XWrapper : public QObject
37 , public QAbstractNativeEventFilter
38 {
39 Q_OBJECT
40
41 xcb_connection_t * const Conn_;
42 Display * const Display_;
43 const Window AppWin_;
44
45 QHash<QByteArray, Atom> Atoms_;
46
47 struct PrivateCtor { explicit PrivateCtor () = default; };
48 public:
49 XWrapper (xcb_connection_t*, Display*, PrivateCtor);
50
51 enum class Layer
52 {
53 Top,
54 Bottom,
56 };
57
58 static std::optional<XWrapper&> Instance ();
59
60 xcb_connection_t* GetConnection () const;
61 Display* GetDisplay () const;
62 Window GetRootWindow () const;
63
64 bool nativeEventFilter (const QByteArray& eventType, void *message, qintptr *result) override;
65
66 void Sync ();
67
68 QList<Window> GetWindows ();
69 QString GetWindowTitle (Window);
70 QIcon GetWindowIcon (Window);
71 WinStateFlags GetWindowState (Window);
72 AllowedActionFlags GetWindowActions (Window);
73
74 Window GetActiveApp ();
75
76 bool IsLCWindow (Window);
77 bool ShouldShow (Window);
78
79 void Subscribe (Window);
80
81 void SetStrut (QWidget*, Qt::ToolBarArea);
82 void ClearStrut (QWidget*);
83 void SetStrut (Window wid,
84 ulong left, ulong right, ulong top, ulong bottom,
85 ulong leftStartY, ulong leftEndY,
86 ulong rightStartY, ulong rightEndY,
87 ulong topStartX, ulong topEndX,
88 ulong bottomStartX, ulong bottomEndX);
89
90 void RaiseWindow (Window);
91 void MinimizeWindow (Window);
92 void MaximizeWindow (Window);
93 void UnmaximizeWindow (Window);
94 void ShadeWindow (Window);
95 void UnshadeWindow (Window);
96 void MoveWindowTo (Window, Layer);
97 void CloseWindow (Window);
98
99 void ResizeWindow (Window, int, int);
100
101 int GetDesktopCount ();
102 int GetCurrentDesktop ();
103 void SetCurrentDesktop (int);
104 QStringList GetDesktopNames ();
105 QString GetDesktopName (int, const QString& = QString ());
106 int GetWindowDesktop (Window);
107 void MoveWindowToDesktop (Window, int);
108
109 QRect GetAvailableGeometry (QScreen&);
110 QRect GetAvailableGeometry (QWidget*);
111
120 Atom GetAtom (std::string_view str);
121 private:
122 template<typename T>
123 void HandlePropNotify (T);
124
125 template<typename Flag>
126 QFlags<Flag> GetFlagsList (Window wid, Atom property, const QHash<Atom, Flag>& atom2flag) const;
127
128 Window GetActiveWindow ();
129
130 bool GetWinProp (Window, Atom, ulong*, uchar**, Atom = static_cast<Atom> (0)) const;
131 bool GetRootWinProp (Atom, ulong*, uchar**, Atom = static_cast<Atom> (0)) const;
132 QList<Atom> GetWindowType (Window);
133
134 bool SendMessage (Window, Atom, ulong, ulong = 0, ulong = 0, ulong = 0, ulong = 0);
135 private slots:
136 void initialize ();
137 signals:
141
142 void windowNameChanged (ulong);
143 void windowIconChanged (ulong);
145 void windowStateChanged (ulong);
147 };
148}
void activeWindowChanged()
void windowIconChanged(ulong)
XWrapper(xcb_connection_t *, Display *, PrivateCtor)
Definition xwrapper.cpp:35
void windowNameChanged(ulong)
void windowDesktopChanged(ulong)
void windowActionsChanged(ulong)
void windowStateChanged(ulong)
@ Normal
Standard priority.
#define UTIL_X11_API
Definition x11config.h:16
union _XEvent XEvent
Definition xwrapper.h:30
struct _XDisplay Display
Definition xwrapper.h:27
unsigned long Window
Definition xwrapper.h:28