Always center unless ANYWHERE quirk is set or window was manually
moved or resized.
Add new load_float_geom() function.
Fix float_toggle to ignore fullscreen windows.
Fix ConfigureRequest events sometimes causing a focus change.
Fix event_drain sometimes not working as expected.
Remove some #if 0 code.
#ifdef SWM_DEBUG
void leavenotify(xcb_leave_notify_event_t *);
#endif
#ifdef SWM_DEBUG
void leavenotify(xcb_leave_notify_event_t *);
#endif
+void load_float_geom(struct ws_win *, struct swm_region *);
void map_window_raised(xcb_window_t);
void mapnotify(xcb_map_notify_event_t *);
void mappingnotify(xcb_mapping_notify_event_t *);
void map_window_raised(xcb_window_t);
void mapnotify(xcb_map_notify_event_t *);
void mappingnotify(xcb_mapping_notify_event_t *);
win->g = win->ws->r->g;
win->bordered = 0;
} else {
win->g = win->ws->r->g;
win->bordered = 0;
} else {
- if (win->g_floatvalid) {
- /* refloat at last floating relative position */
- win->g = win->g_float;
- X(win) += X(win->ws->r);
- Y(win) += Y(win->ws->r);
- }
+ load_float_geom(win, win->ws->r);
}
if ((cfw = find_window(cur_focus)) != NULL)
unfocus_win(cfw);
}
if ((cfw = find_window(cur_focus)) != NULL)
unfocus_win(cfw);
- else {
-#if 0
- /* use larger hammer since the window was killed somehow */
- TAILQ_FOREACH(cfw, &win->ws->winlist, entry)
- if (cfw->ws && cfw->ws->r && cfw->ws->r->s)
- xcb_change_window_attributes(conn, cfw->id,
- XCB_CW_BORDER_PIXEL,
- &cfw->ws->r->s->c[SWM_S_COLOR_UNFOCUS].pixel);
-#endif
- }
{
xcb_generic_event_t *evt;
{
xcb_generic_event_t *evt;
+ /* ensure all pending requests have been processed before filtering. */
+ xcb_aux_sync(conn);
while ((evt = xcb_poll_for_event(conn))) {
if (XCB_EVENT_RESPONSE_TYPE(evt) != rt)
event_handle(evt);
while ((evt = xcb_poll_for_event(conn))) {
if (XCB_EVENT_RESPONSE_TYPE(evt) != rt)
event_handle(evt);
void
store_float_geom(struct ws_win *win, struct swm_region *r)
{
void
store_float_geom(struct ws_win *win, struct swm_region *r)
{
+ if (win == NULL || r == NULL)
+ return;
+
/* retain window geom and region geom */
win->g_float = win->g;
win->g_float.x -= X(r);
/* retain window geom and region geom */
win->g_float = win->g;
win->g_float.x -= X(r);
win->g_float.w, win->g_float.h);
}
win->g_float.w, win->g_float.h);
}
+void
+load_float_geom(struct ws_win *win, struct swm_region *r)
+{
+ if (win == NULL || r == NULL)
+ return;
+
+ if (win->g_floatvalid) {
+ win->g = win->g_float;
+ X(win) += X(r);
+ Y(win) += Y(r);
+ DNPRINTF(SWM_D_MISC, "load_float_geom: window: 0x%x, g: (%d,%d)"
+ "%d x %d\n", win->id, X(win), Y(win), WIDTH(win),
+ HEIGHT(win));
+ } else {
+ DNPRINTF(SWM_D_MISC, "load_float_geom: window: 0x%x, g_float "
+ "is not set.\n", win->id);
+ }
+}
+
void
stack_floater(struct ws_win *win, struct swm_region *r)
{
void
stack_floater(struct ws_win *win, struct swm_region *r)
{
* to allow windows to change their size (e.g. mplayer fs) only retrieve
* geom on ws switches or return from max mode
*/
* to allow windows to change their size (e.g. mplayer fs) only retrieve
* geom on ws switches or return from max mode
*/
- if (win->g_floatvalid && (win->floatmaxed || (r != r->ws->old_r &&
- !(win->ewmh_flags & EWMH_F_FULLSCREEN)))) {
- /* refloat at last floating relative position */
- win->g = win->g_float;
- X(win) += X(r);
- Y(win) += Y(r);
+ if (win->floatmaxed || (r != r->ws->old_r &&
+ !(win->ewmh_flags & EWMH_F_FULLSCREEN))) {
+ /* update geometry for the new region */
+ load_float_geom(win, r);
if (!win->g_floatvalid)
store_float_geom(win, win->ws->r);
if (!win->g_floatvalid)
store_float_geom(win, win->ws->r);
- win->g = win->ws->r->g;
HEIGHT(win) = (double)HEIGHT(r) * dialog_ratio;
}
HEIGHT(win) = (double)HEIGHT(r) * dialog_ratio;
}
+ if (!win->manual && !(win->ewmh_flags & EWMH_F_FULLSCREEN) &&
+ !(win->quirks & SWM_Q_ANYWHERE)) {
- * floaters and transients are auto-centred unless moved
- * or resized
+ * floaters and transients are auto-centred unless moved,
+ * resized or ANYWHERE quirk is set.
*/
X(win) = X(r) + (WIDTH(r) - WIDTH(win)) / 2 - BORDER(win);
Y(win) = Y(r) + (HEIGHT(r) - HEIGHT(win)) / 2 - BORDER(win);
*/
X(win) = X(r) + (WIDTH(r) - WIDTH(win)) / 2 - BORDER(win);
Y(win) = Y(r) + (HEIGHT(r) - HEIGHT(win)) / 2 - BORDER(win);
+
+ store_float_geom(win, r);
}
/* keep window within region bounds */
}
/* keep window within region bounds */
}
win->floating = 0;
} else {
}
win->floating = 0;
} else {
- if (win->g_floatvalid) {
- /* refloat at last floating relative position */
- X(win) = win->g_float.x + X(r);
- Y(win) = win->g_float.y + Y(r);
- WIDTH(win) = win->g_float.w;
- HEIGHT(win) = win->g_float.h;
- }
+ load_float_geom(win, r);
+ if (win->ewmh_flags & EWMH_F_FULLSCREEN)
+ return;
+
ewmh_update_win_state(win, ewmh[_NET_WM_STATE_ABOVE].atom,
_NET_WM_STATE_TOGGLE);
ewmh_update_win_state(win, ewmh[_NET_WM_STATE_ABOVE].atom,
_NET_WM_STATE_TOGGLE);
X(win) = win->wa->x + win->wa->border_width;
Y(win) = win->wa->y + win->wa->border_width;
win->bordered = 0;
X(win) = win->wa->x + win->wa->border_width;
Y(win) = win->wa->y + win->wa->border_width;
win->bordered = 0;
win->floatmaxed = 0;
win->ewmh_flags = 0;
win->s = r->s; /* this never changes */
win->floatmaxed = 0;
win->ewmh_flags = 0;
win->s = r->s; /* this never changes */
+ store_float_geom(win, r);
+
/* Get WM_SIZE_HINTS. */
xcb_icccm_get_wm_normal_hints_reply(conn,
xcb_icccm_get_wm_normal_hints(conn, win->id),
/* Get WM_SIZE_HINTS. */
xcb_icccm_get_wm_normal_hints_reply(conn,
xcb_icccm_get_wm_normal_hints(conn, win->id),
/* java is retarded so treat it special */
if (strstr(win->ch.instance_name, "sun-awt")) {
/* java is retarded so treat it special */
if (strstr(win->ch.instance_name, "sun-awt")) {
+ DNPRINTF(SWM_D_CLASS, "manage_window: java window "
+ "detected.\n");
win->java = 1;
border_me = 1;
}
win->java = 1;
border_me = 1;
}
fake_keypress(win, XK_KP_Add, XCB_MOD_MASK_SHIFT);
}
fake_keypress(win, XK_KP_Add, XCB_MOD_MASK_SHIFT);
}
- /* Make sure window is positioned inside its region, if its active. */
- if (win->ws->r)
- constrain_window(win, win->ws->r, 0);
-
if (border_me) {
win->bordered = 1;
X(win) -= border_width;
Y(win) -= border_width;
}
if (border_me) {
win->bordered = 1;
X(win) -= border_width;
Y(win) -= border_width;
}
+ /* Make sure window is positioned inside its region, if its active. */
+ if (win->ws->r)
+ constrain_window(win, win->ws->r, 0);
+
if (win->ws->r || border_me)
update_window(win);
if (win->ws->r || border_me)
update_window(win);
event_mask |= XCB_EVENT_MASK_LEAVE_WINDOW;
#endif
event_mask |= XCB_EVENT_MASK_LEAVE_WINDOW;
#endif
- xcb_change_window_attributes(conn, id, XCB_CW_EVENT_MASK, &event_mask);
+ xcb_change_window_attributes(conn, win->id, XCB_CW_EVENT_MASK,
+ &event_mask);
out:
/* Figure out where to stack the window in the workspace. */
out:
/* Figure out where to stack the window in the workspace. */
configurerequest(xcb_configure_request_event_t *e)
{
struct ws_win *win;
configurerequest(xcb_configure_request_event_t *e)
{
struct ws_win *win;
+ struct swm_region *r = NULL;
int new = 0, i = 0;
uint16_t mask = 0;
uint32_t wc[7] = {0};
int new = 0, i = 0;
uint16_t mask = 0;
uint32_t wc[7] = {0};
if ((win = find_window(e->window)) == NULL)
if ((win = find_unmanaged_window(e->window)) == NULL)
new = 1;
if ((win = find_window(e->window)) == NULL)
if ((win = find_unmanaged_window(e->window)) == NULL)
new = 1;
#ifdef SWM_DEBUG
if (swm_debug & SWM_D_EVENT) {
print_win_geom(e->window);
#ifdef SWM_DEBUG
if (swm_debug & SWM_D_EVENT) {
print_win_geom(e->window);
xcb_configure_window(conn, e->window, mask, wc);
} else if ((!win->manual || win->quirks & SWM_Q_ANYWHERE) &&
!(win->ewmh_flags & EWMH_F_FULLSCREEN)) {
xcb_configure_window(conn, e->window, mask, wc);
} else if ((!win->manual || win->quirks & SWM_Q_ANYWHERE) &&
!(win->ewmh_flags & EWMH_F_FULLSCREEN)) {
- if (e->value_mask & XCB_CONFIG_WINDOW_X) {
- win->g_float.x = e->x;
- if (win->ws->r)
- win->g_float.x -= X(win->ws->r);
- else if (win->ws->old_r)
- win->g_float.x -= X(win->ws->old_r);
- }
+ if (win->ws->r)
+ r = win->ws->r;
+ else if (win->ws->old_r)
+ r = win->ws->old_r;
+
+ /* windows are centered unless ANYWHERE quirk is set. */
+ if (win->quirks & SWM_Q_ANYWHERE) {
+ if (e->value_mask & XCB_CONFIG_WINDOW_X) {
+ win->g_float.x = e->x;
+ if (r)
+ win->g_float.x -= X(r);
+ }
- if (e->value_mask & XCB_CONFIG_WINDOW_Y) {
- win->g_float.y = e->y;
- if (win->ws->r)
- win->g_float.y -= Y(win->ws->r);
- else if (win->ws->old_r)
- win->g_float.y -= Y(win->ws->old_r);
+ if (e->value_mask & XCB_CONFIG_WINDOW_Y) {
+ win->g_float.y = e->y;
+ if (r)
+ win->g_float.y -= Y(r);
+ }
}
if (e->value_mask & XCB_CONFIG_WINDOW_WIDTH)
}
if (e->value_mask & XCB_CONFIG_WINDOW_WIDTH)
- if (win->floating && win->ws->r) {
- /* window is visible and floating; update position. */
- win->g = win->g_float;
- X(win) += X(win->ws->r);
- Y(win) += Y(win->ws->r);
+ if (win->floating && r) {
+ WIDTH(win) = win->g_float.w;
+ HEIGHT(win) = win->g_float.h;
+ stack_floater(win, win->ws->r);
+
+ if (focus_mode == SWM_FOCUS_DEFAULT) {
+ event_drain(XCB_ENTER_NOTIFY);
+ } else {
+ xcb_flush(conn);
+ }
} else {
config_win(win, e);
} else {
config_win(win, e);
}
} else {
config_win(win, e);
}
} else {
config_win(win, e);
e->mode, get_notify_detail_label(e->detail), e->detail, e->root,
e->child, YESNO(e->same_screen_focus), e->state);
e->mode, get_notify_detail_label(e->detail), e->detail, e->root,
e->child, YESNO(e->same_screen_focus), e->state);
-#if 0
- if (e->mode != XCB_NOTIFY_MODE_NORMAL) {
- DNPRINTF(SWM_D_EVENT, "skip enternotify: generated by "
- "cursor grab.\n");
- return;
- }
-#endif
-
switch (focus_mode) {
case SWM_FOCUS_DEFAULT:
break;
switch (focus_mode) {
case SWM_FOCUS_DEFAULT:
break;