add native Wayland window backend

Wayland support was missing a proper windowing layer: the GLFW backend
leaves the known platform gaps (cursor themes, window icon, window
position, fullscreen output selection).

The new backend talks to the compositor directly:
- xdg-shell, EGL, xkbcommon (keyboard, repeat, layout) instead of GLFW;
- cursors through wp_cursor_shape_manager_v1, so no cursor theme lookup
  is required and no "standard cursor shape unavailable" errors appear;
- window icon and title are drawn by the engine itself, since Wayland
  has no window icon protocol and GNOME provides no server-side
  decorations;
- fullscreen requests the current output (set_fullscreen with NULL), so
  the window no longer jumps to another monitor;
- interactive resize presents a cached frame scaled to the new size
  while the pointer is down and refreshes the real frame when the drag
  pauses, keeping the window glued to the cursor.

libdecor is not used: libdecor_frame_commit() redraws the whole
decoration and acks the configure in the same call, and mutter sends
200-330 configures per second during an interactive resize, so the
decoration was redrawn hundreds of times per second (measured: 2 s of
work per second, loop stalls up to 6 s). The decorations are drawn by
the engine instead, which measured 2.3 ms average configure-to-present
latency during a real drag.

GLFW stays the backend for X11 and Windows; VOXEL_WINDOW_BACKEND=x11
forces it on Wayland sessions.
This commit is contained in:
alexei-zebra 2026-10-09 00:43:41 +03:00
parent 1dd1af1a72
commit 1e689e88b1
No known key found for this signature in database
GPG key ID: D19D450AC3D9A80E
18 changed files with 6567 additions and 526 deletions

View file

@ -72,6 +72,67 @@ endif()
target_include_directories(VoxelCoreSrc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
option(VOXELENGINE_WAYLAND "Build the native Wayland window backend" ON)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND VOXELENGINE_WAYLAND)
find_package(PkgConfig REQUIRED)
pkg_check_modules(wayland-client IMPORTED_TARGET wayland-client)
pkg_check_modules(xkbcommon IMPORTED_TARGET xkbcommon)
pkg_check_modules(egl IMPORTED_TARGET egl)
find_library(WAYLAND_EGL_LIBRARY NAMES wayland-egl libwayland-egl.so.1)
find_program(WAYLAND_SCANNER wayland-scanner)
if(NOT wayland-client_FOUND OR NOT xkbcommon_FOUND OR NOT egl_FOUND
OR NOT WAYLAND_EGL_LIBRARY OR NOT WAYLAND_SCANNER)
message(STATUS "Wayland backend is off: dependencies are not found")
else()
set(WAYLAND_PROTOCOLS ${CMAKE_CURRENT_SOURCE_DIR}/window/wayland/protocols)
set(WAYLAND_GENERATED ${CMAKE_CURRENT_BINARY_DIR}/wayland-protocols)
file(MAKE_DIRECTORY ${WAYLAND_GENERATED})
set(WAYLAND_SOURCES)
function(voxel_wayland_protocol XML NAME)
add_custom_command(
OUTPUT ${WAYLAND_GENERATED}/${NAME}-client-protocol.h
${WAYLAND_GENERATED}/${NAME}-protocol.c
COMMAND ${WAYLAND_SCANNER} client-header
${WAYLAND_PROTOCOLS}/${XML}
${WAYLAND_GENERATED}/${NAME}-client-protocol.h
COMMAND ${WAYLAND_SCANNER} private-code
${WAYLAND_PROTOCOLS}/${XML}
${WAYLAND_GENERATED}/${NAME}-protocol.c
DEPENDS ${WAYLAND_PROTOCOLS}/${XML}
VERBATIM)
set(WAYLAND_SOURCES ${WAYLAND_SOURCES}
${WAYLAND_GENERATED}/${NAME}-protocol.c
PARENT_SCOPE)
endfunction()
voxel_wayland_protocol(xdg-shell.xml xdg-shell)
voxel_wayland_protocol(cursor-shape-v1.xml cursor-shape-v1)
voxel_wayland_protocol(idle-inhibit-unstable-v1.xml
idle-inhibit-unstable-v1)
voxel_wayland_protocol(pointer-constraints-unstable-v1.xml
pointer-constraints-unstable-v1)
voxel_wayland_protocol(relative-pointer-unstable-v1.xml
relative-pointer-unstable-v1)
voxel_wayland_protocol(xdg-decoration-unstable-v1.xml
xdg-decoration-unstable-v1)
# tablet is referenced by cursor-shape-v1
voxel_wayland_protocol(tablet-unstable-v2.xml tablet-unstable-v2)
target_sources(VoxelCoreSrc PRIVATE ${WAYLAND_SOURCES})
target_include_directories(VoxelCoreSrc PUBLIC ${WAYLAND_GENERATED})
target_compile_definitions(VoxelCoreSrc PUBLIC VOXELENGINE_WAYLAND=1)
target_link_libraries(
VoxelCoreSrc
PRIVATE PkgConfig::wayland-client
PkgConfig::xkbcommon
PkgConfig::egl
${WAYLAND_EGL_LIBRARY})
message(STATUS "Wayland backend is on")
endif()
endif()
target_link_libraries(
VoxelCoreSrc
PRIVATE glfw

View file

@ -48,7 +48,7 @@ void Mainloop::run() {
engine.applicationTick();
engine.updateFrontend();
if (!window.isIconified()) {
if (!window.isIconified() && window.isFrameRequired()) {
engine.renderFrame();
}
engine.postUpdate();

View file

@ -59,9 +59,11 @@ WindowControl::Result WindowControl::initialize() {
throw initialize_error("could not initialize window");
}
window->setFramerate(settings.display.framerate.get());
if (auto icon = load_icon()) {
icon->flipY();
window->setIcon(icon.get());
if (window->isIconSupported()) {
if (auto icon = load_icon()) {
icon->flipY();
window->setIcon(icon.get());
}
}
return Result {std::move(window), std::move(input)};

41
src/window/Window.cpp Normal file
View file

@ -0,0 +1,41 @@
#include "Window.hpp"
#include "debug/Logger.hpp"
#include "detail/WindowBackends.hpp"
#include "window/input.hpp"
#include <cstdlib>
#include <cstring>
static debug::Logger logger("window");
#ifdef VOXELENGINE_WAYLAND
static bool prefer_wayland() {
const char* backend = getenv("VOXEL_WINDOW_BACKEND");
if (backend != nullptr) {
return strcmp(backend, "wayland") == 0;
}
const char* display = getenv("WAYLAND_DISPLAY");
if (display != nullptr && *display) {
return true;
}
return getenv("DISPLAY") == nullptr;
}
#endif
std::tuple<
std::unique_ptr<Window>,
std::unique_ptr<Input>
> Window::initialize(DisplaySettings* settings, std::string title) {
input_util::initialize();
#ifdef VOXELENGINE_WAYLAND
if (prefer_wayland()) {
auto result = wayland_window_initialize(settings, title);
if (std::get<0>(result) && std::get<1>(result)) {
return result;
}
logger.warning() << "could not initialize the Wayland backend";
}
#endif
return glfw_window_initialize(settings, std::move(title));
}

View file

@ -32,6 +32,10 @@ public:
virtual bool isShouldClose() const = 0;
virtual void setShouldClose(bool flag) = 0;
virtual bool isFrameRequired() const {
return true;
}
virtual void setCursor(CursorShape shape) = 0;
virtual void setMode(WindowMode mode) = 0;
virtual WindowMode getMode() const = 0;
@ -39,6 +43,9 @@ public:
virtual void focus() = 0;
virtual void setTitle(const std::string& title) = 0;
virtual bool isIconSupported() const = 0;
virtual void setIcon(const ImageData* image) = 0;
virtual void pushScissor(glm::vec4 area) = 0;

View file

@ -0,0 +1,152 @@
#include "BaseInput.hpp"
void BaseInput::onKeyCallback(int key, bool pressed) {
bool prevPressed = keys[key];
keys[key] = pressed;
frames[key] = currentFrame;
if (pressed && !prevPressed) {
const auto& callbacks = keyCallbacks.find(static_cast<Keycode>(key));
if (callbacks != keyCallbacks.end()) {
callbacks->second.notify();
}
}
if (pressed && key < MOUSE_KEYS_OFFSET) {
pressedKeys.push_back(static_cast<Keycode>(key));
}
}
void BaseInput::onMouseCallback(int button, bool pressed) {
onKeyCallback(button + MOUSE_KEYS_OFFSET, pressed);
}
bool BaseInput::isCursorLocked() const {
return cursorLocked;
}
void BaseInput::setCursorPosition(double xpos, double ypos) {
if (cursorDrag) {
delta.x += xpos - cursor.x;
delta.y += ypos - cursor.y;
} else {
cursorDrag = true;
}
cursor.x = xpos;
cursor.y = ypos;
}
Bindings& BaseInput::getBindings() {
return bindings;
}
const Bindings& BaseInput::getBindings() const {
return bindings;
}
ObserverHandler BaseInput::addKeyCallback(Keycode key, InputCallback callback) {
return keyCallbacks[key].add(std::move(callback));
}
ObserverHandler BaseInput::addMouseCallback(Mousecode button, InputCallback callback) {
return addKeyCallback(
static_cast<Keycode>(MOUSE_KEYS_OFFSET + static_cast<int>(button)),
std::move(callback)
);
}
const std::vector<Keycode>& BaseInput::getPressedKeys() const {
return pressedKeys;
}
const std::vector<uint>& BaseInput::getCodepoints() const {
return codepoints;
}
CursorState BaseInput::getCursor() const {
return {isCursorLocked(), cursor, delta};
}
int BaseInput::getScroll() {
return scroll;
}
bool BaseInput::pressed(Keycode key) const {
int keycode = static_cast<int>(key);
if (keycode < 0 || keycode >= KEYS_BUFFER_SIZE) {
return false;
}
return keys[keycode];
}
bool BaseInput::jpressed(Keycode keycode) const {
return pressed(keycode) &&
frames[static_cast<int>(keycode)] == currentFrame;
}
bool BaseInput::clicked(Mousecode code) const {
return pressed(
static_cast<Keycode>(MOUSE_KEYS_OFFSET + static_cast<int>(code))
);
}
bool BaseInput::jclicked(Mousecode code) const {
return clicked(code) &&
frames[static_cast<int>(code) + MOUSE_KEYS_OFFSET] == currentFrame;
}
void BaseInput::simulateKey(Keycode key, bool pressed) {
onKeyCallback(static_cast<int>(key), pressed);
}
void BaseInput::simulateClick(int button, bool pressed) {
onMouseCallback(button, pressed);
}
void BaseInput::simulateCursorPos(double xpos, double ypos) {
setCursorPosition(xpos, ypos);
}
void BaseInput::simulateCodepoint(uint codepoint) {
codepoints.push_back(codepoint);
}
void BaseInput::beginFrame() {
delta.x = 0.0f;
delta.y = 0.0f;
scroll = 0;
currentFrame++;
codepoints.clear();
pressedKeys.clear();
}
void BaseInput::updateBindings() {
for (auto& [_, binding] : bindings.getAll()) {
if (!binding.enabled) {
binding.state = false;
continue;
}
binding.justChanged = false;
bool newstate = false;
switch (binding.type) {
case InputType::KEYBOARD:
newstate = pressed(static_cast<Keycode>(binding.code));
break;
case InputType::MOUSE:
newstate = clicked(static_cast<Mousecode>(binding.code));
break;
}
if (newstate) {
if (!binding.state) {
binding.state = true;
binding.justChanged = true;
binding.onactived.notify();
}
} else {
if (binding.state) {
binding.state = false;
binding.justChanged = true;
}
}
}
}

View file

@ -0,0 +1,58 @@
#pragma once
#include "window/input.hpp"
#include <glm/vec2.hpp>
#include <unordered_map>
#include <vector>
inline constexpr short KEYS_BUFFER_SIZE = 1036;
inline constexpr short MOUSE_KEYS_OFFSET = 1024;
class BaseInput : public Input {
public:
std::vector<uint> codepoints;
int scroll = 0;
void onKeyCallback(int key, bool pressed);
void onMouseCallback(int button, bool pressed);
bool isCursorLocked() const override;
void setCursorPosition(double xpos, double ypos);
Bindings& getBindings() override;
const Bindings& getBindings() const override;
ObserverHandler addKeyCallback(Keycode key, InputCallback callback) override;
ObserverHandler addMouseCallback(Mousecode button, InputCallback callback) override;
const std::vector<Keycode>& getPressedKeys() const override;
const std::vector<uint>& getCodepoints() const override;
CursorState getCursor() const override;
int getScroll() override;
bool pressed(Keycode key) const override;
bool jpressed(Keycode keycode) const override;
bool clicked(Mousecode code) const override;
bool jclicked(Mousecode code) const override;
void simulateKey(Keycode key, bool pressed) override;
void simulateClick(int button, bool pressed) override;
void simulateCursorPos(double xpos, double ypos) override;
void simulateCodepoint(uint codepoint) override;
protected:
void beginFrame();
void updateBindings();
uint currentFrame = 0;
uint frames[KEYS_BUFFER_SIZE] {};
std::vector<Keycode> pressedKeys;
Bindings bindings;
bool keys[KEYS_BUFFER_SIZE] {};
std::unordered_map<Keycode, util::HandlersList<>> keyCallbacks;
bool cursorLocked = false;
bool cursorDrag = false;
glm::vec2 delta {};
glm::vec2 cursor {};
};

View file

@ -1,4 +1,6 @@
#include "window/Window.hpp"
#include "window/detail/BaseInput.hpp"
#include "window/detail/WindowBackends.hpp"
#include <GL/glew.h>
#include <GLFW/glfw3.h>
@ -18,9 +20,42 @@
static debug::Logger logger("window");
static const char* get_platform_name() {
#if GLFW_VERSION_MAJOR > 3 || (GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4)
switch (glfwGetPlatform()) {
case GLFW_PLATFORM_WIN32: return "Win32";
case GLFW_PLATFORM_COCOA: return "Cocoa";
case GLFW_PLATFORM_WAYLAND: return "Wayland (GLFW)";
case GLFW_PLATFORM_X11: return "X11";
case GLFW_PLATFORM_NULL: return "Null";
}
#endif
return "unknown";
}
static std::unordered_set<std::string> supported_gl_extensions;
static void window_size_callback(GLFWwindow* window, int width, int height);
static GLFWmonitor* get_window_monitor(GLFWwindow* window) {
int x = 0, y = 0, width = 0, height = 0;
glfwGetWindowPos(window, &x, &y);
glfwGetWindowSize(window, &width, &height);
x += width / 2;
y += height / 2;
int count = 0;
GLFWmonitor** monitors = glfwGetMonitors(&count);
for (int i = 0; i < count; i++) {
int monitorX = 0, monitorY = 0;
glfwGetMonitorPos(monitors[i], &monitorX, &monitorY);
const GLFWvidmode* mode = glfwGetVideoMode(monitors[i]);
if (mode && x >= monitorX && x < monitorX + mode->width &&
y >= monitorY && y < monitorY + mode->height) {
return monitors[i];
}
}
return glfwGetPrimaryMonitor();
}
static void init_gl_extensions_list() {
GLint numExtensions = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions);
@ -85,21 +120,6 @@ static void GLAPIENTRY gl_message_callback(
#endif
static bool initialize_gl(int width, int height) {
glewExperimental = GL_TRUE;
GLenum glewErr = glewInit();
if (glewErr != GLEW_OK) {
if (glewErr == GLEW_ERROR_NO_GLX_DISPLAY) {
// see issue #240
logger.warning()
<< "glewInit() returned GLEW_ERROR_NO_GLX_DISPLAY; ignored";
} else {
logger.error() << "failed to initialize GLEW:\n"
<< glewGetErrorString(glewErr);
return true;
}
}
#ifndef __APPLE__
glEnable(GL_DEBUG_OUTPUT);
glDebugMessageCallback(gl_message_callback, nullptr);
@ -163,137 +183,8 @@ static void glfw_error_callback(int error, const char* description) {
}
}
inline constexpr short KEYS_BUFFER_SIZE = 1036;
inline constexpr short MOUSE_KEYS_OFFSET = 1024;
static GLFWcursor* standard_cursors[static_cast<int>(CursorShape::LAST) + 1] = {};
class BaseInput : public Input {
public:
std::vector<uint> codepoints;
int scroll = 0;
void onKeyCallback(int key, bool pressed) {
bool prevPressed = keys[key];
keys[key] = pressed;
frames[key] = currentFrame;
if (pressed && !prevPressed) {
const auto& callbacks = keyCallbacks.find(static_cast<Keycode>(key));
if (callbacks != keyCallbacks.end()) {
callbacks->second.notify();
}
}
if (pressed && key < MOUSE_KEYS_OFFSET) {
pressedKeys.push_back(static_cast<Keycode>(key));
}
}
void onMouseCallback(int button, bool pressed) {
int key = button + MOUSE_KEYS_OFFSET;
onKeyCallback(key, pressed);
}
bool isCursorLocked() const override {
return cursorLocked;
}
void setCursorPosition(double xpos, double ypos) {
if (cursorDrag) {
delta.x += xpos - cursor.x;
delta.y += ypos - cursor.y;
} else {
cursorDrag = true;
}
cursor.x = xpos;
cursor.y = ypos;
}
Bindings& getBindings() override {
return bindings;
}
const Bindings& getBindings() const override {
return bindings;
}
ObserverHandler addKeyCallback(Keycode key, InputCallback callback) override {
return keyCallbacks[key].add(std::move(callback));
}
ObserverHandler addMouseCallback(Mousecode button, InputCallback callback) override {
return addKeyCallback(
static_cast<Keycode>(MOUSE_KEYS_OFFSET + static_cast<int>(button)),
std::move(callback)
);
}
const std::vector<Keycode>& getPressedKeys() const override {
return pressedKeys;
}
const std::vector<uint>& getCodepoints() const override {
return codepoints;
}
CursorState getCursor() const override {
return {isCursorLocked(), cursor, delta};
}
int getScroll() override {
return scroll;
}
bool pressed(Keycode key) const override {
int keycode = static_cast<int>(key);
if (keycode < 0 || keycode >= KEYS_BUFFER_SIZE) {
return false;
}
return keys[keycode];
}
bool jpressed(Keycode keycode) const override {
return pressed(keycode) &&
frames[static_cast<int>(keycode)] == currentFrame;
}
bool clicked(Mousecode code) const override {
return pressed(
static_cast<Keycode>(MOUSE_KEYS_OFFSET + static_cast<int>(code))
);
}
bool jclicked(Mousecode code) const override {
return clicked(code) &&
frames[static_cast<int>(code) + MOUSE_KEYS_OFFSET] ==
currentFrame;
}
void simulateKey(Keycode key, bool pressed) override {
onKeyCallback(static_cast<int>(key), pressed);
}
void simulateClick(int button, bool pressed) override {
onMouseCallback(static_cast<int>(button), pressed);
}
void simulateCursorPos(double xpos, double ypos) override {
setCursorPosition(xpos, ypos);
}
void simulateCodepoint(uint codepoint) override {
codepoints.push_back(codepoint);
}
protected:
uint currentFrame = 0;
uint frames[KEYS_BUFFER_SIZE] {};
std::vector<Keycode> pressedKeys;
Bindings bindings;
bool keys[KEYS_BUFFER_SIZE] {};
std::unordered_map<Keycode, util::HandlersList<>> keyCallbacks;
bool cursorLocked = false;
bool cursorDrag = false;
glm::vec2 delta {};
glm::vec2 cursor {};
};
class GLFWInput : public BaseInput {
public:
GLFWInput(GLFWwindow* window)
@ -301,48 +192,14 @@ public:
}
void pollEvents(bool waitForRefresh) override {
delta.x = 0.0f;
delta.y = 0.0f;
scroll = 0;
currentFrame++;
codepoints.clear();
pressedKeys.clear();
beginFrame();
if (waitForRefresh) {
glfwWaitEventsTimeout(0.5);
} else {
glfwPollEvents();
}
for (auto& [_, binding] : bindings.getAll()) {
if (!binding.enabled) {
binding.state = false;
continue;
}
binding.justChanged = false;
bool newstate = false;
switch (binding.type) {
case InputType::KEYBOARD:
newstate = pressed(static_cast<Keycode>(binding.code));
break;
case InputType::MOUSE:
newstate = clicked(static_cast<Mousecode>(binding.code));
break;
}
if (newstate) {
if (!binding.state) {
binding.state = true;
binding.justChanged = true;
binding.onactived.notify();
}
} else {
if (binding.state) {
binding.state = false;
binding.justChanged = true;
}
}
}
updateBindings();
}
const char* getClipboardText() const override {
@ -455,7 +312,7 @@ public:
void setMode(WindowMode mode) override {
Window::mode = mode;
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
GLFWmonitor* monitor = get_window_monitor(window);
const GLFWvidmode* glfwMode = glfwGetVideoMode(monitor);
if (input.isCursorLocked()){
@ -507,6 +364,10 @@ public:
glfwSetWindowTitle(window, title.c_str());
}
bool isIconSupported() const override {
return true;
}
void setIcon(const ImageData* image) override {
if (image == nullptr) {
glfwSetWindowIcon(window, 0, nullptr);
@ -709,7 +570,7 @@ static void setup_callbacks(GLFWwindow* window) {
std::tuple<
std::unique_ptr<Window>,
std::unique_ptr<Input>
> Window::initialize(DisplaySettings* settings, std::string title) {
> glfw_window_initialize(DisplaySettings* settings, std::string title) {
int width = settings->width.get();
int height = settings->height.get();
@ -718,6 +579,7 @@ std::tuple<
logger.error() << "failed to initialize GLFW";
return {nullptr, nullptr};
}
logger.info() << "windowing platform: " << get_platform_name();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
@ -782,7 +644,6 @@ std::tuple<
setup_callbacks(window);
glfwSwapInterval(1);
input_util::initialize();
create_standard_cursors();
glm::vec2 scale;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,17 @@
#pragma once
#include <memory>
#include <string>
#include <tuple>
class Window;
class Input;
struct DisplaySettings;
std::tuple<std::unique_ptr<Window>, std::unique_ptr<Input>>
glfw_window_initialize(DisplaySettings* settings, std::string title);
#ifdef VOXELENGINE_WAYLAND
std::tuple<std::unique_ptr<Window>, std::unique_ptr<Input>>
wayland_window_initialize(DisplaySettings* settings, std::string title);
#endif

View file

@ -1,339 +1,267 @@
#include "input.hpp"
#include "debug/Logger.hpp"
#include "util/stringutil.hpp"
#include "data/dv.hpp"
#include <GLFW/glfw3.h>
#include <unordered_map>
#ifdef _WIN32
#include <windows.h>
#endif // _WIN32
static debug::Logger logger("input");
static std::unordered_map<std::string, int> keycodes {
{"enter", GLFW_KEY_ENTER},
{"space", GLFW_KEY_SPACE},
{"backspace", GLFW_KEY_BACKSPACE},
{"caps-lock", GLFW_KEY_CAPS_LOCK},
{"escape", GLFW_KEY_ESCAPE},
{"delete", GLFW_KEY_DELETE},
{"home", GLFW_KEY_HOME},
{"end", GLFW_KEY_END},
{"tab", GLFW_KEY_TAB},
{"insert", GLFW_KEY_INSERT},
{"page-down", GLFW_KEY_PAGE_DOWN},
{"page-up", GLFW_KEY_PAGE_UP},
{"left-shift", GLFW_KEY_LEFT_SHIFT},
{"right-shift", GLFW_KEY_RIGHT_SHIFT},
{"left-ctrl", GLFW_KEY_LEFT_CONTROL},
{"right-ctrl", GLFW_KEY_RIGHT_CONTROL},
{"left-alt", GLFW_KEY_LEFT_ALT},
{"right-alt", GLFW_KEY_RIGHT_ALT},
{"left-super", GLFW_KEY_LEFT_SUPER},
{"right-super", GLFW_KEY_RIGHT_SUPER},
{"grave-accent", GLFW_KEY_GRAVE_ACCENT},
{"left", GLFW_KEY_LEFT},
{"right", GLFW_KEY_RIGHT},
{"down", GLFW_KEY_DOWN},
{"up", GLFW_KEY_UP},
{"num-lock", GLFW_KEY_NUM_LOCK},
{"print-screen", GLFW_KEY_PRINT_SCREEN},
{"num-add", GLFW_KEY_KP_ADD},
{"num-multiply", GLFW_KEY_KP_MULTIPLY},
{"num-divide", GLFW_KEY_KP_DIVIDE},
{"num-subtract", GLFW_KEY_KP_SUBTRACT},
{"num-enter", GLFW_KEY_KP_ENTER},
{"num-equal", GLFW_KEY_KP_EQUAL},
{"num-decimal", GLFW_KEY_KP_DECIMAL},
};
static std::unordered_map<std::string, int> mousecodes {
{"left", GLFW_MOUSE_BUTTON_1},
{"right", GLFW_MOUSE_BUTTON_2},
{"middle", GLFW_MOUSE_BUTTON_3},
{"side1", GLFW_MOUSE_BUTTON_4},
{"side2", GLFW_MOUSE_BUTTON_5},
{"side3", GLFW_MOUSE_BUTTON_6},
{"side4", GLFW_MOUSE_BUTTON_7},
{"side5", GLFW_MOUSE_BUTTON_8},
};
static std::unordered_map<int, std::string> keynames {};
static std::unordered_map<int, std::string> buttonsnames{};
std::string input_util::get_name(Mousecode code) {
const auto found = buttonsnames.find(static_cast<int>(code));
if (found == buttonsnames.end()) {
return "unknown";
}
return found->second;
}
std::string input_util::get_name(Keycode code) {
const auto found = keynames.find(static_cast<int>(code));
if (found == keynames.end()) {
return "unknown";
}
return found->second;
}
void Binding::reset(InputType type, int code) {
this->type = type;
this->code = code;
}
void Binding::reset(Keycode code) {
reset(InputType::KEYBOARD, static_cast<int>(code));
}
void Binding::reset(Mousecode code) {
reset(InputType::MOUSE, static_cast<int>(code));
}
void input_util::initialize() {
for (int i = 0; i <= 9; i++) {
keycodes[std::to_string(i)] = GLFW_KEY_0 + i;
}
for (int i = 0; i < 25; i++) {
keycodes["f" + std::to_string(i + 1)] = GLFW_KEY_F1 + i;
}
for (char i = 'a'; i <= 'z'; i++) {
keycodes[std::string({i})] = GLFW_KEY_A - 'a' + i;
}
for (int i = 0; i <= 9; i++) {
keycodes["num-" + std::to_string(i)] = GLFW_KEY_KP_0 + i;
}
for (const auto& entry : keycodes) {
keynames[entry.second] = entry.first;
}
for (const auto& entry : mousecodes) {
buttonsnames[entry.second] = entry.first;
}
}
Keycode input_util::keycode_from(const std::string& name) {
const auto& found = keycodes.find(name);
if (found == keycodes.end()) {
return Keycode::UNKNOWN;
}
return static_cast<Keycode>(found->second);
}
Mousecode input_util::mousecode_from(const std::string& name) {
const auto& found = mousecodes.find(name);
if (found == mousecodes.end()) {
return Mousecode::UNKNOWN;
}
return static_cast<Mousecode>(found->second);
}
static const char* numpad_key_names[] {
"Num 0",
"Num 1",
"Num 2",
"Num 3",
"Num 4",
"Num 5",
"Num 6",
"Num 7",
"Num 8",
"Num 9",
"Num .",
"Num /",
"Num *",
"Num -",
"Num +",
"Num Enter",
"Num =",
};
std::string input_util::to_string(Keycode code) {
int icode_repr = static_cast<int>(code);
if (icode_repr == -1) {
return "Unknown";
}
if (icode_repr >= GLFW_KEY_KP_0 && icode_repr <= GLFW_KEY_KP_EQUAL) {
return numpad_key_names[icode_repr - GLFW_KEY_KP_0];
}
const char* name =
glfwGetKeyName(icode_repr, glfwGetKeyScancode(icode_repr));
if (name == nullptr) {
switch (icode_repr) {
case GLFW_KEY_TAB:
return "Tab";
case GLFW_KEY_LEFT_CONTROL:
return "Left Ctrl";
case GLFW_KEY_RIGHT_CONTROL:
return "Right Ctrl";
case GLFW_KEY_LEFT_ALT:
return "Left Alt";
case GLFW_KEY_RIGHT_ALT:
return "Right Alt";
case GLFW_KEY_LEFT_SHIFT:
return "Left Shift";
case GLFW_KEY_RIGHT_SHIFT:
return "Right Shift";
case GLFW_KEY_CAPS_LOCK:
return "Caps-Lock";
case GLFW_KEY_SPACE:
return "Space";
case GLFW_KEY_ESCAPE:
return "Esc";
case GLFW_KEY_ENTER:
return "Enter";
case GLFW_KEY_UP:
return "Up";
case GLFW_KEY_DOWN:
return "Down";
case GLFW_KEY_LEFT:
return "Left";
case GLFW_KEY_RIGHT:
return "Right";
case GLFW_KEY_BACKSPACE:
return "Backspace";
case GLFW_KEY_F1:
return "F1";
case GLFW_KEY_F2:
return "F2";
case GLFW_KEY_F3:
return "F3";
case GLFW_KEY_F4:
return "F4";
case GLFW_KEY_F5:
return "F5";
case GLFW_KEY_F6:
return "F6";
case GLFW_KEY_F7:
return "F7";
case GLFW_KEY_F8:
return "F8";
case GLFW_KEY_F9:
return "F9";
case GLFW_KEY_F10:
return "F10";
case GLFW_KEY_F11:
return "F11";
case GLFW_KEY_F12:
return "F12";
case GLFW_KEY_DELETE:
return "Delete";
case GLFW_KEY_HOME:
return "Home";
case GLFW_KEY_END:
return "End";
case GLFW_KEY_LEFT_SUPER:
return "Left Super";
case GLFW_KEY_RIGHT_SUPER:
return "Right Super";
case GLFW_KEY_PAGE_UP:
return "Page Up";
case GLFW_KEY_PAGE_DOWN:
return "Page Down";
case GLFW_KEY_INSERT:
return "Insert";
case GLFW_KEY_PRINT_SCREEN:
return "Print Screen";
case GLFW_KEY_NUM_LOCK:
return "Num Lock";
case GLFW_KEY_MENU:
return "Menu";
case GLFW_KEY_PAUSE:
return "Pause";
default:
return "Unknown";
}
}
return std::string(name);
}
std::string input_util::to_string(Mousecode code) {
switch (code) {
case Mousecode::BUTTON_1:
return "LMB";
case Mousecode::BUTTON_2:
return "RMB";
case Mousecode::BUTTON_3:
return "MMB";
case Mousecode::BUTTON_4:
case Mousecode::BUTTON_5:
case Mousecode::BUTTON_6:
case Mousecode::BUTTON_7:
case Mousecode::BUTTON_8:
return "XButton " + std::to_string(static_cast<int>(code) -
static_cast<int>(Mousecode::BUTTON_3));
default:
return "unknown button";
}
}
const Binding& Bindings::require(const std::string& name) const {
if (const auto found = get(name)) {
return *found;
}
throw std::runtime_error("binding '" + name + "' does not exist");
}
Binding& Bindings::require(const std::string& name) {
if (const auto found = get(name)) {
return *found;
}
throw std::runtime_error("binding '" + name + "' does not exist");
}
void Bindings::read(const dv::value& map, BindType bindType) {
for (auto& [sectionName, section] : map.asObject()) {
for (auto& [name, value] : section.asObject()) {
auto key = sectionName + "." + name;
auto [prefix, codename] = util::split_at(value.asString(), ':');
InputType type;
int code;
if (prefix == "key") {
type = InputType::KEYBOARD;
code = static_cast<int>(input_util::keycode_from(codename));
} else if (prefix == "mouse") {
type = InputType::MOUSE;
code = static_cast<int>(input_util::mousecode_from(codename));
} else {
logger.error()
<< "unknown input type: " << prefix << " (binding "
<< util::quote(key) << ")";
continue;
}
if (bindType == BindType::BIND) {
bind(key, type, code);
} else if (bindType == BindType::REBIND) {
rebind(key, type, code);
}
}
}
}
#include "coders/toml.hpp"
std::string Bindings::write() const {
auto obj = dv::object();
for (auto& entry : bindings) {
const auto& binding = entry.second;
std::string value;
switch (binding.type) {
case InputType::KEYBOARD:
value =
"key:" +
input_util::get_name(static_cast<Keycode>(binding.code));
break;
case InputType::MOUSE:
value =
"mouse:" +
input_util::get_name(static_cast<Mousecode>(binding.code));
break;
default:
throw std::runtime_error("unsupported control type");
}
obj[entry.first] = std::move(value);
}
return toml::stringify(obj);
}
#include "input.hpp"
#include "debug/Logger.hpp"
#include "util/stringutil.hpp"
#include "data/dv.hpp"
#include <GLFW/glfw3.h>
#include <cctype>
#include <unordered_map>
#ifdef _WIN32
#include <windows.h>
#endif // _WIN32
static debug::Logger logger("input");
static std::unordered_map<std::string, int> keycodes {
{"enter", GLFW_KEY_ENTER},
{"space", GLFW_KEY_SPACE},
{"backspace", GLFW_KEY_BACKSPACE},
{"caps-lock", GLFW_KEY_CAPS_LOCK},
{"escape", GLFW_KEY_ESCAPE},
{"delete", GLFW_KEY_DELETE},
{"home", GLFW_KEY_HOME},
{"end", GLFW_KEY_END},
{"tab", GLFW_KEY_TAB},
{"insert", GLFW_KEY_INSERT},
{"page-down", GLFW_KEY_PAGE_DOWN},
{"page-up", GLFW_KEY_PAGE_UP},
{"left-shift", GLFW_KEY_LEFT_SHIFT},
{"right-shift", GLFW_KEY_RIGHT_SHIFT},
{"left-ctrl", GLFW_KEY_LEFT_CONTROL},
{"right-ctrl", GLFW_KEY_RIGHT_CONTROL},
{"left-alt", GLFW_KEY_LEFT_ALT},
{"right-alt", GLFW_KEY_RIGHT_ALT},
{"left-super", GLFW_KEY_LEFT_SUPER},
{"right-super", GLFW_KEY_RIGHT_SUPER},
{"grave-accent", GLFW_KEY_GRAVE_ACCENT},
{"left", GLFW_KEY_LEFT},
{"right", GLFW_KEY_RIGHT},
{"down", GLFW_KEY_DOWN},
{"up", GLFW_KEY_UP},
{"num-lock", GLFW_KEY_NUM_LOCK},
{"print-screen", GLFW_KEY_PRINT_SCREEN},
{"num-add", GLFW_KEY_KP_ADD},
{"num-multiply", GLFW_KEY_KP_MULTIPLY},
{"num-divide", GLFW_KEY_KP_DIVIDE},
{"num-subtract", GLFW_KEY_KP_SUBTRACT},
{"num-enter", GLFW_KEY_KP_ENTER},
{"num-equal", GLFW_KEY_KP_EQUAL},
{"num-decimal", GLFW_KEY_KP_DECIMAL},
};
static std::unordered_map<std::string, int> mousecodes {
{"left", GLFW_MOUSE_BUTTON_1},
{"right", GLFW_MOUSE_BUTTON_2},
{"middle", GLFW_MOUSE_BUTTON_3},
{"side1", GLFW_MOUSE_BUTTON_4},
{"side2", GLFW_MOUSE_BUTTON_5},
{"side3", GLFW_MOUSE_BUTTON_6},
{"side4", GLFW_MOUSE_BUTTON_7},
{"side5", GLFW_MOUSE_BUTTON_8},
};
static std::unordered_map<int, std::string> keynames {};
static std::unordered_map<int, std::string> buttonsnames{};
std::string input_util::get_name(Mousecode code) {
const auto found = buttonsnames.find(static_cast<int>(code));
if (found == buttonsnames.end()) {
return "unknown";
}
return found->second;
}
std::string input_util::get_name(Keycode code) {
const auto found = keynames.find(static_cast<int>(code));
if (found == keynames.end()) {
return "unknown";
}
return found->second;
}
void Binding::reset(InputType type, int code) {
this->type = type;
this->code = code;
}
void Binding::reset(Keycode code) {
reset(InputType::KEYBOARD, static_cast<int>(code));
}
void Binding::reset(Mousecode code) {
reset(InputType::MOUSE, static_cast<int>(code));
}
void input_util::initialize() {
for (int i = 0; i <= 9; i++) {
keycodes[std::to_string(i)] = GLFW_KEY_0 + i;
}
for (int i = 0; i < 25; i++) {
keycodes["f" + std::to_string(i + 1)] = GLFW_KEY_F1 + i;
}
for (char i = 'a'; i <= 'z'; i++) {
keycodes[std::string({i})] = GLFW_KEY_A - 'a' + i;
}
for (int i = 0; i <= 9; i++) {
keycodes["num-" + std::to_string(i)] = GLFW_KEY_KP_0 + i;
}
for (const auto& entry : keycodes) {
keynames[entry.second] = entry.first;
}
for (const auto& entry : mousecodes) {
buttonsnames[entry.second] = entry.first;
}
}
Keycode input_util::keycode_from(const std::string& name) {
const auto& found = keycodes.find(name);
if (found == keycodes.end()) {
return Keycode::UNKNOWN;
}
return static_cast<Keycode>(found->second);
}
Mousecode input_util::mousecode_from(const std::string& name) {
const auto& found = mousecodes.find(name);
if (found == mousecodes.end()) {
return Mousecode::UNKNOWN;
}
return static_cast<Mousecode>(found->second);
}
static const char* numpad_key_names[] {
"Num 0",
"Num 1",
"Num 2",
"Num 3",
"Num 4",
"Num 5",
"Num 6",
"Num 7",
"Num 8",
"Num 9",
"Num .",
"Num /",
"Num *",
"Num -",
"Num +",
"Num Enter",
"Num =",
};
std::string input_util::to_string(Keycode code) {
int icode_repr = static_cast<int>(code);
if (icode_repr == -1) {
return "Unknown";
}
if (icode_repr >= GLFW_KEY_KP_0 && icode_repr <= GLFW_KEY_KP_EQUAL) {
return numpad_key_names[icode_repr - GLFW_KEY_KP_0];
}
const auto found = keynames.find(icode_repr);
if (found == keynames.end()) {
return "Unknown";
}
std::string result;
bool capitalize = true;
for (char c : found->second) {
if (c == '-') {
result += ' ';
capitalize = true;
continue;
}
result += capitalize ? static_cast<char>(std::toupper(c)) : c;
capitalize = false;
}
return result;
}
std::string input_util::to_string(Mousecode code) {
switch (code) {
case Mousecode::BUTTON_1:
return "LMB";
case Mousecode::BUTTON_2:
return "RMB";
case Mousecode::BUTTON_3:
return "MMB";
case Mousecode::BUTTON_4:
case Mousecode::BUTTON_5:
case Mousecode::BUTTON_6:
case Mousecode::BUTTON_7:
case Mousecode::BUTTON_8:
return "XButton " + std::to_string(static_cast<int>(code) -
static_cast<int>(Mousecode::BUTTON_3));
default:
return "unknown button";
}
}
const Binding& Bindings::require(const std::string& name) const {
if (const auto found = get(name)) {
return *found;
}
throw std::runtime_error("binding '" + name + "' does not exist");
}
Binding& Bindings::require(const std::string& name) {
if (const auto found = get(name)) {
return *found;
}
throw std::runtime_error("binding '" + name + "' does not exist");
}
void Bindings::read(const dv::value& map, BindType bindType) {
for (auto& [sectionName, section] : map.asObject()) {
for (auto& [name, value] : section.asObject()) {
auto key = sectionName + "." + name;
auto [prefix, codename] = util::split_at(value.asString(), ':');
InputType type;
int code;
if (prefix == "key") {
type = InputType::KEYBOARD;
code = static_cast<int>(input_util::keycode_from(codename));
} else if (prefix == "mouse") {
type = InputType::MOUSE;
code = static_cast<int>(input_util::mousecode_from(codename));
} else {
logger.error()
<< "unknown input type: " << prefix << " (binding "
<< util::quote(key) << ")";
continue;
}
if (bindType == BindType::BIND) {
bind(key, type, code);
} else if (bindType == BindType::REBIND) {
rebind(key, type, code);
}
}
}
}
#include "coders/toml.hpp"
std::string Bindings::write() const {
auto obj = dv::object();
for (auto& entry : bindings) {
const auto& binding = entry.second;
std::string value;
switch (binding.type) {
case InputType::KEYBOARD:
value =
"key:" +
input_util::get_name(static_cast<Keycode>(binding.code));
break;
case InputType::MOUSE:
value =
"mouse:" +
input_util::get_name(static_cast<Mousecode>(binding.code));
break;
default:
throw std::runtime_error("unsupported control type");
}
obj[entry.first] = std::move(value);
}
return toml::stringify(obj);
}

View file

@ -0,0 +1,162 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="cursor_shape_v1">
<copyright>
Copyright 2018 The Chromium Authors
Copyright 2023 Simon Ser
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="wp_cursor_shape_manager_v1" version="2">
<description summary="cursor shape manager">
This global offers an alternative, optional way to set cursor images. This
new way uses enumerated cursors instead of a wl_surface like
wl_pointer.set_cursor does.
Warning! The protocol described in this file is currently in the testing
phase. Backward compatible changes may be added together with the
corresponding interface version bump. Backward incompatible changes can
only be done by creating a new major version of the extension.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the manager">
Destroy the cursor shape manager.
</description>
</request>
<request name="get_pointer">
<description summary="manage the cursor shape of a pointer device">
Obtain a wp_cursor_shape_device_v1 for a wl_pointer object.
When the pointer capability is removed from the wl_seat, the
wp_cursor_shape_device_v1 object becomes inert.
</description>
<arg name="cursor_shape_device" type="new_id" interface="wp_cursor_shape_device_v1"/>
<arg name="pointer" type="object" interface="wl_pointer"/>
</request>
<request name="get_tablet_tool_v2">
<description summary="manage the cursor shape of a tablet tool device">
Obtain a wp_cursor_shape_device_v1 for a zwp_tablet_tool_v2 object.
When the zwp_tablet_tool_v2 is removed, the wp_cursor_shape_device_v1
object becomes inert.
</description>
<arg name="cursor_shape_device" type="new_id" interface="wp_cursor_shape_device_v1"/>
<arg name="tablet_tool" type="object" interface="zwp_tablet_tool_v2"/>
</request>
</interface>
<interface name="wp_cursor_shape_device_v1" version="2">
<description summary="cursor shape for a device">
This interface allows clients to set the cursor shape.
</description>
<enum name="shape">
<description summary="cursor shapes">
This enum describes cursor shapes.
The names are taken from the CSS W3C specification:
https://w3c.github.io/csswg-drafts/css-ui/#cursor
with a few additions.
Note that there are some groups of cursor shapes that are related:
The first group is drag-and-drop cursors which are used to indicate
the selected action during dnd operations. The second group is resize
cursors which are used to indicate resizing and moving possibilities
on window borders. It is recommended that the shapes in these groups
should use visually compatible images and metaphors.
</description>
<entry name="default" value="1" summary="default cursor"/>
<entry name="context_menu" value="2" summary="a context menu is available for the object under the cursor"/>
<entry name="help" value="3" summary="help is available for the object under the cursor"/>
<entry name="pointer" value="4" summary="pointer that indicates a link or another interactive element"/>
<entry name="progress" value="5" summary="progress indicator"/>
<entry name="wait" value="6" summary="program is busy, user should wait"/>
<entry name="cell" value="7" summary="a cell or set of cells may be selected"/>
<entry name="crosshair" value="8" summary="simple crosshair"/>
<entry name="text" value="9" summary="text may be selected"/>
<entry name="vertical_text" value="10" summary="vertical text may be selected"/>
<entry name="alias" value="11" summary="drag-and-drop: alias of/shortcut to something is to be created"/>
<entry name="copy" value="12" summary="drag-and-drop: something is to be copied"/>
<entry name="move" value="13" summary="drag-and-drop: something is to be moved"/>
<entry name="no_drop" value="14" summary="drag-and-drop: the dragged item cannot be dropped at the current cursor location"/>
<entry name="not_allowed" value="15" summary="drag-and-drop: the requested action will not be carried out"/>
<entry name="grab" value="16" summary="drag-and-drop: something can be grabbed"/>
<entry name="grabbing" value="17" summary="drag-and-drop: something is being grabbed"/>
<entry name="e_resize" value="18" summary="resizing: the east border is to be moved"/>
<entry name="n_resize" value="19" summary="resizing: the north border is to be moved"/>
<entry name="ne_resize" value="20" summary="resizing: the north-east corner is to be moved"/>
<entry name="nw_resize" value="21" summary="resizing: the north-west corner is to be moved"/>
<entry name="s_resize" value="22" summary="resizing: the south border is to be moved"/>
<entry name="se_resize" value="23" summary="resizing: the south-east corner is to be moved"/>
<entry name="sw_resize" value="24" summary="resizing: the south-west corner is to be moved"/>
<entry name="w_resize" value="25" summary="resizing: the west border is to be moved"/>
<entry name="ew_resize" value="26" summary="resizing: the east and west borders are to be moved"/>
<entry name="ns_resize" value="27" summary="resizing: the north and south borders are to be moved"/>
<entry name="nesw_resize" value="28" summary="resizing: the north-east and south-west corners are to be moved"/>
<entry name="nwse_resize" value="29" summary="resizing: the north-west and south-east corners are to be moved"/>
<entry name="col_resize" value="30" summary="resizing: that the item/column can be resized horizontally"/>
<entry name="row_resize" value="31" summary="resizing: that the item/row can be resized vertically"/>
<entry name="all_scroll" value="32" summary="something can be scrolled in any direction"/>
<entry name="zoom_in" value="33" summary="something can be zoomed in"/>
<entry name="zoom_out" value="34" summary="something can be zoomed out"/>
<entry name="dnd_ask" value="35" summary="drag-and-drop: the user will select which action will be carried out (non-css value)" since="2"/>
<entry name="all_resize" value="36" summary="resizing: something can be moved or resized in any direction (non-css value)" since="2"/>
</enum>
<enum name="error">
<entry name="invalid_shape" value="1"
summary="the specified shape value is invalid"/>
</enum>
<request name="destroy" type="destructor">
<description summary="destroy the cursor shape device">
Destroy the cursor shape device.
The device cursor shape remains unchanged.
</description>
</request>
<request name="set_shape">
<description summary="set device cursor to the shape">
Sets the device cursor to the specified shape. The compositor will
change the cursor image based on the specified shape.
The cursor actually changes only if the input device focus is one of
the requesting client's surfaces. If any, the previous cursor image
(surface or shape) is replaced.
The "shape" argument must be a valid enum entry, otherwise the
invalid_shape protocol error is raised.
This is similar to the wl_pointer.set_cursor and
zwp_tablet_tool_v2.set_cursor requests, but this request accepts a
shape instead of contents in the form of a surface. Clients can mix
set_cursor and set_shape requests.
The serial parameter must match the latest wl_pointer.enter or
zwp_tablet_tool_v2.proximity_in serial number sent to the client.
Otherwise the request will be ignored.
</description>
<arg name="serial" type="uint" summary="serial number of the enter event"/>
<arg name="shape" type="uint" enum="shape"/>
</request>
</interface>
</protocol>

View file

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="idle_inhibit_unstable_v1">
<copyright>
Copyright © 2015 Samsung Electronics Co., Ltd
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="zwp_idle_inhibit_manager_v1" version="1">
<description summary="control behavior when display idles">
This interface permits inhibiting the idle behavior such as screen
blanking, locking, and screensaving. The client binds the idle manager
globally, then creates idle-inhibitor objects for each surface.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible changes
may be added together with the corresponding interface version bump.
Backward incompatible changes are done by bumping the version number in
the protocol and interface names and resetting the interface version.
Once the protocol is to be declared stable, the 'z' prefix and the
version number in the protocol and interface names are removed and the
interface version number is reset.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the idle inhibitor object">
Destroy the inhibit manager.
</description>
</request>
<request name="create_inhibitor">
<description summary="create a new inhibitor object">
Create a new inhibitor object associated with the given surface.
</description>
<arg name="id" type="new_id" interface="zwp_idle_inhibitor_v1"/>
<arg name="surface" type="object" interface="wl_surface"
summary="the surface that inhibits the idle behavior"/>
</request>
</interface>
<interface name="zwp_idle_inhibitor_v1" version="1">
<description summary="context object for inhibiting idle behavior">
An idle inhibitor prevents the output that the associated surface is
visible on from being set to a state where it is not visually usable due
to lack of user interaction (e.g. blanked, dimmed, locked, set to power
save, etc.) Any screensaver processes are also blocked from displaying.
If the surface is destroyed, unmapped, becomes occluded, loses
visibility, or otherwise becomes not visually relevant for the user, the
idle inhibitor will not be honored by the compositor; if the surface
subsequently regains visibility the inhibitor takes effect once again.
Likewise, the inhibitor isn't honored if the system was already idled at
the time the inhibitor was established, although if the system later
de-idles and re-idles the inhibitor will take effect.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the idle inhibitor object">
Remove the inhibitor effect from the associated wl_surface.
</description>
</request>
</interface>
</protocol>

View file

@ -0,0 +1,334 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="pointer_constraints_unstable_v1">
<copyright>
Copyright © 2014 Jonas Ådahl
Copyright © 2015 Red Hat Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<description summary="protocol for constraining pointer motions">
This protocol specifies a set of interfaces used for adding constraints to
the motion of a pointer. Possible constraints include confining pointer
motions to a given region, or locking it to its current position.
In order to constrain the pointer, a client must first bind the global
interface "wp_pointer_constraints" which, if a compositor supports pointer
constraints, is exposed by the registry. Using the bound global object, the
client uses the request that corresponds to the type of constraint it wants
to make. See wp_pointer_constraints for more details.
Warning! The protocol described in this file is experimental and backward
incompatible changes may be made. Backward compatible changes may be added
together with the corresponding interface version bump. Backward
incompatible changes are done by bumping the version number in the protocol
and interface names and resetting the interface version. Once the protocol
is to be declared stable, the 'z' prefix and the version number in the
protocol and interface names are removed and the interface version number is
reset.
</description>
<interface name="zwp_pointer_constraints_v1" version="1">
<description summary="constrain the movement of a pointer">
The global interface exposing pointer constraining functionality. It
exposes two requests: lock_pointer for locking the pointer to its
position, and confine_pointer for locking the pointer to a region.
The lock_pointer and confine_pointer requests create the objects
wp_locked_pointer and wp_confined_pointer respectively, and the client can
use these objects to interact with the lock.
For any surface, only one lock or confinement may be active across all
wl_pointer objects of the same seat. If a lock or confinement is requested
when another lock or confinement is active or requested on the same surface
and with any of the wl_pointer objects of the same seat, an
'already_constrained' error will be raised.
</description>
<enum name="error">
<description summary="wp_pointer_constraints error values">
These errors can be emitted in response to wp_pointer_constraints
requests.
</description>
<entry name="already_constrained" value="1"
summary="pointer constraint already requested on that surface"/>
</enum>
<enum name="lifetime">
<description summary="constraint lifetime">
These values represent different lifetime semantics. They are passed
as arguments to the factory requests to specify how the constraint
lifetimes should be managed.
</description>
<entry name="oneshot" value="1">
<description summary="the pointer constraint is defunct once deactivated">
A oneshot pointer constraint will never reactivate once it has been
deactivated. See the corresponding deactivation event
(wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for
details.
</description>
</entry>
<entry name="persistent" value="2">
<description summary="the pointer constraint may reactivate">
A persistent pointer constraint may again reactivate once it has
been deactivated. See the corresponding deactivation event
(wp_locked_pointer.unlocked and wp_confined_pointer.unconfined) for
details.
</description>
</entry>
</enum>
<request name="destroy" type="destructor">
<description summary="destroy the pointer constraints manager object">
Used by the client to notify the server that it will no longer use this
pointer constraints object.
</description>
</request>
<request name="lock_pointer">
<description summary="lock pointer to a position">
The lock_pointer request lets the client request to disable movements of
the virtual pointer (i.e. the cursor), effectively locking the pointer
to a position. This request may not take effect immediately; in the
future, when the compositor deems implementation-specific constraints
are satisfied, the pointer lock will be activated and the compositor
sends a locked event.
The protocol provides no guarantee that the constraints are ever
satisfied, and does not require the compositor to send an error if the
constraints cannot ever be satisfied. It is thus possible to request a
lock that will never activate.
There may not be another pointer constraint of any kind requested or
active on the surface for any of the wl_pointer objects of the seat of
the passed pointer when requesting a lock. If there is, an error will be
raised. See general pointer lock documentation for more details.
The intersection of the region passed with this request and the input
region of the surface is used to determine where the pointer must be
in order for the lock to activate. It is up to the compositor whether to
warp the pointer or require some kind of user interaction for the lock
to activate. If the region is null the surface input region is used.
A surface may receive pointer focus without the lock being activated.
The request creates a new object wp_locked_pointer which is used to
interact with the lock as well as receive updates about its state. See
the the description of wp_locked_pointer for further information.
Note that while a pointer is locked, the wl_pointer objects of the
corresponding seat will not emit any wl_pointer.motion events, but
relative motion events will still be emitted via wp_relative_pointer
objects of the same seat. wl_pointer.axis and wl_pointer.button events
are unaffected.
</description>
<arg name="id" type="new_id" interface="zwp_locked_pointer_v1"/>
<arg name="surface" type="object" interface="wl_surface"
summary="surface to lock pointer to"/>
<arg name="pointer" type="object" interface="wl_pointer"
summary="the pointer that should be locked"/>
<arg name="region" type="object" interface="wl_region" allow-null="true"
summary="region of surface"/>
<arg name="lifetime" type="uint" enum="lifetime" summary="lock lifetime"/>
</request>
<request name="confine_pointer">
<description summary="confine pointer to a region">
The confine_pointer request lets the client request to confine the
pointer cursor to a given region. This request may not take effect
immediately; in the future, when the compositor deems implementation-
specific constraints are satisfied, the pointer confinement will be
activated and the compositor sends a confined event.
The intersection of the region passed with this request and the input
region of the surface is used to determine where the pointer must be
in order for the confinement to activate. It is up to the compositor
whether to warp the pointer or require some kind of user interaction for
the confinement to activate. If the region is null the surface input
region is used.
The request will create a new object wp_confined_pointer which is used
to interact with the confinement as well as receive updates about its
state. See the the description of wp_confined_pointer for further
information.
</description>
<arg name="id" type="new_id" interface="zwp_confined_pointer_v1"/>
<arg name="surface" type="object" interface="wl_surface"
summary="surface to lock pointer to"/>
<arg name="pointer" type="object" interface="wl_pointer"
summary="the pointer that should be confined"/>
<arg name="region" type="object" interface="wl_region" allow-null="true"
summary="region of surface"/>
<arg name="lifetime" type="uint" enum="lifetime" summary="confinement lifetime"/>
</request>
</interface>
<interface name="zwp_locked_pointer_v1" version="1">
<description summary="receive relative pointer motion events">
The wp_locked_pointer interface represents a locked pointer state.
While the lock of this object is active, the wl_pointer objects of the
associated seat will not emit any wl_pointer.motion events.
This object will send the event 'locked' when the lock is activated.
Whenever the lock is activated, it is guaranteed that the locked surface
will already have received pointer focus and that the pointer will be
within the region passed to the request creating this object.
To unlock the pointer, send the destroy request. This will also destroy
the wp_locked_pointer object.
If the compositor decides to unlock the pointer the unlocked event is
sent. See wp_locked_pointer.unlock for details.
When unlocking, the compositor may warp the cursor position to the set
cursor position hint. If it does, it will not result in any relative
motion events emitted via wp_relative_pointer.
If the surface the lock was requested on is destroyed and the lock is not
yet activated, the wp_locked_pointer object is now defunct and must be
destroyed.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the locked pointer object">
Destroy the locked pointer object. If applicable, the compositor will
unlock the pointer.
</description>
</request>
<request name="set_cursor_position_hint">
<description summary="set the pointer cursor position hint">
Set the cursor position hint relative to the top left corner of the
surface.
If the client is drawing its own cursor, it should update the position
hint to the position of its own cursor. A compositor may use this
information to warp the pointer upon unlock in order to avoid pointer
jumps.
The cursor position hint is double-buffered state, see
wl_surface.commit.
</description>
<arg name="surface_x" type="fixed"
summary="surface-local x coordinate"/>
<arg name="surface_y" type="fixed"
summary="surface-local y coordinate"/>
</request>
<request name="set_region">
<description summary="set a new lock region">
Set a new region used to lock the pointer.
The new lock region is double-buffered, see wl_surface.commit.
For details about the lock region, see wp_locked_pointer.
</description>
<arg name="region" type="object" interface="wl_region" allow-null="true"
summary="region of surface"/>
</request>
<event name="locked">
<description summary="lock activation event">
Notification that the pointer lock of the seat's pointer is activated.
</description>
</event>
<event name="unlocked">
<description summary="lock deactivation event">
Notification that the pointer lock of the seat's pointer is no longer
active. If this is a oneshot pointer lock (see
wp_pointer_constraints.lifetime) this object is now defunct and should
be destroyed. If this is a persistent pointer lock (see
wp_pointer_constraints.lifetime) this pointer lock may again
reactivate in the future.
</description>
</event>
</interface>
<interface name="zwp_confined_pointer_v1" version="1">
<description summary="confined pointer object">
The wp_confined_pointer interface represents a confined pointer state.
This object will send the event 'confined' when the confinement is
activated. Whenever the confinement is activated, it is guaranteed that
the surface the pointer is confined to will already have received pointer
focus and that the pointer will be within the region passed to the request
creating this object. It is up to the compositor to decide whether this
requires some user interaction and if the pointer will warp to within the
passed region if outside.
To unconfine the pointer, send the destroy request. This will also destroy
the wp_confined_pointer object.
If the compositor decides to unconfine the pointer the unconfined event is
sent. The wp_confined_pointer object is at this point defunct and should
be destroyed.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the confined pointer object">
Destroy the confined pointer object. If applicable, the compositor will
unconfine the pointer.
</description>
</request>
<request name="set_region">
<description summary="set a new confine region">
Set a new region used to confine the pointer.
The new confine region is double-buffered, see wl_surface.commit.
If the confinement is active when the new confinement region is applied
and the pointer ends up outside of newly applied region, the pointer may
warped to a position within the new confinement region. If warped, a
wl_pointer.motion event will be emitted, but no
wp_relative_pointer.relative_motion event.
The compositor may also, instead of using the new region, unconfine the
pointer.
For details about the confine region, see wp_confined_pointer.
</description>
<arg name="region" type="object" interface="wl_region" allow-null="true"
summary="region of surface"/>
</request>
<event name="confined">
<description summary="pointer confined">
Notification that the pointer confinement of the seat's pointer is
activated.
</description>
</event>
<event name="unconfined">
<description summary="pointer unconfined">
Notification that the pointer confinement of the seat's pointer is no
longer active. If this is a oneshot pointer confinement (see
wp_pointer_constraints.lifetime) this object is now defunct and should
be destroyed. If this is a persistent pointer confinement (see
wp_pointer_constraints.lifetime) this pointer confinement may again
reactivate in the future.
</description>
</event>
</interface>
</protocol>

View file

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="relative_pointer_unstable_v1">
<copyright>
Copyright © 2014 Jonas Ådahl
Copyright © 2015 Red Hat Inc.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<description summary="protocol for relative pointer motion events">
This protocol specifies a set of interfaces used for making clients able to
receive relative pointer events not obstructed by barriers (such as the
monitor edge or other pointer barriers).
To start receiving relative pointer events, a client must first bind the
global interface "wp_relative_pointer_manager" which, if a compositor
supports relative pointer motion events, is exposed by the registry. After
having created the relative pointer manager proxy object, the client uses
it to create the actual relative pointer object using the
"get_relative_pointer" request given a wl_pointer. The relative pointer
motion events will then, when applicable, be transmitted via the proxy of
the newly created relative pointer object. See the documentation of the
relative pointer interface for more details.
Warning! The protocol described in this file is experimental and backward
incompatible changes may be made. Backward compatible changes may be added
together with the corresponding interface version bump. Backward
incompatible changes are done by bumping the version number in the protocol
and interface names and resetting the interface version. Once the protocol
is to be declared stable, the 'z' prefix and the version number in the
protocol and interface names are removed and the interface version number is
reset.
</description>
<interface name="zwp_relative_pointer_manager_v1" version="1">
<description summary="get relative pointer objects">
A global interface used for getting the relative pointer object for a
given pointer.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the relative pointer manager object">
Used by the client to notify the server that it will no longer use this
relative pointer manager object.
</description>
</request>
<request name="get_relative_pointer">
<description summary="get a relative pointer object">
Create a relative pointer interface given a wl_pointer object. See the
wp_relative_pointer interface for more details.
</description>
<arg name="id" type="new_id" interface="zwp_relative_pointer_v1"/>
<arg name="pointer" type="object" interface="wl_pointer"/>
</request>
</interface>
<interface name="zwp_relative_pointer_v1" version="1">
<description summary="relative pointer object">
A wp_relative_pointer object is an extension to the wl_pointer interface
used for emitting relative pointer events. It shares the same focus as
wl_pointer objects of the same seat and will only emit events when it has
focus.
</description>
<request name="destroy" type="destructor">
<description summary="release the relative pointer object"/>
</request>
<event name="relative_motion">
<description summary="relative pointer motion">
Relative x/y pointer motion from the pointer of the seat associated with
this object.
A relative motion is in the same dimension as regular wl_pointer motion
events, except they do not represent an absolute position. For example,
moving a pointer from (x, y) to (x', y') would have the equivalent
relative motion (x' - x, y' - y). If a pointer motion caused the
absolute pointer position to be clipped by for example the edge of the
monitor, the relative motion is unaffected by the clipping and will
represent the unclipped motion.
This event also contains non-accelerated motion deltas. The
non-accelerated delta is, when applicable, the regular pointer motion
delta as it was before having applied motion acceleration and other
transformations such as normalization.
Note that the non-accelerated delta does not represent 'raw' events as
they were read from some device. Pointer motion acceleration is device-
and configuration-specific and non-accelerated deltas and accelerated
deltas may have the same value on some devices.
Relative motions are not coupled to wl_pointer.motion events, and can be
sent in combination with such events, but also independently. There may
also be scenarios where wl_pointer.motion is sent, but there is no
relative motion. The order of an absolute and relative motion event
originating from the same physical motion is not guaranteed.
If the client needs button events or focus state, it can receive them
from a wl_pointer object of the same seat that the wp_relative_pointer
object is associated with.
</description>
<arg name="utime_hi" type="uint"
summary="high 32 bits of a 64 bit timestamp with microsecond granularity"/>
<arg name="utime_lo" type="uint"
summary="low 32 bits of a 64 bit timestamp with microsecond granularity"/>
<arg name="dx" type="fixed"
summary="the x component of the motion vector"/>
<arg name="dy" type="fixed"
summary="the y component of the motion vector"/>
<arg name="dx_unaccel" type="fixed"
summary="the x component of the unaccelerated motion vector"/>
<arg name="dy_unaccel" type="fixed"
summary="the y component of the unaccelerated motion vector"/>
</event>
</interface>
</protocol>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,176 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="xdg_decoration_unstable_v1">
<copyright>
Copyright © 2018 Simon Ser
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>
<interface name="zxdg_decoration_manager_v1" version="2">
<description summary="window decoration manager">
This interface allows a compositor to announce support for server-side
decorations.
A window decoration is a set of window controls as deemed appropriate by
the party managing them, such as user interface components used to move,
resize and change a window's state.
A client can use this protocol to request being decorated by a supporting
compositor.
If compositor and client do not negotiate the use of a server-side
decoration using this protocol, clients continue to self-decorate as they
see fit.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible changes
may be added together with the corresponding interface version bump.
Backward incompatible changes are done by bumping the version number in
the protocol and interface names and resetting the interface version.
Once the protocol is to be declared stable, the 'z' prefix and the
version number in the protocol and interface names are removed and the
interface version number is reset.
</description>
<request name="destroy" type="destructor">
<description summary="destroy the decoration manager object">
Destroy the decoration manager. This doesn't destroy objects created
with the manager.
</description>
</request>
<request name="get_toplevel_decoration">
<description summary="create a new toplevel decoration object">
Create a new decoration object associated with the given toplevel.
For objects of version 1, creating an xdg_toplevel_decoration from an
xdg_toplevel which has a buffer attached or committed is a client
error, and any attempts by a client to attach or manipulate a buffer
prior to the first xdg_toplevel_decoration.configure event must also be
treated as errors.
For objects of version 2 or newer, creating an xdg_toplevel_decoration
from an xdg_toplevel which has a buffer attached or committed is
allowed. The initial decoration mode of the surface if a buffer is
already attached depends on whether a xdg_toplevel_decoration object
has been associated with the surface or not prior to this request.
If an xdg_toplevel_decoration was associated with the surface, then
destroyed without a surface commit, the previous decoration mode is
retained.
If no xdg_toplevel_decoration was associated with the surface prior to
this request, or if a surface commit has been performed after a previous
xdg_toplevel_decoration object associated with the surface was
destroyed, the decoration mode is assumed to be client-side.
</description>
<arg name="id" type="new_id" interface="zxdg_toplevel_decoration_v1"/>
<arg name="toplevel" type="object" interface="xdg_toplevel"/>
</request>
</interface>
<interface name="zxdg_toplevel_decoration_v1" version="2">
<description summary="decoration object for a toplevel surface">
The decoration object allows the compositor to toggle server-side window
decorations for a toplevel surface. The client can request to switch to
another mode.
The xdg_toplevel_decoration object must be destroyed before its
xdg_toplevel.
</description>
<enum name="error">
<entry name="unconfigured_buffer" value="0"
summary="xdg_toplevel has a buffer attached before configure"/>
<entry name="already_constructed" value="1"
summary="xdg_toplevel already has a decoration object"/>
<entry name="orphaned" value="2"
summary="xdg_toplevel destroyed before the decoration object"/>
<entry name="invalid_mode" value="3" summary="invalid mode"/>
</enum>
<request name="destroy" type="destructor">
<description summary="destroy the decoration object">
Switch back to a mode without any server-side decorations at the next
commit, unless a new xdg_toplevel_decoration is created for the surface
first.
</description>
</request>
<enum name="mode">
<description summary="window decoration modes">
These values describe window decoration modes.
</description>
<entry name="client_side" value="1"
summary="no server-side window decoration"/>
<entry name="server_side" value="2"
summary="server-side window decoration"/>
</enum>
<request name="set_mode">
<description summary="set the decoration mode">
Set the toplevel surface decoration mode. This informs the compositor
that the client prefers the provided decoration mode.
After requesting a decoration mode, the compositor will respond by
emitting an xdg_surface.configure event. The client should then update
its content, drawing it without decorations if the received mode is
server-side decorations. The client must also acknowledge the configure
when committing the new content (see xdg_surface.ack_configure).
The compositor can decide not to use the client's mode and enforce a
different mode instead.
Clients whose decoration mode depend on the xdg_toplevel state may send
a set_mode request in response to an xdg_surface.configure event and wait
for the next xdg_surface.configure event to prevent unwanted state.
Such clients are responsible for preventing configure loops and must
make sure not to send multiple successive set_mode requests with the
same decoration mode.
If an invalid mode is supplied by the client, the invalid_mode protocol
error is raised by the compositor.
</description>
<arg name="mode" type="uint" enum="mode" summary="the decoration mode"/>
</request>
<request name="unset_mode">
<description summary="unset the decoration mode">
Unset the toplevel surface decoration mode. This informs the compositor
that the client doesn't prefer a particular decoration mode.
This request has the same semantics as set_mode.
</description>
</request>
<event name="configure">
<description summary="notify a decoration mode change">
The configure event configures the effective decoration mode. The
configured state should not be applied immediately. Clients must send an
ack_configure in response to this event. See xdg_surface.configure and
xdg_surface.ack_configure for details.
A configure event can be sent at any time. The specified mode must be
obeyed by the client.
</description>
<arg name="mode" type="uint" enum="mode" summary="the decoration mode"/>
</event>
</interface>
</protocol>

File diff suppressed because it is too large Load diff