#include "ui/views/widget/native_widget_aura.h"
#include <memory>
#include <optional>
#include <utility>
#include <vector>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/task/single_thread_task_runner.h"
#include "base/uuid.h"
#include "build/build_config.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/capture_client.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/screen_position_client.h"
#include "ui/aura/client/window_parenting_client.h"
#include "ui/aura/client/window_types.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_observer.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/os_exchange_data.h"
#include "ui/base/mojom/ui_base_types.mojom-shared.h"
#include "ui/base/ui_base_types.h"
#include "ui/compositor/layer.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
#include "ui/gfx/canvas.h"
#include "ui/native_theme/native_theme_aura.h"
#include "ui/views/buildflags.h"
#include "ui/views/drag_utils.h"
#include "ui/views/views_delegate.h"
#include "ui/views/views_features.h"
#include "ui/views/widget/drop_helper.h"
#include "ui/views/widget/focus_manager_event_handler.h"
#include "ui/views/widget/native_widget_delegate.h"
#include "ui/views/widget/root_view.h"
#include "ui/views/widget/tooltip_manager_aura.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/coordinate_conversion.h"
#include "ui/wm/core/scoped_animation_disabler.h"
#include "ui/wm/core/shadow_types.h"
#include "ui/wm/core/transient_window_manager.h"
#include "ui/wm/core/window_animations.h"
#include "ui/wm/core/window_properties.h"
#include "ui/wm/core/window_util.h"
#include "ui/wm/public/activation_client.h"
#include "ui/wm/public/window_move_client.h"
#if BUILDFLAG(ENABLE_DESKTOP_AURA)
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host.h"
#endif
#if BUILDFLAG(ENABLE_DESKTOP_AURA) && BUILDFLAG(IS_OZONE)
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h"
#endif
#if BUILDFLAG(IS_WIN)
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
#endif
DEFINE_UI_CLASS_PROPERTY_TYPE(…)
namespace views {
namespace {
DEFINE_UI_CLASS_PROPERTY_KEY(…)
void SetRestoreBounds(aura::Window* window, const gfx::Rect& bounds) { … }
void SetIcon(aura::Window* window,
const aura::WindowProperty<gfx::ImageSkia*>* key,
const gfx::ImageSkia& value) { … }
bool FindLayersInOrder(
const std::vector<raw_ptr<ui::Layer, VectorExperimental>>& children,
const ui::Layer** first,
const ui::Layer** second) { … }
void ReparentAuraWindow(aura::Window* window, aura::Window* parent) { … }
}
NativeWidgetAura::NativeWidgetAura(internal::NativeWidgetDelegate* delegate)
: … { … }
void NativeWidgetAura::RegisterNativeWidgetForWindow(
internal::NativeWidgetPrivate* native_widget,
aura::Window* window) { … }
void NativeWidgetAura::AssignIconToAuraWindow(aura::Window* window,
const gfx::ImageSkia& window_icon,
const gfx::ImageSkia& app_icon) { … }
void NativeWidgetAura::SetShadowElevationFromInitParams(
aura::Window* window,
const Widget::InitParams& params) { … }
void NativeWidgetAura::SetResizeBehaviorFromDelegate(WidgetDelegate* delegate,
aura::Window* window) { … }
void NativeWidgetAura::InitNativeWidget(Widget::InitParams params) { … }
void NativeWidgetAura::OnWidgetInitDone() { … }
void NativeWidgetAura::ReparentNativeViewImpl(gfx::NativeView new_parent) { … }
std::unique_ptr<NonClientFrameView>
NativeWidgetAura::CreateNonClientFrameView() { … }
bool NativeWidgetAura::ShouldUseNativeFrame() const { … }
bool NativeWidgetAura::ShouldWindowContentsBeTransparent() const { … }
void NativeWidgetAura::FrameTypeChanged() { … }
Widget* NativeWidgetAura::GetWidget() { … }
const Widget* NativeWidgetAura::GetWidget() const { … }
gfx::NativeView NativeWidgetAura::GetNativeView() const { … }
gfx::NativeWindow NativeWidgetAura::GetNativeWindow() const { … }
Widget* NativeWidgetAura::GetTopLevelWidget() { … }
const ui::Compositor* NativeWidgetAura::GetCompositor() const { … }
const ui::Layer* NativeWidgetAura::GetLayer() const { … }
void NativeWidgetAura::ReorderNativeViews() { … }
void NativeWidgetAura::ViewRemoved(View* view) { … }
void NativeWidgetAura::SetNativeWindowProperty(const char* name, void* value) { … }
void* NativeWidgetAura::GetNativeWindowProperty(const char* name) const { … }
TooltipManager* NativeWidgetAura::GetTooltipManager() const { … }
void NativeWidgetAura::SetCapture() { … }
void NativeWidgetAura::ReleaseCapture() { … }
bool NativeWidgetAura::HasCapture() const { … }
ui::InputMethod* NativeWidgetAura::GetInputMethod() { … }
void NativeWidgetAura::CenterWindow(const gfx::Size& size) { … }
void NativeWidgetAura::GetWindowPlacement(
gfx::Rect* bounds,
ui::WindowShowState* show_state) const { … }
bool NativeWidgetAura::SetWindowTitle(const std::u16string& title) { … }
void NativeWidgetAura::SetWindowIcons(const gfx::ImageSkia& window_icon,
const gfx::ImageSkia& app_icon) { … }
const gfx::ImageSkia* NativeWidgetAura::GetWindowIcon() { … }
const gfx::ImageSkia* NativeWidgetAura::GetWindowAppIcon() { … }
void NativeWidgetAura::InitModalType(ui::mojom::ModalType modal_type) { … }
gfx::Rect NativeWidgetAura::GetWindowBoundsInScreen() const { … }
gfx::Rect NativeWidgetAura::GetClientAreaBoundsInScreen() const { … }
gfx::Rect NativeWidgetAura::GetRestoredBounds() const { … }
std::string NativeWidgetAura::GetWorkspace() const { … }
void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) { … }
void NativeWidgetAura::SetBoundsInternal(const gfx::Rect& bounds,
std::optional<int64_t> display_id) { … }
void NativeWidgetAura::SetBoundsConstrained(const gfx::Rect& bounds) { … }
void NativeWidgetAura::SetSize(const gfx::Size& size) { … }
void NativeWidgetAura::StackAbove(gfx::NativeView native_view) { … }
void NativeWidgetAura::StackAtTop() { … }
bool NativeWidgetAura::IsStackedAbove(gfx::NativeView native_view) { … }
void NativeWidgetAura::SetShape(std::unique_ptr<Widget::ShapeRects> shape) { … }
void NativeWidgetAura::Close() { … }
void NativeWidgetAura::CloseNow() { … }
void NativeWidgetAura::Show(ui::WindowShowState show_state,
const gfx::Rect& restore_bounds) { … }
void NativeWidgetAura::Hide() { … }
bool NativeWidgetAura::IsVisible() const { … }
void NativeWidgetAura::Activate() { … }
void NativeWidgetAura::Deactivate() { … }
bool NativeWidgetAura::IsActive() const { … }
void NativeWidgetAura::SetZOrderLevel(ui::ZOrderLevel order) { … }
ui::ZOrderLevel NativeWidgetAura::GetZOrderLevel() const { … }
void NativeWidgetAura::SetVisibleOnAllWorkspaces(bool always_visible) { … }
bool NativeWidgetAura::IsVisibleOnAllWorkspaces() const { … }
void NativeWidgetAura::Maximize() { … }
void NativeWidgetAura::Minimize() { … }
bool NativeWidgetAura::IsMaximized() const { … }
bool NativeWidgetAura::IsMinimized() const { … }
void NativeWidgetAura::Restore() { … }
void NativeWidgetAura::SetFullscreen(bool fullscreen,
int64_t target_display_id) { … }
bool NativeWidgetAura::IsFullscreen() const { … }
void NativeWidgetAura::SetCanAppearInExistingFullscreenSpaces(
bool can_appear_in_existing_fullscreen_spaces) { … }
void NativeWidgetAura::SetOpacity(float opacity) { … }
void NativeWidgetAura::SetAspectRatio(const gfx::SizeF& aspect_ratio,
const gfx::Size& excluded_margin) { … }
void NativeWidgetAura::FlashFrame(bool flash) { … }
void NativeWidgetAura::RunShellDrag(std::unique_ptr<ui::OSExchangeData> data,
const gfx::Point& location,
int operation,
ui::mojom::DragEventSource source) { … }
void NativeWidgetAura::CancelShellDrag(View* view) { … }
void NativeWidgetAura::SchedulePaintInRect(const gfx::Rect& rect) { … }
void NativeWidgetAura::ScheduleLayout() { … }
void NativeWidgetAura::SetCursor(const ui::Cursor& cursor) { … }
bool NativeWidgetAura::IsMouseEventsEnabled() const { … }
bool NativeWidgetAura::IsMouseButtonDown() const { … }
void NativeWidgetAura::ClearNativeFocus() { … }
gfx::Rect NativeWidgetAura::GetWorkAreaBoundsInScreen() const { … }
Widget::MoveLoopResult NativeWidgetAura::RunMoveLoop(
const gfx::Vector2d& drag_offset,
Widget::MoveLoopSource source,
Widget::MoveLoopEscapeBehavior escape_behavior) { … }
void NativeWidgetAura::EndMoveLoop() { … }
void NativeWidgetAura::SetVisibilityChangedAnimationsEnabled(bool value) { … }
void NativeWidgetAura::SetVisibilityAnimationDuration(
const base::TimeDelta& duration) { … }
void NativeWidgetAura::SetVisibilityAnimationTransition(
Widget::VisibilityTransition transition) { … }
ui::GestureRecognizer* NativeWidgetAura::GetGestureRecognizer() { … }
ui::GestureConsumer* NativeWidgetAura::GetGestureConsumer() { … }
void NativeWidgetAura::OnSizeConstraintsChanged() { … }
void NativeWidgetAura::OnNativeViewHierarchyWillChange() { … }
void NativeWidgetAura::OnNativeViewHierarchyChanged() { … }
bool NativeWidgetAura::SetAllowScreenshots(bool allow) { … }
bool NativeWidgetAura::AreScreenshotsAllowed() { … }
std::string NativeWidgetAura::GetName() const { … }
base::WeakPtr<internal::NativeWidgetPrivate> NativeWidgetAura::GetWeakPtr() { … }
gfx::Size NativeWidgetAura::GetMinimumSize() const { … }
gfx::Size NativeWidgetAura::GetMaximumSize() const { … }
void NativeWidgetAura::OnBoundsChanged(const gfx::Rect& old_bounds,
const gfx::Rect& new_bounds) { … }
gfx::NativeCursor NativeWidgetAura::GetCursor(const gfx::Point& point) { … }
int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { … }
bool NativeWidgetAura::ShouldDescendIntoChildForEventHandling(
aura::Window* child,
const gfx::Point& location) { … }
bool NativeWidgetAura::CanFocus() { … }
void NativeWidgetAura::OnCaptureLost() { … }
void NativeWidgetAura::OnPaint(const ui::PaintContext& context) { … }
void NativeWidgetAura::OnDeviceScaleFactorChanged(
float old_device_scale_factor,
float new_device_scale_factor) { … }
void NativeWidgetAura::OnWindowDestroying(aura::Window* window) { … }
void NativeWidgetAura::OnWindowDestroyed(aura::Window* window) { … }
void NativeWidgetAura::OnWindowTargetVisibilityChanged(bool visible) { … }
bool NativeWidgetAura::HasHitTestMask() const { … }
void NativeWidgetAura::GetHitTestMask(SkPath* mask) const { … }
void NativeWidgetAura::UpdateVisualState() { … }
void NativeWidgetAura::OnWindowPropertyChanged(aura::Window* window,
const void* key,
intptr_t old) { … }
void NativeWidgetAura::OnResizeLoopStarted(aura::Window* window) { … }
void NativeWidgetAura::OnResizeLoopEnded(aura::Window* window) { … }
void NativeWidgetAura::OnWindowAddedToRootWindow(aura::Window* window) { … }
void NativeWidgetAura::OnWindowRemovingFromRootWindow(aura::Window* window,
aura::Window* new_root) { … }
void NativeWidgetAura::OnKeyEvent(ui::KeyEvent* event) { … }
void NativeWidgetAura::OnMouseEvent(ui::MouseEvent* event) { … }
void NativeWidgetAura::OnScrollEvent(ui::ScrollEvent* event) { … }
void NativeWidgetAura::OnGestureEvent(ui::GestureEvent* event) { … }
bool NativeWidgetAura::ShouldActivate() const { … }
void NativeWidgetAura::OnWindowActivated(
wm::ActivationChangeObserver::ActivationReason,
aura::Window* gained_active,
aura::Window* lost_active) { … }
void NativeWidgetAura::OnWindowFocused(aura::Window* gained_focus,
aura::Window* lost_focus) { … }
void NativeWidgetAura::OnDragEntered(const ui::DropTargetEvent& event) { … }
aura::client::DragUpdateInfo NativeWidgetAura::OnDragUpdated(
const ui::DropTargetEvent& event) { … }
void NativeWidgetAura::OnDragExited() { … }
aura::client::DragDropDelegate::DropCallback NativeWidgetAura::GetDropCallback(
const ui::DropTargetEvent& event) { … }
void NativeWidgetAura::OnTransientParentChanged(aura::Window* new_parent) { … }
NativeWidgetAura::~NativeWidgetAura() { … }
void NativeWidgetAura::SetInitialFocus(ui::WindowShowState show_state) { … }
namespace {
#if BUILDFLAG(ENABLE_DESKTOP_AURA) && (BUILDFLAG(IS_WIN) || BUILDFLAG(IS_OZONE))
void CloseWindow(aura::Window* window) { … }
#endif
#if BUILDFLAG(IS_WIN)
BOOL CALLBACK WindowCallbackProc(HWND hwnd, LPARAM lParam) {
aura::Window* root_window =
DesktopWindowTreeHostWin::GetContentWindowForHWND(hwnd);
CloseWindow(root_window);
return TRUE;
}
#endif
}
void Widget::CloseAllSecondaryWidgets() { … }
namespace internal {
NativeWidgetPrivate* NativeWidgetPrivate::CreateNativeWidget(
internal::NativeWidgetDelegate* delegate) { … }
NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeView(
gfx::NativeView native_view) { … }
NativeWidgetPrivate* NativeWidgetPrivate::GetNativeWidgetForNativeWindow(
gfx::NativeWindow native_window) { … }
NativeWidgetPrivate* NativeWidgetPrivate::GetTopLevelNativeWidget(
gfx::NativeView native_view) { … }
void NativeWidgetPrivate::GetAllChildWidgets(gfx::NativeView native_view,
Widget::Widgets* children) { … }
void NativeWidgetPrivate::GetAllOwnedWidgets(gfx::NativeView native_view,
Widget::Widgets* owned) { … }
void NativeWidgetPrivate::ReparentNativeView(gfx::NativeView native_view,
gfx::NativeView new_parent) { … }
gfx::NativeView NativeWidgetPrivate::GetGlobalCapture(
gfx::NativeView native_view) { … }
}
}