aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Alexander Orzechowski <alex@ozal.ski>2023-11-22 15:11:12 -0500
committerLibravatar Kirill Primak <vyivel@eclair.cafe>2024-01-18 18:36:54 +0300
commit9da295c11f90dcfbf254ccf23b9124c87ccd8ddf (patch)
tree328cf15feeccd8bdc90f1205542857ab34afeaa2 /sway/tree/view.c
parentscene_graph: Port opacity and filter modes (diff)
downloadsway-9da295c11f90dcfbf254ccf23b9124c87ccd8ddf.tar.gz
sway-9da295c11f90dcfbf254ccf23b9124c87ccd8ddf.tar.zst
sway-9da295c11f90dcfbf254ccf23b9124c87ccd8ddf.zip
scene_graph: Implement toplevel clipping
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 3bc0855b..d6984178 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -893,14 +893,29 @@ void view_update_size(struct sway_view *view) {
893 container_set_geometry_from_content(con); 893 container_set_geometry_from_content(con);
894} 894}
895 895
896void view_center_surface(struct sway_view *view) { 896void view_center_and_clip_surface(struct sway_view *view) {
897 struct sway_container *con = view->container; 897 struct sway_container *con = view->container;
898 // We always center the current coordinates rather than the next, as the
899 // geometry immediately affects the currently active rendering.
900 int x = (int) fmax(0, (con->current.content_width - view->geometry.width) / 2);
901 int y = (int) fmax(0, (con->current.content_height - view->geometry.height) / 2);
902 898
903 wlr_scene_node_set_position(&view->content_tree->node, x, y); 899 if (container_is_floating(con)) {
900 // We always center the current coordinates rather than the next, as the
901 // geometry immediately affects the currently active rendering.
902 int x = (int) fmax(0, (con->current.content_width - view->geometry.width) / 2);
903 int y = (int) fmax(0, (con->current.content_height - view->geometry.height) / 2);
904
905 wlr_scene_node_set_position(&view->content_tree->node, x, y);
906 } else {
907 wlr_scene_node_set_position(&view->content_tree->node, 0, 0);
908 }
909
910 // only make sure to clip the content if there is content to clip
911 if (!wl_list_empty(&con->view->content_tree->children)) {
912 wlr_scene_subsurface_tree_set_clip(&con->view->content_tree->node, &(struct wlr_box){
913 .x = con->view->geometry.x,
914 .y = con->view->geometry.y,
915 .width = con->current.content_width,
916 .height = con->current.content_height,
917 });
918 }
904} 919}
905 920
906struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) { 921struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) {