Mercurial > minori
annotate dep/animia/src/win/x11.cc @ 199:9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Tue, 02 Jan 2024 02:34:27 -0500 |
parents | bc1ae1810855 |
children | 58e81b42a0d6 |
rev | line source |
---|---|
157 | 1 #include "animia/win/x11.h" |
2 #include "animia/win.h" | |
3 #include "animia.h" | |
4 | |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
5 #include <X11/Xlib.h> |
157 | 6 #include <X11/Xutil.h> |
7 #include <X11/Xatom.h> // XA_* | |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
8 #ifdef HAVE_XRES |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
9 #include <X11/extensions/XRes.h> |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
10 #endif |
158
80d6b28eb29f
dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents:
157
diff
changeset
|
11 |
157 | 12 #include <cstdint> |
13 #include <string> | |
158
80d6b28eb29f
dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents:
157
diff
changeset
|
14 #include <set> |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
15 |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
16 /* The code for this is very fugly because X11 uses lots of generic type names |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
17 (i.e., Window, Display), so I have to use :: when defining vars to distinguish |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
18 between Animia's types and X11's types */ |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
19 |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
20 namespace animia::internal::x11 { |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
21 |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
22 /* specify that these are X types. */ |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
23 typedef ::Window XWindow; |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
24 typedef ::Display XDisplay; |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
25 typedef ::Atom XAtom; |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
26 |
157 | 27 /* should return UTF8_STRING or STRING */ |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
28 static bool GetWindowPropertyAsString(XDisplay* display, XWindow window, XAtom atom, std::string& result, XAtom reqtype = AnyPropertyType) { |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
29 int format; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
30 unsigned long leftover_bytes, num_of_items; |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
31 XAtom type; |
157 | 32 unsigned char* data; |
166 | 33 |
34 int status = ::XGetWindowProperty(display, window, atom, 0L, (~0L), False, reqtype, | |
35 &type, &format, &num_of_items, &leftover_bytes, &data); | |
36 if (status != Success || !(reqtype == AnyPropertyType || type == reqtype) || !num_of_items) | |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
37 return false; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
38 |
157 | 39 result = std::string((char*)data, num_of_items); |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
40 |
166 | 41 ::XFree(data); |
42 | |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
43 return true; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
44 } |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
45 |
157 | 46 /* this should return CARDINAL, a 32-bit integer */ |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
47 static bool GetWindowPID(XDisplay* display, XWindow window, pid_t& result) { |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
48 #ifdef HAVE_XRES |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
49 { |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
50 long num_ids; |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
51 XResClientIdValue *client_ids; |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
52 XResClientIdSpec spec = { |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
53 .client = window, |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
54 .mask = XRES_CLIENT_ID_PID_MASK |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
55 }; |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
56 |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
57 ::XResQueryClientIds(display, 1, &spec, &num_ids, &client_ids); |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
58 |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
59 for (long i = 0; i < num_ids; i++) { |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
60 if (client_ids[i].spec.mask == XRES_CLIENT_ID_PID_MASK) { |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
61 result = ::XResGetClientPid(&client_ids[i]); |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
62 ::XResClientIdsDestroy(num_ids, client_ids); |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
63 return true; |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
64 } |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
65 } |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
66 |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
67 ::XResClientIdsDestroy(num_ids, client_ids); |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
68 |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
69 return false; |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
70 } |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
71 #endif |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
72 |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
73 int format; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
74 unsigned long leftover_bytes, num_of_items; |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
75 XAtom atom = ::XInternAtom(display, "_NET_WM_PID", False), type; |
157 | 76 unsigned char* data; |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
77 |
166 | 78 int status = ::XGetWindowProperty(display, window, atom, 0L, (~0L), False, XA_CARDINAL, |
79 &type, &format, &num_of_items, &leftover_bytes, &data); | |
80 if (status != Success || type != XA_CARDINAL || num_of_items < 1) | |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
81 return false; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
82 |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
83 result = static_cast<pid_t>(*reinterpret_cast<uint32_t*>(data)); |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
84 |
166 | 85 ::XFree(data); |
86 | |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
87 return true; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
88 } |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
89 |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
90 static bool FetchName(XDisplay* display, XWindow window, std::string& result) { |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
91 /* TODO: Check if XInternAtom created None or not... */ |
158
80d6b28eb29f
dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents:
157
diff
changeset
|
92 if (GetWindowPropertyAsString(display, window, ::XInternAtom(display, "_NET_WM_NAME", False), |
166 | 93 result, ::XInternAtom(display, "UTF8_STRING", False))) |
94 return true; | |
95 | |
96 if (GetWindowPropertyAsString(display, window, ::XInternAtom(display, "WM_NAME", False), | |
97 result, XA_STRING)) | |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
98 return true; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
99 |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
100 /* Fallback to XGetWMName() */ |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
101 XTextProperty text; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
102 |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
103 { |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
104 int status = ::XGetWMName(display, window, &text); |
157 | 105 if (!status || !text.value || !text.nitems) |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
106 return false; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
107 } |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
108 |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
109 char** list; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
110 |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
111 { |
157 | 112 int count; |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
113 |
157 | 114 int status = ::XmbTextPropertyToTextList(display, &text, &list, &count); |
166 | 115 if (status != Success || !count || !*list) |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
116 return false; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
117 } |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
118 |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
119 ::XFree(text.value); |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
120 |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
121 result = *list; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
122 |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
123 ::XFreeStringList(list); |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
124 |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
125 return true; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
126 } |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
127 |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
128 static bool WalkWindows(XDisplay* display, std::set<XWindow>& children, const std::set<XWindow>& windows) { |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
129 /* This can take a VERY long time if many windows are open. */ |
166 | 130 if (windows.empty()) |
131 return false; | |
132 | |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
133 for (const XWindow& window : windows) { |
166 | 134 unsigned int num_children = 0; |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
135 XWindow* children_arr = nullptr; |
166 | 136 |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
137 XWindow root_return; |
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
138 XWindow parent_return; |
166 | 139 |
140 int status = ::XQueryTree(display, window, &root_return, &parent_return, &children_arr, &num_children); | |
167
31735c8592bc
dep/animia: make x11 window walking actually work
paper@DavesDouble.local
parents:
166
diff
changeset
|
141 if (!status || !children_arr) |
166 | 142 continue; |
143 | |
144 if (num_children < 1) { | |
145 ::XFree(children_arr); | |
146 continue; | |
147 } | |
148 | |
149 for (int i = 0; i < num_children; i++) | |
150 if (!children.count(children_arr[i])) | |
151 children.insert(children_arr[i]); | |
152 | |
153 ::XFree(children_arr); | |
154 | |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
155 std::set<XWindow> children_children; |
166 | 156 |
167
31735c8592bc
dep/animia: make x11 window walking actually work
paper@DavesDouble.local
parents:
166
diff
changeset
|
157 if (WalkWindows(display, children_children, children)) |
166 | 158 children.insert(children_children.begin(), children_children.end()); |
159 } | |
160 | |
161 return true; | |
162 } | |
163 | |
198
bc1ae1810855
dep/animia: switch from using classes to global functions
Paper <mrpapersonic@gmail.com>
parents:
191
diff
changeset
|
164 bool EnumerateWindows(window_proc_t window_proc) { |
158
80d6b28eb29f
dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents:
157
diff
changeset
|
165 if (!window_proc) |
80d6b28eb29f
dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents:
157
diff
changeset
|
166 return false; |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
167 |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
168 XDisplay* display = ::XOpenDisplay(nullptr); |
166 | 169 if (!display) |
170 return false; | |
171 | |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
172 XWindow root = ::XDefaultRootWindow(display); |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
173 |
199
9f3534f6b8c4
dep/animia: initial Wayland support, drop non-working kvm fd plugin
Paper <mrpapersonic@gmail.com>
parents:
198
diff
changeset
|
174 std::set<XWindow> windows; |
166 | 175 WalkWindows(display, windows, {root}); |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
176 |
166 | 177 for (const auto& window : windows) { |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
178 Window win; |
158
80d6b28eb29f
dep/animia: fix most X11 stuff
Paper <mrpapersonic@gmail.com>
parents:
157
diff
changeset
|
179 win.id = window; |
157 | 180 { |
181 ::XClassHint* hint = ::XAllocClassHint(); | |
182 if (::XGetClassHint(display, window, hint)) { | |
183 win.class_name = hint->res_class; | |
184 ::XFree(hint); | |
185 } | |
186 } | |
166 | 187 FetchName(display, window, win.text); |
156
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
188 |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
189 Process proc; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
190 GetWindowPID(display, window, proc.pid); |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
191 |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
192 if (!window_proc(proc, win)) |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
193 return false; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
194 } |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
195 |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
196 return true; |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
197 } |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
198 |
cdf79282d647
dep/animia: add VERY early x11 window stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
199 } |