Xinqi Bao's Git
projects
/
st.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
change "op" cap in terminfo entry to xterm/rxvt value.
[st.git]
/
st.c
diff --git
a/st.c
b/st.c
index
b331ead
..
a60377b
100644
(file)
--- a/
st.c
+++ b/
st.c
@@
-43,6
+43,8
@@
#define ESC_ARG_SIZ 16
#define DRAW_BUF_SIZ 1024
#define UTF_SIZ 4
#define ESC_ARG_SIZ 16
#define DRAW_BUF_SIZ 1024
#define UTF_SIZ 4
+#define XK_NO_MOD UINT_MAX
+#define XK_ANY_MOD 0
#define SERRNO strerror(errno)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SERRNO strerror(errno)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
@@
-241,6
+243,8
@@
static void (*handler[LASTEvent])(XEvent *) = {
[VisibilityNotify] = visibility,
[UnmapNotify] = unmap,
[Expose] = expose,
[VisibilityNotify] = visibility,
[UnmapNotify] = unmap,
[Expose] = expose,
+ [EnterNotify] = focus,
+ [LeaveNotify] = focus,
[FocusIn] = focus,
[FocusOut] = focus,
[MotionNotify] = bmotion,
[FocusIn] = focus,
[FocusOut] = focus,
[MotionNotify] = bmotion,
@@
-615,7
+619,7
@@
bmotion(XEvent *e) {
if(oldey != sel.ey || oldex != sel.ex) {
int starty = MIN(oldey, sel.ey);
int endy = MAX(oldey, sel.ey);
if(oldey != sel.ey || oldex != sel.ex) {
int starty = MIN(oldey, sel.ey);
int endy = MAX(oldey, sel.ey);
- drawregion(0, (starty > 0 ? starty : 0), term.col, (
sel.e
y < term.row ? endy+1 : term.row));
+ drawregion(0, (starty > 0 ? starty : 0), term.col, (
end
y < term.row ? endy+1 : term.row));
}
}
}
}
}
}
@@
-1635,7
+1639,8
@@
xinit(void) {
attrs.bit_gravity = NorthWestGravity;
attrs.event_mask = FocusChangeMask | KeyPressMask
| ExposureMask | VisibilityChangeMask | StructureNotifyMask
attrs.bit_gravity = NorthWestGravity;
attrs.event_mask = FocusChangeMask | KeyPressMask
| ExposureMask | VisibilityChangeMask | StructureNotifyMask
- | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
+ | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask
+ | EnterWindowMask | LeaveWindowMask;
attrs.colormap = xw.cmap;
parent = opt_embed ? strtol(opt_embed, NULL, 0) : XRootWindow(xw.dpy, xw.scr);
attrs.colormap = xw.cmap;
parent = opt_embed ? strtol(opt_embed, NULL, 0) : XRootWindow(xw.dpy, xw.scr);
@@
-1819,7
+1824,7
@@
xseturgency(int add) {
void
focus(XEvent *ev) {
void
focus(XEvent *ev) {
- if(ev->type == FocusIn) {
+ if(ev->type == FocusIn
|| ev->type == EnterNotify
) {
xw.state |= WIN_FOCUSED;
xseturgency(0);
} else
xw.state |= WIN_FOCUSED;
xseturgency(0);
} else
@@
-1830,9
+1835,12
@@
focus(XEvent *ev) {
char*
kmap(KeySym k, unsigned int state) {
int i;
char*
kmap(KeySym k, unsigned int state) {
int i;
- for(i = 0; i < LEN(key); i++)
- if(key[i].k == k && (key[i].mask == 0 || key[i].mask & state))
+ state &= ~Mod2Mask;
+ for(i = 0; i < LEN(key); i++) {
+ unsigned int mask = key[i].mask;
+ if(key[i].k == k && ((state & mask) == mask || (mask == XK_NO_MOD && !state)))
return (char*)key[i].s;
return (char*)key[i].s;
+ }
return NULL;
}
return NULL;
}