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.382 by root, Tue Jun 5 12:04:55 2012 UTC vs.
Revision 1.403 by root, Thu Jun 17 00:49:20 2021 UTC

11 * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA> 11 * Copyright (c) 1997 mj olesen <olesen@me.QueensU.CA>
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-2010 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 2 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.
22 * 23 *
23 * This program is distributed in the hope that it will be useful, 24 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of 25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58rxvt_t rxvt_current_term; 59rxvt_t rxvt_current_term;
59 60
60static char curlocale[128], savelocale[128]; 61static char curlocale[128], savelocale[128];
61 62
62bool 63bool
63rxvt_set_locale (const char *locale) NOTHROW 64rxvt_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
78void 79void
79rxvt_push_locale (const char *locale) NOTHROW 80rxvt_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
85void 86void
86rxvt_pop_locale () NOTHROW 87rxvt_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
123 v.push_back (compose_char (c1, c2)); 124 v.push_back (compose_char (c1, c2));
124 125
125 return v.size () - 1 + COMPOSE_LO; 126 return v.size () - 1 + COMPOSE_LO;
126} 127}
127 128
129template<typename T>
128int rxvt_composite_vec::expand (unicode_t c, wchar_t *r) 130int rxvt_composite_vec::expand (unicode_t c, T *r)
129{ 131{
130 compose_char *cc = (*this)[c]; 132 compose_char *cc = (*this)[c];
131 133
132 if (!cc) 134 if (!cc)
133 { 135 {
144 len++; 146 len++;
145 if (r) *r++ = cc->c2; 147 if (r) *r++ = cc->c2;
146 } 148 }
147 149
148 return len; 150 return len;
149
150} 151}
152
153template int rxvt_composite_vec::expand<text_t> (unicode_t c, text_t *);
154template int rxvt_composite_vec::expand<wchar_t> (unicode_t c, wchar_t *);
151#endif 155#endif
152 156
153rxvt_term::rxvt_term () 157rxvt_term::rxvt_term ()
154{ 158{
155#if HAVE_BG_PIXMAP
156 update_background_ev.set<rxvt_term, &rxvt_term::update_background_cb> (this);
157#endif
158#ifdef CURSOR_BLINK 159#ifdef CURSOR_BLINK
159 cursor_blink_ev.set <rxvt_term, &rxvt_term::cursor_blink_cb> (this); cursor_blink_ev.set (0., CURSOR_BLINK_INTERVAL); 160 cursor_blink_ev.set <rxvt_term, &rxvt_term::cursor_blink_cb> (this); cursor_blink_ev.set (0., CURSOR_BLINK_INTERVAL);
160#endif 161#endif
161#ifdef TEXT_BLINK 162#ifdef TEXT_BLINK
162 text_blink_ev.set <rxvt_term, &rxvt_term::text_blink_cb> (this); text_blink_ev.set (0., TEXT_BLINK_INTERVAL); 163 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); 169 sel_scroll_ev.set <rxvt_term, &rxvt_term::sel_scroll_cb> (this);
169#endif 170#endif
170#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 171#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
171 slip_wheel_ev.set <rxvt_term, &rxvt_term::slip_wheel_cb> (this); 172 slip_wheel_ev.set <rxvt_term, &rxvt_term::slip_wheel_cb> (this);
172#endif 173#endif
173#if ENABLE_TRANSPARENCY || ENABLE_PERL 174#if ENABLE_PERL
174 rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this), 175 rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this),
175#endif 176#endif
176 scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), 177 scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this),
177#if USE_XIM 178#if USE_XIM
178 im_ev.set <rxvt_term, &rxvt_term::im_cb> (this), 179 im_ev.set <rxvt_term, &rxvt_term::im_cb> (this),
222 if (fontset[i] != fontset[0]) 223 if (fontset[i] != fontset[0])
223 delete fontset[i]; 224 delete fontset[i];
224#endif 225#endif
225 delete fontset[0]; 226 delete fontset[0];
226 227
227#ifdef HAVE_BG_PIXMAP 228#if HAVE_IMG
228 bg_destroy (); 229 delete bg_img;
229#endif 230#endif
230 231
231 if (display) 232 if (display)
232 { 233 {
233 selection_clear (); 234 selection_clear ();
235 236
236#if USE_XIM 237#if USE_XIM
237 im_destroy (); 238 im_destroy ();
238#endif 239#endif
239 scrollBar.destroy (); 240 scrollBar.destroy ();
241
242 if (gc)
240 if (gc) XFreeGC (dpy, gc); 243 XFreeGC (dpy, gc);
241 244
242 delete drawable; 245 delete drawable;
246
243 // destroy all windows 247 // destroy all windows
244 if (parent) 248 if (parent)
245 XDestroyWindow (dpy, parent); 249 XDestroyWindow (dpy, parent);
246 250
247 for (int i = 0; i < TOTAL_COLORS; i++) 251 for (int i = 0; i < TOTAL_COLORS; i++)
248 if (ISSET_PIXCOLOR (i)) 252 if (ISSET_PIXCOLOR (i))
249 { 253 {
250 pix_colors_focused [i].free (this); 254 pix_colors_focused [i].free (this);
251#if OFF_FOCUS_FADING 255#if OFF_FOCUS_FADING
256 if (rs[Rs_fade])
252 pix_colors_unfocused [i].free (this); 257 pix_colors_unfocused [i].free (this);
253#endif 258#endif
254 } 259 }
255 260
256 clear (); 261 clear ();
257 262
270 free (locale); 275 free (locale);
271 free (v_buffer); 276 free (v_buffer);
272 277
273 delete selection_req; 278 delete selection_req;
274 279
280 if (env && memcmp (env, envv->begin (), envv->size () * sizeof (char *)))
281 rxvt_warn ("env has been modified, probably as a result of a lib calling setenv.\n");
282
283 delete [] env;
284
275 delete envv; 285 delete envv;
276 delete argv; 286 delete argv;
277 287
278#ifdef KEYSYM_RESOURCE 288#ifdef KEYSYM_RESOURCE
279 delete keyboard; 289 delete keyboard;
280#endif 290#endif
281#ifndef NO_RESOURCES 291#ifndef NO_RESOURCES
282 XrmDestroyDatabase (option_db); 292 XrmDestroyDatabase (option_db);
283#endif 293#endif
294
295 SET_R ((rxvt_term *)0);
284} 296}
285 297
286// child has exited, usually destroys 298// child has exited, usually destroys
287void 299void
288rxvt_term::child_cb (ev::child &w, int status) 300rxvt_term::child_cb (ev::child &w, int status)
311 { 323 {
312#if USE_XIM 324#if USE_XIM
313 im_ev.stop (display); 325 im_ev.stop (display);
314#endif 326#endif
315 scrollbar_ev.stop (display); 327 scrollbar_ev.stop (display);
316#if ENABLE_TRANSPARENCY || ENABLE_PERL 328#if ENABLE_PERL
317 rootwin_ev.stop (display); 329 rootwin_ev.stop (display);
318#endif 330#endif
319 termwin_ev.stop (display); 331 termwin_ev.stop (display);
320 vt_ev.stop (display); 332 vt_ev.stop (display);
321 } 333 }
348 360
349 delete this; 361 delete this;
350} 362}
351 363
352void 364void
353rxvt_term::set_option (uint8_t opt, bool set) NOTHROW 365rxvt_term::set_option (uint8_t opt, bool set) noexcept
354{ 366{
355 if (!opt) 367 if (!opt)
356 return; 368 return;
357 369
358 uint8_t mask = 1 << (opt & 7); 370 uint8_t mask = 1 << (opt & 7);
376 388
377#if !ENABLE_MINIMAL 389#if !ENABLE_MINIMAL
378static void ecb_cold 390static void ecb_cold
379print_x_error (Display *dpy, XErrorEvent *event) 391print_x_error (Display *dpy, XErrorEvent *event)
380{ 392{
381 char buffer[BUFSIZ]; 393 char buffer[BUFSIZ];
382 char mesg[BUFSIZ]; 394 char mesg[BUFSIZ];
383 char number[32]; 395 char number[32];
384 396
385 rxvt_warn ("An X Error occurred, trying to continue after report.\n"); 397 rxvt_warn ("An X Error occurred, trying to continue after report.\n");
386 398
387 XGetErrorDatabaseText (dpy, "XlibMessage", "ErrorSerial", "Error Serial #%d", mesg, BUFSIZ); 399 XGetErrorDatabaseText (dpy, "XlibMessage", "ErrorSerial", "Error Serial #%d", mesg, BUFSIZ);
388 snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->serial); 400 snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->serial);
389 401
390 XGetErrorText (dpy, event->error_code, buffer, BUFSIZ); 402 XGetErrorText (dpy, event->error_code, buffer, BUFSIZ);
391 XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "X Error", mesg, BUFSIZ); 403 XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "X Error", mesg, BUFSIZ);
392 rxvt_warn ("+ %s: %s\n", mesg, buffer); 404 rxvt_warn ("+ %s: %s\n", mesg, buffer);
393 405
394 XGetErrorDatabaseText (dpy, "XlibMessage", "MajorCode", "Request Major code %d", mesg, BUFSIZ); 406 XGetErrorDatabaseText (dpy, "XlibMessage", "MajorCode", "Request Major code %d", mesg, BUFSIZ);
395 snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->request_code); 407 snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->request_code);
396 408
397 if (event->request_code >= 128) 409 if (event->request_code >= 128)
398 { 410 {
399#if 0 411#if 0
400 /* XListExtensions and probably query extensions hangs when there are multiple queues errors */ 412 /* XListExtensions and probably query extensions hangs when there are multiple queues errors */
401 int nexts; 413 int nexts;
402 char **exts = XListExtensions (dpy, &nexts); 414 char **exts = XListExtensions (dpy, &nexts);
403 415
404 while (nexts) 416 while (nexts)
405 { 417 {
406 char *extname = exts [nexts - 1]; 418 char *extname = exts [nexts - 1];
407 int major, first_event, first_error; 419 int major, first_event, first_error;
408 420
409 if (XQueryExtension (dpy, extname, &major, &first_event, &first_error) && major == event->request_code) 421 if (XQueryExtension (dpy, extname, &major, &first_event, &first_error) && major == event->request_code)
410 { 422 {
411 XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); 423 XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ);
412 rxvt_warn ("+ (which is extension %s minor code %d)\n", extname, event->minor_code); 424 rxvt_warn ("+ (which is extension %s minor code %d)\n", extname, event->minor_code);
413 425
414 snprintf (buffer, BUFSIZ, "%s.%d", extname, event->minor_code); 426 snprintf (buffer, BUFSIZ, "%s.%d", extname, event->minor_code);
415 XGetErrorDatabaseText (dpy, "XRequest", buffer, "an unregistered minor code", buffer, BUFSIZ); 427 XGetErrorDatabaseText (dpy, "XRequest", buffer, "an unregistered minor code", buffer, BUFSIZ);
416 rxvt_warn ("+ (which is %s)\n", buffer); 428 rxvt_warn ("+ (which is %s)\n", buffer);
417 429
418 break; 430 break;
419 } 431 }
420 432
421 printf ("nextss %d %s\n", nexts, extname);//D 433 printf ("nextss %d %s\n", nexts, extname);//D
422 --nexts; 434 --nexts;
423 ++exts; 435 ++exts;
424 } 436 }
425#else 437#else
426 int nexts = 0; 438 int nexts = 0;
427 char **exts = 0; 439 char **exts = 0;
428#endif 440#endif
429 441
430 if (!nexts) 442 if (!nexts)
431 { 443 {
432 rxvt_warn ("+ (which is an unknown extension)\n", buffer); 444 rxvt_warn ("+ (which is an unknown extension)\n", buffer);
433 445
434 XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); 446 XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ);
435 snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->minor_code); 447 snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->minor_code);
436 448
437#if 0 449#if 0
438 sprintf (number, "RENDER.%d", event->minor_code); 450 sprintf (number, "RENDER.%d", event->minor_code);
439 XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); 451 XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ);
440 rxvt_warn ("+ (which is %s)\n", buffer); 452 rxvt_warn ("+ (which is %s)\n", buffer);
441#endif 453#endif
442 } 454 }
443 455
444 XFreeExtensionList (exts); 456 XFreeExtensionList (exts);
445 } 457 }
446 else 458 else
447 { 459 {
448 sprintf (number, "%d", event->request_code); 460 sprintf (number, "%d", event->request_code);
449 XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); 461 XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ);
450 rxvt_warn ("+ (which is %s)\n", buffer); 462 rxvt_warn ("+ (which is %s)\n", buffer);
451 } 463 }
452 464
453 if (event->error_code == BadWindow 465 if (event->error_code == BadWindow
454 || event->error_code == BadPixmap 466 || event->error_code == BadPixmap
455 || event->error_code == BadCursor 467 || event->error_code == BadCursor
456 || event->error_code == BadFont 468 || event->error_code == BadFont
457 || event->error_code == BadDrawable 469 || event->error_code == BadDrawable
458 || event->error_code == BadColor 470 || event->error_code == BadColor
459 || event->error_code == BadGC 471 || event->error_code == BadGC
460 || event->error_code == BadIDChoice 472 || event->error_code == BadIDChoice
461 || event->error_code == BadValue 473 || event->error_code == BadValue
462 || event->error_code == BadAtom) 474 || event->error_code == BadAtom)
463 { 475 {
464 if (event->error_code == BadValue) 476 if (event->error_code == BadValue)
465 XGetErrorDatabaseText (dpy, "XlibMessage", "Value", "Value 0x%x", mesg, BUFSIZ); 477 XGetErrorDatabaseText (dpy, "XlibMessage", "Value", "Value 0x%x", mesg, BUFSIZ);
466 else if (event->error_code == BadAtom) 478 else if (event->error_code == BadAtom)
467 XGetErrorDatabaseText (dpy, "XlibMessage", "AtomID", "AtomID 0x%x", mesg, BUFSIZ); 479 XGetErrorDatabaseText (dpy, "XlibMessage", "AtomID", "AtomID 0x%x", mesg, BUFSIZ);
468 else 480 else
469 XGetErrorDatabaseText (dpy, "XlibMessage", "ResourceID", "ResourceID 0x%x", mesg, BUFSIZ); 481 XGetErrorDatabaseText (dpy, "XlibMessage", "ResourceID", "ResourceID 0x%x", mesg, BUFSIZ);
470 482
471 snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->resourceid); 483 snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->resourceid);
472 } 484 }
473} 485}
474#endif 486#endif
475 487
476int ecb_cold 488int ecb_cold
477rxvt_xerror_handler (Display *display, XErrorEvent *event) 489rxvt_xerror_handler (Display *display, XErrorEvent *event)
478{ 490{
479 if (GET_R->allowedxerror == -1) 491 if (GET_R && GET_R->allowedxerror == -1)
480 GET_R->allowedxerror = event->error_code; 492 GET_R->allowedxerror = event->error_code;
481 else 493 else
482 { 494 {
483 // GET_R is most likely not the terminal which caused the error, 495 // GET_R is most likely not the terminal which caused the error,
484 // so just output the error and continue 496 // so just output the error and continue
817 829
818 delete fontset[0]; 830 delete fontset[0];
819 fontset[0] = fs; 831 fontset[0] = fs;
820 832
821 prop = (*fs)[rxvt_fontset::firstFont]->properties (); 833 prop = (*fs)[rxvt_fontset::firstFont]->properties ();
822 prop.width += letterSpace; 834 prop.width = max (prop.width + letterSpace, 1);
823 835
824 fs->set_prop (prop, false); 836 fs->set_prop (prop, false);
825 837
826 fwidth = prop.width; 838 fwidth = prop.width;
827 fheight = prop.height + lineSpace; 839 fheight = prop.height + lineSpace;
927 939
928void 940void
929rxvt_term::set_window_color (int idx, const char *color) 941rxvt_term::set_window_color (int idx, const char *color)
930{ 942{
931#ifdef XTERM_COLOR_CHANGE 943#ifdef XTERM_COLOR_CHANGE
932 rxvt_color xcol;
933
934 if (color == NULL || *color == '\0') 944 if (color == NULL || *color == '\0')
935 return; 945 return;
936 946
937 color = strdup (color); 947 color = strdup (color);
938 allocated.push_back ((void *)color); 948 allocated.push_back ((void *)color);
944 int i = atoi (color); 954 int i = atoi (color);
945 955
946 if (i >= 8 && i <= 15) 956 if (i >= 8 && i <= 15)
947 { 957 {
948 /* bright colors */ 958 /* bright colors */
949 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i - 8]; 959 alias_color (idx, minBrightCOLOR + i - 8);
950 goto done; 960 goto done;
951 } 961 }
952 962
953 if (i >= 0 && i <= 7) 963 if (i >= 0 && i <= 7)
954 { 964 {
955 /* normal colors */ 965 /* normal colors */
956 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; 966 alias_color (idx, minCOLOR + i);
957 goto done; 967 goto done;
958 } 968 }
959 } 969 }
960 970
961 set_color (xcol, color); 971 pix_colors_focused[idx].free (this);
962 972 set_color (pix_colors_focused[idx], color);
963 /*
964 * FIXME: should free colors here, but no idea how to do it so instead,
965 * so just keep gobbling up the colormap
966 */
967
968 pix_colors_focused[idx] = xcol;
969 973
970done: 974done:
971 /*TODO: handle Color_BD, scrollbar background, etc. */ 975 /*TODO: handle Color_BD, scrollbar background, etc. */
972 976
973 update_fade_color (idx); 977 update_fade_color (idx);
974 recolour_cursor (); 978 recolor_cursor ();
975 scr_recolour (); 979 scr_recolor ();
976#endif /* XTERM_COLOR_CHANGE */ 980#endif /* XTERM_COLOR_CHANGE */
977} 981}
978 982
979void 983void
980rxvt_term::recolour_cursor () 984rxvt_term::recolor_cursor ()
981{ 985{
982 XColor fg, bg; 986 XColor fg, bg;
983 987
984 (ISSET_PIXCOLOR (Color_pointer_fg) 988 (ISSET_PIXCOLOR (Color_pointer_fg)
985 ? pix_colors_focused[Color_pointer_fg] 989 ? pix_colors_focused[Color_pointer_fg]
1014 1018
1015 for (i = Color_Black; i <= Color_White; i++) 1019 for (i = Color_Black; i <= Color_White; i++)
1016 if (pix_colors[Color_bg] == pix_colors[i]) 1020 if (pix_colors[Color_bg] == pix_colors[i])
1017 { 1021 {
1018 sprintf (bstr, "%d", i - Color_Black); 1022 sprintf (bstr, "%d", i - Color_Black);
1019#if BG_IMAGE_FROM_FILE 1023#if HAVE_IMG
1020 xpmb = "default;"; 1024 xpmb = "default;";
1021#endif 1025#endif
1022 break; 1026 break;
1023 } 1027 }
1024 1028
1040} 1044}
1041 1045
1042void 1046void
1043rxvt_term::alias_color (int dst, int src) 1047rxvt_term::alias_color (int dst, int src)
1044{ 1048{
1049 pix_colors[dst].free (this);
1045 pix_colors[dst].set (this, rs[Rs_color + dst] = rs[Rs_color + src]); 1050 pix_colors[dst].set (this, rs[Rs_color + dst] = rs[Rs_color + src]);
1046} 1051}
1052
1053#ifdef SMART_RESIZE
1054static unsigned int
1055get_parent_bw (Display *dpy, Window w)
1056{
1057 int idummy;
1058 unsigned int udummy;
1059 Window wdummy, parent;
1060 Window *children;
1061 unsigned int nchildren, border_width;
1062
1063 XQueryTree (dpy, w, &wdummy, &parent, &children, &nchildren);
1064 XFree (children);
1065 XGetGeometry (dpy, parent, &wdummy, &idummy, &idummy,
1066 &udummy, &udummy, &border_width, &udummy);
1067
1068 return border_width;
1069}
1070#endif
1047 1071
1048/* -------------------------------------------------------------------- * 1072/* -------------------------------------------------------------------- *
1049 * - WINDOW RESIZING - * 1073 * - WINDOW RESIZING - *
1050 * -------------------------------------------------------------------- */ 1074 * -------------------------------------------------------------------- */
1051void 1075void
1087 * if display->root isn't the parent window, a WM will probably have offset 1111 * if display->root isn't the parent window, a WM will probably have offset
1088 * our position for handles and decorations. Counter it 1112 * our position for handles and decorations. Counter it
1089 */ 1113 */
1090 if (x1 != x || y1 != y) 1114 if (x1 != x || y1 != y)
1091 { 1115 {
1092 x -= x1; 1116 unsigned int border_width = get_parent_bw (dpy, parent);
1093 y -= y1; 1117
1118 x -= x1 + border_width;
1119 y -= y1 + border_width;
1094 } 1120 }
1095 1121
1096 x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2; 1122 x1 = (DisplayWidth (dpy, display->screen) - old_width ) / 2;
1097 y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2; 1123 y1 = (DisplayHeight (dpy, display->screen) - old_height) / 2;
1098 dx = old_width - szHint.width; 1124 dx = old_width - szHint.width;
1128 XMoveResizeWindow (dpy, vt, 1154 XMoveResizeWindow (dpy, vt,
1129 window_vt_x, window_vt_y, 1155 window_vt_x, window_vt_y,
1130 vt_width, vt_height); 1156 vt_width, vt_height);
1131 1157
1132 HOOK_INVOKE ((this, HOOK_SIZE_CHANGE, DT_INT, newwidth, DT_INT, newheight, DT_END)); 1158 HOOK_INVOKE ((this, HOOK_SIZE_CHANGE, DT_INT, newwidth, DT_INT, newheight, DT_END));
1133
1134#ifdef HAVE_BG_PIXMAP
1135 if (bg_window_size_sensitive ())
1136 update_background ();
1137#endif
1138 } 1159 }
1139 1160
1140 if (fix_screen || old_height == 0) 1161 if (fix_screen || old_height == 0)
1141 scr_reset (); 1162 scr_reset ();
1142 1163
1363 unsigned long fg, bg; 1384 unsigned long fg, bg;
1364 const char *p; 1385 const char *p;
1365 char **s; 1386 char **s;
1366 XIMStyles *xim_styles; 1387 XIMStyles *xim_styles;
1367 1388
1368 set_environ (envv); 1389 set_environ (env);
1369 1390
1370 if (! ((p = XSetLocaleModifiers (modifiers)) && *p)) 1391 if (!((p = XSetLocaleModifiers (modifiers)) && *p))
1371 return false; 1392 return false;
1372 1393
1373 input_method = display->get_xim (locale, modifiers); 1394 input_method = display->get_xim (locale, modifiers);
1374 if (input_method == NULL) 1395 if (input_method == NULL)
1375 return false; 1396 return false;
1675{ 1696{
1676 Window cr; 1697 Window cr;
1677 XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr); 1698 XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr);
1678} 1699}
1679 1700
1680#ifdef HAVE_BG_PIXMAP
1681
1682void
1683rxvt_term::update_background ()
1684{
1685 if (update_background_ev.is_active ())
1686 return;
1687
1688 bg_invalidate ();
1689
1690 if (!mapped)
1691 return;
1692
1693 ev_tstamp to_wait = 0.5 - (ev::now () - bg_valid_since);
1694
1695 if (to_wait <= 0.)
1696 bg_render ();
1697 else
1698 update_background_ev.start (to_wait);
1699}
1700
1701void
1702rxvt_term::update_background_cb (ev::timer &w, int revents)
1703{
1704 make_current ();
1705
1706 update_background_ev.stop ();
1707 bg_render ();
1708 refresh_check ();
1709}
1710
1711#endif /* HAVE_BG_PIXMAP */
1712
1713/*----------------------- end-of-file (C source) -----------------------*/ 1701/*----------------------- end-of-file (C source) -----------------------*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines