… | |
… | |
54 | #ifdef KEYSYM_RESOURCE |
54 | #ifdef KEYSYM_RESOURCE |
55 | # include "keyboard.h" |
55 | # include "keyboard.h" |
56 | #endif |
56 | #endif |
57 | |
57 | |
58 | #include <csignal> |
58 | #include <csignal> |
|
|
59 | |
|
|
60 | #if LINUX_YIELD_HACK |
|
|
61 | # include <ctime> |
|
|
62 | #endif |
59 | |
63 | |
60 | /*----------------------------------------------------------------------*/ |
64 | /*----------------------------------------------------------------------*/ |
61 | |
65 | |
62 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
66 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
63 | |
67 | |
… | |
… | |
1097 | { |
1101 | { |
1098 | check_watcher yield_ev; |
1102 | check_watcher yield_ev; |
1099 | |
1103 | |
1100 | void yield_cb (check_watcher &w) |
1104 | void yield_cb (check_watcher &w) |
1101 | { |
1105 | { |
1102 | usleep (0); |
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 | |
1103 | w.stop (); |
1114 | w.stop (); |
1104 | } |
1115 | } |
1105 | |
1116 | |
1106 | event_handler () |
1117 | event_handler () |
1107 | : yield_ev (this, &event_handler::yield_cb) |
1118 | : yield_ev (this, &event_handler::yield_cb) |
… | |
… | |
1166 | } |
1177 | } |
1167 | |
1178 | |
1168 | void |
1179 | void |
1169 | rxvt_term::pointer_unblank () |
1180 | rxvt_term::pointer_unblank () |
1170 | { |
1181 | { |
1171 | XDefineCursor (xdisp, vt, TermWin_cursor); |
1182 | XDefineCursor (dpy, vt, TermWin_cursor); |
1172 | recolour_cursor (); |
1183 | recolour_cursor (); |
1173 | |
1184 | |
1174 | #ifdef POINTER_BLANK |
1185 | #ifdef POINTER_BLANK |
1175 | hidden_pointer = 0; |
1186 | hidden_pointer = 0; |
1176 | |
1187 | |
… | |
… | |
1184 | rxvt_term::pointer_blank () |
1195 | rxvt_term::pointer_blank () |
1185 | { |
1196 | { |
1186 | if (!OPTION (Opt_pointerBlank)) |
1197 | if (!OPTION (Opt_pointerBlank)) |
1187 | return; |
1198 | return; |
1188 | |
1199 | |
1189 | XDefineCursor (xdisp, vt, display->blank_cursor); |
1200 | XDefineCursor (dpy, vt, display->blank_cursor); |
1190 | XFlush (xdisp); |
1201 | XFlush (dpy); |
1191 | |
1202 | |
1192 | hidden_pointer = 1; |
1203 | hidden_pointer = 1; |
1193 | } |
1204 | } |
1194 | |
1205 | |
1195 | void |
1206 | void |
… | |
… | |
1274 | void |
1285 | void |
1275 | rxvt_term::x_cb (XEvent &ev) |
1286 | rxvt_term::x_cb (XEvent &ev) |
1276 | { |
1287 | { |
1277 | make_current (); |
1288 | make_current (); |
1278 | |
1289 | |
1279 | dLocal (Display *, xdisp); |
1290 | dLocal (Display *, dpy); |
1280 | |
1291 | |
1281 | if (ev.xany.window == vt |
1292 | if (ev.xany.window == vt |
1282 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1293 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1283 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1294 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1284 | return; |
1295 | return; |
… | |
… | |
1394 | 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))) |
1395 | destroy (); |
1406 | destroy (); |
1396 | } |
1407 | } |
1397 | #if ENABLE_EWMH |
1408 | #if ENABLE_EWMH |
1398 | 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]) |
1399 | XSendEvent (xdisp, ev.xclient.window = display->root, |
1410 | XSendEvent (dpy, ev.xclient.window = display->root, |
1400 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1411 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1401 | &ev); |
1412 | &ev); |
1402 | #endif |
1413 | #endif |
1403 | } |
1414 | } |
1404 | } |
1415 | } |
… | |
… | |
1452 | break; |
1463 | break; |
1453 | |
1464 | |
1454 | case ConfigureNotify: |
1465 | case ConfigureNotify: |
1455 | if (ev.xconfigure.window == parent[0]) |
1466 | if (ev.xconfigure.window == parent[0]) |
1456 | { |
1467 | { |
1457 | while (XCheckTypedWindowEvent (xdisp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1468 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1458 | ; |
1469 | ; |
1459 | |
1470 | |
1460 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1471 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1461 | { |
1472 | { |
1462 | seen_resize = 1; |
1473 | seen_resize = 1; |
… | |
… | |
1520 | if (ev.xany.window == vt) |
1531 | if (ev.xany.window == vt) |
1521 | { |
1532 | { |
1522 | do |
1533 | do |
1523 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1534 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1524 | ev.xexpose.width, ev.xexpose.height, False); |
1535 | ev.xexpose.width, ev.xexpose.height, False); |
1525 | while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)); |
1536 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1526 | |
1537 | |
1527 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1538 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1528 | |
1539 | |
1529 | while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)) |
1540 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
1530 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1541 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1531 | ev.xexpose.width, ev.xexpose.height, False); |
1542 | ev.xexpose.width, ev.xexpose.height, False); |
1532 | |
1543 | |
1533 | want_refresh = 1; |
1544 | want_refresh = 1; |
1534 | } |
1545 | } |
1535 | else |
1546 | else |
1536 | { |
1547 | { |
1537 | XEvent unused_event; |
1548 | XEvent unused_event; |
1538 | |
1549 | |
1539 | while (XCheckTypedWindowEvent (xdisp, ev.xany.window, Expose, &unused_event)) |
1550 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1540 | ; |
1551 | ; |
1541 | while (XCheckTypedWindowEvent (xdisp, ev.xany.window, GraphicsExpose, &unused_event)) |
1552 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1542 | ; |
1553 | ; |
1543 | |
1554 | |
1544 | if (isScrollbarWindow (ev.xany.window)) |
1555 | if (isScrollbarWindow (ev.xany.window)) |
1545 | { |
1556 | { |
1546 | scrollBar.setIdle (); |
1557 | scrollBar.setIdle (); |
1547 | scrollbar_show (0); |
1558 | scrollbar_show (0); |
1548 | } |
1559 | } |
1549 | |
1560 | |
1550 | #ifdef TRANSPARENT |
1561 | #ifdef TRANSPARENT |
1551 | if (am_transparent && ev.xany.window == parent[0]) |
1562 | if (am_transparent && ev.xany.window == parent[0]) |
1552 | XClearWindow (xdisp, ev.xany.window); |
1563 | XClearWindow (dpy, ev.xany.window); |
1553 | #endif |
1564 | #endif |
1554 | } |
1565 | } |
1555 | break; |
1566 | break; |
1556 | |
1567 | |
1557 | case MotionNotify: |
1568 | case MotionNotify: |
… | |
… | |
1567 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1578 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1568 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1579 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1569 | ; // nop |
1580 | ; // nop |
1570 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1581 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1571 | { |
1582 | { |
1572 | while (XCheckTypedWindowEvent (xdisp, vt, MotionNotify, &ev)) |
1583 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1573 | ; |
1584 | ; |
1574 | |
1585 | |
1575 | XQueryPointer (xdisp, vt, |
1586 | XQueryPointer (dpy, vt, |
1576 | &unused_root, &unused_child, |
1587 | &unused_root, &unused_child, |
1577 | &unused_root_x, &unused_root_y, |
1588 | &unused_root_x, &unused_root_y, |
1578 | &ev.xbutton.x, &ev.xbutton.y, |
1589 | &ev.xbutton.x, &ev.xbutton.y, |
1579 | &ev.xbutton.state); |
1590 | &ev.xbutton.state); |
1580 | #ifdef MOUSE_THRESHOLD |
1591 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1644 | #endif |
1655 | #endif |
1645 | } |
1656 | } |
1646 | } |
1657 | } |
1647 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1658 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1648 | { |
1659 | { |
1649 | while (XCheckTypedWindowEvent (xdisp, scrollBar.win, |
1660 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1650 | MotionNotify, &ev)) |
1661 | MotionNotify, &ev)) |
1651 | ; |
1662 | ; |
1652 | |
1663 | |
1653 | XQueryPointer (xdisp, scrollBar.win, |
1664 | XQueryPointer (dpy, scrollBar.win, |
1654 | &unused_root, &unused_child, |
1665 | &unused_root, &unused_child, |
1655 | &unused_root_x, &unused_root_y, |
1666 | &unused_root_x, &unused_root_y, |
1656 | &ev.xbutton.x, &ev.xbutton.y, |
1667 | &ev.xbutton.x, &ev.xbutton.y, |
1657 | &unused_mask); |
1668 | &unused_mask); |
1658 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1669 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
… | |
… | |
2419 | pchanged = 0; |
2430 | pchanged = 0; |
2420 | |
2431 | |
2421 | if (!OPTION (Opt_transparent)) |
2432 | if (!OPTION (Opt_transparent)) |
2422 | return pchanged; /* Don't try any more */ |
2433 | return pchanged; /* Don't try any more */ |
2423 | |
2434 | |
2424 | XGetWindowAttributes (xdisp, display->root, &wrootattr); |
2435 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
2425 | rootdepth = wrootattr.depth; |
2436 | rootdepth = wrootattr.depth; |
2426 | |
2437 | |
2427 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
2438 | XGetWindowAttributes (dpy, parent[0], &wattr); |
2428 | |
2439 | |
2429 | if (rootdepth != wattr.depth) |
2440 | if (rootdepth != wattr.depth) |
2430 | { |
2441 | { |
2431 | if (am_transparent) |
2442 | if (am_transparent) |
2432 | { |
2443 | { |
2433 | pchanged = 1; |
2444 | pchanged = 1; |
2434 | XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); |
2445 | XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
2435 | am_transparent = am_pixmap_trans = 0; |
2446 | am_transparent = am_pixmap_trans = 0; |
2436 | } |
2447 | } |
2437 | |
2448 | |
2438 | return pchanged; /* Don't try any more */ |
2449 | return pchanged; /* Don't try any more */ |
2439 | } |
2450 | } |
2440 | |
2451 | |
2441 | /* 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. */ |
2442 | XSync (xdisp, False); |
2453 | XSync (dpy, False); |
2443 | |
2454 | |
2444 | /* |
2455 | /* |
2445 | * Make the frame window set by the window manager have |
2456 | * Make the frame window set by the window manager have |
2446 | * the root background. Some window managers put multiple nested frame |
2457 | * the root background. Some window managers put multiple nested frame |
2447 | * 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. |
2448 | */ |
2459 | */ |
2449 | i = (xa[XA_XROOTPMAP_ID] |
2460 | i = (xa[XA_XROOTPMAP_ID] |
2450 | && XGetWindowProperty (xdisp, display->root, xa[XA_XROOTPMAP_ID], |
2461 | && XGetWindowProperty (dpy, display->root, xa[XA_XROOTPMAP_ID], |
2451 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2462 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2452 | &nitems, &bytes_after, &prop) == Success); |
2463 | &nitems, &bytes_after, &prop) == Success); |
2453 | |
2464 | |
2454 | if (!i || prop == NULL) |
2465 | if (!i || prop == NULL) |
2455 | i = (xa[XA_ESETROOT_PMAP_ID] |
2466 | i = (xa[XA_ESETROOT_PMAP_ID] |
2456 | && XGetWindowProperty (xdisp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2467 | && XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID], |
2457 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2468 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2458 | &nitems, &bytes_after, &prop) == Success); |
2469 | &nitems, &bytes_after, &prop) == Success); |
2459 | |
2470 | |
2460 | if (!i || prop == NULL |
2471 | if (!i || prop == NULL |
2461 | #if TINTING |
2472 | #if TINTING |
… | |
… | |
2480 | Window cr; |
2491 | Window cr; |
2481 | XImage *image; |
2492 | XImage *image; |
2482 | GC gc; |
2493 | GC gc; |
2483 | XGCValues gcvalue; |
2494 | XGCValues gcvalue; |
2484 | |
2495 | |
2485 | XTranslateCoordinates (xdisp, parent[0], display->root, |
2496 | XTranslateCoordinates (dpy, parent[0], display->root, |
2486 | 0, 0, &sx, &sy, &cr); |
2497 | 0, 0, &sx, &sy, &cr); |
2487 | nw = (unsigned int)szHint.width; |
2498 | nw = (unsigned int)szHint.width; |
2488 | nh = (unsigned int)szHint.height; |
2499 | nh = (unsigned int)szHint.height; |
2489 | nx = ny = 0; |
2500 | nx = ny = 0; |
2490 | |
2501 | |
… | |
… | |
2503 | } |
2514 | } |
2504 | |
2515 | |
2505 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2516 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
2506 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2517 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
2507 | |
2518 | |
2508 | XSync (xdisp, False); |
2519 | XSync (dpy, False); |
2509 | allowedxerror = -1; |
2520 | allowedxerror = -1; |
2510 | image = XGetImage (xdisp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2521 | image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2511 | |
2522 | |
2512 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2523 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2513 | /* XXX: may need a delay here? */ |
2524 | /* XXX: may need a delay here? */ |
2514 | allowedxerror = 0; |
2525 | allowedxerror = 0; |
2515 | |
2526 | |
… | |
… | |
2518 | if (am_transparent && am_pixmap_trans) |
2529 | if (am_transparent && am_pixmap_trans) |
2519 | { |
2530 | { |
2520 | pchanged = 1; |
2531 | pchanged = 1; |
2521 | if (pixmap != None) |
2532 | if (pixmap != None) |
2522 | { |
2533 | { |
2523 | XFreePixmap (xdisp, pixmap); |
2534 | XFreePixmap (dpy, pixmap); |
2524 | pixmap = None; |
2535 | pixmap = None; |
2525 | } |
2536 | } |
2526 | } |
2537 | } |
2527 | |
2538 | |
2528 | am_pixmap_trans = 0; |
2539 | am_pixmap_trans = 0; |
2529 | } |
2540 | } |
2530 | else |
2541 | else |
2531 | { |
2542 | { |
2532 | if (pixmap != None) |
2543 | if (pixmap != None) |
2533 | XFreePixmap (xdisp, pixmap); |
2544 | XFreePixmap (dpy, pixmap); |
2534 | |
2545 | |
2535 | #if TINTING |
2546 | #if TINTING |
2536 | if (ISSET_PIXCOLOR (Color_tint)) |
2547 | if (ISSET_PIXCOLOR (Color_tint)) |
2537 | { |
2548 | { |
2538 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
2549 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
… | |
… | |
2542 | |
2553 | |
2543 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
2554 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
2544 | } |
2555 | } |
2545 | #endif |
2556 | #endif |
2546 | |
2557 | |
2547 | pixmap = XCreatePixmap (xdisp, vt, szHint.width, szHint.height, image->depth); |
2558 | pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth); |
2548 | gc = XCreateGC (xdisp, vt, 0UL, &gcvalue); |
2559 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
2549 | XPutImage (xdisp, pixmap, gc, image, 0, 0, |
2560 | XPutImage (dpy, pixmap, gc, image, 0, 0, |
2550 | nx, ny, image->width, image->height); |
2561 | nx, ny, image->width, image->height); |
2551 | XFreeGC (xdisp, gc); |
2562 | XFreeGC (dpy, gc); |
2552 | XDestroyImage (image); |
2563 | XDestroyImage (image); |
2553 | XSetWindowBackgroundPixmap (xdisp, parent[0], pixmap); |
2564 | XSetWindowBackgroundPixmap (dpy, parent[0], pixmap); |
2554 | XClearWindow (xdisp, parent[0]); |
2565 | XClearWindow (dpy, parent[0]); |
2555 | |
2566 | |
2556 | if (!am_transparent || !am_pixmap_trans) |
2567 | if (!am_transparent || !am_pixmap_trans) |
2557 | pchanged = 1; |
2568 | pchanged = 1; |
2558 | |
2569 | |
2559 | am_transparent = am_pixmap_trans = 1; |
2570 | am_transparent = am_pixmap_trans = 1; |
2560 | } |
2571 | } |
2561 | } |
2572 | } |
2562 | |
2573 | |
2563 | if (am_pixmap_trans) |
2574 | if (am_pixmap_trans) |
2564 | XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); |
2575 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
2565 | else |
2576 | else |
2566 | { |
2577 | { |
2567 | unsigned int n; |
2578 | unsigned int n; |
2568 | /* |
2579 | /* |
2569 | * InheritPixmap transparency |
2580 | * InheritPixmap transparency |
2570 | */ |
2581 | */ |
2571 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2582 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2572 | { |
2583 | { |
2573 | oldp = parent[i]; |
2584 | oldp = parent[i]; |
2574 | XQueryTree (xdisp, parent[i - 1], &root, &parent[i], &list, &n); |
2585 | XQueryTree (dpy, parent[i - 1], &root, &parent[i], &list, &n); |
2575 | XFree (list); |
2586 | XFree (list); |
2576 | |
2587 | |
2577 | if (parent[i] == display->root) |
2588 | if (parent[i] == display->root) |
2578 | { |
2589 | { |
2579 | if (oldp != None) |
2590 | if (oldp != None) |
… | |
… | |
2589 | n = 0; |
2600 | n = 0; |
2590 | |
2601 | |
2591 | if (pchanged) |
2602 | if (pchanged) |
2592 | for (; n < (unsigned int)i; n++) |
2603 | for (; n < (unsigned int)i; n++) |
2593 | { |
2604 | { |
2594 | XGetWindowAttributes (xdisp, parent[n], &wattr); |
2605 | XGetWindowAttributes (dpy, parent[n], &wattr); |
2595 | |
2606 | |
2596 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2607 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2597 | { |
2608 | { |
2598 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2609 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
2599 | break; |
2610 | break; |
2600 | } |
2611 | } |
2601 | } |
2612 | } |
2602 | |
2613 | |
2603 | if (n > (sizeof (parent) / sizeof (parent[0]))) |
2614 | if (n > (sizeof (parent) / sizeof (parent[0]))) |
2604 | { |
2615 | { |
2605 | XSetWindowBackground (xdisp, parent[0], pix_colors_focused[Color_border]); |
2616 | XSetWindowBackground (dpy, parent[0], pix_colors_focused[Color_border]); |
2606 | XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); |
2617 | XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
2607 | am_transparent = 0; |
2618 | am_transparent = 0; |
2608 | /* XXX: also turn off Opt_transparent? */ |
2619 | /* XXX: also turn off Opt_transparent? */ |
2609 | } |
2620 | } |
2610 | else |
2621 | else |
2611 | { |
2622 | { |
2612 | for (n = 0; n < (unsigned int)i; n++) |
2623 | for (n = 0; n < (unsigned int)i; n++) |
2613 | { |
2624 | { |
2614 | XSetWindowBackgroundPixmap (xdisp, parent[n], ParentRelative); |
2625 | XSetWindowBackgroundPixmap (dpy, parent[n], ParentRelative); |
2615 | XClearWindow (xdisp, parent[n]); |
2626 | XClearWindow (dpy, parent[n]); |
2616 | } |
2627 | } |
2617 | |
2628 | |
2618 | XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); |
2629 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
2619 | am_transparent = 1; |
2630 | am_transparent = 1; |
2620 | } |
2631 | } |
2621 | |
2632 | |
2622 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2633 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
2623 | parent[i] = None; |
2634 | parent[i] = None; |
2624 | } |
2635 | } |
2625 | |
2636 | |
2626 | if (scrollBar.win) |
2637 | if (scrollBar.win) |
2627 | { |
2638 | { |
2628 | XSetWindowBackgroundPixmap (xdisp, scrollBar.win, ParentRelative); |
2639 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
2629 | scrollBar.setIdle (); |
2640 | scrollBar.setIdle (); |
2630 | scrollbar_show (0); |
2641 | scrollbar_show (0); |
2631 | } |
2642 | } |
2632 | |
2643 | |
2633 | if (am_transparent) |
2644 | if (am_transparent) |
… | |
… | |
3524 | { |
3535 | { |
3525 | int x, y; |
3536 | int x, y; |
3526 | XWindowAttributes wattr; |
3537 | XWindowAttributes wattr; |
3527 | Window wdummy; |
3538 | Window wdummy; |
3528 | |
3539 | |
3529 | dLocal (Display *, xdisp); |
3540 | dLocal (Display *, dpy); |
3530 | |
3541 | |
3531 | if (nargs == 0) |
3542 | if (nargs == 0) |
3532 | return; |
3543 | return; |
3533 | |
3544 | |
3534 | switch (args[0]) |
3545 | switch (args[0]) |
3535 | { |
3546 | { |
3536 | /* |
3547 | /* |
3537 | * commands |
3548 | * commands |
3538 | */ |
3549 | */ |
3539 | case 1: /* deiconify window */ |
3550 | case 1: /* deiconify window */ |
3540 | XMapWindow (xdisp, parent[0]); |
3551 | XMapWindow (dpy, parent[0]); |
3541 | break; |
3552 | break; |
3542 | case 2: /* iconify window */ |
3553 | case 2: /* iconify window */ |
3543 | XIconifyWindow (xdisp, parent[0], display->screen); |
3554 | XIconifyWindow (dpy, parent[0], display->screen); |
3544 | break; |
3555 | break; |
3545 | case 3: /* set position (pixels) */ |
3556 | case 3: /* set position (pixels) */ |
3546 | XMoveWindow (xdisp, parent[0], args[1], args[2]); |
3557 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3547 | break; |
3558 | break; |
3548 | case 4: /* set size (pixels) */ |
3559 | case 4: /* set size (pixels) */ |
3549 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3560 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3550 | break; |
3561 | break; |
3551 | case 5: /* raise window */ |
3562 | case 5: /* raise window */ |
3552 | XRaiseWindow (xdisp, parent[0]); |
3563 | XRaiseWindow (dpy, parent[0]); |
3553 | break; |
3564 | break; |
3554 | case 6: /* lower window */ |
3565 | case 6: /* lower window */ |
3555 | XLowerWindow (xdisp, parent[0]); |
3566 | XLowerWindow (dpy, parent[0]); |
3556 | break; |
3567 | break; |
3557 | case 7: /* refresh window */ |
3568 | case 7: /* refresh window */ |
3558 | scr_touch (true); |
3569 | scr_touch (true); |
3559 | break; |
3570 | break; |
3560 | case 8: /* set size (chars) */ |
3571 | case 8: /* set size (chars) */ |
… | |
… | |
3571 | |
3582 | |
3572 | /* |
3583 | /* |
3573 | * reports - some output format copied from XTerm |
3584 | * reports - some output format copied from XTerm |
3574 | */ |
3585 | */ |
3575 | case 11: /* report window state */ |
3586 | case 11: /* report window state */ |
3576 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3587 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3577 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3588 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3578 | break; |
3589 | break; |
3579 | case 13: /* report window position */ |
3590 | case 13: /* report window position */ |
3580 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3591 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3581 | XTranslateCoordinates (xdisp, parent[0], wattr.root, |
3592 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3582 | -wattr.border_width, -wattr.border_width, |
3593 | -wattr.border_width, -wattr.border_width, |
3583 | &x, &y, &wdummy); |
3594 | &x, &y, &wdummy); |
3584 | tt_printf ("\033[3;%d;%dt", x, y); |
3595 | tt_printf ("\033[3;%d;%dt", x, y); |
3585 | break; |
3596 | break; |
3586 | case 14: /* report window size (pixels) */ |
3597 | case 14: /* report window size (pixels) */ |
3587 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3598 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3588 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3599 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3589 | break; |
3600 | break; |
3590 | case 18: /* report text area size (chars) */ |
3601 | case 18: /* report text area size (chars) */ |
3591 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3602 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3592 | break; |
3603 | break; |
… | |
… | |
3594 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3605 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3595 | break; |
3606 | break; |
3596 | case 20: /* report icon label */ |
3607 | case 20: /* report icon label */ |
3597 | { |
3608 | { |
3598 | char *s; |
3609 | char *s; |
3599 | XGetIconName (xdisp, parent[0], &s); |
3610 | XGetIconName (dpy, parent[0], &s); |
3600 | 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 */ |
3601 | XFree (s); |
3612 | XFree (s); |
3602 | } |
3613 | } |
3603 | break; |
3614 | break; |
3604 | case 21: /* report window title */ |
3615 | case 21: /* report window title */ |
3605 | { |
3616 | { |
3606 | char *s; |
3617 | char *s; |
3607 | XFetchName (xdisp, parent[0], &s); |
3618 | XFetchName (dpy, parent[0], &s); |
3608 | 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 */ |
3609 | XFree (s); |
3620 | XFree (s); |
3610 | } |
3621 | } |
3611 | break; |
3622 | break; |
3612 | } |
3623 | } |
… | |
… | |
3738 | int color; |
3749 | int color; |
3739 | char *buf, *name; |
3750 | char *buf, *name; |
3740 | bool query = str[0] == '?' && !str[1]; |
3751 | bool query = str[0] == '?' && !str[1]; |
3741 | int saveop = op; |
3752 | int saveop = op; |
3742 | |
3753 | |
3743 | dLocal (Display *, xdisp); |
3754 | dLocal (Display *, dpy); |
3744 | |
3755 | |
3745 | assert (str != NULL); |
3756 | assert (str != NULL); |
3746 | switch (op) |
3757 | switch (op) |
3747 | { |
3758 | { |
3748 | case XTerm_name: |
3759 | case XTerm_name: |
… | |
… | |
3764 | unsigned long bytes_after; |
3775 | unsigned long bytes_after; |
3765 | unsigned char *value = 0; |
3776 | unsigned char *value = 0; |
3766 | const char *str = ""; |
3777 | const char *str = ""; |
3767 | |
3778 | |
3768 | if (prop |
3779 | if (prop |
3769 | && XGetWindowProperty (xdisp, parent[0], |
3780 | && XGetWindowProperty (dpy, parent[0], |
3770 | prop, 0, 1<<16, 0, AnyPropertyType, |
3781 | prop, 0, 1<<16, 0, AnyPropertyType, |
3771 | &actual_type, &actual_format, |
3782 | &actual_type, &actual_format, |
3772 | &nitems, &bytes_after, &value) == Success |
3783 | &nitems, &bytes_after, &value) == Success |
3773 | && actual_type != None |
3784 | && actual_type != None |
3774 | && actual_format == 8) |
3785 | && actual_format == 8) |
… | |
… | |
3786 | { |
3797 | { |
3787 | *eq = 0; |
3798 | *eq = 0; |
3788 | set_utf8_property (display->atom (str), eq + 1); |
3799 | set_utf8_property (display->atom (str), eq + 1); |
3789 | } |
3800 | } |
3790 | else |
3801 | else |
3791 | XDeleteProperty (xdisp, parent[0], |
3802 | XDeleteProperty (dpy, parent[0], |
3792 | display->atom (str)); |
3803 | display->atom (str)); |
3793 | } |
3804 | } |
3794 | break; |
3805 | break; |
3795 | |
3806 | |
3796 | case XTerm_Color: |
3807 | case XTerm_Color: |