...
 
Commits (2)
......@@ -359,20 +359,28 @@ client_resize(struct client *c, struct size size)
bool
client_send_event(struct client *c, Atom atom)
{
int unsigned i;
int n;
Atom *supported;
bool exists;
Atom *supported_atoms;
bool is_supported;
XEvent ev;
if (XGetWMProtocols(x11.dpy, c->win, &supported, &n)) {
while (!exists && n--) {
exists = supported[n] == atom;
}
XFree(supported);
if (!XGetWMProtocols(x11.dpy, c->win, &supported_atoms, &n)) {
warn("Could not get supported WM protocols for %lu", c->win);
return false;
}
if (!exists) {
if (n <= 0) {
debug("X window %lu does not support any protocols");
return false;
}
for (i = 0, is_supported = false;
i < (int unsigned) n && !is_supported;
++i)
if (supported_atoms[i] == atom)
is_supported = true;
XFree(supported_atoms);
ev.type = ClientMessage;
ev.xclient.window = c->win;
ev.xclient.message_type = x11.wmatom[WMProtocols];
......
......@@ -281,14 +281,12 @@ dmenu(union arg arg)
cmdline[i + 3] = a;
cmdline[i + 3] = NULL;
/* create pipes */
/* create pipes and launch dmenu */
if (arg.i != DMenuSpawn)
if (pipe(in) < 0 || pipe(out) < 0)
die("Could not create pipes for dmenu: %s",
strerror(errno));
if (fork() == 0) {
/* child process */
if (arg.i != DMenuSpawn) {
close(in[1]);
close(out[0]);
......@@ -300,8 +298,10 @@ dmenu(union arg arg)
sane_execvp(cmdline[0], cmdline);
die("Failed to execute %s: %s", cmdline[0], strerror(errno));
}
close(in[0]);
close(out[1]);
if (arg.i != DMenuSpawn) {
close(in[0]);
close(out[1]);
}
free(cmdline);
switch (arg.i) {
......@@ -945,7 +945,6 @@ run(void)
int ret;
fd_set fds;
struct timeval timeout = { .tv_usec = 0, .tv_sec = 0 };
dmenu_out =
running = true;
while (running && !XNextEvent(x11.dpy, &e)) {
......@@ -1751,6 +1750,7 @@ updategeom(void)
}
monitor_show_workspace(mon, ws);
}
mon = seat->monitors->elements[0];
x = 0;
y = 0;
w = (int unsigned) DisplayWidth(x11.dpy, x11.screen);
......@@ -1970,11 +1970,14 @@ main(int argc, char **argv)
note("starting %s...", APPNAME);
setup(sessionfile);
run();
sessionfile = NULL;
cleanup(&sessionfile);
XCloseDisplay(x11.dpy);
if (restarting) {
note("restarting %s...", APPNAME);
execlp(APPNAME, APPNAME, sessionfile, NULL);
} else if (sessionfile) {
free(sessionfile);
}
note("shutting down %s...", APPNAME);
return EXIT_SUCCESS;
......
......@@ -263,8 +263,8 @@ monitor_show_workspace(struct monitor *mon, struct workspace *ws)
if (ws) {
ws->mon = mon;
monitor_arrange(mon);
workspace_focus(ws, mon->focused);
}
workspace_focus(ws, mon->focused);
statusbar_update(mon->bar);
if (!oldmon) {
......