diff options
Diffstat (limited to 'chromium/ui/aura')
-rw-r--r-- | chromium/ui/aura/BUILD.gn | 1 | ||||
-rw-r--r-- | chromium/ui/aura/client/screen_position_client.cc | 22 | ||||
-rw-r--r-- | chromium/ui/aura/client/screen_position_client.h | 12 | ||||
-rw-r--r-- | chromium/ui/aura/client/screen_position_client_unittest.cc | 65 | ||||
-rw-r--r-- | chromium/ui/aura/gestures/gesture_recognizer_unittest.cc | 4 | ||||
-rw-r--r-- | chromium/ui/aura/native_window_occlusion_tracker_win.cc | 183 | ||||
-rw-r--r-- | chromium/ui/aura/native_window_occlusion_tracker_win.h | 50 | ||||
-rw-r--r-- | chromium/ui/aura/screen_ozone.cc | 13 | ||||
-rw-r--r-- | chromium/ui/aura/screen_ozone.h | 4 | ||||
-rw-r--r-- | chromium/ui/aura/window.cc | 2 | ||||
-rw-r--r-- | chromium/ui/aura/window_event_dispatcher.cc | 7 | ||||
-rw-r--r-- | chromium/ui/aura/window_event_dispatcher.h | 2 | ||||
-rw-r--r-- | chromium/ui/aura/window_event_dispatcher_unittest.cc | 6 | ||||
-rw-r--r-- | chromium/ui/aura/window_occlusion_tracker_unittest.cc | 4 | ||||
-rw-r--r-- | chromium/ui/aura/window_unittest.cc | 2 |
15 files changed, 340 insertions, 37 deletions
diff --git a/chromium/ui/aura/BUILD.gn b/chromium/ui/aura/BUILD.gn index 76a5742b2f3..193de1bb5ca 100644 --- a/chromium/ui/aura/BUILD.gn +++ b/chromium/ui/aura/BUILD.gn @@ -322,6 +322,7 @@ test("aura_unittests") { sources = [ "../compositor_extra/shadow_unittest.cc", + "client/screen_position_client_unittest.cc", "gestures/gesture_recognizer_unittest.cc", "test/aura_test_suite.h", "test/run_all_unittests.cc", diff --git a/chromium/ui/aura/client/screen_position_client.cc b/chromium/ui/aura/client/screen_position_client.cc index b40ff46ebc1..7bc23e48b42 100644 --- a/chromium/ui/aura/client/screen_position_client.cc +++ b/chromium/ui/aura/client/screen_position_client.cc @@ -30,6 +30,28 @@ void ScreenPositionClient::ConvertPointFromScreen(const Window* window, *point = gfx::ToFlooredPoint(point_float); } +void ScreenPositionClient::ConvertPointToRootWindowIgnoringTransforms( + const Window* window, + gfx::Point* point) { + DCHECK(window); + DCHECK(window->GetRootWindow()); + Window* ancestor = const_cast<Window*>(window); + while (ancestor && !ancestor->IsRootWindow()) { + const gfx::Point origin = ancestor->bounds().origin(); + point->Offset(origin.x(), origin.y()); + ancestor = ancestor->parent(); + } +} + +void ScreenPositionClient::ConvertPointToScreenIgnoringTransforms( + const aura::Window* window, + gfx::Point* point) { + const aura::Window* root_window = window->GetRootWindow(); + ConvertPointToRootWindowIgnoringTransforms(window, point); + gfx::Point origin = GetRootWindowOriginInScreen(root_window); + point->Offset(origin.x(), origin.y()); +} + void SetScreenPositionClient(Window* root_window, ScreenPositionClient* client) { DCHECK_EQ(root_window->GetRootWindow(), root_window); diff --git a/chromium/ui/aura/client/screen_position_client.h b/chromium/ui/aura/client/screen_position_client.h index 24e22be60c6..f2d7a44a155 100644 --- a/chromium/ui/aura/client/screen_position_client.h +++ b/chromium/ui/aura/client/screen_position_client.h @@ -45,6 +45,18 @@ class AURA_EXPORT ScreenPositionClient { virtual void SetBounds(Window* window, const gfx::Rect& bounds, const display::Display& display) = 0; + // Converts |point| from |window|'s coordinate space into screen coordinate + // space. Ignores any transforms that may be applied on |window| or its window + // hieraichy. + void ConvertPointToScreenIgnoringTransforms(const Window* window, + gfx::Point* point); + void ConvertPointToRootWindowIgnoringTransforms(const Window* window, + gfx::Point* point); + + protected: + // Returns the origin of the host platform-window in system DIP coordinates. + virtual gfx::Point GetRootWindowOriginInScreen( + const aura::Window* root_window) = 0; }; // Sets/Gets the activation client on the Window. diff --git a/chromium/ui/aura/client/screen_position_client_unittest.cc b/chromium/ui/aura/client/screen_position_client_unittest.cc new file mode 100644 index 00000000000..834b73bfbc6 --- /dev/null +++ b/chromium/ui/aura/client/screen_position_client_unittest.cc @@ -0,0 +1,65 @@ +// Copyright 2020 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/aura/client/screen_position_client.h" + +#include <memory> + +#include "ui/aura/test/aura_test_base.h" + +namespace aura { +namespace client { + +using ScreenPositionClientTest = test::AuraTestBase; + +class TestScreenPositionClient : public ScreenPositionClient { + public: + TestScreenPositionClient() = default; + TestScreenPositionClient(const TestScreenPositionClient&) = delete; + TestScreenPositionClient& operator=(const TestScreenPositionClient&) = delete; + ~TestScreenPositionClient() override = default; + + // ScreenPositionClient: + void ConvertPointToScreen(const Window* window, gfx::PointF* point) override { + } + void ConvertPointFromScreen(const Window* window, + gfx::PointF* point) override {} + void ConvertHostPointToScreen(Window* root_window, + gfx::Point* point) override {} + void SetBounds(Window* window, + const gfx::Rect& bounds, + const display::Display& display) override {} + + protected: + // ScreenPositionClient: + gfx::Point GetRootWindowOriginInScreen( + const aura::Window* root_window) override { + return gfx::Point(); + } +}; + +TEST_F(ScreenPositionClientTest, ConvertPointToRootWindowIgnoringTransforms) { + std::unique_ptr<Window> parent(CreateNormalWindow(1, root_window(), nullptr)); + std::unique_ptr<Window> child(CreateNormalWindow(2, parent.get(), nullptr)); + + parent->SetBounds(gfx::Rect(50, 50, 200, 200)); + child->SetBounds(gfx::Rect(150, 150, 200, 200)); + + TestScreenPositionClient test_client; + gfx::Point point(100, 100); + test_client.ConvertPointToRootWindowIgnoringTransforms(parent.get(), &point); + EXPECT_EQ(gfx::Point(150, 150), point); + + point = gfx::Point(100, 100); + test_client.ConvertPointToRootWindowIgnoringTransforms(child.get(), &point); + EXPECT_EQ(gfx::Point(300, 300), point); + + point = gfx::Point(100, 100); + child->SetTransform(gfx::Transform(1, 0, 0, 1, 100, 100)); + test_client.ConvertPointToRootWindowIgnoringTransforms(child.get(), &point); + EXPECT_EQ(gfx::Point(300, 300), point); +} + +} // namespace client +} // namespace aura diff --git a/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc b/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc index c681aa4b077..9d582844a33 100644 --- a/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc +++ b/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc @@ -351,7 +351,7 @@ class QueueTouchEventDelegate : public GestureEventConsumeDelegate { synchronous_ack_for_next_event_ == AckState::CONSUMED ? ui::ER_CONSUMED : ui::ER_UNHANDLED, - false /* is_source_touch_event_set_non_blocking */, window_); + false /* is_source_touch_event_set_blocking */, window_); synchronous_ack_for_next_event_ = AckState::PENDING; } else { sent_events_ids_.push_back(event->unique_event_id()); @@ -389,7 +389,7 @@ class QueueTouchEventDelegate : public GestureEventConsumeDelegate { dispatcher_->ProcessedTouchEvent( sent_event_id, window_, prevent_defaulted ? ui::ER_HANDLED : ui::ER_UNHANDLED, - false /* is_source_touch_event_set_non_blocking */); + false /* is_source_touch_event_set_blocking */); } Window* window_; diff --git a/chromium/ui/aura/native_window_occlusion_tracker_win.cc b/chromium/ui/aura/native_window_occlusion_tracker_win.cc index 66fd0b94353..9b7e1e3fa9d 100644 --- a/chromium/ui/aura/native_window_occlusion_tracker_win.cc +++ b/chromium/ui/aura/native_window_occlusion_tracker_win.cc @@ -5,11 +5,14 @@ #include "ui/aura/native_window_occlusion_tracker_win.h" #include <dwmapi.h> +#include <powersetting.h> #include <memory> +#include <string> #include "base/bind.h" #include "base/callback.h" #include "base/memory/scoped_refptr.h" +#include "base/strings/utf_string_conversions.h" #include "base/synchronization/waitable_event.h" #include "base/task/post_task.h" #include "base/task/task_traits.h" @@ -19,6 +22,58 @@ #include "base/win/scoped_gdi_object.h" #include "base/win/windows_version.h" #include "ui/aura/window_tree_host.h" +#include "ui/base/ui_base_features.h" +#include "ui/gfx/win/hwnd_util.h" + +const CLSID CLSID_ImmersiveShell = { + 0xC2F03A33, + 0x21F5, + 0x47FA, + {0xB4, 0xBB, 0x15, 0x63, 0x62, 0xA2, 0xF2, 0x39}}; + +const CLSID CLSID_VirtualDesktopAPI_Unknown = { + 0xC5E0CDCA, + 0x7B6E, + 0x41B2, + {0x9F, 0xC4, 0xD9, 0x39, 0x75, 0xCC, 0x46, 0x7B}}; + +struct IApplicationView : public IUnknown { + public: +}; + +MIDL_INTERFACE("FF72FFDD-BE7E-43FC-9C03-AD81681E88E4") +IVirtualDesktop : public IUnknown { + public: + virtual HRESULT STDMETHODCALLTYPE IsViewVisible(IApplicationView * pView, + int* pfVisible) = 0; + virtual HRESULT STDMETHODCALLTYPE GetID(GUID * pGuid) = 0; +}; + +enum AdjacentDesktop { LeftDirection = 3, RightDirection = 4 }; + +MIDL_INTERFACE("F31574D6-B682-4cdc-BD56-1827860ABEC6") +IVirtualDesktopManagerInternal : public IUnknown { + public: + virtual HRESULT STDMETHODCALLTYPE GetCount(UINT * pCount) = 0; + virtual HRESULT STDMETHODCALLTYPE MoveViewToDesktop( + IApplicationView * pView, IVirtualDesktop * pDesktop) = 0; + virtual HRESULT STDMETHODCALLTYPE CanViewMoveDesktops( + IApplicationView * pView, int* pfCanViewMoveDesktops) = 0; + virtual HRESULT STDMETHODCALLTYPE GetCurrentDesktop(IVirtualDesktop * + *desktop) = 0; + virtual HRESULT STDMETHODCALLTYPE GetDesktops(IObjectArray * *ppDesktops) = 0; + virtual HRESULT STDMETHODCALLTYPE GetAdjacentDesktop( + IVirtualDesktop * pDesktopReference, AdjacentDesktop uDirection, + IVirtualDesktop * *ppAdjacentDesktop) = 0; + virtual HRESULT STDMETHODCALLTYPE SwitchDesktop(IVirtualDesktop * + pDesktop) = 0; + virtual HRESULT STDMETHODCALLTYPE CreateDesktopW(IVirtualDesktop * + *ppNewDesktop) = 0; + virtual HRESULT STDMETHODCALLTYPE RemoveDesktop( + IVirtualDesktop * pRemove, IVirtualDesktop * pFallbackDesktop) = 0; + virtual HRESULT STDMETHODCALLTYPE FindDesktop( + GUID * desktopId, IVirtualDesktop * *ppDesktop) = 0; +}; namespace aura { @@ -28,6 +83,9 @@ namespace { const base::TimeDelta kUpdateOcclusionDelay = base::TimeDelta::FromMilliseconds(16); +const base::TimeDelta kUpdateVirtualDesktopDelay = + base::TimeDelta::FromMilliseconds(1000); + // This global variable can be accessed only on main thread. NativeWindowOcclusionTrackerWin* g_tracker = nullptr; @@ -120,7 +178,8 @@ NativeWindowOcclusionTrackerWin::NativeWindowOcclusionTrackerWin() base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})), session_change_observer_( base::BindRepeating(&NativeWindowOcclusionTrackerWin::OnSessionChange, - base::Unretained(this))) { + base::Unretained(this))), + power_setting_change_listener_(this) { WindowOcclusionCalculator::CreateInstance( update_occlusion_task_runner_, base::SequencedTaskRunnerHandle::Get(), base::BindRepeating( @@ -225,7 +284,8 @@ bool NativeWindowOcclusionTrackerWin::IsWindowVisibleAndFullyOpaque( void NativeWindowOcclusionTrackerWin::UpdateOcclusionState( const base::flat_map<HWND, Window::OcclusionState>& - root_window_hwnds_occlusion_state) { + root_window_hwnds_occlusion_state, + bool show_all_windows) { num_visible_root_windows_ = 0; for (const auto& root_window_pair : root_window_hwnds_occlusion_state) { auto it = hwnd_root_window_map_.find(root_window_pair.first); @@ -234,17 +294,22 @@ void NativeWindowOcclusionTrackerWin::UpdateOcclusionState( continue; // Check Window::IsVisible here, on the UI thread, because it can't be // checked on the occlusion calculation thread. Do this first before - // checking screen_locked_ so that hidden windows remain hidden. + // checking screen_locked_ or display_on_ 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 + Window::OcclusionState occl_state = root_window_pair.second; + // If the screen is locked or off, ignore occlusion state results and // mark the window as occluded. - it->second->GetHost()->SetNativeWindowOcclusionState( - screen_locked_ ? Window::OcclusionState::OCCLUDED - : root_window_pair.second); + if (screen_locked_ || !display_on_) + occl_state = Window::OcclusionState::OCCLUDED; + else if (show_all_windows) + occl_state = Window::OcclusionState::VISIBLE; + + it->second->GetHost()->SetNativeWindowOcclusionState(occl_state); num_visible_root_windows_++; } } @@ -260,14 +325,29 @@ void NativeWindowOcclusionTrackerWin::OnSessionChange( screen_locked_ = false; } else if (status_code == WTS_SESSION_LOCK && is_current_session) { 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( - IsIconic(root_window_hwnd_pair.first) - ? Window::OcclusionState::HIDDEN - : Window::OcclusionState::OCCLUDED); - } + MarkNonIconicWindowsOccluded(); + } +} + +void NativeWindowOcclusionTrackerWin::OnDisplayStateChanged(bool display_on) { + if (display_on == display_on_) + return; + + display_on_ = display_on; + // Display changing to on will cause a foreground window change, + // which will trigger an occlusion calculation on its own. + if (!display_on_) + MarkNonIconicWindowsOccluded(); +} + +void NativeWindowOcclusionTrackerWin::MarkNonIconicWindowsOccluded() { + // 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( + IsIconic(root_window_hwnd_pair.first) + ? Window::OcclusionState::HIDDEN + : Window::OcclusionState::OCCLUDED); } } @@ -282,6 +362,19 @@ NativeWindowOcclusionTrackerWin::WindowOcclusionCalculator:: if (base::win::GetVersion() >= base::win::Version::WIN10) { ::CoCreateInstance(__uuidof(VirtualDesktopManager), nullptr, CLSCTX_ALL, IID_PPV_ARGS(&virtual_desktop_manager_)); + + Microsoft::WRL::ComPtr<IServiceProvider> service_provider; + if (base::FeatureList::IsEnabled( + features::kCalculateNativeWinOcclusionCheckVirtualDesktopUsed) && + SUCCEEDED(::CoCreateInstance(CLSID_ImmersiveShell, NULL, + CLSCTX_LOCAL_SERVER, + IID_PPV_ARGS(&service_provider)))) { + service_provider->QueryService( + CLSID_VirtualDesktopAPI_Unknown, + IID_PPV_ARGS(&virtual_desktop_manager_internal_)); + if (virtual_desktop_manager_internal_) + ComputeVirtualDesktopUsed(); + } } DETACH_FROM_SEQUENCE(sequence_checker_); } @@ -329,6 +422,8 @@ void NativeWindowOcclusionTrackerWin::WindowOcclusionCalculator:: UnregisterEventHooks(); if (occlusion_update_timer_.IsRunning()) occlusion_update_timer_.Stop(); + if (virtual_desktop_update_timer_.IsRunning()) + virtual_desktop_update_timer_.Stop(); } } @@ -469,17 +564,31 @@ void NativeWindowOcclusionTrackerWin::WindowOcclusionCalculator:: // Post a task to the browser ui thread to update the window occlusion state // on the root windows. ui_thread_task_runner_->PostTask( - FROM_HERE, base::BindOnce(update_occlusion_state_callback_, - root_window_hwnds_occlusion_state_)); + FROM_HERE, + base::BindOnce(update_occlusion_state_callback_, + root_window_hwnds_occlusion_state_, showing_thumbnails_)); +} + +void NativeWindowOcclusionTrackerWin::WindowOcclusionCalculator:: + ComputeVirtualDesktopUsed() { + UINT count = 0; + if (SUCCEEDED(virtual_desktop_manager_internal_->GetCount(&count))) + virtual_desktops_used_ = count > 1; } void NativeWindowOcclusionTrackerWin::WindowOcclusionCalculator:: ScheduleOcclusionCalculationIfNeeded() { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - if (!occlusion_update_timer_.IsRunning()) + if (!occlusion_update_timer_.IsRunning()) { occlusion_update_timer_.Start( FROM_HERE, kUpdateOcclusionDelay, this, &WindowOcclusionCalculator::ComputeNativeWindowOcclusionStatus); + if (virtual_desktop_manager_internal_) { + virtual_desktop_update_timer_.Start( + FROM_HERE, kUpdateVirtualDesktopDelay, this, + &WindowOcclusionCalculator::ComputeVirtualDesktopUsed); + } + } } void NativeWindowOcclusionTrackerWin::WindowOcclusionCalculator:: @@ -515,6 +624,10 @@ void NativeWindowOcclusionTrackerWin::WindowOcclusionCalculator:: // Detects foreground window changing. RegisterGlobalEventHook(EVENT_SYSTEM_FOREGROUND, EVENT_SYSTEM_FOREGROUND); + // Detects objects getting shown and hidden. Used to know when the task bar + // and alt tab are showing preview windows so we can unocclude Chrome windows. + RegisterGlobalEventHook(EVENT_OBJECT_SHOW, EVENT_OBJECT_HIDE); + // Detects object state changes, e.g., enable/disable state, native window // maximize and native window restore events. RegisterGlobalEventHook(EVENT_OBJECT_STATECHANGE, EVENT_OBJECT_STATECHANGE); @@ -626,6 +739,38 @@ void NativeWindowOcclusionTrackerWin::WindowOcclusionCalculator:: if (id_object != OBJID_WINDOW) return; + // Detect if either the alt tab view or the task list thumbnail is being + // shown. If so, mark all non-hidden windows as occluded, and remember that + // we're in the showing_thumbnails state. This lasts until we get told that + // either the alt tab view or task list thumbnail are hidden. + if (event == EVENT_OBJECT_SHOW) { + // Avoid getting the hwnd's class name, and recomputing occlusion, if not + // needed. + if (showing_thumbnails_) + return; + std::string hwnd_class_name = base::UTF16ToUTF8(gfx::GetClassName(hwnd)); + if ((hwnd_class_name == "MultitaskingViewFrame" || + hwnd_class_name == "TaskListThumbnailWnd")) { + showing_thumbnails_ = true; + ui_thread_task_runner_->PostTask( + FROM_HERE, base::BindOnce(update_occlusion_state_callback_, + root_window_hwnds_occlusion_state_, + showing_thumbnails_)); + return; + } + } else if (event == EVENT_OBJECT_HIDE) { + // Avoid getting the hwnd's class name, and recomputing occlusion, if not + // needed. + if (!showing_thumbnails_) + return; + std::string hwnd_class_name = base::UTF16ToUTF8(gfx::GetClassName(hwnd)); + if (hwnd_class_name == "MultitaskingViewFrame" || + hwnd_class_name == "TaskListThumbnailWnd") { + showing_thumbnails_ = false; + // Let occlusion calculation fix occlusion state. + } + } + // Don't continually calculate occlusion while a window is moving, but rather // once at the beginning and once at the end. if (event == EVENT_SYSTEM_MOVESIZESTART) { @@ -677,7 +822,7 @@ bool NativeWindowOcclusionTrackerWin::WindowOcclusionCalculator:: base::Optional<bool> NativeWindowOcclusionTrackerWin:: WindowOcclusionCalculator::IsWindowOnCurrentVirtualDesktop(HWND hwnd) { - if (!virtual_desktop_manager_) + if (!virtual_desktop_manager_ || !virtual_desktops_used_) return true; BOOL on_current_desktop; diff --git a/chromium/ui/aura/native_window_occlusion_tracker_win.h b/chromium/ui/aura/native_window_occlusion_tracker_win.h index 751562e9bb5..8fe2f6f3348 100644 --- a/chromium/ui/aura/native_window_occlusion_tracker_win.h +++ b/chromium/ui/aura/native_window_occlusion_tracker_win.h @@ -23,6 +23,7 @@ #include "ui/aura/aura_export.h" #include "ui/aura/window.h" #include "ui/aura/window_observer.h" +#include "ui/base/win/power_setting_change_listener.h" #include "ui/base/win/session_change_observer.h" namespace base { @@ -33,12 +34,16 @@ namespace gfx { class Rect; } +struct IVirtualDesktopManagerInternal; + namespace aura { // This class keeps track of whether any HWNDs are occluding any app windows. // It notifies the host of any app window whose occlusion state changes. Most // code should not need to use this; it's an implementation detail. -class AURA_EXPORT NativeWindowOcclusionTrackerWin : public WindowObserver { +class AURA_EXPORT NativeWindowOcclusionTrackerWin + : public WindowObserver, + public ui::PowerSettingChangeListener { public: static NativeWindowOcclusionTrackerWin* GetOrCreateInstance(); @@ -67,7 +72,8 @@ class AURA_EXPORT NativeWindowOcclusionTrackerWin : public WindowObserver { class WindowOcclusionCalculator { public: using UpdateOcclusionStateCallback = base::RepeatingCallback<void( - const base::flat_map<HWND, Window::OcclusionState>&)>; + const base::flat_map<HWND, Window::OcclusionState>&, + bool show_all_windows)>; // Creates WindowOcclusionCalculator instance. Must be called on UI thread. static void CreateInstance( @@ -130,6 +136,10 @@ class AURA_EXPORT NativeWindowOcclusionTrackerWin : public WindowObserver { // their occlusion status has changed. void ComputeNativeWindowOcclusionStatus(); + // Computes if virtual desktops are used. This is used as an optimization + // since IsWindowOnCurrentVirtualDesktop is a slow call. + void ComputeVirtualDesktopUsed(); + // Schedules an occlusion calculation |update_occlusion_delay_| time in the // future, if one isn't already scheduled. void ScheduleOcclusionCalculationIfNeeded(); @@ -213,6 +223,9 @@ class AURA_EXPORT NativeWindowOcclusionTrackerWin : public WindowObserver { // Timer to delay occlusion update. base::OneShotTimer occlusion_update_timer_; + // Timer to check how many virtual desktops are present. + base::OneShotTimer virtual_desktop_update_timer_; + // Used to keep track of whether we're in the middle of getting window move // events, in order to wait until the window move is complete before // calculating window occlusion. @@ -231,9 +244,22 @@ class AURA_EXPORT NativeWindowOcclusionTrackerWin : public WindowObserver { // windows from |unoccluded_desktop_region_|. int num_root_windows_with_unknown_occlusion_state_; + // This is true if the task bar thumbnails or the alt tab thumbnails are + // showing. + bool showing_thumbnails_ = false; + + // By caching if virtual desktops are in use or not we can avoid calling + // IsWindowOnCurrentVirtualDesktop which is slow. Start with an initial + // value of true so that we only optimize after we get confirmation that + // there are no virtual desktops. + bool virtual_desktops_used_ = true; + // Only used on Win10+. Microsoft::WRL::ComPtr<IVirtualDesktopManager> virtual_desktop_manager_; + Microsoft::WRL::ComPtr<IVirtualDesktopManagerInternal> + virtual_desktop_manager_internal_; + SEQUENCE_CHECKER(sequence_checker_); base::WeakPtrFactory<WindowOcclusionCalculator> weak_factory_{this}; @@ -250,14 +276,24 @@ class AURA_EXPORT NativeWindowOcclusionTrackerWin : public WindowObserver { // window rectangle in |window_rect|. static bool IsWindowVisibleAndFullyOpaque(HWND hwnd, gfx::Rect* window_rect); - // Updates root windows occclusion state. + // Updates root windows occclusion state. If |show_all_windows| is true, + // all non-hidden windows will be marked visible. This is used to force + // rendering of thumbnails. void UpdateOcclusionState(const base::flat_map<HWND, Window::OcclusionState>& - root_window_hwnds_occlusion_state); + root_window_hwnds_occlusion_state, + bool show_all_windows); // This is called with session changed notifications. If the screen is locked // by the current session, it marks app windows as occluded. void OnSessionChange(WPARAM status_code, const bool* is_current_session); + // This is called when the display is put to sleep. If the display is sleeping + // it marks app windows as occluded. + void OnDisplayStateChanged(bool display_on) override; + + // Marks all root windows as either occluded, or if hwnd IsIconic, hidden. + void MarkNonIconicWindowsOccluded(); + // Task runner to call ComputeNativeWindowOcclusionStatus, and to handle // Windows event notifications, off of the UI thread. const scoped_refptr<base::SequencedTaskRunner> update_occlusion_task_runner_; @@ -273,9 +309,15 @@ class AURA_EXPORT NativeWindowOcclusionTrackerWin : public WindowObserver { // Manages observation of Windows Session Change messages. ui::SessionChangeObserver session_change_observer_; + // Listens for Power Setting Change messages. + ui::ScopedPowerSettingChangeListener power_setting_change_listener_; + // If the screen is locked, windows are considered occluded. bool screen_locked_ = false; + // If the display is off, windows are considered occluded. + bool display_on_ = true; + base::WeakPtrFactory<NativeWindowOcclusionTrackerWin> weak_factory_{this}; DISALLOW_COPY_AND_ASSIGN(NativeWindowOcclusionTrackerWin); diff --git a/chromium/ui/aura/screen_ozone.cc b/chromium/ui/aura/screen_ozone.cc index aa167666369..df496fb5e9d 100644 --- a/chromium/ui/aura/screen_ozone.cc +++ b/chromium/ui/aura/screen_ozone.cc @@ -89,6 +89,14 @@ void ScreenOzone::SetScreenSaverSuspended(bool suspend) { platform_screen_->SetScreenSaverSuspended(suspend); } +bool ScreenOzone::IsScreenSaverActive() const { + return platform_screen_->IsScreenSaverActive(); +} + +base::TimeDelta ScreenOzone::CalculateIdleTime() const { + return platform_screen_->CalculateIdleTime(); +} + void ScreenOzone::AddObserver(display::DisplayObserver* observer) { platform_screen_->AddObserver(observer); } @@ -101,6 +109,11 @@ std::string ScreenOzone::GetCurrentWorkspace() { return platform_screen_->GetCurrentWorkspace(); } +base::Value ScreenOzone::GetGpuExtraInfoAsListValue( + const gfx::GpuExtraInfo& gpu_extra_info) { + return platform_screen_->GetGpuExtraInfoAsListValue(gpu_extra_info); +} + gfx::NativeWindow ScreenOzone::GetNativeWindowFromAcceleratedWidget( gfx::AcceleratedWidget widget) const { return nullptr; diff --git a/chromium/ui/aura/screen_ozone.h b/chromium/ui/aura/screen_ozone.h index cd130694503..f92c14f5667 100644 --- a/chromium/ui/aura/screen_ozone.h +++ b/chromium/ui/aura/screen_ozone.h @@ -42,9 +42,13 @@ class AURA_EXPORT ScreenOzone : public display::Screen { const gfx::Rect& match_rect) const override; display::Display GetPrimaryDisplay() const override; void SetScreenSaverSuspended(bool suspend) override; + bool IsScreenSaverActive() const override; + base::TimeDelta CalculateIdleTime() const override; void AddObserver(display::DisplayObserver* observer) override; void RemoveObserver(display::DisplayObserver* observer) override; std::string GetCurrentWorkspace() override; + base::Value GetGpuExtraInfoAsListValue( + const gfx::GpuExtraInfo& gpu_extra_info) override; // Returns the NativeWindow associated with the AcceleratedWidget. virtual gfx::NativeWindow GetNativeWindowFromAcceleratedWidget( diff --git a/chromium/ui/aura/window.cc b/chromium/ui/aura/window.cc index 3d112662de9..a752e293658 100644 --- a/chromium/ui/aura/window.cc +++ b/chromium/ui/aura/window.cc @@ -11,8 +11,8 @@ #include "base/auto_reset.h" #include "base/bind.h" -#include "base/bind_helpers.h" #include "base/callback.h" +#include "base/callback_helpers.h" #include "base/logging.h" #include "base/macros.h" #include "base/stl_util.h" diff --git a/chromium/ui/aura/window_event_dispatcher.cc b/chromium/ui/aura/window_event_dispatcher.cc index 56e87735fc5..af90753ae70 100644 --- a/chromium/ui/aura/window_event_dispatcher.cc +++ b/chromium/ui/aura/window_event_dispatcher.cc @@ -184,11 +184,10 @@ void WindowEventDispatcher::ProcessedTouchEvent( uint32_t unique_event_id, Window* window, ui::EventResult result, - bool is_source_touch_event_set_non_blocking) { + bool is_source_touch_event_set_blocking) { ui::GestureRecognizer::Gestures gestures = Env::GetInstance()->gesture_recognizer()->AckTouchEvent( - unique_event_id, result, is_source_touch_event_set_non_blocking, - window); + unique_event_id, result, is_source_touch_event_set_blocking, window); DispatchDetails details = ProcessGestures(window, std::move(gestures)); if (details.dispatcher_destroyed) return; @@ -575,7 +574,7 @@ ui::EventDispatchDetails WindowEventDispatcher::PostDispatchEvent( ui::GestureRecognizer::Gestures gestures = Env::GetInstance()->gesture_recognizer()->AckTouchEvent( touchevent.unique_event_id(), event.result(), - false /* is_source_touch_event_set_non_blocking */, window); + false /* is_source_touch_event_set_blocking */, window); return ProcessGestures(window, std::move(gestures)); } diff --git a/chromium/ui/aura/window_event_dispatcher.h b/chromium/ui/aura/window_event_dispatcher.h index 5435ce7b7f3..573cec8f5ca 100644 --- a/chromium/ui/aura/window_event_dispatcher.h +++ b/chromium/ui/aura/window_event_dispatcher.h @@ -106,7 +106,7 @@ class AURA_EXPORT WindowEventDispatcher : public ui::EventProcessor, virtual void ProcessedTouchEvent(uint32_t unique_event_id, Window* window, ui::EventResult result, - bool is_source_touch_event_set_non_blocking); + bool is_source_touch_event_set_blocking); // These methods are used to defer the processing of mouse/touch events // related to resize. A client (typically a RenderWidgetHostViewAura) can call diff --git a/chromium/ui/aura/window_event_dispatcher_unittest.cc b/chromium/ui/aura/window_event_dispatcher_unittest.cc index 37cc19b9d2c..35fd78d0632 100644 --- a/chromium/ui/aura/window_event_dispatcher_unittest.cc +++ b/chromium/ui/aura/window_event_dispatcher_unittest.cc @@ -14,7 +14,7 @@ #include "base/run_loop.h" #include "base/single_thread_task_runner.h" #include "base/stl_util.h" -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "base/test/metrics/histogram_tester.h" #include "base/threading/thread_task_runner_handle.h" #include "build/build_config.h" @@ -1009,7 +1009,7 @@ TEST_F(WindowEventDispatcherTest, CallToProcessedTouchEvent) { host()->dispatcher()->ProcessedTouchEvent( 0, window.get(), ui::ER_UNHANDLED, - false /* is_source_touch_event_set_non_blocking */); + false /* is_source_touch_event_set_blocking */); } // This event handler requests the dispatcher to start holding pointer-move @@ -2873,7 +2873,7 @@ class AsyncWindowDelegate : public test::TestWindowDelegate { event->DisableSynchronousHandling(); dispatcher_->ProcessedTouchEvent( event->unique_event_id(), window_, ui::ER_UNHANDLED, - false /* is_source_touch_event_set_non_blocking */); + false /* is_source_touch_event_set_blocking */); event->StopPropagation(); } diff --git a/chromium/ui/aura/window_occlusion_tracker_unittest.cc b/chromium/ui/aura/window_occlusion_tracker_unittest.cc index 31ba4e71245..a8ecbcf2a62 100644 --- a/chromium/ui/aura/window_occlusion_tracker_unittest.cc +++ b/chromium/ui/aura/window_occlusion_tracker_unittest.cc @@ -4,10 +4,10 @@ #include "ui/aura/window_occlusion_tracker.h" -#include "base/bind_helpers.h" +#include "base/callback_helpers.h" #include "base/macros.h" #include "base/run_loop.h" -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "base/test/gtest_util.h" #include "base/test/scoped_feature_list.h" #include "build/build_config.h" diff --git a/chromium/ui/aura/window_unittest.cc b/chromium/ui/aura/window_unittest.cc index 54265f64c98..6bf4c71aff6 100644 --- a/chromium/ui/aura/window_unittest.cc +++ b/chromium/ui/aura/window_unittest.cc @@ -15,7 +15,7 @@ #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" -#include "base/test/bind_test_util.h" +#include "base/test/bind.h" #include "build/build_config.h" #include "cc/trees/layer_tree_frame_sink.h" #include "testing/gtest/include/gtest/gtest.h" |