aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2011-09-16 18:03:44 +0200
committerAurélien Aptel <aurelien.aptel@gmail.com>2011-09-16 18:03:44 +0200
commit43a4c5ebb200b88dd32836aa784ea8ee2473af43 (patch)
tree53d940753d45b9131c32c5b893e89e2bdcd9c5ee
parentbf2e23f5356eb259af0478bcb70be64ddcd3718c (diff)
downloadst-patched-43a4c5ebb200b88dd32836aa784ea8ee2473af43.tar.bz2
st-patched-43a4c5ebb200b88dd32836aa784ea8ee2473af43.tar.xz
st-patched-43a4c5ebb200b88dd32836aa784ea8ee2473af43.zip
tweak focus to support XEMBED client message and remove focus on EnterNotify. (thx Adrian)
-rw-r--r--st.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/st.c b/st.c
index 4649079..6f292ba 100644
--- a/st.c
+++ b/st.c
@@ -37,6 +37,10 @@
37 "st-" VERSION ", (c) 2010-2011 st engineers\n" \ 37 "st-" VERSION ", (c) 2010-2011 st engineers\n" \
38 "usage: st [-t title] [-c class] [-w windowid] [-v] [-e command...]\n" 38 "usage: st [-t title] [-c class] [-w windowid] [-v] [-e command...]\n"
39 39
40/* XEMBED messages */
41#define XEMBED_FOCUS_IN 4
42#define XEMBED_FOCUS_OUT 5
43
40/* Arbitrary sizes */ 44/* Arbitrary sizes */
41#define ESC_TITLE_SIZ 256 45#define ESC_TITLE_SIZ 256
42#define ESC_BUF_SIZ 256 46#define ESC_BUF_SIZ 256
@@ -217,6 +221,7 @@ static void visibility(XEvent *);
217static void unmap(XEvent *); 221static void unmap(XEvent *);
218static char* kmap(KeySym, unsigned int state); 222static char* kmap(KeySym, unsigned int state);
219static void kpress(XEvent *); 223static void kpress(XEvent *);
224static void cmessage(XEvent *);
220static void resize(XEvent *); 225static void resize(XEvent *);
221static void focus(XEvent *); 226static void focus(XEvent *);
222static void brelease(XEvent *); 227static void brelease(XEvent *);
@@ -237,12 +242,11 @@ static int isfullutf8(char *, int);
237 242
238static void (*handler[LASTEvent])(XEvent *) = { 243static void (*handler[LASTEvent])(XEvent *) = {
239 [KeyPress] = kpress, 244 [KeyPress] = kpress,
245 [ClientMessage] = cmessage,
240 [ConfigureNotify] = resize, 246 [ConfigureNotify] = resize,
241 [VisibilityNotify] = visibility, 247 [VisibilityNotify] = visibility,
242 [UnmapNotify] = unmap, 248 [UnmapNotify] = unmap,
243 [Expose] = expose, 249 [Expose] = expose,
244 [EnterNotify] = focus,
245 [LeaveNotify] = focus,
246 [FocusIn] = focus, 250 [FocusIn] = focus,
247 [FocusOut] = focus, 251 [FocusOut] = focus,
248 [MotionNotify] = bmotion, 252 [MotionNotify] = bmotion,
@@ -264,6 +268,7 @@ static char **opt_cmd = NULL;
264static char *opt_title = NULL; 268static char *opt_title = NULL;
265static char *opt_embed = NULL; 269static char *opt_embed = NULL;
266static char *opt_class = NULL; 270static char *opt_class = NULL;
271static Atom xembedatom;
267 272
268int 273int
269utf8decode(char *s, long *u) { 274utf8decode(char *s, long *u) {
@@ -1666,6 +1671,8 @@ xinit(void) {
1666 &(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xffff}, 1671 &(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xffff},
1667 &(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000}); 1672 &(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000});
1668 1673
1674 xembedatom = XInternAtom(xw.dpy, "_XEMBED", False);
1675
1669 XStoreName(xw.dpy, xw.win, opt_title ? opt_title : "st"); 1676 XStoreName(xw.dpy, xw.win, opt_title ? opt_title : "st");
1670 XMapWindow(xw.dpy, xw.win); 1677 XMapWindow(xw.dpy, xw.win);
1671 xhints(); 1678 xhints();
@@ -1822,7 +1829,7 @@ xseturgency(int add) {
1822 1829
1823void 1830void
1824focus(XEvent *ev) { 1831focus(XEvent *ev) {
1825 if(ev->type == FocusIn || ev->type == EnterNotify) { 1832 if(ev->type == FocusIn) {
1826 xw.state |= WIN_FOCUSED; 1833 xw.state |= WIN_FOCUSED;
1827 xseturgency(0); 1834 xseturgency(0);
1828 } else 1835 } else
@@ -1890,6 +1897,19 @@ kpress(XEvent *ev) {
1890} 1897}
1891 1898
1892void 1899void
1900cmessage(XEvent *e) {
1901 if (e->xclient.message_type == xembedatom && e->xclient.format == 32) {
1902 if (e->xclient.data.l[1] == XEMBED_FOCUS_IN) {
1903 xw.state |= WIN_FOCUSED;
1904 xseturgency(0);
1905 } else if (e->xclient.data.l[1] == XEMBED_FOCUS_OUT) {
1906 xw.state &= ~WIN_FOCUSED;
1907 }
1908 draw();
1909 }
1910}
1911
1912void
1893resize(XEvent *e) { 1913resize(XEvent *e) {
1894 int col, row; 1914 int col, row;
1895 1915