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

[FancyZones] Do not zone window if it merges with other window #6549

Merged
merged 5 commits into from
Sep 11, 2020

Conversation

stefansjfw
Copy link
Collaborator

@stefansjfw stefansjfw commented Sep 10, 2020

e.g. merge Chrome tab into other Chrome window

Summary of the Pull Request

What is this about?
If some of the window properties changed while drag&drop (durring MoveSize* FZ methods), that means that window is merged with other window or changed in some other way. Therefore, that window shouldn't be zoned.

PR Checklist

auto myTie = [](const FancyZonesUtils::FancyZonesWindowInfo& windowInfo) {
return std::tie(windowInfo.noVisibleOwner, windowInfo.processPath, windowInfo.standardWindow);
};
if (myTie(windowInfo) == myTie(m_moveSizeStartWindowInfo))
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be fine, but I would feel more comfortable if we do an explicit check for the specific case we know of and only bail out only if windowInfo.noVisibleOwner and windowInfo.standardWindow change from true to false.
Also, let's not check windowInfo.processPath because as far as we know, this is not a factor.
Also add a comment explaining what case we are covering with that check.

@enricogior enricogior added the Product-FancyZones Refers to the FancyZones PowerToy label Sep 10, 2020
zoneWindow->MoveSizeEnd(m_windowMoveSize, ptScreen);
auto windowInfo = FancyZonesUtils::GetFancyZonesWindowInfo(window);
auto myTie = [](const FancyZonesUtils::FancyZonesWindowInfo& windowInfo) {
return std::tie(windowInfo.noVisibleOwner, windowInfo.processPath, windowInfo.standardWindow);
Copy link
Contributor

Choose a reason for hiding this comment

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

I like what You did here, but I still think that overriding == operator would be cleaner approach. But I’m perfectly fine with both. Nice work!

Comment on lines 323 to 324
if (windowInfo.standardWindow == m_moveSizeStartWindowInfo.standardWindow &&
windowInfo.noVisibleOwner == m_moveSizeStartWindowInfo.noVisibleOwner)
Copy link
Contributor

@enricogior enricogior Sep 11, 2020

Choose a reason for hiding this comment

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

Let's do:

if (windowInfo.standardWindow == false && windowInfo.noVisibleOwner == false && m_moveSizeStartWindowInfo.standardWindow == true && m_moveSizeStartWindowInfo.noVisibleOwner == true)
{
    // Abort the zoning, this is a Chromium based tab that is merged back with an existing window
    ...
}

So the check is 100% specific for the Chrome tab case and doesn't cover the other way around (that we don't even know if it's actually possible, but if it is, it's not currently broken)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

other way around isn't possible, as if standardWindow was false in moveSizeStart, we wouldn't get here at all

Copy link
Contributor

Choose a reason for hiding this comment

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

Still, I prefer the code covers the specific case, this is for long term code maintainability, it should only check what we know it should check and not cover other cases.

Copy link
Contributor

@enricogior enricogior left a comment

Choose a reason for hiding this comment

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

Tested with Chrome and Edge Chromium, worked as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Product-FancyZones Refers to the FancyZones PowerToy
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants