chromium/ui/views/widget/desktop_aura/desktop_native_widget_aura.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"

#include <memory>
#include <string_view>
#include <utility>

#include "base/auto_reset.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/client/drag_drop_delegate.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/client/window_parenting_client.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_occlusion_tracker.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/class_property.h"
#include "ui/base/data_transfer_policy/data_transfer_endpoint.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/hit_test.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/owned_window_anchor.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/ui_base_types.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
#include "ui/display/screen.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/views/corewm/tooltip.h"
#include "ui/views/corewm/tooltip_controller.h"
#include "ui/views/drag_utils.h"
#include "ui/views/view_constants_aura.h"
#include "ui/views/views_delegate.h"
#include "ui/views/widget/desktop_aura/desktop_capture_client.h"
#include "ui/views/widget/desktop_aura/desktop_event_client.h"
#include "ui/views/widget/desktop_aura/desktop_focus_rules.h"
#include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
#include "ui/views/widget/desktop_aura/desktop_screen_position_client.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h"
#include "ui/views/widget/focus_manager_event_handler.h"
#include "ui/views/widget/native_widget_aura.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/tooltip_manager_aura.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_aura_utils.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/widget/window_reorderer.h"
#include "ui/wm/core/compound_event_filter.h"
#include "ui/wm/core/cursor_manager.h"
#include "ui/wm/core/focus_controller.h"
#include "ui/wm/core/native_cursor_manager.h"
#include "ui/wm/core/shadow_controller.h"
#include "ui/wm/core/shadow_controller_delegate.h"
#include "ui/wm/core/shadow_types.h"
#include "ui/wm/core/visibility_controller.h"
#include "ui/wm/core/window_animations.h"
#include "ui/wm/core/window_modality_controller.h"
#include "ui/wm/core/window_util.h"
#include "ui/wm/public/activation_client.h"

#if BUILDFLAG(IS_WIN)
#include "ui/base/win/shell.h"
#include "ui/views/widget/desktop_aura/desktop_native_cursor_manager_win.h"
#endif

DEFINE_EXPORTED_UI_CLASS_PROPERTY_TYPE()

