summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorportix <portix@gmx.net>2014-03-07 12:39:43 +0100
committerportix <portix@gmx.net>2014-03-07 12:39:43 +0100
commit0d3a6a6a21a1a10929ca4cd439591410260e3675 (patch)
treefca239eea81b42605191c0fa6f9e7418ccf60df8
parent279e552445cd6a418b460a4c21b3c6f172a87c28 (diff)
downloaddwb-0d3a6a6a21a1a10929ca4cd439591410260e3675.zip
Wait for exit when dwbremote :q is called
-rw-r--r--dwbremote/dwbremote.c13
-rw-r--r--dwbremote/dwbremote.h3
-rw-r--r--src/dwb.c4
-rw-r--r--src/ipc.c11
-rw-r--r--src/ipc.h1
5 files changed, 30 insertions, 2 deletions
diff --git a/dwbremote/dwbremote.c b/dwbremote/dwbremote.c
index 5c8adcb5..ae69f07f 100644
--- a/dwbremote/dwbremote.c
+++ b/dwbremote/dwbremote.c
@@ -140,3 +140,16 @@ error_out:
XFree((char *)children);
return max;
}
+void
+dwbremote_wait(Display *dpy, Window win, Atom atom) {
+ XEvent e;
+ XPropertyEvent *pe;
+ XSelectInput (dpy, win, PropertyChangeMask);
+ while (1) {
+ XNextEvent(dpy, &e);
+ pe = &(e.xproperty);
+ if (pe->atom == atom) {
+ break;
+ }
+ }
+}
diff --git a/dwbremote/dwbremote.h b/dwbremote/dwbremote.h
index 65c4b8fd..bfa772f9 100644
--- a/dwbremote/dwbremote.h
+++ b/dwbremote/dwbremote.h
@@ -59,4 +59,7 @@ dwbremote_set_int_property(Display *dpy, Window win, Atom atom, int status);
int
dwbremote_get_last_focus_id(Display *dpy, Window win, Atom a, Window *win_ret);
+void
+dwbremote_wait(Display *dpy, Window win, Atom atom);
+
#endif
diff --git a/src/dwb.c b/src/dwb.c
index 97ba4993..b209c56c 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -4036,6 +4036,7 @@ dwb_end(gint session_flags)
return false;
}
}
+ ipc_send_end_win();
if (EMIT_SCRIPT(CLOSE))
{
/**
@@ -5258,8 +5259,9 @@ dwb_parse_command_line(const char *line)
if (!found)
g_free(orig_line);
g_strfreev(token);
- if (ret == STATUS_END)
+ if (ret == STATUS_END) {
return ret;
+ }
dwb_glist_prepend_unique(&dwb.fc.commands, g_strdup(line));
dwb.state.last_com_history = dwb.fc.commands;
diff --git a/src/ipc.c b/src/ipc.c
index 8ec42276..11305280 100644
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -26,7 +26,7 @@
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
-#define IPC_EXECUTE(list) do { char *_ex_command = g_strjoinv(" ", list); dwb_parse_command_line(_ex_command); g_free(_ex_command); } while(0)
+#define IPC_EXECUTE(list) do { char *_ex_command = g_strjoinv(" ", list); s_dirty = true; dwb_parse_command_line(_ex_command); s_dirty = false; g_free(_ex_command); } while(0)
#define OPTNL(cond) ((cond) ? "" : "\n")
@@ -48,6 +48,7 @@ static Window s_win;
static gulong s_sig_property;
static gulong s_sig_focus;
static Window s_root;
+static int s_dirty;
static long
get_number(const char *text)
@@ -413,6 +414,13 @@ ipc_send_hook(char *name, const char *format, ...)
dwbremote_set_property_value(s_dpy, s_win, s_atoms[DWB_ATOM_HOOK], name);
}
void
+ipc_send_end_win(void) {
+ if (s_win != 0 && s_dirty) {
+ dwbremote_set_int_property(s_dpy, s_win, s_atoms[DWB_ATOM_STATUS], 0);
+ dwbremote_wait(s_dpy, s_win, s_atoms[DWB_ATOM_STATUS]);
+ }
+}
+void
ipc_end(GtkWidget *widget)
{
if (s_sig_property != 0)
@@ -427,6 +435,7 @@ ipc_end(GtkWidget *widget)
XDeleteProperty(s_dpy, s_win, s_atoms[DWB_ATOM_FOCUS_ID]);
s_sig_focus = 0;
}
+ s_win = 0;
}
void
ipc_start(GtkWidget *widget)
diff --git a/src/ipc.h b/src/ipc.h
index 9e99cfa4..a58cf00c 100644
--- a/src/ipc.h
+++ b/src/ipc.h
@@ -38,6 +38,7 @@ enum {
void ipc_start(GtkWidget *);
void ipc_end(GtkWidget *);
void ipc_send_hook(char *hook, const char *format, ...);
+void ipc_send_end_win(void);
#define IPC_SEND_HOOK(hook, ...); do { \
if (dwb.state.ipc_hooks & IPC_HOOK_##hook) ipc_send_hook(#hook, __VA_ARGS__); \