aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2018-02-23 14:16:52 -0600
committerDevin J. Pohly <djpohly@gmail.com>2018-02-25 21:56:26 -0600
commit05c66cb37d9ff278a3e0c45682c4b5e7945deb42 (patch)
tree273ee88089e86784a261c5564dd51e9489bcd09e
parent33201ac65f74e45b4fa60822ba9a538c3cfa9b25 (diff)
downloadst-patched-05c66cb37d9ff278a3e0c45682c4b5e7945deb42.tar.bz2
st-patched-05c66cb37d9ff278a3e0c45682c4b5e7945deb42.tar.xz
st-patched-05c66cb37d9ff278a3e0c45682c4b5e7945deb42.zip
Split mode bits between Term and TermWindow
Moves the mode bits used by x.c from Term to TermWindow, absorbing UI/input-related mode bits (visible/focused/numlock) along the way. This is gradually reducing external references to Term. Since TermWindow is already internal to x.c, we add xsetmode() to allow st to modify window bits in accordance with escape sequences. IS_SET() is redefined accordingly (term.mode in st.c, win.mode in x.c). Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
-rw-r--r--st.c64
-rw-r--r--st.h33
-rw-r--r--win.h24
-rw-r--r--x.c50
4 files changed, 88 insertions, 83 deletions
diff --git a/st.c b/st.c
index 3ebf8c6..01791a5 100644
--- a/st.c
+++ b/st.c
@@ -42,6 +42,7 @@
42#define STR_ARG_SIZ ESC_ARG_SIZ 42#define STR_ARG_SIZ ESC_ARG_SIZ
43 43
44/* macros */ 44/* macros */
45#define IS_SET(flag) ((term.mode & (flag)) != 0)
45#define NUMMAXLEN(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) 46#define NUMMAXLEN(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)
46#define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == '\177') 47#define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == '\177')
47#define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f)) 48#define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f))
@@ -51,6 +52,17 @@
51/* constants */ 52/* constants */
52#define ISO14755CMD "dmenu -w \"$WINDOWID\" -p codepoint: </dev/null" 53#define ISO14755CMD "dmenu -w \"$WINDOWID\" -p codepoint: </dev/null"
53 54
55enum term_mode {
56 MODE_WRAP = 1 << 0,
57 MODE_INSERT = 1 << 1,
58 MODE_ALTSCREEN = 1 << 2,
59 MODE_CRLF = 1 << 3,
60 MODE_ECHO = 1 << 4,
61 MODE_PRINT = 1 << 5,
62 MODE_UTF8 = 1 << 6,
63 MODE_SIXEL = 1 << 7,
64};
65
54enum cursor_movement { 66enum cursor_movement {
55 CURSOR_SAVE, 67 CURSOR_SAVE,
56 CURSOR_LOAD 68 CURSOR_LOAD
@@ -977,8 +989,6 @@ tnew(int col, int row)
977{ 989{
978 term = (Term){ .c = { .attr = { .fg = defaultfg, .bg = defaultbg } } }; 990 term = (Term){ .c = { .attr = { .fg = defaultfg, .bg = defaultbg } } };
979 tresize(col, row); 991 tresize(col, row);
980 term.numlock = 1;
981
982 treset(); 992 treset();
983} 993}
984 994
@@ -1414,20 +1424,16 @@ tsetscroll(int t, int b)
1414void 1424void
1415tsetmode(int priv, int set, int *args, int narg) 1425tsetmode(int priv, int set, int *args, int narg)
1416{ 1426{
1417 int *lim, mode; 1427 int alt, *lim;
1418 int alt;
1419 1428
1420 for (lim = args + narg; args < lim; ++args) { 1429 for (lim = args + narg; args < lim; ++args) {
1421 if (priv) { 1430 if (priv) {
1422 switch (*args) { 1431 switch (*args) {
1423 case 1: /* DECCKM -- Cursor key */ 1432 case 1: /* DECCKM -- Cursor key */
1424 MODBIT(term.mode, set, MODE_APPCURSOR); 1433 xsetmode(set, MODE_APPCURSOR);
1425 break; 1434 break;
1426 case 5: /* DECSCNM -- Reverse video */ 1435 case 5: /* DECSCNM -- Reverse video */
1427 mode = term.mode; 1436 xsetmode(set, MODE_REVERSE);
1428 MODBIT(term.mode, set, MODE_REVERSE);
1429 if (mode != term.mode)
1430 redraw();
1431 break; 1437 break;
1432 case 6: /* DECOM -- Origin */ 1438 case 6: /* DECOM -- Origin */
1433 MODBIT(term.c.state, set, CURSOR_ORIGIN); 1439 MODBIT(term.c.state, set, CURSOR_ORIGIN);
@@ -1447,36 +1453,36 @@ tsetmode(int priv, int set, int *args, int narg)
1447 case 12: /* att610 -- Start blinking cursor (IGNORED) */ 1453 case 12: /* att610 -- Start blinking cursor (IGNORED) */
1448 break; 1454 break;
1449 case 25: /* DECTCEM -- Text Cursor Enable Mode */ 1455 case 25: /* DECTCEM -- Text Cursor Enable Mode */
1450 MODBIT(term.mode, !set, MODE_HIDE); 1456 xsetmode(!set, MODE_HIDE);
1451 break; 1457 break;
1452 case 9: /* X10 mouse compatibility mode */ 1458 case 9: /* X10 mouse compatibility mode */
1453 xsetpointermotion(0); 1459 xsetpointermotion(0);
1454 MODBIT(term.mode, 0, MODE_MOUSE); 1460 xsetmode(0, MODE_MOUSE);
1455 MODBIT(term.mode, set, MODE_MOUSEX10); 1461 xsetmode(set, MODE_MOUSEX10);
1456 break; 1462 break;
1457 case 1000: /* 1000: report button press */ 1463 case 1000: /* 1000: report button press */
1458 xsetpointermotion(0); 1464 xsetpointermotion(0);
1459 MODBIT(term.mode, 0, MODE_MOUSE); 1465 xsetmode(0, MODE_MOUSE);
1460 MODBIT(term.mode, set, MODE_MOUSEBTN); 1466 xsetmode(set, MODE_MOUSEBTN);
1461 break; 1467 break;
1462 case 1002: /* 1002: report motion on button press */ 1468 case 1002: /* 1002: report motion on button press */
1463 xsetpointermotion(0); 1469 xsetpointermotion(0);
1464 MODBIT(term.mode, 0, MODE_MOUSE); 1470 xsetmode(0, MODE_MOUSE);
1465 MODBIT(term.mode, set, MODE_MOUSEMOTION); 1471 xsetmode(set, MODE_MOUSEMOTION);
1466 break; 1472 break;
1467 case 1003: /* 1003: enable all mouse motions */ 1473 case 1003: /* 1003: enable all mouse motions */
1468 xsetpointermotion(set); 1474 xsetpointermotion(set);
1469 MODBIT(term.mode, 0, MODE_MOUSE); 1475 xsetmode(0, MODE_MOUSE);
1470 MODBIT(term.mode, set, MODE_MOUSEMANY); 1476 xsetmode(set, MODE_MOUSEMANY);
1471 break; 1477 break;
1472 case 1004: /* 1004: send focus events to tty */ 1478 case 1004: /* 1004: send focus events to tty */
1473 MODBIT(term.mode, set, MODE_FOCUS); 1479 xsetmode(set, MODE_FOCUS);
1474 break; 1480 break;
1475 case 1006: /* 1006: extended reporting mode */ 1481 case 1006: /* 1006: extended reporting mode */
1476 MODBIT(term.mode, set, MODE_MOUSESGR); 1482 xsetmode(set, MODE_MOUSESGR);
1477 break; 1483 break;
1478 case 1034: 1484 case 1034:
1479 MODBIT(term.mode, set, MODE_8BIT); 1485 xsetmode(set, MODE_8BIT);
1480 break; 1486 break;
1481 case 1049: /* swap screen & set/restore cursor as xterm */ 1487 case 1049: /* swap screen & set/restore cursor as xterm */
1482 if (!allowaltscreen) 1488 if (!allowaltscreen)
@@ -1501,7 +1507,7 @@ tsetmode(int priv, int set, int *args, int narg)
1501 tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD); 1507 tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD);
1502 break; 1508 break;
1503 case 2004: /* 2004: bracketed paste mode */ 1509 case 2004: /* 2004: bracketed paste mode */
1504 MODBIT(term.mode, set, MODE_BRCKTPASTE); 1510 xsetmode(set, MODE_BRCKTPASTE);
1505 break; 1511 break;
1506 /* Not implemented mouse modes. See comments there. */ 1512 /* Not implemented mouse modes. See comments there. */
1507 case 1001: /* mouse highlight mode; can hang the 1513 case 1001: /* mouse highlight mode; can hang the
@@ -1522,8 +1528,8 @@ tsetmode(int priv, int set, int *args, int narg)
1522 switch (*args) { 1528 switch (*args) {
1523 case 0: /* Error (IGNORED) */ 1529 case 0: /* Error (IGNORED) */
1524 break; 1530 break;
1525 case 2: /* KAM -- keyboard action */ 1531 case 2:
1526 MODBIT(term.mode, set, MODE_KBDLOCK); 1532 xsetmode(set, MODE_KBDLOCK);
1527 break; 1533 break;
1528 case 4: /* IRM -- Insertion-replacement */ 1534 case 4: /* IRM -- Insertion-replacement */
1529 MODBIT(term.mode, set, MODE_INSERT); 1535 MODBIT(term.mode, set, MODE_INSERT);
@@ -2230,10 +2236,10 @@ eschandle(uchar ascii)
2230 xloadcols(); 2236 xloadcols();
2231 break; 2237 break;
2232 case '=': /* DECPAM -- Application keypad */ 2238 case '=': /* DECPAM -- Application keypad */
2233 term.mode |= MODE_APPKEYPAD; 2239 xsetmode(1, MODE_APPKEYPAD);
2234 break; 2240 break;
2235 case '>': /* DECPNM -- Normal keypad */ 2241 case '>': /* DECPNM -- Normal keypad */
2236 term.mode &= ~MODE_APPKEYPAD; 2242 xsetmode(0, MODE_APPKEYPAD);
2237 break; 2243 break;
2238 case '7': /* DECSC -- Save Cursor */ 2244 case '7': /* DECSC -- Save Cursor */
2239 tcursor(CURSOR_SAVE); 2245 tcursor(CURSOR_SAVE);
@@ -2526,9 +2532,3 @@ redraw(void)
2526 tfulldirt(); 2532 tfulldirt();
2527 draw(); 2533 draw();
2528} 2534}
2529
2530void
2531numlock(const Arg *dummy)
2532{
2533 term.numlock ^= 1;
2534}
diff --git a/st.h b/st.h
index d7738a0..3382d61 100644
--- a/st.h
+++ b/st.h
@@ -13,7 +13,6 @@
13#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x) 13#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
14#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \ 14#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \
15 (a).bg != (b).bg) 15 (a).bg != (b).bg)
16#define IS_SET(flag) ((term.mode & (flag)) != 0)
17#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \ 16#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
18 (t1.tv_nsec-t2.tv_nsec)/1E6) 17 (t1.tv_nsec-t2.tv_nsec)/1E6)
19#define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit))) 18#define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
@@ -37,34 +36,6 @@ enum glyph_attribute {
37 ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT, 36 ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
38}; 37};
39 38
40enum term_mode {
41 MODE_WRAP = 1 << 0,
42 MODE_INSERT = 1 << 1,
43 MODE_APPKEYPAD = 1 << 2,
44 MODE_ALTSCREEN = 1 << 3,
45 MODE_CRLF = 1 << 4,
46 MODE_MOUSEBTN = 1 << 5,
47 MODE_MOUSEMOTION = 1 << 6,
48 MODE_REVERSE = 1 << 7,
49 MODE_KBDLOCK = 1 << 8,
50 MODE_HIDE = 1 << 9,
51 MODE_ECHO = 1 << 10,
52 MODE_APPCURSOR = 1 << 11,
53 MODE_MOUSESGR = 1 << 12,
54 MODE_8BIT = 1 << 13,
55 MODE_BLINK = 1 << 14,
56 MODE_FBLINK = 1 << 15,
57 MODE_FOCUS = 1 << 16,
58 MODE_MOUSEX10 = 1 << 17,
59 MODE_MOUSEMANY = 1 << 18,
60 MODE_BRCKTPASTE = 1 << 19,
61 MODE_PRINT = 1 << 20,
62 MODE_UTF8 = 1 << 21,
63 MODE_SIXEL = 1 << 22,
64 MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\
65 |MODE_MOUSEMANY,
66};
67
68enum selection_mode { 39enum selection_mode {
69 SEL_IDLE = 0, 40 SEL_IDLE = 0,
70 SEL_EMPTY = 1, 41 SEL_EMPTY = 1,
@@ -120,7 +91,6 @@ typedef struct {
120 char trantbl[4]; /* charset table translation */ 91 char trantbl[4]; /* charset table translation */
121 int charset; /* current charset */ 92 int charset; /* current charset */
122 int icharset; /* selected charset for sequence */ 93 int icharset; /* selected charset for sequence */
123 int numlock; /* lock numbers in keyboard */
124 int *tabs; 94 int *tabs;
125} Term; 95} Term;
126 96
@@ -130,7 +100,7 @@ typedef struct {
130 int w, h; /* window width and height */ 100 int w, h; /* window width and height */
131 int ch; /* char height */ 101 int ch; /* char height */
132 int cw; /* char width */ 102 int cw; /* char width */
133 char state; /* focus, redraw, visible */ 103 int mode; /* window state/mode flags */
134 int cursor; /* cursor style */ 104 int cursor; /* cursor style */
135} TermWindow; 105} TermWindow;
136 106
@@ -163,7 +133,6 @@ void die(const char *, ...);
163void redraw(void); 133void redraw(void);
164 134
165void iso14755(const Arg *); 135void iso14755(const Arg *);
166void numlock(const Arg *);
167void printscreen(const Arg *); 136void printscreen(const Arg *);
168void printsel(const Arg *); 137void printsel(const Arg *);
169void sendbreak(const Arg *); 138void sendbreak(const Arg *);
diff --git a/win.h b/win.h
index 123662e..1e08b16 100644
--- a/win.h
+++ b/win.h
@@ -1,5 +1,28 @@
1/* See LICENSE for license details. */ 1/* See LICENSE for license details. */
2 2
3enum win_mode {
4 MODE_VISIBLE = 1 << 0,
5 MODE_FOCUSED = 1 << 1,
6 MODE_APPKEYPAD = 1 << 2,
7 MODE_MOUSEBTN = 1 << 3,
8 MODE_MOUSEMOTION = 1 << 4,
9 MODE_REVERSE = 1 << 5,
10 MODE_KBDLOCK = 1 << 6,
11 MODE_HIDE = 1 << 7,
12 MODE_APPCURSOR = 1 << 8,
13 MODE_MOUSESGR = 1 << 9,
14 MODE_8BIT = 1 << 10,
15 MODE_BLINK = 1 << 11,
16 MODE_FBLINK = 1 << 12,
17 MODE_FOCUS = 1 << 13,
18 MODE_MOUSEX10 = 1 << 14,
19 MODE_MOUSEMANY = 1 << 15,
20 MODE_BRCKTPASTE = 1 << 16,
21 MODE_NUMLOCK = 1 << 17,
22 MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\
23 |MODE_MOUSEMANY,
24};
25
3void draw(void); 26void draw(void);
4void drawregion(int, int, int, int); 27void drawregion(int, int, int, int);
5 28
@@ -10,5 +33,6 @@ void xloadcols(void);
10int xsetcolorname(int, const char *); 33int xsetcolorname(int, const char *);
11void xsettitle(char *); 34void xsettitle(char *);
12int xsetcursor(int); 35int xsetcursor(int);
36void xsetmode(int, unsigned int);
13void xsetpointermotion(int); 37void xsetpointermotion(int);
14void xsetsel(char *); 38void xsetsel(char *);
diff --git a/x.c b/x.c
index 76fb910..c5826cf 100644
--- a/x.c
+++ b/x.c
@@ -51,6 +51,7 @@ typedef struct {
51/* function definitions used in config.h */ 51/* function definitions used in config.h */
52static void clipcopy(const Arg *); 52static void clipcopy(const Arg *);
53static void clippaste(const Arg *); 53static void clippaste(const Arg *);
54static void numlock(const Arg *);
54static void selpaste(const Arg *); 55static void selpaste(const Arg *);
55static void zoom(const Arg *); 56static void zoom(const Arg *);
56static void zoomabs(const Arg *); 57static void zoomabs(const Arg *);
@@ -64,6 +65,7 @@ static void zoomreset(const Arg *);
64#define XEMBED_FOCUS_OUT 5 65#define XEMBED_FOCUS_OUT 5
65 66
66/* macros */ 67/* macros */
68#define IS_SET(flag) ((win.mode & (flag)) != 0)
67#define TRUERED(x) (((x) & 0xff0000) >> 8) 69#define TRUERED(x) (((x) & 0xff0000) >> 8)
68#define TRUEGREEN(x) (((x) & 0xff00)) 70#define TRUEGREEN(x) (((x) & 0xff00))
69#define TRUEBLUE(x) (((x) & 0xff) << 8) 71#define TRUEBLUE(x) (((x) & 0xff) << 8)
@@ -196,11 +198,6 @@ static XWindow xw;
196static XSelection xsel; 198static XSelection xsel;
197static TermWindow win; 199static TermWindow win;
198 200
199enum window_state {
200 WIN_VISIBLE = 1,
201 WIN_FOCUSED = 2
202};
203
204/* Font Ring Cache */ 201/* Font Ring Cache */
205enum { 202enum {
206 FRC_NORMAL, 203 FRC_NORMAL,
@@ -264,6 +261,12 @@ selpaste(const Arg *dummy)
264} 261}
265 262
266void 263void
264numlock(const Arg *dummy)
265{
266 win.mode ^= MODE_NUMLOCK;
267}
268
269void
267zoom(const Arg *arg) 270zoom(const Arg *arg)
268{ 271{
269 Arg larg; 272 Arg larg;
@@ -1090,6 +1093,7 @@ xinit(void)
1090 XChangeProperty(xw.dpy, xw.win, xw.netwmpid, XA_CARDINAL, 32, 1093 XChangeProperty(xw.dpy, xw.win, xw.netwmpid, XA_CARDINAL, 32,
1091 PropModeReplace, (uchar *)&thispid, 1); 1094 PropModeReplace, (uchar *)&thispid, 1);
1092 1095
1096 win.mode = MODE_NUMLOCK;
1093 resettitle(); 1097 resettitle();
1094 XMapWindow(xw.dpy, xw.win); 1098 XMapWindow(xw.dpy, xw.win);
1095 xhints(); 1099 xhints();
@@ -1319,14 +1323,13 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i
1319 fg = &revfg; 1323 fg = &revfg;
1320 } 1324 }
1321 1325
1322
1323 if (base.mode & ATTR_REVERSE) { 1326 if (base.mode & ATTR_REVERSE) {
1324 temp = fg; 1327 temp = fg;
1325 fg = bg; 1328 fg = bg;
1326 bg = temp; 1329 bg = temp;
1327 } 1330 }
1328 1331
1329 if (base.mode & ATTR_BLINK && term.mode & MODE_BLINK) 1332 if (base.mode & ATTR_BLINK && win.mode & MODE_BLINK)
1330 fg = bg; 1333 fg = bg;
1331 1334
1332 if (base.mode & ATTR_INVISIBLE) 1335 if (base.mode & ATTR_INVISIBLE)
@@ -1440,7 +1443,7 @@ xdrawcursor(void)
1440 return; 1443 return;
1441 1444
1442 /* draw the new one */ 1445 /* draw the new one */
1443 if (win.state & WIN_FOCUSED) { 1446 if (IS_SET(MODE_FOCUSED)) {
1444 switch (win.cursor) { 1447 switch (win.cursor) {
1445 case 7: /* st extension: snowman */ 1448 case 7: /* st extension: snowman */
1446 utf8decode("☃", &g.u, UTF_SIZ); 1449 utf8decode("☃", &g.u, UTF_SIZ);
@@ -1527,7 +1530,7 @@ drawregion(int x1, int y1, int x2, int y2)
1527 Glyph base, new; 1530 Glyph base, new;
1528 XftGlyphFontSpec *specs; 1531 XftGlyphFontSpec *specs;
1529 1532
1530 if (!(win.state & WIN_VISIBLE)) 1533 if (!(IS_SET(MODE_VISIBLE)))
1531 return; 1534 return;
1532 1535
1533 for (y = y1; y < y2; y++) { 1536 for (y = y1; y < y2; y++) {
@@ -1575,13 +1578,13 @@ visibility(XEvent *ev)
1575{ 1578{
1576 XVisibilityEvent *e = &ev->xvisibility; 1579 XVisibilityEvent *e = &ev->xvisibility;
1577 1580
1578 MODBIT(win.state, e->state != VisibilityFullyObscured, WIN_VISIBLE); 1581 MODBIT(win.mode, e->state != VisibilityFullyObscured, MODE_VISIBLE);
1579} 1582}
1580 1583
1581void 1584void
1582unmap(XEvent *ev) 1585unmap(XEvent *ev)
1583{ 1586{
1584 win.state &= ~WIN_VISIBLE; 1587 win.mode &= ~MODE_VISIBLE;
1585} 1588}
1586 1589
1587void 1590void
@@ -1591,6 +1594,15 @@ xsetpointermotion(int set)
1591 XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs); 1594 XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs);
1592} 1595}
1593 1596
1597void
1598xsetmode(int set, unsigned int flags)
1599{
1600 int mode = win.mode;
1601 MODBIT(win.mode, set, flags);
1602 if ((win.mode & MODE_REVERSE) != (mode & MODE_REVERSE))
1603 redraw();
1604}
1605
1594int 1606int
1595xsetcursor(int cursor) 1607xsetcursor(int cursor)
1596{ 1608{
@@ -1614,7 +1626,7 @@ xseturgency(int add)
1614void 1626void
1615xbell(void) 1627xbell(void)
1616{ 1628{
1617 if (!(win.state & WIN_FOCUSED)) 1629 if (!(IS_SET(MODE_FOCUSED)))
1618 xseturgency(1); 1630 xseturgency(1);
1619 if (bellvolume) 1631 if (bellvolume)
1620 XkbBell(xw.dpy, xw.win, bellvolume, (Atom)NULL); 1632 XkbBell(xw.dpy, xw.win, bellvolume, (Atom)NULL);
@@ -1630,13 +1642,13 @@ focus(XEvent *ev)
1630 1642
1631 if (ev->type == FocusIn) { 1643 if (ev->type == FocusIn) {
1632 XSetICFocus(xw.xic); 1644 XSetICFocus(xw.xic);
1633 win.state |= WIN_FOCUSED; 1645 win.mode |= MODE_FOCUSED;
1634 xseturgency(0); 1646 xseturgency(0);
1635 if (IS_SET(MODE_FOCUS)) 1647 if (IS_SET(MODE_FOCUS))
1636 ttywrite("\033[I", 3, 0); 1648 ttywrite("\033[I", 3, 0);
1637 } else { 1649 } else {
1638 XUnsetICFocus(xw.xic); 1650 XUnsetICFocus(xw.xic);
1639 win.state &= ~WIN_FOCUSED; 1651 win.mode &= ~MODE_FOCUSED;
1640 if (IS_SET(MODE_FOCUS)) 1652 if (IS_SET(MODE_FOCUS))
1641 ttywrite("\033[O", 3, 0); 1653 ttywrite("\033[O", 3, 0);
1642 } 1654 }
@@ -1673,7 +1685,7 @@ kmap(KeySym k, uint state)
1673 1685
1674 if (IS_SET(MODE_APPKEYPAD) ? kp->appkey < 0 : kp->appkey > 0) 1686 if (IS_SET(MODE_APPKEYPAD) ? kp->appkey < 0 : kp->appkey > 0)
1675 continue; 1687 continue;
1676 if (term.numlock && kp->appkey == 2) 1688 if (IS_SET(MODE_NUMLOCK) && kp->appkey == 2)
1677 continue; 1689 continue;
1678 1690
1679 if (IS_SET(MODE_APPCURSOR) ? kp->appcursor < 0 : kp->appcursor > 0) 1691 if (IS_SET(MODE_APPCURSOR) ? kp->appcursor < 0 : kp->appcursor > 0)
@@ -1742,10 +1754,10 @@ cmessage(XEvent *e)
1742 */ 1754 */
1743 if (e->xclient.message_type == xw.xembed && e->xclient.format == 32) { 1755 if (e->xclient.message_type == xw.xembed && e->xclient.format == 32) {
1744 if (e->xclient.data.l[1] == XEMBED_FOCUS_IN) { 1756 if (e->xclient.data.l[1] == XEMBED_FOCUS_IN) {
1745 win.state |= WIN_FOCUSED; 1757 win.mode |= MODE_FOCUSED;
1746 xseturgency(0); 1758 xseturgency(0);
1747 } else if (e->xclient.data.l[1] == XEMBED_FOCUS_OUT) { 1759 } else if (e->xclient.data.l[1] == XEMBED_FOCUS_OUT) {
1748 win.state &= ~WIN_FOCUSED; 1760 win.mode &= ~MODE_FOCUSED;
1749 } 1761 }
1750 } else if (e->xclient.data.l[0] == xw.wmdeletewin) { 1762 } else if (e->xclient.data.l[0] == xw.wmdeletewin) {
1751 /* Send SIGHUP to shell */ 1763 /* Send SIGHUP to shell */
@@ -1810,7 +1822,7 @@ run(void)
1810 if (blinktimeout) { 1822 if (blinktimeout) {
1811 blinkset = tattrset(ATTR_BLINK); 1823 blinkset = tattrset(ATTR_BLINK);
1812 if (!blinkset) 1824 if (!blinkset)
1813 MODBIT(term.mode, 0, MODE_BLINK); 1825 MODBIT(win.mode, 0, MODE_BLINK);
1814 } 1826 }
1815 } 1827 }
1816 1828
@@ -1825,7 +1837,7 @@ run(void)
1825 dodraw = 0; 1837 dodraw = 0;
1826 if (blinktimeout && TIMEDIFF(now, lastblink) > blinktimeout) { 1838 if (blinktimeout && TIMEDIFF(now, lastblink) > blinktimeout) {
1827 tsetdirtattr(ATTR_BLINK); 1839 tsetdirtattr(ATTR_BLINK);
1828 term.mode ^= MODE_BLINK; 1840 win.mode ^= MODE_BLINK;
1829 lastblink = now; 1841 lastblink = now;
1830 dodraw = 1; 1842 dodraw = 1;
1831 } 1843 }