… | |
… | |
2 | #include <rxvt.h> |
2 | #include <rxvt.h> |
3 | #include <rxvtcolor.h> |
3 | #include <rxvtcolor.h> |
4 | |
4 | |
5 | #include <unistd.h> |
5 | #include <unistd.h> |
6 | #include <fcntl.h> |
6 | #include <fcntl.h> |
|
|
7 | |
|
|
8 | class byteorder byteorder; |
|
|
9 | |
|
|
10 | byteorder::byteorder () |
|
|
11 | { |
|
|
12 | union { |
|
|
13 | uint32_t u; |
|
|
14 | uint8_t b[4]; |
|
|
15 | } w; |
|
|
16 | |
|
|
17 | w.b[0] = 0x11; |
|
|
18 | w.b[1] = 0x22; |
|
|
19 | w.b[2] = 0x33; |
|
|
20 | w.b[3] = 0x44; |
|
|
21 | |
|
|
22 | e = w.u; |
|
|
23 | } |
7 | |
24 | |
8 | refcounted::refcounted (const char *id) |
25 | refcounted::refcounted (const char *id) |
9 | { |
26 | { |
10 | this->id = STRDUP (id); |
27 | this->id = STRDUP (id); |
11 | } |
28 | } |
… | |
… | |
110 | } |
127 | } |
111 | |
128 | |
112 | bool rxvt_display::init () |
129 | bool rxvt_display::init () |
113 | { |
130 | { |
114 | display = XOpenDisplay (id); |
131 | display = XOpenDisplay (id); |
|
|
132 | |
|
|
133 | if (!display) |
|
|
134 | return false; |
115 | |
135 | |
116 | screen = DefaultScreen (display); |
136 | screen = DefaultScreen (display); |
117 | root = DefaultRootWindow (display); |
137 | root = DefaultRootWindow (display); |
118 | visual = DefaultVisual (display, screen); |
138 | visual = DefaultVisual (display, screen); |
119 | cmap = DefaultColormap (display, screen); |
139 | cmap = DefaultColormap (display, screen); |
… | |
… | |
152 | |
172 | |
153 | rxvt_display::~rxvt_display () |
173 | rxvt_display::~rxvt_display () |
154 | { |
174 | { |
155 | x_ev.stop (); |
175 | x_ev.stop (); |
156 | |
176 | |
|
|
177 | if (display) |
157 | XCloseDisplay (display); |
178 | XCloseDisplay (display); |
158 | } |
179 | } |
159 | |
180 | |
160 | void rxvt_display::im_change_cb () |
181 | void rxvt_display::im_change_cb () |
161 | { |
182 | { |
162 | for (im_watcher **i = imw.begin (); i != imw.end (); ++i) |
183 | for (im_watcher **i = imw.begin (); i != imw.end (); ++i) |
… | |
… | |
249 | } |
270 | } |
250 | |
271 | |
251 | void rxvt_display::put_xim (rxvt_xim *xim) |
272 | void rxvt_display::put_xim (rxvt_xim *xim) |
252 | { |
273 | { |
253 | xims.put (xim); |
274 | xims.put (xim); |
|
|
275 | } |
|
|
276 | |
|
|
277 | Atom rxvt_display::atom (const char *name) |
|
|
278 | { |
|
|
279 | return XInternAtom (display, name, False); |
254 | } |
280 | } |
255 | |
281 | |
256 | ///////////////////////////////////////////////////////////////////////////// |
282 | ///////////////////////////////////////////////////////////////////////////// |
257 | |
283 | |
258 | template refcache<rxvt_display>; |
284 | template refcache<rxvt_display>; |
… | |
… | |
339 | rxvt_color::free (rxvt_display *display) |
365 | rxvt_color::free (rxvt_display *display) |
340 | { |
366 | { |
341 | #if XFT |
367 | #if XFT |
342 | XftColorFree (display->display, display->visual, display->cmap, &c); |
368 | XftColorFree (display->display, display->visual, display->cmap, &c); |
343 | #else |
369 | #else |
344 | XFreeColors (display->display, display->cmap, &c, 1, AllPlanes); |
370 | XFreeColors (display->display, display->cmap, &p, 1, AllPlanes); |
345 | #endif |
371 | #endif |
346 | } |
372 | } |
347 | |
373 | |