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

Allow changing resize increments after window creation #2411

Merged
merged 1 commit into from
Sep 3, 2022
Merged

Allow changing resize increments after window creation #2411

merged 1 commit into from
Sep 3, 2022

Conversation

necauqua
Copy link
Contributor

@necauqua necauqua commented Aug 7, 2022

Pretty basic "I hope it works" implementation, only tested on X11, can test on a mac in a few days.

Once this is reviewed->merged->released I hope to finally make Alacritty not suck, heh

The branch is based on the #2410 because I kept moving the test window to the other screen, I'll rebase once it's merged, done

Currently this is a draft to run your CI and to get reviews. should be ready

Closes #2020

  • Tested on all platforms changed
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

@necauqua necauqua changed the title Implement dynamically changing resize increments Allow changing resize increments after window creation Aug 7, 2022
@necauqua
Copy link
Contributor Author

necauqua commented Aug 8, 2022

Still marked as a draft because I did not test this on a mac yet, if you have a mac and are willing to test this you are welcome

@kchibisov
Copy link
Member

I could test macOs, but not soon. Maybe @madsmtm could check.

@madsmtm madsmtm self-requested a review August 10, 2022 14:30
Copy link
Member

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, looks good and seems to work fine barring a few things

@necauqua
Copy link
Contributor Author

Ok so I guess @madsmtm tested this on a mac so I'm undrafting this.
A couple of remaining minor reviews waiting for clarification after my comment and contentResizeIncrements/resizeIncrements debate also waits for a quorum agreement I guess

@necauqua necauqua marked this pull request as ready for review August 13, 2022 23:02
Copy link
Member

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

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

Works flawlessly on macOS now, thanks!

@msiglreith msiglreith removed their request for review August 14, 2022 11:11
@necauqua
Copy link
Contributor Author

Hey @kchibisov have you had a chance to see my reply to your comments about logging on unsupported platforms?

Do you insist on adding those logs or does my reasoning make sense to keep it as I did it initially

@kchibisov
Copy link
Member

@necauqua the thing is that log was added after some point in time, so the platforms inherited // not supported comments and there wasn't anything to change that. In general we want to log, but for now we can leave it as is for consistency sake.

@@ -386,7 +386,7 @@ impl UnownedWindow {
normal_hints.set_min_size(min_inner_size.map(Into::into));
normal_hints.set_max_size(max_inner_size.map(Into::into));
normal_hints.set_resize_increments(
pl_attribs
window_attrs
.resize_increments
.map(|size| size.to_physical::<u32>(scale_factor).into()),
Copy link
Member

Choose a reason for hiding this comment

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

There's no need for map given that function handles that or the scaling is wrong when calling the set_resize_increments here? Could you add a comment about that at least? I do understand that the code was like that before, but it would be nice to ensure that and remove extra convertion, since it looks confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You might be confused by the two lines above which look like normal_hints.set_max_size(max_inner_size.map(Into::into)); - but in fact I modelled resize_incremets exactly like min/max_inner_size.

In those lines above e.g. the min_inner_size is is defined as let mut min_inner_size = window_attrs.min_inner_size.map(|size| size.to_physical::<u32>(scale_factor)), it just needs to be a mut local to update it for the ability to make windows unresizable.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not saying that the logic is wrong or anything. I'm trying to say that set_resize_increments already does conversion to physical pixels with the scale_factor so the logic seems redundant and you can pass resize_increments directly?

There's a chance that I don't understand this code or scale factor isn't there.

Copy link
Contributor Author

@necauqua necauqua Aug 28, 2022

Choose a reason for hiding this comment

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

Here we call normal_hints.set_resize_increments which just accepts a pair of i32s, physical, not window.set_resize_increments which accepts the Size enum and does the conversion - so that on window creation there is only one xconn.set_normal_hints call to set all the initial hints at once.

Same with other normal_hints related things like position/size/min_size/max_size as I said

@necauqua
Copy link
Contributor Author

Ok then

Maybe later some separate effort should be put in to update all these comments with log warnings (I'd personally also add a feature to disable that? or better a special log target(s) for those 'not implemented/unsupported' warnings)

@necauqua
Copy link
Contributor Author

oh wow I dont think I've anything to do with those fails

@@ -386,7 +386,7 @@ impl UnownedWindow {
normal_hints.set_min_size(min_inner_size.map(Into::into));
normal_hints.set_max_size(max_inner_size.map(Into::into));
normal_hints.set_resize_increments(
pl_attribs
window_attrs
.resize_increments
.map(|size| size.to_physical::<u32>(scale_factor).into()),
Copy link
Member

Choose a reason for hiding this comment

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

I'm not saying that the logic is wrong or anything. I'm trying to say that set_resize_increments already does conversion to physical pixels with the scale_factor so the logic seems redundant and you can pass resize_increments directly?

There's a chance that I don't understand this code or scale factor isn't there.

@kchibisov
Copy link
Member

Could you rebase. Should be good after that.

@kchibisov kchibisov merged commit ab56e9f into rust-windowing:master Sep 3, 2022
@necauqua necauqua deleted the dynamic-resize-increments branch September 3, 2022 18:54
madsmtm added a commit that referenced this pull request Sep 8, 2022
madsmtm added a commit that referenced this pull request Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Support updating resize increments
4 participants