-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwmhack.h
96 lines (87 loc) · 3.14 KB
/
wmhack.h
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
#include <iostream>
#include <unistd.h>
#include <X11/cursorfont.h>
#include <limits>
#include <list>
#include <vector>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xmd.h>
#include <X11/extensions/Xinerama.h>
#include <X11/Xmu/WinUtil.h>
struct X11Env;
struct Size {
unsigned width;
unsigned height;
};
struct Geometry {
Size size;
int x;
int y;
};
extern std::ostream & operator<<(std::ostream &os, const Geometry &m);
struct Range {
long start;
long end;
bool empty() { return start == end; }
bool aligned(long origin, long extent)
{ return !empty() && start < origin + extent && end >= origin; }
};
extern std::ostream & operator<<(std::ostream &os, const Range &m);
struct PartialStrut {
long left;
long right;
long top;
long bottom;
Range rleft;
Range rright;
Range rtop;
Range rbottom;
void box(const X11Env &x11, Geometry &g);
};
extern std::ostream & operator<<(std::ostream &os, const PartialStrut &m);
struct X11Env {
Display *display;
Window root;
Geometry rootGeom;
std::vector<Geometry> monitors;
X11Env(Display *display_);
Atom atom(const char *name) { return XInternAtom(display, name, False); }
Atom NetCurrentDesktop = atom("_NET_CURRENT_DESKTOP");
Atom NetActiveWindow = atom("_NET_ACTIVE_WINDOW");
Atom NetDesktopNames = atom("_NET_DESKTOP_NAMES");
Atom AWindow = atom("WINDOW");
Atom Cardinal = atom("CARDINAL");
Atom VisualId = atom("VISUALID");
Atom NetMoveResizeWindow = atom("_NET_MOVERESIZE_WINDOW");
Atom NetFrameExtents = atom("_NET_FRAME_EXTENTS");
Atom NetClientList = atom("_NET_CLIENT_LIST");
Atom NetWmStrut = atom("_NET_WM_STRUT");
Atom NetWmStrutPartial = atom("_NET_WM_STRUT_PARTIAL");
Atom NetWmStateFullscreen = atom("_NET_WM_STATE_FULLSCREEN");
Atom NetWmStateBelow = atom("_NET_WM_STATE_BELOW");
Atom NetWmStateAbove = atom("_NET_WM_STATE_ABOVE");
Atom NetWmState = atom("_NET_WM_STATE");
Atom NetWmDesktop = atom("_NET_WM_DESKTOP");
Atom NetWmStateAdd = atom("_NET_WM_STATE_ADD");
Atom NetWmStateMaximizedVert = atom("_NET_WM_STATE_MAXIMIZED_VERT");
Atom NetWmStateMaximizedHoriz = atom("_NET_WM_STATE_MAXIMIZED_HORZ");
Atom NetWmStateShaded = atom("_NET_WM_STATE_SHADED");
Atom NetWmOpacity = atom("_NET_WM_WINDOW_OPACITY");
Atom WorkDir = atom("_PME_WORKDIR");
void detectMonitors(); // Get the geometry of the monitors.
Geometry getGeometry(Window w) const;
Geometry getGeometry(Window w, Window *root) const;
void setGeometry(Window win, const Geometry &geom) const;
Window pick(); // pick a window on the display using the mouse.
Window active(); // find active window
enum StateUpdateAction { REMOVE = 0, ADD = 1, TOGGLE = 2 };
void updateState(Window win, const Atom toggle, StateUpdateAction update) const;
int monitorForWindow(Window); // find index of monitor on which a window lies.
long desktopForWindow(Window) const; // what desktop is a window on? returns -1 if no desktops.
operator Display *() const { return display; }
};