chromium/ui/ozone/platform/wayland/host/wayland_window.cc

// Copyright 2016 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/ozone/platform/wayland/host/wayland_window.h"

#include <aura-shell-client-protocol.h>
#include <stdint.h>
#include <wayland-cursor.h>

#include <algorithm>
#include <memory>
#include <optional>
#include <utility>

#include "base/auto_reset.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/memory/scoped_refptr.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "build/chromeos_buildflags.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/mojom/cursor_type.mojom.h"
#include "ui/base/cursor/platform_cursor.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
#include "ui/events/event_target_iterator.h"
#include "ui/events/event_utils.h"
#include "ui/events/ozone/events_ozone.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rrect_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/overlay_priority_hint.h"
#include "ui/ozone/common/bitmap_cursor.h"
#include "ui/ozone/common/features.h"
#include "ui/ozone/platform/wayland/common/wayland_overlay_config.h"
#include "ui/ozone/platform/wayland/host/dump_util.h"
#include "ui/ozone/platform/wayland/host/wayland_bubble.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_cursor_shape.h"
#include "ui/ozone/platform/wayland/host/wayland_data_drag_controller.h"
#include "ui/ozone/platform/wayland/host/wayland_event_source.h"
#include "ui/ozone/platform/wayland/host/wayland_frame_manager.h"
#include "ui/ozone/platform/wayland/host/wayland_output.h"
#include "ui/ozone/platform/wayland/host/wayland_output_manager.h"
#include "ui/ozone/platform/wayland/host/wayland_popup.h"
#include "ui/ozone/platform/wayland/host/wayland_screen.h"
#include "ui/ozone/platform/wayland/host/wayland_seat.h"
#include "ui/ozone/platform/wayland/host/wayland_subsurface.h"
#include "ui/ozone/platform/wayland/host/wayland_surface.h"
#include "ui/ozone/platform/wayland/host/wayland_zaura_shell.h"
#include "ui/ozone/platform/wayland/host/wayland_zcr_cursor_shapes.h"
#include "ui/ozone/platform/wayland/mojom/wayland_overlay_config.mojom.h"
#include "ui/platform_window/common/platform_window_defaults.h"
#include "ui/platform_window/wm/wm_drag_handler.h"
#include "ui/platform_window/wm/wm_drop_handler.h"

namespace ui {
namespace {

CursorType;
DragOperation;

// Wayland compositors usually remove keyboard focus during drag
// sessions, thus modifier events are not sent, instead they are handled
// at server side, and clients are indirectly notified through, e.g:
// wl_data_offer.dnd_actions events.
// There is an open discussion about being more explicit about this on
// the spec: https://gitlab.freedesktop.org/wayland/wayland/-/issues/441
// For now, assume no keyboard modifiers info is available during dnd.
static constexpr int kWaylandDndModifiers =;

bool OverlayStackOrderCompare(const wl::WaylandOverlayConfig& i,
                              const wl::WaylandOverlayConfig& j) {}

}  // namespace

WaylandWindow::WaylandWindow(PlatformWindowDelegate* delegate,
                             WaylandConnection* connection)
    :{}

WaylandWindow::~WaylandWindow() {}

void WaylandWindow::OnWindowLostCapture() {}

void WaylandWindow::UpdateWindowScale(bool update_bounds) {}

void WaylandWindow::OnEnteredOutputScaleChanged() {}

WaylandZAuraSurface* WaylandWindow::GetZAuraSurface() {}

gfx::AcceleratedWidget WaylandWindow::GetWidget() const {}

void WaylandWindow::AddBubble(WaylandBubble* window) {}

void WaylandWindow::RemoveBubble(WaylandBubble* window) {}

void WaylandWindow::ActivateBubble(WaylandBubble* window) {}

void WaylandWindow::SetWindowScale(float new_scale) {}

std::optional<float> WaylandWindow::GetScaleFactorFromEnteredOutputs() {}

std::optional<WaylandOutput::Id> WaylandWindow::GetPreferredEnteredOutputId() {}

std::optional<float> WaylandWindow::GetPreferredScaleFactor() const {}

void WaylandWindow::OnPointerFocusChanged(bool focused) {}

bool WaylandWindow::HasPointerFocus() const {}

bool WaylandWindow::HasKeyboardFocus() const {}

void WaylandWindow::RemoveEnteredOutput(uint32_t output_id) {}

bool WaylandWindow::StartDrag(
    const ui::OSExchangeData& data,
    int operations,
    mojom::DragEventSource source,
    gfx::NativeCursor cursor,
    bool can_grab_pointer,
    base::OnceClosure drag_started_callback,
    WmDragHandler::DragFinishedCallback drag_finished_callback,
    WmDragHandler::LocationDelegate* location_delegate) {}

void WaylandWindow::UpdateDragImage(const gfx::ImageSkia& image,
                                    const gfx::Vector2d& offset) {}

void WaylandWindow::CancelDrag() {}

void WaylandWindow::Show(bool inactive) {}

void WaylandWindow::Hide() {}

void WaylandWindow::OnChannelDestroyed() {}

void WaylandWindow::DumpState(std::ostream& out) const {}

bool WaylandWindow::SupportsConfigureMinimizedState() const {}

bool WaylandWindow::SupportsConfigurePinnedState() const {}

void WaylandWindow::Close() {}

bool WaylandWindow::IsVisible() const {}

void WaylandWindow::PrepareForShutdown() {}

void WaylandWindow::SetBoundsInPixels(const gfx::Rect& bounds_px) {}

gfx::Rect WaylandWindow::GetBoundsInPixels() const {}

void WaylandWindow::SetBoundsInDIP(const gfx::Rect& bounds_dip) {}

gfx::Rect WaylandWindow::GetBoundsInDIP() const {}

void WaylandWindow::OnSurfaceConfigureEvent() {}

void WaylandWindow::SetTitle(const std::u16string& title) {}

void WaylandWindow::SetCapture() {}

void WaylandWindow::ReleaseCapture() {}

bool WaylandWindow::HasCapture() const {}

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

void WaylandWindow::Maximize() {}

void WaylandWindow::Minimize() {}

void WaylandWindow::Restore() {}

PlatformWindowState WaylandWindow::GetPlatformWindowState() const {}

void WaylandWindow::Activate() {}

void WaylandWindow::Deactivate() {}

void WaylandWindow::SetUseNativeFrame(bool use_native_frame) {}

bool WaylandWindow::ShouldUseNativeFrame() const {}

void WaylandWindow::SetCursor(scoped_refptr<PlatformCursor> platform_cursor) {}

void WaylandWindow::MoveCursorTo(const gfx::Point& location) {}

void WaylandWindow::ConfineCursorToBounds(const gfx::Rect& bounds) {}

void WaylandWindow::SetRestoredBoundsInDIP(const gfx::Rect& bounds) {}

gfx::Rect WaylandWindow::GetRestoredBoundsInDIP() const {}

bool WaylandWindow::ShouldWindowContentsBeTransparent() const {}

void WaylandWindow::SetAspectRatio(const gfx::SizeF& aspect_ratio) {}

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

void WaylandWindow::SizeConstraintsChanged() {}

bool WaylandWindow::ShouldUpdateWindowShape() const {}

bool WaylandWindow::CanDispatchEvent(const PlatformEvent& event) {}

uint32_t WaylandWindow::DispatchEvent(const PlatformEvent& native_event) {}

// EventTarget:
bool WaylandWindow::CanAcceptEvent(const Event& event) {}

EventTarget* WaylandWindow::GetParentTarget() {}

std::unique_ptr<EventTargetIterator> WaylandWindow::GetChildIterator() const {}

EventTargeter* WaylandWindow::GetEventTargeter() {}

void WaylandWindow::OcclusionStateChanged(
    PlatformWindowOcclusionState occlusion_state) {}

void WaylandWindow::HandleSurfaceConfigure(uint32_t serial) {}

WaylandWindow::WindowStates::WindowStates() = default;
WaylandWindow::WindowStates::~WindowStates() = default;

std::string WaylandWindow::WindowStates::ToString() const {}

void WaylandWindow::HandleToplevelConfigure(int32_t widht,
                                            int32_t height,
                                            const WindowStates& window_states) {}

void WaylandWindow::HandleAuraToplevelConfigure(
    int32_t x,
    int32_t y,
    int32_t width,
    int32_t height,
    const WindowStates& window_states) {}

void WaylandWindow::HandlePopupConfigure(const gfx::Rect& bounds_dip) {}

void WaylandWindow::OnCloseRequest() {}

void WaylandWindow::OnDragEnter(const gfx::PointF& point, int operations) {}

void WaylandWindow::OnDragDataAvailable(std::unique_ptr<OSExchangeData> data) {}

int WaylandWindow::OnDragMotion(const gfx::PointF& point, int operations) {}

void WaylandWindow::OnDragDrop() {}

void WaylandWindow::OnDragLeave() {}

void WaylandWindow::OnDragSessionClose(DragOperation operation) {}

bool WaylandWindow::Initialize(PlatformWindowInitProperties properties) {}

void WaylandWindow::SetWindowGeometry(
    const PlatformWindowDelegate::State& state) {}

gfx::Vector2d WaylandWindow::GetWindowGeometryOffsetInDIP() const {}

WaylandWindow* WaylandWindow::GetRootParentWindow() {}

void WaylandWindow::OnEnteredOutput() {}

void WaylandWindow::OnLeftOutput() {}

WaylandWindow* WaylandWindow::GetTopMostChildWindow() {}

WaylandWindow* WaylandWindow::GetXdgParentWindow() {}

bool WaylandWindow::IsOpaqueWindow() const {}

bool WaylandWindow::IsActive() const {}

WaylandBubble* WaylandWindow::AsWaylandBubble() {}

WaylandPopup* WaylandWindow::AsWaylandPopup() {}

WaylandToplevelWindow* WaylandWindow::AsWaylandToplevelWindow() {}

bool WaylandWindow::IsScreenCoordinatesEnabled() const {}

uint32_t WaylandWindow::DispatchEventToDelegate(
    const PlatformEvent& native_event) {}

std::unique_ptr<WaylandSurface> WaylandWindow::TakeWaylandSurface() {}

bool WaylandWindow::RequestSubsurface() {}

bool WaylandWindow::ArrangeSubsurfaceStack(size_t above, size_t below) {}

bool WaylandWindow::CommitOverlays(
    uint32_t frame_id,
    const gfx::FrameData& data,
    std::vector<wl::WaylandOverlayConfig>& overlays) {}

void WaylandWindow::UpdateCursorShape(scoped_refptr<BitmapCursor> cursor) {}

#if BUILDFLAG(IS_LINUX)
void WaylandWindow::OnCursorLoaded(scoped_refptr<WaylandAsyncCursor> cursor,
                                   scoped_refptr<BitmapCursor> bitmap_cursor) {}
#endif

void WaylandWindow::ProcessPendingConfigureState(uint32_t serial) {}

void WaylandWindow::RequestStateFromServer(PlatformWindowDelegate::State state,
                                           int64_t serial) {}

void WaylandWindow::RequestStateFromClient(
    PlatformWindowDelegate::State state) {}

void WaylandWindow::RequestState(PlatformWindowDelegate::State state,
                                 int64_t serial,
                                 bool force) {}

void WaylandWindow::ProcessSequencePoint(int64_t viz_seq) {}

gfx::Rect WaylandWindow::AdjustBoundsToConstraintsPx(
    const gfx::Rect& bounds_px) {}

gfx::Rect WaylandWindow::AdjustBoundsToConstraintsDIP(
    const gfx::Rect& bounds_dip) {}

void WaylandWindow::LatchStateRequest(const StateRequest& req) {}

void WaylandWindow::MaybeApplyLatestStateRequest(bool force) {}

PlatformWindowDelegate::State WaylandWindow::GetLatestRequestedState() const {}

void WaylandWindow::RoundTripQueue() {}

bool WaylandWindow::HasInFlightRequestsForState() const {}

int64_t WaylandWindow::GetVizSequenceIdForAppliedState() const {}

int64_t WaylandWindow::GetVizSequenceIdForLatchedState() const {}

void WaylandWindow::SetLatchImmediately(bool latch_immediately) {}

void WaylandWindow::ForceApplyWindowStateDoNotUse(
    PlatformWindowState window_state) {}

}  // namespace ui