|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+#include "windowhelper.hpp"
|
|
|
2
|
+
|
|
|
3
|
+glm::vec4 getWindowGeometry( Window win, bool removeDecoration ) {
|
|
|
4
|
+ XWindowAttributes attr;
|
|
|
5
|
+ XGetWindowAttributes( x11->display, win, &attr );
|
|
|
6
|
+ unsigned int width = attr.width;
|
|
|
7
|
+ unsigned int height = attr.height;
|
|
|
8
|
+ unsigned int border = attr.border_width;
|
|
|
9
|
+ int x, y;
|
|
|
10
|
+ Window junk;
|
|
|
11
|
+ XTranslateCoordinates( x11->display, win, attr.root, -attr.border_width, -attr.border_width, &x, &y, &junk );
|
|
|
12
|
+ if ( !removeDecoration ) {
|
|
|
13
|
+ width += border*2;
|
|
|
14
|
+ height += border*2;
|
|
|
15
|
+ return glm::vec4( x, y, width, height );
|
|
|
16
|
+ }
|
|
|
17
|
+ // This is required to be defined by the window manager, so we can assume it exists.
|
|
|
18
|
+ Atom actual_type;
|
|
|
19
|
+ int actual_format;
|
|
|
20
|
+ unsigned long nitems, bytes_after;
|
|
|
21
|
+ unsigned char *data;
|
|
|
22
|
+ int result = XGetWindowProperty(x11->display, win,
|
|
|
23
|
+ XInternAtom(x11->display, "_NET_FRAME_EXTENTS", true),
|
|
|
24
|
+ 0, 4, False, AnyPropertyType,
|
|
|
25
|
+ &actual_type, &actual_format, &nitems, &bytes_after, &data);
|
|
|
26
|
+ if ( result == Success ) {
|
|
|
27
|
+ // Make sure we got the data we expect...
|
|
|
28
|
+ if ((nitems == 4) && (bytes_after == 0)) {
|
|
|
29
|
+ x += (int)data[0];
|
|
|
30
|
+ width -= (int)data[1];
|
|
|
31
|
+ y += (int)data[2];
|
|
|
32
|
+ height -= (int)data[3];
|
|
|
33
|
+ }
|
|
|
34
|
+ }
|
|
|
35
|
+ return glm::vec4( x, y, width, height );
|
|
|
36
|
+}
|