… | |
… | |
49 | #include "rxvt.h" /* NECESSARY */ |
49 | #include "rxvt.h" /* NECESSARY */ |
50 | #include "version.h" |
50 | #include "version.h" |
51 | #include "command.h" |
51 | #include "command.h" |
52 | |
52 | |
53 | #include <wchar.h> |
53 | #include <wchar.h> |
|
|
54 | #include <signal.h> |
54 | |
55 | |
55 | /*----------------------------------------------------------------------*/ |
56 | /*----------------------------------------------------------------------*/ |
56 | |
57 | |
57 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
58 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
58 | |
59 | |
… | |
… | |
417 | { |
418 | { |
418 | /* normal XTerm key bindings */ |
419 | /* normal XTerm key bindings */ |
419 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
420 | case XK_Insert: /* Shift+Insert = paste mouse selection */ |
420 | selection_request (ev.time, 0, 0); |
421 | selection_request (ev.time, 0, 0); |
421 | return; |
422 | return; |
422 | #if TODO // TODO |
423 | #if TODO |
423 | /* rxvt extras */ |
424 | /* rxvt extras */ |
424 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
425 | case XK_KP_Add: /* Shift+KP_Add = bigger font */ |
425 | change_font (FONT_UP); |
426 | change_font (FONT_UP); |
426 | return; |
427 | return; |
427 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
428 | case XK_KP_Subtract: /* Shift+KP_Subtract = smaller font */ |
… | |
… | |
1216 | if (ev.type == KeyPress && hidden_pointer == 0) |
1217 | if (ev.type == KeyPress && hidden_pointer == 0) |
1217 | pointer_blank (); |
1218 | pointer_blank (); |
1218 | } |
1219 | } |
1219 | #endif |
1220 | #endif |
1220 | |
1221 | |
1221 | Window unused_root, unused_child; |
1222 | Window unused_root, unused_child; |
1222 | int unused_root_x, unused_root_y; |
1223 | int unused_root_x, unused_root_y; |
1223 | unsigned int unused_mask; |
1224 | unsigned int unused_mask; |
1224 | |
1225 | |
1225 | switch (ev.type) |
1226 | switch (ev.type) |
1226 | { |
1227 | { |
1227 | case KeyPress: |
1228 | case KeyPress: |
1228 | #if ISO_14755 |
1229 | #if ISO_14755 |
… | |
… | |
1333 | 0L, 1000000L, |
1334 | 0L, 1000000L, |
1334 | False, AnyPropertyType, |
1335 | False, AnyPropertyType, |
1335 | &ActualType, &ActualFormat, |
1336 | &ActualType, &ActualFormat, |
1336 | &Size, &RemainingBytes, |
1337 | &Size, &RemainingBytes, |
1337 | &data); |
1338 | &data); |
1338 | XChangeProperty (display->display, display->root, |
1339 | set_string_property (XA_CUT_BUFFER0, data); |
1339 | XA_CUT_BUFFER0, XA_STRING, |
|
|
1340 | 8, PropModeReplace, |
|
|
1341 | data, strlen (data)); |
|
|
1342 | XFree (data); |
1340 | XFree (data); |
1343 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1341 | selection_paste (display->root, XA_CUT_BUFFER0, True); |
1344 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1342 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1345 | } |
1343 | } |
1346 | #endif /* OFFIX_DND */ |
1344 | #endif /* OFFIX_DND */ |
… | |
… | |
1452 | resize_all_windows (width, height, 1); |
1450 | resize_all_windows (width, height, 1); |
1453 | } |
1451 | } |
1454 | |
1452 | |
1455 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1453 | #ifdef TRANSPARENT /* XXX: maybe not needed - leave in for now */ |
1456 | if (options & Opt_transparent) |
1454 | if (options & Opt_transparent) |
1457 | { |
|
|
1458 | check_our_parents (); |
1455 | check_our_parents (); |
1459 | if (am_transparent) |
|
|
1460 | want_refresh = want_full_refresh = 1; |
|
|
1461 | } |
|
|
1462 | #endif |
1456 | #endif |
1463 | } |
1457 | } |
1464 | break; |
1458 | break; |
1465 | |
1459 | |
1466 | case PropertyNotify: |
1460 | case PropertyNotify: |
… | |
… | |
2415 | sy = 0; |
2409 | sy = 0; |
2416 | } |
2410 | } |
2417 | |
2411 | |
2418 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2412 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2419 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2413 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
|
|
2414 | |
|
|
2415 | XSync (display->display, False); |
2420 | allowedxerror = -1; |
2416 | allowedxerror = -1; |
2421 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2417 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2422 | |
2418 | |
2423 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2419 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2424 | /* XXX: may need a delay here? */ |
2420 | /* XXX: may need a delay here? */ |
… | |
… | |
2470 | |
2466 | |
2471 | am_transparent = am_pixmap_trans = 1; |
2467 | am_transparent = am_pixmap_trans = 1; |
2472 | } |
2468 | } |
2473 | } |
2469 | } |
2474 | |
2470 | |
2475 | if (!am_pixmap_trans) |
2471 | if (am_pixmap_trans) |
|
|
2472 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
|
|
2473 | else |
2476 | { |
2474 | { |
2477 | unsigned int n; |
2475 | unsigned int n; |
2478 | /* |
2476 | /* |
2479 | * InheritPixmap transparency |
2477 | * InheritPixmap transparency |
2480 | */ |
2478 | */ |
… | |
… | |
2543 | if (scrollBar.win) |
2541 | if (scrollBar.win) |
2544 | { |
2542 | { |
2545 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2543 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2546 | scrollBar.setIdle (); |
2544 | scrollBar.setIdle (); |
2547 | scrollbar_show (0); |
2545 | scrollbar_show (0); |
|
|
2546 | } |
|
|
2547 | |
|
|
2548 | if (am_transparent) |
|
|
2549 | { |
|
|
2550 | want_refresh = want_full_refresh = 1; |
|
|
2551 | if (am_pixmap_trans) |
|
|
2552 | flush (); |
2548 | } |
2553 | } |
2549 | |
2554 | |
2550 | return pchanged; |
2555 | return pchanged; |
2551 | } |
2556 | } |
2552 | #endif |
2557 | #endif |
… | |
… | |
3512 | * ends_how is terminator used. returned input must be free()'d |
3517 | * ends_how is terminator used. returned input must be free()'d |
3513 | */ |
3518 | */ |
3514 | unsigned char * |
3519 | unsigned char * |
3515 | rxvt_term::get_to_st (unicode_t &ends_how) |
3520 | rxvt_term::get_to_st (unicode_t &ends_how) |
3516 | { |
3521 | { |
3517 | unicode_t seen_esc = 0, ch; |
3522 | unicode_t ch; |
|
|
3523 | bool seen_esc = false; |
3518 | unsigned int n = 0; |
3524 | unsigned int n = 0; |
3519 | unsigned char *s; |
|
|
3520 | unsigned char string[STRING_MAX]; |
3525 | wchar_t string[STRING_MAX]; |
3521 | |
3526 | |
3522 | while ((ch = cmd_getc ()) != NOCHAR) |
3527 | while ((ch = cmd_getc ()) != NOCHAR) |
3523 | { |
3528 | { |
3524 | if (seen_esc) |
3529 | if (seen_esc) |
3525 | { |
3530 | { |
… | |
… | |
3528 | else |
3533 | else |
3529 | return NULL; |
3534 | return NULL; |
3530 | } |
3535 | } |
3531 | else if (ch == C0_ESC) |
3536 | else if (ch == C0_ESC) |
3532 | { |
3537 | { |
3533 | seen_esc = 1; |
3538 | seen_esc = true; |
3534 | continue; |
3539 | continue; |
3535 | } |
3540 | } |
3536 | else if (ch == C0_BEL || ch == CHAR_ST) |
3541 | else if (ch == C0_BEL || ch == CHAR_ST) |
3537 | break; |
3542 | break; |
3538 | else if (ch < 0x20) |
3543 | else if (ch < 0x20) |
3539 | return NULL; /* other control character - exit */ |
3544 | return NULL; /* other control character - exit */ |
3540 | |
3545 | |
3541 | seen_esc = 0; |
3546 | seen_esc = false; |
3542 | |
3547 | |
3543 | if (n >= sizeof (string) - 1) |
3548 | if (n >= sizeof (string) - 1) |
3544 | // stop at some sane length |
3549 | // stop at some sane length |
3545 | return NULL; |
3550 | return NULL; |
3546 | |
3551 | |
… | |
… | |
3550 | string[n++] = ch; |
3555 | string[n++] = ch; |
3551 | } |
3556 | } |
3552 | |
3557 | |
3553 | string[n++] = '\0'; |
3558 | string[n++] = '\0'; |
3554 | |
3559 | |
3555 | if ((s = (unsigned char *)rxvt_malloc (n)) == NULL) |
|
|
3556 | return NULL; |
|
|
3557 | |
|
|
3558 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3560 | ends_how = (ch == 0x5c ? C0_ESC : ch); |
3559 | strncpy (s, string, n); |
3561 | |
3560 | return s; |
3562 | return (unsigned char *)rxvt_wcstombs (string); |
3561 | } |
3563 | } |
3562 | |
3564 | |
3563 | /*----------------------------------------------------------------------*/ |
3565 | /*----------------------------------------------------------------------*/ |
3564 | /* |
3566 | /* |
3565 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
3567 | * process DEVICE CONTROL STRING `ESC P ... (ST|BEL)' or `0x90 ... (ST|BEL)' |
… | |
… | |
3666 | set_title (str); |
3668 | set_title (str); |
3667 | break; |
3669 | break; |
3668 | case XTerm_property: |
3670 | case XTerm_property: |
3669 | if (str[0] == '?') |
3671 | if (str[0] == '?') |
3670 | { |
3672 | { |
3671 | Atom prop = XInternAtom (display->display, str + 1, True); |
3673 | Atom prop = display->atom (str + 1); |
3672 | Atom actual_type; |
3674 | Atom actual_type; |
3673 | int actual_format; |
3675 | int actual_format; |
3674 | unsigned long nitems; |
3676 | unsigned long nitems; |
3675 | unsigned long bytes_after; |
3677 | unsigned long bytes_after; |
3676 | unsigned char *value = 0; |
3678 | unsigned char *value = 0; |
… | |
… | |
3694 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3696 | char *eq = strchr (str, '='); // constness lost, but verified to be ok |
3695 | |
3697 | |
3696 | if (eq) |
3698 | if (eq) |
3697 | { |
3699 | { |
3698 | *eq = 0; |
3700 | *eq = 0; |
3699 | XChangeProperty (display->display, TermWin.parent[0], |
3701 | set_utf8_property (display->atom (str), eq + 1); |
3700 | display->atom (str), XA_STRING, 8, |
|
|
3701 | PropModeReplace, (unsigned char *)eq + 1, |
|
|
3702 | strlen (eq + 1)); |
|
|
3703 | } |
3702 | } |
3704 | else |
3703 | else |
3705 | XDeleteProperty (display->display, TermWin.parent[0], |
3704 | XDeleteProperty (display->display, TermWin.parent[0], |
3706 | display->atom (str)); |
3705 | display->atom (str)); |
3707 | } |
3706 | } |
… | |
… | |
3761 | break; |
3760 | break; |
3762 | case XTerm_Color_RV: |
3761 | case XTerm_Color_RV: |
3763 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3762 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3764 | break; |
3763 | break; |
3765 | #endif |
3764 | #endif |
3766 | #if TRANSPARENT || TINTING |
3765 | #if TRANSPARENT && TINTING |
3767 | case XTerm_Color_tint: |
3766 | case XTerm_Color_tint: |
3768 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
3767 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
3769 | check_our_parents (); |
3768 | check_our_parents (); |
3770 | if (am_transparent) |
3769 | if (am_transparent) |
3771 | want_full_refresh = want_refresh = 1; |
3770 | want_full_refresh = want_refresh = 1; |