ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.97 by root, Mon Jul 26 18:01:19 2004 UTC vs.
Revision 1.131 by root, Fri Aug 13 22:38:57 2004 UTC

57#define IS_CONTROL(ch) !((ch) & 0xffffff60UL) 57#define IS_CONTROL(ch) !((ch) & 0xffffff60UL)
58 58
59// exception thrown when the command parser runs out of input data 59// exception thrown when the command parser runs out of input data
60class out_of_input { } out_of_input; 60class out_of_input { } out_of_input;
61 61
62#ifndef NO_FRILLS
63
64#define ISO_14755_KEYCODE_VALID 0x80000000UL
65#define ISO_14755_ACTIVE 0x40000000UL
66#define ISO_14755_ESCAPE_NEXT 0x20000000UL
67
68static unsigned short iso14755_symtab[] = {
69 // keysym, unicode
70 XK_Left, 0x2190,
71 XK_KP_Left, 0x2190,
72 XK_Up, 0x2191,
73 XK_KP_Up, 0x2191,
74 XK_Right, 0x2192,
75 XK_KP_Right, 0x2192,
76 XK_Down, 0x2193,
77 XK_KP_Down, 0x2193,
78 XK_Linefeed, 0x21b4,
79 XK_Return, 0x21b5,
80 XK_KP_Enter, 0x21b5,
81
82 XK_Prior, 0x21de,
83 XK_Next, 0x21df,
84 XK_Tab, 0x21e5,
85 XK_ISO_Left_Tab, 0x21e6,
86 XK_Shift_L, 0x21e7,
87 XK_Shift_R, 0x21e7,
88
89 XK_Shift_Lock, 0x21eb,
90 XK_ISO_Lock, 0x21eb,
91 XK_ISO_Lock, 0x21eb,
92 XK_Caps_Lock, 0x21ec,
93 XK_Num_Lock, 0x21ed,
94 XK_ISO_Level3_Shift, 0x21ee,
95 XK_ISO_Level3_Lock, 0x21ef,
96 XK_ISO_Group_Lock, 0x21f0,
97 XK_Home, 0x21f1,
98 XK_End, 0x21f2,
99
100 XK_Execute, 0x2318,
101 XK_Begin, 0x2320,
102 XK_Delete, 0x2326,
103 XK_Clear, 0x2327,
104 XK_BackSpace, 0x232b,
105 XK_Insert, 0x2380,
106 XK_Control_L, 0x2388,
107 XK_Control_R, 0x2388,
108 XK_Pause, 0x2389,
109 XK_Break, 0x238a,
110 XK_Escape, 0x238b,
111 XK_Undo, 0x238c,
112 XK_Print, 0x2399,
113
114 XK_space, 0x2423,
115 XK_KP_Space, 0x2422,
116 0,
117};
118
119void
120rxvt_term::commit_iso14755 ()
121{
122 wchar_t ch[2];
123
124 ch[0] = iso14755buf & 0x1fffffffUL; // actually, unicode needs a 0x1fffff mask
125 ch[1] = 0;
126
127 if (iso14755buf & ISO_14755_KEYCODE_VALID)
128 {
129 char mb[16];
130 int len;
131
132 // allow verbatim 0-bytes and control-bytes to be entered
133 if (ch[0] >= 0x20)
134 len = wcstombs (mb, ch, 16);
135 else
136 {
137 mb[0] = ch[0];
138 len = 1;
139 }
140
141 if (len > 0)
142 tt_write ((unsigned char *)mb, len);
143 else
144 scr_bell ();
145 }
146
147 iso14755buf = 0;
148}
149
150int
151rxvt_term::hex_keyval (XKeyEvent &ev)
152{
153 // check wether this event corresponds to a hex digit
154 // if the modifiers had not been pressed.
155 for (int index = 0; index < 8; index++)
156 {
157 KeySym k = XLookupKeysym (&ev, index);
158
159 if (k >= XK_KP_0 && k <= XK_KP_9) return k - XK_KP_0;
160 else if (k >= XK_0 && k <= XK_9) return k - XK_0;
161 else if (k >= XK_a && k <= XK_f) return k - XK_a + 10;
162 else if (k >= XK_A && k <= XK_F) return k - XK_A + 10;
163 }
164
165 return -1;
166}
167#endif
168
62/*{{{ Convert the keypress event into a string */ 169/*{{{ Convert the keypress event into a string */
63void 170void
64rxvt_term::lookup_key (XKeyEvent &ev) 171rxvt_term::lookup_key (XKeyEvent &ev)
65{ 172{
66 int ctrl, meta, shft, len; 173 int ctrl, meta, shft, len;
151 { 258 {
152 if (TermWin.saveLines) 259 if (TermWin.saveLines)
153 { 260 {
154#ifdef UNSHIFTED_SCROLLKEYS 261#ifdef UNSHIFTED_SCROLLKEYS
155 if (!ctrl && !meta) 262 if (!ctrl && !meta)
156 {
157#else 263#else
158 if (IS_SCROLL_MOD) 264 if (IS_SCROLL_MOD)
265#endif
159 { 266 {
160#endif
161 int lnsppg; 267 int lnsppg;
162 268
163#ifdef PAGING_CONTEXT_LINES 269#ifdef PAGING_CONTEXT_LINES
164 lnsppg = TermWin.nrow - PAGING_CONTEXT_LINES; 270 lnsppg = TermWin.nrow - PAGING_CONTEXT_LINES;
165#else 271#else
222 { 328 {
223 /* normal XTerm key bindings */ 329 /* normal XTerm key bindings */
224 case XK_Insert: /* Shift+Insert = paste mouse selection */ 330 case XK_Insert: /* Shift+Insert = paste mouse selection */
225 selection_request (ev.time, 0, 0); 331 selection_request (ev.time, 0, 0);
226 return; 332 return;
333#if TODO // TODO
227 /* rxvt extras */ 334 /* rxvt extras */
228 case XK_KP_Add: /* Shift+KP_Add = bigger font */ 335 case XK_KP_Add: /* Shift+KP_Add = bigger font */
229 change_font (FONT_UP); 336 change_font (FONT_UP);
230 return; 337 return;
231 case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ 338 case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */
232 change_font (FONT_DN); 339 change_font (FONT_DN);
233 return; 340 return;
341#endif
234 } 342 }
235 } 343 }
236 } 344 }
345
346#ifndef NO_FRILLS
347 // ISO 14755 support
348 if (shft && ctrl)
349 {
350 int hv;
351
352 if (keysym == XK_space || keysym == XK_KP_Space
353 || keysym == XK_Return || keysym == XK_KP_Enter)
354 {
355 commit_iso14755 ();
356 return;
357 }
358 else if ((hv = hex_keyval (ev)) >= 0)
359 {
360 iso14755buf = (iso14755buf << 4) | hv | ISO_14755_KEYCODE_VALID;
361 return;
362 }
363 else
364 iso14755buf = 0;
365 }
366 else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R))
367 || (shft && (keysym == XK_Control_L || keysym == XK_Control_R)))
368 iso14755buf |= ISO_14755_ACTIVE;
369#endif
370
237#ifdef PRINTPIPE 371#ifdef PRINTPIPE
238 if (keysym == XK_Print) 372 if (keysym == XK_Print)
239 { 373 {
240 scr_printscreen (ctrl | shft); 374 scr_printscreen (ctrl | shft);
241 return; 375 return;
306 newlen = 0; 440 newlen = 0;
307 } 441 }
308 break; 442 break;
309 443
310#ifdef XK_KP_Left 444#ifdef XK_KP_Left
311 case XK_KP_Up: /* \033Ox or standard */ 445 case XK_KP_Up: /* \033Ox or standard */
312 case XK_KP_Down: /* \033Or or standard */ 446 case XK_KP_Down: /* \033Or or standard */
313 case XK_KP_Right: /* \033Ov or standard */ 447 case XK_KP_Right: /* \033Ov or standard */
314 case XK_KP_Left: /* \033Ot or standard */ 448 case XK_KP_Left: /* \033Ot or standard */
315 if ((PrivateModes & PrivMode_aplKP) ? !shft : shft) 449 if ((PrivateModes & PrivMode_aplKP) ? !shft : shft)
316 { 450 {
661 if (want_full_refresh) 795 if (want_full_refresh)
662 { 796 {
663 want_full_refresh = 0; 797 want_full_refresh = 0;
664 scr_clear (); 798 scr_clear ();
665 scr_touch (false); 799 scr_touch (false);
666 want_refresh = 1;
667 } 800 }
668#endif 801#endif
669 802
670 if (want_refresh) 803 if (want_refresh)
671 { 804 {
675 IMSendSpot (); 808 IMSendSpot ();
676#endif 809#endif
677 } 810 }
678 811
679 display->flush (); 812 display->flush ();
813
814 flush_ev.stop ();
680} 815}
681 816
682void 817void
683rxvt_term::check_cb (check_watcher &w) 818rxvt_term::check_cb (check_watcher &w)
684{ 819{
685 SET_R (this); 820 SET_R (this);
686 SET_LOCALE (locale); 821 SET_LOCALE (locale);
687 822
823 display->flush ();
824
825 if (want_refresh && !flush_ev.active)
826 flush_ev.start (NOW + 0.01);
827}
828
829void
830rxvt_term::flush_cb (time_watcher &w)
831{
832 SET_R (this);
833 SET_LOCALE (locale);
834
835 refresh_limit = 1;
836 refresh_count = 0;
688 flush (); 837 flush ();
689} 838}
690 839
691#ifdef CURSOR_BLINK 840#ifdef CURSOR_BLINK
692void 841void
796 while (pty_fill ()) 945 while (pty_fill ())
797 if (cmd_parse ()) 946 if (cmd_parse ())
798 break; 947 break;
799} 948}
800 949
801#ifdef POINTER_BLANK
802void 950void
803rxvt_term::pointer_unblank () 951rxvt_term::pointer_unblank ()
804{ 952{
805 XDefineCursor (display->display, TermWin.vt, TermWin_cursor); 953 XDefineCursor (display->display, TermWin.vt, TermWin_cursor);
806 recolour_cursor (); 954 recolour_cursor ();
807 955
956#ifdef POINTER_BLANK
808 hidden_pointer = 0; 957 hidden_pointer = 0;
809 958
810 if (Options & Opt_pointerBlank) 959 if (Options & Opt_pointerBlank)
811 pointer_ev.start (NOW + pointerBlankDelay); 960 pointer_ev.start (NOW + pointerBlankDelay);
961#endif
812} 962}
813 963
964#ifdef POINTER_BLANK
814void 965void
815rxvt_term::pointer_blank () 966rxvt_term::pointer_blank ()
816{ 967{
817 if (! (Options & Opt_pointerBlank)) 968 if (! (Options & Opt_pointerBlank))
818 return; 969 return;
1008#endif 1159#endif
1009 1160
1010 switch (ev.type) 1161 switch (ev.type)
1011 { 1162 {
1012 case KeyPress: 1163 case KeyPress:
1164 if (!(iso14755buf & ISO_14755_ESCAPE_NEXT))
1013 lookup_key (ev.xkey); 1165 lookup_key (ev.xkey);
1166
1167 break;
1168
1169 case KeyRelease:
1170 {
1171#if (defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)) || !defined (NO_FRILLS)
1172 KeySym ks;
1173
1174 ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/
1175#endif
1176
1177#ifndef NO_FRILLS
1178 // ISO 14755 support
1179 if (iso14755buf)
1180 if (iso14755buf & ISO_14755_ESCAPE_NEXT)
1181 {
1182 // iso14755 part 5.2 handling: release time
1183 // first: controls
1184 if ((ev.xkey.state & ControlMask)
1185 && ((ks >= 0x40 && ks <= 0x5f)
1186 || (ks >= 0x61 && ks <= 0x7f)))
1187 {
1188 iso14755buf = ISO_14755_KEYCODE_VALID | 0x2400 | (ks & 0x1f);
1189 commit_iso14755 ();
1190 return; // case-break;
1191 }
1192
1193 for (unsigned short *i = iso14755_symtab; i[0]; i+= 2)
1194 if (i[0] == ks)
1195 {
1196 iso14755buf = ISO_14755_KEYCODE_VALID | i[1];
1197 commit_iso14755 ();
1198 return; // case-break;
1199 }
1200
1201 iso14755buf = 0;
1202 scr_bell ();
1014 break; 1203 break;
1204 }
1205 else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask))
1206 {
1207 if (iso14755buf & ISO_14755_KEYCODE_VALID)
1208 commit_iso14755 ();
1209 else if (iso14755buf & ISO_14755_ACTIVE)
1210 iso14755buf = ISO_14755_ESCAPE_NEXT; // iso14755 part 5.2: remember empty begin/end pair
1211 }
1212#endif
1015 1213
1016#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) 1214#if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)
1017 case KeyRelease:
1018 {
1019 if (!(ev.xkey.state & ControlMask)) 1215 if (!(ev.xkey.state & ControlMask))
1020 slip_wheel_ev.stop (); 1216 slip_wheel_ev.stop ();
1021 else
1022 {
1023 KeySym ks;
1024
1025 ks = XKeycodeToKeysym (display->display, ev.xkey.keycode, 0);
1026 if (ks == XK_Control_L || ks == XK_Control_R) 1217 else if (ks == XK_Control_L || ks == XK_Control_R)
1027 mouse_slip_wheel_speed = 0; 1218 mouse_slip_wheel_speed = 0;
1028 } 1219#endif
1029 break; 1220 break;
1030 } 1221 }
1031#endif
1032 1222
1033 case ButtonPress: 1223 case ButtonPress:
1034 button_press (ev.xbutton); 1224 button_press (ev.xbutton);
1035 break; 1225 break;
1036 1226
1072 } 1262 }
1073#endif /* OFFIX_DND */ 1263#endif /* OFFIX_DND */
1074 break; 1264 break;
1075 1265
1076 case MappingNotify: 1266 case MappingNotify:
1077 XRefreshKeyboardMapping (& (ev.xmapping)); 1267 XRefreshKeyboardMapping (&ev.xmapping);
1078 break; 1268 break;
1079 1269
1080 /* 1270 /*
1081 * XXX: this is not the _current_ arrangement 1271 * XXX: this is not the _current_ arrangement
1082 * Here's my conclusion: 1272 * Here's my conclusion:
1113#endif 1303#endif
1114#ifdef CURSOR_BLINK 1304#ifdef CURSOR_BLINK
1115 if (Options & Opt_cursorBlink) 1305 if (Options & Opt_cursorBlink)
1116 cursor_blink_ev.start (NOW + BLINK_INTERVAL); 1306 cursor_blink_ev.start (NOW + BLINK_INTERVAL);
1117#endif 1307#endif
1308#ifdef OFF_FOCUS_FADING
1309 if (rs[Rs_fade])
1310 {
1311 PixColors = PixColorsFocused;
1312 set_colorfgbg ();
1313 scr_clear ();
1314 scr_touch (true);
1315 }
1316#endif
1118 1317
1119 } 1318 }
1120 break; 1319 break;
1121 1320
1122 case FocusOut: 1321 case FocusOut:
1131#ifdef CURSOR_BLINK 1330#ifdef CURSOR_BLINK
1132 if (Options & Opt_cursorBlink) 1331 if (Options & Opt_cursorBlink)
1133 cursor_blink_ev.stop (); 1332 cursor_blink_ev.stop ();
1134 hidden_cursor = 0; 1333 hidden_cursor = 0;
1135#endif 1334#endif
1335#ifdef OFF_FOCUS_FADING
1336 if (rs[Rs_fade])
1337 {
1338 PixColors = PixColorsUnFocused;
1339 set_colorfgbg ();
1340 scr_clear ();
1341 scr_touch (true);
1342 }
1343#endif
1136 1344
1137 } 1345 }
1138 break; 1346 break;
1139 1347
1140 case ConfigureNotify: 1348 case ConfigureNotify:
1149 D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); 1357 D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height));
1150 } 1358 }
1151 while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); 1359 while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev));
1152 1360
1153 if (szHint.width != width || szHint.height != height) 1361 if (szHint.width != width || szHint.height != height)
1154 {
1155 D_SIZE ((stderr, "Size: Resizing from: %4d x %4d", szHint.width, szHint.height));
1156 resize_all_windows (width, height, 1); 1362 resize_all_windows (width, height, 1);
1157 } 1363
1158#ifdef DEBUG_SIZE
1159 else
1160 {
1161 D_SIZE ((stderr, "Size: Not resizing"));
1162 }
1163#endif
1164#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ 1364#ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */
1165 if (Options & Opt_transparent) 1365 if (Options & Opt_transparent)
1166 { 1366 {
1167 check_our_parents (); 1367 check_our_parents ();
1168 if (am_transparent) 1368 if (am_transparent)
1169 want_full_refresh = 1; 1369 want_refresh = want_full_refresh = 1;
1170 } 1370 }
1171#endif 1371#endif
1172 } 1372 }
1373 break;
1374
1375 case PropertyNotify:
1376 if (ev.xproperty.atom == xa[XA_VT_SELECTION]
1377 && ev.xproperty.state == PropertyNewValue)
1378 selection_property (ev.xproperty.window, ev.xproperty.atom);
1379
1173 break; 1380 break;
1174 1381
1175 case SelectionClear: 1382 case SelectionClear:
1176 selection_clear (); 1383 selection_clear ();
1177 break; 1384 break;
1208 1415
1209 case GraphicsExpose: 1416 case GraphicsExpose:
1210 case Expose: 1417 case Expose:
1211 if (ev.xany.window == TermWin.vt) 1418 if (ev.xany.window == TermWin.vt)
1212 { 1419 {
1213#ifdef NO_SLOW_LINK_SUPPORT 1420 do
1214 scr_expose (ev.xexpose.x, ev.xexpose.y, 1421 scr_expose (ev.xexpose.x, ev.xexpose.y,
1215 ev.xexpose.width, ev.xexpose.height, False); 1422 ev.xexpose.width, ev.xexpose.height, False);
1216#else 1423 while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev));
1217 // I don't understand this, so I changed it :) 1424
1425 ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose;
1426
1427 while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev))
1218 scr_expose (ev.xexpose.x, ev.xexpose.y, 1428 scr_expose (ev.xexpose.x, ev.xexpose.y,
1219 ev.xexpose.width, ev.xexpose.height, False); 1429 ev.xexpose.width, ev.xexpose.height, False);
1220 //scr_expose (ev.xexpose.x, 0, 1430
1221 // ev.xexpose.width, TermWin.height, False); 1431 scr_refresh (refresh_type);
1222#endif
1223 want_refresh = 1;
1224 } 1432 }
1225 else 1433 else
1226 { 1434 {
1227 XEvent unused_event; 1435 XEvent unused_event;
1228 1436
1237 scrollbar_show (0); 1445 scrollbar_show (0);
1238 } 1446 }
1239#ifdef MENUBAR 1447#ifdef MENUBAR
1240 if (menubar_visible () && isMenuBarWindow (ev.xany.window)) 1448 if (menubar_visible () && isMenuBarWindow (ev.xany.window))
1241 menubar_expose (); 1449 menubar_expose ();
1450#endif
1451
1452#ifdef TRANSPARENT
1453 if (am_transparent && ev.xany.window == TermWin.parent[0])
1454 XClearWindow (display->display, ev.xany.window);
1242#endif 1455#endif
1243 } 1456 }
1244 break; 1457 break;
1245 1458
1246 case MotionNotify: 1459 case MotionNotify:
1347 } 1560 }
1348 break; 1561 break;
1349 } 1562 }
1350} 1563}
1351 1564
1565#if TRANSPARENT
1352void 1566void
1353rxvt_term::rootwin_cb (XEvent &ev) 1567rxvt_term::rootwin_cb (XEvent &ev)
1354{ 1568{
1355 SET_R (this); 1569 SET_R (this);
1356 SET_LOCALE (locale); 1570 SET_LOCALE (locale);
1357 1571
1358 switch (ev.type) 1572 switch (ev.type)
1359 { 1573 {
1360 case PropertyNotify: 1574 case PropertyNotify:
1361 if (ev.xproperty.atom == xa[XA_VT_SELECTION])
1362 {
1363 if (ev.xproperty.state == PropertyNewValue)
1364 selection_property (ev.xproperty.window, ev.xproperty.atom);
1365 break;
1366 }
1367#ifdef TRANSPARENT
1368 else
1369 {
1370 /* 1575 /*
1371 * if user used some Esetroot compatible prog to set the root bg, 1576 * if user used some Esetroot compatible prog to set the root bg,
1372 * use the property to determine the pixmap. We use it later on. 1577 * use the property to determine the pixmap. We use it later on.
1373 */ 1578 */
1374 if (xa[XA_XROOTPMAPID] == 0) 1579 if (xa[XA_XROOTPMAPID] == 0)
1375 xa[XA_XROOTPMAPID] = XInternAtom (display->display, "_XROOTPMAP_ID", False); 1580 xa[XA_XROOTPMAPID] = XInternAtom (display->display, "_XROOTPMAP_ID", False);
1376 1581
1377 if (ev.xproperty.atom != xa[XA_XROOTPMAPID]) 1582 if (ev.xproperty.atom != xa[XA_XROOTPMAPID])
1378 return; 1583 return;
1379 }
1380 1584
1381 /* FALLTHROUGH */ 1585 /* FALLTHROUGH */
1382 case ReparentNotify: 1586 case ReparentNotify:
1383 if ((Options & Opt_transparent) && check_our_parents () && am_transparent) 1587 if ((Options & Opt_transparent) && check_our_parents () && am_transparent)
1384 want_full_refresh = 1; 1588 want_refresh = want_full_refresh = 1;
1385 break; 1589 break;
1386#endif
1387 } 1590 }
1388} 1591}
1592#endif
1389 1593
1390void 1594void
1391rxvt_term::button_press (XButtonEvent &ev) 1595rxvt_term::button_press (XButtonEvent &ev)
1392{ 1596{
1393 int reportmode = 0, clickintime; 1597 int reportmode = 0, clickintime;
1571 break; 1775 break;
1572 case R_SB_ALIGN_BOTTOM: 1776 case R_SB_ALIGN_BOTTOM:
1573 csrO = scrollBar.bot - scrollBar.top; 1777 csrO = scrollBar.bot - scrollBar.top;
1574 break; 1778 break;
1575 } 1779 }
1780
1576 if (scrollBar.style == R_SB_XTERM 1781 if (scrollBar.style == R_SB_XTERM
1577 || scrollbar_above_slider (ev.y) 1782 || scrollbar_above_slider (ev.y)
1578 || scrollbar_below_slider (ev.y)) 1783 || scrollbar_below_slider (ev.y))
1579 scr_move_to ( scrollbar_position (ev.y) - csrO, 1784 scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ());
1580 scrollbar_size ()); 1785
1581 scrollBar.setMotion (); 1786 scrollBar.setMotion ();
1582 break; 1787 break;
1583 1788
1584 case Button1: 1789 case Button1:
1585 if (scrollbar_align == R_SB_ALIGN_CENTRE) 1790 if (scrollbar_align == R_SB_ALIGN_CENTRE)
1609 scr_page ((ev.button == Button1 ? DN : UP), 1814 scr_page ((ev.button == Button1 ? DN : UP),
1610 (TermWin.nrow 1815 (TermWin.nrow
1611 * scrollbar_position (ev.y) 1816 * scrollbar_position (ev.y)
1612 / scrollbar_size ())); 1817 / scrollbar_size ()));
1613 } 1818 }
1819
1614 break; 1820 break;
1615 } 1821 }
1616 } 1822 }
1617 return; 1823 return;
1618 } 1824 }
1708 1914
1709# ifdef MOUSE_SLIP_WHEELING 1915# ifdef MOUSE_SLIP_WHEELING
1710 if (ev.state & ControlMask) 1916 if (ev.state & ControlMask)
1711 { 1917 {
1712 mouse_slip_wheel_speed += v ? -1 : 1; 1918 mouse_slip_wheel_speed += v ? -1 : 1;
1919 if (mouse_slip_wheel_speed < -TermWin.nrow) mouse_slip_wheel_speed = -TermWin.nrow;
1920 if (mouse_slip_wheel_speed > +TermWin.nrow) mouse_slip_wheel_speed = +TermWin.nrow;
1921
1922 if (slip_wheel_ev.at < NOW)
1713 slip_wheel_ev.start (NOW + SCROLLBAR_CONTINUOUS_DELAY); 1923 slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY;
1924
1925 slip_wheel_ev.start ();
1714 } 1926 }
1927 else
1928 {
1715# endif 1929# endif
1716# ifdef JUMP_MOUSE_WHEEL 1930# ifdef JUMP_MOUSE_WHEEL
1717 scr_page (v, i);
1718 scr_refresh (SMOOTH_REFRESH);
1719 scrollbar_show (1);
1720# else
1721 while (i--)
1722 {
1723 scr_page (v, 1); 1931 scr_page (v, i);
1724 scr_refresh (SMOOTH_REFRESH); 1932 scr_refresh (SMOOTH_REFRESH);
1725 scrollbar_show (1); 1933 scrollbar_show (1);
1934# else
1935 while (i--)
1936 {
1937 scr_page (v, 1);
1938 scr_refresh (SMOOTH_REFRESH);
1939 scrollbar_show (1);
1940 }
1941# endif
1942# ifdef MOUSE_SLIP_WHEELING
1726 } 1943 }
1727# endif 1944#endif
1728
1729 } 1945 }
1730 break; 1946 break;
1731#endif 1947#endif
1732
1733 } 1948 }
1734 } 1949 }
1735#ifdef MENUBAR 1950#ifdef MENUBAR
1736 else if (isMenuBarWindow (ev.window)) 1951 else if (isMenuBarWindow (ev.window))
1737 menubar_control (ev); 1952 menubar_control (ev);
1738#endif 1953#endif
1739} 1954}
1740 1955
1741#ifdef TRANSPARENT 1956#ifdef TRANSPARENT
1742#if TINTING 1957#if TINTING
1743/* shading taken from eterm-0.9.2 */ 1958/* taken from aterm-0.4.2 */
1744/* RGB 15 */
1745 1959
1746static void 1960typedef uint32_t RUINT32T;
1747shade_ximage_15(void *data, int bpl, int w, int h, int rm, int gm, int bm)
1748{
1749 unsigned char *ptr;
1750 int x, y;
1751 1961
1752 ptr = (unsigned char *)data + (w * sizeof(uint16_t)); 1962void ShadeXImage(rxvt_display *display, XImage* srcImage, int shade, int rm, int gm, int bm)
1753 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { 1963{
1754 /* No saturation */ 1964 int sh_r, sh_g, sh_b;
1755 for (y = h; --y >= 0;) { 1965 RUINT32T mask_r, mask_g, mask_b;
1756 for (x = -w; x < 0; x++) { 1966 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b;
1757 int r, g, b; 1967 unsigned int lower_lim_r, lower_lim_g, lower_lim_b;
1968 unsigned int upper_lim_r, upper_lim_g, upper_lim_b;
1969 int i;
1758 1970
1759 b = ((uint16_t *) ptr)[x]; 1971 Visual* visual = display->visual;
1760 r = (b & 0x7c00) * rm; 1972
1761 g = (b & 0x3e0) * gm; 1973 if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ;
1762 b = (b & 0x1f) * bm; 1974
1763 ((uint16_t *) ptr)[x] = ((r >> 8) & 0x7c00) 1975 /* for convenience */
1764 | ((g >> 8) & 0x3e0) 1976 mask_r = visual->red_mask;
1765 | ((b >> 8) & 0x1f); 1977 mask_g = visual->green_mask;
1766 } 1978 mask_b = visual->blue_mask;
1767 ptr += bpl; 1979
1768 } 1980 /* boring lookup table pre-initialization */
1981 switch (srcImage->bits_per_pixel) {
1982 case 15:
1983 if ((mask_r != 0x7c00) ||
1984 (mask_g != 0x03e0) ||
1985 (mask_b != 0x001f))
1986 return;
1987 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32));
1988 lookup_r = lookup;
1989 lookup_g = lookup+32;
1990 lookup_b = lookup+32+32;
1991 sh_r = 10;
1992 sh_g = 5;
1993 sh_b = 0;
1994 break;
1995 case 16:
1996 if ((mask_r != 0xf800) ||
1997 (mask_g != 0x07e0) ||
1998 (mask_b != 0x001f))
1999 return;
2000 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32));
2001 lookup_r = lookup;
2002 lookup_g = lookup+32;
2003 lookup_b = lookup+32+64;
2004 sh_r = 11;
2005 sh_g = 5;
2006 sh_b = 0;
2007 break;
2008 case 24:
2009 if ((mask_r != 0xff0000) ||
2010 (mask_g != 0x00ff00) ||
2011 (mask_b != 0x0000ff))
2012 return;
2013 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
2014 lookup_r = lookup;
2015 lookup_g = lookup+256;
2016 lookup_b = lookup+256+256;
2017 sh_r = 16;
2018 sh_g = 8;
2019 sh_b = 0;
2020 break;
2021 case 32:
2022 if ((mask_r != 0xff0000) ||
2023 (mask_g != 0x00ff00) ||
2024 (mask_b != 0x0000ff))
2025 return;
2026 lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256));
2027 lookup_r = lookup;
2028 lookup_g = lookup+256;
2029 lookup_b = lookup+256+256;
2030 sh_r = 16;
2031 sh_g = 8;
2032 sh_b = 0;
2033 break;
2034 default:
2035 return; /* we do not support this color depth */
2036 }
2037
2038 /* prepare limits for color transformation (each channel is handled separately) */
2039 if (shade < 0) {
2040 shade = -shade;
2041 if (shade < 0) shade = 0;
2042 if (shade > 100) shade = 100;
2043
2044 lower_lim_r = 65535-rm;
2045 lower_lim_g = 65535-gm;
2046 lower_lim_b = 65535-bm;
2047
2048 lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100);
2049 lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100);
2050 lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100);
2051
2052 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
1769 } else { 2053 } else {
1770 for (y = h; --y >= 0;) { 2054 if (shade < 0) shade = 0;
1771 for (x = -w; x < 0; x++) { 2055 if (shade > 100) shade = 100;
1772 int r, g, b;
1773 2056
1774 b = ((uint16_t *) ptr)[x]; 2057 lower_lim_r = lower_lim_g = lower_lim_b = 0;
1775 r = (b & 0x7c00) * rm; 2058
1776 g = (b & 0x3e0) * gm; 2059 upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100);
1777 b = (b & 0x1f) * bm; 2060 upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100);
1778 r |= (!(r >> 15) - 1); 2061 upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100);
1779 g |= (!(g >> 10) - 1); 2062 }
1780 b |= (!(b >> 5) - 1); 2063
1781 ((uint16_t *) ptr)[x] = ((r >> 8) & 0x7c00) 2064 /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */
1782 | ((g >> 8) & 0x3e0) 2065 if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 ))
1783 | ((b >> 8) & 0x1f); 2066 {
1784 } 2067 unsigned int tmp;
1785 ptr += bpl; 2068
2069 tmp = lower_lim_r;
2070 lower_lim_r = lower_lim_b;
2071 lower_lim_b = tmp;
2072
2073 tmp = upper_lim_r;
2074 upper_lim_r = upper_lim_b;
2075 upper_lim_b = tmp;
2076 }
2077
2078 /* fill our lookup tables */
2079 for (i = 0; i <= mask_r>>sh_r; i++)
2080 {
2081 RUINT32T tmp;
2082 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r));
2083 tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r);
2084 lookup_r[i] = (tmp/65535)<<sh_r;
2085 }
2086 for (i = 0; i <= mask_g>>sh_g; i++)
2087 {
2088 RUINT32T tmp;
2089 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g));
2090 tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g);
2091 lookup_g[i] = (tmp/65535)<<sh_g;
2092 }
2093 for (i = 0; i <= mask_b>>sh_b; i++)
2094 {
2095 RUINT32T tmp;
2096 tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b));
2097 tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b);
2098 lookup_b[i] = (tmp/65535)<<sh_b;
2099 }
2100
2101 /* apply table to input image (replacing colors by newly calculated ones) */
2102 switch (srcImage->bits_per_pixel)
2103 {
2104 case 15:
2105 {
2106 unsigned short *p1, *pf, *p, *pl;
2107 p1 = (unsigned short *) srcImage->data;
2108 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2109 while (p1 < pf)
2110 {
2111 p = p1;
2112 pl = p1 + srcImage->width;
2113 for (; p < pl; p++)
1786 } 2114 {
2115 *p = lookup_r[(*p & 0x7c00)>>10] |
2116 lookup_g[(*p & 0x03e0)>> 5] |
2117 lookup_b[(*p & 0x001f)];
2118 }
2119 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
1787 } 2120 }
1788} 2121 break;
1789 2122 }
1790/* RGB 16 */ 2123 case 16:
1791static void 2124 {
1792shade_ximage_16(void *data, int bpl, int w, int h, int rm, int gm, int bm) 2125 unsigned short *p1, *pf, *p, *pl;
1793{ 2126 p1 = (unsigned short *) srcImage->data;
1794 unsigned char *ptr; 2127 pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
1795 int x, y; 2128 while (p1 < pf)
1796 2129 {
1797 ptr = (unsigned char *)data + (w * sizeof(uint16_t)); 2130 p = p1;
1798 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) { 2131 pl = p1 + srcImage->width;
1799 /* No saturation */ 2132 for (; p < pl; p++)
1800 for (y = h; --y >= 0;) {
1801 for (x = -w; x < 0; x++) {
1802 int r, g, b;
1803
1804 b = ((uint16_t *) ptr)[x];
1805 r = (b & 0xf800) * rm;
1806 g = (b & 0x7e0) * gm;
1807 b = (b & 0x1f) * bm;
1808 ((uint16_t *) ptr)[x] = ((r >> 8) & 0xf800)
1809 | ((g >> 8) & 0x7e0)
1810 | ((b >> 8) & 0x1f);
1811 }
1812 ptr += bpl;
1813 } 2133 {
1814 } else { 2134 *p = lookup_r[(*p & 0xf800)>>11] |
1815 for (y = h; --y >= 0;) { 2135 lookup_g[(*p & 0x07e0)>> 5] |
1816 for (x = -w; x < 0; x++) { 2136 lookup_b[(*p & 0x001f)];
1817 int r, g, b;
1818
1819 b = ((uint16_t *) ptr)[x];
1820 r = (b & 0xf800) * rm;
1821 g = (b & 0x7e0) * gm;
1822 b = (b & 0x1f) * bm;
1823 r |= (!(r >> 16) - 1);
1824 g |= (!(g >> 11) - 1);
1825 b |= (!(b >> 5) - 1);
1826 ((uint16_t *) ptr)[x] = ((r >> 8) & 0xf800)
1827 | ((g >> 8) & 0x7e0)
1828 | ((b >> 8) & 0x1f);
1829 } 2137 }
1830 ptr += bpl; 2138 p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line);
2139 }
2140 break;
2141 }
2142 case 24:
2143 {
2144 unsigned char *p1, *pf, *p, *pl;
2145 p1 = (unsigned char *) srcImage->data;
2146 pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
2147 while (p1 < pf)
2148 {
2149 p = p1;
2150 pl = p1 + srcImage->width * 3;
2151 for (; p < pl; p += 3)
1831 } 2152 {
2153 p[0] = lookup_r[(p[0] & 0xff0000)>>16];
2154 p[1] = lookup_r[(p[1] & 0x00ff00)>> 8];
2155 p[2] = lookup_r[(p[2] & 0x0000ff)];
2156 }
2157 p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line);
1832 } 2158 }
1833} 2159 break;
2160 }
2161 case 32:
2162 {
2163 RUINT32T *p1, *pf, *p, *pl;
2164 p1 = (RUINT32T *) srcImage->data;
2165 pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line);
1834 2166
1835/* RGB 24 */ 2167 while (p1 < pf)
1836static void 2168 {
1837shade_ximage_24(void *data, int bpl, int w, int h, int rm, int gm, int bm) 2169 p = p1;
1838{ 2170 pl = p1 + srcImage->width;
1839 unsigned char *ptr; 2171 for (; p < pl; p++)
1840 int x, y;
1841
1842 ptr = (unsigned char *)data + (w * 3);
1843 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
1844 /* No saturation */
1845 for (y = h; --y >= 0;) {
1846 for (x = -(w * 3); x < 0; x += 3) {
1847 int r, g, b;
1848
1849 if (byteorder.big_endian()) {
1850 r = (ptr[x + 0] * rm) >> 8;
1851 g = (ptr[x + 1] * gm) >> 8;
1852 b = (ptr[x + 2] * bm) >> 8;
1853 ptr[x + 0] = r;
1854 ptr[x + 1] = g;
1855 ptr[x + 2] = b;
1856 } else {
1857 r = (ptr[x + 2] * rm) >> 8;
1858 g = (ptr[x + 1] * gm) >> 8;
1859 b = (ptr[x + 0] * bm) >> 8;
1860 ptr[x + 2] = r;
1861 ptr[x + 1] = g;
1862 ptr[x + 0] = b;
1863 }
1864 }
1865 ptr += bpl;
1866 } 2172 {
1867 } else { 2173 *p = lookup_r[(*p & 0xff0000)>>16] |
1868 for (y = h; --y >= 0;) { 2174 lookup_g[(*p & 0x00ff00)>> 8] |
1869 for (x = -(w * 3); x < 0; x += 3) { 2175 lookup_b[(*p & 0x0000ff)] |
1870 int r, g, b; 2176 (*p & ~0xffffff);
1871
1872 if (byteorder.big_endian()) {
1873 r = (ptr[x + 0] * rm) >> 8;
1874 g = (ptr[x + 1] * gm) >> 8;
1875 b = (ptr[x + 2] * bm) >> 8;
1876
1877 r |= (!(r >> 8) - 1);
1878 g |= (!(g >> 8) - 1);
1879 b |= (!(b >> 8) - 1);
1880
1881 ptr[x + 0] = r;
1882 ptr[x + 1] = g;
1883 ptr[x + 2] = b;
1884 } else {
1885 r = (ptr[x + 2] * rm) >> 8;
1886 g = (ptr[x + 1] * gm) >> 8;
1887 b = (ptr[x + 0] * bm) >> 8;
1888
1889 r |= (!(r >> 8) - 1);
1890 g |= (!(g >> 8) - 1);
1891 b |= (!(b >> 8) - 1);
1892
1893 ptr[x + 2] = r;
1894 ptr[x + 1] = g;
1895 ptr[x + 0] = b;
1896 }
1897 } 2177 }
1898 ptr += bpl; 2178 p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line);
1899 } 2179 }
2180 break;
2181 }
1900 } 2182 }
1901}
1902 2183
1903/* RGB 32 */ 2184 free (lookup);
1904static void
1905shade_ximage_32(void *data, int bpl, int w, int h, int rm, int gm, int bm)
1906{
1907 unsigned char *ptr;
1908 int x, y;
1909
1910 ptr = (unsigned char *)data + (w * 4);
1911 if ((rm <= 256) && (gm <= 256) && (bm <= 256)) {
1912 /* No saturation */
1913 for (y = h; --y >= 0;) {
1914 if (byteorder.big_endian()) {
1915 for (x = -(w * 4); x < 0; x += 4) {
1916 int r, g, b;
1917
1918 r = (ptr[x + 1] * rm) >> 8;
1919 g = (ptr[x + 2] * gm) >> 8;
1920 b = (ptr[x + 3] * bm) >> 8;
1921 ptr[x + 1] = r;
1922 ptr[x + 2] = g;
1923 ptr[x + 3] = b;
1924 }
1925 } else {
1926 for (x = -(w * 4); x < 0; x += 4) {
1927 int r, g, b;
1928
1929 r = (ptr[x + 2] * rm) >> 8;
1930 g = (ptr[x + 1] * gm) >> 8;
1931 b = (ptr[x + 0] * bm) >> 8;
1932 ptr[x + 2] = r;
1933 ptr[x + 1] = g;
1934 ptr[x + 0] = b;
1935 }
1936 }
1937 ptr += bpl;
1938 }
1939 } else {
1940 for (y = h; --y >= 0;) {
1941 for (x = -(w * 4); x < 0; x += 4) {
1942 int r, g, b;
1943
1944 if (byteorder.big_endian()) {
1945 r = (ptr[x + 1] * rm) >> 8;
1946 g = (ptr[x + 2] * gm) >> 8;
1947 b = (ptr[x + 3] * bm) >> 8;
1948
1949 r |= (!(r >> 8) - 1);
1950 g |= (!(g >> 8) - 1);
1951 b |= (!(b >> 8) - 1);
1952
1953 ptr[x + 1] = r;
1954 ptr[x + 2] = g;
1955 ptr[x + 3] = b;
1956 } else {
1957 r = (ptr[x + 2] * rm) >> 8;
1958 g = (ptr[x + 1] * gm) >> 8;
1959 b = (ptr[x + 0] * bm) >> 8;
1960
1961 r |= (!(r >> 8) - 1);
1962 g |= (!(g >> 8) - 1);
1963 b |= (!(b >> 8) - 1);
1964
1965 ptr[x + 2] = r;
1966 ptr[x + 1] = g;
1967 ptr[x + 0] = b;
1968 }
1969 }
1970 ptr += bpl;
1971 }
1972 }
1973} 2185}
1974
1975#endif 2186#endif
1976 2187
1977/* 2188/*
1978 * Check our parents are still who we think they are. 2189 * Check our parents are still who we think they are.
1979 * Do transparency updates if required 2190 * Do transparency updates if required
2002 if (rootdepth != wattr.depth) 2213 if (rootdepth != wattr.depth)
2003 { 2214 {
2004 if (am_transparent) 2215 if (am_transparent)
2005 { 2216 {
2006 pchanged = 1; 2217 pchanged = 1;
2007 XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); 2218 XSetWindowBackground (display->display, TermWin.vt, PixColorsFocused[Color_bg]);
2008 am_transparent = am_pixmap_trans = 0; 2219 am_transparent = am_pixmap_trans = 0;
2009 } 2220 }
2010 2221
2011 return pchanged; /* Don't try any more */ 2222 return pchanged; /* Don't try any more */
2012 } 2223 }
2028 i = (xa[XA_XSETROOTID] 2239 i = (xa[XA_XSETROOTID]
2029 && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], 2240 && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID],
2030 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 2241 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2031 &nitems, &bytes_after, &prop) == Success); 2242 &nitems, &bytes_after, &prop) == Success);
2032 2243
2033 if (!i || prop == NULL) 2244 if (!i || prop == NULL
2245#if TINTING
2246 || !rs[Rs_color + Color_tint]
2247#endif
2248 )
2034 have_pixmap = 0; 2249 have_pixmap = 0;
2035 else 2250 else
2036 { 2251 {
2037 have_pixmap = 1; 2252 have_pixmap = 1;
2038 rootpixmap = *(Pixmap *)prop; 2253 rootpixmap = *(Pixmap *)prop;
2100 XFreePixmap (display->display, TermWin.pixmap); 2315 XFreePixmap (display->display, TermWin.pixmap);
2101 2316
2102#if TINTING 2317#if TINTING
2103 if (ISSET_PIXCOLOR (Color_tint)) 2318 if (ISSET_PIXCOLOR (Color_tint))
2104 { 2319 {
2105 unsigned short shade, rm, gm, bm; 2320 unsigned short rm, gm, bm;
2321 int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
2106 2322
2107 PixColors[Color_tint].get (display, rm, gm, bm); 2323 PixColorsFocused[Color_tint].get (display, rm, gm, bm);
2108 2324
2109 rm >>= 8; gm >>= 8; bm >>= 8; // not 100% correct, but... 2325 ShadeXImage (display, image, shade, rm, gm, bm);
2110
2111 /* Determine bitshift and bitmask values */
2112 switch (image->bits_per_pixel)
2113 {
2114 case 15: shade_ximage_15 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2115 case 16: shade_ximage_16 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2116 case 24: shade_ximage_24 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2117 case 32: shade_ximage_32 (image->data, image->bytes_per_line, image->width, image->height, rm, gm, bm); break;
2118 }
2119 } 2326 }
2120#endif 2327#endif
2121 2328
2122 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, 2329 TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt,
2123 szHint.width, szHint.height, image->depth); 2330 szHint.width, szHint.height, image->depth);
2124 gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); 2331 gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue);
2125 XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, 2332 XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0,
2126 nx, ny, image->width, image->height); 2333 nx, ny, image->width, image->height);
2127 XFreeGC (display->display, gc); 2334 XFreeGC (display->display, gc);
2128 XDestroyImage (image); 2335 XDestroyImage (image);
2129 XSetWindowBackgroundPixmap (display->display, TermWin.vt, 2336 XSetWindowBackgroundPixmap (display->display, TermWin.parent[0], TermWin.pixmap);
2130 TermWin.pixmap); 2337 XClearWindow (display->display, TermWin.parent[0]);
2131 2338
2132 if (!am_transparent || !am_pixmap_trans) 2339 if (!am_transparent || !am_pixmap_trans)
2133 pchanged = 1; 2340 pchanged = 1;
2134 2341
2135 am_transparent = am_pixmap_trans = 1; 2342 am_transparent = am_pixmap_trans = 1;
2180 } 2387 }
2181 2388
2182 if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) 2389 if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0])))
2183 { 2390 {
2184 D_X ((stderr, "InheritPixmap Turning off")); 2391 D_X ((stderr, "InheritPixmap Turning off"));
2185 XSetWindowBackground (display->display, TermWin.parent[0], PixColors[Color_fg]); 2392 XSetWindowBackground (display->display, TermWin.parent[0], PixColorsFocused[Color_fg]);
2186 XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); 2393 XSetWindowBackground (display->display, TermWin.vt, PixColorsFocused[Color_bg]);
2187 am_transparent = 0; 2394 am_transparent = 0;
2188 /* XXX: also turn off Opt_transparent? */ 2395 /* XXX: also turn off Opt_transparent? */
2189 } 2396 }
2190 else 2397 else
2191 { 2398 {
2194 * needed for fvwm2.2.2 (and before?) */ 2401 * needed for fvwm2.2.2 (and before?) */
2195 sleep (1); 2402 sleep (1);
2196#endif 2403#endif
2197 D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1)); 2404 D_X ((stderr, "InheritPixmap Turning on (%d parents)", i - 1));
2198 for (n = 0; n < (unsigned int)i; n++) 2405 for (n = 0; n < (unsigned int)i; n++)
2406 {
2199 XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); 2407 XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative);
2408 XClearWindow (display->display, TermWin.parent[n]);
2409 }
2200 2410
2201 XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); 2411 XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative);
2202 am_transparent = 1; 2412 am_transparent = 1;
2203 } 2413 }
2204 2414
2205 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) 2415 for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++)
2206 TermWin.parent[i] = None; 2416 TermWin.parent[i] = None;
2417 }
2418
2419 // this is experimental
2420 if (scrollBar.win)
2421 {
2422 XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative);
2423 XClearWindow (display->display, scrollBar.win);
2424 scrollBar.setIdle ();
2425 scrollbar_show (0);
2207 } 2426 }
2208 2427
2209 return pchanged; 2428 return pchanged;
2210} 2429}
2211#endif 2430#endif
2236 unicode_t buf[UBUFSIZ]; 2455 unicode_t buf[UBUFSIZ];
2237 bool refreshnow = false; 2456 bool refreshnow = false;
2238 int nlines = 0; 2457 int nlines = 0;
2239 unicode_t *str = buf; 2458 unicode_t *str = buf;
2240 2459
2241 *str++ = ch;
2242
2243 for (;;) 2460 for (;;)
2244 { 2461 {
2245 seq_begin = cmdbuf_ptr;
2246 ch = next_char ();
2247
2248 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) 2462 if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT))
2249 break; 2463 break;
2250 2464
2251 *str++ = ch; 2465 *str++ = ch;
2252 2466
2253 if (ch == C0_LF) 2467 if (ch == C0_LF)
2254 { 2468 {
2255 nlines++; 2469 nlines++;
2256 refresh_count++; 2470 refresh_count++;
2257 2471
2258 if (! (Options & Opt_jumpScroll) 2472 if (!(Options & Opt_jumpScroll)
2259 || (refresh_count >= (refresh_limit * (TermWin.nrow - 1)))) 2473 || (refresh_count >= refresh_limit * (TermWin.nrow - 1)))
2260 { 2474 {
2261 refreshnow = true; 2475 refreshnow = true;
2262 flag = true;
2263 ch = NOCHAR; 2476 ch = NOCHAR;
2264 break; 2477 break;
2265 } 2478 }
2266 2479
2267 // scr_add_lines only works for nlines < TermWin.nrow - 1. 2480 // scr_add_lines only works for nlines <= TermWin.nrow - 1.
2268 if (nlines >= TermWin.nrow - 1) 2481 if (nlines >= TermWin.nrow - 1)
2269 { 2482 {
2270 scr_add_lines (buf, nlines, str - buf); 2483 scr_add_lines (buf, nlines, str - buf);
2271 nlines = 0; 2484 nlines = 0;
2272 str = buf; 2485 str = buf;
2276 if (str >= buf + UBUFSIZ) 2489 if (str >= buf + UBUFSIZ)
2277 { 2490 {
2278 ch = NOCHAR; 2491 ch = NOCHAR;
2279 break; 2492 break;
2280 } 2493 }
2494
2495 seq_begin = cmdbuf_ptr;
2496 ch = next_char ();
2281 } 2497 }
2282 2498
2283 scr_add_lines (buf, nlines, str - buf); 2499 scr_add_lines (buf, nlines, str - buf);
2284 2500
2285 /* 2501 /*
2286 * If there have been a lot of new lines, then update the screen 2502 * If there have been a lot of new lines, then update the screen
2287 * What the heck I'll cheat and only refresh less than every page-full. 2503 * What the heck I'll cheat and only refresh less than every page-full.
2288 * the number of pages between refreshes is refresh_limit, which 2504 * the number of pages between refreshes is refresh_limit, which
2289 * is incremented here because we must be doing flat-out scrolling. 2505 * is incremented here because we must be doing flat-out scrolling.
2290 *
2291 * refreshing should be correct for small scrolls, because of the
2292 * time-out
2293 */ 2506 */
2294 if (refreshnow) 2507 if (refreshnow)
2295 { 2508 {
2296 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) 2509 if ((Options & Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD)
2297 refresh_limit++; 2510 refresh_limit++;
2298 else 2511 else
2512 {
2513 flag = true;
2299 scr_refresh (refresh_type); 2514 scr_refresh (refresh_type);
2515 }
2300 } 2516 }
2301 2517
2302 } 2518 }
2303 else 2519 else
2304 { 2520 {
3129 break; 3345 break;
3130 case 19: /* report window size (chars) */ 3346 case 19: /* report window size (chars) */
3131 tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); 3347 tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol);
3132 break; 3348 break;
3133 case 20: /* report icon label */ 3349 case 20: /* report icon label */
3134 if (Options & Opt_insecure)
3135 { 3350 {
3136 char *s; 3351 char *s;
3137 XGetIconName (display->display, TermWin.parent[0], &s); 3352 XGetIconName (display->display, TermWin.parent[0], &s);
3138 tt_printf ("\033]L%-.200s\234", s ? s : ""); /* 8bit ST */ 3353 tt_printf ("\033]L%-.250s\234", (Options & Opt_insecure) && s ? s : ""); /* 8bit ST */
3354 XFree (s);
3139 } 3355 }
3140 break; 3356 break;
3141 case 21: /* report window title */ 3357 case 21: /* report window title */
3142 if (Options & Opt_insecure)
3143 { 3358 {
3144 char *s; 3359 char *s;
3145 XFetchName (display->display, TermWin.parent[0], &s); 3360 XFetchName (display->display, TermWin.parent[0], &s);
3146 tt_printf ("\033]l%-.200s\234", s ? s : ""); /* 8bit ST */ 3361 tt_printf ("\033]l%-.250s\234", (Options & Opt_insecure) && s ? s : ""); /* 8bit ST */
3362 XFree (s);
3147 } 3363 }
3148 break; 3364 break;
3149 } 3365 }
3150} 3366}
3151#endif 3367#endif
3152 3368
3249void 3465void
3250rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp) 3466rxvt_term::process_color_seq (int report, int color, const char *str, unsigned char resp)
3251{ 3467{
3252 if (str[0] == '?' && !str[1]) 3468 if (str[0] == '?' && !str[1])
3253 { 3469 {
3254 if (Options & Opt_insecure)
3255 {
3256 unsigned short r, g, b; 3470 unsigned short r, g, b;
3257 PixColors[color].get (display, r, g, b); 3471 PixColorsFocused[color].get (display, r, g, b);
3258 tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp); 3472 tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, r, g, b, resp);
3259 }
3260 } 3473 }
3261 else 3474 else
3262 set_window_color (color, str); 3475 set_window_color (color, str);
3263} 3476}
3264 3477
3364 if ((buf = STRCHR (name, ';')) != NULL) 3577 if ((buf = STRCHR (name, ';')) != NULL)
3365 *buf++ = '\0'; 3578 *buf++ = '\0';
3366 3579
3367 if (name[0] == '?' && !name[1]) 3580 if (name[0] == '?' && !name[1])
3368 { 3581 {
3369 if (Options & Opt_insecure)
3370 {
3371 unsigned short r, g, b; 3582 unsigned short r, g, b;
3372 PixColors[color + minCOLOR].get (display, r, g, b); 3583 PixColorsFocused[color + minCOLOR].get (display, r, g, b);
3373 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp); 3584 tt_printf ("\033]%d;%d;rgb:%04x/%04x/%04x%c", XTerm_Color, color, r, g, b, resp);
3374 }
3375 } 3585 }
3376 else 3586 else
3377 set_window_color (color + minCOLOR, name); 3587 set_window_color (color + minCOLOR, name);
3378 } 3588 }
3379 break; 3589 break;
3443 // TODO, when secure mode? 3653 // TODO, when secure mode?
3444 break; 3654 break;
3445 3655
3446 case XTerm_font: 3656 case XTerm_font:
3447 if (query) 3657 if (query)
3448 {
3449 if (Options & Opt_insecure)
3450 tt_printf ("\33]%d;%-.250s%c", XTerm_font, 3658 tt_printf ("\33]%d;%-.250s%c", XTerm_font,
3659 (Options & Opt_insecure) && TermWin.fontset->fontdesc
3451 TermWin.fontset->fontdesc 3660 ? TermWin.fontset->fontdesc : "",
3452 ? TermWin.fontset->fontdesc
3453 : "",
3454 resp); 3661 resp);
3455 }
3456 else 3662 else
3457 change_font (str); 3663 change_font (str);
3458 break; 3664 break;
3459 3665
3460#ifndef NO_FRILLS 3666#ifndef NO_FRILLS
3461 case XTerm_locale: 3667 case XTerm_locale:
3462 if (query) 3668 if (query)
3463 {
3464 if (Options & Opt_insecure)
3465 tt_printf ("\33]%d;%-.250s%c", XTerm_locale, locale, resp); 3669 tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (Options & Opt_insecure) ? locale : "", resp);
3466 }
3467 else 3670 else
3468 { 3671 {
3469 set_locale (str); 3672 set_locale (str);
3470# ifdef USE_XIM 3673# ifdef USE_XIM
3471 im_cb (); 3674 im_cb ();
3472# endif 3675# endif
3473 } 3676 }
3474 break; 3677 break;
3475 3678
3476 case XTerm_findfont: 3679 case XTerm_findfont:
3477 if (Options & Opt_insecure)
3478 { 3680 {
3479 int fid = TermWin.fontset->find_font (atoi (str)); 3681 int fid = TermWin.fontset->find_font (atoi (str));
3480 tt_printf ("\33]%d;%d;%-.250s%c", XTerm_findfont, 3682 tt_printf ("\33]%d;%d;%-.250s%c", XTerm_findfont,
3481 fid, (*TermWin.fontset)[fid]->name, resp); 3683 fid,
3684 (Options & Opt_insecure) ? (*TermWin.fontset)[fid]->name : "",
3685 resp);
3482 } 3686 }
3483 break; 3687 break;
3484#endif 3688#endif
3485 3689
3486#ifdef MENUBAR 3690#ifdef MENUBAR
3487 case XTerm_Menu: 3691 case XTerm_Menu:
3750 rendset = 0, rendstyle = ~RS_None; 3954 rendset = 0, rendstyle = ~RS_None;
3751 break; 3955 break;
3752 case 1: 3956 case 1:
3753 rendset = 1, rendstyle = RS_Bold; 3957 rendset = 1, rendstyle = RS_Bold;
3754 break; 3958 break;
3959 //case 2: // faint or second colour
3755 case 4: 3960 case 4:
3756 rendset = 1, rendstyle = RS_Uline; 3961 rendset = 1, rendstyle = RS_Uline;
3757 break; 3962 break;
3758 case 5: 3963 case 5: // slowly blinking
3964 case 6: // rapidly blinking
3759 rendset = 1, rendstyle = RS_Blink; 3965 rendset = 1, rendstyle = RS_Blink;
3760 break; 3966 break;
3761 //case 6: // scoansi light background 3967 //case 6: // scoansi light background
3762 case 7: 3968 case 7:
3763 rendset = 1, rendstyle = RS_RVid; 3969 rendset = 1, rendstyle = RS_RVid;
3764 break; 3970 break;
3765 case 8: 3971 case 8:
3766 // invisible. NYI 3972 // invisible. NYI
3767 break; 3973 break;
3974 //case 9: // crossed out
3768 //case 10: // scoansi acs off 3975 //case 10: // scoansi acs off, primary font
3769 //case 11: // scoansi acs on 3976 //case 11: // scoansi acs on, first alt font
3770 //case 12: // scoansi acs on, |0x80 3977 //case 12: // scoansi acs on, |0x80, second alt font
3771 case 21: // disable bold, blink and invis (some terminals use this) 3978 //...
3979 //case 19: // ninth alt font
3980 //case 20: // gothic
3981 case 21: // disable bold, faint
3772 rendset = 0, rendstyle = RS_Bold | RS_Blink; 3982 rendset = 0, rendstyle = RS_Bold;
3773 break; 3983 break;
3774 case 22: 3984 case 22:
3775 rendset = 0, rendstyle = RS_Bold; 3985 rendset = 0, rendstyle = RS_Bold;
3776 break; 3986 break;
3987 //case 23: disable italic
3777 case 24: 3988 case 24:
3778 rendset = 0, rendstyle = RS_Uline; 3989 rendset = 0, rendstyle = RS_Uline;
3779 break; 3990 break;
3780 case 25: 3991 case 25:
3781 rendset = 0, rendstyle = RS_Blink; 3992 rendset = 0, rendstyle = RS_Blink;
3782 break; 3993 break;
3783 case 27: 3994 case 27:
3784 rendset = 0, rendstyle = RS_RVid; 3995 rendset = 0, rendstyle = RS_RVid;
3785 break; 3996 break;
3786 case 28:
3787 // visible. NYI 3997 //case 28: // visible. NYI
3788 break; 3998 //case 29: // not crossed-out
3789 } 3999 }
3790 4000
3791 if (rendset != -1) 4001 if (rendset != -1)
3792 { 4002 {
3793 scr_rendition (rendset, rendstyle); 4003 scr_rendition (rendset, rendstyle);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines