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.142 by root, Sat Feb 19 04:16:49 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_XEMBED
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 * ------------------------------------------------------------------------- */
457 (*t)->destroy (); 575 (*t)->destroy ();
458 break; 576 break;
459 } 577 }
460} 578}
461 579
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}
503
504/* ------------------------------------------------------------------------- * 580/* ------------------------------------------------------------------------- *
505 * MEMORY ALLOCATION WRAPPERS * 581 * MEMORY ALLOCATION WRAPPERS *
506 * ------------------------------------------------------------------------- */ 582 * ------------------------------------------------------------------------- */
507void * 583void *
508rxvt_malloc (size_t size) 584rxvt_malloc (size_t size)
513 rxvt_fatal ("memory allocation failure. aborting.\n"); 589 rxvt_fatal ("memory allocation failure. aborting.\n");
514 590
515 return p; 591 return p;
516} 592}
517 593
518/* INTPROTO */
519void * 594void *
520rxvt_calloc (size_t number, size_t size) 595rxvt_calloc (size_t number, size_t size)
521{ 596{
522 void *p = calloc (number, size); 597 void *p = calloc (number, size);
523 598
525 rxvt_fatal ("memory allocation failure. aborting.\n"); 600 rxvt_fatal ("memory allocation failure. aborting.\n");
526 601
527 return p; 602 return p;
528} 603}
529 604
530/* INTPROTO */
531void * 605void *
532rxvt_realloc (void *ptr, size_t size) 606rxvt_realloc (void *ptr, size_t size)
533{ 607{
534 void *p = realloc (ptr, size); 608 void *p = realloc (ptr, size);
535 609
619 * if width/height are non-zero then override calculated width/height 693 * if width/height are non-zero then override calculated width/height
620 */ 694 */
621void 695void
622rxvt_term::window_calc (unsigned int width, unsigned int height) 696rxvt_term::window_calc (unsigned int width, unsigned int height)
623{ 697{
624 short recalc_x, recalc_y; 698 short recalc_x, recalc_y;
625 int x, y, sb_w, mb_h, flags; 699 int x, y, sb_w, mb_h, flags;
626 unsigned int w, h; 700 unsigned int w, h;
627 unsigned int max_width, max_height; 701 unsigned int max_width, max_height;
702 dDisp;
628 703
629 D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", 704 D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
630 TermWin.ncol, TermWin.nrow, szHint.width, 705 TermWin.ncol, TermWin.nrow, szHint.width,
631 szHint.height)); 706 szHint.height));
632 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; 707 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity;
638 if (!parsed_geometry) 713 if (!parsed_geometry)
639 { 714 {
640 parsed_geometry = 1; 715 parsed_geometry = 1;
641 if (rs[Rs_geometry]) 716 if (rs[Rs_geometry])
642 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); 717 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h);
718
643 if (flags & WidthValue) 719 if (flags & WidthValue)
644 { 720 {
645 TermWin.ncol = BOUND_POSITIVE_INT16 (w); 721 TermWin.ncol = BOUND_POSITIVE_INT16 (w);
646 szHint.flags |= USSize; 722 szHint.flags |= USSize;
647 } 723 }
724
648 if (flags & HeightValue) 725 if (flags & HeightValue)
649 { 726 {
650 TermWin.nrow = BOUND_POSITIVE_INT16 (h); 727 TermWin.nrow = BOUND_POSITIVE_INT16 (h);
651 szHint.flags |= USSize; 728 szHint.flags |= USSize;
652 } 729 }
730
653 if (flags & XValue) 731 if (flags & XValue)
654 { 732 {
655 szHint.x = x; 733 szHint.x = x;
656 szHint.flags |= USPosition; 734 szHint.flags |= USPosition;
657 if (flags & XNegative) 735 if (flags & XNegative)
658 { 736 {
659 recalc_x = 1; 737 recalc_x = 1;
660 szHint.win_gravity = NorthEastGravity; 738 szHint.win_gravity = NorthEastGravity;
661 } 739 }
662 } 740 }
741
663 if (flags & YValue) 742 if (flags & YValue)
664 { 743 {
665 szHint.y = y; 744 szHint.y = y;
666 szHint.flags |= USPosition; 745 szHint.flags |= USPosition;
667 if (flags & YNegative) 746 if (flags & YNegative)
730 809
731 if (scrollbar_visible () && (options & Opt_scrollBar_right)) 810 if (scrollbar_visible () && (options & Opt_scrollBar_right))
732 window_sb_x = szHint.width - sb_w; 811 window_sb_x = szHint.width - sb_w;
733 812
734 if (recalc_x) 813 if (recalc_x)
735 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) 814 szHint.x += (DisplayWidth (disp, display->screen)
736 - szHint.width - 2 * TermWin.ext_bwidth); 815 - szHint.width - 2 * TermWin.ext_bwidth);
737 if (recalc_y) 816 if (recalc_y)
738 szHint.y += (DisplayHeight (display->display, DefaultScreen (display->display)) 817 szHint.y += (DisplayHeight (disp, display->screen)
739 - szHint.height - 2 * TermWin.ext_bwidth); 818 - szHint.height - 2 * TermWin.ext_bwidth);
740 819
741 TermWin.ncol = TermWin.width / TermWin.fwidth; 820 TermWin.ncol = TermWin.width / TermWin.fwidth;
742 TermWin.nrow = TermWin.height / TermWin.fheight; 821 TermWin.nrow = TermWin.height / TermWin.fheight;
743 D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", 822 D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
766 (void)ioctl (pty.pty, TIOCSWINSZ, &ws); 845 (void)ioctl (pty.pty, TIOCSWINSZ, &ws);
767 846
768#if 0 847#if 0
769 // TIOCSWINSZ⎈ is supposed to do this automatically and correctly 848 // TIOCSWINSZ⎈ is supposed to do this automatically and correctly
770 if (cmd_pid) /* force through to the command */ 849 if (cmd_pid) /* force through to the command */
771 kill (cmd_pid, SIGWINCH); 850 kill (-cmd_pid, SIGWINCH);
772#endif 851#endif
773} 852}
774 853
775/*----------------------------------------------------------------------*/ 854/*----------------------------------------------------------------------*/
776/* set_fonts () - load and set the various fonts 855/* set_fonts () - load and set the various fonts
908 987
909 /* handle color aliases */ 988 /* handle color aliases */
910 if (isdigit (*color)) 989 if (isdigit (*color))
911 { 990 {
912 i = atoi (color); 991 i = atoi (color);
992
913 if (i >= 8 && i <= 15) 993 if (i >= 8 && i <= 15)
914 { /* bright colors */ 994 { /* bright colors */
915 i -= 8; 995 i -= 8;
916# ifndef NO_BRIGHTCOLOR 996# ifndef NO_BRIGHTCOLOR
917 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; 997 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i];
918 SET_PIXCOLOR (idx); 998 SET_PIXCOLOR (idx);
919 goto Done; 999 goto Done;
920# endif 1000# endif
921
922 } 1001 }
1002
923 if (i >= 0 && i <= 7) 1003 if (i >= 0 && i <= 7)
924 { /* normal colors */ 1004 { /* normal colors */
925 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; 1005 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i];
926 SET_PIXCOLOR (idx); 1006 SET_PIXCOLOR (idx);
927 goto Done; 1007 goto Done;
928 } 1008 }
929 } 1009 }
930 1010
931 if (!rXParseAllocColor (& xcol, color)) 1011 if (!rXParseAllocColor (&xcol, color))
932 return; 1012 return;
933 1013
934 /* XStoreColor (display->display, display->cmap, XColor*); */ 1014 /* XStoreColor (display->display, display->cmap, XColor*); */
935 1015
936 /* 1016 /*
1039 * -------------------------------------------------------------------- */ 1119 * -------------------------------------------------------------------- */
1040void 1120void
1041rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent) 1121rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent)
1042{ 1122{
1043 int fix_screen; 1123 int fix_screen;
1044
1045#ifdef SMART_RESIZE 1124#ifdef SMART_RESIZE
1046 int old_width = szHint.width, old_height = szHint.height; 1125 int old_width = szHint.width, old_height = szHint.height;
1047#endif 1126#endif
1127 dDisp;
1048 1128
1049 window_calc (width, height); 1129 window_calc (width, height);
1050 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); 1130 XSetWMNormalHints (disp, TermWin.parent[0], &szHint);
1051 1131
1052 if (!ignoreparent) 1132 if (!ignoreparent)
1053 { 1133 {
1054#ifdef SMART_RESIZE 1134#ifdef SMART_RESIZE
1055 /* 1135 /*
1059 int x, y, x1, y1; 1139 int x, y, x1, y1;
1060 int dx, dy; 1140 int dx, dy;
1061 unsigned int unused_w1, unused_h1, unused_b1, unused_d1; 1141 unsigned int unused_w1, unused_h1, unused_b1, unused_d1;
1062 Window unused_cr; 1142 Window unused_cr;
1063 1143
1064 XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 1144 XTranslateCoordinates (disp, TermWin.parent[0], display->root,
1065 0, 0, &x, &y, &unused_cr); 1145 0, 0, &x, &y, &unused_cr);
1066 XGetGeometry (display->display, TermWin.parent[0], &unused_cr, &x1, &y1, 1146 XGetGeometry (disp, TermWin.parent[0], &unused_cr, &x1, &y1,
1067 &unused_w1, &unused_h1, &unused_b1, &unused_d1); 1147 &unused_w1, &unused_h1, &unused_b1, &unused_d1);
1068 /* 1148 /*
1069 * if display->root isn't the parent window, a WM will probably have offset 1149 * if display->root isn't the parent window, a WM will probably have offset
1070 * our position for handles and decorations. Counter it 1150 * our position for handles and decorations. Counter it
1071 */ 1151 */
1073 { 1153 {
1074 x -= x1; 1154 x -= x1;
1075 y -= y1; 1155 y -= y1;
1076 } 1156 }
1077 1157
1078 x1 = (DisplayWidth (display->display, display->screen) - old_width) / 2; 1158 x1 = (DisplayWidth (disp, display->screen) - old_width) / 2;
1079 y1 = (DisplayHeight (display->display, display->screen) - old_height) / 2; 1159 y1 = (DisplayHeight (disp, display->screen) - old_height) / 2;
1080 dx = old_width - szHint.width; 1160 dx = old_width - szHint.width;
1081 dy = old_height - szHint.height; 1161 dy = old_height - szHint.height;
1082 1162
1083 /* Check position of the center of the window */ 1163 /* Check position of the center of the window */
1084 if (x < x1) /* left half */ 1164 if (x < x1) /* left half */
1088 if (y < y1) /* top half */ 1168 if (y < y1) /* top half */
1089 dy = 0; 1169 dy = 0;
1090 else if (y == y1) /* exact center */ 1170 else if (y == y1) /* exact center */
1091 dy /= 2; 1171 dy /= 2;
1092 1172
1093 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, 1173 XMoveResizeWindow (disp, TermWin.parent[0], x + dx, y + dy,
1094 szHint.width, szHint.height); 1174 szHint.width, szHint.height);
1095#else 1175#else
1096 XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height); 1176 XResizeWindow (disp, TermWin.parent[0], szHint.width, szHint.height);
1097#endif 1177#endif
1098 } 1178 }
1099 1179
1100 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; 1180 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow;
1101 1181
1102 if (fix_screen || width != old_width || height != old_height) 1182 if (fix_screen || width != old_width || height != old_height)
1103 { 1183 {
1104 if (scrollbar_visible ()) 1184 if (scrollbar_visible ())
1105 { 1185 {
1106 XMoveResizeWindow (display->display, scrollBar.win, 1186 XMoveResizeWindow (disp, scrollBar.win,
1107 window_sb_x, 0, 1187 window_sb_x, 0,
1108 scrollbar_TotalWidth (), szHint.height); 1188 scrollbar_TotalWidth (), szHint.height);
1109 resize_scrollbar (); 1189 resize_scrollbar ();
1110 } 1190 }
1111 1191
1112 if (menubar_visible ()) 1192 if (menubar_visible ())
1113 XMoveResizeWindow (display->display, menuBar.win, 1193 XMoveResizeWindow (disp, menuBar.win,
1114 window_vt_x, 0, 1194 window_vt_x, 0,
1115 TermWin_TotalWidth (), menuBar_TotalHeight ()); 1195 TermWin_TotalWidth (), menuBar_TotalHeight ());
1116 1196
1117 XMoveResizeWindow (display->display, TermWin.vt, 1197 XMoveResizeWindow (disp, TermWin.vt,
1118 window_vt_x, window_vt_y, 1198 window_vt_x, window_vt_y,
1119 TermWin_TotalWidth (), TermWin_TotalHeight ()); 1199 TermWin_TotalWidth (), TermWin_TotalHeight ());
1200
1120 scr_clear (); 1201 scr_clear ();
1121#ifdef XPM_BACKGROUND 1202#ifdef XPM_BACKGROUND
1122 resize_pixmap (); 1203 resize_pixmap ();
1123#endif 1204#endif
1124 } 1205 }
1147 } 1228 }
1148 1229
1149 old_width = szHint.width; 1230 old_width = szHint.width;
1150 old_height = szHint.height; 1231 old_height = szHint.height;
1151 1232
1233#ifdef XPM_BACKGROUND
1234 if (TermWin.pixmap)
1235 scr_touch (false);
1236#endif
1237
1152#ifdef USE_XIM 1238#ifdef USE_XIM
1153 IMSetStatusPosition (); 1239 IMSetStatusPosition ();
1154#endif 1240#endif
1155} 1241}
1156 1242
1164 XWindowAttributes wattr; 1250 XWindowAttributes wattr;
1165 1251
1166 if (width == 0 || height == 0) 1252 if (width == 0 || height == 0)
1167 { 1253 {
1168 XGetWindowAttributes (display->display, display->root, &wattr); 1254 XGetWindowAttributes (display->display, display->root, &wattr);
1255
1169 if (width == 0) 1256 if (width == 0)
1170 width = wattr.width - szHint.base_width; 1257 width = wattr.width - szHint.base_width;
1171 if (height == 0) 1258 if (height == 0)
1172 height = wattr.height - szHint.base_height; 1259 height = wattr.height - szHint.base_height;
1173 } 1260 }
1385 "*", 1472 "*",
1386 TermWin.fheight, 1473 TermWin.fheight,
1387 TermWin.fheight + 1, TermWin.fheight - 1, 1474 TermWin.fheight + 1, TermWin.fheight - 1,
1388 TermWin.fheight - 2, TermWin.fheight + 2); 1475 TermWin.fheight - 2, TermWin.fheight + 2);
1389 1476
1390 fs = XCreateFontSet (display->display, pat, 1477 fs = XCreateFontSet (display->display, rs[Rs_imFont] ? rs[Rs_imFont] : pat,
1391 &missing_charset_list, &missing_charset_count, &def_string); 1478 &missing_charset_list, &missing_charset_count, &def_string);
1392 1479
1393 if (missing_charset_list) 1480 if (missing_charset_list)
1394 XFreeStringList (missing_charset_list); 1481 XFreeStringList (missing_charset_list);
1395 1482
1471{ 1558{
1472 int i, found, had_im; 1559 int i, found, had_im;
1473 const char *p; 1560 const char *p;
1474 char **s; 1561 char **s;
1475 char buf[IMBUFSIZ]; 1562 char buf[IMBUFSIZ];
1563
1564 SET_R (this);
1476 1565
1477 im_destroy (); 1566 im_destroy ();
1478 1567
1479 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); 1568 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()"));
1480 if (Input_Context) 1569 if (Input_Context)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines