LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
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 <QX11Info>
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 
22 class QIcon;
23 class QWidget;
24 class QRect;
25 
26 using Window = unsigned long;
27 #define _XTYPEDEF_XID
28 
29 using XEvent = union _XEvent;
30 
31 namespace LC::Util
32 {
33  class UTIL_X11_API XWrapper : public QObject
34  , public QAbstractNativeEventFilter
35  {
36  Q_OBJECT
37 
38  Display *Display_;
39  Window AppWin_;
40 
41  QHash<QByteArray, Atom> Atoms_;
42 
43  XWrapper ();
44  public:
45  enum class Layer
46  {
47  Top,
48  Bottom,
49  Normal
50  };
51 
52  static XWrapper& Instance ();
53 
54  Display* GetDisplay () const;
55  Window GetRootWindow () const;
56 
57  bool nativeEventFilter (const QByteArray& eventType, void *message, long *result) override;
58 
59  void Sync ();
60 
61  QList<Window> GetWindows ();
62  QString GetWindowTitle (Window);
63  QIcon GetWindowIcon (Window);
64  WinStateFlags GetWindowState (Window);
65  AllowedActionFlags GetWindowActions (Window);
66 
67  Window GetActiveApp ();
68 
69  bool IsLCWindow (Window);
70  bool ShouldShow (Window);
71 
72  void Subscribe (Window);
73 
74  void SetStrut (QWidget*, Qt::ToolBarArea);
75  void ClearStrut (QWidget*);
76  void SetStrut (Window wid,
77  ulong left, ulong right, ulong top, ulong bottom,
78  ulong leftStartY, ulong leftEndY,
79  ulong rightStartY, ulong rightEndY,
80  ulong topStartX, ulong topEndX,
81  ulong bottomStartX, ulong bottomEndX);
82 
83  void RaiseWindow (Window);
84  void MinimizeWindow (Window);
85  void MaximizeWindow (Window);
86  void UnmaximizeWindow (Window);
87  void ShadeWindow (Window);
88  void UnshadeWindow (Window);
89  void MoveWindowTo (Window, Layer);
90  void CloseWindow (Window);
91 
92  void ResizeWindow (Window, int, int);
93 
94  int GetDesktopCount ();
95  int GetCurrentDesktop ();
96  void SetCurrentDesktop (int);
97  QStringList GetDesktopNames ();
98  QString GetDesktopName (int, const QString& = QString ());
99  int GetWindowDesktop (Window);
100  void MoveWindowToDesktop (Window, int);
101 
102  QRect GetAvailableGeometry (int screen = -1);
103  QRect GetAvailableGeometry (QWidget*);
104 
113  Atom GetAtom (std::string_view str);
114  private:
115  template<typename T>
116  void HandlePropNotify (T);
117 
118  template<typename Flag>
119  QFlags<Flag> GetFlagsList (Window wid, Atom property, const QHash<Atom, Flag>& atom2flag) const;
120 
121  Window GetActiveWindow ();
122 
123  bool GetWinProp (Window, Atom, ulong*, uchar**, Atom = static_cast<Atom> (0)) const;
124  bool GetRootWinProp (Atom, ulong*, uchar**, Atom = static_cast<Atom> (0)) const;
125  QList<Atom> GetWindowType (Window);
126 
127  bool SendMessage (Window, Atom, ulong, ulong = 0, ulong = 0, ulong = 0, ulong = 0);
128  private slots:
129  void initialize ();
130  signals:
131  void windowListChanged ();
132  void activeWindowChanged ();
133  void desktopChanged ();
134 
135  void windowNameChanged (ulong);
136  void windowIconChanged (ulong);
137  void windowDesktopChanged (ulong);
138  void windowStateChanged (ulong);
139  void windowActionsChanged (ulong);
140  };
141 }
LC::Util::QueuePriority::Normal
@ Normal
Standard priority.
QList
Definition: ianrulesstorage.h:14
XEvent
union _XEvent XEvent
Definition: xwrapper.h:29
LC::Util
Definition: icoreproxy.h:33
winflags.h
LC::Util::XWrapper
Definition: xwrapper.h:33
LC::Util::XWrapper::Layer
Layer
Definition: xwrapper.h:45
Window
unsigned long Window
Definition: xwrapper.h:26
UTIL_X11_API
#define UTIL_X11_API
Definition: x11config.h:16
x11config.h