-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Fancy zones: show active layouts on all monitors #1553
Changes from 6 commits
02bb084
2e0fce3
e3cf84a
f852ff3
9133847
60e3725
70f9316
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -883,11 +883,29 @@ void FancyZones::MoveSizeStartInternal(HWND window, HMONITOR monitor, POINT cons | |
{ | ||
m_zoneWindowMoveSize = iter->second; | ||
m_zoneWindowMoveSize->MoveSizeEnter(window, m_dragEnabled); | ||
if (m_settings->GetSettings().showZonesOnAllMonitors) | ||
{ | ||
for (auto [keyMonitor, zoneWindow] : m_zoneWindowMap) | ||
{ | ||
// Skip calling ShowZoneWindow for iter->second (m_zoneWindowMoveSize) since it | ||
// was already called in MoveSizeEnter | ||
if (zoneWindow && zoneWindow != iter->second) | ||
{ | ||
zoneWindow->ShowZoneWindow(); | ||
} | ||
} | ||
} | ||
} | ||
else if (m_zoneWindowMoveSize) | ||
{ | ||
m_zoneWindowMoveSize->MoveSizeCancel(); | ||
m_zoneWindowMoveSize = nullptr; | ||
for (auto [keyMonitor, zoneWindow] : m_zoneWindowMap) | ||
{ | ||
if (zoneWindow) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to check zoneWindow every time? We would never add it into the map if creation of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with you but I still added the checks just because most of the code base seems to have such redundant checks. |
||
{ | ||
zoneWindow->HideZoneWindow(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
@@ -924,6 +942,15 @@ void FancyZones::MoveSizeEndInternal(HWND window, POINT const& ptScreen, require | |
} | ||
} | ||
} | ||
|
||
// Also, hide all windows (regardless of settings) | ||
for (auto [keyMonitor, zoneWindow] : m_zoneWindowMap) | ||
{ | ||
if (zoneWindow) | ||
{ | ||
zoneWindow->HideZoneWindow(); | ||
} | ||
} | ||
} | ||
|
||
void FancyZones::MoveSizeUpdateInternal(HMONITOR monitor, POINT const& ptScreen, require_write_lock writeLock) noexcept | ||
|
@@ -938,9 +965,15 @@ void FancyZones::MoveSizeUpdateInternal(HMONITOR monitor, POINT const& ptScreen, | |
// Update the ZoneWindow already handling move/size | ||
if (!m_dragEnabled) | ||
{ | ||
// Drag got disabled, tell it to cancel and clear out m_zoneWindowMoveSize | ||
auto zoneWindow = std::move(m_zoneWindowMoveSize); | ||
zoneWindow->MoveSizeCancel(); | ||
// Drag got disabled, tell it to cancel and hide all windows | ||
m_zoneWindowMoveSize = nullptr; | ||
for (auto [keyMonitor, zoneWindow] : m_zoneWindowMap) | ||
{ | ||
if (zoneWindow) | ||
{ | ||
zoneWindow->HideZoneWindow(); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
|
@@ -951,7 +984,11 @@ void FancyZones::MoveSizeUpdateInternal(HMONITOR monitor, POINT const& ptScreen, | |
{ | ||
// The drag has moved to a different monitor. | ||
auto const isDragEnabled = m_zoneWindowMoveSize->IsDragEnabled(); | ||
m_zoneWindowMoveSize->MoveSizeCancel(); | ||
// only hide if the option to show all zones is off | ||
if (!m_settings->GetSettings().showZonesOnAllMonitors) | ||
{ | ||
m_zoneWindowMoveSize->HideZoneWindow(); | ||
} | ||
m_zoneWindowMoveSize = iter->second; | ||
m_zoneWindowMoveSize->MoveSizeEnter(m_windowMoveSize, isDragEnabled); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zoneWindow != iter->second
why do we need to skip
m_zoneWindowMoveSize
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't need to, I just didn't want to call that function twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's name the condition something like
const bool moveSizeEnterCalled = zoneWindow != m_zoneWindowMoveSiz;
, so we don't have to look up the reason for the condition each time.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it apparent what I'm doing here? I'm treating
iter->second
(e.g.m_zoneWindowMoveSize
) in one way, and every otherzoneWindow
in another way.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see the logic, but there's no intent visible for why you're doing that, so anyone reading this code in the future will have to go through all the functions called above that line, understand what they do, take a guess that the only reason you've intended to skip it is because of the double call to
ShowZoneWindow
. Imagine that the future code will change and you'll also have to track all the conditions leading to theShowZoneWindow
inMoveSizeEnter
etc. Adding just a single line will eliminate the future possibility of spending time for everyone on the thing you already know.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can I write a comment explaining what you said instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, the only reason I've proposed that is to minimize implicit context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion if its possible to add literals like
const bool moveSizeEnterCalled = zoneWindow != m_zoneWindowMoveSiz;
I far better than adding comments. Cause literals are tied to the code. Comments are not and can be outdated easyly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but if some code changes, the variable's name will no longer represent the real situation. In this case a variable is as good as a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can happen, but variable and function names should be updated when changing the code.
Also its guaranteed that when changing the code, variable name and its usage will be shown in pull request as reviewed code. Comments are not and there for can be easier overlooked.
It was established in previous review that if something can be explained by descrptive variable and fuction name it's prefered over comment