Commit 3e715045 authored by David Bienvenu's avatar David Bienvenu Committed by Commit Bot

If screen is locked, set visible windows as occluded.

If a background occlusion calculation is in progress when the screen is locked,
it will overwrite the setting of visible windows as occluded by the code receiving
the screen lock notification.

Bug: 532128, 813093
Change-Id: Ia256dd3668029220d00d31101942600527fe5f6e
Reviewed-on: https://chromium-review.googlesource.com/c/1492038Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636874}
parent 03357ce3
......@@ -179,23 +179,35 @@ void NativeWindowOcclusionTrackerWin::UpdateOcclusionState(
if (it == hwnd_root_window_map_.end())
continue;
// Check Window::IsVisible here, on the UI thread, because it can't be
// checked on the occlusion calculation thread.
bool root_window_hidden = !it->second->IsVisible();
// checked on the occlusion calculation thread. Do this first before
// checking screen_locked_ so that hidden windows remain hidden.
if (!it->second->IsVisible()) {
it->second->GetHost()->SetNativeWindowOcclusionState(
Window::OcclusionState::HIDDEN);
continue;
}
// If the screen is locked, ignore occlusion state results and
// mark the window as occluded.
it->second->GetHost()->SetNativeWindowOcclusionState(
root_window_hidden ? Window::OcclusionState::HIDDEN
: root_window_pair.second);
if (!root_window_hidden)
num_visible_root_windows_++;
screen_locked_ ? Window::OcclusionState::OCCLUDED
: root_window_pair.second);
num_visible_root_windows_++;
}
}
void NativeWindowOcclusionTrackerWin::OnSessionChange(WPARAM status_code) {
if (status_code == WTS_SESSION_LOCK) {
// Tell all root windows that they're occluded.
screen_locked_ = true;
// Set all visible root windows as occluded. If not visible,
// set them as hidden.
for (const auto& root_window_hwnd_pair : hwnd_root_window_map_) {
root_window_hwnd_pair.second->GetHost()->SetNativeWindowOcclusionState(
Window::OcclusionState::OCCLUDED);
root_window_hwnd_pair.second->IsVisible()
? Window::OcclusionState::OCCLUDED
: Window::OcclusionState::HIDDEN);
}
} else if (status_code == WTS_SESSION_UNLOCK) {
screen_locked_ = false;
}
// Other session changes don't need to trigger occlusion calculation. In
// particular, UNLOCK will cause a foreground window change, which will
......
......@@ -222,6 +222,9 @@ class AURA_EXPORT NativeWindowOcclusionTrackerWin : public WindowObserver {
// Manages observation of Windows Session Change messages.
ui::SessionChangeObserver session_change_observer_;
// If the screen is locked, windows are considered occluded.
bool screen_locked_ = false;
DISALLOW_COPY_AND_ASSIGN(NativeWindowOcclusionTrackerWin);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment