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.128 by root, Mon Jan 17 00:59:23 2005 UTC vs.
Revision 1.137 by root, Tue Feb 15 16:04:45 2005 UTC

159#endif 159#endif
160#ifdef USE_XIM 160#ifdef USE_XIM
161 im_ev (this, &rxvt_term::im_cb), 161 im_ev (this, &rxvt_term::im_cb),
162#endif 162#endif
163 sw_term (this, &rxvt_term::sig_term), 163 sw_term (this, &rxvt_term::sig_term),
164 sw_int (this, &rxvt_term::sig_term),
164 sw_chld (this, &rxvt_term::sig_chld), 165 sw_chld (this, &rxvt_term::sig_chld),
165 termwin_ev (this, &rxvt_term::x_cb), 166 termwin_ev (this, &rxvt_term::x_cb),
166 vt_ev (this, &rxvt_term::x_cb), 167 vt_ev (this, &rxvt_term::x_cb),
167 check_ev (this, &rxvt_term::check_cb), 168 check_ev (this, &rxvt_term::check_cb),
168 flush_ev (this, &rxvt_term::flush_cb), 169 flush_ev (this, &rxvt_term::flush_cb),
180 if (!keyboard) 181 if (!keyboard)
181 rxvt_fatal ("out of memory, aborting.\n"); 182 rxvt_fatal ("out of memory, aborting.\n");
182#endif 183#endif
183} 184}
184 185
185rxvt_term::~rxvt_term () 186// clean up the most important stuff, do *not* call x or free mem etc.
187// for use before an emergency exit
188void rxvt_term::emergency_cleanup ()
186{ 189{
187 termlist.erase (find (termlist.begin (), termlist.end(), this));
188
189 if (cmd_pid) 190 if (cmd_pid)
190 kill (-cmd_pid, SIGHUP); 191 kill (-cmd_pid, SIGHUP);
191 192
192 pty.put ();
193
194#ifdef UTMP_SUPPORT 193#ifdef UTMP_SUPPORT
195 privileged_utmp (RESTORE); 194 privileged_utmp (RESTORE);
196#endif 195#endif
196
197 pty.put ();
198}
199
200rxvt_term::~rxvt_term ()
201{
202 termlist.erase (find (termlist.begin (), termlist.end(), this));
203
204 emergency_cleanup ();
197 205
198#if ENABLE_STYLES 206#if ENABLE_STYLES
199 for (int i = RS_styleCount; --i; ) 207 for (int i = RS_styleCount; --i; )
200 if (TermWin.fontset[i] != TermWin.fontset[0]) 208 if (TermWin.fontset[i] != TermWin.fontset[0])
201 delete TermWin.fontset[i]; 209 delete TermWin.fontset[i];
202#endif 210#endif
203 delete TermWin.fontset[0]; 211 delete TermWin.fontset[0];
204 212
205 if (display) 213 if (display)
206 { 214 {
215 dDisp;
216
207 selection_clear (); 217 selection_clear ();
208 218
209#ifdef USE_XIM 219#ifdef USE_XIM
210 im_destroy (); 220 im_destroy ();
211#endif 221#endif
212#ifdef MENUBAR 222#ifdef MENUBAR
213 if (menubarGC) XFreeGC (display->display, menubarGC); 223 if (menubarGC) XFreeGC (disp, menubarGC);
214#endif 224#endif
215#ifdef XTERM_SCROLLBAR 225#ifdef XTERM_SCROLLBAR
216 if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC); 226 if (xscrollbarGC) XFreeGC (disp, xscrollbarGC);
217 if (ShadowGC) XFreeGC (display->display, ShadowGC); 227 if (ShadowGC) XFreeGC (disp, ShadowGC);
218#endif 228#endif
219#ifdef PLAIN_SCROLLBAR 229#ifdef PLAIN_SCROLLBAR
220 if (pscrollbarGC) XFreeGC (display->display, pscrollbarGC); 230 if (pscrollbarGC) XFreeGC (disp, pscrollbarGC);
221#endif 231#endif
222#ifdef NEXT_SCROLLBAR 232#ifdef NEXT_SCROLLBAR
223 if (blackGC) XFreeGC (display->display, blackGC); 233 if (blackGC) XFreeGC (disp, blackGC);
224 if (whiteGC) XFreeGC (display->display, whiteGC); 234 if (whiteGC) XFreeGC (disp, whiteGC);
225 if (grayGC) XFreeGC (display->display, grayGC); 235 if (grayGC) XFreeGC (disp, grayGC);
226 if (darkGC) XFreeGC (display->display, darkGC); 236 if (darkGC) XFreeGC (disp, darkGC);
227 if (stippleGC) XFreeGC (display->display, stippleGC); 237 if (stippleGC) XFreeGC (disp, stippleGC);
228 if (dimple) XFreePixmap (display->display, dimple); 238 if (dimple) XFreePixmap (disp, dimple);
229 if (upArrow) XFreePixmap (display->display, upArrow); 239 if (upArrow) XFreePixmap (disp, upArrow);
230 if (downArrow) XFreePixmap (display->display, downArrow); 240 if (downArrow) XFreePixmap (disp, downArrow);
231 if (upArrowHi) XFreePixmap (display->display, upArrowHi); 241 if (upArrowHi) XFreePixmap (disp, upArrowHi);
232 if (downArrowHi) XFreePixmap (display->display, downArrowHi); 242 if (downArrowHi) XFreePixmap (disp, downArrowHi);
233#endif 243#endif
234#if defined(MENUBAR) || defined(RXVT_SCROLLBAR) 244#if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
235 if (topShadowGC) XFreeGC (display->display, topShadowGC); 245 if (topShadowGC) XFreeGC (disp, topShadowGC);
236 if (botShadowGC) XFreeGC (display->display, botShadowGC); 246 if (botShadowGC) XFreeGC (disp, botShadowGC);
237 if (scrollbarGC) XFreeGC (display->display, scrollbarGC); 247 if (scrollbarGC) XFreeGC (disp, scrollbarGC);
238#endif 248#endif
239 if (TermWin.gc) XFreeGC (display->display, TermWin.gc); 249 if (TermWin.gc) XFreeGC (disp, TermWin.gc);
240 250
241#if defined(MENUBAR) && (MENUBAR_MAX > 1) 251#if defined(MENUBAR) && (MENUBAR_MAX > 1)
242 delete menuBar.drawable; 252 delete menuBar.drawable;
243 //if (menuBar.win) 253 //if (menuBar.win)
244 // XDestroyWindow (display->display, menuBar.win); 254 // XDestroyWindow (disp, menuBar.win);
245#endif 255#endif
246 delete TermWin.drawable; 256 delete TermWin.drawable;
247 // destroy all windows 257 // destroy all windows
248 if (TermWin.parent[0]) 258 if (TermWin.parent[0]
259#if ENABLE_FRILLS
260 && !rs[Rs_embed]
261#endif
262 )
249 XDestroyWindow (display->display, TermWin.parent[0]); 263 XDestroyWindow (disp, TermWin.parent[0]);
250 } 264 }
251 265
252 // TODO: free pixcolours, colours should become part of rxvt_display 266 // TODO: free pixcolours, colours should become part of rxvt_display
253 267
254 delete pix_colors_focused; 268 delete pix_colors_focused;
260 274
261 scr_release (); 275 scr_release ();
262 276
263 /* clear all resources */ 277 /* clear all resources */
264 for (int i = 0; i < allocated.size (); i++) 278 for (int i = 0; i < allocated.size (); i++)
265 free (allocated[i]); 279 free (allocated [i]);
266 280
267 free (selection.text); 281 free (selection.text);
268 // TODO: manage env vars in child only(!) 282 // TODO: manage env vars in child only(!)
269 free (env_windowid); 283 free (env_windowid);
270 free (env_display); 284 free (env_display);
276 290
277 delete envv; 291 delete envv;
278 delete argv; 292 delete argv;
279 293
280#ifdef KEYSYM_RESOURCE 294#ifdef KEYSYM_RESOURCE
281 delete keyboard; 295 delete keyboard;
282#endif 296#endif
283} 297}
284 298
285void 299void
286rxvt_term::destroy () 300rxvt_term::destroy ()
339 353
340 delete this; 354 delete this;
341} 355}
342 356
343/*----------------------------------------------------------------------*/ 357/*----------------------------------------------------------------------*/
358/*
359 * Exit gracefully, clearing the utmp entry and restoring tty attributes
360 * TODO: if debugging, this should free up any known resources if we can
361 */
362static XErrorHandler old_xerror_handler;
363
364static void
365rxvt_emergency_cleanup ()
366{
367 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
368 (*t)->emergency_cleanup ();
369}
370
371#if ENABLE_FRILLS
372static void
373print_x_error (Display *dpy, XErrorEvent *event)
374{
375 char buffer[BUFSIZ];
376 char mesg[BUFSIZ];
377 char number[32];
378 char *mtype = "XlibMessage";
379 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
380 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
381 rxvt_warn ("An X Error occured, trying to continue after report.\n");
382 rxvt_warn ("%s: %s\n", mesg, buffer);
383 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ);
384 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code);
385 sprintf(number, "%d", event->request_code);
386 XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
387 rxvt_warn ("(which is %s)\n", buffer);
388 if (event->request_code >= 128) {
389 XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
390 mesg, BUFSIZ);
391 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code);
392 }
393 if ((event->error_code == BadWindow) ||
394 (event->error_code == BadPixmap) ||
395 (event->error_code == BadCursor) ||
396 (event->error_code == BadFont) ||
397 (event->error_code == BadDrawable) ||
398 (event->error_code == BadColor) ||
399 (event->error_code == BadGC) ||
400 (event->error_code == BadIDChoice) ||
401 (event->error_code == BadValue) ||
402 (event->error_code == BadAtom)) {
403 if (event->error_code == BadValue)
404 XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
405 mesg, BUFSIZ);
406 else if (event->error_code == BadAtom)
407 XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
408 mesg, BUFSIZ);
409 else
410 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
411 mesg, BUFSIZ);
412 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid);
413 }
414 XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
415 mesg, BUFSIZ);
416 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial);
417}
418#endif
419
420int
421rxvt_xerror_handler (Display *display, XErrorEvent *event)
422{
423 if (GET_R->allowedxerror == -1)
424 GET_R->allowedxerror = event->error_code;
425 else
426 {
427 //TODO: GET_R is most likely not the terminal which caused the error
428 //TODO: maybe just output the error and continue?
429#if ENABLE_FRILLS
430 print_x_error (display, event);
431#else
432 old_xerror_handler (display, event);
433#endif
434 }
435
436 return 0;
437}
438
439int
440rxvt_xioerror_handler (Display *display)
441{
442 rxvt_warn ("X connection to '%s' broken, unable to recover, exiting.\n",
443 DisplayString (display));
444 rxvt_emergency_cleanup ();
445 _exit (EXIT_FAILURE);
446}
447
448/*
449 * Catch a fatal signal and tidy up before quitting
450 */
451void
452rxvt_term::sig_term (sig_watcher &w)
453{
454#ifdef DEBUG_CMD
455 rxvt_warn ("caught signal %d, exiting.\n", w.signum);
456#endif
457 rxvt_emergency_cleanup ();
458 signal (w.signum, SIG_DFL);
459 kill (getpid (), w.signum);
460}
461
462/*----------------------------------------------------------------------*/
344/* rxvt_init () */ 463/* rxvt_init () */
345bool 464bool
346rxvt_term::init (int argc, const char *const *argv) 465rxvt_term::init (int argc, const char *const *argv)
347{ 466{
348 SET_R (this); 467 SET_R (this);
368 scrollBar.setIdle (); /* set existence for size calculations */ 487 scrollBar.setIdle (); /* set existence for size calculations */
369#endif 488#endif
370 489
371 create_windows (argc, argv); 490 create_windows (argc, argv);
372 491
492 dDisp;
493
373 init_xlocale (); 494 init_xlocale ();
374 495
375 scr_reset (); /* initialize screen */ 496 scr_reset (); /* initialize screen */
376 497
377#if 0 498#if 0
378 XSynchronize (display->display, True); 499 XSynchronize (disp, True);
379#endif 500#endif
380 501
381#ifdef HAVE_SCROLLBARS 502#ifdef HAVE_SCROLLBARS
382 if (options & Opt_scrollBar) 503 if (options & Opt_scrollBar)
383 resize_scrollbar (); /* create and map scrollbar */ 504 resize_scrollbar (); /* create and map scrollbar */
384#endif 505#endif
385#if (MENUBAR_MAX) 506#if (MENUBAR_MAX)
386 if (menubar_visible ()) 507 if (menubar_visible ())
387 XMapWindow (display->display, menuBar.win); 508 XMapWindow (disp, menuBar.win);
388#endif 509#endif
389#ifdef TRANSPARENT 510#ifdef TRANSPARENT
390 if (options & Opt_transparent) 511 if (options & Opt_transparent)
391 { 512 {
392 XSelectInput (display->display, display->root, PropertyChangeMask); 513 XSelectInput (disp, display->root, PropertyChangeMask);
393 check_our_parents (); 514 check_our_parents ();
394 rootwin_ev.start (display, display->root); 515 rootwin_ev.start (display, display->root);
395 } 516 }
396#endif 517#endif
397 518
398 XMapWindow (display->display, TermWin.vt); 519 XMapWindow (disp, TermWin.vt);
399 XMapWindow (display->display, TermWin.parent[0]); 520 XMapWindow (disp, TermWin.parent[0]);
400 521
401 set_colorfgbg (); 522 set_colorfgbg ();
402 523
403 init_command (cmd_argv); 524 init_command (cmd_argv);
404 525
408 529
409 check_ev.start (); 530 check_ev.start ();
410 531
411 return true; 532 return true;
412} 533}
413
414static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event);
415 534
416void 535void
417rxvt_init () 536rxvt_init ()
418{ 537{
419 /* 538 /*
432 /* need to trap SIGURG for SVR4 (Unixware) rlogin */ 551 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
433 /* signal (SIGURG, SIG_DFL); */ 552 /* signal (SIGURG, SIG_DFL); */
434 553
435 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 554 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
436 // TODO: handle this with exceptions and tolerate the memory loss 555 // TODO: handle this with exceptions and tolerate the memory loss
437 //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); 556 XSetIOErrorHandler (rxvt_xioerror_handler);
438} 557}
439 558
440/* ------------------------------------------------------------------------- * 559/* ------------------------------------------------------------------------- *
441 * SIGNAL HANDLING & EXIT HANDLER * 560 * SIGNAL HANDLING & EXIT HANDLER *
442 * ------------------------------------------------------------------------- */ 561 * ------------------------------------------------------------------------- */
455 if (pid == (*t)->cmd_pid) 574 if (pid == (*t)->cmd_pid)
456 { 575 {
457 (*t)->destroy (); 576 (*t)->destroy ();
458 break; 577 break;
459 } 578 }
460}
461
462/*----------------------------------------------------------------------*/
463/*
464 * Exit gracefully, clearing the utmp entry and restoring tty attributes
465 * TODO: if debugging, this should free up any known resources if we can
466 */
467void
468rxvt_destroy_all ()
469{
470 // TODO: rxvtd should clean up all ressources
471 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
472 (*t)->destroy ();
473}
474
475/*
476 * Catch a fatal signal and tidy up before quitting
477 */
478void
479rxvt_term::sig_term (sig_watcher &w)
480{
481#ifdef DEBUG_CMD
482 rxvt_warn ("caught signal %d, exiting.\n", w.signum);
483#endif
484 rxvt_destroy_all ();
485 signal (w.signum, SIG_DFL);
486 kill (getpid (), w.signum);
487}
488
489/* INTPROTO */
490int
491rxvt_xerror_handler (Display *display, XErrorEvent *event)
492{
493 if (GET_R->allowedxerror == -1)
494 GET_R->allowedxerror = event->error_code;
495 else
496 {
497 old_xerror_handler (display, event);
498 GET_R->destroy ();
499 }
500
501 return 0;
502} 579}
503 580
504/* ------------------------------------------------------------------------- * 581/* ------------------------------------------------------------------------- *
505 * MEMORY ALLOCATION WRAPPERS * 582 * MEMORY ALLOCATION WRAPPERS *
506 * ------------------------------------------------------------------------- */ 583 * ------------------------------------------------------------------------- */
619 * if width/height are non-zero then override calculated width/height 696 * if width/height are non-zero then override calculated width/height
620 */ 697 */
621void 698void
622rxvt_term::window_calc (unsigned int width, unsigned int height) 699rxvt_term::window_calc (unsigned int width, unsigned int height)
623{ 700{
624 short recalc_x, recalc_y; 701 short recalc_x, recalc_y;
625 int x, y, sb_w, mb_h, flags; 702 int x, y, sb_w, mb_h, flags;
626 unsigned int w, h; 703 unsigned int w, h;
627 unsigned int max_width, max_height; 704 unsigned int max_width, max_height;
705 dDisp;
628 706
629 D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", 707 D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
630 TermWin.ncol, TermWin.nrow, szHint.width, 708 TermWin.ncol, TermWin.nrow, szHint.width,
631 szHint.height)); 709 szHint.height));
632 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; 710 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity;
638 if (!parsed_geometry) 716 if (!parsed_geometry)
639 { 717 {
640 parsed_geometry = 1; 718 parsed_geometry = 1;
641 if (rs[Rs_geometry]) 719 if (rs[Rs_geometry])
642 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); 720 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h);
721
643 if (flags & WidthValue) 722 if (flags & WidthValue)
644 { 723 {
645 TermWin.ncol = BOUND_POSITIVE_INT16 (w); 724 TermWin.ncol = BOUND_POSITIVE_INT16 (w);
646 szHint.flags |= USSize; 725 szHint.flags |= USSize;
647 } 726 }
727
648 if (flags & HeightValue) 728 if (flags & HeightValue)
649 { 729 {
650 TermWin.nrow = BOUND_POSITIVE_INT16 (h); 730 TermWin.nrow = BOUND_POSITIVE_INT16 (h);
651 szHint.flags |= USSize; 731 szHint.flags |= USSize;
652 } 732 }
733
653 if (flags & XValue) 734 if (flags & XValue)
654 { 735 {
655 szHint.x = x; 736 szHint.x = x;
656 szHint.flags |= USPosition; 737 szHint.flags |= USPosition;
657 if (flags & XNegative) 738 if (flags & XNegative)
658 { 739 {
659 recalc_x = 1; 740 recalc_x = 1;
660 szHint.win_gravity = NorthEastGravity; 741 szHint.win_gravity = NorthEastGravity;
661 } 742 }
662 } 743 }
744
663 if (flags & YValue) 745 if (flags & YValue)
664 { 746 {
665 szHint.y = y; 747 szHint.y = y;
666 szHint.flags |= USPosition; 748 szHint.flags |= USPosition;
667 if (flags & YNegative) 749 if (flags & YNegative)
730 812
731 if (scrollbar_visible () && (options & Opt_scrollBar_right)) 813 if (scrollbar_visible () && (options & Opt_scrollBar_right))
732 window_sb_x = szHint.width - sb_w; 814 window_sb_x = szHint.width - sb_w;
733 815
734 if (recalc_x) 816 if (recalc_x)
735 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) 817 szHint.x += (DisplayWidth (disp, display->screen)
736 - szHint.width - 2 * TermWin.ext_bwidth); 818 - szHint.width - 2 * TermWin.ext_bwidth);
737 if (recalc_y) 819 if (recalc_y)
738 szHint.y += (DisplayHeight (display->display, DefaultScreen (display->display)) 820 szHint.y += (DisplayHeight (disp, display->screen)
739 - szHint.height - 2 * TermWin.ext_bwidth); 821 - szHint.height - 2 * TermWin.ext_bwidth);
740 822
741 TermWin.ncol = TermWin.width / TermWin.fwidth; 823 TermWin.ncol = TermWin.width / TermWin.fwidth;
742 TermWin.nrow = TermWin.height / TermWin.fheight; 824 TermWin.nrow = TermWin.height / TermWin.fheight;
743 D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", 825 D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
908 990
909 /* handle color aliases */ 991 /* handle color aliases */
910 if (isdigit (*color)) 992 if (isdigit (*color))
911 { 993 {
912 i = atoi (color); 994 i = atoi (color);
995
913 if (i >= 8 && i <= 15) 996 if (i >= 8 && i <= 15)
914 { /* bright colors */ 997 { /* bright colors */
915 i -= 8; 998 i -= 8;
916# ifndef NO_BRIGHTCOLOR 999# ifndef NO_BRIGHTCOLOR
917 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; 1000 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i];
918 SET_PIXCOLOR (idx); 1001 SET_PIXCOLOR (idx);
919 goto Done; 1002 goto Done;
920# endif 1003# endif
921
922 } 1004 }
1005
923 if (i >= 0 && i <= 7) 1006 if (i >= 0 && i <= 7)
924 { /* normal colors */ 1007 { /* normal colors */
925 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; 1008 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i];
926 SET_PIXCOLOR (idx); 1009 SET_PIXCOLOR (idx);
927 goto Done; 1010 goto Done;
928 } 1011 }
929 } 1012 }
930 1013
931 if (!rXParseAllocColor (& xcol, color)) 1014 if (!rXParseAllocColor (&xcol, color))
932 return; 1015 return;
933 1016
934 /* XStoreColor (display->display, display->cmap, XColor*); */ 1017 /* XStoreColor (display->display, display->cmap, XColor*); */
935 1018
936 /* 1019 /*
1039 * -------------------------------------------------------------------- */ 1122 * -------------------------------------------------------------------- */
1040void 1123void
1041rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent) 1124rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent)
1042{ 1125{
1043 int fix_screen; 1126 int fix_screen;
1044
1045#ifdef SMART_RESIZE 1127#ifdef SMART_RESIZE
1046 int old_width = szHint.width, old_height = szHint.height; 1128 int old_width = szHint.width, old_height = szHint.height;
1047#endif 1129#endif
1130 dDisp;
1048 1131
1049 window_calc (width, height); 1132 window_calc (width, height);
1050 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); 1133 XSetWMNormalHints (disp, TermWin.parent[0], &szHint);
1051 1134
1052 if (!ignoreparent) 1135 if (!ignoreparent)
1053 { 1136 {
1054#ifdef SMART_RESIZE 1137#ifdef SMART_RESIZE
1055 /* 1138 /*
1059 int x, y, x1, y1; 1142 int x, y, x1, y1;
1060 int dx, dy; 1143 int dx, dy;
1061 unsigned int unused_w1, unused_h1, unused_b1, unused_d1; 1144 unsigned int unused_w1, unused_h1, unused_b1, unused_d1;
1062 Window unused_cr; 1145 Window unused_cr;
1063 1146
1064 XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 1147 XTranslateCoordinates (disp, TermWin.parent[0], display->root,
1065 0, 0, &x, &y, &unused_cr); 1148 0, 0, &x, &y, &unused_cr);
1066 XGetGeometry (display->display, TermWin.parent[0], &unused_cr, &x1, &y1, 1149 XGetGeometry (disp, TermWin.parent[0], &unused_cr, &x1, &y1,
1067 &unused_w1, &unused_h1, &unused_b1, &unused_d1); 1150 &unused_w1, &unused_h1, &unused_b1, &unused_d1);
1068 /* 1151 /*
1069 * if display->root isn't the parent window, a WM will probably have offset 1152 * if display->root isn't the parent window, a WM will probably have offset
1070 * our position for handles and decorations. Counter it 1153 * our position for handles and decorations. Counter it
1071 */ 1154 */
1073 { 1156 {
1074 x -= x1; 1157 x -= x1;
1075 y -= y1; 1158 y -= y1;
1076 } 1159 }
1077 1160
1078 x1 = (DisplayWidth (display->display, display->screen) - old_width) / 2; 1161 x1 = (DisplayWidth (disp, display->screen) - old_width) / 2;
1079 y1 = (DisplayHeight (display->display, display->screen) - old_height) / 2; 1162 y1 = (DisplayHeight (disp, display->screen) - old_height) / 2;
1080 dx = old_width - szHint.width; 1163 dx = old_width - szHint.width;
1081 dy = old_height - szHint.height; 1164 dy = old_height - szHint.height;
1082 1165
1083 /* Check position of the center of the window */ 1166 /* Check position of the center of the window */
1084 if (x < x1) /* left half */ 1167 if (x < x1) /* left half */
1088 if (y < y1) /* top half */ 1171 if (y < y1) /* top half */
1089 dy = 0; 1172 dy = 0;
1090 else if (y == y1) /* exact center */ 1173 else if (y == y1) /* exact center */
1091 dy /= 2; 1174 dy /= 2;
1092 1175
1093 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, 1176 XMoveResizeWindow (disp, TermWin.parent[0], x + dx, y + dy,
1094 szHint.width, szHint.height); 1177 szHint.width, szHint.height);
1095#else 1178#else
1096 XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height); 1179 XResizeWindow (disp, TermWin.parent[0], szHint.width, szHint.height);
1097#endif 1180#endif
1098 } 1181 }
1099 1182
1100 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; 1183 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow;
1101 1184
1102 if (fix_screen || width != old_width || height != old_height) 1185 if (fix_screen || width != old_width || height != old_height)
1103 { 1186 {
1104 if (scrollbar_visible ()) 1187 if (scrollbar_visible ())
1105 { 1188 {
1106 XMoveResizeWindow (display->display, scrollBar.win, 1189 XMoveResizeWindow (disp, scrollBar.win,
1107 window_sb_x, 0, 1190 window_sb_x, 0,
1108 scrollbar_TotalWidth (), szHint.height); 1191 scrollbar_TotalWidth (), szHint.height);
1109 resize_scrollbar (); 1192 resize_scrollbar ();
1110 } 1193 }
1111 1194
1112 if (menubar_visible ()) 1195 if (menubar_visible ())
1113 XMoveResizeWindow (display->display, menuBar.win, 1196 XMoveResizeWindow (disp, menuBar.win,
1114 window_vt_x, 0, 1197 window_vt_x, 0,
1115 TermWin_TotalWidth (), menuBar_TotalHeight ()); 1198 TermWin_TotalWidth (), menuBar_TotalHeight ());
1116 1199
1117 XMoveResizeWindow (display->display, TermWin.vt, 1200 XMoveResizeWindow (disp, TermWin.vt,
1118 window_vt_x, window_vt_y, 1201 window_vt_x, window_vt_y,
1119 TermWin_TotalWidth (), TermWin_TotalHeight ()); 1202 TermWin_TotalWidth (), TermWin_TotalHeight ());
1203
1120 scr_clear (); 1204 scr_clear ();
1121#ifdef XPM_BACKGROUND 1205#ifdef XPM_BACKGROUND
1122 resize_pixmap (); 1206 resize_pixmap ();
1123#endif 1207#endif
1124 } 1208 }
1146 } 1230 }
1147 } 1231 }
1148 1232
1149 old_width = szHint.width; 1233 old_width = szHint.width;
1150 old_height = szHint.height; 1234 old_height = szHint.height;
1235
1236#ifdef XPM_BACKGROUND
1237 if (TermWin.pixmap)
1238 scr_touch (false);
1239#endif
1151 1240
1152#ifdef USE_XIM 1241#ifdef USE_XIM
1153 IMSetStatusPosition (); 1242 IMSetStatusPosition ();
1154#endif 1243#endif
1155} 1244}
1385 "*", 1474 "*",
1386 TermWin.fheight, 1475 TermWin.fheight,
1387 TermWin.fheight + 1, TermWin.fheight - 1, 1476 TermWin.fheight + 1, TermWin.fheight - 1,
1388 TermWin.fheight - 2, TermWin.fheight + 2); 1477 TermWin.fheight - 2, TermWin.fheight + 2);
1389 1478
1390 fs = XCreateFontSet (display->display, pat, 1479 fs = XCreateFontSet (display->display, rs[Rs_imFont] ? rs[Rs_imFont] : pat,
1391 &missing_charset_list, &missing_charset_count, &def_string); 1480 &missing_charset_list, &missing_charset_count, &def_string);
1392 1481
1393 if (missing_charset_list) 1482 if (missing_charset_list)
1394 XFreeStringList (missing_charset_list); 1483 XFreeStringList (missing_charset_list);
1395 1484
1471{ 1560{
1472 int i, found, had_im; 1561 int i, found, had_im;
1473 const char *p; 1562 const char *p;
1474 char **s; 1563 char **s;
1475 char buf[IMBUFSIZ]; 1564 char buf[IMBUFSIZ];
1565
1566 SET_R (this);
1476 1567
1477 im_destroy (); 1568 im_destroy ();
1478 1569
1479 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); 1570 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()"));
1480 if (Input_Context) 1571 if (Input_Context)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines