… | |
… | |
252 | delete drawable; |
252 | delete drawable; |
253 | // destroy all windows |
253 | // destroy all windows |
254 | if (parent[0]) |
254 | if (parent[0]) |
255 | XDestroyWindow (xdisp, parent[0]); |
255 | XDestroyWindow (xdisp, parent[0]); |
256 | |
256 | |
|
|
257 | for (int i = 0; i < TOTAL_COLORS; i++) |
|
|
258 | if (ISSET_PIXCOLOR (i)) |
|
|
259 | { |
|
|
260 | pix_colors_focused [i].free (this); |
|
|
261 | #if OFF_FOCUS_FADING |
|
|
262 | pix_colors_unfocused [i].free (this); |
|
|
263 | #endif |
|
|
264 | } |
|
|
265 | |
257 | clear (); |
266 | clear (); |
258 | } |
267 | } |
259 | |
268 | |
260 | // TODO: free pixcolours, colours should become part of rxvt_display |
|
|
261 | delete pix_colors_focused; |
269 | delete pix_colors_focused; |
262 | #if OFF_FOCUS_FADING |
270 | #if OFF_FOCUS_FADING |
263 | delete pix_colors_unfocused; |
271 | delete pix_colors_unfocused; |
264 | #endif |
272 | #endif |
265 | |
273 | |
… | |
… | |
368 | { |
376 | { |
369 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
377 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
370 | (*t)->emergency_cleanup (); |
378 | (*t)->emergency_cleanup (); |
371 | } |
379 | } |
372 | |
380 | |
373 | #if ENABLE_FRILLS |
381 | #if !ENABLE_MINIMAL |
374 | static void |
382 | static void |
375 | print_x_error (Display *dpy, XErrorEvent *event) |
383 | print_x_error (Display *dpy, XErrorEvent *event) |
376 | { |
384 | { |
377 | char buffer[BUFSIZ]; |
385 | char buffer[BUFSIZ]; |
378 | char mesg[BUFSIZ]; |
386 | char mesg[BUFSIZ]; |
… | |
… | |
426 | GET_R->allowedxerror = event->error_code; |
434 | GET_R->allowedxerror = event->error_code; |
427 | else |
435 | else |
428 | { |
436 | { |
429 | // GET_R is most likely not the terminal which caused the error, |
437 | // GET_R is most likely not the terminal which caused the error, |
430 | // so just output the error and continue |
438 | // so just output the error and continue |
431 | #if ENABLE_FRILLS |
439 | #if ENABLE_MINIMAL |
|
|
440 | old_xerror_handler (display, event); |
|
|
441 | #else |
432 | print_x_error (display, event); |
442 | print_x_error (display, event); |
433 | #else |
|
|
434 | old_xerror_handler (display, event); |
|
|
435 | #endif |
443 | #endif |
436 | } |
444 | } |
437 | |
445 | |
438 | return 0; |
446 | return 0; |
439 | } |
447 | } |
… | |
… | |
691 | |
699 | |
692 | if (scrollBar.state) |
700 | if (scrollBar.state) |
693 | { |
701 | { |
694 | sb_w = scrollbar_TotalWidth (); |
702 | sb_w = scrollbar_TotalWidth (); |
695 | szHint.base_width += sb_w; |
703 | szHint.base_width += sb_w; |
|
|
704 | |
696 | if (!OPTION (Opt_scrollBar_right)) |
705 | if (!OPTION (Opt_scrollBar_right)) |
697 | window_vt_x += sb_w; |
706 | window_vt_x += sb_w; |
698 | } |
707 | } |
699 | |
708 | |
700 | szHint.width_inc = fwidth; |
709 | szHint.width_inc = fwidth; |
… | |
… | |
887 | void |
896 | void |
888 | rxvt_term::set_window_color (int idx, const char *color) |
897 | rxvt_term::set_window_color (int idx, const char *color) |
889 | { |
898 | { |
890 | rxvt_color xcol; |
899 | rxvt_color xcol; |
891 | int i; |
900 | int i; |
892 | |
901 | |
893 | if (color == NULL || *color == '\0') |
902 | if (color == NULL || *color == '\0') |
894 | return; |
903 | return; |
|
|
904 | |
|
|
905 | color = strdup (color); |
|
|
906 | allocated.push_back ((void *)color); |
|
|
907 | rs[Rs_color + idx] = color; |
895 | |
908 | |
896 | /* handle color aliases */ |
909 | /* handle color aliases */ |
897 | if (isdigit (*color)) |
910 | if (isdigit (*color)) |
898 | { |
911 | { |
899 | i = atoi (color); |
912 | i = atoi (color); |
900 | |
913 | |
901 | if (i >= 8 && i <= 15) |
914 | if (i >= 8 && i <= 15) |
902 | { /* bright colors */ |
915 | { /* bright colors */ |
903 | i -= 8; |
916 | i -= 8; |
904 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; |
917 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; |
905 | SET_PIXCOLOR (idx); |
|
|
906 | goto done; |
918 | goto done; |
907 | } |
919 | } |
908 | |
920 | |
909 | if (i >= 0 && i <= 7) |
921 | if (i >= 0 && i <= 7) |
910 | { /* normal colors */ |
922 | { /* normal colors */ |
911 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
923 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
912 | SET_PIXCOLOR (idx); |
|
|
913 | goto done; |
924 | goto done; |
914 | } |
925 | } |
915 | } |
926 | } |
916 | |
927 | |
917 | if (!set_color (xcol, color)) |
928 | set_color (xcol, color); |
918 | return; |
|
|
919 | |
|
|
920 | /* XStoreColor (xdisp, display->cmap, XColor*); */ |
|
|
921 | |
929 | |
922 | /* |
930 | /* |
923 | * FIXME: should free colors here, but no idea how to do it so instead, |
931 | * FIXME: should free colors here, but no idea how to do it so instead, |
924 | * so just keep gobbling up the colormap |
932 | * so just keep gobbling up the colormap |
925 | */ |
933 | */ |
926 | # if 0 |
|
|
927 | for (i = Color_Black; i <= Color_White; i++) |
|
|
928 | if (pix_colors[idx] == pix_colors[i]) |
|
|
929 | break; |
|
|
930 | if (i > Color_White) |
|
|
931 | { |
|
|
932 | /* fprintf (stderr, "XFreeColors: pix_colors [%d] = %lu\n", idx, pix_colors [idx]); */ |
|
|
933 | XFreeColors (xdisp, display->cmap, (pix_colors + idx), 1, |
|
|
934 | DisplayPlanes (xdisp, display->screen)); |
|
|
935 | } |
|
|
936 | # endif |
|
|
937 | |
934 | |
938 | pix_colors_focused[idx] = xcol; |
935 | pix_colors_focused[idx] = xcol; |
939 | SET_PIXCOLOR (idx); |
|
|
940 | |
936 | |
941 | /* XSetWindowAttributes attr; */ |
937 | /* XSetWindowAttributes attr; */ |
942 | /* Cursor cursor; */ |
938 | /* Cursor cursor; */ |
943 | done: |
939 | done: |
944 | |
940 | |
945 | #if OFF_FOCUS_FADING |
941 | #if OFF_FOCUS_FADING |
946 | if (rs[Rs_fade]) |
942 | if (rs[Rs_fade]) |
947 | pix_colors_unfocused[idx] = pix_colors_focused[idx].fade (this, atoi (rs[Rs_fade]), pix_colors[Color_fade]); |
943 | { |
|
|
944 | rgba c; |
|
|
945 | pix_colors [Color_fade].get (c); |
|
|
946 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
947 | } |
948 | #endif |
948 | #endif |
949 | |
949 | |
950 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
950 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
951 | |
951 | |
952 | recolour_cursor (); |
952 | recolour_cursor (); |
… | |
… | |
958 | #endif /* XTERM_COLOR_CHANGE */ |
958 | #endif /* XTERM_COLOR_CHANGE */ |
959 | |
959 | |
960 | void |
960 | void |
961 | rxvt_term::recolour_cursor () |
961 | rxvt_term::recolour_cursor () |
962 | { |
962 | { |
963 | XColor xcol[2]; |
963 | XColor fg, bg; |
964 | |
964 | |
965 | xcol[0].pixel = ISSET_PIXCOLOR (Color_pointer_fg) |
965 | (ISSET_PIXCOLOR (Color_pointer_fg) |
966 | ? pix_colors_focused[Color_pointer_fg] |
966 | ? pix_colors_focused[Color_pointer_fg] |
967 | : pix_colors_focused[Color_fg]; |
967 | : pix_colors_focused[Color_fg]).get (fg); |
|
|
968 | |
968 | xcol[1].pixel = ISSET_PIXCOLOR (Color_pointer_bg) |
969 | (ISSET_PIXCOLOR (Color_pointer_bg) |
969 | ? pix_colors_focused[Color_pointer_bg] |
970 | ? pix_colors_focused[Color_pointer_bg] |
970 | : pix_colors_focused[Color_bg]; |
971 | : pix_colors_focused[Color_bg]).get (bg); |
971 | |
972 | |
972 | XQueryColors (xdisp, cmap, xcol, 2); |
|
|
973 | XRecolorCursor (xdisp, TermWin_cursor, xcol + 0, xcol + 1); |
973 | XRecolorCursor (xdisp, TermWin_cursor, &fg, &bg); |
974 | } |
974 | } |
975 | |
975 | |
976 | /*----------------------------------------------------------------------*/ |
976 | /*----------------------------------------------------------------------*/ |
977 | /* |
977 | /* |
978 | * find if fg/bg matches any of the normal (low-intensity) colors |
978 | * find if fg/bg matches any of the normal (low-intensity) colors |
… | |
… | |
1014 | if (color.set (this, name)) |
1014 | if (color.set (this, name)) |
1015 | return true; |
1015 | return true; |
1016 | |
1016 | |
1017 | rxvt_warn ("can't get colour '%s', continuing without.\n", name); |
1017 | rxvt_warn ("can't get colour '%s', continuing without.\n", name); |
1018 | return false; |
1018 | return false; |
|
|
1019 | } |
|
|
1020 | |
|
|
1021 | void |
|
|
1022 | rxvt_term::alias_color (int dst, int src) |
|
|
1023 | { |
|
|
1024 | pix_colors[dst].set (this, rs[Rs_color + dst] = rs[Rs_color + src]); |
1019 | } |
1025 | } |
1020 | |
1026 | |
1021 | /* -------------------------------------------------------------------- * |
1027 | /* -------------------------------------------------------------------- * |
1022 | * - WINDOW RESIZING - * |
1028 | * - WINDOW RESIZING - * |
1023 | * -------------------------------------------------------------------- */ |
1029 | * -------------------------------------------------------------------- */ |
… | |
… | |
1147 | #ifdef USE_XIM |
1153 | #ifdef USE_XIM |
1148 | |
1154 | |
1149 | void |
1155 | void |
1150 | rxvt_term::im_set_color (unsigned long &fg, unsigned long &bg) |
1156 | rxvt_term::im_set_color (unsigned long &fg, unsigned long &bg) |
1151 | { |
1157 | { |
1152 | fg = pix_colors[Color_fg]; |
1158 | fg = pix_colors [Color_fg]; |
1153 | bg = pix_colors[Color_bg]; |
1159 | bg = pix_colors [Color_bg]; |
1154 | } |
1160 | } |
1155 | |
1161 | |
1156 | void |
1162 | void |
1157 | rxvt_term::im_set_size (XRectangle &size) |
1163 | rxvt_term::im_set_size (XRectangle &size) |
1158 | { |
1164 | { |