… | |
… | |
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-2014 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 3 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. |
… | |
… | |
58 | rxvt_t rxvt_current_term; |
59 | rxvt_t rxvt_current_term; |
59 | |
60 | |
60 | static char curlocale[128], savelocale[128]; |
61 | static char curlocale[128], savelocale[128]; |
61 | |
62 | |
62 | bool |
63 | bool |
63 | rxvt_set_locale (const char *locale) NOTHROW |
64 | rxvt_set_locale (const char *locale) noexcept |
64 | { |
65 | { |
65 | int size = strlen (locale) + 1; |
66 | int size = strlen (locale) + 1; |
66 | |
67 | |
67 | if (size > sizeof (curlocale)) |
68 | if (size > sizeof (curlocale)) |
68 | rxvt_fatal ("locale string too long, aborting.\n"); |
69 | rxvt_fatal ("locale string too long, aborting.\n"); |
… | |
… | |
74 | setlocale (LC_CTYPE, curlocale); |
75 | setlocale (LC_CTYPE, curlocale); |
75 | return true; |
76 | return true; |
76 | } |
77 | } |
77 | |
78 | |
78 | void |
79 | void |
79 | rxvt_push_locale (const char *locale) NOTHROW |
80 | rxvt_push_locale (const char *locale) noexcept |
80 | { |
81 | { |
81 | strcpy (savelocale, curlocale); |
82 | strcpy (savelocale, curlocale); |
82 | rxvt_set_locale (locale); |
83 | rxvt_set_locale (locale); |
83 | } |
84 | } |
84 | |
85 | |
85 | void |
86 | void |
86 | rxvt_pop_locale () NOTHROW |
87 | rxvt_pop_locale () noexcept |
87 | { |
88 | { |
88 | rxvt_set_locale (savelocale); |
89 | rxvt_set_locale (savelocale); |
89 | } |
90 | } |
90 | |
91 | |
91 | #if ENABLE_COMBINING |
92 | #if ENABLE_COMBINING |
… | |
… | |
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 BG_IMAGE_FROM_ROOT || 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 | #if 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), |
… | |
… | |
221 | for (int i = RS_styleCount; --i; ) |
219 | for (int i = RS_styleCount; --i; ) |
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 | |
|
|
227 | #ifdef HAVE_BG_PIXMAP |
|
|
228 | bg_destroy (); |
|
|
229 | #endif |
|
|
230 | |
224 | |
231 | #if HAVE_IMG |
225 | #if HAVE_IMG |
232 | delete bg_img; |
226 | delete bg_img; |
233 | #endif |
227 | #endif |
234 | |
228 | |
… | |
… | |
281 | delete selection_req; |
275 | delete selection_req; |
282 | |
276 | |
283 | if (env && memcmp (env, envv->begin (), envv->size () * sizeof (char *))) |
277 | 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"); |
278 | rxvt_warn ("env has been modified, probably as a result of a lib calling setenv.\n"); |
285 | |
279 | |
286 | delete env; |
280 | delete [] env; |
287 | |
281 | |
288 | delete envv; |
282 | delete envv; |
289 | delete argv; |
283 | delete argv; |
290 | |
284 | |
291 | #ifdef KEYSYM_RESOURCE |
285 | #ifdef KEYSYM_RESOURCE |
… | |
… | |
326 | { |
320 | { |
327 | #if USE_XIM |
321 | #if USE_XIM |
328 | im_ev.stop (display); |
322 | im_ev.stop (display); |
329 | #endif |
323 | #endif |
330 | scrollbar_ev.stop (display); |
324 | scrollbar_ev.stop (display); |
331 | #if BG_IMAGE_FROM_ROOT || ENABLE_PERL |
325 | #if ENABLE_PERL |
332 | rootwin_ev.stop (display); |
326 | rootwin_ev.stop (display); |
333 | #endif |
327 | #endif |
334 | termwin_ev.stop (display); |
328 | termwin_ev.stop (display); |
335 | vt_ev.stop (display); |
329 | vt_ev.stop (display); |
336 | } |
330 | } |
… | |
… | |
363 | |
357 | |
364 | delete this; |
358 | delete this; |
365 | } |
359 | } |
366 | |
360 | |
367 | void |
361 | void |
368 | rxvt_term::set_option (uint8_t opt, bool set) NOTHROW |
362 | rxvt_term::set_option (uint8_t opt, bool set) noexcept |
369 | { |
363 | { |
370 | if (!opt) |
364 | if (!opt) |
371 | return; |
365 | return; |
372 | |
366 | |
373 | uint8_t mask = 1 << (opt & 7); |
367 | uint8_t mask = 1 << (opt & 7); |
… | |
… | |
942 | |
936 | |
943 | void |
937 | void |
944 | rxvt_term::set_window_color (int idx, const char *color) |
938 | rxvt_term::set_window_color (int idx, const char *color) |
945 | { |
939 | { |
946 | #ifdef XTERM_COLOR_CHANGE |
940 | #ifdef XTERM_COLOR_CHANGE |
947 | rxvt_color xcol; |
|
|
948 | |
|
|
949 | if (color == NULL || *color == '\0') |
941 | if (color == NULL || *color == '\0') |
950 | return; |
942 | return; |
951 | |
943 | |
952 | color = strdup (color); |
944 | color = strdup (color); |
953 | allocated.push_back ((void *)color); |
945 | allocated.push_back ((void *)color); |
… | |
… | |
959 | int i = atoi (color); |
951 | int i = atoi (color); |
960 | |
952 | |
961 | if (i >= 8 && i <= 15) |
953 | if (i >= 8 && i <= 15) |
962 | { |
954 | { |
963 | /* bright colors */ |
955 | /* bright colors */ |
964 | pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; |
956 | alias_color (idx, minBrightCOLOR + i - 8); |
965 | goto done; |
957 | goto done; |
966 | } |
958 | } |
967 | |
959 | |
968 | if (i >= 0 && i <= 7) |
960 | if (i >= 0 && i <= 7) |
969 | { |
961 | { |
970 | /* normal colors */ |
962 | /* normal colors */ |
971 | pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; |
963 | alias_color (idx, minCOLOR + i); |
972 | goto done; |
964 | goto done; |
973 | } |
965 | } |
974 | } |
966 | } |
975 | |
967 | |
976 | set_color (xcol, color); |
968 | pix_colors_focused[idx].free (this); |
977 | |
969 | set_color (pix_colors_focused[idx], color); |
978 | /* |
|
|
979 | * FIXME: should free colors here, but no idea how to do it so instead, |
|
|
980 | * so just keep gobbling up the colormap |
|
|
981 | */ |
|
|
982 | |
|
|
983 | pix_colors_focused[idx] = xcol; |
|
|
984 | |
970 | |
985 | done: |
971 | done: |
986 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
972 | /*TODO: handle Color_BD, scrollbar background, etc. */ |
987 | |
973 | |
988 | update_fade_color (idx); |
974 | update_fade_color (idx); |
989 | recolour_cursor (); |
975 | recolor_cursor (); |
990 | scr_recolour (); |
976 | scr_recolor (); |
991 | #endif /* XTERM_COLOR_CHANGE */ |
977 | #endif /* XTERM_COLOR_CHANGE */ |
992 | } |
978 | } |
993 | |
979 | |
994 | void |
980 | void |
995 | rxvt_term::recolour_cursor () |
981 | rxvt_term::recolor_cursor () |
996 | { |
982 | { |
997 | XColor fg, bg; |
983 | XColor fg, bg; |
998 | |
984 | |
999 | (ISSET_PIXCOLOR (Color_pointer_fg) |
985 | (ISSET_PIXCOLOR (Color_pointer_fg) |
1000 | ? pix_colors_focused[Color_pointer_fg] |
986 | ? pix_colors_focused[Color_pointer_fg] |
… | |
… | |
1029 | |
1015 | |
1030 | for (i = Color_Black; i <= Color_White; i++) |
1016 | for (i = Color_Black; i <= Color_White; i++) |
1031 | if (pix_colors[Color_bg] == pix_colors[i]) |
1017 | if (pix_colors[Color_bg] == pix_colors[i]) |
1032 | { |
1018 | { |
1033 | sprintf (bstr, "%d", i - Color_Black); |
1019 | sprintf (bstr, "%d", i - Color_Black); |
1034 | #if BG_IMAGE_FROM_FILE |
1020 | #if HAVE_IMG |
1035 | xpmb = "default;"; |
1021 | xpmb = "default;"; |
1036 | #endif |
1022 | #endif |
1037 | break; |
1023 | break; |
1038 | } |
1024 | } |
1039 | |
1025 | |
… | |
… | |
1055 | } |
1041 | } |
1056 | |
1042 | |
1057 | void |
1043 | void |
1058 | rxvt_term::alias_color (int dst, int src) |
1044 | rxvt_term::alias_color (int dst, int src) |
1059 | { |
1045 | { |
|
|
1046 | pix_colors[dst].free (this); |
1060 | 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]); |
1061 | } |
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 |
1062 | |
1068 | |
1063 | /* -------------------------------------------------------------------- * |
1069 | /* -------------------------------------------------------------------- * |
1064 | * - WINDOW RESIZING - * |
1070 | * - WINDOW RESIZING - * |
1065 | * -------------------------------------------------------------------- */ |
1071 | * -------------------------------------------------------------------- */ |
1066 | void |
1072 | void |
… | |
… | |
1102 | * 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 |
1103 | * our position for handles and decorations. Counter it |
1109 | * our position for handles and decorations. Counter it |
1104 | */ |
1110 | */ |
1105 | if (x1 != x || y1 != y) |
1111 | if (x1 != x || y1 != y) |
1106 | { |
1112 | { |
1107 | x -= x1; |
1113 | unsigned int border_width = get_parent_bw (dpy, parent); |
1108 | y -= y1; |
1114 | |
|
|
1115 | x -= x1 + border_width; |
|
|
1116 | y -= y1 + border_width; |
1109 | } |
1117 | } |
1110 | |
1118 | |
1111 | x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2; |
1119 | x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2; |
1112 | y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2; |
1120 | y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2; |
1113 | dx = old_width - szHint.width; |
1121 | dx = old_width - szHint.width; |
… | |
… | |
1143 | XMoveResizeWindow (dpy, vt, |
1151 | XMoveResizeWindow (dpy, vt, |
1144 | window_vt_x, window_vt_y, |
1152 | window_vt_x, window_vt_y, |
1145 | vt_width, vt_height); |
1153 | vt_width, vt_height); |
1146 | |
1154 | |
1147 | HOOK_INVOKE ((this, HOOK_SIZE_CHANGE, DT_INT, newwidth, DT_INT, newheight, DT_END)); |
1155 | HOOK_INVOKE ((this, HOOK_SIZE_CHANGE, DT_INT, newwidth, DT_INT, newheight, DT_END)); |
1148 | |
|
|
1149 | #ifdef HAVE_BG_PIXMAP |
|
|
1150 | if (bg_window_size_sensitive ()) |
|
|
1151 | update_background (); |
|
|
1152 | #endif |
|
|
1153 | } |
1156 | } |
1154 | |
1157 | |
1155 | if (fix_screen || old_height == 0) |
1158 | if (fix_screen || old_height == 0) |
1156 | scr_reset (); |
1159 | scr_reset (); |
1157 | |
1160 | |
… | |
… | |
1690 | { |
1693 | { |
1691 | Window cr; |
1694 | Window cr; |
1692 | XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr); |
1695 | XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr); |
1693 | } |
1696 | } |
1694 | |
1697 | |
1695 | #ifdef HAVE_BG_PIXMAP |
|
|
1696 | |
|
|
1697 | void |
|
|
1698 | rxvt_term::update_background () |
|
|
1699 | { |
|
|
1700 | if (update_background_ev.is_active ()) |
|
|
1701 | return; |
|
|
1702 | |
|
|
1703 | ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since); |
|
|
1704 | |
|
|
1705 | if (to_wait <= 0.) |
|
|
1706 | bg_render (); |
|
|
1707 | else |
|
|
1708 | update_background_ev.start (to_wait); |
|
|
1709 | } |
|
|
1710 | |
|
|
1711 | void |
|
|
1712 | rxvt_term::update_background_cb (ev::timer &w, int revents) |
|
|
1713 | { |
|
|
1714 | make_current (); |
|
|
1715 | |
|
|
1716 | update_background_ev.stop (); |
|
|
1717 | bg_render (); |
|
|
1718 | refresh_check (); |
|
|
1719 | } |
|
|
1720 | |
|
|
1721 | #endif /* HAVE_BG_PIXMAP */ |
|
|
1722 | |
|
|
1723 | /*----------------------- end-of-file (C source) -----------------------*/ |
1698 | /*----------------------- end-of-file (C source) -----------------------*/ |