aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO1
-rw-r--r--st.c32
2 files changed, 28 insertions, 5 deletions
diff --git a/TODO b/TODO
index ef68386..62a9f42 100644
--- a/TODO
+++ b/TODO
@@ -11,6 +11,7 @@ code & interface
11* clean selection code 11* clean selection code
12* clean and complete terminfo entry 12* clean and complete terminfo entry
13* fix shift up/down (shift selection in emacs) 13* fix shift up/down (shift selection in emacs)
14* fast drawing
14* ... 15* ...
15 16
16misc 17misc
diff --git a/st.c b/st.c
index a60377b..c295de6 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
@@ -122,6 +126,7 @@ typedef struct {
122 Colormap cmap; 126 Colormap cmap;
123 Window win; 127 Window win;
124 Pixmap buf; 128 Pixmap buf;
129 Atom xembed;
125 XIM xim; 130 XIM xim;
126 XIC xic; 131 XIC xic;
127 int scr; 132 int scr;
@@ -219,6 +224,7 @@ static void visibility(XEvent *);
219static void unmap(XEvent *); 224static void unmap(XEvent *);
220static char* kmap(KeySym, unsigned int state); 225static char* kmap(KeySym, unsigned int state);
221static void kpress(XEvent *); 226static void kpress(XEvent *);
227static void cmessage(XEvent *);
222static void resize(XEvent *); 228static void resize(XEvent *);
223static void focus(XEvent *); 229static void focus(XEvent *);
224static void brelease(XEvent *); 230static void brelease(XEvent *);
@@ -239,12 +245,11 @@ static int isfullutf8(char *, int);
239 245
240static void (*handler[LASTEvent])(XEvent *) = { 246static void (*handler[LASTEvent])(XEvent *) = {
241 [KeyPress] = kpress, 247 [KeyPress] = kpress,
248 [ClientMessage] = cmessage,
242 [ConfigureNotify] = resize, 249 [ConfigureNotify] = resize,
243 [VisibilityNotify] = visibility, 250 [VisibilityNotify] = visibility,
244 [UnmapNotify] = unmap, 251 [UnmapNotify] = unmap,
245 [Expose] = expose, 252 [Expose] = expose,
246 [EnterNotify] = focus,
247 [LeaveNotify] = focus,
248 [FocusIn] = focus, 253 [FocusIn] = focus,
249 [FocusOut] = focus, 254 [FocusOut] = focus,
250 [MotionNotify] = bmotion, 255 [MotionNotify] = bmotion,
@@ -1629,8 +1634,8 @@ xinit(void) {
1629 xloadcols(); 1634 xloadcols();
1630 1635
1631 /* window - default size */ 1636 /* window - default size */
1632 xw.bufh = 24 * xw.ch; 1637 xw.bufh = term.row * xw.ch;
1633 xw.bufw = 80 * xw.cw; 1638 xw.bufw = term.col * xw.cw;
1634 xw.h = xw.bufh + 2*BORDER; 1639 xw.h = xw.bufh + 2*BORDER;
1635 xw.w = xw.bufw + 2*BORDER; 1640 xw.w = xw.bufw + 2*BORDER;
1636 1641
@@ -1668,6 +1673,8 @@ xinit(void) {
1668 &(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xffff}, 1673 &(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xffff},
1669 &(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000}); 1674 &(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000});
1670 1675
1676 xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
1677
1671 XStoreName(xw.dpy, xw.win, opt_title ? opt_title : "st"); 1678 XStoreName(xw.dpy, xw.win, opt_title ? opt_title : "st");
1672 XMapWindow(xw.dpy, xw.win); 1679 XMapWindow(xw.dpy, xw.win);
1673 xhints(); 1680 xhints();
@@ -1824,7 +1831,7 @@ xseturgency(int add) {
1824 1831
1825void 1832void
1826focus(XEvent *ev) { 1833focus(XEvent *ev) {
1827 if(ev->type == FocusIn || ev->type == EnterNotify) { 1834 if(ev->type == FocusIn) {
1828 xw.state |= WIN_FOCUSED; 1835 xw.state |= WIN_FOCUSED;
1829 xseturgency(0); 1836 xseturgency(0);
1830 } else 1837 } else
@@ -1895,6 +1902,21 @@ kpress(XEvent *ev) {
1895} 1902}
1896 1903
1897void 1904void
1905cmessage(XEvent *e) {
1906 /* See xembed specs
1907 http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html */
1908 if (e->xclient.message_type == xw.xembed && e->xclient.format == 32) {
1909 if (e->xclient.data.l[1] == XEMBED_FOCUS_IN) {
1910 xw.state |= WIN_FOCUSED;
1911 xseturgency(0);
1912 } else if (e->xclient.data.l[1] == XEMBED_FOCUS_OUT) {
1913 xw.state &= ~WIN_FOCUSED;
1914 }
1915 draw();
1916 }
1917}
1918
1919void
1898resize(XEvent *e) { 1920resize(XEvent *e) {
1899 int col, row; 1921 int col, row;
1900 1922