… | |
… | |
49 | #include "rxvt.h" |
49 | #include "rxvt.h" |
50 | #include "rxvtperl.h" |
50 | #include "rxvtperl.h" |
51 | #include "version.h" |
51 | #include "version.h" |
52 | #include "command.h" |
52 | #include "command.h" |
53 | |
53 | |
54 | #if HAVE_SCHED_YIELD |
|
|
55 | #undef HAVE_SCHED_YIELD // disabled for the time being |
|
|
56 | //# include <sched.h> |
|
|
57 | #endif |
|
|
58 | |
|
|
59 | #ifdef KEYSYM_RESOURCE |
54 | #ifdef KEYSYM_RESOURCE |
60 | # include "keyboard.h" |
55 | # include "keyboard.h" |
61 | #endif |
56 | #endif |
62 | |
57 | |
63 | #include <csignal> |
58 | #include <csignal> |
|
|
59 | |
|
|
60 | #if LINUX_YIELD_HACK |
|
|
61 | # include <ctime> |
|
|
62 | #endif |
64 | |
63 | |
65 | /*----------------------------------------------------------------------*/ |
64 | /*----------------------------------------------------------------------*/ |
66 | |
65 | |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
66 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
68 | |
67 | |
… | |
… | |
1095 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1094 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1096 | } |
1095 | } |
1097 | } |
1096 | } |
1098 | #endif |
1097 | #endif |
1099 | |
1098 | |
1100 | #if HAVE_SCHED_YIELD |
1099 | #if LINUX_YIELD_HACK |
1101 | static struct event_handler |
1100 | static struct event_handler |
1102 | { |
1101 | { |
1103 | check_watcher cw_yield; |
1102 | check_watcher yield_ev; |
1104 | |
1103 | |
1105 | void yield (check_watcher &w) |
1104 | void yield_cb (check_watcher &w) |
1106 | { |
1105 | { |
1107 | sched_yield (); |
1106 | // this should really be sched_yield(), but the linux guys thought |
|
|
1107 | // that giving a process calling sched_yield () less cpu time than |
|
|
1108 | // ones with high nice levels is a useful thing to do. It surely is is |
|
|
1109 | // allowed by the sus... as is returning ENOSYS. |
|
|
1110 | |
|
|
1111 | struct timespec ts = { 0, 0 }; |
|
|
1112 | nanosleep (&ts, 0); |
|
|
1113 | |
1108 | w.stop (); |
1114 | w.stop (); |
1109 | } |
1115 | } |
1110 | |
1116 | |
1111 | event_handler () |
1117 | event_handler () |
1112 | : cw_yield (this, &event_handler::yield) |
1118 | : yield_ev (this, &event_handler::yield_cb) |
1113 | { |
1119 | { |
1114 | } |
1120 | } |
1115 | } event_handler; |
1121 | } event_handler; |
1116 | #endif |
1122 | #endif |
1117 | |
1123 | |
… | |
… | |
1137 | cmdbuf_endp += r; |
1143 | cmdbuf_endp += r; |
1138 | return true; |
1144 | return true; |
1139 | } |
1145 | } |
1140 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1146 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1141 | { |
1147 | { |
1142 | #if HAVE_SCHED_YIELD |
1148 | #if LINUX_YIELD_HACK |
1143 | if (display->is_local) |
1149 | if (display->is_local) |
1144 | event_handler.cw_yield.start (); |
1150 | event_handler.yield_ev.start (); |
1145 | #endif |
1151 | #endif |
1146 | } |
1152 | } |
1147 | else |
1153 | else |
1148 | { |
1154 | { |
1149 | pty_ev.stop (); |
1155 | pty_ev.stop (); |
… | |
… | |
1171 | } |
1177 | } |
1172 | |
1178 | |
1173 | void |
1179 | void |
1174 | rxvt_term::pointer_unblank () |
1180 | rxvt_term::pointer_unblank () |
1175 | { |
1181 | { |
1176 | XDefineCursor (xdisp, vt, TermWin_cursor); |
1182 | XDefineCursor (dpy, vt, TermWin_cursor); |
1177 | recolour_cursor (); |
1183 | recolour_cursor (); |
1178 | |
1184 | |
1179 | #ifdef POINTER_BLANK |
1185 | #ifdef POINTER_BLANK |
1180 | hidden_pointer = 0; |
1186 | hidden_pointer = 0; |
1181 | |
1187 | |
… | |
… | |
1189 | rxvt_term::pointer_blank () |
1195 | rxvt_term::pointer_blank () |
1190 | { |
1196 | { |
1191 | if (!OPTION (Opt_pointerBlank)) |
1197 | if (!OPTION (Opt_pointerBlank)) |
1192 | return; |
1198 | return; |
1193 | |
1199 | |
1194 | XDefineCursor (xdisp, vt, display->blank_cursor); |
1200 | XDefineCursor (dpy, vt, display->blank_cursor); |
1195 | XFlush (xdisp); |
1201 | XFlush (dpy); |
1196 | |
1202 | |
1197 | hidden_pointer = 1; |
1203 | hidden_pointer = 1; |
1198 | } |
1204 | } |
1199 | |
1205 | |
1200 | void |
1206 | void |
… | |
… | |
1279 | void |
1285 | void |
1280 | rxvt_term::x_cb (XEvent &ev) |
1286 | rxvt_term::x_cb (XEvent &ev) |
1281 | { |
1287 | { |
1282 | make_current (); |
1288 | make_current (); |
1283 | |
1289 | |
1284 | dLocal (Display *, xdisp); |
1290 | dLocal (Display *, dpy); |
1285 | |
1291 | |
1286 | if (ev.xany.window == vt |
1292 | if (ev.xany.window == vt |
1287 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1293 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1288 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1294 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1289 | return; |
1295 | return; |
… | |
… | |
1399 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1405 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1400 | destroy (); |
1406 | destroy (); |
1401 | } |
1407 | } |
1402 | #if ENABLE_EWMH |
1408 | #if ENABLE_EWMH |
1403 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1409 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1404 | XSendEvent (xdisp, ev.xclient.window = display->root, |
1410 | XSendEvent (dpy, ev.xclient.window = display->root, |
1405 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1411 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1406 | &ev); |
1412 | &ev); |
1407 | #endif |
1413 | #endif |
1408 | } |
1414 | } |
1409 | } |
1415 | } |
… | |
… | |
1457 | break; |
1463 | break; |
1458 | |
1464 | |
1459 | case ConfigureNotify: |
1465 | case ConfigureNotify: |
1460 | if (ev.xconfigure.window == parent[0]) |
1466 | if (ev.xconfigure.window == parent[0]) |
1461 | { |
1467 | { |
1462 | while (XCheckTypedWindowEvent (xdisp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1468 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1463 | ; |
1469 | ; |
1464 | |
1470 | |
1465 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1471 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1466 | { |
1472 | { |
1467 | seen_resize = 1; |
1473 | seen_resize = 1; |
… | |
… | |
1525 | if (ev.xany.window == vt) |
1531 | if (ev.xany.window == vt) |
1526 | { |
1532 | { |
1527 | do |
1533 | do |
1528 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1534 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1529 | ev.xexpose.width, ev.xexpose.height, False); |
1535 | ev.xexpose.width, ev.xexpose.height, False); |
1530 | while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)); |
1536 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1531 | |
1537 | |
1532 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1538 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1533 | |
1539 | |
1534 | while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)) |
1540 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
1535 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1541 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1536 | ev.xexpose.width, ev.xexpose.height, False); |
1542 | ev.xexpose.width, ev.xexpose.height, False); |
1537 | |
1543 | |
1538 | want_refresh = 1; |
1544 | want_refresh = 1; |
1539 | } |
1545 | } |
1540 | else |
1546 | else |
1541 | { |
1547 | { |
1542 | XEvent unused_event; |
1548 | XEvent unused_event; |
1543 | |
1549 | |
1544 | while (XCheckTypedWindowEvent (xdisp, ev.xany.window, Expose, &unused_event)) |
1550 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1545 | ; |
1551 | ; |
1546 | while (XCheckTypedWindowEvent (xdisp, ev.xany.window, GraphicsExpose, &unused_event)) |
1552 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1547 | ; |
1553 | ; |
1548 | |
1554 | |
1549 | if (isScrollbarWindow (ev.xany.window)) |
1555 | if (isScrollbarWindow (ev.xany.window)) |
1550 | { |
1556 | { |
1551 | scrollBar.setIdle (); |
1557 | scrollBar.setIdle (); |
1552 | scrollbar_show (0); |
1558 | scrollbar_show (0); |
1553 | } |
1559 | } |
1554 | |
1560 | |
1555 | #ifdef TRANSPARENT |
1561 | #ifdef TRANSPARENT |
1556 | if (am_transparent && ev.xany.window == parent[0]) |
1562 | if (am_transparent && ev.xany.window == parent[0]) |
1557 | XClearWindow (xdisp, ev.xany.window); |
1563 | XClearWindow (dpy, ev.xany.window); |
1558 | #endif |
1564 | #endif |
1559 | } |
1565 | } |
1560 | break; |
1566 | break; |
1561 | |
1567 | |
1562 | case MotionNotify: |
1568 | case MotionNotify: |
… | |
… | |
1572 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1578 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1573 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1579 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1574 | ; // nop |
1580 | ; // nop |
1575 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1581 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1576 | { |
1582 | { |
1577 | while (XCheckTypedWindowEvent (xdisp, vt, MotionNotify, &ev)) |
1583 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1578 | ; |
1584 | ; |
1579 | |
1585 | |
1580 | XQueryPointer (xdisp, vt, |
1586 | XQueryPointer (dpy, vt, |
1581 | &unused_root, &unused_child, |
1587 | &unused_root, &unused_child, |
1582 | &unused_root_x, &unused_root_y, |
1588 | &unused_root_x, &unused_root_y, |
1583 | &ev.xbutton.x, &ev.xbutton.y, |
1589 | &ev.xbutton.x, &ev.xbutton.y, |
1584 | &ev.xbutton.state); |
1590 | &ev.xbutton.state); |
1585 | #ifdef MOUSE_THRESHOLD |
1591 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1649 | #endif |
1655 | #endif |
1650 | } |
1656 | } |
1651 | } |
1657 | } |
1652 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1658 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1653 | { |
1659 | { |
1654 | while (XCheckTypedWindowEvent (xdisp, scrollBar.win, |
1660 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1655 | MotionNotify, &ev)) |
1661 | MotionNotify, &ev)) |
1656 | ; |
1662 | ; |
1657 | |
1663 | |
1658 | XQueryPointer (xdisp, scrollBar.win, |
1664 | XQueryPointer (dpy, scrollBar.win, |
1659 | &unused_root, &unused_child, |
1665 | &unused_root, &unused_child, |
1660 | &unused_root_x, &unused_root_y, |
1666 | &unused_root_x, &unused_root_y, |
1661 | &ev.xbutton.x, &ev.xbutton.y, |
1667 | &ev.xbutton.x, &ev.xbutton.y, |
1662 | &unused_mask); |
1668 | &unused_mask); |
1663 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1669 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
… | |
… | |
1703 | rxvt_term::focus_in () |
1709 | rxvt_term::focus_in () |
1704 | { |
1710 | { |
1705 | if (!focus) |
1711 | if (!focus) |
1706 | { |
1712 | { |
1707 | focus = 1; |
1713 | focus = 1; |
|
|
1714 | want_refresh = 1; |
1708 | |
1715 | |
1709 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1716 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1710 | |
1717 | |
1711 | #if USE_XIM |
1718 | #if USE_XIM |
1712 | if (Input_Context != NULL) |
1719 | if (Input_Context != NULL) |
… | |
… | |
1721 | #endif |
1728 | #endif |
1722 | #if OFF_FOCUS_FADING |
1729 | #if OFF_FOCUS_FADING |
1723 | if (rs[Rs_fade]) |
1730 | if (rs[Rs_fade]) |
1724 | { |
1731 | { |
1725 | pix_colors = pix_colors_focused; |
1732 | pix_colors = pix_colors_focused; |
1726 | want_refresh = 1; |
|
|
1727 | scr_recolour (); |
1733 | scr_recolour (); |
1728 | } |
1734 | } |
1729 | #endif |
1735 | #endif |
1730 | } |
1736 | } |
1731 | } |
1737 | } |
… | |
… | |
1734 | rxvt_term::focus_out () |
1740 | rxvt_term::focus_out () |
1735 | { |
1741 | { |
1736 | if (focus) |
1742 | if (focus) |
1737 | { |
1743 | { |
1738 | focus = 0; |
1744 | focus = 0; |
|
|
1745 | want_refresh = 1; |
1739 | |
1746 | |
1740 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1747 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1741 | |
1748 | |
1742 | #if ENABLE_FRILLS || ISO_14755 |
1749 | #if ENABLE_FRILLS || ISO_14755 |
1743 | if (iso14755buf) |
1750 | if (iso14755buf) |
… | |
… | |
1759 | #endif |
1766 | #endif |
1760 | #if OFF_FOCUS_FADING |
1767 | #if OFF_FOCUS_FADING |
1761 | if (rs[Rs_fade]) |
1768 | if (rs[Rs_fade]) |
1762 | { |
1769 | { |
1763 | pix_colors = pix_colors_unfocused; |
1770 | pix_colors = pix_colors_unfocused; |
1764 | want_refresh = 1; |
|
|
1765 | scr_recolour (); |
1771 | scr_recolour (); |
1766 | } |
1772 | } |
1767 | #endif |
1773 | #endif |
1768 | } |
1774 | } |
1769 | } |
1775 | } |
… | |
… | |
2424 | pchanged = 0; |
2430 | pchanged = 0; |
2425 | |
2431 | |
2426 | if (!OPTION (Opt_transparent)) |
2432 | if (!OPTION (Opt_transparent)) |
2427 | return pchanged; /* Don't try any more */ |
2433 | return pchanged; /* Don't try any more */ |
2428 | |
2434 | |
2429 | XGetWindowAttributes (xdisp, display->root, &wrootattr); |
2435 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
2430 | rootdepth = wrootattr.depth; |
2436 | rootdepth = wrootattr.depth; |
2431 | |
2437 | |
2432 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
2438 | XGetWindowAttributes (dpy, parent[0], &wattr); |
2433 | |
2439 | |
2434 | if (rootdepth != wattr.depth) |
2440 | if (rootdepth != wattr.depth) |
2435 | { |
2441 | { |
2436 | if (am_transparent) |
2442 | if (am_transparent) |
2437 | { |
2443 | { |
2438 | pchanged = 1; |
2444 | pchanged = 1; |
2439 | XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); |
2445 | XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
2440 | am_transparent = am_pixmap_trans = 0; |
2446 | am_transparent = am_pixmap_trans = 0; |
2441 | } |
2447 | } |
2442 | |
2448 | |
2443 | return pchanged; /* Don't try any more */ |
2449 | return pchanged; /* Don't try any more */ |
2444 | } |
2450 | } |
2445 | |
2451 | |
2446 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2452 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2447 | XSync (xdisp, False); |
2453 | XSync (dpy, False); |
2448 | |
2454 | |
2449 | /* |
2455 | /* |
2450 | * Make the frame window set by the window manager have |
2456 | * Make the frame window set by the window manager have |
2451 | * the root background. Some window managers put multiple nested frame |
2457 | * the root background. Some window managers put multiple nested frame |
2452 | * windows for each client, so we have to take care about that. |
2458 | * windows for each client, so we have to take care about that. |
2453 | */ |
2459 | */ |
2454 | i = (xa[XA_XROOTPMAP_ID] |
2460 | i = (xa[XA_XROOTPMAP_ID] |
2455 | && XGetWindowProperty (xdisp, display->root, xa[XA_XROOTPMAP_ID], |
2461 | && XGetWindowProperty (dpy, display->root, xa[XA_XROOTPMAP_ID], |
2456 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2462 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2457 | &nitems, &bytes_after, &prop) == Success); |
2463 | &nitems, &bytes_after, &prop) == Success); |
2458 | |
2464 | |
2459 | if (!i || prop == NULL) |
2465 | if (!i || prop == NULL) |
2460 | i = (xa[XA_ESETROOT_PMAP_ID] |
2466 | i = (xa[XA_ESETROOT_PMAP_ID] |
2461 | && XGetWindowProperty (xdisp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2467 | && XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID], |
2462 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2468 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2463 | &nitems, &bytes_after, &prop) == Success); |
2469 | &nitems, &bytes_after, &prop) == Success); |
2464 | |
2470 | |
2465 | if (!i || prop == NULL |
2471 | if (!i || prop == NULL |
2466 | #if TINTING |
2472 | #if TINTING |
2467 | || !rs[Rs_color + Color_tint] |
2473 | || !ISSET_PIXCOLOR (Color_tint) |
2468 | #endif |
2474 | #endif |
2469 | ) |
2475 | ) |
2470 | have_pixmap = 0; |
2476 | have_pixmap = 0; |
2471 | else |
2477 | else |
2472 | { |
2478 | { |
… | |
… | |
2485 | Window cr; |
2491 | Window cr; |
2486 | XImage *image; |
2492 | XImage *image; |
2487 | GC gc; |
2493 | GC gc; |
2488 | XGCValues gcvalue; |
2494 | XGCValues gcvalue; |
2489 | |
2495 | |
2490 | XTranslateCoordinates (xdisp, parent[0], display->root, |
2496 | XTranslateCoordinates (dpy, parent[0], display->root, |
2491 | 0, 0, &sx, &sy, &cr); |
2497 | 0, 0, &sx, &sy, &cr); |
2492 | nw = (unsigned int)szHint.width; |
2498 | nw = (unsigned int)szHint.width; |
2493 | nh = (unsigned int)szHint.height; |
2499 | nh = (unsigned int)szHint.height; |
2494 | nx = ny = 0; |
2500 | nx = ny = 0; |
2495 | |
2501 | |
… | |
… | |
2508 | } |
2514 | } |
2509 | |
2515 | |
2510 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2516 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2511 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2517 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2512 | |
2518 | |
2513 | XSync (xdisp, False); |
2519 | XSync (dpy, False); |
2514 | allowedxerror = -1; |
2520 | allowedxerror = -1; |
2515 | image = XGetImage (xdisp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2521 | image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2516 | |
2522 | |
2517 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2523 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2518 | /* XXX: may need a delay here? */ |
2524 | /* XXX: may need a delay here? */ |
2519 | allowedxerror = 0; |
2525 | allowedxerror = 0; |
2520 | |
2526 | |
… | |
… | |
2523 | if (am_transparent && am_pixmap_trans) |
2529 | if (am_transparent && am_pixmap_trans) |
2524 | { |
2530 | { |
2525 | pchanged = 1; |
2531 | pchanged = 1; |
2526 | if (pixmap != None) |
2532 | if (pixmap != None) |
2527 | { |
2533 | { |
2528 | XFreePixmap (xdisp, pixmap); |
2534 | XFreePixmap (dpy, pixmap); |
2529 | pixmap = None; |
2535 | pixmap = None; |
2530 | } |
2536 | } |
2531 | } |
2537 | } |
2532 | |
2538 | |
2533 | am_pixmap_trans = 0; |
2539 | am_pixmap_trans = 0; |
2534 | } |
2540 | } |
2535 | else |
2541 | else |
2536 | { |
2542 | { |
2537 | if (pixmap != None) |
2543 | if (pixmap != None) |
2538 | XFreePixmap (xdisp, pixmap); |
2544 | XFreePixmap (dpy, pixmap); |
2539 | |
2545 | |
2540 | #if TINTING |
2546 | #if TINTING |
2541 | if (ISSET_PIXCOLOR (Color_tint)) |
2547 | if (ISSET_PIXCOLOR (Color_tint)) |
2542 | { |
2548 | { |
2543 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
2549 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
2544 | |
2550 | |
2545 | rxvt_rgba c; |
2551 | rgba c; |
2546 | pix_colors_focused [Color_tint].get (this, c); |
2552 | pix_colors_focused [Color_tint].get (c); |
2547 | |
2553 | |
2548 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
2554 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
2549 | } |
2555 | } |
2550 | #endif |
2556 | #endif |
2551 | |
2557 | |
2552 | pixmap = XCreatePixmap (xdisp, vt, szHint.width, szHint.height, image->depth); |
2558 | pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth); |
2553 | gc = XCreateGC (xdisp, vt, 0UL, &gcvalue); |
2559 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
2554 | XPutImage (xdisp, pixmap, gc, image, 0, 0, |
2560 | XPutImage (dpy, pixmap, gc, image, 0, 0, |
2555 | nx, ny, image->width, image->height); |
2561 | nx, ny, image->width, image->height); |
2556 | XFreeGC (xdisp, gc); |
2562 | XFreeGC (dpy, gc); |
2557 | XDestroyImage (image); |
2563 | XDestroyImage (image); |
2558 | XSetWindowBackgroundPixmap (xdisp, parent[0], pixmap); |
2564 | XSetWindowBackgroundPixmap (dpy, parent[0], pixmap); |
2559 | XClearWindow (xdisp, parent[0]); |
2565 | XClearWindow (dpy, parent[0]); |
2560 | |
2566 | |
2561 | if (!am_transparent || !am_pixmap_trans) |
2567 | if (!am_transparent || !am_pixmap_trans) |
2562 | pchanged = 1; |
2568 | pchanged = 1; |
2563 | |
2569 | |
2564 | am_transparent = am_pixmap_trans = 1; |
2570 | am_transparent = am_pixmap_trans = 1; |
2565 | } |
2571 | } |
2566 | } |
2572 | } |
2567 | |
2573 | |
2568 | if (am_pixmap_trans) |
2574 | if (am_pixmap_trans) |
2569 | XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); |
2575 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
2570 | else |
2576 | else |
2571 | { |
2577 | { |
2572 | unsigned int n; |
2578 | unsigned int n; |
2573 | /* |
2579 | /* |
2574 | * InheritPixmap transparency |
2580 | * InheritPixmap transparency |
2575 | */ |
2581 | */ |
2576 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2582 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2577 | { |
2583 | { |
2578 | oldp = parent[i]; |
2584 | oldp = parent[i]; |
2579 | XQueryTree (xdisp, parent[i - 1], &root, |
2585 | XQueryTree (dpy, parent[i - 1], &root, &parent[i], &list, &n); |
2580 | &parent[i], &list, &n); |
|
|
2581 | XFree (list); |
2586 | XFree (list); |
2582 | |
2587 | |
2583 | if (parent[i] == display->root) |
2588 | if (parent[i] == display->root) |
2584 | { |
2589 | { |
2585 | if (oldp != None) |
2590 | if (oldp != None) |
… | |
… | |
2593 | } |
2598 | } |
2594 | |
2599 | |
2595 | n = 0; |
2600 | n = 0; |
2596 | |
2601 | |
2597 | if (pchanged) |
2602 | if (pchanged) |
2598 | { |
|
|
2599 | for (; n < (unsigned int)i; n++) |
2603 | for (; n < (unsigned int)i; n++) |
2600 | { |
2604 | { |
2601 | XGetWindowAttributes (xdisp, parent[n], &wattr); |
2605 | XGetWindowAttributes (dpy, parent[n], &wattr); |
|
|
2606 | |
2602 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2607 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2603 | { |
2608 | { |
2604 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2609 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2605 | break; |
2610 | break; |
2606 | } |
2611 | } |
2607 | } |
2612 | } |
2608 | } |
|
|
2609 | |
2613 | |
2610 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
2614 | if (n > (sizeof (parent) / sizeof (parent[0]))) |
2611 | { |
2615 | { |
2612 | XSetWindowBackground (xdisp, parent[0], pix_colors_focused[Color_border]); |
2616 | XSetWindowBackground (dpy, parent[0], pix_colors_focused[Color_border]); |
2613 | XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); |
2617 | XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
2614 | am_transparent = 0; |
2618 | am_transparent = 0; |
2615 | /* XXX: also turn off Opt_transparent? */ |
2619 | /* XXX: also turn off Opt_transparent? */ |
2616 | } |
2620 | } |
2617 | else |
2621 | else |
2618 | { |
2622 | { |
2619 | for (n = 0; n < (unsigned int)i; n++) |
2623 | for (n = 0; n < (unsigned int)i; n++) |
2620 | { |
2624 | { |
2621 | XSetWindowBackgroundPixmap (xdisp, parent[n], ParentRelative); |
2625 | XSetWindowBackgroundPixmap (dpy, parent[n], ParentRelative); |
2622 | XClearWindow (xdisp, parent[n]); |
2626 | XClearWindow (dpy, parent[n]); |
2623 | } |
2627 | } |
2624 | |
2628 | |
2625 | XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); |
2629 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
2626 | am_transparent = 1; |
2630 | am_transparent = 1; |
2627 | } |
2631 | } |
2628 | |
2632 | |
2629 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2633 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2630 | parent[i] = None; |
2634 | parent[i] = None; |
2631 | } |
2635 | } |
2632 | |
2636 | |
2633 | if (scrollBar.win) |
2637 | if (scrollBar.win) |
2634 | { |
2638 | { |
2635 | XSetWindowBackgroundPixmap (xdisp, scrollBar.win, ParentRelative); |
2639 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2636 | scrollBar.setIdle (); |
2640 | scrollBar.setIdle (); |
2637 | scrollbar_show (0); |
2641 | scrollbar_show (0); |
2638 | } |
2642 | } |
2639 | |
2643 | |
2640 | if (am_transparent) |
2644 | if (am_transparent) |
… | |
… | |
3531 | { |
3535 | { |
3532 | int x, y; |
3536 | int x, y; |
3533 | XWindowAttributes wattr; |
3537 | XWindowAttributes wattr; |
3534 | Window wdummy; |
3538 | Window wdummy; |
3535 | |
3539 | |
3536 | dLocal (Display *, xdisp); |
3540 | dLocal (Display *, dpy); |
3537 | |
3541 | |
3538 | if (nargs == 0) |
3542 | if (nargs == 0) |
3539 | return; |
3543 | return; |
3540 | |
3544 | |
3541 | switch (args[0]) |
3545 | switch (args[0]) |
3542 | { |
3546 | { |
3543 | /* |
3547 | /* |
3544 | * commands |
3548 | * commands |
3545 | */ |
3549 | */ |
3546 | case 1: /* deiconify window */ |
3550 | case 1: /* deiconify window */ |
3547 | XMapWindow (xdisp, parent[0]); |
3551 | XMapWindow (dpy, parent[0]); |
3548 | break; |
3552 | break; |
3549 | case 2: /* iconify window */ |
3553 | case 2: /* iconify window */ |
3550 | XIconifyWindow (xdisp, parent[0], display->screen); |
3554 | XIconifyWindow (dpy, parent[0], display->screen); |
3551 | break; |
3555 | break; |
3552 | case 3: /* set position (pixels) */ |
3556 | case 3: /* set position (pixels) */ |
3553 | XMoveWindow (xdisp, parent[0], args[1], args[2]); |
3557 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3554 | break; |
3558 | break; |
3555 | case 4: /* set size (pixels) */ |
3559 | case 4: /* set size (pixels) */ |
3556 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3560 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3557 | break; |
3561 | break; |
3558 | case 5: /* raise window */ |
3562 | case 5: /* raise window */ |
3559 | XRaiseWindow (xdisp, parent[0]); |
3563 | XRaiseWindow (dpy, parent[0]); |
3560 | break; |
3564 | break; |
3561 | case 6: /* lower window */ |
3565 | case 6: /* lower window */ |
3562 | XLowerWindow (xdisp, parent[0]); |
3566 | XLowerWindow (dpy, parent[0]); |
3563 | break; |
3567 | break; |
3564 | case 7: /* refresh window */ |
3568 | case 7: /* refresh window */ |
3565 | scr_touch (true); |
3569 | scr_touch (true); |
3566 | break; |
3570 | break; |
3567 | case 8: /* set size (chars) */ |
3571 | case 8: /* set size (chars) */ |
… | |
… | |
3574 | if (args[0] >= 24) /* set height (chars) */ |
3578 | if (args[0] >= 24) /* set height (chars) */ |
3575 | set_widthheight ((unsigned int)width, |
3579 | set_widthheight ((unsigned int)width, |
3576 | (unsigned int) (args[1] * fheight)); |
3580 | (unsigned int) (args[1] * fheight)); |
3577 | break; |
3581 | break; |
3578 | |
3582 | |
3579 | |
|
|
3580 | /* |
3583 | /* |
3581 | * reports - some output format copied from XTerm |
3584 | * reports - some output format copied from XTerm |
3582 | */ |
3585 | */ |
3583 | case 11: /* report window state */ |
3586 | case 11: /* report window state */ |
3584 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3587 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3585 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3588 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3586 | break; |
3589 | break; |
3587 | case 13: /* report window position */ |
3590 | case 13: /* report window position */ |
3588 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3591 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3589 | XTranslateCoordinates (xdisp, parent[0], wattr.root, |
3592 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3590 | -wattr.border_width, -wattr.border_width, |
3593 | -wattr.border_width, -wattr.border_width, |
3591 | &x, &y, &wdummy); |
3594 | &x, &y, &wdummy); |
3592 | tt_printf ("\033[3;%d;%dt", x, y); |
3595 | tt_printf ("\033[3;%d;%dt", x, y); |
3593 | break; |
3596 | break; |
3594 | case 14: /* report window size (pixels) */ |
3597 | case 14: /* report window size (pixels) */ |
3595 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3598 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3596 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3599 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3597 | break; |
3600 | break; |
3598 | case 18: /* report text area size (chars) */ |
3601 | case 18: /* report text area size (chars) */ |
3599 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3602 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3600 | break; |
3603 | break; |
… | |
… | |
3602 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3605 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3603 | break; |
3606 | break; |
3604 | case 20: /* report icon label */ |
3607 | case 20: /* report icon label */ |
3605 | { |
3608 | { |
3606 | char *s; |
3609 | char *s; |
3607 | XGetIconName (xdisp, parent[0], &s); |
3610 | XGetIconName (dpy, parent[0], &s); |
3608 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3611 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3609 | XFree (s); |
3612 | XFree (s); |
3610 | } |
3613 | } |
3611 | break; |
3614 | break; |
3612 | case 21: /* report window title */ |
3615 | case 21: /* report window title */ |
3613 | { |
3616 | { |
3614 | char *s; |
3617 | char *s; |
3615 | XFetchName (xdisp, parent[0], &s); |
3618 | XFetchName (dpy, parent[0], &s); |
3616 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3619 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3617 | XFree (s); |
3620 | XFree (s); |
3618 | } |
3621 | } |
3619 | break; |
3622 | break; |
3620 | } |
3623 | } |
… | |
… | |
3721 | void |
3724 | void |
3722 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3725 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3723 | { |
3726 | { |
3724 | if (str[0] == '?' && !str[1]) |
3727 | if (str[0] == '?' && !str[1]) |
3725 | { |
3728 | { |
3726 | rxvt_rgba c; |
3729 | rgba c; |
3727 | pix_colors_focused[color].get (this, c); |
3730 | pix_colors_focused[color].get (c); |
3728 | |
3731 | |
3729 | #if XFT |
3732 | #if XFT |
3730 | if (c.a != rxvt_rgba::MAX_CC) |
3733 | if (c.a != rgba::MAX_CC) |
3731 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
3734 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
3732 | else |
3735 | else |
3733 | #endif |
3736 | #endif |
3734 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3737 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3735 | } |
3738 | } |
… | |
… | |
3746 | int color; |
3749 | int color; |
3747 | char *buf, *name; |
3750 | char *buf, *name; |
3748 | bool query = str[0] == '?' && !str[1]; |
3751 | bool query = str[0] == '?' && !str[1]; |
3749 | int saveop = op; |
3752 | int saveop = op; |
3750 | |
3753 | |
3751 | dLocal (Display *, xdisp); |
3754 | dLocal (Display *, dpy); |
3752 | |
3755 | |
3753 | assert (str != NULL); |
3756 | assert (str != NULL); |
3754 | switch (op) |
3757 | switch (op) |
3755 | { |
3758 | { |
3756 | case XTerm_name: |
3759 | case XTerm_name: |
… | |
… | |
3772 | unsigned long bytes_after; |
3775 | unsigned long bytes_after; |
3773 | unsigned char *value = 0; |
3776 | unsigned char *value = 0; |
3774 | const char *str = ""; |
3777 | const char *str = ""; |
3775 | |
3778 | |
3776 | if (prop |
3779 | if (prop |
3777 | && XGetWindowProperty (xdisp, parent[0], |
3780 | && XGetWindowProperty (dpy, parent[0], |
3778 | prop, 0, 1<<16, 0, AnyPropertyType, |
3781 | prop, 0, 1<<16, 0, AnyPropertyType, |
3779 | &actual_type, &actual_format, |
3782 | &actual_type, &actual_format, |
3780 | &nitems, &bytes_after, &value) == Success |
3783 | &nitems, &bytes_after, &value) == Success |
3781 | && actual_type != None |
3784 | && actual_type != None |
3782 | && actual_format == 8) |
3785 | && actual_format == 8) |
… | |
… | |
3794 | { |
3797 | { |
3795 | *eq = 0; |
3798 | *eq = 0; |
3796 | set_utf8_property (display->atom (str), eq + 1); |
3799 | set_utf8_property (display->atom (str), eq + 1); |
3797 | } |
3800 | } |
3798 | else |
3801 | else |
3799 | XDeleteProperty (xdisp, parent[0], |
3802 | XDeleteProperty (dpy, parent[0], |
3800 | display->atom (str)); |
3803 | display->atom (str)); |
3801 | } |
3804 | } |
3802 | break; |
3805 | break; |
3803 | |
3806 | |
3804 | case XTerm_Color: |
3807 | case XTerm_Color: |
… | |
… | |
3853 | break; |
3856 | break; |
3854 | #endif |
3857 | #endif |
3855 | #if TRANSPARENT && TINTING |
3858 | #if TRANSPARENT && TINTING |
3856 | case URxvt_Color_tint: |
3859 | case URxvt_Color_tint: |
3857 | process_color_seq (op, Color_tint, str, resp); |
3860 | process_color_seq (op, Color_tint, str, resp); |
|
|
3861 | |
3858 | check_our_parents (); |
3862 | check_our_parents (); |
|
|
3863 | |
3859 | if (am_transparent) |
3864 | if (am_transparent) |
3860 | want_full_refresh = want_refresh = 1; |
3865 | want_full_refresh = want_refresh = 1; |
|
|
3866 | |
3861 | break; |
3867 | break; |
3862 | #endif |
3868 | #endif |
3863 | |
3869 | |
3864 | case Rxvt_Pixmap: |
3870 | case Rxvt_Pixmap: |
3865 | { |
3871 | { |