ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.301 by root, Tue Jan 31 21:23:13 2006 UTC vs.
Revision 1.305 by root, Thu Feb 2 18:04:45 2006 UTC

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
1090 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1094 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
1091 } 1095 }
1092} 1096}
1093#endif 1097#endif
1094 1098
1099#if LINUX_YIELD_HACK
1100static struct event_handler
1101{
1102 check_watcher yield_ev;
1103
1104 void yield_cb (check_watcher &w)
1105 {
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
1114 w.stop ();
1115 }
1116
1117 event_handler ()
1118 : yield_ev (this, &event_handler::yield_cb)
1119 {
1120 }
1121} event_handler;
1122#endif
1123
1095bool 1124bool
1096rxvt_term::pty_fill () 1125rxvt_term::pty_fill ()
1097{ 1126{
1098 ssize_t n = cmdbuf_endp - cmdbuf_ptr; 1127 ssize_t n = cmdbuf_endp - cmdbuf_ptr;
1099 1128
1114 cmdbuf_endp += r; 1143 cmdbuf_endp += r;
1115 return true; 1144 return true;
1116 } 1145 }
1117 else if (r < 0 && (errno == EAGAIN || errno == EINTR)) 1146 else if (r < 0 && (errno == EAGAIN || errno == EINTR))
1118 { 1147 {
1119#if HAVE_SCHED_YIELD 1148#if LINUX_YIELD_HACK
1120 if (display->is_local) 1149 if (display->is_local)
1121 event_handler.cw_yield.start (); 1150 event_handler.yield_ev.start ();
1122#endif 1151#endif
1123 } 1152 }
1124 else 1153 else
1125 { 1154 {
1126 pty_ev.stop (); 1155 pty_ev.stop ();
1148} 1177}
1149 1178
1150void 1179void
1151rxvt_term::pointer_unblank () 1180rxvt_term::pointer_unblank ()
1152{ 1181{
1153 XDefineCursor (xdisp, vt, TermWin_cursor); 1182 XDefineCursor (dpy, vt, TermWin_cursor);
1154 recolour_cursor (); 1183 recolour_cursor ();
1155 1184
1156#ifdef POINTER_BLANK 1185#ifdef POINTER_BLANK
1157 hidden_pointer = 0; 1186 hidden_pointer = 0;
1158 1187
1166rxvt_term::pointer_blank () 1195rxvt_term::pointer_blank ()
1167{ 1196{
1168 if (!OPTION (Opt_pointerBlank)) 1197 if (!OPTION (Opt_pointerBlank))
1169 return; 1198 return;
1170 1199
1171 XDefineCursor (xdisp, vt, display->blank_cursor); 1200 XDefineCursor (dpy, vt, display->blank_cursor);
1172 XFlush (xdisp); 1201 XFlush (dpy);
1173 1202
1174 hidden_pointer = 1; 1203 hidden_pointer = 1;
1175} 1204}
1176 1205
1177void 1206void
1256void 1285void
1257rxvt_term::x_cb (XEvent &ev) 1286rxvt_term::x_cb (XEvent &ev)
1258{ 1287{
1259 make_current (); 1288 make_current ();
1260 1289
1261 dLocal (Display *, xdisp); 1290 dLocal (Display *, dpy);
1262 1291
1263 if (ev.xany.window == vt 1292 if (ev.xany.window == vt
1264 && SHOULD_INVOKE (HOOK_X_EVENT) 1293 && SHOULD_INVOKE (HOOK_X_EVENT)
1265 && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) 1294 && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END)))
1266 return; 1295 return;
1376 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)))
1377 destroy (); 1406 destroy ();
1378 } 1407 }
1379#if ENABLE_EWMH 1408#if ENABLE_EWMH
1380 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])
1381 XSendEvent (xdisp, ev.xclient.window = display->root, 1410 XSendEvent (dpy, ev.xclient.window = display->root,
1382 False, SubstructureRedirectMask | SubstructureNotifyMask, 1411 False, SubstructureRedirectMask | SubstructureNotifyMask,
1383 &ev); 1412 &ev);
1384#endif 1413#endif
1385 } 1414 }
1386 } 1415 }
1434 break; 1463 break;
1435 1464
1436 case ConfigureNotify: 1465 case ConfigureNotify:
1437 if (ev.xconfigure.window == parent[0]) 1466 if (ev.xconfigure.window == parent[0])
1438 { 1467 {
1439 while (XCheckTypedWindowEvent (xdisp, ev.xconfigure.window, ConfigureNotify, &ev)) 1468 while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev))
1440 ; 1469 ;
1441 1470
1442 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) 1471 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height)
1443 { 1472 {
1444 seen_resize = 1; 1473 seen_resize = 1;
1502 if (ev.xany.window == vt) 1531 if (ev.xany.window == vt)
1503 { 1532 {
1504 do 1533 do
1505 scr_expose (ev.xexpose.x, ev.xexpose.y, 1534 scr_expose (ev.xexpose.x, ev.xexpose.y,
1506 ev.xexpose.width, ev.xexpose.height, False); 1535 ev.xexpose.width, ev.xexpose.height, False);
1507 while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)); 1536 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev));
1508 1537
1509 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; 1538 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose;
1510 1539
1511 while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)) 1540 while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev))
1512 scr_expose (ev.xexpose.x, ev.xexpose.y, 1541 scr_expose (ev.xexpose.x, ev.xexpose.y,
1513 ev.xexpose.width, ev.xexpose.height, False); 1542 ev.xexpose.width, ev.xexpose.height, False);
1514 1543
1515 want_refresh = 1; 1544 want_refresh = 1;
1516 } 1545 }
1517 else 1546 else
1518 { 1547 {
1519 XEvent unused_event; 1548 XEvent unused_event;
1520 1549
1521 while (XCheckTypedWindowEvent (xdisp, ev.xany.window, Expose, &unused_event)) 1550 while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event))
1522 ; 1551 ;
1523 while (XCheckTypedWindowEvent (xdisp, ev.xany.window, GraphicsExpose, &unused_event)) 1552 while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event))
1524 ; 1553 ;
1525 1554
1526 if (isScrollbarWindow (ev.xany.window)) 1555 if (isScrollbarWindow (ev.xany.window))
1527 { 1556 {
1528 scrollBar.setIdle (); 1557 scrollBar.setIdle ();
1529 scrollbar_show (0); 1558 scrollbar_show (0);
1530 } 1559 }
1531 1560
1532#ifdef TRANSPARENT 1561#ifdef TRANSPARENT
1533 if (am_transparent && ev.xany.window == parent[0]) 1562 if (am_transparent && ev.xany.window == parent[0])
1534 XClearWindow (xdisp, ev.xany.window); 1563 XClearWindow (dpy, ev.xany.window);
1535#endif 1564#endif
1536 } 1565 }
1537 break; 1566 break;
1538 1567
1539 case MotionNotify: 1568 case MotionNotify:
1549 if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) 1578 if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY)
1550 && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) 1579 && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END)))
1551 ; // nop 1580 ; // nop
1552 else if (ev.xbutton.state & (Button1Mask | Button3Mask)) 1581 else if (ev.xbutton.state & (Button1Mask | Button3Mask))
1553 { 1582 {
1554 while (XCheckTypedWindowEvent (xdisp, vt, MotionNotify, &ev)) 1583 while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev))
1555 ; 1584 ;
1556 1585
1557 XQueryPointer (xdisp, vt, 1586 XQueryPointer (dpy, vt,
1558 &unused_root, &unused_child, 1587 &unused_root, &unused_child,
1559 &unused_root_x, &unused_root_y, 1588 &unused_root_x, &unused_root_y,
1560 &ev.xbutton.x, &ev.xbutton.y, 1589 &ev.xbutton.x, &ev.xbutton.y,
1561 &ev.xbutton.state); 1590 &ev.xbutton.state);
1562#ifdef MOUSE_THRESHOLD 1591#ifdef MOUSE_THRESHOLD
1626#endif 1655#endif
1627 } 1656 }
1628 } 1657 }
1629 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) 1658 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ())
1630 { 1659 {
1631 while (XCheckTypedWindowEvent (xdisp, scrollBar.win, 1660 while (XCheckTypedWindowEvent (dpy, scrollBar.win,
1632 MotionNotify, &ev)) 1661 MotionNotify, &ev))
1633 ; 1662 ;
1634 1663
1635 XQueryPointer (xdisp, scrollBar.win, 1664 XQueryPointer (dpy, scrollBar.win,
1636 &unused_root, &unused_child, 1665 &unused_root, &unused_child,
1637 &unused_root_x, &unused_root_y, 1666 &unused_root_x, &unused_root_y,
1638 &ev.xbutton.x, &ev.xbutton.y, 1667 &ev.xbutton.x, &ev.xbutton.y,
1639 &unused_mask); 1668 &unused_mask);
1640 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1669 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
2401 pchanged = 0; 2430 pchanged = 0;
2402 2431
2403 if (!OPTION (Opt_transparent)) 2432 if (!OPTION (Opt_transparent))
2404 return pchanged; /* Don't try any more */ 2433 return pchanged; /* Don't try any more */
2405 2434
2406 XGetWindowAttributes (xdisp, display->root, &wrootattr); 2435 XGetWindowAttributes (dpy, display->root, &wrootattr);
2407 rootdepth = wrootattr.depth; 2436 rootdepth = wrootattr.depth;
2408 2437
2409 XGetWindowAttributes (xdisp, parent[0], &wattr); 2438 XGetWindowAttributes (dpy, parent[0], &wattr);
2410 2439
2411 if (rootdepth != wattr.depth) 2440 if (rootdepth != wattr.depth)
2412 { 2441 {
2413 if (am_transparent) 2442 if (am_transparent)
2414 { 2443 {
2415 pchanged = 1; 2444 pchanged = 1;
2416 XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); 2445 XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]);
2417 am_transparent = am_pixmap_trans = 0; 2446 am_transparent = am_pixmap_trans = 0;
2418 } 2447 }
2419 2448
2420 return pchanged; /* Don't try any more */ 2449 return pchanged; /* Don't try any more */
2421 } 2450 }
2422 2451
2423 /* 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. */
2424 XSync (xdisp, False); 2453 XSync (dpy, False);
2425 2454
2426 /* 2455 /*
2427 * Make the frame window set by the window manager have 2456 * Make the frame window set by the window manager have
2428 * the root background. Some window managers put multiple nested frame 2457 * the root background. Some window managers put multiple nested frame
2429 * 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.
2430 */ 2459 */
2431 i = (xa[XA_XROOTPMAP_ID] 2460 i = (xa[XA_XROOTPMAP_ID]
2432 && XGetWindowProperty (xdisp, display->root, xa[XA_XROOTPMAP_ID], 2461 && XGetWindowProperty (dpy, display->root, xa[XA_XROOTPMAP_ID],
2433 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 2462 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2434 &nitems, &bytes_after, &prop) == Success); 2463 &nitems, &bytes_after, &prop) == Success);
2435 2464
2436 if (!i || prop == NULL) 2465 if (!i || prop == NULL)
2437 i = (xa[XA_ESETROOT_PMAP_ID] 2466 i = (xa[XA_ESETROOT_PMAP_ID]
2438 && XGetWindowProperty (xdisp, display->root, xa[XA_ESETROOT_PMAP_ID], 2467 && XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID],
2439 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 2468 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2440 &nitems, &bytes_after, &prop) == Success); 2469 &nitems, &bytes_after, &prop) == Success);
2441 2470
2442 if (!i || prop == NULL 2471 if (!i || prop == NULL
2443#if TINTING 2472#if TINTING
2462 Window cr; 2491 Window cr;
2463 XImage *image; 2492 XImage *image;
2464 GC gc; 2493 GC gc;
2465 XGCValues gcvalue; 2494 XGCValues gcvalue;
2466 2495
2467 XTranslateCoordinates (xdisp, parent[0], display->root, 2496 XTranslateCoordinates (dpy, parent[0], display->root,
2468 0, 0, &sx, &sy, &cr); 2497 0, 0, &sx, &sy, &cr);
2469 nw = (unsigned int)szHint.width; 2498 nw = (unsigned int)szHint.width;
2470 nh = (unsigned int)szHint.height; 2499 nh = (unsigned int)szHint.height;
2471 nx = ny = 0; 2500 nx = ny = 0;
2472 2501
2485 } 2514 }
2486 2515
2487 min_it (nw, (unsigned int) (wrootattr.width - sx)); 2516 min_it (nw, (unsigned int) (wrootattr.width - sx));
2488 min_it (nh, (unsigned int) (wrootattr.height - sy)); 2517 min_it (nh, (unsigned int) (wrootattr.height - sy));
2489 2518
2490 XSync (xdisp, False); 2519 XSync (dpy, False);
2491 allowedxerror = -1; 2520 allowedxerror = -1;
2492 image = XGetImage (xdisp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); 2521 image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
2493 2522
2494 /* XXX: handle BadMatch - usually because we're outside the pixmap */ 2523 /* XXX: handle BadMatch - usually because we're outside the pixmap */
2495 /* XXX: may need a delay here? */ 2524 /* XXX: may need a delay here? */
2496 allowedxerror = 0; 2525 allowedxerror = 0;
2497 2526
2500 if (am_transparent && am_pixmap_trans) 2529 if (am_transparent && am_pixmap_trans)
2501 { 2530 {
2502 pchanged = 1; 2531 pchanged = 1;
2503 if (pixmap != None) 2532 if (pixmap != None)
2504 { 2533 {
2505 XFreePixmap (xdisp, pixmap); 2534 XFreePixmap (dpy, pixmap);
2506 pixmap = None; 2535 pixmap = None;
2507 } 2536 }
2508 } 2537 }
2509 2538
2510 am_pixmap_trans = 0; 2539 am_pixmap_trans = 0;
2511 } 2540 }
2512 else 2541 else
2513 { 2542 {
2514 if (pixmap != None) 2543 if (pixmap != None)
2515 XFreePixmap (xdisp, pixmap); 2544 XFreePixmap (dpy, pixmap);
2516 2545
2517#if TINTING 2546#if TINTING
2518 if (ISSET_PIXCOLOR (Color_tint)) 2547 if (ISSET_PIXCOLOR (Color_tint))
2519 { 2548 {
2520 int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; 2549 int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
2524 2553
2525 ShadeXImage (this, image, shade, c.r, c.g, c.b); 2554 ShadeXImage (this, image, shade, c.r, c.g, c.b);
2526 } 2555 }
2527#endif 2556#endif
2528 2557
2529 pixmap = XCreatePixmap (xdisp, vt, szHint.width, szHint.height, image->depth); 2558 pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth);
2530 gc = XCreateGC (xdisp, vt, 0UL, &gcvalue); 2559 gc = XCreateGC (dpy, vt, 0UL, &gcvalue);
2531 XPutImage (xdisp, pixmap, gc, image, 0, 0, 2560 XPutImage (dpy, pixmap, gc, image, 0, 0,
2532 nx, ny, image->width, image->height); 2561 nx, ny, image->width, image->height);
2533 XFreeGC (xdisp, gc); 2562 XFreeGC (dpy, gc);
2534 XDestroyImage (image); 2563 XDestroyImage (image);
2535 XSetWindowBackgroundPixmap (xdisp, parent[0], pixmap); 2564 XSetWindowBackgroundPixmap (dpy, parent[0], pixmap);
2536 XClearWindow (xdisp, parent[0]); 2565 XClearWindow (dpy, parent[0]);
2537 2566
2538 if (!am_transparent || !am_pixmap_trans) 2567 if (!am_transparent || !am_pixmap_trans)
2539 pchanged = 1; 2568 pchanged = 1;
2540 2569
2541 am_transparent = am_pixmap_trans = 1; 2570 am_transparent = am_pixmap_trans = 1;
2542 } 2571 }
2543 } 2572 }
2544 2573
2545 if (am_pixmap_trans) 2574 if (am_pixmap_trans)
2546 XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); 2575 XSetWindowBackgroundPixmap (dpy, vt, ParentRelative);
2547 else 2576 else
2548 { 2577 {
2549 unsigned int n; 2578 unsigned int n;
2550 /* 2579 /*
2551 * InheritPixmap transparency 2580 * InheritPixmap transparency
2552 */ 2581 */
2553 for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) 2582 for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++)
2554 { 2583 {
2555 oldp = parent[i]; 2584 oldp = parent[i];
2556 XQueryTree (xdisp, parent[i - 1], &root, &parent[i], &list, &n); 2585 XQueryTree (dpy, parent[i - 1], &root, &parent[i], &list, &n);
2557 XFree (list); 2586 XFree (list);
2558 2587
2559 if (parent[i] == display->root) 2588 if (parent[i] == display->root)
2560 { 2589 {
2561 if (oldp != None) 2590 if (oldp != None)
2571 n = 0; 2600 n = 0;
2572 2601
2573 if (pchanged) 2602 if (pchanged)
2574 for (; n < (unsigned int)i; n++) 2603 for (; n < (unsigned int)i; n++)
2575 { 2604 {
2576 XGetWindowAttributes (xdisp, parent[n], &wattr); 2605 XGetWindowAttributes (dpy, parent[n], &wattr);
2577 2606
2578 if (wattr.depth != rootdepth || wattr.c_class == InputOnly) 2607 if (wattr.depth != rootdepth || wattr.c_class == InputOnly)
2579 { 2608 {
2580 n = (int) (sizeof (parent) / sizeof (Window)) + 1; 2609 n = (int) (sizeof (parent) / sizeof (Window)) + 1;
2581 break; 2610 break;
2582 } 2611 }
2583 } 2612 }
2584 2613
2585 if (n > (sizeof (parent) / sizeof (parent[0]))) 2614 if (n > (sizeof (parent) / sizeof (parent[0])))
2586 { 2615 {
2587 XSetWindowBackground (xdisp, parent[0], pix_colors_focused[Color_border]); 2616 XSetWindowBackground (dpy, parent[0], pix_colors_focused[Color_border]);
2588 XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); 2617 XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]);
2589 am_transparent = 0; 2618 am_transparent = 0;
2590 /* XXX: also turn off Opt_transparent? */ 2619 /* XXX: also turn off Opt_transparent? */
2591 } 2620 }
2592 else 2621 else
2593 { 2622 {
2594 for (n = 0; n < (unsigned int)i; n++) 2623 for (n = 0; n < (unsigned int)i; n++)
2595 { 2624 {
2596 XSetWindowBackgroundPixmap (xdisp, parent[n], ParentRelative); 2625 XSetWindowBackgroundPixmap (dpy, parent[n], ParentRelative);
2597 XClearWindow (xdisp, parent[n]); 2626 XClearWindow (dpy, parent[n]);
2598 } 2627 }
2599 2628
2600 XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); 2629 XSetWindowBackgroundPixmap (dpy, vt, ParentRelative);
2601 am_transparent = 1; 2630 am_transparent = 1;
2602 } 2631 }
2603 2632
2604 for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) 2633 for (; i < (int) (sizeof (parent) / sizeof (Window)); i++)
2605 parent[i] = None; 2634 parent[i] = None;
2606 } 2635 }
2607 2636
2608 if (scrollBar.win) 2637 if (scrollBar.win)
2609 { 2638 {
2610 XSetWindowBackgroundPixmap (xdisp, scrollBar.win, ParentRelative); 2639 XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative);
2611 scrollBar.setIdle (); 2640 scrollBar.setIdle ();
2612 scrollbar_show (0); 2641 scrollbar_show (0);
2613 } 2642 }
2614 2643
2615 if (am_transparent) 2644 if (am_transparent)
3506{ 3535{
3507 int x, y; 3536 int x, y;
3508 XWindowAttributes wattr; 3537 XWindowAttributes wattr;
3509 Window wdummy; 3538 Window wdummy;
3510 3539
3511 dLocal (Display *, xdisp); 3540 dLocal (Display *, dpy);
3512 3541
3513 if (nargs == 0) 3542 if (nargs == 0)
3514 return; 3543 return;
3515 3544
3516 switch (args[0]) 3545 switch (args[0])
3517 { 3546 {
3518 /* 3547 /*
3519 * commands 3548 * commands
3520 */ 3549 */
3521 case 1: /* deiconify window */ 3550 case 1: /* deiconify window */
3522 XMapWindow (xdisp, parent[0]); 3551 XMapWindow (dpy, parent[0]);
3523 break; 3552 break;
3524 case 2: /* iconify window */ 3553 case 2: /* iconify window */
3525 XIconifyWindow (xdisp, parent[0], display->screen); 3554 XIconifyWindow (dpy, parent[0], display->screen);
3526 break; 3555 break;
3527 case 3: /* set position (pixels) */ 3556 case 3: /* set position (pixels) */
3528 XMoveWindow (xdisp, parent[0], args[1], args[2]); 3557 XMoveWindow (dpy, parent[0], args[1], args[2]);
3529 break; 3558 break;
3530 case 4: /* set size (pixels) */ 3559 case 4: /* set size (pixels) */
3531 set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); 3560 set_widthheight ((unsigned int)args[2], (unsigned int)args[1]);
3532 break; 3561 break;
3533 case 5: /* raise window */ 3562 case 5: /* raise window */
3534 XRaiseWindow (xdisp, parent[0]); 3563 XRaiseWindow (dpy, parent[0]);
3535 break; 3564 break;
3536 case 6: /* lower window */ 3565 case 6: /* lower window */
3537 XLowerWindow (xdisp, parent[0]); 3566 XLowerWindow (dpy, parent[0]);
3538 break; 3567 break;
3539 case 7: /* refresh window */ 3568 case 7: /* refresh window */
3540 scr_touch (true); 3569 scr_touch (true);
3541 break; 3570 break;
3542 case 8: /* set size (chars) */ 3571 case 8: /* set size (chars) */
3553 3582
3554 /* 3583 /*
3555 * reports - some output format copied from XTerm 3584 * reports - some output format copied from XTerm
3556 */ 3585 */
3557 case 11: /* report window state */ 3586 case 11: /* report window state */
3558 XGetWindowAttributes (xdisp, parent[0], &wattr); 3587 XGetWindowAttributes (dpy, parent[0], &wattr);
3559 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); 3588 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2);
3560 break; 3589 break;
3561 case 13: /* report window position */ 3590 case 13: /* report window position */
3562 XGetWindowAttributes (xdisp, parent[0], &wattr); 3591 XGetWindowAttributes (dpy, parent[0], &wattr);
3563 XTranslateCoordinates (xdisp, parent[0], wattr.root, 3592 XTranslateCoordinates (dpy, parent[0], wattr.root,
3564 -wattr.border_width, -wattr.border_width, 3593 -wattr.border_width, -wattr.border_width,
3565 &x, &y, &wdummy); 3594 &x, &y, &wdummy);
3566 tt_printf ("\033[3;%d;%dt", x, y); 3595 tt_printf ("\033[3;%d;%dt", x, y);
3567 break; 3596 break;
3568 case 14: /* report window size (pixels) */ 3597 case 14: /* report window size (pixels) */
3569 XGetWindowAttributes (xdisp, parent[0], &wattr); 3598 XGetWindowAttributes (dpy, parent[0], &wattr);
3570 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); 3599 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width);
3571 break; 3600 break;
3572 case 18: /* report text area size (chars) */ 3601 case 18: /* report text area size (chars) */
3573 tt_printf ("\033[8;%d;%dt", nrow, ncol); 3602 tt_printf ("\033[8;%d;%dt", nrow, ncol);
3574 break; 3603 break;
3576 tt_printf ("\033[9;%d;%dt", nrow, ncol); 3605 tt_printf ("\033[9;%d;%dt", nrow, ncol);
3577 break; 3606 break;
3578 case 20: /* report icon label */ 3607 case 20: /* report icon label */
3579 { 3608 {
3580 char *s; 3609 char *s;
3581 XGetIconName (xdisp, parent[0], &s); 3610 XGetIconName (dpy, parent[0], &s);
3582 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 */
3583 XFree (s); 3612 XFree (s);
3584 } 3613 }
3585 break; 3614 break;
3586 case 21: /* report window title */ 3615 case 21: /* report window title */
3587 { 3616 {
3588 char *s; 3617 char *s;
3589 XFetchName (xdisp, parent[0], &s); 3618 XFetchName (dpy, parent[0], &s);
3590 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 */
3591 XFree (s); 3620 XFree (s);
3592 } 3621 }
3593 break; 3622 break;
3594 } 3623 }
3720 int color; 3749 int color;
3721 char *buf, *name; 3750 char *buf, *name;
3722 bool query = str[0] == '?' && !str[1]; 3751 bool query = str[0] == '?' && !str[1];
3723 int saveop = op; 3752 int saveop = op;
3724 3753
3725 dLocal (Display *, xdisp); 3754 dLocal (Display *, dpy);
3726 3755
3727 assert (str != NULL); 3756 assert (str != NULL);
3728 switch (op) 3757 switch (op)
3729 { 3758 {
3730 case XTerm_name: 3759 case XTerm_name:
3746 unsigned long bytes_after; 3775 unsigned long bytes_after;
3747 unsigned char *value = 0; 3776 unsigned char *value = 0;
3748 const char *str = ""; 3777 const char *str = "";
3749 3778
3750 if (prop 3779 if (prop
3751 && XGetWindowProperty (xdisp, parent[0], 3780 && XGetWindowProperty (dpy, parent[0],
3752 prop, 0, 1<<16, 0, AnyPropertyType, 3781 prop, 0, 1<<16, 0, AnyPropertyType,
3753 &actual_type, &actual_format, 3782 &actual_type, &actual_format,
3754 &nitems, &bytes_after, &value) == Success 3783 &nitems, &bytes_after, &value) == Success
3755 && actual_type != None 3784 && actual_type != None
3756 && actual_format == 8) 3785 && actual_format == 8)
3768 { 3797 {
3769 *eq = 0; 3798 *eq = 0;
3770 set_utf8_property (display->atom (str), eq + 1); 3799 set_utf8_property (display->atom (str), eq + 1);
3771 } 3800 }
3772 else 3801 else
3773 XDeleteProperty (xdisp, parent[0], 3802 XDeleteProperty (dpy, parent[0],
3774 display->atom (str)); 3803 display->atom (str));
3775 } 3804 }
3776 break; 3805 break;
3777 3806
3778 case XTerm_Color: 3807 case XTerm_Color:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines