… | |
… | |
172 | #endif |
172 | #endif |
173 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
173 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
174 | rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this), |
174 | rootwin_ev.set <rxvt_term, &rxvt_term::rootwin_cb> (this), |
175 | #endif |
175 | #endif |
176 | scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), |
176 | scrollbar_ev.set <rxvt_term, &rxvt_term::x_cb> (this), |
177 | #ifdef USE_XIM |
177 | #if USE_XIM |
178 | im_ev.set <rxvt_term, &rxvt_term::im_cb> (this), |
178 | im_ev.set <rxvt_term, &rxvt_term::im_cb> (this), |
179 | #endif |
179 | #endif |
180 | #ifdef POINTER_BLANK |
180 | #ifdef POINTER_BLANK |
181 | pointer_ev.set <rxvt_term, &rxvt_term::pointer_cb> (this); |
181 | pointer_ev.set <rxvt_term, &rxvt_term::pointer_cb> (this); |
182 | #endif |
182 | #endif |
… | |
… | |
231 | if (display) |
231 | if (display) |
232 | { |
232 | { |
233 | selection_clear (); |
233 | selection_clear (); |
234 | selection_clear (true); |
234 | selection_clear (true); |
235 | |
235 | |
236 | #ifdef USE_XIM |
236 | #if USE_XIM |
237 | im_destroy (); |
237 | im_destroy (); |
238 | #endif |
238 | #endif |
239 | scrollBar.destroy (); |
239 | scrollBar.destroy (); |
240 | if (gc) XFreeGC (dpy, gc); |
240 | if (gc) XFreeGC (dpy, gc); |
241 | |
241 | |
… | |
… | |
362 | } |
362 | } |
363 | |
363 | |
364 | /*----------------------------------------------------------------------*/ |
364 | /*----------------------------------------------------------------------*/ |
365 | /* |
365 | /* |
366 | * Exit gracefully, clearing the utmp entry and restoring tty attributes |
366 | * Exit gracefully, clearing the utmp entry and restoring tty attributes |
367 | * TODO: if debugging, this should free up any known resources if we can |
|
|
368 | */ |
367 | */ |
369 | static XErrorHandler old_xerror_handler; |
368 | static XErrorHandler old_xerror_handler; |
370 | |
369 | |
371 | static void |
370 | static void |
372 | rxvt_emergency_cleanup () |
371 | rxvt_emergency_cleanup () |
… | |
… | |
374 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
373 | for (rxvt_term **t = rxvt_term::termlist.begin (); t < rxvt_term::termlist.end (); t++) |
375 | (*t)->emergency_cleanup (); |
374 | (*t)->emergency_cleanup (); |
376 | } |
375 | } |
377 | |
376 | |
378 | #if !ENABLE_MINIMAL |
377 | #if !ENABLE_MINIMAL |
379 | static void |
378 | static void ecb_cold |
380 | print_x_error (Display *dpy, XErrorEvent *event) |
379 | print_x_error (Display *dpy, XErrorEvent *event) |
381 | { |
380 | { |
382 | char buffer[BUFSIZ]; |
381 | char buffer[BUFSIZ]; |
383 | char mesg[BUFSIZ]; |
382 | char mesg[BUFSIZ]; |
384 | char number[32]; |
383 | char number[32]; |
385 | const char mtype[] = "XlibMessage"; |
384 | |
386 | XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); |
|
|
387 | XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); |
|
|
388 | rxvt_warn ("An X Error occurred, trying to continue after report.\n"); |
385 | rxvt_warn ("An X Error occurred, trying to continue after report.\n"); |
|
|
386 | |
|
|
387 | XGetErrorDatabaseText (dpy, "XlibMessage", "ErrorSerial", "Error Serial #%d", mesg, BUFSIZ); |
|
|
388 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->serial); |
|
|
389 | |
|
|
390 | XGetErrorText (dpy, event->error_code, buffer, BUFSIZ); |
|
|
391 | XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "X Error", mesg, BUFSIZ); |
389 | rxvt_warn ("%s: %s\n", mesg, buffer); |
392 | rxvt_warn ("+ %s: %s\n", mesg, buffer); |
|
|
393 | |
390 | XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
394 | XGetErrorDatabaseText (dpy, "XlibMessage", "MajorCode", "Request Major code %d", mesg, BUFSIZ); |
391 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->request_code); |
395 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->request_code); |
|
|
396 | |
392 | sprintf(number, "%d", event->request_code); |
397 | sprintf (number, "%d", event->request_code); |
393 | XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); |
398 | XGetErrorDatabaseText (dpy, "XRequest", number, "", buffer, BUFSIZ); |
394 | rxvt_warn ("(which is %s)\n", buffer); |
399 | rxvt_warn ("+ (which is %s)\n", buffer); |
|
|
400 | |
395 | if (event->request_code >= 128) { |
401 | if (event->request_code >= 128) |
|
|
402 | { |
396 | XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", |
403 | XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "Request Minor code %d", mesg, BUFSIZ); |
397 | mesg, BUFSIZ); |
404 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->minor_code); |
398 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->minor_code); |
|
|
399 | } |
405 | } |
|
|
406 | |
400 | if ((event->error_code == BadWindow) || |
407 | if (event->error_code == BadWindow |
401 | (event->error_code == BadPixmap) || |
408 | || event->error_code == BadPixmap |
402 | (event->error_code == BadCursor) || |
409 | || event->error_code == BadCursor |
403 | (event->error_code == BadFont) || |
410 | || event->error_code == BadFont |
404 | (event->error_code == BadDrawable) || |
411 | || event->error_code == BadDrawable |
405 | (event->error_code == BadColor) || |
412 | || event->error_code == BadColor |
406 | (event->error_code == BadGC) || |
413 | || event->error_code == BadGC |
407 | (event->error_code == BadIDChoice) || |
414 | || event->error_code == BadIDChoice |
408 | (event->error_code == BadValue) || |
415 | || event->error_code == BadValue |
409 | (event->error_code == BadAtom)) { |
416 | || event->error_code == BadAtom) |
|
|
417 | { |
410 | if (event->error_code == BadValue) |
418 | if (event->error_code == BadValue) |
411 | XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x", |
419 | XGetErrorDatabaseText (dpy, "XlibMessage", "Value", "Value 0x%x", mesg, BUFSIZ); |
412 | mesg, BUFSIZ); |
|
|
413 | else if (event->error_code == BadAtom) |
420 | else if (event->error_code == BadAtom) |
414 | XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x", |
421 | XGetErrorDatabaseText (dpy, "XlibMessage", "AtomID", "AtomID 0x%x", mesg, BUFSIZ); |
415 | mesg, BUFSIZ); |
|
|
416 | else |
422 | else |
417 | XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", |
423 | XGetErrorDatabaseText (dpy, "XlibMessage", "ResourceID", "ResourceID 0x%x", mesg, BUFSIZ); |
418 | mesg, BUFSIZ); |
|
|
419 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->resourceid); |
|
|
420 | } |
|
|
421 | XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", |
|
|
422 | mesg, BUFSIZ); |
|
|
423 | rxvt_warn (strncat (mesg, "\n", BUFSIZ), event->serial); |
|
|
424 | } |
|
|
425 | #endif |
|
|
426 | |
424 | |
427 | int |
425 | snprintf (buffer, BUFSIZ, "+ %s\n", mesg); rxvt_warn (buffer, event->resourceid); |
|
|
426 | } |
|
|
427 | } |
|
|
428 | #endif |
|
|
429 | |
|
|
430 | int ecb_cold |
428 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
431 | rxvt_xerror_handler (Display *display, XErrorEvent *event) |
429 | { |
432 | { |
430 | if (GET_R->allowedxerror == -1) |
433 | if (GET_R->allowedxerror == -1) |
431 | GET_R->allowedxerror = event->error_code; |
434 | GET_R->allowedxerror = event->error_code; |
432 | else |
435 | else |
… | |
… | |
441 | } |
444 | } |
442 | |
445 | |
443 | return 0; |
446 | return 0; |
444 | } |
447 | } |
445 | |
448 | |
446 | int |
449 | int ecb_cold |
447 | rxvt_xioerror_handler (Display *display) |
450 | rxvt_xioerror_handler (Display *display) |
448 | { |
451 | { |
449 | rxvt_warn ("X connection to '%s' broken, unable to recover, exiting.\n", |
452 | rxvt_warn ("X connection to '%s' broken, unable to recover, exiting.\n", |
450 | DisplayString (display)); |
453 | DisplayString (display)); |
451 | rxvt_emergency_cleanup (); |
454 | rxvt_emergency_cleanup (); |
… | |
… | |
571 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
574 | old_xerror_handler = XSetErrorHandler ((XErrorHandler) rxvt_xerror_handler); |
572 | // TODO: handle this with exceptions and tolerate the memory loss |
575 | // TODO: handle this with exceptions and tolerate the memory loss |
573 | XSetIOErrorHandler (rxvt_xioerror_handler); |
576 | XSetIOErrorHandler (rxvt_xioerror_handler); |
574 | |
577 | |
575 | XrmInitialize (); |
578 | XrmInitialize (); |
|
|
579 | |
|
|
580 | #if HAVE_PIXBUF |
|
|
581 | g_type_init (); |
|
|
582 | #endif |
576 | } |
583 | } |
577 | |
584 | |
578 | /*----------------------------------------------------------------------*/ |
585 | /*----------------------------------------------------------------------*/ |
579 | /* |
586 | /* |
580 | * window size/position calculations for XSizeHint and other storage. |
587 | * window size/position calculations for XSizeHint and other storage. |
… | |
… | |
764 | |
771 | |
765 | delete fontset[0]; |
772 | delete fontset[0]; |
766 | fontset[0] = fs; |
773 | fontset[0] = fs; |
767 | |
774 | |
768 | prop = (*fs)[rxvt_fontset::firstFont]->properties (); |
775 | prop = (*fs)[rxvt_fontset::firstFont]->properties (); |
769 | prop.height += lineSpace; |
|
|
770 | prop.width += letterSpace; |
776 | prop.width += letterSpace; |
771 | |
777 | |
772 | fs->set_prop (prop, false); |
778 | fs->set_prop (prop, false); |
773 | |
779 | |
774 | fwidth = prop.width; |
780 | fwidth = prop.width; |
775 | fheight = prop.height; |
781 | fheight = prop.height + lineSpace; |
776 | fbase = prop.ascent; |
782 | fbase = prop.ascent; |
777 | |
783 | |
778 | for (int style = 1; style < 4; style++) |
784 | for (int style = 1; style < 4; style++) |
779 | { |
785 | { |
780 | #if ENABLE_STYLES |
786 | #if ENABLE_STYLES |
… | |
… | |
962 | |
968 | |
963 | for (i = Color_Black; i <= Color_White; i++) |
969 | for (i = Color_Black; i <= Color_White; i++) |
964 | if (pix_colors[Color_bg] == pix_colors[i]) |
970 | if (pix_colors[Color_bg] == pix_colors[i]) |
965 | { |
971 | { |
966 | sprintf (bstr, "%d", i - Color_Black); |
972 | sprintf (bstr, "%d", i - Color_Black); |
967 | #ifdef BG_IMAGE_FROM_FILE |
973 | #if BG_IMAGE_FROM_FILE |
968 | xpmb = "default;"; |
974 | xpmb = "default;"; |
969 | #endif |
975 | #endif |
970 | break; |
976 | break; |
971 | } |
977 | } |
972 | |
978 | |
… | |
… | |
1075 | |
1081 | |
1076 | XMoveResizeWindow (dpy, vt, |
1082 | XMoveResizeWindow (dpy, vt, |
1077 | window_vt_x, window_vt_y, |
1083 | window_vt_x, window_vt_y, |
1078 | vt_width, vt_height); |
1084 | vt_width, vt_height); |
1079 | |
1085 | |
|
|
1086 | HOOK_INVOKE ((this, HOOK_SIZE_CHANGE, DT_INT, newwidth, DT_INT, newheight, DT_END)); |
|
|
1087 | |
1080 | #ifdef HAVE_BG_PIXMAP |
1088 | #ifdef HAVE_BG_PIXMAP |
1081 | if (bg_window_size_sensitive ()) |
1089 | if (bg_window_size_sensitive ()) |
1082 | update_background (); |
1090 | update_background (); |
1083 | #endif |
1091 | #endif |
1084 | } |
1092 | } |
1085 | |
1093 | |
1086 | if (fix_screen || old_height == 0) |
1094 | if (fix_screen || old_height == 0) |
1087 | scr_reset (); |
1095 | scr_reset (); |
1088 | |
1096 | |
1089 | #ifdef USE_XIM |
1097 | #if USE_XIM |
1090 | im_set_position (); |
1098 | im_set_position (); |
1091 | #endif |
1099 | #endif |
1092 | } |
1100 | } |
1093 | |
1101 | |
1094 | /* |
1102 | /* |
… | |
… | |
1119 | } |
1127 | } |
1120 | |
1128 | |
1121 | /* -------------------------------------------------------------------- * |
1129 | /* -------------------------------------------------------------------- * |
1122 | * - X INPUT METHOD ROUTINES - * |
1130 | * - X INPUT METHOD ROUTINES - * |
1123 | * -------------------------------------------------------------------- */ |
1131 | * -------------------------------------------------------------------- */ |
1124 | #ifdef USE_XIM |
1132 | #if USE_XIM |
1125 | |
1133 | |
1126 | void |
1134 | void |
1127 | rxvt_term::im_set_color (unsigned long &fg, unsigned long &bg) |
1135 | rxvt_term::im_set_color (unsigned long &fg, unsigned long &bg) |
1128 | { |
1136 | { |
1129 | fg = pix_colors [Color_fg]; |
1137 | fg = pix_colors [Color_fg]; |
… | |
… | |
1564 | |
1572 | |
1565 | /* try with no modifiers base IF the user didn't specify an IM */ |
1573 | /* try with no modifiers base IF the user didn't specify an IM */ |
1566 | if (im_get_ic ("@im=none")) |
1574 | if (im_get_ic ("@im=none")) |
1567 | goto done; |
1575 | goto done; |
1568 | |
1576 | |
1569 | done: ; |
1577 | done: |
1570 | if (rs[Rs_imLocale]) |
1578 | if (rs[Rs_imLocale]) |
1571 | SET_LOCALE (locale); |
1579 | SET_LOCALE (locale); |
1572 | } |
1580 | } |
1573 | |
1581 | |
1574 | void |
1582 | void |
… | |
… | |
1621 | { |
1629 | { |
1622 | Window cr; |
1630 | Window cr; |
1623 | XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr); |
1631 | XTranslateCoordinates (dpy, parent, display->root, 0, 0, &x, &y, &cr); |
1624 | } |
1632 | } |
1625 | |
1633 | |
1626 | Pixmap |
|
|
1627 | rxvt_term::get_pixmap_property (Atom property) |
|
|
1628 | { |
|
|
1629 | Pixmap pixmap = None; |
|
|
1630 | |
|
|
1631 | int aformat; |
|
|
1632 | unsigned long nitems, bytes_after; |
|
|
1633 | Atom atype; |
|
|
1634 | unsigned char *prop; |
|
|
1635 | int result = XGetWindowProperty (dpy, display->root, property, |
|
|
1636 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
1637 | &nitems, &bytes_after, &prop); |
|
|
1638 | if (result == Success) |
|
|
1639 | { |
|
|
1640 | if (atype == XA_PIXMAP) |
|
|
1641 | pixmap = *(Pixmap *)prop; |
|
|
1642 | XFree (prop); |
|
|
1643 | } |
|
|
1644 | |
|
|
1645 | return pixmap; |
|
|
1646 | } |
|
|
1647 | |
|
|
1648 | #ifdef HAVE_BG_PIXMAP |
1634 | #ifdef HAVE_BG_PIXMAP |
1649 | |
1635 | |
1650 | void |
1636 | void |
1651 | rxvt_term::update_background () |
1637 | rxvt_term::update_background () |
1652 | { |
1638 | { |