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

xdg: Add get_anchor_point method to PositionerState #1630

Merged
merged 1 commit into from
Jan 13, 2025

Conversation

ids1024
Copy link
Member

@ids1024 ids1024 commented Jan 9, 2025

These two changes are used for pop-os/cosmic-comp#1122.

Cosmic-comp's implementation is a little unusual. It tries to fit the popup within the tile if it can do so without resizing. If this fails, it instead tries to fit it within the output, using resizes as well if still needed. I'm not sure if many compositors will need this, but this seems as good a way as any to expose a way to do this.

It also has a check to test which output the anchor point is in. It seems reasonable to expose this as a method.

@YaLTeR
Copy link
Contributor

YaLTeR commented Jan 9, 2025

FWIW you don't need an extra argument, just do this:

// Do not try to resize to fit the padded target rectangle.
let mut no_resize = positioner;
no_resize
    .constraint_adjustment
    .remove(ConstraintAdjustment::ResizeX);
no_resize
    .constraint_adjustment
    .remove(ConstraintAdjustment::ResizeY);

let geo = no_resize.get_unconstrained_geometry(padded.to_i32_round());
if padded.contains_rect(geo.to_f64()) {
    return geo;
}

// Could not unconstrain into the padded target, so resort to the regular one.
positioner.get_unconstrained_geometry(target.to_i32_round())

That's how I intended it to be used from the start.

@ids1024
Copy link
Member Author

ids1024 commented Jan 9, 2025

Ah, I hadn't even noticed that get_unconstrained_geometry (unlike get_geometry) consumes self and is a method of a Copy type. Yeah, that makes sense.

@ids1024 ids1024 force-pushed the unconstained_geometry branch from 4b0f940 to 041cf85 Compare January 9, 2025 20:09
@ids1024 ids1024 changed the title get_unconstrained_geometry adjustment argument, and get_anchor_point method xdg: Add get_anchor_point method to PositionerState Jan 9, 2025
@Drakulix Drakulix merged commit 2a0d430 into Smithay:master Jan 13, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants