… | |
… | |
25 | #include <rxvtcolor.h> |
25 | #include <rxvtcolor.h> |
26 | |
26 | |
27 | #include <unistd.h> |
27 | #include <unistd.h> |
28 | #include <fcntl.h> |
28 | #include <fcntl.h> |
29 | |
29 | |
|
|
30 | #ifndef NO_SLOW_LINK_SUPPORT |
|
|
31 | # include <sys/socket.h> |
|
|
32 | # include <sys/un.h> |
|
|
33 | #endif |
|
|
34 | |
30 | class byteorder byteorder; |
35 | class byteorder byteorder; |
31 | |
36 | |
32 | byteorder::byteorder () |
37 | byteorder::byteorder () |
33 | { |
38 | { |
34 | union { |
39 | union { |
… | |
… | |
104 | |
109 | |
105 | ///////////////////////////////////////////////////////////////////////////// |
110 | ///////////////////////////////////////////////////////////////////////////// |
106 | |
111 | |
107 | #ifdef USE_XIM |
112 | #ifdef USE_XIM |
108 | static void |
113 | static void |
|
|
114 | #if XIMCB_PROTO_BROKEN |
|
|
115 | im_destroy_cb (XIC unused1, XPointer client_data, XPointer unused3) |
|
|
116 | #else |
109 | im_destroy_cb (XIM unused1, XPointer client_data, XPointer unused3) |
117 | im_destroy_cb (XIM unused1, XPointer client_data, XPointer unused3) |
|
|
118 | #endif |
110 | { |
119 | { |
111 | rxvt_xim *xim = (rxvt_xim *)client_data; |
120 | rxvt_xim *xim = (rxvt_xim *)client_data; |
112 | rxvt_display *display = xim->display; |
121 | rxvt_display *display = xim->display; |
113 | |
122 | |
114 | display->xims.erase (find (display->xims.begin (), display->xims.end (), xim)); |
123 | display->xims.erase (find (display->xims.begin (), display->xims.end (), xim)); |
… | |
… | |
160 | screen = DefaultScreen (display); |
169 | screen = DefaultScreen (display); |
161 | root = DefaultRootWindow (display); |
170 | root = DefaultRootWindow (display); |
162 | visual = DefaultVisual (display, screen); |
171 | visual = DefaultVisual (display, screen); |
163 | cmap = DefaultColormap (display, screen); |
172 | cmap = DefaultColormap (display, screen); |
164 | depth = DefaultDepth (display, screen); |
173 | depth = DefaultDepth (display, screen); |
|
|
174 | |
|
|
175 | int fd = XConnectionNumber (display); |
|
|
176 | |
|
|
177 | #ifndef NO_SLOW_LINK_SUPPORT |
|
|
178 | // try to detetc wether we have a local connection. |
|
|
179 | // assume unix domains socket == local, everything else not |
|
|
180 | // TODO: might want to check for inet/127.0.0.1 |
|
|
181 | is_local = 0; |
|
|
182 | sockaddr_un sa; |
|
|
183 | socklen_t sl = sizeof (sa); |
|
|
184 | |
|
|
185 | if (!getsockname (fd, (sockaddr *)&sa, &sl)) |
|
|
186 | is_local = sa.sun_family == AF_LOCAL; |
|
|
187 | #endif |
165 | |
188 | |
166 | #ifdef PREFER_24BIT |
189 | #ifdef PREFER_24BIT |
167 | /* |
190 | /* |
168 | * If depth is not 24, look for a 24bit visual. |
191 | * If depth is not 24, look for a 24bit visual. |
169 | */ |
192 | */ |
… | |
… | |
180 | visual, AllocNone); |
203 | visual, AllocNone); |
181 | } |
204 | } |
182 | } |
205 | } |
183 | #endif |
206 | #endif |
184 | |
207 | |
185 | int fd = XConnectionNumber (display); |
|
|
186 | x_ev.start (fd, EVENT_READ); |
208 | x_ev.start (fd, EVENT_READ); |
187 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
209 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
188 | |
210 | |
189 | XSelectInput (display, root, PropertyChangeMask); |
211 | XSelectInput (display, root, PropertyChangeMask); |
190 | #ifdef USE_XIM |
212 | #ifdef USE_XIM |
… | |
… | |
243 | |
265 | |
244 | void rxvt_display::flush () |
266 | void rxvt_display::flush () |
245 | { |
267 | { |
246 | for (;;) |
268 | for (;;) |
247 | { |
269 | { |
248 | XFlush (display); |
|
|
249 | |
|
|
250 | if (!XPending (display)) |
270 | if (!XPending (display)) |
251 | break; |
271 | break; |
252 | |
272 | |
253 | x_cb (x_ev, 0); |
273 | x_cb (x_ev, 0); |
254 | } |
274 | } |
… | |
… | |
407 | #else |
427 | #else |
408 | XFreeColors (display->display, display->cmap, &p, 1, AllPlanes); |
428 | XFreeColors (display->display, display->cmap, &p, 1, AllPlanes); |
409 | #endif |
429 | #endif |
410 | } |
430 | } |
411 | |
431 | |
|
|
432 | rxvt_color |
|
|
433 | rxvt_color::fade (rxvt_display *display, int percent) |
|
|
434 | { |
|
|
435 | unsigned short cr, cg, cb; |
|
|
436 | rxvt_color faded; |
|
|
437 | |
|
|
438 | get (display, cr, cg, cb); |
|
|
439 | faded.set (display, |
|
|
440 | cr * percent / 100, |
|
|
441 | cg * percent / 100, |
|
|
442 | cb * percent / 100); |
|
|
443 | |
|
|
444 | return faded; |
|
|
445 | } |
|
|
446 | |