namespace views {

DEFINE_UI_CLASS_PROPERTY_KEY()

namespace {

// This class provides functionality to create a top level widget to host a
// child window.
class DesktopNativeWidgetTopLevelHandler : public aura::WindowObserver {};

class DesktopNativeWidgetAuraWindowParentingClient
    : public aura::client::WindowParentingClient {};

}  // namespace

class RootWindowDestructionObserver : public aura::WindowObserver {};

////////////////////////////////////////////////////////////////////////////////
// DesktopNativeWidgetAura, public:

int DesktopNativeWidgetAura::cursor_reference_count_ =;
DesktopNativeCursorManager* DesktopNativeWidgetAura::native_cursor_manager_ =;
wm::CursorManager* DesktopNativeWidgetAura::cursor_manager_ =;

DesktopNativeWidgetAura::DesktopNativeWidgetAura(
    internal::NativeWidgetDelegate* delegate)
    :{}

DesktopNativeWidgetAura::~DesktopNativeWidgetAura() {}

// static
DesktopNativeWidgetAura* DesktopNativeWidgetAura::ForWindow(
    aura::Window* window) {}

void DesktopNativeWidgetAura::OnHostClosed() {}

void DesktopNativeWidgetAura::OnDesktopWindowTreeHostDestroyed(
    aura::WindowTreeHost* host) {}

base::WeakPtr<internal::NativeWidgetPrivate>
DesktopNativeWidgetAura::GetWeakPtr() {}

void DesktopNativeWidgetAura::NotifyAccessibilityEvent(
    ax::mojom::Event event_type) {}

views::corewm::TooltipController*
DesktopNativeWidgetAura::tooltip_controller() {}

void DesktopNativeWidgetAura::HandleActivationChanged(bool active) {}

void DesktopNativeWidgetAura::OnHostWillClose() {}

gfx::NativeWindow DesktopNativeWidgetAura::GetNativeWindow() const {}

void DesktopNativeWidgetAura::UpdateWindowTransparency() {}

////////////////////////////////////////////////////////////////////////////////
// DesktopNativeWidgetAura, internal::NativeWidgetPrivate implementation:
void DesktopNativeWidgetAura::InitNativeWidget(Widget::InitParams params) {}

void DesktopNativeWidgetAura::OnWidgetInitDone() {}

void DesktopNativeWidgetAura::ReparentNativeViewImpl(
    gfx::NativeView new_parent) {}

std::unique_ptr<NonClientFrameView>
DesktopNativeWidgetAura::CreateNonClientFrameView() {}

bool DesktopNativeWidgetAura::ShouldUseNativeFrame() const {}

bool DesktopNativeWidgetAura::ShouldWindowContentsBeTransparent() const {}

void DesktopNativeWidgetAura::FrameTypeChanged() {}

Widget* DesktopNativeWidgetAura::GetWidget() {}

const Widget* DesktopNativeWidgetAura::GetWidget() const {}

gfx::NativeView DesktopNativeWidgetAura::GetNativeView() const {}

Widget* DesktopNativeWidgetAura::GetTopLevelWidget() {}

const ui::Compositor* DesktopNativeWidgetAura::GetCompositor() const {}

const ui::Layer* DesktopNativeWidgetAura::GetLayer() const {}

void DesktopNativeWidgetAura::ReorderNativeViews() {}

void DesktopNativeWidgetAura::ViewRemoved(View* view) {}

void DesktopNativeWidgetAura::SetNativeWindowProperty(const char* name,
                                                      void* value) {}

void* DesktopNativeWidgetAura::GetNativeWindowProperty(const char* name) const {}

TooltipManager* DesktopNativeWidgetAura::GetTooltipManager() const {}

void DesktopNativeWidgetAura::SetCapture() {}

void DesktopNativeWidgetAura::ReleaseCapture() {}

bool DesktopNativeWidgetAura::HasCapture() const {}

ui::InputMethod* DesktopNativeWidgetAura::GetInputMethod() {}

void DesktopNativeWidgetAura::CenterWindow(const gfx::Size& size) {}

void DesktopNativeWidgetAura::GetWindowPlacement(
    gfx::Rect* bounds,
    ui::WindowShowState* maximized) const {}

bool DesktopNativeWidgetAura::SetWindowTitle(const std::u16string& title) {}

void DesktopNativeWidgetAura::SetWindowIcons(const gfx::ImageSkia& window_icon,
                                             const gfx::ImageSkia& app_icon) {}

const gfx::ImageSkia* DesktopNativeWidgetAura::GetWindowIcon() {}

const gfx::ImageSkia* DesktopNativeWidgetAura::GetWindowAppIcon() {}

void DesktopNativeWidgetAura::InitModalType(ui::mojom::ModalType modal_type) {}

gfx::Rect DesktopNativeWidgetAura::GetWindowBoundsInScreen() const {}

gfx::Rect DesktopNativeWidgetAura::GetClientAreaBoundsInScreen() const {}

gfx::Rect DesktopNativeWidgetAura::GetRestoredBounds() const {}

std::string DesktopNativeWidgetAura::GetWorkspace() const {}

void DesktopNativeWidgetAura::SetBounds(const gfx::Rect& bounds) {}

void DesktopNativeWidgetAura::SetBoundsConstrained(const gfx::Rect& bounds) {}

void DesktopNativeWidgetAura::SetSize(const gfx::Size& size) {}

void DesktopNativeWidgetAura::StackAbove(gfx::NativeView native_view) {}

void DesktopNativeWidgetAura::StackAtTop() {}

bool DesktopNativeWidgetAura::IsStackedAbove(gfx::NativeView native_view) {}

void DesktopNativeWidgetAura::SetShape(
    std::unique_ptr<Widget::ShapeRects> shape) {}

void DesktopNativeWidgetAura::Close() {}

void DesktopNativeWidgetAura::CloseNow() {}

void DesktopNativeWidgetAura::Show(ui::WindowShowState show_state,
                                   const gfx::Rect& restore_bounds) {}

void DesktopNativeWidgetAura::Hide() {}

bool DesktopNativeWidgetAura::IsVisible() const {}

void DesktopNativeWidgetAura::Activate() {}

void DesktopNativeWidgetAura::Deactivate() {}

bool DesktopNativeWidgetAura::IsActive() const {}

void DesktopNativeWidgetAura::PaintAsActiveChanged() {}

void DesktopNativeWidgetAura::SetZOrderLevel(ui::ZOrderLevel order) {}

ui::ZOrderLevel DesktopNativeWidgetAura::GetZOrderLevel() const {}

void DesktopNativeWidgetAura::SetVisibleOnAllWorkspaces(bool always_visible) {}

bool DesktopNativeWidgetAura::IsVisibleOnAllWorkspaces() const {}

void DesktopNativeWidgetAura::Maximize() {}

void DesktopNativeWidgetAura::Minimize() {}

bool DesktopNativeWidgetAura::IsMaximized() const {}

bool DesktopNativeWidgetAura::IsMinimized() const {}

void DesktopNativeWidgetAura::Restore() {}

void DesktopNativeWidgetAura::SetFullscreen(bool fullscreen,
                                            int64_t target_display_id) {}

bool DesktopNativeWidgetAura::IsFullscreen() const {}

void DesktopNativeWidgetAura::SetCanAppearInExistingFullscreenSpaces(
    bool can_appear_in_existing_fullscreen_spaces) {}

void DesktopNativeWidgetAura::SetOpacity(float opacity) {}

void DesktopNativeWidgetAura::SetAspectRatio(const gfx::SizeF& aspect_ratio,
                                             const gfx::Size& excluded_margin) {}

void DesktopNativeWidgetAura::FlashFrame(bool flash_frame) {}

void DesktopNativeWidgetAura::RunShellDrag(
    std::unique_ptr<ui::OSExchangeData> data,
    const gfx::Point& location,
    int operation,
    ui::mojom::DragEventSource source) {}

void DesktopNativeWidgetAura::CancelShellDrag(View* view) {}

void DesktopNativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) {}

