@@ -8,10 +8,9 @@ extern "C" {
8
8
WindowHandle getActiveWindow () {
9
9
Display* xServer = XGetMainDisplay ();
10
10
Window window;
11
- if (xServer != nullptr ) {
11
+ if (xServer != NULL ) {
12
12
int32_t revertToWindow;
13
13
XGetInputFocus (xServer, &window, &revertToWindow);
14
- XCloseMainDisplay ();
15
14
return window;
16
15
}
17
16
return -1 ;
@@ -20,7 +19,7 @@ WindowHandle getActiveWindow() {
20
19
std::vector<WindowHandle> getWindows () {
21
20
Display* xServer = XGetMainDisplay ();
22
21
std::vector<WindowHandle> windowHandles;
23
- if (xServer != nullptr ) {
22
+ if (xServer != NULL ) {
24
23
Window defaultRootWindow = DefaultRootWindow (xServer);
25
24
Window rootWindow;
26
25
Window parentWindow;
@@ -33,37 +32,34 @@ std::vector<WindowHandle> getWindows() {
33
32
windowHandles.push_back (windowList[idx]);
34
33
}
35
34
}
36
- XCloseMainDisplay ();
37
35
}
38
36
return windowHandles;
39
37
}
40
38
41
39
std::string getWindowTitle (const WindowHandle windowHandle) {
42
40
Display* xServer = XGetMainDisplay ();
43
41
std::string windowName = " " ;
44
- if (xServer != nullptr ) {
42
+ if (xServer != NULL ) {
45
43
XTextProperty windowTextProperty;
46
44
Status getWMNameResult = XGetWMName (xServer, windowHandle, &windowTextProperty);
47
45
if (getWMNameResult > 0 ) {
48
46
windowName = std::string (reinterpret_cast <const char *>(windowTextProperty.value ));
49
47
}
50
- XCloseMainDisplay ();
51
48
}
52
- return windowName;
49
+ return windowName;
53
50
}
54
51
55
52
MMRect getWindowRect (const WindowHandle windowHandle) {
56
53
Display* xServer = XGetMainDisplay ();
57
54
MMRect windowRect = MMRectMake (0 , 0 , 0 , 0 );
58
- if (xServer != nullptr ) {
55
+ if (xServer != NULL ) {
59
56
Window rootWindow;
60
57
int32_t x, y;
61
58
uint32_t width, height, border_width, border_height;
62
59
Status getXGeometryResult = XGetGeometry (xServer, windowHandle, &rootWindow, &x, &y, &width, &height, &border_width, &border_height);
63
60
if (getXGeometryResult > 0 ) {
64
61
windowRect = MMRectMake (x, y, width, height);
65
62
}
66
- XCloseMainDisplay ();
67
63
}
68
64
return windowRect;
69
- }
65
+ }
0 commit comments