… | |
… | |
177 | bool |
177 | bool |
178 | rxvt_xim::ref_init () |
178 | rxvt_xim::ref_init () |
179 | { |
179 | { |
180 | display = GET_R->display; //HACK: TODO |
180 | display = GET_R->display; //HACK: TODO |
181 | |
181 | |
182 | xim = XOpenIM (display->display, NULL, NULL, NULL); |
182 | xim = XOpenIM (display->display, 0, 0, 0); |
183 | |
183 | |
184 | if (!xim) |
184 | if (!xim) |
185 | return false; |
185 | return false; |
186 | |
186 | |
187 | XIMCallback ximcallback; |
187 | XIMCallback ximcallback; |
188 | ximcallback.client_data = (XPointer)this; |
188 | ximcallback.client_data = (XPointer)this; |
189 | ximcallback.callback = im_destroy_cb; |
189 | ximcallback.callback = im_destroy_cb; |
190 | |
190 | |
191 | XSetIMValues (xim, XNDestroyCallback, &ximcallback, NULL); |
191 | XSetIMValues (xim, XNDestroyCallback, &ximcallback, 0); |
192 | |
192 | |
193 | return true; |
193 | return true; |
194 | } |
194 | } |
195 | |
195 | |
196 | rxvt_xim::~rxvt_xim () |
196 | rxvt_xim::~rxvt_xim () |
… | |
… | |
248 | , selection_owner (0) |
248 | , selection_owner (0) |
249 | { |
249 | { |
250 | } |
250 | } |
251 | |
251 | |
252 | XrmDatabase |
252 | XrmDatabase |
253 | rxvt_display::get_resources () |
253 | rxvt_display::get_resources (bool refresh) |
254 | { |
254 | { |
255 | char *homedir = (char *)getenv ("HOME"); |
255 | char *homedir = (char *)getenv ("HOME"); |
256 | char fname[1024]; |
256 | char fname[1024]; |
257 | |
257 | |
258 | /* |
258 | /* |
259 | * get resources using the X library function |
259 | * get resources using the X library function |
260 | */ |
260 | */ |
261 | char *displayResource, *xe; |
261 | char *displayResource, *xe; |
262 | XrmDatabase database, rdb1; |
262 | XrmDatabase rdb1, database = 0; |
263 | |
|
|
264 | database = NULL; |
|
|
265 | |
263 | |
266 | // for ordering, see for example http://www.faqs.org/faqs/Xt-FAQ/ Subject: 20 |
264 | // for ordering, see for example http://www.faqs.org/faqs/Xt-FAQ/ Subject: 20 |
267 | |
265 | |
268 | // 6. System wide per application default file. |
266 | // 6. System wide per application default file. |
269 | |
267 | |
… | |
… | |
279 | // 5. User's per application default file. |
277 | // 5. User's per application default file. |
280 | // none |
278 | // none |
281 | |
279 | |
282 | // 4. User's defaults file. |
280 | // 4. User's defaults file. |
283 | /* Get any Xserver defaults */ |
281 | /* Get any Xserver defaults */ |
|
|
282 | if (refresh) |
|
|
283 | { |
|
|
284 | // fucking xlib keeps a copy of the rm string |
|
|
285 | Atom actual_type; |
|
|
286 | int actual_format; |
|
|
287 | unsigned long nitems, nremaining; |
|
|
288 | char *val = 0; |
|
|
289 | |
|
|
290 | #if XLIB_ILLEGAL_ACCESS |
|
|
291 | if (display->xdefaults) |
|
|
292 | XFree (display->xdefaults); |
|
|
293 | #endif |
|
|
294 | |
|
|
295 | if (XGetWindowProperty (display, root, XA_RESOURCE_MANAGER, |
|
|
296 | 0L, 100000000L, False, |
|
|
297 | XA_STRING, &actual_type, &actual_format, |
|
|
298 | &nitems, &nremaining, |
|
|
299 | (unsigned char **)&val) == Success |
|
|
300 | && actual_type == XA_STRING |
|
|
301 | && actual_format == 8) |
|
|
302 | displayResource = val; |
|
|
303 | else |
|
|
304 | { |
|
|
305 | displayResource = 0; |
|
|
306 | if (val) |
|
|
307 | XFree(val); |
|
|
308 | } |
|
|
309 | |
|
|
310 | #if XLIB_ILLEGAL_ACCESS |
|
|
311 | display->xdefaults = displayResource; |
|
|
312 | #endif |
|
|
313 | } |
|
|
314 | else |
284 | displayResource = XResourceManagerString (display); |
315 | displayResource = XResourceManagerString (display); |
285 | |
316 | |
286 | if (displayResource != NULL) |
317 | if (displayResource) |
287 | { |
318 | { |
288 | if ((rdb1 = XrmGetStringDatabase (displayResource))) |
319 | if ((rdb1 = XrmGetStringDatabase (displayResource))) |
289 | XrmMergeDatabases (rdb1, &database); |
320 | XrmMergeDatabases (rdb1, &database); |
290 | } |
321 | } |
291 | else if (homedir) |
322 | else if (homedir) |
… | |
… | |
294 | |
325 | |
295 | if ((rdb1 = XrmGetFileDatabase (fname))) |
326 | if ((rdb1 = XrmGetFileDatabase (fname))) |
296 | XrmMergeDatabases (rdb1, &database); |
327 | XrmMergeDatabases (rdb1, &database); |
297 | } |
328 | } |
298 | |
329 | |
|
|
330 | #if !XLIB_ILLEGAL_ACCESS |
|
|
331 | if (refresh && displayResource) |
|
|
332 | XFree (displayResource); |
|
|
333 | #endif |
|
|
334 | |
299 | /* Get screen specific resources */ |
335 | /* Get screen specific resources */ |
300 | displayResource = XScreenResourceString (ScreenOfDisplay (display, screen)); |
336 | displayResource = XScreenResourceString (ScreenOfDisplay (display, screen)); |
301 | |
337 | |
302 | if (displayResource != NULL) |
338 | if (displayResource) |
303 | { |
339 | { |
304 | if ((rdb1 = XrmGetStringDatabase (displayResource))) |
340 | if ((rdb1 = XrmGetStringDatabase (displayResource))) |
305 | /* Merge with screen-independent resources */ |
341 | /* Merge with screen-independent resources */ |
306 | XrmMergeDatabases (rdb1, &database); |
342 | XrmMergeDatabases (rdb1, &database); |
307 | |
343 | |
… | |
… | |
348 | display = XOpenDisplay (id); |
384 | display = XOpenDisplay (id); |
349 | |
385 | |
350 | if (!display) |
386 | if (!display) |
351 | return false; |
387 | return false; |
352 | |
388 | |
353 | screen = DefaultScreen (display); |
389 | screen = DefaultScreen (display); |
354 | root = DefaultRootWindow (display); |
390 | root = DefaultRootWindow (display); |
355 | |
391 | |
356 | assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); |
392 | assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); |
357 | XInternAtoms (display, (char **)xa_names, NUM_XA, False, xa); |
393 | XInternAtoms (display, (char **)xa_names, NUM_XA, False, xa); |
358 | |
394 | |
359 | XrmSetDatabase (display, get_resources ()); |
395 | XrmSetDatabase (display, get_resources (false)); |
360 | |
396 | |
361 | #ifdef POINTER_BLANK |
397 | #ifdef POINTER_BLANK |
362 | XColor blackcolour; |
398 | XColor blackcolour; |
363 | blackcolour.red = 0; |
399 | blackcolour.red = 0; |
364 | blackcolour.green = 0; |
400 | blackcolour.green = 0; |
… | |
… | |
397 | rxvt_display::ref_next () |
433 | rxvt_display::ref_next () |
398 | { |
434 | { |
399 | // TODO: somehow check wether the database files/resources changed |
435 | // TODO: somehow check wether the database files/resources changed |
400 | // before affording re-loading/parsing |
436 | // before affording re-loading/parsing |
401 | XrmDestroyDatabase (XrmGetDatabase (display)); |
437 | XrmDestroyDatabase (XrmGetDatabase (display)); |
402 | XrmSetDatabase (display, get_resources ()); |
438 | XrmSetDatabase (display, get_resources (true)); |
403 | } |
439 | } |
404 | |
440 | |
405 | rxvt_display::~rxvt_display () |
441 | rxvt_display::~rxvt_display () |
406 | { |
442 | { |
407 | if (!display) |
443 | if (!display) |