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.320 by sf-exg, Sat Jan 30 20:43:56 2010 UTC vs.
Revision 1.331 by sf-exg, Mon Jul 26 22:07:38 2010 UTC

35#include "keyboard.h" 35#include "keyboard.h"
36#include "rxvtperl.h" 36#include "rxvtperl.h"
37 37
38#include <limits> 38#include <limits>
39 39
40#include <cassert>
40#include <csignal> 41#include <csignal>
41#include <cstring> 42#include <cstring>
42 43
43#include <termios.h> 44#include <termios.h>
44 45
101 { 102 {
102 if (cc->c2 == c2) return c1; 103 if (cc->c2 == c2) return c1;
103 cc = (*this)[cc->c1]; 104 cc = (*this)[cc->c1];
104 } 105 }
105 106
106 // check to see wether this combination already exists otherwise 107 // check to see whether this combination already exists otherwise
107 for (cc = v.end (); cc-- > v.begin (); ) 108 for (cc = v.end (); cc-- > v.begin (); )
108 { 109 {
109 if (cc->c1 == c1 && cc->c2 == c2) 110 if (cc->c1 == c1 && cc->c2 == c2)
110 return COMPOSE_LO + (cc - v.begin ()); 111 return COMPOSE_LO + (cc - v.begin ());
111 } 112 }
382 char mesg[BUFSIZ]; 383 char mesg[BUFSIZ];
383 char number[32]; 384 char number[32];
384 char *mtype = "XlibMessage"; 385 char *mtype = "XlibMessage";
385 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); 386 XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
386 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); 387 XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
387 rxvt_warn ("An X Error occured, trying to continue after report.\n"); 388 rxvt_warn ("An X Error occurred, trying to continue after report.\n");
388 rxvt_warn ("%s: %s\n", mesg, buffer); 389 rxvt_warn ("%s: %s\n", mesg, buffer);
389 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ); 390 XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ);
390 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code); 391 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code);
391 sprintf(number, "%d", event->request_code); 392 sprintf(number, "%d", event->request_code);
392 XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); 393 XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
393 rxvt_warn ("(which is %s)\n", buffer); 394 rxvt_warn ("(which is %s)\n", buffer);
394 if (event->request_code >= 128) { 395 if (event->request_code >= 128) {
395 XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", 396 XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
396 mesg, BUFSIZ); 397 mesg, BUFSIZ);
397 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code); 398 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code);
398 } 399 }
399 if ((event->error_code == BadWindow) || 400 if ((event->error_code == BadWindow) ||
400 (event->error_code == BadPixmap) || 401 (event->error_code == BadPixmap) ||
401 (event->error_code == BadCursor) || 402 (event->error_code == BadCursor) ||
402 (event->error_code == BadFont) || 403 (event->error_code == BadFont) ||
403 (event->error_code == BadDrawable) || 404 (event->error_code == BadDrawable) ||
404 (event->error_code == BadColor) || 405 (event->error_code == BadColor) ||
405 (event->error_code == BadGC) || 406 (event->error_code == BadGC) ||
406 (event->error_code == BadIDChoice) || 407 (event->error_code == BadIDChoice) ||
407 (event->error_code == BadValue) || 408 (event->error_code == BadValue) ||
408 (event->error_code == BadAtom)) { 409 (event->error_code == BadAtom)) {
409 if (event->error_code == BadValue) 410 if (event->error_code == BadValue)
410 XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", 411 XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
411 mesg, BUFSIZ); 412 mesg, BUFSIZ);
412 else if (event->error_code == BadAtom) 413 else if (event->error_code == BadAtom)
413 XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", 414 XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
414 mesg, BUFSIZ); 415 mesg, BUFSIZ);
415 else 416 else
416 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", 417 XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
417 mesg, BUFSIZ); 418 mesg, BUFSIZ);
418 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid); 419 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid);
419 } 420 }
420 XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", 421 XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
421 mesg, BUFSIZ); 422 mesg, BUFSIZ);
422 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial); 423 rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial);
423} 424}
424#endif 425#endif
425 426
426int 427int
478char **rxvt_environ; // startup environment 479char **rxvt_environ; // startup environment
479 480
480void 481void
481rxvt_init () 482rxvt_init ()
482{ 483{
484 assert (("fontMask must not overlap other RS masks",
485 0 == (RS_fontMask & (RS_Sel | RS_baseattrMask | RS_customMask | RS_bgMask | RS_fgMask))));
486
487 // get rid of stdin/stdout as we don't need them, to free resources
488 dup2 (STDERR_FILENO, STDIN_FILENO);
489 dup2 (STDERR_FILENO, STDOUT_FILENO);
490
483 ptytty::init (); 491 ptytty::init ();
484 492
485 if (!ev_default_loop (0)) 493 if (!ev_default_loop (0))
486 rxvt_fatal ("cannot initialise libev (bad value for LIBEV_METHODS?)\n"); 494 rxvt_fatal ("cannot initialise libev (bad value for LIBEV_METHODS?)\n");
487 495
490 signal (SIGHUP, SIG_IGN); 498 signal (SIGHUP, SIG_IGN);
491 signal (SIGPIPE, SIG_IGN); 499 signal (SIGPIPE, SIG_IGN);
492 500
493 sig_handlers.sw_term.start (SIGTERM); ev_unref (); 501 sig_handlers.sw_term.start (SIGTERM); ev_unref ();
494 sig_handlers.sw_int.start (SIGINT); ev_unref (); 502 sig_handlers.sw_int.start (SIGINT); ev_unref ();
495
496 /* need to trap SIGURG for SVR4 (Unixware) rlogin */
497 /* signal (SIGURG, SIG_DFL); */
498 503
499 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); 504 old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler);
500 // TODO: handle this with exceptions and tolerate the memory loss 505 // TODO: handle this with exceptions and tolerate the memory loss
501 XSetIOErrorHandler (rxvt_xioerror_handler); 506 XSetIOErrorHandler (rxvt_xioerror_handler);
502 507
688#endif 693#endif
689 694
690 delete fontset[0]; 695 delete fontset[0];
691 fontset[0] = fs; 696 fontset[0] = fs;
692 697
693 prop = (*fs)[1]->properties (); 698 prop = (*fs)[rxvt_fontset::firstFont]->properties ();
694 prop.height += lineSpace; 699 prop.height += lineSpace;
695 prop.width += letterSpace; 700 prop.width += letterSpace;
696 701
697 fs->set_prop (prop, false); 702 fs->set_prop (prop, false);
698 703
750 prop, XA_STRING, 8, PropModeReplace, 755 prop, XA_STRING, 8, PropModeReplace,
751 (const unsigned char *)str, len >= 0 ? len : strlen (str)); 756 (const unsigned char *)str, len >= 0 ? len : strlen (str));
752} 757}
753 758
754void 759void
760rxvt_term::set_mbstring_property (Atom prop, const char *str, int len)
761{
762 XTextProperty ct;
763
764 if (XmbTextListToTextProperty (dpy, (char **)&str, 1, XStdICCTextStyle, &ct) >= 0)
765 {
766 XSetTextProperty (dpy, parent[0], &ct, prop);
767 XFree (ct.value);
768 }
769}
770
771void
755rxvt_term::set_utf8_property (Atom prop, const char *str, int len) 772rxvt_term::set_utf8_property (Atom prop, const char *str, int len)
756{ 773{
757 wchar_t *ws = rxvt_mbstowcs (str, len); 774 wchar_t *ws = rxvt_mbstowcs (str, len);
758 char *s = rxvt_wcstoutf8 (ws); 775 char *s = rxvt_wcstoutf8 (ws);
759 776
769/*----------------------------------------------------------------------*/ 786/*----------------------------------------------------------------------*/
770/* xterm sequences - title, iconName, color (exptl) */ 787/* xterm sequences - title, iconName, color (exptl) */
771void 788void
772rxvt_term::set_title (const char *str) 789rxvt_term::set_title (const char *str)
773{ 790{
774 set_string_property (XA_WM_NAME, str); 791 set_mbstring_property (XA_WM_NAME, str);
775#if ENABLE_EWMH 792#if ENABLE_EWMH
776 set_utf8_property (xa[XA_NET_WM_NAME], str); 793 set_utf8_property (xa[XA_NET_WM_NAME], str);
777#endif 794#endif
778} 795}
779 796
780void 797void
781rxvt_term::set_icon_name (const char *str) 798rxvt_term::set_icon_name (const char *str)
782{ 799{
783 set_string_property (XA_WM_ICON_NAME, str); 800 set_mbstring_property (XA_WM_ICON_NAME, str);
784#if ENABLE_EWMH 801#if ENABLE_EWMH
785 set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); 802 set_utf8_property (xa[XA_NET_WM_ICON_NAME], str);
786#endif 803#endif
787} 804}
788 805
995 } 1012 }
996 1013
997 if (fix_screen || old_height == 0) 1014 if (fix_screen || old_height == 0)
998 scr_reset (); 1015 scr_reset ();
999 1016
1000 // TODO, with nvidia-8178, resizes kill the alpha channel, report if not fixed in newer version
1001 //scr_touch (false);
1002
1003#ifdef HAVE_BG_PIXMAP 1017#ifdef HAVE_BG_PIXMAP
1004// TODO: this don't seem to have any effect - do we still need it ? If so - in which case exactly ? 1018// TODO: this don't seem to have any effect - do we still need it ? If so - in which case exactly ?
1005// if (bgPixmap.pixmap) 1019// if (bgPixmap.pixmap)
1006// scr_touch (false); 1020// scr_touch (false);
1007#endif 1021#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines