/* function definitions used in config.h */
static void clipcopy(const Arg *);
static void clippaste(const Arg *);
+static void numlock(const Arg *);
static void selpaste(const Arg *);
static void zoom(const Arg *);
static void zoomabs(const Arg *);
#define XEMBED_FOCUS_OUT 5
/* macros */
+#define IS_SET(flag) ((win.mode & (flag)) != 0)
#define TRUERED(x) (((x) & 0xff0000) >> 8)
#define TRUEGREEN(x) (((x) & 0xff00))
#define TRUEBLUE(x) (((x) & 0xff) << 8)
static XSelection xsel;
static TermWindow win;
-enum window_state {
- WIN_VISIBLE = 1,
- WIN_FOCUSED = 2
-};
-
/* Font Ring Cache */
enum {
FRC_NORMAL,
xw.win, CurrentTime);
}
+void
+numlock(const Arg *dummy)
+{
+ win.mode ^= MODE_NUMLOCK;
+}
+
void
zoom(const Arg *arg)
{
XChangeProperty(xw.dpy, xw.win, xw.netwmpid, XA_CARDINAL, 32,
PropModeReplace, (uchar *)&thispid, 1);
+ win.mode = MODE_NUMLOCK;
resettitle();
XMapWindow(xw.dpy, xw.win);
xhints();
fg = &revfg;
}
-
if (base.mode & ATTR_REVERSE) {
temp = fg;
fg = bg;
bg = temp;
}
- if (base.mode & ATTR_BLINK && term.mode & MODE_BLINK)
+ if (base.mode & ATTR_BLINK && win.mode & MODE_BLINK)
fg = bg;
if (base.mode & ATTR_INVISIBLE)
return;
/* draw the new one */
- if (win.state & WIN_FOCUSED) {
+ if (IS_SET(MODE_FOCUSED)) {
switch (win.cursor) {
case 7: /* st extension: snowman */
utf8decode("☃", &g.u, UTF_SIZ);
Glyph base, new;
XftGlyphFontSpec *specs;
- if (!(win.state & WIN_VISIBLE))
+ if (!(IS_SET(MODE_VISIBLE)))
return;
for (y = y1; y < y2; y++) {
{
XVisibilityEvent *e = &ev->xvisibility;
- MODBIT(win.state, e->state != VisibilityFullyObscured, WIN_VISIBLE);
+ MODBIT(win.mode, e->state != VisibilityFullyObscured, MODE_VISIBLE);
}
void
unmap(XEvent *ev)
{
- win.state &= ~WIN_VISIBLE;
+ win.mode &= ~MODE_VISIBLE;
}
void
XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs);
}
+void
+xsetmode(int set, unsigned int flags)
+{
+ int mode = win.mode;
+ MODBIT(win.mode, set, flags);
+ if ((win.mode & MODE_REVERSE) != (mode & MODE_REVERSE))
+ redraw();
+}
+
int
xsetcursor(int cursor)
{
void
xbell(void)
{
- if (!(win.state & WIN_FOCUSED))
+ if (!(IS_SET(MODE_FOCUSED)))
xseturgency(1);
if (bellvolume)
XkbBell(xw.dpy, xw.win, bellvolume, (Atom)NULL);
if (ev->type == FocusIn) {
XSetICFocus(xw.xic);
- win.state |= WIN_FOCUSED;
+ win.mode |= MODE_FOCUSED;
xseturgency(0);
if (IS_SET(MODE_FOCUS))
ttywrite("\033[I", 3, 0);
} else {
XUnsetICFocus(xw.xic);
- win.state &= ~WIN_FOCUSED;
+ win.mode &= ~MODE_FOCUSED;
if (IS_SET(MODE_FOCUS))
ttywrite("\033[O", 3, 0);
}
if (IS_SET(MODE_APPKEYPAD) ? kp->appkey < 0 : kp->appkey > 0)
continue;
- if (term.numlock && kp->appkey == 2)
+ if (IS_SET(MODE_NUMLOCK) && kp->appkey == 2)
continue;
if (IS_SET(MODE_APPCURSOR) ? kp->appcursor < 0 : kp->appcursor > 0)
*/
if (e->xclient.message_type == xw.xembed && e->xclient.format == 32) {
if (e->xclient.data.l[1] == XEMBED_FOCUS_IN) {
- win.state |= WIN_FOCUSED;
+ win.mode |= MODE_FOCUSED;
xseturgency(0);
} else if (e->xclient.data.l[1] == XEMBED_FOCUS_OUT) {
- win.state &= ~WIN_FOCUSED;
+ win.mode &= ~MODE_FOCUSED;
}
} else if (e->xclient.data.l[0] == xw.wmdeletewin) {
/* Send SIGHUP to shell */
if (blinktimeout) {
blinkset = tattrset(ATTR_BLINK);
if (!blinkset)
- MODBIT(term.mode, 0, MODE_BLINK);
+ MODBIT(win.mode, 0, MODE_BLINK);
}
}
dodraw = 0;
if (blinktimeout && TIMEDIFF(now, lastblink) > blinktimeout) {
tsetdirtattr(ATTR_BLINK);
- term.mode ^= MODE_BLINK;
+ win.mode ^= MODE_BLINK;
lastblink = now;
dodraw = 1;
}