mirror of
https://github.com/swaywm/sway.git
synced 2026-04-20 06:47:03 -04:00
Store geometry in the view and handle any floating view resizing
This commit is contained in:
parent
4e755c4b12
commit
b0a5f3a25f
11 changed files with 144 additions and 112 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#include <time.h>
|
||||
#include <wlr/types/wlr_buffer.h>
|
||||
#include "sway/debug.h"
|
||||
#include "sway/desktop.h"
|
||||
#include "sway/desktop/idle_inhibit_v1.h"
|
||||
#include "sway/desktop/transaction.h"
|
||||
#include "sway/output.h"
|
||||
|
|
@ -169,51 +170,17 @@ static void transaction_apply(struct sway_transaction *transaction) {
|
|||
transaction->instructions->items[i];
|
||||
struct sway_container *container = instruction->container;
|
||||
|
||||
// Damage the old and new locations
|
||||
struct wlr_box old_con_box = {
|
||||
.x = container->current.swayc_x,
|
||||
.y = container->current.swayc_y,
|
||||
.width = container->current.swayc_width,
|
||||
.height = container->current.swayc_height,
|
||||
};
|
||||
struct wlr_box new_con_box = {
|
||||
.x = instruction->state.swayc_x,
|
||||
.y = instruction->state.swayc_y,
|
||||
.width = instruction->state.swayc_width,
|
||||
.height = instruction->state.swayc_height,
|
||||
};
|
||||
// Handle geometry, which may overflow the bounds of the container
|
||||
struct wlr_box old_surface_box = {0,0,0,0};
|
||||
struct wlr_box new_surface_box = {0,0,0,0};
|
||||
if (container->type == C_VIEW) {
|
||||
// Damage the old location
|
||||
desktop_damage_whole_container(container);
|
||||
if (container->type == C_VIEW && container->sway_view->saved_buffer) {
|
||||
struct sway_view *view = container->sway_view;
|
||||
if (container->sway_view->saved_buffer) {
|
||||
old_surface_box.x =
|
||||
container->current.view_x - view->saved_geometry.x;
|
||||
old_surface_box.y =
|
||||
container->current.view_y - view->saved_geometry.y;
|
||||
old_surface_box.width = view->saved_buffer_width;
|
||||
old_surface_box.height = view->saved_buffer_height;
|
||||
}
|
||||
struct wlr_surface *surface = container->sway_view->surface;
|
||||
if (surface) {
|
||||
struct wlr_box geometry;
|
||||
view_get_geometry(view, &geometry);
|
||||
new_surface_box.x = instruction->state.view_x - geometry.x;
|
||||
new_surface_box.y = instruction->state.view_y - geometry.y;
|
||||
new_surface_box.width = surface->current.width;
|
||||
new_surface_box.height = surface->current.height;
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < root_container.current.children->length; ++j) {
|
||||
struct sway_container *output =
|
||||
root_container.current.children->items[j];
|
||||
if (output->sway_output) {
|
||||
output_damage_box(output->sway_output, &old_con_box);
|
||||
output_damage_box(output->sway_output, &new_con_box);
|
||||
output_damage_box(output->sway_output, &old_surface_box);
|
||||
output_damage_box(output->sway_output, &new_surface_box);
|
||||
}
|
||||
struct wlr_box box = {
|
||||
.x = container->current.view_x - view->saved_geometry.x,
|
||||
.y = container->current.view_y - view->saved_geometry.y,
|
||||
.width = view->saved_buffer_width,
|
||||
.height = view->saved_buffer_height,
|
||||
};
|
||||
desktop_damage_box(&box);
|
||||
}
|
||||
|
||||
// There are separate children lists for each instruction state, the
|
||||
|
|
@ -230,6 +197,20 @@ static void transaction_apply(struct sway_transaction *transaction) {
|
|||
view_remove_saved_buffer(container->sway_view);
|
||||
}
|
||||
|
||||
// Damage the new location
|
||||
desktop_damage_whole_container(container);
|
||||
if (container->type == C_VIEW && container->sway_view->surface) {
|
||||
struct sway_view *view = container->sway_view;
|
||||
struct wlr_surface *surface = view->surface;
|
||||
struct wlr_box box = {
|
||||
.x = container->current.view_x - view->geometry.x,
|
||||
.y = container->current.view_y - view->geometry.y,
|
||||
.width = surface->current.width,
|
||||
.height = surface->current.height,
|
||||
};
|
||||
desktop_damage_box(&box);
|
||||
}
|
||||
|
||||
container->instruction = NULL;
|
||||
}
|
||||
}
|
||||
|
|
@ -323,7 +304,8 @@ static void transaction_commit(struct sway_transaction *transaction) {
|
|||
}
|
||||
if (con->type == C_VIEW) {
|
||||
view_save_buffer(con->sway_view);
|
||||
view_get_geometry(con->sway_view, &con->sway_view->saved_geometry);
|
||||
memcpy(&con->sway_view->saved_geometry, &con->sway_view->geometry,
|
||||
sizeof(struct wlr_box));
|
||||
}
|
||||
con->instruction = instruction;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue