#include "ui/aura/window_tree_host.h"
#include <optional>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/scoped_refptr.h"
#include "base/metrics/field_trial_params.h"
#include "base/no_destructor.h"
#include "base/observer_list.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/viz/common/features.h"
#include "components/viz/common/surfaces/frame_sink_id.h"
#include "components/viz/host/host_frame_sink_manager.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/env.h"
#include "ui/aura/host_frame_rate_throttler.h"
#include "ui/aura/native_window_occlusion_tracker.h"
#include "ui/aura/scoped_keyboard_hook.h"
#include "ui/aura/scoped_simple_keyboard_hook.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_targeter.h"
#include "ui/aura/window_tree_host_observer.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/ime/init/input_method_factory.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/view_prop.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/compositor_switches.h"
#include "ui/compositor/layer.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point3_f.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/icc_profile.h"
#include "ui/gfx/switches.h"
#include "ui/platform_window/platform_window_init_properties.h"
#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif
namespace aura {
namespace {
const char kWindowTreeHostForAcceleratedWidget[] = …;
#if DCHECK_IS_ON()
class ScopedLocalSurfaceIdValidator { … };
#else
class ScopedLocalSurfaceIdValidator {
public:
explicit ScopedLocalSurfaceIdValidator(Window* window) {}
~ScopedLocalSurfaceIdValidator() {}
};
#endif
}
WindowTreeHost::VideoCaptureLock::~VideoCaptureLock() { … }
WindowTreeHost::VideoCaptureLock::VideoCaptureLock(WindowTreeHost* host)
: … { … }
const char WindowTreeHost::kWindowTreeHostUsesParent[] = …;
WindowTreeHost::~WindowTreeHost() { … }
WindowTreeHost* WindowTreeHost::GetForAcceleratedWidget(
gfx::AcceleratedWidget widget) { … }
void WindowTreeHost::InitHost() { … }
void WindowTreeHost::AddObserver(WindowTreeHostObserver* observer) { … }
void WindowTreeHost::RemoveObserver(WindowTreeHostObserver* observer) { … }
bool WindowTreeHost::HasObserver(const WindowTreeHostObserver* observer) const { … }
base::WeakPtr<WindowTreeHost> WindowTreeHost::GetWeakPtr() { … }
gfx::Transform WindowTreeHost::GetRootTransform() const { … }
void WindowTreeHost::SetRootTransform(const gfx::Transform& transform) { … }
gfx::Transform WindowTreeHost::GetInverseRootTransform() const { … }
void WindowTreeHost::SetDisplayTransformHint(gfx::OverlayTransform transform) { … }
gfx::Transform WindowTreeHost::GetRootTransformForLocalEventCoordinates()
const { … }
gfx::Transform WindowTreeHost::GetInverseRootTransformForLocalEventCoordinates()
const { … }
void WindowTreeHost::UpdateCompositorScaleAndSize(
const gfx::Size& new_size_in_pixels) { … }
void WindowTreeHost::ConvertDIPToScreenInPixels(gfx::Point* point) const { … }
void WindowTreeHost::ConvertScreenInPixelsToDIP(gfx::Point* point) const { … }
void WindowTreeHost::ConvertDIPToPixels(gfx::Point* point) const { … }
void WindowTreeHost::ConvertDIPToPixels(gfx::PointF* point) const { … }
void WindowTreeHost::ConvertPixelsToDIP(gfx::Point* point) const { … }
void WindowTreeHost::ConvertPixelsToDIP(gfx::PointF* point) const { … }
void WindowTreeHost::SetCursor(gfx::NativeCursor cursor) { … }
void WindowTreeHost::OnCursorVisibilityChanged(bool show) { … }
void WindowTreeHost::MoveCursorToLocationInDIP(
const gfx::Point& location_in_dip) { … }
void WindowTreeHost::MoveCursorToLocationInPixels(
const gfx::Point& location_in_pixels) { … }
ui::InputMethod* WindowTreeHost::GetInputMethod() { … }
void WindowTreeHost::SetSharedInputMethod(ui::InputMethod* input_method) { … }
ui::EventDispatchDetails WindowTreeHost::DispatchKeyEventPostIME(
ui::KeyEvent* event) { … }
ui::EventSink* WindowTreeHost::GetEventSink() { … }
int64_t WindowTreeHost::GetDisplayId() { … }
void WindowTreeHost::Show() { … }
void WindowTreeHost::Hide() { … }
gfx::Rect WindowTreeHost::GetBoundsInDIP() const { … }
gfx::Rect WindowTreeHost::GetBoundsInAcceleratedWidgetPixelCoordinates() { … }
std::unique_ptr<ScopedKeyboardHook> WindowTreeHost::CaptureSystemKeyEvents(
std::optional<base::flat_set<ui::DomCode>> dom_codes) { … }
bool WindowTreeHost::ShouldSendKeyEventToIme() { … }
bool WindowTreeHost::IsNativeWindowOcclusionEnabled() const { … }
void WindowTreeHost::SetNativeWindowOcclusionState(
Window::OcclusionState raw_occlusion_state,
const SkRegion& raw_occluded_region) { … }
void WindowTreeHost::UpdateRootWindowSize() { … }
gfx::Rect WindowTreeHost::CalculateRootWindowBounds() const { … }
std::unique_ptr<ScopedEnableUnadjustedMouseEvents>
WindowTreeHost::RequestUnadjustedMovement() { … }
bool WindowTreeHost::SupportsMouseLock() { … }
void WindowTreeHost::LockMouse(Window* window) { … }
void WindowTreeHost::UnlockMouse(Window* window) { … }
std::unique_ptr<WindowTreeHost::VideoCaptureLock>
WindowTreeHost::CreateVideoCaptureLock() { … }
WindowTreeHost::WindowTreeHost(std::unique_ptr<Window> window)
: … { … }
void WindowTreeHost::UpdateCompositorVisibility(bool visible) { … }
void WindowTreeHost::DestroyCompositor() { … }
void WindowTreeHost::DestroyDispatcher() { … }
void WindowTreeHost::OnAcceleratedWidgetMadeVisible(bool value) { … }
void WindowTreeHost::CreateCompositor(bool force_software_compositor,
bool use_external_begin_frame_control,
bool enable_compositing_based_throttling,
size_t memory_limit_when_visible_mb) { … }
void WindowTreeHost::InitCompositor() { … }
void WindowTreeHost::OnAcceleratedWidgetAvailable() { … }
void WindowTreeHost::OnHostMovedInPixels() { … }
void WindowTreeHost::OnHostResizedInPixels(
const gfx::Size& new_size_in_pixels) { … }
void WindowTreeHost::OnHostWorkspaceChanged() { … }
void WindowTreeHost::OnHostDisplayChanged() { … }
void WindowTreeHost::OnHostCloseRequested() { … }
void WindowTreeHost::OnHostLostWindowCapture() { … }
void WindowTreeHost::OnDisplayMetricsChanged(const display::Display& display,
uint32_t metrics) { … }
gfx::Rect WindowTreeHost::GetTransformedRootWindowBoundsFromPixelSize(
const gfx::Size& size_in_pixels) const { … }
void WindowTreeHost::SetNativeWindowOcclusionEnabled(bool enable) { … }
void WindowTreeHost::DecrementVideoCaptureCount() { … }
void WindowTreeHost::MaybeUpdateComposibleVisibilityForVideoLockCountChange() { … }
void WindowTreeHost::MaybeUpdateCompositorVisibilityForNativeOcclusion() { … }
bool WindowTreeHost::CalculateCompositorVisibilityFromOcclusionState() const { … }
bool WindowTreeHost::NativeOcclusionAffectsThrottle() const { … }
bool WindowTreeHost::NativeOcclusionAffectsVisibility() const { … }
bool WindowTreeHost::ShouldThrottle() const { … }
const base::flat_set<raw_ptr<WindowTreeHost, CtnExperimental>>&
WindowTreeHost::GetThrottledHostsForTesting() { … }
void WindowTreeHost::MoveCursorToInternal(const gfx::Point& root_location,
const gfx::Point& host_location) { … }
void WindowTreeHost::OnCompositingAckDeprecated(ui::Compositor* compositor) { … }
void WindowTreeHost::OnCompositingChildResizing(ui::Compositor* compositor) { … }
void WindowTreeHost::OnFrameSinksToThrottleUpdated(
const base::flat_set<viz::FrameSinkId>& ids) { … }
void WindowTreeHost::OnSetPreferredRefreshRate(ui::Compositor*,
float preferred_refresh_rate) { … }
}