#ifndef UI_BASE_X_X11_UTIL_H_
#define UI_BASE_X_X11_UTIL_H_
#include <array>
#include <cstddef>
#include <cstdint>
#include <memory>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
#include "base/component_export.h"
#include "base/containers/flat_set.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_refptr.h"
#include "base/synchronization/lock.h"
#include "build/build_config.h"
#include "third_party/skia/include/core/SkColorType.h"
#include "ui/base/x/x11_cursor.h"
#include "ui/gfx/icc_profile.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/future.h"
#include "ui/gfx/x/xproto.h"
class SkPixmap;
namespace gfx {
class Point;
}
namespace ui {
COMPONENT_EXPORT(UI_BASE_X)
size_t RowBytesForVisualWidth(const x11::Connection::VisualInfo& visual_info,
int width);
COMPONENT_EXPORT(UI_BASE_X)
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);
COMPONENT_EXPORT(UI_BASE_X) bool IsXInput2Available();
COMPONENT_EXPORT(UI_BASE_X) bool QueryShmSupport();
COMPONENT_EXPORT(UI_BASE_X)
int CoalescePendingMotionEvents(const x11::Event& xev, x11::Event* last_event);
COMPONENT_EXPORT(UI_BASE_X)
void SetUseOSWindowFrame(x11::Window window, bool use_os_window_frame);
COMPONENT_EXPORT(UI_BASE_X) bool IsShapeExtensionAvailable();
COMPONENT_EXPORT(UI_BASE_X) x11::Window GetX11RootWindow();
COMPONENT_EXPORT(UI_BASE_X) bool GetCurrentDesktop(int32_t* desktop);
enum HideTitlebarWhenMaximized : uint32_t {
SHOW_TITLEBAR_WHEN_MAXIMIZED = 0,
HIDE_TITLEBAR_WHEN_MAXIMIZED = 1,
};
COMPONENT_EXPORT(UI_BASE_X)
void SetHideTitlebarWhenMaximizedProperty(x11::Window window,
HideTitlebarWhenMaximized property);
COMPONENT_EXPORT(UI_BASE_X)
bool GetRawBytesOfProperty(x11::Window window,
x11::Atom property,
scoped_refptr<base::RefCountedMemory>* out_data,
x11::Atom* out_type);
COMPONENT_EXPORT(UI_BASE_X)
void SetWindowClassHint(x11::Connection* connection,
x11::Window window,
const std::string& res_name,
const std::string& res_class);
COMPONENT_EXPORT(UI_BASE_X)
void SetWindowRole(x11::Window window, const std::string& role);
COMPONENT_EXPORT(UI_BASE_X)
void SetWMSpecState(x11::Window window,
bool enabled,
x11::Atom state1,
x11::Atom state2);
COMPONENT_EXPORT(UI_BASE_X)
void DoWMMoveResize(x11::Connection* connection,
x11::Window root_window,
x11::Window window,
const gfx::Point& location_px,
int direction);
COMPONENT_EXPORT(UI_BASE_X)
bool HasWMSpecProperty(const base::flat_set<x11::Atom>& properties,
x11::Atom atom);
COMPONENT_EXPORT(UI_BASE_X) bool GetCustomFramePrefDefault();
static const int32_t kAllDesktops = -1;
COMPONENT_EXPORT(UI_BASE_X)
bool GetWindowDesktop(x11::Window window, int32_t* desktop);
enum WindowManagerName {
WM_OTHER,
WM_UNNAMED,
WM_AWESOME,
WM_BLACKBOX,
WM_COMPIZ,
WM_ENLIGHTENMENT,
WM_FLUXBOX,
WM_I3,
WM_ICE_WM,
WM_ION3,
WM_KWIN,
WM_MATCHBOX,
WM_METACITY,
WM_MUFFIN,
WM_MUTTER,
WM_NOTION,
WM_OPENBOX,
WM_QTILE,
WM_RATPOISON,
WM_STUMPWM,
WM_WMII,
WM_XFWM4,
WM_XMONAD,
};
COMPONENT_EXPORT(UI_BASE_X) WindowManagerName GuessWindowManager();
COMPONENT_EXPORT(UI_BASE_X) std::string GuessWindowManagerName();
enum class UMALinuxWindowManager {
kOther = 0,
kBlackbox = 1,
kChromeOS = 2,
kCompiz = 3,
kEnlightenment = 4,
kIceWM = 5,
kKWin = 6,
kMetacity = 7,
kMuffin = 8,
kMutter = 9,
kOpenbox = 10,
kXfwm4 = 11,
kAwesome = 12,
kI3 = 13,
kIon3 = 14,
kMatchbox = 15,
kNotion = 16,
kQtile = 17,
kRatpoison = 18,
kStumpWM = 19,
kWmii = 20,
kFluxbox = 21,
kXmonad = 22,
kUnnamed = 23,
kMaxValue = kUnnamed
};
COMPONENT_EXPORT(UI_BASE_X) UMALinuxWindowManager GetWindowManagerUMA();
COMPONENT_EXPORT(UI_BASE_X) bool IsWmTiling(WindowManagerName window_manager);
COMPONENT_EXPORT(UI_BASE_X) bool IsX11WindowFullScreen(x11::Window window);
COMPONENT_EXPORT(UI_BASE_X) bool SuspendX11ScreenSaver(bool suspend);
COMPONENT_EXPORT(UI_BASE_X)
SkColorType ColorTypeForVisual(x11::VisualId visual_id);
COMPONENT_EXPORT(UI_BASE_X)
x11::Future<void> SendClientMessage(
x11::Window window,
x11::Window target,
x11::Atom type,
const std::array<uint32_t, 5> data,
x11::EventMask event_mask = static_cast<x11::EventMask>(
static_cast<int>(x11::EventMask::SubstructureNotify) |
static_cast<int>(x11::EventMask::SubstructureRedirect)));
COMPONENT_EXPORT(UI_BASE_X) bool IsVulkanSurfaceSupported();
COMPONENT_EXPORT(UI_BASE_X)
gfx::ImageSkia GetNativeWindowIcon(intptr_t target_window_id);
}
#endif