--- rxvt-unicode/src/command.C 2006/01/31 21:35:39 1.302 +++ rxvt-unicode/src/command.C 2007/06/26 13:05:05 1.334 @@ -1,4 +1,4 @@ -/*--------------------------------*-C-*---------------------------------* +/*----------------------------------------------------------------------* * File: command.C *----------------------------------------------------------------------* * @@ -57,6 +57,10 @@ #include +#if LINUX_YIELD_HACK +# include +#endif + /*----------------------------------------------------------------------*/ #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) @@ -296,9 +300,8 @@ } #endif -/*{{{ Convert the keypress event into a string */ void -rxvt_term::lookup_key (XKeyEvent &ev) +rxvt_term::key_press (XKeyEvent &ev) { int ctrl, meta, shft, len; unsigned int newlen; @@ -306,6 +309,11 @@ int valid_keysym; char kbuf[KBUFSZ]; +#if ISO_14755 + if (iso14755buf & ISO_14755_52) + return; +#endif + /* * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an * escape sequence to toggle the Keypad. @@ -494,6 +502,14 @@ # endif return; } + else if (keysym == XK_BackSpace) + { + iso14755buf = ((iso14755buf & ISO_14755_MASK) >> 4) | ISO_14755_51; +# if ISO_14755 + iso14755_51 (iso14755buf & ISO_14755_MASK); +# endif + return; + } else if ((hv = hex_keyval (ev)) >= 0) { iso14755buf = ((iso14755buf << 4) & ISO_14755_MASK) @@ -522,7 +538,7 @@ # endif } #endif - + #ifdef PRINTPIPE if (keysym == XK_Print) { @@ -871,7 +887,7 @@ if (len <= 0) return; /* not mapped */ - if (OPTION (Opt_scrollTtyKeypress)) + if (option (Opt_scrollTtyKeypress)) if (view_start) { view_start = 0; @@ -905,7 +921,83 @@ tt_write (kbuf, (unsigned int)len); } -/*}}} */ + +void +rxvt_term::key_release (XKeyEvent &ev) +{ +#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL + KeySym keysym; + + keysym = XLookupKeysym (&ev, ev.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ +#endif + +#if ENABLE_FRILLS || ISO_14755 + // ISO 14755 support + if (iso14755buf) + if (iso14755buf & ISO_14755_52) + { +# if ENABLE_OVERLAY + scr_overlay_off (); +# endif +# if ISO_14755 + // iso14755 part 5.2 handling: release time + // first: controls + if ((ev.state & ControlMask) + && ((keysym >= 0x40 && keysym <= 0x5f) + || (keysym >= 0x61 && keysym <= 0x7f))) + { + iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); + commit_iso14755 (); + + return; + } + + for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) + if (i[0] == keysym) + { + iso14755buf = ISO_14755_51 | i[1]; + commit_iso14755 (); + + return; + } + + scr_bell (); +# endif + iso14755buf = 0; + + return; + } + else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) + { +# if ENABLE_OVERLAY + scr_overlay_off (); +# endif + if (iso14755buf & ISO_14755_51) + commit_iso14755 (); +#if ISO_14755 + else if (option (Opt_iso14755_52) && iso14755buf & ISO_14755_STARTED) + { + iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair + + scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); + scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); + } +# endif + else + iso14755buf = 0; + } +#endif + + if (HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) + return; + +#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) + if (!(ev.state & ControlMask)) + slip_wheel_ev.stop (); + else if (keysym == XK_Control_L || keysym == XK_Control_R) + mouse_slip_wheel_speed = 0; +#endif +} #if defined (KEYSYM_RESOURCE) unsigned int @@ -945,7 +1037,7 @@ { flush_ev.stop (); -#ifdef TRANSPARENT +#ifdef ENABLE_TRANSPARENCY if (want_full_refresh) { want_full_refresh = 0; @@ -1020,7 +1112,6 @@ { make_current (); - refresh_limit = 1; refresh_count = 0; flush (); } @@ -1096,10 +1187,17 @@ static struct event_handler { check_watcher yield_ev; - + void yield_cb (check_watcher &w) { - usleep (0); + // this should really be sched_yield(), but the linux guys thought + // that giving a process calling sched_yield () less cpu time than + // ones with high nice levels is a useful thing to do. It surely is is + // allowed by the sus... as is returning ENOSYS. + + struct timespec ts = { 0, 0 }; + nanosleep (&ts, 0); + w.stop (); } @@ -1143,10 +1241,10 @@ { pty_ev.stop (); - if (!OPTION (Opt_hold)) + if (!option (Opt_hold)) destroy (); } - + return false; } @@ -1168,13 +1266,13 @@ void rxvt_term::pointer_unblank () { - XDefineCursor (xdisp, vt, TermWin_cursor); + XDefineCursor (dpy, vt, TermWin_cursor); recolour_cursor (); #ifdef POINTER_BLANK hidden_pointer = 0; - if (OPTION (Opt_pointerBlank)) + if (option (Opt_pointerBlank)) pointer_ev.start (NOW + pointerBlankDelay); #endif } @@ -1183,11 +1281,11 @@ void rxvt_term::pointer_blank () { - if (!OPTION (Opt_pointerBlank)) + if (!option (Opt_pointerBlank)) return; - XDefineCursor (xdisp, vt, display->blank_cursor); - XFlush (xdisp); + XDefineCursor (dpy, vt, display->blank_cursor); + XFlush (dpy); hidden_pointer = 1; } @@ -1276,7 +1374,7 @@ { make_current (); - dLocal (Display *, xdisp); + dLocal (Display *, dpy); if (ev.xany.window == vt && SHOULD_INVOKE (HOOK_X_EVENT) @@ -1291,87 +1389,12 @@ switch (ev.type) { case KeyPress: -#if ISO_14755 - if (!(iso14755buf & ISO_14755_52)) -#endif - lookup_key (ev.xkey); - + key_press (ev.xkey); break; case KeyRelease: - { -#if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL - KeySym keysym; - - keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ -#endif - -#if ENABLE_FRILLS || ISO_14755 - // ISO 14755 support - if (iso14755buf) - if (iso14755buf & ISO_14755_52) - { -# if ENABLE_OVERLAY - scr_overlay_off (); -# endif -# if ISO_14755 - // iso14755 part 5.2 handling: release time - // first: controls - if ((ev.xkey.state & ControlMask) - && ((keysym >= 0x40 && keysym <= 0x5f) - || (keysym >= 0x61 && keysym <= 0x7f))) - { - iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); - commit_iso14755 (); - goto skip_switch; - } - - for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) - if (i[0] == keysym) - { - iso14755buf = ISO_14755_51 | i[1]; - commit_iso14755 (); - goto skip_switch; - } - - scr_bell (); -# endif - iso14755buf = 0; - break; - } - else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) - { -# if ENABLE_OVERLAY - scr_overlay_off (); -# endif - if (iso14755buf & ISO_14755_51) - commit_iso14755 (); -#if ISO_14755 - else if (iso14755buf & ISO_14755_STARTED) - { - iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair - - scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); - scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); - } -# endif - else - iso14755buf = 0; - } -#endif - - if (ev.xany.window == vt - && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) - break; - -#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) - if (!(ev.xkey.state & ControlMask)) - slip_wheel_ev.stop (); - else if (keysym == XK_Control_L || keysym == XK_Control_R) - mouse_slip_wheel_speed = 0; -#endif - break; - } + key_release (ev.xkey); + break; case ButtonPress: button_press (ev.xbutton); @@ -1396,7 +1419,7 @@ } #if ENABLE_EWMH else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) - XSendEvent (xdisp, ev.xclient.window = display->root, + XSendEvent (dpy, ev.xclient.window = display->root, False, SubstructureRedirectMask | SubstructureNotifyMask, &ev); #endif @@ -1444,29 +1467,42 @@ break; case FocusIn: - focus_in (); + if (ev.xfocus.detail != NotifyInferior + && ev.xfocus.detail != NotifyPointer + && ev.xfocus.mode != NotifyGrab) + focus_in (); break; case FocusOut: - focus_out (); + if (ev.xfocus.detail != NotifyInferior + && ev.xfocus.detail != NotifyPointer + && ev.xfocus.mode != NotifyGrab) + focus_out (); break; case ConfigureNotify: if (ev.xconfigure.window == parent[0]) { - while (XCheckTypedWindowEvent (xdisp, ev.xconfigure.window, ConfigureNotify, &ev)) + while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) ; if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) { seen_resize = 1; resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); +#ifdef XPM_BACKGROUND + if (!option (Opt_transparent) && bgPixmap.auto_resize) + { + resize_pixmap (); + scr_touch (true); + } +#endif } HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); -#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ - if (OPTION (Opt_transparent)) +#ifdef ENABLE_TRANSPARENCY + if (option (Opt_transparent)) check_our_parents (); #endif } @@ -1509,11 +1545,11 @@ HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); break; -#ifdef TRANSPARENT +#ifdef ENABLE_TRANSPARENCY case ReparentNotify: rootwin_cb (ev); break; -#endif /* TRANSPARENT */ +#endif /* ENABLE_TRANSPARENCY */ case GraphicsExpose: case Expose: @@ -1522,11 +1558,11 @@ do scr_expose (ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height, False); - while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)); + while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; - while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)) + while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) scr_expose (ev.xexpose.x, ev.xexpose.y, ev.xexpose.width, ev.xexpose.height, False); @@ -1536,9 +1572,9 @@ { XEvent unused_event; - while (XCheckTypedWindowEvent (xdisp, ev.xany.window, Expose, &unused_event)) + while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) ; - while (XCheckTypedWindowEvent (xdisp, ev.xany.window, GraphicsExpose, &unused_event)) + while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) ; if (isScrollbarWindow (ev.xany.window)) @@ -1547,9 +1583,9 @@ scrollbar_show (0); } -#ifdef TRANSPARENT +#ifdef ENABLE_TRANSPARENCY if (am_transparent && ev.xany.window == parent[0]) - XClearWindow (xdisp, ev.xany.window); + XClearWindow (dpy, ev.xany.window); #endif } break; @@ -1569,10 +1605,10 @@ ; // nop else if (ev.xbutton.state & (Button1Mask | Button3Mask)) { - while (XCheckTypedWindowEvent (xdisp, vt, MotionNotify, &ev)) + while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) ; - XQueryPointer (xdisp, vt, + XQueryPointer (dpy, vt, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &ev.xbutton.x, &ev.xbutton.y, @@ -1646,11 +1682,11 @@ } else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) { - while (XCheckTypedWindowEvent (xdisp, scrollBar.win, + while (XCheckTypedWindowEvent (dpy, scrollBar.win, MotionNotify, &ev)) ; - XQueryPointer (xdisp, scrollBar.win, + XQueryPointer (dpy, scrollBar.win, &unused_root, &unused_child, &unused_root_x, &unused_root_y, &ev.xbutton.x, &ev.xbutton.y, @@ -1658,16 +1694,13 @@ scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, scrollbar_size ()); want_refresh = 1; - refresh_limit = 0; scrollbar_show (1); } break; } -skip_switch: ; - #if defined(CURSOR_BLINK) - if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) + if (option (Opt_cursorBlink) && ev.type == KeyPress) { if (hidden_cursor) { @@ -1680,7 +1713,7 @@ #endif #if defined(POINTER_BLANK) - if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) + if (option (Opt_pointerBlank) && pointerBlankDelay > 0) { if (ev.type == MotionNotify || ev.type == ButtonPress @@ -1702,17 +1735,17 @@ focus = 1; want_refresh = 1; - HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); + HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); #if USE_XIM if (Input_Context != NULL) { - IMSetStatusPosition (); + IMSetPosition (); XSetICFocus (Input_Context); } #endif #if CURSOR_BLINK - if (OPTION (Opt_cursorBlink)) + if (option (Opt_cursorBlink)) cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); #endif #if OFF_FOCUS_FADING @@ -1722,6 +1755,19 @@ scr_recolour (); } #endif +#if ENABLE_FRILLS + if (option (Opt_urgentOnBell)) + { + XWMHints *h; + + h = XGetWMHints(dpy, parent[0]); + if (h != NULL) + { + h->flags &= ~XUrgencyHint; + XSetWMHints(dpy, parent[0], h); + } + } +#endif } } @@ -1749,7 +1795,7 @@ XUnsetICFocus (Input_Context); #endif #if CURSOR_BLINK - if (OPTION (Opt_cursorBlink)) + if (option (Opt_cursorBlink)) cursor_blink_ev.stop (); hidden_cursor = 0; #endif @@ -1763,12 +1809,30 @@ } } -#if TRANSPARENT +void +rxvt_term::update_fade_color (unsigned int idx) +{ +#if OFF_FOCUS_FADING + if (rs[Rs_fade]) + { + rgba c; + pix_colors [Color_fade].get (c); + pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); + } +#endif +} + +#if ENABLE_TRANSPARENCY || ENABLE_PERL void rxvt_term::rootwin_cb (XEvent &ev) { make_current (); + if (SHOULD_INVOKE (HOOK_ROOT_EVENT) + && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) + return; + +# if ENABLE_TRANSPARENCY switch (ev.type) { case PropertyNotify: @@ -1782,10 +1846,11 @@ /* FALLTHROUGH */ case ReparentNotify: - if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) - want_refresh = want_full_refresh = 1; + if (option (Opt_transparent)) + check_our_parents (); break; } +# endif } #endif @@ -2123,7 +2188,7 @@ case Button2: if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? - selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); + selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); break; #ifdef MOUSE_WHEEL @@ -2137,7 +2202,7 @@ if (ev.state & ShiftMask) i = 1; - else if (OPTION (Opt_mouseWheelScrollPage)) + else if (option (Opt_mouseWheelScrollPage)) i = nrow - 1; else i = 5; @@ -2169,478 +2234,6 @@ } } -#ifdef TRANSPARENT -#if TINTING -/* taken from aterm-0.4.2 */ - -typedef uint32_t RUINT32T; - -void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) -{ - int sh_r, sh_g, sh_b; - RUINT32T mask_r, mask_g, mask_b; - RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; - unsigned int lower_lim_r, lower_lim_g, lower_lim_b; - unsigned int upper_lim_r, upper_lim_g, upper_lim_b; - int i; - - Visual *visual = term->visual; - - if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; - - /* for convenience */ - mask_r = visual->red_mask; - mask_g = visual->green_mask; - mask_b = visual->blue_mask; - - /* boring lookup table pre-initialization */ - switch (srcImage->bits_per_pixel) { - case 15: - if ((mask_r != 0x7c00) || - (mask_g != 0x03e0) || - (mask_b != 0x001f)) - return; - lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); - lookup_r = lookup; - lookup_g = lookup+32; - lookup_b = lookup+32+32; - sh_r = 10; - sh_g = 5; - sh_b = 0; - break; - case 16: - if ((mask_r != 0xf800) || - (mask_g != 0x07e0) || - (mask_b != 0x001f)) - return; - lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); - lookup_r = lookup; - lookup_g = lookup+32; - lookup_b = lookup+32+64; - sh_r = 11; - sh_g = 5; - sh_b = 0; - break; - case 24: - if ((mask_r != 0xff0000) || - (mask_g != 0x00ff00) || - (mask_b != 0x0000ff)) - return; - lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); - lookup_r = lookup; - lookup_g = lookup+256; - lookup_b = lookup+256+256; - sh_r = 16; - sh_g = 8; - sh_b = 0; - break; - case 32: - if ((mask_r != 0xff0000) || - (mask_g != 0x00ff00) || - (mask_b != 0x0000ff)) - return; - lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); - lookup_r = lookup; - lookup_g = lookup+256; - lookup_b = lookup+256+256; - sh_r = 16; - sh_g = 8; - sh_b = 0; - break; - default: - return; /* we do not support this color depth */ - } - - /* prepare limits for color transformation (each channel is handled separately) */ - if (shade < 0) { - shade = -shade; - if (shade < 0) shade = 0; - if (shade > 100) shade = 100; - - lower_lim_r = 65535-rm; - lower_lim_g = 65535-gm; - lower_lim_b = 65535-bm; - - lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); - lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); - lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); - - upper_lim_r = upper_lim_g = upper_lim_b = 65535; - } else { - if (shade < 0) shade = 0; - if (shade > 100) shade = 100; - - lower_lim_r = lower_lim_g = lower_lim_b = 0; - - upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); - upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); - upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); - } - - /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ - if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) - { - unsigned int tmp; - - tmp = lower_lim_r; - lower_lim_r = lower_lim_b; - lower_lim_b = tmp; - - tmp = upper_lim_r; - upper_lim_r = upper_lim_b; - upper_lim_b = tmp; - } - - /* fill our lookup tables */ - for (i = 0; i <= mask_r>>sh_r; i++) - { - RUINT32T tmp; - tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); - tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); - lookup_r[i] = (tmp/65535)<>sh_g; i++) - { - RUINT32T tmp; - tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); - tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); - lookup_g[i] = (tmp/65535)<>sh_b; i++) - { - RUINT32T tmp; - tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); - tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); - lookup_b[i] = (tmp/65535)<bits_per_pixel) - { - case 15: - { - unsigned short *p1, *pf, *p, *pl; - p1 = (unsigned short *) srcImage->data; - pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); - while (p1 < pf) - { - p = p1; - pl = p1 + srcImage->width; - for (; p < pl; p++) - { - *p = lookup_r[(*p & 0x7c00)>>10] | - lookup_g[(*p & 0x03e0)>> 5] | - lookup_b[(*p & 0x001f)]; - } - p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); - } - break; - } - case 16: - { - unsigned short *p1, *pf, *p, *pl; - p1 = (unsigned short *) srcImage->data; - pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); - while (p1 < pf) - { - p = p1; - pl = p1 + srcImage->width; - for (; p < pl; p++) - { - *p = lookup_r[(*p & 0xf800)>>11] | - lookup_g[(*p & 0x07e0)>> 5] | - lookup_b[(*p & 0x001f)]; - } - p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); - } - break; - } - case 24: - { - unsigned char *p1, *pf, *p, *pl; - p1 = (unsigned char *) srcImage->data; - pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); - while (p1 < pf) - { - p = p1; - pl = p1 + srcImage->width * 3; - for (; p < pl; p += 3) - { - p[0] = lookup_r[(p[0] & 0xff0000)>>16]; - p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; - p[2] = lookup_r[(p[2] & 0x0000ff)]; - } - p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); - } - break; - } - case 32: - { - RUINT32T *p1, *pf, *p, *pl; - p1 = (RUINT32T *) srcImage->data; - pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); - - while (p1 < pf) - { - p = p1; - pl = p1 + srcImage->width; - for (; p < pl; p++) - { - *p = lookup_r[(*p & 0xff0000)>>16] | - lookup_g[(*p & 0x00ff00)>> 8] | - lookup_b[(*p & 0x0000ff)] | - (*p & ~0xffffff); - } - p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); - } - break; - } - } - - free (lookup); -} -#endif - -/* - * Check our parents are still who we think they are. - * Do transparency updates if required - */ -int -rxvt_term::check_our_parents () -{ - int i, pchanged, aformat, have_pixmap, rootdepth; - unsigned long nitems, bytes_after; - Atom atype; - unsigned char *prop = NULL; - Window root, oldp, *list; - Pixmap rootpixmap = None; - XWindowAttributes wattr, wrootattr; - - pchanged = 0; - - if (!OPTION (Opt_transparent)) - return pchanged; /* Don't try any more */ - - XGetWindowAttributes (xdisp, display->root, &wrootattr); - rootdepth = wrootattr.depth; - - XGetWindowAttributes (xdisp, parent[0], &wattr); - - if (rootdepth != wattr.depth) - { - if (am_transparent) - { - pchanged = 1; - XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); - am_transparent = am_pixmap_trans = 0; - } - - return pchanged; /* Don't try any more */ - } - - /* Get all X ops out of the queue so that our information is up-to-date. */ - XSync (xdisp, False); - - /* - * Make the frame window set by the window manager have - * the root background. Some window managers put multiple nested frame - * windows for each client, so we have to take care about that. - */ - i = (xa[XA_XROOTPMAP_ID] - && XGetWindowProperty (xdisp, display->root, xa[XA_XROOTPMAP_ID], - 0L, 1L, False, XA_PIXMAP, &atype, &aformat, - &nitems, &bytes_after, &prop) == Success); - - if (!i || prop == NULL) - i = (xa[XA_ESETROOT_PMAP_ID] - && XGetWindowProperty (xdisp, display->root, xa[XA_ESETROOT_PMAP_ID], - 0L, 1L, False, XA_PIXMAP, &atype, &aformat, - &nitems, &bytes_after, &prop) == Success); - - if (!i || prop == NULL -#if TINTING - || !ISSET_PIXCOLOR (Color_tint) -#endif - ) - have_pixmap = 0; - else - { - have_pixmap = 1; - rootpixmap = *(Pixmap *)prop; - XFree (prop); - } - - if (have_pixmap) - { - /* - * Copy display->root pixmap transparency - */ - int sx, sy, nx, ny; - unsigned int nw, nh; - Window cr; - XImage *image; - GC gc; - XGCValues gcvalue; - - XTranslateCoordinates (xdisp, parent[0], display->root, - 0, 0, &sx, &sy, &cr); - nw = (unsigned int)szHint.width; - nh = (unsigned int)szHint.height; - nx = ny = 0; - - if (sx < 0) - { - nw += sx; - nx = -sx; - sx = 0; - } - - if (sy < 0) - { - nh += sy; - ny = -sy; - sy = 0; - } - - min_it (nw, (unsigned int) (wrootattr.width - sx)); - min_it (nh, (unsigned int) (wrootattr.height - sy)); - - XSync (xdisp, False); - allowedxerror = -1; - image = XGetImage (xdisp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); - - /* XXX: handle BadMatch - usually because we're outside the pixmap */ - /* XXX: may need a delay here? */ - allowedxerror = 0; - - if (image == NULL) - { - if (am_transparent && am_pixmap_trans) - { - pchanged = 1; - if (pixmap != None) - { - XFreePixmap (xdisp, pixmap); - pixmap = None; - } - } - - am_pixmap_trans = 0; - } - else - { - if (pixmap != None) - XFreePixmap (xdisp, pixmap); - -#if TINTING - if (ISSET_PIXCOLOR (Color_tint)) - { - int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; - - rgba c; - pix_colors_focused [Color_tint].get (c); - - ShadeXImage (this, image, shade, c.r, c.g, c.b); - } -#endif - - pixmap = XCreatePixmap (xdisp, vt, szHint.width, szHint.height, image->depth); - gc = XCreateGC (xdisp, vt, 0UL, &gcvalue); - XPutImage (xdisp, pixmap, gc, image, 0, 0, - nx, ny, image->width, image->height); - XFreeGC (xdisp, gc); - XDestroyImage (image); - XSetWindowBackgroundPixmap (xdisp, parent[0], pixmap); - XClearWindow (xdisp, parent[0]); - - if (!am_transparent || !am_pixmap_trans) - pchanged = 1; - - am_transparent = am_pixmap_trans = 1; - } - } - - if (am_pixmap_trans) - XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); - else - { - unsigned int n; - /* - * InheritPixmap transparency - */ - for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) - { - oldp = parent[i]; - XQueryTree (xdisp, parent[i - 1], &root, &parent[i], &list, &n); - XFree (list); - - if (parent[i] == display->root) - { - if (oldp != None) - pchanged = 1; - - break; - } - - if (oldp != parent[i]) - pchanged = 1; - } - - n = 0; - - if (pchanged) - for (; n < (unsigned int)i; n++) - { - XGetWindowAttributes (xdisp, parent[n], &wattr); - - if (wattr.depth != rootdepth || wattr.c_class == InputOnly) - { - n = (int) (sizeof (parent) / sizeof (Window)) + 1; - break; - } - } - - if (n > (sizeof (parent) / sizeof (parent[0]))) - { - XSetWindowBackground (xdisp, parent[0], pix_colors_focused[Color_border]); - XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); - am_transparent = 0; - /* XXX: also turn off Opt_transparent? */ - } - else - { - for (n = 0; n < (unsigned int)i; n++) - { - XSetWindowBackgroundPixmap (xdisp, parent[n], ParentRelative); - XClearWindow (xdisp, parent[n]); - } - - XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); - am_transparent = 1; - } - - for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) - parent[i] = None; - } - - if (scrollBar.win) - { - XSetWindowBackgroundPixmap (xdisp, scrollBar.win, ParentRelative); - scrollBar.setIdle (); - scrollbar_show (0); - } - - if (am_transparent) - { - want_refresh = want_full_refresh = 1; - if (am_pixmap_trans) - flush (); - } - - return pchanged; -} -#endif - /*}}} */ bool @@ -2698,13 +2291,16 @@ refresh_count++; - if (!OPTION (Opt_jumpScroll) - || (refresh_count >= refresh_limit * (nrow - 1))) + if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) { - refreshnow = true; refresh_count = 0; - ch = NOCHAR; - break; + + if (!option (Opt_skipScroll) || io_manager::now () > NOW + 1. / 60.) + { + refreshnow = true; + ch = NOCHAR; + break; + } } // scr_add_lines only works for nlines <= nrow - 1. @@ -2742,20 +2338,14 @@ /* * If there have been a lot of new lines, then update the screen - * What the heck I'll cheat and only refresh less than every page-full. - * the number of pages between refreshes is refresh_limit, which - * is incremented here because we must be doing flat-out scrolling. + * What the heck we'll cheat and only refresh less than every page-full. + * if skipScroll is enabled. */ if (refreshnow) { - if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) - refresh_limit++; - else - { - flag = true; - scr_refresh (); - want_refresh = 1; - } + flag = true; + scr_refresh (); + want_refresh = 1; } } @@ -2914,7 +2504,7 @@ break; /* done = 1 */ } } - + for (i = 0; i < len; i++) if (putc (buf[i], fd) == EOF) { @@ -2986,7 +2576,7 @@ case 0x9b: /* CSI */ process_csi_seq (); break; - case 0x9d: /* CSI */ + case 0x9d: /* OSC */ process_osc_seq (); break; #endif @@ -3279,7 +2869,7 @@ case '>': if (ch == CSI_DA) /* secondary device attributes */ { - // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, + // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt, // 'U' for rxvt-unicode != 7.[34] (where it was broken). // // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt @@ -3423,7 +3013,7 @@ scr_report_position (); break; case 7: /* unofficial extension */ - if (OPTION (Opt_insecure)) + if (option (Opt_insecure)) tt_printf ("%-.250s\012", rs[Rs_display_name]); break; case 8: /* unofficial extension */ @@ -3526,7 +3116,7 @@ XWindowAttributes wattr; Window wdummy; - dLocal (Display *, xdisp); + dLocal (Display *, dpy); if (nargs == 0) return; @@ -3537,22 +3127,22 @@ * commands */ case 1: /* deiconify window */ - XMapWindow (xdisp, parent[0]); + XMapWindow (dpy, parent[0]); break; case 2: /* iconify window */ - XIconifyWindow (xdisp, parent[0], display->screen); + XIconifyWindow (dpy, parent[0], display->screen); break; case 3: /* set position (pixels) */ - XMoveWindow (xdisp, parent[0], args[1], args[2]); + XMoveWindow (dpy, parent[0], args[1], args[2]); break; case 4: /* set size (pixels) */ set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); break; case 5: /* raise window */ - XRaiseWindow (xdisp, parent[0]); + XRaiseWindow (dpy, parent[0]); break; case 6: /* lower window */ - XLowerWindow (xdisp, parent[0]); + XLowerWindow (dpy, parent[0]); break; case 7: /* refresh window */ scr_touch (true); @@ -3573,18 +3163,18 @@ * reports - some output format copied from XTerm */ case 11: /* report window state */ - XGetWindowAttributes (xdisp, parent[0], &wattr); + XGetWindowAttributes (dpy, parent[0], &wattr); tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); break; case 13: /* report window position */ - XGetWindowAttributes (xdisp, parent[0], &wattr); - XTranslateCoordinates (xdisp, parent[0], wattr.root, + XGetWindowAttributes (dpy, parent[0], &wattr); + XTranslateCoordinates (dpy, parent[0], wattr.root, -wattr.border_width, -wattr.border_width, &x, &y, &wdummy); tt_printf ("\033[3;%d;%dt", x, y); break; case 14: /* report window size (pixels) */ - XGetWindowAttributes (xdisp, parent[0], &wattr); + XGetWindowAttributes (dpy, parent[0], &wattr); tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); break; case 18: /* report text area size (chars) */ @@ -3596,16 +3186,16 @@ case 20: /* report icon label */ { char *s; - XGetIconName (xdisp, parent[0], &s); - tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ + XGetIconName (dpy, parent[0], &s); + tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ XFree (s); } break; case 21: /* report window title */ { char *s; - XFetchName (xdisp, parent[0], &s); - tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ + XFetchName (dpy, parent[0], &s); + tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ XFree (s); } break; @@ -3642,6 +3232,8 @@ } else if (ch == C0_BEL || ch == CHAR_ST) break; + else if (ch == C0_SYN) + ch = cmd_get8 (); else if (ch < 0x20) return NULL; /* other control character - exit */ @@ -3651,10 +3243,7 @@ // stop at some sane length return NULL; - if (ch == C0_SYN) - string[n++] = cmd_get8 (); - else - string[n++] = ch; + string[n++] = ch; } string[n++] = '\0'; @@ -3740,9 +3329,13 @@ bool query = str[0] == '?' && !str[1]; int saveop = op; - dLocal (Display *, xdisp); + dLocal (Display *, dpy); assert (str != NULL); + + if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) + return; + switch (op) { case XTerm_name: @@ -3766,7 +3359,7 @@ const char *str = ""; if (prop - && XGetWindowProperty (xdisp, parent[0], + && XGetWindowProperty (dpy, parent[0], prop, 0, 1<<16, 0, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &value) == Success @@ -3788,7 +3381,7 @@ set_utf8_property (display->atom (str), eq + 1); } else - XDeleteProperty (xdisp, parent[0], + XDeleteProperty (dpy, parent[0], display->atom (str)); } break; @@ -3844,7 +3437,7 @@ process_color_seq (op, Color_IT, str, resp); break; #endif -#if TRANSPARENT && TINTING +#if ENABLE_TRANSPARENCY && TINTING case URxvt_Color_tint: process_color_seq (op, Color_tint, str, resp); @@ -3884,6 +3477,10 @@ scr_touch (true); #endif } +#if ENABLE_TRANSPARENCY && defined(HAVE_AFTERIMAGE) + if (option (Opt_transparent)) + check_our_parents (); +#endif } break; @@ -3920,7 +3517,7 @@ #endif if (query) tt_printf ("\33]%d;%-.250s%c", saveop, - OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc + option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc ? fontset[op - URxvt_font]->fontdesc : "", resp); else @@ -3944,7 +3541,7 @@ #if !ENABLE_MINIMAL case URxvt_locale: if (query) - tt_printf ("\33]%d;%-.250s%c", op, OPTION (Opt_insecure) ? locale : "", resp); + tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); else { set_locale (str); @@ -3969,7 +3566,7 @@ #if ENABLE_PERL case URxvt_perl: - if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) + if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) ; // no responses yet break; #endif @@ -4095,7 +3692,7 @@ #endif case 1048: /* alternative cursor save */ case 1049: - if (OPTION (Opt_secondaryScreen)) + if (option (Opt_secondaryScreen)) if (mode == 0) scr_cursor (RESTORE); else if (mode == 1) @@ -4170,14 +3767,14 @@ set_option (Opt_scrollTtyKeypress, state); break; case 1047: /* secondary screen w/ clearing last */ - if (OPTION (Opt_secondaryScreen)) + if (option (Opt_secondaryScreen)) if (current_screen != PRIMARY) scr_erase_screen (2); scr_change_screen (state); break; case 1049: /* secondary screen w/ clearing first */ scr_change_screen (state); - if (OPTION (Opt_secondaryScreen)) + if (option (Opt_secondaryScreen)) if (current_screen != PRIMARY) scr_erase_screen (2); break;