Always auto center on 'scratchpad show' if window hasn't been repositioned by the user

This change ensures a scratchpad window is still centered on the screen
if it has first been shown on another screen of a different
resolution. Moving or resizing the scratchpad manually disables this
behavior.
This commit is contained in:
Sebastian Ullrich
2012-09-24 21:14:40 +02:00
committed by Michael Stapelberg
parent 7f0065e1b1
commit 49979c9d15
5 changed files with 46 additions and 5 deletions

View File

@ -592,6 +592,10 @@ static void cmd_resize_floating(I3_CMD, char *way, char *direction, Con *floatin
} else if (strcmp(direction, "left") == 0) {
floating_con->rect.x -= (floating_con->rect.width - old_rect.width);
}
/* If this is a scratchpad window, don't auto center it from now on. */
if (floating_con->scratchpad_state == SCRATCHPAD_FRESH)
floating_con->scratchpad_state = SCRATCHPAD_CHANGED;
}
static bool cmd_resize_tiling_direction(I3_CMD, Con *current, char *way, char *direction, int ppt) {

View File

@ -438,6 +438,11 @@ void floating_drag_window(Con *con, const xcb_button_press_event_t *event) {
/* Drag the window */
drag_pointer(con, event, XCB_NONE, BORDER_TOP /* irrelevant */, XCURSOR_CURSOR_MOVE, drag_window_callback, event);
/* If this is a scratchpad window, don't auto center it from now on. */
if (con->scratchpad_state == SCRATCHPAD_FRESH)
con->scratchpad_state = SCRATCHPAD_CHANGED;
tree_render();
}
@ -537,6 +542,10 @@ void floating_resize_window(Con *con, const bool proportional,
struct resize_window_callback_params params = { corner, proportional, event };
drag_pointer(con, event, XCB_NONE, BORDER_TOP /* irrelevant */, cursor, resize_window_callback, &params);
/* If this is a scratchpad window, don't auto center it from now on. */
if (con->scratchpad_state == SCRATCHPAD_FRESH)
con->scratchpad_state = SCRATCHPAD_CHANGED;
}
/*
@ -660,6 +669,11 @@ void floating_reposition(Con *con, Rect newrect) {
con->rect = newrect;
floating_maybe_reassign_ws(con);
/* If this is a scratchpad window, don't auto center it from now on. */
if (con->scratchpad_state == SCRATCHPAD_FRESH)
con->scratchpad_state = SCRATCHPAD_CHANGED;
tree_render();
}

View File

@ -178,7 +178,6 @@ void scratchpad_show(Con *con) {
((output->rect.width / 2.0) - (con->rect.width / 2.0));
con->rect.y = output->rect.y +
((output->rect.height / 2.0) - (con->rect.height / 2.0));
con->scratchpad_state = SCRATCHPAD_CHANGED;
}
/* Activate active workspace if window is from another workspace to ensure