Fix geometry
This commit is contained in:
parent
b3ee9af0c8
commit
982a2d0c99
|
@ -88,6 +88,7 @@ struct sway_view {
|
|||
|
||||
struct wlr_buffer *saved_buffer;
|
||||
int saved_buffer_width, saved_buffer_height;
|
||||
struct wlr_box saved_geometry; // The "old" geometry during a transaction
|
||||
|
||||
bool destroying;
|
||||
|
||||
|
@ -242,6 +243,8 @@ const char *view_get_shell(struct sway_view *view);
|
|||
void view_get_constraints(struct sway_view *view, double *min_width,
|
||||
double *max_width, double *min_height, double *max_height);
|
||||
|
||||
void view_get_geometry(struct sway_view *view, struct wlr_box *box);
|
||||
|
||||
uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
|
||||
int height);
|
||||
|
||||
|
|
|
@ -140,12 +140,16 @@ void output_surface_for_each_surface(struct sway_output *output,
|
|||
void output_view_for_each_surface(struct sway_output *output,
|
||||
struct sway_view *view, sway_surface_iterator_func_t iterator,
|
||||
void *user_data) {
|
||||
struct wlr_box geometry;
|
||||
view_get_geometry(view, &geometry);
|
||||
struct surface_iterator_data data = {
|
||||
.user_iterator = iterator,
|
||||
.user_data = user_data,
|
||||
.output = output,
|
||||
.ox = view->swayc->current.view_x - output->swayc->current.swayc_x,
|
||||
.oy = view->swayc->current.view_y - output->swayc->current.swayc_y,
|
||||
.ox = view->swayc->current.view_x - output->swayc->current.swayc_x
|
||||
- geometry.x,
|
||||
.oy = view->swayc->current.view_y - output->swayc->current.swayc_y
|
||||
- geometry.y,
|
||||
.width = view->swayc->current.view_width,
|
||||
.height = view->swayc->current.view_height,
|
||||
.rotation = 0, // TODO
|
||||
|
|
|
@ -192,10 +192,12 @@ static void render_view_toplevels(struct sway_view *view,
|
|||
.damage = damage,
|
||||
.alpha = alpha,
|
||||
};
|
||||
struct wlr_box geometry;
|
||||
view_get_geometry(view, &geometry);
|
||||
// Render all toplevels without descending into popups
|
||||
output_surface_for_each_surface(output, view->surface,
|
||||
view->swayc->current.view_x - output->wlr_output->lx,
|
||||
view->swayc->current.view_y - output->wlr_output->ly,
|
||||
view->swayc->current.view_x - output->wlr_output->lx - geometry.x,
|
||||
view->swayc->current.view_y - output->wlr_output->ly - geometry.y,
|
||||
render_surface_iterator, &data);
|
||||
}
|
||||
|
||||
|
@ -232,6 +234,10 @@ static void render_saved_view(struct sway_view *view,
|
|||
.width = view->saved_buffer_width,
|
||||
.height = view->saved_buffer_height,
|
||||
};
|
||||
struct wlr_box geometry;
|
||||
view_get_geometry(view, &geometry);
|
||||
box.x -= geometry.x;
|
||||
box.y -= geometry.y;
|
||||
|
||||
struct wlr_box output_box = {
|
||||
.width = output->swayc->current.swayc_width,
|
||||
|
|
|
@ -170,23 +170,49 @@ static void transaction_apply(struct sway_transaction *transaction) {
|
|||
struct sway_container *container = instruction->container;
|
||||
|
||||
// Damage the old and new locations
|
||||
struct wlr_box old_box = {
|
||||
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_box = {
|
||||
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) {
|
||||
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];
|
||||
struct sway_container *output =
|
||||
root_container.current.children->items[j];
|
||||
if (output->sway_output) {
|
||||
output_damage_box(output->sway_output, &old_box);
|
||||
output_damage_box(output->sway_output, &new_box);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -297,6 +323,7 @@ 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);
|
||||
}
|
||||
con->instruction = instruction;
|
||||
}
|
||||
|
@ -355,7 +382,9 @@ static void set_instruction_ready(
|
|||
}
|
||||
|
||||
instruction->container->instruction = NULL;
|
||||
transaction_progress_queue();
|
||||
if (!txn_debug) {
|
||||
transaction_progress_queue();
|
||||
}
|
||||
}
|
||||
|
||||
void transaction_notify_view_ready_by_serial(struct sway_view *view,
|
||||
|
|
|
@ -525,6 +525,11 @@ static void surface_at_view(struct sway_container *swayc, double lx, double ly,
|
|||
double view_sx = lx - sview->x;
|
||||
double view_sy = ly - sview->y;
|
||||
|
||||
struct wlr_box geometry;
|
||||
view_get_geometry(sview, &geometry);
|
||||
view_sx += geometry.x;
|
||||
view_sy += geometry.y;
|
||||
|
||||
double _sx, _sy;
|
||||
struct wlr_surface *_surface = NULL;
|
||||
switch (sview->type) {
|
||||
|
|
Loading…
Reference in a new issue