#include <pwd.h>
#include <regex.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void leavenotify(xcb_leave_notify_event_t *);
#endif
void load_float_geom(struct ws_win *);
-struct ws_win *manage_window(xcb_window_t, int);
+struct ws_win *manage_window(xcb_window_t, int, bool);
void map_window(struct ws_win *);
void mapnotify(xcb_map_notify_event_t *);
void mappingnotify(xcb_mapping_notify_event_t *);
}
struct ws_win *
-manage_window(xcb_window_t id, int mapped)
+manage_window(xcb_window_t id, int spawn_pos, bool mapped)
{
struct ws_win *win, *ww;
struct swm_region *r;
/* Figure out where to stack the window in the workspace. */
if (trans && (ww = find_window(trans)))
TAILQ_INSERT_AFTER(&win->ws->winlist, ww, win, entry);
- else if (win->ws->focus && spawn_position == SWM_STACK_ABOVE)
+ else if (win->ws->focus && spawn_pos == SWM_STACK_ABOVE)
TAILQ_INSERT_AFTER(&win->ws->winlist, win->ws->focus, win,
entry);
- else if (win->ws->focus && spawn_position == SWM_STACK_BELOW)
+ else if (win->ws->focus && spawn_pos == SWM_STACK_BELOW)
TAILQ_INSERT_BEFORE(win->ws->focus, win, entry);
- else switch (spawn_position) {
+ else switch (spawn_pos) {
default:
case SWM_STACK_TOP:
case SWM_STACK_ABOVE:
DNPRINTF(SWM_D_EVENT, "mapnotify: win %#x\n", e->window);
- if ((win = manage_window(e->window, 1)) == NULL)
+ if ((win = manage_window(e->window, spawn_position, true)) == NULL)
return;
ws = win->ws;
goto out;
}
- win = manage_window(e->window,
+ win = manage_window(e->window, spawn_position,
(war->map_state == XCB_MAP_STATE_VIEWABLE));
if (win == NULL)
goto out;
manage = state != XCB_ICCCM_WM_STATE_WITHDRAWN;
mapped = gar->map_state == XCB_MAP_STATE_VIEWABLE;
if (mapped || manage)
- manage_window(wins[j], mapped);
+ manage_window(wins[j], SWM_STACK_TOP, mapped);
free(gar);
}
/* transient windows */
pc = xcb_icccm_get_wm_transient_for(conn, wins[j]);
if (xcb_icccm_get_wm_transient_for_reply(conn, pc,
&trans, NULL) && manage)
- manage_window(wins[j], mapped);
+ manage_window(wins[j], SWM_STACK_TOP, mapped);
free(gar);
}
free(qtr);
struct swm_region *r;
char conf[PATH_MAX], *cfile = NULL;
struct stat sb;
- int xfd, i, num_screens, startup = 1;
+ int xfd, i, num_screens;
struct sigaction sact;
xcb_generic_event_t *evt;
struct timeval tv;
fd_set rd;
int rd_max;
- int stdin_ready = 0;
int num_readable;
+ bool stdin_ready = false, startup = true;
/* suppress unused warning since var is needed */
(void)argc;
/* If just (re)started, set default focus if needed. */
if (startup) {
- startup = 0;
+ startup = false;
if (focus_mode != SWM_FOCUS_FOLLOW) {
r = TAILQ_FIRST(&screens[0].rl);
if (num_readable == -1 && errno != EINTR) {
DNPRINTF(SWM_D_MISC, "select failed");
} else if (num_readable > 0 && FD_ISSET(STDIN_FILENO, &rd)) {
- stdin_ready = 1;
+ stdin_ready = true;
}
if (restart_wm)
goto done;
if (stdin_ready) {
- stdin_ready = 0;
+ stdin_ready = false;
bar_extra_update();
}