void DesktopNativeWidgetAura::ScheduleLayout() {}

void DesktopNativeWidgetAura::SetCursor(const ui::Cursor& cursor) {}

bool DesktopNativeWidgetAura::IsMouseEventsEnabled() const {}

bool DesktopNativeWidgetAura::IsMouseButtonDown() const {}

void DesktopNativeWidgetAura::ClearNativeFocus() {}

gfx::Rect DesktopNativeWidgetAura::GetWorkAreaBoundsInScreen() const {}

bool DesktopNativeWidgetAura::IsMoveLoopSupported() const {}

Widget::MoveLoopResult DesktopNativeWidgetAura::RunMoveLoop(
    const gfx::Vector2d& drag_offset,
    Widget::MoveLoopSource source,
    Widget::MoveLoopEscapeBehavior escape_behavior) {}

void DesktopNativeWidgetAura::EndMoveLoop() {}

void DesktopNativeWidgetAura::SetVisibilityChangedAnimationsEnabled(
    bool value) {}

void DesktopNativeWidgetAura::SetVisibilityAnimationDuration(
    const base::TimeDelta& duration) {}

void DesktopNativeWidgetAura::SetVisibilityAnimationTransition(
    Widget::VisibilityTransition transition) {}

ui::GestureRecognizer* DesktopNativeWidgetAura::GetGestureRecognizer() {}

ui::GestureConsumer* DesktopNativeWidgetAura::GetGestureConsumer() {}

void DesktopNativeWidgetAura::OnSizeConstraintsChanged() {}

void DesktopNativeWidgetAura::OnNativeViewHierarchyWillChange() {}

void DesktopNativeWidgetAura::OnNativeViewHierarchyChanged() {}

bool DesktopNativeWidgetAura::SetAllowScreenshots(bool allow) {}

bool DesktopNativeWidgetAura::AreScreenshotsAllowed() {}

std::string DesktopNativeWidgetAura::GetName() const {}

////////////////////////////////////////////////////////////////////////////////
// DesktopNativeWidgetAura, aura::WindowDelegate implementation:

gfx::Size DesktopNativeWidgetAura::GetMinimumSize() const {}

gfx::Size DesktopNativeWidgetAura::GetMaximumSize() const {}

gfx::NativeCursor DesktopNativeWidgetAura::GetCursor(const gfx::Point& point) {}

int DesktopNativeWidgetAura::GetNonClientComponent(
    const gfx::Point& point) const {}

bool DesktopNativeWidgetAura::ShouldDescendIntoChildForEventHandling(
    aura::Window* child,
    const gfx::Point& location) {}

bool DesktopNativeWidgetAura::CanFocus() {}

void DesktopNativeWidgetAura::OnCaptureLost() {}

void DesktopNativeWidgetAura::OnPaint(const ui::PaintContext& context) {}

void DesktopNativeWidgetAura::OnDeviceScaleFactorChanged(
    float old_device_scale_factor,
    float new_device_scale_factor) {}

void DesktopNativeWidgetAura::OnWindowDestroying(aura::Window* window) {}

void DesktopNativeWidgetAura::OnWindowDestroyed(aura::Window* window) {}

void DesktopNativeWidgetAura::OnWindowTargetVisibilityChanged(bool visible) {}

bool DesktopNativeWidgetAura::HasHitTestMask() const {}

void DesktopNativeWidgetAura::GetHitTestMask(SkPath* mask) const {}

void DesktopNativeWidgetAura::UpdateVisualState() {}

////////////////////////////////////////////////////////////////////////////////
// DesktopNativeWidgetAura, ui::EventHandler implementation:

void DesktopNativeWidgetAura::OnKeyEvent(ui::KeyEvent* event) {}

void DesktopNativeWidgetAura::OnMouseEvent(ui::MouseEvent* event) {}

void DesktopNativeWidgetAura::OnScrollEvent(ui::ScrollEvent* event) {}

void DesktopNativeWidgetAura::OnGestureEvent(ui::GestureEvent* event) {}

std::string_view DesktopNativeWidgetAura::GetLogContext() const {}

////////////////////////////////////////////////////////////////////////////////
// DesktopNativeWidgetAura, wm::ActivationDelegate implementation:

bool DesktopNativeWidgetAura::ShouldActivate() const {}

////////////////////////////////////////////////////////////////////////////////
// DesktopNativeWidgetAura, wm::ActivationChangeObserver implementation:

void DesktopNativeWidgetAura::OnWindowActivated(
    wm::ActivationChangeObserver::ActivationReason reason,
    aura::Window* gained_active,
    aura::Window* lost_active) {}

////////////////////////////////////////////////////////////////////////////////
// DesktopNativeWidgetAura, aura::client::FocusChangeObserver implementation:

void DesktopNativeWidgetAura::OnWindowFocused(aura::Window* gained_focus,
                                              aura::Window* lost_focus) {}

////////////////////////////////////////////////////////////////////////////////
// DesktopNativeWidgetAura, aura::WindowDragDropDelegate implementation:

void DesktopNativeWidgetAura::OnDragEntered(const ui::DropTargetEvent& event) {}

aura::client::DragUpdateInfo DesktopNativeWidgetAura::OnDragUpdated(
    const ui::DropTargetEvent& event) {}

void DesktopNativeWidgetAura::OnDragExited() {}

aura::client::DragDropDelegate::DropCallback
DesktopNativeWidgetAura::GetDropCallback(const ui::DropTargetEvent& event) {}

////////////////////////////////////////////////////////////////////////////////
// DesktopNativeWidgetAura, aura::WindowTreeHostObserver implementation:

void DesktopNativeWidgetAura::OnHostCloseRequested(aura::WindowTreeHost* host) {}

void DesktopNativeWidgetAura::OnHostResized(aura::WindowTreeHost* host) {}

void DesktopNativeWidgetAura::OnHostWorkspaceChanged(
    aura::WindowTreeHost* host) {}

void DesktopNativeWidgetAura::OnHostMovedInPixels(aura::WindowTreeHost* host) {}

////////////////////////////////////////////////////////////////////////////////
// DesktopNativeWidgetAura, private:

void DesktopNativeWidgetAura::RootWindowDestroyed() {}

void DesktopNativeWidgetAura::PerformDrop(
    views::DropHelper::DropCallback drop_cb,
    std::unique_ptr<ui::OSExchangeData> data,
    ui::mojom::DragOperation& output_drag_op,
    std::unique_ptr<ui::LayerTreeOwner> drag_image_layer_owner) {}

}  // namespace views