fix: only update view position when needed

This commit is contained in:
DanyLE 2024-04-13 12:27:33 +02:00
parent c50bc3864f
commit 7df1dec7f3

19
view.c
View File

@ -418,7 +418,10 @@ void diyac_view_update_app_id(struct diyac_view *view)
void diyac_view_sync_geo(struct diyac_view *view)
{
struct wlr_box size;
int current_x, current_y, next_x, next_y;
wlr_scene_node_coords(&view->scene_tree->node, &current_x, &current_y);
wlr_xdg_surface_get_geometry(view->xdg_surface, &size);
if (!view->state.fullscreen && !view->state.maximized)
{
@ -445,16 +448,20 @@ void diyac_view_sync_geo(struct diyac_view *view)
view->original.width = size.width;
view->original.height = size.height;
wlr_scene_node_set_position(&view->scene_tree->node, view->original.x, view->original.y);
next_x = view->original.x;
next_y = view->original.y;
view->pending_size = view->original;
}
else
{
if(wlr_box_equal(&size, &view->pending_size))
next_x = view->pending_size.x;
next_y = view->pending_size.y;
}
if(current_x != next_x || current_y != next_y)
{
return;
}
//wlr_log(WLR_ERROR, "update fullscreen position");
wlr_scene_node_set_position(&view->scene_tree->node, view->pending_size.x, view->pending_size.y);
//wlr_log(WLR_INFO, "update fullscreen position [%d,%d] VS pending [%d,%d]",
// current_x, current_y, next_x, next_y);
wlr_scene_node_set_position(&view->scene_tree->node, next_x, next_y);
}
}