… | |
… | |
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 | free (val); |
|
|
156 | } |
|
|
157 | else |
|
|
158 | display = 0; |
|
|
159 | #endif |
|
|
160 | |
|
|
161 | if (!display) |
148 | display = XOpenDisplay (id); |
162 | display = XOpenDisplay (id); |
149 | |
163 | |
150 | if (!display) |
164 | if (!display) |
151 | return false; |
165 | return false; |
152 | |
166 | |
153 | screen = DefaultScreen (display); |
167 | screen = DefaultScreen (display); |
… | |
… | |
166 | sockaddr_un sa; |
180 | sockaddr_un sa; |
167 | socklen_t sl = sizeof (sa); |
181 | socklen_t sl = sizeof (sa); |
168 | |
182 | |
169 | if (!getsockname (fd, (sockaddr *)&sa, &sl)) |
183 | if (!getsockname (fd, (sockaddr *)&sa, &sl)) |
170 | is_local = sa.sun_family == AF_LOCAL; |
184 | is_local = sa.sun_family == AF_LOCAL; |
|
|
185 | #endif |
|
|
186 | |
|
|
187 | #ifdef POINTER_BLANK |
|
|
188 | XColor blackcolour; |
|
|
189 | blackcolour.red = 0; |
|
|
190 | blackcolour.green = 0; |
|
|
191 | blackcolour.blue = 0; |
|
|
192 | Font f = XLoadFont (display, "fixed"); |
|
|
193 | blank_cursor = XCreateGlyphCursor (display, f, f, ' ', ' ', |
|
|
194 | &blackcolour, &blackcolour); |
|
|
195 | XUnloadFont (display, f); |
171 | #endif |
196 | #endif |
172 | |
197 | |
173 | #ifdef PREFER_24BIT |
198 | #ifdef PREFER_24BIT |
174 | /* |
199 | /* |
175 | * If depth is not 24, look for a 24bit visual. |
200 | * If depth is not 24, look for a 24bit visual. |
… | |
… | |
203 | } |
228 | } |
204 | |
229 | |
205 | rxvt_display::~rxvt_display () |
230 | rxvt_display::~rxvt_display () |
206 | { |
231 | { |
207 | x_ev.stop (); |
232 | x_ev.stop (); |
|
|
233 | #ifdef USE_XIM |
|
|
234 | xims.clear (); |
|
|
235 | #endif |
208 | |
236 | |
209 | if (display) |
237 | if (display) |
210 | XCloseDisplay (display); |
238 | XCloseDisplay (display); |
211 | } |
239 | } |
212 | |
240 | |
… | |
… | |
217 | (*i)->call (); |
245 | (*i)->call (); |
218 | } |
246 | } |
219 | |
247 | |
220 | void rxvt_display::im_change_check () |
248 | void rxvt_display::im_change_check () |
221 | { |
249 | { |
222 | // make sure we only call im_change_cb when a new input method |
250 | // try to only call im_change_cb when a new input method |
223 | // registers, as xlib crashes due to a race otherwise. |
251 | // registers, as xlib crashes due to a race otherwise. |
224 | Atom actual_type, *atoms; |
252 | Atom actual_type, *atoms; |
225 | int actual_format; |
253 | int actual_format; |
226 | unsigned long nitems, bytes_after; |
254 | unsigned long nitems, bytes_after; |
227 | |
255 | |
… | |
… | |
270 | } |
298 | } |
271 | #endif |
299 | #endif |
272 | } |
300 | } |
273 | while (XEventsQueued (display, QueuedAlready)); |
301 | while (XEventsQueued (display, QueuedAlready)); |
274 | |
302 | |
275 | flush (); |
303 | XFlush (display); |
276 | } |
304 | } |
277 | |
305 | |
278 | void rxvt_display::flush () |
306 | void rxvt_display::flush () |
279 | { |
307 | { |
|
|
308 | if (XEventsQueued (display, QueuedAlready)) |
|
|
309 | x_cb (x_ev, EVENT_READ); |
|
|
310 | |
280 | XFlush (display); |
311 | XFlush (display); |
281 | } |
312 | } |
282 | |
313 | |
283 | void rxvt_display::reg (xevent_watcher *w) |
314 | void rxvt_display::reg (xevent_watcher *w) |
284 | { |
315 | { |
… | |
… | |
332 | return xim; |
363 | return xim; |
333 | } |
364 | } |
334 | |
365 | |
335 | void rxvt_display::put_xim (rxvt_xim *xim) |
366 | void rxvt_display::put_xim (rxvt_xim *xim) |
336 | { |
367 | { |
|
|
368 | #if XLIB_IS_RACEFREE |
337 | xims.put (xim); |
369 | xims.put (xim); |
|
|
370 | #endif |
338 | } |
371 | } |
339 | #endif |
372 | #endif |
340 | |
373 | |
341 | Atom rxvt_display::atom (const char *name) |
374 | Atom rxvt_display::atom (const char *name) |
342 | { |
375 | { |