1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: command.C |
2 | * File: command.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
6 | * Copyright (c) 1992 John Bovey, University of Kent at Canterbury <jdb@ukc.ac.uk> |
… | |
… | |
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-2006 Marc Lehmann <pcg@goof.com> |
30 | * Copyright (c) 2003-2007 Marc Lehmann <pcg@goof.com> |
|
|
31 | * Copyright (c) 2007 Emanuele Giaquinta <e.giaquinta@glauco.it> |
31 | * |
32 | * |
32 | * This program is free software; you can redistribute it and/or modify |
33 | * 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 |
34 | * 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 |
35 | * the Free Software Foundation; either version 2 of the License, or |
35 | * (at your option) any later version. |
36 | * (at your option) any later version. |
… | |
… | |
49 | #include "rxvt.h" |
50 | #include "rxvt.h" |
50 | #include "rxvtperl.h" |
51 | #include "rxvtperl.h" |
51 | #include "version.h" |
52 | #include "version.h" |
52 | #include "command.h" |
53 | #include "command.h" |
53 | |
54 | |
54 | #if HAVE_SCHED_YIELD |
|
|
55 | #undef HAVE_SCHED_YIELD // disabled for the time being |
|
|
56 | //# include <sched.h> |
|
|
57 | #endif |
|
|
58 | |
|
|
59 | #ifdef KEYSYM_RESOURCE |
55 | #ifdef KEYSYM_RESOURCE |
60 | # include "keyboard.h" |
56 | # include "keyboard.h" |
61 | #endif |
57 | #endif |
62 | |
58 | |
63 | #include <csignal> |
59 | #include <csignal> |
|
|
60 | |
|
|
61 | #if LINUX_YIELD_HACK |
|
|
62 | # include <ctime> |
|
|
63 | #endif |
64 | |
64 | |
65 | /*----------------------------------------------------------------------*/ |
65 | /*----------------------------------------------------------------------*/ |
66 | |
66 | |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
67 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
68 | |
68 | |
… | |
… | |
96 | XK_Shift_L, 0x21e7, |
96 | XK_Shift_L, 0x21e7, |
97 | XK_Shift_R, 0x21e7, |
97 | XK_Shift_R, 0x21e7, |
98 | |
98 | |
99 | XK_Shift_Lock, 0x21eb, |
99 | XK_Shift_Lock, 0x21eb, |
100 | XK_ISO_Lock, 0x21eb, |
100 | XK_ISO_Lock, 0x21eb, |
101 | XK_ISO_Lock, 0x21eb, |
|
|
102 | XK_Caps_Lock, 0x21ec, |
101 | XK_Caps_Lock, 0x21ec, |
103 | XK_Num_Lock, 0x21ed, |
102 | XK_Num_Lock, 0x21ed, |
104 | XK_ISO_Level3_Shift, 0x21ee, |
103 | XK_ISO_Level3_Shift, 0x21ee, |
105 | XK_ISO_Level3_Lock, 0x21ef, |
104 | XK_ISO_Level3_Lock, 0x21ef, |
106 | XK_ISO_Group_Lock, 0x21f0, |
105 | XK_ISO_Group_Lock, 0x21f0, |
… | |
… | |
200 | r & RS_Uline ? " uline" : "", |
199 | r & RS_Uline ? " uline" : "", |
201 | r & RS_Careful ? " careful" : ""); |
200 | r & RS_Careful ? " careful" : ""); |
202 | |
201 | |
203 | int width = wcswidth (fname, wcslen (fname)); |
202 | int width = wcswidth (fname, wcslen (fname)); |
204 | |
203 | |
205 | max_it (width, 8+5); // for char + hey |
204 | max_it (width, 8+5); // for char + hex |
206 | max_it (width, strlen (attr)); |
205 | max_it (width, strlen (attr)); |
207 | |
206 | |
208 | if (y >= 0) |
207 | if (y >= 0) |
209 | { |
208 | { |
210 | y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1; |
209 | y = (y >= nrow - len - 4 && x < width + 2) ? 0 : -1; |
… | |
… | |
222 | ch = *chr++; |
221 | ch = *chr++; |
223 | |
222 | |
224 | sprintf (buf, "%8x", ch); |
223 | sprintf (buf, "%8x", ch); |
225 | scr_overlay_set (0, y, buf); |
224 | scr_overlay_set (0, y, buf); |
226 | scr_overlay_set (9, y, '='); |
225 | scr_overlay_set (9, y, '='); |
227 | # if !UNICODE3 |
226 | # if !UNICODE_3 |
228 | if (ch >= 0x10000) |
227 | if (ch >= 0x10000) |
229 | ch = 0xfffd; |
228 | ch = 0xfffd; |
230 | # endif |
229 | # endif |
231 | scr_overlay_set (11, y, ch, r); |
230 | scr_overlay_set (11, y, ch, r); |
232 | |
231 | |
… | |
… | |
280 | } |
279 | } |
281 | |
280 | |
282 | iso14755buf = 0; |
281 | iso14755buf = 0; |
283 | } |
282 | } |
284 | |
283 | |
285 | int |
284 | static int |
286 | rxvt_term::hex_keyval (XKeyEvent &ev) |
285 | hex_keyval (XKeyEvent &ev) |
287 | { |
286 | { |
288 | // check wether this event corresponds to a hex digit |
287 | // check wether this event corresponds to a hex digit |
289 | // if the modifiers had not been pressed. |
288 | // if the modifiers had not been pressed. |
290 | for (int index = 0; index < 8; index++) |
289 | for (int index = 0; index < 8; index++) |
291 | { |
290 | { |
… | |
… | |
299 | |
298 | |
300 | return -1; |
299 | return -1; |
301 | } |
300 | } |
302 | #endif |
301 | #endif |
303 | |
302 | |
304 | /*{{{ Convert the keypress event into a string */ |
303 | static inline KeySym |
|
|
304 | translate_keypad (KeySym keysym, bool kp) |
|
|
305 | { |
|
|
306 | #ifdef XK_KP_Home |
|
|
307 | static const KeySym keypadtrans[] = { |
|
|
308 | XK_KP_7, // XK_KP_Home |
|
|
309 | XK_KP_4, // XK_KP_Left |
|
|
310 | XK_KP_8, // XK_KP_Up |
|
|
311 | XK_KP_6, // XK_KP_Right |
|
|
312 | XK_KP_2, // XK_KP_Down |
|
|
313 | # ifndef UNSHIFTED_SCROLLKEYS |
|
|
314 | XK_KP_9, // XK_KP_Prior |
|
|
315 | XK_KP_3, // XK_KP_Next |
|
|
316 | # else |
|
|
317 | XK_Prior, |
|
|
318 | XK_Next, |
|
|
319 | # endif |
|
|
320 | XK_KP_1, // XK_KP_End |
|
|
321 | XK_KP_5, // XK_KP_Begin |
|
|
322 | }; |
|
|
323 | |
|
|
324 | if (IN_RANGE_INC (keysym, XK_KP_Home, XK_KP_Begin)) |
|
|
325 | { |
|
|
326 | unsigned int index = keysym - XK_KP_Home; |
|
|
327 | keysym = kp ? keypadtrans[index] : XK_Home + index; |
|
|
328 | } |
|
|
329 | else if (keysym == XK_KP_Insert) |
|
|
330 | keysym = kp ? XK_KP_0 : XK_Insert; |
|
|
331 | # ifndef NO_DELETE_KEY |
|
|
332 | else if (keysym == XK_KP_Delete) |
|
|
333 | keysym = kp ? XK_KP_Decimal : XK_Delete; |
|
|
334 | # endif |
|
|
335 | #endif |
|
|
336 | return keysym; |
|
|
337 | } |
|
|
338 | |
|
|
339 | static inline int |
|
|
340 | map_function_key (KeySym keysym) |
|
|
341 | { |
|
|
342 | int param = 0; |
|
|
343 | |
|
|
344 | if (IN_RANGE_INC (keysym, XK_F1, XK_F35)) |
|
|
345 | { |
|
|
346 | param = 11 + keysym - XK_F1; |
|
|
347 | if (keysym >= XK_F17) |
|
|
348 | param += 4; |
|
|
349 | else if (keysym >= XK_F15) |
|
|
350 | param += 3; |
|
|
351 | else if (keysym >= XK_F11) |
|
|
352 | param += 2; |
|
|
353 | else if (keysym >= XK_F6) |
|
|
354 | param += 1; |
|
|
355 | } |
|
|
356 | else |
|
|
357 | switch (keysym) |
|
|
358 | { |
|
|
359 | case XK_Find: |
|
|
360 | param = 1; |
|
|
361 | break; |
|
|
362 | case XK_Insert: |
|
|
363 | param = 2; |
|
|
364 | break; |
|
|
365 | #ifdef DXK_Remove |
|
|
366 | case DXK_Remove: |
|
|
367 | #endif |
|
|
368 | case XK_Execute: |
|
|
369 | param = 3; |
|
|
370 | break; |
|
|
371 | case XK_Select: |
|
|
372 | param = 4; |
|
|
373 | break; |
|
|
374 | #ifndef UNSHIFTED_SCROLLKEYS |
|
|
375 | case XK_Prior: |
|
|
376 | param = 5; |
|
|
377 | break; |
|
|
378 | case XK_Next: |
|
|
379 | param = 6; |
|
|
380 | break; |
|
|
381 | case XK_Home: |
|
|
382 | param = 7; |
|
|
383 | break; |
|
|
384 | case XK_End: |
|
|
385 | param = 8; |
|
|
386 | break; |
|
|
387 | #endif |
|
|
388 | case XK_Help: |
|
|
389 | param = 28; |
|
|
390 | break; |
|
|
391 | case XK_Menu: |
|
|
392 | param = 29; |
|
|
393 | break; |
|
|
394 | } |
|
|
395 | return param; |
|
|
396 | } |
|
|
397 | |
305 | void |
398 | void |
306 | rxvt_term::lookup_key (XKeyEvent &ev) |
399 | rxvt_term::key_press (XKeyEvent &ev) |
307 | { |
400 | { |
308 | int ctrl, meta, shft, len; |
401 | int ctrl, meta, shft, len; |
309 | unsigned int newlen; |
|
|
310 | KeySym keysym; |
402 | KeySym keysym; |
311 | int valid_keysym; |
403 | int valid_keysym; |
312 | char kbuf[KBUFSZ]; |
404 | char kbuf[KBUFSZ]; |
|
|
405 | |
|
|
406 | #if ISO_14755 |
|
|
407 | if (iso14755buf & ISO_14755_52) |
|
|
408 | return; |
|
|
409 | #endif |
313 | |
410 | |
314 | /* |
411 | /* |
315 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
412 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
316 | * escape sequence to toggle the Keypad. |
413 | * escape sequence to toggle the Keypad. |
317 | * |
414 | * |
… | |
… | |
497 | # if ISO_14755 |
594 | # if ISO_14755 |
498 | iso14755_51 (0); |
595 | iso14755_51 (0); |
499 | # endif |
596 | # endif |
500 | return; |
597 | return; |
501 | } |
598 | } |
|
|
599 | else if (keysym == XK_BackSpace) |
|
|
600 | { |
|
|
601 | iso14755buf = ((iso14755buf & ISO_14755_MASK) >> 4) | ISO_14755_51; |
|
|
602 | # if ISO_14755 |
|
|
603 | iso14755_51 (iso14755buf & ISO_14755_MASK); |
|
|
604 | # endif |
|
|
605 | return; |
|
|
606 | } |
502 | else if ((hv = hex_keyval (ev)) >= 0) |
607 | else if ((hv = hex_keyval (ev)) >= 0) |
503 | { |
608 | { |
504 | iso14755buf = ((iso14755buf << 4) & ISO_14755_MASK) |
609 | iso14755buf = ((iso14755buf << 4) & ISO_14755_MASK) |
505 | | hv | ISO_14755_51; |
610 | | hv | ISO_14755_51; |
506 | # if ISO_14755 |
611 | # if ISO_14755 |
… | |
… | |
508 | # endif |
613 | # endif |
509 | return; |
614 | return; |
510 | } |
615 | } |
511 | else |
616 | else |
512 | { |
617 | { |
513 | # if ENABLE_OVERLAY |
618 | # if ISO_14755 |
514 | scr_overlay_off (); |
619 | scr_overlay_off (); |
515 | # endif |
620 | # endif |
516 | iso14755buf = 0; |
621 | iso14755buf = 0; |
517 | } |
622 | } |
518 | } |
623 | } |
519 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
624 | else if ((ctrl && (keysym == XK_Shift_L || keysym == XK_Shift_R)) |
520 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
625 | || (shft && (keysym == XK_Control_L || keysym == XK_Control_R))) |
521 | if (!(iso14755buf & ISO_14755_STARTED)) |
626 | if (!(iso14755buf & ISO_14755_STARTED)) |
522 | { |
627 | { |
523 | iso14755buf |= ISO_14755_STARTED; |
628 | iso14755buf |= ISO_14755_STARTED; |
524 | # if ENABLE_OVERLAY |
629 | # if ISO_14755 |
525 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
630 | scr_overlay_new (0, -1, sizeof ("ISO 14755 mode") - 1, 1); |
526 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
631 | scr_overlay_set (0, 0, "ISO 14755 mode"); |
527 | # endif |
632 | # endif |
528 | } |
633 | } |
529 | #endif |
634 | #endif |
530 | |
635 | |
531 | #ifdef PRINTPIPE |
636 | #ifdef PRINTPIPE |
532 | if (keysym == XK_Print) |
637 | if (keysym == XK_Print) |
533 | { |
638 | { |
534 | scr_printscreen (ctrl | shft); |
639 | scr_printscreen (ctrl | shft); |
535 | return; |
640 | return; |
536 | } |
641 | } |
537 | #endif |
642 | #endif |
538 | |
643 | |
539 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
644 | if (keysym >= 0xFF00 && keysym <= 0xFFFF) |
540 | { |
645 | { |
541 | { |
646 | bool kp = priv_modes & PrivMode_aplKP ? !shft : shft; |
542 | newlen = 1; |
647 | unsigned int newlen = 1; |
543 | switch (keysym) |
648 | |
|
|
649 | switch (translate_keypad (keysym, kp)) |
544 | { |
650 | { |
545 | #ifndef NO_BACKSPACE_KEY |
651 | #ifndef NO_BACKSPACE_KEY |
546 | case XK_BackSpace: |
652 | case XK_BackSpace: |
547 | if (priv_modes & PrivMode_HaveBackSpace) |
653 | if (priv_modes & PrivMode_HaveBackSpace) |
548 | { |
654 | { |
549 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
655 | kbuf[0] = (!! (priv_modes & PrivMode_BackSpace) |
550 | ^ !!ctrl) ? '\b' : '\177'; |
656 | ^ !!ctrl) ? '\b' : '\177'; |
551 | kbuf[1] = '\0'; |
657 | kbuf[1] = '\0'; |
552 | } |
658 | } |
553 | else |
659 | else |
554 | strcpy (kbuf, key_backspace); |
660 | strcpy (kbuf, rs[Rs_backspace_key]); |
555 | break; |
661 | break; |
556 | #endif |
662 | #endif |
557 | #ifndef NO_DELETE_KEY |
663 | #ifndef NO_DELETE_KEY |
558 | # ifdef XK_KP_Prior |
|
|
559 | case XK_KP_Delete: |
|
|
560 | /* allow shift to override */ |
|
|
561 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
562 | { |
|
|
563 | strcpy (kbuf, "\033On"); |
|
|
564 | break; |
|
|
565 | } |
|
|
566 | /* FALLTHROUGH */ |
|
|
567 | # endif |
|
|
568 | case XK_Delete: |
664 | case XK_Delete: |
569 | strcpy (kbuf, key_delete); |
665 | strcpy (kbuf, rs[Rs_delete_key]); |
570 | break; |
666 | break; |
571 | #endif |
667 | #endif |
572 | case XK_Tab: |
668 | case XK_Tab: |
573 | if (shft) |
669 | if (shft) |
574 | strcpy (kbuf, "\033[Z"); |
670 | strcpy (kbuf, "\033[Z"); |
… | |
… | |
584 | #endif |
680 | #endif |
585 | newlen = 0; |
681 | newlen = 0; |
586 | } |
682 | } |
587 | break; |
683 | break; |
588 | |
684 | |
589 | #ifdef XK_KP_Left |
|
|
590 | case XK_KP_Up: /* \033Ox or standard */ |
|
|
591 | case XK_KP_Down: /* \033Or or standard */ |
|
|
592 | case XK_KP_Right: /* \033Ov or standard */ |
|
|
593 | case XK_KP_Left: /* \033Ot or standard */ |
|
|
594 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
595 | { |
|
|
596 | strcpy (kbuf, "\033OZ"); |
|
|
597 | kbuf[2] = "txvr"[keysym - XK_KP_Left]; |
|
|
598 | break; |
|
|
599 | } |
|
|
600 | else |
|
|
601 | /* translate to std. cursor key */ |
|
|
602 | keysym = XK_Left + (keysym - XK_KP_Left); |
|
|
603 | /* FALLTHROUGH */ |
|
|
604 | #endif |
|
|
605 | case XK_Up: /* "\033[A" */ |
685 | case XK_Up: /* "\033[A" */ |
606 | case XK_Down: /* "\033[B" */ |
686 | case XK_Down: /* "\033[B" */ |
607 | case XK_Right: /* "\033[C" */ |
687 | case XK_Right: /* "\033[C" */ |
608 | case XK_Left: /* "\033[D" */ |
688 | case XK_Left: /* "\033[D" */ |
609 | strcpy (kbuf, "\033[Z"); |
689 | strcpy (kbuf, "\033[Z"); |
… | |
… | |
618 | } |
698 | } |
619 | else if (priv_modes & PrivMode_aplCUR) |
699 | else if (priv_modes & PrivMode_aplCUR) |
620 | kbuf[1] = 'O'; |
700 | kbuf[1] = 'O'; |
621 | break; |
701 | break; |
622 | |
702 | |
623 | #ifndef UNSHIFTED_SCROLLKEYS |
|
|
624 | # ifdef XK_KP_Prior |
|
|
625 | case XK_KP_Prior: |
|
|
626 | /* allow shift to override */ |
|
|
627 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
628 | { |
|
|
629 | strcpy (kbuf, "\033Oy"); |
|
|
630 | break; |
|
|
631 | } |
|
|
632 | /* FALLTHROUGH */ |
|
|
633 | # endif |
|
|
634 | case XK_Prior: |
|
|
635 | strcpy (kbuf, "\033[5~"); |
|
|
636 | break; |
|
|
637 | # ifdef XK_KP_Next |
|
|
638 | case XK_KP_Next: |
|
|
639 | /* allow shift to override */ |
|
|
640 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
641 | { |
|
|
642 | strcpy (kbuf, "\033Os"); |
|
|
643 | break; |
|
|
644 | } |
|
|
645 | /* FALLTHROUGH */ |
|
|
646 | # endif |
|
|
647 | case XK_Next: |
|
|
648 | strcpy (kbuf, "\033[6~"); |
|
|
649 | break; |
|
|
650 | #endif |
|
|
651 | case XK_KP_Enter: |
703 | case XK_KP_Enter: |
652 | /* allow shift to override */ |
704 | /* allow shift to override */ |
653 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
705 | if (kp) |
654 | { |
706 | { |
655 | strcpy (kbuf, "\033OM"); |
707 | strcpy (kbuf, "\033OM"); |
656 | break; |
708 | break; |
657 | } |
709 | } |
658 | |
710 | |
… | |
… | |
670 | kbuf[0] = '\015'; |
722 | kbuf[0] = '\015'; |
671 | kbuf[1] = '\0'; |
723 | kbuf[1] = '\0'; |
672 | } |
724 | } |
673 | break; |
725 | break; |
674 | |
726 | |
675 | #ifdef XK_KP_Begin |
|
|
676 | case XK_KP_Begin: |
|
|
677 | strcpy (kbuf, "\033Ou"); |
|
|
678 | break; |
|
|
679 | |
|
|
680 | #endif |
|
|
681 | case XK_KP_F1: /* "\033OP" */ |
727 | case XK_KP_F1: /* "\033OP" */ |
682 | case XK_KP_F2: /* "\033OQ" */ |
728 | case XK_KP_F2: /* "\033OQ" */ |
683 | case XK_KP_F3: /* "\033OR" */ |
729 | case XK_KP_F3: /* "\033OR" */ |
684 | case XK_KP_F4: /* "\033OS" */ |
730 | case XK_KP_F4: /* "\033OS" */ |
685 | strcpy (kbuf, "\033OP"); |
731 | strcpy (kbuf, "\033OP"); |
… | |
… | |
701 | case XK_KP_6: /* "\033Ov" : "6" */ |
747 | case XK_KP_6: /* "\033Ov" : "6" */ |
702 | case XK_KP_7: /* "\033Ow" : "7" */ |
748 | case XK_KP_7: /* "\033Ow" : "7" */ |
703 | case XK_KP_8: /* "\033Ox" : "8" */ |
749 | case XK_KP_8: /* "\033Ox" : "8" */ |
704 | case XK_KP_9: /* "\033Oy" : "9" */ |
750 | case XK_KP_9: /* "\033Oy" : "9" */ |
705 | /* allow shift to override */ |
751 | /* allow shift to override */ |
706 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
752 | if (kp) |
707 | { |
753 | { |
708 | strcpy (kbuf, "\033Oj"); |
754 | strcpy (kbuf, "\033Oj"); |
709 | kbuf[2] += (keysym - XK_KP_Multiply); |
755 | kbuf[2] += (keysym - XK_KP_Multiply); |
710 | } |
756 | } |
711 | else |
757 | else |
… | |
… | |
713 | kbuf[0] = ('*' + (keysym - XK_KP_Multiply)); |
759 | kbuf[0] = ('*' + (keysym - XK_KP_Multiply)); |
714 | kbuf[1] = '\0'; |
760 | kbuf[1] = '\0'; |
715 | } |
761 | } |
716 | break; |
762 | break; |
717 | |
763 | |
718 | case XK_Find: |
|
|
719 | strcpy (kbuf, "\033[1~"); |
|
|
720 | break; |
|
|
721 | |
|
|
722 | #ifdef XK_KP_End |
|
|
723 | case XK_KP_Insert: |
|
|
724 | /* allow shift to override */ |
|
|
725 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
726 | { |
|
|
727 | strcpy (kbuf, "\033Op"); |
|
|
728 | break; |
|
|
729 | } |
|
|
730 | /* FALLTHROUGH */ |
|
|
731 | #endif |
|
|
732 | case XK_Insert: |
|
|
733 | strcpy (kbuf, "\033[2~"); |
|
|
734 | break; |
|
|
735 | #ifdef DXK_Remove /* support for DEC remove like key */ |
|
|
736 | case DXK_Remove: |
|
|
737 | /* FALLTHROUGH */ |
|
|
738 | #endif |
|
|
739 | case XK_Execute: |
|
|
740 | strcpy (kbuf, "\033[3~"); |
|
|
741 | break; |
|
|
742 | case XK_Select: |
|
|
743 | strcpy (kbuf, "\033[4~"); |
|
|
744 | break; |
|
|
745 | #ifdef XK_KP_End |
|
|
746 | case XK_KP_End: |
|
|
747 | /* allow shift to override */ |
|
|
748 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
749 | { |
|
|
750 | strcpy (kbuf, "\033Oq"); |
|
|
751 | break; |
|
|
752 | } |
|
|
753 | /* FALLTHROUGH */ |
|
|
754 | #endif |
|
|
755 | case XK_End: |
|
|
756 | strcpy (kbuf, KS_END); |
|
|
757 | break; |
|
|
758 | #ifdef XK_KP_Home |
|
|
759 | case XK_KP_Home: |
|
|
760 | /* allow shift to override */ |
|
|
761 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
762 | { |
|
|
763 | strcpy (kbuf, "\033Ow"); |
|
|
764 | break; |
|
|
765 | } |
|
|
766 | /* FALLTHROUGH */ |
|
|
767 | #endif |
|
|
768 | case XK_Home: |
|
|
769 | strcpy (kbuf, KS_HOME); |
|
|
770 | break; |
|
|
771 | |
|
|
772 | #define FKEY(n, fkey) \ |
|
|
773 | sprintf ((char *)kbuf,"\033[%2d~", (int) ((n) + (keysym - fkey))) |
|
|
774 | |
|
|
775 | case XK_F1: /* "\033[11~" */ |
|
|
776 | case XK_F2: /* "\033[12~" */ |
|
|
777 | case XK_F3: /* "\033[13~" */ |
|
|
778 | case XK_F4: /* "\033[14~" */ |
|
|
779 | case XK_F5: /* "\033[15~" */ |
|
|
780 | FKEY (11, XK_F1); |
|
|
781 | break; |
|
|
782 | case XK_F6: /* "\033[17~" */ |
|
|
783 | case XK_F7: /* "\033[18~" */ |
|
|
784 | case XK_F8: /* "\033[19~" */ |
|
|
785 | case XK_F9: /* "\033[20~" */ |
|
|
786 | case XK_F10: /* "\033[21~" */ |
|
|
787 | FKEY (17, XK_F6); |
|
|
788 | break; |
|
|
789 | case XK_F11: /* "\033[23~" */ |
|
|
790 | case XK_F12: /* "\033[24~" */ |
|
|
791 | case XK_F13: /* "\033[25~" */ |
|
|
792 | case XK_F14: /* "\033[26~" */ |
|
|
793 | FKEY (23, XK_F11); |
|
|
794 | break; |
|
|
795 | case XK_F15: /* "\033[28~" */ |
|
|
796 | case XK_F16: /* "\033[29~" */ |
|
|
797 | FKEY (28, XK_F15); |
|
|
798 | break; |
|
|
799 | case XK_Help: /* "\033[28~" */ |
|
|
800 | FKEY (28, XK_Help); |
|
|
801 | break; |
|
|
802 | case XK_Menu: /* "\033[29~" */ |
|
|
803 | FKEY (29, XK_Menu); |
|
|
804 | break; |
|
|
805 | case XK_F17: /* "\033[31~" */ |
|
|
806 | case XK_F18: /* "\033[32~" */ |
|
|
807 | case XK_F19: /* "\033[33~" */ |
|
|
808 | case XK_F20: /* "\033[34~" */ |
|
|
809 | case XK_F21: /* "\033[35~" */ |
|
|
810 | case XK_F22: /* "\033[36~" */ |
|
|
811 | case XK_F23: /* "\033[37~" */ |
|
|
812 | case XK_F24: /* "\033[38~" */ |
|
|
813 | case XK_F25: /* "\033[39~" */ |
|
|
814 | case XK_F26: /* "\033[40~" */ |
|
|
815 | case XK_F27: /* "\033[41~" */ |
|
|
816 | case XK_F28: /* "\033[42~" */ |
|
|
817 | case XK_F29: /* "\033[43~" */ |
|
|
818 | case XK_F30: /* "\033[44~" */ |
|
|
819 | case XK_F31: /* "\033[45~" */ |
|
|
820 | case XK_F32: /* "\033[46~" */ |
|
|
821 | case XK_F33: /* "\033[47~" */ |
|
|
822 | case XK_F34: /* "\033[48~" */ |
|
|
823 | case XK_F35: /* "\033[49~" */ |
|
|
824 | FKEY (31, XK_F17); |
|
|
825 | break; |
|
|
826 | #undef FKEY |
|
|
827 | default: |
764 | default: |
|
|
765 | { |
|
|
766 | int param = map_function_key (keysym); |
|
|
767 | if (param > 0) |
|
|
768 | sprintf (kbuf,"\033[%d~", param); |
|
|
769 | else |
828 | newlen = 0; |
770 | newlen = 0; |
|
|
771 | } |
829 | break; |
772 | break; |
830 | } |
773 | } |
831 | |
774 | |
832 | if (newlen) |
775 | if (newlen) |
833 | len = strlen (kbuf); |
776 | len = strlen (kbuf); |
834 | } |
|
|
835 | |
777 | |
836 | /* |
778 | /* |
837 | * Pass meta for all function keys, if 'meta' option set |
779 | * Pass meta for all function keys, if 'meta' option set |
838 | */ |
780 | */ |
839 | #ifdef META8_OPTION |
781 | #ifdef META8_OPTION |
… | |
… | |
874 | return; |
816 | return; |
875 | |
817 | |
876 | if (len <= 0) |
818 | if (len <= 0) |
877 | return; /* not mapped */ |
819 | return; /* not mapped */ |
878 | |
820 | |
879 | if (OPTION (Opt_scrollTtyKeypress)) |
821 | if (option (Opt_scrollTtyKeypress)) |
880 | if (view_start) |
822 | if (view_start) |
881 | { |
823 | { |
882 | view_start = 0; |
824 | view_start = 0; |
883 | want_refresh = 1; |
825 | want_refresh = 1; |
884 | } |
826 | } |
… | |
… | |
908 | tt_write (&ch, 1); |
850 | tt_write (&ch, 1); |
909 | } |
851 | } |
910 | |
852 | |
911 | tt_write (kbuf, (unsigned int)len); |
853 | tt_write (kbuf, (unsigned int)len); |
912 | } |
854 | } |
913 | /*}}} */ |
855 | |
|
|
856 | void |
|
|
857 | rxvt_term::key_release (XKeyEvent &ev) |
|
|
858 | { |
|
|
859 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
|
|
860 | KeySym keysym; |
|
|
861 | |
|
|
862 | keysym = XLookupKeysym (&ev, ev.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
863 | #endif |
|
|
864 | |
|
|
865 | #if ENABLE_FRILLS || ISO_14755 |
|
|
866 | // ISO 14755 support |
|
|
867 | if (iso14755buf) |
|
|
868 | if (iso14755buf & ISO_14755_52) |
|
|
869 | { |
|
|
870 | # if ISO_14755 |
|
|
871 | scr_overlay_off (); |
|
|
872 | # endif |
|
|
873 | # if ISO_14755 |
|
|
874 | // iso14755 part 5.2 handling: release time |
|
|
875 | // first: controls |
|
|
876 | if ((ev.state & ControlMask) |
|
|
877 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
878 | || (keysym >= 0x61 && keysym <= 0x7f))) |
|
|
879 | { |
|
|
880 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
881 | commit_iso14755 (); |
|
|
882 | |
|
|
883 | return; |
|
|
884 | } |
|
|
885 | |
|
|
886 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
887 | if (i[0] == keysym) |
|
|
888 | { |
|
|
889 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
890 | commit_iso14755 (); |
|
|
891 | |
|
|
892 | return; |
|
|
893 | } |
|
|
894 | |
|
|
895 | scr_bell (); |
|
|
896 | # endif |
|
|
897 | iso14755buf = 0; |
|
|
898 | |
|
|
899 | return; |
|
|
900 | } |
|
|
901 | else if ((ev.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
902 | { |
|
|
903 | # if ISO_14755 |
|
|
904 | scr_overlay_off (); |
|
|
905 | # endif |
|
|
906 | if (iso14755buf & ISO_14755_51) |
|
|
907 | commit_iso14755 (); |
|
|
908 | #if ISO_14755 |
|
|
909 | else if (option (Opt_iso14755_52) && iso14755buf & ISO_14755_STARTED) |
|
|
910 | { |
|
|
911 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
912 | |
|
|
913 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
914 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
915 | } |
|
|
916 | # endif |
|
|
917 | else |
|
|
918 | iso14755buf = 0; |
|
|
919 | } |
|
|
920 | #endif |
|
|
921 | |
|
|
922 | if (HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
923 | return; |
|
|
924 | |
|
|
925 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
926 | if (!(ev.state & ControlMask)) |
|
|
927 | slip_wheel_ev.stop (); |
|
|
928 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
|
|
929 | mouse_slip_wheel_speed = 0; |
|
|
930 | #endif |
|
|
931 | } |
914 | |
932 | |
915 | #if defined (KEYSYM_RESOURCE) |
933 | #if defined (KEYSYM_RESOURCE) |
916 | unsigned int |
934 | unsigned int |
917 | rxvt_term::cmd_write (const char *str, unsigned int count) |
935 | rxvt_term::cmd_write (const char *str, unsigned int count) |
918 | { |
936 | { |
… | |
… | |
948 | void |
966 | void |
949 | rxvt_term::flush () |
967 | rxvt_term::flush () |
950 | { |
968 | { |
951 | flush_ev.stop (); |
969 | flush_ev.stop (); |
952 | |
970 | |
953 | #ifdef TRANSPARENT |
971 | #ifdef HAVE_BG_PIXMAP |
954 | if (want_full_refresh) |
972 | if (bgPixmap.check_clearChanged ()) |
955 | { |
973 | { |
956 | want_full_refresh = 0; |
974 | // scr_clear (true); This needs to be researched further! |
957 | scr_clear (); |
|
|
958 | scr_touch (false); |
975 | scr_touch (false); |
959 | } |
976 | } |
960 | #endif |
977 | #endif |
961 | |
978 | |
962 | if (want_refresh) |
979 | if (want_refresh) |
… | |
… | |
1007 | } |
1024 | } |
1008 | |
1025 | |
1009 | display->flush (); |
1026 | display->flush (); |
1010 | } |
1027 | } |
1011 | |
1028 | |
|
|
1029 | /* checks wether a refresh is requested and starts the refresh timer */ |
1012 | void |
1030 | void |
1013 | rxvt_term::check_cb (check_watcher &w) |
1031 | rxvt_term::refresh_check () |
|
|
1032 | { |
|
|
1033 | if (want_refresh && !flush_ev.is_active ()) |
|
|
1034 | flush_ev.start (1. / 60.); // refresh at max. 60 Hz normally |
|
|
1035 | |
|
|
1036 | display->flush (); |
|
|
1037 | } |
|
|
1038 | |
|
|
1039 | void |
|
|
1040 | rxvt_term::flush_cb (ev::timer &w, int revents) |
1014 | { |
1041 | { |
1015 | make_current (); |
1042 | make_current (); |
1016 | |
1043 | |
1017 | display->flush (); |
|
|
1018 | |
|
|
1019 | if (want_refresh && !flush_ev.active) |
|
|
1020 | flush_ev.start (NOW + 1. / 60.); // refresh at max. 60 hz normally |
|
|
1021 | } |
|
|
1022 | |
|
|
1023 | void |
|
|
1024 | rxvt_term::flush_cb (time_watcher &w) |
|
|
1025 | { |
|
|
1026 | make_current (); |
|
|
1027 | |
|
|
1028 | refresh_limit = 1; |
|
|
1029 | refresh_count = 0; |
1044 | refresh_count = 0; |
1030 | flush (); |
1045 | flush (); |
1031 | } |
1046 | } |
1032 | |
1047 | |
1033 | #ifdef CURSOR_BLINK |
1048 | #ifdef CURSOR_BLINK |
1034 | void |
1049 | void |
1035 | rxvt_term::cursor_blink_cb (time_watcher &w) |
1050 | rxvt_term::cursor_blink_cb (ev::timer &w, int revents) |
1036 | { |
1051 | { |
1037 | hidden_cursor = !hidden_cursor; |
1052 | hidden_cursor = !hidden_cursor; |
1038 | want_refresh = 1; |
1053 | want_refresh = 1; |
1039 | |
1054 | refresh_check (); |
1040 | w.start (w.at + CURSOR_BLINK_INTERVAL); |
|
|
1041 | } |
1055 | } |
1042 | #endif |
1056 | #endif |
1043 | |
1057 | |
1044 | #ifdef TEXT_BLINK |
1058 | #ifdef TEXT_BLINK |
1045 | void |
1059 | void |
1046 | rxvt_term::text_blink_cb (time_watcher &w) |
1060 | rxvt_term::text_blink_cb (ev::timer &w, int revents) |
1047 | { |
1061 | { |
1048 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
1062 | if (scr_refresh_rend (RS_Blink, RS_Blink)) |
1049 | { |
1063 | { |
1050 | hidden_text = !hidden_text; |
1064 | hidden_text = !hidden_text; |
1051 | want_refresh = 1; |
1065 | want_refresh = 1; |
1052 | w.start (w.at + TEXT_BLINK_INTERVAL); |
1066 | refresh_check (); |
1053 | } |
1067 | } |
|
|
1068 | else |
|
|
1069 | w.stop (); |
1054 | } |
1070 | } |
1055 | #endif |
1071 | #endif |
1056 | |
1072 | |
1057 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1073 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1058 | void |
1074 | void |
1059 | rxvt_term::cont_scroll_cb (time_watcher &w) |
1075 | rxvt_term::cont_scroll_cb (ev::timer &w, int revents) |
1060 | { |
1076 | { |
1061 | if ((scrollbar_isUp() || scrollbar_isDn()) && |
1077 | if ((scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) |
1062 | scr_page (scrollbar_isUp() ? UP : DN, 1)) |
1078 | && scr_page (scrollBar.state == STATE_UP ? UP : DN, 1)) |
1063 | { |
1079 | { |
1064 | want_refresh = 1; |
1080 | want_refresh = 1; |
1065 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1081 | refresh_check (); |
1066 | } |
1082 | } |
|
|
1083 | else |
|
|
1084 | w.stop (); |
1067 | } |
1085 | } |
1068 | #endif |
1086 | #endif |
1069 | |
1087 | |
1070 | #ifdef SELECTION_SCROLLING |
1088 | #ifdef SELECTION_SCROLLING |
1071 | void |
1089 | void |
1072 | rxvt_term::sel_scroll_cb (time_watcher &w) |
1090 | rxvt_term::sel_scroll_cb (ev::timer &w, int revents) |
1073 | { |
1091 | { |
1074 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1092 | if (scr_page (scroll_selection_dir, scroll_selection_lines)) |
1075 | { |
1093 | { |
1076 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1094 | selection_extend (selection_save_x, selection_save_y, selection_save_state); |
1077 | want_refresh = 1; |
1095 | want_refresh = 1; |
1078 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1096 | refresh_check (); |
1079 | } |
1097 | } |
|
|
1098 | else |
|
|
1099 | w.stop (); |
1080 | } |
1100 | } |
1081 | #endif |
1101 | #endif |
1082 | |
1102 | |
1083 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1103 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
1084 | void |
1104 | void |
1085 | rxvt_term::slip_wheel_cb (time_watcher &w) |
1105 | rxvt_term::slip_wheel_cb (ev::timer &w, int revents) |
1086 | { |
1106 | { |
1087 | if (mouse_slip_wheel_speed == 0 |
1107 | if (scr_changeview (view_start - mouse_slip_wheel_speed)) |
1088 | || mouse_slip_wheel_speed < 0 ? scr_page (DN, -mouse_slip_wheel_speed) |
|
|
1089 | : scr_page (UP, mouse_slip_wheel_speed)) |
|
|
1090 | { |
1108 | { |
1091 | if (view_start == top_row || view_start == 0) |
|
|
1092 | mouse_slip_wheel_speed = 0; |
|
|
1093 | |
|
|
1094 | want_refresh = 1; |
1109 | want_refresh = 1; |
1095 | w.start (w.at + SCROLLBAR_CONTINUOUS_DELAY); |
1110 | refresh_check (); |
|
|
1111 | } |
|
|
1112 | |
|
|
1113 | if (view_start == top_row || view_start == 0 || mouse_slip_wheel_speed == 0) |
1096 | } |
1114 | { |
|
|
1115 | mouse_slip_wheel_speed = 0; |
|
|
1116 | w.stop (); |
|
|
1117 | } |
1097 | } |
1118 | } |
1098 | #endif |
1119 | #endif |
1099 | |
1120 | |
1100 | #if HAVE_SCHED_YIELD |
1121 | #if LINUX_YIELD_HACK |
1101 | static struct event_handler |
1122 | static struct event_handler |
1102 | { |
1123 | { |
1103 | check_watcher cw_yield; |
1124 | ev::prepare yield_ev; |
1104 | |
1125 | |
1105 | void yield (check_watcher &w) |
1126 | void yield_cb (ev::prepare &w, int revents) |
1106 | { |
1127 | { |
1107 | sched_yield (); |
1128 | // this should really be sched_yield(), but the linux guys thought |
|
|
1129 | // that giving a process calling sched_yield () less cpu time than |
|
|
1130 | // ones with high nice levels is a useful thing to do. It surely is is |
|
|
1131 | // allowed by the sus... as is returning ENOSYS. |
|
|
1132 | |
|
|
1133 | struct timespec ts = { 0, 0 }; |
|
|
1134 | nanosleep (&ts, 0); |
|
|
1135 | |
1108 | w.stop (); |
1136 | w.stop (); |
1109 | } |
1137 | } |
1110 | |
1138 | |
1111 | event_handler () |
1139 | event_handler () |
1112 | : cw_yield (this, &event_handler::yield) |
1140 | : yield_ev (this, &event_handler::yield_cb) |
1113 | { |
1141 | { |
1114 | } |
1142 | } |
1115 | } event_handler; |
1143 | } event_handler; |
1116 | #endif |
1144 | #endif |
1117 | |
1145 | |
… | |
… | |
1137 | cmdbuf_endp += r; |
1165 | cmdbuf_endp += r; |
1138 | return true; |
1166 | return true; |
1139 | } |
1167 | } |
1140 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1168 | else if (r < 0 && (errno == EAGAIN || errno == EINTR)) |
1141 | { |
1169 | { |
1142 | #if HAVE_SCHED_YIELD |
1170 | #if LINUX_YIELD_HACK |
1143 | if (display->is_local) |
1171 | if (display->is_local) |
1144 | event_handler.cw_yield.start (); |
1172 | event_handler.yield_ev.start (); |
1145 | #endif |
1173 | #endif |
1146 | } |
1174 | } |
1147 | else |
1175 | else |
1148 | { |
1176 | { |
1149 | pty_ev.stop (); |
1177 | pty_ev.stop (); |
1150 | |
1178 | |
1151 | if (!OPTION (Opt_hold)) |
1179 | if (!option (Opt_hold)) |
1152 | destroy (); |
1180 | destroy (); |
1153 | } |
1181 | } |
1154 | |
1182 | |
1155 | return false; |
1183 | return false; |
1156 | } |
1184 | } |
1157 | |
1185 | |
1158 | void |
1186 | void |
1159 | rxvt_term::pty_cb (io_watcher &w, short revents) |
1187 | rxvt_term::pty_cb (ev::io &w, int revents) |
1160 | { |
1188 | { |
1161 | make_current (); |
1189 | make_current (); |
1162 | |
1190 | |
1163 | if (revents & EVENT_READ) |
1191 | if (revents & ev::READ) |
1164 | // loop, but don't allow a single term to monopolize us |
1192 | // loop, but don't allow a single term to monopolize us |
1165 | while (pty_fill ()) |
1193 | while (pty_fill ()) |
1166 | if (cmd_parse ()) |
1194 | if (cmd_parse ()) |
1167 | break; |
1195 | break; |
1168 | |
1196 | |
1169 | if (revents & EVENT_WRITE) |
1197 | if (revents & ev::WRITE) |
1170 | pty_write (); |
1198 | pty_write (); |
|
|
1199 | |
|
|
1200 | refresh_check (); |
1171 | } |
1201 | } |
1172 | |
1202 | |
1173 | void |
1203 | void |
1174 | rxvt_term::pointer_unblank () |
1204 | rxvt_term::pointer_unblank () |
1175 | { |
1205 | { |
1176 | XDefineCursor (xdisp, vt, TermWin_cursor); |
1206 | XDefineCursor (dpy, vt, TermWin_cursor); |
1177 | recolour_cursor (); |
1207 | recolour_cursor (); |
1178 | |
1208 | |
1179 | #ifdef POINTER_BLANK |
1209 | #ifdef POINTER_BLANK |
1180 | hidden_pointer = 0; |
1210 | hidden_pointer = 0; |
1181 | |
1211 | |
1182 | if (OPTION (Opt_pointerBlank)) |
1212 | if (option (Opt_pointerBlank)) |
1183 | pointer_ev.start (NOW + pointerBlankDelay); |
1213 | pointer_ev.start (pointerBlankDelay); |
1184 | #endif |
1214 | #endif |
1185 | } |
1215 | } |
1186 | |
1216 | |
1187 | #ifdef POINTER_BLANK |
1217 | #ifdef POINTER_BLANK |
1188 | void |
1218 | void |
1189 | rxvt_term::pointer_blank () |
1219 | rxvt_term::pointer_blank () |
1190 | { |
1220 | { |
1191 | if (!OPTION (Opt_pointerBlank)) |
1221 | if (!option (Opt_pointerBlank)) |
1192 | return; |
1222 | return; |
1193 | |
1223 | |
1194 | XDefineCursor (xdisp, vt, display->blank_cursor); |
1224 | XDefineCursor (dpy, vt, display->blank_cursor); |
1195 | XFlush (xdisp); |
1225 | XFlush (dpy); |
1196 | |
1226 | |
1197 | hidden_pointer = 1; |
1227 | hidden_pointer = 1; |
1198 | } |
1228 | } |
1199 | |
1229 | |
1200 | void |
1230 | void |
1201 | rxvt_term::pointer_cb (time_watcher &w) |
1231 | rxvt_term::pointer_cb (ev::timer &w, int revents) |
1202 | { |
1232 | { |
1203 | make_current (); |
1233 | make_current (); |
1204 | |
1234 | |
1205 | pointer_blank (); |
1235 | pointer_blank (); |
1206 | } |
1236 | } |
… | |
… | |
1209 | void |
1239 | void |
1210 | rxvt_term::mouse_report (XButtonEvent &ev) |
1240 | rxvt_term::mouse_report (XButtonEvent &ev) |
1211 | { |
1241 | { |
1212 | int button_number, key_state = 0; |
1242 | int button_number, key_state = 0; |
1213 | int x, y; |
1243 | int x, y; |
|
|
1244 | int code = 32; |
1214 | |
1245 | |
1215 | x = ev.x; |
1246 | x = Pixel2Col (ev.x); |
1216 | y = ev.y; |
1247 | y = Pixel2Row (ev.y); |
1217 | pixel_position (&x, &y); |
1248 | if (ev.type == MotionNotify) |
|
|
1249 | { |
|
|
1250 | if (x == mouse_row && y == mouse_col) |
|
|
1251 | return; |
|
|
1252 | mouse_row = x; |
|
|
1253 | mouse_col = y; |
|
|
1254 | code += 32; |
|
|
1255 | } |
1218 | |
1256 | |
1219 | if (MEvent.button == AnyButton) |
1257 | if (MEvent.button == AnyButton) |
1220 | button_number = 3; |
1258 | button_number = 3; |
1221 | else |
1259 | else |
1222 | { |
1260 | { |
… | |
… | |
1268 | x + 1, |
1306 | x + 1, |
1269 | y + 1); |
1307 | y + 1); |
1270 | #endif |
1308 | #endif |
1271 | |
1309 | |
1272 | tt_printf ("\033[M%c%c%c", |
1310 | tt_printf ("\033[M%c%c%c", |
1273 | (32 + button_number + key_state), |
1311 | (code + button_number + key_state), |
1274 | (32 + x + 1), |
1312 | (32 + x + 1), |
1275 | (32 + y + 1)); |
1313 | (32 + y + 1)); |
1276 | } |
1314 | } |
1277 | |
1315 | |
1278 | /*{{{ process an X event */ |
1316 | /*{{{ process an X event */ |
1279 | void |
1317 | void |
1280 | rxvt_term::x_cb (XEvent &ev) |
1318 | rxvt_term::x_cb (XEvent &ev) |
1281 | { |
1319 | { |
1282 | make_current (); |
1320 | make_current (); |
1283 | |
1321 | |
1284 | dLocal (Display *, xdisp); |
1322 | dLocal (Display *, dpy); |
1285 | |
1323 | |
1286 | if (ev.xany.window == vt |
1324 | if (ev.xany.window == vt |
1287 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1325 | && SHOULD_INVOKE (HOOK_X_EVENT) |
1288 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1326 | && HOOK_INVOKE ((this, HOOK_X_EVENT, DT_XEVENT, &ev, DT_END))) |
1289 | return; |
1327 | return; |
… | |
… | |
1294 | unsigned int unused_mask; |
1332 | unsigned int unused_mask; |
1295 | |
1333 | |
1296 | switch (ev.type) |
1334 | switch (ev.type) |
1297 | { |
1335 | { |
1298 | case KeyPress: |
1336 | case KeyPress: |
1299 | #if ISO_14755 |
1337 | key_press (ev.xkey); |
1300 | if (!(iso14755buf & ISO_14755_52)) |
|
|
1301 | #endif |
|
|
1302 | lookup_key (ev.xkey); |
|
|
1303 | |
|
|
1304 | break; |
1338 | break; |
1305 | |
1339 | |
1306 | case KeyRelease: |
1340 | case KeyRelease: |
1307 | { |
1341 | key_release (ev.xkey); |
1308 | #if (MOUSE_WHEEL && MOUSE_SLIP_WHEELING) || ISO_14755 || ENABLE_PERL |
|
|
1309 | KeySym keysym; |
|
|
1310 | |
|
|
1311 | keysym = XLookupKeysym (&ev.xkey, ev.xkey.state & ShiftMask ? 1 : 0); // sorry, only shift supported :/ |
|
|
1312 | #endif |
|
|
1313 | |
|
|
1314 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1315 | // ISO 14755 support |
|
|
1316 | if (iso14755buf) |
|
|
1317 | if (iso14755buf & ISO_14755_52) |
|
|
1318 | { |
|
|
1319 | # if ENABLE_OVERLAY |
|
|
1320 | scr_overlay_off (); |
|
|
1321 | # endif |
|
|
1322 | # if ISO_14755 |
|
|
1323 | // iso14755 part 5.2 handling: release time |
|
|
1324 | // first: controls |
|
|
1325 | if ((ev.xkey.state & ControlMask) |
|
|
1326 | && ((keysym >= 0x40 && keysym <= 0x5f) |
|
|
1327 | || (keysym >= 0x61 && keysym <= 0x7f))) |
|
|
1328 | { |
|
|
1329 | iso14755buf = ISO_14755_51 | 0x2400 | (keysym & 0x1f); |
|
|
1330 | commit_iso14755 (); |
|
|
1331 | goto skip_switch; |
|
|
1332 | } |
|
|
1333 | |
|
|
1334 | for (unsigned short *i = iso14755_symtab; i[0]; i+= 2) |
|
|
1335 | if (i[0] == keysym) |
|
|
1336 | { |
|
|
1337 | iso14755buf = ISO_14755_51 | i[1]; |
|
|
1338 | commit_iso14755 (); |
|
|
1339 | goto skip_switch; |
|
|
1340 | } |
|
|
1341 | |
|
|
1342 | scr_bell (); |
|
|
1343 | # endif |
|
|
1344 | iso14755buf = 0; |
|
|
1345 | break; |
|
|
1346 | } |
|
|
1347 | else if ((ev.xkey.state & (ShiftMask | ControlMask)) != (ShiftMask | ControlMask)) |
|
|
1348 | { |
|
|
1349 | # if ENABLE_OVERLAY |
|
|
1350 | scr_overlay_off (); |
|
|
1351 | # endif |
|
|
1352 | if (iso14755buf & ISO_14755_51) |
|
|
1353 | commit_iso14755 (); |
|
|
1354 | #if ISO_14755 |
|
|
1355 | else if (iso14755buf & ISO_14755_STARTED) |
|
|
1356 | { |
|
|
1357 | iso14755buf = ISO_14755_52; // iso14755 part 5.2: remember empty begin/end pair |
|
|
1358 | |
|
|
1359 | scr_overlay_new (0, -1, sizeof ("KEYCAP PICTURE INSERT MODE") - 1, 1); |
|
|
1360 | scr_overlay_set (0, 0, "KEYCAP PICTURE INSERT MODE"); |
|
|
1361 | } |
|
|
1362 | # endif |
|
|
1363 | else |
|
|
1364 | iso14755buf = 0; |
|
|
1365 | } |
|
|
1366 | #endif |
|
|
1367 | |
|
|
1368 | if (ev.xany.window == vt |
|
|
1369 | && HOOK_INVOKE ((this, HOOK_KEY_RELEASE, DT_XEVENT, &ev, DT_INT, keysym, DT_END))) |
|
|
1370 | break; |
|
|
1371 | |
|
|
1372 | #if defined(MOUSE_WHEEL) && defined(MOUSE_SLIP_WHEELING) |
|
|
1373 | if (!(ev.xkey.state & ControlMask)) |
|
|
1374 | slip_wheel_ev.stop (); |
|
|
1375 | else if (keysym == XK_Control_L || keysym == XK_Control_R) |
|
|
1376 | mouse_slip_wheel_speed = 0; |
|
|
1377 | #endif |
|
|
1378 | break; |
1342 | break; |
1379 | } |
|
|
1380 | |
1343 | |
1381 | case ButtonPress: |
1344 | case ButtonPress: |
1382 | button_press (ev.xbutton); |
1345 | button_press (ev.xbutton); |
1383 | break; |
1346 | break; |
1384 | |
1347 | |
… | |
… | |
1399 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1362 | if (!HOOK_INVOKE ((this, HOOK_WM_DELETE_WINDOW, DT_XEVENT, &ev, DT_END))) |
1400 | destroy (); |
1363 | destroy (); |
1401 | } |
1364 | } |
1402 | #if ENABLE_EWMH |
1365 | #if ENABLE_EWMH |
1403 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1366 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
1404 | XSendEvent (xdisp, ev.xclient.window = display->root, |
1367 | XSendEvent (dpy, ev.xclient.window = display->root, |
1405 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1368 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
1406 | &ev); |
1369 | &ev); |
1407 | #endif |
1370 | #endif |
1408 | } |
1371 | } |
1409 | } |
1372 | } |
… | |
… | |
1415 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
1378 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
1416 | focus_out (); |
1379 | focus_out (); |
1417 | } |
1380 | } |
1418 | #endif |
1381 | #endif |
1419 | } |
1382 | } |
1420 | break; |
|
|
1421 | |
|
|
1422 | case MappingNotify: |
|
|
1423 | XRefreshKeyboardMapping (&ev.xmapping); |
|
|
1424 | break; |
1383 | break; |
1425 | |
1384 | |
1426 | /* |
1385 | /* |
1427 | * XXX: this is not the _current_ arrangement |
1386 | * XXX: this is not the _current_ arrangement |
1428 | * Here's my conclusion: |
1387 | * Here's my conclusion: |
… | |
… | |
1447 | break; |
1406 | break; |
1448 | } |
1407 | } |
1449 | break; |
1408 | break; |
1450 | |
1409 | |
1451 | case FocusIn: |
1410 | case FocusIn: |
|
|
1411 | if (ev.xfocus.detail != NotifyInferior |
|
|
1412 | && ev.xfocus.detail != NotifyPointer |
|
|
1413 | && ev.xfocus.mode != NotifyGrab) |
1452 | focus_in (); |
1414 | focus_in (); |
1453 | break; |
1415 | break; |
1454 | |
1416 | |
1455 | case FocusOut: |
1417 | case FocusOut: |
|
|
1418 | if (ev.xfocus.detail != NotifyInferior |
|
|
1419 | && ev.xfocus.detail != NotifyPointer |
|
|
1420 | && ev.xfocus.mode != NotifyGrab) |
1456 | focus_out (); |
1421 | focus_out (); |
1457 | break; |
1422 | break; |
1458 | |
1423 | |
1459 | case ConfigureNotify: |
1424 | case ConfigureNotify: |
|
|
1425 | /*fprintf (stderr, "ConfigureNotify for %X, parent is %X, geom is %dx%d%+d%+d, old geom was %dx%d\n", |
|
|
1426 | ev.xconfigure.window, parent[0], ev.xconfigure.width, ev.xconfigure.height, ev.xconfigure.x, ev.xconfigure.y, |
|
|
1427 | szHint.width, szHint.height);*/ |
1460 | if (ev.xconfigure.window == parent[0]) |
1428 | if (ev.xconfigure.window == parent[0]) |
1461 | { |
1429 | { |
1462 | while (XCheckTypedWindowEvent (xdisp, ev.xconfigure.window, ConfigureNotify, &ev)) |
1430 | while (XCheckTypedWindowEvent (dpy, ev.xconfigure.window, ConfigureNotify, &ev)) |
1463 | ; |
1431 | ; |
1464 | |
1432 | |
1465 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1433 | if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) |
1466 | { |
1434 | { |
1467 | seen_resize = 1; |
1435 | seen_resize = 1; |
1468 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1436 | resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); |
1469 | } |
1437 | } |
|
|
1438 | else |
|
|
1439 | { |
|
|
1440 | #ifdef HAVE_BG_PIXMAP |
|
|
1441 | if (bgPixmap.window_position_sensitive ()) |
|
|
1442 | { |
|
|
1443 | if (mapped) |
|
|
1444 | update_background (); |
|
|
1445 | else |
|
|
1446 | bgPixmap.invalidate (); |
|
|
1447 | } |
|
|
1448 | #endif |
|
|
1449 | } |
1470 | |
1450 | |
1471 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1451 | HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1472 | |
|
|
1473 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
|
|
1474 | if (OPTION (Opt_transparent)) |
|
|
1475 | check_our_parents (); |
|
|
1476 | #endif |
|
|
1477 | } |
1452 | } |
1478 | break; |
1453 | break; |
1479 | |
1454 | |
1480 | case PropertyNotify: |
1455 | case PropertyNotify: |
1481 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1456 | if (!HOOK_INVOKE ((this, HOOK_PROPERTY_NOTIFY, DT_XEVENT, &ev, DT_END))) |
… | |
… | |
1497 | case SelectionRequest: |
1472 | case SelectionRequest: |
1498 | selection_send (ev.xselectionrequest); |
1473 | selection_send (ev.xselectionrequest); |
1499 | break; |
1474 | break; |
1500 | |
1475 | |
1501 | case MapNotify: |
1476 | case MapNotify: |
|
|
1477 | #ifdef HAVE_BG_PIXMAP |
|
|
1478 | /* This is needed spcifically to fix the case of no window manager or a |
|
|
1479 | * non-reparenting window manager. In those cases we never get first |
|
|
1480 | * ConfigureNotify. Also that speeds startup under normal WM, by taking |
|
|
1481 | * care of multiplicity of ConfigureNotify events arriwing while WM does |
|
|
1482 | * reparenting. |
|
|
1483 | * We should not render background immidiately, as there could be several |
|
|
1484 | * ConfigureNotify's to follow. Lets take care of all of them in one scoop |
|
|
1485 | * by scheduling background redraw as soon as we can, but giving a short |
|
|
1486 | * bit of time for ConfigureNotifies to arrive. |
|
|
1487 | * We should render background PRIOR to drawing any text, but AFTER all |
|
|
1488 | * of ConfigureNotifys for the best results. |
|
|
1489 | */ |
|
|
1490 | if (bgPixmap.flags & bgPixmap_t::isInvalid) |
|
|
1491 | update_background_ev.start (0.025); |
|
|
1492 | #endif |
1502 | mapped = 1; |
1493 | mapped = 1; |
1503 | #ifdef TEXT_BLINK |
1494 | #ifdef TEXT_BLINK |
1504 | text_blink_ev.start (NOW + TEXT_BLINK_INTERVAL); |
1495 | text_blink_ev.start (); |
1505 | #endif |
1496 | #endif |
1506 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1497 | HOOK_INVOKE ((this, HOOK_MAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1507 | break; |
1498 | break; |
1508 | |
1499 | |
1509 | case UnmapNotify: |
1500 | case UnmapNotify: |
… | |
… | |
1511 | #ifdef TEXT_BLINK |
1502 | #ifdef TEXT_BLINK |
1512 | text_blink_ev.stop (); |
1503 | text_blink_ev.stop (); |
1513 | #endif |
1504 | #endif |
1514 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1505 | HOOK_INVOKE ((this, HOOK_UNMAP_NOTIFY, DT_XEVENT, &ev, DT_END)); |
1515 | break; |
1506 | break; |
1516 | |
|
|
1517 | #ifdef TRANSPARENT |
|
|
1518 | case ReparentNotify: |
|
|
1519 | rootwin_cb (ev); |
|
|
1520 | break; |
|
|
1521 | #endif /* TRANSPARENT */ |
|
|
1522 | |
1507 | |
1523 | case GraphicsExpose: |
1508 | case GraphicsExpose: |
1524 | case Expose: |
1509 | case Expose: |
1525 | if (ev.xany.window == vt) |
1510 | if (ev.xany.window == vt) |
1526 | { |
1511 | { |
1527 | do |
1512 | do |
|
|
1513 | { |
1528 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1514 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1529 | ev.xexpose.width, ev.xexpose.height, False); |
1515 | ev.xexpose.width, ev.xexpose.height, False); |
|
|
1516 | } |
1530 | while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)); |
1517 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)); |
1531 | |
1518 | |
1532 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1519 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1533 | |
1520 | |
1534 | while (XCheckTypedWindowEvent (xdisp, vt, ev.xany.type, &ev)) |
1521 | while (XCheckTypedWindowEvent (dpy, vt, ev.xany.type, &ev)) |
|
|
1522 | { |
1535 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1523 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1536 | ev.xexpose.width, ev.xexpose.height, False); |
1524 | ev.xexpose.width, ev.xexpose.height, False); |
|
|
1525 | } |
1537 | |
1526 | |
1538 | want_refresh = 1; |
1527 | want_refresh = 1; |
1539 | } |
1528 | } |
1540 | else |
1529 | else |
1541 | { |
1530 | { |
1542 | XEvent unused_event; |
1531 | XEvent unused_event; |
1543 | |
1532 | |
1544 | while (XCheckTypedWindowEvent (xdisp, ev.xany.window, Expose, &unused_event)) |
1533 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, Expose, &unused_event)) |
1545 | ; |
1534 | ; |
1546 | while (XCheckTypedWindowEvent (xdisp, ev.xany.window, GraphicsExpose, &unused_event)) |
1535 | while (XCheckTypedWindowEvent (dpy, ev.xany.window, GraphicsExpose, &unused_event)) |
1547 | ; |
1536 | ; |
1548 | |
1537 | |
1549 | if (isScrollbarWindow (ev.xany.window)) |
1538 | if (scrollBar.state && ev.xany.window == scrollBar.win) |
1550 | { |
1539 | { |
1551 | scrollBar.setIdle (); |
1540 | scrollBar.state = STATE_IDLE; |
1552 | scrollbar_show (0); |
1541 | scrollbar_show (0); |
1553 | } |
1542 | } |
1554 | |
|
|
1555 | #ifdef TRANSPARENT |
|
|
1556 | if (am_transparent && ev.xany.window == parent[0]) |
|
|
1557 | XClearWindow (xdisp, ev.xany.window); |
|
|
1558 | #endif |
|
|
1559 | } |
1543 | } |
1560 | break; |
1544 | break; |
1561 | |
1545 | |
1562 | case MotionNotify: |
1546 | case MotionNotify: |
1563 | #ifdef POINTER_BLANK |
1547 | #ifdef POINTER_BLANK |
1564 | if (hidden_pointer) |
1548 | if (hidden_pointer) |
1565 | pointer_unblank (); |
1549 | pointer_unblank (); |
1566 | #endif |
1550 | #endif |
|
|
1551 | if ((priv_modes & PrivMode_MouseBtnEvent && ev.xbutton.state & (Button1Mask|Button2Mask|Button3Mask)) |
|
|
1552 | || priv_modes & PrivMode_MouseAnyEvent) |
|
|
1553 | mouse_report (ev.xbutton); |
1567 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1554 | if ((priv_modes & PrivMode_mouse_report) && !bypass_keystate) |
1568 | break; |
1555 | break; |
1569 | |
1556 | |
1570 | if (ev.xany.window == vt) |
1557 | if (ev.xany.window == vt) |
1571 | { |
1558 | { |
1572 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1559 | if (SHOULD_INVOKE (HOOK_MOTION_NOTIFY) |
1573 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1560 | && HOOK_INVOKE ((this, HOOK_MOTION_NOTIFY, DT_XEVENT, &ev, DT_END))) |
1574 | ; // nop |
1561 | ; // nop |
1575 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1562 | else if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1576 | { |
1563 | { |
1577 | while (XCheckTypedWindowEvent (xdisp, vt, MotionNotify, &ev)) |
1564 | while (XCheckTypedWindowEvent (dpy, vt, MotionNotify, &ev)) |
1578 | ; |
1565 | ; |
1579 | |
1566 | |
1580 | XQueryPointer (xdisp, vt, |
1567 | XQueryPointer (dpy, vt, |
1581 | &unused_root, &unused_child, |
1568 | &unused_root, &unused_child, |
1582 | &unused_root_x, &unused_root_y, |
1569 | &unused_root_x, &unused_root_y, |
1583 | &ev.xbutton.x, &ev.xbutton.y, |
1570 | &ev.xbutton.x, &ev.xbutton.y, |
1584 | &ev.xbutton.state); |
1571 | &ev.xbutton.state); |
1585 | #ifdef MOUSE_THRESHOLD |
1572 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1605 | int dist; |
1592 | int dist; |
1606 | |
1593 | |
1607 | /* don't clobber the current delay if we are |
1594 | /* don't clobber the current delay if we are |
1608 | * already in the middle of scrolling. |
1595 | * already in the middle of scrolling. |
1609 | */ |
1596 | */ |
1610 | if (!sel_scroll_ev.active) |
1597 | if (!sel_scroll_ev.is_active ()) |
1611 | sel_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1598 | sel_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
1612 | |
1599 | |
1613 | /* save the event params so we can highlight |
1600 | /* save the event params so we can highlight |
1614 | * the selection in the pending-scroll loop |
1601 | * the selection in the pending-scroll loop |
1615 | */ |
1602 | */ |
1616 | selection_save_x = ev.xbutton.x; |
1603 | selection_save_x = ev.xbutton.x; |
… | |
… | |
1638 | else |
1625 | else |
1639 | { |
1626 | { |
1640 | /* we are within the text window, so we |
1627 | /* we are within the text window, so we |
1641 | * shouldn't be scrolling |
1628 | * shouldn't be scrolling |
1642 | */ |
1629 | */ |
1643 | if (sel_scroll_ev.active) |
|
|
1644 | sel_scroll_ev.stop(); |
1630 | sel_scroll_ev.stop(); |
1645 | } |
1631 | } |
1646 | #endif |
1632 | #endif |
1647 | #ifdef MOUSE_THRESHOLD |
1633 | #ifdef MOUSE_THRESHOLD |
1648 | } |
1634 | } |
1649 | #endif |
1635 | #endif |
1650 | } |
1636 | } |
1651 | } |
1637 | } |
1652 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1638 | else if (scrollBar.state == STATE_MOTION && ev.xany.window == scrollBar.win) |
1653 | { |
1639 | { |
1654 | while (XCheckTypedWindowEvent (xdisp, scrollBar.win, |
1640 | while (XCheckTypedWindowEvent (dpy, scrollBar.win, |
1655 | MotionNotify, &ev)) |
1641 | MotionNotify, &ev)) |
1656 | ; |
1642 | ; |
1657 | |
1643 | |
1658 | XQueryPointer (xdisp, scrollBar.win, |
1644 | XQueryPointer (dpy, scrollBar.win, |
1659 | &unused_root, &unused_child, |
1645 | &unused_root, &unused_child, |
1660 | &unused_root_x, &unused_root_y, |
1646 | &unused_root_x, &unused_root_y, |
1661 | &ev.xbutton.x, &ev.xbutton.y, |
1647 | &ev.xbutton.x, &ev.xbutton.y, |
1662 | &unused_mask); |
1648 | &unused_mask); |
1663 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1649 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1664 | scrollbar_size ()); |
1650 | scrollbar_size ()); |
1665 | want_refresh = 1; |
1651 | want_refresh = 1; |
1666 | refresh_limit = 0; |
|
|
1667 | scrollbar_show (1); |
1652 | scrollbar_show (1); |
1668 | } |
1653 | } |
1669 | break; |
1654 | break; |
1670 | } |
1655 | } |
1671 | |
1656 | |
1672 | skip_switch: ; |
|
|
1673 | |
|
|
1674 | #if defined(CURSOR_BLINK) |
1657 | #if defined(CURSOR_BLINK) |
1675 | if (OPTION (Opt_cursorBlink) && ev.type == KeyPress) |
1658 | if (option (Opt_cursorBlink) && ev.type == KeyPress) |
1676 | { |
1659 | { |
1677 | if (hidden_cursor) |
1660 | if (hidden_cursor) |
1678 | { |
1661 | { |
1679 | hidden_cursor = 0; |
1662 | hidden_cursor = 0; |
1680 | want_refresh = 1; |
1663 | want_refresh = 1; |
1681 | } |
1664 | } |
1682 | |
1665 | |
1683 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1666 | cursor_blink_ev.again (); |
1684 | } |
1667 | } |
1685 | #endif |
1668 | #endif |
1686 | |
1669 | |
1687 | #if defined(POINTER_BLANK) |
1670 | #if defined(POINTER_BLANK) |
1688 | if (OPTION (Opt_pointerBlank) && pointerBlankDelay > 0) |
1671 | if (option (Opt_pointerBlank) && pointerBlankDelay > 0) |
1689 | { |
1672 | { |
1690 | if (ev.type == MotionNotify |
1673 | if (ev.type == MotionNotify |
1691 | || ev.type == ButtonPress |
1674 | || ev.type == ButtonPress |
1692 | || ev.type == ButtonRelease) |
1675 | || ev.type == ButtonRelease) |
1693 | if (hidden_pointer) |
1676 | if (hidden_pointer) |
… | |
… | |
1695 | |
1678 | |
1696 | if (ev.type == KeyPress && hidden_pointer == 0) |
1679 | if (ev.type == KeyPress && hidden_pointer == 0) |
1697 | pointer_blank (); |
1680 | pointer_blank (); |
1698 | } |
1681 | } |
1699 | #endif |
1682 | #endif |
|
|
1683 | |
|
|
1684 | refresh_check (); |
1700 | } |
1685 | } |
1701 | |
1686 | |
1702 | void |
1687 | void |
1703 | rxvt_term::focus_in () |
1688 | rxvt_term::focus_in () |
1704 | { |
1689 | { |
1705 | if (!focus) |
1690 | if (!focus) |
1706 | { |
1691 | { |
1707 | focus = 1; |
1692 | focus = 1; |
1708 | want_refresh = 1; |
1693 | want_refresh = 1; |
1709 | |
1694 | |
1710 | HOOK_INVOKE ((this, HOOK_FOCUS_OUT, DT_END)); |
1695 | HOOK_INVOKE ((this, HOOK_FOCUS_IN, DT_END)); |
1711 | |
1696 | |
1712 | #if USE_XIM |
1697 | #if USE_XIM |
1713 | if (Input_Context != NULL) |
1698 | if (Input_Context != NULL) |
1714 | { |
1699 | { |
1715 | IMSetStatusPosition (); |
1700 | IMSetPosition (); |
1716 | XSetICFocus (Input_Context); |
1701 | XSetICFocus (Input_Context); |
1717 | } |
1702 | } |
1718 | #endif |
1703 | #endif |
1719 | #if CURSOR_BLINK |
1704 | #if CURSOR_BLINK |
1720 | if (OPTION (Opt_cursorBlink)) |
1705 | if (option (Opt_cursorBlink)) |
1721 | cursor_blink_ev.start (NOW + CURSOR_BLINK_INTERVAL); |
1706 | cursor_blink_ev.again (); |
1722 | #endif |
1707 | #endif |
1723 | #if OFF_FOCUS_FADING |
1708 | #if OFF_FOCUS_FADING |
1724 | if (rs[Rs_fade]) |
1709 | if (rs[Rs_fade]) |
1725 | { |
1710 | { |
1726 | pix_colors = pix_colors_focused; |
1711 | pix_colors = pix_colors_focused; |
1727 | scr_recolour (); |
1712 | scr_recolour (); |
1728 | } |
1713 | } |
1729 | #endif |
1714 | #endif |
|
|
1715 | #if ENABLE_FRILLS |
|
|
1716 | if (option (Opt_urgentOnBell)) |
|
|
1717 | { |
|
|
1718 | if (XWMHints *h = XGetWMHints(dpy, parent[0])) |
|
|
1719 | { |
|
|
1720 | h->flags &= ~XUrgencyHint; |
|
|
1721 | XSetWMHints (dpy, parent[0], h); |
|
|
1722 | } |
|
|
1723 | } |
|
|
1724 | #endif |
1730 | } |
1725 | } |
1731 | } |
1726 | } |
1732 | |
1727 | |
1733 | void |
1728 | void |
1734 | rxvt_term::focus_out () |
1729 | rxvt_term::focus_out () |
… | |
… | |
1742 | |
1737 | |
1743 | #if ENABLE_FRILLS || ISO_14755 |
1738 | #if ENABLE_FRILLS || ISO_14755 |
1744 | if (iso14755buf) |
1739 | if (iso14755buf) |
1745 | { |
1740 | { |
1746 | iso14755buf = 0; |
1741 | iso14755buf = 0; |
1747 | # if ENABLE_OVERLAY |
1742 | # if ISO_14755 |
1748 | scr_overlay_off (); |
1743 | scr_overlay_off (); |
1749 | # endif |
1744 | # endif |
1750 | } |
1745 | } |
1751 | #endif |
1746 | #endif |
1752 | #if USE_XIM |
1747 | #if USE_XIM |
1753 | if (Input_Context != NULL) |
1748 | if (Input_Context != NULL) |
1754 | XUnsetICFocus (Input_Context); |
1749 | XUnsetICFocus (Input_Context); |
1755 | #endif |
1750 | #endif |
1756 | #if CURSOR_BLINK |
1751 | #if CURSOR_BLINK |
1757 | if (OPTION (Opt_cursorBlink)) |
1752 | if (option (Opt_cursorBlink)) |
1758 | cursor_blink_ev.stop (); |
1753 | cursor_blink_ev.stop (); |
|
|
1754 | |
1759 | hidden_cursor = 0; |
1755 | hidden_cursor = 0; |
1760 | #endif |
1756 | #endif |
1761 | #if OFF_FOCUS_FADING |
1757 | #if OFF_FOCUS_FADING |
1762 | if (rs[Rs_fade]) |
1758 | if (rs[Rs_fade]) |
1763 | { |
1759 | { |
… | |
… | |
1766 | } |
1762 | } |
1767 | #endif |
1763 | #endif |
1768 | } |
1764 | } |
1769 | } |
1765 | } |
1770 | |
1766 | |
1771 | #if TRANSPARENT |
1767 | void |
|
|
1768 | rxvt_term::update_fade_color (unsigned int idx) |
|
|
1769 | { |
|
|
1770 | #if OFF_FOCUS_FADING |
|
|
1771 | if (rs[Rs_fade]) |
|
|
1772 | { |
|
|
1773 | rgba c; |
|
|
1774 | pix_colors [Color_fade].get (c); |
|
|
1775 | pix_colors_focused [idx].fade (this, atoi (rs[Rs_fade]), pix_colors_unfocused [idx], c); |
|
|
1776 | } |
|
|
1777 | #endif |
|
|
1778 | } |
|
|
1779 | |
|
|
1780 | #if ENABLE_TRANSPARENCY || ENABLE_PERL |
1772 | void |
1781 | void |
1773 | rxvt_term::rootwin_cb (XEvent &ev) |
1782 | rxvt_term::rootwin_cb (XEvent &ev) |
1774 | { |
1783 | { |
1775 | make_current (); |
1784 | make_current (); |
1776 | |
1785 | |
|
|
1786 | if (SHOULD_INVOKE (HOOK_ROOT_EVENT) |
|
|
1787 | && HOOK_INVOKE ((this, HOOK_ROOT_EVENT, DT_XEVENT, &ev, DT_END))) |
|
|
1788 | return; |
|
|
1789 | |
|
|
1790 | # if ENABLE_TRANSPARENCY |
1777 | switch (ev.type) |
1791 | switch (ev.type) |
1778 | { |
1792 | { |
1779 | case PropertyNotify: |
1793 | case PropertyNotify: |
1780 | /* |
1794 | /* |
1781 | * if user used some Esetroot compatible prog to set the root bg, |
1795 | * if user used some Esetroot compatible prog to set the root bg, |
1782 | * use the property to determine the pixmap. We use it later on. |
1796 | * use the property to determine the pixmap. We use it later on. |
1783 | */ |
1797 | */ |
1784 | if (ev.xproperty.atom != xa[XA_XROOTPMAP_ID] |
1798 | if (ev.xproperty.atom == xa[XA_XROOTPMAP_ID] |
1785 | && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) |
1799 | || ev.xproperty.atom == xa[XA_ESETROOT_PMAP_ID]) |
1786 | return; |
1800 | { |
|
|
1801 | bgPixmap.set_root_pixmap (); |
|
|
1802 | update_background (); |
|
|
1803 | } |
1787 | |
1804 | |
1788 | /* FALLTHROUGH */ |
|
|
1789 | case ReparentNotify: |
|
|
1790 | if (OPTION (Opt_transparent) && check_our_parents () && am_transparent) |
|
|
1791 | want_refresh = want_full_refresh = 1; |
|
|
1792 | break; |
1805 | break; |
1793 | } |
1806 | } |
|
|
1807 | # endif |
|
|
1808 | |
|
|
1809 | refresh_check (); |
1794 | } |
1810 | } |
1795 | #endif |
1811 | #endif |
1796 | |
1812 | |
1797 | void |
1813 | void |
1798 | rxvt_term::button_press (XButtonEvent &ev) |
1814 | rxvt_term::button_press (XButtonEvent &ev) |
… | |
… | |
1853 | mouse_report (ev); |
1869 | mouse_report (ev); |
1854 | } |
1870 | } |
1855 | #else |
1871 | #else |
1856 | MEvent.button = ev.button; |
1872 | MEvent.button = ev.button; |
1857 | mouse_report (ev); |
1873 | mouse_report (ev); |
1858 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1874 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
1859 | |
1875 | |
1860 | } |
1876 | } |
1861 | else |
1877 | else |
1862 | { |
1878 | { |
1863 | if (ev.button != MEvent.button) |
1879 | if (ev.button != MEvent.button) |
… | |
… | |
1911 | } |
1927 | } |
1912 | |
1928 | |
1913 | /* |
1929 | /* |
1914 | * Scrollbar window processing of button press |
1930 | * Scrollbar window processing of button press |
1915 | */ |
1931 | */ |
1916 | if (isScrollbarWindow (ev.window)) |
1932 | if (scrollBar.state && ev.window == scrollBar.win) |
1917 | { |
1933 | { |
1918 | scrollBar.setIdle (); |
1934 | page_dirn direction = NO_DIR; |
|
|
1935 | |
|
|
1936 | if (scrollBar.upButton (ev.y)) |
|
|
1937 | direction = UP; /* up */ |
|
|
1938 | else if (scrollBar.dnButton (ev.y)) |
|
|
1939 | direction = DN; /* down */ |
|
|
1940 | |
|
|
1941 | scrollBar.state = STATE_IDLE; |
1919 | /* |
1942 | /* |
1920 | * Rxvt-style scrollbar: |
1943 | * Rxvt-style scrollbar: |
1921 | * move up if mouse is above slider |
1944 | * move up if mouse is above slider |
1922 | * move dn if mouse is below slider |
1945 | * move dn if mouse is below slider |
1923 | * |
1946 | * |
… | |
… | |
1932 | /* |
1955 | /* |
1933 | * Mouse report disabled scrollbar: |
1956 | * Mouse report disabled scrollbar: |
1934 | * arrow buttons - send up/down |
1957 | * arrow buttons - send up/down |
1935 | * click on scrollbar - send pageup/down |
1958 | * click on scrollbar - send pageup/down |
1936 | */ |
1959 | */ |
1937 | if ((scrollBar.style == R_SB_NEXT |
1960 | if (direction == UP) |
1938 | && scrollbarnext_upButton (ev.y)) |
|
|
1939 | || (scrollBar.style == R_SB_RXVT |
|
|
1940 | && scrollbarrxvt_upButton (ev.y))) |
|
|
1941 | tt_printf ("\033[A"); |
1961 | tt_printf ("\033[A"); |
1942 | else if ((scrollBar.style == R_SB_NEXT |
1962 | else if (direction == DN) |
1943 | && scrollbarnext_dnButton (ev.y)) |
|
|
1944 | || (scrollBar.style == R_SB_RXVT |
|
|
1945 | && scrollbarrxvt_dnButton (ev.y))) |
|
|
1946 | tt_printf ("\033[B"); |
1963 | tt_printf ("\033[B"); |
1947 | else |
1964 | else |
1948 | switch (ev.button) |
1965 | switch (ev.button) |
1949 | { |
1966 | { |
1950 | case Button2: |
1967 | case Button2: |
… | |
… | |
1957 | tt_printf ("\033[5~"); |
1974 | tt_printf ("\033[5~"); |
1958 | break; |
1975 | break; |
1959 | } |
1976 | } |
1960 | } |
1977 | } |
1961 | else |
1978 | else |
1962 | #endif /* NO_SCROLLBAR_REPORT */ |
1979 | #endif /* NO_SCROLLBAR_REPORT */ |
1963 | |
|
|
1964 | { |
|
|
1965 | char upordown = 0; |
|
|
1966 | |
|
|
1967 | if (scrollBar.style == R_SB_NEXT) |
|
|
1968 | { |
1980 | { |
1969 | if (scrollbarnext_upButton (ev.y)) |
1981 | if (direction != NO_DIR) |
1970 | upordown = -1; /* up */ |
|
|
1971 | else if (scrollbarnext_dnButton (ev.y)) |
|
|
1972 | upordown = 1; /* down */ |
|
|
1973 | } |
|
|
1974 | else if (scrollBar.style == R_SB_RXVT) |
|
|
1975 | { |
|
|
1976 | if (scrollbarrxvt_upButton (ev.y)) |
|
|
1977 | upordown = -1; /* up */ |
|
|
1978 | else if (scrollbarrxvt_dnButton (ev.y)) |
|
|
1979 | upordown = 1; /* down */ |
|
|
1980 | } |
|
|
1981 | if (upordown) |
|
|
1982 | { |
1982 | { |
1983 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
1983 | #ifndef NO_SCROLLBAR_BUTTON_CONTINUAL_SCROLLING |
|
|
1984 | if (!cont_scroll_ev.is_active ()) |
1984 | cont_scroll_ev.start (NOW + SCROLLBAR_INITIAL_DELAY); |
1985 | cont_scroll_ev.start (SCROLLBAR_INITIAL_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
1985 | #endif |
1986 | #endif |
1986 | if (scr_page (upordown < 0 ? UP : DN, 1)) |
1987 | if (scr_page (direction, 1)) |
1987 | { |
1988 | { |
1988 | if (upordown < 0) |
1989 | if (direction == UP) |
1989 | scrollBar.setUp (); |
1990 | scrollBar.state = STATE_UP; |
1990 | else |
1991 | else |
1991 | scrollBar.setDn (); |
1992 | scrollBar.state = STATE_DOWN; |
1992 | } |
1993 | } |
1993 | } |
1994 | } |
1994 | else |
1995 | else |
1995 | switch (ev.button) |
1996 | switch (ev.button) |
1996 | { |
1997 | { |
1997 | case Button2: |
1998 | case Button2: |
1998 | switch (scrollbar_align) |
1999 | switch (scrollBar.align) |
1999 | { |
2000 | { |
2000 | case R_SB_ALIGN_TOP: |
2001 | case R_SB_ALIGN_TOP: |
2001 | csrO = 0; |
2002 | csrO = 0; |
2002 | break; |
2003 | break; |
2003 | case R_SB_ALIGN_CENTRE: |
2004 | case R_SB_ALIGN_CENTRE: |
… | |
… | |
2011 | if (scrollBar.style == R_SB_XTERM |
2012 | if (scrollBar.style == R_SB_XTERM |
2012 | || scrollbar_above_slider (ev.y) |
2013 | || scrollbar_above_slider (ev.y) |
2013 | || scrollbar_below_slider (ev.y)) |
2014 | || scrollbar_below_slider (ev.y)) |
2014 | scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ()); |
2015 | scr_move_to (scrollbar_position (ev.y) - csrO, scrollbar_size ()); |
2015 | |
2016 | |
2016 | scrollBar.setMotion (); |
2017 | scrollBar.state = STATE_MOTION; |
2017 | break; |
2018 | break; |
2018 | |
2019 | |
2019 | case Button1: |
2020 | case Button1: |
2020 | if (scrollbar_align == R_SB_ALIGN_CENTRE) |
2021 | if (scrollBar.align == R_SB_ALIGN_CENTRE) |
2021 | csrO = ev.y - scrollBar.top; |
2022 | csrO = ev.y - scrollBar.top; |
2022 | /* FALLTHROUGH */ |
2023 | /* FALLTHROUGH */ |
2023 | |
2024 | |
2024 | case Button3: |
2025 | case Button3: |
2025 | if (scrollBar.style != R_SB_XTERM) |
2026 | if (scrollBar.style != R_SB_XTERM) |
… | |
… | |
2035 | scr_page (DN, nrow - 1); |
2036 | scr_page (DN, nrow - 1); |
2036 | # else |
2037 | # else |
2037 | scr_page (DN, nrow / 4); |
2038 | scr_page (DN, nrow / 4); |
2038 | # endif |
2039 | # endif |
2039 | else |
2040 | else |
2040 | scrollBar.setMotion (); |
2041 | scrollBar.state = STATE_MOTION; |
2041 | } |
2042 | } |
2042 | else |
2043 | else |
2043 | { |
2044 | { |
2044 | scr_page ((ev.button == Button1 ? DN : UP), |
2045 | scr_page ((ev.button == Button1 ? DN : UP), |
2045 | (nrow |
2046 | (nrow |
… | |
… | |
2062 | |
2063 | |
2063 | csrO = 0; /* reset csr Offset */ |
2064 | csrO = 0; /* reset csr Offset */ |
2064 | if (!bypass_keystate) |
2065 | if (!bypass_keystate) |
2065 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
2066 | reportmode = !! (priv_modes & PrivMode_mouse_report); |
2066 | |
2067 | |
2067 | if (scrollbar_isUpDn ()) |
2068 | if (scrollBar.state == STATE_UP || scrollBar.state == STATE_DOWN) |
2068 | { |
2069 | { |
2069 | scrollBar.setIdle (); |
2070 | scrollBar.state = STATE_IDLE; |
2070 | scrollbar_show (0); |
2071 | scrollbar_show (0); |
2071 | } |
2072 | } |
2072 | |
2073 | |
2073 | #ifdef SELECTION_SCROLLING |
2074 | #ifdef SELECTION_SCROLLING |
2074 | if (sel_scroll_ev.active) |
|
|
2075 | sel_scroll_ev.stop(); |
2075 | sel_scroll_ev.stop(); |
2076 | #endif |
2076 | #endif |
2077 | |
2077 | |
2078 | if (ev.window == vt) |
2078 | if (ev.window == vt) |
2079 | { |
2079 | { |
2080 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
2080 | if (HOOK_INVOKE ((this, HOOK_BUTTON_RELEASE, DT_XEVENT, &ev, DT_END))) |
… | |
… | |
2104 | mouse_report (ev); |
2104 | mouse_report (ev); |
2105 | } |
2105 | } |
2106 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
2106 | #else /* MOUSE_REPORT_DOUBLECLICK */ |
2107 | MEvent.button = AnyButton; |
2107 | MEvent.button = AnyButton; |
2108 | mouse_report (ev); |
2108 | mouse_report (ev); |
2109 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
2109 | #endif /* MOUSE_REPORT_DOUBLECLICK */ |
2110 | return; |
2110 | return; |
2111 | } |
2111 | } |
2112 | |
2112 | |
2113 | /* |
2113 | /* |
2114 | * dumb hack to compensate for the failure of click-and-drag |
2114 | * dumb hack to compensate for the failure of click-and-drag |
… | |
… | |
2126 | selection_make (ev.time); |
2126 | selection_make (ev.time); |
2127 | break; |
2127 | break; |
2128 | |
2128 | |
2129 | case Button2: |
2129 | case Button2: |
2130 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
2130 | if (IN_RANGE_EXC (ev.x, 0, width) && IN_RANGE_EXC (ev.y, 0, height)) // inside window? |
2131 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Primary : Sel_Primary); |
2131 | selection_request (ev.time, ev.state & ModMetaMask ? Sel_Clipboard : Sel_Primary); |
2132 | break; |
2132 | break; |
2133 | |
2133 | |
2134 | #ifdef MOUSE_WHEEL |
2134 | #ifdef MOUSE_WHEEL |
2135 | case Button4: |
2135 | case Button4: |
2136 | case Button5: |
2136 | case Button5: |
… | |
… | |
2140 | |
2140 | |
2141 | v = ev.button == Button4 ? UP : DN; |
2141 | v = ev.button == Button4 ? UP : DN; |
2142 | |
2142 | |
2143 | if (ev.state & ShiftMask) |
2143 | if (ev.state & ShiftMask) |
2144 | i = 1; |
2144 | i = 1; |
2145 | else if (OPTION (Opt_mouseWheelScrollPage)) |
2145 | else if (option (Opt_mouseWheelScrollPage)) |
2146 | i = nrow - 1; |
2146 | i = nrow - 1; |
2147 | else |
2147 | else |
2148 | i = 5; |
2148 | i = 5; |
2149 | |
2149 | |
2150 | # ifdef MOUSE_SLIP_WHEELING |
2150 | # ifdef MOUSE_SLIP_WHEELING |
… | |
… | |
2152 | { |
2152 | { |
2153 | mouse_slip_wheel_speed += v ? -1 : 1; |
2153 | mouse_slip_wheel_speed += v ? -1 : 1; |
2154 | if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; |
2154 | if (mouse_slip_wheel_speed < -nrow) mouse_slip_wheel_speed = -nrow; |
2155 | if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; |
2155 | if (mouse_slip_wheel_speed > +nrow) mouse_slip_wheel_speed = +nrow; |
2156 | |
2156 | |
2157 | if (slip_wheel_ev.at < NOW) |
2157 | if (!slip_wheel_ev.is_active ()) |
2158 | slip_wheel_ev.at = NOW + SCROLLBAR_CONTINUOUS_DELAY; |
2158 | slip_wheel_ev.start (SCROLLBAR_CONTINUOUS_DELAY, SCROLLBAR_CONTINUOUS_DELAY); |
2159 | |
|
|
2160 | slip_wheel_ev.start (); |
|
|
2161 | } |
2159 | } |
2162 | else |
2160 | else |
|
|
2161 | # endif |
2163 | { |
2162 | { |
2164 | # endif |
|
|
2165 | scr_page (v, i); |
2163 | scr_page (v, i); |
2166 | scrollbar_show (1); |
2164 | scrollbar_show (1); |
2167 | # ifdef MOUSE_SLIP_WHEELING |
|
|
2168 | } |
2165 | } |
2169 | # endif |
|
|
2170 | } |
2166 | } |
2171 | break; |
2167 | break; |
2172 | #endif |
2168 | #endif |
2173 | } |
2169 | } |
2174 | } |
2170 | } |
2175 | } |
2171 | } |
2176 | |
|
|
2177 | #ifdef TRANSPARENT |
|
|
2178 | #if TINTING |
|
|
2179 | /* taken from aterm-0.4.2 */ |
|
|
2180 | |
|
|
2181 | typedef uint32_t RUINT32T; |
|
|
2182 | |
|
|
2183 | void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) |
|
|
2184 | { |
|
|
2185 | int sh_r, sh_g, sh_b; |
|
|
2186 | RUINT32T mask_r, mask_g, mask_b; |
|
|
2187 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
|
|
2188 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
|
|
2189 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
|
|
2190 | int i; |
|
|
2191 | |
|
|
2192 | Visual *visual = term->visual; |
|
|
2193 | |
|
|
2194 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
|
|
2195 | |
|
|
2196 | /* for convenience */ |
|
|
2197 | mask_r = visual->red_mask; |
|
|
2198 | mask_g = visual->green_mask; |
|
|
2199 | mask_b = visual->blue_mask; |
|
|
2200 | |
|
|
2201 | /* boring lookup table pre-initialization */ |
|
|
2202 | switch (srcImage->bits_per_pixel) { |
|
|
2203 | case 15: |
|
|
2204 | if ((mask_r != 0x7c00) || |
|
|
2205 | (mask_g != 0x03e0) || |
|
|
2206 | (mask_b != 0x001f)) |
|
|
2207 | return; |
|
|
2208 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+32+32)); |
|
|
2209 | lookup_r = lookup; |
|
|
2210 | lookup_g = lookup+32; |
|
|
2211 | lookup_b = lookup+32+32; |
|
|
2212 | sh_r = 10; |
|
|
2213 | sh_g = 5; |
|
|
2214 | sh_b = 0; |
|
|
2215 | break; |
|
|
2216 | case 16: |
|
|
2217 | if ((mask_r != 0xf800) || |
|
|
2218 | (mask_g != 0x07e0) || |
|
|
2219 | (mask_b != 0x001f)) |
|
|
2220 | return; |
|
|
2221 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(32+64+32)); |
|
|
2222 | lookup_r = lookup; |
|
|
2223 | lookup_g = lookup+32; |
|
|
2224 | lookup_b = lookup+32+64; |
|
|
2225 | sh_r = 11; |
|
|
2226 | sh_g = 5; |
|
|
2227 | sh_b = 0; |
|
|
2228 | break; |
|
|
2229 | case 24: |
|
|
2230 | if ((mask_r != 0xff0000) || |
|
|
2231 | (mask_g != 0x00ff00) || |
|
|
2232 | (mask_b != 0x0000ff)) |
|
|
2233 | return; |
|
|
2234 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2235 | lookup_r = lookup; |
|
|
2236 | lookup_g = lookup+256; |
|
|
2237 | lookup_b = lookup+256+256; |
|
|
2238 | sh_r = 16; |
|
|
2239 | sh_g = 8; |
|
|
2240 | sh_b = 0; |
|
|
2241 | break; |
|
|
2242 | case 32: |
|
|
2243 | if ((mask_r != 0xff0000) || |
|
|
2244 | (mask_g != 0x00ff00) || |
|
|
2245 | (mask_b != 0x0000ff)) |
|
|
2246 | return; |
|
|
2247 | lookup = (RUINT32T *) malloc (sizeof (RUINT32T)*(256+256+256)); |
|
|
2248 | lookup_r = lookup; |
|
|
2249 | lookup_g = lookup+256; |
|
|
2250 | lookup_b = lookup+256+256; |
|
|
2251 | sh_r = 16; |
|
|
2252 | sh_g = 8; |
|
|
2253 | sh_b = 0; |
|
|
2254 | break; |
|
|
2255 | default: |
|
|
2256 | return; /* we do not support this color depth */ |
|
|
2257 | } |
|
|
2258 | |
|
|
2259 | /* prepare limits for color transformation (each channel is handled separately) */ |
|
|
2260 | if (shade < 0) { |
|
|
2261 | shade = -shade; |
|
|
2262 | if (shade < 0) shade = 0; |
|
|
2263 | if (shade > 100) shade = 100; |
|
|
2264 | |
|
|
2265 | lower_lim_r = 65535-rm; |
|
|
2266 | lower_lim_g = 65535-gm; |
|
|
2267 | lower_lim_b = 65535-bm; |
|
|
2268 | |
|
|
2269 | lower_lim_r = 65535-(unsigned int)(((RUINT32T)lower_lim_r)*((RUINT32T)shade)/100); |
|
|
2270 | lower_lim_g = 65535-(unsigned int)(((RUINT32T)lower_lim_g)*((RUINT32T)shade)/100); |
|
|
2271 | lower_lim_b = 65535-(unsigned int)(((RUINT32T)lower_lim_b)*((RUINT32T)shade)/100); |
|
|
2272 | |
|
|
2273 | upper_lim_r = upper_lim_g = upper_lim_b = 65535; |
|
|
2274 | } else { |
|
|
2275 | if (shade < 0) shade = 0; |
|
|
2276 | if (shade > 100) shade = 100; |
|
|
2277 | |
|
|
2278 | lower_lim_r = lower_lim_g = lower_lim_b = 0; |
|
|
2279 | |
|
|
2280 | upper_lim_r = (unsigned int)((((RUINT32T)rm)*((RUINT32T)shade))/100); |
|
|
2281 | upper_lim_g = (unsigned int)((((RUINT32T)gm)*((RUINT32T)shade))/100); |
|
|
2282 | upper_lim_b = (unsigned int)((((RUINT32T)bm)*((RUINT32T)shade))/100); |
|
|
2283 | } |
|
|
2284 | |
|
|
2285 | /* switch red and blue bytes if necessary, we need it for some weird XServers like XFree86 3.3.3.1 */ |
|
|
2286 | if ((srcImage->bits_per_pixel == 24) && (mask_r >= 0xFF0000 )) |
|
|
2287 | { |
|
|
2288 | unsigned int tmp; |
|
|
2289 | |
|
|
2290 | tmp = lower_lim_r; |
|
|
2291 | lower_lim_r = lower_lim_b; |
|
|
2292 | lower_lim_b = tmp; |
|
|
2293 | |
|
|
2294 | tmp = upper_lim_r; |
|
|
2295 | upper_lim_r = upper_lim_b; |
|
|
2296 | upper_lim_b = tmp; |
|
|
2297 | } |
|
|
2298 | |
|
|
2299 | /* fill our lookup tables */ |
|
|
2300 | for (i = 0; i <= mask_r>>sh_r; i++) |
|
|
2301 | { |
|
|
2302 | RUINT32T tmp; |
|
|
2303 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_r-lower_lim_r)); |
|
|
2304 | tmp += ((RUINT32T)(mask_r>>sh_r))*((RUINT32T)lower_lim_r); |
|
|
2305 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
2306 | } |
|
|
2307 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
2308 | { |
|
|
2309 | RUINT32T tmp; |
|
|
2310 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_g-lower_lim_g)); |
|
|
2311 | tmp += ((RUINT32T)(mask_g>>sh_g))*((RUINT32T)lower_lim_g); |
|
|
2312 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
2313 | } |
|
|
2314 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
2315 | { |
|
|
2316 | RUINT32T tmp; |
|
|
2317 | tmp = ((RUINT32T)i)*((RUINT32T)(upper_lim_b-lower_lim_b)); |
|
|
2318 | tmp += ((RUINT32T)(mask_b>>sh_b))*((RUINT32T)lower_lim_b); |
|
|
2319 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
2320 | } |
|
|
2321 | |
|
|
2322 | /* apply table to input image (replacing colors by newly calculated ones) */ |
|
|
2323 | switch (srcImage->bits_per_pixel) |
|
|
2324 | { |
|
|
2325 | case 15: |
|
|
2326 | { |
|
|
2327 | unsigned short *p1, *pf, *p, *pl; |
|
|
2328 | p1 = (unsigned short *) srcImage->data; |
|
|
2329 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2330 | while (p1 < pf) |
|
|
2331 | { |
|
|
2332 | p = p1; |
|
|
2333 | pl = p1 + srcImage->width; |
|
|
2334 | for (; p < pl; p++) |
|
|
2335 | { |
|
|
2336 | *p = lookup_r[(*p & 0x7c00)>>10] | |
|
|
2337 | lookup_g[(*p & 0x03e0)>> 5] | |
|
|
2338 | lookup_b[(*p & 0x001f)]; |
|
|
2339 | } |
|
|
2340 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2341 | } |
|
|
2342 | break; |
|
|
2343 | } |
|
|
2344 | case 16: |
|
|
2345 | { |
|
|
2346 | unsigned short *p1, *pf, *p, *pl; |
|
|
2347 | p1 = (unsigned short *) srcImage->data; |
|
|
2348 | pf = (unsigned short *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2349 | while (p1 < pf) |
|
|
2350 | { |
|
|
2351 | p = p1; |
|
|
2352 | pl = p1 + srcImage->width; |
|
|
2353 | for (; p < pl; p++) |
|
|
2354 | { |
|
|
2355 | *p = lookup_r[(*p & 0xf800)>>11] | |
|
|
2356 | lookup_g[(*p & 0x07e0)>> 5] | |
|
|
2357 | lookup_b[(*p & 0x001f)]; |
|
|
2358 | } |
|
|
2359 | p1 = (unsigned short *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2360 | } |
|
|
2361 | break; |
|
|
2362 | } |
|
|
2363 | case 24: |
|
|
2364 | { |
|
|
2365 | unsigned char *p1, *pf, *p, *pl; |
|
|
2366 | p1 = (unsigned char *) srcImage->data; |
|
|
2367 | pf = (unsigned char *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2368 | while (p1 < pf) |
|
|
2369 | { |
|
|
2370 | p = p1; |
|
|
2371 | pl = p1 + srcImage->width * 3; |
|
|
2372 | for (; p < pl; p += 3) |
|
|
2373 | { |
|
|
2374 | p[0] = lookup_r[(p[0] & 0xff0000)>>16]; |
|
|
2375 | p[1] = lookup_r[(p[1] & 0x00ff00)>> 8]; |
|
|
2376 | p[2] = lookup_r[(p[2] & 0x0000ff)]; |
|
|
2377 | } |
|
|
2378 | p1 = (unsigned char *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2379 | } |
|
|
2380 | break; |
|
|
2381 | } |
|
|
2382 | case 32: |
|
|
2383 | { |
|
|
2384 | RUINT32T *p1, *pf, *p, *pl; |
|
|
2385 | p1 = (RUINT32T *) srcImage->data; |
|
|
2386 | pf = (RUINT32T *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
|
|
2387 | |
|
|
2388 | while (p1 < pf) |
|
|
2389 | { |
|
|
2390 | p = p1; |
|
|
2391 | pl = p1 + srcImage->width; |
|
|
2392 | for (; p < pl; p++) |
|
|
2393 | { |
|
|
2394 | *p = lookup_r[(*p & 0xff0000)>>16] | |
|
|
2395 | lookup_g[(*p & 0x00ff00)>> 8] | |
|
|
2396 | lookup_b[(*p & 0x0000ff)] | |
|
|
2397 | (*p & ~0xffffff); |
|
|
2398 | } |
|
|
2399 | p1 = (RUINT32T *) ((char *) p1 + srcImage->bytes_per_line); |
|
|
2400 | } |
|
|
2401 | break; |
|
|
2402 | } |
|
|
2403 | } |
|
|
2404 | |
|
|
2405 | free (lookup); |
|
|
2406 | } |
|
|
2407 | #endif |
|
|
2408 | |
|
|
2409 | /* |
|
|
2410 | * Check our parents are still who we think they are. |
|
|
2411 | * Do transparency updates if required |
|
|
2412 | */ |
|
|
2413 | int |
|
|
2414 | rxvt_term::check_our_parents () |
|
|
2415 | { |
|
|
2416 | int i, pchanged, aformat, have_pixmap, rootdepth; |
|
|
2417 | unsigned long nitems, bytes_after; |
|
|
2418 | Atom atype; |
|
|
2419 | unsigned char *prop = NULL; |
|
|
2420 | Window root, oldp, *list; |
|
|
2421 | Pixmap rootpixmap = None; |
|
|
2422 | XWindowAttributes wattr, wrootattr; |
|
|
2423 | |
|
|
2424 | pchanged = 0; |
|
|
2425 | |
|
|
2426 | if (!OPTION (Opt_transparent)) |
|
|
2427 | return pchanged; /* Don't try any more */ |
|
|
2428 | |
|
|
2429 | XGetWindowAttributes (xdisp, display->root, &wrootattr); |
|
|
2430 | rootdepth = wrootattr.depth; |
|
|
2431 | |
|
|
2432 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
|
|
2433 | |
|
|
2434 | if (rootdepth != wattr.depth) |
|
|
2435 | { |
|
|
2436 | if (am_transparent) |
|
|
2437 | { |
|
|
2438 | pchanged = 1; |
|
|
2439 | XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); |
|
|
2440 | am_transparent = am_pixmap_trans = 0; |
|
|
2441 | } |
|
|
2442 | |
|
|
2443 | return pchanged; /* Don't try any more */ |
|
|
2444 | } |
|
|
2445 | |
|
|
2446 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
|
|
2447 | XSync (xdisp, False); |
|
|
2448 | |
|
|
2449 | /* |
|
|
2450 | * Make the frame window set by the window manager have |
|
|
2451 | * the root background. Some window managers put multiple nested frame |
|
|
2452 | * windows for each client, so we have to take care about that. |
|
|
2453 | */ |
|
|
2454 | i = (xa[XA_XROOTPMAP_ID] |
|
|
2455 | && XGetWindowProperty (xdisp, display->root, xa[XA_XROOTPMAP_ID], |
|
|
2456 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2457 | &nitems, &bytes_after, &prop) == Success); |
|
|
2458 | |
|
|
2459 | if (!i || prop == NULL) |
|
|
2460 | i = (xa[XA_ESETROOT_PMAP_ID] |
|
|
2461 | && XGetWindowProperty (xdisp, display->root, xa[XA_ESETROOT_PMAP_ID], |
|
|
2462 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
2463 | &nitems, &bytes_after, &prop) == Success); |
|
|
2464 | |
|
|
2465 | if (!i || prop == NULL |
|
|
2466 | #if TINTING |
|
|
2467 | || !rs[Rs_color + Color_tint] |
|
|
2468 | #endif |
|
|
2469 | ) |
|
|
2470 | have_pixmap = 0; |
|
|
2471 | else |
|
|
2472 | { |
|
|
2473 | have_pixmap = 1; |
|
|
2474 | rootpixmap = *(Pixmap *)prop; |
|
|
2475 | XFree (prop); |
|
|
2476 | } |
|
|
2477 | |
|
|
2478 | if (have_pixmap) |
|
|
2479 | { |
|
|
2480 | /* |
|
|
2481 | * Copy display->root pixmap transparency |
|
|
2482 | */ |
|
|
2483 | int sx, sy, nx, ny; |
|
|
2484 | unsigned int nw, nh; |
|
|
2485 | Window cr; |
|
|
2486 | XImage *image; |
|
|
2487 | GC gc; |
|
|
2488 | XGCValues gcvalue; |
|
|
2489 | |
|
|
2490 | XTranslateCoordinates (xdisp, parent[0], display->root, |
|
|
2491 | 0, 0, &sx, &sy, &cr); |
|
|
2492 | nw = (unsigned int)szHint.width; |
|
|
2493 | nh = (unsigned int)szHint.height; |
|
|
2494 | nx = ny = 0; |
|
|
2495 | |
|
|
2496 | if (sx < 0) |
|
|
2497 | { |
|
|
2498 | nw += sx; |
|
|
2499 | nx = -sx; |
|
|
2500 | sx = 0; |
|
|
2501 | } |
|
|
2502 | |
|
|
2503 | if (sy < 0) |
|
|
2504 | { |
|
|
2505 | nh += sy; |
|
|
2506 | ny = -sy; |
|
|
2507 | sy = 0; |
|
|
2508 | } |
|
|
2509 | |
|
|
2510 | min_it (nw, (unsigned int) (wrootattr.width - sx)); |
|
|
2511 | min_it (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2512 | |
|
|
2513 | XSync (xdisp, False); |
|
|
2514 | allowedxerror = -1; |
|
|
2515 | image = XGetImage (xdisp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
|
|
2516 | |
|
|
2517 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
|
|
2518 | /* XXX: may need a delay here? */ |
|
|
2519 | allowedxerror = 0; |
|
|
2520 | |
|
|
2521 | if (image == NULL) |
|
|
2522 | { |
|
|
2523 | if (am_transparent && am_pixmap_trans) |
|
|
2524 | { |
|
|
2525 | pchanged = 1; |
|
|
2526 | if (pixmap != None) |
|
|
2527 | { |
|
|
2528 | XFreePixmap (xdisp, pixmap); |
|
|
2529 | pixmap = None; |
|
|
2530 | } |
|
|
2531 | } |
|
|
2532 | |
|
|
2533 | am_pixmap_trans = 0; |
|
|
2534 | } |
|
|
2535 | else |
|
|
2536 | { |
|
|
2537 | if (pixmap != None) |
|
|
2538 | XFreePixmap (xdisp, pixmap); |
|
|
2539 | |
|
|
2540 | #if TINTING |
|
|
2541 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
2542 | { |
|
|
2543 | int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100; |
|
|
2544 | |
|
|
2545 | rxvt_rgba c; |
|
|
2546 | pix_colors_focused [Color_tint].get (this, c); |
|
|
2547 | |
|
|
2548 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
|
|
2549 | } |
|
|
2550 | #endif |
|
|
2551 | |
|
|
2552 | pixmap = XCreatePixmap (xdisp, vt, szHint.width, szHint.height, image->depth); |
|
|
2553 | gc = XCreateGC (xdisp, vt, 0UL, &gcvalue); |
|
|
2554 | XPutImage (xdisp, pixmap, gc, image, 0, 0, |
|
|
2555 | nx, ny, image->width, image->height); |
|
|
2556 | XFreeGC (xdisp, gc); |
|
|
2557 | XDestroyImage (image); |
|
|
2558 | XSetWindowBackgroundPixmap (xdisp, parent[0], pixmap); |
|
|
2559 | XClearWindow (xdisp, parent[0]); |
|
|
2560 | |
|
|
2561 | if (!am_transparent || !am_pixmap_trans) |
|
|
2562 | pchanged = 1; |
|
|
2563 | |
|
|
2564 | am_transparent = am_pixmap_trans = 1; |
|
|
2565 | } |
|
|
2566 | } |
|
|
2567 | |
|
|
2568 | if (am_pixmap_trans) |
|
|
2569 | XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); |
|
|
2570 | else |
|
|
2571 | { |
|
|
2572 | unsigned int n; |
|
|
2573 | /* |
|
|
2574 | * InheritPixmap transparency |
|
|
2575 | */ |
|
|
2576 | for (i = 1; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2577 | { |
|
|
2578 | oldp = parent[i]; |
|
|
2579 | XQueryTree (xdisp, parent[i - 1], &root, |
|
|
2580 | &parent[i], &list, &n); |
|
|
2581 | XFree (list); |
|
|
2582 | |
|
|
2583 | if (parent[i] == display->root) |
|
|
2584 | { |
|
|
2585 | if (oldp != None) |
|
|
2586 | pchanged = 1; |
|
|
2587 | |
|
|
2588 | break; |
|
|
2589 | } |
|
|
2590 | |
|
|
2591 | if (oldp != parent[i]) |
|
|
2592 | pchanged = 1; |
|
|
2593 | } |
|
|
2594 | |
|
|
2595 | n = 0; |
|
|
2596 | |
|
|
2597 | if (pchanged) |
|
|
2598 | { |
|
|
2599 | for (; n < (unsigned int)i; n++) |
|
|
2600 | { |
|
|
2601 | XGetWindowAttributes (xdisp, parent[n], &wattr); |
|
|
2602 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
|
|
2603 | { |
|
|
2604 | n = (int) (sizeof (parent) / sizeof (Window)) + 1; |
|
|
2605 | break; |
|
|
2606 | } |
|
|
2607 | } |
|
|
2608 | } |
|
|
2609 | |
|
|
2610 | if (n > (int) (sizeof (parent) / sizeof (parent[0]))) |
|
|
2611 | { |
|
|
2612 | XSetWindowBackground (xdisp, parent[0], pix_colors_focused[Color_border]); |
|
|
2613 | XSetWindowBackground (xdisp, vt, pix_colors_focused[Color_bg]); |
|
|
2614 | am_transparent = 0; |
|
|
2615 | /* XXX: also turn off Opt_transparent? */ |
|
|
2616 | } |
|
|
2617 | else |
|
|
2618 | { |
|
|
2619 | for (n = 0; n < (unsigned int)i; n++) |
|
|
2620 | { |
|
|
2621 | XSetWindowBackgroundPixmap (xdisp, parent[n], ParentRelative); |
|
|
2622 | XClearWindow (xdisp, parent[n]); |
|
|
2623 | } |
|
|
2624 | |
|
|
2625 | XSetWindowBackgroundPixmap (xdisp, vt, ParentRelative); |
|
|
2626 | am_transparent = 1; |
|
|
2627 | } |
|
|
2628 | |
|
|
2629 | for (; i < (int) (sizeof (parent) / sizeof (Window)); i++) |
|
|
2630 | parent[i] = None; |
|
|
2631 | } |
|
|
2632 | |
|
|
2633 | if (scrollBar.win) |
|
|
2634 | { |
|
|
2635 | XSetWindowBackgroundPixmap (xdisp, scrollBar.win, ParentRelative); |
|
|
2636 | scrollBar.setIdle (); |
|
|
2637 | scrollbar_show (0); |
|
|
2638 | } |
|
|
2639 | |
|
|
2640 | if (am_transparent) |
|
|
2641 | { |
|
|
2642 | want_refresh = want_full_refresh = 1; |
|
|
2643 | if (am_pixmap_trans) |
|
|
2644 | flush (); |
|
|
2645 | } |
|
|
2646 | |
|
|
2647 | return pchanged; |
|
|
2648 | } |
|
|
2649 | #endif |
|
|
2650 | |
2172 | |
2651 | /*}}} */ |
2173 | /*}}} */ |
2652 | |
2174 | |
2653 | bool |
2175 | bool |
2654 | rxvt_term::cmd_parse () |
2176 | rxvt_term::cmd_parse () |
… | |
… | |
2703 | if (ch == C0_LF) |
2225 | if (ch == C0_LF) |
2704 | nlines++; |
2226 | nlines++; |
2705 | |
2227 | |
2706 | refresh_count++; |
2228 | refresh_count++; |
2707 | |
2229 | |
2708 | if (!OPTION (Opt_jumpScroll) |
2230 | if (!option (Opt_jumpScroll) || refresh_count >= nrow - 1) |
2709 | || (refresh_count >= refresh_limit * (nrow - 1))) |
|
|
2710 | { |
2231 | { |
2711 | refreshnow = true; |
|
|
2712 | refresh_count = 0; |
2232 | refresh_count = 0; |
|
|
2233 | |
|
|
2234 | if (!option (Opt_skipScroll) || ev_time () > ev::now () + 1. / 60.) |
|
|
2235 | { |
|
|
2236 | refreshnow = true; |
2713 | ch = NOCHAR; |
2237 | ch = NOCHAR; |
2714 | break; |
2238 | break; |
|
|
2239 | } |
2715 | } |
2240 | } |
2716 | |
2241 | |
2717 | // scr_add_lines only works for nlines <= nrow - 1. |
2242 | // scr_add_lines only works for nlines <= nrow - 1. |
2718 | if (nlines >= nrow - 1) |
2243 | if (nlines >= nrow - 1) |
2719 | { |
2244 | { |
… | |
… | |
2747 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2272 | && HOOK_INVOKE ((this, HOOK_ADD_LINES, DT_WCS_LEN, buf, str - buf, DT_END)))) |
2748 | scr_add_lines (buf, str - buf, nlines); |
2273 | scr_add_lines (buf, str - buf, nlines); |
2749 | |
2274 | |
2750 | /* |
2275 | /* |
2751 | * If there have been a lot of new lines, then update the screen |
2276 | * If there have been a lot of new lines, then update the screen |
2752 | * What the heck I'll cheat and only refresh less than every page-full. |
2277 | * What the heck we'll cheat and only refresh less than every page-full. |
2753 | * the number of pages between refreshes is refresh_limit, which |
2278 | * if skipScroll is enabled. |
2754 | * is incremented here because we must be doing flat-out scrolling. |
|
|
2755 | */ |
2279 | */ |
2756 | if (refreshnow) |
2280 | if (refreshnow) |
2757 | { |
2281 | { |
2758 | if (OPTION (Opt_jumpScroll) && refresh_limit < REFRESH_PERIOD) |
|
|
2759 | refresh_limit++; |
|
|
2760 | else |
|
|
2761 | { |
|
|
2762 | flag = true; |
2282 | flag = true; |
2763 | scr_refresh (); |
2283 | scr_refresh (); |
2764 | want_refresh = 1; |
2284 | want_refresh = 1; |
2765 | } |
|
|
2766 | } |
2285 | } |
2767 | |
2286 | |
2768 | } |
2287 | } |
2769 | else |
2288 | else |
2770 | { |
2289 | { |
… | |
… | |
2919 | { |
2438 | { |
2920 | if ((buf[len++] = cmd_getc ()) == 'i') |
2439 | if ((buf[len++] = cmd_getc ()) == 'i') |
2921 | break; /* done = 1 */ |
2440 | break; /* done = 1 */ |
2922 | } |
2441 | } |
2923 | } |
2442 | } |
2924 | |
2443 | |
2925 | for (i = 0; i < len; i++) |
2444 | for (i = 0; i < len; i++) |
2926 | if (putc (buf[i], fd) == EOF) |
2445 | if (putc (buf[i], fd) == EOF) |
2927 | { |
2446 | { |
2928 | done = 1; |
2447 | done = 1; |
2929 | break; |
2448 | break; |
… | |
… | |
2931 | } |
2450 | } |
2932 | } |
2451 | } |
2933 | |
2452 | |
2934 | pclose_printer (fd); |
2453 | pclose_printer (fd); |
2935 | } |
2454 | } |
2936 | #endif /* PRINTPIPE */ |
2455 | #endif /* PRINTPIPE */ |
2937 | /*}}} */ |
2456 | /*}}} */ |
2938 | |
2457 | |
2939 | /* *INDENT-OFF* */ |
2458 | /* *INDENT-OFF* */ |
2940 | enum { |
2459 | enum { |
2941 | C1_40 = 0x40, |
2460 | C1_40 = 0x40, |
… | |
… | |
2991 | process_dcs_seq (); |
2510 | process_dcs_seq (); |
2992 | break; |
2511 | break; |
2993 | case 0x9b: /* CSI */ |
2512 | case 0x9b: /* CSI */ |
2994 | process_csi_seq (); |
2513 | process_csi_seq (); |
2995 | break; |
2514 | break; |
2996 | case 0x9d: /* CSI */ |
2515 | case 0x9d: /* OSC */ |
2997 | process_osc_seq (); |
2516 | process_osc_seq (); |
2998 | break; |
2517 | break; |
2999 | #endif |
2518 | #endif |
3000 | } |
2519 | } |
3001 | } |
2520 | } |
… | |
… | |
3227 | rxvt_term::process_csi_seq () |
2746 | rxvt_term::process_csi_seq () |
3228 | { |
2747 | { |
3229 | unicode_t ch, priv, i; |
2748 | unicode_t ch, priv, i; |
3230 | unsigned int nargs, p; |
2749 | unsigned int nargs, p; |
3231 | int n, ndef; |
2750 | int n, ndef; |
3232 | int arg[ESC_ARGS]; |
2751 | int arg[ESC_ARGS] = { }; |
3233 | |
2752 | |
3234 | for (nargs = ESC_ARGS; nargs > 0;) |
2753 | nargs = 0; |
3235 | arg[--nargs] = 0; |
|
|
3236 | |
2754 | |
3237 | priv = 0; |
2755 | priv = 0; |
3238 | ch = cmd_getc (); |
2756 | ch = cmd_getc (); |
3239 | if (ch >= '<' && ch <= '?') |
2757 | if (ch >= '<' && ch <= '?') |
|
|
2758 | { |
3240 | { /* '<' '=' '>' '?' */ |
2759 | /* '<' '=' '>' '?' */ |
3241 | priv = ch; |
2760 | priv = ch; |
3242 | ch = cmd_getc (); |
2761 | ch = cmd_getc (); |
3243 | } |
2762 | } |
3244 | |
2763 | |
3245 | /* read any numerical arguments */ |
2764 | /* read any numerical arguments */ |
… | |
… | |
3284 | switch (priv) |
2803 | switch (priv) |
3285 | { |
2804 | { |
3286 | case '>': |
2805 | case '>': |
3287 | if (ch == CSI_DA) /* secondary device attributes */ |
2806 | if (ch == CSI_DA) /* secondary device attributes */ |
3288 | { |
2807 | { |
3289 | // first parameter is normally 0 for vt100, 1 for some newer vtxxx, 'R' for rxvt, |
2808 | // first parameter is normally 0 for vt100, 1 for vt220, 'R' for rxvt, |
3290 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
2809 | // 'U' for rxvt-unicode != 7.[34] (where it was broken). |
3291 | // |
2810 | // |
3292 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
2811 | // second parameter is xterm patch level for xterm, MMmmpp (e.g. 20703) for rxvt |
3293 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, and 94 for later versions, to signify |
2812 | // and Mm (e.g. 72 for 7.2) for urxvt <= 7.2, 94 for urxvt <= 8.3, and 95 for later |
3294 | // that we do not support xterm mouse reporting (should be 95 when we do). |
2813 | // versions. |
3295 | // |
2814 | // |
3296 | tt_printf ("\033[>%d;94;0c", 'U'); |
2815 | tt_printf ("\033[>%d;95;0c", 'U'); |
3297 | } |
2816 | } |
3298 | break; |
2817 | break; |
|
|
2818 | |
3299 | case '?': |
2819 | case '?': |
3300 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
2820 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3301 | process_terminal_mode (ch, priv, nargs, arg); |
2821 | process_terminal_mode (ch, priv, nargs, arg); |
3302 | break; |
2822 | break; |
3303 | } |
2823 | } |
… | |
… | |
3428 | break; |
2948 | break; |
3429 | case 6: /* CPR requested */ |
2949 | case 6: /* CPR requested */ |
3430 | scr_report_position (); |
2950 | scr_report_position (); |
3431 | break; |
2951 | break; |
3432 | case 7: /* unofficial extension */ |
2952 | case 7: /* unofficial extension */ |
3433 | if (OPTION (Opt_insecure)) |
2953 | if (option (Opt_insecure)) |
3434 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
2954 | tt_printf ("%-.250s\012", rs[Rs_display_name]); |
3435 | break; |
2955 | break; |
3436 | case 8: /* unofficial extension */ |
2956 | case 8: /* unofficial extension */ |
3437 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
2957 | process_xterm_seq (XTerm_title, RESNAME "-" VERSION, CHAR_ST); |
3438 | break; |
2958 | break; |
… | |
… | |
3531 | { |
3051 | { |
3532 | int x, y; |
3052 | int x, y; |
3533 | XWindowAttributes wattr; |
3053 | XWindowAttributes wattr; |
3534 | Window wdummy; |
3054 | Window wdummy; |
3535 | |
3055 | |
3536 | dLocal (Display *, xdisp); |
3056 | dLocal (Display *, dpy); |
3537 | |
3057 | |
3538 | if (nargs == 0) |
3058 | if (nargs == 0) |
3539 | return; |
3059 | return; |
3540 | |
3060 | |
3541 | switch (args[0]) |
3061 | switch (args[0]) |
3542 | { |
3062 | { |
3543 | /* |
3063 | /* |
3544 | * commands |
3064 | * commands |
3545 | */ |
3065 | */ |
3546 | case 1: /* deiconify window */ |
3066 | case 1: /* deiconify window */ |
3547 | XMapWindow (xdisp, parent[0]); |
3067 | XMapWindow (dpy, parent[0]); |
3548 | break; |
3068 | break; |
3549 | case 2: /* iconify window */ |
3069 | case 2: /* iconify window */ |
3550 | XIconifyWindow (xdisp, parent[0], display->screen); |
3070 | XIconifyWindow (dpy, parent[0], display->screen); |
3551 | break; |
3071 | break; |
3552 | case 3: /* set position (pixels) */ |
3072 | case 3: /* set position (pixels) */ |
3553 | XMoveWindow (xdisp, parent[0], args[1], args[2]); |
3073 | XMoveWindow (dpy, parent[0], args[1], args[2]); |
3554 | break; |
3074 | break; |
3555 | case 4: /* set size (pixels) */ |
3075 | case 4: /* set size (pixels) */ |
3556 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3076 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3557 | break; |
3077 | break; |
3558 | case 5: /* raise window */ |
3078 | case 5: /* raise window */ |
3559 | XRaiseWindow (xdisp, parent[0]); |
3079 | XRaiseWindow (dpy, parent[0]); |
3560 | break; |
3080 | break; |
3561 | case 6: /* lower window */ |
3081 | case 6: /* lower window */ |
3562 | XLowerWindow (xdisp, parent[0]); |
3082 | XLowerWindow (dpy, parent[0]); |
3563 | break; |
3083 | break; |
3564 | case 7: /* refresh window */ |
3084 | case 7: /* refresh window */ |
3565 | scr_touch (true); |
3085 | scr_touch (true); |
3566 | break; |
3086 | break; |
3567 | case 8: /* set size (chars) */ |
3087 | case 8: /* set size (chars) */ |
… | |
… | |
3574 | if (args[0] >= 24) /* set height (chars) */ |
3094 | if (args[0] >= 24) /* set height (chars) */ |
3575 | set_widthheight ((unsigned int)width, |
3095 | set_widthheight ((unsigned int)width, |
3576 | (unsigned int) (args[1] * fheight)); |
3096 | (unsigned int) (args[1] * fheight)); |
3577 | break; |
3097 | break; |
3578 | |
3098 | |
3579 | |
|
|
3580 | /* |
3099 | /* |
3581 | * reports - some output format copied from XTerm |
3100 | * reports - some output format copied from XTerm |
3582 | */ |
3101 | */ |
3583 | case 11: /* report window state */ |
3102 | case 11: /* report window state */ |
3584 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3103 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3585 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3104 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3586 | break; |
3105 | break; |
3587 | case 13: /* report window position */ |
3106 | case 13: /* report window position */ |
3588 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3107 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3589 | XTranslateCoordinates (xdisp, parent[0], wattr.root, |
3108 | XTranslateCoordinates (dpy, parent[0], wattr.root, |
3590 | -wattr.border_width, -wattr.border_width, |
3109 | -wattr.border_width, -wattr.border_width, |
3591 | &x, &y, &wdummy); |
3110 | &x, &y, &wdummy); |
3592 | tt_printf ("\033[3;%d;%dt", x, y); |
3111 | tt_printf ("\033[3;%d;%dt", x, y); |
3593 | break; |
3112 | break; |
3594 | case 14: /* report window size (pixels) */ |
3113 | case 14: /* report window size (pixels) */ |
3595 | XGetWindowAttributes (xdisp, parent[0], &wattr); |
3114 | XGetWindowAttributes (dpy, parent[0], &wattr); |
3596 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3115 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3597 | break; |
3116 | break; |
3598 | case 18: /* report text area size (chars) */ |
3117 | case 18: /* report text area size (chars) */ |
3599 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3118 | tt_printf ("\033[8;%d;%dt", nrow, ncol); |
3600 | break; |
3119 | break; |
… | |
… | |
3602 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3121 | tt_printf ("\033[9;%d;%dt", nrow, ncol); |
3603 | break; |
3122 | break; |
3604 | case 20: /* report icon label */ |
3123 | case 20: /* report icon label */ |
3605 | { |
3124 | { |
3606 | char *s; |
3125 | char *s; |
3607 | XGetIconName (xdisp, parent[0], &s); |
3126 | XGetIconName (dpy, parent[0], &s); |
3608 | tt_printf ("\033]L%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3127 | tt_printf ("\033]L%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3609 | XFree (s); |
3128 | XFree (s); |
3610 | } |
3129 | } |
3611 | break; |
3130 | break; |
3612 | case 21: /* report window title */ |
3131 | case 21: /* report window title */ |
3613 | { |
3132 | { |
3614 | char *s; |
3133 | char *s; |
3615 | XFetchName (xdisp, parent[0], &s); |
3134 | XFetchName (dpy, parent[0], &s); |
3616 | tt_printf ("\033]l%-.250s\234", OPTION (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3135 | tt_printf ("\033]l%-.250s\234", option (Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3617 | XFree (s); |
3136 | XFree (s); |
3618 | } |
3137 | } |
3619 | break; |
3138 | break; |
3620 | } |
3139 | } |
3621 | } |
3140 | } |
… | |
… | |
3648 | seen_esc = true; |
3167 | seen_esc = true; |
3649 | continue; |
3168 | continue; |
3650 | } |
3169 | } |
3651 | else if (ch == C0_BEL || ch == CHAR_ST) |
3170 | else if (ch == C0_BEL || ch == CHAR_ST) |
3652 | break; |
3171 | break; |
|
|
3172 | else if (ch == C0_SYN) |
|
|
3173 | ch = cmd_get8 (); |
3653 | else if (ch < 0x20) |
3174 | else if (ch < 0x20) |
3654 | return NULL; /* other control character - exit */ |
3175 | return NULL; /* other control character - exit */ |
3655 | |
3176 | |
3656 | seen_esc = false; |
3177 | seen_esc = false; |
3657 | |
3178 | |
3658 | if (n >= STRING_MAX - 1) |
3179 | if (n >= STRING_MAX - 1) |
3659 | // stop at some sane length |
3180 | // stop at some sane length |
3660 | return NULL; |
3181 | return NULL; |
3661 | |
3182 | |
3662 | if (ch == C0_SYN) |
|
|
3663 | string[n++] = cmd_get8 (); |
|
|
3664 | else |
|
|
3665 | string[n++] = ch; |
3183 | string[n++] = ch; |
3666 | } |
3184 | } |
3667 | |
3185 | |
3668 | string[n++] = '\0'; |
3186 | string[n++] = '\0'; |
3669 | |
3187 | |
3670 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3188 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
… | |
… | |
3721 | void |
3239 | void |
3722 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3240 | rxvt_term::process_color_seq (int report, int color, const char *str, char resp) |
3723 | { |
3241 | { |
3724 | if (str[0] == '?' && !str[1]) |
3242 | if (str[0] == '?' && !str[1]) |
3725 | { |
3243 | { |
3726 | rxvt_rgba c; |
3244 | rgba c; |
3727 | pix_colors_focused[color].get (this, c); |
3245 | pix_colors_focused[color].get (c); |
3728 | |
3246 | |
3729 | #if XFT |
3247 | #if XFT |
3730 | if (c.a != rxvt_rgba::MAX_CC) |
3248 | if (c.a != rgba::MAX_CC) |
3731 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
3249 | tt_printf ("\033]%d;rgba:%04x/%04x/%04x/%04x%c", report, c.a, c.r, c.g, c.b, resp); |
3732 | else |
3250 | else |
3733 | #endif |
3251 | #endif |
3734 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3252 | tt_printf ("\033]%d;rgb:%04x/%04x/%04x%c", report, c.r, c.g, c.b, resp); |
3735 | } |
3253 | } |
… | |
… | |
3746 | int color; |
3264 | int color; |
3747 | char *buf, *name; |
3265 | char *buf, *name; |
3748 | bool query = str[0] == '?' && !str[1]; |
3266 | bool query = str[0] == '?' && !str[1]; |
3749 | int saveop = op; |
3267 | int saveop = op; |
3750 | |
3268 | |
3751 | dLocal (Display *, xdisp); |
3269 | dLocal (Display *, dpy); |
3752 | |
3270 | |
3753 | assert (str != NULL); |
3271 | assert (str != NULL); |
|
|
3272 | |
|
|
3273 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_INT, op, DT_STR, str, DT_END))) |
|
|
3274 | return; |
|
|
3275 | |
3754 | switch (op) |
3276 | switch (op) |
3755 | { |
3277 | { |
3756 | case XTerm_name: |
3278 | case XTerm_name: |
3757 | set_title (str); |
3279 | set_title (str); |
3758 | /* FALLTHROUGH */ |
3280 | /* FALLTHROUGH */ |
… | |
… | |
3772 | unsigned long bytes_after; |
3294 | unsigned long bytes_after; |
3773 | unsigned char *value = 0; |
3295 | unsigned char *value = 0; |
3774 | const char *str = ""; |
3296 | const char *str = ""; |
3775 | |
3297 | |
3776 | if (prop |
3298 | if (prop |
3777 | && XGetWindowProperty (xdisp, parent[0], |
3299 | && XGetWindowProperty (dpy, parent[0], |
3778 | prop, 0, 1<<16, 0, AnyPropertyType, |
3300 | prop, 0, 1<<16, 0, AnyPropertyType, |
3779 | &actual_type, &actual_format, |
3301 | &actual_type, &actual_format, |
3780 | &nitems, &bytes_after, &value) == Success |
3302 | &nitems, &bytes_after, &value) == Success |
3781 | && actual_type != None |
3303 | && actual_type != None |
3782 | && actual_format == 8) |
3304 | && actual_format == 8) |
… | |
… | |
3794 | { |
3316 | { |
3795 | *eq = 0; |
3317 | *eq = 0; |
3796 | set_utf8_property (display->atom (str), eq + 1); |
3318 | set_utf8_property (display->atom (str), eq + 1); |
3797 | } |
3319 | } |
3798 | else |
3320 | else |
3799 | XDeleteProperty (xdisp, parent[0], |
3321 | XDeleteProperty (dpy, parent[0], |
3800 | display->atom (str)); |
3322 | display->atom (str)); |
3801 | } |
3323 | } |
3802 | break; |
3324 | break; |
3803 | |
3325 | |
3804 | case XTerm_Color: |
3326 | case XTerm_Color: |
… | |
… | |
3817 | *buf++ = '\0'; |
3339 | *buf++ = '\0'; |
3818 | |
3340 | |
3819 | process_color_seq (op, color, name, resp); |
3341 | process_color_seq (op, color, name, resp); |
3820 | } |
3342 | } |
3821 | break; |
3343 | break; |
|
|
3344 | case Rxvt_restoreFG: |
3822 | case XTerm_Color00: |
3345 | case XTerm_Color00: |
3823 | process_color_seq (op, Color_fg, str, resp); |
3346 | process_color_seq (op, Color_fg, str, resp); |
3824 | break; |
3347 | break; |
|
|
3348 | case Rxvt_restoreBG: |
3825 | case XTerm_Color01: |
3349 | case XTerm_Color01: |
3826 | process_color_seq (op, Color_bg, str, resp); |
3350 | process_color_seq (op, Color_bg, str, resp); |
3827 | break; |
3351 | break; |
3828 | #ifndef NO_CURSORCOLOR |
3352 | #ifndef NO_CURSORCOLOR |
3829 | case XTerm_Color_cursor: |
3353 | case XTerm_Color_cursor: |
… | |
… | |
3850 | break; |
3374 | break; |
3851 | case URxvt_Color_IT: |
3375 | case URxvt_Color_IT: |
3852 | process_color_seq (op, Color_IT, str, resp); |
3376 | process_color_seq (op, Color_IT, str, resp); |
3853 | break; |
3377 | break; |
3854 | #endif |
3378 | #endif |
3855 | #if TRANSPARENT && TINTING |
3379 | #if ENABLE_TRANSPARENCY |
3856 | case URxvt_Color_tint: |
3380 | case URxvt_Color_tint: |
3857 | process_color_seq (op, Color_tint, str, resp); |
3381 | process_color_seq (op, Color_tint, str, resp); |
3858 | check_our_parents (); |
3382 | { |
3859 | if (am_transparent) |
3383 | bool changed = false; |
3860 | want_full_refresh = want_refresh = 1; |
|
|
3861 | break; |
|
|
3862 | #endif |
|
|
3863 | |
3384 | |
|
|
3385 | if (ISSET_PIXCOLOR (Color_tint)) |
|
|
3386 | changed = bgPixmap.set_tint (pix_colors_focused [Color_tint]); |
|
|
3387 | else |
|
|
3388 | changed = bgPixmap.unset_tint (); |
|
|
3389 | |
|
|
3390 | if (changed) |
|
|
3391 | update_background (); |
|
|
3392 | } |
|
|
3393 | |
|
|
3394 | break; |
|
|
3395 | #endif |
|
|
3396 | |
|
|
3397 | #if BG_IMAGE_FROM_FILE |
3864 | case Rxvt_Pixmap: |
3398 | case Rxvt_Pixmap: |
3865 | { |
3399 | if (!strcmp (str, "?")) |
3866 | if (*str != ';') |
|
|
3867 | { |
3400 | { |
3868 | #if XPM_BACKGROUND |
3401 | char str[256]; |
3869 | scale_pixmap (""); /* reset to default scaling */ |
3402 | |
3870 | set_bgPixmap (str); /* change pixmap */ |
3403 | sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ |
3871 | scr_touch (true); |
3404 | min (bgPixmap.h_scale, 32767), min (bgPixmap.v_scale, 32767), |
3872 | #endif |
3405 | min (bgPixmap.h_align, 32767), min (bgPixmap.v_align, 32767)); |
|
|
3406 | process_xterm_seq (XTerm_title, str, CHAR_ST); |
3873 | } |
3407 | } |
3874 | |
3408 | else |
|
|
3409 | { |
3875 | int changed = 0; |
3410 | int changed = 0; |
3876 | |
3411 | |
3877 | while ((str = strchr (str, ';')) != NULL) |
3412 | if (*str != ';') |
3878 | { |
3413 | { |
|
|
3414 | /* reset to default scaling :*/ |
|
|
3415 | bgPixmap.unset_geometry (); |
|
|
3416 | if (bgPixmap.set_file (str)) /* change pixmap */ |
|
|
3417 | changed++; |
|
|
3418 | str = strchr (str, ';'); |
|
|
3419 | if (str == NULL) |
|
|
3420 | bgPixmap.set_defaultGeometry (); |
|
|
3421 | } |
|
|
3422 | |
|
|
3423 | while (str) |
|
|
3424 | { |
3879 | str++; |
3425 | str++; |
3880 | #if XPM_BACKGROUND |
3426 | if (bgPixmap.set_geometry (str)) |
3881 | changed += scale_pixmap (str); |
3427 | changed++; |
3882 | #endif |
3428 | str = strchr (str, ';'); |
3883 | } |
3429 | } |
3884 | |
3430 | |
3885 | if (changed) |
3431 | if (changed) |
3886 | { |
3432 | update_background (); |
3887 | #ifdef XPM_BACKGROUND |
|
|
3888 | resize_pixmap (); |
|
|
3889 | scr_touch (true); |
|
|
3890 | #endif |
|
|
3891 | } |
3433 | } |
3892 | } |
|
|
3893 | break; |
3434 | break; |
3894 | |
3435 | #endif |
3895 | case Rxvt_restoreFG: |
|
|
3896 | set_window_color (Color_fg, str); |
|
|
3897 | break; |
|
|
3898 | case Rxvt_restoreBG: |
|
|
3899 | set_window_color (Color_bg, str); |
|
|
3900 | break; |
|
|
3901 | |
3436 | |
3902 | case XTerm_logfile: |
3437 | case XTerm_logfile: |
3903 | // TODO, when secure mode? |
3438 | // TODO, when secure mode? |
3904 | break; |
3439 | break; |
3905 | |
3440 | |
… | |
… | |
3923 | case URxvt_italicFont: |
3458 | case URxvt_italicFont: |
3924 | case URxvt_boldItalicFont: |
3459 | case URxvt_boldItalicFont: |
3925 | #endif |
3460 | #endif |
3926 | if (query) |
3461 | if (query) |
3927 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3462 | tt_printf ("\33]%d;%-.250s%c", saveop, |
3928 | OPTION (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3463 | option (Opt_insecure) && fontset[op - URxvt_font]->fontdesc |
3929 | ? fontset[op - URxvt_font]->fontdesc : "", |
3464 | ? fontset[op - URxvt_font]->fontdesc : "", |
3930 | resp); |
3465 | resp); |
3931 | else |
3466 | else |
3932 | { |
3467 | { |
3933 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
3468 | const char *&res = rs[Rs_font + (op - URxvt_font)]; |
… | |
… | |
3947 | break; |
3482 | break; |
3948 | |
3483 | |
3949 | #if !ENABLE_MINIMAL |
3484 | #if !ENABLE_MINIMAL |
3950 | case URxvt_locale: |
3485 | case URxvt_locale: |
3951 | if (query) |
3486 | if (query) |
3952 | tt_printf ("\33]%d;%-.250s%c", op, OPTION (Opt_insecure) ? locale : "", resp); |
3487 | tt_printf ("\33]%d;%-.250s%c", op, option (Opt_insecure) ? locale : "", resp); |
3953 | else |
3488 | else |
3954 | { |
3489 | { |
3955 | set_locale (str); |
3490 | set_locale (str); |
3956 | pty->set_utf8_mode (enc_utf8); |
3491 | pty->set_utf8_mode (enc_utf8); |
3957 | init_xlocale (); |
3492 | init_xlocale (); |
… | |
… | |
3972 | break; |
3507 | break; |
3973 | #endif |
3508 | #endif |
3974 | |
3509 | |
3975 | #if ENABLE_PERL |
3510 | #if ENABLE_PERL |
3976 | case URxvt_perl: |
3511 | case URxvt_perl: |
3977 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ, DT_STR, str, DT_END))) |
3512 | if (HOOK_INVOKE ((this, HOOK_OSC_SEQ_PERL, DT_STR, str, DT_END))) |
3978 | ; // no responses yet |
3513 | ; // no responses yet |
3979 | break; |
3514 | break; |
3980 | #endif |
3515 | #endif |
3981 | } |
3516 | } |
3982 | } |
3517 | } |
… | |
… | |
4020 | { |
3555 | { |
4021 | unsigned int i, j; |
3556 | unsigned int i, j; |
4022 | int state; |
3557 | int state; |
4023 | |
3558 | |
4024 | static const struct |
3559 | static const struct |
4025 | { |
3560 | { |
4026 | const int argval; |
3561 | const int argval; |
4027 | const unsigned long bit; |
3562 | const unsigned long bit; |
4028 | } |
|
|
4029 | |
|
|
4030 | argtopriv[] = { |
3563 | } argtopriv[] = { |
4031 | { 1, PrivMode_aplCUR }, |
3564 | { 1, PrivMode_aplCUR }, |
4032 | { 2, PrivMode_vt52 }, |
3565 | { 2, PrivMode_vt52 }, |
4033 | { 3, PrivMode_132 }, |
3566 | { 3, PrivMode_132 }, |
4034 | { 4, PrivMode_smoothScroll }, |
3567 | { 4, PrivMode_smoothScroll }, |
4035 | { 5, PrivMode_rVideo }, |
3568 | { 5, PrivMode_rVideo }, |
… | |
… | |
4051 | { 66, PrivMode_aplKP }, |
3584 | { 66, PrivMode_aplKP }, |
4052 | #ifndef NO_BACKSPACE_KEY |
3585 | #ifndef NO_BACKSPACE_KEY |
4053 | { 67, PrivMode_BackSpace }, |
3586 | { 67, PrivMode_BackSpace }, |
4054 | #endif |
3587 | #endif |
4055 | { 1000, PrivMode_MouseX11 }, |
3588 | { 1000, PrivMode_MouseX11 }, |
4056 | // 1001 Use Hilite Mouse Tracking. NYI, TODO |
3589 | { 1002, PrivMode_MouseBtnEvent }, |
4057 | // 1002 Use Cell Motion Mouse Tracking. NYI, TODO |
3590 | { 1003, PrivMode_MouseAnyEvent }, |
4058 | // 1003 Use All Motion Mouse Tracking. NYI, TODO |
|
|
4059 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
3591 | { 1010, PrivMode_TtyOutputInh }, // rxvt extension |
4060 | { 1011, PrivMode_Keypress }, // rxvt extension |
3592 | { 1011, PrivMode_Keypress }, // rxvt extension |
4061 | // 1035 enable modifiers for alt, numlock NYI |
3593 | // 1035 enable modifiers for alt, numlock NYI |
4062 | // 1036 send ESC for meta keys NYI |
3594 | // 1036 send ESC for meta keys NYI |
4063 | // 1037 send DEL for keypad delete NYI |
3595 | // 1037 send DEL for keypad delete NYI |
4064 | { 1047, PrivMode_Screen }, |
3596 | { 1047, PrivMode_Screen }, |
4065 | // 1048 save and restore cursor |
3597 | // 1048 save and restore cursor |
4066 | { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ |
3598 | { 1049, PrivMode_Screen }, /* xterm extension, clear screen on ti rather than te */ |
4067 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
3599 | // 1051, 1052, 1060, 1061 keyboard emulation NYI |
|
|
3600 | { 2004, PrivMode_BracketPaste }, |
4068 | }; |
3601 | }; |
4069 | |
3602 | |
4070 | if (nargs == 0) |
3603 | if (nargs == 0) |
4071 | return; |
3604 | return; |
4072 | |
3605 | |
… | |
… | |
4098 | scr_touch (true); |
3631 | scr_touch (true); |
4099 | break; |
3632 | break; |
4100 | #endif |
3633 | #endif |
4101 | case 1048: /* alternative cursor save */ |
3634 | case 1048: /* alternative cursor save */ |
4102 | case 1049: |
3635 | case 1049: |
4103 | if (OPTION (Opt_secondaryScreen)) |
3636 | if (option (Opt_secondaryScreen)) |
4104 | if (mode == 0) |
3637 | if (mode == 0) |
4105 | scr_cursor (RESTORE); |
3638 | scr_cursor (RESTORE); |
4106 | else if (mode == 1) |
3639 | else if (mode == 1) |
4107 | scr_cursor (SAVE); |
3640 | scr_cursor (SAVE); |
4108 | break; |
3641 | break; |
… | |
… | |
4120 | */ |
3653 | */ |
4121 | PrivMode (1, PrivMode_vt52); |
3654 | PrivMode (1, PrivMode_vt52); |
4122 | break; |
3655 | break; |
4123 | case 3: /* 80/132 */ |
3656 | case 3: /* 80/132 */ |
4124 | if (priv_modes & PrivMode_132OK) |
3657 | if (priv_modes & PrivMode_132OK) |
|
|
3658 | { |
|
|
3659 | scr_poweron (); |
4125 | set_widthheight (((state ? 132 : 80) * fwidth), height); |
3660 | set_widthheight (((state ? 132 : 80) * fwidth), 24 * fheight); |
|
|
3661 | } |
4126 | break; |
3662 | break; |
4127 | case 4: /* smooth scrolling */ |
3663 | case 4: /* smooth scrolling */ |
4128 | set_option (Opt_jumpScroll, !state); |
3664 | set_option (Opt_jumpScroll, !state); |
4129 | break; |
3665 | break; |
4130 | case 5: /* reverse video */ |
3666 | case 5: /* reverse video */ |
… | |
… | |
4137 | scr_autowrap (state); |
3673 | scr_autowrap (state); |
4138 | break; |
3674 | break; |
4139 | /* case 8: - auto repeat, can't do on a per window basis */ |
3675 | /* case 8: - auto repeat, can't do on a per window basis */ |
4140 | case 9: /* X10 mouse reporting */ |
3676 | case 9: /* X10 mouse reporting */ |
4141 | if (state) /* orthogonal */ |
3677 | if (state) /* orthogonal */ |
4142 | priv_modes &= ~PrivMode_MouseX11; |
3678 | priv_modes &= ~(PrivMode_MouseX11|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
4143 | break; |
3679 | break; |
4144 | #ifdef scrollBar_esc |
3680 | #ifdef scrollBar_esc |
4145 | case scrollBar_esc: |
3681 | case scrollBar_esc: |
4146 | if (scrollbar_mapping (state)) |
3682 | if (scrollbar_mapping (state)) |
4147 | { |
3683 | { |
… | |
… | |
4160 | break; |
3696 | break; |
4161 | /* case 66: - application key pad */ |
3697 | /* case 66: - application key pad */ |
4162 | /* case 67: - backspace key */ |
3698 | /* case 67: - backspace key */ |
4163 | case 1000: /* X11 mouse reporting */ |
3699 | case 1000: /* X11 mouse reporting */ |
4164 | if (state) /* orthogonal */ |
3700 | if (state) /* orthogonal */ |
4165 | priv_modes &= ~PrivMode_MouseX10; |
3701 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseBtnEvent|PrivMode_MouseAnyEvent); |
4166 | break; |
3702 | break; |
4167 | #if 0 |
|
|
4168 | case 1001: |
3703 | case 1002: |
4169 | break; /* X11 mouse highlighting */ |
3704 | case 1003: |
4170 | #endif |
3705 | if (state) |
|
|
3706 | { |
|
|
3707 | priv_modes &= ~(PrivMode_MouseX10|PrivMode_MouseX11); |
|
|
3708 | priv_modes &= arg[i] == 1003 ? ~PrivMode_MouseBtnEvent : ~PrivMode_MouseAnyEvent; |
|
|
3709 | vt_emask_mouse = PointerMotionMask; |
|
|
3710 | } |
|
|
3711 | else |
|
|
3712 | vt_emask_mouse = NoEventMask; |
|
|
3713 | vt_select_input (); |
|
|
3714 | break; |
4171 | case 1010: /* scroll to bottom on TTY output inhibit */ |
3715 | case 1010: /* scroll to bottom on TTY output inhibit */ |
4172 | set_option (Opt_scrollTtyOutput, !state); |
3716 | set_option (Opt_scrollTtyOutput, !state); |
4173 | break; |
3717 | break; |
4174 | case 1011: /* scroll to bottom on key press */ |
3718 | case 1011: /* scroll to bottom on key press */ |
4175 | set_option (Opt_scrollTtyKeypress, state); |
3719 | set_option (Opt_scrollTtyKeypress, state); |
4176 | break; |
3720 | break; |
4177 | case 1047: /* secondary screen w/ clearing last */ |
3721 | case 1047: /* secondary screen w/ clearing last */ |
4178 | if (OPTION (Opt_secondaryScreen)) |
3722 | if (option (Opt_secondaryScreen)) |
4179 | if (current_screen != PRIMARY) |
3723 | if (current_screen != PRIMARY) |
4180 | scr_erase_screen (2); |
3724 | scr_erase_screen (2); |
4181 | scr_change_screen (state); |
3725 | scr_change_screen (state); |
4182 | break; |
3726 | break; |
4183 | case 1049: /* secondary screen w/ clearing first */ |
3727 | case 1049: /* secondary screen w/ clearing first */ |
4184 | scr_change_screen (state); |
3728 | scr_change_screen (state); |
4185 | if (OPTION (Opt_secondaryScreen)) |
3729 | if (option (Opt_secondaryScreen)) |
4186 | if (current_screen != PRIMARY) |
3730 | if (current_screen != PRIMARY) |
4187 | scr_erase_screen (2); |
3731 | scr_erase_screen (2); |
4188 | break; |
3732 | break; |
4189 | default: |
3733 | default: |
4190 | break; |
3734 | break; |
… | |
… | |
4352 | rxvt_term::process_graphics () |
3896 | rxvt_term::process_graphics () |
4353 | { |
3897 | { |
4354 | unicode_t ch, cmd = cmd_getc (); |
3898 | unicode_t ch, cmd = cmd_getc (); |
4355 | |
3899 | |
4356 | if (cmd == 'Q') |
3900 | if (cmd == 'Q') |
|
|
3901 | { |
4357 | { /* query graphics */ |
3902 | /* query graphics */ |
4358 | tt_printf ("\033G0\012"); /* no graphics */ |
3903 | tt_printf ("\033G0\012"); /* no graphics */ |
4359 | return; |
3904 | return; |
4360 | } |
3905 | } |
4361 | /* swallow other graphics sequences until terminating ':' */ |
3906 | /* swallow other graphics sequences until terminating ':' */ |
4362 | do |
3907 | do |
… | |
… | |
4412 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
3957 | v_buffer = (char *)realloc (v_buffer, v_buflen + len); |
4413 | |
3958 | |
4414 | memcpy (v_buffer + v_buflen, data, len); |
3959 | memcpy (v_buffer + v_buflen, data, len); |
4415 | v_buflen += len; |
3960 | v_buflen += len; |
4416 | |
3961 | |
4417 | pty_ev.set (EVENT_READ | EVENT_WRITE); |
3962 | pty_ev.set (ev::READ | ev::WRITE); |
4418 | } |
3963 | } |
4419 | |
3964 | |
4420 | void rxvt_term::pty_write () |
3965 | void rxvt_term::pty_write () |
4421 | { |
3966 | { |
4422 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
3967 | int written = write (pty->pty, v_buffer, min (v_buflen, MAX_PTY_WRITE)); |
… | |
… | |
4427 | |
3972 | |
4428 | if (v_buflen == 0) |
3973 | if (v_buflen == 0) |
4429 | { |
3974 | { |
4430 | free (v_buffer); |
3975 | free (v_buffer); |
4431 | v_buffer = 0; |
3976 | v_buffer = 0; |
4432 | v_buflen = 0; |
|
|
4433 | |
3977 | |
4434 | pty_ev.set (EVENT_READ); |
3978 | pty_ev.set (ev::READ); |
4435 | return; |
3979 | return; |
4436 | } |
3980 | } |
4437 | |
3981 | |
4438 | memmove (v_buffer, v_buffer + written, v_buflen); |
3982 | memmove (v_buffer, v_buffer + written, v_buflen); |
4439 | } |
3983 | } |
4440 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
3984 | else if (written != -1 || (errno != EAGAIN && errno != EINTR)) |
4441 | pty_ev.set (EVENT_READ); |
3985 | pty_ev.set (ev::READ); |
4442 | } |
3986 | } |
4443 | |
3987 | |
4444 | /*----------------------- end-of-file (C source) -----------------------*/ |
3988 | /*----------------------- end-of-file (C source) -----------------------*/ |
4445 | |
3989 | |