Bugfix: Check if a floating window’s coordinates are within a different workspace when managing (Thanks Merovius)

Fixes: #297
next
Michael Stapelberg 2011-04-18 19:28:03 +02:00
parent 60532a90e7
commit f613df48d2
2 changed files with 40 additions and 20 deletions

View File

@ -59,6 +59,13 @@ void toggle_floating_mode(Con *con, bool automatic);
*/
void floating_raise_con(Con *con);
/**
* Checks if cons coordinates are within its workspace and re-assigns it to
* the actual workspace if not.
*
*/
bool floating_maybe_reassign_ws(Con *con);
#if 0
/**
* Removes the floating client from its workspace and attaches it to the new

View File

@ -156,6 +156,8 @@ void floating_enable(Con *con, bool automatic) {
// TODO: dont influence focus handling when Con was not focused before.
if (set_focus)
con_focus(con);
floating_maybe_reassign_ws(nc);
}
void floating_disable(Con *con, bool automatic) {
@ -225,6 +227,36 @@ void floating_raise_con(Con *con) {
TAILQ_INSERT_TAIL(&(con->parent->floating_head), con, floating_windows);
}
/*
* Checks if cons coordinates are within its workspace and re-assigns it to
* the actual workspace if not.
*
*/
bool floating_maybe_reassign_ws(Con *con) {
Output *output = get_output_containing(
con->rect.x + (con->rect.width / 2),
con->rect.y + (con->rect.height / 2));
if (!output) {
ELOG("No output found at destination coordinates?\n");
return false;
}
if (con_get_output(con) == output->con) {
DLOG("still the same ws\n");
return false;
}
DLOG("Need to re-assign!\n");
Con *content = output_get_content(output->con);
Con *ws = TAILQ_FIRST(&(content->nodes_head));
DLOG("Moving con %p / %s to workspace %p / %s\n", con, con->name, ws, ws->name);
con_move_to_workspace(con, ws);
con_focus(con_descend_focused(con));
return true;
}
DRAGGING_CB(drag_window_callback) {
struct xcb_button_press_event_t *event = extra;
@ -237,27 +269,8 @@ DRAGGING_CB(drag_window_callback) {
xcb_flush(conn);
/* Check if we cross workspace boundaries while moving */
Output *output = get_output_containing(
con->rect.x + (con->rect.width / 2),
con->rect.y + (con->rect.height / 2));
if (!output) {
ELOG("No output found at destination coordinates?\n");
if (!floating_maybe_reassign_ws(con))
return;
}
if (con_get_output(con) == output->con) {
DLOG("still the same ws\n");
return;
}
DLOG("Need to re-assign!\n");
Con *content = output_get_content(output->con);
Con *ws = TAILQ_FIRST(&(content->nodes_head));
DLOG("Moving con %p / %s to workspace %p / %s\n", con, con->name, ws, ws->name);
con_move_to_workspace(con, ws);
con_focus(con_descend_focused(con));
tree_render();
}