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.119 by root, Mon Dec 13 01:29:03 2004 UTC vs.
Revision 1.136 by root, Mon Feb 14 18:47:54 2005 UTC

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 */ 35#include "main.intpro" /* PROTOS for internal routines */
36 36
37#include <signal.h> 37#include <csignal>
38#include <cstring>
38 39
39#ifdef TTY_GID_SUPPORT 40#ifdef TTY_GID_SUPPORT
40# include <grp.h> 41# include <grp.h>
41#endif 42#endif
42 43
43#ifdef HAVE_TERMIOS_H 44#ifdef HAVE_TERMIOS_H
44# include <termios.h> 45# include <termios.h>
45#endif 46#endif
46 47
47#include <cstring> 48#ifdef KEYSYM_RESOURCE
49# include "keyboard.h"
50#endif
48 51
49vector<rxvt_term *> rxvt_term::termlist; 52vector<rxvt_term *> rxvt_term::termlist;
50 53
51static char curlocale[128]; 54static char curlocale[128];
52 55
156#endif 159#endif
157#ifdef USE_XIM 160#ifdef USE_XIM
158 im_ev (this, &rxvt_term::im_cb), 161 im_ev (this, &rxvt_term::im_cb),
159#endif 162#endif
160 sw_term (this, &rxvt_term::sig_term), 163 sw_term (this, &rxvt_term::sig_term),
164 sw_int (this, &rxvt_term::sig_term),
161 sw_chld (this, &rxvt_term::sig_chld), 165 sw_chld (this, &rxvt_term::sig_chld),
162 termwin_ev (this, &rxvt_term::x_cb), 166 termwin_ev (this, &rxvt_term::x_cb),
163 vt_ev (this, &rxvt_term::x_cb), 167 vt_ev (this, &rxvt_term::x_cb),
164 check_ev (this, &rxvt_term::check_cb), 168 check_ev (this, &rxvt_term::check_cb),
165 flush_ev (this, &rxvt_term::flush_cb), 169 flush_ev (this, &rxvt_term::flush_cb),
168 incr_ev (this, &rxvt_term::incr_cb) 172 incr_ev (this, &rxvt_term::incr_cb)
169{ 173{
170 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base; 174 cmdbuf_ptr = cmdbuf_endp = cmdbuf_base;
171 175
172 termlist.push_back (this); 176 termlist.push_back (this);
173}
174 177
175rxvt_term::~rxvt_term () 178#ifdef KEYSYM_RESOURCE
176{ 179 keyboard = new keyboard_manager;
177 termlist.erase (find (termlist.begin (), termlist.end(), this));
178 180
181 if (!keyboard)
182 rxvt_fatal ("out of memory, aborting.\n");
183#endif
184}
185
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 ()
189{
179 if (cmd_pid) 190 if (cmd_pid)
180 kill (-cmd_pid, SIGHUP); 191 kill (-cmd_pid, SIGHUP);
181 192
182 pty.put ();
183
184#ifdef UTMP_SUPPORT 193#ifdef UTMP_SUPPORT
185 privileged_utmp (RESTORE); 194 privileged_utmp (RESTORE);
186#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 ();
187 205
188#if ENABLE_STYLES 206#if ENABLE_STYLES
189 for (int i = RS_styleCount; --i; ) 207 for (int i = RS_styleCount; --i; )
190 if (TermWin.fontset[i] != TermWin.fontset[0]) 208 if (TermWin.fontset[i] != TermWin.fontset[0])
191 delete TermWin.fontset[i]; 209 delete TermWin.fontset[i];
192#endif 210#endif
193 delete TermWin.fontset[0]; 211 delete TermWin.fontset[0];
194 212
195 if (display) 213 if (display)
196 { 214 {
215 dDisp;
216
197 selection_clear (); 217 selection_clear ();
198 218
199#ifdef USE_XIM 219#ifdef USE_XIM
200 im_destroy (); 220 im_destroy ();
201#endif 221#endif
202#ifdef MENUBAR 222#ifdef MENUBAR
203 if (menubarGC) XFreeGC (display->display, menubarGC); 223 if (menubarGC) XFreeGC (disp, menubarGC);
204#endif 224#endif
205#ifdef XTERM_SCROLLBAR 225#ifdef XTERM_SCROLLBAR
206 if (xscrollbarGC) XFreeGC (display->display, xscrollbarGC); 226 if (xscrollbarGC) XFreeGC (disp, xscrollbarGC);
207 if (ShadowGC) XFreeGC (display->display, ShadowGC); 227 if (ShadowGC) XFreeGC (disp, ShadowGC);
208#endif 228#endif
209#ifdef PLAIN_SCROLLBAR 229#ifdef PLAIN_SCROLLBAR
210 if (pscrollbarGC) XFreeGC (display->display, pscrollbarGC); 230 if (pscrollbarGC) XFreeGC (disp, pscrollbarGC);
211#endif 231#endif
212#ifdef NEXT_SCROLLBAR 232#ifdef NEXT_SCROLLBAR
213 if (blackGC) XFreeGC (display->display, blackGC); 233 if (blackGC) XFreeGC (disp, blackGC);
214 if (whiteGC) XFreeGC (display->display, whiteGC); 234 if (whiteGC) XFreeGC (disp, whiteGC);
215 if (grayGC) XFreeGC (display->display, grayGC); 235 if (grayGC) XFreeGC (disp, grayGC);
216 if (darkGC) XFreeGC (display->display, darkGC); 236 if (darkGC) XFreeGC (disp, darkGC);
217 if (stippleGC) XFreeGC (display->display, stippleGC); 237 if (stippleGC) XFreeGC (disp, stippleGC);
218 if (dimple) XFreePixmap (display->display, dimple); 238 if (dimple) XFreePixmap (disp, dimple);
219 if (upArrow) XFreePixmap (display->display, upArrow); 239 if (upArrow) XFreePixmap (disp, upArrow);
220 if (downArrow) XFreePixmap (display->display, downArrow); 240 if (downArrow) XFreePixmap (disp, downArrow);
221 if (upArrowHi) XFreePixmap (display->display, upArrowHi); 241 if (upArrowHi) XFreePixmap (disp, upArrowHi);
222 if (downArrowHi) XFreePixmap (display->display, downArrowHi); 242 if (downArrowHi) XFreePixmap (disp, downArrowHi);
223#endif 243#endif
224#if defined(MENUBAR) || defined(RXVT_SCROLLBAR) 244#if defined(MENUBAR) || defined(RXVT_SCROLLBAR)
225 if (topShadowGC) XFreeGC (display->display, topShadowGC); 245 if (topShadowGC) XFreeGC (disp, topShadowGC);
226 if (botShadowGC) XFreeGC (display->display, botShadowGC); 246 if (botShadowGC) XFreeGC (disp, botShadowGC);
227 if (scrollbarGC) XFreeGC (display->display, scrollbarGC); 247 if (scrollbarGC) XFreeGC (disp, scrollbarGC);
228#endif 248#endif
229 if (TermWin.gc) XFreeGC (display->display, TermWin.gc); 249 if (TermWin.gc) XFreeGC (disp, TermWin.gc);
230 250
231#if defined(MENUBAR) && (MENUBAR_MAX > 1) 251#if defined(MENUBAR) && (MENUBAR_MAX > 1)
232 delete menuBar.drawable; 252 delete menuBar.drawable;
233 //if (menuBar.win) 253 //if (menuBar.win)
234 // XDestroyWindow (display->display, menuBar.win); 254 // XDestroyWindow (disp, menuBar.win);
235#endif 255#endif
236 delete TermWin.drawable; 256 delete TermWin.drawable;
237 // destroy all windows 257 // destroy all windows
238 if (TermWin.parent[0]) 258 if (TermWin.parent[0] && !rs[Rs_embed])
239 XDestroyWindow (display->display, TermWin.parent[0]); 259 XDestroyWindow (disp, TermWin.parent[0]);
240 } 260 }
241 261
242 // TODO: free pixcolours, colours should become part of rxvt_display 262 // TODO: free pixcolours, colours should become part of rxvt_display
243 263
244 delete pix_colors_focused; 264 delete pix_colors_focused;
250 270
251 scr_release (); 271 scr_release ();
252 272
253 /* clear all resources */ 273 /* clear all resources */
254 for (int i = 0; i < allocated.size (); i++) 274 for (int i = 0; i < allocated.size (); i++)
255 free (allocated[i]); 275 free (allocated [i]);
256 276
257 free (selection.text); 277 free (selection.text);
258 // TODO: manage env vars in child only(!) 278 // TODO: manage env vars in child only(!)
259 free (env_windowid); 279 free (env_windowid);
260 free (env_display); 280 free (env_display);
261 free (env_term); 281 free (env_term);
262 free (env_colorfgbg); 282 free (env_colorfgbg);
263 free (locale); 283 free (locale);
284 free (v_buffer);
264 free (incr_buf); 285 free (incr_buf);
265 286
266 delete envv; 287 delete envv;
267 delete argv; 288 delete argv;
289
290#ifdef KEYSYM_RESOURCE
291 delete keyboard;
292#endif
268} 293}
269 294
270void 295void
271rxvt_term::destroy () 296rxvt_term::destroy ()
272{ 297{
324 349
325 delete this; 350 delete this;
326} 351}
327 352
328/*----------------------------------------------------------------------*/ 353/*----------------------------------------------------------------------*/
354/*
355 * Exit gracefully, clearing the utmp entry and restoring tty attributes
356 * TODO: if debugging, this should free up any known resources if we can
357 */
358static XErrorHandler old_xerror_handler;
359
360static void
361rxvt_emergency_cleanup ()
362{
363 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
364 (*t)->emergency_cleanup ();
365}
366
367#if ENABLE_FRILLS
368static void
369print_x_error (Display *dpy, XErrorEvent *event)
370{
371 char buffer[BUFSIZ];
372 char mesg[BUFSIZ];
373 char number[32];
374 char *mtype = "XlibMessage";
375 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
376 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
377 rxvt_warn ("An X Error occured, trying to continue after report.\n");
378 rxvt_warn ("%s: %s\n", mesg, buffer);
379 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ);
380 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code);
381 sprintf(number, "%d", event->request_code);
382 XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
383 rxvt_warn ("(which is %s)\n", buffer);
384 if (event->request_code >= 128) {
385 XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
386 mesg, BUFSIZ);
387 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code);
388 }
389 if ((event->error_code == BadWindow) ||
390 (event->error_code == BadPixmap) ||
391 (event->error_code == BadCursor) ||
392 (event->error_code == BadFont) ||
393 (event->error_code == BadDrawable) ||
394 (event->error_code == BadColor) ||
395 (event->error_code == BadGC) ||
396 (event->error_code == BadIDChoice) ||
397 (event->error_code == BadValue) ||
398 (event->error_code == BadAtom)) {
399 if (event->error_code == BadValue)
400 XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
401 mesg, BUFSIZ);
402 else if (event->error_code == BadAtom)
403 XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
404 mesg, BUFSIZ);
405 else
406 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
407 mesg, BUFSIZ);
408 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid);
409 }
410 XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
411 mesg, BUFSIZ);
412 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial);
413}
414#endif
415
416int
417rxvt_xerror_handler (Display *display, XErrorEvent *event)
418{
419 if (GET_R->allowedxerror == -1)
420 GET_R->allowedxerror = event->error_code;
421 else
422 {
423 //TODO: GET_R is most likely not the terminal which caused the error
424 //TODO: maybe just output the error and continue?
425#if ENABLE_FRILLS
426 print_x_error (display, event);
427#else
428 old_xerror_handler (display, event);
429#endif
430 }
431
432 return 0;
433}
434
435int
436rxvt_xioerror_handler (Display *display)
437{
438 rxvt_warn ("X connection to '%s' broken, unable to recover, exiting.\n",
439 DisplayString (display));
440 rxvt_emergency_cleanup ();
441 _exit (EXIT_FAILURE);
442}
443
444/*
445 * Catch a fatal signal and tidy up before quitting
446 */
447void
448rxvt_term::sig_term (sig_watcher &w)
449{
450#ifdef DEBUG_CMD
451 rxvt_warn ("caught signal %d, exiting.\n", w.signum);
452#endif
453 rxvt_emergency_cleanup ();
454 signal (w.signum, SIG_DFL);
455 kill (getpid (), w.signum);
456}
457
458/*----------------------------------------------------------------------*/
329/* rxvt_init () */ 459/* rxvt_init () */
330bool 460bool
331rxvt_term::init (int argc, const char *const *argv) 461rxvt_term::init (int argc, const char *const *argv)
332{ 462{
333 SET_R (this); 463 SET_R (this);
334 464
465 set_locale ("");
466
335 if (!init_vars ()) 467 if (!init_vars ())
336 return false; 468 return false;
337 469
338 init_secondary (); 470 init_secondary ();
339 471
340 const char **cmd_argv = init_resources (argc, argv); 472 const char **cmd_argv = init_resources (argc, argv);
341 473
342 set_locale (""); 474#ifdef KEYSYM_RESOURCE
475 keyboard->register_done ();
476#endif
343 477
344#if MENUBAR_MAX 478#if MENUBAR_MAX
345 menubar_read (rs[Rs_menu]); 479 menubar_read (rs[Rs_menu]);
346#endif 480#endif
347#ifdef HAVE_SCROLLBARS 481#ifdef HAVE_SCROLLBARS
349 scrollBar.setIdle (); /* set existence for size calculations */ 483 scrollBar.setIdle (); /* set existence for size calculations */
350#endif 484#endif
351 485
352 create_windows (argc, argv); 486 create_windows (argc, argv);
353 487
488 dDisp;
489
354 init_xlocale (); 490 init_xlocale ();
355 491
356 scr_reset (); /* initialize screen */ 492 scr_reset (); /* initialize screen */
357 493
358#if 0 494#if 0
359 XSynchronize (display->display, True); 495 XSynchronize (disp, True);
360#endif 496#endif
361 497
362#ifdef HAVE_SCROLLBARS 498#ifdef HAVE_SCROLLBARS
363 if (options & Opt_scrollBar) 499 if (options & Opt_scrollBar)
364 resize_scrollbar (); /* create and map scrollbar */ 500 resize_scrollbar (); /* create and map scrollbar */
365#endif 501#endif
366#if (MENUBAR_MAX) 502#if (MENUBAR_MAX)
367 if (menubar_visible ()) 503 if (menubar_visible ())
368 XMapWindow (display->display, menuBar.win); 504 XMapWindow (disp, menuBar.win);
369#endif 505#endif
370#ifdef TRANSPARENT 506#ifdef TRANSPARENT
371 if (options & Opt_transparent) 507 if (options & Opt_transparent)
372 { 508 {
373 XSelectInput (display->display, display->root, PropertyChangeMask); 509 XSelectInput (disp, display->root, PropertyChangeMask);
374 check_our_parents (); 510 check_our_parents ();
375 rootwin_ev.start (display, display->root); 511 rootwin_ev.start (display, display->root);
376 } 512 }
377#endif 513#endif
378 514
379 XMapWindow (display->display, TermWin.vt); 515 XMapWindow (disp, TermWin.vt);
380 XMapWindow (display->display, TermWin.parent[0]); 516 XMapWindow (disp, TermWin.parent[0]);
381 517
382 set_colorfgbg (); 518 set_colorfgbg ();
383 519
384 init_command (cmd_argv); 520 init_command (cmd_argv);
385 521
522 free (cmd_argv);
523
386 pty_ev.start (pty.pty, EVENT_READ); 524 pty_ev.start (pty.pty, EVENT_READ);
387 525
388 check_ev.start (); 526 check_ev.start ();
389 527
390 return true; 528 return true;
391} 529}
392
393static int (*old_xerror_handler) (Display *dpy, XErrorEvent *event);
394 530
395void 531void
396rxvt_init () 532rxvt_init ()
397{ 533{
398 /* 534 /*
411 /* need to trap SIGURG for SVR4 (Unixware) rlogin */ 547 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
412 /* signal (SIGURG, SIG_DFL); */ 548 /* signal (SIGURG, SIG_DFL); */
413 549
414 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 550 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
415 // TODO: handle this with exceptions and tolerate the memory loss 551 // TODO: handle this with exceptions and tolerate the memory loss
416 //XSetIOErrorHandler ((XErrorHandler) rxvt_xioerror_handler); 552 XSetIOErrorHandler (rxvt_xioerror_handler);
417} 553}
418 554
419/* ------------------------------------------------------------------------- * 555/* ------------------------------------------------------------------------- *
420 * SIGNAL HANDLING & EXIT HANDLER * 556 * SIGNAL HANDLING & EXIT HANDLER *
421 * ------------------------------------------------------------------------- */ 557 * ------------------------------------------------------------------------- */
434 if (pid == (*t)->cmd_pid) 570 if (pid == (*t)->cmd_pid)
435 { 571 {
436 (*t)->destroy (); 572 (*t)->destroy ();
437 break; 573 break;
438 } 574 }
439}
440
441/*----------------------------------------------------------------------*/
442/*
443 * Exit gracefully, clearing the utmp entry and restoring tty attributes
444 * TODO: if debugging, this should free up any known resources if we can
445 */
446void
447rxvt_destroy_all ()
448{
449 // TODO: rxvtd should clean up all ressources
450 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
451 (*t)->destroy ();
452}
453
454/*
455 * Catch a fatal signal and tidy up before quitting
456 */
457void
458rxvt_term::sig_term (sig_watcher &w)
459{
460#ifdef DEBUG_CMD
461 rxvt_warn ("caught signal %d, exiting.\n", w.signum);
462#endif
463 rxvt_destroy_all ();
464 signal (w.signum, SIG_DFL);
465 kill (getpid (), w.signum);
466}
467
468/* INTPROTO */
469int
470rxvt_xerror_handler (Display *display, XErrorEvent *event)
471{
472 if (GET_R->allowedxerror == -1)
473 GET_R->allowedxerror = event->error_code;
474 else
475 {
476 old_xerror_handler (display, event);
477 GET_R->destroy ();
478 }
479
480 return 0;
481} 575}
482 576
483/* ------------------------------------------------------------------------- * 577/* ------------------------------------------------------------------------- *
484 * MEMORY ALLOCATION WRAPPERS * 578 * MEMORY ALLOCATION WRAPPERS *
485 * ------------------------------------------------------------------------- */ 579 * ------------------------------------------------------------------------- */
598 * if width/height are non-zero then override calculated width/height 692 * if width/height are non-zero then override calculated width/height
599 */ 693 */
600void 694void
601rxvt_term::window_calc (unsigned int width, unsigned int height) 695rxvt_term::window_calc (unsigned int width, unsigned int height)
602{ 696{
603 short recalc_x, recalc_y; 697 short recalc_x, recalc_y;
604 int x, y, sb_w, mb_h, flags; 698 int x, y, sb_w, mb_h, flags;
605 unsigned int w, h; 699 unsigned int w, h;
606 unsigned int max_width, max_height; 700 unsigned int max_width, max_height;
701 dDisp;
607 702
608 D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", 703 D_SIZE ((stderr, "< Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
609 TermWin.ncol, TermWin.nrow, szHint.width, 704 TermWin.ncol, TermWin.nrow, szHint.width,
610 szHint.height)); 705 szHint.height));
611 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity; 706 szHint.flags = PMinSize | PResizeInc | PBaseSize | PWinGravity;
617 if (!parsed_geometry) 712 if (!parsed_geometry)
618 { 713 {
619 parsed_geometry = 1; 714 parsed_geometry = 1;
620 if (rs[Rs_geometry]) 715 if (rs[Rs_geometry])
621 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); 716 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h);
717
622 if (flags & WidthValue) 718 if (flags & WidthValue)
623 { 719 {
624 TermWin.ncol = BOUND_POSITIVE_INT16 (w); 720 TermWin.ncol = BOUND_POSITIVE_INT16 (w);
625 szHint.flags |= USSize; 721 szHint.flags |= USSize;
626 } 722 }
723
627 if (flags & HeightValue) 724 if (flags & HeightValue)
628 { 725 {
629 TermWin.nrow = BOUND_POSITIVE_INT16 (h); 726 TermWin.nrow = BOUND_POSITIVE_INT16 (h);
630 szHint.flags |= USSize; 727 szHint.flags |= USSize;
631 } 728 }
729
632 if (flags & XValue) 730 if (flags & XValue)
633 { 731 {
634 szHint.x = x; 732 szHint.x = x;
635 szHint.flags |= USPosition; 733 szHint.flags |= USPosition;
636 if (flags & XNegative) 734 if (flags & XNegative)
637 { 735 {
638 recalc_x = 1; 736 recalc_x = 1;
639 szHint.win_gravity = NorthEastGravity; 737 szHint.win_gravity = NorthEastGravity;
640 } 738 }
641 } 739 }
740
642 if (flags & YValue) 741 if (flags & YValue)
643 { 742 {
644 szHint.y = y; 743 szHint.y = y;
645 szHint.flags |= USPosition; 744 szHint.flags |= USPosition;
646 if (flags & YNegative) 745 if (flags & YNegative)
709 808
710 if (scrollbar_visible () && (options & Opt_scrollBar_right)) 809 if (scrollbar_visible () && (options & Opt_scrollBar_right))
711 window_sb_x = szHint.width - sb_w; 810 window_sb_x = szHint.width - sb_w;
712 811
713 if (recalc_x) 812 if (recalc_x)
714 szHint.x += (DisplayWidth (display->display, DefaultScreen (display->display)) 813 szHint.x += (DisplayWidth (disp, display->screen)
715 - szHint.width - 2 * TermWin.ext_bwidth); 814 - szHint.width - 2 * TermWin.ext_bwidth);
716 if (recalc_y) 815 if (recalc_y)
717 szHint.y += (DisplayHeight (display->display, DefaultScreen (display->display)) 816 szHint.y += (DisplayHeight (disp, display->screen)
718 - szHint.height - 2 * TermWin.ext_bwidth); 817 - szHint.height - 2 * TermWin.ext_bwidth);
719 818
720 TermWin.ncol = TermWin.width / TermWin.fwidth; 819 TermWin.ncol = TermWin.width / TermWin.fwidth;
721 TermWin.nrow = TermWin.height / TermWin.fheight; 820 TermWin.nrow = TermWin.height / TermWin.fheight;
722 D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d", 821 D_SIZE ((stderr, "> Cols/Rows: %3d x %3d ; Width/Height: %4d x %4d",
781 880
782 delete TermWin.fontset[0]; 881 delete TermWin.fontset[0];
783 TermWin.fontset[0] = fs; 882 TermWin.fontset[0] = fs;
784 883
785 prop = (*fs)[1]->properties (); 884 prop = (*fs)[1]->properties ();
885 prop.height += TermWin.lineSpace;
786 fs->set_prop (prop); 886 fs->set_prop (prop);
787 887
788 TermWin.fwidth = prop.width; 888 TermWin.fwidth = prop.width;
789 TermWin.fheight = prop.height; 889 TermWin.fheight = prop.height;
790 TermWin.fweight = prop.weight; 890 TermWin.fweight = prop.weight;
859void 959void
860rxvt_term::set_title (const char *str) 960rxvt_term::set_title (const char *str)
861{ 961{
862 set_string_property (XA_WM_NAME, str); 962 set_string_property (XA_WM_NAME, str);
863#if ENABLE_FRILLS 963#if ENABLE_FRILLS
864 set_utf8_property (display->atom ("_NET_WM_NAME"), str); 964 set_utf8_property (xa[XA_NET_WM_NAME], str);
865#endif 965#endif
866} 966}
867 967
868void 968void
869rxvt_term::set_icon_name (const char *str) 969rxvt_term::set_icon_name (const char *str)
870{ 970{
871 set_string_property (XA_WM_ICON_NAME, str); 971 set_string_property (XA_WM_ICON_NAME, str);
872#if ENABLE_FRILLS 972#if ENABLE_FRILLS
873 set_utf8_property (display->atom ("_NET_WM_ICON_NAME"), str); 973 set_utf8_property (xa[XA_NET_WM_ICON_NAME], str);
874#endif 974#endif
875} 975}
876 976
877#ifdef XTERM_COLOR_CHANGE 977#ifdef XTERM_COLOR_CHANGE
878void 978void
886 986
887 /* handle color aliases */ 987 /* handle color aliases */
888 if (isdigit (*color)) 988 if (isdigit (*color))
889 { 989 {
890 i = atoi (color); 990 i = atoi (color);
991
891 if (i >= 8 && i <= 15) 992 if (i >= 8 && i <= 15)
892 { /* bright colors */ 993 { /* bright colors */
893 i -= 8; 994 i -= 8;
894# ifndef NO_BRIGHTCOLOR 995# ifndef NO_BRIGHTCOLOR
895 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; 996 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i];
896 SET_PIXCOLOR (idx); 997 SET_PIXCOLOR (idx);
897 goto Done; 998 goto Done;
898# endif 999# endif
899
900 } 1000 }
1001
901 if (i >= 0 && i <= 7) 1002 if (i >= 0 && i <= 7)
902 { /* normal colors */ 1003 { /* normal colors */
903 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; 1004 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i];
904 SET_PIXCOLOR (idx); 1005 SET_PIXCOLOR (idx);
905 goto Done; 1006 goto Done;
906 } 1007 }
907 } 1008 }
908 1009
909 if (!rXParseAllocColor (& xcol, color)) 1010 if (!rXParseAllocColor (&xcol, color))
910 return; 1011 return;
911 1012
912 /* XStoreColor (display->display, display->cmap, XColor*); */ 1013 /* XStoreColor (display->display, display->cmap, XColor*); */
913 1014
914 /* 1015 /*
997 1098
998 sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr); 1099 sprintf (env_colorfgbg, "COLORFGBG=%s;%s%s", fstr, xpmb, bstr);
999} 1100}
1000 1101
1001/*----------------------------------------------------------------------*/ 1102/*----------------------------------------------------------------------*/
1002/*
1003 * Colour determination for low colour displays, routine from
1004 * Hans de Goede <hans@highrise.nl>
1005 */
1006 1103
1007int 1104int
1008rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour) 1105rxvt_term::rXParseAllocColor (rxvt_color *screen_in_out, const char *colour)
1009{ 1106{
1010 if (!screen_in_out->set (display, colour)) 1107 if (!screen_in_out->set (display, colour))
1021 * -------------------------------------------------------------------- */ 1118 * -------------------------------------------------------------------- */
1022void 1119void
1023rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent) 1120rxvt_term::resize_all_windows (unsigned int width, unsigned int height, int ignoreparent)
1024{ 1121{
1025 int fix_screen; 1122 int fix_screen;
1026
1027#ifdef SMART_RESIZE 1123#ifdef SMART_RESIZE
1028 int old_width = szHint.width, old_height = szHint.height; 1124 int old_width = szHint.width, old_height = szHint.height;
1029#endif 1125#endif
1126 dDisp;
1030 1127
1031 window_calc (width, height); 1128 window_calc (width, height);
1032 XSetWMNormalHints (display->display, TermWin.parent[0], &szHint); 1129 XSetWMNormalHints (disp, TermWin.parent[0], &szHint);
1033 1130
1034 if (!ignoreparent) 1131 if (!ignoreparent)
1035 { 1132 {
1036#ifdef SMART_RESIZE 1133#ifdef SMART_RESIZE
1037 /* 1134 /*
1041 int x, y, x1, y1; 1138 int x, y, x1, y1;
1042 int dx, dy; 1139 int dx, dy;
1043 unsigned int unused_w1, unused_h1, unused_b1, unused_d1; 1140 unsigned int unused_w1, unused_h1, unused_b1, unused_d1;
1044 Window unused_cr; 1141 Window unused_cr;
1045 1142
1046 XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 1143 XTranslateCoordinates (disp, TermWin.parent[0], display->root,
1047 0, 0, &x, &y, &unused_cr); 1144 0, 0, &x, &y, &unused_cr);
1048 XGetGeometry (display->display, TermWin.parent[0], &unused_cr, &x1, &y1, 1145 XGetGeometry (disp, TermWin.parent[0], &unused_cr, &x1, &y1,
1049 &unused_w1, &unused_h1, &unused_b1, &unused_d1); 1146 &unused_w1, &unused_h1, &unused_b1, &unused_d1);
1050 /* 1147 /*
1051 * if display->root isn't the parent window, a WM will probably have offset 1148 * if display->root isn't the parent window, a WM will probably have offset
1052 * our position for handles and decorations. Counter it 1149 * our position for handles and decorations. Counter it
1053 */ 1150 */
1055 { 1152 {
1056 x -= x1; 1153 x -= x1;
1057 y -= y1; 1154 y -= y1;
1058 } 1155 }
1059 1156
1060 x1 = (DisplayWidth (display->display, display->screen) - old_width) / 2; 1157 x1 = (DisplayWidth (disp, display->screen) - old_width) / 2;
1061 y1 = (DisplayHeight (display->display, display->screen) - old_height) / 2; 1158 y1 = (DisplayHeight (disp, display->screen) - old_height) / 2;
1062 dx = old_width - szHint.width; 1159 dx = old_width - szHint.width;
1063 dy = old_height - szHint.height; 1160 dy = old_height - szHint.height;
1064 1161
1065 /* Check position of the center of the window */ 1162 /* Check position of the center of the window */
1066 if (x < x1) /* left half */ 1163 if (x < x1) /* left half */
1070 if (y < y1) /* top half */ 1167 if (y < y1) /* top half */
1071 dy = 0; 1168 dy = 0;
1072 else if (y == y1) /* exact center */ 1169 else if (y == y1) /* exact center */
1073 dy /= 2; 1170 dy /= 2;
1074 1171
1075 XMoveResizeWindow (display->display, TermWin.parent[0], x + dx, y + dy, 1172 XMoveResizeWindow (disp, TermWin.parent[0], x + dx, y + dy,
1076 szHint.width, szHint.height); 1173 szHint.width, szHint.height);
1077#else 1174#else
1078 XResizeWindow (display->display, TermWin.parent[0], szHint.width, szHint.height); 1175 XResizeWindow (disp, TermWin.parent[0], szHint.width, szHint.height);
1079#endif 1176#endif
1080 } 1177 }
1081 1178
1082 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow; 1179 fix_screen = TermWin.ncol != prev_ncol || TermWin.nrow != prev_nrow;
1083 1180
1084 if (fix_screen || width != old_width || height != old_height) 1181 if (fix_screen || width != old_width || height != old_height)
1085 { 1182 {
1086 if (scrollbar_visible ()) 1183 if (scrollbar_visible ())
1087 { 1184 {
1088 XMoveResizeWindow (display->display, scrollBar.win, 1185 XMoveResizeWindow (disp, scrollBar.win,
1089 window_sb_x, 0, 1186 window_sb_x, 0,
1090 scrollbar_TotalWidth (), szHint.height); 1187 scrollbar_TotalWidth (), szHint.height);
1091 resize_scrollbar (); 1188 resize_scrollbar ();
1092 } 1189 }
1093 1190
1094 if (menubar_visible ()) 1191 if (menubar_visible ())
1095 XMoveResizeWindow (display->display, menuBar.win, 1192 XMoveResizeWindow (disp, menuBar.win,
1096 window_vt_x, 0, 1193 window_vt_x, 0,
1097 TermWin_TotalWidth (), menuBar_TotalHeight ()); 1194 TermWin_TotalWidth (), menuBar_TotalHeight ());
1098 1195
1099 XMoveResizeWindow (display->display, TermWin.vt, 1196 XMoveResizeWindow (disp, TermWin.vt,
1100 window_vt_x, window_vt_y, 1197 window_vt_x, window_vt_y,
1101 TermWin_TotalWidth (), TermWin_TotalHeight ()); 1198 TermWin_TotalWidth (), TermWin_TotalHeight ());
1199
1102 scr_clear (); 1200 scr_clear ();
1103#ifdef XPM_BACKGROUND 1201#ifdef XPM_BACKGROUND
1104 resize_pixmap (); 1202 resize_pixmap ();
1105#endif 1203#endif
1106 } 1204 }
1128 } 1226 }
1129 } 1227 }
1130 1228
1131 old_width = szHint.width; 1229 old_width = szHint.width;
1132 old_height = szHint.height; 1230 old_height = szHint.height;
1231
1232#ifdef XPM_BACKGROUND
1233 if (TermWin.pixmap)
1234 scr_touch (false);
1235#endif
1133 1236
1134#ifdef USE_XIM 1237#ifdef USE_XIM
1135 IMSetStatusPosition (); 1238 IMSetStatusPosition ();
1136#endif 1239#endif
1137} 1240}
1367 "*", 1470 "*",
1368 TermWin.fheight, 1471 TermWin.fheight,
1369 TermWin.fheight + 1, TermWin.fheight - 1, 1472 TermWin.fheight + 1, TermWin.fheight - 1,
1370 TermWin.fheight - 2, TermWin.fheight + 2); 1473 TermWin.fheight - 2, TermWin.fheight + 2);
1371 1474
1372 fs = XCreateFontSet (display->display, pat, 1475 fs = XCreateFontSet (display->display, rs[Rs_imFont] ? rs[Rs_imFont] : pat,
1373 &missing_charset_list, &missing_charset_count, &def_string); 1476 &missing_charset_list, &missing_charset_count, &def_string);
1374 1477
1375 if (missing_charset_list) 1478 if (missing_charset_list)
1376 XFreeStringList (missing_charset_list); 1479 XFreeStringList (missing_charset_list);
1377 1480
1453{ 1556{
1454 int i, found, had_im; 1557 int i, found, had_im;
1455 const char *p; 1558 const char *p;
1456 char **s; 1559 char **s;
1457 char buf[IMBUFSIZ]; 1560 char buf[IMBUFSIZ];
1561
1562 SET_R (this);
1458 1563
1459 im_destroy (); 1564 im_destroy ();
1460 1565
1461 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); 1566 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()"));
1462 if (Input_Context) 1567 if (Input_Context)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines