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: improve windows and apps filtering #673

Merged
merged 1 commit into from
Nov 18, 2019

Conversation

bzoz
Copy link
Contributor

@bzoz bzoz commented Nov 7, 2019

Summary of the Pull Request

Unifies the way windows are considered "interesting" by FancyZone. Before the change, WinKey + arrows would use a different method than dragging. This PR makes both use the WinKey + arrows method.

Cleans up FancyZones Settings.cpp by removing m_configStrings variable. Contrary to its name it was used to create color picker control.

Adds a multiline option to the text input to settings. Uses this to provide the user with a way to exclude certain apps from snapping to zones.

PR Checklist

Validation Steps Performed

Manual

@bzoz bzoz requested a review from enricogior November 7, 2019 11:03
@enricogior
Copy link
Contributor

@bzoz
I haven't done a full review yet, my first consideration is about a possible optimization for the new and more complex IsInterestingWindow().
I've noticed that IsInterestingWindow() it's called very frequently by this code:

case EVENT_OBJECT_UNCLOAKED:
case EVENT_OBJECT_SHOW:
case EVENT_OBJECT_CREATE:
{
if (data->idObject == OBJID_WINDOW)
{
if (IsInterestingWindow(data->hwnd))
{
m_app.as<IFancyZonesCallback>()->WindowCreated(data->hwnd);
}
}
}
break;

and it's quite common that it is called multiple times in a row for the same HWND.
So what about caching the last HWND result?

@bzoz
Copy link
Contributor Author

bzoz commented Nov 7, 2019

@enricogior I was thinking the same thing, but from a quick test, it looks like the performance impact is minimal. That said, I think we do need some caching.

My idea is to keep a cache of about 64 last HWNDs queries, but also check (using GetWindowThreadProcessId) if the HWND still belongs to the same process as when it was added to the cachce.

@enricogior
Copy link
Contributor

@bzoz are you planning to add the caching in this PR or do you prefer to merge this one and add the caching later on?

@enricogior
Copy link
Contributor

@bzoz
can you make the description text to not wrap at the multiline control size but extend to the full size of the window?
image

{
for (const auto& excluded : m_settings->GetSettings().excludedAppsArray)
{
if (windowAndPath.process_path.find(excluded) != std::wstring::npos)
Copy link
Contributor

@enricogior enricogior Nov 11, 2019

Choose a reason for hiding this comment

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

This is a partial match, for example if the excluded app is notepad and the target app is notepad++.exe, it will disable fancyzones for notepad++.exe, this may generate confusion to the users.
We either force the users to add the application extension, like in notepad.exe, or handle it in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Requiring an exact match would also be confusing, the app binary file name does not really have match exactly the app name. The best solution would probably be if a user can click on a window to disable it, maybe by using the system menu hook from #677?

Copy link
Contributor

Choose a reason for hiding this comment

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

At least we need to document how it works, so a user may try to use the extension in order to avoid partial matching.
The FancyZones readme is outdated anyway and requires to be updated.
So let's open an issue for the Readme update after this PR is merged.

@bzoz
Copy link
Contributor Author

bzoz commented Nov 12, 2019

Fixed the label size and added caching of the HWNDs, PTAL

@bzoz
Copy link
Contributor Author

bzoz commented Nov 13, 2019

Updated, PTAL

src/common/common.cpp Outdated Show resolved Hide resolved
src/common/common.cpp Outdated Show resolved Hide resolved
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.

Great work!

Unifies the way windows are considered "interesting" by FancyZone.
Berfore the change WinKey + arrows would use different method than
dragging. This PR makes both use the WinKey + arrows method.

Cleans up FancyZones Settings.cpp by removing m_configStrings variable.
Contrary to its name it was used to create color picker control.

Adds a multiline option to the text input to settings. Uses this to
provide the user with a way to exclude certain apps from snapping to
zones.
@bzoz bzoz merged commit 03438f9 into microsoft:master Nov 18, 2019
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.

2 participants