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.146 by root, Mon Nov 28 18:37:42 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])
249 XDestroyWindow (display->display, TermWin.parent[0]); 258 XDestroyWindow (disp, TermWin.parent[0]);
250 } 259 }
251 260
252 // TODO: free pixcolours, colours should become part of rxvt_display 261 // TODO: free pixcolours, colours should become part of rxvt_display
253 262
254 delete pix_colors_focused; 263 delete pix_colors_focused;
255#ifdef OFF_FOCUS_FADING 264#if OFF_FOCUS_FADING
256 delete pix_colors_unfocused; 265 delete pix_colors_unfocused;
257#endif 266#endif
258 267
259 displays.put (display); 268 displays.put (display);
260 269
261 scr_release (); 270 scr_release ();
262 271
263 /* clear all resources */ 272 /* clear all resources */
264 for (int i = 0; i < allocated.size (); i++) 273 for (int i = 0; i < allocated.size (); i++)
265 free (allocated[i]); 274 free (allocated [i]);
266 275
267 free (selection.text); 276 free (selection.text);
268 // TODO: manage env vars in child only(!) 277 // TODO: manage env vars in child only(!)
269 free (env_windowid); 278 free (env_windowid);
270 free (env_display); 279 free (env_display);
276 285
277 delete envv; 286 delete envv;
278 delete argv; 287 delete argv;
279 288
280#ifdef KEYSYM_RESOURCE 289#ifdef KEYSYM_RESOURCE
281 delete keyboard; 290 delete keyboard;
282#endif 291#endif
283} 292}
284 293
285void 294void
286rxvt_term::destroy () 295rxvt_term::destroy ()
339 348
340 delete this; 349 delete this;
341} 350}
342 351
343/*----------------------------------------------------------------------*/ 352/*----------------------------------------------------------------------*/
353/*
354 * Exit gracefully, clearing the utmp entry and restoring tty attributes
355 * TODO: if debugging, this should free up any known resources if we can
356 */
357static XErrorHandler old_xerror_handler;
358
359static void
360rxvt_emergency_cleanup ()
361{
362 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
363 (*t)->emergency_cleanup ();
364}
365
366#if ENABLE_FRILLS
367static void
368print_x_error (Display *dpy, XErrorEvent *event)
369{
370 char buffer[BUFSIZ];
371 char mesg[BUFSIZ];
372 char number[32];
373 char *mtype = "XlibMessage";
374 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
375 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
376 rxvt_warn ("An X Error occured, trying to continue after report.\n");
377 rxvt_warn ("%s: %s\n", mesg, buffer);
378 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ);
379 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code);
380 sprintf(number, "%d", event->request_code);
381 XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
382 rxvt_warn ("(which is %s)\n", buffer);
383 if (event->request_code >= 128) {
384 XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
385 mesg, BUFSIZ);
386 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code);
387 }
388 if ((event->error_code == BadWindow) ||
389 (event->error_code == BadPixmap) ||
390 (event->error_code == BadCursor) ||
391 (event->error_code == BadFont) ||
392 (event->error_code == BadDrawable) ||
393 (event->error_code == BadColor) ||
394 (event->error_code == BadGC) ||
395 (event->error_code == BadIDChoice) ||
396 (event->error_code == BadValue) ||
397 (event->error_code == BadAtom)) {
398 if (event->error_code == BadValue)
399 XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
400 mesg, BUFSIZ);
401 else if (event->error_code == BadAtom)
402 XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
403 mesg, BUFSIZ);
404 else
405 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
406 mesg, BUFSIZ);
407 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid);
408 }
409 XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
410 mesg, BUFSIZ);
411 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial);
412}
413#endif
414
415int
416rxvt_xerror_handler (Display *display, XErrorEvent *event)
417{
418 if (GET_R->allowedxerror == -1)
419 GET_R->allowedxerror = event->error_code;
420 else
421 {
422 // GET_R is most likely not the terminal which caused the error,
423 // so just output the error and continue
424#if ENABLE_FRILLS
425 print_x_error (display, event);
426#else
427 old_xerror_handler (display, event);
428#endif
429 }
430
431 return 0;
432}
433
434int
435rxvt_xioerror_handler (Display *display)
436{
437 rxvt_warn ("X connection to '%s' broken, unable to recover, exiting.\n",
438 DisplayString (display));
439 rxvt_emergency_cleanup ();
440 _exit (EXIT_FAILURE);
441}
442
443/*
444 * Catch a fatal signal and tidy up before quitting
445 */
446void
447rxvt_term::sig_term (sig_watcher &w)
448{
449#ifdef DEBUG_CMD
450 rxvt_warn ("caught signal %d, exiting.\n", w.signum);
451#endif
452 rxvt_emergency_cleanup ();
453 signal (w.signum, SIG_DFL);
454 kill (getpid (), w.signum);
455}
456
457/*----------------------------------------------------------------------*/
344/* rxvt_init () */ 458/* rxvt_init () */
345bool 459bool
346rxvt_term::init (int argc, const char *const *argv) 460rxvt_term::init (int argc, const char *const *argv)
347{ 461{
348 SET_R (this); 462 SET_R (this);
368 scrollBar.setIdle (); /* set existence for size calculations */ 482 scrollBar.setIdle (); /* set existence for size calculations */
369#endif 483#endif
370 484
371 create_windows (argc, argv); 485 create_windows (argc, argv);
372 486
487 dDisp;
488
373 init_xlocale (); 489 init_xlocale ();
374 490
375 scr_reset (); /* initialize screen */ 491 scr_reset (); /* initialize screen */
376 492
377#if 0 493#if 0
378 XSynchronize (display->display, True); 494 XSynchronize (disp, True);
379#endif 495#endif
380 496
381#ifdef HAVE_SCROLLBARS 497#ifdef HAVE_SCROLLBARS
382 if (options & Opt_scrollBar) 498 if (options & Opt_scrollBar)
383 resize_scrollbar (); /* create and map scrollbar */ 499 resize_scrollbar (); /* create and map scrollbar */
384#endif 500#endif
385#if (MENUBAR_MAX) 501#if (MENUBAR_MAX)
386 if (menubar_visible ()) 502 if (menubar_visible ())
387 XMapWindow (display->display, menuBar.win); 503 XMapWindow (disp, menuBar.win);
388#endif 504#endif
389#ifdef TRANSPARENT 505#ifdef TRANSPARENT
390 if (options & Opt_transparent) 506 if (options & Opt_transparent)
391 { 507 {
392 XSelectInput (display->display, display->root, PropertyChangeMask); 508 XSelectInput (disp, display->root, PropertyChangeMask);
393 check_our_parents (); 509 check_our_parents ();
394 rootwin_ev.start (display, display->root); 510 rootwin_ev.start (display, display->root);
395 } 511 }
396#endif 512#endif
397 513
398 XMapWindow (display->display, TermWin.vt); 514 XMapWindow (disp, TermWin.vt);
399 XMapWindow (display->display, TermWin.parent[0]); 515 XMapWindow (disp, TermWin.parent[0]);
400 516
401 set_colorfgbg (); 517 set_colorfgbg ();
402 518
403 init_command (cmd_argv); 519 init_command (cmd_argv);
404 520
408 524
409 check_ev.start (); 525 check_ev.start ();
410 526
411 return true; 527 return true;
412} 528}
413
414static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event);
415 529
416void 530void
417rxvt_init () 531rxvt_init ()
418{ 532{
419 /* 533 /*
432 /* need to trap SIGURG for SVR4 (Unixware) rlogin */ 546 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
433 /* signal (SIGURG, SIG_DFL); */ 547 /* signal (SIGURG, SIG_DFL); */
434 548
435 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 549 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
436 // TODO: handle this with exceptions and tolerate the memory loss 550 // TODO: handle this with exceptions and tolerate the memory loss
437 //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); 551 XSetIOErrorHandler (rxvt_xioerror_handler);
438} 552}
439 553
440/* ------------------------------------------------------------------------- * 554/* ------------------------------------------------------------------------- *
441 * SIGNAL HANDLING & EXIT HANDLER * 555 * SIGNAL HANDLING & EXIT HANDLER *
442 * ------------------------------------------------------------------------- */ 556 * ------------------------------------------------------------------------- */
457 (*t)->destroy (); 571 (*t)->destroy ();
458 break; 572 break;
459 } 573 }
460} 574}
461 575
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/* ------------------------------------------------------------------------- * 576/* ------------------------------------------------------------------------- *
505 * MEMORY ALLOCATION WRAPPERS * 577 * MEMORY ALLOCATION WRAPPERS *
506 * ------------------------------------------------------------------------- */ 578 * ------------------------------------------------------------------------- */
507void * 579void *
508rxvt_malloc (size_t size) 580rxvt_malloc (size_t size)
513 rxvt_fatal ("memory allocation failure. aborting.\n"); 585 rxvt_fatal ("memory allocation failure. aborting.\n");
514 586
515 return p; 587 return p;
516} 588}
517 589
518/* INTPROTO */
519void * 590void *
520rxvt_calloc (size_t number, size_t size) 591rxvt_calloc (size_t number, size_t size)
521{ 592{
522 void *p = calloc (number, size); 593 void *p = calloc (number, size);
523 594
525 rxvt_fatal ("memory allocation failure. aborting.\n"); 596 rxvt_fatal ("memory allocation failure. aborting.\n");
526 597
527 return p; 598 return p;
528} 599}
529 600
530/* INTPROTO */
531void * 601void *
532rxvt_realloc (void *ptr, size_t size) 602rxvt_realloc (void *ptr, size_t size)
533{ 603{
534 void *p = realloc (ptr, size); 604 void *p = realloc (ptr, size);
535 605
619 * if width/height are non-zero then override calculated width/height 689 * if width/height are non-zero then override calculated width/height
620 */ 690 */
621void 691void
622rxvt_term::window_calc (unsigned int width, unsigned int height) 692rxvt_term::window_calc (unsigned int width, unsigned int height)
623{ 693{
624 short recalc_x, recalc_y; 694 short recalc_x, recalc_y;
625 int x, y, sb_w, mb_h, flags; 695 int x, y, sb_w, mb_h, flags;
626 unsigned int w, h; 696 unsigned int w, h;
627 unsigned int max_width, max_height; 697 unsigned int max_width, max_height;
698 dDisp;
628 699
629 D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", 700 D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
630 TermWin.ncol, TermWin.nrow, szHint.width, 701 TermWin.ncol, TermWin.nrow, szHint.width,
631 szHint.height)); 702 szHint.height));
632 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; 703 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity;
638 if (!parsed_geometry) 709 if (!parsed_geometry)
639 { 710 {
640 parsed_geometry = 1; 711 parsed_geometry = 1;
641 if (rs[Rs_geometry]) 712 if (rs[Rs_geometry])
642 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); 713 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h);
714
643 if (flags & WidthValue) 715 if (flags & WidthValue)
644 { 716 {
645 TermWin.ncol = BOUND_POSITIVE_INT16 (w); 717 TermWin.ncol = BOUND_POSITIVE_INT16 (w);
646 szHint.flags |= USSize; 718 szHint.flags |= USSize;
647 } 719 }
720
648 if (flags & HeightValue) 721 if (flags & HeightValue)
649 { 722 {
650 TermWin.nrow = BOUND_POSITIVE_INT16 (h); 723 TermWin.nrow = BOUND_POSITIVE_INT16 (h);
651 szHint.flags |= USSize; 724 szHint.flags |= USSize;
652 } 725 }
726
653 if (flags & XValue) 727 if (flags & XValue)
654 { 728 {
655 szHint.x = x; 729 szHint.x = x;
656 szHint.flags |= USPosition; 730 szHint.flags |= USPosition;
657 if (flags & XNegative) 731 if (flags & XNegative)
658 { 732 {
659 recalc_x = 1; 733 recalc_x = 1;
660 szHint.win_gravity = NorthEastGravity; 734 szHint.win_gravity = NorthEastGravity;
661 } 735 }
662 } 736 }
737
663 if (flags & YValue) 738 if (flags & YValue)
664 { 739 {
665 szHint.y = y; 740 szHint.y = y;
666 szHint.flags |= USPosition; 741 szHint.flags |= USPosition;
667 if (flags & YNegative) 742 if (flags & YNegative)
730 805
731 if (scrollbar_visible () && (options & Opt_scrollBar_right)) 806 if (scrollbar_visible () && (options & Opt_scrollBar_right))
732 window_sb_x = szHint.width - sb_w; 807 window_sb_x = szHint.width - sb_w;
733 808
734 if (recalc_x) 809 if (recalc_x)
735 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) 810 szHint.x += (DisplayWidth (disp, display->screen)
736 - szHint.width - 2 * TermWin.ext_bwidth); 811 - szHint.width - 2 * TermWin.ext_bwidth);
737 if (recalc_y) 812 if (recalc_y)
738 szHint.y += (DisplayHeight (display->display, DefaultScreen (display->display)) 813 szHint.y += (DisplayHeight (disp, display->screen)
739 - szHint.height - 2 * TermWin.ext_bwidth); 814 - szHint.height - 2 * TermWin.ext_bwidth);
740 815
741 TermWin.ncol = TermWin.width / TermWin.fwidth; 816 TermWin.ncol = TermWin.width / TermWin.fwidth;
742 TermWin.nrow = TermWin.height / TermWin.fheight; 817 TermWin.nrow = TermWin.height / TermWin.fheight;
743 D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", 818 D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
766 (void)ioctl (pty.pty, TIOCSWINSZ, &ws); 841 (void)ioctl (pty.pty, TIOCSWINSZ, &ws);
767 842
768#if 0 843#if 0
769 // TIOCSWINSZ⎈ is supposed to do this automatically and correctly 844 // TIOCSWINSZ⎈ is supposed to do this automatically and correctly
770 if (cmd_pid) /* force through to the command */ 845 if (cmd_pid) /* force through to the command */
771 kill (cmd_pid, SIGWINCH); 846 kill (-cmd_pid, SIGWINCH);
772#endif 847#endif
773} 848}
774 849
775/*----------------------------------------------------------------------*/ 850/*----------------------------------------------------------------------*/
776/* set_fonts () - load and set the various fonts 851/* set_fonts () - load and set the various fonts
880/* xterm sequences - title, iconName, color (exptl) */ 955/* xterm sequences - title, iconName, color (exptl) */
881void 956void
882rxvt_term::set_title (const char *str) 957rxvt_term::set_title (const char *str)
883{ 958{
884 set_string_property (XA_WM_NAME, str); 959 set_string_property (XA_WM_NAME, str);
885#if ENABLE_FRILLS 960#if ENABLE_EWMH
886 set_utf8_property (xa[XA_NET_WM_NAME], str); 961 set_utf8_property (xa[XA_NET_WM_NAME], str);
887#endif 962#endif
888} 963}
889 964
890void 965void
891rxvt_term::set_icon_name (const char *str) 966rxvt_term::set_icon_name (const char *str)
892{ 967{
893 set_string_property (XA_WM_ICON_NAME, str); 968 set_string_property (XA_WM_ICON_NAME, str);
894#if ENABLE_FRILLS 969#if ENABLE_EWMH
895 set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); 970 set_utf8_property (xa[XA_NET_WM_ICON_NAME], str);
896#endif 971#endif
897} 972}
898 973
899#ifdef XTERM_COLOR_CHANGE 974#ifdef XTERM_COLOR_CHANGE
908 983
909 /* handle color aliases */ 984 /* handle color aliases */
910 if (isdigit (*color)) 985 if (isdigit (*color))
911 { 986 {
912 i = atoi (color); 987 i = atoi (color);
988
913 if (i >= 8 && i <= 15) 989 if (i >= 8 && i <= 15)
914 { /* bright colors */ 990 { /* bright colors */
915 i -= 8; 991 i -= 8;
916# ifndef NO_BRIGHTCOLOR 992# ifndef NO_BRIGHTCOLOR
917 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; 993 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i];
918 SET_PIXCOLOR (idx); 994 SET_PIXCOLOR (idx);
919 goto Done; 995 goto done;
920# endif 996# endif
921
922 } 997 }
998
923 if (i >= 0 && i <= 7) 999 if (i >= 0 && i <= 7)
924 { /* normal colors */ 1000 { /* normal colors */
925 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; 1001 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i];
926 SET_PIXCOLOR (idx); 1002 SET_PIXCOLOR (idx);
927 goto Done; 1003 goto done;
928 } 1004 }
929 } 1005 }
930 1006
931 if (!rXParseAllocColor (& xcol, color)) 1007 if (!rXParseAllocColor (&xcol, color))
932 return; 1008 return;
933 1009
934 /* XStoreColor (display->display, display->cmap, XColor*); */ 1010 /* XStoreColor (display->display, display->cmap, XColor*); */
935 1011
936 /* 1012 /*
952 pix_colors_focused[idx] = xcol; 1028 pix_colors_focused[idx] = xcol;
953 SET_PIXCOLOR (idx); 1029 SET_PIXCOLOR (idx);
954 1030
955 /* XSetWindowAttributes attr; */ 1031 /* XSetWindowAttributes attr; */
956 /* Cursor cursor; */ 1032 /* Cursor cursor; */
957Done: 1033done:
1034
958#ifdef OFF_FOCUS_FADING 1035#if OFF_FOCUS_FADING
959 if (rs[Rs_fade]) 1036 if (rs[Rs_fade])
960 pix_colors_unfocused[idx] = pix_colors_focused[idx].fade (display, atoi (rs[Rs_fade])); 1037 pix_colors_unfocused[idx] = pix_colors_focused[idx].fade (display, atoi (rs[Rs_fade]), pix_colors[Color_fade]);
961#endif 1038#endif
962 1039
963 /*TODO: handle Color_BD, scrollbar background, etc. */ 1040 /*TODO: handle Color_BD, scrollbar background, etc. */
964 1041
965 recolour_cursor (); 1042 recolour_cursor ();
1039 * -------------------------------------------------------------------- */ 1116 * -------------------------------------------------------------------- */
1040void 1117void
1041rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent) 1118rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent)
1042{ 1119{
1043 int fix_screen; 1120 int fix_screen;
1044
1045#ifdef SMART_RESIZE 1121#ifdef SMART_RESIZE
1046 int old_width = szHint.width, old_height = szHint.height; 1122 int old_width = szHint.width, old_height = szHint.height;
1047#endif 1123#endif
1124 dDisp;
1048 1125
1049 window_calc (width, height); 1126 window_calc (width, height);
1050 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); 1127 XSetWMNormalHints (disp, TermWin.parent[0], &szHint);
1051 1128
1052 if (!ignoreparent) 1129 if (!ignoreparent)
1053 { 1130 {
1054#ifdef SMART_RESIZE 1131#ifdef SMART_RESIZE
1055 /* 1132 /*
1059 int x, y, x1, y1; 1136 int x, y, x1, y1;
1060 int dx, dy; 1137 int dx, dy;
1061 unsigned int unused_w1, unused_h1, unused_b1, unused_d1; 1138 unsigned int unused_w1, unused_h1, unused_b1, unused_d1;
1062 Window unused_cr; 1139 Window unused_cr;
1063 1140
1064 XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 1141 XTranslateCoordinates (disp, TermWin.parent[0], display->root,
1065 0, 0, &x, &y, &unused_cr); 1142 0, 0, &x, &y, &unused_cr);
1066 XGetGeometry (display->display, TermWin.parent[0], &unused_cr, &x1, &y1, 1143 XGetGeometry (disp, TermWin.parent[0], &unused_cr, &x1, &y1,
1067 &unused_w1, &unused_h1, &unused_b1, &unused_d1); 1144 &unused_w1, &unused_h1, &unused_b1, &unused_d1);
1068 /* 1145 /*
1069 * if display->root isn't the parent window, a WM will probably have offset 1146 * if display->root isn't the parent window, a WM will probably have offset
1070 * our position for handles and decorations. Counter it 1147 * our position for handles and decorations. Counter it
1071 */ 1148 */
1073 { 1150 {
1074 x -= x1; 1151 x -= x1;
1075 y -= y1; 1152 y -= y1;
1076 } 1153 }
1077 1154
1078 x1 = (DisplayWidth (display->display, display->screen) - old_width) / 2; 1155 x1 = (DisplayWidth (disp, display->screen) - old_width) / 2;
1079 y1 = (DisplayHeight (display->display, display->screen) - old_height) / 2; 1156 y1 = (DisplayHeight (disp, display->screen) - old_height) / 2;
1080 dx = old_width - szHint.width; 1157 dx = old_width - szHint.width;
1081 dy = old_height - szHint.height; 1158 dy = old_height - szHint.height;
1082 1159
1083 /* Check position of the center of the window */ 1160 /* Check position of the center of the window */
1084 if (x < x1) /* left half */ 1161 if (x < x1) /* left half */
1088 if (y < y1) /* top half */ 1165 if (y < y1) /* top half */
1089 dy = 0; 1166 dy = 0;
1090 else if (y == y1) /* exact center */ 1167 else if (y == y1) /* exact center */
1091 dy /= 2; 1168 dy /= 2;
1092 1169
1093 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, 1170 XMoveResizeWindow (disp, TermWin.parent[0], x + dx, y + dy,
1094 szHint.width, szHint.height); 1171 szHint.width, szHint.height);
1095#else 1172#else
1096 XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height); 1173 XResizeWindow (disp, TermWin.parent[0], szHint.width, szHint.height);
1097#endif 1174#endif
1098 } 1175 }
1099 1176
1100 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; 1177 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow;
1101 1178
1102 if (fix_screen || width != old_width || height != old_height) 1179 if (fix_screen || width != old_width || height != old_height)
1103 { 1180 {
1104 if (scrollbar_visible ()) 1181 if (scrollbar_visible ())
1105 { 1182 {
1106 XMoveResizeWindow (display->display, scrollBar.win, 1183 XMoveResizeWindow (disp, scrollBar.win,
1107 window_sb_x, 0, 1184 window_sb_x, 0,
1108 scrollbar_TotalWidth (), szHint.height); 1185 scrollbar_TotalWidth (), szHint.height);
1109 resize_scrollbar (); 1186 resize_scrollbar ();
1110 } 1187 }
1111 1188
1112 if (menubar_visible ()) 1189 if (menubar_visible ())
1113 XMoveResizeWindow (display->display, menuBar.win, 1190 XMoveResizeWindow (disp, menuBar.win,
1114 window_vt_x, 0, 1191 window_vt_x, 0,
1115 TermWin_TotalWidth (), menuBar_TotalHeight ()); 1192 TermWin_TotalWidth (), menuBar_TotalHeight ());
1116 1193
1117 XMoveResizeWindow (display->display, TermWin.vt, 1194 XMoveResizeWindow (disp, TermWin.vt,
1118 window_vt_x, window_vt_y, 1195 window_vt_x, window_vt_y,
1119 TermWin_TotalWidth (), TermWin_TotalHeight ()); 1196 TermWin_TotalWidth (), TermWin_TotalHeight ());
1197
1120 scr_clear (); 1198 scr_clear ();
1121#ifdef XPM_BACKGROUND 1199#ifdef XPM_BACKGROUND
1122 resize_pixmap (); 1200 resize_pixmap ();
1123#endif 1201#endif
1124 } 1202 }
1147 } 1225 }
1148 1226
1149 old_width = szHint.width; 1227 old_width = szHint.width;
1150 old_height = szHint.height; 1228 old_height = szHint.height;
1151 1229
1230#ifdef XPM_BACKGROUND
1231 if (TermWin.pixmap)
1232 scr_touch (false);
1233#endif
1234
1152#ifdef USE_XIM 1235#ifdef USE_XIM
1153 IMSetStatusPosition (); 1236 IMSetStatusPosition ();
1154#endif 1237#endif
1155} 1238}
1156 1239
1164 XWindowAttributes wattr; 1247 XWindowAttributes wattr;
1165 1248
1166 if (width == 0 || height == 0) 1249 if (width == 0 || height == 0)
1167 { 1250 {
1168 XGetWindowAttributes (display->display, display->root, &wattr); 1251 XGetWindowAttributes (display->display, display->root, &wattr);
1252
1169 if (width == 0) 1253 if (width == 0)
1170 width = wattr.width - szHint.base_width; 1254 width = wattr.width - szHint.base_width;
1171 if (height == 0) 1255 if (height == 0)
1172 height = wattr.height - szHint.base_height; 1256 height = wattr.height - szHint.base_height;
1173 } 1257 }
1385 "*", 1469 "*",
1386 TermWin.fheight, 1470 TermWin.fheight,
1387 TermWin.fheight + 1, TermWin.fheight - 1, 1471 TermWin.fheight + 1, TermWin.fheight - 1,
1388 TermWin.fheight - 2, TermWin.fheight + 2); 1472 TermWin.fheight - 2, TermWin.fheight + 2);
1389 1473
1390 fs = XCreateFontSet (display->display, pat, 1474 fs = XCreateFontSet (display->display, rs[Rs_imFont] ? rs[Rs_imFont] : pat,
1391 &missing_charset_list, &missing_charset_count, &def_string); 1475 &missing_charset_list, &missing_charset_count, &def_string);
1392 1476
1393 if (missing_charset_list) 1477 if (missing_charset_list)
1394 XFreeStringList (missing_charset_list); 1478 XFreeStringList (missing_charset_list);
1395 1479
1471{ 1555{
1472 int i, found, had_im; 1556 int i, found, had_im;
1473 const char *p; 1557 const char *p;
1474 char **s; 1558 char **s;
1475 char buf[IMBUFSIZ]; 1559 char buf[IMBUFSIZ];
1560
1561 SET_R (this);
1476 1562
1477 im_destroy (); 1563 im_destroy ();
1478 1564
1479 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); 1565 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()"));
1480 if (Input_Context) 1566 if (Input_Context)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines