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

Add the ability to unmaximize a window by dragging. #172

Merged
merged 6 commits into from
Mar 9, 2021

Conversation

okratitan
Copy link
Contributor

Fixes #138

Copy link
Contributor

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

This is a great change thanks - just a suggestion inline let me know what you think.

if moveDeltaX == 0 && moveDeltaY == 0 {
return
}
if f.client.Maximized() {
if uint16(moveDeltaX) > x11.TitleHeight(x11.XWin(f.client)) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Might it be clearer if we add a new variable that avoids this call twice? Might help show intent too.

dragThreshold := x11.TitleHeight(x11.XWin(f.client))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With the new changes it's only one threshold now, vertical. Per @Jacalz horizontal drag shouldn't unmaximize. That will change we do quarter snapping though I'm sure.

Copy link
Contributor

Choose a reason for hiding this comment

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

There is now a magic "*3" so I think the comment still applies with regard to intent.
Looking at the code it is also not clear why the y position needs to be checked twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Semantically we don't want to start counting the delta until the cursor has been dragged out of the titlebar vertically. So that's the first check. The second check is to calculate the resistance at which we want to unmaximize. I understand currently I'm using titlebar height * 3 to calculate that distance - and thus the if could be shortened to just check a delta of titlebar height * 4 and get the same effect - I figured they were two different things and we may not always use titlebar height to calculate the delta resistance. I can make a const for the resistance and then I think this if check will make sense if the y position of the cursor > titlebar position && the delta of how far the mouse has been dragged > resistance const then unmaximize.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation, if the first check is to ensure it is within the bar then you’re missing a check for y >= f.y.

I don’t think a const makes sense, as the title height is a variable.
However the same border theme lookup is being done twice in this line, so is it not more efficient to capture in a var?

Jacalz
Jacalz previously approved these changes Mar 9, 2021
Copy link
Member

@Jacalz Jacalz left a comment

Choose a reason for hiding this comment

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

Feels great. Good job 👍

Copy link
Contributor

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

Great improvement thanks

@okratitan okratitan merged commit 01c7bf9 into FyshOS:develop Mar 9, 2021
@okratitan okratitan deleted the dragUnmaximize branch March 9, 2021 21:45
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