… | |
… | |
11 | * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA> |
11 | * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA> |
12 | * - extensive modifications |
12 | * - extensive modifications |
13 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
13 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
14 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
14 | * Copyright (c) 1998-2001 Geoff Wing <gcw@pobox.com> |
15 | * - extensive modifications |
15 | * - extensive modifications |
16 | * Copyright (c) 2003-2010 Marc Lehmann <schmorp@schmorp.de> |
16 | * Copyright (c) 2003-2014 Marc Lehmann <schmorp@schmorp.de> |
|
|
17 | * Copyright (c) 2015 Emanuele Giaquinta <e.giaquinta@glauco.it> |
17 | * |
18 | * |
18 | * This program is free software; you can redistribute it and/or modify |
19 | * This program is free software; you can redistribute it and/or modify |
19 | * it under the terms of the GNU General Public License as published by |
20 | * it under the terms of the GNU General Public License as published by |
20 | * the Free Software Foundation; either version 2 of the License, or |
21 | * the Free Software Foundation; either version 3 of the License, or |
21 | * (at your option) any later version. |
22 | * (at your option) any later version. |
22 | * |
23 | * |
23 | * This program is distributed in the hope that it will be useful, |
24 | * This program is distributed in the hope that it will be useful, |
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
… | |
… | |
150 | } |
151 | } |
151 | #endif |
152 | #endif |
152 | |
153 | |
153 | rxvt_term::rxvt_term () |
154 | rxvt_term::rxvt_term () |
154 | { |
155 | { |
155 | #if HAVE_BG_PIXMAP |
|
|
156 | update_background_ev.set<rxvt_term, &rxvt_term::update_background_cb> (this); |
|
|
157 | #endif |
|
|
158 | #ifdef CURSOR_BLINK |
156 | #ifdef CURSOR_BLINK |
159 | cursor_blink_ev.set <rxvt_term, &rxvt_term::cursor_blink_cb> (this); cursor_blink_ev.set (0., CURSOR_BLINK_INTERVAL); |
157 | cursor_blink_ev.set <rxvt_term, &rxvt_term::cursor_blink_cb> (this); cursor_blink_ev.set (0., CURSOR_BLINK_INTERVAL); |
160 | #endif |
158 | #endif |
161 | #ifdef TEXT_BLINK |
159 | #ifdef TEXT_BLINK |
162 | text_blink_ev.set <rxvt_term, &rxvt_term::text_blink_cb> (this); text_blink_ev.set (0., TEXT_BLINK_INTERVAL); |
160 | text_blink_ev.set <rxvt_term, &rxvt_term::text_blink_cb> (this); text_blink_ev.set (0., TEXT_BLINK_INTERVAL); |
… | |
… | |
168 | sel_scroll_ev.set <rxvt_term, &rxvt_term::sel_scroll_cb> (this); |
166 | sel_scroll_ev.set <rxvt_term, &rxvt_term::sel_scroll_cb> (this); |
169 | #endif |
167 | #endif |
170 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
168 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
171 | slip_wheel_ev.set <rxvt_term, &rxvt_term::slip_wheel_cb> (this); |
169 | slip_wheel_ev.set <rxvt_term, &rxvt_term::slip_wheel_cb> (this); |
172 | #endif |
170 | #endif |
173 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
171 | #if ENABLE_PERL |
174 | rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this), |
172 | rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this), |
175 | #endif |
173 | #endif |
176 | scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), |
174 | scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), |
177 | #ifdef USE_XIM |
175 | #if USE_XIM |
178 | im_ev.set <rxvt_term, &rxvt_term::im_cb> (this), |
176 | im_ev.set <rxvt_term, &rxvt_term::im_cb> (this), |
179 | #endif |
177 | #endif |
180 | #ifdef POINTER_BLANK |
178 | #ifdef POINTER_BLANK |
181 | pointer_ev.set <rxvt_term, &rxvt_term::pointer_cb> (this); |
179 | pointer_ev.set <rxvt_term, &rxvt_term::pointer_cb> (this); |
182 | #endif |
180 | #endif |
… | |
… | |
222 | if (fontset[i] != fontset[0]) |
220 | if (fontset[i] != fontset[0]) |
223 | delete fontset[i]; |
221 | delete fontset[i]; |
224 | #endif |
222 | #endif |
225 | delete fontset[0]; |
223 | delete fontset[0]; |
226 | |
224 | |
227 | #ifdef HAVE_BG_PIXMAP |
225 | #if HAVE_IMG |
228 | bg_destroy (); |
226 | delete bg_img; |
229 | #endif |
227 | #endif |
230 | |
228 | |
231 | if (display) |
229 | if (display) |
232 | { |
230 | { |
233 | selection_clear (); |
231 | selection_clear (); |
234 | selection_clear (true); |
232 | selection_clear (true); |
235 | |
233 | |
236 | #ifdef USE_XIM |
234 | #if USE_XIM |
237 | im_destroy (); |
235 | im_destroy (); |
238 | #endif |
236 | #endif |
239 | scrollBar.destroy (); |
237 | scrollBar.destroy (); |
|
|
238 | |
|
|
239 | if (gc) |
240 | if (gc) XFreeGC (dpy, gc); |
240 | XFreeGC (dpy, gc); |
241 | |
241 | |
242 | delete drawable; |
242 | delete drawable; |
|
|
243 | |
243 | // destroy all windows |
244 | // destroy all windows |
244 | if (parent) |
245 | if (parent) |
245 | XDestroyWindow (dpy, parent); |
246 | XDestroyWindow (dpy, parent); |
246 | |
247 | |
247 | for (int i = 0; i < TOTAL_COLORS; i++) |
248 | for (int i = 0; i < TOTAL_COLORS; i++) |
248 | if (ISSET_PIXCOLOR (i)) |
249 | if (ISSET_PIXCOLOR (i)) |
249 | { |
250 | { |
250 | pix_colors_focused [i].free (this); |
251 | pix_colors_focused [i].free (this); |
251 | #if OFF_FOCUS_FADING |
252 | #if OFF_FOCUS_FADING |
|
|
253 | if (rs[Rs_fade]) |
252 | pix_colors_unfocused [i].free (this); |
254 | pix_colors_unfocused [i].free (this); |
253 | #endif |
255 | #endif |
254 | } |
256 | } |
255 | |
257 | |
256 | clear (); |
258 | clear (); |
257 | |
259 | |
… | |
… | |
270 | free (locale); |
272 | free (locale); |
271 | free (v_buffer); |
273 | free (v_buffer); |
272 | |
274 | |
273 | delete selection_req; |
275 | delete selection_req; |
274 | |
276 | |
|
|
277 | if (env && memcmp (env, envv->begin (), envv->size () * sizeof (char *))) |
|
|
278 | rxvt_warn ("env has been modified, probably as a result of a lib calling setenv.\n"); |
|
|
279 | |
|
|
280 | delete [] env; |
|
|
281 | |
275 | delete envv; |
282 | delete envv; |
276 | delete argv; |
283 | delete argv; |
277 | |
284 | |
278 | #ifdef KEYSYM_RESOURCE |
285 | #ifdef KEYSYM_RESOURCE |
279 | delete keyboard; |
286 | delete keyboard; |
280 | #endif |
287 | #endif |
281 | #ifndef NO_RESOURCES |
288 | #ifndef NO_RESOURCES |
282 | XrmDestroyDatabase (option_db); |
289 | XrmDestroyDatabase (option_db); |
283 | #endif |
290 | #endif |
|
|
291 | |
|
|
292 | SET_R ((rxvt_term *)0); |
284 | } |
293 | } |
285 | |
294 | |
286 | // child has exited, usually destroys |
295 | // child has exited, usually destroys |
287 | void |
296 | void |
288 | rxvt_term::child_cb (ev::child &w, int status) |
297 | rxvt_term::child_cb (ev::child &w, int status) |
… | |
… | |
311 | { |
320 | { |
312 | #if USE_XIM |
321 | #if USE_XIM |
313 | im_ev.stop (display); |
322 | im_ev.stop (display); |
314 | #endif |
323 | #endif |
315 | scrollbar_ev.stop (display); |
324 | scrollbar_ev.stop (display); |
316 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
325 | #if ENABLE_PERL |
317 | rootwin_ev.stop (display); |
326 | rootwin_ev.stop (display); |
318 | #endif |
327 | #endif |
319 | termwin_ev.stop (display); |
328 | termwin_ev.stop (display); |
320 | vt_ev.stop (display); |
329 | vt_ev.stop (display); |
321 | } |
330 | } |
… | |
… | |
362 | } |
371 | } |
363 | |
372 | |
364 | /*----------------------------------------------------------------------*/ |
373 | /*----------------------------------------------------------------------*/ |
365 | /* |
374 | /* |
366 | * Exit gracefully, clearing the utmp entry and restoring tty attributes |
375 | * Exit gracefully, clearing the utmp entry and restoring tty attributes |
367 | * TODO: if debugging, this should free up any known resources if we can |
|
|
368 | */ |
376 | */ |
369 | static XErrorHandler old_xerror_handler; |
377 | static XErrorHandler old_xerror_handler; |
370 | |
378 | |
371 | static void |
379 | static void |
372 | rxvt_emergency_cleanup () |
380 | rxvt_emergency_cleanup () |
… | |
… | |
374 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
382 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
375 | (*t)->emergency_cleanup (); |
383 | (*t)->emergency_cleanup (); |
376 | } |
384 | } |
377 | |
385 | |
378 | #if !ENABLE_MINIMAL |
386 | #if !ENABLE_MINIMAL |
379 | static void |
387 | static void ecb_cold |
380 | print_x_error (Display *dpy, XErrorEvent *event) |
388 | print_x_error (Display *dpy, XErrorEvent *event) |
381 | { |
389 | { |
382 | char buffer[BUFSIZ]; |
390 | char buffer[BUFSIZ]; |
383 | char mesg[BUFSIZ]; |
391 | char mesg[BUFSIZ]; |
384 | char number[32]; |
392 | char number[32]; |
385 | const char mtype[] = "XlibMessage"; |
393 | |
386 | XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); |
|
|
387 | XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); |
|
|
388 | rxvt_warn ("An X Error occurred, trying to continue after report.\n"); |
394 | rxvt_warn ("An X Error occurred, trying to continue after report.\n"); |
|
|
395 | |
|
|
396 | XGetErrorDatabaseText (dpy, "XlibMessage", "ErrorSerial", "Error Serial #%d", mesg, BUFSIZ); |
|
|
397 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->serial); |
|
|
398 | |
|
|
399 | XGetErrorText (dpy, event->error_code, buffer, BUFSIZ); |
|
|
400 | XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "X Error", mesg, BUFSIZ); |
389 | rxvt_warn ("%s: %s\n", mesg, buffer); |
401 | rxvt_warn ("+ %s: %s\n", mesg, buffer); |
|
|
402 | |
390 | XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
403 | XGetErrorDatabaseText (dpy, "XlibMessage", "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
391 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code); |
404 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->request_code); |
|
|
405 | |
|
|
406 | if (event->request_code >= 128) |
|
|
407 | { |
|
|
408 | #if 0 |
|
|
409 | /* XListExtensions and probably query extensions hangs when there are multiple queues errors */ |
|
|
410 | int nexts; |
|
|
411 | char **exts = XListExtensions (dpy, &nexts); |
|
|
412 | |
|
|
413 | while (nexts) |
|
|
414 | { |
|
|
415 | char *extname = exts [nexts - 1]; |
|
|
416 | int major, first_event, first_error; |
|
|
417 | |
|
|
418 | if (XQueryExtension (dpy, extname, &major, &first_event, &first_error) && major == event->request_code) |
|
|
419 | { |
|
|
420 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); |
|
|
421 | rxvt_warn ("+ (which is extension %s minor code %d)\n", extname, event->minor_code); |
|
|
422 | |
|
|
423 | snprintf (buffer, BUFSIZ, "%s.%d", extname, event->minor_code); |
|
|
424 | XGetErrorDatabaseText (dpy, "XRequest", buffer, "an unregistered minor code", buffer, BUFSIZ); |
|
|
425 | rxvt_warn ("+ (which is %s)\n", buffer); |
|
|
426 | |
|
|
427 | break; |
|
|
428 | } |
|
|
429 | |
|
|
430 | printf ("nextss %d %s\n", nexts, extname);//D |
|
|
431 | --nexts; |
|
|
432 | ++exts; |
|
|
433 | } |
|
|
434 | #else |
|
|
435 | int nexts = 0; |
|
|
436 | char **exts = 0; |
|
|
437 | #endif |
|
|
438 | |
|
|
439 | if (!nexts) |
|
|
440 | { |
|
|
441 | rxvt_warn ("+ (which is an unknown extension)\n", buffer); |
|
|
442 | |
|
|
443 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); |
|
|
444 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->minor_code); |
|
|
445 | |
|
|
446 | #if 0 |
|
|
447 | sprintf (number, "RENDER.%d", event->minor_code); |
|
|
448 | XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); |
|
|
449 | rxvt_warn ("+ (which is %s)\n", buffer); |
|
|
450 | #endif |
|
|
451 | } |
|
|
452 | |
|
|
453 | XFreeExtensionList (exts); |
|
|
454 | } |
|
|
455 | else |
|
|
456 | { |
392 | sprintf(number, "%d", event->request_code); |
457 | sprintf (number, "%d", event->request_code); |
393 | XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); |
458 | XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); |
394 | rxvt_warn ("(which is %s)\n", buffer); |
459 | rxvt_warn ("+ (which is %s)\n", buffer); |
395 | if (event->request_code >= 128) { |
|
|
396 | XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", |
|
|
397 | mesg, BUFSIZ); |
|
|
398 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code); |
|
|
399 | } |
460 | } |
|
|
461 | |
400 | if ((event->error_code == BadWindow) || |
462 | if (event->error_code == BadWindow |
401 | (event->error_code == BadPixmap) || |
463 | || event->error_code == BadPixmap |
402 | (event->error_code == BadCursor) || |
464 | || event->error_code == BadCursor |
403 | (event->error_code == BadFont) || |
465 | || event->error_code == BadFont |
404 | (event->error_code == BadDrawable) || |
466 | || event->error_code == BadDrawable |
405 | (event->error_code == BadColor) || |
467 | || event->error_code == BadColor |
406 | (event->error_code == BadGC) || |
468 | || event->error_code == BadGC |
407 | (event->error_code == BadIDChoice) || |
469 | || event->error_code == BadIDChoice |
408 | (event->error_code == BadValue) || |
470 | || event->error_code == BadValue |
409 | (event->error_code == BadAtom)) { |
471 | || event->error_code == BadAtom) |
|
|
472 | { |
410 | if (event->error_code == BadValue) |
473 | if (event->error_code == BadValue) |
411 | XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", |
474 | XGetErrorDatabaseText (dpy, "XlibMessage", "Value", "Value 0x%x", mesg, BUFSIZ); |
412 | mesg, BUFSIZ); |
|
|
413 | else if (event->error_code == BadAtom) |
475 | else if (event->error_code == BadAtom) |
414 | XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", |
476 | XGetErrorDatabaseText (dpy, "XlibMessage", "AtomID", "AtomID 0x%x", mesg, BUFSIZ); |
415 | mesg, BUFSIZ); |
|
|
416 | else |
477 | else |
417 | XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", |
478 | XGetErrorDatabaseText (dpy, "XlibMessage", "ResourceID", "ResourceID 0x%x", mesg, BUFSIZ); |
418 | mesg, BUFSIZ); |
|
|
419 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid); |
|
|
420 | } |
|
|
421 | XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", |
|
|
422 | mesg, BUFSIZ); |
|
|
423 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial); |
|
|
424 | } |
|
|
425 | #endif |
|
|
426 | |
479 | |
427 | int |
480 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->resourceid); |
|
|
481 | } |
|
|
482 | } |
|
|
483 | #endif |
|
|
484 | |
|
|
485 | int ecb_cold |
428 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
486 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
429 | { |
487 | { |
430 | if (GET_R->allowedxerror == -1) |
488 | if (GET_R && GET_R->allowedxerror == -1) |
431 | GET_R->allowedxerror = event->error_code; |
489 | GET_R->allowedxerror = event->error_code; |
432 | else |
490 | else |
433 | { |
491 | { |
434 | // GET_R is most likely not the terminal which caused the error, |
492 | // GET_R is most likely not the terminal which caused the error, |
435 | // so just output the error and continue |
493 | // so just output the error and continue |
… | |
… | |
441 | } |
499 | } |
442 | |
500 | |
443 | return 0; |
501 | return 0; |
444 | } |
502 | } |
445 | |
503 | |
446 | int |
504 | int ecb_cold |
447 | rxvt_xioerror_handler (Display *display) |
505 | rxvt_xioerror_handler (Display *display) |
448 | { |
506 | { |
449 | rxvt_warn ("X connection to '%s' broken, unable to recover, exiting.\n", |
507 | rxvt_warn ("X connection to '%s' broken, unable to recover, exiting.\n", |
450 | DisplayString (display)); |
508 | DisplayString (display)); |
451 | rxvt_emergency_cleanup (); |
509 | rxvt_emergency_cleanup (); |
… | |
… | |
571 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
629 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
572 | // TODO: handle this with exceptions and tolerate the memory loss |
630 | // TODO: handle this with exceptions and tolerate the memory loss |
573 | XSetIOErrorHandler (rxvt_xioerror_handler); |
631 | XSetIOErrorHandler (rxvt_xioerror_handler); |
574 | |
632 | |
575 | XrmInitialize (); |
633 | XrmInitialize (); |
|
|
634 | |
|
|
635 | #if HAVE_PIXBUF |
|
|
636 | g_type_init (); |
|
|
637 | #endif |
576 | } |
638 | } |
577 | |
639 | |
578 | /*----------------------------------------------------------------------*/ |
640 | /*----------------------------------------------------------------------*/ |
579 | /* |
641 | /* |
580 | * window size/position calculations for XSizeHint and other storage. |
642 | * window size/position calculations for XSizeHint and other storage. |
… | |
… | |
764 | |
826 | |
765 | delete fontset[0]; |
827 | delete fontset[0]; |
766 | fontset[0] = fs; |
828 | fontset[0] = fs; |
767 | |
829 | |
768 | prop = (*fs)[rxvt_fontset::firstFont]->properties (); |
830 | prop = (*fs)[rxvt_fontset::firstFont]->properties (); |
769 | prop.height += lineSpace; |
831 | prop.width = max (prop.width + letterSpace, 1); |
770 | prop.width += letterSpace; |
|
|
771 | |
832 | |
772 | fs->set_prop (prop, false); |
833 | fs->set_prop (prop, false); |
773 | |
834 | |
774 | fwidth = prop.width; |
835 | fwidth = prop.width; |
775 | fheight = prop.height; |
836 | fheight = prop.height + lineSpace; |
776 | fbase = prop.ascent; |
837 | fbase = prop.ascent; |
777 | |
838 | |
778 | for (int style = 1; style < 4; style++) |
839 | for (int style = 1; style < 4; style++) |
779 | { |
840 | { |
780 | #if ENABLE_STYLES |
841 | #if ENABLE_STYLES |
… | |
… | |
875 | |
936 | |
876 | void |
937 | void |
877 | rxvt_term::set_window_color (int idx, const char *color) |
938 | rxvt_term::set_window_color (int idx, const char *color) |
878 | { |
939 | { |
879 | #ifdef XTERM_COLOR_CHANGE |
940 | #ifdef XTERM_COLOR_CHANGE |
880 | rxvt_color xcol; |
|
|
881 | |
|
|
882 | if (color == NULL || *color == '\0') |
941 | if (color == NULL || *color == '\0') |
883 | return; |
942 | return; |
884 | |
943 | |
885 | color = strdup (color); |
944 | color = strdup (color); |
886 | allocated.push_back ((void *)color); |
945 | allocated.push_back ((void *)color); |
… | |
… | |
892 | int i = atoi (color); |
951 | int i = atoi (color); |
893 | |
952 | |
894 | if (i >= 8 && i <= 15) |
953 | if (i >= 8 && i <= 15) |
895 | { |
954 | { |
896 | /* bright colors */ |
955 | /* bright colors */ |
897 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; |
956 | alias_color (idx, minBrightCOLOR + i - 8); |
898 | goto done; |
957 | goto done; |
899 | } |
958 | } |
900 | |
959 | |
901 | if (i >= 0 && i <= 7) |
960 | if (i >= 0 && i <= 7) |
902 | { |
961 | { |
903 | /* normal colors */ |
962 | /* normal colors */ |
904 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
963 | alias_color (idx, minCOLOR + i); |
905 | goto done; |
964 | goto done; |
906 | } |
965 | } |
907 | } |
966 | } |
908 | |
967 | |
909 | set_color (xcol, color); |
968 | pix_colors_focused[idx].free (this); |
910 | |
969 | set_color (pix_colors_focused[idx], color); |
911 | /* |
|
|
912 | * FIXME: should free colors here, but no idea how to do it so instead, |
|
|
913 | * so just keep gobbling up the colormap |
|
|
914 | */ |
|
|
915 | |
|
|
916 | pix_colors_focused[idx] = xcol; |
|
|
917 | |
970 | |
918 | done: |
971 | done: |
919 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
972 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
920 | |
973 | |
921 | update_fade_color (idx); |
974 | update_fade_color (idx); |
922 | recolour_cursor (); |
975 | recolor_cursor (); |
923 | scr_recolour (); |
976 | scr_recolor (); |
924 | #endif /* XTERM_COLOR_CHANGE */ |
977 | #endif /* XTERM_COLOR_CHANGE */ |
925 | } |
978 | } |
926 | |
979 | |
927 | void |
980 | void |
928 | rxvt_term::recolour_cursor () |
981 | rxvt_term::recolor_cursor () |
929 | { |
982 | { |
930 | XColor fg, bg; |
983 | XColor fg, bg; |
931 | |
984 | |
932 | (ISSET_PIXCOLOR (Color_pointer_fg) |
985 | (ISSET_PIXCOLOR (Color_pointer_fg) |
933 | ? pix_colors_focused[Color_pointer_fg] |
986 | ? pix_colors_focused[Color_pointer_fg] |
… | |
… | |
962 | |
1015 | |
963 | for (i = Color_Black; i <= Color_White; i++) |
1016 | for (i = Color_Black; i <= Color_White; i++) |
964 | if (pix_colors[Color_bg] == pix_colors[i]) |
1017 | if (pix_colors[Color_bg] == pix_colors[i]) |
965 | { |
1018 | { |
966 | sprintf (bstr, "%d", i - Color_Black); |
1019 | sprintf (bstr, "%d", i - Color_Black); |
967 | #ifdef BG_IMAGE_FROM_FILE |
1020 | #if HAVE_IMG |
968 | xpmb = "default;"; |
1021 | xpmb = "default;"; |
969 | #endif |
1022 | #endif |
970 | break; |
1023 | break; |
971 | } |
1024 | } |
972 | |
1025 | |
… | |
… | |
988 | } |
1041 | } |
989 | |
1042 | |
990 | void |
1043 | void |
991 | rxvt_term::alias_color (int dst, int src) |
1044 | rxvt_term::alias_color (int dst, int src) |
992 | { |
1045 | { |
|
|
1046 | pix_colors[dst].free (this); |
993 | pix_colors[dst].set (this, rs[Rs_color + dst] = rs[Rs_color + src]); |
1047 | pix_colors[dst].set (this, rs[Rs_color + dst] = rs[Rs_color + src]); |
994 | } |
1048 | } |
|
|
1049 | |
|
|
1050 | #ifdef SMART_RESIZE |
|
|
1051 | static unsigned int |
|
|
1052 | get_parent_bw (Display *dpy, Window w) |
|
|
1053 | { |
|
|
1054 | int idummy; |
|
|
1055 | unsigned int udummy; |
|
|
1056 | Window wdummy, parent; |
|
|
1057 | Window *children; |
|
|
1058 | unsigned int nchildren, border_width; |
|
|
1059 | |
|
|
1060 | XQueryTree (dpy, w, &wdummy, &parent, &children, &nchildren); |
|
|
1061 | XFree (children); |
|
|
1062 | XGetGeometry (dpy, parent, &wdummy, &idummy, &idummy, |
|
|
1063 | &udummy, &udummy, &border_width, &udummy); |
|
|
1064 | |
|
|
1065 | return border_width; |
|
|
1066 | } |
|
|
1067 | #endif |
995 | |
1068 | |
996 | /* -------------------------------------------------------------------- * |
1069 | /* -------------------------------------------------------------------- * |
997 | * - WINDOW RESIZING - * |
1070 | * - WINDOW RESIZING - * |
998 | * -------------------------------------------------------------------- */ |
1071 | * -------------------------------------------------------------------- */ |
999 | void |
1072 | void |
… | |
… | |
1035 | * if display->root isn't the parent window, a WM will probably have offset |
1108 | * if display->root isn't the parent window, a WM will probably have offset |
1036 | * our position for handles and decorations. Counter it |
1109 | * our position for handles and decorations. Counter it |
1037 | */ |
1110 | */ |
1038 | if (x1 != x || y1 != y) |
1111 | if (x1 != x || y1 != y) |
1039 | { |
1112 | { |
1040 | x -= x1; |
1113 | unsigned int border_width = get_parent_bw (dpy, parent); |
1041 | y -= y1; |
1114 | |
|
|
1115 | x -= x1 + border_width; |
|
|
1116 | y -= y1 + border_width; |
1042 | } |
1117 | } |
1043 | |
1118 | |
1044 | x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2; |
1119 | x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2; |
1045 | y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2; |
1120 | y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2; |
1046 | dx = old_width - szHint.width; |
1121 | dx = old_width - szHint.width; |
… | |
… | |
1075 | |
1150 | |
1076 | XMoveResizeWindow (dpy, vt, |
1151 | XMoveResizeWindow (dpy, vt, |
1077 | window_vt_x, window_vt_y, |
1152 | window_vt_x, window_vt_y, |
1078 | vt_width, vt_height); |
1153 | vt_width, vt_height); |
1079 | |
1154 | |
1080 | #ifdef HAVE_BG_PIXMAP |
1155 | HOOK_INVOKE ((this, HOOK_SIZE_CHANGE, DT_INT, newwidth, DT_INT, newheight, DT_END)); |
1081 | if (bg_window_size_sensitive ()) |
|
|
1082 | update_background (); |
|
|
1083 | #endif |
|
|
1084 | } |
1156 | } |
1085 | |
1157 | |
1086 | if (fix_screen || old_height == 0) |
1158 | if (fix_screen || old_height == 0) |
1087 | scr_reset (); |
1159 | scr_reset (); |
1088 | |
1160 | |
1089 | #ifdef USE_XIM |
1161 | #if USE_XIM |
1090 | im_set_position (); |
1162 | im_set_position (); |
1091 | #endif |
1163 | #endif |
1092 | } |
1164 | } |
1093 | |
1165 | |
1094 | /* |
1166 | /* |
… | |
… | |
1119 | } |
1191 | } |
1120 | |
1192 | |
1121 | /* -------------------------------------------------------------------- * |
1193 | /* -------------------------------------------------------------------- * |
1122 | * - X INPUT METHOD ROUTINES - * |
1194 | * - X INPUT METHOD ROUTINES - * |
1123 | * -------------------------------------------------------------------- */ |
1195 | * -------------------------------------------------------------------- */ |
1124 | #ifdef USE_XIM |
1196 | #if USE_XIM |
1125 | |
1197 | |
1126 | void |
1198 | void |
1127 | rxvt_term::im_set_color (unsigned long &fg, unsigned long &bg) |
1199 | rxvt_term::im_set_color (unsigned long &fg, unsigned long &bg) |
1128 | { |
1200 | { |
1129 | fg = pix_colors [Color_fg]; |
1201 | fg = pix_colors [Color_fg]; |
… | |
… | |
1309 | unsigned long fg, bg; |
1381 | unsigned long fg, bg; |
1310 | const char *p; |
1382 | const char *p; |
1311 | char **s; |
1383 | char **s; |
1312 | XIMStyles *xim_styles; |
1384 | XIMStyles *xim_styles; |
1313 | |
1385 | |
1314 | set_environ (envv); |
1386 | set_environ (env); |
1315 | |
1387 | |
1316 | if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) |
1388 | if (!((p = XSetLocaleModifiers (modifiers)) && *p)) |
1317 | return false; |
1389 | return false; |
1318 | |
1390 | |
1319 | input_method = display->get_xim (locale, modifiers); |
1391 | input_method = display->get_xim (locale, modifiers); |
1320 | if (input_method == NULL) |
1392 | if (input_method == NULL) |
1321 | return false; |
1393 | return false; |
… | |
… | |
1621 | { |
1693 | { |
1622 | Window cr; |
1694 | Window cr; |
1623 | XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr); |
1695 | XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr); |
1624 | } |
1696 | } |
1625 | |
1697 | |
1626 | Pixmap |
|
|
1627 | rxvt_term::get_pixmap_property (Atom property) |
|
|
1628 | { |
|
|
1629 | Pixmap pixmap = None; |
|
|
1630 | |
|
|
1631 | int aformat; |
|
|
1632 | unsigned long nitems, bytes_after; |
|
|
1633 | Atom atype; |
|
|
1634 | unsigned char *prop; |
|
|
1635 | int result = XGetWindowProperty (dpy, display->root, property, |
|
|
1636 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
1637 | &nitems, &bytes_after, &prop); |
|
|
1638 | if (result == Success) |
|
|
1639 | { |
|
|
1640 | if (atype == XA_PIXMAP) |
|
|
1641 | pixmap = *(Pixmap *)prop; |
|
|
1642 | XFree (prop); |
|
|
1643 | } |
|
|
1644 | |
|
|
1645 | return pixmap; |
|
|
1646 | } |
|
|
1647 | |
|
|
1648 | #ifdef HAVE_BG_PIXMAP |
|
|
1649 | |
|
|
1650 | void |
|
|
1651 | rxvt_term::update_background () |
|
|
1652 | { |
|
|
1653 | if (update_background_ev.is_active ()) |
|
|
1654 | return; |
|
|
1655 | |
|
|
1656 | bg_invalidate (); |
|
|
1657 | |
|
|
1658 | if (!mapped) |
|
|
1659 | return; |
|
|
1660 | |
|
|
1661 | ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since); |
|
|
1662 | |
|
|
1663 | if (to_wait <= 0.) |
|
|
1664 | bg_render (); |
|
|
1665 | else |
|
|
1666 | update_background_ev.start (to_wait); |
|
|
1667 | } |
|
|
1668 | |
|
|
1669 | void |
|
|
1670 | rxvt_term::update_background_cb (ev::timer &w, int revents) |
|
|
1671 | { |
|
|
1672 | make_current (); |
|
|
1673 | |
|
|
1674 | update_background_ev.stop (); |
|
|
1675 | bg_render (); |
|
|
1676 | refresh_check (); |
|
|
1677 | } |
|
|
1678 | |
|
|
1679 | #endif /* HAVE_BG_PIXMAP */ |
|
|
1680 | |
|
|
1681 | /*----------------------- end-of-file (C source) -----------------------*/ |
1698 | /*----------------------- end-of-file (C source) -----------------------*/ |