--- rxvt-unicode/src/command.C 2011/09/30 13:31:21 1.498 +++ rxvt-unicode/src/command.C 2012/06/05 14:46:54 1.516 @@ -56,10 +56,10 @@ # include "keyboard.h" #endif -#include +#include #if LINUX_YIELD_HACK -# include +# include #endif /*----------------------------------------------------------------------*/ @@ -133,7 +133,7 @@ 0, }; -void +void ecb_cold rxvt_term::iso14755_54 (int x, int y) { x = Pixel2Col (x); @@ -160,7 +160,7 @@ } } -void +void ecb_cold rxvt_term::iso14755_51 (unicode_t ch, rend_t r, int x, int y) { rxvt_fontset *fs = FONTSET (r); @@ -256,7 +256,7 @@ } #endif -void +void ecb_cold rxvt_term::commit_iso14755 () { wchar_t ch = iso14755buf & ISO_14755_MASK; @@ -284,7 +284,7 @@ iso14755buf = 0; } -static int +static int ecb_cold hex_keyval (XKeyEvent &ev) { // check whether this event corresponds to a hex digit @@ -303,7 +303,7 @@ } #endif -static inline KeySym +static inline KeySym ecb_cold translate_keypad (KeySym keysym, bool kp) { #ifdef XK_KP_Home @@ -339,7 +339,7 @@ return keysym; } -static inline int +static inline int ecb_cold map_function_key (KeySym keysym) { int param = 0; @@ -398,7 +398,7 @@ return param; } -void +void ecb_cold rxvt_term::key_press (XKeyEvent &ev) { int ctrl, meta, shft, len; @@ -423,7 +423,7 @@ kbuf[0] = 0; -#ifdef USE_XIM +#if USE_XIM if (Input_Context) { Status status_return; @@ -778,13 +778,28 @@ if (newlen) len = strlen (kbuf); - /* - * Pass meta for all function keys, if 'meta' option set - */ + if (len > 0) + { + /* + * pass Shift/Control indicators for function keys ending with `~' + * + * eg, + * Prior = "ESC[5~" + * Shift+Prior = "ESC[5$" + * Ctrl+Prior = "ESC[5^" + * Ctrl+Shift+Prior = "ESC[5@" + */ + if (kbuf[0] == C0_ESC && kbuf[1] == '[' && kbuf[len - 1] == '~') + kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); + + /* + * Pass meta for all function keys, if 'meta' option set + */ #ifdef META8_OPTION - if (meta && (meta_char == 0x80) && len > 0) - kbuf[len - 1] |= 0x80; + if (meta && (meta_char == 0x80)) + kbuf[len - 1] |= 0x80; #endif + } } else if (ctrl && keysym == XK_minus) @@ -828,20 +843,6 @@ want_refresh = 1; } - /* - * these modifications only affect the static keybuffer - * pass Shift/Control indicators for function keys ending with `~' - * - * eg, - * Prior = "ESC[5~" - * Shift+Prior = "ESC[5$" - * Ctrl+Prior = "ESC[5^" - * Ctrl+Shift+Prior = "ESC[5@" - * Meta adds an Escape prefix (with META8_OPTION, if meta == ). - */ - if (kbuf[0] == C0_ESC && kbuf[1] == '[' && kbuf[len - 1] == '~') - kbuf[len - 1] = (shft ? (ctrl ? '@' : '$') : (ctrl ? '^' : '~')); - /* escape prefix */ if (meta #ifdef META8_OPTION @@ -856,7 +857,7 @@ tt_write (kbuf, (unsigned int)len); } -void +void ecb_cold rxvt_term::key_release (XKeyEvent &ev) { #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL @@ -988,7 +989,7 @@ scr_refresh (); scrollBar.show (1); -#ifdef USE_XIM +#if USE_XIM im_send_spot (); #endif } @@ -1017,6 +1018,21 @@ #ifdef CURSOR_BLINK void +rxvt_term::cursor_blink_reset () +{ + if (hidden_cursor) + { + hidden_cursor = 0; + want_refresh = 1; + } + + if (option (Opt_cursorBlink)) + cursor_blink_ev.again (); + else + cursor_blink_ev.stop (); +} + +void rxvt_term::cursor_blink_cb (ev::timer &w, int revents) { hidden_cursor = !hidden_cursor; @@ -1205,7 +1221,7 @@ refresh_check (); } -void +void ecb_cold rxvt_term::pointer_unblank () { XDefineCursor (dpy, vt, TermWin_cursor); @@ -1220,7 +1236,7 @@ } #ifdef POINTER_BLANK -void +void ecb_cold rxvt_term::pointer_blank () { if (!option (Opt_pointerBlank)) @@ -1232,7 +1248,7 @@ hidden_pointer = 1; } -void +void ecb_cold rxvt_term::pointer_cb (ev::timer &w, int revents) { make_current (); @@ -1334,7 +1350,7 @@ } /*{{{ process an X event */ -void +void ecb_hot rxvt_term::x_cb (XEvent &ev) { make_current (); @@ -1447,11 +1463,19 @@ while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) ; + bool want_position_change = SHOULD_INVOKE (HOOK_POSITION_CHANGE); + #ifdef HAVE_BG_PIXMAP - bool moved = false; if (bg_window_position_sensitive ()) + want_position_change = true; +#endif + + bool moved = false; + + if (want_position_change) { int x, y; + if (ev.xconfigure.send_event) { x = ev.xconfigure.x; @@ -1460,11 +1484,17 @@ else get_window_origin (x, y); + if (x != parent_x || y != parent_y) + { + HOOK_INVOKE ((this, HOOK_POSITION_CHANGE, DT_INT, x, DT_INT, y, DT_END)); + parent_x = x; + parent_y = y; + } + if (bg_set_position (x, y) || !(bg_flags & BG_IS_VALID)) moved = true; } -#endif if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) { @@ -1635,7 +1665,7 @@ else { scroll_selection_dir = DN; - dist = ev.xbutton.y - (int_bwidth + height); + dist = ev.xbutton.y - (int_bwidth + vt_height); } scroll_selection_lines = Pixel2Height (dist) @@ -1677,16 +1707,8 @@ } #if defined(CURSOR_BLINK) - if (option (Opt_cursorBlink) && ev.type == KeyPress) - { - if (hidden_cursor) - { - hidden_cursor = 0; - want_refresh = 1; - } - - cursor_blink_ev.again (); - } + if (ev.type == KeyPress) + cursor_blink_reset (); #endif #if defined(POINTER_BLANK) @@ -1707,7 +1729,7 @@ } #if ENABLE_FRILLS -void +void ecb_cold rxvt_term::set_urgency (bool enable) { if (enable == urgency_hint) @@ -1723,7 +1745,7 @@ } #endif -void +void ecb_cold rxvt_term::focus_in () { if (!focus) @@ -1758,7 +1780,7 @@ } } -void +void ecb_cold rxvt_term::focus_out () { if (focus) @@ -1801,7 +1823,7 @@ } } -void +void ecb_cold rxvt_term::update_fade_color (unsigned int idx) { #if OFF_FOCUS_FADING @@ -1815,7 +1837,7 @@ } #if ENABLE_TRANSPARENCY || ENABLE_PERL -void +void ecb_hot rxvt_term::rootwin_cb (XEvent &ev) { make_current (); @@ -1824,7 +1846,6 @@ && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) return; -# if ENABLE_TRANSPARENCY switch (ev.type) { case PropertyNotify: @@ -1835,13 +1856,17 @@ if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) { +# if ENABLE_TRANSPARENCY bg_set_root_pixmap (); update_background (); +#endif +#if ENABLE_PERL + HOOK_INVOKE ((this, HOOK_ROOTPMAP_CHANGE, DT_END)); +#endif } break; } -# endif refresh_check (); } @@ -2164,7 +2189,7 @@ break; case Button2: - if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? + if (IN_RANGE_EXC (ev.x, 0, vt_width) && IN_RANGE_EXC (ev.y, 0, vt_height)) // inside window? selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); break; @@ -2209,7 +2234,7 @@ /*}}} */ -void +void ecb_hot rxvt_term::cmd_parse () { wchar_t ch = NOCHAR; @@ -2338,7 +2363,7 @@ } // read the next character -wchar_t +wchar_t ecb_hot rxvt_term::next_char () NOTHROW { while (cmdbuf_ptr < cmdbuf_endp) @@ -2372,7 +2397,7 @@ } // read the next octet -uint32_t +uint32_t ecb_hot rxvt_term::next_octet () NOTHROW { return cmdbuf_ptr < cmdbuf_endp @@ -2382,7 +2407,7 @@ static class out_of_input out_of_input; -wchar_t +wchar_t ecb_hot rxvt_term::cmd_getc () THROW ((class out_of_input)) { wchar_t c = next_char (); @@ -2393,7 +2418,7 @@ return c; } -uint32_t +uint32_t ecb_hot rxvt_term::cmd_get8 () THROW ((class out_of_input)) { uint32_t c = next_octet (); @@ -2407,7 +2432,7 @@ /*{{{ print pipe */ /*----------------------------------------------------------------------*/ #ifdef PRINTPIPE -FILE * +FILE * ecb_cold rxvt_term::popen_printer () { FILE *stream = popen (rs[Rs_print_pipe] ? rs[Rs_print_pipe] : PRINTPIPE, "w"); @@ -2418,7 +2443,7 @@ return stream; } -int +int ecb_cold rxvt_term::pclose_printer (FILE *stream) { fflush (stream); @@ -2428,7 +2453,7 @@ /* * simulate attached vt100 printer */ -void +void ecb_cold rxvt_term::process_print_pipe () { FILE *fd = popen_printer (); @@ -2493,7 +2518,7 @@ }; /*{{{ process non-printing single characters */ -void +void ecb_hot rxvt_term::process_nonprinting (unicode_t ch) { switch (ch) @@ -2549,7 +2574,7 @@ /*{{{ process VT52 escape sequences */ -void +void ecb_cold rxvt_term::process_escape_vt52 (unicode_t ch) { int row, col; @@ -2609,7 +2634,7 @@ /*{{{ process escape sequences */ -void +void ecb_hot rxvt_term::process_escape_seq () { unicode_t ch = cmd_getc (); @@ -2771,7 +2796,7 @@ make_byte (0,0,0,0,0,0,0,0), /* x, y, z, {, |, }, ~, */ }; -void +void ecb_hot rxvt_term::process_csi_seq () { unicode_t ch, priv, i; @@ -2888,11 +2913,11 @@ #endif case CSI_CUU: /* 8.3.22: (1) CURSOR UP */ - case CSI_VPR: /* 8.3.161: (1) LINE POSITION FORWARD */ + case CSI_VPB: /* 8.3.160: (1) LINE POSITION BACKWARD */ arg[0] = -arg[0]; /* FALLTHROUGH */ case CSI_CUD: /* 8.3.19: (1) CURSOR DOWN */ - case CSI_VPB: /* 8.3.160: (1) LINE POSITION BACKWARD */ + case CSI_VPR: /* 8.3.161: (1) LINE POSITION FORWARD */ scr_gotorc (arg[0], 0, RELATIVE); break; @@ -3135,7 +3160,7 @@ //case 9: NYI, TODO, restore maximized window or maximize window default: if (args[0] >= 24) /* set height (chars) */ - set_widthheight ((unsigned int)width, + set_widthheight ((unsigned int)vt_width, (unsigned int) (args[1] * fheight)); break; @@ -3431,7 +3456,7 @@ bool changed = false; if (ISSET_PIXCOLOR (Color_tint)) - changed = bg_set_tint (pix_colors_focused [Color_tint]); + changed = root_effects.set_tint (pix_colors_focused [Color_tint]); if (changed) update_background (); @@ -3445,10 +3470,19 @@ if (!strcmp (str, "?")) { char str[256]; + int h_scale = 0, v_scale = 0; + int h_align = 0, v_align = 0; + if (image_vec.size () > 0) + { + h_scale = image_vec[0].h_scale; + v_scale = image_vec[0].v_scale; + h_align = image_vec[0].h_align; + v_align = image_vec[0].v_align; + } sprintf (str, "[%dx%d+%d+%d]", - min (h_scale, 32767), min (v_scale, 32767), - min (h_align, 32767), min (v_align, 32767)); + h_scale, v_scale, + h_align, v_align); process_xterm_seq (XTerm_title, str, CHAR_ST); } else @@ -3457,14 +3491,22 @@ if (*str != ';') { - if (bg_set_file (str)) /* change pixmap */ - changed = true; + if (image_vec.size () > 0) + changed = image_vec[0].set_file_geometry (str); + else + { + rxvt_image *image = new_image (); + if (!image->set_file_geometry (str)) + image_vec.pop_back (); + else + changed = true; + } } else { str++; - if (bg_set_geometry (str, true)) - changed = true; + if (image_vec.size () > 0) + changed = image_vec[0].set_geometry (str, true); } if (changed) @@ -3573,14 +3615,17 @@ * 't' = toggle * so no need for fancy checking */ -int +int ecb_cold rxvt_term::privcases (int mode, unsigned long bit) { int state; if (mode == 's') { - SavedModes |= (priv_modes & bit); + if (priv_modes & bit) + SavedModes |= bit; + else + SavedModes &= ~bit; return -1; } else @@ -3800,7 +3845,7 @@ /*}}} */ /*{{{ process sgr sequences */ -void +void ecb_hot rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) { unsigned int i;