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.399 by sf-exg, Tue Oct 13 08:10:43 2015 UTC vs.
Revision 1.402 by sf-exg, Thu May 13 19:40:19 2021 UTC

59rxvt_t rxvt_current_term; 59rxvt_t rxvt_current_term;
60 60
61static char curlocale[128], savelocale[128]; 61static char curlocale[128], savelocale[128];
62 62
63bool 63bool
64rxvt_set_locale (const char *locale) NOTHROW 64rxvt_set_locale (const char *locale) noexcept
65{ 65{
66 int size = strlen (locale) + 1; 66 int size = strlen (locale) + 1;
67 67
68 if (size > sizeof (curlocale)) 68 if (size > sizeof (curlocale))
69 rxvt_fatal ("locale string too long, aborting.\n"); 69 rxvt_fatal ("locale string too long, aborting.\n");
75 setlocale (LC_CTYPE, curlocale); 75 setlocale (LC_CTYPE, curlocale);
76 return true; 76 return true;
77} 77}
78 78
79void 79void
80rxvt_push_locale (const char *locale) NOTHROW 80rxvt_push_locale (const char *locale) noexcept
81{ 81{
82 strcpy (savelocale, curlocale); 82 strcpy (savelocale, curlocale);
83 rxvt_set_locale (locale); 83 rxvt_set_locale (locale);
84} 84}
85 85
86void 86void
87rxvt_pop_locale () NOTHROW 87rxvt_pop_locale () noexcept
88{ 88{
89 rxvt_set_locale (savelocale); 89 rxvt_set_locale (savelocale);
90} 90}
91 91
92#if ENABLE_COMBINING 92#if ENABLE_COMBINING
151} 151}
152#endif 152#endif
153 153
154rxvt_term::rxvt_term () 154rxvt_term::rxvt_term ()
155{ 155{
156#if HAVE_BG_PIXMAP
157 update_background_ev.set<rxvt_term, &rxvt_term::update_background_cb> (this);
158#endif
159#ifdef CURSOR_BLINK 156#ifdef CURSOR_BLINK
160 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);
161#endif 158#endif
162#ifdef TEXT_BLINK 159#ifdef TEXT_BLINK
163 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);
169 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);
170#endif 167#endif
171#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 168#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
172 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);
173#endif 170#endif
174#if BG_IMAGE_FROM_ROOT || ENABLE_PERL 171#if ENABLE_PERL
175 rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this), 172 rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this),
176#endif 173#endif
177 scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), 174 scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this),
178#if USE_XIM 175#if USE_XIM
179 im_ev.set <rxvt_term, &rxvt_term::im_cb> (this), 176 im_ev.set <rxvt_term, &rxvt_term::im_cb> (this),
222 for (int i = RS_styleCount; --i; ) 219 for (int i = RS_styleCount; --i; )
223 if (fontset[i] != fontset[0]) 220 if (fontset[i] != fontset[0])
224 delete fontset[i]; 221 delete fontset[i];
225#endif 222#endif
226 delete fontset[0]; 223 delete fontset[0];
227
228#ifdef HAVE_BG_PIXMAP
229 bg_destroy ();
230#endif
231 224
232#if HAVE_IMG 225#if HAVE_IMG
233 delete bg_img; 226 delete bg_img;
234#endif 227#endif
235 228
327 { 320 {
328#if USE_XIM 321#if USE_XIM
329 im_ev.stop (display); 322 im_ev.stop (display);
330#endif 323#endif
331 scrollbar_ev.stop (display); 324 scrollbar_ev.stop (display);
332#if BG_IMAGE_FROM_ROOT || ENABLE_PERL 325#if ENABLE_PERL
333 rootwin_ev.stop (display); 326 rootwin_ev.stop (display);
334#endif 327#endif
335 termwin_ev.stop (display); 328 termwin_ev.stop (display);
336 vt_ev.stop (display); 329 vt_ev.stop (display);
337 } 330 }
364 357
365 delete this; 358 delete this;
366} 359}
367 360
368void 361void
369rxvt_term::set_option (uint8_t opt, bool set) NOTHROW 362rxvt_term::set_option (uint8_t opt, bool set) noexcept
370{ 363{
371 if (!opt) 364 if (!opt)
372 return; 365 return;
373 366
374 uint8_t mask = 1 << (opt & 7); 367 uint8_t mask = 1 << (opt & 7);
1022 1015
1023 for (i = Color_Black; i <= Color_White; i++) 1016 for (i = Color_Black; i <= Color_White; i++)
1024 if (pix_colors[Color_bg] == pix_colors[i]) 1017 if (pix_colors[Color_bg] == pix_colors[i])
1025 { 1018 {
1026 sprintf (bstr, "%d", i - Color_Black); 1019 sprintf (bstr, "%d", i - Color_Black);
1027#if BG_IMAGE_FROM_FILE 1020#if HAVE_IMG
1028 xpmb = "default;"; 1021 xpmb = "default;";
1029#endif 1022#endif
1030 break; 1023 break;
1031 } 1024 }
1032 1025
1051rxvt_term::alias_color (int dst, int src) 1044rxvt_term::alias_color (int dst, int src)
1052{ 1045{
1053 pix_colors[dst].free (this); 1046 pix_colors[dst].free (this);
1054 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]);
1055} 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
1056 1068
1057/* -------------------------------------------------------------------- * 1069/* -------------------------------------------------------------------- *
1058 * - WINDOW RESIZING - * 1070 * - WINDOW RESIZING - *
1059 * -------------------------------------------------------------------- */ 1071 * -------------------------------------------------------------------- */
1060void 1072void
1096 * 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
1097 * our position for handles and decorations. Counter it 1109 * our position for handles and decorations. Counter it
1098 */ 1110 */
1099 if (x1 != x || y1 != y) 1111 if (x1 != x || y1 != y)
1100 { 1112 {
1101 x -= x1; 1113 unsigned int border_width = get_parent_bw (dpy, parent);
1102 y -= y1; 1114
1115 x -= x1 + border_width;
1116 y -= y1 + border_width;
1103 } 1117 }
1104 1118
1105 x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2; 1119 x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2;
1106 y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2; 1120 y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2;
1107 dx = old_width - szHint.width; 1121 dx = old_width - szHint.width;
1137 XMoveResizeWindow (dpy, vt, 1151 XMoveResizeWindow (dpy, vt,
1138 window_vt_x, window_vt_y, 1152 window_vt_x, window_vt_y,
1139 vt_width, vt_height); 1153 vt_width, vt_height);
1140 1154
1141 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));
1142
1143#ifdef HAVE_BG_PIXMAP
1144 if (bg_window_size_sensitive ())
1145 update_background ();
1146#endif
1147 } 1156 }
1148 1157
1149 if (fix_screen || old_height == 0) 1158 if (fix_screen || old_height == 0)
1150 scr_reset (); 1159 scr_reset ();
1151 1160
1684{ 1693{
1685 Window cr; 1694 Window cr;
1686 XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr); 1695 XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr);
1687} 1696}
1688 1697
1689#ifdef HAVE_BG_PIXMAP
1690
1691void
1692rxvt_term::update_background ()
1693{
1694 if (update_background_ev.is_active ())
1695 return;
1696
1697 ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since);
1698
1699 if (to_wait <= 0.)
1700 bg_render ();
1701 else
1702 update_background_ev.start (to_wait);
1703}
1704
1705void
1706rxvt_term::update_background_cb (ev::timer &w, int revents)
1707{
1708 make_current ();
1709
1710 update_background_ev.stop ();
1711 bg_render ();
1712 refresh_check ();
1713}
1714
1715#endif /* HAVE_BG_PIXMAP */
1716
1717/*----------------------- end-of-file (C source) -----------------------*/ 1698/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines