Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tree/view: Do not clip to geometry if using CSD #8033

Merged
merged 1 commit into from May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 13 additions & 6 deletions sway/tree/view.c
Expand Up @@ -927,11 +927,14 @@ void view_update_size(struct sway_view *view) {
void view_center_and_clip_surface(struct sway_view *view) {
struct sway_container *con = view->container;

bool clip_to_geometry = true;

if (container_is_floating(con)) {
// We always center the current coordinates rather than the next, as the
// geometry immediately affects the currently active rendering.
int x = (int) fmax(0, (con->current.content_width - view->geometry.width) / 2);
int y = (int) fmax(0, (con->current.content_height - view->geometry.height) / 2);
clip_to_geometry = !view->using_csd;

wlr_scene_node_set_position(&view->content_tree->node, x, y);
} else {
Expand All @@ -940,12 +943,16 @@ void view_center_and_clip_surface(struct sway_view *view) {

// only make sure to clip the content if there is content to clip
if (!wl_list_empty(&con->view->content_tree->children)) {
wlr_scene_subsurface_tree_set_clip(&con->view->content_tree->node, &(struct wlr_box){
.x = con->view->geometry.x,
.y = con->view->geometry.y,
.width = con->current.content_width,
.height = con->current.content_height,
});
struct wlr_box clip = {0};
if (clip_to_geometry) {
clip = (struct wlr_box){
.x = con->view->geometry.x,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should just be using con->current.content_x instead of con->view->geometry.x here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried this but it did not work properly. Looks like content_x and content_y are absolute coordinates, while subsurface_tree_set_clip expects surface-local coordinates.

.y = con->view->geometry.y,
.width = con->current.content_width,
.height = con->current.content_height,
};
}
wlr_scene_subsurface_tree_set_clip(&con->view->content_tree->node, &clip);
}
}

Expand Down