… | |
… | |
48 | #include "../config.h" /* NECESSARY */ |
48 | #include "../config.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
50 | #include "version.h" |
50 | #include "version.h" |
51 | #include "command.h" |
51 | #include "command.h" |
52 | |
52 | |
53 | #include <cwchar> |
53 | #ifdef KEYSYM_RESOURCE |
|
|
54 | # include "keyboard.h" |
|
|
55 | #endif |
|
|
56 | |
54 | #include <csignal> |
57 | #include <csignal> |
55 | |
58 | |
56 | /*----------------------------------------------------------------------*/ |
59 | /*----------------------------------------------------------------------*/ |
57 | |
60 | |
58 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
61 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
… | |
… | |
344 | valid_keysym = keysym != NoSymbol; |
347 | valid_keysym = keysym != NoSymbol; |
345 | } |
348 | } |
346 | |
349 | |
347 | if (valid_keysym) |
350 | if (valid_keysym) |
348 | { |
351 | { |
|
|
352 | #ifdef KEYSYM_RESOURCE |
|
|
353 | if (keyboard->dispatch (this, keysym, ev.state)) |
|
|
354 | return; |
|
|
355 | #endif |
|
|
356 | |
349 | if (TermWin.saveLines) |
357 | if (TermWin.saveLines) |
350 | { |
358 | { |
351 | #ifdef UNSHIFTED_SCROLLKEYS |
359 | #ifdef UNSHIFTED_SCROLLKEYS |
352 | if (!ctrl && !meta) |
360 | if (!ctrl && !meta) |
353 | #else |
361 | #else |
… | |
… | |
487 | } |
495 | } |
488 | #endif |
496 | #endif |
489 | |
497 | |
490 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
498 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
491 | { |
499 | { |
492 | #ifdef KEYSYM_RESOURCE |
|
|
493 | if (!(shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
|
|
494 | { |
|
|
495 | unsigned int l; |
|
|
496 | const unsigned char *kbuf0; |
|
|
497 | |
|
|
498 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
|
|
499 | l = (unsigned int)*kbuf0++; |
|
|
500 | |
|
|
501 | /* escape prefix */ |
|
|
502 | if (meta |
|
|
503 | # ifdef META8_OPTION |
|
|
504 | && meta_char == C0_ESC |
|
|
505 | # endif |
|
|
506 | ) |
|
|
507 | { |
|
|
508 | const unsigned char ch = C0_ESC; |
|
|
509 | tt_write (&ch, 1); |
|
|
510 | } |
|
|
511 | |
|
|
512 | tt_write (kbuf0, l); |
|
|
513 | return; |
|
|
514 | } |
|
|
515 | else |
|
|
516 | #endif |
|
|
517 | { |
500 | { |
518 | newlen = 1; |
501 | newlen = 1; |
519 | switch (keysym) |
502 | switch (keysym) |
520 | { |
503 | { |
521 | #ifndef NO_BACKSPACE_KEY |
504 | #ifndef NO_BACKSPACE_KEY |
… | |
… | |
785 | case XK_F35: /* "\033[49~" */ |
768 | case XK_F35: /* "\033[49~" */ |
786 | FKEY (31, XK_F17); |
769 | FKEY (31, XK_F17); |
787 | break; |
770 | break; |
788 | #undef FKEY |
771 | #undef FKEY |
789 | default: |
772 | default: |
790 | if (len == 0 |
773 | newlen = 0; |
791 | && (keysym & 0xfff0) != 0xff70 |
774 | break; |
792 | && (keysym & 0xfff0) != 0xffe0) |
|
|
793 | /* generate a keycode for every remaining keypress */ |
|
|
794 | sprintf ((char *)kbuf, "\033[%x;%xA", (unsigned char)ev.state, (unsigned short)keysym); |
|
|
795 | } |
775 | } |
796 | |
776 | |
797 | if (newlen) |
777 | if (newlen) |
798 | len = strlen (kbuf); |
778 | len = strlen (kbuf); |
799 | } |
779 | } |
… | |
… | |
814 | } |
794 | } |
815 | else if (keysym == XK_ISO_Left_Tab) |
795 | else if (keysym == XK_ISO_Left_Tab) |
816 | { |
796 | { |
817 | strcpy (kbuf, "\033[Z"); |
797 | strcpy (kbuf, "\033[Z"); |
818 | len = 3; |
798 | len = 3; |
819 | } |
|
|
820 | else if (len == 0 |
|
|
821 | && (keysym & 0xffe0) != 0xfe00 |
|
|
822 | && (keysym < 0xfe50 || keysym > 0xfe6f)) |
|
|
823 | { |
|
|
824 | /* generate a keycode for every remaining keypress */ |
|
|
825 | len = sprintf ((char *)kbuf, "\033[%x;%xA", (unsigned char)ev.state, (unsigned short)keysym); |
|
|
826 | } |
799 | } |
827 | else |
800 | else |
828 | { |
801 | { |
829 | #ifdef META8_OPTION |
802 | #ifdef META8_OPTION |
830 | /* set 8-bit on */ |
803 | /* set 8-bit on */ |
… | |
… | |
889 | #endif /* DEBUG_CMD */ |
862 | #endif /* DEBUG_CMD */ |
890 | tt_write (kbuf, (unsigned int)len); |
863 | tt_write (kbuf, (unsigned int)len); |
891 | } |
864 | } |
892 | /*}}} */ |
865 | /*}}} */ |
893 | |
866 | |
894 | #if (MENUBAR_MAX) |
867 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
895 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
868 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
896 | /* attempt to `write' count to the input buffer */ |
869 | /* attempt to `write' count to the input buffer */ |
897 | unsigned int |
870 | unsigned int |
898 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
871 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
899 | { |
872 | { |
… | |
… | |
922 | |
895 | |
923 | cmd_parse (); |
896 | cmd_parse (); |
924 | |
897 | |
925 | return 0; |
898 | return 0; |
926 | } |
899 | } |
927 | #endif /* MENUBAR_MAX */ |
900 | #endif |
928 | |
901 | |
929 | void |
902 | void |
930 | rxvt_term::flush () |
903 | rxvt_term::flush () |
931 | { |
904 | { |
932 | flush_ev.stop (); |
905 | flush_ev.stop (); |
… | |
… | |
1033 | { |
1006 | { |
1034 | if (mouse_slip_wheel_speed == 0 |
1007 | if (mouse_slip_wheel_speed == 0 |
1035 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1008 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1036 | : scr_page (UP, mouse_slip_wheel_speed)) |
1009 | : scr_page (UP, mouse_slip_wheel_speed)) |
1037 | { |
1010 | { |
|
|
1011 | if (TermWin.view_start == TermWin.nscrolled || |
|
|
1012 | TermWin.view_start == 0) |
|
|
1013 | mouse_slip_wheel_speed = 0; |
|
|
1014 | |
1038 | refresh_type |= SMOOTH_REFRESH; |
1015 | refresh_type |= SMOOTH_REFRESH; |
1039 | want_refresh = 1; |
1016 | want_refresh = 1; |
1040 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1017 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1041 | } |
1018 | } |
1042 | } |
1019 | } |
… | |
… | |
1105 | rxvt_term::pointer_blank () |
1082 | rxvt_term::pointer_blank () |
1106 | { |
1083 | { |
1107 | if (! (options & Opt_pointerBlank)) |
1084 | if (! (options & Opt_pointerBlank)) |
1108 | return; |
1085 | return; |
1109 | |
1086 | |
1110 | XDefineCursor (display->display, TermWin.vt, blank_cursor); |
1087 | XDefineCursor (display->display, TermWin.vt, display->blank_cursor); |
1111 | XFlush (display->display); |
1088 | XFlush (display->display); |
1112 | |
1089 | |
1113 | hidden_pointer = 1; |
1090 | hidden_pointer = 1; |
1114 | } |
1091 | } |
1115 | |
1092 | |
… | |
… | |
1204 | |
1181 | |
1205 | /*{{{ process an X event */ |
1182 | /*{{{ process an X event */ |
1206 | void |
1183 | void |
1207 | rxvt_term::x_cb (XEvent &ev) |
1184 | rxvt_term::x_cb (XEvent &ev) |
1208 | { |
1185 | { |
|
|
1186 | dDisp; |
|
|
1187 | |
1209 | SET_R (this); |
1188 | SET_R (this); |
1210 | SET_LOCALE (locale); |
1189 | SET_LOCALE (locale); |
1211 | |
1190 | |
1212 | #if defined(CURSOR_BLINK) |
1191 | #if defined(CURSOR_BLINK) |
1213 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
1192 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
… | |
… | |
1344 | Atom ActualType; |
1323 | Atom ActualType; |
1345 | int ActualFormat; |
1324 | int ActualFormat; |
1346 | unsigned char *data; |
1325 | unsigned char *data; |
1347 | unsigned long Size, RemainingBytes; |
1326 | unsigned long Size, RemainingBytes; |
1348 | |
1327 | |
1349 | XGetWindowProperty (display->display, display->root, |
1328 | XGetWindowProperty (disp, display->root, |
1350 | xa[XA_DNDSELECTION], |
1329 | xa[XA_DNDSELECTION], |
1351 | 0L, 1000000L, |
1330 | 0L, 1000000L, |
1352 | False, AnyPropertyType, |
1331 | False, AnyPropertyType, |
1353 | &ActualType, &ActualFormat, |
1332 | &ActualType, &ActualFormat, |
1354 | &Size, &RemainingBytes, |
1333 | &Size, &RemainingBytes, |
1355 | &data); |
1334 | &data); |
1356 | set_string_property (XA_CUT_BUFFER0, data); |
1335 | set_string_property (XA_CUT_BUFFER0, data); |
1357 | XFree (data); |
1336 | XFree (data); |
1358 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
1337 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
1359 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1338 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
1360 | } |
1339 | } |
1361 | #endif /* OFFIX_DND */ |
1340 | #endif /* OFFIX_DND */ |
1362 | break; |
1341 | break; |
1363 | |
1342 | |
1364 | case MappingNotify: |
1343 | case MappingNotify: |
… | |
… | |
1457 | { /* Wrap lots of configures into one */ |
1436 | { /* Wrap lots of configures into one */ |
1458 | width = ev.xconfigure.width; |
1437 | width = ev.xconfigure.width; |
1459 | height = ev.xconfigure.height; |
1438 | height = ev.xconfigure.height; |
1460 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1439 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1461 | } |
1440 | } |
1462 | while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); |
1441 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)); |
1463 | |
1442 | |
1464 | if (szHint.width != width || szHint.height != height) |
1443 | if (szHint.width != width || szHint.height != height) |
1465 | { |
1444 | { |
1466 | seen_resize = 1; |
1445 | seen_resize = 1; |
1467 | resize_all_windows (width, height, 1); |
1446 | resize_all_windows (width, height, 1); |
… | |
… | |
1519 | if (ev.xany.window == TermWin.vt) |
1498 | if (ev.xany.window == TermWin.vt) |
1520 | { |
1499 | { |
1521 | do |
1500 | do |
1522 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1501 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1523 | ev.xexpose.width, ev.xexpose.height, False); |
1502 | ev.xexpose.width, ev.xexpose.height, False); |
1524 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)); |
1503 | while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev)); |
1525 | |
1504 | |
1526 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1505 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1527 | |
1506 | |
1528 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)) |
1507 | while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev)) |
1529 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1508 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1530 | ev.xexpose.width, ev.xexpose.height, False); |
1509 | ev.xexpose.width, ev.xexpose.height, False); |
1531 | |
1510 | |
1532 | scr_refresh (refresh_type); |
1511 | scr_refresh (refresh_type); |
1533 | } |
1512 | } |
1534 | else |
1513 | else |
1535 | { |
1514 | { |
1536 | XEvent unused_event; |
1515 | XEvent unused_event; |
1537 | |
1516 | |
1538 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, Expose, &unused_event)) |
1517 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1539 | ; |
1518 | ; |
1540 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, GraphicsExpose, &unused_event)) |
1519 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1541 | ; |
1520 | ; |
1542 | |
1521 | |
1543 | if (isScrollbarWindow (ev.xany.window)) |
1522 | if (isScrollbarWindow (ev.xany.window)) |
1544 | { |
1523 | { |
1545 | scrollBar.setIdle (); |
1524 | scrollBar.setIdle (); |
… | |
… | |
1550 | menubar_expose (); |
1529 | menubar_expose (); |
1551 | #endif |
1530 | #endif |
1552 | |
1531 | |
1553 | #ifdef TRANSPARENT |
1532 | #ifdef TRANSPARENT |
1554 | if (am_transparent && ev.xany.window == TermWin.parent[0]) |
1533 | if (am_transparent && ev.xany.window == TermWin.parent[0]) |
1555 | XClearWindow (display->display, ev.xany.window); |
1534 | XClearWindow (disp, ev.xany.window); |
1556 | #endif |
1535 | #endif |
1557 | } |
1536 | } |
1558 | break; |
1537 | break; |
1559 | |
1538 | |
1560 | case MotionNotify: |
1539 | case MotionNotify: |
… | |
… | |
1574 | |
1553 | |
1575 | if (ev.xany.window == TermWin.vt) |
1554 | if (ev.xany.window == TermWin.vt) |
1576 | { |
1555 | { |
1577 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1556 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1578 | { |
1557 | { |
1579 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, MotionNotify, &ev)) |
1558 | while (XCheckTypedWindowEvent (disp, TermWin.vt, MotionNotify, &ev)) |
1580 | ; |
1559 | ; |
1581 | |
1560 | |
1582 | XQueryPointer (display->display, TermWin.vt, |
1561 | XQueryPointer (disp, TermWin.vt, |
1583 | &unused_root, &unused_child, |
1562 | &unused_root, &unused_child, |
1584 | &unused_root_x, &unused_root_y, |
1563 | &unused_root_x, &unused_root_y, |
1585 | &ev.xbutton.x, &ev.xbutton.y, |
1564 | &ev.xbutton.x, &ev.xbutton.y, |
1586 | &ev.xbutton.state); |
1565 | &ev.xbutton.state); |
1587 | #ifdef MOUSE_THRESHOLD |
1566 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1651 | #endif |
1630 | #endif |
1652 | } |
1631 | } |
1653 | } |
1632 | } |
1654 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1633 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1655 | { |
1634 | { |
1656 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1635 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1657 | MotionNotify, &ev)) |
1636 | MotionNotify, &ev)) |
1658 | ; |
1637 | ; |
1659 | |
1638 | |
1660 | XQueryPointer (display->display, scrollBar.win, |
1639 | XQueryPointer (disp, scrollBar.win, |
1661 | &unused_root, &unused_child, |
1640 | &unused_root, &unused_child, |
1662 | &unused_root_x, &unused_root_y, |
1641 | &unused_root_x, &unused_root_y, |
1663 | &ev.xbutton.x, &ev.xbutton.y, |
1642 | &ev.xbutton.x, &ev.xbutton.y, |
1664 | &unused_mask); |
1643 | &unused_mask); |
1665 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1644 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
… | |
… | |
1767 | { |
1746 | { |
1768 | case Button1: |
1747 | case Button1: |
1769 | /* allow meta + click to select rectangular areas */ |
1748 | /* allow meta + click to select rectangular areas */ |
1770 | /* should be done in screen.C */ |
1749 | /* should be done in screen.C */ |
1771 | #if ENABLE_FRILLS |
1750 | #if ENABLE_FRILLS |
1772 | selection.rect = !! (ev.state & ModMetaMask); |
1751 | selection.rect = !!(ev.state & ModMetaMask); |
1773 | #else |
1752 | #else |
1774 | selection.rect = false; |
1753 | selection.rect = false; |
1775 | #endif |
1754 | #endif |
1776 | |
1755 | |
1777 | /* allow shift+left click to extend selection */ |
1756 | /* allow shift+left click to extend selection */ |
… | |
… | |
2103 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2082 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2104 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2083 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2105 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2084 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2106 | int i; |
2085 | int i; |
2107 | |
2086 | |
2108 | Visual* visual = display->visual; |
2087 | Visual *visual = display->visual; |
2109 | |
2088 | |
2110 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2089 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2111 | |
2090 | |
2112 | /* for convenience */ |
2091 | /* for convenience */ |
2113 | mask_r = visual->red_mask; |
2092 | mask_r = visual->red_mask; |
… | |
… | |
2334 | Atom atype; |
2313 | Atom atype; |
2335 | unsigned char *prop = NULL; |
2314 | unsigned char *prop = NULL; |
2336 | Window root, oldp, *list; |
2315 | Window root, oldp, *list; |
2337 | Pixmap rootpixmap = None; |
2316 | Pixmap rootpixmap = None; |
2338 | XWindowAttributes wattr, wrootattr; |
2317 | XWindowAttributes wattr, wrootattr; |
|
|
2318 | dDisp; |
2339 | |
2319 | |
2340 | pchanged = 0; |
2320 | pchanged = 0; |
2341 | |
2321 | |
2342 | if (!(options & Opt_transparent)) |
2322 | if (!(options & Opt_transparent)) |
2343 | return pchanged; /* Don't try any more */ |
2323 | return pchanged; /* Don't try any more */ |
2344 | |
2324 | |
2345 | XGetWindowAttributes (display->display, display->root, &wrootattr); |
2325 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2346 | rootdepth = wrootattr.depth; |
2326 | rootdepth = wrootattr.depth; |
2347 | |
2327 | |
2348 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
2328 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
2349 | |
2329 | |
2350 | if (rootdepth != wattr.depth) |
2330 | if (rootdepth != wattr.depth) |
2351 | { |
2331 | { |
2352 | if (am_transparent) |
2332 | if (am_transparent) |
2353 | { |
2333 | { |
2354 | pchanged = 1; |
2334 | pchanged = 1; |
2355 | XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]); |
2335 | XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]); |
2356 | am_transparent = am_pixmap_trans = 0; |
2336 | am_transparent = am_pixmap_trans = 0; |
2357 | } |
2337 | } |
2358 | |
2338 | |
2359 | return pchanged; /* Don't try any more */ |
2339 | return pchanged; /* Don't try any more */ |
2360 | } |
2340 | } |
2361 | |
2341 | |
2362 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2342 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2363 | XSync (display->display, False); |
2343 | XSync (disp, False); |
2364 | |
2344 | |
2365 | /* |
2345 | /* |
2366 | * Make the frame window set by the window manager have |
2346 | * Make the frame window set by the window manager have |
2367 | * the root background. Some window managers put multiple nested frame |
2347 | * the root background. Some window managers put multiple nested frame |
2368 | * windows for each client, so we have to take care about that. |
2348 | * windows for each client, so we have to take care about that. |
2369 | */ |
2349 | */ |
2370 | i = (xa[XA_XROOTPMAP_ID] |
2350 | i = (xa[XA_XROOTPMAP_ID] |
2371 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAP_ID], |
2351 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
2372 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2352 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2373 | &nitems, &bytes_after, &prop) == Success); |
2353 | &nitems, &bytes_after, &prop) == Success); |
2374 | |
2354 | |
2375 | if (!i || prop == NULL) |
2355 | if (!i || prop == NULL) |
2376 | i = (xa[XA_ESETROOT_PMAP_ID] |
2356 | i = (xa[XA_ESETROOT_PMAP_ID] |
2377 | && XGetWindowProperty (display->display, display->root, xa[XA_ESETROOT_PMAP_ID], |
2357 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2378 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2358 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2379 | &nitems, &bytes_after, &prop) == Success); |
2359 | &nitems, &bytes_after, &prop) == Success); |
2380 | |
2360 | |
2381 | if (!i || prop == NULL |
2361 | if (!i || prop == NULL |
2382 | #if TINTING |
2362 | #if TINTING |
… | |
… | |
2401 | Window cr; |
2381 | Window cr; |
2402 | XImage *image; |
2382 | XImage *image; |
2403 | GC gc; |
2383 | GC gc; |
2404 | XGCValues gcvalue; |
2384 | XGCValues gcvalue; |
2405 | |
2385 | |
2406 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
2386 | XTranslateCoordinates (disp, TermWin.parent[0], display->root, |
2407 | 0, 0, &sx, &sy, &cr); |
2387 | 0, 0, &sx, &sy, &cr); |
2408 | nw = (unsigned int)szHint.width; |
2388 | nw = (unsigned int)szHint.width; |
2409 | nh = (unsigned int)szHint.height; |
2389 | nh = (unsigned int)szHint.height; |
2410 | nx = ny = 0; |
2390 | nx = ny = 0; |
2411 | |
2391 | |
… | |
… | |
2424 | } |
2404 | } |
2425 | |
2405 | |
2426 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2406 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2427 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2407 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2428 | |
2408 | |
2429 | XSync (display->display, False); |
2409 | XSync (disp, False); |
2430 | allowedxerror = -1; |
2410 | allowedxerror = -1; |
2431 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2411 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2432 | |
2412 | |
2433 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2413 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2434 | /* XXX: may need a delay here? */ |
2414 | /* XXX: may need a delay here? */ |
2435 | allowedxerror = 0; |
2415 | allowedxerror = 0; |
2436 | |
2416 | |
… | |
… | |
2439 | if (am_transparent && am_pixmap_trans) |
2419 | if (am_transparent && am_pixmap_trans) |
2440 | { |
2420 | { |
2441 | pchanged = 1; |
2421 | pchanged = 1; |
2442 | if (TermWin.pixmap != None) |
2422 | if (TermWin.pixmap != None) |
2443 | { |
2423 | { |
2444 | XFreePixmap (display->display, TermWin.pixmap); |
2424 | XFreePixmap (disp, TermWin.pixmap); |
2445 | TermWin.pixmap = None; |
2425 | TermWin.pixmap = None; |
2446 | } |
2426 | } |
2447 | } |
2427 | } |
2448 | |
2428 | |
2449 | am_pixmap_trans = 0; |
2429 | am_pixmap_trans = 0; |
2450 | } |
2430 | } |
2451 | else |
2431 | else |
2452 | { |
2432 | { |
2453 | if (TermWin.pixmap != None) |
2433 | if (TermWin.pixmap != None) |
2454 | XFreePixmap (display->display, TermWin.pixmap); |
2434 | XFreePixmap (disp, TermWin.pixmap); |
2455 | |
2435 | |
2456 | #if TINTING |
2436 | #if TINTING |
2457 | if (ISSET_PIXCOLOR (Color_tint)) |
2437 | if (ISSET_PIXCOLOR (Color_tint)) |
2458 | { |
2438 | { |
2459 | unsigned short rm, gm, bm; |
2439 | unsigned short rm, gm, bm; |
… | |
… | |
2463 | |
2443 | |
2464 | ShadeXImage (display, image, shade, rm, gm, bm); |
2444 | ShadeXImage (display, image, shade, rm, gm, bm); |
2465 | } |
2445 | } |
2466 | #endif |
2446 | #endif |
2467 | |
2447 | |
2468 | TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, |
2448 | TermWin.pixmap = XCreatePixmap (disp, TermWin.vt, |
2469 | szHint.width, szHint.height, image->depth); |
2449 | szHint.width, szHint.height, image->depth); |
2470 | gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); |
2450 | gc = XCreateGC (disp, TermWin.vt, 0UL, &gcvalue); |
2471 | XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, |
2451 | XPutImage (disp, TermWin.pixmap, gc, image, 0, 0, |
2472 | nx, ny, image->width, image->height); |
2452 | nx, ny, image->width, image->height); |
2473 | XFreeGC (display->display, gc); |
2453 | XFreeGC (disp, gc); |
2474 | XDestroyImage (image); |
2454 | XDestroyImage (image); |
2475 | XSetWindowBackgroundPixmap (display->display, TermWin.parent[0], TermWin.pixmap); |
2455 | XSetWindowBackgroundPixmap (disp, TermWin.parent[0], TermWin.pixmap); |
2476 | XClearWindow (display->display, TermWin.parent[0]); |
2456 | XClearWindow (disp, TermWin.parent[0]); |
2477 | |
2457 | |
2478 | if (!am_transparent || !am_pixmap_trans) |
2458 | if (!am_transparent || !am_pixmap_trans) |
2479 | pchanged = 1; |
2459 | pchanged = 1; |
2480 | |
2460 | |
2481 | am_transparent = am_pixmap_trans = 1; |
2461 | am_transparent = am_pixmap_trans = 1; |
2482 | } |
2462 | } |
2483 | } |
2463 | } |
2484 | |
2464 | |
2485 | if (am_pixmap_trans) |
2465 | if (am_pixmap_trans) |
2486 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
2466 | XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative); |
2487 | else |
2467 | else |
2488 | { |
2468 | { |
2489 | unsigned int n; |
2469 | unsigned int n; |
2490 | /* |
2470 | /* |
2491 | * InheritPixmap transparency |
2471 | * InheritPixmap transparency |
2492 | */ |
2472 | */ |
2493 | for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2473 | for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2494 | { |
2474 | { |
2495 | oldp = TermWin.parent[i]; |
2475 | oldp = TermWin.parent[i]; |
2496 | XQueryTree (display->display, TermWin.parent[i - 1], &root, |
2476 | XQueryTree (disp, TermWin.parent[i - 1], &root, |
2497 | &TermWin.parent[i], &list, &n); |
2477 | &TermWin.parent[i], &list, &n); |
2498 | XFree (list); |
2478 | XFree (list); |
2499 | |
2479 | |
2500 | if (TermWin.parent[i] == display->root) |
2480 | if (TermWin.parent[i] == display->root) |
2501 | { |
2481 | { |
… | |
… | |
2513 | |
2493 | |
2514 | if (pchanged) |
2494 | if (pchanged) |
2515 | { |
2495 | { |
2516 | for (; n < (unsigned int)i; n++) |
2496 | for (; n < (unsigned int)i; n++) |
2517 | { |
2497 | { |
2518 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
2498 | XGetWindowAttributes (disp, TermWin.parent[n], &wattr); |
2519 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2499 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2520 | { |
2500 | { |
2521 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2501 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2522 | break; |
2502 | break; |
2523 | } |
2503 | } |
2524 | } |
2504 | } |
2525 | } |
2505 | } |
2526 | |
2506 | |
2527 | if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) |
2507 | if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) |
2528 | { |
2508 | { |
2529 | XSetWindowBackground (display->display, TermWin.parent[0], pix_colors_focused[Color_fg]); |
2509 | XSetWindowBackground (disp, TermWin.parent[0], pix_colors_focused[Color_fg]); |
2530 | XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]); |
2510 | XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]); |
2531 | am_transparent = 0; |
2511 | am_transparent = 0; |
2532 | /* XXX: also turn off Opt_transparent? */ |
2512 | /* XXX: also turn off Opt_transparent? */ |
2533 | } |
2513 | } |
2534 | else |
2514 | else |
2535 | { |
2515 | { |
… | |
… | |
2538 | * needed for fvwm2.2.2 (and before?) */ |
2518 | * needed for fvwm2.2.2 (and before?) */ |
2539 | sleep (1); |
2519 | sleep (1); |
2540 | #endif |
2520 | #endif |
2541 | for (n = 0; n < (unsigned int)i; n++) |
2521 | for (n = 0; n < (unsigned int)i; n++) |
2542 | { |
2522 | { |
2543 | XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); |
2523 | XSetWindowBackgroundPixmap (disp, TermWin.parent[n], ParentRelative); |
2544 | XClearWindow (display->display, TermWin.parent[n]); |
2524 | XClearWindow (disp, TermWin.parent[n]); |
2545 | } |
2525 | } |
2546 | |
2526 | |
2547 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
2527 | XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative); |
2548 | am_transparent = 1; |
2528 | am_transparent = 1; |
2549 | } |
2529 | } |
2550 | |
2530 | |
2551 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2531 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2552 | TermWin.parent[i] = None; |
2532 | TermWin.parent[i] = None; |
2553 | } |
2533 | } |
2554 | |
2534 | |
2555 | if (scrollBar.win) |
2535 | if (scrollBar.win) |
2556 | { |
2536 | { |
2557 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2537 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
2558 | scrollBar.setIdle (); |
2538 | scrollBar.setIdle (); |
2559 | scrollbar_show (0); |
2539 | scrollbar_show (0); |
2560 | } |
2540 | } |
2561 | |
2541 | |
2562 | if (am_transparent) |
2542 | if (am_transparent) |
… | |
… | |
3196 | { |
3176 | { |
3197 | switch (priv) |
3177 | switch (priv) |
3198 | { |
3178 | { |
3199 | case '>': |
3179 | case '>': |
3200 | if (ch == CSI_DA) /* secondary device attributes */ |
3180 | if (ch == CSI_DA) /* secondary device attributes */ |
3201 | tt_printf ("\033[>%d;%-.8s;0c", 'R', VSTRING); |
3181 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3202 | break; |
3182 | break; |
3203 | case '?': |
3183 | case '?': |
3204 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3184 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3205 | process_terminal_mode (ch, priv, nargs, arg); |
3185 | process_terminal_mode (ch, priv, nargs, arg); |
3206 | break; |
3186 | break; |
… | |
… | |
3435 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3415 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3436 | { |
3416 | { |
3437 | int x, y; |
3417 | int x, y; |
3438 | XWindowAttributes wattr; |
3418 | XWindowAttributes wattr; |
3439 | Window wdummy; |
3419 | Window wdummy; |
|
|
3420 | dDisp; |
3440 | |
3421 | |
3441 | if (nargs == 0) |
3422 | if (nargs == 0) |
3442 | return; |
3423 | return; |
3443 | |
3424 | |
3444 | switch (args[0]) |
3425 | switch (args[0]) |
3445 | { |
3426 | { |
3446 | /* |
3427 | /* |
3447 | * commands |
3428 | * commands |
3448 | */ |
3429 | */ |
3449 | case 1: /* deiconify window */ |
3430 | case 1: /* deiconify window */ |
3450 | XMapWindow (display->display, TermWin.parent[0]); |
3431 | XMapWindow (disp, TermWin.parent[0]); |
3451 | break; |
3432 | break; |
3452 | case 2: /* iconify window */ |
3433 | case 2: /* iconify window */ |
3453 | XIconifyWindow (display->display, TermWin.parent[0], |
3434 | XIconifyWindow (disp, TermWin.parent[0], display->screen); |
3454 | DefaultScreen (display->display)); |
|
|
3455 | break; |
3435 | break; |
3456 | case 3: /* set position (pixels) */ |
3436 | case 3: /* set position (pixels) */ |
3457 | XMoveWindow (display->display, TermWin.parent[0], args[1], args[2]); |
3437 | XMoveWindow (disp, TermWin.parent[0], args[1], args[2]); |
3458 | break; |
3438 | break; |
3459 | case 4: /* set size (pixels) */ |
3439 | case 4: /* set size (pixels) */ |
3460 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3440 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3461 | break; |
3441 | break; |
3462 | case 5: /* raise window */ |
3442 | case 5: /* raise window */ |
3463 | XRaiseWindow (display->display, TermWin.parent[0]); |
3443 | XRaiseWindow (disp, TermWin.parent[0]); |
3464 | break; |
3444 | break; |
3465 | case 6: /* lower window */ |
3445 | case 6: /* lower window */ |
3466 | XLowerWindow (display->display, TermWin.parent[0]); |
3446 | XLowerWindow (disp, TermWin.parent[0]); |
3467 | break; |
3447 | break; |
3468 | case 7: /* refresh window */ |
3448 | case 7: /* refresh window */ |
3469 | scr_touch (true); |
3449 | scr_touch (true); |
3470 | break; |
3450 | break; |
3471 | case 8: /* set size (chars) */ |
3451 | case 8: /* set size (chars) */ |
… | |
… | |
3483 | |
3463 | |
3484 | /* |
3464 | /* |
3485 | * reports - some output format copied from XTerm |
3465 | * reports - some output format copied from XTerm |
3486 | */ |
3466 | */ |
3487 | case 11: /* report window state */ |
3467 | case 11: /* report window state */ |
3488 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3468 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3489 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3469 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3490 | break; |
3470 | break; |
3491 | case 13: /* report window position */ |
3471 | case 13: /* report window position */ |
3492 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3472 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3493 | XTranslateCoordinates (display->display, TermWin.parent[0], wattr.root, |
3473 | XTranslateCoordinates (disp, TermWin.parent[0], wattr.root, |
3494 | -wattr.border_width, -wattr.border_width, |
3474 | -wattr.border_width, -wattr.border_width, |
3495 | &x, &y, &wdummy); |
3475 | &x, &y, &wdummy); |
3496 | tt_printf ("\033[3;%d;%dt", x, y); |
3476 | tt_printf ("\033[3;%d;%dt", x, y); |
3497 | break; |
3477 | break; |
3498 | case 14: /* report window size (pixels) */ |
3478 | case 14: /* report window size (pixels) */ |
3499 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3479 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3500 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3480 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3501 | break; |
3481 | break; |
3502 | case 18: /* report text area size (chars) */ |
3482 | case 18: /* report text area size (chars) */ |
3503 | tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); |
3483 | tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); |
3504 | break; |
3484 | break; |
… | |
… | |
3506 | tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); |
3486 | tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); |
3507 | break; |
3487 | break; |
3508 | case 20: /* report icon label */ |
3488 | case 20: /* report icon label */ |
3509 | { |
3489 | { |
3510 | char *s; |
3490 | char *s; |
3511 | XGetIconName (display->display, TermWin.parent[0], &s); |
3491 | XGetIconName (disp, TermWin.parent[0], &s); |
3512 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3492 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3513 | XFree (s); |
3493 | XFree (s); |
3514 | } |
3494 | } |
3515 | break; |
3495 | break; |
3516 | case 21: /* report window title */ |
3496 | case 21: /* report window title */ |
3517 | { |
3497 | { |
3518 | char *s; |
3498 | char *s; |
3519 | XFetchName (display->display, TermWin.parent[0], &s); |
3499 | XFetchName (disp, TermWin.parent[0], &s); |
3520 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3500 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3521 | XFree (s); |
3501 | XFree (s); |
3522 | } |
3502 | } |
3523 | break; |
3503 | break; |
3524 | } |
3504 | } |
… | |
… | |
3666 | int changed = 0; |
3646 | int changed = 0; |
3667 | int color; |
3647 | int color; |
3668 | char *buf, *name; |
3648 | char *buf, *name; |
3669 | bool query = str[0] == '?' && !str[1]; |
3649 | bool query = str[0] == '?' && !str[1]; |
3670 | int saveop = op; |
3650 | int saveop = op; |
|
|
3651 | dDisp; |
3671 | |
3652 | |
3672 | assert (str != NULL); |
3653 | assert (str != NULL); |
3673 | switch (op) |
3654 | switch (op) |
3674 | { |
3655 | { |
3675 | case XTerm_name: |
3656 | case XTerm_name: |
… | |
… | |
3691 | unsigned long bytes_after; |
3672 | unsigned long bytes_after; |
3692 | unsigned char *value = 0; |
3673 | unsigned char *value = 0; |
3693 | const char *str = ""; |
3674 | const char *str = ""; |
3694 | |
3675 | |
3695 | if (prop |
3676 | if (prop |
3696 | && XGetWindowProperty (display->display, TermWin.parent[0], |
3677 | && XGetWindowProperty (disp, TermWin.parent[0], |
3697 | prop, 0, 1<<16, 0, AnyPropertyType, |
3678 | prop, 0, 1<<16, 0, AnyPropertyType, |
3698 | &actual_type, &actual_format, |
3679 | &actual_type, &actual_format, |
3699 | &nitems, &bytes_after, &value) == Success |
3680 | &nitems, &bytes_after, &value) == Success |
3700 | && actual_type != None |
3681 | && actual_type != None |
3701 | && actual_format == 8) |
3682 | && actual_format == 8) |
… | |
… | |
3713 | { |
3694 | { |
3714 | *eq = 0; |
3695 | *eq = 0; |
3715 | set_utf8_property (display->atom (str), eq + 1); |
3696 | set_utf8_property (display->atom (str), eq + 1); |
3716 | } |
3697 | } |
3717 | else |
3698 | else |
3718 | XDeleteProperty (display->display, TermWin.parent[0], |
3699 | XDeleteProperty (disp, TermWin.parent[0], |
3719 | display->atom (str)); |
3700 | display->atom (str)); |
3720 | } |
3701 | } |
3721 | break; |
3702 | break; |
3722 | |
3703 | |
3723 | case XTerm_Color: |
3704 | case XTerm_Color: |
… | |
… | |
3798 | { |
3779 | { |
3799 | str++; |
3780 | str++; |
3800 | #if XPM_BACKGROUND |
3781 | #if XPM_BACKGROUND |
3801 | changed += scale_pixmap (str); |
3782 | changed += scale_pixmap (str); |
3802 | #endif |
3783 | #endif |
3803 | |
|
|
3804 | } |
3784 | } |
|
|
3785 | |
3805 | if (changed) |
3786 | if (changed) |
3806 | { |
3787 | { |
3807 | #ifdef XPM_BACKGROUND |
3788 | #ifdef XPM_BACKGROUND |
3808 | resize_pixmap (); |
3789 | resize_pixmap (); |
3809 | #endif |
3790 | #endif |
… | |
… | |
3850 | if (query) |
3831 | if (query) |
3851 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3832 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3852 | else |
3833 | else |
3853 | { |
3834 | { |
3854 | set_locale (str); |
3835 | set_locale (str); |
|
|
3836 | pty.set_utf8_mode (enc_utf8); |
3855 | # ifdef USE_XIM |
3837 | # ifdef USE_XIM |
3856 | im_cb (); |
3838 | im_cb (); |
3857 | # endif |
3839 | # endif |
3858 | } |
3840 | } |
3859 | break; |
3841 | break; |