#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "ui/base/x/x11_util.h"
#include <sys/ipc.h>
#include <sys/shm.h>
#include <bitset>
#include <limits>
#include <utility>
#include <vector>
#include "base/command_line.h"
#include "base/containers/contains.h"
#include "base/containers/span.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_refptr.h"
#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/task/single_thread_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkImageInfo.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/display/util/gpu_info_util.h"
#include "ui/events/devices/x11/device_data_manager_x11.h"
#include "ui/events/devices/x11/touch_factory_x11.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/switches.h"
#include "ui/gfx/x/atom_cache.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/screensaver.h"
#include "ui/gfx/x/shm.h"
#include "ui/gfx/x/xproto.h"
#if BUILDFLAG(IS_FREEBSD)
#include <sys/sysctl.h>
#include <sys/types.h>
#endif
namespace ui {
namespace {
constexpr int kNetWMStateAdd = …;
constexpr int kNetWMStateRemove = …;
bool IsX11ScreenSaverAvailable() { … }
bool EventHasCoordinates(const x11::Event& event) { … }
}
size_t RowBytesForVisualWidth(const x11::Connection::VisualInfo& visual_info,
int width) { … }
void DrawPixmap(x11::Connection* connection,
x11::VisualId visual,
x11::Drawable drawable,
x11::GraphicsContext gc,
const SkPixmap& skia_pixmap,
int src_x,
int src_y,
int dst_x,
int dst_y,
int width,
int height) { … }
bool IsXInput2Available() { … }
bool QueryShmSupport() { … }
int CoalescePendingMotionEvents(const x11::Event& x11_event,
x11::Event* last_event) { … }
void SetUseOSWindowFrame(x11::Window window, bool use_os_window_frame) { … }
bool IsShapeExtensionAvailable() { … }
x11::Window GetX11RootWindow() { … }
bool GetCurrentDesktop(int32_t* desktop) { … }
void SetHideTitlebarWhenMaximizedProperty(x11::Window window,
HideTitlebarWhenMaximized property) { … }
bool GetRawBytesOfProperty(x11::Window window,
x11::Atom property,
scoped_refptr<base::RefCountedMemory>* out_data,
x11::Atom* out_type) { … }
void SetWindowClassHint(x11::Connection* connection,
x11::Window window,
const std::string& res_name,
const std::string& res_class) { … }
void SetWindowRole(x11::Window window, const std::string& role) { … }
void SetWMSpecState(x11::Window window,
bool enabled,
x11::Atom state1,
x11::Atom state2) { … }
void DoWMMoveResize(x11::Connection* connection,
x11::Window root_window,
x11::Window window,
const gfx::Point& location_px,
int direction) { … }
bool HasWMSpecProperty(const base::flat_set<x11::Atom>& properties,
x11::Atom atom) { … }
bool GetCustomFramePrefDefault() { … }
bool IsWmTiling(WindowManagerName window_manager) { … }
bool GetWindowDesktop(x11::Window window, int32_t* desktop) { … }
WindowManagerName GuessWindowManager() { … }
std::string GuessWindowManagerName() { … }
UMALinuxWindowManager GetWindowManagerUMA() { … }
bool IsX11WindowFullScreen(x11::Window window) { … }
bool SuspendX11ScreenSaver(bool suspend) { … }
SkColorType ColorTypeForVisual(x11::VisualId visual) { … }
x11::Future<void> SendClientMessage(x11::Window window,
x11::Window target,
x11::Atom type,
const std::array<uint32_t, 5> data,
x11::EventMask event_mask) { … }
bool IsVulkanSurfaceSupported() { … }
gfx::ImageSkia GetNativeWindowIcon(intptr_t target_window_id) { … }
}