… | |
… | |
48 | #include "../config.h" /* NECESSARY */ |
48 | #include "../config.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
50 | #include "version.h" |
50 | #include "version.h" |
51 | #include "command.h" |
51 | #include "command.h" |
52 | |
52 | |
53 | #include <wchar.h> |
53 | #ifdef KEYSYM_RESOURCE |
|
|
54 | # include "keyboard.h" |
|
|
55 | #endif |
|
|
56 | |
|
|
57 | #include <csignal> |
54 | |
58 | |
55 | /*----------------------------------------------------------------------*/ |
59 | /*----------------------------------------------------------------------*/ |
56 | |
60 | |
57 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
61 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
58 | |
62 | |
… | |
… | |
133 | { |
137 | { |
134 | text_t t = screen.text[y + TermWin.saveLines - TermWin.view_start][x]; |
138 | text_t t = screen.text[y + TermWin.saveLines - TermWin.view_start][x]; |
135 | |
139 | |
136 | if (t != NOCHAR || !x) |
140 | if (t != NOCHAR || !x) |
137 | { |
141 | { |
138 | iso14755_51 (screen.text[y + TermWin.saveLines - TermWin.view_start][x]); |
142 | iso14755_51 (screen.text[y + TermWin.saveLines - TermWin.view_start][x], |
|
|
143 | screen.rend[y + TermWin.saveLines - TermWin.view_start][x]); |
139 | iso14755buf = ISO_14755_54; |
144 | iso14755buf = ISO_14755_54; |
140 | break; |
145 | break; |
141 | } |
146 | } |
142 | |
147 | |
143 | x--; |
148 | x--; |
… | |
… | |
146 | } |
151 | } |
147 | #endif |
152 | #endif |
148 | |
153 | |
149 | #if ENABLE_OVERLAY |
154 | #if ENABLE_OVERLAY |
150 | void |
155 | void |
151 | rxvt_term::iso14755_51 (wchar_t ch) |
156 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r) |
152 | { |
157 | { |
|
|
158 | rxvt_fontset *fs = FONTSET (r); |
|
|
159 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
153 | wchar_t *chr, *alloc; |
160 | wchar_t *chr, *alloc, ch2; |
154 | int len; |
161 | int len; |
155 | |
162 | |
156 | #if ENABLE_COMBINING |
163 | #if ENABLE_COMBINING |
157 | if (IS_COMPOSE (ch)) |
164 | if (IS_COMPOSE (ch)) |
158 | { |
165 | { |
… | |
… | |
161 | rxvt_composite.expand (ch, chr); |
168 | rxvt_composite.expand (ch, chr); |
162 | } |
169 | } |
163 | else |
170 | else |
164 | #endif |
171 | #endif |
165 | { |
172 | { |
|
|
173 | ch2 = ch; |
|
|
174 | |
166 | alloc = 0; |
175 | alloc = 0; |
167 | chr = &ch; |
176 | chr = &ch2; |
168 | len = 1; |
177 | len = 1; |
169 | } |
178 | } |
170 | |
179 | |
171 | scr_overlay_new (0, -1, 8 + 5, len); |
180 | int width = strlen (f->name); |
|
|
181 | |
|
|
182 | scr_overlay_new (0, -1, width < 8+5 ? 8+5 : width, len + 1); |
|
|
183 | |
|
|
184 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
172 | |
185 | |
173 | for (int y = 0; y < len; y++) |
186 | for (int y = 0; y < len; y++) |
174 | { |
187 | { |
175 | char buf[9]; |
188 | char buf[9]; |
176 | |
189 | |
… | |
… | |
181 | scr_overlay_set (9, y, '='); |
194 | scr_overlay_set (9, y, '='); |
182 | #if !UNICODE3 |
195 | #if !UNICODE3 |
183 | if (ch >= 0x10000) |
196 | if (ch >= 0x10000) |
184 | ch = 0xfffd; |
197 | ch = 0xfffd; |
185 | #endif |
198 | #endif |
186 | scr_overlay_set (11, y, ch); |
199 | scr_overlay_set (11, y, ch, r); |
187 | scr_overlay_set (12, y, NOCHAR); |
200 | scr_overlay_set (12, y, NOCHAR, r); |
188 | } |
201 | } |
|
|
202 | |
|
|
203 | scr_overlay_set (0, len, f->name); |
189 | |
204 | |
190 | #if ENABLE_COMBINING |
205 | #if ENABLE_COMBINING |
191 | if (alloc) |
206 | if (alloc) |
192 | delete [] alloc; |
207 | delete [] alloc; |
193 | #endif |
208 | #endif |
… | |
… | |
332 | valid_keysym = keysym != NoSymbol; |
347 | valid_keysym = keysym != NoSymbol; |
333 | } |
348 | } |
334 | |
349 | |
335 | if (valid_keysym) |
350 | if (valid_keysym) |
336 | { |
351 | { |
|
|
352 | #ifdef KEYSYM_RESOURCE |
|
|
353 | if (keyboard->dispatch (this, keysym, ev.state)) |
|
|
354 | return; |
|
|
355 | #endif |
|
|
356 | |
337 | if (TermWin.saveLines) |
357 | if (TermWin.saveLines) |
338 | { |
358 | { |
339 | #ifdef UNSHIFTED_SCROLLKEYS |
359 | #ifdef UNSHIFTED_SCROLLKEYS |
340 | if (!ctrl && !meta) |
360 | if (!ctrl && !meta) |
341 | #else |
361 | #else |
… | |
… | |
406 | { |
426 | { |
407 | /* normal XTerm key bindings */ |
427 | /* normal XTerm key bindings */ |
408 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
428 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
409 | selection_request (ev.time, 0, 0); |
429 | selection_request (ev.time, 0, 0); |
410 | return; |
430 | return; |
411 | #if TODO // TODO |
431 | #if TODO |
412 | /* rxvt extras */ |
432 | /* rxvt extras */ |
413 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
433 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
414 | change_font (FONT_UP); |
434 | change_font (FONT_UP); |
415 | return; |
435 | return; |
416 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
436 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
… | |
… | |
475 | } |
495 | } |
476 | #endif |
496 | #endif |
477 | |
497 | |
478 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
498 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
479 | { |
499 | { |
480 | #ifdef KEYSYM_RESOURCE |
|
|
481 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
|
|
482 | { |
|
|
483 | unsigned int l; |
|
|
484 | const unsigned char *kbuf0; |
|
|
485 | |
|
|
486 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
|
|
487 | l = (unsigned int)*kbuf0++; |
|
|
488 | |
|
|
489 | /* escape prefix */ |
|
|
490 | if (meta |
|
|
491 | # ifdef META8_OPTION |
|
|
492 | && meta_char == C0_ESC |
|
|
493 | # endif |
|
|
494 | ) |
|
|
495 | { |
|
|
496 | const unsigned char ch = C0_ESC; |
|
|
497 | tt_write (&ch, 1); |
|
|
498 | } |
|
|
499 | |
|
|
500 | tt_write (kbuf0, l); |
|
|
501 | return; |
|
|
502 | } |
|
|
503 | else |
|
|
504 | #endif |
|
|
505 | { |
500 | { |
506 | newlen = 1; |
501 | newlen = 1; |
507 | switch (keysym) |
502 | switch (keysym) |
508 | { |
503 | { |
509 | #ifndef NO_BACKSPACE_KEY |
504 | #ifndef NO_BACKSPACE_KEY |
… | |
… | |
776 | #undef FKEY |
771 | #undef FKEY |
777 | default: |
772 | default: |
778 | newlen = 0; |
773 | newlen = 0; |
779 | break; |
774 | break; |
780 | } |
775 | } |
|
|
776 | |
781 | if (newlen) |
777 | if (newlen) |
782 | len = strlen (kbuf); |
778 | len = strlen (kbuf); |
783 | } |
779 | } |
784 | |
780 | |
785 | /* |
781 | /* |
… | |
… | |
793 | } |
789 | } |
794 | else if (ctrl && keysym == XK_minus) |
790 | else if (ctrl && keysym == XK_minus) |
795 | { |
791 | { |
796 | len = 1; |
792 | len = 1; |
797 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
793 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
|
|
794 | } |
|
|
795 | else if (keysym == XK_ISO_Left_Tab) |
|
|
796 | { |
|
|
797 | strcpy (kbuf, "\033[Z"); |
|
|
798 | len = 3; |
798 | } |
799 | } |
799 | else |
800 | else |
800 | { |
801 | { |
801 | #ifdef META8_OPTION |
802 | #ifdef META8_OPTION |
802 | /* set 8-bit on */ |
803 | /* set 8-bit on */ |
… | |
… | |
861 | #endif /* DEBUG_CMD */ |
862 | #endif /* DEBUG_CMD */ |
862 | tt_write (kbuf, (unsigned int)len); |
863 | tt_write (kbuf, (unsigned int)len); |
863 | } |
864 | } |
864 | /*}}} */ |
865 | /*}}} */ |
865 | |
866 | |
866 | #if (MENUBAR_MAX) |
867 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
867 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
868 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
868 | /* attempt to `write' count to the input buffer */ |
869 | /* attempt to `write' count to the input buffer */ |
869 | unsigned int |
870 | unsigned int |
870 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
871 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
871 | { |
872 | { |
… | |
… | |
894 | |
895 | |
895 | cmd_parse (); |
896 | cmd_parse (); |
896 | |
897 | |
897 | return 0; |
898 | return 0; |
898 | } |
899 | } |
899 | #endif /* MENUBAR_MAX */ |
900 | #endif |
900 | |
901 | |
901 | void |
902 | void |
902 | rxvt_term::flush () |
903 | rxvt_term::flush () |
903 | { |
904 | { |
|
|
905 | flush_ev.stop (); |
|
|
906 | |
904 | #ifdef TRANSPARENT |
907 | #ifdef TRANSPARENT |
905 | if (want_full_refresh) |
908 | if (want_full_refresh) |
906 | { |
909 | { |
907 | want_full_refresh = 0; |
910 | want_full_refresh = 0; |
908 | scr_clear (); |
911 | scr_clear (); |
… | |
… | |
918 | IMSendSpot (); |
921 | IMSendSpot (); |
919 | #endif |
922 | #endif |
920 | } |
923 | } |
921 | |
924 | |
922 | display->flush (); |
925 | display->flush (); |
923 | |
|
|
924 | flush_ev.stop (); |
|
|
925 | } |
926 | } |
926 | |
927 | |
927 | void |
928 | void |
928 | rxvt_term::check_cb (check_watcher &w) |
929 | rxvt_term::check_cb (check_watcher &w) |
929 | { |
930 | { |
… | |
… | |
1005 | { |
1006 | { |
1006 | if (mouse_slip_wheel_speed == 0 |
1007 | if (mouse_slip_wheel_speed == 0 |
1007 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1008 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1008 | : scr_page (UP, mouse_slip_wheel_speed)) |
1009 | : scr_page (UP, mouse_slip_wheel_speed)) |
1009 | { |
1010 | { |
|
|
1011 | if (TermWin.view_start == TermWin.nscrolled || |
|
|
1012 | TermWin.view_start == 0) |
|
|
1013 | mouse_slip_wheel_speed = 0; |
|
|
1014 | |
1010 | refresh_type |= SMOOTH_REFRESH; |
1015 | refresh_type |= SMOOTH_REFRESH; |
1011 | want_refresh = 1; |
1016 | want_refresh = 1; |
1012 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1017 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1013 | } |
1018 | } |
1014 | } |
1019 | } |
… | |
… | |
1046 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1051 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1047 | { |
1052 | { |
1048 | SET_R (this); |
1053 | SET_R (this); |
1049 | SET_LOCALE (locale); |
1054 | SET_LOCALE (locale); |
1050 | |
1055 | |
1051 | if (revents & EVENT_WRITE) |
|
|
1052 | tt_write (0, 0); |
|
|
1053 | else if (revents & EVENT_READ) |
1056 | if (revents & EVENT_READ) |
1054 | // loop, but don't allow a single term to monopolize us |
1057 | // loop, but don't allow a single term to monopolize us |
1055 | while (pty_fill ()) |
1058 | while (pty_fill ()) |
1056 | if (cmd_parse ()) |
1059 | if (cmd_parse ()) |
1057 | break; |
1060 | break; |
|
|
1061 | |
|
|
1062 | if (revents & EVENT_WRITE) |
|
|
1063 | pty_write (); |
1058 | } |
1064 | } |
1059 | |
1065 | |
1060 | void |
1066 | void |
1061 | rxvt_term::pointer_unblank () |
1067 | rxvt_term::pointer_unblank () |
1062 | { |
1068 | { |
… | |
… | |
1076 | rxvt_term::pointer_blank () |
1082 | rxvt_term::pointer_blank () |
1077 | { |
1083 | { |
1078 | if (! (options & Opt_pointerBlank)) |
1084 | if (! (options & Opt_pointerBlank)) |
1079 | return; |
1085 | return; |
1080 | |
1086 | |
1081 | XDefineCursor (display->display, TermWin.vt, blank_cursor); |
1087 | XDefineCursor (display->display, TermWin.vt, display->blank_cursor); |
1082 | XFlush (display->display); |
1088 | XFlush (display->display); |
1083 | |
1089 | |
1084 | hidden_pointer = 1; |
1090 | hidden_pointer = 1; |
1085 | } |
1091 | } |
1086 | |
1092 | |
… | |
… | |
1137 | + ((MEvent.state & ModMetaMask) ? 8 : 0) |
1143 | + ((MEvent.state & ModMetaMask) ? 8 : 0) |
1138 | + ((MEvent.state & ControlMask) ? 16 : 0); |
1144 | + ((MEvent.state & ControlMask) ? 16 : 0); |
1139 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1145 | #ifdef MOUSE_REPORT_DOUBLECLICK |
1140 | key_state += ((MEvent.clicks > 1) ? 32 : 0); |
1146 | key_state += ((MEvent.clicks > 1) ? 32 : 0); |
1141 | #endif |
1147 | #endif |
1142 | |
|
|
1143 | } |
1148 | } |
1144 | |
1149 | |
1145 | #ifdef DEBUG_MOUSEREPORT |
1150 | #if DEBUG_MOUSEREPORT |
1146 | fprintf (stderr, "Mouse ["); |
1151 | fprintf (stderr, "Mouse ["); |
1147 | if (key_state & 16) |
1152 | if (key_state & 16) |
1148 | fputc ('C', stderr); |
1153 | fputc ('C', stderr); |
1149 | if (key_state & 4) |
1154 | if (key_state & 4) |
1150 | fputc ('S', stderr); |
1155 | fputc ('S', stderr); |
… | |
… | |
1154 | fputc ('2', stderr); |
1159 | fputc ('2', stderr); |
1155 | fprintf (stderr, "]: <%d>, %d/%d\n", |
1160 | fprintf (stderr, "]: <%d>, %d/%d\n", |
1156 | button_number, |
1161 | button_number, |
1157 | x + 1, |
1162 | x + 1, |
1158 | y + 1); |
1163 | y + 1); |
1159 | #else |
1164 | #endif |
|
|
1165 | |
1160 | tt_printf ("\033[M%c%c%c", |
1166 | tt_printf ("\033[M%c%c%c", |
1161 | (32 + button_number + key_state), |
1167 | (32 + button_number + key_state), |
1162 | (32 + x + 1), |
1168 | (32 + x + 1), |
1163 | (32 + y + 1)); |
1169 | (32 + y + 1)); |
1164 | #endif |
|
|
1165 | } |
1170 | } |
1166 | |
1171 | |
1167 | #ifdef USING_W11LIB |
1172 | #ifdef USING_W11LIB |
1168 | void |
1173 | void |
1169 | rxvt_W11_process_x_event (XEvent *ev) |
1174 | rxvt_W11_process_x_event (XEvent *ev) |
… | |
… | |
1176 | |
1181 | |
1177 | /*{{{ process an X event */ |
1182 | /*{{{ process an X event */ |
1178 | void |
1183 | void |
1179 | rxvt_term::x_cb (XEvent &ev) |
1184 | rxvt_term::x_cb (XEvent &ev) |
1180 | { |
1185 | { |
|
|
1186 | dDisp; |
|
|
1187 | |
1181 | SET_R (this); |
1188 | SET_R (this); |
1182 | SET_LOCALE (locale); |
1189 | SET_LOCALE (locale); |
1183 | |
1190 | |
1184 | #if defined(CURSOR_BLINK) |
1191 | #if defined(CURSOR_BLINK) |
1185 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
1192 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
… | |
… | |
1206 | if (ev.type == KeyPress && hidden_pointer == 0) |
1213 | if (ev.type == KeyPress && hidden_pointer == 0) |
1207 | pointer_blank (); |
1214 | pointer_blank (); |
1208 | } |
1215 | } |
1209 | #endif |
1216 | #endif |
1210 | |
1217 | |
1211 | #ifdef USE_XIM |
|
|
1212 | if (XFilterEvent (&ev, None)) |
|
|
1213 | return; |
|
|
1214 | #endif |
|
|
1215 | |
|
|
1216 | Window unused_root, unused_child; |
1218 | Window unused_root, unused_child; |
1217 | int unused_root_x, unused_root_y; |
1219 | int unused_root_x, unused_root_y; |
1218 | unsigned int unused_mask; |
1220 | unsigned int unused_mask; |
1219 | |
1221 | |
1220 | switch (ev.type) |
1222 | switch (ev.type) |
1221 | { |
1223 | { |
1222 | case KeyPress: |
1224 | case KeyPress: |
1223 | #if ISO_14755 |
1225 | #if ISO_14755 |
… | |
… | |
1227 | |
1229 | |
1228 | break; |
1230 | break; |
1229 | |
1231 | |
1230 | case KeyRelease: |
1232 | case KeyRelease: |
1231 | { |
1233 | { |
1232 | #if (defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING)) || defined (ENABLE_FRILLS) |
1234 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 |
1233 | KeySym ks; |
1235 | KeySym ks; |
1234 | |
1236 | |
1235 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1237 | ks = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
1236 | #endif |
1238 | #endif |
1237 | |
1239 | |
… | |
… | |
1321 | Atom ActualType; |
1323 | Atom ActualType; |
1322 | int ActualFormat; |
1324 | int ActualFormat; |
1323 | unsigned char *data; |
1325 | unsigned char *data; |
1324 | unsigned long Size, RemainingBytes; |
1326 | unsigned long Size, RemainingBytes; |
1325 | |
1327 | |
1326 | XGetWindowProperty (display->display, display->root, |
1328 | XGetWindowProperty (disp, display->root, |
1327 | xa[XA_DNDSELECTION], |
1329 | xa[XA_DNDSELECTION], |
1328 | 0L, 1000000L, |
1330 | 0L, 1000000L, |
1329 | False, AnyPropertyType, |
1331 | False, AnyPropertyType, |
1330 | &ActualType, &ActualFormat, |
1332 | &ActualType, &ActualFormat, |
1331 | &Size, &RemainingBytes, |
1333 | &Size, &RemainingBytes, |
1332 | &data); |
1334 | &data); |
1333 | XChangeProperty (display->display, display->root, |
1335 | set_string_property (XA_CUT_BUFFER0, data); |
1334 | XA_CUT_BUFFER0, XA_STRING, |
|
|
1335 | 8, PropModeReplace, |
|
|
1336 | data, strlen (data)); |
|
|
1337 | XFree (data); |
1336 | XFree (data); |
1338 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1337 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
1339 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1338 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
1340 | } |
1339 | } |
1341 | #endif /* OFFIX_DND */ |
1340 | #endif /* OFFIX_DND */ |
1342 | break; |
1341 | break; |
1343 | |
1342 | |
1344 | case MappingNotify: |
1343 | case MappingNotify: |
… | |
… | |
1388 | #endif |
1387 | #endif |
1389 | #ifdef OFF_FOCUS_FADING |
1388 | #ifdef OFF_FOCUS_FADING |
1390 | if (rs[Rs_fade]) |
1389 | if (rs[Rs_fade]) |
1391 | { |
1390 | { |
1392 | pix_colors = pix_colors_focused; |
1391 | pix_colors = pix_colors_focused; |
1393 | set_colorfgbg (); |
|
|
1394 | scr_clear (); |
1392 | scr_recolour (); |
1395 | scr_touch (true); |
|
|
1396 | } |
1393 | } |
1397 | #endif |
1394 | #endif |
1398 | |
1395 | |
1399 | } |
1396 | } |
1400 | break; |
1397 | break; |
… | |
… | |
1402 | case FocusOut: |
1399 | case FocusOut: |
1403 | if (TermWin.focus) |
1400 | if (TermWin.focus) |
1404 | { |
1401 | { |
1405 | TermWin.focus = 0; |
1402 | TermWin.focus = 0; |
1406 | want_refresh = 1; |
1403 | want_refresh = 1; |
|
|
1404 | |
|
|
1405 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1406 | iso14755buf = 0; |
|
|
1407 | #endif |
|
|
1408 | #if ENABLE_OVERLAY |
|
|
1409 | scr_overlay_off (); |
|
|
1410 | #endif |
1407 | #ifdef USE_XIM |
1411 | #ifdef USE_XIM |
1408 | if (Input_Context != NULL) |
1412 | if (Input_Context != NULL) |
1409 | XUnsetICFocus (Input_Context); |
1413 | XUnsetICFocus (Input_Context); |
1410 | #endif |
1414 | #endif |
1411 | #ifdef CURSOR_BLINK |
1415 | #ifdef CURSOR_BLINK |
… | |
… | |
1415 | #endif |
1419 | #endif |
1416 | #ifdef OFF_FOCUS_FADING |
1420 | #ifdef OFF_FOCUS_FADING |
1417 | if (rs[Rs_fade]) |
1421 | if (rs[Rs_fade]) |
1418 | { |
1422 | { |
1419 | pix_colors = pix_colors_unfocused; |
1423 | pix_colors = pix_colors_unfocused; |
1420 | set_colorfgbg (); |
|
|
1421 | scr_clear (); |
1424 | scr_recolour (); |
1422 | scr_touch (true); |
|
|
1423 | } |
1425 | } |
1424 | #endif |
1426 | #endif |
1425 | |
|
|
1426 | } |
1427 | } |
1427 | break; |
1428 | break; |
1428 | |
1429 | |
1429 | case ConfigureNotify: |
1430 | case ConfigureNotify: |
1430 | if (ev.xconfigure.window == TermWin.parent[0]) |
1431 | if (ev.xconfigure.window == TermWin.parent[0]) |
… | |
… | |
1435 | { /* Wrap lots of configures into one */ |
1436 | { /* Wrap lots of configures into one */ |
1436 | width = ev.xconfigure.width; |
1437 | width = ev.xconfigure.width; |
1437 | height = ev.xconfigure.height; |
1438 | height = ev.xconfigure.height; |
1438 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1439 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1439 | } |
1440 | } |
1440 | while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); |
1441 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)); |
1441 | |
1442 | |
1442 | if (szHint.width != width || szHint.height != height) |
1443 | if (szHint.width != width || szHint.height != height) |
|
|
1444 | { |
|
|
1445 | seen_resize = 1; |
1443 | resize_all_windows (width, height, 1); |
1446 | resize_all_windows (width, height, 1); |
|
|
1447 | } |
1444 | |
1448 | |
1445 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1449 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1446 | if (options & Opt_transparent) |
1450 | if (options & Opt_transparent) |
1447 | { |
|
|
1448 | check_our_parents (); |
1451 | check_our_parents (); |
1449 | if (am_transparent) |
|
|
1450 | want_refresh = want_full_refresh = 1; |
|
|
1451 | } |
|
|
1452 | #endif |
1452 | #endif |
1453 | } |
1453 | } |
1454 | break; |
1454 | break; |
1455 | |
1455 | |
1456 | case PropertyNotify: |
1456 | case PropertyNotify: |
… | |
… | |
1464 | selection_clear (); |
1464 | selection_clear (); |
1465 | break; |
1465 | break; |
1466 | |
1466 | |
1467 | case SelectionNotify: |
1467 | case SelectionNotify: |
1468 | if (selection_wait == Sel_normal) |
1468 | if (selection_wait == Sel_normal) |
1469 | selection_paste (ev.xselection.requestor, |
1469 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1470 | ev.xselection.property, True); |
|
|
1471 | break; |
1470 | break; |
1472 | |
1471 | |
1473 | case SelectionRequest: |
1472 | case SelectionRequest: |
1474 | selection_send (ev.xselectionrequest); |
1473 | selection_send (ev.xselectionrequest); |
1475 | break; |
1474 | break; |
… | |
… | |
1499 | if (ev.xany.window == TermWin.vt) |
1498 | if (ev.xany.window == TermWin.vt) |
1500 | { |
1499 | { |
1501 | do |
1500 | do |
1502 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1501 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1503 | ev.xexpose.width, ev.xexpose.height, False); |
1502 | ev.xexpose.width, ev.xexpose.height, False); |
1504 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)); |
1503 | while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev)); |
1505 | |
1504 | |
1506 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1505 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1507 | |
1506 | |
1508 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)) |
1507 | while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev)) |
1509 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1508 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1510 | ev.xexpose.width, ev.xexpose.height, False); |
1509 | ev.xexpose.width, ev.xexpose.height, False); |
1511 | |
1510 | |
1512 | scr_refresh (refresh_type); |
1511 | scr_refresh (refresh_type); |
1513 | } |
1512 | } |
1514 | else |
1513 | else |
1515 | { |
1514 | { |
1516 | XEvent unused_event; |
1515 | XEvent unused_event; |
1517 | |
1516 | |
1518 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, Expose, &unused_event)) |
1517 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1519 | ; |
1518 | ; |
1520 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, GraphicsExpose, &unused_event)) |
1519 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1521 | ; |
1520 | ; |
1522 | |
1521 | |
1523 | if (isScrollbarWindow (ev.xany.window)) |
1522 | if (isScrollbarWindow (ev.xany.window)) |
1524 | { |
1523 | { |
1525 | scrollBar.setIdle (); |
1524 | scrollBar.setIdle (); |
… | |
… | |
1530 | menubar_expose (); |
1529 | menubar_expose (); |
1531 | #endif |
1530 | #endif |
1532 | |
1531 | |
1533 | #ifdef TRANSPARENT |
1532 | #ifdef TRANSPARENT |
1534 | if (am_transparent && ev.xany.window == TermWin.parent[0]) |
1533 | if (am_transparent && ev.xany.window == TermWin.parent[0]) |
1535 | XClearWindow (display->display, ev.xany.window); |
1534 | XClearWindow (disp, ev.xany.window); |
1536 | #endif |
1535 | #endif |
1537 | } |
1536 | } |
1538 | break; |
1537 | break; |
1539 | |
1538 | |
1540 | case MotionNotify: |
1539 | case MotionNotify: |
… | |
… | |
1547 | { |
1546 | { |
1548 | menubar_control (ev.xbutton); |
1547 | menubar_control (ev.xbutton); |
1549 | break; |
1548 | break; |
1550 | } |
1549 | } |
1551 | #endif |
1550 | #endif |
1552 | if ((priv_modes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1551 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1553 | break; |
1552 | break; |
1554 | |
1553 | |
1555 | if (ev.xany.window == TermWin.vt) |
1554 | if (ev.xany.window == TermWin.vt) |
1556 | { |
1555 | { |
1557 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1556 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1558 | { |
1557 | { |
1559 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, MotionNotify, &ev)) |
1558 | while (XCheckTypedWindowEvent (disp, TermWin.vt, MotionNotify, &ev)) |
1560 | ; |
1559 | ; |
1561 | |
1560 | |
1562 | XQueryPointer (display->display, TermWin.vt, |
1561 | XQueryPointer (disp, TermWin.vt, |
1563 | &unused_root, &unused_child, |
1562 | &unused_root, &unused_child, |
1564 | &unused_root_x, &unused_root_y, |
1563 | &unused_root_x, &unused_root_y, |
1565 | & (ev.xbutton.x), & (ev.xbutton.y), |
1564 | &ev.xbutton.x, &ev.xbutton.y, |
1566 | &unused_mask); |
1565 | &ev.xbutton.state); |
1567 | #ifdef MOUSE_THRESHOLD |
1566 | #ifdef MOUSE_THRESHOLD |
1568 | /* deal with a `jumpy' mouse */ |
1567 | /* deal with a `jumpy' mouse */ |
1569 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1568 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1570 | { |
1569 | { |
1571 | #endif |
1570 | #endif |
… | |
… | |
1576 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1575 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1577 | break; |
1576 | break; |
1578 | } |
1577 | } |
1579 | #endif |
1578 | #endif |
1580 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1579 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1581 | (ev.xbutton.state & Button3Mask) ? 2 : 0); |
1580 | ev.xbutton.state & Button3Mask ? 2 : 0); |
|
|
1581 | |
1582 | #ifdef SELECTION_SCROLLING |
1582 | #ifdef SELECTION_SCROLLING |
1583 | if (ev.xbutton.y < TermWin.int_bwidth |
1583 | if (ev.xbutton.y < TermWin.int_bwidth |
1584 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1584 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1585 | { |
1585 | { |
1586 | int dist; |
1586 | int dist; |
… | |
… | |
1597 | selection_save_x = ev.xbutton.x; |
1597 | selection_save_x = ev.xbutton.x; |
1598 | selection_save_y = ev.xbutton.y; |
1598 | selection_save_y = ev.xbutton.y; |
1599 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1599 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1600 | |
1600 | |
1601 | /* calc number of lines to scroll */ |
1601 | /* calc number of lines to scroll */ |
1602 | if (ev.xbutton.y<TermWin.int_bwidth) |
1602 | if (ev.xbutton.y < TermWin.int_bwidth) |
1603 | { |
1603 | { |
1604 | scroll_selection_dir = UP; |
1604 | scroll_selection_dir = UP; |
1605 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1605 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1606 | } |
1606 | } |
1607 | else |
1607 | else |
… | |
… | |
1630 | #endif |
1630 | #endif |
1631 | } |
1631 | } |
1632 | } |
1632 | } |
1633 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1633 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1634 | { |
1634 | { |
1635 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1635 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1636 | MotionNotify, &ev)) ; |
1636 | MotionNotify, &ev)) |
|
|
1637 | ; |
|
|
1638 | |
1637 | XQueryPointer (display->display, scrollBar.win, |
1639 | XQueryPointer (disp, scrollBar.win, |
1638 | &unused_root, &unused_child, |
1640 | &unused_root, &unused_child, |
1639 | &unused_root_x, &unused_root_y, |
1641 | &unused_root_x, &unused_root_y, |
1640 | & (ev.xbutton.x), & (ev.xbutton.y), |
1642 | &ev.xbutton.x, &ev.xbutton.y, |
1641 | &unused_mask); |
1643 | &unused_mask); |
1642 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1644 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1643 | scrollbar_size ()); |
1645 | scrollbar_size ()); |
1644 | scr_refresh (refresh_type); |
1646 | scr_refresh (refresh_type); |
1645 | refresh_limit = 0; |
1647 | refresh_limit = 0; |
… | |
… | |
1661 | case PropertyNotify: |
1663 | case PropertyNotify: |
1662 | /* |
1664 | /* |
1663 | * if user used some Esetroot compatible prog to set the root bg, |
1665 | * if user used some Esetroot compatible prog to set the root bg, |
1664 | * use the property to determine the pixmap. We use it later on. |
1666 | * use the property to determine the pixmap. We use it later on. |
1665 | */ |
1667 | */ |
1666 | if (xa[XA_XROOTPMAPID] == 0) |
|
|
1667 | xa[XA_XROOTPMAPID] = XInternAtom (display->display, "_XROOTPMAP_ID", False); |
|
|
1668 | |
|
|
1669 | if (ev.xproperty.atom != xa[XA_XROOTPMAPID]) |
1668 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
|
|
1669 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1670 | return; |
1670 | return; |
1671 | |
1671 | |
1672 | /* FALLTHROUGH */ |
1672 | /* FALLTHROUGH */ |
1673 | case ReparentNotify: |
1673 | case ReparentNotify: |
1674 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
1674 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
… | |
… | |
1700 | return; |
1700 | return; |
1701 | } |
1701 | } |
1702 | #endif |
1702 | #endif |
1703 | |
1703 | |
1704 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
1704 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
|
|
1705 | |
1705 | if (reportmode) |
1706 | if (reportmode) |
1706 | { |
1707 | { |
1707 | /* mouse report from vt window */ |
1708 | /* mouse report from vt window */ |
1708 | /* save the xbutton state (for ButtonRelease) */ |
1709 | /* save the xbutton state (for ButtonRelease) */ |
1709 | MEvent.state = ev.state; |
1710 | MEvent.state = ev.state; |
… | |
… | |
1738 | } |
1739 | } |
1739 | else |
1740 | else |
1740 | { |
1741 | { |
1741 | if (ev.button != MEvent.button) |
1742 | if (ev.button != MEvent.button) |
1742 | MEvent.clicks = 0; |
1743 | MEvent.clicks = 0; |
|
|
1744 | |
1743 | switch (ev.button) |
1745 | switch (ev.button) |
1744 | { |
1746 | { |
1745 | case Button1: |
1747 | case Button1: |
|
|
1748 | /* allow meta + click to select rectangular areas */ |
|
|
1749 | /* should be done in screen.C */ |
|
|
1750 | #if ENABLE_FRILLS |
|
|
1751 | selection.rect = !!(ev.state & ModMetaMask); |
|
|
1752 | #else |
|
|
1753 | selection.rect = false; |
|
|
1754 | #endif |
|
|
1755 | |
1746 | /* allow shift+left click to extend selection */ |
1756 | /* allow shift+left click to extend selection */ |
1747 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1757 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1748 | { |
1758 | { |
1749 | if (MEvent.button == Button1 && clickintime) |
1759 | if (MEvent.button == Button1 && clickintime) |
1750 | selection_rotate (ev.x, ev.y); |
1760 | selection_rotate (ev.x, ev.y); |
… | |
… | |
2072 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2082 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2073 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2083 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2074 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2084 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2075 | int i; |
2085 | int i; |
2076 | |
2086 | |
2077 | Visual* visual = display->visual; |
2087 | Visual *visual = display->visual; |
2078 | |
2088 | |
2079 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2089 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2080 | |
2090 | |
2081 | /* for convenience */ |
2091 | /* for convenience */ |
2082 | mask_r = visual->red_mask; |
2092 | mask_r = visual->red_mask; |
… | |
… | |
2303 | Atom atype; |
2313 | Atom atype; |
2304 | unsigned char *prop = NULL; |
2314 | unsigned char *prop = NULL; |
2305 | Window root, oldp, *list; |
2315 | Window root, oldp, *list; |
2306 | Pixmap rootpixmap = None; |
2316 | Pixmap rootpixmap = None; |
2307 | XWindowAttributes wattr, wrootattr; |
2317 | XWindowAttributes wattr, wrootattr; |
|
|
2318 | dDisp; |
2308 | |
2319 | |
2309 | pchanged = 0; |
2320 | pchanged = 0; |
2310 | |
2321 | |
2311 | if (!(options & Opt_transparent)) |
2322 | if (!(options & Opt_transparent)) |
2312 | return pchanged; /* Don't try any more */ |
2323 | return pchanged; /* Don't try any more */ |
2313 | |
2324 | |
2314 | XGetWindowAttributes (display->display, display->root, &wrootattr); |
2325 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2315 | rootdepth = wrootattr.depth; |
2326 | rootdepth = wrootattr.depth; |
2316 | |
2327 | |
2317 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
2328 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
2318 | |
2329 | |
2319 | if (rootdepth != wattr.depth) |
2330 | if (rootdepth != wattr.depth) |
2320 | { |
2331 | { |
2321 | if (am_transparent) |
2332 | if (am_transparent) |
2322 | { |
2333 | { |
2323 | pchanged = 1; |
2334 | pchanged = 1; |
2324 | XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]); |
2335 | XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]); |
2325 | am_transparent = am_pixmap_trans = 0; |
2336 | am_transparent = am_pixmap_trans = 0; |
2326 | } |
2337 | } |
2327 | |
2338 | |
2328 | return pchanged; /* Don't try any more */ |
2339 | return pchanged; /* Don't try any more */ |
2329 | } |
2340 | } |
2330 | |
2341 | |
2331 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2342 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2332 | XSync (display->display, False); |
2343 | XSync (disp, False); |
2333 | |
2344 | |
2334 | /* |
2345 | /* |
2335 | * Make the frame window set by the window manager have |
2346 | * Make the frame window set by the window manager have |
2336 | * the root background. Some window managers put multiple nested frame |
2347 | * the root background. Some window managers put multiple nested frame |
2337 | * windows for each client, so we have to take care about that. |
2348 | * windows for each client, so we have to take care about that. |
2338 | */ |
2349 | */ |
2339 | i = (xa[XA_XROOTPMAPID] |
2350 | i = (xa[XA_XROOTPMAP_ID] |
2340 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID], |
2351 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
2341 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2352 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2342 | &nitems, &bytes_after, &prop) == Success); |
2353 | &nitems, &bytes_after, &prop) == Success); |
2343 | |
2354 | |
2344 | if (!i || prop == NULL) |
2355 | if (!i || prop == NULL) |
2345 | i = (xa[XA_XSETROOTID] |
2356 | i = (xa[XA_ESETROOT_PMAP_ID] |
2346 | && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], |
2357 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2347 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2358 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2348 | &nitems, &bytes_after, &prop) == Success); |
2359 | &nitems, &bytes_after, &prop) == Success); |
2349 | |
2360 | |
2350 | if (!i || prop == NULL |
2361 | if (!i || prop == NULL |
2351 | #if TINTING |
2362 | #if TINTING |
… | |
… | |
2370 | Window cr; |
2381 | Window cr; |
2371 | XImage *image; |
2382 | XImage *image; |
2372 | GC gc; |
2383 | GC gc; |
2373 | XGCValues gcvalue; |
2384 | XGCValues gcvalue; |
2374 | |
2385 | |
2375 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
2386 | XTranslateCoordinates (disp, TermWin.parent[0], display->root, |
2376 | 0, 0, &sx, &sy, &cr); |
2387 | 0, 0, &sx, &sy, &cr); |
2377 | nw = (unsigned int)szHint.width; |
2388 | nw = (unsigned int)szHint.width; |
2378 | nh = (unsigned int)szHint.height; |
2389 | nh = (unsigned int)szHint.height; |
2379 | nx = ny = 0; |
2390 | nx = ny = 0; |
2380 | |
2391 | |
… | |
… | |
2392 | sy = 0; |
2403 | sy = 0; |
2393 | } |
2404 | } |
2394 | |
2405 | |
2395 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2406 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2396 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2407 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2408 | |
|
|
2409 | XSync (disp, False); |
2397 | allowedxerror = -1; |
2410 | allowedxerror = -1; |
2398 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2411 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2399 | |
2412 | |
2400 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2413 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2401 | /* XXX: may need a delay here? */ |
2414 | /* XXX: may need a delay here? */ |
2402 | allowedxerror = 0; |
2415 | allowedxerror = 0; |
2403 | |
2416 | |
… | |
… | |
2406 | if (am_transparent && am_pixmap_trans) |
2419 | if (am_transparent && am_pixmap_trans) |
2407 | { |
2420 | { |
2408 | pchanged = 1; |
2421 | pchanged = 1; |
2409 | if (TermWin.pixmap != None) |
2422 | if (TermWin.pixmap != None) |
2410 | { |
2423 | { |
2411 | XFreePixmap (display->display, TermWin.pixmap); |
2424 | XFreePixmap (disp, TermWin.pixmap); |
2412 | TermWin.pixmap = None; |
2425 | TermWin.pixmap = None; |
2413 | } |
2426 | } |
2414 | } |
2427 | } |
2415 | |
2428 | |
2416 | am_pixmap_trans = 0; |
2429 | am_pixmap_trans = 0; |
2417 | } |
2430 | } |
2418 | else |
2431 | else |
2419 | { |
2432 | { |
2420 | if (TermWin.pixmap != None) |
2433 | if (TermWin.pixmap != None) |
2421 | XFreePixmap (display->display, TermWin.pixmap); |
2434 | XFreePixmap (disp, TermWin.pixmap); |
2422 | |
2435 | |
2423 | #if TINTING |
2436 | #if TINTING |
2424 | if (ISSET_PIXCOLOR (Color_tint)) |
2437 | if (ISSET_PIXCOLOR (Color_tint)) |
2425 | { |
2438 | { |
2426 | unsigned short rm, gm, bm; |
2439 | unsigned short rm, gm, bm; |
… | |
… | |
2430 | |
2443 | |
2431 | ShadeXImage (display, image, shade, rm, gm, bm); |
2444 | ShadeXImage (display, image, shade, rm, gm, bm); |
2432 | } |
2445 | } |
2433 | #endif |
2446 | #endif |
2434 | |
2447 | |
2435 | TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, |
2448 | TermWin.pixmap = XCreatePixmap (disp, TermWin.vt, |
2436 | szHint.width, szHint.height, image->depth); |
2449 | szHint.width, szHint.height, image->depth); |
2437 | gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); |
2450 | gc = XCreateGC (disp, TermWin.vt, 0UL, &gcvalue); |
2438 | XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, |
2451 | XPutImage (disp, TermWin.pixmap, gc, image, 0, 0, |
2439 | nx, ny, image->width, image->height); |
2452 | nx, ny, image->width, image->height); |
2440 | XFreeGC (display->display, gc); |
2453 | XFreeGC (disp, gc); |
2441 | XDestroyImage (image); |
2454 | XDestroyImage (image); |
2442 | XSetWindowBackgroundPixmap (display->display, TermWin.parent[0], TermWin.pixmap); |
2455 | XSetWindowBackgroundPixmap (disp, TermWin.parent[0], TermWin.pixmap); |
2443 | XClearWindow (display->display, TermWin.parent[0]); |
2456 | XClearWindow (disp, TermWin.parent[0]); |
2444 | |
2457 | |
2445 | if (!am_transparent || !am_pixmap_trans) |
2458 | if (!am_transparent || !am_pixmap_trans) |
2446 | pchanged = 1; |
2459 | pchanged = 1; |
2447 | |
2460 | |
2448 | am_transparent = am_pixmap_trans = 1; |
2461 | am_transparent = am_pixmap_trans = 1; |
2449 | } |
2462 | } |
2450 | } |
2463 | } |
2451 | |
2464 | |
2452 | if (!am_pixmap_trans) |
2465 | if (am_pixmap_trans) |
|
|
2466 | XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative); |
|
|
2467 | else |
2453 | { |
2468 | { |
2454 | unsigned int n; |
2469 | unsigned int n; |
2455 | /* |
2470 | /* |
2456 | * InheritPixmap transparency |
2471 | * InheritPixmap transparency |
2457 | */ |
2472 | */ |
2458 | for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2473 | for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2459 | { |
2474 | { |
2460 | oldp = TermWin.parent[i]; |
2475 | oldp = TermWin.parent[i]; |
2461 | XQueryTree (display->display, TermWin.parent[i - 1], &root, |
2476 | XQueryTree (disp, TermWin.parent[i - 1], &root, |
2462 | &TermWin.parent[i], &list, &n); |
2477 | &TermWin.parent[i], &list, &n); |
2463 | XFree (list); |
2478 | XFree (list); |
2464 | |
2479 | |
2465 | if (TermWin.parent[i] == display->root) |
2480 | if (TermWin.parent[i] == display->root) |
2466 | { |
2481 | { |
… | |
… | |
2478 | |
2493 | |
2479 | if (pchanged) |
2494 | if (pchanged) |
2480 | { |
2495 | { |
2481 | for (; n < (unsigned int)i; n++) |
2496 | for (; n < (unsigned int)i; n++) |
2482 | { |
2497 | { |
2483 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
2498 | XGetWindowAttributes (disp, TermWin.parent[n], &wattr); |
2484 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2499 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2485 | { |
2500 | { |
2486 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2501 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2487 | break; |
2502 | break; |
2488 | } |
2503 | } |
2489 | } |
2504 | } |
2490 | } |
2505 | } |
2491 | |
2506 | |
2492 | if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) |
2507 | if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) |
2493 | { |
2508 | { |
2494 | XSetWindowBackground (display->display, TermWin.parent[0], pix_colors_focused[Color_fg]); |
2509 | XSetWindowBackground (disp, TermWin.parent[0], pix_colors_focused[Color_fg]); |
2495 | XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]); |
2510 | XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]); |
2496 | am_transparent = 0; |
2511 | am_transparent = 0; |
2497 | /* XXX: also turn off Opt_transparent? */ |
2512 | /* XXX: also turn off Opt_transparent? */ |
2498 | } |
2513 | } |
2499 | else |
2514 | else |
2500 | { |
2515 | { |
… | |
… | |
2503 | * needed for fvwm2.2.2 (and before?) */ |
2518 | * needed for fvwm2.2.2 (and before?) */ |
2504 | sleep (1); |
2519 | sleep (1); |
2505 | #endif |
2520 | #endif |
2506 | for (n = 0; n < (unsigned int)i; n++) |
2521 | for (n = 0; n < (unsigned int)i; n++) |
2507 | { |
2522 | { |
2508 | XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); |
2523 | XSetWindowBackgroundPixmap (disp, TermWin.parent[n], ParentRelative); |
2509 | XClearWindow (display->display, TermWin.parent[n]); |
2524 | XClearWindow (disp, TermWin.parent[n]); |
2510 | } |
2525 | } |
2511 | |
2526 | |
2512 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
2527 | XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative); |
2513 | am_transparent = 1; |
2528 | am_transparent = 1; |
2514 | } |
2529 | } |
2515 | |
2530 | |
2516 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2531 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2517 | TermWin.parent[i] = None; |
2532 | TermWin.parent[i] = None; |
2518 | } |
2533 | } |
2519 | |
2534 | |
2520 | // this is experimental |
|
|
2521 | if (scrollBar.win) |
2535 | if (scrollBar.win) |
2522 | { |
2536 | { |
2523 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2537 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
2524 | XClearWindow (display->display, scrollBar.win); |
|
|
2525 | scrollBar.setIdle (); |
2538 | scrollBar.setIdle (); |
2526 | scrollbar_show (0); |
2539 | scrollbar_show (0); |
|
|
2540 | } |
|
|
2541 | |
|
|
2542 | if (am_transparent) |
|
|
2543 | { |
|
|
2544 | want_refresh = want_full_refresh = 1; |
|
|
2545 | if (am_pixmap_trans) |
|
|
2546 | flush (); |
2527 | } |
2547 | } |
2528 | |
2548 | |
2529 | return pchanged; |
2549 | return pchanged; |
2530 | } |
2550 | } |
2531 | #endif |
2551 | #endif |
… | |
… | |
2557 | seen_input = 1; |
2577 | seen_input = 1; |
2558 | // many badly-written programs (e.g. jed) contain a race condition: |
2578 | // many badly-written programs (e.g. jed) contain a race condition: |
2559 | // they first read the screensize and then install a SIGWINCH handler. |
2579 | // they first read the screensize and then install a SIGWINCH handler. |
2560 | // some window managers resize the window early, and these programs |
2580 | // some window managers resize the window early, and these programs |
2561 | // then sometimes get the size wrong. |
2581 | // then sometimes get the size wrong. |
|
|
2582 | // unfortunately other programs are even more buggy and dislike |
|
|
2583 | // being sent SIGWINCH, so only do it when we were in fact being |
|
|
2584 | // resized. |
|
|
2585 | if (seen_resize) |
2562 | kill (-cmd_pid, SIGWINCH); |
2586 | kill (-cmd_pid, SIGWINCH); |
2563 | } |
2587 | } |
2564 | |
2588 | |
2565 | /* Read a text string from the input buffer */ |
2589 | /* Read a text string from the input buffer */ |
2566 | unicode_t buf[UBUFSIZ]; |
2590 | unicode_t buf[UBUFSIZ]; |
2567 | bool refreshnow = false; |
2591 | bool refreshnow = false; |
… | |
… | |
2679 | if (len == (size_t)-1) |
2703 | if (len == (size_t)-1) |
2680 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2704 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2681 | |
2705 | |
2682 | // assume wchar == unicode |
2706 | // assume wchar == unicode |
2683 | cmdbuf_ptr += len; |
2707 | cmdbuf_ptr += len; |
2684 | return wc; |
2708 | return wc & UNICODE_MASK; |
2685 | } |
2709 | } |
2686 | |
2710 | |
2687 | return NOCHAR; |
2711 | return NOCHAR; |
2688 | } |
2712 | } |
2689 | |
2713 | |
… | |
… | |
3391 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3415 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3392 | { |
3416 | { |
3393 | int x, y; |
3417 | int x, y; |
3394 | XWindowAttributes wattr; |
3418 | XWindowAttributes wattr; |
3395 | Window wdummy; |
3419 | Window wdummy; |
|
|
3420 | dDisp; |
3396 | |
3421 | |
3397 | if (nargs == 0) |
3422 | if (nargs == 0) |
3398 | return; |
3423 | return; |
3399 | |
3424 | |
3400 | switch (args[0]) |
3425 | switch (args[0]) |
3401 | { |
3426 | { |
3402 | /* |
3427 | /* |
3403 | * commands |
3428 | * commands |
3404 | */ |
3429 | */ |
3405 | case 1: /* deiconify window */ |
3430 | case 1: /* deiconify window */ |
3406 | XMapWindow (display->display, TermWin.parent[0]); |
3431 | XMapWindow (disp, TermWin.parent[0]); |
3407 | break; |
3432 | break; |
3408 | case 2: /* iconify window */ |
3433 | case 2: /* iconify window */ |
3409 | XIconifyWindow (display->display, TermWin.parent[0], |
3434 | XIconifyWindow (disp, TermWin.parent[0], display->screen); |
3410 | DefaultScreen (display->display)); |
|
|
3411 | break; |
3435 | break; |
3412 | case 3: /* set position (pixels) */ |
3436 | case 3: /* set position (pixels) */ |
3413 | XMoveWindow (display->display, TermWin.parent[0], args[1], args[2]); |
3437 | XMoveWindow (disp, TermWin.parent[0], args[1], args[2]); |
3414 | break; |
3438 | break; |
3415 | case 4: /* set size (pixels) */ |
3439 | case 4: /* set size (pixels) */ |
3416 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3440 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3417 | break; |
3441 | break; |
3418 | case 5: /* raise window */ |
3442 | case 5: /* raise window */ |
3419 | XRaiseWindow (display->display, TermWin.parent[0]); |
3443 | XRaiseWindow (disp, TermWin.parent[0]); |
3420 | break; |
3444 | break; |
3421 | case 6: /* lower window */ |
3445 | case 6: /* lower window */ |
3422 | XLowerWindow (display->display, TermWin.parent[0]); |
3446 | XLowerWindow (disp, TermWin.parent[0]); |
3423 | break; |
3447 | break; |
3424 | case 7: /* refresh window */ |
3448 | case 7: /* refresh window */ |
3425 | scr_touch (true); |
3449 | scr_touch (true); |
3426 | break; |
3450 | break; |
3427 | case 8: /* set size (chars) */ |
3451 | case 8: /* set size (chars) */ |
… | |
… | |
3439 | |
3463 | |
3440 | /* |
3464 | /* |
3441 | * reports - some output format copied from XTerm |
3465 | * reports - some output format copied from XTerm |
3442 | */ |
3466 | */ |
3443 | case 11: /* report window state */ |
3467 | case 11: /* report window state */ |
3444 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3468 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3445 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3469 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3446 | break; |
3470 | break; |
3447 | case 13: /* report window position */ |
3471 | case 13: /* report window position */ |
3448 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3472 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3449 | XTranslateCoordinates (display->display, TermWin.parent[0], wattr.root, |
3473 | XTranslateCoordinates (disp, TermWin.parent[0], wattr.root, |
3450 | -wattr.border_width, -wattr.border_width, |
3474 | -wattr.border_width, -wattr.border_width, |
3451 | &x, &y, &wdummy); |
3475 | &x, &y, &wdummy); |
3452 | tt_printf ("\033[3;%d;%dt", x, y); |
3476 | tt_printf ("\033[3;%d;%dt", x, y); |
3453 | break; |
3477 | break; |
3454 | case 14: /* report window size (pixels) */ |
3478 | case 14: /* report window size (pixels) */ |
3455 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3479 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3456 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3480 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3457 | break; |
3481 | break; |
3458 | case 18: /* report text area size (chars) */ |
3482 | case 18: /* report text area size (chars) */ |
3459 | tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); |
3483 | tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); |
3460 | break; |
3484 | break; |
… | |
… | |
3462 | tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); |
3486 | tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); |
3463 | break; |
3487 | break; |
3464 | case 20: /* report icon label */ |
3488 | case 20: /* report icon label */ |
3465 | { |
3489 | { |
3466 | char *s; |
3490 | char *s; |
3467 | XGetIconName (display->display, TermWin.parent[0], &s); |
3491 | XGetIconName (disp, TermWin.parent[0], &s); |
3468 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3492 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3469 | XFree (s); |
3493 | XFree (s); |
3470 | } |
3494 | } |
3471 | break; |
3495 | break; |
3472 | case 21: /* report window title */ |
3496 | case 21: /* report window title */ |
3473 | { |
3497 | { |
3474 | char *s; |
3498 | char *s; |
3475 | XFetchName (display->display, TermWin.parent[0], &s); |
3499 | XFetchName (disp, TermWin.parent[0], &s); |
3476 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3500 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3477 | XFree (s); |
3501 | XFree (s); |
3478 | } |
3502 | } |
3479 | break; |
3503 | break; |
3480 | } |
3504 | } |
… | |
… | |
3487 | * ends_how is terminator used. returned input must be free()'d |
3511 | * ends_how is terminator used. returned input must be free()'d |
3488 | */ |
3512 | */ |
3489 | unsigned char * |
3513 | unsigned char * |
3490 | rxvt_term::get_to_st (unicode_t &ends_how) |
3514 | rxvt_term::get_to_st (unicode_t &ends_how) |
3491 | { |
3515 | { |
3492 | unicode_t prev = 0, ch; |
3516 | unicode_t ch; |
|
|
3517 | bool seen_esc = false; |
3493 | unsigned int n = 0; |
3518 | unsigned int n = 0; |
3494 | unsigned char *s; |
|
|
3495 | unsigned char string[STRING_MAX]; |
3519 | wchar_t string[STRING_MAX]; |
3496 | |
3520 | |
3497 | while ((ch = cmd_getc ()) != NOCHAR) |
3521 | while ((ch = cmd_getc ()) != NOCHAR) |
3498 | { |
3522 | { |
3499 | if (prev == C0_ESC) |
3523 | if (seen_esc) |
3500 | { |
3524 | { |
3501 | if (ch == 0x5c) /* 7bit ST */ |
3525 | if (ch == 0x5c) /* 7bit ST */ |
3502 | break; |
3526 | break; |
3503 | else |
3527 | else |
3504 | return NULL; |
3528 | return NULL; |
3505 | } |
3529 | } |
|
|
3530 | else if (ch == C0_ESC) |
|
|
3531 | { |
|
|
3532 | seen_esc = true; |
|
|
3533 | continue; |
|
|
3534 | } |
3506 | else if (ch == C0_BEL || ch == CHAR_ST) |
3535 | else if (ch == C0_BEL || ch == CHAR_ST) |
3507 | break; |
3536 | break; |
3508 | else if (ch < 0x20) |
3537 | else if (ch < 0x20) |
3509 | return NULL; /* other control character - exit */ |
3538 | return NULL; /* other control character - exit */ |
|
|
3539 | |
|
|
3540 | seen_esc = false; |
3510 | |
3541 | |
3511 | if (n >= sizeof (string) - 1) |
3542 | if (n >= sizeof (string) - 1) |
3512 | // stop at some sane length |
3543 | // stop at some sane length |
3513 | return NULL; |
3544 | return NULL; |
3514 | |
3545 | |
3515 | if (ch == C0_SYN) |
3546 | if (ch == C0_SYN) |
3516 | { |
|
|
3517 | string[n++] = cmd_get8 (); |
3547 | string[n++] = cmd_get8 (); |
3518 | prev = 0; |
|
|
3519 | } |
|
|
3520 | else |
3548 | else |
3521 | string[n++] = prev = ch; |
3549 | string[n++] = ch; |
3522 | } |
3550 | } |
3523 | |
3551 | |
3524 | string[n++] = '\0'; |
3552 | string[n++] = '\0'; |
3525 | |
3553 | |
3526 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
|
|
3527 | return NULL; |
|
|
3528 | |
|
|
3529 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3554 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3530 | strncpy (s, string, n); |
3555 | |
3531 | return s; |
3556 | return (unsigned char *)rxvt_wcstombs (string); |
3532 | } |
3557 | } |
3533 | |
3558 | |
3534 | /*----------------------------------------------------------------------*/ |
3559 | /*----------------------------------------------------------------------*/ |
3535 | /* |
3560 | /* |
3536 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3561 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
… | |
… | |
3620 | { |
3645 | { |
3621 | int changed = 0; |
3646 | int changed = 0; |
3622 | int color; |
3647 | int color; |
3623 | char *buf, *name; |
3648 | char *buf, *name; |
3624 | bool query = str[0] == '?' && !str[1]; |
3649 | bool query = str[0] == '?' && !str[1]; |
|
|
3650 | int saveop = op; |
|
|
3651 | dDisp; |
3625 | |
3652 | |
3626 | assert (str != NULL); |
3653 | assert (str != NULL); |
3627 | switch (op) |
3654 | switch (op) |
3628 | { |
3655 | { |
3629 | case XTerm_name: |
3656 | case XTerm_name: |
… | |
… | |
3636 | set_title (str); |
3663 | set_title (str); |
3637 | break; |
3664 | break; |
3638 | case XTerm_property: |
3665 | case XTerm_property: |
3639 | if (str[0] == '?') |
3666 | if (str[0] == '?') |
3640 | { |
3667 | { |
3641 | Atom prop = XInternAtom (display->display, str + 1, True); |
3668 | Atom prop = display->atom (str + 1); |
3642 | Atom actual_type; |
3669 | Atom actual_type; |
3643 | int actual_format; |
3670 | int actual_format; |
3644 | unsigned long nitems; |
3671 | unsigned long nitems; |
3645 | unsigned long bytes_after; |
3672 | unsigned long bytes_after; |
3646 | unsigned char *value = 0; |
3673 | unsigned char *value = 0; |
3647 | const char *str = ""; |
3674 | const char *str = ""; |
3648 | |
3675 | |
3649 | if (prop |
3676 | if (prop |
3650 | && XGetWindowProperty (display->display, TermWin.parent[0], |
3677 | && XGetWindowProperty (disp, TermWin.parent[0], |
3651 | prop, 0, 1<<16, 0, AnyPropertyType, |
3678 | prop, 0, 1<<16, 0, AnyPropertyType, |
3652 | &actual_type, &actual_format, |
3679 | &actual_type, &actual_format, |
3653 | &nitems, &bytes_after, &value) == Success |
3680 | &nitems, &bytes_after, &value) == Success |
3654 | && actual_type != None |
3681 | && actual_type != None |
3655 | && actual_format == 8) |
3682 | && actual_format == 8) |
… | |
… | |
3664 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3691 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3665 | |
3692 | |
3666 | if (eq) |
3693 | if (eq) |
3667 | { |
3694 | { |
3668 | *eq = 0; |
3695 | *eq = 0; |
3669 | XChangeProperty (display->display, TermWin.parent[0], |
3696 | set_utf8_property (display->atom (str), eq + 1); |
3670 | display->atom (str), XA_STRING, 8, |
|
|
3671 | PropModeReplace, (unsigned char *)eq + 1, |
|
|
3672 | strlen (eq + 1)); |
|
|
3673 | } |
3697 | } |
3674 | else |
3698 | else |
3675 | XDeleteProperty (display->display, TermWin.parent[0], |
3699 | XDeleteProperty (disp, TermWin.parent[0], |
3676 | display->atom (str)); |
3700 | display->atom (str)); |
3677 | } |
3701 | } |
3678 | break; |
3702 | break; |
3679 | |
3703 | |
3680 | case XTerm_Color: |
3704 | case XTerm_Color: |
… | |
… | |
3721 | break; |
3745 | break; |
3722 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3746 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3723 | case XTerm_Color_BD: |
3747 | case XTerm_Color_BD: |
3724 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3748 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3725 | break; |
3749 | break; |
|
|
3750 | case XTerm_Color_IT: |
|
|
3751 | process_color_seq (XTerm_Color_IT, Color_IT, str, resp); |
|
|
3752 | break; |
3726 | case XTerm_Color_UL: |
3753 | case XTerm_Color_UL: |
3727 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3754 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3728 | break; |
3755 | break; |
3729 | case XTerm_Color_RV: |
3756 | case XTerm_Color_RV: |
3730 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3757 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
|
|
3758 | break; |
|
|
3759 | #endif |
|
|
3760 | #if TRANSPARENT && TINTING |
|
|
3761 | case XTerm_Color_tint: |
|
|
3762 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
|
|
3763 | check_our_parents (); |
|
|
3764 | if (am_transparent) |
|
|
3765 | want_full_refresh = want_refresh = 1; |
3731 | break; |
3766 | break; |
3732 | #endif |
3767 | #endif |
3733 | |
3768 | |
3734 | case XTerm_Pixmap: |
3769 | case XTerm_Pixmap: |
3735 | if (*str != ';') |
3770 | if (*str != ';') |
… | |
… | |
3744 | { |
3779 | { |
3745 | str++; |
3780 | str++; |
3746 | #if XPM_BACKGROUND |
3781 | #if XPM_BACKGROUND |
3747 | changed += scale_pixmap (str); |
3782 | changed += scale_pixmap (str); |
3748 | #endif |
3783 | #endif |
3749 | |
|
|
3750 | } |
3784 | } |
|
|
3785 | |
3751 | if (changed) |
3786 | if (changed) |
3752 | { |
3787 | { |
3753 | #ifdef XPM_BACKGROUND |
3788 | #ifdef XPM_BACKGROUND |
3754 | resize_pixmap (); |
3789 | resize_pixmap (); |
3755 | #endif |
3790 | #endif |
… | |
… | |
3767 | case XTerm_logfile: |
3802 | case XTerm_logfile: |
3768 | // TODO, when secure mode? |
3803 | // TODO, when secure mode? |
3769 | break; |
3804 | break; |
3770 | |
3805 | |
3771 | case XTerm_font: |
3806 | case XTerm_font: |
|
|
3807 | op = URxvt_font; |
|
|
3808 | case URxvt_font: |
|
|
3809 | #if ENABLE_STYLES |
|
|
3810 | case URxvt_boldFont: |
|
|
3811 | case URxvt_italicFont: |
|
|
3812 | case URxvt_boldItalicFont: |
|
|
3813 | #endif |
3772 | if (query) |
3814 | if (query) |
3773 | tt_printf ("\33]%d;%-.250s%c", XTerm_font, |
3815 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3774 | (options & Opt_insecure) && TermWin.fontset->fontdesc |
3816 | (options & Opt_insecure) && TermWin.fontset[op - URxvt_font]->fontdesc |
3775 | ? TermWin.fontset->fontdesc : "", |
3817 | ? TermWin.fontset[op - URxvt_font]->fontdesc : "", |
3776 | resp); |
3818 | resp); |
3777 | else |
3819 | else |
|
|
3820 | { |
|
|
3821 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
|
|
3822 | |
|
|
3823 | res = strdup (str); |
|
|
3824 | allocated.push_back ((void *)res); |
3778 | change_font (str); |
3825 | set_fonts (); |
|
|
3826 | } |
3779 | break; |
3827 | break; |
3780 | |
3828 | |
3781 | #if ENABLE_FRILLS |
3829 | #if ENABLE_FRILLS |
3782 | case XTerm_locale: |
3830 | case XTerm_locale: |
3783 | if (query) |
3831 | if (query) |
3784 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3832 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3785 | else |
3833 | else |
3786 | { |
3834 | { |
3787 | set_locale (str); |
3835 | set_locale (str); |
|
|
3836 | pty.set_utf8_mode (enc_utf8); |
3788 | # ifdef USE_XIM |
3837 | # ifdef USE_XIM |
3789 | im_cb (); |
3838 | im_cb (); |
3790 | # endif |
3839 | # endif |
3791 | } |
3840 | } |
3792 | break; |
|
|
3793 | |
|
|
3794 | case XTerm_findfont: |
|
|
3795 | { |
|
|
3796 | int fid = TermWin.fontset->find_font (atoi (str)); |
|
|
3797 | tt_printf ("\33]%d;%d;%-.250s%c", XTerm_findfont, |
|
|
3798 | fid, |
|
|
3799 | (options & Opt_insecure) ? (*TermWin.fontset)[fid]->name : "", |
|
|
3800 | resp); |
|
|
3801 | } |
|
|
3802 | break; |
3841 | break; |
3803 | #endif |
3842 | #endif |
3804 | |
3843 | |
3805 | #ifdef MENUBAR |
3844 | #ifdef MENUBAR |
3806 | case XTerm_Menu: |
3845 | case XTerm_Menu: |
… | |
… | |
3935 | |
3974 | |
3936 | /* extra handling for values with state unkept */ |
3975 | /* extra handling for values with state unkept */ |
3937 | switch (arg[i]) |
3976 | switch (arg[i]) |
3938 | { |
3977 | { |
3939 | case 1048: /* alternative cursor save */ |
3978 | case 1048: /* alternative cursor save */ |
|
|
3979 | case 1049: |
3940 | if (options & Opt_secondaryScreen) |
3980 | if (options & Opt_secondaryScreen) |
3941 | if (mode == 0) |
3981 | if (mode == 0) |
3942 | scr_cursor (RESTORE); |
3982 | scr_cursor (RESTORE); |
3943 | else if (mode == 1) |
3983 | else if (mode == 1) |
3944 | scr_cursor (SAVE); |
3984 | scr_cursor (SAVE); |
… | |
… | |
4069 | rendset = 0, rendstyle = ~RS_None; |
4109 | rendset = 0, rendstyle = ~RS_None; |
4070 | break; |
4110 | break; |
4071 | case 1: |
4111 | case 1: |
4072 | rendset = 1, rendstyle = RS_Bold; |
4112 | rendset = 1, rendstyle = RS_Bold; |
4073 | break; |
4113 | break; |
4074 | //case 2: // faint or second colour |
4114 | //case 2: // low intensity |
4075 | //case 3: // italic |
4115 | case 3: |
|
|
4116 | rendset = 1, rendstyle = RS_Italic; |
|
|
4117 | break; |
4076 | case 4: |
4118 | case 4: |
4077 | rendset = 1, rendstyle = RS_Uline; |
4119 | rendset = 1, rendstyle = RS_Uline; |
4078 | break; |
4120 | break; |
4079 | case 5: // slowly blinking |
4121 | case 5: // slowly blinking |
4080 | case 6: // rapidly blinking |
4122 | case 6: // rapidly blinking |
… | |
… | |
4092 | //case 11: // scoansi acs on, first alt font |
4134 | //case 11: // scoansi acs on, first alt font |
4093 | //case 12: // scoansi acs on, |0x80, second alt font |
4135 | //case 12: // scoansi acs on, |0x80, second alt font |
4094 | //... |
4136 | //... |
4095 | //case 19: // ninth alt font |
4137 | //case 19: // ninth alt font |
4096 | //case 20: // gothic |
4138 | //case 20: // gothic |
4097 | case 21: // disable bold, faint |
4139 | case 21: // disable bold, faint, sometimes doubly underlined (iso 8613) |
4098 | rendset = 0, rendstyle = RS_Bold; |
4140 | rendset = 0, rendstyle = RS_Bold; |
4099 | break; |
4141 | break; |
4100 | case 22: |
4142 | case 22: // normal intensity |
4101 | rendset = 0, rendstyle = RS_Bold; |
4143 | rendset = 0, rendstyle = RS_Bold; |
4102 | break; |
4144 | break; |
4103 | //case 23: disable italic |
4145 | case 23: // disable italic |
|
|
4146 | rendset = 0, rendstyle = RS_Italic; |
|
|
4147 | break; |
4104 | case 24: |
4148 | case 24: |
4105 | rendset = 0, rendstyle = RS_Uline; |
4149 | rendset = 0, rendstyle = RS_Uline; |
4106 | break; |
4150 | break; |
4107 | case 25: |
4151 | case 25: |
4108 | rendset = 0, rendstyle = RS_Blink; |
4152 | rendset = 0, rendstyle = RS_Blink; |
4109 | break; |
4153 | break; |
4110 | case 26: |
4154 | case 26: // variable spacing (iso 8613) |
4111 | rendset = 0, rendstyle = RS_Blink; |
4155 | rendset = 0, rendstyle = RS_Blink; |
4112 | break; |
4156 | break; |
4113 | case 27: |
4157 | case 27: |
4114 | rendset = 0, rendstyle = RS_RVid; |
4158 | rendset = 0, rendstyle = RS_RVid; |
4115 | break; |
4159 | break; |
… | |
… | |
4133 | case 35: |
4177 | case 35: |
4134 | case 36: |
4178 | case 36: |
4135 | case 37: |
4179 | case 37: |
4136 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); |
4180 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 30)), Color_fg); |
4137 | break; |
4181 | break; |
4138 | #ifdef TTY_256COLOR |
4182 | case 38: // set fg color, ISO 8613-6 |
4139 | case 38: |
|
|
4140 | if (nargs > i + 2 && arg[i + 1] == 5) |
4183 | if (nargs > i + 2 && arg[i + 1] == 5) |
4141 | { |
4184 | { |
4142 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); |
4185 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_fg); |
4143 | i += 2; |
4186 | i += 2; |
4144 | } |
4187 | } |
4145 | break; |
4188 | break; |
4146 | #endif |
|
|
4147 | case 39: /* default fg */ |
4189 | case 39: /* default fg */ |
4148 | scr_color (Color_fg, Color_fg); |
4190 | scr_color (Color_fg, Color_fg); |
4149 | break; |
4191 | break; |
4150 | |
4192 | |
4151 | case 40: |
4193 | case 40: |
… | |
… | |
4156 | case 45: |
4198 | case 45: |
4157 | case 46: |
4199 | case 46: |
4158 | case 47: |
4200 | case 47: |
4159 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); |
4201 | scr_color ((unsigned int) (minCOLOR + (arg[i] - 40)), Color_bg); |
4160 | break; |
4202 | break; |
4161 | #ifdef TTY_256COLOR |
4203 | case 48: // set bg color, ISO 8613-6 |
4162 | case 48: |
|
|
4163 | if (nargs > i + 2 && arg[i + 1] == 5) |
4204 | if (nargs > i + 2 && arg[i + 1] == 5) |
4164 | { |
4205 | { |
4165 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); |
4206 | scr_color ((unsigned int) (minCOLOR + arg[i + 2]), Color_bg); |
4166 | i += 2; |
4207 | i += 2; |
4167 | } |
4208 | } |
4168 | break; |
4209 | break; |
4169 | #endif |
|
|
4170 | case 49: /* default bg */ |
4210 | case 49: /* default bg */ |
4171 | scr_color (Color_bg, Color_bg); |
4211 | scr_color (Color_bg, Color_bg); |
4172 | break; |
4212 | break; |
|
|
4213 | |
|
|
4214 | //case 50: // not variable spacing |
4173 | |
4215 | |
4174 | #ifndef NO_BRIGHTCOLOR |
4216 | #ifndef NO_BRIGHTCOLOR |
4175 | case 90: |
4217 | case 90: |
4176 | case 91: /* set bright fg color */ |
4218 | case 91: /* set bright fg color */ |
4177 | case 92: |
4219 | case 92: |
4178 | case 93: |
4220 | case 93: |
4179 | case 94: |
4221 | case 94: |
4180 | case 95: |
4222 | case 95: |
4181 | case 96: |
4223 | case 96: |
4182 | case 97: |
4224 | case 97: |
4183 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 90)), |
4225 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 90)), Color_fg); |
4184 | Color_fg); |
|
|
4185 | break; |
4226 | break; |
4186 | case 100: |
4227 | case 100: |
4187 | case 101: /* set bright bg color */ |
4228 | case 101: /* set bright bg color */ |
4188 | case 102: |
4229 | case 102: |
4189 | case 103: |
4230 | case 103: |
4190 | case 104: |
4231 | case 104: |
4191 | case 105: |
4232 | case 105: |
4192 | case 106: |
4233 | case 106: |
4193 | case 107: |
4234 | case 107: |
4194 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), |
4235 | scr_color ((unsigned int) (minBrightCOLOR + (arg[i] - 100)), Color_bg); |
4195 | Color_bg); |
|
|
4196 | break; |
4236 | break; |
4197 | #endif |
4237 | #endif |
4198 | |
4238 | |
4199 | } |
4239 | } |
4200 | } |
4240 | } |
… | |
… | |
4239 | |
4279 | |
4240 | /* ---------------------------------------------------------------------- */ |
4280 | /* ---------------------------------------------------------------------- */ |
4241 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4281 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4242 | * or generated by us in response to a query ESC sequence. |
4282 | * or generated by us in response to a query ESC sequence. |
4243 | */ |
4283 | */ |
|
|
4284 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
|
|
4285 | |
4244 | void |
4286 | void |
4245 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4287 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4246 | { |
4288 | { |
4247 | enum { MAX_PTY_WRITE = 255 }; // minimum MAX_INPUT |
4289 | if (v_buflen == 0) |
|
|
4290 | { |
|
|
4291 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4248 | |
4292 | |
4249 | if (len) |
4293 | if ((unsigned int)written == len) |
|
|
4294 | return; |
|
|
4295 | |
|
|
4296 | data += written; |
|
|
4297 | len -= written; |
4250 | { |
4298 | } |
|
|
4299 | |
|
|
4300 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4301 | |
|
|
4302 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4303 | v_buflen += len; |
|
|
4304 | |
|
|
4305 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4306 | } |
|
|
4307 | |
|
|
4308 | void rxvt_term::pty_write () |
|
|
4309 | { |
|
|
4310 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4311 | |
|
|
4312 | if (written > 0) |
|
|
4313 | { |
|
|
4314 | v_buflen -= written; |
|
|
4315 | |
4251 | if (v_buflen == 0) |
4316 | if (v_buflen == 0) |
4252 | { |
4317 | { |
4253 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
|
|
4254 | |
|
|
4255 | if ((unsigned int)written == len) |
|
|
4256 | return; |
|
|
4257 | |
|
|
4258 | data += written; |
|
|
4259 | len -= written; |
|
|
4260 | } |
|
|
4261 | |
|
|
4262 | |
|
|
4263 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4264 | |
|
|
4265 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4266 | v_buflen += len; |
|
|
4267 | } |
|
|
4268 | |
|
|
4269 | for (;;) |
|
|
4270 | { |
|
|
4271 | int written = write (pty.pty, v_buffer, min (MAX_PTY_WRITE, v_buflen)); |
|
|
4272 | |
|
|
4273 | if (written > 0) |
|
|
4274 | { |
|
|
4275 | v_buflen -= written; |
|
|
4276 | |
|
|
4277 | if (v_buflen == 0) |
|
|
4278 | { |
|
|
4279 | free (v_buffer); |
4318 | free (v_buffer); |
4280 | v_buffer = 0; |
4319 | v_buffer = 0; |
4281 | v_buflen = 0; |
4320 | v_buflen = 0; |
4282 | |
4321 | |
4283 | pty_ev.set (EVENT_READ); |
4322 | pty_ev.set (EVENT_READ); |
4284 | return; |
|
|
4285 | } |
|
|
4286 | |
|
|
4287 | memmove (v_buffer, v_buffer + written, v_buflen); |
|
|
4288 | } |
|
|
4289 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4290 | // original code just ignores this... |
|
|
4291 | destroy (); |
|
|
4292 | else |
|
|
4293 | { |
|
|
4294 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4295 | return; |
4323 | return; |
4296 | } |
4324 | } |
|
|
4325 | |
|
|
4326 | memmove (v_buffer, v_buffer + written, v_buflen); |
4297 | } |
4327 | } |
|
|
4328 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4329 | // original code just ignores this... |
|
|
4330 | destroy (); |
4298 | } |
4331 | } |
4299 | |
4332 | |
4300 | /*----------------------- end-of-file (C source) -----------------------*/ |
4333 | /*----------------------- end-of-file (C source) -----------------------*/ |
4301 | |
4334 | |