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.134 by root, Fri Feb 4 11:41: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
260 } 259 }
261 260
262 // TODO: free pixcolours, colours should become part of rxvt_display 261 // TODO: free pixcolours, colours should become part of rxvt_display
263 262
264 delete pix_colors_focused; 263 delete pix_colors_focused;
265#ifdef OFF_FOCUS_FADING 264#if OFF_FOCUS_FADING
266 delete pix_colors_unfocused; 265 delete pix_colors_unfocused;
267#endif 266#endif
268 267
269 displays.put (display); 268 displays.put (display);
270 269
362{ 361{
363 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) 362 for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++)
364 (*t)->emergency_cleanup (); 363 (*t)->emergency_cleanup ();
365} 364}
366 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
367int 415int
368rxvt_xerror_handler (Display *display, XErrorEvent *event) 416rxvt_xerror_handler (Display *display, XErrorEvent *event)
369{ 417{
370 if (GET_R->allowedxerror == -1) 418 if (GET_R->allowedxerror == -1)
371 GET_R->allowedxerror = event->error_code; 419 GET_R->allowedxerror = event->error_code;
372 else 420 else
373 { 421 {
374 //TODO: GET_R is most likely not the terminal which caused the error 422 // GET_R is most likely not the terminal which caused the error,
375 //TODO: maybe just output the error and continue? 423 // so just output the error and continue
424#if ENABLE_FRILLS
425 print_x_error (display, event);
426#else
376 old_xerror_handler (display, event); 427 old_xerror_handler (display, event);
377 GET_R->destroy (); 428#endif
378 } 429 }
379 430
380 return 0; 431 return 0;
381} 432}
382 433
534 rxvt_fatal ("memory allocation failure. aborting.\n"); 585 rxvt_fatal ("memory allocation failure. aborting.\n");
535 586
536 return p; 587 return p;
537} 588}
538 589
539/* INTPROTO */
540void * 590void *
541rxvt_calloc (size_t number, size_t size) 591rxvt_calloc (size_t number, size_t size)
542{ 592{
543 void *p = calloc (number, size); 593 void *p = calloc (number, size);
544 594
546 rxvt_fatal ("memory allocation failure. aborting.\n"); 596 rxvt_fatal ("memory allocation failure. aborting.\n");
547 597
548 return p; 598 return p;
549} 599}
550 600
551/* INTPROTO */
552void * 601void *
553rxvt_realloc (void *ptr, size_t size) 602rxvt_realloc (void *ptr, size_t size)
554{ 603{
555 void *p = realloc (ptr, size); 604 void *p = realloc (ptr, size);
556 605
660 if (!parsed_geometry) 709 if (!parsed_geometry)
661 { 710 {
662 parsed_geometry = 1; 711 parsed_geometry = 1;
663 if (rs[Rs_geometry]) 712 if (rs[Rs_geometry])
664 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); 713 flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h);
714
665 if (flags & WidthValue) 715 if (flags & WidthValue)
666 { 716 {
667 TermWin.ncol = BOUND_POSITIVE_INT16 (w); 717 TermWin.ncol = BOUND_POSITIVE_INT16 (w);
668 szHint.flags |= USSize; 718 szHint.flags |= USSize;
669 } 719 }
720
670 if (flags & HeightValue) 721 if (flags & HeightValue)
671 { 722 {
672 TermWin.nrow = BOUND_POSITIVE_INT16 (h); 723 TermWin.nrow = BOUND_POSITIVE_INT16 (h);
673 szHint.flags |= USSize; 724 szHint.flags |= USSize;
674 } 725 }
726
675 if (flags & XValue) 727 if (flags & XValue)
676 { 728 {
677 szHint.x = x; 729 szHint.x = x;
678 szHint.flags |= USPosition; 730 szHint.flags |= USPosition;
679 if (flags & XNegative) 731 if (flags & XNegative)
680 { 732 {
681 recalc_x = 1; 733 recalc_x = 1;
682 szHint.win_gravity = NorthEastGravity; 734 szHint.win_gravity = NorthEastGravity;
683 } 735 }
684 } 736 }
737
685 if (flags & YValue) 738 if (flags & YValue)
686 { 739 {
687 szHint.y = y; 740 szHint.y = y;
688 szHint.flags |= USPosition; 741 szHint.flags |= USPosition;
689 if (flags & YNegative) 742 if (flags & YNegative)
788 (void)ioctl (pty.pty, TIOCSWINSZ, &ws); 841 (void)ioctl (pty.pty, TIOCSWINSZ, &ws);
789 842
790#if 0 843#if 0
791 // TIOCSWINSZ⎈ is supposed to do this automatically and correctly 844 // TIOCSWINSZ⎈ is supposed to do this automatically and correctly
792 if (cmd_pid) /* force through to the command */ 845 if (cmd_pid) /* force through to the command */
793 kill (cmd_pid, SIGWINCH); 846 kill (-cmd_pid, SIGWINCH);
794#endif 847#endif
795} 848}
796 849
797/*----------------------------------------------------------------------*/ 850/*----------------------------------------------------------------------*/
798/* set_fonts () - load and set the various fonts 851/* set_fonts () - load and set the various fonts
902/* xterm sequences - title, iconName, color (exptl) */ 955/* xterm sequences - title, iconName, color (exptl) */
903void 956void
904rxvt_term::set_title (const char *str) 957rxvt_term::set_title (const char *str)
905{ 958{
906 set_string_property (XA_WM_NAME, str); 959 set_string_property (XA_WM_NAME, str);
907#if ENABLE_FRILLS 960#if ENABLE_EWMH
908 set_utf8_property (xa[XA_NET_WM_NAME], str); 961 set_utf8_property (xa[XA_NET_WM_NAME], str);
909#endif 962#endif
910} 963}
911 964
912void 965void
913rxvt_term::set_icon_name (const char *str) 966rxvt_term::set_icon_name (const char *str)
914{ 967{
915 set_string_property (XA_WM_ICON_NAME, str); 968 set_string_property (XA_WM_ICON_NAME, str);
916#if ENABLE_FRILLS 969#if ENABLE_EWMH
917 set_utf8_property (xa[XA_NET_WM_ICON_NAME], str); 970 set_utf8_property (xa[XA_NET_WM_ICON_NAME], str);
918#endif 971#endif
919} 972}
920 973
921#ifdef XTERM_COLOR_CHANGE 974#ifdef XTERM_COLOR_CHANGE
937 { /* bright colors */ 990 { /* bright colors */
938 i -= 8; 991 i -= 8;
939# ifndef NO_BRIGHTCOLOR 992# ifndef NO_BRIGHTCOLOR
940 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i]; 993 pix_colors_focused[idx] = pix_colors_focused[minBrightCOLOR + i];
941 SET_PIXCOLOR (idx); 994 SET_PIXCOLOR (idx);
942 goto Done; 995 goto done;
943# endif 996# endif
944 } 997 }
945 998
946 if (i >= 0 && i <= 7) 999 if (i >= 0 && i <= 7)
947 { /* normal colors */ 1000 { /* normal colors */
948 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i]; 1001 pix_colors_focused[idx] = pix_colors_focused[minCOLOR + i];
949 SET_PIXCOLOR (idx); 1002 SET_PIXCOLOR (idx);
950 goto Done; 1003 goto done;
951 } 1004 }
952 } 1005 }
953 1006
954 if (!rXParseAllocColor (&xcol, color)) 1007 if (!rXParseAllocColor (&xcol, color))
955 return; 1008 return;
975 pix_colors_focused[idx] = xcol; 1028 pix_colors_focused[idx] = xcol;
976 SET_PIXCOLOR (idx); 1029 SET_PIXCOLOR (idx);
977 1030
978 /* XSetWindowAttributes attr; */ 1031 /* XSetWindowAttributes attr; */
979 /* Cursor cursor; */ 1032 /* Cursor cursor; */
980Done: 1033done:
1034
981#ifdef OFF_FOCUS_FADING 1035#if OFF_FOCUS_FADING
982 if (rs[Rs_fade]) 1036 if (rs[Rs_fade])
983 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]);
984#endif 1038#endif
985 1039
986 /*TODO: handle Color_BD, scrollbar background, etc. */ 1040 /*TODO: handle Color_BD, scrollbar background, etc. */
987 1041
988 recolour_cursor (); 1042 recolour_cursor ();
1193 XWindowAttributes wattr; 1247 XWindowAttributes wattr;
1194 1248
1195 if (width == 0 || height == 0) 1249 if (width == 0 || height == 0)
1196 { 1250 {
1197 XGetWindowAttributes (display->display, display->root, &wattr); 1251 XGetWindowAttributes (display->display, display->root, &wattr);
1252
1198 if (width == 0) 1253 if (width == 0)
1199 width = wattr.width - szHint.base_width; 1254 width = wattr.width - szHint.base_width;
1200 if (height == 0) 1255 if (height == 0)
1201 height = wattr.height - szHint.base_height; 1256 height = wattr.height - szHint.base_height;
1202 } 1257 }
1500{ 1555{
1501 int i, found, had_im; 1556 int i, found, had_im;
1502 const char *p; 1557 const char *p;
1503 char **s; 1558 char **s;
1504 char buf[IMBUFSIZ]; 1559 char buf[IMBUFSIZ];
1560
1561 SET_R (this);
1505 1562
1506 im_destroy (); 1563 im_destroy ();
1507 1564
1508 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); 1565 D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()"));
1509 if (Input_Context) 1566 if (Input_Context)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines