ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/main.C
(Generate patch)

Comparing rxvt-unicode/src/main.C (file contents):
Revision 1.394 by root, Sat Dec 13 10:07:30 2014 UTC vs.
Revision 1.401 by sf-exg, Thu Jul 14 05:33:26 2016 UTC

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.
150} 151}
151#endif 152#endif
152 153
153rxvt_term::rxvt_term () 154rxvt_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),
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
228 bg_destroy ();
229#endif
230
231#if HAVE_IMG 225#if HAVE_IMG
232 delete bg_img; 226 delete bg_img;
233#endif 227#endif
234 228
235 if (display) 229 if (display)
254 for (int i = 0; i < TOTAL_COLORS; i++) 248 for (int i = 0; i < TOTAL_COLORS; i++)
255 if (ISSET_PIXCOLOR (i)) 249 if (ISSET_PIXCOLOR (i))
256 { 250 {
257 pix_colors_focused [i].free (this); 251 pix_colors_focused [i].free (this);
258#if OFF_FOCUS_FADING 252#if OFF_FOCUS_FADING
253 if (rs[Rs_fade])
259 pix_colors_unfocused [i].free (this); 254 pix_colors_unfocused [i].free (this);
260#endif 255#endif
261 } 256 }
262 257
263 clear (); 258 clear ();
264 259
280 delete selection_req; 275 delete selection_req;
281 276
282 if (env && memcmp (env, envv->begin (), envv->size () * sizeof (char *))) 277 if (env && memcmp (env, envv->begin (), envv->size () * sizeof (char *)))
283 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");
284 279
285 delete env; 280 delete [] env;
286 281
287 delete envv; 282 delete envv;
288 delete argv; 283 delete argv;
289 284
290#ifdef KEYSYM_RESOURCE 285#ifdef KEYSYM_RESOURCE
325 { 320 {
326#if USE_XIM 321#if USE_XIM
327 im_ev.stop (display); 322 im_ev.stop (display);
328#endif 323#endif
329 scrollbar_ev.stop (display); 324 scrollbar_ev.stop (display);
330#if BG_IMAGE_FROM_ROOT || ENABLE_PERL 325#if ENABLE_PERL
331 rootwin_ev.stop (display); 326 rootwin_ev.stop (display);
332#endif 327#endif
333 termwin_ev.stop (display); 328 termwin_ev.stop (display);
334 vt_ev.stop (display); 329 vt_ev.stop (display);
335 } 330 }
941 936
942void 937void
943rxvt_term::set_window_color (int idx, const char *color) 938rxvt_term::set_window_color (int idx, const char *color)
944{ 939{
945#ifdef XTERM_COLOR_CHANGE 940#ifdef XTERM_COLOR_CHANGE
946 rxvt_color xcol;
947
948 if (color == NULL || *color == '\0') 941 if (color == NULL || *color == '\0')
949 return; 942 return;
950 943
951 color = strdup (color); 944 color = strdup (color);
952 allocated.push_back ((void *)color); 945 allocated.push_back ((void *)color);
958 int i = atoi (color); 951 int i = atoi (color);
959 952
960 if (i >= 8 && i <= 15) 953 if (i >= 8 && i <= 15)
961 { 954 {
962 /* bright colors */ 955 /* bright colors */
963 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; 956 alias_color (idx, minBrightCOLOR + i - 8);
964 goto done; 957 goto done;
965 } 958 }
966 959
967 if (i >= 0 && i <= 7) 960 if (i >= 0 && i <= 7)
968 { 961 {
969 /* normal colors */ 962 /* normal colors */
970 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; 963 alias_color (idx, minCOLOR + i);
971 goto done; 964 goto done;
972 } 965 }
973 } 966 }
974 967
975 set_color (xcol, color); 968 pix_colors_focused[idx].free (this);
976 969 set_color (pix_colors_focused[idx], color);
977 /*
978 * FIXME: should free colors here, but no idea how to do it so instead,
979 * so just keep gobbling up the colormap
980 */
981
982 pix_colors_focused[idx] = xcol;
983 970
984done: 971done:
985 /*TODO: handle Color_BD, scrollbar background, etc. */ 972 /*TODO: handle Color_BD, scrollbar background, etc. */
986 973
987 update_fade_color (idx); 974 update_fade_color (idx);
988 recolour_cursor (); 975 recolor_cursor ();
989 scr_recolour (); 976 scr_recolor ();
990#endif /* XTERM_COLOR_CHANGE */ 977#endif /* XTERM_COLOR_CHANGE */
991} 978}
992 979
993void 980void
994rxvt_term::recolour_cursor () 981rxvt_term::recolor_cursor ()
995{ 982{
996 XColor fg, bg; 983 XColor fg, bg;
997 984
998 (ISSET_PIXCOLOR (Color_pointer_fg) 985 (ISSET_PIXCOLOR (Color_pointer_fg)
999 ? pix_colors_focused[Color_pointer_fg] 986 ? pix_colors_focused[Color_pointer_fg]
1028 1015
1029 for (i = Color_Black; i <= Color_White; i++) 1016 for (i = Color_Black; i <= Color_White; i++)
1030 if (pix_colors[Color_bg] == pix_colors[i]) 1017 if (pix_colors[Color_bg] == pix_colors[i])
1031 { 1018 {
1032 sprintf (bstr, "%d", i - Color_Black); 1019 sprintf (bstr, "%d", i - Color_Black);
1033#if BG_IMAGE_FROM_FILE 1020#if HAVE_IMG
1034 xpmb = "default;"; 1021 xpmb = "default;";
1035#endif 1022#endif
1036 break; 1023 break;
1037 } 1024 }
1038 1025
1054} 1041}
1055 1042
1056void 1043void
1057rxvt_term::alias_color (int dst, int src) 1044rxvt_term::alias_color (int dst, int src)
1058{ 1045{
1046 pix_colors[dst].free (this);
1059 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]);
1060} 1048}
1049
1050#ifdef SMART_RESIZE
1051static unsigned int
1052get_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
1061 1068
1062/* -------------------------------------------------------------------- * 1069/* -------------------------------------------------------------------- *
1063 * - WINDOW RESIZING - * 1070 * - WINDOW RESIZING - *
1064 * -------------------------------------------------------------------- */ 1071 * -------------------------------------------------------------------- */
1065void 1072void
1101 * 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
1102 * our position for handles and decorations. Counter it 1109 * our position for handles and decorations. Counter it
1103 */ 1110 */
1104 if (x1 != x || y1 != y) 1111 if (x1 != x || y1 != y)
1105 { 1112 {
1106 x -= x1; 1113 unsigned int border_width = get_parent_bw (dpy, parent);
1107 y -= y1; 1114
1115 x -= x1 + border_width;
1116 y -= y1 + border_width;
1108 } 1117 }
1109 1118
1110 x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2; 1119 x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2;
1111 y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2; 1120 y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2;
1112 dx = old_width - szHint.width; 1121 dx = old_width - szHint.width;
1142 XMoveResizeWindow (dpy, vt, 1151 XMoveResizeWindow (dpy, vt,
1143 window_vt_x, window_vt_y, 1152 window_vt_x, window_vt_y,
1144 vt_width, vt_height); 1153 vt_width, vt_height);
1145 1154
1146 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));
1147
1148#ifdef HAVE_BG_PIXMAP
1149 if (bg_window_size_sensitive ())
1150 update_background ();
1151#endif
1152 } 1156 }
1153 1157
1154 if (fix_screen || old_height == 0) 1158 if (fix_screen || old_height == 0)
1155 scr_reset (); 1159 scr_reset ();
1156 1160
1689{ 1693{
1690 Window cr; 1694 Window cr;
1691 XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr); 1695 XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr);
1692} 1696}
1693 1697
1694#ifdef HAVE_BG_PIXMAP
1695
1696void
1697rxvt_term::update_background ()
1698{
1699 if (update_background_ev.is_active ())
1700 return;
1701
1702 ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since);
1703
1704 if (to_wait <= 0.)
1705 bg_render ();
1706 else
1707 update_background_ev.start (to_wait);
1708}
1709
1710void
1711rxvt_term::update_background_cb (ev::timer &w, int revents)
1712{
1713 make_current ();
1714
1715 update_background_ev.stop ();
1716 bg_render ();
1717 refresh_check ();
1718}
1719
1720#endif /* HAVE_BG_PIXMAP */
1721
1722/*----------------------- end-of-file (C source) -----------------------*/ 1698/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines