-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathManager.hpp
More file actions
118 lines (97 loc) · 2.5 KB
/
Manager.hpp
File metadata and controls
118 lines (97 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#pragma once
#include "Geometry.hpp"
#include <X11/Xlib.h>
#include <map>
#include <vector>
#include <cstdint>
struct MonitorCfg
{
std::string name;
int screen;
std::string connector;
};
struct Monitor
{
const MonitorCfg& cfg;
Rect r;
Window root;
Point absOrigin;
Window gridDraw;
unsigned gridX;
unsigned gridY;
};
struct Root
{
int screen;
Point absOrigin;
};
struct Client
{
Window client;
Window root;
Rect preMax;
bool ign;
Point absOrigin;
};
struct Drag
{
Window w = 0;
int xR, yR;
int x, y;
int width, height;
int btn;
DIR dirVert;
DIR dirHorz;
};
class Manager
{
public:
Manager(const std::string& display,
const std::map<int,Point>& screens,
const std::string& screenshotDir,
const std::map<std::string,MonitorCfg>& monitorCfg);
~Manager();
bool init();
void run();
private:
// X server events
void onReq_Map(const XMapRequestEvent& e);
void onNot_Unmap(const XUnmapEvent& e);
void onReq_Configure(const XConfigureRequestEvent& e);
void onNot_Motion(const XButtonEvent& e);
void handleFocusChange(const XFocusChangeEvent& e, bool in);
void onKeyPress(const XKeyEvent& e);
void onBtnPress(const XButtonEvent& e);
void onClientMessage(const XClientMessageEvent& e);
// Keypress handlers
void onKeyTerminal(const XKeyEvent& e);
void onKeyMoveMonitor(const XKeyEvent& e);
void onKeyMoveFocus(const XKeyEvent& e);
void onKeyMaximize(const XKeyEvent& e);
void onKeyUnmaximize(const XKeyEvent& e);
void onKeyClose(const XKeyEvent& e);
void onKeyLauncher(const XKeyEvent& e);
void onKeyScreenshot(const XKeyEvent& e);
void onKeyGrid(const XKeyEvent& e);
void onKeyGridActive(const XKeyEvent& e);
void onKeySnapGrid(const XKeyEvent& e);
void onKeyMoveGridLoc(const XKeyEvent& e);
void onKeyMoveGridSize(const XKeyEvent& e);
// Misc
void addClient(Window w, bool checkIgn);
void switchFocus(Window w);
void snapGrid(Window w, Rect r);
void drawGrid(Monitor* mon, bool active);
Window getNextWindowInDir(DIR dir, Window w);
const std::string& _argDisp;
const std::map<int,Point>& _argScreens;
const std::string& _argScreenshotDir;
const std::map<std::string,MonitorCfg>& _argMonitorCfg;
Display* _disp = nullptr;
std::map<Window, Client> _clients;
std::map<Window, Root> _roots;
std::vector<Monitor> _monitors;
Drag _drag = {};
bool _gridActive = false;
Window _lastFocus = 0;
};