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.179 by root, Wed Dec 15 05:39:08 2004 UTC vs.
Revision 1.194 by root, Mon Feb 14 10:44:50 2005 UTC

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 <wchar.h> 53#ifdef KEYSYM_RESOURCE
54# include "keyboard.h"
55#endif
56
54#include <signal.h> 57#include <csignal>
55 58
56/*----------------------------------------------------------------------*/ 59/*----------------------------------------------------------------------*/
57 60
58#define IS_CONTROL(ch) !((ch) & 0xffffff60UL) 61#define IS_CONTROL(ch) !((ch) & 0xffffff60UL)
59 62
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
788#undef FKEY 771#undef FKEY
789 default: 772 default:
790 newlen = 0; 773 newlen = 0;
791 break; 774 break;
792 } 775 }
776
793 if (newlen) 777 if (newlen)
794 len = strlen (kbuf); 778 len = strlen (kbuf);
795 } 779 }
796 780
797 /* 781 /*
805 } 789 }
806 else if (ctrl && keysym == XK_minus) 790 else if (ctrl && keysym == XK_minus)
807 { 791 {
808 len = 1; 792 len = 1;
809 kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ 793 kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */
794 }
795 else if (keysym == XK_ISO_Left_Tab)
796 {
797 strcpy (kbuf, "\033[Z");
798 len = 3;
810 } 799 }
811 else 800 else
812 { 801 {
813#ifdef META8_OPTION 802#ifdef META8_OPTION
814 /* set 8-bit on */ 803 /* set 8-bit on */
873#endif /* DEBUG_CMD */ 862#endif /* DEBUG_CMD */
874 tt_write (kbuf, (unsigned int)len); 863 tt_write (kbuf, (unsigned int)len);
875} 864}
876/*}}} */ 865/*}}} */
877 866
878#if (MENUBAR_MAX) 867#if MENUBAR_MAX || defined (KEYSYM_RESOURCE)
879/*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ 868/*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */
880/* attempt to `write' count to the input buffer */ 869/* attempt to `write' count to the input buffer */
881unsigned int 870unsigned int
882rxvt_term::cmd_write (const unsigned char *str, unsigned int count) 871rxvt_term::cmd_write (const unsigned char *str, unsigned int count)
883{ 872{
906 895
907 cmd_parse (); 896 cmd_parse ();
908 897
909 return 0; 898 return 0;
910} 899}
911#endif /* MENUBAR_MAX */ 900#endif
912 901
913void 902void
914rxvt_term::flush () 903rxvt_term::flush ()
915{ 904{
916 flush_ev.stop (); 905 flush_ev.stop ();
1017{ 1006{
1018 if (mouse_slip_wheel_speed == 0 1007 if (mouse_slip_wheel_speed == 0
1019 || 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)
1020 : scr_page (UP, mouse_slip_wheel_speed)) 1009 : scr_page (UP, mouse_slip_wheel_speed))
1021 { 1010 {
1011 if (TermWin.view_start == TermWin.nscrolled ||
1012 TermWin.view_start == 0)
1013 mouse_slip_wheel_speed = 0;
1014
1022 refresh_type |= SMOOTH_REFRESH; 1015 refresh_type |= SMOOTH_REFRESH;
1023 want_refresh = 1; 1016 want_refresh = 1;
1024 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); 1017 w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY);
1025 } 1018 }
1026} 1019}
1089rxvt_term::pointer_blank () 1082rxvt_term::pointer_blank ()
1090{ 1083{
1091 if (! (options & Opt_pointerBlank)) 1084 if (! (options & Opt_pointerBlank))
1092 return; 1085 return;
1093 1086
1094 XDefineCursor (display->display, TermWin.vt, blank_cursor); 1087 XDefineCursor (display->display, TermWin.vt, display->blank_cursor);
1095 XFlush (display->display); 1088 XFlush (display->display);
1096 1089
1097 hidden_pointer = 1; 1090 hidden_pointer = 1;
1098} 1091}
1099 1092
1188 1181
1189/*{{{ process an X event */ 1182/*{{{ process an X event */
1190void 1183void
1191rxvt_term::x_cb (XEvent &ev) 1184rxvt_term::x_cb (XEvent &ev)
1192{ 1185{
1186 dDisp;
1187
1193 SET_R (this); 1188 SET_R (this);
1194 SET_LOCALE (locale); 1189 SET_LOCALE (locale);
1195 1190
1196#if defined(CURSOR_BLINK) 1191#if defined(CURSOR_BLINK)
1197 if ((options & Opt_cursorBlink) && ev.type == KeyPress) 1192 if ((options & Opt_cursorBlink) && ev.type == KeyPress)
1328 Atom ActualType; 1323 Atom ActualType;
1329 int ActualFormat; 1324 int ActualFormat;
1330 unsigned char *data; 1325 unsigned char *data;
1331 unsigned long Size, RemainingBytes; 1326 unsigned long Size, RemainingBytes;
1332 1327
1333 XGetWindowProperty (display->display, display->root, 1328 XGetWindowProperty (disp, display->root,
1334 xa[XA_DNDSELECTION], 1329 xa[XA_DNDSELECTION],
1335 0L, 1000000L, 1330 0L, 1000000L,
1336 False, AnyPropertyType, 1331 False, AnyPropertyType,
1337 &ActualType, &ActualFormat, 1332 &ActualType, &ActualFormat,
1338 &Size, &RemainingBytes, 1333 &Size, &RemainingBytes,
1339 &data); 1334 &data);
1340 set_string_property (XA_CUT_BUFFER0, data); 1335 set_string_property (XA_CUT_BUFFER0, data);
1341 XFree (data); 1336 XFree (data);
1342 selection_paste (display->root, XA_CUT_BUFFER0, true); 1337 selection_paste (display->root, XA_CUT_BUFFER0, true);
1343 XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); 1338 XSetInputFocus (disp, display->root, RevertToNone, CurrentTime);
1344 } 1339 }
1345#endif /* OFFIX_DND */ 1340#endif /* OFFIX_DND */
1346 break; 1341 break;
1347 1342
1348 case MappingNotify: 1343 case MappingNotify:
1441 { /* Wrap lots of configures into one */ 1436 { /* Wrap lots of configures into one */
1442 width = ev.xconfigure.width; 1437 width = ev.xconfigure.width;
1443 height = ev.xconfigure.height; 1438 height = ev.xconfigure.height;
1444 D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); 1439 D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height));
1445 } 1440 }
1446 while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); 1441 while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev));
1447 1442
1448 if (szHint.width != width || szHint.height != height) 1443 if (szHint.width != width || szHint.height != height)
1449 { 1444 {
1450 seen_resize = 1; 1445 seen_resize = 1;
1451 resize_all_windows (width, height, 1); 1446 resize_all_windows (width, height, 1);
1503 if (ev.xany.window == TermWin.vt) 1498 if (ev.xany.window == TermWin.vt)
1504 { 1499 {
1505 do 1500 do
1506 scr_expose (ev.xexpose.x, ev.xexpose.y, 1501 scr_expose (ev.xexpose.x, ev.xexpose.y,
1507 ev.xexpose.width, ev.xexpose.height, False); 1502 ev.xexpose.width, ev.xexpose.height, False);
1508 while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)); 1503 while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev));
1509 1504
1510 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; 1505 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose;
1511 1506
1512 while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)) 1507 while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev))
1513 scr_expose (ev.xexpose.x, ev.xexpose.y, 1508 scr_expose (ev.xexpose.x, ev.xexpose.y,
1514 ev.xexpose.width, ev.xexpose.height, False); 1509 ev.xexpose.width, ev.xexpose.height, False);
1515 1510
1516 scr_refresh (refresh_type); 1511 scr_refresh (refresh_type);
1517 } 1512 }
1518 else 1513 else
1519 { 1514 {
1520 XEvent unused_event; 1515 XEvent unused_event;
1521 1516
1522 while (XCheckTypedWindowEvent (display->display, ev.xany.window, Expose, &unused_event)) 1517 while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event))
1523 ; 1518 ;
1524 while (XCheckTypedWindowEvent (display->display, ev.xany.window, GraphicsExpose, &unused_event)) 1519 while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event))
1525 ; 1520 ;
1526 1521
1527 if (isScrollbarWindow (ev.xany.window)) 1522 if (isScrollbarWindow (ev.xany.window))
1528 { 1523 {
1529 scrollBar.setIdle (); 1524 scrollBar.setIdle ();
1534 menubar_expose (); 1529 menubar_expose ();
1535#endif 1530#endif
1536 1531
1537#ifdef TRANSPARENT 1532#ifdef TRANSPARENT
1538 if (am_transparent && ev.xany.window == TermWin.parent[0]) 1533 if (am_transparent && ev.xany.window == TermWin.parent[0])
1539 XClearWindow (display->display, ev.xany.window); 1534 XClearWindow (disp, ev.xany.window);
1540#endif 1535#endif
1541 } 1536 }
1542 break; 1537 break;
1543 1538
1544 case MotionNotify: 1539 case MotionNotify:
1558 1553
1559 if (ev.xany.window == TermWin.vt) 1554 if (ev.xany.window == TermWin.vt)
1560 { 1555 {
1561 if (ev.xbutton.state & (Button1Mask | Button3Mask)) 1556 if (ev.xbutton.state & (Button1Mask | Button3Mask))
1562 { 1557 {
1563 while (XCheckTypedWindowEvent (display->display, TermWin.vt, MotionNotify, &ev)) 1558 while (XCheckTypedWindowEvent (disp, TermWin.vt, MotionNotify, &ev))
1564 ; 1559 ;
1565 1560
1566 XQueryPointer (display->display, TermWin.vt, 1561 XQueryPointer (disp, TermWin.vt,
1567 &unused_root, &unused_child, 1562 &unused_root, &unused_child,
1568 &unused_root_x, &unused_root_y, 1563 &unused_root_x, &unused_root_y,
1569 &ev.xbutton.x, &ev.xbutton.y, 1564 &ev.xbutton.x, &ev.xbutton.y,
1570 &ev.xbutton.state); 1565 &ev.xbutton.state);
1571#ifdef MOUSE_THRESHOLD 1566#ifdef MOUSE_THRESHOLD
1635#endif 1630#endif
1636 } 1631 }
1637 } 1632 }
1638 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) 1633 else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ())
1639 { 1634 {
1640 while (XCheckTypedWindowEvent (display->display, scrollBar.win, 1635 while (XCheckTypedWindowEvent (disp, scrollBar.win,
1641 MotionNotify, &ev)) 1636 MotionNotify, &ev))
1642 ; 1637 ;
1643 1638
1644 XQueryPointer (display->display, scrollBar.win, 1639 XQueryPointer (disp, scrollBar.win,
1645 &unused_root, &unused_child, 1640 &unused_root, &unused_child,
1646 &unused_root_x, &unused_root_y, 1641 &unused_root_x, &unused_root_y,
1647 &ev.xbutton.x, &ev.xbutton.y, 1642 &ev.xbutton.x, &ev.xbutton.y,
1648 &unused_mask); 1643 &unused_mask);
1649 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, 1644 scr_move_to (scrollbar_position (ev.xbutton.y) - csrO,
1751 { 1746 {
1752 case Button1: 1747 case Button1:
1753 /* allow meta + click to select rectangular areas */ 1748 /* allow meta + click to select rectangular areas */
1754 /* should be done in screen.C */ 1749 /* should be done in screen.C */
1755#if ENABLE_FRILLS 1750#if ENABLE_FRILLS
1756 selection.rect = !! (ev.state & ModMetaMask); 1751 selection.rect = !!(ev.state & ModMetaMask);
1757#else 1752#else
1758 selection.rect = false; 1753 selection.rect = false;
1759#endif 1754#endif
1760 1755
1761 /* allow shift+left click to extend selection */ 1756 /* allow shift+left click to extend selection */
2087 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; 2082 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b;
2088 unsigned int lower_lim_r, lower_lim_g, lower_lim_b; 2083 unsigned int lower_lim_r, lower_lim_g, lower_lim_b;
2089 unsigned int upper_lim_r, upper_lim_g, upper_lim_b; 2084 unsigned int upper_lim_r, upper_lim_g, upper_lim_b;
2090 int i; 2085 int i;
2091 2086
2092 Visual* visual = display->visual; 2087 Visual *visual = display->visual;
2093 2088
2094 if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; 2089 if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ;
2095 2090
2096 /* for convenience */ 2091 /* for convenience */
2097 mask_r = visual->red_mask; 2092 mask_r = visual->red_mask;
2318 Atom atype; 2313 Atom atype;
2319 unsigned char *prop = NULL; 2314 unsigned char *prop = NULL;
2320 Window root, oldp, *list; 2315 Window root, oldp, *list;
2321 Pixmap rootpixmap = None; 2316 Pixmap rootpixmap = None;
2322 XWindowAttributes wattr, wrootattr; 2317 XWindowAttributes wattr, wrootattr;
2318 dDisp;
2323 2319
2324 pchanged = 0; 2320 pchanged = 0;
2325 2321
2326 if (!(options & Opt_transparent)) 2322 if (!(options & Opt_transparent))
2327 return pchanged; /* Don't try any more */ 2323 return pchanged; /* Don't try any more */
2328 2324
2329 XGetWindowAttributes (display->display, display->root, &wrootattr); 2325 XGetWindowAttributes (disp, display->root, &wrootattr);
2330 rootdepth = wrootattr.depth; 2326 rootdepth = wrootattr.depth;
2331 2327
2332 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); 2328 XGetWindowAttributes (disp, TermWin.parent[0], &wattr);
2333 2329
2334 if (rootdepth != wattr.depth) 2330 if (rootdepth != wattr.depth)
2335 { 2331 {
2336 if (am_transparent) 2332 if (am_transparent)
2337 { 2333 {
2338 pchanged = 1; 2334 pchanged = 1;
2339 XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]); 2335 XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]);
2340 am_transparent = am_pixmap_trans = 0; 2336 am_transparent = am_pixmap_trans = 0;
2341 } 2337 }
2342 2338
2343 return pchanged; /* Don't try any more */ 2339 return pchanged; /* Don't try any more */
2344 } 2340 }
2345 2341
2346 /* 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. */
2347 XSync (display->display, False); 2343 XSync (disp, False);
2348 2344
2349 /* 2345 /*
2350 * Make the frame window set by the window manager have 2346 * Make the frame window set by the window manager have
2351 * the root background. Some window managers put multiple nested frame 2347 * the root background. Some window managers put multiple nested frame
2352 * 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.
2353 */ 2349 */
2354 i = (xa[XA_XROOTPMAP_ID] 2350 i = (xa[XA_XROOTPMAP_ID]
2355 && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAP_ID], 2351 && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID],
2356 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 2352 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2357 &nitems, &bytes_after, &prop) == Success); 2353 &nitems, &bytes_after, &prop) == Success);
2358 2354
2359 if (!i || prop == NULL) 2355 if (!i || prop == NULL)
2360 i = (xa[XA_ESETROOT_PMAP_ID] 2356 i = (xa[XA_ESETROOT_PMAP_ID]
2361 && XGetWindowProperty (display->display, display->root, xa[XA_ESETROOT_PMAP_ID], 2357 && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID],
2362 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 2358 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2363 &nitems, &bytes_after, &prop) == Success); 2359 &nitems, &bytes_after, &prop) == Success);
2364 2360
2365 if (!i || prop == NULL 2361 if (!i || prop == NULL
2366#if TINTING 2362#if TINTING
2385 Window cr; 2381 Window cr;
2386 XImage *image; 2382 XImage *image;
2387 GC gc; 2383 GC gc;
2388 XGCValues gcvalue; 2384 XGCValues gcvalue;
2389 2385
2390 XTranslateCoordinates (display->display, TermWin.parent[0], display->root, 2386 XTranslateCoordinates (disp, TermWin.parent[0], display->root,
2391 0, 0, &sx, &sy, &cr); 2387 0, 0, &sx, &sy, &cr);
2392 nw = (unsigned int)szHint.width; 2388 nw = (unsigned int)szHint.width;
2393 nh = (unsigned int)szHint.height; 2389 nh = (unsigned int)szHint.height;
2394 nx = ny = 0; 2390 nx = ny = 0;
2395 2391
2408 } 2404 }
2409 2405
2410 MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); 2406 MIN_IT (nw, (unsigned int) (wrootattr.width - sx));
2411 MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); 2407 MIN_IT (nh, (unsigned int) (wrootattr.height - sy));
2412 2408
2413 XSync (display->display, False); 2409 XSync (disp, False);
2414 allowedxerror = -1; 2410 allowedxerror = -1;
2415 image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); 2411 image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
2416 2412
2417 /* XXX: handle BadMatch - usually because we're outside the pixmap */ 2413 /* XXX: handle BadMatch - usually because we're outside the pixmap */
2418 /* XXX: may need a delay here? */ 2414 /* XXX: may need a delay here? */
2419 allowedxerror = 0; 2415 allowedxerror = 0;
2420 2416
2423 if (am_transparent && am_pixmap_trans) 2419 if (am_transparent && am_pixmap_trans)
2424 { 2420 {
2425 pchanged = 1; 2421 pchanged = 1;
2426 if (TermWin.pixmap != None) 2422 if (TermWin.pixmap != None)
2427 { 2423 {
2428 XFreePixmap (display->display, TermWin.pixmap); 2424 XFreePixmap (disp, TermWin.pixmap);
2429 TermWin.pixmap = None; 2425 TermWin.pixmap = None;
2430 } 2426 }
2431 } 2427 }
2432 2428
2433 am_pixmap_trans = 0; 2429 am_pixmap_trans = 0;
2434 } 2430 }
2435 else 2431 else
2436 { 2432 {
2437 if (TermWin.pixmap != None) 2433 if (TermWin.pixmap != None)
2438 XFreePixmap (display->display, TermWin.pixmap); 2434 XFreePixmap (disp, TermWin.pixmap);
2439 2435
2440#if TINTING 2436#if TINTING
2441 if (ISSET_PIXCOLOR (Color_tint)) 2437 if (ISSET_PIXCOLOR (Color_tint))
2442 { 2438 {
2443 unsigned short rm, gm, bm; 2439 unsigned short rm, gm, bm;
2447 2443
2448 ShadeXImage (display, image, shade, rm, gm, bm); 2444 ShadeXImage (display, image, shade, rm, gm, bm);
2449 } 2445 }
2450#endif 2446#endif
2451 2447
2452 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, 2448 TermWin.pixmap = XCreatePixmap (disp, TermWin.vt,
2453 szHint.width, szHint.height, image->depth); 2449 szHint.width, szHint.height, image->depth);
2454 gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); 2450 gc = XCreateGC (disp, TermWin.vt, 0UL, &gcvalue);
2455 XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, 2451 XPutImage (disp, TermWin.pixmap, gc, image, 0, 0,
2456 nx, ny, image->width, image->height); 2452 nx, ny, image->width, image->height);
2457 XFreeGC (display->display, gc); 2453 XFreeGC (disp, gc);
2458 XDestroyImage (image); 2454 XDestroyImage (image);
2459 XSetWindowBackgroundPixmap (display->display, TermWin.parent[0], TermWin.pixmap); 2455 XSetWindowBackgroundPixmap (disp, TermWin.parent[0], TermWin.pixmap);
2460 XClearWindow (display->display, TermWin.parent[0]); 2456 XClearWindow (disp, TermWin.parent[0]);
2461 2457
2462 if (!am_transparent || !am_pixmap_trans) 2458 if (!am_transparent || !am_pixmap_trans)
2463 pchanged = 1; 2459 pchanged = 1;
2464 2460
2465 am_transparent = am_pixmap_trans = 1; 2461 am_transparent = am_pixmap_trans = 1;
2466 } 2462 }
2467 } 2463 }
2468 2464
2469 if (am_pixmap_trans) 2465 if (am_pixmap_trans)
2470 XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); 2466 XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative);
2471 else 2467 else
2472 { 2468 {
2473 unsigned int n; 2469 unsigned int n;
2474 /* 2470 /*
2475 * InheritPixmap transparency 2471 * InheritPixmap transparency
2476 */ 2472 */
2477 for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) 2473 for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
2478 { 2474 {
2479 oldp = TermWin.parent[i]; 2475 oldp = TermWin.parent[i];
2480 XQueryTree (display->display, TermWin.parent[i - 1], &root, 2476 XQueryTree (disp, TermWin.parent[i - 1], &root,
2481 &TermWin.parent[i], &list, &n); 2477 &TermWin.parent[i], &list, &n);
2482 XFree (list); 2478 XFree (list);
2483 2479
2484 if (TermWin.parent[i] == display->root) 2480 if (TermWin.parent[i] == display->root)
2485 { 2481 {
2497 2493
2498 if (pchanged) 2494 if (pchanged)
2499 { 2495 {
2500 for (; n < (unsigned int)i; n++) 2496 for (; n < (unsigned int)i; n++)
2501 { 2497 {
2502 XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); 2498 XGetWindowAttributes (disp, TermWin.parent[n], &wattr);
2503 if (wattr.depth != rootdepth || wattr.c_class == InputOnly) 2499 if (wattr.depth != rootdepth || wattr.c_class == InputOnly)
2504 { 2500 {
2505 n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; 2501 n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1;
2506 break; 2502 break;
2507 } 2503 }
2508 } 2504 }
2509 } 2505 }
2510 2506
2511 if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) 2507 if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0])))
2512 { 2508 {
2513 XSetWindowBackground (display->display, TermWin.parent[0], pix_colors_focused[Color_fg]); 2509 XSetWindowBackground (disp, TermWin.parent[0], pix_colors_focused[Color_fg]);
2514 XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]); 2510 XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]);
2515 am_transparent = 0; 2511 am_transparent = 0;
2516 /* XXX: also turn off Opt_transparent? */ 2512 /* XXX: also turn off Opt_transparent? */
2517 } 2513 }
2518 else 2514 else
2519 { 2515 {
2522 * needed for fvwm2.2.2 (and before?) */ 2518 * needed for fvwm2.2.2 (and before?) */
2523 sleep (1); 2519 sleep (1);
2524#endif 2520#endif
2525 for (n = 0; n < (unsigned int)i; n++) 2521 for (n = 0; n < (unsigned int)i; n++)
2526 { 2522 {
2527 XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); 2523 XSetWindowBackgroundPixmap (disp, TermWin.parent[n], ParentRelative);
2528 XClearWindow (display->display, TermWin.parent[n]); 2524 XClearWindow (disp, TermWin.parent[n]);
2529 } 2525 }
2530 2526
2531 XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); 2527 XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative);
2532 am_transparent = 1; 2528 am_transparent = 1;
2533 } 2529 }
2534 2530
2535 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) 2531 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
2536 TermWin.parent[i] = None; 2532 TermWin.parent[i] = None;
2537 } 2533 }
2538 2534
2539 if (scrollBar.win) 2535 if (scrollBar.win)
2540 { 2536 {
2541 XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); 2537 XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative);
2542 scrollBar.setIdle (); 2538 scrollBar.setIdle ();
2543 scrollbar_show (0); 2539 scrollbar_show (0);
2544 } 2540 }
2545 2541
2546 if (am_transparent) 2542 if (am_transparent)
2707 if (len == (size_t)-1) 2703 if (len == (size_t)-1)
2708 return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through 2704 return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through
2709 2705
2710 // assume wchar == unicode 2706 // assume wchar == unicode
2711 cmdbuf_ptr += len; 2707 cmdbuf_ptr += len;
2712 return wc; 2708 return wc & UNICODE_MASK;
2713 } 2709 }
2714 2710
2715 return NOCHAR; 2711 return NOCHAR;
2716} 2712}
2717 2713
3180 { 3176 {
3181 switch (priv) 3177 switch (priv)
3182 { 3178 {
3183 case '>': 3179 case '>':
3184 if (ch == CSI_DA) /* secondary device attributes */ 3180 if (ch == CSI_DA) /* secondary device attributes */
3185 tt_printf ("\033[>%d;%-.8s;0c", 'R', VSTRING); 3181 tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]);
3186 break; 3182 break;
3187 case '?': 3183 case '?':
3188 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') 3184 if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't')
3189 process_terminal_mode (ch, priv, nargs, arg); 3185 process_terminal_mode (ch, priv, nargs, arg);
3190 break; 3186 break;
3419rxvt_term::process_window_ops (const int *args, unsigned int nargs) 3415rxvt_term::process_window_ops (const int *args, unsigned int nargs)
3420{ 3416{
3421 int x, y; 3417 int x, y;
3422 XWindowAttributes wattr; 3418 XWindowAttributes wattr;
3423 Window wdummy; 3419 Window wdummy;
3420 dDisp;
3424 3421
3425 if (nargs == 0) 3422 if (nargs == 0)
3426 return; 3423 return;
3427 3424
3428 switch (args[0]) 3425 switch (args[0])
3429 { 3426 {
3430 /* 3427 /*
3431 * commands 3428 * commands
3432 */ 3429 */
3433 case 1: /* deiconify window */ 3430 case 1: /* deiconify window */
3434 XMapWindow (display->display, TermWin.parent[0]); 3431 XMapWindow (disp, TermWin.parent[0]);
3435 break; 3432 break;
3436 case 2: /* iconify window */ 3433 case 2: /* iconify window */
3437 XIconifyWindow (display->display, TermWin.parent[0], 3434 XIconifyWindow (disp, TermWin.parent[0], display->screen);
3438 DefaultScreen (display->display));
3439 break; 3435 break;
3440 case 3: /* set position (pixels) */ 3436 case 3: /* set position (pixels) */
3441 XMoveWindow (display->display, TermWin.parent[0], args[1], args[2]); 3437 XMoveWindow (disp, TermWin.parent[0], args[1], args[2]);
3442 break; 3438 break;
3443 case 4: /* set size (pixels) */ 3439 case 4: /* set size (pixels) */
3444 set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); 3440 set_widthheight ((unsigned int)args[2], (unsigned int)args[1]);
3445 break; 3441 break;
3446 case 5: /* raise window */ 3442 case 5: /* raise window */
3447 XRaiseWindow (display->display, TermWin.parent[0]); 3443 XRaiseWindow (disp, TermWin.parent[0]);
3448 break; 3444 break;
3449 case 6: /* lower window */ 3445 case 6: /* lower window */
3450 XLowerWindow (display->display, TermWin.parent[0]); 3446 XLowerWindow (disp, TermWin.parent[0]);
3451 break; 3447 break;
3452 case 7: /* refresh window */ 3448 case 7: /* refresh window */
3453 scr_touch (true); 3449 scr_touch (true);
3454 break; 3450 break;
3455 case 8: /* set size (chars) */ 3451 case 8: /* set size (chars) */
3467 3463
3468 /* 3464 /*
3469 * reports - some output format copied from XTerm 3465 * reports - some output format copied from XTerm
3470 */ 3466 */
3471 case 11: /* report window state */ 3467 case 11: /* report window state */
3472 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); 3468 XGetWindowAttributes (disp, TermWin.parent[0], &wattr);
3473 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); 3469 tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2);
3474 break; 3470 break;
3475 case 13: /* report window position */ 3471 case 13: /* report window position */
3476 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); 3472 XGetWindowAttributes (disp, TermWin.parent[0], &wattr);
3477 XTranslateCoordinates (display->display, TermWin.parent[0], wattr.root, 3473 XTranslateCoordinates (disp, TermWin.parent[0], wattr.root,
3478 -wattr.border_width, -wattr.border_width, 3474 -wattr.border_width, -wattr.border_width,
3479 &x, &y, &wdummy); 3475 &x, &y, &wdummy);
3480 tt_printf ("\033[3;%d;%dt", x, y); 3476 tt_printf ("\033[3;%d;%dt", x, y);
3481 break; 3477 break;
3482 case 14: /* report window size (pixels) */ 3478 case 14: /* report window size (pixels) */
3483 XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); 3479 XGetWindowAttributes (disp, TermWin.parent[0], &wattr);
3484 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); 3480 tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width);
3485 break; 3481 break;
3486 case 18: /* report text area size (chars) */ 3482 case 18: /* report text area size (chars) */
3487 tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); 3483 tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol);
3488 break; 3484 break;
3490 tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); 3486 tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol);
3491 break; 3487 break;
3492 case 20: /* report icon label */ 3488 case 20: /* report icon label */
3493 { 3489 {
3494 char *s; 3490 char *s;
3495 XGetIconName (display->display, TermWin.parent[0], &s); 3491 XGetIconName (disp, TermWin.parent[0], &s);
3496 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 */
3497 XFree (s); 3493 XFree (s);
3498 } 3494 }
3499 break; 3495 break;
3500 case 21: /* report window title */ 3496 case 21: /* report window title */
3501 { 3497 {
3502 char *s; 3498 char *s;
3503 XFetchName (display->display, TermWin.parent[0], &s); 3499 XFetchName (disp, TermWin.parent[0], &s);
3504 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 */
3505 XFree (s); 3501 XFree (s);
3506 } 3502 }
3507 break; 3503 break;
3508 } 3504 }
3650 int changed = 0; 3646 int changed = 0;
3651 int color; 3647 int color;
3652 char *buf, *name; 3648 char *buf, *name;
3653 bool query = str[0] == '?' && !str[1]; 3649 bool query = str[0] == '?' && !str[1];
3654 int saveop = op; 3650 int saveop = op;
3651 dDisp;
3655 3652
3656 assert (str != NULL); 3653 assert (str != NULL);
3657 switch (op) 3654 switch (op)
3658 { 3655 {
3659 case XTerm_name: 3656 case XTerm_name:
3675 unsigned long bytes_after; 3672 unsigned long bytes_after;
3676 unsigned char *value = 0; 3673 unsigned char *value = 0;
3677 const char *str = ""; 3674 const char *str = "";
3678 3675
3679 if (prop 3676 if (prop
3680 && XGetWindowProperty (display->display, TermWin.parent[0], 3677 && XGetWindowProperty (disp, TermWin.parent[0],
3681 prop, 0, 1<<16, 0, AnyPropertyType, 3678 prop, 0, 1<<16, 0, AnyPropertyType,
3682 &actual_type, &actual_format, 3679 &actual_type, &actual_format,
3683 &nitems, &bytes_after, &value) == Success 3680 &nitems, &bytes_after, &value) == Success
3684 && actual_type != None 3681 && actual_type != None
3685 && actual_format == 8) 3682 && actual_format == 8)
3697 { 3694 {
3698 *eq = 0; 3695 *eq = 0;
3699 set_utf8_property (display->atom (str), eq + 1); 3696 set_utf8_property (display->atom (str), eq + 1);
3700 } 3697 }
3701 else 3698 else
3702 XDeleteProperty (display->display, TermWin.parent[0], 3699 XDeleteProperty (disp, TermWin.parent[0],
3703 display->atom (str)); 3700 display->atom (str));
3704 } 3701 }
3705 break; 3702 break;
3706 3703
3707 case XTerm_Color: 3704 case XTerm_Color:
3782 { 3779 {
3783 str++; 3780 str++;
3784#if XPM_BACKGROUND 3781#if XPM_BACKGROUND
3785 changed += scale_pixmap (str); 3782 changed += scale_pixmap (str);
3786#endif 3783#endif
3787
3788 } 3784 }
3785
3789 if (changed) 3786 if (changed)
3790 { 3787 {
3791#ifdef XPM_BACKGROUND 3788#ifdef XPM_BACKGROUND
3792 resize_pixmap (); 3789 resize_pixmap ();
3793#endif 3790#endif
3834 if (query) 3831 if (query)
3835 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);
3836 else 3833 else
3837 { 3834 {
3838 set_locale (str); 3835 set_locale (str);
3836 pty.set_utf8_mode (enc_utf8);
3839# ifdef USE_XIM 3837# ifdef USE_XIM
3840 im_cb (); 3838 im_cb ();
3841# endif 3839# endif
3842 } 3840 }
3843 break; 3841 break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines