#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "ui/ozone/platform/x11/x11_window.h"
#include "base/memory/scoped_refptr.h"
#include "base/no_destructor.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "build/chromeos_buildflags.h"
#include "net/base/network_interfaces.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkRegion.h"
#include "ui/base/buildflags.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/platform_cursor.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/wm_role_names_linux.h"
#include "ui/base/x/x11_cursor.h"
#include "ui/base/x/x11_os_exchange_data_provider.h"
#include "ui/base/x/x11_pointer_grab.h"
#include "ui/base/x/x11_util.h"
#include "ui/display/screen.h"
#include "ui/events/devices/x11/touch_factory_x11.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/events/ozone/events_ozone.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/events/x/events_x_utils.h"
#include "ui/events/x/x11_event_translation.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/geometry/transform.h"
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/x/atom_cache.h"
#include "ui/gfx/x/visual_manager.h"
#include "ui/gfx/x/window_event_manager.h"
#include "ui/gfx/x/x11_path.h"
#include "ui/gfx/x/xproto.h"
#include "ui/ozone/platform/x11/hit_test_x11.h"
#include "ui/ozone/platform/x11/x11_window_manager.h"
#include "ui/platform_window/common/platform_window_defaults.h"
#include "ui/platform_window/extensions/workspace_extension_delegate.h"
#include "ui/platform_window/extensions/x11_extension_delegate.h"
#include "ui/platform_window/wm/wm_drop_handler.h"
#if BUILDFLAG(USE_ATK)
#include "ui/ozone/platform/x11/atk_event_conversion.h"
#endif
namespace ui {
namespace {
DragOperation;
constexpr float kDragWidgetOpacity = …;
bool CoalesceEventsIfNeeded(const x11::Event& xev,
EventType type,
x11::Event* out) { … }
int GetKeyModifiers(const XDragDropClient* client) { … }
const int32_t kAllWorkspaces = …;
constexpr char kX11WindowRolePopup[] = …;
constexpr char kX11WindowRoleBubble[] = …;
constexpr char kDarkGtkThemeVariant[] = …;
constexpr long kSystemTrayRequestDock = …;
constexpr int kXembedInfoProtocolVersion = …;
constexpr int kXembedFlagMap = …;
constexpr int kXembedInfoFlags = …;
enum CrossingFlags : uint8_t { … };
gfx::Rect SanitizeBounds(const gfx::Rect& bounds) { … }
void SerializeImageRepresentation(const gfx::ImageSkiaRep& rep,
std::vector<uint32_t>* data) { … }
x11::NotifyMode XI2ModeToXMode(x11::Input::NotifyMode xi2_mode) { … }
x11::NotifyDetail XI2DetailToXDetail(x11::Input::NotifyDetail xi2_detail) { … }
void SyncSetCounter(x11::Connection* connection,
x11::Sync::Counter counter,
int64_t value) { … }
std::vector<x11::Window> GetParentsList(x11::Connection* connection,
x11::Window window) { … }
std::vector<x11::Window>& GetSecuritySurfaces() { … }
}
X11Window::X11Window(PlatformWindowDelegate* platform_window_delegate)
: … { … }
X11Window::~X11Window() { … }
void X11Window::Initialize(PlatformWindowInitProperties properties) { … }
void X11Window::OnXWindowLostCapture() { … }
void X11Window::OnMouseEnter() { … }
gfx::AcceleratedWidget X11Window::GetWidget() const { … }
void X11Window::Show(bool inactive) { … }
void X11Window::Hide() { … }
void X11Window::Close() { … }
bool X11Window::IsVisible() const { … }
void X11Window::PrepareForShutdown() { … }
void X11Window::SetBoundsInPixels(const gfx::Rect& bounds) { … }
gfx::Rect X11Window::GetBoundsInPixels() const { … }
void X11Window::SetBoundsInDIP(const gfx::Rect& bounds_in_dip) { … }
gfx::Rect X11Window::GetBoundsInDIP() const { … }
void X11Window::SetTitle(const std::u16string& title) { … }
void X11Window::SetCapture() { … }
void X11Window::ReleaseCapture() { … }
bool X11Window::HasCapture() const { … }
void X11Window::SetFullscreen(bool fullscreen, int64_t target_display_id) { … }
void X11Window::Maximize() { … }
void X11Window::Minimize() { … }
void X11Window::Restore() { … }
PlatformWindowState X11Window::GetPlatformWindowState() const { … }
void X11Window::Activate() { … }
void X11Window::Deactivate() { … }
void X11Window::SetUseNativeFrame(bool use_native_frame) { … }
bool X11Window::ShouldUseNativeFrame() const { … }
void X11Window::SetCursor(scoped_refptr<PlatformCursor> cursor) { … }
void X11Window::MoveCursorTo(const gfx::Point& location_px) { … }
void X11Window::ConfineCursorToBounds(const gfx::Rect& bounds) { … }
void X11Window::SetRestoredBoundsInDIP(const gfx::Rect& bounds) { … }
gfx::Rect X11Window::GetRestoredBoundsInDIP() const { … }
bool X11Window::ShouldWindowContentsBeTransparent() const { … }
void X11Window::SetZOrderLevel(ZOrderLevel order) { … }
ZOrderLevel X11Window::GetZOrderLevel() const { … }
void X11Window::StackAbove(gfx::AcceleratedWidget widget) { … }
void X11Window::StackAtTop() { … }
void X11Window::FlashFrame(bool flash_frame) { … }
void X11Window::SetShape(std::unique_ptr<ShapeRects> native_shape,
const gfx::Transform& transform) { … }
void X11Window::SetAspectRatio(const gfx::SizeF& aspect_ratio) { … }
void X11Window::SetWindowIcons(const gfx::ImageSkia& window_icon,
const gfx::ImageSkia& app_icon) { … }
void X11Window::SizeConstraintsChanged() { … }
void X11Window::SetOpacity(float opacity) { … }
bool X11Window::CanSetDecorationInsets() const { … }
void X11Window::SetOpaqueRegion(
std::optional<std::vector<gfx::Rect>> region_px) { … }
void X11Window::SetInputRegion(
std::optional<std::vector<gfx::Rect>> region_px) { … }
void X11Window::NotifyStartupComplete(const std::string& startup_id) { … }
std::string X11Window::GetWorkspace() const { … }
void X11Window::SetVisibleOnAllWorkspaces(bool always_visible) { … }
bool X11Window::IsVisibleOnAllWorkspaces() const { … }
void X11Window::SetWorkspaceExtensionDelegate(
WorkspaceExtensionDelegate* delegate) { … }
bool X11Window::IsSyncExtensionAvailable() const { … }
bool X11Window::IsWmTiling() const { … }
void X11Window::OnCompleteSwapAfterResize() { … }
gfx::Rect X11Window::GetXRootWindowOuterBounds() const { … }
void X11Window::LowerXWindow() { … }
void X11Window::SetOverrideRedirect(bool override_redirect) { … }
bool X11Window::CanResetOverrideRedirect() const { … }
void X11Window::SetX11ExtensionDelegate(X11ExtensionDelegate* delegate) { … }
bool X11Window::HandleAsAtkEvent(const x11::KeyEvent& key_event,
bool send_event,
bool transient) { … }
void X11Window::OnEvent(const x11::Event& xev) { … }
bool X11Window::CanDispatchEvent(const PlatformEvent& xev) { … }
uint32_t X11Window::DispatchEvent(const PlatformEvent& event) { … }
void X11Window::DispatchUiEvent(ui::Event* event, const x11::Event& xev) { … }
void X11Window::UpdateDecorationInsets() { … }
void X11Window::OnXWindowStateChanged() { … }
void X11Window::OnXWindowDamageEvent(const gfx::Rect& damage_rect) { … }
void X11Window::OnXWindowCloseRequested() { … }
void X11Window::OnXWindowIsActiveChanged(bool active) { … }
void X11Window::OnXWindowWorkspaceChanged() { … }
void X11Window::OnXWindowLostPointerGrab() { … }
void X11Window::OnXWindowSelectionEvent(const x11::SelectionNotifyEvent& xev) { … }
void X11Window::OnXWindowDragDropEvent(const x11::ClientMessageEvent& xev) { … }
std::optional<gfx::Size> X11Window::GetMinimumSizeForXWindow() { … }
std::optional<gfx::Size> X11Window::GetMaximumSizeForXWindow() { … }
SkPath X11Window::GetWindowMaskForXWindow() { … }
void X11Window::DispatchHostWindowDragMovement(
int hittest,
const gfx::Point& pointer_location_in_px) { … }
bool X11Window::RunMoveLoop(const gfx::Vector2d& drag_offset) { … }
void X11Window::EndMoveLoop() { … }
bool X11Window::StartDrag(
const 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 X11Window::CancelDrag() { … }
void X11Window::UpdateDragImage(const gfx::ImageSkia& image,
const gfx::Vector2d& offset) { … }
std::optional<gfx::AcceleratedWidget> X11Window::GetDragWidget() { … }
int X11Window::UpdateDrag(const gfx::Point& connection_point) { … }
void X11Window::UpdateCursor(DragOperation negotiated_operation) { … }
void X11Window::OnBeginForeignDrag(x11::Window window) { … }
void X11Window::OnEndForeignDrag() { … }
void X11Window::OnBeforeDragLeave() { … }
DragOperation X11Window::PerformDrop() { … }
void X11Window::EndDragLoop() { … }
void X11Window::OnMouseMovement(const gfx::Point& connection_point,
int flags,
base::TimeTicks event_time) { … }
void X11Window::OnMouseReleased() { … }
void X11Window::OnMoveLoopEnded() { … }
void X11Window::SetBoundsOnMove(const gfx::Rect& requested_bounds) { … }
scoped_refptr<X11Cursor> X11Window::GetLastCursor() { … }
gfx::Size X11Window::GetSize() { … }
void X11Window::QuitDragLoop() { … }
gfx::Size X11Window::AdjustSizeForDisplay(
const gfx::Size& requested_size_in_pixels) { … }
void X11Window::CreateXWindow(const PlatformWindowInitProperties& properties) { … }
void X11Window::CloseXWindow() { … }
void X11Window::Map(bool inactive) { … }
void X11Window::SetFullscreen(bool fullscreen) { … }
bool X11Window::IsActive() const { … }
bool X11Window::IsMinimized() const { … }
bool X11Window::IsMaximized() const { … }
bool X11Window::IsFullscreen() const { … }
gfx::Rect X11Window::GetOuterBounds() const { … }
void X11Window::ResetWindowRegion() { … }
void X11Window::OnWorkspaceUpdated() { … }
void X11Window::SetFlashFrameHint(bool flash_frame) { … }
void X11Window::UpdateMinAndMaxSize() { … }
void X11Window::BeforeActivationStateChanged() { … }
void X11Window::AfterActivationStateChanged() { … }
void X11Window::MaybeUpdateOcclusionState() { … }
void X11Window::OnCrossingEvent(bool enter,
bool focus_in_window_or_ancestor,
x11::NotifyMode mode,
x11::NotifyDetail detail) { … }
void X11Window::OnFocusEvent(bool focus_in,
x11::NotifyMode mode,
x11::NotifyDetail detail) { … }
bool X11Window::IsTargetedBy(const x11::Event& xev) const { … }
void X11Window::SetTransientWindow(x11::Window window) { … }
void X11Window::HandleEvent(const x11::Event& xev) { … }
void X11Window::UpdateWMUserTime(Event* event) { … }
void X11Window::OnWindowMapped() { … }
void X11Window::OnConfigureEvent(const x11::ConfigureNotifyEvent& configure,
bool send_event) { … }
void X11Window::SetWMSpecState(bool enabled,
x11::Atom state1,
x11::Atom state2) { … }
void X11Window::OnWMStateUpdated() { … }
WindowTiledEdges X11Window::GetTiledState() const { … }
void X11Window::UpdateWindowProperties(
const base::flat_set<x11::Atom>& new_window_properties) { … }
void X11Window::OnFrameExtentsUpdated() { … }
void X11Window::DispatchResize(bool origin_changed) { … }
void X11Window::DelayedResize(bool origin_changed) { … }
void X11Window::CancelResize() { … }
void X11Window::UnconfineCursor() { … }
void X11Window::UpdateWindowRegion(
std::unique_ptr<std::vector<x11::Rectangle>> region) { … }
void X11Window::NotifyBoundsChanged(bool origin_changed) { … }
bool X11Window::InitializeAsStatusIcon() { … }
}