… | |
… | |
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 | * |
17 | * |
18 | * This program is free software; you can redistribute it and/or modify |
18 | * 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 |
19 | * 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 |
20 | * the Free Software Foundation; either version 3 of the License, or |
21 | * (at your option) any later version. |
21 | * (at your option) any later version. |
22 | * |
22 | * |
23 | * This program is distributed in the hope that it will be useful, |
23 | * This program is distributed in the hope that it will be useful, |
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
… | |
… | |
239 | |
239 | |
240 | #if USE_XIM |
240 | #if USE_XIM |
241 | im_destroy (); |
241 | im_destroy (); |
242 | #endif |
242 | #endif |
243 | scrollBar.destroy (); |
243 | scrollBar.destroy (); |
|
|
244 | |
|
|
245 | if (gc) |
244 | if (gc) XFreeGC (dpy, gc); |
246 | XFreeGC (dpy, gc); |
245 | |
247 | |
246 | delete drawable; |
248 | delete drawable; |
|
|
249 | |
247 | // destroy all windows |
250 | // destroy all windows |
248 | if (parent) |
251 | if (parent) |
249 | XDestroyWindow (dpy, parent); |
252 | XDestroyWindow (dpy, parent); |
250 | |
253 | |
251 | for (int i = 0; i < TOTAL_COLORS; i++) |
254 | for (int i = 0; i < TOTAL_COLORS; i++) |
252 | if (ISSET_PIXCOLOR (i)) |
255 | if (ISSET_PIXCOLOR (i)) |
253 | { |
256 | { |
254 | pix_colors_focused [i].free (this); |
257 | pix_colors_focused [i].free (this); |
255 | #if OFF_FOCUS_FADING |
258 | #if OFF_FOCUS_FADING |
|
|
259 | if (rs[Rs_fade]) |
256 | pix_colors_unfocused [i].free (this); |
260 | pix_colors_unfocused [i].free (this); |
257 | #endif |
261 | #endif |
258 | } |
262 | } |
259 | |
263 | |
260 | clear (); |
264 | clear (); |
261 | |
265 | |
… | |
… | |
274 | free (locale); |
278 | free (locale); |
275 | free (v_buffer); |
279 | free (v_buffer); |
276 | |
280 | |
277 | delete selection_req; |
281 | delete selection_req; |
278 | |
282 | |
|
|
283 | if (env && memcmp (env, envv->begin (), envv->size () * sizeof (char *))) |
|
|
284 | rxvt_warn ("env has been modified, probably as a result of a lib calling setenv.\n"); |
|
|
285 | |
|
|
286 | delete [] env; |
|
|
287 | |
279 | delete envv; |
288 | delete envv; |
280 | delete argv; |
289 | delete argv; |
281 | |
290 | |
282 | #ifdef KEYSYM_RESOURCE |
291 | #ifdef KEYSYM_RESOURCE |
283 | delete keyboard; |
292 | delete keyboard; |
284 | #endif |
293 | #endif |
285 | #ifndef NO_RESOURCES |
294 | #ifndef NO_RESOURCES |
286 | XrmDestroyDatabase (option_db); |
295 | XrmDestroyDatabase (option_db); |
287 | #endif |
296 | #endif |
|
|
297 | |
|
|
298 | SET_R ((rxvt_term *)0); |
288 | } |
299 | } |
289 | |
300 | |
290 | // child has exited, usually destroys |
301 | // child has exited, usually destroys |
291 | void |
302 | void |
292 | rxvt_term::child_cb (ev::child &w, int status) |
303 | rxvt_term::child_cb (ev::child &w, int status) |
… | |
… | |
380 | |
391 | |
381 | #if !ENABLE_MINIMAL |
392 | #if !ENABLE_MINIMAL |
382 | static void ecb_cold |
393 | static void ecb_cold |
383 | print_x_error (Display *dpy, XErrorEvent *event) |
394 | print_x_error (Display *dpy, XErrorEvent *event) |
384 | { |
395 | { |
385 | char buffer[BUFSIZ]; |
396 | char buffer[BUFSIZ]; |
386 | char mesg[BUFSIZ]; |
397 | char mesg[BUFSIZ]; |
387 | char number[32]; |
398 | char number[32]; |
388 | |
399 | |
389 | rxvt_warn ("An X Error occurred, trying to continue after report.\n"); |
400 | rxvt_warn ("An X Error occurred, trying to continue after report.\n"); |
390 | |
401 | |
391 | XGetErrorDatabaseText (dpy, "XlibMessage", "ErrorSerial", "Error Serial #%d", mesg, BUFSIZ); |
402 | XGetErrorDatabaseText (dpy, "XlibMessage", "ErrorSerial", "Error Serial #%d", mesg, BUFSIZ); |
392 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->serial); |
403 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->serial); |
393 | |
404 | |
394 | XGetErrorText (dpy, event->error_code, buffer, BUFSIZ); |
405 | XGetErrorText (dpy, event->error_code, buffer, BUFSIZ); |
395 | XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "X Error", mesg, BUFSIZ); |
406 | XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "X Error", mesg, BUFSIZ); |
396 | rxvt_warn ("+ %s: %s\n", mesg, buffer); |
407 | rxvt_warn ("+ %s: %s\n", mesg, buffer); |
397 | |
408 | |
398 | XGetErrorDatabaseText (dpy, "XlibMessage", "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
409 | XGetErrorDatabaseText (dpy, "XlibMessage", "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
399 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->request_code); |
410 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->request_code); |
400 | |
411 | |
401 | if (event->request_code >= 128) |
412 | if (event->request_code >= 128) |
402 | { |
413 | { |
403 | #if 0 |
414 | #if 0 |
404 | /* XListExtensions and probably query extensions hangs when there are multiple queues errors */ |
415 | /* XListExtensions and probably query extensions hangs when there are multiple queues errors */ |
405 | int nexts; |
416 | int nexts; |
406 | char **exts = XListExtensions (dpy, &nexts); |
417 | char **exts = XListExtensions (dpy, &nexts); |
407 | |
418 | |
408 | while (nexts) |
419 | while (nexts) |
409 | { |
420 | { |
410 | char *extname = exts [nexts - 1]; |
421 | char *extname = exts [nexts - 1]; |
411 | int major, first_event, first_error; |
422 | int major, first_event, first_error; |
412 | |
423 | |
413 | if (XQueryExtension (dpy, extname, &major, &first_event, &first_error) && major == event->request_code) |
424 | if (XQueryExtension (dpy, extname, &major, &first_event, &first_error) && major == event->request_code) |
414 | { |
425 | { |
415 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); |
426 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); |
416 | rxvt_warn ("+ (which is extension %s minor code %d)\n", extname, event->minor_code); |
427 | rxvt_warn ("+ (which is extension %s minor code %d)\n", extname, event->minor_code); |
417 | |
428 | |
418 | snprintf (buffer, BUFSIZ, "%s.%d", extname, event->minor_code); |
429 | snprintf (buffer, BUFSIZ, "%s.%d", extname, event->minor_code); |
419 | XGetErrorDatabaseText (dpy, "XRequest", buffer, "an unregistered minor code", buffer, BUFSIZ); |
430 | XGetErrorDatabaseText (dpy, "XRequest", buffer, "an unregistered minor code", buffer, BUFSIZ); |
420 | rxvt_warn ("+ (which is %s)\n", buffer); |
431 | rxvt_warn ("+ (which is %s)\n", buffer); |
421 | |
432 | |
422 | break; |
433 | break; |
423 | } |
434 | } |
424 | |
435 | |
425 | printf ("nextss %d %s\n", nexts, extname);//D |
436 | printf ("nextss %d %s\n", nexts, extname);//D |
426 | --nexts; |
437 | --nexts; |
427 | ++exts; |
438 | ++exts; |
428 | } |
439 | } |
429 | #else |
440 | #else |
430 | int nexts = 0; |
441 | int nexts = 0; |
431 | char **exts = 0; |
442 | char **exts = 0; |
432 | #endif |
443 | #endif |
433 | |
444 | |
434 | if (!nexts) |
445 | if (!nexts) |
435 | { |
446 | { |
436 | rxvt_warn ("+ (which is an unknown extension)\n", buffer); |
447 | rxvt_warn ("+ (which is an unknown extension)\n", buffer); |
437 | |
448 | |
438 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); |
449 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); |
439 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->minor_code); |
450 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->minor_code); |
440 | |
451 | |
441 | #if 0 |
452 | #if 0 |
442 | sprintf (number, "RENDER.%d", event->minor_code); |
453 | sprintf (number, "RENDER.%d", event->minor_code); |
443 | XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); |
454 | XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); |
444 | rxvt_warn ("+ (which is %s)\n", buffer); |
455 | rxvt_warn ("+ (which is %s)\n", buffer); |
445 | #endif |
456 | #endif |
446 | } |
457 | } |
447 | |
458 | |
448 | XFreeExtensionList (exts); |
459 | XFreeExtensionList (exts); |
449 | } |
460 | } |
450 | else |
461 | else |
451 | { |
462 | { |
452 | sprintf (number, "%d", event->request_code); |
463 | sprintf (number, "%d", event->request_code); |
453 | XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); |
464 | XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); |
454 | rxvt_warn ("+ (which is %s)\n", buffer); |
465 | rxvt_warn ("+ (which is %s)\n", buffer); |
455 | } |
466 | } |
456 | |
467 | |
457 | if (event->error_code == BadWindow |
468 | if (event->error_code == BadWindow |
458 | || event->error_code == BadPixmap |
469 | || event->error_code == BadPixmap |
459 | || event->error_code == BadCursor |
470 | || event->error_code == BadCursor |
460 | || event->error_code == BadFont |
471 | || event->error_code == BadFont |
461 | || event->error_code == BadDrawable |
472 | || event->error_code == BadDrawable |
462 | || event->error_code == BadColor |
473 | || event->error_code == BadColor |
463 | || event->error_code == BadGC |
474 | || event->error_code == BadGC |
464 | || event->error_code == BadIDChoice |
475 | || event->error_code == BadIDChoice |
465 | || event->error_code == BadValue |
476 | || event->error_code == BadValue |
466 | || event->error_code == BadAtom) |
477 | || event->error_code == BadAtom) |
467 | { |
478 | { |
468 | if (event->error_code == BadValue) |
479 | if (event->error_code == BadValue) |
469 | XGetErrorDatabaseText (dpy, "XlibMessage", "Value", "Value 0x%x", mesg, BUFSIZ); |
480 | XGetErrorDatabaseText (dpy, "XlibMessage", "Value", "Value 0x%x", mesg, BUFSIZ); |
470 | else if (event->error_code == BadAtom) |
481 | else if (event->error_code == BadAtom) |
471 | XGetErrorDatabaseText (dpy, "XlibMessage", "AtomID", "AtomID 0x%x", mesg, BUFSIZ); |
482 | XGetErrorDatabaseText (dpy, "XlibMessage", "AtomID", "AtomID 0x%x", mesg, BUFSIZ); |
472 | else |
483 | else |
473 | XGetErrorDatabaseText (dpy, "XlibMessage", "ResourceID", "ResourceID 0x%x", mesg, BUFSIZ); |
484 | XGetErrorDatabaseText (dpy, "XlibMessage", "ResourceID", "ResourceID 0x%x", mesg, BUFSIZ); |
474 | |
485 | |
475 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->resourceid); |
486 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->resourceid); |
476 | } |
487 | } |
477 | } |
488 | } |
478 | #endif |
489 | #endif |
479 | |
490 | |
480 | int ecb_cold |
491 | int ecb_cold |
481 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
492 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
482 | { |
493 | { |
483 | if (GET_R->allowedxerror == -1) |
494 | if (GET_R && GET_R->allowedxerror == -1) |
484 | GET_R->allowedxerror = event->error_code; |
495 | GET_R->allowedxerror = event->error_code; |
485 | else |
496 | else |
486 | { |
497 | { |
487 | // GET_R is most likely not the terminal which caused the error, |
498 | // GET_R is most likely not the terminal which caused the error, |
488 | // so just output the error and continue |
499 | // so just output the error and continue |
… | |
… | |
931 | |
942 | |
932 | void |
943 | void |
933 | rxvt_term::set_window_color (int idx, const char *color) |
944 | rxvt_term::set_window_color (int idx, const char *color) |
934 | { |
945 | { |
935 | #ifdef XTERM_COLOR_CHANGE |
946 | #ifdef XTERM_COLOR_CHANGE |
936 | rxvt_color xcol; |
|
|
937 | |
|
|
938 | if (color == NULL || *color == '\0') |
947 | if (color == NULL || *color == '\0') |
939 | return; |
948 | return; |
940 | |
949 | |
941 | color = strdup (color); |
950 | color = strdup (color); |
942 | allocated.push_back ((void *)color); |
951 | allocated.push_back ((void *)color); |
… | |
… | |
948 | int i = atoi (color); |
957 | int i = atoi (color); |
949 | |
958 | |
950 | if (i >= 8 && i <= 15) |
959 | if (i >= 8 && i <= 15) |
951 | { |
960 | { |
952 | /* bright colors */ |
961 | /* bright colors */ |
953 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; |
962 | alias_color (idx, minBrightCOLOR + i - 8); |
954 | goto done; |
963 | goto done; |
955 | } |
964 | } |
956 | |
965 | |
957 | if (i >= 0 && i <= 7) |
966 | if (i >= 0 && i <= 7) |
958 | { |
967 | { |
959 | /* normal colors */ |
968 | /* normal colors */ |
960 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
969 | alias_color (idx, minCOLOR + i); |
961 | goto done; |
970 | goto done; |
962 | } |
971 | } |
963 | } |
972 | } |
964 | |
973 | |
965 | set_color (xcol, color); |
974 | pix_colors_focused[idx].free (this); |
966 | |
975 | set_color (pix_colors_focused[idx], color); |
967 | /* |
|
|
968 | * FIXME: should free colors here, but no idea how to do it so instead, |
|
|
969 | * so just keep gobbling up the colormap |
|
|
970 | */ |
|
|
971 | |
|
|
972 | pix_colors_focused[idx] = xcol; |
|
|
973 | |
976 | |
974 | done: |
977 | done: |
975 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
978 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
976 | |
979 | |
977 | update_fade_color (idx); |
980 | update_fade_color (idx); |
978 | recolour_cursor (); |
981 | recolor_cursor (); |
979 | scr_recolour (); |
982 | scr_recolor (); |
980 | #endif /* XTERM_COLOR_CHANGE */ |
983 | #endif /* XTERM_COLOR_CHANGE */ |
981 | } |
984 | } |
982 | |
985 | |
983 | void |
986 | void |
984 | rxvt_term::recolour_cursor () |
987 | rxvt_term::recolor_cursor () |
985 | { |
988 | { |
986 | XColor fg, bg; |
989 | XColor fg, bg; |
987 | |
990 | |
988 | (ISSET_PIXCOLOR (Color_pointer_fg) |
991 | (ISSET_PIXCOLOR (Color_pointer_fg) |
989 | ? pix_colors_focused[Color_pointer_fg] |
992 | ? pix_colors_focused[Color_pointer_fg] |
… | |
… | |
1044 | } |
1047 | } |
1045 | |
1048 | |
1046 | void |
1049 | void |
1047 | rxvt_term::alias_color (int dst, int src) |
1050 | rxvt_term::alias_color (int dst, int src) |
1048 | { |
1051 | { |
|
|
1052 | pix_colors[dst].free (this); |
1049 | pix_colors[dst].set (this, rs[Rs_color + dst] = rs[Rs_color + src]); |
1053 | pix_colors[dst].set (this, rs[Rs_color + dst] = rs[Rs_color + src]); |
1050 | } |
1054 | } |
1051 | |
1055 | |
1052 | /* -------------------------------------------------------------------- * |
1056 | /* -------------------------------------------------------------------- * |
1053 | * - WINDOW RESIZING - * |
1057 | * - WINDOW RESIZING - * |
… | |
… | |
1367 | unsigned long fg, bg; |
1371 | unsigned long fg, bg; |
1368 | const char *p; |
1372 | const char *p; |
1369 | char **s; |
1373 | char **s; |
1370 | XIMStyles *xim_styles; |
1374 | XIMStyles *xim_styles; |
1371 | |
1375 | |
1372 | set_environ (envv); |
1376 | set_environ (env); |
1373 | |
1377 | |
1374 | if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) |
1378 | if (!((p = XSetLocaleModifiers (modifiers)) && *p)) |
1375 | return false; |
1379 | return false; |
1376 | |
1380 | |
1377 | input_method = display->get_xim (locale, modifiers); |
1381 | input_method = display->get_xim (locale, modifiers); |
1378 | if (input_method == NULL) |
1382 | if (input_method == NULL) |
1379 | return false; |
1383 | return false; |
… | |
… | |
1687 | rxvt_term::update_background () |
1691 | rxvt_term::update_background () |
1688 | { |
1692 | { |
1689 | if (update_background_ev.is_active ()) |
1693 | if (update_background_ev.is_active ()) |
1690 | return; |
1694 | return; |
1691 | |
1695 | |
1692 | bg_flags &= BG_INHIBIT_RENDER; |
|
|
1693 | |
|
|
1694 | if (!mapped) |
|
|
1695 | return; |
|
|
1696 | |
|
|
1697 | ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since); |
1696 | ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since); |
1698 | |
1697 | |
1699 | if (to_wait <= 0.) |
1698 | if (to_wait <= 0.) |
1700 | bg_render (); |
1699 | bg_render (); |
1701 | else |
1700 | else |