… | |
… | |
25 | * - extensive modifications |
25 | * - extensive modifications |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
27 | * Copyright (c) 2001 Marius Gedminas |
27 | * Copyright (c) 2001 Marius Gedminas |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
30 | * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> |
30 | * Copyright (c) 2003-2005 Marc Lehmann <pcg@goof.com> |
31 | * |
31 | * |
32 | * This program is free software; you can redistribute it and/or modify |
32 | * This program is free software; you can redistribute it and/or modify |
33 | * it under the terms of the GNU General Public License as published by |
33 | * it under the terms of the GNU General Public License as published by |
34 | * the Free Software Foundation; either version 2 of the License, or |
34 | * the Free Software Foundation; either version 2 of the License, or |
35 | * (at your option) any later version. |
35 | * (at your option) any later version. |
… | |
… | |
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 | |
… | |
… | |
113 | XK_Escape, 0x238b, |
117 | XK_Escape, 0x238b, |
114 | XK_Undo, 0x238c, |
118 | XK_Undo, 0x238c, |
115 | XK_Print, 0x2399, |
119 | XK_Print, 0x2399, |
116 | |
120 | |
117 | XK_space, 0x2423, |
121 | XK_space, 0x2423, |
|
|
122 | |
|
|
123 | #ifdef XK_KP_Begin |
|
|
124 | XK_KP_Prior, 0x21de, |
|
|
125 | XK_KP_Next, 0x21df, |
|
|
126 | XK_KP_Begin, 0x2320, |
|
|
127 | XK_KP_Insert, 0x2380, |
|
|
128 | XK_KP_Delete, 0x2326, |
118 | XK_KP_Space, 0x2422, |
129 | XK_KP_Space, 0x2422, |
|
|
130 | #endif |
119 | 0, |
131 | 0, |
120 | }; |
132 | }; |
121 | |
133 | |
122 | void |
134 | void |
123 | rxvt_term::iso14755_54 (int x, int y) |
135 | rxvt_term::iso14755_54 (int x, int y) |
… | |
… | |
151 | void |
163 | void |
152 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r) |
164 | rxvt_term::iso14755_51 (unicode_t ch, rend_t r) |
153 | { |
165 | { |
154 | rxvt_fontset *fs = FONTSET (r); |
166 | rxvt_fontset *fs = FONTSET (r); |
155 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
167 | rxvt_font *f = (*fs)[fs->find_font (ch)]; |
156 | wchar_t *chr, *alloc, ch2; |
168 | wchar_t *chr, *alloc, ch2, *fname; |
157 | int len; |
169 | int len; |
|
|
170 | |
|
|
171 | fname = rxvt_utf8towcs (f->name); |
158 | |
172 | |
159 | #if ENABLE_COMBINING |
173 | #if ENABLE_COMBINING |
160 | if (IS_COMPOSE (ch)) |
174 | if (IS_COMPOSE (ch)) |
161 | { |
175 | { |
162 | len = rxvt_composite.expand (ch, 0); |
176 | len = rxvt_composite.expand (ch, 0); |
… | |
… | |
171 | alloc = 0; |
185 | alloc = 0; |
172 | chr = &ch2; |
186 | chr = &ch2; |
173 | len = 1; |
187 | len = 1; |
174 | } |
188 | } |
175 | |
189 | |
176 | int width = strlen (f->name); |
190 | int width = wcswidth (fname, wcslen (fname)); |
177 | |
191 | |
178 | scr_overlay_new (0, -1, width < 8+5 ? 8+5 : width, len + 1); |
192 | scr_overlay_new (0, -1, width < 8+5 ? 8+5 : width, len + 1); |
179 | |
193 | |
180 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
194 | r = SET_STYLE (OVERLAY_RSTYLE, GET_STYLE (r)); |
181 | |
195 | |
… | |
… | |
194 | #endif |
208 | #endif |
195 | scr_overlay_set (11, y, ch, r); |
209 | scr_overlay_set (11, y, ch, r); |
196 | scr_overlay_set (12, y, NOCHAR, r); |
210 | scr_overlay_set (12, y, NOCHAR, r); |
197 | } |
211 | } |
198 | |
212 | |
199 | scr_overlay_set (0, len, f->name); |
213 | scr_overlay_set (0, len, fname); |
|
|
214 | |
|
|
215 | free (fname); |
200 | |
216 | |
201 | #if ENABLE_COMBINING |
217 | #if ENABLE_COMBINING |
202 | if (alloc) |
218 | if (alloc) |
203 | delete [] alloc; |
219 | delete [] alloc; |
204 | #endif |
220 | #endif |
… | |
… | |
272 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
288 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
273 | * escape sequence to toggle the Keypad. |
289 | * escape sequence to toggle the Keypad. |
274 | * |
290 | * |
275 | * Always permit `shift' to override the current setting |
291 | * Always permit `shift' to override the current setting |
276 | */ |
292 | */ |
277 | shft = (ev.state & ShiftMask); |
293 | shft = ev.state & ShiftMask; |
278 | ctrl = (ev.state & ControlMask); |
294 | ctrl = ev.state & ControlMask; |
279 | meta = (ev.state & ModMetaMask); |
295 | meta = ev.state & ModMetaMask; |
280 | |
296 | |
281 | if (numlock_state || (ev.state & ModNumLockMask)) |
297 | if (numlock_state || (ev.state & ModNumLockMask)) |
282 | { |
298 | { |
283 | numlock_state = (ev.state & ModNumLockMask); |
299 | numlock_state = (ev.state & ModNumLockMask); |
284 | PrivMode ((!numlock_state), PrivMode_aplKP); |
300 | PrivMode ((!numlock_state), PrivMode_aplKP); |
… | |
… | |
304 | |
320 | |
305 | // the XOpenIM manpage lies about hardcoding the locale |
321 | // the XOpenIM manpage lies about hardcoding the locale |
306 | // at the point of XOpenIM, so temporarily switch locales |
322 | // at the point of XOpenIM, so temporarily switch locales |
307 | if (rs[Rs_imLocale]) |
323 | if (rs[Rs_imLocale]) |
308 | SET_LOCALE (rs[Rs_imLocale]); |
324 | SET_LOCALE (rs[Rs_imLocale]); |
|
|
325 | |
309 | // assume wchar_t == unicode or better |
326 | // assume wchar_t == unicode or better |
310 | len = XwcLookupString (Input_Context, &ev, wkbuf, |
327 | len = XwcLookupString (Input_Context, &ev, wkbuf, |
311 | KBUFSZ, &keysym, &status_return); |
328 | KBUFSZ, &keysym, &status_return); |
|
|
329 | |
312 | if (rs[Rs_imLocale]) |
330 | if (rs[Rs_imLocale]) |
313 | SET_LOCALE (locale); |
331 | SET_LOCALE (locale); |
314 | |
332 | |
315 | if (status_return == XLookupChars |
333 | if (status_return == XLookupChars |
316 | || status_return == XLookupBoth) |
334 | || status_return == XLookupBoth) |
… | |
… | |
343 | valid_keysym = keysym != NoSymbol; |
361 | valid_keysym = keysym != NoSymbol; |
344 | } |
362 | } |
345 | |
363 | |
346 | if (valid_keysym) |
364 | if (valid_keysym) |
347 | { |
365 | { |
|
|
366 | #ifdef KEYSYM_RESOURCE |
|
|
367 | if (keyboard->dispatch (this, keysym, ev.state)) |
|
|
368 | return; |
|
|
369 | #endif |
|
|
370 | |
348 | if (TermWin.saveLines) |
371 | if (TermWin.saveLines) |
349 | { |
372 | { |
350 | #ifdef UNSHIFTED_SCROLLKEYS |
373 | #ifdef UNSHIFTED_SCROLLKEYS |
351 | if (!ctrl && !meta) |
374 | if (!ctrl && !meta) |
352 | #else |
375 | #else |
… | |
… | |
417 | { |
440 | { |
418 | /* normal XTerm key bindings */ |
441 | /* normal XTerm key bindings */ |
419 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
442 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
420 | selection_request (ev.time, 0, 0); |
443 | selection_request (ev.time, 0, 0); |
421 | return; |
444 | return; |
422 | #if TODO // TODO |
445 | #if TODO |
423 | /* rxvt extras */ |
446 | /* rxvt extras */ |
424 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
447 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
425 | change_font (FONT_UP); |
448 | change_font (FONT_UP); |
426 | return; |
449 | return; |
427 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
450 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
… | |
… | |
486 | } |
509 | } |
487 | #endif |
510 | #endif |
488 | |
511 | |
489 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
512 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
490 | { |
513 | { |
491 | #ifdef KEYSYM_RESOURCE |
|
|
492 | if (! (shft | ctrl) && Keysym_map[keysym & 0xFF] != NULL) |
|
|
493 | { |
|
|
494 | unsigned int l; |
|
|
495 | const unsigned char *kbuf0; |
|
|
496 | |
|
|
497 | kbuf0 = (Keysym_map[keysym & 0xFF]); |
|
|
498 | l = (unsigned int)*kbuf0++; |
|
|
499 | |
|
|
500 | /* escape prefix */ |
|
|
501 | if (meta |
|
|
502 | # ifdef META8_OPTION |
|
|
503 | && meta_char == C0_ESC |
|
|
504 | # endif |
|
|
505 | ) |
|
|
506 | { |
|
|
507 | const unsigned char ch = C0_ESC; |
|
|
508 | tt_write (&ch, 1); |
|
|
509 | } |
|
|
510 | |
|
|
511 | tt_write (kbuf0, l); |
|
|
512 | return; |
|
|
513 | } |
|
|
514 | else |
|
|
515 | #endif |
|
|
516 | { |
514 | { |
517 | newlen = 1; |
515 | newlen = 1; |
518 | switch (keysym) |
516 | switch (keysym) |
519 | { |
517 | { |
520 | #ifndef NO_BACKSPACE_KEY |
518 | #ifndef NO_BACKSPACE_KEY |
… | |
… | |
528 | else |
526 | else |
529 | strcpy (kbuf, key_backspace); |
527 | strcpy (kbuf, key_backspace); |
530 | break; |
528 | break; |
531 | #endif |
529 | #endif |
532 | #ifndef NO_DELETE_KEY |
530 | #ifndef NO_DELETE_KEY |
|
|
531 | # ifdef XK_KP_Prior |
|
|
532 | case XK_KP_Delete: |
|
|
533 | /* allow shift to override */ |
|
|
534 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
535 | { |
|
|
536 | strcpy (kbuf, "\033On"); |
|
|
537 | break; |
|
|
538 | } |
|
|
539 | /* FALLTHROUGH */ |
|
|
540 | # endif |
533 | case XK_Delete: |
541 | case XK_Delete: |
534 | strcpy (kbuf, key_delete); |
542 | strcpy (kbuf, key_delete); |
535 | break; |
543 | break; |
536 | #endif |
544 | #endif |
537 | case XK_Tab: |
545 | case XK_Tab: |
… | |
… | |
640 | #ifdef XK_KP_Begin |
648 | #ifdef XK_KP_Begin |
641 | case XK_KP_Begin: |
649 | case XK_KP_Begin: |
642 | strcpy (kbuf, "\033Ou"); |
650 | strcpy (kbuf, "\033Ou"); |
643 | break; |
651 | break; |
644 | |
652 | |
645 | case XK_KP_Insert: |
|
|
646 | strcpy (kbuf, "\033Op"); |
|
|
647 | break; |
|
|
648 | |
|
|
649 | case XK_KP_Delete: |
|
|
650 | strcpy (kbuf, "\033On"); |
|
|
651 | break; |
|
|
652 | #endif |
653 | #endif |
653 | case XK_KP_F1: /* "\033OP" */ |
654 | case XK_KP_F1: /* "\033OP" */ |
654 | case XK_KP_F2: /* "\033OQ" */ |
655 | case XK_KP_F2: /* "\033OQ" */ |
655 | case XK_KP_F3: /* "\033OR" */ |
656 | case XK_KP_F3: /* "\033OR" */ |
656 | case XK_KP_F4: /* "\033OS" */ |
657 | case XK_KP_F4: /* "\033OS" */ |
… | |
… | |
688 | break; |
689 | break; |
689 | |
690 | |
690 | case XK_Find: |
691 | case XK_Find: |
691 | strcpy (kbuf, "\033[1~"); |
692 | strcpy (kbuf, "\033[1~"); |
692 | break; |
693 | break; |
|
|
694 | |
|
|
695 | #ifdef XK_KP_End |
|
|
696 | case XK_KP_Insert: |
|
|
697 | /* allow shift to override */ |
|
|
698 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
699 | { |
|
|
700 | strcpy (kbuf, "\033Op"); |
|
|
701 | break; |
|
|
702 | } |
|
|
703 | /* FALLTHROUGH */ |
|
|
704 | #endif |
693 | case XK_Insert: |
705 | case XK_Insert: |
694 | strcpy (kbuf, "\033[2~"); |
706 | strcpy (kbuf, "\033[2~"); |
695 | break; |
707 | break; |
696 | #ifdef DXK_Remove /* support for DEC remove like key */ |
708 | #ifdef DXK_Remove /* support for DEC remove like key */ |
697 | case DXK_Remove: |
709 | case DXK_Remove: |
… | |
… | |
787 | #undef FKEY |
799 | #undef FKEY |
788 | default: |
800 | default: |
789 | newlen = 0; |
801 | newlen = 0; |
790 | break; |
802 | break; |
791 | } |
803 | } |
|
|
804 | |
792 | if (newlen) |
805 | if (newlen) |
793 | len = strlen (kbuf); |
806 | len = strlen (kbuf); |
794 | } |
807 | } |
795 | |
808 | |
796 | /* |
809 | /* |
… | |
… | |
804 | } |
817 | } |
805 | else if (ctrl && keysym == XK_minus) |
818 | else if (ctrl && keysym == XK_minus) |
806 | { |
819 | { |
807 | len = 1; |
820 | len = 1; |
808 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
821 | kbuf[0] = '\037'; /* Ctrl-Minus generates ^_ (31) */ |
|
|
822 | } |
|
|
823 | else if (keysym == XK_ISO_Left_Tab) |
|
|
824 | { |
|
|
825 | strcpy (kbuf, "\033[Z"); |
|
|
826 | len = 3; |
809 | } |
827 | } |
810 | else |
828 | else |
811 | { |
829 | { |
812 | #ifdef META8_OPTION |
830 | #ifdef META8_OPTION |
813 | /* set 8-bit on */ |
831 | /* set 8-bit on */ |
… | |
… | |
872 | #endif /* DEBUG_CMD */ |
890 | #endif /* DEBUG_CMD */ |
873 | tt_write (kbuf, (unsigned int)len); |
891 | tt_write (kbuf, (unsigned int)len); |
874 | } |
892 | } |
875 | /*}}} */ |
893 | /*}}} */ |
876 | |
894 | |
877 | #if (MENUBAR_MAX) |
895 | #if MENUBAR_MAX || defined (KEYSYM_RESOURCE) |
878 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
896 | /*{{{ rxvt_cmd_write (), rxvt_cmd_getc () */ |
879 | /* attempt to `write' count to the input buffer */ |
897 | /* attempt to `write' count to the input buffer */ |
880 | unsigned int |
898 | unsigned int |
881 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
899 | rxvt_term::cmd_write (const unsigned char *str, unsigned int count) |
882 | { |
900 | { |
… | |
… | |
905 | |
923 | |
906 | cmd_parse (); |
924 | cmd_parse (); |
907 | |
925 | |
908 | return 0; |
926 | return 0; |
909 | } |
927 | } |
910 | #endif /* MENUBAR_MAX */ |
928 | #endif |
911 | |
929 | |
912 | void |
930 | void |
913 | rxvt_term::flush () |
931 | rxvt_term::flush () |
914 | { |
932 | { |
|
|
933 | flush_ev.stop (); |
|
|
934 | |
915 | #ifdef TRANSPARENT |
935 | #ifdef TRANSPARENT |
916 | if (want_full_refresh) |
936 | if (want_full_refresh) |
917 | { |
937 | { |
918 | want_full_refresh = 0; |
938 | want_full_refresh = 0; |
919 | scr_clear (); |
939 | scr_clear (); |
… | |
… | |
929 | IMSendSpot (); |
949 | IMSendSpot (); |
930 | #endif |
950 | #endif |
931 | } |
951 | } |
932 | |
952 | |
933 | display->flush (); |
953 | display->flush (); |
934 | |
|
|
935 | flush_ev.stop (); |
|
|
936 | } |
954 | } |
937 | |
955 | |
938 | void |
956 | void |
939 | rxvt_term::check_cb (check_watcher &w) |
957 | rxvt_term::check_cb (check_watcher &w) |
940 | { |
958 | { |
… | |
… | |
1016 | { |
1034 | { |
1017 | if (mouse_slip_wheel_speed == 0 |
1035 | if (mouse_slip_wheel_speed == 0 |
1018 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1036 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
1019 | : scr_page (UP, mouse_slip_wheel_speed)) |
1037 | : scr_page (UP, mouse_slip_wheel_speed)) |
1020 | { |
1038 | { |
|
|
1039 | if (TermWin.view_start == TermWin.nscrolled || |
|
|
1040 | TermWin.view_start == 0) |
|
|
1041 | mouse_slip_wheel_speed = 0; |
|
|
1042 | |
1021 | refresh_type |= SMOOTH_REFRESH; |
1043 | refresh_type |= SMOOTH_REFRESH; |
1022 | want_refresh = 1; |
1044 | want_refresh = 1; |
1023 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1045 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1024 | } |
1046 | } |
1025 | } |
1047 | } |
… | |
… | |
1057 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1079 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1058 | { |
1080 | { |
1059 | SET_R (this); |
1081 | SET_R (this); |
1060 | SET_LOCALE (locale); |
1082 | SET_LOCALE (locale); |
1061 | |
1083 | |
1062 | if (revents & EVENT_WRITE) |
|
|
1063 | tt_write (0, 0); |
|
|
1064 | else if (revents & EVENT_READ) |
1084 | if (revents & EVENT_READ) |
1065 | // loop, but don't allow a single term to monopolize us |
1085 | // loop, but don't allow a single term to monopolize us |
1066 | while (pty_fill ()) |
1086 | while (pty_fill ()) |
1067 | if (cmd_parse ()) |
1087 | if (cmd_parse ()) |
1068 | break; |
1088 | break; |
|
|
1089 | |
|
|
1090 | if (revents & EVENT_WRITE) |
|
|
1091 | pty_write (); |
1069 | } |
1092 | } |
1070 | |
1093 | |
1071 | void |
1094 | void |
1072 | rxvt_term::pointer_unblank () |
1095 | rxvt_term::pointer_unblank () |
1073 | { |
1096 | { |
… | |
… | |
1087 | rxvt_term::pointer_blank () |
1110 | rxvt_term::pointer_blank () |
1088 | { |
1111 | { |
1089 | if (! (options & Opt_pointerBlank)) |
1112 | if (! (options & Opt_pointerBlank)) |
1090 | return; |
1113 | return; |
1091 | |
1114 | |
1092 | XDefineCursor (display->display, TermWin.vt, blank_cursor); |
1115 | XDefineCursor (display->display, TermWin.vt, display->blank_cursor); |
1093 | XFlush (display->display); |
1116 | XFlush (display->display); |
1094 | |
1117 | |
1095 | hidden_pointer = 1; |
1118 | hidden_pointer = 1; |
1096 | } |
1119 | } |
1097 | |
1120 | |
… | |
… | |
1186 | |
1209 | |
1187 | /*{{{ process an X event */ |
1210 | /*{{{ process an X event */ |
1188 | void |
1211 | void |
1189 | rxvt_term::x_cb (XEvent &ev) |
1212 | rxvt_term::x_cb (XEvent &ev) |
1190 | { |
1213 | { |
|
|
1214 | dDisp; |
|
|
1215 | |
1191 | SET_R (this); |
1216 | SET_R (this); |
1192 | SET_LOCALE (locale); |
1217 | SET_LOCALE (locale); |
1193 | |
1218 | |
1194 | #if defined(CURSOR_BLINK) |
1219 | #if defined(CURSOR_BLINK) |
1195 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
1220 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
… | |
… | |
1216 | if (ev.type == KeyPress && hidden_pointer == 0) |
1241 | if (ev.type == KeyPress && hidden_pointer == 0) |
1217 | pointer_blank (); |
1242 | pointer_blank (); |
1218 | } |
1243 | } |
1219 | #endif |
1244 | #endif |
1220 | |
1245 | |
1221 | #ifdef USE_XIM |
|
|
1222 | if (XFilterEvent (&ev, None)) |
|
|
1223 | return; |
|
|
1224 | #endif |
|
|
1225 | |
|
|
1226 | Window unused_root, unused_child; |
1246 | Window unused_root, unused_child; |
1227 | int unused_root_x, unused_root_y; |
1247 | int unused_root_x, unused_root_y; |
1228 | unsigned int unused_mask; |
1248 | unsigned int unused_mask; |
1229 | |
1249 | |
1230 | switch (ev.type) |
1250 | switch (ev.type) |
1231 | { |
1251 | { |
1232 | case KeyPress: |
1252 | case KeyPress: |
1233 | #if ISO_14755 |
1253 | #if ISO_14755 |
… | |
… | |
1316 | button_release (ev.xbutton); |
1336 | button_release (ev.xbutton); |
1317 | break; |
1337 | break; |
1318 | |
1338 | |
1319 | case ClientMessage: |
1339 | case ClientMessage: |
1320 | if (ev.xclient.format == 32 |
1340 | if (ev.xclient.format == 32 |
|
|
1341 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1342 | { |
1321 | && (Atom)ev.xclient.data.l[0] == xa[XA_WMDELETEWINDOW]) |
1343 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1322 | destroy (); |
1344 | destroy (); |
|
|
1345 | #if ENABLE_EWMH |
|
|
1346 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
|
|
1347 | XSendEvent (disp, ev.xclient.window = display->root, |
|
|
1348 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
|
|
1349 | &ev); |
|
|
1350 | #endif |
|
|
1351 | } |
|
|
1352 | #if ENABLE_XEMBED |
|
|
1353 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1354 | { |
|
|
1355 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1356 | focus_in (); |
|
|
1357 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1358 | focus_out (); |
|
|
1359 | } |
|
|
1360 | #endif |
1323 | #ifdef OFFIX_DND |
1361 | #ifdef OFFIX_DND |
1324 | /* OffiX Dnd (drag 'n' drop) protocol */ |
1362 | /* OffiX Dnd (drag 'n' drop) protocol */ |
1325 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
1363 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
1326 | && (ev.xclient.data.l[0] == DndFile |
1364 | && (ev.xclient.data.l[0] == DndFile |
1327 | || ev.xclient.data.l[0] == DndDir |
1365 | || ev.xclient.data.l[0] == DndDir |
1328 | || ev.xclient.data.l[0] == DndLink)) |
1366 | || ev.xclient.data.l[0] == DndLink)) |
1329 | { |
1367 | { |
1330 | /* Get Dnd data */ |
1368 | /* Get Dnd data */ |
1331 | Atom ActualType; |
1369 | Atom ActualType; |
1332 | int ActualFormat; |
1370 | int ActualFormat; |
1333 | unsigned char *data; |
1371 | unsigned char *data; |
1334 | unsigned long Size, RemainingBytes; |
1372 | unsigned long Size, RemainingBytes; |
1335 | |
1373 | |
1336 | XGetWindowProperty (display->display, display->root, |
1374 | XGetWindowProperty (disp, display->root, |
1337 | xa[XA_DNDSELECTION], |
1375 | xa[XA_DNDSELECTION], |
1338 | 0L, 1000000L, |
1376 | 0L, 1000000L, |
1339 | False, AnyPropertyType, |
1377 | False, AnyPropertyType, |
1340 | &ActualType, &ActualFormat, |
1378 | &ActualType, &ActualFormat, |
1341 | &Size, &RemainingBytes, |
1379 | &Size, &RemainingBytes, |
1342 | &data); |
1380 | &data); |
1343 | XChangeProperty (display->display, display->root, |
1381 | set_string_property (XA_CUT_BUFFER0, data); |
1344 | XA_CUT_BUFFER0, XA_STRING, |
|
|
1345 | 8, PropModeReplace, |
|
|
1346 | data, strlen (data)); |
|
|
1347 | XFree (data); |
1382 | XFree (data); |
1348 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1383 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
1349 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1384 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
1350 | } |
1385 | } |
1351 | #endif /* OFFIX_DND */ |
1386 | #endif /* OFFIX_DND */ |
1352 | break; |
1387 | break; |
1353 | |
1388 | |
1354 | case MappingNotify: |
1389 | case MappingNotify: |
… | |
… | |
1379 | break; |
1414 | break; |
1380 | } |
1415 | } |
1381 | break; |
1416 | break; |
1382 | |
1417 | |
1383 | case FocusIn: |
1418 | case FocusIn: |
1384 | if (!TermWin.focus) |
1419 | focus_in (); |
1385 | { |
|
|
1386 | TermWin.focus = 1; |
|
|
1387 | want_refresh = 1; |
|
|
1388 | #ifdef USE_XIM |
|
|
1389 | if (Input_Context != NULL) |
|
|
1390 | { |
|
|
1391 | IMSetStatusPosition (); |
|
|
1392 | XSetICFocus (Input_Context); |
|
|
1393 | } |
|
|
1394 | #endif |
|
|
1395 | #ifdef CURSOR_BLINK |
|
|
1396 | if (options & Opt_cursorBlink) |
|
|
1397 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1398 | #endif |
|
|
1399 | #ifdef OFF_FOCUS_FADING |
|
|
1400 | if (rs[Rs_fade]) |
|
|
1401 | { |
|
|
1402 | pix_colors = pix_colors_focused; |
|
|
1403 | scr_recolour (); |
|
|
1404 | } |
|
|
1405 | #endif |
|
|
1406 | |
|
|
1407 | } |
|
|
1408 | break; |
1420 | break; |
1409 | |
1421 | |
1410 | case FocusOut: |
1422 | case FocusOut: |
1411 | if (TermWin.focus) |
1423 | focus_out (); |
1412 | { |
|
|
1413 | TermWin.focus = 0; |
|
|
1414 | want_refresh = 1; |
|
|
1415 | |
|
|
1416 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1417 | iso14755buf = 0; |
|
|
1418 | #endif |
|
|
1419 | #if ENABLE_OVERLAY |
|
|
1420 | scr_overlay_off (); |
|
|
1421 | #endif |
|
|
1422 | #ifdef USE_XIM |
|
|
1423 | if (Input_Context != NULL) |
|
|
1424 | XUnsetICFocus (Input_Context); |
|
|
1425 | #endif |
|
|
1426 | #ifdef CURSOR_BLINK |
|
|
1427 | if (options & Opt_cursorBlink) |
|
|
1428 | cursor_blink_ev.stop (); |
|
|
1429 | hidden_cursor = 0; |
|
|
1430 | #endif |
|
|
1431 | #ifdef OFF_FOCUS_FADING |
|
|
1432 | if (rs[Rs_fade]) |
|
|
1433 | { |
|
|
1434 | pix_colors = pix_colors_unfocused; |
|
|
1435 | scr_recolour (); |
|
|
1436 | } |
|
|
1437 | #endif |
|
|
1438 | } |
|
|
1439 | break; |
1424 | break; |
1440 | |
1425 | |
1441 | case ConfigureNotify: |
1426 | case ConfigureNotify: |
1442 | if (ev.xconfigure.window == TermWin.parent[0]) |
1427 | if (ev.xconfigure.window == TermWin.parent[0]) |
1443 | { |
1428 | { |
… | |
… | |
1447 | { /* Wrap lots of configures into one */ |
1432 | { /* Wrap lots of configures into one */ |
1448 | width = ev.xconfigure.width; |
1433 | width = ev.xconfigure.width; |
1449 | height = ev.xconfigure.height; |
1434 | height = ev.xconfigure.height; |
1450 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1435 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1451 | } |
1436 | } |
1452 | while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); |
1437 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)); |
1453 | |
1438 | |
1454 | if (szHint.width != width || szHint.height != height) |
1439 | if (szHint.width != width || szHint.height != height) |
1455 | { |
1440 | { |
1456 | seen_resize = 1; |
1441 | seen_resize = 1; |
1457 | resize_all_windows (width, height, 1); |
1442 | resize_all_windows (width, height, 1); |
1458 | } |
1443 | } |
1459 | |
1444 | |
1460 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1445 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1461 | if (options & Opt_transparent) |
1446 | if (options & Opt_transparent) |
1462 | { |
|
|
1463 | check_our_parents (); |
1447 | check_our_parents (); |
1464 | if (am_transparent) |
|
|
1465 | want_refresh = want_full_refresh = 1; |
|
|
1466 | } |
|
|
1467 | #endif |
1448 | #endif |
1468 | } |
1449 | } |
1469 | break; |
1450 | break; |
1470 | |
1451 | |
1471 | case PropertyNotify: |
1452 | case PropertyNotify: |
… | |
… | |
1479 | selection_clear (); |
1460 | selection_clear (); |
1480 | break; |
1461 | break; |
1481 | |
1462 | |
1482 | case SelectionNotify: |
1463 | case SelectionNotify: |
1483 | if (selection_wait == Sel_normal) |
1464 | if (selection_wait == Sel_normal) |
1484 | selection_paste (ev.xselection.requestor, |
1465 | selection_paste (ev.xselection.requestor, ev.xselection.property, true); |
1485 | ev.xselection.property, True); |
|
|
1486 | break; |
1466 | break; |
1487 | |
1467 | |
1488 | case SelectionRequest: |
1468 | case SelectionRequest: |
1489 | selection_send (ev.xselectionrequest); |
1469 | selection_send (ev.xselectionrequest); |
1490 | break; |
1470 | break; |
… | |
… | |
1514 | if (ev.xany.window == TermWin.vt) |
1494 | if (ev.xany.window == TermWin.vt) |
1515 | { |
1495 | { |
1516 | do |
1496 | do |
1517 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1497 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1518 | ev.xexpose.width, ev.xexpose.height, False); |
1498 | ev.xexpose.width, ev.xexpose.height, False); |
1519 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)); |
1499 | while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev)); |
1520 | |
1500 | |
1521 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1501 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1522 | |
1502 | |
1523 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)) |
1503 | while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev)) |
1524 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1504 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1525 | ev.xexpose.width, ev.xexpose.height, False); |
1505 | ev.xexpose.width, ev.xexpose.height, False); |
1526 | |
1506 | |
1527 | scr_refresh (refresh_type); |
1507 | scr_refresh (refresh_type); |
1528 | } |
1508 | } |
1529 | else |
1509 | else |
1530 | { |
1510 | { |
1531 | XEvent unused_event; |
1511 | XEvent unused_event; |
1532 | |
1512 | |
1533 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, Expose, &unused_event)) |
1513 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1534 | ; |
1514 | ; |
1535 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, GraphicsExpose, &unused_event)) |
1515 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1536 | ; |
1516 | ; |
1537 | |
1517 | |
1538 | if (isScrollbarWindow (ev.xany.window)) |
1518 | if (isScrollbarWindow (ev.xany.window)) |
1539 | { |
1519 | { |
1540 | scrollBar.setIdle (); |
1520 | scrollBar.setIdle (); |
… | |
… | |
1545 | menubar_expose (); |
1525 | menubar_expose (); |
1546 | #endif |
1526 | #endif |
1547 | |
1527 | |
1548 | #ifdef TRANSPARENT |
1528 | #ifdef TRANSPARENT |
1549 | if (am_transparent && ev.xany.window == TermWin.parent[0]) |
1529 | if (am_transparent && ev.xany.window == TermWin.parent[0]) |
1550 | XClearWindow (display->display, ev.xany.window); |
1530 | XClearWindow (disp, ev.xany.window); |
1551 | #endif |
1531 | #endif |
1552 | } |
1532 | } |
1553 | break; |
1533 | break; |
1554 | |
1534 | |
1555 | case MotionNotify: |
1535 | case MotionNotify: |
… | |
… | |
1562 | { |
1542 | { |
1563 | menubar_control (ev.xbutton); |
1543 | menubar_control (ev.xbutton); |
1564 | break; |
1544 | break; |
1565 | } |
1545 | } |
1566 | #endif |
1546 | #endif |
1567 | if ((priv_modes & PrivMode_mouse_report) && ! (bypass_keystate)) |
1547 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1568 | break; |
1548 | break; |
1569 | |
1549 | |
1570 | if (ev.xany.window == TermWin.vt) |
1550 | if (ev.xany.window == TermWin.vt) |
1571 | { |
1551 | { |
1572 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1552 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1573 | { |
1553 | { |
1574 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, MotionNotify, &ev)) |
1554 | while (XCheckTypedWindowEvent (disp, TermWin.vt, MotionNotify, &ev)) |
1575 | ; |
1555 | ; |
1576 | |
1556 | |
1577 | XQueryPointer (display->display, TermWin.vt, |
1557 | XQueryPointer (disp, TermWin.vt, |
1578 | &unused_root, &unused_child, |
1558 | &unused_root, &unused_child, |
1579 | &unused_root_x, &unused_root_y, |
1559 | &unused_root_x, &unused_root_y, |
1580 | & (ev.xbutton.x), & (ev.xbutton.y), |
1560 | &ev.xbutton.x, &ev.xbutton.y, |
1581 | &unused_mask); |
1561 | &ev.xbutton.state); |
1582 | #ifdef MOUSE_THRESHOLD |
1562 | #ifdef MOUSE_THRESHOLD |
1583 | /* deal with a `jumpy' mouse */ |
1563 | /* deal with a `jumpy' mouse */ |
1584 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1564 | if ((ev.xmotion.time - MEvent.time) > MOUSE_THRESHOLD) |
1585 | { |
1565 | { |
1586 | #endif |
1566 | #endif |
… | |
… | |
1591 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1571 | iso14755_54 (ev.xbutton.x, ev.xbutton.y); |
1592 | break; |
1572 | break; |
1593 | } |
1573 | } |
1594 | #endif |
1574 | #endif |
1595 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1575 | selection_extend (ev.xbutton.x, ev.xbutton.y, |
1596 | (ev.xbutton.state & Button3Mask) ? 2 : 0); |
1576 | ev.xbutton.state & Button3Mask ? 2 : 0); |
|
|
1577 | |
1597 | #ifdef SELECTION_SCROLLING |
1578 | #ifdef SELECTION_SCROLLING |
1598 | if (ev.xbutton.y < TermWin.int_bwidth |
1579 | if (ev.xbutton.y < TermWin.int_bwidth |
1599 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1580 | || Pixel2Row (ev.xbutton.y) > (TermWin.nrow-1)) |
1600 | { |
1581 | { |
1601 | int dist; |
1582 | int dist; |
… | |
… | |
1612 | selection_save_x = ev.xbutton.x; |
1593 | selection_save_x = ev.xbutton.x; |
1613 | selection_save_y = ev.xbutton.y; |
1594 | selection_save_y = ev.xbutton.y; |
1614 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1595 | selection_save_state = (ev.xbutton.state & Button3Mask) ? 2 : 0; |
1615 | |
1596 | |
1616 | /* calc number of lines to scroll */ |
1597 | /* calc number of lines to scroll */ |
1617 | if (ev.xbutton.y<TermWin.int_bwidth) |
1598 | if (ev.xbutton.y < TermWin.int_bwidth) |
1618 | { |
1599 | { |
1619 | scroll_selection_dir = UP; |
1600 | scroll_selection_dir = UP; |
1620 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1601 | dist = TermWin.int_bwidth - ev.xbutton.y; |
1621 | } |
1602 | } |
1622 | else |
1603 | else |
… | |
… | |
1645 | #endif |
1626 | #endif |
1646 | } |
1627 | } |
1647 | } |
1628 | } |
1648 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1629 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1649 | { |
1630 | { |
1650 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1631 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1651 | MotionNotify, &ev)) ; |
1632 | MotionNotify, &ev)) |
|
|
1633 | ; |
|
|
1634 | |
1652 | XQueryPointer (display->display, scrollBar.win, |
1635 | XQueryPointer (disp, scrollBar.win, |
1653 | &unused_root, &unused_child, |
1636 | &unused_root, &unused_child, |
1654 | &unused_root_x, &unused_root_y, |
1637 | &unused_root_x, &unused_root_y, |
1655 | & (ev.xbutton.x), & (ev.xbutton.y), |
1638 | &ev.xbutton.x, &ev.xbutton.y, |
1656 | &unused_mask); |
1639 | &unused_mask); |
1657 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1640 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1658 | scrollbar_size ()); |
1641 | scrollbar_size ()); |
1659 | scr_refresh (refresh_type); |
1642 | scr_refresh (refresh_type); |
1660 | refresh_limit = 0; |
1643 | refresh_limit = 0; |
… | |
… | |
1662 | } |
1645 | } |
1663 | break; |
1646 | break; |
1664 | } |
1647 | } |
1665 | } |
1648 | } |
1666 | |
1649 | |
|
|
1650 | void |
|
|
1651 | rxvt_term::focus_in () |
|
|
1652 | { |
|
|
1653 | if (!TermWin.focus) |
|
|
1654 | { |
|
|
1655 | TermWin.focus = 1; |
|
|
1656 | want_refresh = 1; |
|
|
1657 | #ifdef USE_XIM |
|
|
1658 | if (Input_Context != NULL) |
|
|
1659 | { |
|
|
1660 | IMSetStatusPosition (); |
|
|
1661 | XSetICFocus (Input_Context); |
|
|
1662 | } |
|
|
1663 | #endif |
|
|
1664 | #ifdef CURSOR_BLINK |
|
|
1665 | if (options & Opt_cursorBlink) |
|
|
1666 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1667 | #endif |
|
|
1668 | #ifdef OFF_FOCUS_FADING |
|
|
1669 | if (rs[Rs_fade]) |
|
|
1670 | { |
|
|
1671 | pix_colors = pix_colors_focused; |
|
|
1672 | scr_recolour (); |
|
|
1673 | } |
|
|
1674 | #endif |
|
|
1675 | } |
|
|
1676 | } |
|
|
1677 | |
|
|
1678 | void |
|
|
1679 | rxvt_term::focus_out () |
|
|
1680 | { |
|
|
1681 | if (TermWin.focus) |
|
|
1682 | { |
|
|
1683 | TermWin.focus = 0; |
|
|
1684 | want_refresh = 1; |
|
|
1685 | |
|
|
1686 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1687 | iso14755buf = 0; |
|
|
1688 | #endif |
|
|
1689 | #if ENABLE_OVERLAY |
|
|
1690 | scr_overlay_off (); |
|
|
1691 | #endif |
|
|
1692 | #ifdef USE_XIM |
|
|
1693 | if (Input_Context != NULL) |
|
|
1694 | XUnsetICFocus (Input_Context); |
|
|
1695 | #endif |
|
|
1696 | #ifdef CURSOR_BLINK |
|
|
1697 | if (options & Opt_cursorBlink) |
|
|
1698 | cursor_blink_ev.stop (); |
|
|
1699 | hidden_cursor = 0; |
|
|
1700 | #endif |
|
|
1701 | #ifdef OFF_FOCUS_FADING |
|
|
1702 | if (rs[Rs_fade]) |
|
|
1703 | { |
|
|
1704 | pix_colors = pix_colors_unfocused; |
|
|
1705 | scr_recolour (); |
|
|
1706 | } |
|
|
1707 | #endif |
|
|
1708 | } |
|
|
1709 | } |
|
|
1710 | |
1667 | #if TRANSPARENT |
1711 | #if TRANSPARENT |
1668 | void |
1712 | void |
1669 | rxvt_term::rootwin_cb (XEvent &ev) |
1713 | rxvt_term::rootwin_cb (XEvent &ev) |
1670 | { |
1714 | { |
1671 | SET_R (this); |
1715 | SET_R (this); |
… | |
… | |
1676 | case PropertyNotify: |
1720 | case PropertyNotify: |
1677 | /* |
1721 | /* |
1678 | * if user used some Esetroot compatible prog to set the root bg, |
1722 | * if user used some Esetroot compatible prog to set the root bg, |
1679 | * use the property to determine the pixmap. We use it later on. |
1723 | * use the property to determine the pixmap. We use it later on. |
1680 | */ |
1724 | */ |
1681 | if (xa[XA_XROOTPMAPID] == 0) |
|
|
1682 | xa[XA_XROOTPMAPID] = XInternAtom (display->display, "_XROOTPMAP_ID", False); |
|
|
1683 | |
|
|
1684 | if (ev.xproperty.atom != xa[XA_XROOTPMAPID]) |
1725 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
|
|
1726 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1685 | return; |
1727 | return; |
1686 | |
1728 | |
1687 | /* FALLTHROUGH */ |
1729 | /* FALLTHROUGH */ |
1688 | case ReparentNotify: |
1730 | case ReparentNotify: |
1689 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
1731 | if ((options & Opt_transparent) && check_our_parents () && am_transparent) |
… | |
… | |
1715 | return; |
1757 | return; |
1716 | } |
1758 | } |
1717 | #endif |
1759 | #endif |
1718 | |
1760 | |
1719 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
1761 | clickintime = ev.time - MEvent.time < MULTICLICK_TIME; |
|
|
1762 | |
1720 | if (reportmode) |
1763 | if (reportmode) |
1721 | { |
1764 | { |
1722 | /* mouse report from vt window */ |
1765 | /* mouse report from vt window */ |
1723 | /* save the xbutton state (for ButtonRelease) */ |
1766 | /* save the xbutton state (for ButtonRelease) */ |
1724 | MEvent.state = ev.state; |
1767 | MEvent.state = ev.state; |
… | |
… | |
1753 | } |
1796 | } |
1754 | else |
1797 | else |
1755 | { |
1798 | { |
1756 | if (ev.button != MEvent.button) |
1799 | if (ev.button != MEvent.button) |
1757 | MEvent.clicks = 0; |
1800 | MEvent.clicks = 0; |
|
|
1801 | |
1758 | switch (ev.button) |
1802 | switch (ev.button) |
1759 | { |
1803 | { |
1760 | case Button1: |
1804 | case Button1: |
|
|
1805 | /* allow meta + click to select rectangular areas */ |
|
|
1806 | /* should be done in screen.C */ |
|
|
1807 | #if ENABLE_FRILLS |
|
|
1808 | selection.rect = !!(ev.state & ModMetaMask); |
|
|
1809 | #else |
|
|
1810 | selection.rect = false; |
|
|
1811 | #endif |
|
|
1812 | |
1761 | /* allow shift+left click to extend selection */ |
1813 | /* allow shift+left click to extend selection */ |
1762 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1814 | if (ev.state & ShiftMask && ! (priv_modes & PrivMode_mouse_report)) |
1763 | { |
1815 | { |
1764 | if (MEvent.button == Button1 && clickintime) |
1816 | if (MEvent.button == Button1 && clickintime) |
1765 | selection_rotate (ev.x, ev.y); |
1817 | selection_rotate (ev.x, ev.y); |
… | |
… | |
2087 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2139 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2088 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2140 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2089 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2141 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2090 | int i; |
2142 | int i; |
2091 | |
2143 | |
2092 | Visual* visual = display->visual; |
2144 | Visual *visual = display->visual; |
2093 | |
2145 | |
2094 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2146 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2095 | |
2147 | |
2096 | /* for convenience */ |
2148 | /* for convenience */ |
2097 | mask_r = visual->red_mask; |
2149 | mask_r = visual->red_mask; |
… | |
… | |
2318 | Atom atype; |
2370 | Atom atype; |
2319 | unsigned char *prop = NULL; |
2371 | unsigned char *prop = NULL; |
2320 | Window root, oldp, *list; |
2372 | Window root, oldp, *list; |
2321 | Pixmap rootpixmap = None; |
2373 | Pixmap rootpixmap = None; |
2322 | XWindowAttributes wattr, wrootattr; |
2374 | XWindowAttributes wattr, wrootattr; |
|
|
2375 | dDisp; |
2323 | |
2376 | |
2324 | pchanged = 0; |
2377 | pchanged = 0; |
2325 | |
2378 | |
2326 | if (!(options & Opt_transparent)) |
2379 | if (!(options & Opt_transparent)) |
2327 | return pchanged; /* Don't try any more */ |
2380 | return pchanged; /* Don't try any more */ |
2328 | |
2381 | |
2329 | XGetWindowAttributes (display->display, display->root, &wrootattr); |
2382 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2330 | rootdepth = wrootattr.depth; |
2383 | rootdepth = wrootattr.depth; |
2331 | |
2384 | |
2332 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
2385 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
2333 | |
2386 | |
2334 | if (rootdepth != wattr.depth) |
2387 | if (rootdepth != wattr.depth) |
2335 | { |
2388 | { |
2336 | if (am_transparent) |
2389 | if (am_transparent) |
2337 | { |
2390 | { |
2338 | pchanged = 1; |
2391 | pchanged = 1; |
2339 | XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]); |
2392 | XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]); |
2340 | am_transparent = am_pixmap_trans = 0; |
2393 | am_transparent = am_pixmap_trans = 0; |
2341 | } |
2394 | } |
2342 | |
2395 | |
2343 | return pchanged; /* Don't try any more */ |
2396 | return pchanged; /* Don't try any more */ |
2344 | } |
2397 | } |
2345 | |
2398 | |
2346 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2399 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2347 | XSync (display->display, False); |
2400 | XSync (disp, False); |
2348 | |
2401 | |
2349 | /* |
2402 | /* |
2350 | * Make the frame window set by the window manager have |
2403 | * Make the frame window set by the window manager have |
2351 | * the root background. Some window managers put multiple nested frame |
2404 | * the root background. Some window managers put multiple nested frame |
2352 | * windows for each client, so we have to take care about that. |
2405 | * windows for each client, so we have to take care about that. |
2353 | */ |
2406 | */ |
2354 | i = (xa[XA_XROOTPMAPID] |
2407 | i = (xa[XA_XROOTPMAP_ID] |
2355 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAPID], |
2408 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
2356 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2409 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2357 | &nitems, &bytes_after, &prop) == Success); |
2410 | &nitems, &bytes_after, &prop) == Success); |
2358 | |
2411 | |
2359 | if (!i || prop == NULL) |
2412 | if (!i || prop == NULL) |
2360 | i = (xa[XA_XSETROOTID] |
2413 | i = (xa[XA_ESETROOT_PMAP_ID] |
2361 | && XGetWindowProperty (display->display, display->root, xa[XA_XSETROOTID], |
2414 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2362 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2415 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2363 | &nitems, &bytes_after, &prop) == Success); |
2416 | &nitems, &bytes_after, &prop) == Success); |
2364 | |
2417 | |
2365 | if (!i || prop == NULL |
2418 | if (!i || prop == NULL |
2366 | #if TINTING |
2419 | #if TINTING |
… | |
… | |
2385 | Window cr; |
2438 | Window cr; |
2386 | XImage *image; |
2439 | XImage *image; |
2387 | GC gc; |
2440 | GC gc; |
2388 | XGCValues gcvalue; |
2441 | XGCValues gcvalue; |
2389 | |
2442 | |
2390 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
2443 | XTranslateCoordinates (disp, TermWin.parent[0], display->root, |
2391 | 0, 0, &sx, &sy, &cr); |
2444 | 0, 0, &sx, &sy, &cr); |
2392 | nw = (unsigned int)szHint.width; |
2445 | nw = (unsigned int)szHint.width; |
2393 | nh = (unsigned int)szHint.height; |
2446 | nh = (unsigned int)szHint.height; |
2394 | nx = ny = 0; |
2447 | nx = ny = 0; |
2395 | |
2448 | |
… | |
… | |
2407 | sy = 0; |
2460 | sy = 0; |
2408 | } |
2461 | } |
2409 | |
2462 | |
2410 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2463 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2411 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2464 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2465 | |
|
|
2466 | XSync (disp, False); |
2412 | allowedxerror = -1; |
2467 | allowedxerror = -1; |
2413 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2468 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2414 | |
2469 | |
2415 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2470 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2416 | /* XXX: may need a delay here? */ |
2471 | /* XXX: may need a delay here? */ |
2417 | allowedxerror = 0; |
2472 | allowedxerror = 0; |
2418 | |
2473 | |
… | |
… | |
2421 | if (am_transparent && am_pixmap_trans) |
2476 | if (am_transparent && am_pixmap_trans) |
2422 | { |
2477 | { |
2423 | pchanged = 1; |
2478 | pchanged = 1; |
2424 | if (TermWin.pixmap != None) |
2479 | if (TermWin.pixmap != None) |
2425 | { |
2480 | { |
2426 | XFreePixmap (display->display, TermWin.pixmap); |
2481 | XFreePixmap (disp, TermWin.pixmap); |
2427 | TermWin.pixmap = None; |
2482 | TermWin.pixmap = None; |
2428 | } |
2483 | } |
2429 | } |
2484 | } |
2430 | |
2485 | |
2431 | am_pixmap_trans = 0; |
2486 | am_pixmap_trans = 0; |
2432 | } |
2487 | } |
2433 | else |
2488 | else |
2434 | { |
2489 | { |
2435 | if (TermWin.pixmap != None) |
2490 | if (TermWin.pixmap != None) |
2436 | XFreePixmap (display->display, TermWin.pixmap); |
2491 | XFreePixmap (disp, TermWin.pixmap); |
2437 | |
2492 | |
2438 | #if TINTING |
2493 | #if TINTING |
2439 | if (ISSET_PIXCOLOR (Color_tint)) |
2494 | if (ISSET_PIXCOLOR (Color_tint)) |
2440 | { |
2495 | { |
2441 | unsigned short rm, gm, bm; |
2496 | unsigned short rm, gm, bm; |
… | |
… | |
2445 | |
2500 | |
2446 | ShadeXImage (display, image, shade, rm, gm, bm); |
2501 | ShadeXImage (display, image, shade, rm, gm, bm); |
2447 | } |
2502 | } |
2448 | #endif |
2503 | #endif |
2449 | |
2504 | |
2450 | TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, |
2505 | TermWin.pixmap = XCreatePixmap (disp, TermWin.vt, |
2451 | szHint.width, szHint.height, image->depth); |
2506 | szHint.width, szHint.height, image->depth); |
2452 | gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); |
2507 | gc = XCreateGC (disp, TermWin.vt, 0UL, &gcvalue); |
2453 | XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, |
2508 | XPutImage (disp, TermWin.pixmap, gc, image, 0, 0, |
2454 | nx, ny, image->width, image->height); |
2509 | nx, ny, image->width, image->height); |
2455 | XFreeGC (display->display, gc); |
2510 | XFreeGC (disp, gc); |
2456 | XDestroyImage (image); |
2511 | XDestroyImage (image); |
2457 | XSetWindowBackgroundPixmap (display->display, TermWin.parent[0], TermWin.pixmap); |
2512 | XSetWindowBackgroundPixmap (disp, TermWin.parent[0], TermWin.pixmap); |
2458 | XClearWindow (display->display, TermWin.parent[0]); |
2513 | XClearWindow (disp, TermWin.parent[0]); |
2459 | |
2514 | |
2460 | if (!am_transparent || !am_pixmap_trans) |
2515 | if (!am_transparent || !am_pixmap_trans) |
2461 | pchanged = 1; |
2516 | pchanged = 1; |
2462 | |
2517 | |
2463 | am_transparent = am_pixmap_trans = 1; |
2518 | am_transparent = am_pixmap_trans = 1; |
2464 | } |
2519 | } |
2465 | } |
2520 | } |
2466 | |
2521 | |
2467 | if (!am_pixmap_trans) |
2522 | if (am_pixmap_trans) |
|
|
2523 | XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative); |
|
|
2524 | else |
2468 | { |
2525 | { |
2469 | unsigned int n; |
2526 | unsigned int n; |
2470 | /* |
2527 | /* |
2471 | * InheritPixmap transparency |
2528 | * InheritPixmap transparency |
2472 | */ |
2529 | */ |
2473 | for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2530 | for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2474 | { |
2531 | { |
2475 | oldp = TermWin.parent[i]; |
2532 | oldp = TermWin.parent[i]; |
2476 | XQueryTree (display->display, TermWin.parent[i - 1], &root, |
2533 | XQueryTree (disp, TermWin.parent[i - 1], &root, |
2477 | &TermWin.parent[i], &list, &n); |
2534 | &TermWin.parent[i], &list, &n); |
2478 | XFree (list); |
2535 | XFree (list); |
2479 | |
2536 | |
2480 | if (TermWin.parent[i] == display->root) |
2537 | if (TermWin.parent[i] == display->root) |
2481 | { |
2538 | { |
… | |
… | |
2493 | |
2550 | |
2494 | if (pchanged) |
2551 | if (pchanged) |
2495 | { |
2552 | { |
2496 | for (; n < (unsigned int)i; n++) |
2553 | for (; n < (unsigned int)i; n++) |
2497 | { |
2554 | { |
2498 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
2555 | XGetWindowAttributes (disp, TermWin.parent[n], &wattr); |
2499 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2556 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2500 | { |
2557 | { |
2501 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2558 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2502 | break; |
2559 | break; |
2503 | } |
2560 | } |
2504 | } |
2561 | } |
2505 | } |
2562 | } |
2506 | |
2563 | |
2507 | if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) |
2564 | if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) |
2508 | { |
2565 | { |
2509 | XSetWindowBackground (display->display, TermWin.parent[0], pix_colors_focused[Color_fg]); |
2566 | XSetWindowBackground (disp, TermWin.parent[0], pix_colors_focused[Color_fg]); |
2510 | XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]); |
2567 | XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]); |
2511 | am_transparent = 0; |
2568 | am_transparent = 0; |
2512 | /* XXX: also turn off Opt_transparent? */ |
2569 | /* XXX: also turn off Opt_transparent? */ |
2513 | } |
2570 | } |
2514 | else |
2571 | else |
2515 | { |
2572 | { |
… | |
… | |
2518 | * needed for fvwm2.2.2 (and before?) */ |
2575 | * needed for fvwm2.2.2 (and before?) */ |
2519 | sleep (1); |
2576 | sleep (1); |
2520 | #endif |
2577 | #endif |
2521 | for (n = 0; n < (unsigned int)i; n++) |
2578 | for (n = 0; n < (unsigned int)i; n++) |
2522 | { |
2579 | { |
2523 | XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); |
2580 | XSetWindowBackgroundPixmap (disp, TermWin.parent[n], ParentRelative); |
2524 | XClearWindow (display->display, TermWin.parent[n]); |
2581 | XClearWindow (disp, TermWin.parent[n]); |
2525 | } |
2582 | } |
2526 | |
2583 | |
2527 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
2584 | XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative); |
2528 | am_transparent = 1; |
2585 | am_transparent = 1; |
2529 | } |
2586 | } |
2530 | |
2587 | |
2531 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2588 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2532 | TermWin.parent[i] = None; |
2589 | TermWin.parent[i] = None; |
2533 | } |
2590 | } |
2534 | |
2591 | |
2535 | if (scrollBar.win) |
2592 | if (scrollBar.win) |
2536 | { |
2593 | { |
2537 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2594 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
2538 | scrollBar.setIdle (); |
2595 | scrollBar.setIdle (); |
2539 | scrollbar_show (0); |
2596 | scrollbar_show (0); |
|
|
2597 | } |
|
|
2598 | |
|
|
2599 | if (am_transparent) |
|
|
2600 | { |
|
|
2601 | want_refresh = want_full_refresh = 1; |
|
|
2602 | if (am_pixmap_trans) |
|
|
2603 | flush (); |
2540 | } |
2604 | } |
2541 | |
2605 | |
2542 | return pchanged; |
2606 | return pchanged; |
2543 | } |
2607 | } |
2544 | #endif |
2608 | #endif |
… | |
… | |
2573 | // some window managers resize the window early, and these programs |
2637 | // some window managers resize the window early, and these programs |
2574 | // then sometimes get the size wrong. |
2638 | // then sometimes get the size wrong. |
2575 | // unfortunately other programs are even more buggy and dislike |
2639 | // unfortunately other programs are even more buggy and dislike |
2576 | // being sent SIGWINCH, so only do it when we were in fact being |
2640 | // being sent SIGWINCH, so only do it when we were in fact being |
2577 | // resized. |
2641 | // resized. |
2578 | if (seen_resize) |
2642 | if (seen_resize && cmd_pid) |
2579 | kill (-cmd_pid, SIGWINCH); |
2643 | kill (-cmd_pid, SIGWINCH); |
2580 | } |
2644 | } |
2581 | |
2645 | |
2582 | /* Read a text string from the input buffer */ |
2646 | /* Read a text string from the input buffer */ |
2583 | unicode_t buf[UBUFSIZ]; |
2647 | unicode_t buf[UBUFSIZ]; |
2584 | bool refreshnow = false; |
2648 | bool refreshnow = false; |
2585 | int nlines = 0; |
2649 | int nlines = 0; |
2586 | unicode_t *str = buf; |
2650 | unicode_t *str = buf; |
|
|
2651 | unicode_t *eol = str + min (TermWin.ncol, UBUFSIZ); |
2587 | |
2652 | |
2588 | for (;;) |
2653 | for (;;) |
2589 | { |
2654 | { |
2590 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2655 | if (ch == NOCHAR || (IS_CONTROL (ch) && ch != C0_LF && ch != C0_CR && ch != C0_HT)) |
2591 | break; |
2656 | break; |
2592 | |
2657 | |
2593 | *str++ = ch; |
2658 | *str++ = ch; |
2594 | |
2659 | |
2595 | if (ch == C0_LF) |
2660 | if (ch == C0_LF || str >= eol) |
2596 | { |
2661 | { |
|
|
2662 | if (ch == C0_LF) |
2597 | nlines++; |
2663 | nlines++; |
|
|
2664 | |
2598 | refresh_count++; |
2665 | refresh_count++; |
2599 | |
2666 | |
2600 | if (!(options & Opt_jumpScroll) |
2667 | if (!(options & Opt_jumpScroll) |
2601 | || (refresh_count >= refresh_limit * (TermWin.nrow - 1))) |
2668 | || (refresh_count >= refresh_limit * (TermWin.nrow - 1))) |
2602 | { |
2669 | { |
… | |
… | |
2609 | if (nlines >= TermWin.nrow - 1) |
2676 | if (nlines >= TermWin.nrow - 1) |
2610 | { |
2677 | { |
2611 | scr_add_lines (buf, nlines, str - buf); |
2678 | scr_add_lines (buf, nlines, str - buf); |
2612 | nlines = 0; |
2679 | nlines = 0; |
2613 | str = buf; |
2680 | str = buf; |
|
|
2681 | eol = str + min (TermWin.ncol, UBUFSIZ); |
2614 | } |
2682 | } |
2615 | } |
|
|
2616 | |
2683 | |
2617 | if (str >= buf + UBUFSIZ) |
2684 | if (str >= eol) |
2618 | { |
2685 | { |
|
|
2686 | if (eol >= buf + UBUFSIZ) |
|
|
2687 | { |
2619 | ch = NOCHAR; |
2688 | ch = NOCHAR; |
2620 | break; |
2689 | break; |
|
|
2690 | } |
|
|
2691 | else |
|
|
2692 | eol = min (eol + TermWin.ncol, buf + UBUFSIZ); |
|
|
2693 | } |
|
|
2694 | |
2621 | } |
2695 | } |
2622 | |
2696 | |
2623 | seq_begin = cmdbuf_ptr; |
2697 | seq_begin = cmdbuf_ptr; |
2624 | ch = next_char (); |
2698 | ch = next_char (); |
2625 | } |
2699 | } |
… | |
… | |
2696 | if (len == (size_t)-1) |
2770 | if (len == (size_t)-1) |
2697 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2771 | return *cmdbuf_ptr++; // the _occasional_ latin1 character is allowed to slip through |
2698 | |
2772 | |
2699 | // assume wchar == unicode |
2773 | // assume wchar == unicode |
2700 | cmdbuf_ptr += len; |
2774 | cmdbuf_ptr += len; |
2701 | return wc; |
2775 | return wc & UNICODE_MASK; |
2702 | } |
2776 | } |
2703 | |
2777 | |
2704 | return NOCHAR; |
2778 | return NOCHAR; |
2705 | } |
2779 | } |
2706 | |
2780 | |
… | |
… | |
3169 | { |
3243 | { |
3170 | switch (priv) |
3244 | switch (priv) |
3171 | { |
3245 | { |
3172 | case '>': |
3246 | case '>': |
3173 | if (ch == CSI_DA) /* secondary device attributes */ |
3247 | if (ch == CSI_DA) /* secondary device attributes */ |
3174 | tt_printf ("\033[>%d;%-.8s;0c", 'R', VSTRING); |
3248 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3175 | break; |
3249 | break; |
3176 | case '?': |
3250 | case '?': |
3177 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3251 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3178 | process_terminal_mode (ch, priv, nargs, arg); |
3252 | process_terminal_mode (ch, priv, nargs, arg); |
3179 | break; |
3253 | break; |
… | |
… | |
3408 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3482 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3409 | { |
3483 | { |
3410 | int x, y; |
3484 | int x, y; |
3411 | XWindowAttributes wattr; |
3485 | XWindowAttributes wattr; |
3412 | Window wdummy; |
3486 | Window wdummy; |
|
|
3487 | dDisp; |
3413 | |
3488 | |
3414 | if (nargs == 0) |
3489 | if (nargs == 0) |
3415 | return; |
3490 | return; |
3416 | |
3491 | |
3417 | switch (args[0]) |
3492 | switch (args[0]) |
3418 | { |
3493 | { |
3419 | /* |
3494 | /* |
3420 | * commands |
3495 | * commands |
3421 | */ |
3496 | */ |
3422 | case 1: /* deiconify window */ |
3497 | case 1: /* deiconify window */ |
3423 | XMapWindow (display->display, TermWin.parent[0]); |
3498 | XMapWindow (disp, TermWin.parent[0]); |
3424 | break; |
3499 | break; |
3425 | case 2: /* iconify window */ |
3500 | case 2: /* iconify window */ |
3426 | XIconifyWindow (display->display, TermWin.parent[0], |
3501 | XIconifyWindow (disp, TermWin.parent[0], display->screen); |
3427 | DefaultScreen (display->display)); |
|
|
3428 | break; |
3502 | break; |
3429 | case 3: /* set position (pixels) */ |
3503 | case 3: /* set position (pixels) */ |
3430 | XMoveWindow (display->display, TermWin.parent[0], args[1], args[2]); |
3504 | XMoveWindow (disp, TermWin.parent[0], args[1], args[2]); |
3431 | break; |
3505 | break; |
3432 | case 4: /* set size (pixels) */ |
3506 | case 4: /* set size (pixels) */ |
3433 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3507 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3434 | break; |
3508 | break; |
3435 | case 5: /* raise window */ |
3509 | case 5: /* raise window */ |
3436 | XRaiseWindow (display->display, TermWin.parent[0]); |
3510 | XRaiseWindow (disp, TermWin.parent[0]); |
3437 | break; |
3511 | break; |
3438 | case 6: /* lower window */ |
3512 | case 6: /* lower window */ |
3439 | XLowerWindow (display->display, TermWin.parent[0]); |
3513 | XLowerWindow (disp, TermWin.parent[0]); |
3440 | break; |
3514 | break; |
3441 | case 7: /* refresh window */ |
3515 | case 7: /* refresh window */ |
3442 | scr_touch (true); |
3516 | scr_touch (true); |
3443 | break; |
3517 | break; |
3444 | case 8: /* set size (chars) */ |
3518 | case 8: /* set size (chars) */ |
… | |
… | |
3456 | |
3530 | |
3457 | /* |
3531 | /* |
3458 | * reports - some output format copied from XTerm |
3532 | * reports - some output format copied from XTerm |
3459 | */ |
3533 | */ |
3460 | case 11: /* report window state */ |
3534 | case 11: /* report window state */ |
3461 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3535 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3462 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3536 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3463 | break; |
3537 | break; |
3464 | case 13: /* report window position */ |
3538 | case 13: /* report window position */ |
3465 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3539 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3466 | XTranslateCoordinates (display->display, TermWin.parent[0], wattr.root, |
3540 | XTranslateCoordinates (disp, TermWin.parent[0], wattr.root, |
3467 | -wattr.border_width, -wattr.border_width, |
3541 | -wattr.border_width, -wattr.border_width, |
3468 | &x, &y, &wdummy); |
3542 | &x, &y, &wdummy); |
3469 | tt_printf ("\033[3;%d;%dt", x, y); |
3543 | tt_printf ("\033[3;%d;%dt", x, y); |
3470 | break; |
3544 | break; |
3471 | case 14: /* report window size (pixels) */ |
3545 | case 14: /* report window size (pixels) */ |
3472 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3546 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3473 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3547 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3474 | break; |
3548 | break; |
3475 | case 18: /* report text area size (chars) */ |
3549 | case 18: /* report text area size (chars) */ |
3476 | tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); |
3550 | tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); |
3477 | break; |
3551 | break; |
… | |
… | |
3479 | tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); |
3553 | tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); |
3480 | break; |
3554 | break; |
3481 | case 20: /* report icon label */ |
3555 | case 20: /* report icon label */ |
3482 | { |
3556 | { |
3483 | char *s; |
3557 | char *s; |
3484 | XGetIconName (display->display, TermWin.parent[0], &s); |
3558 | XGetIconName (disp, TermWin.parent[0], &s); |
3485 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3559 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3486 | XFree (s); |
3560 | XFree (s); |
3487 | } |
3561 | } |
3488 | break; |
3562 | break; |
3489 | case 21: /* report window title */ |
3563 | case 21: /* report window title */ |
3490 | { |
3564 | { |
3491 | char *s; |
3565 | char *s; |
3492 | XFetchName (display->display, TermWin.parent[0], &s); |
3566 | XFetchName (disp, TermWin.parent[0], &s); |
3493 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3567 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3494 | XFree (s); |
3568 | XFree (s); |
3495 | } |
3569 | } |
3496 | break; |
3570 | break; |
3497 | } |
3571 | } |
… | |
… | |
3504 | * ends_how is terminator used. returned input must be free()'d |
3578 | * ends_how is terminator used. returned input must be free()'d |
3505 | */ |
3579 | */ |
3506 | unsigned char * |
3580 | unsigned char * |
3507 | rxvt_term::get_to_st (unicode_t &ends_how) |
3581 | rxvt_term::get_to_st (unicode_t &ends_how) |
3508 | { |
3582 | { |
3509 | unicode_t seen_esc = 0, ch; |
3583 | unicode_t ch; |
|
|
3584 | bool seen_esc = false; |
3510 | unsigned int n = 0; |
3585 | unsigned int n = 0; |
3511 | unsigned char *s; |
|
|
3512 | unsigned char string[STRING_MAX]; |
3586 | wchar_t string[STRING_MAX]; |
3513 | |
3587 | |
3514 | while ((ch = cmd_getc ()) != NOCHAR) |
3588 | while ((ch = cmd_getc ()) != NOCHAR) |
3515 | { |
3589 | { |
3516 | if (seen_esc) |
3590 | if (seen_esc) |
3517 | { |
3591 | { |
… | |
… | |
3520 | else |
3594 | else |
3521 | return NULL; |
3595 | return NULL; |
3522 | } |
3596 | } |
3523 | else if (ch == C0_ESC) |
3597 | else if (ch == C0_ESC) |
3524 | { |
3598 | { |
3525 | seen_esc = 1; |
3599 | seen_esc = true; |
3526 | continue; |
3600 | continue; |
3527 | } |
3601 | } |
3528 | else if (ch == C0_BEL || ch == CHAR_ST) |
3602 | else if (ch == C0_BEL || ch == CHAR_ST) |
3529 | break; |
3603 | break; |
3530 | else if (ch < 0x20) |
3604 | else if (ch < 0x20) |
3531 | return NULL; /* other control character - exit */ |
3605 | return NULL; /* other control character - exit */ |
3532 | |
3606 | |
3533 | seen_esc = 0; |
3607 | seen_esc = false; |
3534 | |
3608 | |
3535 | if (n >= sizeof (string) - 1) |
3609 | if (n >= STRING_MAX - 1) |
3536 | // stop at some sane length |
3610 | // stop at some sane length |
3537 | return NULL; |
3611 | return NULL; |
3538 | |
3612 | |
3539 | if (ch == C0_SYN) |
3613 | if (ch == C0_SYN) |
3540 | string[n++] = cmd_get8 (); |
3614 | string[n++] = cmd_get8 (); |
… | |
… | |
3542 | string[n++] = ch; |
3616 | string[n++] = ch; |
3543 | } |
3617 | } |
3544 | |
3618 | |
3545 | string[n++] = '\0'; |
3619 | string[n++] = '\0'; |
3546 | |
3620 | |
3547 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
|
|
3548 | return NULL; |
|
|
3549 | |
|
|
3550 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3621 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3551 | strncpy (s, string, n); |
3622 | |
3552 | return s; |
3623 | return (unsigned char *)rxvt_wcstombs (string); |
3553 | } |
3624 | } |
3554 | |
3625 | |
3555 | /*----------------------------------------------------------------------*/ |
3626 | /*----------------------------------------------------------------------*/ |
3556 | /* |
3627 | /* |
3557 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3628 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
… | |
… | |
3611 | set_window_color (color, str); |
3682 | set_window_color (color, str); |
3612 | } |
3683 | } |
3613 | |
3684 | |
3614 | /* |
3685 | /* |
3615 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3686 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3616 | * 0 = change iconName/title |
|
|
3617 | * 1 = change iconName |
|
|
3618 | * 2 = change title |
|
|
3619 | * 4 = change color |
|
|
3620 | * 10 = change fg color |
|
|
3621 | * 11 = change bg color |
|
|
3622 | * 12 = change text color |
|
|
3623 | * 13 = change mouse foreground color |
|
|
3624 | * 17 = change highlight character colour |
|
|
3625 | * 18 = change bold character color |
|
|
3626 | * 19 = change underlined character color |
|
|
3627 | * 46 = change logfile (not implemented) |
|
|
3628 | * 50 = change font |
|
|
3629 | * |
|
|
3630 | * rxvt extensions: |
|
|
3631 | * 20 = bg pixmap |
|
|
3632 | * 39 = change default fg color |
|
|
3633 | * 49 = change default bg color |
|
|
3634 | * 55 = dump scrollback buffer and all of screen |
|
|
3635 | * 701 = change locale |
|
|
3636 | * 702 = find font |
|
|
3637 | * 703 = menu |
|
|
3638 | */ |
3687 | */ |
3639 | void |
3688 | void |
3640 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3689 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3641 | { |
3690 | { |
3642 | int changed = 0; |
3691 | int changed = 0; |
3643 | int color; |
3692 | int color; |
3644 | char *buf, *name; |
3693 | char *buf, *name; |
3645 | bool query = str[0] == '?' && !str[1]; |
3694 | bool query = str[0] == '?' && !str[1]; |
3646 | int saveop = op; |
3695 | int saveop = op; |
|
|
3696 | dDisp; |
3647 | |
3697 | |
3648 | assert (str != NULL); |
3698 | assert (str != NULL); |
3649 | switch (op) |
3699 | switch (op) |
3650 | { |
3700 | { |
3651 | case XTerm_name: |
3701 | case XTerm_name: |
… | |
… | |
3658 | set_title (str); |
3708 | set_title (str); |
3659 | break; |
3709 | break; |
3660 | case XTerm_property: |
3710 | case XTerm_property: |
3661 | if (str[0] == '?') |
3711 | if (str[0] == '?') |
3662 | { |
3712 | { |
3663 | Atom prop = XInternAtom (display->display, str + 1, True); |
3713 | Atom prop = display->atom (str + 1); |
3664 | Atom actual_type; |
3714 | Atom actual_type; |
3665 | int actual_format; |
3715 | int actual_format; |
3666 | unsigned long nitems; |
3716 | unsigned long nitems; |
3667 | unsigned long bytes_after; |
3717 | unsigned long bytes_after; |
3668 | unsigned char *value = 0; |
3718 | unsigned char *value = 0; |
3669 | const char *str = ""; |
3719 | const char *str = ""; |
3670 | |
3720 | |
3671 | if (prop |
3721 | if (prop |
3672 | && XGetWindowProperty (display->display, TermWin.parent[0], |
3722 | && XGetWindowProperty (disp, TermWin.parent[0], |
3673 | prop, 0, 1<<16, 0, AnyPropertyType, |
3723 | prop, 0, 1<<16, 0, AnyPropertyType, |
3674 | &actual_type, &actual_format, |
3724 | &actual_type, &actual_format, |
3675 | &nitems, &bytes_after, &value) == Success |
3725 | &nitems, &bytes_after, &value) == Success |
3676 | && actual_type != None |
3726 | && actual_type != None |
3677 | && actual_format == 8) |
3727 | && actual_format == 8) |
… | |
… | |
3686 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3736 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3687 | |
3737 | |
3688 | if (eq) |
3738 | if (eq) |
3689 | { |
3739 | { |
3690 | *eq = 0; |
3740 | *eq = 0; |
3691 | XChangeProperty (display->display, TermWin.parent[0], |
3741 | set_utf8_property (display->atom (str), eq + 1); |
3692 | display->atom (str), XA_STRING, 8, |
|
|
3693 | PropModeReplace, (unsigned char *)eq + 1, |
|
|
3694 | strlen (eq + 1)); |
|
|
3695 | } |
3742 | } |
3696 | else |
3743 | else |
3697 | XDeleteProperty (display->display, TermWin.parent[0], |
3744 | XDeleteProperty (disp, TermWin.parent[0], |
3698 | display->atom (str)); |
3745 | display->atom (str)); |
3699 | } |
3746 | } |
3700 | break; |
3747 | break; |
3701 | |
3748 | |
3702 | case XTerm_Color: |
3749 | case XTerm_Color: |
… | |
… | |
3743 | break; |
3790 | break; |
3744 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3791 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3745 | case XTerm_Color_BD: |
3792 | case XTerm_Color_BD: |
3746 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3793 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3747 | break; |
3794 | break; |
3748 | case XTerm_Color_IT: |
|
|
3749 | process_color_seq (XTerm_Color_IT, Color_IT, str, resp); |
|
|
3750 | break; |
|
|
3751 | case XTerm_Color_UL: |
3795 | case XTerm_Color_UL: |
3752 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3796 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3753 | break; |
3797 | break; |
3754 | case XTerm_Color_RV: |
3798 | case XTerm_Color_RV: |
3755 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3799 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3756 | break; |
3800 | break; |
|
|
3801 | case URxvt_Color_IT: |
|
|
3802 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
|
|
3803 | break; |
3757 | #endif |
3804 | #endif |
3758 | #if TRANSPARENT || TINTING |
3805 | #if TRANSPARENT && TINTING |
3759 | case XTerm_Color_tint: |
3806 | case URxvt_Color_tint: |
3760 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
3807 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3761 | check_our_parents (); |
3808 | check_our_parents (); |
3762 | if (am_transparent) |
3809 | if (am_transparent) |
3763 | want_full_refresh = want_refresh = 1; |
3810 | want_full_refresh = want_refresh = 1; |
3764 | break; |
3811 | break; |
3765 | #endif |
3812 | #endif |
… | |
… | |
3777 | { |
3824 | { |
3778 | str++; |
3825 | str++; |
3779 | #if XPM_BACKGROUND |
3826 | #if XPM_BACKGROUND |
3780 | changed += scale_pixmap (str); |
3827 | changed += scale_pixmap (str); |
3781 | #endif |
3828 | #endif |
3782 | |
|
|
3783 | } |
3829 | } |
|
|
3830 | |
3784 | if (changed) |
3831 | if (changed) |
3785 | { |
3832 | { |
3786 | #ifdef XPM_BACKGROUND |
3833 | #ifdef XPM_BACKGROUND |
3787 | resize_pixmap (); |
3834 | resize_pixmap (); |
3788 | #endif |
3835 | #endif |
… | |
… | |
3799 | |
3846 | |
3800 | case XTerm_logfile: |
3847 | case XTerm_logfile: |
3801 | // TODO, when secure mode? |
3848 | // TODO, when secure mode? |
3802 | break; |
3849 | break; |
3803 | |
3850 | |
|
|
3851 | #ifdef MENUBAR |
|
|
3852 | case URxvt_Menu: |
|
|
3853 | if (options & Opt_insecure) |
|
|
3854 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3855 | break; |
|
|
3856 | #endif |
|
|
3857 | #if 0 |
|
|
3858 | case XTerm_dumpscreen: /* no error notices */ |
|
|
3859 | { |
|
|
3860 | int fd; |
|
|
3861 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
|
|
3862 | { |
|
|
3863 | scr_dump (fd); |
|
|
3864 | close (fd); |
|
|
3865 | } |
|
|
3866 | } |
|
|
3867 | break; |
|
|
3868 | #endif |
3804 | case XTerm_font: |
3869 | case XTerm_font: |
3805 | op = URxvt_font; |
3870 | op = URxvt_font; |
3806 | case URxvt_font: |
3871 | case URxvt_font: |
3807 | #if ENABLE_STYLES |
3872 | #if ENABLE_STYLES |
3808 | case URxvt_boldFont: |
3873 | case URxvt_boldFont: |
… | |
… | |
3823 | set_fonts (); |
3888 | set_fonts (); |
3824 | } |
3889 | } |
3825 | break; |
3890 | break; |
3826 | |
3891 | |
3827 | #if ENABLE_FRILLS |
3892 | #if ENABLE_FRILLS |
3828 | case XTerm_locale: |
3893 | case URxvt_locale: |
3829 | if (query) |
3894 | if (query) |
3830 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3895 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, (options & Opt_insecure) ? locale : "", resp); |
3831 | else |
3896 | else |
3832 | { |
3897 | { |
3833 | set_locale (str); |
3898 | set_locale (str); |
3834 | # ifdef USE_XIM |
3899 | pty.set_utf8_mode (enc_utf8); |
3835 | im_cb (); |
3900 | init_xlocale (); |
3836 | # endif |
|
|
3837 | } |
3901 | } |
3838 | break; |
3902 | break; |
3839 | #endif |
|
|
3840 | |
3903 | |
3841 | #ifdef MENUBAR |
3904 | case URxvt_view_up: |
3842 | case XTerm_Menu: |
3905 | case URxvt_view_down: |
3843 | if (options & Opt_insecure) |
3906 | int lines = atoi (str); |
3844 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
3907 | |
3845 | break; |
3908 | if (lines) |
3846 | #endif |
3909 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3847 | #if 0 |
|
|
3848 | case XTerm_dumpscreen: /* no error notices */ |
|
|
3849 | { |
3910 | else |
3850 | int fd; |
|
|
3851 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
|
|
3852 | { |
3911 | { |
3853 | scr_dump (fd); |
3912 | scr_erase_savelines (); |
3854 | close (fd); |
|
|
3855 | } |
3913 | } |
3856 | } |
3914 | |
3857 | break; |
3915 | break; |
3858 | #endif |
3916 | #endif |
3859 | } |
3917 | } |
3860 | } |
3918 | } |
3861 | /*----------------------------------------------------------------------*/ |
3919 | /*----------------------------------------------------------------------*/ |
… | |
… | |
4276 | |
4334 | |
4277 | /* ---------------------------------------------------------------------- */ |
4335 | /* ---------------------------------------------------------------------- */ |
4278 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4336 | /* Write data to the pty as typed by the user, pasted with the mouse, |
4279 | * or generated by us in response to a query ESC sequence. |
4337 | * or generated by us in response to a query ESC sequence. |
4280 | */ |
4338 | */ |
|
|
4339 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
|
|
4340 | |
4281 | void |
4341 | void |
4282 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4342 | rxvt_term::tt_write (const unsigned char *data, unsigned int len) |
4283 | { |
4343 | { |
4284 | const unsigned int MAX_PTY_WRITE = 255; // minimum MAX_INPUT |
4344 | if (v_buflen == 0) |
|
|
4345 | { |
|
|
4346 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
4285 | |
4347 | |
4286 | if (len) |
4348 | if ((unsigned int)written == len) |
|
|
4349 | return; |
|
|
4350 | |
|
|
4351 | data += written; |
|
|
4352 | len -= written; |
4287 | { |
4353 | } |
|
|
4354 | |
|
|
4355 | v_buffer = (unsigned char *)realloc (v_buffer, v_buflen + len); |
|
|
4356 | |
|
|
4357 | memcpy (v_buffer + v_buflen, data, len); |
|
|
4358 | v_buflen += len; |
|
|
4359 | |
|
|
4360 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4361 | } |
|
|
4362 | |
|
|
4363 | void rxvt_term::pty_write () |
|
|
4364 | { |
|
|
4365 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4366 | |
|
|
4367 | if (written > 0) |
|
|
4368 | { |
|
|
4369 | v_buflen -= written; |
|
|
4370 | |
4288 | if (v_buflen == 0) |
4371 | if (v_buflen == 0) |
4289 | { |
4372 | { |
4290 | ssize_t written = write (pty.pty, data, min (len, MAX_PTY_WRITE)); |
|
|
4291 | |
|
|
4292 | if ((unsigned int)written == len) |
|
|
4293 | return; |
|
|
4294 | |
|
|
4295 | data += written; |
|
|
4296 | len -= written; |
|
|
4297 | } |
|
|
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 | |
|
|
4306 | for (;;) |
|
|
4307 | { |
|
|
4308 | int written = write (pty.pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
|
|
4309 | |
|
|
4310 | if (written > 0) |
|
|
4311 | { |
|
|
4312 | v_buflen -= written; |
|
|
4313 | |
|
|
4314 | if (v_buflen == 0) |
|
|
4315 | { |
|
|
4316 | free (v_buffer); |
4373 | free (v_buffer); |
4317 | v_buffer = 0; |
4374 | v_buffer = 0; |
4318 | v_buflen = 0; |
4375 | v_buflen = 0; |
4319 | |
4376 | |
4320 | pty_ev.set (EVENT_READ); |
4377 | pty_ev.set (EVENT_READ); |
4321 | return; |
|
|
4322 | } |
|
|
4323 | |
|
|
4324 | memmove (v_buffer, v_buffer + written, v_buflen); |
|
|
4325 | } |
|
|
4326 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4327 | // original code just ignores this... |
|
|
4328 | destroy (); |
|
|
4329 | else |
|
|
4330 | { |
|
|
4331 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
|
|
4332 | return; |
4378 | return; |
4333 | } |
4379 | } |
|
|
4380 | |
|
|
4381 | memmove (v_buffer, v_buffer + written, v_buflen); |
4334 | } |
4382 | } |
|
|
4383 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
|
|
4384 | // original code just ignores this... |
|
|
4385 | destroy (); |
4335 | } |
4386 | } |
4336 | |
4387 | |
4337 | /*----------------------- end-of-file (C source) -----------------------*/ |
4388 | /*----------------------- end-of-file (C source) -----------------------*/ |
4338 | |
4389 | |