Color Options:
#include "../config.h"
#include "rxvt.h"
+-- 3 lines: #if 0 OBSOLETE HOTKEY CODE ---------------------------------------
#ifdef DEBUG_VERBOSE
# define DEBUG_LEVEL 1
#else
# define DEBUG_LEVEL 0
#endif
#if DEBUG_LEVEL
# define DBG_MSG(d,x) if(d <= DEBUG_LEVEL) fprintf x
#else
# define DBG_MSG(d,x)
#endif
#ifdef USE_DEADKEY
typedef struct _DeadKeyChar {
KeySym ks;
KeySym dk;
KeySym ach;
} DeadKeyChar;
static DeadKeyChar dkc_tab[] = {
{XK_A, XK_grave, XK_Agrave},
{XK_A, XK_acute, XK_Agrave},
{XK_A, XK_apostrophe, XK_Aacute},
{XK_A, XK_asciicircum, XK_Acircumflex},
{XK_A, XK_asciitilde, XK_Atilde},
{XK_A, XK_quotedbl, XK_Adiaeresis},
{XK_a, XK_grave, XK_agrave},
{XK_a, XK_acute, XK_agrave},
{XK_a, XK_apostrophe, XK_aacute},
{XK_a, XK_asciicircum, XK_acircumflex},
{XK_a, XK_asciitilde, XK_atilde},
{XK_a, XK_quotedbl, XK_adiaeresis},
{XK_C, XK_grave, XK_Ccedilla},
{XK_C, XK_acute, XK_Ccedilla},
{XK_c, XK_grave, XK_ccedilla},
{XK_c, XK_acute, XK_ccedilla},
{XK_E, XK_grave, XK_Egrave},
{XK_E, XK_acute, XK_Eacute},
{XK_E, XK_apostrophe, XK_Eacute},
{XK_E, XK_asciicircum, XK_Ecircumflex},
{XK_E, XK_quotedbl, XK_Ediaeresis},
{XK_e, XK_grave, XK_egrave},
{XK_e, XK_acute, XK_eacute},
{XK_e, XK_apostrophe, XK_eacute},
{XK_e, XK_asciicircum, XK_ecircumflex},
{XK_e, XK_quotedbl, XK_ediaeresis},
{XK_I, XK_grave, XK_Igrave},
{XK_I, XK_acute, XK_Iacute},
{XK_I, XK_apostrophe, XK_Iacute},
{XK_I, XK_asciicircum, XK_Icircumflex},
{XK_I, XK_quotedbl, XK_Idiaeresis},
{XK_i, XK_grave, XK_igrave},
{XK_i, XK_acute, XK_iacute},
{XK_i, XK_apostrophe, XK_iacute},
{XK_i, XK_asciicircum, XK_icircumflex},
{XK_i, XK_quotedbl, XK_idiaeresis},
{XK_N, XK_asciitilde, XK_Ntilde},
{XK_n, XK_asciitilde, XK_ntilde},
{XK_O, XK_grave, XK_Ograve},
{XK_O, XK_acute, XK_Oacute},
{XK_O, XK_apostrophe, XK_Oacute},
{XK_O, XK_asciicircum, XK_Ocircumflex},
{XK_O, XK_asciitilde, XK_Otilde},
{XK_O, XK_quotedbl, XK_Odiaeresis},
{XK_o, XK_grave, XK_ograve},
{XK_o, XK_acute, XK_oacute},
{XK_o, XK_apostrophe, XK_oacute},
{XK_o, XK_asciicircum, XK_ocircumflex},
{XK_o, XK_asciitilde, XK_otilde},
{XK_o, XK_quotedbl, XK_odiaeresis},
{XK_U, XK_grave, XK_Ugrave},
{XK_U, XK_acute, XK_Uacute},
{XK_U, XK_apostrophe, XK_Uacute},
{XK_U, XK_asciicircum, XK_Ucircumflex},
{XK_U, XK_quotedbl, XK_Udiaeresis},
{XK_u, XK_grave, XK_ugrave},
{XK_u, XK_acute, XK_uacute},
{XK_u, XK_apostrophe, XK_uacute},
{XK_u, XK_asciicircum, XK_ucircumflex},
{XK_u, XK_quotedbl, XK_udiaeresis},
{XK_Y, XK_acute, XK_Yacute},
{XK_Y, XK_apostrophe, XK_Yacute},
{XK_y, XK_acute, XK_yacute},
{XK_y, XK_apostrophe, XK_yacute},
{XK_y, XK_quotedbl, XK_ydiaeresis},
{0, 0, 0},
};
# define DEADKEY_CHAR_NUMBER (int)((sizeof(dkc_tab) / sizeof(DeadKeyChar)))
#endif
void rxvt_process_keypress (rxvt_t*, XKeyEvent*);
void rxvt_clean_cmd_page (rxvt_t*);
int rxvt_find_cmd_child (rxvt_t*, int*);
void rxvt_check_cmdbuf (rxvt_t*, int);
unsigned char rxvt_cmd_getc (rxvt_t*, int* page);
#ifdef POINTER_BLANK
void rxvt_pointer_blank (rxvt_t*, int);
#endif
void rxvt_mouse_report (rxvt_t*, const XButtonEvent*);
void rxvt_set_bg_focused (rxvt_t*, int, Bool);
#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
void rxvt_process_keyrelease (rxvt_t*, XKeyEvent*);
#endif
void rxvt_scrollbar_dispatcher (rxvt_t*, int, XButtonEvent*);
void rxvt_process_buttonpress (rxvt_t*, int, XButtonEvent*);
#ifdef MOUSE_WHEEL
void rxvt_process_wheel_button (rxvt_t*, int, XButtonEvent*);
#endif
void rxvt_process_buttonrelease (rxvt_t*, int, XButtonEvent*);
void rxvt_process_clientmessage (rxvt_t*, XClientMessageEvent*);
void rxvt_process_visibilitynotify (rxvt_t*, XVisibilityEvent*);
#ifdef MONITOR_ENTER_LEAVE
void rxvt_process_enter (rxvt_t*, XCrossingEvent*);
void rxvt_process_leave (rxvt_t*, XCrossingEvent*);
#endif
void rxvt_process_focusin (rxvt_t*, XFocusChangeEvent*);
void rxvt_process_focusout (rxvt_t*, XFocusChangeEvent*);
int rxvt_calc_colrow (rxvt_t* r, unsigned int width, unsigned int height);
void rxvt_resize_sub_windows (rxvt_t* r);
void rxvt_resize_on_configure (rxvt_t* r, unsigned int width, unsigned int height);
#ifndef NO_FRILLS
Bool getWMStruts (Display *dpy, Window w, CARD32 *left, CARD32 *right, CARD32 *top, CARD32 *bottom);
#endif
void rxvt_process_configurenotify (rxvt_t*, XConfigureEvent*);
void rxvt_process_selectionnotify (rxvt_t*, XSelectionEvent*);
void rxvt_process_propertynotify (rxvt_t*, XEvent*);
void rxvt_process_expose (rxvt_t*, XEvent*);
void rxvt_process_motionnotify (rxvt_t*, XEvent*);
void rxvt_process_x_event (rxvt_t*, XEvent*);
#ifdef PRINTPIPE
void rxvt_process_print_pipe (rxvt_t*, int);
#endif
void rxvt_process_nonprinting (rxvt_t*, int, unsigned char);
void rxvt_process_escape_vt52 (rxvt_t*, int, unsigned char);
void rxvt_process_escape_seq (rxvt_t*, int);
void rxvt_process_csi_seq (rxvt_t*, int);
#ifndef NO_FRILLS
void rxvt_process_window_ops (rxvt_t*, int, const int*, unsigned int);
#endif
unsigned char* rxvt_get_to_st (rxvt_t*, int, unsigned char*);
void rxvt_process_dcs_seq (rxvt_t*, int);
void rxvt_process_osc_seq (rxvt_t*, int);
void rxvt_xwsh_seq (rxvt_t*, int, const char*);
void rxvt_process_xwsh_seq (rxvt_t*, int);
int rxvt_privcases (rxvt_t*, int, int, unsigned long);
void rxvt_process_terminal_mode (rxvt_t*, int, int, int, unsigned int, const int*);
void rxvt_process_sgr_mode (rxvt_t*, int, unsigned int, const int*);
void rxvt_process_graphics (rxvt_t*, int);
+--630 lines: Process keysyms between 0xff00 and 0xffff ------------------------
+--523 lines: Convert the keypress event into a string -------------------------
+--887 lines: rxvt_cmd_write(), rxvt_cmd_getc() --------------------------------
void
rxvt_pointer_unblank(rxvt_t* r, int page)
{
DBG_MSG( 1, ( stderr, "Unblanking pointer\n"));
XDefineCursor(r->Xdisplay, PVTS(r, page)->vt, r->term_pointer);
rxvt_recolour_cursor(r);
#ifdef POINTER_BLANK
if (!(r->Options & Opt_pointerBlank))
return;
PVTS(r, page)->hidden_pointer = 0;
if (r->h->pointerBlankDelay > 0)
{
struct timeval tp;
(void)gettimeofday(&tp, NULL);
r->h->lastmotion.tv_sec = tp.tv_sec;
r->h->lastmotion.tv_usec = tp.tv_usec;
}
#endif
}
#ifdef POINTER_BLANK
void
rxvt_pointer_blank(rxvt_t* r, int page)
{
DBG_MSG(1, ( stderr, "Blanking pointer\n"));
if ((r->Options & Opt_pointerBlank) && (None != r->h->blank_pointer))
{
XDefineCursor(r->Xdisplay, PVTS(r, page)->vt,
r->h->blank_pointer);
XFlush(r->Xdisplay);
PVTS(r, page)->hidden_pointer = 1;
}
}
#endif
void
rxvt_mouse_report(rxvt_t* r, const XButtonEvent *ev)
{
int button_number, key_state = 0;
int x, y;
x = ev->x;
y = ev->y;
rxvt_pixel_position(r, &x, &y);
if (r->h->MEvent.button == AnyButton)
{
button_number = 3;
}
else
{
button_number = r->h->MEvent.button - Button1;
if (button_number >= 3)
button_number += (64 - 3);
}
if (AVTS(r)->PrivateModes & PrivMode_MouseX10)
{
key_state = 0;
if (button_number == 3)
return;
}
else
{
key_state = ((r->h->MEvent.state & ShiftMask) ? 4 : 0)
+ ((r->h->MEvent.state & r->h->ModMetaMask) ? 8 : 0)
+ ((r->h->MEvent.state & ControlMask) ? 16 : 0);
#ifdef MOUSE_REPORT_DOUBLECLICK
key_state += ((r->h->MEvent.clicks > 1) ? 32 : 0);
#endif
}
#ifdef DEBUG_MOUSEREPORT
fprintf(stderr, "Mouse [");
if (key_state & 16)
fputc('C', stderr);
if (key_state & 4)
fputc('S', stderr);
if (key_state & 8)
fputc('A', stderr);
if (key_state & 32)
fputc('2', stderr);
fprintf(stderr, "]: <%d>, %d/%d\n",
button_number,
x + 1,
y + 1);
#else
rxvt_tt_printf(r, ATAB(r), "\033[M%c%c%c",
(32 + button_number + key_state),
(32 + x + 1),
(32 + y + 1));
#endif
}
void
rxvt_set_bg_focused(rxvt_t* r, int page, Bool focus)
{
XGCValues gcvalue;
assert (0 == r->ufbg_switched);
if (focus)
rxvt_restore_ufbg_color (r);
else
rxvt_switch_ufbg_color (r);
gcvalue.background = r->PixColors[Color_bg];
# ifdef TRANSPARENT
if (!(r->Options & Opt_transparent))
# endif
#ifdef BACKGROUND_IMAGE
if (None == PVTS(r, page)->pixmap)
#endif
{
XSetBackground(r->Xdisplay, r->TermWin.gc,
r->PixColors[Color_bg]);
XSetWindowBackground(r->Xdisplay, PVTS(r, page)->vt,
r->PixColors[Color_bg]);
}
#ifdef TRANSPARENT
if (r->Options & Opt_transparent)
rxvt_check_our_parents(r);
else
#endif
#ifdef BACKGROUND_IMAGE
if (None != PVTS(r, page)->pixmap)
{
DBG_MSG (1, (stderr, "reset pixmap bg of vt %d\n", page));
XSetWindowBackgroundPixmap(r->Xdisplay, PVTS(r, page)->vt,
PVTS(r, page)->pixmap);
}
#endif
{
}
XSetForeground (r->Xdisplay, r->TermWin.gc, r->PixColors[Color_fg]);
XSetBackground (r->Xdisplay, r->TermWin.gc, r->PixColors[Color_bg]);
rxvt_scr_clear(r, page);
rxvt_scr_touch(r, page, True);
}
#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
void
rxvt_process_keyrelease(rxvt_t* r, XKeyEvent *ev)
{
DBG_MSG(2, (stderr, "KeyRelease event\n"));
if (!(ev->state & ControlMask))
r->h->mouse_slip_wheel_speed = 0;
else
{
KeySym ks;
ks = XKeycodeToKeysym(r->Xdisplay, ev->keycode, 0);
if (ks == XK_Control_L || ks == XK_Control_R)
r->h->mouse_slip_wheel_speed = 0;
}
}
#endif
#ifdef HAVE_SCROLLBARS
void
rxvt_scrollbar_dispatcher (rxvt_t* r, int page, XButtonEvent* ev)
{
int reportmode = 0;
struct rxvt_hidden* h = r->h;
if (!h->bypass_keystate)
reportmode = !!(PVTS(r, page)->PrivateModes & PrivMode_mouse_report);
scrollbar_setIdle();
# ifndef NO_SCROLLBAR_REPORT
if (reportmode)
{
if (
(r->scrollBar.style == R_SB_NEXT && scrollbarnext_upButton(ev->y))
|| (r->scrollBar.style == R_SB_RXVT && scrollbarrxvt_upButton(ev->y))
|| (r->scrollBar.style == R_SB_SGI && scrollbarsgi_upButton(ev->y))
)
{
rxvt_tt_printf(r, page, "\033[A");
}
else if (
(r->scrollBar.style == R_SB_NEXT && scrollbarnext_dnButton(ev->y))
|| (r->scrollBar.style == R_SB_RXVT
&& scrollbarrxvt_dnButton(ev->y))
|| (r->scrollBar.style == R_SB_SGI
&& scrollbarsgi_dnButton(ev->y))
)
{
rxvt_tt_printf(r, page, "\033[B");
}
else
{
switch (ev->button)
{
case Button2:
rxvt_tt_printf(r, page, "\014");
break;
case Button1:
rxvt_tt_printf(r, page, "\033[6~");
break;
case Button3:
rxvt_tt_printf(r, page, "\033[5~");
break;
}
}
}
else
# endif
{
int upordown = 0;
if (r->scrollBar.style == R_SB_NEXT)
{
if (scrollbarnext_upButton(ev->y))
upordown = -1;
else if (scrollbarnext_dnButton(ev->y))
upordown = 1;
}
else if (r->scrollBar.style == R_SB_RXVT)
{
if (scrollbarrxvt_upButton(ev->y))
upordown = -1;
else if (scrollbarrxvt_dnButton(ev->y))
upordown = 1;
}
else if (r->scrollBar.style == R_SB_SGI)
{
if (scrollbarsgi_upButton(ev->y))
upordown = -1;
else if (scrollbarsgi_dnButton(ev->y))
upordown = 1;
}
if (upordown)
{
#ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
h->scroll_arrow_delay = SCROLLBAR_INITIAL_DELAY;
#endif
if (rxvt_scr_page(r, ATAB(r), upordown < 0?UP:DN,1))
{
if (upordown < 0)
scrollbar_setUp();
else
scrollbar_setDn();
}
}
else
{
switch (ev->button)
{
case Button2:
switch (h->scrollbar_align)
{
case R_SB_ALIGN_TOP:
h->csrO = 0;
break;
case R_SB_ALIGN_CENTRE:
h->csrO = (r->scrollBar.bot-r->scrollBar.top)/2;
break;
case R_SB_ALIGN_BOTTOM:
h->csrO = r->scrollBar.bot - r->scrollBar.top;
break;
}
if (
r->scrollBar.style == R_SB_XTERM
|| scrollbar_above_slider(ev->y)
|| scrollbar_below_slider(ev->y)
)
{
rxvt_scr_move_to(r, page,
scrollbar_position(ev->y) - h->csrO, scrollbar_size());
}
scrollbar_setMotion();
break;
case Button1:
if (h->scrollbar_align == R_SB_ALIGN_CENTRE)
h->csrO = ev->y - r->scrollBar.top;
case Button3:
if (r->scrollBar.style != R_SB_XTERM)
{
if (scrollbar_above_slider(ev->y))
# ifdef RXVT_SCROLL_FULL
rxvt_scr_page(r, ATAB(r), UP, r->TermWin.nrow-1);
# else
rxvt_scr_page(r, ATAB(r), UP, r->TermWin.nrow/4);
# endif
else if (scrollbar_below_slider(ev->y))
# ifdef RXVT_SCROLL_FULL
rxvt_scr_page(r, ATAB(r), DN, r->TermWin.nrow - 1);
# else
rxvt_scr_page(r, ATAB(r), DN, r->TermWin.nrow / 4);
# endif
else
scrollbar_setMotion();
}
else
{
rxvt_scr_page(r, ATAB(r),
(ev->button == Button1 ? DN : UP),
(r->TermWin.nrow * scrollbar_position(ev->y)
/ scrollbar_size()));
}
break;
}
}
}
return;
}
#endif
void
rxvt_process_buttonpress(rxvt_t* r, int page, XButtonEvent *ev)
{
int reportmode = 0, clickintime;
struct rxvt_hidden* h = r->h;
DBG_MSG(2, (stderr, "ButtonPress event\n"));
h->bypass_keystate = ev->state & (h->ModMetaMask | ShiftMask);
if (!h->bypass_keystate)
reportmode = !!(PVTS(r, page)->PrivateModes & PrivMode_mouse_report);
if (ev->window == PVTS(r, page)->vt)
{
#ifdef HAVE_MENUBAR
if( ev->state & ControlMask && !r->h->ActiveMenu)
{
int button;
switch( ev->button )
{
case Button1:
button = 0; break;
case Button2:
button = 1; break;
case Button3:
button = 2; break;
default:
button = -1;
}
if( button >=0 && r->h->popupMenu[button] )
{
int x, y;
Window unused_cr;
r->h->showingMenu |= POPUP_MENU;
XTranslateCoordinates( r->Xdisplay, ev->window, r->TermWin.parent,
ev->x, ev->y, &x, &y, &unused_cr);
r->h->ActiveMenu = r->h->popupMenu[button];
r->h->ActiveMenu->x = x;
r->h->ActiveMenu->y = y;
XDefineCursor(r->Xdisplay, AVTS(r)->vt, r->h->bar_pointer);
rxvt_menu_show(r);
return;
}
}
#endif
clickintime = ev->time - h->MEvent.time < MULTICLICK_TIME;
if (reportmode)
{
h->MEvent.state = ev->state;
#ifdef MOUSE_REPORT_DOUBLECLICK
if (ev->button == h->MEvent.button && clickintime)
{
h->MEvent.clicks++;
if (h->MEvent.clicks > 1)
{
h->MEvent.clicks = 2;
rxvt_mouse_report(r, ev);
h->MEvent.clicks = 0;
h->MEvent.button = AnyButton;
}
}
else
{
h->MEvent.clicks = 1;
h->MEvent.button = ev->button;
rxvt_mouse_report(r, ev);
}
#else
h->MEvent.button = ev->button;
rxvt_mouse_report(r, ev);
#endif
}
else
{
if (ev->button != h->MEvent.button)
h->MEvent.clicks = 0;
switch (ev->button)
{
case Button1:
if (h->MEvent.button == Button1 && clickintime)
h->MEvent.clicks++;
else
h->MEvent.clicks = 1;
rxvt_selection_click(r, page, h->MEvent.clicks,
ev->x, ev->y);
h->MEvent.button = Button1;
break;
case Button3:
if (h->MEvent.button == Button3 && clickintime)
rxvt_selection_rotate(r, page, ev->x, ev->y);
else
rxvt_selection_extend(r, page, ev->x, ev->y, 1);
h->MEvent.button = Button3;
break;
}
}
h->MEvent.time = ev->time;
return;
}
if (rxvt_is_tabbar_win (r, ev->window))
rxvt_tabbar_dispatcher (r, ev);
#ifdef HAVE_SCROLLBARS
if (rxvt_is_scrollbar_win (r, ev->window))
rxvt_scrollbar_dispatcher (r, page, ev);
#endif
#ifdef HAVE_MENUBAR
if (rxvt_is_menubar_win(r, ev->window))
rxvt_menubar_control(r, ev);
#endif
}
#ifdef MOUSE_WHEEL
void
rxvt_process_wheel_button(rxvt_t* r, int page, XButtonEvent *ev)
{
int i, v;
v = (ev->button == Button4) ? UP : DN;
if (ev->state & ShiftMask)
i = 1;
else if ((r->Options & Opt_mouseWheelScrollPage))
i = r->TermWin.nrow - 1;
else
i = 5;
# ifdef MOUSE_SLIP_WHEELING
if (ev->state & ControlMask)
{
r->h->mouse_slip_wheel_speed += (v ? -1 : 1);
r->h->mouse_slip_wheel_delay = SCROLLBAR_CONTINUOUS_DELAY;
}
# endif
# ifdef JUMP_MOUSE_WHEEL
rxvt_scr_page(r, ATAB(r), v, i);
# ifdef XFT_SUPPORT
if (!((r->Options & Opt_xft) && (r->Options2 & Opt2_xftAntialias)))
# endif
rxvt_scr_refresh(r, page, SMOOTH_REFRESH);
# ifdef HAVE_SCROLLBARS
rxvt_scrollbar_update(r, 1);
# endif
# else
for (; i--;)
{
rxvt_scr_page(r, ATAB(r), v, 1);
# ifdef XFT_SUPPORT
if (!((r->Options & Opt_xft) && (r->Options2 & Opt2_xftAntialias)))
# endif
rxvt_scr_refresh(r, page, SMOOTH_REFRESH);
# ifdef HAVE_SCROLLBARS
rxvt_scrollbar_update(r, 1);
# endif
}
# endif
}
#endif
void
rxvt_process_buttonrelease(rxvt_t* r, int page, XButtonEvent *ev)
{
int reportmode = 0;
if ( r->tabClicked != -1 )
{
if ( rxvt_is_tabbar_win( r, ev->window ) )
{
rxvt_tabbar_button_release( r, ev );
return;
}
else
r->tabClicked = -1;
}
DBG_MSG(2, (stderr, "ButtonRelease event\n"));
r->h->csrO = 0;
if (!r->h->bypass_keystate)
reportmode = !!(PVTS(r, page)->PrivateModes & PrivMode_mouse_report);
#ifdef HAVE_SCROLLBARS
if (scrollbar_isUpDn())
{
scrollbar_setIdle();
rxvt_scrollbar_update(r, 0);
# ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING
r->h->refresh_type &= ~SMOOTH_REFRESH;
# endif
}
#endif
#ifdef HAVE_MENUBAR
if( r->h->showingMenu )
{
r->h->showingMenu &= ~POPUP_MENU;
XDefineCursor( r->Xdisplay, AVTS(r)->vt, r->term_pointer);
rxvt_menu_select(r, ev);
return;
}
#endif
#ifdef SELECTION_SCROLLING
r->h->pending_scroll_selection=0;
#endif
if (ev->window == PVTS(r, page)->vt)
{
if (ev->subwindow == None)
{
if (reportmode)
{
if (ev->button >= 4)
return;
#ifdef MOUSE_REPORT_DOUBLECLICK
if (
r->h->MEvent.button != AnyButton
&& (
ev->button != r->h->MEvent.button
|| (ev->time - r->h->MEvent.time > MULTICLICK_TIME / 2)
)
)
{
r->h->MEvent.clicks = 0;
r->h->MEvent.button = AnyButton;
rxvt_mouse_report(r, ev);
}
#else
r->h->MEvent.button = AnyButton;
rxvt_mouse_report(r, ev);
#endif
return;
}
if (PVTS(r, page)->PrivateModes & PrivMode_mouse_report
&& r->h->bypass_keystate
&& ev->button == Button1 && r->h->MEvent.clicks <= 1)
rxvt_selection_extend(r, page, ev->x, ev->y, 0);
switch (ev->button)
{
case Button1:
case Button3:
rxvt_selection_make(r, page, ev->time);
break;
case Button2:
rxvt_selection_request(r, page, ev->time, ev->x, ev->y);
break;
#ifdef MOUSE_WHEEL
case Button4:
case Button5:
rxvt_process_wheel_button (r, page, ev);
break;
#endif
}
}
}
#ifdef HAVE_MENUBAR
else if (rxvt_is_menubar_win(r, ev->window))
rxvt_menubar_control(r, ev);
#endif
}
void
rxvt_process_clientmessage(rxvt_t* r, XClientMessageEvent* ev)
{
DBG_MSG(2, (stderr, "ClientMessage event\n"));
if (ev->format == 32 &&
(Atom)ev->data.l[0] == r->h->xa[XA_WMDELETEWINDOW])
rxvt_clean_exit (r);
#ifdef OFFIX_DND
if (
ev->xclient.message_type == h->xa[XA_DNDPROTOCOL]
&& (
ev->xclient.data.l[0] == DndFile
|| ev->xclient.data.l[0] == DndDir
|| ev->xclient.data.l[0] == DndLink
)
)
{
Atom ActualType;
int ActualFormat;
unsigned char* data;
unsigned long Size, RemainingBytes;
XGetWindowProperty(r->Xdisplay, XROOT,
r->h->xa[XA_DNDSELECTION], 0L, 1000000L,
False, AnyPropertyType, &ActualType, &ActualFormat,
&Size, &RemainingBytes, &data);
XChangeProperty(r->Xdisplay, XROOT, XA_CUT_BUFFER0,
XA_STRING, 8, PropModeReplace, data, STRLEN(data));
rxvt_selection_paste(r, ATAB(r), XROOT, XA_CUT_BUFFER0, True);
XSetInputFocus(r->Xdisplay, XROOT, RevertToNone, CurrentTime);
}
#endif
}
void
rxvt_process_visibilitynotify(rxvt_t* r, XVisibilityEvent* ev)
{
DBG_MSG(2, (stderr, "VisibilityNotify event\n"));
switch (ev->state)
{
case VisibilityUnobscured:
r->h->refresh_type = FAST_REFRESH;
break;
case VisibilityPartiallyObscured:
r->h->refresh_type = SLOW_REFRESH;
break;
default:
r->h->refresh_type = NO_REFRESH;
break;
}
}
#ifdef MONITOR_ENTER_LEAVE
void
rxvt_process_enter (rxvt_t* r, XCrossingEvent* ev)
{
if (ev->window == r->TermWin.parent)
{
DBG_MSG(1, (stderr, "Enter event\n"));
r->TermWin.enter = 1;
}
}
void
rxvt_process_leave (rxvt_t* r, XCrossingEvent* ev)
{
if (ev->window == r->TermWin.parent)
{
DBG_MSG(1, (stderr, "Leave event\n"));
r->TermWin.enter = 0;
}
}
#endif
void
rxvt_process_focusin (rxvt_t* r, XFocusChangeEvent* ev)
{
if (ev->window == r->TermWin.parent)
{
#ifdef OFF_FOCUS_FADING
register int changed = 0;
#endif
DBG_MSG(2, (stderr, "FocusIn event\n"));
r->TermWin.focus = 1;
r->h->want_refresh = 1;
#ifdef USE_XIM
if (r->h->Input_Context != NULL)
XSetICFocus(r->h->Input_Context);
#endif
rxvt_restore_ufbg_color (r);
#ifdef OFF_FOCUS_FADING
changed = rxvt_restore_pix_color (r);
#endif
if (
ISSET_PIXCOLOR(r->h, Color_ufbg)
#ifdef OFF_FOCUS_FADING
|| (r->h->rs[Rs_fade] && changed)
#endif
)
{
rxvt_set_bg_focused(r, ATAB(r), True);
}
}
}
void
rxvt_process_focusout (rxvt_t* r, XFocusChangeEvent* ev)
{
if (ev->window == r->TermWin.parent)
{
#ifdef OFF_FOCUS_FADING
register int changed = 0;
#endif
DBG_MSG(2, (stderr, "FocusOut event\n"));
r->TermWin.focus = 0;
r->h->want_refresh = 1;
#ifdef USE_XIM
if (r->h->Input_Context != NULL)
XUnsetICFocus(r->h->Input_Context);
#endif
rxvt_restore_ufbg_color (r);
#ifdef OFF_FOCUS_FADING
changed = rxvt_switch_pix_color (r);
#endif
if (
ISSET_PIXCOLOR(r->h, Color_ufbg)
#ifdef OFF_FOCUS_FADING
|| (r->h->rs[Rs_fade] && changed)
#endif
)
{
rxvt_set_bg_focused(r, ATAB(r), False);
}
}
}
void
rxvt_resize_on_subwin (rxvt_t* r, resize_reason_t reason)
{
unsigned oldWidth = r->szHint.width;
unsigned oldHeight = r->szHint.height;
switch (reason)
{
#ifdef HAVE_MENUBAR
case HIDE_MENUBAR:
r->szHint.base_height -= rxvt_menubar_rheight (r);
r->szHint.min_height -= rxvt_menubar_rheight (r);
r->szHint.height -= rxvt_menubar_rheight (r);
break;
case SHOW_MENUBAR:
r->szHint.base_height += rxvt_menubar_rheight (r);
r->szHint.min_height += rxvt_menubar_rheight (r);
r->szHint.height += rxvt_menubar_rheight (r);
break;
#endif
case HIDE_TABBAR:
r->szHint.base_height -= rxvt_tabbar_rheight (r);
r->szHint.min_height -= rxvt_tabbar_rheight (r);
r->szHint.height -= rxvt_tabbar_rheight (r);
break;
case SHOW_TABBAR:
r->szHint.base_height += rxvt_tabbar_rheight (r);
r->szHint.min_height += rxvt_tabbar_rheight (r);
r->szHint.height += rxvt_tabbar_rheight (r);
break;
#ifdef HAVE_SCROLLBARS
case HIDE_SCROLLBAR:
r->szHint.base_width -= rxvt_scrollbar_rwidth (r);
r->szHint.min_width -= rxvt_scrollbar_rwidth (r);
r->szHint.width -= rxvt_scrollbar_rwidth (r);
break;
case SHOW_SCROLLBAR:
r->szHint.base_width += rxvt_scrollbar_rwidth (r);
r->szHint.min_width += rxvt_scrollbar_rwidth (r);
r->szHint.width += rxvt_scrollbar_rwidth (r);
break;
#endif
case RESIZE_FONT:
r->szHint.base_width = 2 * r->TermWin.int_bwidth;
r->szHint.base_height = 2 * r->TermWin.int_bwidth;
#ifdef HAVE_SCROLLBARS
if( rxvt_scrollbar_visible( r) )
r->szHint.base_width += rxvt_scrollbar_width (r);
#endif
#ifdef HAVE_MENUBAR
if( rxvt_menubar_visible(r) )
r->szHint.base_height += rxvt_menubar_height (r);
#endif
if( rxvt_tabbar_visible( r ) )
r->szHint.base_height += rxvt_tabbar_height (r);
#ifndef NO_FRILLS
if( r->Options2 & Opt2_smoothResize )
{
r->szHint.width_inc = 1;
r->szHint.height_inc = 1;
}
else
#endif
{
r->szHint.width_inc = r->TermWin.fwidth;
r->szHint.height_inc = r->TermWin.fheight;
}
r->szHint.min_width = r->szHint.base_width + r->TermWin.fwidth;
r->szHint.min_height = r->szHint.base_height + r->TermWin.fheight;
r->szHint.width = r->szHint.base_width +
Width2Pixel(r->TermWin.ncol);
r->szHint.height = r->szHint.base_height +
Height2Pixel(r->TermWin.nrow);
r->h->want_resize |= FORCE_REFRESH;
break;
default:
assert (0);
return ;
}
XSetWMNormalHints (r->Xdisplay, r->TermWin.parent, &(r->szHint));
if (!(r->Options & Opt_scrollBar_right))
r->h->window_vt_x = (r->Options & Opt_scrollBar_right) ?
0 : r->szHint.base_width - 2*r->TermWin.int_bwidth;
r->h->window_vt_y = r->szHint.base_height - 2*r->TermWin.int_bwidth;
if (r->Options2 & Opt2_bottomTabbar)
r->h->window_vt_y -= rxvt_tabbar_height (r);
XResizeWindow(r->Xdisplay, r->TermWin.parent,
r->szHint.width, r->szHint.height);
r->h->want_resize |= FORCE_RESIZE;
#ifndef NO_FRILLS
while( r->Options2 & Opt2_smartResize )
{
CARD32 left, right, top, bottom;
int wx, wy;
unsigned wwidth, wheight;
int newx = r->szHint.x,
newy = r->szHint.y;
unsigned dspw = DisplayWidth( r->Xdisplay, XSCREEN),
dsph = DisplayHeight( r->Xdisplay, XSCREEN);
int dx = (int) r->szHint.width - (int) oldWidth,
dy = (int) r->szHint.height- (int) oldHeight;
if( !getWMStruts( r->Xdisplay, r->TermWin.parent,
&left, &right, &top, &bottom)) break;
wx = r->szHint.x - left;
wy = r->szHint.y - top;
wwidth = r->szHint.width + left + right;
wheight = r->szHint.height + top + bottom;
DBG_MSG(1, (stderr, "Strut: (%lu, %lu %lu, %lu), "
"Geometry: %ux%u+%d+%d, Change: (%d, %d)\n",
left, right, top, bottom, wwidth, wheight, wx, wy, dx, dy ));
if( wwidth >= dspw || wheight >= dsph ) break;
if( wx < 0 && wx + dx >= 0) newx = left;
else if( wx + (int) wwidth > (int) dspw
&& wx + (int) wwidth - dx <= (int) dspw )
newx = dspw - wwidth + left;
if( wy < 0 && wy + dy >= 0) newy = top;
else if( wy + (int) wheight > (int) dsph
&& wy + (int) wheight - dy <= (int) dsph)
newy = dsph - wheight + top;
if(
(newx != r->szHint.x || newy != r->szHint.y)
&& newx - (int) left >=0
&& newx - (int) left + (int) wwidth <= dspw
&& newy - (int) top >=0
&& newy - (int) top + (int) wheight <= dsph
)
{
DBG_MSG( 1, (stderr, "Smart move to %ux%u+%d+%d\n",
r->szHint.width, r->szHint.height, newx, newy));
XMoveWindow( r->Xdisplay, r->TermWin.parent,
newx, newy);
}
break;
}
#endif
r->szHint.width = oldWidth;
r->szHint.height = oldHeight;
}
void
rxvt_resize_on_font (rxvt_t* r, char* fontname)
{
DBG_MSG(1, (stderr, "rxvt_resize_on_font\n"));
#ifdef XFT_SUPPORT
if ((r->Options & Opt_xft) && r->TermWin.xftfont)
if (!rxvt_change_font_xft (r, fontname))
return ;
if (!(r->Options & Opt_xft))
#endif
if (!rxvt_change_font_x11 (r, fontname))
return ;
rxvt_resize_on_subwin (r, RESIZE_FONT);
}
int
rxvt_calc_colrow (rxvt_t* r, unsigned int width, unsigned int height)
{
unsigned int ncol, nrow;
assert (0 != r->TermWin.fwidth);
assert (0 != r->TermWin.fheight);
if ( !r->h->want_resize &&
r->szHint.width == width && r->szHint.height == height)
return 0;
DBG_MSG(1, (stderr, "Recalc row/col of (%d, %d)\n", width, height));
ncol = Pixel2Width (width - r->szHint.base_width);
nrow = Pixel2Height (height - r->szHint.base_height);
MAX_IT(ncol, 1);
MAX_IT(nrow, 1);
r->h->prev_ncol = r->TermWin.ncol;
r->h->prev_nrow = r->TermWin.nrow;
r->TermWin.ncol = ncol;
r->TermWin.nrow = nrow;
r->szHint.width = width;
r->szHint.height = height;
return ((r->h->prev_ncol != r->TermWin.ncol) ||
(r->h->prev_nrow != r->TermWin.nrow));
}
void
rxvt_resize_sub_windows (rxvt_t* r)
{
register int i;
DBG_MSG(1, (stderr, "rxvt_resize_sub_windows\n"));
#ifdef HAVE_SCROLLBARS
rxvt_scrollbar_resize(r);
#endif
#ifdef HAVE_MENUBAR
rxvt_menubar_resize(r);
#endif
rxvt_tabbar_resize (r);
for (i = 0; i <= LTAB(r); i ++)
{
XMoveResizeWindow (r->Xdisplay, PVTS(r, i)->vt,
r->h->window_vt_x, r->h->window_vt_y,
VT_WIDTH(r), VT_HEIGHT(r));
}
}
void
rxvt_resize_on_configure (rxvt_t* r, unsigned int width, unsigned int height)
{
register int i = 0;
unsigned int old_width = r->szHint.width,
old_height = r->szHint.height;
int fix_screen;
DBG_MSG(2, (stderr, "rxvt_resize_on_configure\n"));
fix_screen = rxvt_calc_colrow (r, width, height);
if (r->h->want_resize ||
old_width != r->szHint.width || old_height != r->szHint.height)
rxvt_resize_sub_windows (r);
if (fix_screen)
{
for (i = 0; i <= LTAB(r); i ++)
{
int curr_screen = -1;
RUINT16T old_ncol;
PVTS(r, i)->prev_nrow = r->h->prev_nrow;
PVTS(r, i)->prev_ncol = r->h->prev_ncol;
old_ncol = PVTS(r, i)->prev_ncol;
rxvt_scr_clear(r, i);
#ifdef BACKGROUND_IMAGE
rxvt_resize_pixmap(r, i);
#endif
curr_screen = rxvt_scr_change_screen(r, i, PRIMARY);
rxvt_scr_reset(r, i);
if (curr_screen >= 0)
{
rxvt_scr_change_screen(r, i, curr_screen);
rxvt_selection_check(r, i, (old_ncol != r->TermWin.ncol ? 4 : 0));
}
}
}
#ifdef USE_XIM
rxvt_IM_resize(r);
#endif
}
#ifndef NO_FRILLS
Bool getWMStruts( Display *dpy, Window w,
CARD32 *left, CARD32 *right, CARD32 *top, CARD32 *bottom)
{
Atom atom;
static const int natoms = 2;
static const char *atomName[2] = {
"_KDE_NET_WM_FRAME_STRUT",
"_NET_FRAME_EXTENTS"};
int i;
Atom type;
int format;
unsigned long nitems, bytes_after;
CARD32 *struts;
*left = *right = *top = *bottom = 0;
for( i=0; i < natoms; i++)
{
if( (atom = XInternAtom( dpy, atomName[i], False))
== None) continue;
if( XGetWindowProperty( dpy, w, atom,
0,
4,
False,
XA_CARDINAL,
&type, &format, &nitems, &bytes_after,
(unsigned char **) &struts) != Success )
continue;
if( type == XA_CARDINAL && bytes_after == 0)
{
*left = struts[0];
*right = struts[1];
*top = struts[2];
*bottom = struts[3];
DBG_MSG( 1, (stderr, "Got struts %lu, %lu, %lu, %lu from %s\n",
*left, *right, *top, *bottom, atomName[i]));
i = natoms;
}
XFree( struts);
}
return i == natoms + 1;
}
#endif
void
rxvt_process_configurenotify (rxvt_t* r, XConfigureEvent* ev)
{
unsigned int height, width;
if (ev->window != r->TermWin.parent)
return;
DBG_MSG(2, (stderr, "ConfigureNotify event\n"));
do
{
width = ev->width;
height = ev->height;
}
while ( XCheckTypedWindowEvent(r->Xdisplay, ev->window,
ConfigureNotify, (XEvent*) ev));
XTranslateCoordinates(r->Xdisplay, r->TermWin.parent, XROOT,
0, 0, &r->szHint.x, &r->szHint.y, &ev->window);
DBG_MSG(1, (stderr, "Geometry: %ux%u+%d+%d\n",
width, height, r->szHint.x, r->szHint.y));
if (
r->h->want_resize
|| r->szHint.width != width || r->szHint.height != height
)
{
rxvt_resize_on_configure (r, width, height);
}
#if DEBUG_LEVEL
else
{
DBG_MSG(1, (stderr, "Size: Not resizing\n"));
}
#endif
if( (r->h->want_resize & ~FORCE_REFRESH) )
{
r->h->want_resize = 0;
DBG_MSG( 2, ( stderr, "Forcing refresh (from want_resize)\n"));
#if defined(HAVE_LIBXRENDER) && (defined(BACKGROUND_IMAGE) || defined(TRANSPARENT))
rxvt_refresh_bg_image( r, ATAB(r), False );
#else
rxvt_scr_touch( r, ATAB(r), False);
#endif
}
#ifdef TRANSPARENT
if (r->Options & Opt_transparent)
{
if(
!r->h->bgGrabbed
|| r->h->prevPos.x != r->szHint.x
|| r->h->prevPos.y != r->szHint.y
|| r->h->prevPos.width != width
|| r->h->prevPos.height != height
)
{
if( !r->h->bgRefreshInterval)
{
DBG_MSG( 3, ( stderr, "refreshing parents...\n"));
if( rxvt_check_our_parents(r) )
{
r->h->want_resize = 0;
r->h->want_full_refresh = 1;
}
}
else
{
DBG_MSG( 3, ( stderr,
"Setting timeout for parent refresh.\n"));
gettimeofday( &r->h->lastCNotify, NULL);
}
}
}
#endif
}
void
rxvt_process_selectionnotify (rxvt_t* r, XSelectionEvent* ev)
{
DBG_MSG(2, (stderr, "SelectionNotify event\n"));
if (r->h->selection_wait == Sel_normal)
rxvt_selection_paste(r, ev->requestor, ev->property, True);
}
void
rxvt_process_propertynotify (rxvt_t* r, XEvent* ev)
{
#ifdef TRANSPARENT
int wantRefresh = 0;
#endif
#if DEBUG_LEVEL
char *name;
DBG_MSG( 2, (stderr, "Property notify event:"));
#endif
assert( ev->type == PropertyNotify );
do
{
#if DEBUG_LEVEL
name = XGetAtomName( r->Xdisplay, ev->xproperty.atom);
DBG_MSG( 2, (stderr, "%s(%08lx) ", name, ev->xproperty.atom ));
XFree( name);
#endif
if (
ev->xproperty.atom == r->h->xa[XA_VT_SELECTION]
&& ev->xproperty.state == PropertyNewValue
)
{
rxvt_selection_property(r, ev->xproperty.window, ev->xproperty.atom);
}
#ifdef TRANSPARENT
else if (
r->h->xa[XA_XROOTPMAPID] != None
&& r->h->xa[XA_XSETROOTID] != None
&& (
ev->xproperty.atom == r->h->xa[XA_XROOTPMAPID]
|| ev->xproperty.atom == r->h->xa[XA_XSETROOTID]
)
)
{
if( !wantRefresh)
{
DBG_MSG( 1, (stderr, "(sleeping ... "));
#ifdef HAVE_NANOSLEEP
struct timespec rqt;
rqt.tv_sec = 0;
rqt.tv_nsec = 10000000;
nanosleep(&rqt, NULL);
#else
sleep( 1);
#endif
DBG_MSG( 1, (stderr, "done) "));
}
wantRefresh = 1;
}
#endif
}
while( XCheckTypedEvent( r->Xdisplay, PropertyNotify, ev) );
#if DEBUG_LEVEL
fputc( '\n', stderr);
#endif
#ifdef TRANSPARENT
if( wantRefresh)
{
refreshRootBGVars( r );
if (r->Options & Opt_transparent)
{
rxvt_check_our_parents(r);
r->h->want_full_refresh = 1;
}
}
#endif
}
void
rxvt_process_expose (rxvt_t* r, XEvent* ev)
{
int page = ATAB(r);
Window win = (ev->type == Expose ?
ev->xexpose.window : ev->xgraphicsexpose.drawable );
DBG_MSG(2, (stderr, "Got %s event.\n",
ev->type == Expose ? "Expose" : "GraphicsExpose"));
if (win == PVTS(r, page)->vt)
{
if( r->h->refreshRegion == None )
{
r->h->refreshRegion = XCreateRegion();
DBG_MSG( 3, ( stderr, "Created clip region %p\n",
r->h->refreshRegion));
}
do
{
XRectangle rect;
if( ev->type == Expose)
{
rect.x = ev->xexpose.x;
rect.y = ev->xexpose.y;
rect.width = ev->xexpose.width;
rect.height = ev->xexpose.height;
}
else
{
rect.x = ev->xgraphicsexpose.x;
rect.y = ev->xgraphicsexpose.y;
rect.width = ev->xgraphicsexpose.width;
rect.height = ev->xgraphicsexpose.height;
}
XUnionRectWithRegion( &rect, r->h->refreshRegion,
r->h->refreshRegion);
rxvt_scr_expose(r, page,
rect.x, rect.y, rect.width, rect.height,
False);
DBG_MSG( 3, ( stderr, "Adding [%ux%u+%d+%d] to expose region\n",
rect.width, rect.height, rect.x, rect.y));
}
while(
XCheckTypedWindowEvent( r->Xdisplay, win, Expose, ev)
|| XCheckTypedWindowEvent( r->Xdisplay, win, GraphicsExpose, ev)
);
r->h->refresh_type |= CLIPPED_REFRESH;
r->h->want_clip_refresh = 1;
}
else
{
XEvent unused_xevent;
#ifdef DEBUG_VERBOSE
if (rxvt_is_tabbar_win (r, win))
{
DBG_MSG(2, (stderr, "Expose event on tabbar\n"));
}
# ifdef HAVE_SCROLLBARS
else if (rxvt_is_scrollbar_win (r, win))
{
DBG_MSG(2, (stderr, "Expose event on scrollbar\n"));
}
# endif
# ifdef HAVE_MENUBAR
else if (rxvt_is_menubar_win (r, win))
{
DBG_MSG(2, (stderr, "Expose event on menubar\n"));
}
# endif
#endif
if (rxvt_is_tabbar_win(r, win) && rxvt_tabbar_visible (r))
{
rxvt_tabbar_expose(r, ev);
return;
}
while( XCheckTypedWindowEvent(r->Xdisplay, win,
Expose, &unused_xevent) ||
XCheckTypedWindowEvent( r->Xdisplay, win,
GraphicsExpose, &unused_xevent)
);
#ifdef HAVE_SCROLLBARS
if ( rxvt_is_scrollbar_win (r, win) && rxvt_scrollbar_visible (r))
{
scrollbar_setIdle();
rxvt_scrollbar_update(r, 0);
return;
}
#endif
#ifdef HAVE_MENUBAR
if (rxvt_is_menubar_win(r, win) && rxvt_menubar_visible (r))
{
rxvt_menubar_expose(r);
return;
}
#endif
}
}
void
rxvt_process_motionnotify (rxvt_t* r, XEvent* ev)
{
int page = ATAB(r);
Window unused_root, unused_child;
int unused_root_x, unused_root_y;
unsigned int unused_mask;
DBG_MSG(2, (stderr, "MotionNotify event\n"));
#ifdef POINTER_BLANK
if ((r->Options & Opt_pointerBlank) && PVTS(r, page)->hidden_pointer)
rxvt_pointer_unblank (r, page);
#endif
#ifdef HAVE_MENUBAR
if (rxvt_is_menubar_win(r, ev->xmotion.window))
{
rxvt_menubar_control(r, &(ev->xbutton));
return;
}
if (r->h->showingMenu )
{
rxvt_menu_select( r, &(ev->xbutton));
return;
}
#endif
if ((PVTS(r, page)->PrivateModes & PrivMode_mouse_report) &&
!(r->h->bypass_keystate))
return;
if (ev->xany.window == PVTS(r, page)->vt)
{
if ((ev->xbutton.state & (Button1Mask | Button3Mask)))
{
while (XCheckTypedWindowEvent(r->Xdisplay, PVTS(r, page)->vt,
MotionNotify, ev))
;
XQueryPointer(r->Xdisplay, PVTS(r, page)->vt,
&unused_root, &unused_child,
&unused_root_x, &unused_root_y,
&(ev->xbutton.x), &(ev->xbutton.y),
&unused_mask);
#ifdef MOUSE_THRESHOLD
if ((ev->xmotion.time - r->h->MEvent.time) > MOUSE_THRESHOLD)
{
#endif
rxvt_selection_extend(r, page,
(ev->xbutton.x), (ev->xbutton.y),
(ev->xbutton.state & Button3Mask) ? 2 : 0);
#ifdef SELECTION_SCROLLING
if (
ev->xbutton.y<r->TermWin.int_bwidth
|| Pixel2Row(ev->xbutton.y)>(r->TermWin.nrow-1)
)
{
int dist;
r->h->pending_scroll_selection=1;
if (r->h->scroll_selection_delay<=0)
r->h->scroll_selection_delay = SCROLLBAR_CONTINUOUS_DELAY;
r->h->selection_save_x = ev->xbutton.x;
r->h->selection_save_y = ev->xbutton.y;
r->h->selection_save_state = (ev->xbutton.state & Button3Mask) ? 2 : 0;
if (ev->xbutton.y<r->TermWin.int_bwidth)
{
r->h->scroll_selection_dir = UP;
dist = r->TermWin.int_bwidth - ev->xbutton.y;
}
else
{
r->h->scroll_selection_dir = DN;
dist = ev->xbutton.y -
(r->TermWin.int_bwidth + VT_HEIGHT(r));
}
r->h->scroll_selection_lines=(Pixel2Height(dist)/
SELECTION_SCROLL_LINE_SPEEDUP)+1;
MIN_IT(r->h->scroll_selection_lines,
SELECTION_SCROLL_MAX_LINES);
}
else
{
r->h->pending_scroll_selection = 0;
}
#endif
#ifdef MOUSE_THRESHOLD
}
#endif
}
}
#ifdef HAVE_SCROLLBARS
else if (
rxvt_is_scrollbar_win (r, ev->xany.window)
&& scrollbar_isMotion()
)
{
while (
XCheckTypedWindowEvent(r->Xdisplay,
r->scrollBar.win, MotionNotify, ev)
)
;
XQueryPointer(r->Xdisplay, r->scrollBar.win,
&unused_root, &unused_child,
&unused_root_x, &unused_root_y,
&(ev->xbutton.x), &(ev->xbutton.y),
&unused_mask);
rxvt_scr_move_to(r, page,
scrollbar_position(ev->xbutton.y) - r->h->csrO,
scrollbar_size());
rxvt_scr_refresh(r, page, r->h->refresh_type & ~CLIPPED_REFRESH);
r->h->refresh_limit = 0;
rxvt_scrollbar_update(r, 1);
}
#endif
}
+--202 lines: process an X event -----------------------------------------------
+--110 lines: print pipe -------------------------------------------------------
enum {
C1_40 = 0x40,
C1_41 , C1_BPH, C1_NBH, C1_44 , C1_NEL, C1_SSA, C1_ESA,
C1_HTS, C1_HTJ, C1_VTS, C1_PLD, C1_PLU, C1_RI , C1_SS2, C1_SS3,
C1_DCS, C1_PU1, C1_PU2, C1_STS, C1_CCH, C1_MW , C1_SPA, C1_EPA,
C1_SOS, C1_59 , C1_SCI, C1_CSI, CS_ST , C1_OSC, C1_PM , C1_APC
};
+-- 51 lines: process non-printing single characters ---------------------------
+-- 82 lines: process VT52 escape sequences ------------------------------------
+--162 lines: process escape sequences -----------------------------------------
+--353 lines: process CONTROL SEQUENCE INTRODUCER (CSI) sequences `ESC[' -------
#ifndef NO_FRILLS
void
rxvt_process_window_ops(rxvt_t* r, int page, const int *args, unsigned int nargs)
{
int x, y;
unsigned int w, h;
XWindowAttributes wattr;
Window wdummy;
if (nargs == 0)
return;
switch (args[0])
{
case 1:
XMapWindow (r->Xdisplay, r->TermWin.parent);
break;
case 2:
XIconifyWindow (r->Xdisplay, r->TermWin.parent,
DefaultScreen(r->Xdisplay));
break;
case 3:
XMoveWindow (r->Xdisplay, r->TermWin.parent, args[1], args[2]);
break;
case 4:
w = (unsigned int) args[2];
h = (unsigned int) args[1];
XResizeWindow (r->Xdisplay, r->TermWin.parent, w, h);
r->h->want_resize = 1;
break;
case 5:
XRaiseWindow (r->Xdisplay, r->TermWin.parent);
break;
case 6:
XLowerWindow (r->Xdisplay, r->TermWin.parent);
break;
case 7:
rxvt_scr_touch (r, page, True);
break;
case 8:
w = (unsigned int) (Width2Pixel(args[2]) + r->szHint.base_width);
h = (unsigned int) (Height2Pixel(args[1]) + r->szHint.base_height);
XResizeWindow (r->Xdisplay, r->TermWin.parent, w, h);
r->h->want_resize = 1;
break;
default:
if (args[0] >= 24)
{
w = (unsigned int) r->szHint.width;
h = (unsigned int) (args[1] * r->TermWin.fheight + r->szHint.base_height);
XResizeWindow (r->Xdisplay, r->TermWin.parent, w, h);
r->h->want_resize = 1;
}
break;
case 11:
XGetWindowAttributes(r->Xdisplay, r->TermWin.parent, &wattr);
rxvt_tt_printf(r, page, "\033[%dt",
wattr.map_state == IsViewable ? 1 : 2);
break;
case 13:
XGetWindowAttributes(r->Xdisplay, r->TermWin.parent, &wattr);
XTranslateCoordinates(r->Xdisplay, r->TermWin.parent,
wattr.root, -wattr.border_width, -wattr.border_width,
&x, &y, &wdummy);
rxvt_tt_printf(r, page, "\033[3;%d;%dt", x, y);
break;
case 14:
XGetWindowAttributes(r->Xdisplay, r->TermWin.parent, &wattr);
rxvt_tt_printf(r, page, "\033[4;%d;%dt", wattr.height,
wattr.width);
break;
case 18:
rxvt_tt_printf(r, page, "\033[8;%d;%dt", r->TermWin.nrow,
r->TermWin.ncol);
break;
}
}
#endif
unsigned char *
rxvt_get_to_st(rxvt_t* r, int page, unsigned char *ends_how)
{
int readpage = page;
int seen_esc = 0;
unsigned int n = 0;
unsigned char* s;
unsigned char ch, string[STRING_MAX];
#ifdef DEBUG
clock_t checksum = PVTS(r, page)->checksum;
#endif
for (; (ch = rxvt_cmd_getc(r, &readpage));)
{
assert (readpage == page);
assert (checksum == PVTS(r, page)->checksum);
if (ch == C0_BEL ||
ch == CHAR_ST ||
(ch == 0x5c && seen_esc))
break;
if (ch == C0_ESC)
{
seen_esc = 1;
continue;
}
else if (ch == '\t')
ch = ' ';
else if (ch < 0x08 || (ch > 0x0d && ch < 0x20))
{
continue;
}
if (n < sizeof(string) - 1)
string[n++] = ch;
seen_esc = 0;
}
string[n++] = '\0';
if ((s = (unsigned char UNTAINTED *) STRNDUP (string, n)) == NULL)
return NULL;
*ends_how = (ch == 0x5c ? C0_ESC : ch);
return s;
}
void
rxvt_process_dcs_seq(rxvt_t* r, int page)
{
unsigned char eh, *s;
s = rxvt_get_to_st (r, page, &eh);
if (s)
free(s);
return;
}
void
rxvt_process_osc_seq (rxvt_t* r, int page)
{
int readpage = page;
unsigned char ch, eh, *s;
int arg;
#ifdef DEBUG
clock_t checksum = PVTS(r, page)->checksum;
#endif
ch = rxvt_cmd_getc(r, &readpage);
assert (page == readpage);
assert (checksum == PVTS(r, page)->checksum);
for (arg = 0; isdigit(ch); ch = rxvt_cmd_getc(r, &readpage))
{
assert (page == readpage);
assert (checksum == PVTS(r, page)->checksum);
arg = arg * 10 + (ch - '0');
}
if (ch == ';')
{
s = rxvt_get_to_st(r, page, &eh);
if (s)
{
XXX
if (arg == XTerm_Menu)
;
else
rxvt_xterm_seq(r, page, arg, (char *)s, eh);
free(s);
}
}
}
void
rxvt_xwsh_seq(rxvt_t* r, int op, const char *str)
{
assert(str != NULL);
switch (op)
{
case Xwsh_title:
rxvt_set_term_title (r, (const unsigned char*) str);
break;
case Xwsh_iconName:
rxvt_set_icon_name (r, (const unsigned char*) str);
break;
case Xwsh_textColor:
break;
case Xwsh_pageColor:
break;
case Xwsh_selTextColor:
break;
case Xwsh_selPageColor:
break;
case Xwsh_cursorTextColor:
break;
case Xwsh_cursorPageColor:
break;
case Xwsh_halfIntColor:
break;
case Xwsh_boldIntColor:
break;
case Xwsh_bindStrKeyVal:
break;
case Xwsh_bindStrKeyFunc:
break;
}
}
void
rxvt_process_xwsh_seq (rxvt_t* r, int page)
{
int readpage = page;
unsigned char ch, string[STRING_MAX];
int arg;
#ifdef DEBUG
clock_t checksum = PVTS(r, page)->checksum;
#endif
ch = rxvt_cmd_getc (r, &readpage);
assert (page == readpage);
assert (checksum == PVTS(r, page)->checksum);
for (arg = 0; isdigit((int) ch); ch = rxvt_cmd_getc(r, &readpage))
{
assert (page == readpage);
assert (checksum == PVTS(r, page)->checksum);
arg = arg * 10 + (ch - '0');
}
if (ch == '.')
{
if ((ch = rxvt_cmd_getc(r, &readpage)) == 'y')
{
int n = 0;
assert (page == readpage);
assert (checksum == PVTS(r, page)->checksum);
while ((ch = rxvt_cmd_getc(r, &readpage)) != '\033')
{
assert (page == readpage);
assert (checksum == PVTS(r, page)->checksum);
if (ch)
{
if (ch == '\t')
ch = ' ';
else if (ch < ' ')
return;
if (n < sizeof(string) - 1)
string[n++] = ch;
}
}
if ((ch = rxvt_cmd_getc(r, &readpage)) == '\\')
{
assert (page == readpage);
assert (checksum == PVTS(r, page)->checksum);
string[n] = '\0';
rxvt_xwsh_seq(r, arg, (char*) string);
}
}
}
}
void
rxvt_xterm_seq(rxvt_t* r, int page, int op, const char *str, unsigned char resp __attribute__((unused)))
{
int color;
char *buf, *name;
#if defined(TRANSPARENT) || defined(BACKGROUND_IMAGE)
int changed = 0;
# ifdef TINTING_SUPPORT
int shade;
# endif
#endif
assert(str != NULL);
switch (op)
{
case XTerm_name:
rxvt_set_term_title(r, (const unsigned char*) str);
case XTerm_iconName:
rxvt_set_icon_name(r, (const unsigned char*) str);
if (r->Options2 & Opt2_syncTabIcon)
rxvt_tabbar_set_title (r, ATAB(r),
(const unsigned char TAINTED*) str);
break;
case XTerm_title:
#ifndef SET_TAB_TITLE_NOT_WIN_TITLE
rxvt_set_term_title(r, (const unsigned char*) str);
#endif
#ifdef SET_TAB_TITLE_ON_XTERM_SEQUENCE
rxvt_tabbar_set_title (r, page, (const unsigned char TAINTED*) str);
#endif
break;
case XTerm_Color:
for (buf = (char *)str; buf && *buf;)
{
if ((name = STRCHR(buf, ';')) == NULL)
break;
*name++ = '\0';
color = atoi(buf);
if (color < 0 || color >= TOTAL_COLORS)
break;
if ((buf = STRCHR(name, ';')) != NULL)
*buf++ = '\0';
rxvt_set_window_color(r, color + minCOLOR, name);
}
break;
#ifndef NO_CURSORCOLOR
case XTerm_Color_cursor:
rxvt_set_window_color(r, Color_cursor, str);
break;
#endif
case XTerm_Color_pointer:
rxvt_set_window_color(r, Color_pointer, str);
break;
#ifndef NO_BOLD_UNDERLINE_REVERSE
case XTerm_Color_BD:
rxvt_set_window_color(r, Color_BD, str);
break;
case XTerm_Color_UL:
rxvt_set_window_color(r, Color_UL, str);
break;
case XTerm_Color_RV:
rxvt_set_window_color(r, Color_RV, str);
break;
#endif
case XTerm_Menu:
break;
#ifdef BACKGROUND_IMAGE
case XTerm_Pixmap:
if (*str != ';')
{
rxvt_scale_pixmap(r, page, "");
rxvt_load_bg_pixmap(r, page, str);
rxvt_scr_touch(r, page, True);
}
while ((str = STRCHR(str, ';')) != NULL)
{
str++;
changed += rxvt_scale_pixmap(r, page, str);
}
if (changed)
{
rxvt_resize_pixmap(r, page);
rxvt_scr_touch(r, page, True);
}
break;
#endif
case XTerm_restoreFG:
rxvt_set_window_color(r, Color_fg, str);
break;
case XTerm_restoreBG:
rxvt_set_window_color(r, Color_bg, str);
break;
case XTerm_logfile:
TODO
break;
case XTerm_font:
rxvt_resize_on_font (r, (char*) str);
break;
XXX
case Xterm_tabterm:
rxvt_set_term_title(r, (const unsigned char*) str);
case Xterm_tab:
rxvt_tabbar_set_title (r, page, (const unsigned char TAINTED*) str);
break;
+-- 84 lines: #if 0 DISABLED FOR SECURITY REASONS ------------------------------
+-- 13 lines: #if 0 DISABLED because macros are more useful --------------------
#ifdef MULTICHAR_SET
case Xterm_encode:
rxvt_set_multichar_encoding (r, str);
break;
#endif
case Xterm_opacity:
if (None != r->h->xa[XA_NET_WM_WINDOW_OPACITY])
{
int oldopacity = r->TermWin.opacity;
int tmp;
if ('-' == *str && (char) 0 == *(str+1))
{
tmp = (r->h->rs[Rs_opacityDegree]) ?
r->TermWin.opacity_degree : 1;
}
else if ('+' == *str && (char) 0 == *(str+1))
{
tmp = (r->h->rs[Rs_opacityDegree]) ?
-(r->TermWin.opacity_degree) : -1;
}
else
{
tmp = 100 - atoi (str);
if (tmp < 0 || tmp > 100)
tmp = oldopacity;
}
if ('-' == *str || '+' == *str)
r->TermWin.opacity += tmp;
else
r->TermWin.opacity = tmp;
if (r->TermWin.opacity < 0)
r->TermWin.opacity = 0;
if (r->TermWin.opacity > 100)
r->TermWin.opacity = 100;
if (r->TermWin.opacity != oldopacity)
rxvt_set_opacity (r);
}
break;
case Xterm_tabfg:
case Xterm_tabbg:
case Xterm_itabfg:
case Xterm_itabbg:
rxvt_tabbar_change_color (r, op, str);
break;
#if defined(TRANSPARENT) || defined(BACKGROUND_IMAGE)
# ifdef TINTING_SUPPORT
case Xterm_tint:
if (ISSET_PIXCOLOR (r->h, Color_tint) &&
r->h->rs[Rs_shade])
rxvt_set_window_color(r, Color_tint, str);
break;
case Xterm_bgfade:
case Xterm_shade:
if (!ISSET_PIXCOLOR (r->h, Color_tint) ||
!r->h->rs[Rs_shade])
break;
if( *str == '+' || *str == '-' )
{
shade = (100 - r->TermWin.shade) + atoi(str);
}
else
shade = atoi (str);
if (shade >=0 && shade <= 100)
{
shade = 100 - shade;
changed = (r->TermWin.shade != shade);
r->TermWin.shade = shade;
}
if (changed)
{
rxvt_refresh_bg_image (r, page, False);
}
break;
# endif
#endif
+-- 14 lines: #if 0 OBSOLETE HOTKEY CODE ---------------------------------------
case Xterm_termenv:
PVTS(r, page)->termenv = rxvt_get_termenv ((const char*) str);
break;
default:
break;
}
}
+--255 lines: process DEC private mode sequences `ESC [ ? Ps mode' -------------
+--133 lines: process sgr sequences --------------------------------------------
+-- 31 lines: process Rob Nation's own graphics mode sequences -----------------
+--303 lines: Read and process output from the application ---------------------