… | |
… | |
25 | * - extensive modifications |
25 | * - extensive modifications |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
26 | * Copyright (c) 1998 Alfredo K. Kojima <kojima@windowmaker.org> |
27 | * Copyright (c) 2001 Marius Gedminas |
27 | * Copyright (c) 2001 Marius Gedminas |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
28 | * - Ctrl/Mod4+Tab works like Meta+Tab (options) |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
29 | * Copyright (c) 2003 Rob McMullen <robm@flipturn.org> |
30 | * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> |
30 | * Copyright (c) 2003-2005 Marc Lehmann <pcg@goof.com> |
31 | * |
31 | * |
32 | * This program is free software; you can redistribute it and/or modify |
32 | * This program is free software; you can redistribute it and/or modify |
33 | * it under the terms of the GNU General Public License as published by |
33 | * it under the terms of the GNU General Public License as published by |
34 | * the Free Software Foundation; either version 2 of the License, or |
34 | * the Free Software Foundation; either version 2 of the License, or |
35 | * (at your option) any later version. |
35 | * (at your option) any later version. |
… | |
… | |
52 | |
52 | |
53 | #ifdef KEYSYM_RESOURCE |
53 | #ifdef KEYSYM_RESOURCE |
54 | # include "keyboard.h" |
54 | # include "keyboard.h" |
55 | #endif |
55 | #endif |
56 | |
56 | |
57 | #include <cwchar> |
|
|
58 | #include <csignal> |
57 | #include <csignal> |
59 | |
58 | |
60 | /*----------------------------------------------------------------------*/ |
59 | /*----------------------------------------------------------------------*/ |
61 | |
60 | |
62 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
61 | #define IS_CONTROL(ch) !((ch) & 0xffffff60UL) |
… | |
… | |
118 | XK_Escape, 0x238b, |
117 | XK_Escape, 0x238b, |
119 | XK_Undo, 0x238c, |
118 | XK_Undo, 0x238c, |
120 | XK_Print, 0x2399, |
119 | XK_Print, 0x2399, |
121 | |
120 | |
122 | XK_space, 0x2423, |
121 | XK_space, 0x2423, |
|
|
122 | |
|
|
123 | #ifdef XK_KP_Begin |
|
|
124 | XK_KP_Prior, 0x21de, |
|
|
125 | XK_KP_Next, 0x21df, |
|
|
126 | XK_KP_Begin, 0x2320, |
|
|
127 | XK_KP_Insert, 0x2380, |
|
|
128 | XK_KP_Delete, 0x2326, |
123 | XK_KP_Space, 0x2422, |
129 | XK_KP_Space, 0x2422, |
|
|
130 | #endif |
124 | 0, |
131 | 0, |
125 | }; |
132 | }; |
126 | |
133 | |
127 | void |
134 | void |
128 | rxvt_term::iso14755_54 (int x, int y) |
135 | rxvt_term::iso14755_54 (int x, int y) |
… | |
… | |
277 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
284 | * use Num_Lock to toggle Keypad on/off. If Num_Lock is off, allow an |
278 | * escape sequence to toggle the Keypad. |
285 | * escape sequence to toggle the Keypad. |
279 | * |
286 | * |
280 | * Always permit `shift' to override the current setting |
287 | * Always permit `shift' to override the current setting |
281 | */ |
288 | */ |
282 | shft = (ev.state & ShiftMask); |
289 | shft = ev.state & ShiftMask; |
283 | ctrl = (ev.state & ControlMask); |
290 | ctrl = ev.state & ControlMask; |
284 | meta = (ev.state & ModMetaMask); |
291 | meta = ev.state & ModMetaMask; |
285 | |
292 | |
286 | if (numlock_state || (ev.state & ModNumLockMask)) |
293 | if (numlock_state || (ev.state & ModNumLockMask)) |
287 | { |
294 | { |
288 | numlock_state = (ev.state & ModNumLockMask); |
295 | numlock_state = (ev.state & ModNumLockMask); |
289 | PrivMode ((!numlock_state), PrivMode_aplKP); |
296 | PrivMode ((!numlock_state), PrivMode_aplKP); |
… | |
… | |
309 | |
316 | |
310 | // the XOpenIM manpage lies about hardcoding the locale |
317 | // the XOpenIM manpage lies about hardcoding the locale |
311 | // at the point of XOpenIM, so temporarily switch locales |
318 | // at the point of XOpenIM, so temporarily switch locales |
312 | if (rs[Rs_imLocale]) |
319 | if (rs[Rs_imLocale]) |
313 | SET_LOCALE (rs[Rs_imLocale]); |
320 | SET_LOCALE (rs[Rs_imLocale]); |
|
|
321 | |
314 | // assume wchar_t == unicode or better |
322 | // assume wchar_t == unicode or better |
315 | len = XwcLookupString (Input_Context, &ev, wkbuf, |
323 | len = XwcLookupString (Input_Context, &ev, wkbuf, |
316 | KBUFSZ, &keysym, &status_return); |
324 | KBUFSZ, &keysym, &status_return); |
|
|
325 | |
317 | if (rs[Rs_imLocale]) |
326 | if (rs[Rs_imLocale]) |
318 | SET_LOCALE (locale); |
327 | SET_LOCALE (locale); |
319 | |
328 | |
320 | if (status_return == XLookupChars |
329 | if (status_return == XLookupChars |
321 | || status_return == XLookupBoth) |
330 | || status_return == XLookupBoth) |
… | |
… | |
513 | else |
522 | else |
514 | strcpy (kbuf, key_backspace); |
523 | strcpy (kbuf, key_backspace); |
515 | break; |
524 | break; |
516 | #endif |
525 | #endif |
517 | #ifndef NO_DELETE_KEY |
526 | #ifndef NO_DELETE_KEY |
|
|
527 | # ifdef XK_KP_Prior |
|
|
528 | case XK_KP_Delete: |
|
|
529 | /* allow shift to override */ |
|
|
530 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
531 | { |
|
|
532 | strcpy (kbuf, "\033On"); |
|
|
533 | break; |
|
|
534 | } |
|
|
535 | /* FALLTHROUGH */ |
|
|
536 | # endif |
518 | case XK_Delete: |
537 | case XK_Delete: |
519 | strcpy (kbuf, key_delete); |
538 | strcpy (kbuf, key_delete); |
520 | break; |
539 | break; |
521 | #endif |
540 | #endif |
522 | case XK_Tab: |
541 | case XK_Tab: |
… | |
… | |
625 | #ifdef XK_KP_Begin |
644 | #ifdef XK_KP_Begin |
626 | case XK_KP_Begin: |
645 | case XK_KP_Begin: |
627 | strcpy (kbuf, "\033Ou"); |
646 | strcpy (kbuf, "\033Ou"); |
628 | break; |
647 | break; |
629 | |
648 | |
630 | case XK_KP_Insert: |
|
|
631 | strcpy (kbuf, "\033Op"); |
|
|
632 | break; |
|
|
633 | |
|
|
634 | case XK_KP_Delete: |
|
|
635 | strcpy (kbuf, "\033On"); |
|
|
636 | break; |
|
|
637 | #endif |
649 | #endif |
638 | case XK_KP_F1: /* "\033OP" */ |
650 | case XK_KP_F1: /* "\033OP" */ |
639 | case XK_KP_F2: /* "\033OQ" */ |
651 | case XK_KP_F2: /* "\033OQ" */ |
640 | case XK_KP_F3: /* "\033OR" */ |
652 | case XK_KP_F3: /* "\033OR" */ |
641 | case XK_KP_F4: /* "\033OS" */ |
653 | case XK_KP_F4: /* "\033OS" */ |
… | |
… | |
673 | break; |
685 | break; |
674 | |
686 | |
675 | case XK_Find: |
687 | case XK_Find: |
676 | strcpy (kbuf, "\033[1~"); |
688 | strcpy (kbuf, "\033[1~"); |
677 | break; |
689 | break; |
|
|
690 | |
|
|
691 | #ifdef XK_KP_End |
|
|
692 | case XK_KP_Insert: |
|
|
693 | /* allow shift to override */ |
|
|
694 | if ((priv_modes & PrivMode_aplKP) ? !shft : shft) |
|
|
695 | { |
|
|
696 | strcpy (kbuf, "\033Op"); |
|
|
697 | break; |
|
|
698 | } |
|
|
699 | /* FALLTHROUGH */ |
|
|
700 | #endif |
678 | case XK_Insert: |
701 | case XK_Insert: |
679 | strcpy (kbuf, "\033[2~"); |
702 | strcpy (kbuf, "\033[2~"); |
680 | break; |
703 | break; |
681 | #ifdef DXK_Remove /* support for DEC remove like key */ |
704 | #ifdef DXK_Remove /* support for DEC remove like key */ |
682 | case DXK_Remove: |
705 | case DXK_Remove: |
… | |
… | |
1182 | |
1205 | |
1183 | /*{{{ process an X event */ |
1206 | /*{{{ process an X event */ |
1184 | void |
1207 | void |
1185 | rxvt_term::x_cb (XEvent &ev) |
1208 | rxvt_term::x_cb (XEvent &ev) |
1186 | { |
1209 | { |
|
|
1210 | dDisp; |
|
|
1211 | |
1187 | SET_R (this); |
1212 | SET_R (this); |
1188 | SET_LOCALE (locale); |
1213 | SET_LOCALE (locale); |
1189 | |
1214 | |
1190 | #if defined(CURSOR_BLINK) |
1215 | #if defined(CURSOR_BLINK) |
1191 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
1216 | if ((options & Opt_cursorBlink) && ev.type == KeyPress) |
… | |
… | |
1307 | button_release (ev.xbutton); |
1332 | button_release (ev.xbutton); |
1308 | break; |
1333 | break; |
1309 | |
1334 | |
1310 | case ClientMessage: |
1335 | case ClientMessage: |
1311 | if (ev.xclient.format == 32 |
1336 | if (ev.xclient.format == 32 |
|
|
1337 | && ev.xclient.message_type == xa[XA_WM_PROTOCOLS]) |
|
|
1338 | { |
1312 | && (Atom)ev.xclient.data.l[0] == xa[XA_WMDELETEWINDOW]) |
1339 | if (ev.xclient.data.l[0] == xa[XA_WM_DELETE_WINDOW]) |
1313 | destroy (); |
1340 | destroy (); |
|
|
1341 | #if ENABLE_EWMH |
|
|
1342 | else if (ev.xclient.data.l[0] == xa[XA_NET_WM_PING]) |
|
|
1343 | XSendEvent (disp, ev.xclient.window = display->root, |
|
|
1344 | False, SubstructureRedirectMask | SubstructureNotifyMask, |
|
|
1345 | &ev); |
|
|
1346 | #endif |
|
|
1347 | } |
|
|
1348 | #if ENABLE_XEMBED |
|
|
1349 | else if (ev.xclient.format == 32 && ev.xclient.message_type == xa[XA_XEMBED]) |
|
|
1350 | { |
|
|
1351 | if (ev.xclient.data.l[1] == XEMBED_FOCUS_IN) |
|
|
1352 | focus_in (); |
|
|
1353 | else if (ev.xclient.data.l[1] == XEMBED_FOCUS_OUT) |
|
|
1354 | focus_out (); |
|
|
1355 | } |
|
|
1356 | #endif |
1314 | #ifdef OFFIX_DND |
1357 | #ifdef OFFIX_DND |
1315 | /* OffiX Dnd (drag 'n' drop) protocol */ |
1358 | /* OffiX Dnd (drag 'n' drop) protocol */ |
1316 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
1359 | else if (ev.xclient.message_type == xa[XA_DNDPROTOCOL] |
1317 | && (ev.xclient.data.l[0] == DndFile |
1360 | && (ev.xclient.data.l[0] == DndFile |
1318 | || ev.xclient.data.l[0] == DndDir |
1361 | || ev.xclient.data.l[0] == DndDir |
1319 | || ev.xclient.data.l[0] == DndLink)) |
1362 | || ev.xclient.data.l[0] == DndLink)) |
1320 | { |
1363 | { |
1321 | /* Get Dnd data */ |
1364 | /* Get Dnd data */ |
1322 | Atom ActualType; |
1365 | Atom ActualType; |
1323 | int ActualFormat; |
1366 | int ActualFormat; |
1324 | unsigned char *data; |
1367 | unsigned char *data; |
1325 | unsigned long Size, RemainingBytes; |
1368 | unsigned long Size, RemainingBytes; |
1326 | |
1369 | |
1327 | XGetWindowProperty (display->display, display->root, |
1370 | XGetWindowProperty (disp, display->root, |
1328 | xa[XA_DNDSELECTION], |
1371 | xa[XA_DNDSELECTION], |
1329 | 0L, 1000000L, |
1372 | 0L, 1000000L, |
1330 | False, AnyPropertyType, |
1373 | False, AnyPropertyType, |
1331 | &ActualType, &ActualFormat, |
1374 | &ActualType, &ActualFormat, |
1332 | &Size, &RemainingBytes, |
1375 | &Size, &RemainingBytes, |
1333 | &data); |
1376 | &data); |
1334 | set_string_property (XA_CUT_BUFFER0, data); |
1377 | set_string_property (XA_CUT_BUFFER0, data); |
1335 | XFree (data); |
1378 | XFree (data); |
1336 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
1379 | selection_paste (display->root, XA_CUT_BUFFER0, true); |
1337 | XSetInputFocus (display->display, display->root, RevertToNone, CurrentTime); |
1380 | XSetInputFocus (disp, display->root, RevertToNone, CurrentTime); |
1338 | } |
1381 | } |
1339 | #endif /* OFFIX_DND */ |
1382 | #endif /* OFFIX_DND */ |
1340 | break; |
1383 | break; |
1341 | |
1384 | |
1342 | case MappingNotify: |
1385 | case MappingNotify: |
… | |
… | |
1367 | break; |
1410 | break; |
1368 | } |
1411 | } |
1369 | break; |
1412 | break; |
1370 | |
1413 | |
1371 | case FocusIn: |
1414 | case FocusIn: |
1372 | if (!TermWin.focus) |
1415 | focus_in (); |
1373 | { |
|
|
1374 | TermWin.focus = 1; |
|
|
1375 | want_refresh = 1; |
|
|
1376 | #ifdef USE_XIM |
|
|
1377 | if (Input_Context != NULL) |
|
|
1378 | { |
|
|
1379 | IMSetStatusPosition (); |
|
|
1380 | XSetICFocus (Input_Context); |
|
|
1381 | } |
|
|
1382 | #endif |
|
|
1383 | #ifdef CURSOR_BLINK |
|
|
1384 | if (options & Opt_cursorBlink) |
|
|
1385 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1386 | #endif |
|
|
1387 | #ifdef OFF_FOCUS_FADING |
|
|
1388 | if (rs[Rs_fade]) |
|
|
1389 | { |
|
|
1390 | pix_colors = pix_colors_focused; |
|
|
1391 | scr_recolour (); |
|
|
1392 | } |
|
|
1393 | #endif |
|
|
1394 | |
|
|
1395 | } |
|
|
1396 | break; |
1416 | break; |
1397 | |
1417 | |
1398 | case FocusOut: |
1418 | case FocusOut: |
1399 | if (TermWin.focus) |
1419 | focus_out (); |
1400 | { |
|
|
1401 | TermWin.focus = 0; |
|
|
1402 | want_refresh = 1; |
|
|
1403 | |
|
|
1404 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1405 | iso14755buf = 0; |
|
|
1406 | #endif |
|
|
1407 | #if ENABLE_OVERLAY |
|
|
1408 | scr_overlay_off (); |
|
|
1409 | #endif |
|
|
1410 | #ifdef USE_XIM |
|
|
1411 | if (Input_Context != NULL) |
|
|
1412 | XUnsetICFocus (Input_Context); |
|
|
1413 | #endif |
|
|
1414 | #ifdef CURSOR_BLINK |
|
|
1415 | if (options & Opt_cursorBlink) |
|
|
1416 | cursor_blink_ev.stop (); |
|
|
1417 | hidden_cursor = 0; |
|
|
1418 | #endif |
|
|
1419 | #ifdef OFF_FOCUS_FADING |
|
|
1420 | if (rs[Rs_fade]) |
|
|
1421 | { |
|
|
1422 | pix_colors = pix_colors_unfocused; |
|
|
1423 | scr_recolour (); |
|
|
1424 | } |
|
|
1425 | #endif |
|
|
1426 | } |
|
|
1427 | break; |
1420 | break; |
1428 | |
1421 | |
1429 | case ConfigureNotify: |
1422 | case ConfigureNotify: |
1430 | if (ev.xconfigure.window == TermWin.parent[0]) |
1423 | if (ev.xconfigure.window == TermWin.parent[0]) |
1431 | { |
1424 | { |
… | |
… | |
1435 | { /* Wrap lots of configures into one */ |
1428 | { /* Wrap lots of configures into one */ |
1436 | width = ev.xconfigure.width; |
1429 | width = ev.xconfigure.width; |
1437 | height = ev.xconfigure.height; |
1430 | height = ev.xconfigure.height; |
1438 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1431 | D_SIZE ((stderr, "Size: ConfigureNotify: %4d x %4d", width, height)); |
1439 | } |
1432 | } |
1440 | while (XCheckTypedWindowEvent (display->display, ev.xconfigure.window, ConfigureNotify, &ev)); |
1433 | while (XCheckTypedWindowEvent (disp, ev.xconfigure.window, ConfigureNotify, &ev)); |
1441 | |
1434 | |
1442 | if (szHint.width != width || szHint.height != height) |
1435 | if (szHint.width != width || szHint.height != height) |
1443 | { |
1436 | { |
1444 | seen_resize = 1; |
1437 | seen_resize = 1; |
1445 | resize_all_windows (width, height, 1); |
1438 | resize_all_windows (width, height, 1); |
… | |
… | |
1497 | if (ev.xany.window == TermWin.vt) |
1490 | if (ev.xany.window == TermWin.vt) |
1498 | { |
1491 | { |
1499 | do |
1492 | do |
1500 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1493 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1501 | ev.xexpose.width, ev.xexpose.height, False); |
1494 | ev.xexpose.width, ev.xexpose.height, False); |
1502 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)); |
1495 | while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev)); |
1503 | |
1496 | |
1504 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1497 | ev.xany.type = ev.xany.type == Expose ? GraphicsExpose : Expose; |
1505 | |
1498 | |
1506 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, ev.xany.type, &ev)) |
1499 | while (XCheckTypedWindowEvent (disp, TermWin.vt, ev.xany.type, &ev)) |
1507 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1500 | scr_expose (ev.xexpose.x, ev.xexpose.y, |
1508 | ev.xexpose.width, ev.xexpose.height, False); |
1501 | ev.xexpose.width, ev.xexpose.height, False); |
1509 | |
1502 | |
1510 | scr_refresh (refresh_type); |
1503 | scr_refresh (refresh_type); |
1511 | } |
1504 | } |
1512 | else |
1505 | else |
1513 | { |
1506 | { |
1514 | XEvent unused_event; |
1507 | XEvent unused_event; |
1515 | |
1508 | |
1516 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, Expose, &unused_event)) |
1509 | while (XCheckTypedWindowEvent (disp, ev.xany.window, Expose, &unused_event)) |
1517 | ; |
1510 | ; |
1518 | while (XCheckTypedWindowEvent (display->display, ev.xany.window, GraphicsExpose, &unused_event)) |
1511 | while (XCheckTypedWindowEvent (disp, ev.xany.window, GraphicsExpose, &unused_event)) |
1519 | ; |
1512 | ; |
1520 | |
1513 | |
1521 | if (isScrollbarWindow (ev.xany.window)) |
1514 | if (isScrollbarWindow (ev.xany.window)) |
1522 | { |
1515 | { |
1523 | scrollBar.setIdle (); |
1516 | scrollBar.setIdle (); |
… | |
… | |
1528 | menubar_expose (); |
1521 | menubar_expose (); |
1529 | #endif |
1522 | #endif |
1530 | |
1523 | |
1531 | #ifdef TRANSPARENT |
1524 | #ifdef TRANSPARENT |
1532 | if (am_transparent && ev.xany.window == TermWin.parent[0]) |
1525 | if (am_transparent && ev.xany.window == TermWin.parent[0]) |
1533 | XClearWindow (display->display, ev.xany.window); |
1526 | XClearWindow (disp, ev.xany.window); |
1534 | #endif |
1527 | #endif |
1535 | } |
1528 | } |
1536 | break; |
1529 | break; |
1537 | |
1530 | |
1538 | case MotionNotify: |
1531 | case MotionNotify: |
… | |
… | |
1552 | |
1545 | |
1553 | if (ev.xany.window == TermWin.vt) |
1546 | if (ev.xany.window == TermWin.vt) |
1554 | { |
1547 | { |
1555 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1548 | if (ev.xbutton.state & (Button1Mask | Button3Mask)) |
1556 | { |
1549 | { |
1557 | while (XCheckTypedWindowEvent (display->display, TermWin.vt, MotionNotify, &ev)) |
1550 | while (XCheckTypedWindowEvent (disp, TermWin.vt, MotionNotify, &ev)) |
1558 | ; |
1551 | ; |
1559 | |
1552 | |
1560 | XQueryPointer (display->display, TermWin.vt, |
1553 | XQueryPointer (disp, TermWin.vt, |
1561 | &unused_root, &unused_child, |
1554 | &unused_root, &unused_child, |
1562 | &unused_root_x, &unused_root_y, |
1555 | &unused_root_x, &unused_root_y, |
1563 | &ev.xbutton.x, &ev.xbutton.y, |
1556 | &ev.xbutton.x, &ev.xbutton.y, |
1564 | &ev.xbutton.state); |
1557 | &ev.xbutton.state); |
1565 | #ifdef MOUSE_THRESHOLD |
1558 | #ifdef MOUSE_THRESHOLD |
… | |
… | |
1629 | #endif |
1622 | #endif |
1630 | } |
1623 | } |
1631 | } |
1624 | } |
1632 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1625 | else if (isScrollbarWindow (ev.xany.window) && scrollbar_isMotion ()) |
1633 | { |
1626 | { |
1634 | while (XCheckTypedWindowEvent (display->display, scrollBar.win, |
1627 | while (XCheckTypedWindowEvent (disp, scrollBar.win, |
1635 | MotionNotify, &ev)) |
1628 | MotionNotify, &ev)) |
1636 | ; |
1629 | ; |
1637 | |
1630 | |
1638 | XQueryPointer (display->display, scrollBar.win, |
1631 | XQueryPointer (disp, scrollBar.win, |
1639 | &unused_root, &unused_child, |
1632 | &unused_root, &unused_child, |
1640 | &unused_root_x, &unused_root_y, |
1633 | &unused_root_x, &unused_root_y, |
1641 | &ev.xbutton.x, &ev.xbutton.y, |
1634 | &ev.xbutton.x, &ev.xbutton.y, |
1642 | &unused_mask); |
1635 | &unused_mask); |
1643 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
1636 | scr_move_to (scrollbar_position (ev.xbutton.y) - csrO, |
… | |
… | |
1645 | scr_refresh (refresh_type); |
1638 | scr_refresh (refresh_type); |
1646 | refresh_limit = 0; |
1639 | refresh_limit = 0; |
1647 | scrollbar_show (1); |
1640 | scrollbar_show (1); |
1648 | } |
1641 | } |
1649 | break; |
1642 | break; |
|
|
1643 | } |
|
|
1644 | } |
|
|
1645 | |
|
|
1646 | void |
|
|
1647 | rxvt_term::focus_in () |
|
|
1648 | { |
|
|
1649 | if (!TermWin.focus) |
|
|
1650 | { |
|
|
1651 | TermWin.focus = 1; |
|
|
1652 | want_refresh = 1; |
|
|
1653 | #ifdef USE_XIM |
|
|
1654 | if (Input_Context != NULL) |
|
|
1655 | { |
|
|
1656 | IMSetStatusPosition (); |
|
|
1657 | XSetICFocus (Input_Context); |
|
|
1658 | } |
|
|
1659 | #endif |
|
|
1660 | #ifdef CURSOR_BLINK |
|
|
1661 | if (options & Opt_cursorBlink) |
|
|
1662 | cursor_blink_ev.start (NOW + BLINK_INTERVAL); |
|
|
1663 | #endif |
|
|
1664 | #ifdef OFF_FOCUS_FADING |
|
|
1665 | if (rs[Rs_fade]) |
|
|
1666 | { |
|
|
1667 | pix_colors = pix_colors_focused; |
|
|
1668 | scr_recolour (); |
|
|
1669 | } |
|
|
1670 | #endif |
|
|
1671 | } |
|
|
1672 | } |
|
|
1673 | |
|
|
1674 | void |
|
|
1675 | rxvt_term::focus_out () |
|
|
1676 | { |
|
|
1677 | if (TermWin.focus) |
|
|
1678 | { |
|
|
1679 | TermWin.focus = 0; |
|
|
1680 | want_refresh = 1; |
|
|
1681 | |
|
|
1682 | #if ENABLE_FRILLS || ISO_14755 |
|
|
1683 | iso14755buf = 0; |
|
|
1684 | #endif |
|
|
1685 | #if ENABLE_OVERLAY |
|
|
1686 | scr_overlay_off (); |
|
|
1687 | #endif |
|
|
1688 | #ifdef USE_XIM |
|
|
1689 | if (Input_Context != NULL) |
|
|
1690 | XUnsetICFocus (Input_Context); |
|
|
1691 | #endif |
|
|
1692 | #ifdef CURSOR_BLINK |
|
|
1693 | if (options & Opt_cursorBlink) |
|
|
1694 | cursor_blink_ev.stop (); |
|
|
1695 | hidden_cursor = 0; |
|
|
1696 | #endif |
|
|
1697 | #ifdef OFF_FOCUS_FADING |
|
|
1698 | if (rs[Rs_fade]) |
|
|
1699 | { |
|
|
1700 | pix_colors = pix_colors_unfocused; |
|
|
1701 | scr_recolour (); |
|
|
1702 | } |
|
|
1703 | #endif |
1650 | } |
1704 | } |
1651 | } |
1705 | } |
1652 | |
1706 | |
1653 | #if TRANSPARENT |
1707 | #if TRANSPARENT |
1654 | void |
1708 | void |
… | |
… | |
2081 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2135 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
2082 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2136 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
2083 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2137 | unsigned int upper_lim_r, upper_lim_g, upper_lim_b; |
2084 | int i; |
2138 | int i; |
2085 | |
2139 | |
2086 | Visual* visual = display->visual; |
2140 | Visual *visual = display->visual; |
2087 | |
2141 | |
2088 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2142 | if( visual->c_class != TrueColor || srcImage->format != ZPixmap ) return ; |
2089 | |
2143 | |
2090 | /* for convenience */ |
2144 | /* for convenience */ |
2091 | mask_r = visual->red_mask; |
2145 | mask_r = visual->red_mask; |
… | |
… | |
2312 | Atom atype; |
2366 | Atom atype; |
2313 | unsigned char *prop = NULL; |
2367 | unsigned char *prop = NULL; |
2314 | Window root, oldp, *list; |
2368 | Window root, oldp, *list; |
2315 | Pixmap rootpixmap = None; |
2369 | Pixmap rootpixmap = None; |
2316 | XWindowAttributes wattr, wrootattr; |
2370 | XWindowAttributes wattr, wrootattr; |
|
|
2371 | dDisp; |
2317 | |
2372 | |
2318 | pchanged = 0; |
2373 | pchanged = 0; |
2319 | |
2374 | |
2320 | if (!(options & Opt_transparent)) |
2375 | if (!(options & Opt_transparent)) |
2321 | return pchanged; /* Don't try any more */ |
2376 | return pchanged; /* Don't try any more */ |
2322 | |
2377 | |
2323 | XGetWindowAttributes (display->display, display->root, &wrootattr); |
2378 | XGetWindowAttributes (disp, display->root, &wrootattr); |
2324 | rootdepth = wrootattr.depth; |
2379 | rootdepth = wrootattr.depth; |
2325 | |
2380 | |
2326 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
2381 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
2327 | |
2382 | |
2328 | if (rootdepth != wattr.depth) |
2383 | if (rootdepth != wattr.depth) |
2329 | { |
2384 | { |
2330 | if (am_transparent) |
2385 | if (am_transparent) |
2331 | { |
2386 | { |
2332 | pchanged = 1; |
2387 | pchanged = 1; |
2333 | XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]); |
2388 | XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]); |
2334 | am_transparent = am_pixmap_trans = 0; |
2389 | am_transparent = am_pixmap_trans = 0; |
2335 | } |
2390 | } |
2336 | |
2391 | |
2337 | return pchanged; /* Don't try any more */ |
2392 | return pchanged; /* Don't try any more */ |
2338 | } |
2393 | } |
2339 | |
2394 | |
2340 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2395 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
2341 | XSync (display->display, False); |
2396 | XSync (disp, False); |
2342 | |
2397 | |
2343 | /* |
2398 | /* |
2344 | * Make the frame window set by the window manager have |
2399 | * Make the frame window set by the window manager have |
2345 | * the root background. Some window managers put multiple nested frame |
2400 | * the root background. Some window managers put multiple nested frame |
2346 | * windows for each client, so we have to take care about that. |
2401 | * windows for each client, so we have to take care about that. |
2347 | */ |
2402 | */ |
2348 | i = (xa[XA_XROOTPMAP_ID] |
2403 | i = (xa[XA_XROOTPMAP_ID] |
2349 | && XGetWindowProperty (display->display, display->root, xa[XA_XROOTPMAP_ID], |
2404 | && XGetWindowProperty (disp, display->root, xa[XA_XROOTPMAP_ID], |
2350 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2405 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2351 | &nitems, &bytes_after, &prop) == Success); |
2406 | &nitems, &bytes_after, &prop) == Success); |
2352 | |
2407 | |
2353 | if (!i || prop == NULL) |
2408 | if (!i || prop == NULL) |
2354 | i = (xa[XA_ESETROOT_PMAP_ID] |
2409 | i = (xa[XA_ESETROOT_PMAP_ID] |
2355 | && XGetWindowProperty (display->display, display->root, xa[XA_ESETROOT_PMAP_ID], |
2410 | && XGetWindowProperty (disp, display->root, xa[XA_ESETROOT_PMAP_ID], |
2356 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2411 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
2357 | &nitems, &bytes_after, &prop) == Success); |
2412 | &nitems, &bytes_after, &prop) == Success); |
2358 | |
2413 | |
2359 | if (!i || prop == NULL |
2414 | if (!i || prop == NULL |
2360 | #if TINTING |
2415 | #if TINTING |
… | |
… | |
2379 | Window cr; |
2434 | Window cr; |
2380 | XImage *image; |
2435 | XImage *image; |
2381 | GC gc; |
2436 | GC gc; |
2382 | XGCValues gcvalue; |
2437 | XGCValues gcvalue; |
2383 | |
2438 | |
2384 | XTranslateCoordinates (display->display, TermWin.parent[0], display->root, |
2439 | XTranslateCoordinates (disp, TermWin.parent[0], display->root, |
2385 | 0, 0, &sx, &sy, &cr); |
2440 | 0, 0, &sx, &sy, &cr); |
2386 | nw = (unsigned int)szHint.width; |
2441 | nw = (unsigned int)szHint.width; |
2387 | nh = (unsigned int)szHint.height; |
2442 | nh = (unsigned int)szHint.height; |
2388 | nx = ny = 0; |
2443 | nx = ny = 0; |
2389 | |
2444 | |
… | |
… | |
2402 | } |
2457 | } |
2403 | |
2458 | |
2404 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2459 | MIN_IT (nw, (unsigned int) (wrootattr.width - sx)); |
2405 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2460 | MIN_IT (nh, (unsigned int) (wrootattr.height - sy)); |
2406 | |
2461 | |
2407 | XSync (display->display, False); |
2462 | XSync (disp, False); |
2408 | allowedxerror = -1; |
2463 | allowedxerror = -1; |
2409 | image = XGetImage (display->display, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2464 | image = XGetImage (disp, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); |
2410 | |
2465 | |
2411 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2466 | /* XXX: handle BadMatch - usually because we're outside the pixmap */ |
2412 | /* XXX: may need a delay here? */ |
2467 | /* XXX: may need a delay here? */ |
2413 | allowedxerror = 0; |
2468 | allowedxerror = 0; |
2414 | |
2469 | |
… | |
… | |
2417 | if (am_transparent && am_pixmap_trans) |
2472 | if (am_transparent && am_pixmap_trans) |
2418 | { |
2473 | { |
2419 | pchanged = 1; |
2474 | pchanged = 1; |
2420 | if (TermWin.pixmap != None) |
2475 | if (TermWin.pixmap != None) |
2421 | { |
2476 | { |
2422 | XFreePixmap (display->display, TermWin.pixmap); |
2477 | XFreePixmap (disp, TermWin.pixmap); |
2423 | TermWin.pixmap = None; |
2478 | TermWin.pixmap = None; |
2424 | } |
2479 | } |
2425 | } |
2480 | } |
2426 | |
2481 | |
2427 | am_pixmap_trans = 0; |
2482 | am_pixmap_trans = 0; |
2428 | } |
2483 | } |
2429 | else |
2484 | else |
2430 | { |
2485 | { |
2431 | if (TermWin.pixmap != None) |
2486 | if (TermWin.pixmap != None) |
2432 | XFreePixmap (display->display, TermWin.pixmap); |
2487 | XFreePixmap (disp, TermWin.pixmap); |
2433 | |
2488 | |
2434 | #if TINTING |
2489 | #if TINTING |
2435 | if (ISSET_PIXCOLOR (Color_tint)) |
2490 | if (ISSET_PIXCOLOR (Color_tint)) |
2436 | { |
2491 | { |
2437 | unsigned short rm, gm, bm; |
2492 | unsigned short rm, gm, bm; |
… | |
… | |
2441 | |
2496 | |
2442 | ShadeXImage (display, image, shade, rm, gm, bm); |
2497 | ShadeXImage (display, image, shade, rm, gm, bm); |
2443 | } |
2498 | } |
2444 | #endif |
2499 | #endif |
2445 | |
2500 | |
2446 | TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, |
2501 | TermWin.pixmap = XCreatePixmap (disp, TermWin.vt, |
2447 | szHint.width, szHint.height, image->depth); |
2502 | szHint.width, szHint.height, image->depth); |
2448 | gc = XCreateGC (display->display, TermWin.vt, 0UL, &gcvalue); |
2503 | gc = XCreateGC (disp, TermWin.vt, 0UL, &gcvalue); |
2449 | XPutImage (display->display, TermWin.pixmap, gc, image, 0, 0, |
2504 | XPutImage (disp, TermWin.pixmap, gc, image, 0, 0, |
2450 | nx, ny, image->width, image->height); |
2505 | nx, ny, image->width, image->height); |
2451 | XFreeGC (display->display, gc); |
2506 | XFreeGC (disp, gc); |
2452 | XDestroyImage (image); |
2507 | XDestroyImage (image); |
2453 | XSetWindowBackgroundPixmap (display->display, TermWin.parent[0], TermWin.pixmap); |
2508 | XSetWindowBackgroundPixmap (disp, TermWin.parent[0], TermWin.pixmap); |
2454 | XClearWindow (display->display, TermWin.parent[0]); |
2509 | XClearWindow (disp, TermWin.parent[0]); |
2455 | |
2510 | |
2456 | if (!am_transparent || !am_pixmap_trans) |
2511 | if (!am_transparent || !am_pixmap_trans) |
2457 | pchanged = 1; |
2512 | pchanged = 1; |
2458 | |
2513 | |
2459 | am_transparent = am_pixmap_trans = 1; |
2514 | am_transparent = am_pixmap_trans = 1; |
2460 | } |
2515 | } |
2461 | } |
2516 | } |
2462 | |
2517 | |
2463 | if (am_pixmap_trans) |
2518 | if (am_pixmap_trans) |
2464 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
2519 | XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative); |
2465 | else |
2520 | else |
2466 | { |
2521 | { |
2467 | unsigned int n; |
2522 | unsigned int n; |
2468 | /* |
2523 | /* |
2469 | * InheritPixmap transparency |
2524 | * InheritPixmap transparency |
2470 | */ |
2525 | */ |
2471 | for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2526 | for (i = 1; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2472 | { |
2527 | { |
2473 | oldp = TermWin.parent[i]; |
2528 | oldp = TermWin.parent[i]; |
2474 | XQueryTree (display->display, TermWin.parent[i - 1], &root, |
2529 | XQueryTree (disp, TermWin.parent[i - 1], &root, |
2475 | &TermWin.parent[i], &list, &n); |
2530 | &TermWin.parent[i], &list, &n); |
2476 | XFree (list); |
2531 | XFree (list); |
2477 | |
2532 | |
2478 | if (TermWin.parent[i] == display->root) |
2533 | if (TermWin.parent[i] == display->root) |
2479 | { |
2534 | { |
… | |
… | |
2491 | |
2546 | |
2492 | if (pchanged) |
2547 | if (pchanged) |
2493 | { |
2548 | { |
2494 | for (; n < (unsigned int)i; n++) |
2549 | for (; n < (unsigned int)i; n++) |
2495 | { |
2550 | { |
2496 | XGetWindowAttributes (display->display, TermWin.parent[n], &wattr); |
2551 | XGetWindowAttributes (disp, TermWin.parent[n], &wattr); |
2497 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2552 | if (wattr.depth != rootdepth || wattr.c_class == InputOnly) |
2498 | { |
2553 | { |
2499 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2554 | n = (int) (sizeof (TermWin.parent) / sizeof (Window)) + 1; |
2500 | break; |
2555 | break; |
2501 | } |
2556 | } |
2502 | } |
2557 | } |
2503 | } |
2558 | } |
2504 | |
2559 | |
2505 | if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) |
2560 | if (n > (int) (sizeof (TermWin.parent) / sizeof (TermWin.parent[0]))) |
2506 | { |
2561 | { |
2507 | XSetWindowBackground (display->display, TermWin.parent[0], pix_colors_focused[Color_fg]); |
2562 | XSetWindowBackground (disp, TermWin.parent[0], pix_colors_focused[Color_fg]); |
2508 | XSetWindowBackground (display->display, TermWin.vt, pix_colors_focused[Color_bg]); |
2563 | XSetWindowBackground (disp, TermWin.vt, pix_colors_focused[Color_bg]); |
2509 | am_transparent = 0; |
2564 | am_transparent = 0; |
2510 | /* XXX: also turn off Opt_transparent? */ |
2565 | /* XXX: also turn off Opt_transparent? */ |
2511 | } |
2566 | } |
2512 | else |
2567 | else |
2513 | { |
2568 | { |
… | |
… | |
2516 | * needed for fvwm2.2.2 (and before?) */ |
2571 | * needed for fvwm2.2.2 (and before?) */ |
2517 | sleep (1); |
2572 | sleep (1); |
2518 | #endif |
2573 | #endif |
2519 | for (n = 0; n < (unsigned int)i; n++) |
2574 | for (n = 0; n < (unsigned int)i; n++) |
2520 | { |
2575 | { |
2521 | XSetWindowBackgroundPixmap (display->display, TermWin.parent[n], ParentRelative); |
2576 | XSetWindowBackgroundPixmap (disp, TermWin.parent[n], ParentRelative); |
2522 | XClearWindow (display->display, TermWin.parent[n]); |
2577 | XClearWindow (disp, TermWin.parent[n]); |
2523 | } |
2578 | } |
2524 | |
2579 | |
2525 | XSetWindowBackgroundPixmap (display->display, TermWin.vt, ParentRelative); |
2580 | XSetWindowBackgroundPixmap (disp, TermWin.vt, ParentRelative); |
2526 | am_transparent = 1; |
2581 | am_transparent = 1; |
2527 | } |
2582 | } |
2528 | |
2583 | |
2529 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2584 | for (; i < (int) (sizeof (TermWin.parent) / sizeof (Window)); i++) |
2530 | TermWin.parent[i] = None; |
2585 | TermWin.parent[i] = None; |
2531 | } |
2586 | } |
2532 | |
2587 | |
2533 | if (scrollBar.win) |
2588 | if (scrollBar.win) |
2534 | { |
2589 | { |
2535 | XSetWindowBackgroundPixmap (display->display, scrollBar.win, ParentRelative); |
2590 | XSetWindowBackgroundPixmap (disp, scrollBar.win, ParentRelative); |
2536 | scrollBar.setIdle (); |
2591 | scrollBar.setIdle (); |
2537 | scrollbar_show (0); |
2592 | scrollbar_show (0); |
2538 | } |
2593 | } |
2539 | |
2594 | |
2540 | if (am_transparent) |
2595 | if (am_transparent) |
… | |
… | |
2578 | // some window managers resize the window early, and these programs |
2633 | // some window managers resize the window early, and these programs |
2579 | // then sometimes get the size wrong. |
2634 | // then sometimes get the size wrong. |
2580 | // unfortunately other programs are even more buggy and dislike |
2635 | // unfortunately other programs are even more buggy and dislike |
2581 | // being sent SIGWINCH, so only do it when we were in fact being |
2636 | // being sent SIGWINCH, so only do it when we were in fact being |
2582 | // resized. |
2637 | // resized. |
2583 | if (seen_resize) |
2638 | if (seen_resize && cmd_pid) |
2584 | kill (-cmd_pid, SIGWINCH); |
2639 | kill (-cmd_pid, SIGWINCH); |
2585 | } |
2640 | } |
2586 | |
2641 | |
2587 | /* Read a text string from the input buffer */ |
2642 | /* Read a text string from the input buffer */ |
2588 | unicode_t buf[UBUFSIZ]; |
2643 | unicode_t buf[UBUFSIZ]; |
… | |
… | |
3174 | { |
3229 | { |
3175 | switch (priv) |
3230 | switch (priv) |
3176 | { |
3231 | { |
3177 | case '>': |
3232 | case '>': |
3178 | if (ch == CSI_DA) /* secondary device attributes */ |
3233 | if (ch == CSI_DA) /* secondary device attributes */ |
3179 | tt_printf ("\033[>%d;%-.8s;0c", 'R', VSTRING); |
3234 | tt_printf ("\033[>%d;%c%c;0c", 'U', VERSION[0], VERSION[2]); |
3180 | break; |
3235 | break; |
3181 | case '?': |
3236 | case '?': |
3182 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3237 | if (ch == 'h' || ch == 'l' || ch == 'r' || ch == 's' || ch == 't') |
3183 | process_terminal_mode (ch, priv, nargs, arg); |
3238 | process_terminal_mode (ch, priv, nargs, arg); |
3184 | break; |
3239 | break; |
… | |
… | |
3413 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3468 | rxvt_term::process_window_ops (const int *args, unsigned int nargs) |
3414 | { |
3469 | { |
3415 | int x, y; |
3470 | int x, y; |
3416 | XWindowAttributes wattr; |
3471 | XWindowAttributes wattr; |
3417 | Window wdummy; |
3472 | Window wdummy; |
|
|
3473 | dDisp; |
3418 | |
3474 | |
3419 | if (nargs == 0) |
3475 | if (nargs == 0) |
3420 | return; |
3476 | return; |
3421 | |
3477 | |
3422 | switch (args[0]) |
3478 | switch (args[0]) |
3423 | { |
3479 | { |
3424 | /* |
3480 | /* |
3425 | * commands |
3481 | * commands |
3426 | */ |
3482 | */ |
3427 | case 1: /* deiconify window */ |
3483 | case 1: /* deiconify window */ |
3428 | XMapWindow (display->display, TermWin.parent[0]); |
3484 | XMapWindow (disp, TermWin.parent[0]); |
3429 | break; |
3485 | break; |
3430 | case 2: /* iconify window */ |
3486 | case 2: /* iconify window */ |
3431 | XIconifyWindow (display->display, TermWin.parent[0], |
3487 | XIconifyWindow (disp, TermWin.parent[0], display->screen); |
3432 | DefaultScreen (display->display)); |
|
|
3433 | break; |
3488 | break; |
3434 | case 3: /* set position (pixels) */ |
3489 | case 3: /* set position (pixels) */ |
3435 | XMoveWindow (display->display, TermWin.parent[0], args[1], args[2]); |
3490 | XMoveWindow (disp, TermWin.parent[0], args[1], args[2]); |
3436 | break; |
3491 | break; |
3437 | case 4: /* set size (pixels) */ |
3492 | case 4: /* set size (pixels) */ |
3438 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3493 | set_widthheight ((unsigned int)args[2], (unsigned int)args[1]); |
3439 | break; |
3494 | break; |
3440 | case 5: /* raise window */ |
3495 | case 5: /* raise window */ |
3441 | XRaiseWindow (display->display, TermWin.parent[0]); |
3496 | XRaiseWindow (disp, TermWin.parent[0]); |
3442 | break; |
3497 | break; |
3443 | case 6: /* lower window */ |
3498 | case 6: /* lower window */ |
3444 | XLowerWindow (display->display, TermWin.parent[0]); |
3499 | XLowerWindow (disp, TermWin.parent[0]); |
3445 | break; |
3500 | break; |
3446 | case 7: /* refresh window */ |
3501 | case 7: /* refresh window */ |
3447 | scr_touch (true); |
3502 | scr_touch (true); |
3448 | break; |
3503 | break; |
3449 | case 8: /* set size (chars) */ |
3504 | case 8: /* set size (chars) */ |
… | |
… | |
3461 | |
3516 | |
3462 | /* |
3517 | /* |
3463 | * reports - some output format copied from XTerm |
3518 | * reports - some output format copied from XTerm |
3464 | */ |
3519 | */ |
3465 | case 11: /* report window state */ |
3520 | case 11: /* report window state */ |
3466 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3521 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3467 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3522 | tt_printf ("\033[%dt", wattr.map_state == IsViewable ? 1 : 2); |
3468 | break; |
3523 | break; |
3469 | case 13: /* report window position */ |
3524 | case 13: /* report window position */ |
3470 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3525 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3471 | XTranslateCoordinates (display->display, TermWin.parent[0], wattr.root, |
3526 | XTranslateCoordinates (disp, TermWin.parent[0], wattr.root, |
3472 | -wattr.border_width, -wattr.border_width, |
3527 | -wattr.border_width, -wattr.border_width, |
3473 | &x, &y, &wdummy); |
3528 | &x, &y, &wdummy); |
3474 | tt_printf ("\033[3;%d;%dt", x, y); |
3529 | tt_printf ("\033[3;%d;%dt", x, y); |
3475 | break; |
3530 | break; |
3476 | case 14: /* report window size (pixels) */ |
3531 | case 14: /* report window size (pixels) */ |
3477 | XGetWindowAttributes (display->display, TermWin.parent[0], &wattr); |
3532 | XGetWindowAttributes (disp, TermWin.parent[0], &wattr); |
3478 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3533 | tt_printf ("\033[4;%d;%dt", wattr.height, wattr.width); |
3479 | break; |
3534 | break; |
3480 | case 18: /* report text area size (chars) */ |
3535 | case 18: /* report text area size (chars) */ |
3481 | tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); |
3536 | tt_printf ("\033[8;%d;%dt", TermWin.nrow, TermWin.ncol); |
3482 | break; |
3537 | break; |
… | |
… | |
3484 | tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); |
3539 | tt_printf ("\033[9;%d;%dt", TermWin.nrow, TermWin.ncol); |
3485 | break; |
3540 | break; |
3486 | case 20: /* report icon label */ |
3541 | case 20: /* report icon label */ |
3487 | { |
3542 | { |
3488 | char *s; |
3543 | char *s; |
3489 | XGetIconName (display->display, TermWin.parent[0], &s); |
3544 | XGetIconName (disp, TermWin.parent[0], &s); |
3490 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3545 | tt_printf ("\033]L%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3491 | XFree (s); |
3546 | XFree (s); |
3492 | } |
3547 | } |
3493 | break; |
3548 | break; |
3494 | case 21: /* report window title */ |
3549 | case 21: /* report window title */ |
3495 | { |
3550 | { |
3496 | char *s; |
3551 | char *s; |
3497 | XFetchName (display->display, TermWin.parent[0], &s); |
3552 | XFetchName (disp, TermWin.parent[0], &s); |
3498 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3553 | tt_printf ("\033]l%-.250s\234", (options & Opt_insecure) && s ? s : ""); /* 8bit ST */ |
3499 | XFree (s); |
3554 | XFree (s); |
3500 | } |
3555 | } |
3501 | break; |
3556 | break; |
3502 | } |
3557 | } |
… | |
… | |
3535 | else if (ch < 0x20) |
3590 | else if (ch < 0x20) |
3536 | return NULL; /* other control character - exit */ |
3591 | return NULL; /* other control character - exit */ |
3537 | |
3592 | |
3538 | seen_esc = false; |
3593 | seen_esc = false; |
3539 | |
3594 | |
3540 | if (n >= sizeof (string) - 1) |
3595 | if (n >= STRING_MAX - 1) |
3541 | // stop at some sane length |
3596 | // stop at some sane length |
3542 | return NULL; |
3597 | return NULL; |
3543 | |
3598 | |
3544 | if (ch == C0_SYN) |
3599 | if (ch == C0_SYN) |
3545 | string[n++] = cmd_get8 (); |
3600 | string[n++] = cmd_get8 (); |
… | |
… | |
3613 | set_window_color (color, str); |
3668 | set_window_color (color, str); |
3614 | } |
3669 | } |
3615 | |
3670 | |
3616 | /* |
3671 | /* |
3617 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3672 | * XTerm escape sequences: ESC ] Ps;Pt (ST|BEL) |
3618 | * 0 = change iconName/title |
|
|
3619 | * 1 = change iconName |
|
|
3620 | * 2 = change title |
|
|
3621 | * 4 = change color |
|
|
3622 | * 10 = change fg color |
|
|
3623 | * 11 = change bg color |
|
|
3624 | * 12 = change text color |
|
|
3625 | * 13 = change mouse foreground color |
|
|
3626 | * 17 = change highlight character colour |
|
|
3627 | * 18 = change bold character color |
|
|
3628 | * 19 = change underlined character color |
|
|
3629 | * 46 = change logfile (not implemented) |
|
|
3630 | * 50 = change font |
|
|
3631 | * |
|
|
3632 | * rxvt extensions: |
|
|
3633 | * 20 = bg pixmap |
|
|
3634 | * 39 = change default fg color |
|
|
3635 | * 49 = change default bg color |
|
|
3636 | * 55 = dump scrollback buffer and all of screen |
|
|
3637 | * 701 = change locale |
|
|
3638 | * 702 = find font |
|
|
3639 | * 703 = menu |
|
|
3640 | */ |
3673 | */ |
3641 | void |
3674 | void |
3642 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3675 | rxvt_term::process_xterm_seq (int op, const char *str, unsigned char resp) |
3643 | { |
3676 | { |
3644 | int changed = 0; |
3677 | int changed = 0; |
3645 | int color; |
3678 | int color; |
3646 | char *buf, *name; |
3679 | char *buf, *name; |
3647 | bool query = str[0] == '?' && !str[1]; |
3680 | bool query = str[0] == '?' && !str[1]; |
3648 | int saveop = op; |
3681 | int saveop = op; |
|
|
3682 | dDisp; |
3649 | |
3683 | |
3650 | assert (str != NULL); |
3684 | assert (str != NULL); |
3651 | switch (op) |
3685 | switch (op) |
3652 | { |
3686 | { |
3653 | case XTerm_name: |
3687 | case XTerm_name: |
… | |
… | |
3669 | unsigned long bytes_after; |
3703 | unsigned long bytes_after; |
3670 | unsigned char *value = 0; |
3704 | unsigned char *value = 0; |
3671 | const char *str = ""; |
3705 | const char *str = ""; |
3672 | |
3706 | |
3673 | if (prop |
3707 | if (prop |
3674 | && XGetWindowProperty (display->display, TermWin.parent[0], |
3708 | && XGetWindowProperty (disp, TermWin.parent[0], |
3675 | prop, 0, 1<<16, 0, AnyPropertyType, |
3709 | prop, 0, 1<<16, 0, AnyPropertyType, |
3676 | &actual_type, &actual_format, |
3710 | &actual_type, &actual_format, |
3677 | &nitems, &bytes_after, &value) == Success |
3711 | &nitems, &bytes_after, &value) == Success |
3678 | && actual_type != None |
3712 | && actual_type != None |
3679 | && actual_format == 8) |
3713 | && actual_format == 8) |
… | |
… | |
3691 | { |
3725 | { |
3692 | *eq = 0; |
3726 | *eq = 0; |
3693 | set_utf8_property (display->atom (str), eq + 1); |
3727 | set_utf8_property (display->atom (str), eq + 1); |
3694 | } |
3728 | } |
3695 | else |
3729 | else |
3696 | XDeleteProperty (display->display, TermWin.parent[0], |
3730 | XDeleteProperty (disp, TermWin.parent[0], |
3697 | display->atom (str)); |
3731 | display->atom (str)); |
3698 | } |
3732 | } |
3699 | break; |
3733 | break; |
3700 | |
3734 | |
3701 | case XTerm_Color: |
3735 | case XTerm_Color: |
… | |
… | |
3742 | break; |
3776 | break; |
3743 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3777 | #ifndef NO_BOLD_UNDERLINE_REVERSE |
3744 | case XTerm_Color_BD: |
3778 | case XTerm_Color_BD: |
3745 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3779 | process_color_seq (XTerm_Color_BD, Color_BD, str, resp); |
3746 | break; |
3780 | break; |
3747 | case XTerm_Color_IT: |
|
|
3748 | process_color_seq (XTerm_Color_IT, Color_IT, str, resp); |
|
|
3749 | break; |
|
|
3750 | case XTerm_Color_UL: |
3781 | case XTerm_Color_UL: |
3751 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3782 | process_color_seq (XTerm_Color_UL, Color_UL, str, resp); |
3752 | break; |
3783 | break; |
3753 | case XTerm_Color_RV: |
3784 | case XTerm_Color_RV: |
3754 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3785 | process_color_seq (XTerm_Color_RV, Color_RV, str, resp); |
3755 | break; |
3786 | break; |
|
|
3787 | case URxvt_Color_IT: |
|
|
3788 | process_color_seq (URxvt_Color_IT, Color_IT, str, resp); |
|
|
3789 | break; |
3756 | #endif |
3790 | #endif |
3757 | #if TRANSPARENT && TINTING |
3791 | #if TRANSPARENT && TINTING |
3758 | case XTerm_Color_tint: |
3792 | case URxvt_Color_tint: |
3759 | process_color_seq (XTerm_Color_tint, Color_tint, str, resp); |
3793 | process_color_seq (URxvt_Color_tint, Color_tint, str, resp); |
3760 | check_our_parents (); |
3794 | check_our_parents (); |
3761 | if (am_transparent) |
3795 | if (am_transparent) |
3762 | want_full_refresh = want_refresh = 1; |
3796 | want_full_refresh = want_refresh = 1; |
3763 | break; |
3797 | break; |
3764 | #endif |
3798 | #endif |
… | |
… | |
3798 | |
3832 | |
3799 | case XTerm_logfile: |
3833 | case XTerm_logfile: |
3800 | // TODO, when secure mode? |
3834 | // TODO, when secure mode? |
3801 | break; |
3835 | break; |
3802 | |
3836 | |
|
|
3837 | #ifdef MENUBAR |
|
|
3838 | case URxvt_Menu: |
|
|
3839 | if (options & Opt_insecure) |
|
|
3840 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
|
|
3841 | break; |
|
|
3842 | #endif |
|
|
3843 | #if 0 |
|
|
3844 | case XTerm_dumpscreen: /* no error notices */ |
|
|
3845 | { |
|
|
3846 | int fd; |
|
|
3847 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
|
|
3848 | { |
|
|
3849 | scr_dump (fd); |
|
|
3850 | close (fd); |
|
|
3851 | } |
|
|
3852 | } |
|
|
3853 | break; |
|
|
3854 | #endif |
3803 | case XTerm_font: |
3855 | case XTerm_font: |
3804 | op = URxvt_font; |
3856 | op = URxvt_font; |
3805 | case URxvt_font: |
3857 | case URxvt_font: |
3806 | #if ENABLE_STYLES |
3858 | #if ENABLE_STYLES |
3807 | case URxvt_boldFont: |
3859 | case URxvt_boldFont: |
… | |
… | |
3822 | set_fonts (); |
3874 | set_fonts (); |
3823 | } |
3875 | } |
3824 | break; |
3876 | break; |
3825 | |
3877 | |
3826 | #if ENABLE_FRILLS |
3878 | #if ENABLE_FRILLS |
3827 | case XTerm_locale: |
3879 | case URxvt_locale: |
3828 | if (query) |
3880 | if (query) |
3829 | tt_printf ("\33]%d;%-.250s%c", XTerm_locale, (options & Opt_insecure) ? locale : "", resp); |
3881 | tt_printf ("\33]%d;%-.250s%c", URxvt_locale, (options & Opt_insecure) ? locale : "", resp); |
3830 | else |
3882 | else |
3831 | { |
3883 | { |
3832 | set_locale (str); |
3884 | set_locale (str); |
3833 | pty.set_utf8_mode (enc_utf8); |
3885 | pty.set_utf8_mode (enc_utf8); |
3834 | # ifdef USE_XIM |
|
|
3835 | im_cb (); |
3886 | init_xlocale (); |
3836 | # endif |
|
|
3837 | } |
3887 | } |
3838 | break; |
3888 | break; |
3839 | #endif |
|
|
3840 | |
3889 | |
3841 | #ifdef MENUBAR |
3890 | case URxvt_view_up: |
3842 | case XTerm_Menu: |
3891 | case URxvt_view_down: |
3843 | if (options & Opt_insecure) |
3892 | int lines = atoi (str); |
3844 | menubar_dispatch (const_cast<char *>(str)); // casting away constness is checked |
3893 | |
3845 | break; |
3894 | if (lines) |
3846 | #endif |
3895 | scr_page (op == URxvt_view_up ? UP : DN, lines); |
3847 | #if 0 |
|
|
3848 | case XTerm_dumpscreen: /* no error notices */ |
|
|
3849 | { |
3896 | else |
3850 | int fd; |
|
|
3851 | if ((fd = open (str, O_RDWR | O_CREAT | O_EXCL, 0600)) >= 0) |
|
|
3852 | { |
3897 | { |
3853 | scr_dump (fd); |
3898 | scr_erase_savelines (); |
3854 | close (fd); |
|
|
3855 | } |
3899 | } |
3856 | } |
3900 | |
3857 | break; |
3901 | break; |
3858 | #endif |
3902 | #endif |
3859 | } |
3903 | } |
3860 | } |
3904 | } |
3861 | /*----------------------------------------------------------------------*/ |
3905 | /*----------------------------------------------------------------------*/ |