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.138 by root, Wed Feb 16 20:32:05 2005 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines