--- rxvt-unicode/src/command.C 2011/08/31 22:39:49 1.496 +++ rxvt-unicode/src/command.C 2012/06/05 11:00:40 1.515 @@ -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; @@ -1044,8 +1060,8 @@ void rxvt_term::cont_scroll_cb (ev::timer &w, int revents) { - if ((scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) - && scr_page (scrollBar.state == STATE_UP ? UP : DN, 1)) + if ((scrollBar.state == SB_STATE_UP || scrollBar.state == SB_STATE_DOWN) + && scr_page (scrollBar.state == SB_STATE_UP ? UP : DN, 1)) { want_refresh = 1; refresh_check (); @@ -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) { @@ -1559,7 +1589,7 @@ if (scrollBar.state && ev.xany.window == scrollBar.win) { - scrollBar.state = STATE_IDLE; + scrollBar.state = SB_STATE_IDLE; scrollBar.show (0); } } @@ -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) @@ -1657,7 +1687,7 @@ #endif } } - else if (scrollBar.state == STATE_MOTION && ev.xany.window == scrollBar.win) + else if (scrollBar.state == SB_STATE_MOTION && ev.xany.window == scrollBar.win) { while (XCheckTypedWindowEvent (dpy, scrollBar.win, MotionNotify, &ev)) @@ -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) @@ -1718,11 +1740,12 @@ h->flags = h->flags & ~XUrgencyHint | (enable ? XUrgencyHint : 0); XSetWMHints (dpy, parent, h); urgency_hint = enable; + XFree (h); } } #endif -void +void ecb_cold rxvt_term::focus_in () { if (!focus) @@ -1757,7 +1780,7 @@ } } -void +void ecb_cold rxvt_term::focus_out () { if (focus) @@ -1800,7 +1823,7 @@ } } -void +void ecb_cold rxvt_term::update_fade_color (unsigned int idx) { #if OFF_FOCUS_FADING @@ -1814,7 +1837,7 @@ } #if ENABLE_TRANSPARENCY || ENABLE_PERL -void +void ecb_hot rxvt_term::rootwin_cb (XEvent &ev) { make_current (); @@ -1974,7 +1997,7 @@ else if (scrollBar.dnButton (ev.y)) direction = DN; /* down */ - scrollBar.state = STATE_IDLE; + scrollBar.state = SB_STATE_IDLE; /* * Rxvt-style scrollbar: * move up if mouse is above slider @@ -2023,9 +2046,9 @@ if (scr_page (direction, 1)) { if (direction == UP) - scrollBar.state = STATE_UP; + scrollBar.state = SB_STATE_UP; else - scrollBar.state = STATE_DOWN; + scrollBar.state = SB_STATE_DOWN; } } else @@ -2034,32 +2057,32 @@ case Button2: switch (scrollBar.align) { - case R_SB_ALIGN_TOP: + case SB_ALIGN_TOP: csrO = 0; break; - case R_SB_ALIGN_CENTRE: + case SB_ALIGN_CENTRE: csrO = (scrollBar.bot - scrollBar.top) / 2; break; - case R_SB_ALIGN_BOTTOM: + case SB_ALIGN_BOTTOM: csrO = scrollBar.bot - scrollBar.top; break; } - if (scrollBar.style == R_SB_XTERM + if (scrollBar.style == SB_STYLE_XTERM || scrollBar.above_slider (ev.y) || scrollBar.below_slider (ev.y)) scr_move_to (scrollBar.position (ev.y) - csrO, scrollBar.size ()); - scrollBar.state = STATE_MOTION; + scrollBar.state = SB_STATE_MOTION; break; case Button1: - if (scrollBar.align == R_SB_ALIGN_CENTRE) + if (scrollBar.align == SB_ALIGN_CENTRE) csrO = ev.y - scrollBar.top; /* FALLTHROUGH */ case Button3: - if (scrollBar.style != R_SB_XTERM) + if (scrollBar.style != SB_STYLE_XTERM) { if (scrollBar.above_slider (ev.y)) # ifdef RXVT_SCROLL_FULL @@ -2074,7 +2097,7 @@ scr_page (DN, nrow / 4); # endif else - scrollBar.state = STATE_MOTION; + scrollBar.state = SB_STATE_MOTION; } else { @@ -2101,9 +2124,9 @@ if (!bypass_keystate) reportmode = !! (priv_modes & PrivMode_mouse_report); - if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) + if (scrollBar.state == SB_STATE_UP || scrollBar.state == SB_STATE_DOWN) { - scrollBar.state = STATE_IDLE; + scrollBar.state = SB_STATE_IDLE; scrollBar.show (0); } @@ -2163,7 +2186,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; @@ -2208,7 +2231,7 @@ /*}}} */ -void +void ecb_hot rxvt_term::cmd_parse () { wchar_t ch = NOCHAR; @@ -2337,7 +2360,7 @@ } // read the next character -wchar_t +wchar_t ecb_hot rxvt_term::next_char () NOTHROW { while (cmdbuf_ptr < cmdbuf_endp) @@ -2371,7 +2394,7 @@ } // read the next octet -uint32_t +uint32_t ecb_hot rxvt_term::next_octet () NOTHROW { return cmdbuf_ptr < cmdbuf_endp @@ -2381,7 +2404,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 (); @@ -2392,7 +2415,7 @@ return c; } -uint32_t +uint32_t ecb_hot rxvt_term::cmd_get8 () THROW ((class out_of_input)) { uint32_t c = next_octet (); @@ -2406,7 +2429,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"); @@ -2417,7 +2440,7 @@ return stream; } -int +int ecb_cold rxvt_term::pclose_printer (FILE *stream) { fflush (stream); @@ -2427,7 +2450,7 @@ /* * simulate attached vt100 printer */ -void +void ecb_cold rxvt_term::process_print_pipe () { FILE *fd = popen_printer (); @@ -2492,7 +2515,7 @@ }; /*{{{ process non-printing single characters */ -void +void ecb_hot rxvt_term::process_nonprinting (unicode_t ch) { switch (ch) @@ -2548,7 +2571,7 @@ /*{{{ process VT52 escape sequences */ -void +void ecb_cold rxvt_term::process_escape_vt52 (unicode_t ch) { int row, col; @@ -2608,7 +2631,7 @@ /*{{{ process escape sequences */ -void +void ecb_hot rxvt_term::process_escape_seq () { unicode_t ch = cmd_getc (); @@ -2770,7 +2793,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; @@ -2887,11 +2910,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; @@ -3134,7 +3157,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; @@ -3430,7 +3453,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 (); @@ -3444,10 +3467,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 @@ -3456,14 +3488,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) @@ -3572,14 +3612,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 @@ -3799,7 +3842,7 @@ /*}}} */ /*{{{ process sgr sequences */ -void +void ecb_hot rxvt_term::process_sgr_mode (unsigned int nargs, const int *arg) { unsigned int i;