… | |
… | |
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 |
… | |
… | |
253 | //if (menuBar.win) |
252 | //if (menuBar.win) |
254 | // XDestroyWindow (disp, menuBar.win); |
253 | // XDestroyWindow (disp, menuBar.win); |
255 | #endif |
254 | #endif |
256 | delete TermWin.drawable; |
255 | delete TermWin.drawable; |
257 | // destroy all windows |
256 | // destroy all windows |
258 | if (TermWin.parent[0]) |
257 | if (TermWin.parent[0] |
|
|
258 | #if ENABLE_FRILLS |
|
|
259 | && !rs[Rs_embed] |
|
|
260 | #endif |
|
|
261 | ) |
259 | XDestroyWindow (disp, TermWin.parent[0]); |
262 | XDestroyWindow (disp, TermWin.parent[0]); |
260 | } |
263 | } |
261 | |
264 | |
262 | // TODO: free pixcolours, colours should become part of rxvt_display |
265 | // TODO: free pixcolours, colours should become part of rxvt_display |
263 | |
266 | |
… | |
… | |
362 | { |
365 | { |
363 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
366 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
364 | (*t)->emergency_cleanup (); |
367 | (*t)->emergency_cleanup (); |
365 | } |
368 | } |
366 | |
369 | |
|
|
370 | #if ENABLE_FRILLS |
|
|
371 | static void |
|
|
372 | print_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 | |
367 | int |
419 | int |
368 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
420 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
369 | { |
421 | { |
370 | if (GET_R->allowedxerror == -1) |
422 | if (GET_R->allowedxerror == -1) |
371 | GET_R->allowedxerror = event->error_code; |
423 | GET_R->allowedxerror = event->error_code; |
372 | else |
424 | else |
373 | { |
425 | { |
374 | //TODO: GET_R is most likely not the terminal which caused the error |
426 | //TODO: GET_R is most likely not the terminal which caused the error |
375 | //TODO: maybe just output the error and continue? |
427 | //TODO: maybe just output the error and continue? |
|
|
428 | #if ENABLE_FRILLS |
|
|
429 | print_x_error (display, event); |
|
|
430 | #else |
376 | old_xerror_handler (display, event); |
431 | old_xerror_handler (display, event); |
377 | GET_R->destroy (); |
432 | #endif |
378 | } |
433 | } |
379 | |
434 | |
380 | return 0; |
435 | return 0; |
381 | } |
436 | } |
382 | |
437 | |
… | |
… | |
534 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
589 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
535 | |
590 | |
536 | return p; |
591 | return p; |
537 | } |
592 | } |
538 | |
593 | |
539 | /* INTPROTO */ |
|
|
540 | void * |
594 | void * |
541 | rxvt_calloc (size_t number, size_t size) |
595 | rxvt_calloc (size_t number, size_t size) |
542 | { |
596 | { |
543 | void *p = calloc (number, size); |
597 | void *p = calloc (number, size); |
544 | |
598 | |
… | |
… | |
546 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
600 | rxvt_fatal ("memory allocation failure. aborting.\n"); |
547 | |
601 | |
548 | return p; |
602 | return p; |
549 | } |
603 | } |
550 | |
604 | |
551 | /* INTPROTO */ |
|
|
552 | void * |
605 | void * |
553 | rxvt_realloc (void *ptr, size_t size) |
606 | rxvt_realloc (void *ptr, size_t size) |
554 | { |
607 | { |
555 | void *p = realloc (ptr, size); |
608 | void *p = realloc (ptr, size); |
556 | |
609 | |
… | |
… | |
660 | if (!parsed_geometry) |
713 | if (!parsed_geometry) |
661 | { |
714 | { |
662 | parsed_geometry = 1; |
715 | parsed_geometry = 1; |
663 | if (rs[Rs_geometry]) |
716 | if (rs[Rs_geometry]) |
664 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
717 | flags = XParseGeometry (rs[Rs_geometry], &x, &y, &w, &h); |
|
|
718 | |
665 | if (flags & WidthValue) |
719 | if (flags & WidthValue) |
666 | { |
720 | { |
667 | TermWin.ncol = BOUND_POSITIVE_INT16 (w); |
721 | TermWin.ncol = BOUND_POSITIVE_INT16 (w); |
668 | szHint.flags |= USSize; |
722 | szHint.flags |= USSize; |
669 | } |
723 | } |
|
|
724 | |
670 | if (flags & HeightValue) |
725 | if (flags & HeightValue) |
671 | { |
726 | { |
672 | TermWin.nrow = BOUND_POSITIVE_INT16 (h); |
727 | TermWin.nrow = BOUND_POSITIVE_INT16 (h); |
673 | szHint.flags |= USSize; |
728 | szHint.flags |= USSize; |
674 | } |
729 | } |
|
|
730 | |
675 | if (flags & XValue) |
731 | if (flags & XValue) |
676 | { |
732 | { |
677 | szHint.x = x; |
733 | szHint.x = x; |
678 | szHint.flags |= USPosition; |
734 | szHint.flags |= USPosition; |
679 | if (flags & XNegative) |
735 | if (flags & XNegative) |
680 | { |
736 | { |
681 | recalc_x = 1; |
737 | recalc_x = 1; |
682 | szHint.win_gravity = NorthEastGravity; |
738 | szHint.win_gravity = NorthEastGravity; |
683 | } |
739 | } |
684 | } |
740 | } |
|
|
741 | |
685 | if (flags & YValue) |
742 | if (flags & YValue) |
686 | { |
743 | { |
687 | szHint.y = y; |
744 | szHint.y = y; |
688 | szHint.flags |= USPosition; |
745 | szHint.flags |= USPosition; |
689 | if (flags & YNegative) |
746 | if (flags & YNegative) |
… | |
… | |
788 | (void)ioctl (pty.pty, TIOCSWINSZ, &ws); |
845 | (void)ioctl (pty.pty, TIOCSWINSZ, &ws); |
789 | |
846 | |
790 | #if 0 |
847 | #if 0 |
791 | // TIOCSWINSZ⎈ is supposed to do this automatically and correctly |
848 | // TIOCSWINSZ⎈ is supposed to do this automatically and correctly |
792 | if (cmd_pid) /* force through to the command */ |
849 | if (cmd_pid) /* force through to the command */ |
793 | kill (cmd_pid, SIGWINCH); |
850 | kill (-cmd_pid, SIGWINCH); |
794 | #endif |
851 | #endif |
795 | } |
852 | } |
796 | |
853 | |
797 | /*----------------------------------------------------------------------*/ |
854 | /*----------------------------------------------------------------------*/ |
798 | /* set_fonts () - load and set the various fonts |
855 | /* set_fonts () - load and set the various fonts |
… | |
… | |
1501 | int i, found, had_im; |
1558 | int i, found, had_im; |
1502 | const char *p; |
1559 | const char *p; |
1503 | char **s; |
1560 | char **s; |
1504 | char buf[IMBUFSIZ]; |
1561 | char buf[IMBUFSIZ]; |
1505 | |
1562 | |
|
|
1563 | SET_R (this); |
|
|
1564 | |
1506 | im_destroy (); |
1565 | im_destroy (); |
1507 | |
1566 | |
1508 | D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); |
1567 | D_MAIN ((stderr, "rxvt_IMInstantiateCallback ()")); |
1509 | if (Input_Context) |
1568 | if (Input_Context) |
1510 | return; |
1569 | return; |