… | |
… | |
82 | delete obj; |
82 | delete obj; |
83 | } |
83 | } |
84 | } |
84 | } |
85 | |
85 | |
86 | template<class T> |
86 | template<class T> |
87 | refcache<T>::~refcache () |
87 | void refcache<T>::clear () |
88 | { |
88 | { |
89 | while (this->size ()) |
89 | while (this->size ()) |
90 | put (*this->begin ()); |
90 | put (*this->begin ()); |
91 | } |
91 | } |
92 | |
92 | |
… | |
… | |
143 | { |
143 | { |
144 | } |
144 | } |
145 | |
145 | |
146 | bool rxvt_display::init () |
146 | bool rxvt_display::init () |
147 | { |
147 | { |
|
|
148 | #ifdef LOCAL_X_IS_UNIX |
|
|
149 | if (id[0] == ':') |
|
|
150 | { |
|
|
151 | val = rxvt_malloc (5 + strlen (id) + 1); |
|
|
152 | strcpy (val, "unix/"); |
|
|
153 | strcat (val, id); |
|
|
154 | display = XOpenDisplay (val); |
|
|
155 | printf ("OD %s => %p\n", val, display);//D |
|
|
156 | free (val); |
|
|
157 | } |
|
|
158 | else |
|
|
159 | #endif |
|
|
160 | display = 0; |
|
|
161 | |
|
|
162 | if (!display) |
148 | display = XOpenDisplay (id); |
163 | display = XOpenDisplay (id); |
|
|
164 | printf ("O2 %s => %p\n", id, display);//D |
149 | |
165 | |
150 | if (!display) |
166 | if (!display) |
151 | return false; |
167 | return false; |
152 | |
168 | |
153 | screen = DefaultScreen (display); |
169 | screen = DefaultScreen (display); |
… | |
… | |
166 | sockaddr_un sa; |
182 | sockaddr_un sa; |
167 | socklen_t sl = sizeof (sa); |
183 | socklen_t sl = sizeof (sa); |
168 | |
184 | |
169 | if (!getsockname (fd, (sockaddr *)&sa, &sl)) |
185 | if (!getsockname (fd, (sockaddr *)&sa, &sl)) |
170 | is_local = sa.sun_family == AF_LOCAL; |
186 | is_local = sa.sun_family == AF_LOCAL; |
|
|
187 | #endif |
|
|
188 | |
|
|
189 | #ifdef POINTER_BLANK |
|
|
190 | XColor blackcolour; |
|
|
191 | blackcolour.red = 0; |
|
|
192 | blackcolour.green = 0; |
|
|
193 | blackcolour.blue = 0; |
|
|
194 | Font f = XLoadFont (display, "fixed"); |
|
|
195 | blank_cursor = XCreateGlyphCursor (display, f, f, ' ', ' ', |
|
|
196 | &blackcolour, &blackcolour); |
|
|
197 | XUnloadFont (display, f); |
171 | #endif |
198 | #endif |
172 | |
199 | |
173 | #ifdef PREFER_24BIT |
200 | #ifdef PREFER_24BIT |
174 | /* |
201 | /* |
175 | * If depth is not 24, look for a 24bit visual. |
202 | * If depth is not 24, look for a 24bit visual. |
… | |
… | |
203 | } |
230 | } |
204 | |
231 | |
205 | rxvt_display::~rxvt_display () |
232 | rxvt_display::~rxvt_display () |
206 | { |
233 | { |
207 | x_ev.stop (); |
234 | x_ev.stop (); |
|
|
235 | #ifdef USE_XIM |
|
|
236 | xims.clear (); |
|
|
237 | #endif |
208 | |
238 | |
209 | if (display) |
239 | if (display) |
210 | XCloseDisplay (display); |
240 | XCloseDisplay (display); |
211 | } |
241 | } |
212 | |
242 | |
… | |
… | |
217 | (*i)->call (); |
247 | (*i)->call (); |
218 | } |
248 | } |
219 | |
249 | |
220 | void rxvt_display::im_change_check () |
250 | void rxvt_display::im_change_check () |
221 | { |
251 | { |
222 | // make sure we only call im_change_cb when a new input method |
252 | // try to only call im_change_cb when a new input method |
223 | // registers, as xlib crashes due to a race otherwise. |
253 | // registers, as xlib crashes due to a race otherwise. |
224 | Atom actual_type, *atoms; |
254 | Atom actual_type, *atoms; |
225 | int actual_format; |
255 | int actual_format; |
226 | unsigned long nitems, bytes_after; |
256 | unsigned long nitems, bytes_after; |
227 | |
257 | |
… | |
… | |
270 | } |
300 | } |
271 | #endif |
301 | #endif |
272 | } |
302 | } |
273 | while (XEventsQueued (display, QueuedAlready)); |
303 | while (XEventsQueued (display, QueuedAlready)); |
274 | |
304 | |
275 | flush (); |
305 | XFlush (display); |
276 | } |
306 | } |
277 | |
307 | |
278 | void rxvt_display::flush () |
308 | void rxvt_display::flush () |
279 | { |
309 | { |
280 | for (;;) |
310 | if (XEventsQueued (display, QueuedAlready)) |
281 | { |
311 | x_cb (x_ev, EVENT_READ); |
282 | if (!XPending (display)) |
|
|
283 | break; |
|
|
284 | |
312 | |
285 | x_cb (x_ev, 0); |
313 | XFlush (display); |
286 | } |
|
|
287 | } |
314 | } |
288 | |
315 | |
289 | void rxvt_display::reg (xevent_watcher *w) |
316 | void rxvt_display::reg (xevent_watcher *w) |
290 | { |
317 | { |
291 | xw.push_back (w); |
318 | xw.push_back (w); |
… | |
… | |
338 | return xim; |
365 | return xim; |
339 | } |
366 | } |
340 | |
367 | |
341 | void rxvt_display::put_xim (rxvt_xim *xim) |
368 | void rxvt_display::put_xim (rxvt_xim *xim) |
342 | { |
369 | { |
|
|
370 | #if XLIB_IS_RACEFREE |
343 | xims.put (xim); |
371 | xims.put (xim); |
|
|
372 | #endif |
344 | } |
373 | } |
345 | #endif |
374 | #endif |
346 | |
375 | |
347 | Atom rxvt_display::atom (const char *name) |
376 | Atom rxvt_display::atom (const char *name) |
348 | { |
377 | { |