--- rxvt-unicode/src/command.C 2006/01/19 16:22:12 1.272 +++ rxvt-unicode/src/command.C 2006/01/25 02:42:06 1.284 @@ -66,9 +66,6 @@ #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) -// exception thrown when the command parser runs out of input data -class out_of_input { } out_of_input; - #if ENABLE_FRILLS || ISO_14755 #define ISO_14755_STARTED 0x80000000UL @@ -304,9 +301,6 @@ int ctrl, meta, shft, len; unsigned int newlen; KeySym keysym; -#ifdef DEBUG_CMD - static int debug_key = 1; /* accessible by a debugger only */ -#endif int valid_keysym; char kbuf[KBUFSZ]; @@ -907,16 +901,6 @@ tt_write (&ch, 1); } -#if defined(DEBUG_CMD) - /* Display keyboard buffer contents */ - unsigned char *p; - int i; - - fprintf (stderr, "key 0x%04X [%d]: `", (unsigned int)keysym, len); - for (i = 0, p = kbuf; i < len; i++, p++) - fprintf (stderr, (*p >= ' ' && *p < '\177' ? "%c" : "\\%03o"), *p); - fprintf (stderr, "'\n"); -#endif /* DEBUG_CMD */ tt_write (kbuf, (unsigned int)len); } /*}}} */ @@ -1046,7 +1030,7 @@ hidden_cursor = !hidden_cursor; want_refresh = 1; - w.start (w.at + BLINK_INTERVAL); + w.start (w.at + CURSOR_BLINK_INTERVAL); } #endif @@ -1284,16 +1268,6 @@ (32 + y + 1)); } -#ifdef USING_W11LIB -void -rxvt_W11_process_x_event (XEvent *ev) -{ - rxvt_t *r = rxvt_get_r (); - - x_cb (*ev); -} -#endif - /*{{{ process an X event */ void rxvt_term::x_cb (XEvent &ev) @@ -1407,52 +1381,35 @@ case ClientMessage: if (ev.xclient.format == 32 - && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) + && !HOOK_INVOKE ((this, HOOK_CLIENT_MESSAGE, DT_XEVENT, &ev, DT_END))) { - if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) - destroy (); + if (ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) + { + if (!HOOK_INVOKE ((this, HOOK_WM_PROTOCOLS, DT_XEVENT, &ev, DT_END))) + { + if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) + { + if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) + destroy (); + } #if ENABLE_EWMH - else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) - XSendEvent (disp, ev.xclient.window = display->root, - False, SubstructureRedirectMask | SubstructureNotifyMask, - &ev); + else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) + XSendEvent (disp, ev.xclient.window = display->root, + False, SubstructureRedirectMask | SubstructureNotifyMask, + &ev); #endif - } + } + } #if ENABLE_XEMBED - else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) - { - if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) - focus_in (); - else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) - focus_out (); - } + else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) + { + if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) + focus_in (); + else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) + focus_out (); + } #endif -#ifdef OFFIX_DND - /* OffiX Dnd (drag 'n' drop) protocol */ - else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] - && (ev.xclient.data.l[0] == DndFile - || ev.xclient.data.l[0] == DndDir - || ev.xclient.data.l[0] == DndLink)) - { - /* Get Dnd data */ - Atom ActualType; - int ActualFormat; - unsigned char *data; - unsigned long Size, RemainingBytes; - - XGetWindowProperty (disp, display->root, - xa[XA_DNDSELECTION], - 0L, 1000000L, - False, AnyPropertyType, - &ActualType, &ActualFormat, - &Size, &RemainingBytes, - &data); - set_string_property (XA_CUT_BUFFER0, data); - XFree (data); - selection_paste (display->root, XA_CUT_BUFFER0, true); - XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); } -#endif /* OFFIX_DND */ break; case MappingNotify: @@ -1514,9 +1471,10 @@ break; case PropertyNotify: - if (ev.xproperty.atom == xa[XA_VT_SELECTION] - && ev.xproperty.state == PropertyNewValue) - selection_property (ev.xproperty.window, ev.xproperty.atom); + if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) + if (ev.xproperty.atom == xa[XA_VT_SELECTION] + && ev.xproperty.state == PropertyNewValue) + selection_property (ev.xproperty.window, ev.xproperty.atom); break; @@ -1715,7 +1673,7 @@ want_refresh = 1; } - cursor_blink_ev.start (NOW + BLINK_INTERVAL); + cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); } #endif @@ -1753,7 +1711,7 @@ #endif #if CURSOR_BLINK if (OPTION (Opt_cursorBlink)) - cursor_blink_ev.start (NOW + BLINK_INTERVAL); + cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); #endif #if OFF_FOCUS_FADING if (rs[Rs_fade]) @@ -1844,6 +1802,9 @@ */ if (ev.window == vt) { + if (HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) + return; + #if ISO_14755 // 5.4 if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) @@ -1895,49 +1856,48 @@ if (ev.button != MEvent.button) MEvent.clicks = 0; - if (!HOOK_INVOKE ((this, HOOK_BUTTON_PRESS, DT_XEVENT, &ev, DT_END))) - switch (ev.button) - { - case Button1: - /* allow meta + click to select rectangular areas */ - /* should be done in screen.C */ + switch (ev.button) + { + case Button1: + /* allow meta + click to select rectangular areas */ + /* should be done in screen.C */ #if ENABLE_FRILLS - selection.rect = !!(ev.state & ModMetaMask); + selection.rect = !!(ev.state & ModMetaMask); #else - selection.rect = false; + selection.rect = false; #endif - /* allow shift+left click to extend selection */ - if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) - { - if (MEvent.button == Button1 && clickintime) - selection_rotate (ev.x, ev.y); - else - selection_extend (ev.x, ev.y, 1); - } - else - { - if (MEvent.button == Button1 && clickintime) - MEvent.clicks++; - else - MEvent.clicks = 1; + /* allow shift+left click to extend selection */ + if (ev.state & ShiftMask && !(priv_modes & PrivMode_mouse_report)) + { + if (MEvent.button == Button1 && clickintime) + selection_rotate (ev.x, ev.y); + else + selection_extend (ev.x, ev.y, 1); + } + else + { + if (MEvent.button == Button1 && clickintime) + MEvent.clicks++; + else + MEvent.clicks = 1; - selection_click (MEvent.clicks, ev.x, ev.y); - } + selection_click (MEvent.clicks, ev.x, ev.y); + } - MEvent.button = Button1; - break; + MEvent.button = Button1; + break; - case Button3: - if (MEvent.button == Button3 && clickintime) - selection_rotate (ev.x, ev.y); - else - selection_extend (ev.x, ev.y, 1); + case Button3: + if (MEvent.button == Button3 && clickintime) + selection_rotate (ev.x, ev.y); + else + selection_extend (ev.x, ev.y, 1); - MEvent.button = Button3; - break; - } - } + MEvent.button = Button3; + break; + } + } MEvent.time = ev.time; return; @@ -2110,11 +2070,15 @@ if (ev.window == vt) { + if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) + return; + #if ISO_14755 // 5.4 if (iso14755buf & (ISO_14755_STARTED | ISO_14755_54)) return; #endif + if (reportmode) { /* mouse report from vt window */ @@ -2148,9 +2112,6 @@ && ev.button == Button1 && MEvent.clicks <= 1) selection_extend (ev.x, ev.y, 0); - if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) - return; - switch (ev.button) { case Button1: @@ -2159,10 +2120,8 @@ break; case Button2: - if (IN_RANGE_EXC (ev.x, 0, width) - && IN_RANGE_EXC (ev.y, 0, height)) // inside window? - selection_request (ev.time); - + 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); break; #ifdef MOUSE_WHEEL @@ -2652,11 +2611,6 @@ } else { -#if WAIT_FOR_WM - /* wait (an arbitrary period) for the WM to do its thing - * needed for fvwm2.2.2 (and before?) */ - sleep (1); -#endif for (n = 0; n < (unsigned int)i; n++) { XSetWindowBackgroundPixmap (disp, parent[n], ParentRelative); @@ -2829,7 +2783,7 @@ // read the next character wchar_t -rxvt_term::next_char () +rxvt_term::next_char () NOTHROW { while (cmdbuf_ptr < cmdbuf_endp) { @@ -2860,20 +2814,22 @@ // read the next octet uint32_t -rxvt_term::next_octet () +rxvt_term::next_octet () NOTHROW { return cmdbuf_ptr < cmdbuf_endp ? (unsigned char)*cmdbuf_ptr++ : NOCHAR; } +static class out_of_input out_of_input; + /* rxvt_cmd_getc () - Return next input character */ /* * Return the next input character after first passing any keyboard input * to the command. */ wchar_t -rxvt_term::cmd_getc () +rxvt_term::cmd_getc () THROW ((class out_of_input)) { wchar_t c = next_char (); @@ -2884,7 +2840,7 @@ } uint32_t -rxvt_term::cmd_get8 () +rxvt_term::cmd_get8 () THROW ((class out_of_input)) { uint32_t c = next_octet (); @@ -3315,13 +3271,6 @@ if (arg[p] == -1) arg[p] = ndef; -#ifdef DEBUG_CMD - fprintf (stderr, "CSI "); - for (p = 0; p < nargs; p++) - fprintf (stderr, "%d%s", arg[p], p < nargs - 1 ? ";" : ""); - fprintf (stderr, "%c\n", ch); -#endif - /* * private mode handling */ @@ -3331,7 +3280,16 @@ { case '>': if (ch == CSI_DA) /* secondary device attributes */ - tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); + { + // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, + // 'U' for rxvt-unicode <= 7.2, and Mm85 (e.g. 7385 for 7.3) for later versions. + // + // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt + // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify + // that we do not support xterm mouse reporting (should be 95 when we do). + // + tt_printf ("\033[>%c%c85;94;0c", VERSION[0], VERSION[1]); + } break; case '?': if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') @@ -4044,7 +4002,7 @@ /* we're not using priv _yet_ */ void -rxvt_term::process_terminal_mode (int mode, int priv __attribute__ ((unused)), unsigned int nargs, const int *arg) +rxvt_term::process_terminal_mode (int mode, int priv UNUSED, unsigned int nargs, const int *arg) { unsigned int i, j; int state;