aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/transaction.c
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-18 15:10:06 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-08-18 15:10:06 +1000
commitb0a5f3a25f52bc1d48d771cb02820042006d8d9e (patch)
treee7a2e4c60e562589e3b9a54c6ce559a41dcf7534 /sway/desktop/transaction.c
parentSet current size when a floating xwayland view resizes (diff)
downloadsway-b0a5f3a25f52bc1d48d771cb02820042006d8d9e.tar.gz
sway-b0a5f3a25f52bc1d48d771cb02820042006d8d9e.tar.zst
sway-b0a5f3a25f52bc1d48d771cb02820042006d8d9e.zip
Store geometry in the view and handle any floating view resizing
Diffstat (limited to 'sway/desktop/transaction.c')
-rw-r--r--sway/desktop/transaction.c72
1 files changed, 27 insertions, 45 deletions
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index 7383c455..c300558a 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -6,6 +6,7 @@
6#include <time.h> 6#include <time.h>
7#include <wlr/types/wlr_buffer.h> 7#include <wlr/types/wlr_buffer.h>
8#include "sway/debug.h" 8#include "sway/debug.h"
9#include "sway/desktop.h"
9#include "sway/desktop/idle_inhibit_v1.h" 10#include "sway/desktop/idle_inhibit_v1.h"
10#include "sway/desktop/transaction.h" 11#include "sway/desktop/transaction.h"
11#include "sway/output.h" 12#include "sway/output.h"
@@ -169,51 +170,17 @@ static void transaction_apply(struct sway_transaction *transaction) {
169 transaction->instructions->items[i]; 170 transaction->instructions->items[i];
170 struct sway_container *container = instruction->container; 171 struct sway_container *container = instruction->container;
171 172
172 // Damage the old and new locations 173 // Damage the old location
173 struct wlr_box old_con_box = { 174 desktop_damage_whole_container(container);
174 .x = container->current.swayc_x, 175 if (container->type == C_VIEW && container->sway_view->saved_buffer) {
175 .y = container->current.swayc_y,
176 .width = container->current.swayc_width,
177 .height = container->current.swayc_height,
178 };
179 struct wlr_box new_con_box = {
180 .x = instruction->state.swayc_x,
181 .y = instruction->state.swayc_y,
182 .width = instruction->state.swayc_width,
183 .height = instruction->state.swayc_height,
184 };
185 // Handle geometry, which may overflow the bounds of the container
186 struct wlr_box old_surface_box = {0,0,0,0};
187 struct wlr_box new_surface_box = {0,0,0,0};
188 if (container->type == C_VIEW) {
189 struct sway_view *view = container->sway_view; 176 struct sway_view *view = container->sway_view;
190 if (container->sway_view->saved_buffer) { 177 struct wlr_box box = {
191 old_surface_box.x = 178 .x = container->current.view_x - view->saved_geometry.x,
192 container->current.view_x - view->saved_geometry.x; 179 .y = container->current.view_y - view->saved_geometry.y,
193 old_surface_box.y = 180 .width = view->saved_buffer_width,
194 container->current.view_y - view->saved_geometry.y; 181 .height = view->saved_buffer_height,
195 old_surface_box.width = view->saved_buffer_width; 182 };
196 old_surface_box.height = view->saved_buffer_height; 183 desktop_damage_box(&box);
197 }
198 struct wlr_surface *surface = container->sway_view->surface;
199 if (surface) {
200 struct wlr_box geometry;
201 view_get_geometry(view, &geometry);
202 new_surface_box.x = instruction->state.view_x - geometry.x;
203 new_surface_box.y = instruction->state.view_y - geometry.y;
204 new_surface_box.width = surface->current.width;
205 new_surface_box.height = surface->current.height;
206 }
207 }
208 for (int j = 0; j < root_container.current.children->length; ++j) {
209 struct sway_container *output =
210 root_container.current.children->items[j];
211 if (output->sway_output) {
212 output_damage_box(output->sway_output, &old_con_box);
213 output_damage_box(output->sway_output, &new_con_box);
214 output_damage_box(output->sway_output, &old_surface_box);
215 output_damage_box(output->sway_output, &new_surface_box);
216 }
217 } 184 }
218 185
219 // There are separate children lists for each instruction state, the 186 // There are separate children lists for each instruction state, the
@@ -230,6 +197,20 @@ static void transaction_apply(struct sway_transaction *transaction) {
230 view_remove_saved_buffer(container->sway_view); 197 view_remove_saved_buffer(container->sway_view);
231 } 198 }
232 199
200 // Damage the new location
201 desktop_damage_whole_container(container);
202 if (container->type == C_VIEW && container->sway_view->surface) {
203 struct sway_view *view = container->sway_view;
204 struct wlr_surface *surface = view->surface;
205 struct wlr_box box = {
206 .x = container->current.view_x - view->geometry.x,
207 .y = container->current.view_y - view->geometry.y,
208 .width = surface->current.width,
209 .height = surface->current.height,
210 };
211 desktop_damage_box(&box);
212 }
213
233 container->instruction = NULL; 214 container->instruction = NULL;
234 } 215 }
235} 216}
@@ -323,7 +304,8 @@ static void transaction_commit(struct sway_transaction *transaction) {
323 } 304 }
324 if (con->type == C_VIEW) { 305 if (con->type == C_VIEW) {
325 view_save_buffer(con->sway_view); 306 view_save_buffer(con->sway_view);
326 view_get_geometry(con->sway_view, &con->sway_view->saved_geometry); 307 memcpy(&con->sway_view->saved_geometry, &con->sway_view->geometry,
308 sizeof(struct wlr_box));
327 } 309 }
328 con->instruction = instruction; 310 con->instruction = instruction;
329 } 311 }