diff options
-rw-r--r-- | include/sway/tree/view.h | 2 | ||||
-rw-r--r-- | sway/desktop/transaction.c | 2 | ||||
-rw-r--r-- | sway/desktop/xdg_shell.c | 4 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 4 | ||||
-rw-r--r-- | sway/tree/view.c | 27 |
5 files changed, 27 insertions, 12 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 80097dd3..3e5a9bfe 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -274,7 +274,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface, | |||
274 | void view_unmap(struct sway_view *view); | 274 | void view_unmap(struct sway_view *view); |
275 | 275 | ||
276 | void view_update_size(struct sway_view *view); | 276 | void view_update_size(struct sway_view *view); |
277 | void view_center_surface(struct sway_view *view); | 277 | void view_center_and_clip_surface(struct sway_view *view); |
278 | 278 | ||
279 | struct sway_view *view_from_wlr_xdg_surface( | 279 | struct sway_view *view_from_wlr_xdg_surface( |
280 | struct wlr_xdg_surface *xdg_surface); | 280 | struct wlr_xdg_surface *xdg_surface); |
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c index 0755c8a0..980e839e 100644 --- a/sway/desktop/transaction.c +++ b/sway/desktop/transaction.c | |||
@@ -248,7 +248,7 @@ static void apply_container_state(struct sway_container *container, | |||
248 | // the container. This is important for fullscreen views which | 248 | // the container. This is important for fullscreen views which |
249 | // refuse to resize to the size of the output. | 249 | // refuse to resize to the size of the output. |
250 | if (view->surface) { | 250 | if (view->surface) { |
251 | view_center_surface(view); | 251 | view_center_and_clip_surface(view); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | } | 254 | } |
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c index 48b7b4c7..7cdd97c8 100644 --- a/sway/desktop/xdg_shell.c +++ b/sway/desktop/xdg_shell.c | |||
@@ -306,9 +306,9 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
306 | view->geometry.height); | 306 | view->geometry.height); |
307 | } | 307 | } |
308 | transaction_commit_dirty_client(); | 308 | transaction_commit_dirty_client(); |
309 | } else { | ||
310 | view_center_surface(view); | ||
311 | } | 309 | } |
310 | |||
311 | view_center_and_clip_surface(view); | ||
312 | } | 312 | } |
313 | 313 | ||
314 | if (view->container->node.instruction) { | 314 | if (view->container->node.instruction) { |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index e0c80c07..9f3f4d5f 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -436,9 +436,9 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
436 | if (container_is_floating(view->container)) { | 436 | if (container_is_floating(view->container)) { |
437 | view_update_size(view); | 437 | view_update_size(view); |
438 | transaction_commit_dirty_client(); | 438 | transaction_commit_dirty_client(); |
439 | } else { | ||
440 | view_center_surface(view); | ||
441 | } | 439 | } |
440 | |||
441 | view_center_and_clip_surface(view); | ||
442 | } | 442 | } |
443 | 443 | ||
444 | if (view->container->node.instruction) { | 444 | if (view->container->node.instruction) { |
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 | ||
896 | void view_center_surface(struct sway_view *view) { | 896 | void 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 | ||
906 | struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) { | 921 | struct sway_view *view_from_wlr_surface(struct wlr_surface *wlr_surface) { |