Bugfix: correctly translate coordinates for floating windows when outputs change

This commit is contained in:
Michael Stapelberg 2010-03-24 16:09:43 +01:00
parent 0f7ac09c7b
commit 7eea1067f8
2 changed files with 31 additions and 3 deletions

View File

@ -225,6 +225,12 @@ void reposition_client(xcb_connection_t *conn, Client *client) {
return; return;
} }
if (output->current_workspace == NULL) {
DLOG("Boundary checking deferred, no current workspace on output\n");
client->force_reconfigure = true;
return;
}
DLOG("Client is on workspace %p with output %p\n", client->workspace, client->workspace->output); DLOG("Client is on workspace %p with output %p\n", client->workspace, client->workspace->output);
DLOG("but output at %d, %d is %p\n", client->rect.x, client->rect.y, output); DLOG("but output at %d, %d is %p\n", client->rect.x, client->rect.y, output);
floating_assign_to_workspace(client, output->current_workspace); floating_assign_to_workspace(client, output->current_workspace);
@ -737,6 +743,16 @@ void render_workspace(xcb_connection_t *conn, Output *output, Workspace *r_ws) {
yoffset[cols] += single_height; yoffset[cols] += single_height;
} }
/* Reposition all floating clients with force_reconfigure == true */
TAILQ_FOREACH(client, &(r_ws->floating_clients), floating_clients) {
if (!client->force_reconfigure)
continue;
client->force_reconfigure = false;
reposition_client(conn, client);
resize_client(conn, client);
}
ignore_enter_notify_forall(conn, r_ws, false); ignore_enter_notify_forall(conn, r_ws, false);
render_bars(conn, r_ws, width, &height); render_bars(conn, r_ws, width, &height);

View File

@ -35,6 +35,7 @@
#include "log.h" #include "log.h"
#include "ewmh.h" #include "ewmh.h"
#include "ipc.h" #include "ipc.h"
#include "client.h"
/* While a clean namespace is usually a pretty good thing, we really need /* While a clean namespace is usually a pretty good thing, we really need
* to use shorter names than the whole xcb_randr_* default names. */ * to use shorter names than the whole xcb_randr_* default names. */
@ -247,12 +248,23 @@ static void output_change_mode(xcb_connection_t *conn, Output *output) {
if (ws->output != output) if (ws->output != output)
continue; continue;
SLIST_FOREACH(client, &(ws->focus_stack), focus_clients) {
client->force_reconfigure = true;
if (!client_is_floating(client))
continue;
/* For floating clients we need to translate the
* coordinates (old workspace to new workspace) */
DLOG("old: (%x, %x)\n", client->rect.x, client->rect.y);
client->rect.x -= ws->rect.x;
client->rect.y -= ws->rect.y;
client->rect.x += ws->output->rect.x;
client->rect.y += ws->output->rect.y;
DLOG("new: (%x, %x)\n", client->rect.x, client->rect.y);
}
/* Update dimensions from output */ /* Update dimensions from output */
memcpy(&(ws->rect), &(ws->output->rect), sizeof(Rect)); memcpy(&(ws->rect), &(ws->output->rect), sizeof(Rect));
SLIST_FOREACH(client, &(ws->focus_stack), focus_clients)
client->force_reconfigure = true;
/* Update the dimensions of a fullscreen client, if any */ /* Update the dimensions of a fullscreen client, if any */
if (ws->fullscreen_client != NULL) { if (ws->fullscreen_client != NULL) {
DLOG("Updating fullscreen client size\n"); DLOG("Updating fullscreen client size\n");