Xinqi Bao's Git
projects
/
st.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
clean button selection code.
[st.git]
/
st.c
diff --git
a/st.c
b/st.c
index
99ab085
..
5d5ac30
100644
(file)
--- a/
st.c
+++ b/
st.c
@@
-107,6
+107,8
@@
typedef struct {
Colormap cmap;
Window win;
Pixmap buf;
Colormap cmap;
Window win;
Pixmap buf;
+ XIM xim;
+ XIC xic;
int scr;
int w; /* window width */
int h; /* window height */
int scr;
int w; /* window width */
int h; /* window height */
@@
-241,8
+243,9
@@
static inline int selected(int x, int y) {
}
static void getbuttoninfo(XEvent *e, int *b, int *x, int *y) {
}
static void getbuttoninfo(XEvent *e, int *b, int *x, int *y) {
- if(b) *b = e->xbutton.state,
- *b=*b==4096?5:*b==2048?4:*b==1024?3:*b==512?2:*b==256?1:-1;
+ if(b)
+ *b = e->xbutton.button;
+
*x = e->xbutton.x/xw.cw;
*y = e->xbutton.y/xw.ch;
sel.b.x = sel.by < sel.ey ? sel.bx : sel.ex;
*x = e->xbutton.x/xw.cw;
*y = e->xbutton.y/xw.ch;
sel.b.x = sel.by < sel.ey ? sel.bx : sel.ex;
@@
-1228,6
+1231,13
@@
xinit(void) {
| CWColormap,
&attrs);
xw.buf = XCreatePixmap(xw.dis, xw.win, xw.bufw, xw.bufh, XDefaultDepth(xw.dis, xw.scr));
| CWColormap,
&attrs);
xw.buf = XCreatePixmap(xw.dis, xw.win, xw.bufw, xw.bufh, XDefaultDepth(xw.dis, xw.scr));
+
+
+ /* input methods */
+ xw.xim = XOpenIM(xw.dis, NULL, NULL, NULL);
+ xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing
+ | XIMStatusNothing, XNClientWindow, xw.win,
+ XNFocusWindow, xw.win, NULL);
/* gc */
dc.gc = XCreateGC(xw.dis, xw.win, 0, NULL);
/* gc */
dc.gc = XCreateGC(xw.dis, xw.win, 0, NULL);
@@
-1411,10
+1421,11
@@
kpress(XEvent *ev) {
int len;
int meta;
int shift;
int len;
int meta;
int shift;
+ Status status;
meta = e->state & Mod1Mask;
shift = e->state & ShiftMask;
meta = e->state & Mod1Mask;
shift = e->state & ShiftMask;
- len = X
LookupString(e, buf, sizeof(buf), &ksym, NULL
);
+ len = X
mbLookupString(xw.xic, e, buf, sizeof(buf), &ksym, &status
);
if((customkey = kmap(ksym)))
ttywrite(customkey, strlen(customkey));
if((customkey = kmap(ksym)))
ttywrite(customkey, strlen(customkey));
@@
-1484,6
+1495,8
@@
run(void) {
}
while(XPending(xw.dis)) {
XNextEvent(xw.dis, &ev);
}
while(XPending(xw.dis)) {
XNextEvent(xw.dis, &ev);
+ if (XFilterEvent(&ev, xw.win))
+ continue;
if(handler[ev.type])
(handler[ev.type])(&ev);
}
if(handler[ev.type])
(handler[ev.type])(&ev);
}