#define HEIGHT(r) (r)->g.h
#define SWM_MAX_FONT_STEPS (3)
#define WINID(w) (w ? w->id : 0)
+#define YESNO(x) (x ? "yes" : "no")
#define SWM_FOCUS_DEFAULT (0)
#define SWM_FOCUS_SYNERGY (1)
struct search_window {
TAILQ_ENTRY(search_window) entry;
- int idx;
- struct ws_win *win;
+ int idx;
+ struct ws_win *win;
Window indicator;
};
TAILQ_HEAD(search_winlist, search_window);
struct swm_geometry g; /* current geometry */
struct swm_geometry g_float; /* geometry when floating */
struct swm_geometry rg_float; /* region geom when floating */
- int g_floatvalid; /* flag: geometry in g_float is valid */
- int floatmaxed; /* flag: floater was maxed in max_stack */
+ int g_floatvalid; /* g_float geometry validity */
+ int floatmaxed; /* whether maxed by max_stack */
int floating;
int manual;
int iconic;
{"_NET_WM_ACTION_CLOSE", None},
};
-void store_float_geom(struct ws_win *win, struct swm_region *r);
-int floating_toggle_win(struct ws_win *win);
+void store_float_geom(struct ws_win *, struct swm_region *);
+int floating_toggle_win(struct ws_win *);
void spawn_select(struct swm_region *, union arg *, char *, int *);
int
if (!win->floating)
return 0;
- DNPRINTF(SWM_D_MISC, "ewmh_set_win_fullscreen: win 0x%lx fs: %d\n",
- win->id, fs);
+ DNPRINTF(SWM_D_MISC, "ewmh_set_win_fullscreen: window: 0x%lx, "
+ "fullscreen %s\n", win->id, YESNO(fs));
rg = win->ws->r->g;
if (fs) {
store_float_geom(win, win->ws->r);
- win->g.x = rg.x;
- win->g.y = rg.y;
- win->g.w = rg.w;
- win->g.h = rg.h;
+ win->g = rg;
} else {
if (win->g_floatvalid) {
/* refloat at last floating relative position */
- win->g.x = win->g_float.x - win->rg_float.x + rg.x;
- win->g.y = win->g_float.y - win->rg_float.y + rg.y;
- win->g.w = win->g_float.w;
- win->g.h = win->g_float.h;
+ X(win) = win->g_float.x - win->rg_float.x + rg.x;
+ Y(win) = win->g_float.y - win->rg_float.y + rg.y;
+ WIDTH(win) = win->g_float.w;
+ HEIGHT(win) = win->g_float.h;
}
}
/* events */
#ifdef SWM_DEBUG
-void
-dumpevent(XEvent *e)
+char *
+geteventname(XEvent *e)
{
char *name = NULL;
case MappingNotify:
name = "MappingNotify";
break;
+ default:
+ name = "Unknown";
}
- if (name)
- DNPRINTF(SWM_D_EVENTQ ,"window: %lu event: %s (%d), %d "
- "remaining\n",
- e->xany.window, name, e->type, QLength(display));
- else
- DNPRINTF(SWM_D_EVENTQ, "window: %lu unknown event %d, %d "
- "remaining\n",
- e->xany.window, e->type, QLength(display));
+ return name;
+}
+
+char *
+xrandr_geteventname(XEvent *e)
+{
+ char *name = NULL;
+
+ switch(e->type - xrandr_eventbase) {
+ case RRScreenChangeNotify:
+ name = "RRScreenChangeNotify";
+ break;
+ default:
+ name = "Unknown";
+ }
+
+ return name;
}
void
XWindowAttributes wa;
if (r->ws == NULL) {
- fprintf(stderr, "invalid workspace\n");
+ fprintf(stderr, "dumpwins: invalid workspace\n");
return;
}
TAILQ_FOREACH(win, &r->ws->winlist, entry) {
state = getstate(win->id);
if (!XGetWindowAttributes(display, win->id, &wa))
- fprintf(stderr, "window: %lu failed "
+ fprintf(stderr, "window: 0x%lx, failed "
"XGetWindowAttributes\n", win->id);
- fprintf(stderr, "window: %lu map_state: %d state: %d "
- "transient: %lu\n",
+ fprintf(stderr, "window: 0x%lx, map_state: %d, state: %d, "
+ "transient: 0x%lx\n",
win->id, wa.map_state, state, win->transient);
}
TAILQ_FOREACH(win, &r->ws->unmanagedlist, entry) {
state = getstate(win->id);
if (!XGetWindowAttributes(display, win->id, &wa))
- fprintf(stderr, "window: %lu failed "
+ fprintf(stderr, "window: 0x%lx, failed "
"XGetWindowAttributes\n", win->id);
- fprintf(stderr, "window: %lu map_state: %d state: %d "
- "transient: %lu\n",
+ fprintf(stderr, "window: 0x%lx, map_state: %d, state: %d, "
+ "transient: 0x%lx\n",
win->id, wa.map_state, state, win->transient);
}
fprintf(stderr, "=================================\n");
}
#else
-#define dumpevent(e)
void
dumpwins(struct swm_region *r, union arg *args)
{
strlcpy(bar_ext, b, sizeof bar_ext);
}
if (b == NULL && errno != EAGAIN) {
- fprintf(stderr, "bar_extra failed: errno: %d %s\n",
- errno, strerror(errno));
+ fprintf(stderr, "bar_update: bar_extra failed: "
+ "errno: %d %s\n", errno, strerror(errno));
bar_extra_stop();
}
} else
bar_class_name(cn, sizeof cn, r->ws->focus);
bar_window_name(cn, sizeof cn, r->ws->focus);
if (r->ws->name)
- snprintf(ws, sizeof ws, "<%s>", r->ws->name);
+ snprintf(ws, sizeof ws, "<%s>",
+ r->ws->name);
}
if (stack_enabled)
stack = r->ws->stacker;
- snprintf(loc, sizeof loc, "%d:%d %s %s %s%s %s %s",
- x++, r->ws->idx + 1, stack, ws, s, cn, bar_ext,
- bar_vertext);
+ snprintf(loc, sizeof loc, "%d:%d %s %s %s%s %s "
+ "%s", x++, r->ws->idx + 1, stack, ws, s, cn,
+ bar_ext, bar_vertext);
bar_print(r, loc);
}
}
XSelectInput(display, r->bar_window, VisibilityChangeMask);
if (bar_enabled)
XMapRaised(display, r->bar_window);
- DNPRINTF(SWM_D_MISC, "bar_setup: bar_window %lu\n", r->bar_window);
+ DNPRINTF(SWM_D_MISC, "bar_setup: bar_window: 0x%lx\n", r->bar_window);
if (signal(SIGALRM, bar_signal) == SIG_ERR)
err(1, "could not install bar_signal");
while (XCheckMaskEvent(display, EnterWindowMask, &cne))
i++;
- DNPRINTF(SWM_D_MISC, "drain_enter_notify: drained %d\n", i);
+ DNPRINTF(SWM_D_MISC, "drain_enter_notify: drained: %d\n", i);
}
void
{
long data[] = {state, None};
- DNPRINTF(SWM_D_EVENT, "set_win_state: window: %lu\n", win->id);
+ DNPRINTF(SWM_D_EVENT, "set_win_state: window: 0x%lx\n", win->id);
if (win == NULL)
return;
{
bar_version = !bar_version;
if (bar_version)
- snprintf(bar_vertext, sizeof bar_vertext, "Version: %s Build: %s",
- SCROTWM_VERSION, buildstr);
+ snprintf(bar_vertext, sizeof bar_vertext,
+ "Version: %s Build: %s", SCROTWM_VERSION, buildstr);
else
strlcpy(bar_vertext, "", sizeof bar_vertext);
bar_update();
XSendEvent(display, win->id, False, 0L, (XEvent *)&cm);
}
+/* synthetic response to a ConfigureRequest when not making a change */
void
config_win(struct ws_win *win, XConfigureRequestEvent *ev)
{
if (win == NULL)
return;
- if (ev == NULL) {
- DNPRINTF(SWM_D_MISC,
- "config_win: win %lu x %d y %d w %d h %d\n",
- win->id, win->g.x, win->g.y, win->g.w, win->g.h);
+ if (ev == NULL) {
+ /* EWMH */
ce.type = ConfigureNotify;
ce.display = display;
ce.event = win->id;
ce.window = win->id;
- ce.x = win->g.x;
- ce.y = win->g.y;
- ce.width = win->g.w;
- ce.height = win->g.h;
+ ce.x = X(win);
+ ce.y = Y(win);
+ ce.width = WIDTH(win);
+ ce.height = HEIGHT(win);
ce.border_width = border_width;
ce.above = None;
ce.override_redirect = False;
} else {
- DNPRINTF(SWM_D_MISC,
- "config_win: ev win %lu x %d y %d w %d h %d\n",
- ev->window, ev->x, ev->y, ev->width, ev->height);
+ /* normal */
ce.type = ConfigureNotify;
ce.display = ev->display;
ce.event = ev->window;
ce.override_redirect = False;
}
+ DNPRINTF(SWM_D_MISC, "config_win: ewmh: %s, window: 0x%lx, (x,y) w x h: "
+ "(%d,%d) %d x %d, border: %d\n", YESNO(ev == NULL), win->id, ce.x,
+ ce.y, ce.width, ce.height, ce.border_width);
+
XSendEvent(display, win->id, False, StructureNotifyMask, (XEvent *)&ce);
}
event.root = win->s->root;
event.subwindow = None;
event.time = CurrentTime;
- event.x = win->g.x;
- event.y = win->g.y;
+ event.x = X(win);
+ event.y = Y(win);
event.x_root = 1;
event.y_root = 1;
event.same_screen = True;
XEvent cne;
Window none = None;
- DNPRINTF(SWM_D_FOCUS, "unfocus_win: id: %lu\n", WINID(win));
+ DNPRINTF(SWM_D_FOCUS, "unfocus_win: window: 0x%lx\n", WINID(win));
if (win == NULL)
return;
struct ws_win *cfw = NULL;
- DNPRINTF(SWM_D_FOCUS, "focus_win: id: %lu\n", win ? win->id : 0);
+ DNPRINTF(SWM_D_FOCUS, "focus_win: window: 0x%lx\n", WINID(win));
if (win == NULL)
return;
old_ws = this_r->ws;
new_ws = &this_r->s->ws[wsid];
- DNPRINTF(SWM_D_WS, "switchws screen[%d]:%dx%d+%d+%d: "
- "%d -> %d\n", r->s->idx, WIDTH(r), HEIGHT(r), X(r), Y(r),
- old_ws->idx, wsid);
+ DNPRINTF(SWM_D_WS, "switchws: screen[%d]:%dx%d+%d+%d: %d -> %d\n",
+ r->s->idx, WIDTH(r), HEIGHT(r), X(r), Y(r), old_ws->idx, wsid);
if (new_ws == NULL || old_ws == NULL)
return;
struct swm_screen *s = r->s;
int cycle_all = 0;
- DNPRINTF(SWM_D_WS, "cyclews id %d "
- "in screen[%d]:%dx%d+%d+%d ws %d\n", args->id,
- r->s->idx, WIDTH(r), HEIGHT(r), X(r), Y(r), r->ws->idx);
+ DNPRINTF(SWM_D_WS, "cyclews: id: %d, screen[%d]:%dx%d+%d+%d, ws: %d\n",
+ args->id, r->s->idx, WIDTH(r), HEIGHT(r), X(r), Y(r), r->ws->idx);
a.id = r->ws->idx;
do {
{
union arg a;
- DNPRINTF(SWM_D_WS, "priorws id %d "
- "in screen[%d]:%dx%d+%d+%d ws %d\n", args->id,
- r->s->idx, WIDTH(r), HEIGHT(r), X(r), Y(r), r->ws->idx);
+ DNPRINTF(SWM_D_WS, "priorws: id: %d, screen[%d]:%dx%d+%d+%d, ws: %d\n",
+ args->id, r->s->idx, WIDTH(r), HEIGHT(r), X(r), Y(r), r->ws->idx);
if (r->ws_prior == NULL)
return;
return;
/* move mouse to region */
- x = rr->g.x + 1;
- y = rr->g.y + 1 + (bar_enabled ? bar_height : 0);
+ x = X(rr) + 1;
+ y = Y(rr) + 1 + (bar_enabled ? bar_height : 0);
XWarpPointer(display, None, rr->s[i].root, 0, 0, 0, 0, x, y);
a.id = SWM_ARG_ID_FOCUSCUR;
if (rr->ws->focus) {
/* move to focus window */
- x = rr->ws->focus->g.x + 1;
- y = rr->ws->focus->g.y + 1;
+ x = X(rr->ws->focus) + 1;
+ y = Y(rr->ws->focus) + 1;
XWarpPointer(display, None, rr->s[i].root, 0, 0, 0, 0, x, y);
}
}
struct ws_win_list *wl;
- DNPRINTF(SWM_D_WS, "swapwin id %d "
- "in screen %d region %dx%d+%d+%d ws %d\n", args->id,
- r->s->idx, WIDTH(r), HEIGHT(r), X(r), Y(r), r->ws->idx);
+ DNPRINTF(SWM_D_WS, "swapwin: id: %d, screen[%d]:%dx%d+%d+%d, ws: %d\n",
+ args->id, r->s->idx, WIDTH(r), HEIGHT(r), X(r), Y(r), r->ws->idx);
cur_focus = r->ws->focus;
if (cur_focus == NULL)
TAILQ_INSERT_TAIL(wl, source, entry);
break;
default:
- DNPRINTF(SWM_D_MOVE, "invalid id: %d\n", args->id);
+ DNPRINTF(SWM_D_MOVE, "swapwin: invalid id: %d\n", args->id);
return;
}
struct ws_win_list *wl = NULL;
struct workspace *ws = NULL;
- DNPRINTF(SWM_D_FOCUS, "focus_prev: id %lu\n", WINID(win));
+ DNPRINTF(SWM_D_FOCUS, "focus_prev: window: 0x%lx\n", WINID(win));
if (!(win && win->ws))
return;
if (!(r && r->ws))
return;
- DNPRINTF(SWM_D_FOCUS, "focus: id %d\n", args->id);
+ DNPRINTF(SWM_D_FOCUS, "focus: id: %d\n", args->id);
/* treat FOCUS_CUR special */
if (args->id == SWM_ARG_ID_FOCUSCUR) {
winfocus = TAILQ_LAST(wl, ws_win_list);
if (winfocus->iconic == 0)
break;
- winfocus = TAILQ_PREV(winfocus, ws_win_list, entry);
+ winfocus = TAILQ_PREV(winfocus, ws_win_list,
+ entry);
}
}
break;
{
struct workspace *ws = r->ws;
- DNPRINTF(SWM_D_STACK, "stack_config for workspace %d (id %d\n",
+ DNPRINTF(SWM_D_STACK, "stack_config: id: %d workspace: %d\n",
args->id, ws->idx);
if (ws->cur_layout->l_config != NULL)
int j;
#endif
- DNPRINTF(SWM_D_STACK, "stack\n");
+ DNPRINTF(SWM_D_STACK, "stack: begin\n");
for (i = 0; i < ScreenCount(display); i++) {
#ifdef SWM_DEBUG
j = 0;
#endif
TAILQ_FOREACH(r, &screens[i].rl, entry) {
- DNPRINTF(SWM_D_STACK, "stacking workspace %d "
- "(screen %d, region %d)\n", r->ws->idx, i, j++);
+ DNPRINTF(SWM_D_STACK, "stack: workspace: %d "
+ "(screen: %d, region: %d)\n", r->ws->idx, i, j++);
/* start with screen geometry, adjust for bar */
g = r->g;
if (focus_mode == SWM_FOCUS_DEFAULT)
drain_enter_notify();
+
+ DNPRINTF(SWM_D_STACK, "stack: end\n");
}
void
store_float_geom(struct ws_win *win, struct swm_region *r)
{
/* retain window geom and region geom */
- win->g_float.x = win->g.x;
- win->g_float.y = win->g.y;
- win->g_float.w = win->g.w;
- win->g_float.h = win->g.h;
- win->rg_float.x = r->g.x;
- win->rg_float.y = r->g.y;
- win->rg_float.w = r->g.w;
- win->rg_float.h = r->g.h;
+ win->g_float = win->g;
+ win->rg_float = r->g;
win->g_floatvalid = 1;
}
* to allow windows to change their size (e.g. mplayer fs) only retrieve
* geom on ws switches or return from max mode
*/
-
if (win->floatmaxed || (r != r->ws->old_r && win->g_floatvalid
&& !(win->ewmh_flags & EWMH_F_FULLSCREEN))) {
/*
* use stored g and rg to set relative position and size
* as in old region or before max stack mode
*/
- win->g.x = win->g_float.x - win->rg_float.x + r->g.x;
- win->g.y = win->g_float.y - win->rg_float.y + r->g.y;
- win->g.w = win->g_float.w;
- win->g.h = win->g_float.h;
+ X(win) = win->g_float.x - win->rg_float.x + X(r);
+ Y(win) = win->g_float.y - win->rg_float.y + Y(r);
+ WIDTH(win) = win->g_float.w;
+ HEIGHT(win) = win->g_float.h;
win->g_floatvalid = 0;
}
win->floatmaxed = 0;
- if ((win->quirks & SWM_Q_FULLSCREEN) && (win->g.w >= WIDTH(r)) &&
- (win->g.h >= HEIGHT(r)))
+ if ((win->quirks & SWM_Q_FULLSCREEN) && (WIDTH(win) >= WIDTH(r)) &&
+ (HEIGHT(win) >= HEIGHT(r)))
wc.border_width = 0;
else
wc.border_width = border_width;
if (win->transient && (win->quirks & SWM_Q_TRANSSZ)) {
- win->g.w = (double)WIDTH(r) * dialog_ratio;
- win->g.h = (double)HEIGHT(r) * dialog_ratio;
+ WIDTH(win) = (double)WIDTH(r) * dialog_ratio;
+ HEIGHT(win) = (double)HEIGHT(r) * dialog_ratio;
}
if (!win->manual) {
* floaters and transients are auto-centred unless moved
* or resized
*/
- win->g.x = r->g.x + (WIDTH(r) - win->g.w) /
- 2 - wc.border_width;
- win->g.y = r->g.y + (HEIGHT(r) - win->g.h) /
- 2 - wc.border_width;
+ X(win) = X(r) + (WIDTH(r) - WIDTH(win)) / 2 - wc.border_width;
+ Y(win) = Y(r) + (HEIGHT(r) - HEIGHT(win)) / 2 - wc.border_width;
}
/* win can be outside r if new r smaller than old r */
/* Ensure top left corner inside r (move probs otherwise) */
- if (win->g.x < r->g.x - wc.border_width)
- win->g.x = r->g.x - wc.border_width;
- if (win->g.x > r->g.x + r->g.w - 1)
- win->g.x = (win->g.w > r->g.w) ? r->g.x :
- (r->g.x + r->g.w - win->g.w - 2 * wc.border_width);
- if (win->g.y < r->g.y - wc.border_width)
- win->g.y = r->g.y - wc.border_width;
- if (win->g.y > r->g.y + r->g.h - 1)
- win->g.y = (win->g.h > r->g.h) ? r->g.y :
- (r->g.y + r->g.h - win->g.h - 2 * wc.border_width);
-
- wc.x = win->g.x;
- wc.y = win->g.y;
- wc.width = win->g.w;
- wc.height = win->g.h;
+ if (X(win) < X(r) - wc.border_width)
+ X(win) = X(r) - wc.border_width;
+ if (X(win) > X(r) + WIDTH(r) - 1)
+ X(win) = (WIDTH(win) > WIDTH(r)) ? X(r) :
+ (X(r) + WIDTH(r) - WIDTH(win) - 2 * wc.border_width);
+ if (Y(win) < Y(r) - wc.border_width)
+ Y(win) = Y(r) - wc.border_width;
+ if (Y(win) > Y(r) + HEIGHT(r) - 1)
+ Y(win) = (HEIGHT(win) > HEIGHT(r)) ? Y(r) :
+ (Y(r) + HEIGHT(r) - HEIGHT(win) - 2 * wc.border_width);
+
+ wc.x = X(win);
+ wc.y = Y(win);
+ wc.width = WIDTH(win);
+ wc.height = HEIGHT(win);
/*
* Retain floater and transient geometry for correct positioning
if (!(win->ewmh_flags & EWMH_F_FULLSCREEN))
store_float_geom(win, r);
- DNPRINTF(SWM_D_MISC, "stack_floater: win %lu x %d y %d w %d h %d\n",
- win->id, wc.x, wc.y, wc.width, wc.height);
+ DNPRINTF(SWM_D_MISC, "stack_floater: window: %lu, (x,y) w x h: (%d,%d) "
+ "%d x %d\n", win->id, wc.x, wc.y, wc.width, wc.height);
XConfigureWindow(display, win->id, mask, &wc);
}
return;
if (win->sh.width_inc && win->last_inc != win->sh.width_inc &&
- win->g.w / win->sh.width_inc < term_width &&
+ WIDTH(win) / win->sh.width_inc < term_width &&
win->font_steps < SWM_MAX_FONT_STEPS) {
win->font_size_boundary[win->font_steps] =
(win->sh.width_inc * term_width) + win->sh.base_width;
win->last_inc = win->sh.width_inc;
fake_keypress(win, XK_KP_Subtract, ShiftMask);
} else if (win->font_steps && win->last_inc != win->sh.width_inc &&
- win->g.w > win->font_size_boundary[win->font_steps - 1]) {
+ WIDTH(win) > win->font_size_boundary[win->font_steps - 1]) {
win->font_steps--;
font_adjusted++;
win->last_inc = win->sh.width_inc;
int remain, missing, v_slice, reconfigure;
unsigned int mask;
- DNPRINTF(SWM_D_STACK, "stack_master: workspace: %d\n rot=%s flip=%s",
- ws->idx, rot ? "yes" : "no", flip ? "yes" : "no");
+ DNPRINTF(SWM_D_STACK, "stack_master: workspace: %d, rot: %s, "
+ "flip: %s\n", ws->idx, YESNO(rot), YESNO(flip));
winno = count_win(ws, 0);
if (winno == 0 && count_win(ws, 1) == 0)
wc.border_width = border_width;
reconfigure = 0;
if (rot) {
- if (win->g.x != win_g.y || win->g.y != win_g.x ||
- win->g.w != win_g.h || win->g.h != win_g.w) {
+ if (X(win) != win_g.y || Y(win) != win_g.x ||
+ WIDTH(win) != win_g.h || HEIGHT(win) != win_g.w) {
reconfigure = 1;
- win->g.x = wc.x = win_g.y;
- win->g.y = wc.y = win_g.x;
- win->g.w = wc.width = win_g.h;
- win->g.h = wc.height = win_g.w;
+ X(win) = wc.x = win_g.y;
+ Y(win) = wc.y = win_g.x;
+ WIDTH(win) = wc.width = win_g.h;
+ HEIGHT(win) = wc.height = win_g.w;
}
} else {
- if (win->g.x != win_g.x || win->g.y != win_g.y ||
- win->g.w != win_g.w || win->g.h != win_g.h) {
+ if (X(win) != win_g.x || Y(win) != win_g.y ||
+ WIDTH(win) != win_g.w || HEIGHT(win) != win_g.h) {
reconfigure = 1;
- win->g.x = wc.x = win_g.x;
- win->g.y = wc.y = win_g.y;
- win->g.w = wc.width = win_g.w;
- win->g.h = wc.height = win_g.h;
+ X(win) = wc.x = win_g.x;
+ Y(win) = wc.y = win_g.y;
+ WIDTH(win) = wc.width = win_g.w;
+ HEIGHT(win) = wc.height = win_g.h;
}
}
if (reconfigure) {
void
vertical_config(struct workspace *ws, int id)
{
- DNPRINTF(SWM_D_STACK, "vertical_resize: workspace: %d\n", ws->idx);
+ DNPRINTF(SWM_D_STACK, "vertical_config: id: %d, workspace: %d\n",
+ id, ws->idx);
switch (id) {
case SWM_ARG_ID_STACKRESET:
}
/* only reconfigure if necessary */
- if (win->g.x != gg.x || win->g.y != gg.y || win->g.w != gg.w ||
- win->g.h != gg.h) {
+ if (X(win) != gg.x || Y(win) != gg.y || WIDTH(win) != gg.w ||
+ HEIGHT(win) != gg.h) {
bzero(&wc, sizeof wc);
- win->g.x = wc.x = gg.x;
- win->g.y = wc.y = gg.y;
+ X(win) = wc.x = gg.x;
+ Y(win) = wc.y = gg.y;
if (bar_enabled){
wc.border_width = border_width;
- win->g.w = wc.width = gg.w;
- win->g.h = wc.height = gg.h;
+ WIDTH(win) = wc.width = gg.w;
+ HEIGHT(win) = wc.height = gg.h;
} else {
wc.border_width = 0;
- win->g.w = wc.width = gg.w + 2 * border_width;
- win->g.h = wc.height = gg.h + 2 * border_width;
+ WIDTH(win) = wc.width = gg.w + 2 * border_width;
+ HEIGHT(win) = wc.height = gg.h +
+ 2 * border_width;
}
mask = CWX | CWY | CWWidth | CWHeight | CWBorderWidth;
XConfigureWindow(display, win->id, mask, &wc);
if (win->ws->idx == wsid)
return;
- DNPRINTF(SWM_D_MOVE, "send_to_ws: win: %lu\n", win->id);
+ DNPRINTF(SWM_D_MOVE, "send_to_ws: window: 0x%lx\n", win->id);
ws = win->ws;
nws = &win->s->ws[wsid];
if (ws_idx_atom &&
snprintf((char *)ws_idx_str, SWM_PROPLEN, "%d", nws->idx) <
SWM_PROPLEN) {
- DNPRINTF(SWM_D_PROP, "setting property _SWM_WS to %s\n",
+ DNPRINTF(SWM_D_PROP, "send_to_ws: set property: _SWM_WS: %s\n",
ws_idx_str);
XChangeProperty(display, win->id, ws_idx_atom, XA_STRING, 8,
PropModeReplace, ws_idx_str, SWM_PROPLEN);
if (win->iconic == 0)
continue;
- name = get_win_name(display, win->id, a_netwmname, a_utf8_string,
- &len);
+ name = get_win_name(display, win->id, a_netwmname,
+ a_utf8_string, &len);
if (name == NULL)
continue;
fprintf(lfile, "%s.%lu\n", name, win->id);
sw = calloc(1, sizeof(struct search_window));
if (sw == NULL) {
- fprintf(stderr, "search_win: calloc: %s", strerror(errno));
+ fprintf(stderr, "search_win: calloc: %s",
+ strerror(errno));
fclose(lfile);
search_win_cleanup();
return;
struct ws_win *win;
char *s;
- DNPRINTF(SWM_D_MISC, "search_resp_uniconify: resp %s\n", resp);
+ DNPRINTF(SWM_D_MISC, "search_resp_uniconify: resp: %s\n", resp);
TAILQ_FOREACH(win, &search_r->ws->winlist, entry) {
if (win->iconic == 0)
continue;
- name = get_win_name(display, win->id, a_netwmname, a_utf8_string, &len);
+ name = get_win_name(display, win->id, a_netwmname,
+ a_utf8_string, &len);
if (name == NULL)
continue;
if (asprintf(&s, "%s.%lu", name, win->id) == -1) {
{
struct workspace *ws;
- DNPRINTF(SWM_D_MISC, "search_resp_name_workspace: resp %s\n", resp);
+ DNPRINTF(SWM_D_MISC, "search_resp_name_workspace: resp: %s\n", resp);
if (search_r->ws == NULL)
return;
if (len > 1) {
ws->name = strdup(resp);
if (ws->name == NULL) {
- DNPRINTF(SWM_D_MISC, "search_resp_name_workspace: strdup: %s",
- strerror(errno));
+ DNPRINTF(SWM_D_MISC, "search_resp_name_workspace: "
+ "strdup: %s", strerror(errno));
return;
}
}
const char *errstr;
union arg a;
- DNPRINTF(SWM_D_MISC, "search_resp_search_workspace: resp %s\n", resp);
+ DNPRINTF(SWM_D_MISC, "search_resp_search_workspace: resp: %s\n", resp);
q = strdup(resp);
if (!q) {
const char *errstr;
struct search_window *sw;
- DNPRINTF(SWM_D_MISC, "search_resp_search_window: resp %s\n", resp);
+ DNPRINTF(SWM_D_MISC, "search_resp_search_window: resp: %s\n", resp);
s = strdup(resp);
if (!s) {
void
wkill(struct swm_region *r, union arg *args)
{
- DNPRINTF(SWM_D_MISC, "wkill %d\n", args->id);
+ DNPRINTF(SWM_D_MISC, "wkill: id: %d\n", args->id);
if (r->ws->focus == NULL)
return;
} else {
if (win->g_floatvalid) {
/* refloat at last floating relative position */
- win->g.x = win->g_float.x - win->rg_float.x + r->g.x;
- win->g.y = win->g_float.y - win->rg_float.y + r->g.y;
- win->g.w = win->g_float.w;
- win->g.h = win->g_float.h;
+ X(win) = win->g_float.x - win->rg_float.x + X(r);
+ Y(win) = win->g_float.y - win->rg_float.y + Y(r);
+ WIDTH(win) = win->g_float.w;
+ HEIGHT(win) = win->g_float.h;
}
win->floating = 1;
}
void
constrain_window(struct ws_win *win, struct swm_region *r, int resizable)
{
- if (win->g.x + win->g.w > r->g.x + r->g.w - border_width) {
+ if (X(win) + WIDTH(win) > X(r) + WIDTH(r) - border_width) {
if (resizable)
- win->g.w = r->g.x + r->g.w - win->g.x - border_width;
+ WIDTH(win) = X(r) + WIDTH(r) - X(win) - border_width;
else
- win->g.x = r->g.x + r->g.w - win->g.w - border_width;
+ X(win) = X(r) + WIDTH(r) - WIDTH(win) - border_width;
}
- if (win->g.x < r->g.x - border_width) {
+ if (X(win) < X(r) - border_width) {
if (resizable)
- win->g.w -= r->g.x - win->g.x - border_width;
+ WIDTH(win) -= X(r) - X(win) - border_width;
- win->g.x = r->g.x - border_width;
+ X(win) = X(r) - border_width;
}
- if (win->g.y + win->g.h > r->g.y + r->g.h - border_width) {
+ if (Y(win) + HEIGHT(win) > Y(r) + HEIGHT(r) - border_width) {
if (resizable)
- win->g.h = r->g.y + r->g.h - win->g.y - border_width;
+ HEIGHT(win) = Y(r) + HEIGHT(r) - Y(win) - border_width;
else
- win->g.y = r->g.y + r->g.h - win->g.h - border_width;
+ Y(win) = Y(r) + HEIGHT(r) - HEIGHT(win) - border_width;
}
- if (win->g.y < r->g.y - border_width) {
+ if (Y(win) < Y(r) - border_width) {
if (resizable)
- win->g.h -= r->g.y - win->g.y - border_width;
+ HEIGHT(win) -= Y(r) - Y(win) - border_width;
- win->g.y = r->g.y - border_width;
+ Y(win) = Y(r) - border_width;
}
- if (win->g.w < 1)
- win->g.w = 1;
- if (win->g.h < 1)
- win->g.h = 1;
+ if (WIDTH(win) < 1)
+ WIDTH(win) = 1;
+ if (HEIGHT(win) < 1)
+ HEIGHT(win) = 1;
}
void
bzero(&wc, sizeof wc);
mask = CWBorderWidth | CWWidth | CWHeight | CWX | CWY;
wc.border_width = border_width;
- wc.x = win->g.x;
- wc.y = win->g.y;
- wc.width = win->g.w;
- wc.height = win->g.h;
+ wc.x = X(win);
+ wc.y = Y(win);
+ wc.width = WIDTH(win);
+ wc.height = HEIGHT(win);
- DNPRINTF(SWM_D_STACK, "update_window: win %lu x %d y %d w %d h %d\n",
- win->id, wc.x, wc.y, wc.width, wc.height);
+ DNPRINTF(SWM_D_MISC, "update_window: window: 0x%lx, (x,y) w x h: "
+ "(%d,%d) %d x %d\n", win->id, wc.x, wc.y, wc.width, wc.height);
XConfigureWindow(display, win->id, mask, &wc);
}
return;
r = win->ws->r;
- DNPRINTF(SWM_D_MOUSE, "resize: win %lu floating %d trans %lu\n",
- win->id, win->floating, win->transient);
+ DNPRINTF(SWM_D_MOUSE, "resize: window: 0x%lx, floating: %s, "
+ "transient: 0x%lx\n", win->id, YESNO(win->floating),
+ win->transient);
if (!(win->transient != 0 || win->floating != 0))
return;
switch (args->id) {
case SWM_ARG_ID_WIDTHSHRINK:
- win->g.w -= SWM_RESIZE_STEPS;
+ WIDTH(win) -= SWM_RESIZE_STEPS;
resize_step = 1;
break;
case SWM_ARG_ID_WIDTHGROW:
- win->g.w += SWM_RESIZE_STEPS;
+ WIDTH(win) += SWM_RESIZE_STEPS;
resize_step = 1;
break;
case SWM_ARG_ID_HEIGHTSHRINK:
- win->g.h -= SWM_RESIZE_STEPS;
+ HEIGHT(win) -= SWM_RESIZE_STEPS;
resize_step = 1;
break;
case SWM_ARG_ID_HEIGHTGROW:
- win->g.h += SWM_RESIZE_STEPS;
+ HEIGHT(win) += SWM_RESIZE_STEPS;
resize_step = 1;
break;
default:
g = win->g;
- if (wx < win->g.w / 2)
+ if (wx < WIDTH(win) / 2)
left = 1;
- if (wy < win->g.h / 2)
+ if (wy < HEIGHT(win) / 2)
top = 1;
if (args->id == SWM_ARG_ID_CENTER)
if (g.h / 2 + dy < 1)
dy = 1 - g.h / 2;
- win->g.y = g.y - dy;
- win->g.h = g.h + 2 * dy;
+ Y(win) = g.y - dy;
+ HEIGHT(win) = g.h + 2 * dy;
} else {
if (g.h + dy < 1)
dy = 1 - g.h;
if (top)
- win->g.y = g.y - dy;
+ Y(win) = g.y - dy;
- win->g.h = g.h + dy;
+ HEIGHT(win) = g.h + dy;
}
/* horizontal */
if (g.w / 2 + dx < 1)
dx = 1 - g.w / 2;
- win->g.x = g.x - dx;
- win->g.w = g.w + 2 * dx;
+ X(win) = g.x - dx;
+ WIDTH(win) = g.w + 2 * dx;
} else {
if (g.w + dx < 1)
dx = 1 - g.w;
if (left)
- win->g.x = g.x - dx;
+ X(win) = g.x - dx;
- win->g.w = g.w + dx;
+ WIDTH(win) = g.w + dx;
}
constrain_window(win, r, 1);
return;
r = win->ws->r;
- DNPRINTF(SWM_D_MOUSE, "move: win %lu floating %d trans %lu\n",
- win->id, win->floating, win->transient);
+ DNPRINTF(SWM_D_MOUSE, "move: window: 0x%lx, floating: %s, transient: "
+ "0x%lx\n", win->id, YESNO(win->floating), win->transient);
/* in max_stack mode should only move transients */
if (win->ws->cur_layout == &layouts[SWM_MAX_STACK] && !win->transient)
move_step = 0;
switch (args->id) {
case SWM_ARG_ID_MOVELEFT:
- win->g.x -= (SWM_MOVE_STEPS - border_width);
+ X(win) -= (SWM_MOVE_STEPS - border_width);
move_step = 1;
break;
case SWM_ARG_ID_MOVERIGHT:
- win->g.x += (SWM_MOVE_STEPS - border_width);
+ X(win) += (SWM_MOVE_STEPS - border_width);
move_step = 1;
break;
case SWM_ARG_ID_MOVEUP:
- win->g.y -= (SWM_MOVE_STEPS - border_width);
+ Y(win) -= (SWM_MOVE_STEPS - border_width);
move_step = 1;
break;
case SWM_ARG_ID_MOVEDOWN:
- win->g.y += (SWM_MOVE_STEPS - border_width);
+ Y(win) += (SWM_MOVE_STEPS - border_width);
move_step = 1;
break;
default:
if (move_step) {
constrain_window(win, r, 0);
update_window(win);
- store_float_geom(win,r);
+ store_float_geom(win, r);
return;
}
handler[ev.type](&ev);
break;
case MotionNotify:
- win->g.x = ev.xmotion.x_root - wx - border_width;
- win->g.y = ev.xmotion.y_root - wy - border_width;
+ X(win) = ev.xmotion.x_root - wx - border_width;
+ Y(win) = ev.xmotion.y_root - wy - border_width;
constrain_window(win, r, 0);
int i;
char *ap, **real_args;
- DNPRINTF(SWM_D_SPAWN, "spawn_expand %s\n", spawn_name);
+ DNPRINTF(SWM_D_SPAWN, "spawn_expand: %s\n", spawn_name);
/* find program */
for (i = 0; i < spawns_length; i++) {
/* expand spawn_args into real_args */
for (i = 0; i < prog->argc; i++) {
ap = prog->argv[i];
- DNPRINTF(SWM_D_SPAWN, "spawn_custom: raw arg = %s\n", ap);
+ DNPRINTF(SWM_D_SPAWN, "spawn_custom: raw arg: %s\n", ap);
if (!strcasecmp(ap, "$bar_border")) {
if ((real_args[i] =
strdup(r->s->c[SWM_S_COLOR_BAR_BORDER].name))
if ((real_args[i] = strdup(ap)) == NULL)
err(1, "spawn_custom strdup(ap)");
}
- DNPRINTF(SWM_D_SPAWN, "spawn_custom: cooked arg = %s\n",
+ DNPRINTF(SWM_D_SPAWN, "spawn_custom: cooked arg: %s\n",
real_args[i]);
}
#ifdef SWM_DEBUG
- if ((swm_debug & SWM_D_SPAWN) != 0) {
- fprintf(stderr, "spawn_custom: result = ");
- for (i = 0; i < prog->argc; i++)
- fprintf(stderr, "\"%s\" ", real_args[i]);
- fprintf(stderr, "\n");
- }
+ DNPRINTF(SWM_D_SPAWN, "spawn_custom: result: ");
+ for (i = 0; i < prog->argc; i++)
+ DNPRINTF(SWM_D_SPAWN, "\"%s\" ", real_args[i]);
+ DNPRINTF(SWM_D_SPAWN, "\n");
#endif
*ret_args = real_args;
return (prog->argc);
if (prog->argv == NULL) {
/* delete */
DNPRINTF(SWM_D_SPAWN,
- "setspawn: delete #%d %s\n",
+ "setspawn: delete #%d: %s\n",
i, spawns[i].name);
free(spawns[i].name);
for (j = 0; j < spawns[i].argc; j++)
} else {
/* replace */
DNPRINTF(SWM_D_SPAWN,
- "setspawn: replace #%d %s\n",
+ "setspawn: replace #%d: %s\n",
i, spawns[i].name);
free(spawns[i].name);
for (j = 0; j < spawns[i].argc; j++)
if (prog->argv == NULL) {
fprintf(stderr,
- "error: setspawn: cannot find program %s", prog->name);
+ "error: setspawn: cannot find program: %s", prog->name);
free(prog);
return;
}
} else {
/* found: replace */
DNPRINTF(SWM_D_KEY,
- "setkeybinding: replace #%d %s %s\n",
+ "setkeybinding: replace #%d %s [%s]\n",
i, keyfuncs[keys[i].funcid].name,
spawn_name);
free(keys[i].spawn_name);
}
if (keys_length < keys_size) {
j = keys_length++;
- DNPRINTF(SWM_D_KEY, "setkeybinding: add #%d %s %s\n",
+ DNPRINTF(SWM_D_KEY, "setkeybinding: add #%d %s [%s]\n",
j, keyfuncs[kfid].name, spawn_name);
keys[j].mod = mod;
keys[j].keysym = ks;
int wordlen, i, optind;
struct config_option *opt;
- DNPRINTF(SWM_D_CONF, "conf_load begin\n");
+ DNPRINTF(SWM_D_CONF, "conf_load: begin\n");
if (filename == NULL) {
fprintf(stderr, "conf_load: no filename\n");
}
fclose(config);
- DNPRINTF(SWM_D_CONF, "conf_load end\n");
+ DNPRINTF(SWM_D_CONF, "conf_load: end\n");
return (0);
parent->child_trans = win;
else {
DNPRINTF(SWM_D_MISC, "set_child_transient: parent doesn't exist"
- " for %lu trans %lu\n", win->id, win->transient);
+ " for 0x%lx trans 0x%lx\n", win->id, win->transient);
if (win->hints == NULL) {
- fprintf(stderr, "no hints for %lu\n", win->id);
+ fprintf(stderr, "no hints for 0x%lx\n", win->id);
return;
}
XFree(wmh);
if ((wmh = XGetWMHints(display, w->id)) == NULL) {
- fprintf(stderr, "can't get hints for %lu\n",
+ fprintf(stderr, "can't get hints for 0x%lx\n",
w->id);
continue;
}
win->transient = w->id;
*trans = w->id;
DNPRINTF(SWM_D_MISC, "set_child_transient: asjusting "
- "transient to %lu\n", win->transient);
+ "transient to 0x%lx\n", win->transient);
break;
}
}
/* see if we are on the unmanaged list */
if ((win = find_unmanaged_window(id)) != NULL) {
- DNPRINTF(SWM_D_MISC, "manage previously unmanaged window "
- "%lu\n", win->id);
+ DNPRINTF(SWM_D_MISC, "manage_window: previously unmanaged "
+ "window: 0x%lx\n", win->id);
TAILQ_REMOVE(&win->ws->unmanagedlist, win, entry);
if (win->transient) {
set_child_transient(win, &trans);
}
if ((win = calloc(1, sizeof(struct ws_win))) == NULL)
- err(1, "calloc: failed to allocate memory for new window");
+ err(1, "manage_window: calloc: failed to allocate memory for "
+ "new window");
win->id = id;
if (trans) {
win->transient = trans;
set_child_transient(win, &trans);
- DNPRINTF(SWM_D_MISC, "manage_window: win %lu transient %lu\n",
- win->id, win->transient);
+ DNPRINTF(SWM_D_MISC, "manage_window: window: 0x%lx, "
+ "transient: 0x%lx\n", win->id, win->transient);
}
/* get supported protocols */
free(p);
p = NULL;
} else if (prop && win->transient == 0) {
- DNPRINTF(SWM_D_PROP, "got property _SWM_WS=%s\n", prop);
+ DNPRINTF(SWM_D_PROP, "manage_window: get _SWM_WS: %s\n", prop);
ws_idx = strtonum((const char *)prop, 0, 9, &errstr);
if (errstr) {
- DNPRINTF(SWM_D_EVENT, "window idx is %s: %s",
+ DNPRINTF(SWM_D_EVENT, "manage_window: window: #%s: %s",
errstr, prop);
}
ws = &r->s->ws[ws_idx];
r = ww->ws->r;
else
fprintf(stderr,
- "fix this bug mcbride\n");
+ "manage_window: fix this "
+ "bug mcbride\n");
border_me = 1;
}
}
else
TAILQ_INSERT_TAIL(&ws->winlist, win, entry);
- win->g.w = win->wa.width;
- win->g.h = win->wa.height;
- win->g.x = win->wa.x;
- win->g.y = win->wa.y;
+ WIDTH(win) = win->wa.width;
+ HEIGHT(win) = win->wa.height;
+ X(win) = win->wa.x;
+ Y(win) = win->wa.y;
win->g_floatvalid = 0;
win->floatmaxed = 0;
win->ewmh_flags = 0;
if (ws_idx_atom && prop == NULL &&
snprintf((char *)ws_idx_str, SWM_PROPLEN, "%d", ws->idx) <
SWM_PROPLEN) {
- DNPRINTF(SWM_D_PROP, "setting property _SWM_WS to %s\n",
+ DNPRINTF(SWM_D_PROP, "manage_window: set _SWM_WS: %s\n",
ws_idx_str);
XChangeProperty(display, win->id, ws_idx_atom, XA_STRING, 8,
PropModeReplace, ws_idx_str, SWM_PROPLEN);
ewmh_autoquirk(win);
if (XGetClassHint(display, win->id, &win->ch)) {
- DNPRINTF(SWM_D_CLASS, "class: %s name: %s\n",
+ DNPRINTF(SWM_D_CLASS, "manage_window: class: %s, name: %s\n",
win->ch.res_class, win->ch.res_name);
/* java is retarded so treat it special */
for (i = 0; i < quirks_length; i++){
if (!strcmp(win->ch.res_class, quirks[i].class) &&
!strcmp(win->ch.res_name, quirks[i].name)) {
- DNPRINTF(SWM_D_CLASS, "found: %s name: %s\n",
- win->ch.res_class, win->ch.res_name);
+ DNPRINTF(SWM_D_CLASS, "manage_window: found: "
+ "class: %s, name: %s\n", win->ch.res_class,
+ win->ch.res_name);
if (quirks[i].quirk & SWM_Q_FLOAT) {
win->floating = 1;
border_me = 1;
win->manual = 1; /* don't center the quirky windows */
bzero(&wc, sizeof wc);
mask = 0;
- if (bar_enabled && win->g.y < bar_height) {
- win->g.y = wc.y = bar_height;
+ if (bar_enabled && Y(win) < bar_height) {
+ Y(win) = wc.y = bar_height;
mask |= CWY;
}
- if (win->g.w + win->g.x > WIDTH(r)) {
- win->g.x = wc.x = WIDTH(r) - win->g.w - 2;
+ if (WIDTH(win) + X(win) > WIDTH(r)) {
+ X(win) = wc.x = WIDTH(r) - WIDTH(win) - 2;
mask |= CWX;
}
border_me = 1;
void
free_window(struct ws_win *win)
{
- DNPRINTF(SWM_D_MISC, "free_window: %lu\n", win->id);
+ DNPRINTF(SWM_D_MISC, "free_window: window: 0x%lx\n", win->id);
if (win == NULL)
return;
if (win == NULL)
return;
- DNPRINTF(SWM_D_MISC, "unmanage_window: %lu\n", win->id);
+ DNPRINTF(SWM_D_MISC, "unmanage_window: window: 0x%lx\n", win->id);
if (win->transient) {
parent = find_window(win->transient);
void
focus_magic(struct ws_win *win)
{
- DNPRINTF(SWM_D_FOCUS, "focus_magic: %lu\n", WINID(win));
+ DNPRINTF(SWM_D_FOCUS, "focus_magic: window: 0x%lx\n", WINID(win));
if (win == NULL)
return;
void
expose(XEvent *e)
{
- DNPRINTF(SWM_D_EVENT, "expose: window: %lu\n", e->xexpose.window);
+ DNPRINTF(SWM_D_EVENT, "expose: window: 0x%lx\n", e->xexpose.window);
}
void
KeySym keysym;
XKeyEvent *ev = &e->xkey;
- DNPRINTF(SWM_D_EVENT, "keypress: window: %lu\n", ev->window);
-
keysym = XKeycodeToKeysym(display, (KeyCode)ev->keycode, 0);
for (i = 0; i < keys_length; i++)
if (keysym == keys[i].keysym
int i, action;
XButtonPressedEvent *ev = &e->xbutton;
- DNPRINTF(SWM_D_EVENT, "buttonpress: window: %lu\n", ev->window);
-
if ((win = find_window(ev->window)) == NULL)
return;
if ((win = find_unmanaged_window(ev->window)) == NULL)
new = 1;
+ DNPRINTF(SWM_D_EVENT, "configurerequest: window: 0x%lx, new: %s\n",
+ ev->window, YESNO(new));
+
if (new) {
- DNPRINTF(SWM_D_EVENT, "configurerequest: new window: %lu\n",
- ev->window);
bzero(&wc, sizeof wc);
wc.x = ev->x;
wc.y = ev->y;
wc.stack_mode = ev->detail;
XConfigureWindow(display, ev->window, ev->value_mask, &wc);
} else {
- DNPRINTF(SWM_D_EVENT, "configurerequest: change window: %lu\n",
- ev->window);
config_win(win, ev);
}
}
struct ws_win *win;
long mask;
- DNPRINTF(SWM_D_EVENT, "configurenotify: window: %lu\n",
+ DNPRINTF(SWM_D_EVENT, "configurenotify: window: 0x%lx\n",
e->xconfigure.window);
win = find_window(e->xconfigure.window);
struct ws_win *win;
XDestroyWindowEvent *ev = &e->xdestroywindow;
- DNPRINTF(SWM_D_EVENT, "destroynotify: window %lu\n", ev->window);
+ DNPRINTF(SWM_D_EVENT, "destroynotify: window: 0x%lx\n", ev->window);
if ((win = find_window(ev->window)) == NULL) {
if ((win = find_unmanaged_window(ev->window)) == NULL)
Window focus_return;
int revert_to_return;
#endif
- DNPRINTF(SWM_D_FOCUS, "enternotify: window: %lu mode %d detail %d root "
- "%lu subwindow %lu same_screen %d focus %d state %d\n",
- ev->window, ev->mode, ev->detail, ev->root, ev->subwindow,
- ev->same_screen, ev->focus, ev->state);
+ DNPRINTF(SWM_D_FOCUS, "enternotify: window: 0x%lx, mode: %d, detail: "
+ "%d, root: 0x%lx, subwindow: 0x%lx, same_screen: %s, focus: %s, "
+ "state: %d\n", ev->window, ev->mode, ev->detail, ev->root,
+ ev->subwindow, YESNO(ev->same_screen), YESNO(ev->focus), ev->state);
if (ev->mode != NotifyNormal) {
- DNPRINTF(SWM_D_EVENT, "ignoring enternotify: generated by cursor grab.\n");
+ DNPRINTF(SWM_D_EVENT, "skip enternotify: generated by "
+ "cursor grab.\n");
return;
}
}
if ((win = find_window(ev->window)) == NULL) {
- DNPRINTF(SWM_D_EVENT, "ignoring enternotify: win == NULL\n");
+ DNPRINTF(SWM_D_EVENT, "skip enternotify: window is NULL\n");
return;
}
u_int32_t mode_detail;
XFocusChangeEvent *ev = &e->xfocus;
- DNPRINTF(SWM_D_EVENT, "focusevent: %s window: %lu mode %d detail %d\n",
- ev->type == FocusIn ? "entering" : "leaving",
+ DNPRINTF(SWM_D_EVENT, "focusevent: %s window: 0x%lx mode: %d "
+ "detail: %d\n", ev->type == FocusIn ? "entering" : "leaving",
ev->window, ev->mode, ev->detail);
if (last_focus_event == ev->type) {
struct ws_win *win;
XMapEvent *ev = &e->xmap;
- DNPRINTF(SWM_D_EVENT, "mapnotify: window: %lu\n", ev->window);
+ DNPRINTF(SWM_D_EVENT, "mapnotify: window: 0x%lx\n", ev->window);
win = manage_window(ev->window);
if (win)
XWindowAttributes wa;
XMapRequestEvent *ev = &e->xmaprequest;
- DNPRINTF(SWM_D_EVENT, "maprequest: window: %lu\n",
+ DNPRINTF(SWM_D_EVENT, "maprequest: window: 0x%lx\n",
e->xmaprequest.window);
if (!XGetWindowAttributes(display, ev->window, &wa))
struct ws_win *win;
XPropertyEvent *ev = &e->xproperty;
- DNPRINTF(SWM_D_EVENT, "propertynotify: window: %lu atom:%s\n",
+ DNPRINTF(SWM_D_EVENT, "propertynotify: window: 0x%lx, atom: %s\n",
ev->window, XGetAtomName(display, ev->atom));
win = find_window(ev->window);
XGetWMNormalHints(display, win->id, &win->sh, &mask);
fprintf(stderr, "normal hints: flag 0x%x\n", win->sh.flags);
if (win->sh.flags & PMinSize) {
- win->g.w = win->sh.min_width;
- win->g.h = win->sh.min_height;
- fprintf(stderr, "min %d %d\n", win->g.w, win->g.h);
+ WIDTH(win) = win->sh.min_width;
+ HEIGHT(win) = win->sh.min_height;
+ fprintf(stderr, "min %d %d\n", WIDTH(win), HEIGHT(win));
}
XMoveResizeWindow(display, win->id,
- win->g.x, win->g.y, win->g.w, win->g.h);
+ X(win), Y(win), WIDTH(win), HEIGHT(win));
#endif
case XA_WM_CLASS:
if (title_name_enabled || title_class_enabled)
{
struct ws_win *win;
- DNPRINTF(SWM_D_EVENT, "unmapnotify: window: %lu\n", e->xunmap.window);
+ DNPRINTF(SWM_D_EVENT, "unmapnotify: window: 0x%lx\n", e->xunmap.window);
/* determine if we need to help unmanage this window */
win = find_window(e->xunmap.window);
int i;
struct swm_region *r;
- DNPRINTF(SWM_D_EVENT, "visibilitynotify: window: %lu\n",
+ DNPRINTF(SWM_D_EVENT, "visibilitynotify: window: 0x%lx\n",
e->xvisibility.window);
if (e->xvisibility.state == VisibilityUnobscured)
for (i = 0; i < ScreenCount(display); i++)
if (win == NULL)
return;
- DNPRINTF(SWM_D_EVENT, "clientmessage: window: 0x%lx type: %ld \n",
+ DNPRINTF(SWM_D_EVENT, "clientmessage: window: 0x%lx, type: %ld\n",
ev->window, ev->message_type);
if (ev->message_type == ewmh[_NET_ACTIVE_WINDOW].atom) {
- DNPRINTF(SWM_D_EVENT, "clientmessage: _NET_ACTIVE_WINDOW \n");
+ DNPRINTF(SWM_D_EVENT, "clientmessage: _NET_ACTIVE_WINDOW\n");
focus_win(win);
}
if (ev->message_type == ewmh[_NET_CLOSE_WINDOW].atom) {
- DNPRINTF(SWM_D_EVENT, "clientmessage: _NET_CLOSE_WINDOW \n");
+ DNPRINTF(SWM_D_EVENT, "clientmessage: _NET_CLOSE_WINDOW\n");
if (win->can_delete)
client_msg(win, adelete);
else
}
if (ev->message_type == ewmh[_NET_MOVERESIZE_WINDOW].atom) {
DNPRINTF(SWM_D_EVENT,
- "clientmessage: _NET_MOVERESIZE_WINDOW \n");
+ "clientmessage: _NET_MOVERESIZE_WINDOW\n");
if (win->floating) {
if (ev->data.l[0] & (1<<8)) /* x */
- win->g.x = ev->data.l[1];
+ X(win) = ev->data.l[1];
if (ev->data.l[0] & (1<<9)) /* y */
- win->g.y = ev->data.l[2];
+ Y(win) = ev->data.l[2];
if (ev->data.l[0] & (1<<10)) /* width */
- win->g.w = ev->data.l[3];
+ WIDTH(win) = ev->data.l[3];
if (ev->data.l[0] & (1<<11)) /* height */
- win->g.h = ev->data.l[4];
+ HEIGHT(win) = ev->data.l[4];
+
+ update_window(win);
}
else {
/* TODO: Change stack sizes */
+ /* notify no change was made. */
+ config_win(win, NULL);
}
- config_win(win, NULL);
}
if (ev->message_type == ewmh[_NET_WM_STATE].atom) {
- DNPRINTF(SWM_D_EVENT, "clientmessage: _NET_WM_STATE \n");
+ DNPRINTF(SWM_D_EVENT, "clientmessage: _NET_WM_STATE\n");
ewmh_update_win_state(win, ev->data.l[1], ev->data.l[0]);
if (ev->data.l[2])
ewmh_update_win_state(win, ev->data.l[2],
ws = r->ws;
} else
if ((r = calloc(1, sizeof(struct swm_region))) == NULL)
- err(1, "calloc: failed to allocate memory for screen");
+ err(1, "new_region: calloc: failed to allocate memory "
+ "for screen");
/* if we don't have a workspace already, find one */
if (ws == NULL) {
}
if (ws == NULL)
- errx(1, "no free workspaces");
+ errx(1, "new_region: no free workspaces");
X(r) = x;
Y(r) = y;
if (i >= ScreenCount(display))
- errx(1, "invalid screen");
+ errx(1, "scan_xrandr: invalid screen");
/* remove any old regions */
while ((r = TAILQ_FIRST(&screens[i].rl)) != NULL) {
struct swm_region *r;
int i;
- DNPRINTF(SWM_D_EVENT, "screenchange: %lu\n", xe->root);
+ DNPRINTF(SWM_D_EVENT, "screenchange: root: 0x%lx\n", xe->root);
if (!XRRUpdateConfiguration(e))
return;
if ((screens = calloc(ScreenCount(display),
sizeof(struct swm_screen))) == NULL)
- err(1, "calloc: screens");
+ err(1, "setup_screens: calloc: failed to allocate memory for "
+ "screens");
/* initial Xrandr setup */
xrandr_support = XRRQueryExtension(display,
/* map physical screens */
for (i = 0; i < ScreenCount(display); i++) {
- DNPRINTF(SWM_D_WS, "setup_screens: init screen %d\n", i);
+ DNPRINTF(SWM_D_WS, "setup_screens: init screen: %d\n", i);
screens[i].idx = i;
TAILQ_INIT(&screens[i].rl);
TAILQ_INIT(&screens[i].orl);
/* look for local and global conf file */
pwd = getpwuid(getuid());
if (pwd == NULL)
- errx(1, "invalid user %d", getuid());
+ errx(1, "invalid user: %d", getuid());
setup_screens();
setup_globals();
if (running == 0)
goto done;
if (e.type < LASTEvent) {
- dumpevent(&e);
+ DNPRINTF(SWM_D_EVENTQ ,"XEvent: handled: %s, "
+ "window: 0x%lx, type: %s (%d), %d remaining"
+ "\n", YESNO(handler[e.type]),
+ e.xany.window, geteventname(&e),
+ e.type, QLength(display));
+
if (handler[e.type])
handler[e.type](&e);
- else
- DNPRINTF(SWM_D_EVENT,
- "win: %lu unknown event: %d\n",
- e.xany.window, e.type);
} else {
+ DNPRINTF(SWM_D_EVENTQ, "XRandr Event: window: "
+ "0x%lx, type: %s (%d)\n", e.xany.window,
+ xrandr_geteventname(&e), e.type);
+
switch (e.type - xrandr_eventbase) {
case RRScreenChangeNotify:
screenchange(&e);
break;
default:
- DNPRINTF(SWM_D_EVENT,
- "win: %lu unknown xrandr event: "
- "%d\n", e.xany.window, e.type);
break;
}
}
/* move pointer to first screen if multi screen */
if (ScreenCount(display) > 1 || outputs > 1)
XWarpPointer(display, None, rr->s[0].root,
- 0, 0, 0, 0, rr->g.x,
- rr->g.y + (bar_enabled ? bar_height : 0));
+ 0, 0, 0, 0, X(rr),
+ Y(rr) + (bar_enabled ? bar_height : 0));
a.id = SWM_ARG_ID_FOCUSCUR;
focus(rr, &a);