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.397 by root, Sat Dec 13 12:24:32 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),
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 }
1021 1015
1022 for (i = Color_Black; i <= Color_White; i++) 1016 for (i = Color_Black; i <= Color_White; i++)
1023 if (pix_colors[Color_bg] == pix_colors[i]) 1017 if (pix_colors[Color_bg] == pix_colors[i])
1024 { 1018 {
1025 sprintf (bstr, "%d", i - Color_Black); 1019 sprintf (bstr, "%d", i - Color_Black);
1026#if BG_IMAGE_FROM_FILE 1020#if HAVE_IMG
1027 xpmb = "default;"; 1021 xpmb = "default;";
1028#endif 1022#endif
1029 break; 1023 break;
1030 } 1024 }
1031 1025
1050rxvt_term::alias_color (int dst, int src) 1044rxvt_term::alias_color (int dst, int src)
1051{ 1045{
1052 pix_colors[dst].free (this); 1046 pix_colors[dst].free (this);
1053 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]);
1054} 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
1055 1068
1056/* -------------------------------------------------------------------- * 1069/* -------------------------------------------------------------------- *
1057 * - WINDOW RESIZING - * 1070 * - WINDOW RESIZING - *
1058 * -------------------------------------------------------------------- */ 1071 * -------------------------------------------------------------------- */
1059void 1072void
1095 * 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
1096 * our position for handles and decorations. Counter it 1109 * our position for handles and decorations. Counter it
1097 */ 1110 */
1098 if (x1 != x || y1 != y) 1111 if (x1 != x || y1 != y)
1099 { 1112 {
1100 x -= x1; 1113 unsigned int border_width = get_parent_bw (dpy, parent);
1101 y -= y1; 1114
1115 x -= x1 + border_width;
1116 y -= y1 + border_width;
1102 } 1117 }
1103 1118
1104 x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2; 1119 x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2;
1105 y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2; 1120 y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2;
1106 dx = old_width - szHint.width; 1121 dx = old_width - szHint.width;
1136 XMoveResizeWindow (dpy, vt, 1151 XMoveResizeWindow (dpy, vt,
1137 window_vt_x, window_vt_y, 1152 window_vt_x, window_vt_y,
1138 vt_width, vt_height); 1153 vt_width, vt_height);
1139 1154
1140 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));
1141
1142#ifdef HAVE_BG_PIXMAP
1143 if (bg_window_size_sensitive ())
1144 update_background ();
1145#endif
1146 } 1156 }
1147 1157
1148 if (fix_screen || old_height == 0) 1158 if (fix_screen || old_height == 0)
1149 scr_reset (); 1159 scr_reset ();
1150 1160
1683{ 1693{
1684 Window cr; 1694 Window cr;
1685 XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr); 1695 XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr);
1686} 1696}
1687 1697
1688#ifdef HAVE_BG_PIXMAP
1689
1690void
1691rxvt_term::update_background ()
1692{
1693 if (update_background_ev.is_active ())
1694 return;
1695
1696 ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since);
1697
1698 if (to_wait <= 0.)
1699 bg_render ();
1700 else
1701 update_background_ev.start (to_wait);
1702}
1703
1704void
1705rxvt_term::update_background_cb (ev::timer &w, int revents)
1706{
1707 make_current ();
1708
1709 update_background_ev.stop ();
1710 bg_render ();
1711 refresh_check ();
1712}
1713
1714#endif /* HAVE_BG_PIXMAP */
1715
1716/*----------------------- end-of-file (C source) -----------------------*/ 1698/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines