initial commit
This commit is contained in:
commit
41b72e6fdf
46 changed files with 9134 additions and 0 deletions
25
Crafter.Graphics-Types.cppm
Normal file
25
Crafter.Graphics-Types.cppm
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
module;
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
export module Crafter.Graphics:Types;
|
||||
|
||||
namespace Crafter {
|
||||
export struct MousePoint {
|
||||
double x;
|
||||
double y;
|
||||
};
|
||||
|
||||
export struct MouseMoveEvent {
|
||||
MousePoint lastMousePos;
|
||||
MousePoint currentMousePos;
|
||||
MousePoint mouseDelta;
|
||||
};
|
||||
|
||||
export struct Pixel {
|
||||
std::uint8_t r;
|
||||
std::uint8_t g;
|
||||
std::uint8_t b;
|
||||
std::uint8_t a;
|
||||
};
|
||||
}
|
||||
22
Crafter.Graphics-UiElement.cpp
Normal file
22
Crafter.Graphics-UiElement.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
module;
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
module Crafter.Graphics;
|
||||
using namespace Crafter;
|
||||
|
||||
UiElement::UiElement(float anchorX, float anchorY, std::uint32_t bufferWidth, std::uint32_t bufferHeight, std::uint32_t absoluteWidth, std::uint32_t absoluteHeight, float anchorOffsetX, float anchorOffsetY, float z, bool ignoreScaling) : anchorX(anchorX), anchorY(anchorY), bufferWidth(bufferWidth), bufferHeight(bufferHeight), absoluteWidth(absoluteWidth), absoluteHeight(absoluteHeight), anchorOffsetX(anchorOffsetX), anchorOffsetY(anchorOffsetY), z(z), buffer(bufferWidth*bufferHeight), useRelativeSize(false), ignoreScaling(ignoreScaling) {
|
||||
|
||||
}
|
||||
|
||||
UiElement::UiElement(float anchorX, float anchorY, std::uint32_t bufferWidth, std::uint32_t bufferHeight, std::uint32_t absoluteWidth, std::uint32_t absoluteHeight, UiElement* parent, float anchorOffsetX, float anchorOffsetY, float z, bool ignoreScaling) : anchorX(anchorX), anchorY(anchorY), bufferWidth(bufferWidth), bufferHeight(bufferHeight), absoluteWidth(absoluteWidth), absoluteHeight(absoluteHeight), anchorOffsetX(anchorOffsetX), anchorOffsetY(anchorOffsetY), z(z), buffer(bufferWidth*bufferHeight), parent(parent), useRelativeSize(false), ignoreScaling(ignoreScaling) {
|
||||
|
||||
}
|
||||
|
||||
UiElement::UiElement(float anchorX, float anchorY, std::uint32_t bufferWidth, std::uint32_t bufferHeight, float relativeWidth, float relativeHeight, float anchorOffsetX, float anchorOffsetY, float z, bool ignoreScaling) : anchorX(anchorX), anchorY(anchorY), bufferWidth(bufferWidth), bufferHeight(bufferHeight), relativeWidth(relativeWidth), relativeHeight(relativeHeight), anchorOffsetX(anchorOffsetX), anchorOffsetY(anchorOffsetY), z(z), buffer(bufferWidth*bufferHeight), useRelativeSize(true), ignoreScaling(ignoreScaling) {
|
||||
|
||||
}
|
||||
|
||||
UiElement::UiElement(float anchorX, float anchorY, std::uint32_t bufferWidth, std::uint32_t bufferHeight, float relativeWidth, float relativeHeight, UiElement* parent, float anchorOffsetX, float anchorOffsetY, float z, bool ignoreScaling) : anchorX(anchorX), anchorY(anchorY), bufferWidth(bufferWidth), bufferHeight(bufferHeight), relativeWidth(relativeWidth), relativeHeight(relativeHeight), anchorOffsetX(anchorOffsetX), anchorOffsetY(anchorOffsetY), z(z), buffer(bufferWidth*bufferHeight), parent(parent), useRelativeSize(true), ignoreScaling(ignoreScaling) {
|
||||
|
||||
}
|
||||
45
Crafter.Graphics-UiElement.cppm
Normal file
45
Crafter.Graphics-UiElement.cppm
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
module;
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
export module Crafter.Graphics:UiElement;
|
||||
import Crafter.Event;
|
||||
import :Types;
|
||||
import Crafter.Component;
|
||||
|
||||
export namespace Crafter {
|
||||
class UiElement : public Component {
|
||||
public:
|
||||
Event<MouseMoveEvent> onMouseMove;
|
||||
Event<MouseMoveEvent> onMouseEnter;
|
||||
Event<MouseMoveEvent> onMouseLeave;
|
||||
Event<MousePoint> onMouseRightClick;
|
||||
Event<MousePoint> onMouseLeftClick;
|
||||
Event<MousePoint> onMouseRightHold;
|
||||
Event<MousePoint> onMouseLeftHold;
|
||||
Event<MousePoint> onMouseRightRelease;
|
||||
Event<MousePoint> onMouseLeftRelease;
|
||||
float z;
|
||||
float anchorX;
|
||||
float anchorY;
|
||||
bool useRelativeSize;
|
||||
bool ignoreScaling;
|
||||
std::uint32_t bufferWidth;
|
||||
std::uint32_t bufferHeight;
|
||||
std::uint32_t absoluteWidth;
|
||||
std::uint32_t absoluteHeight;
|
||||
float relativeWidth;
|
||||
float relativeHeight;
|
||||
float anchorOffsetX;
|
||||
float anchorOffsetY;
|
||||
std::vector<Pixel> buffer;
|
||||
ComponentRef<UiElement> parent;
|
||||
ComponentRefVectorOwning<UiElement> children;
|
||||
UiElement(float anchorX, float anchorY, std::uint32_t bufferWidth, std::uint32_t bufferHeight, std::uint32_t absoluteWidth, std::uint32_t absoluteHeight, float anchorOffsetX = 0.5, float anchorOffsetY = 0.5, float z = 0, bool ignoreScaling = false);
|
||||
UiElement(float anchorX, float anchorY, std::uint32_t bufferWidth, std::uint32_t bufferHeight, std::uint32_t absoluteWidth, std::uint32_t absoluteHeight, UiElement* parent, float anchorOffsetX = 0.5, float anchorOffsetY = 0.5, float z = 0, bool ignoreScaling = false);
|
||||
UiElement(float anchorX, float anchorY, std::uint32_t bufferWidth, std::uint32_t bufferHeight, float relativeWidth, float relativeHeight, float anchorOffsetX = 0.5, float anchorOffsetY = 0.5, float z = 0, bool ignoreScaling = false);
|
||||
UiElement(float anchorX, float anchorY, std::uint32_t bufferWidth, std::uint32_t bufferHeight, float relativeWidth, float relativeHeight, UiElement* parent, float anchorOffsetX = 0.5, float anchorOffsetY = 0.5, float z = 0, bool ignoreScaling = false);
|
||||
virtual ~UiElement() {};
|
||||
};
|
||||
}
|
||||
32
Crafter.Graphics-UiImage.cppm
Normal file
32
Crafter.Graphics-UiImage.cppm
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// module;
|
||||
|
||||
// #include <cstdint>
|
||||
|
||||
// export module Crafter.Graphics:UiImage;
|
||||
// import Crafter.Event;
|
||||
// import :UiElement;
|
||||
|
||||
// export namespace Crafter {
|
||||
// class UiImage : public UiElement {
|
||||
// public:
|
||||
// int test = 150;
|
||||
// Pixel* image;
|
||||
// UiImage() {
|
||||
|
||||
// }
|
||||
// void Draw(Pixel* buffer, std::uint32_t x, std::uint32_t y, std::uint32_t right, std::uint32_t down) override {
|
||||
// width = 128;
|
||||
// height = 128;
|
||||
// for(std::uint32_t x = 0; x < 128; x++) {
|
||||
// for(std::uint32_t y = 0; y < 128; y++) {
|
||||
// buffer[x*128+y].r = test%255;
|
||||
// buffer[x*128+y].g = test%255;
|
||||
// buffer[x*128+y].b = test%255;
|
||||
// buffer[x*128+y].a = 255;
|
||||
// }
|
||||
// }
|
||||
// test++;
|
||||
// }
|
||||
// ~UiImage() override {};
|
||||
// };
|
||||
// }
|
||||
360
Crafter.Graphics-Window.cpp
Normal file
360
Crafter.Graphics-Window.cpp
Normal file
|
|
@ -0,0 +1,360 @@
|
|||
module;
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/input.h>
|
||||
#include <string>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-cursor.h>
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include <iostream>
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <vulkan/vulkan_wayland.h>
|
||||
#include <wayland-client.h>
|
||||
#include <cstring>
|
||||
#include "xdg-shell-client-protocol.h"
|
||||
#include "wayland-xdg-decoration-unstable-v1-client-protocol.h"
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <print>
|
||||
#include "cat.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-client.h>
|
||||
#include <wayland-client-protocol.h>
|
||||
#include <linux/input-event-codes.h>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
module Crafter.Graphics;
|
||||
import Crafter.Event;
|
||||
using namespace Crafter;
|
||||
|
||||
static void xdg_wm_base_handle_ping(void* data, xdg_wm_base* xdg_wm_base, std::uint32_t serial) {
|
||||
xdg_wm_base_pong(xdg_wm_base, serial);
|
||||
}
|
||||
|
||||
xdg_wm_base_listener xdgWmBaseListener = {
|
||||
.ping = xdg_wm_base_handle_ping,
|
||||
};
|
||||
|
||||
|
||||
void Window::pointer_handle_button(void* data, wl_pointer* pointer, std::uint32_t serial, std::uint32_t time, std::uint32_t button, std::uint32_t state) {
|
||||
Window* window = reinterpret_cast<Window*>(data);
|
||||
if (button == BTN_LEFT) {
|
||||
if(state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||
window->mouseLeftHeld = true;
|
||||
window->onMouseLeftClick.Invoke(window->currentMousePos);
|
||||
} else {
|
||||
window->mouseLeftHeld = false;
|
||||
window->onMouseLeftRelease.Invoke(window->currentMousePos);
|
||||
}
|
||||
} else if(button == BTN_RIGHT){
|
||||
if(state == WL_POINTER_BUTTON_STATE_PRESSED) {
|
||||
window->mouseRightHeld = true;
|
||||
window->onMouseRightClick.Invoke(window->currentMousePos);
|
||||
} else {
|
||||
window->mouseRightHeld = true;
|
||||
window->onMouseRightRelease.Invoke(window->currentMousePos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Window::PointerListenerHandleMotion(void* data, wl_pointer* wl_pointer, uint time, wl_fixed_t surface_x, wl_fixed_t surface_y) {
|
||||
Window* window = reinterpret_cast<Window*>(data);
|
||||
MousePoint pos = {wl_fixed_to_double(surface_x), wl_fixed_to_double(surface_y)};
|
||||
window->lastMousePos = window->currentMousePos;
|
||||
window->currentMousePos = pos;
|
||||
window->mouseDelta = {window->currentMousePos.x-window->lastMousePos.x, window->currentMousePos.y-window->lastMousePos.y};
|
||||
window->onMouseMove.Invoke({window->lastMousePos, window->currentMousePos, window->mouseDelta});
|
||||
}
|
||||
|
||||
void Window::PointerListenerHandleEnter(void* data, wl_pointer* wl_pointer, uint serial, wl_surface* surface, wl_fixed_t surface_x, wl_fixed_t surface_y) {
|
||||
Window* window = reinterpret_cast<Window*>(data);
|
||||
window->onMouseEnter.Invoke({window->lastMousePos, window->currentMousePos, window->mouseDelta});
|
||||
}
|
||||
|
||||
void Window::PointerListenerHandleLeave(void* data, wl_pointer*, std::uint32_t, wl_surface*) {
|
||||
Window* window = reinterpret_cast<Window*>(data);
|
||||
window->onMouseEnter.Invoke({window->lastMousePos, window->currentMousePos, window->mouseDelta});
|
||||
}
|
||||
|
||||
void Window::PointerListenerHandleAxis(void*, wl_pointer*, std::uint32_t, std::uint32_t, wl_fixed_t value) {
|
||||
std::cout << wl_fixed_to_double(value) << std::endl;
|
||||
}
|
||||
|
||||
wl_pointer_listener Window::pointer_listener = {
|
||||
.enter = Window::PointerListenerHandleEnter,
|
||||
.leave = Window::PointerListenerHandleLeave,
|
||||
.motion = Window::PointerListenerHandleMotion,
|
||||
.button = Window::pointer_handle_button,
|
||||
.axis = Window::PointerListenerHandleAxis,
|
||||
};
|
||||
|
||||
void Window::seat_handle_capabilities(void* data, wl_seat* seat, uint32_t capabilities) {
|
||||
Window* window = reinterpret_cast<Window*>(data);
|
||||
window->seat = seat;
|
||||
if (capabilities & WL_SEAT_CAPABILITY_POINTER) {
|
||||
wl_pointer* pointer = wl_seat_get_pointer(seat);
|
||||
wl_pointer_add_listener(pointer, &pointer_listener, window);
|
||||
}
|
||||
}
|
||||
|
||||
wl_seat_listener Window::seat_listener = {
|
||||
.capabilities = seat_handle_capabilities,
|
||||
};
|
||||
|
||||
void Window::handle_global(void *data, wl_registry *registry, std::uint32_t name, const char *interface, std::uint32_t version) {
|
||||
Window* window = reinterpret_cast<Window*>(data);
|
||||
if (strcmp(interface, wl_shm_interface.name) == 0) {
|
||||
window->shm = reinterpret_cast<wl_shm*>(wl_registry_bind(registry, name, &wl_shm_interface, 1));
|
||||
} else if (strcmp(interface, wl_seat_interface.name) == 0) {
|
||||
wl_seat* seat = reinterpret_cast<wl_seat*>(wl_registry_bind(registry, name, &wl_seat_interface, 1));
|
||||
wl_seat_add_listener(seat, &seat_listener, window);
|
||||
} else if (compositor == NULL && strcmp(interface, wl_compositor_interface.name) == 0) {
|
||||
compositor = reinterpret_cast<wl_compositor*>(wl_registry_bind(registry, name, &wl_compositor_interface, 1));
|
||||
} else if (strcmp(interface, xdg_wm_base_interface.name) == 0) {
|
||||
window->xdgWmBase = reinterpret_cast<xdg_wm_base*>(wl_registry_bind(registry, name, &xdg_wm_base_interface, 1));
|
||||
xdg_wm_base_add_listener(window->xdgWmBase, &xdgWmBaseListener, NULL);
|
||||
} else if (strcmp(interface, zxdg_decoration_manager_v1_interface.name) == 0) {
|
||||
window->manager = reinterpret_cast<zxdg_decoration_manager_v1*>(wl_registry_bind(registry, name, &zxdg_decoration_manager_v1_interface, 1));
|
||||
}
|
||||
}
|
||||
|
||||
static void handle_global_remove(void* data, wl_registry* registry, uint32_t name) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
wl_registry_listener Window::registry_listener = {
|
||||
.global = Window::handle_global,
|
||||
.global_remove = handle_global_remove,
|
||||
};
|
||||
|
||||
static void noop5(void*, xdg_toplevel*, std::int32_t, std::int32_t, wl_array*){
|
||||
|
||||
}
|
||||
|
||||
void Window::xdg_toplevel_handle_close(void* data, xdg_toplevel*) {
|
||||
Window* window = reinterpret_cast<Window*>(data);
|
||||
window->onClose.Invoke();
|
||||
}
|
||||
|
||||
xdg_toplevel_listener Window::xdg_toplevel_listener = {
|
||||
.configure = noop5,
|
||||
.close = Window::xdg_toplevel_handle_close,
|
||||
};
|
||||
|
||||
void Window::xdg_surface_handle_configure(void* data, xdg_surface* xdg_surface, std::uint32_t serial) {
|
||||
Window* window = reinterpret_cast<Window*>(data);
|
||||
// The compositor configures our surface, acknowledge the configure event
|
||||
xdg_surface_ack_configure(xdg_surface, serial);
|
||||
|
||||
if (window->configured) {
|
||||
// If this isn't the first configure event we've received, we already
|
||||
// have a buffer attached, so no need to do anything. Commit the
|
||||
// surface to apply the configure acknowledgement.
|
||||
wl_surface_commit(window->surface);
|
||||
}
|
||||
|
||||
window->configured = true;
|
||||
}
|
||||
|
||||
xdg_surface_listener Window::xdg_surface_listener = {
|
||||
.configure = xdg_surface_handle_configure,
|
||||
};
|
||||
|
||||
static void randname(char *buf) {
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
long r = ts.tv_nsec;
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
buf[i] = 'A'+(r&15)+(r&16)*2;
|
||||
r >>= 5;
|
||||
}
|
||||
}
|
||||
|
||||
static int anonymous_shm_open(void) {
|
||||
char name[] = "/hello-wayland-XXXXXX";
|
||||
int retries = 100;
|
||||
|
||||
do {
|
||||
randname(name + strlen(name) - 6);
|
||||
|
||||
--retries;
|
||||
// shm_open guarantees that O_CLOEXEC is set
|
||||
int fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||
if (fd >= 0) {
|
||||
shm_unlink(name);
|
||||
return fd;
|
||||
}
|
||||
} while (retries > 0 && errno == EEXIST);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int create_shm_file(off_t size) {
|
||||
int fd = anonymous_shm_open();
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
|
||||
if (ftruncate(fd, size) < 0) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
Window::Window(std::string name, std::uint32_t width, std::uint32_t height) : width(width), height(height) {
|
||||
// Connect to the Wayland compositor
|
||||
display = wl_display_connect(NULL);
|
||||
if (display == NULL) {
|
||||
std::cerr << "failed to create display" << std::endl;
|
||||
}
|
||||
// Obtain the wl_registry and fetch the list of globals
|
||||
wl_registry* registry = wl_display_get_registry(display);
|
||||
wl_registry_add_listener(registry, ®istry_listener, this);
|
||||
if (wl_display_roundtrip(display) == -1) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// Check that all globals we require are available
|
||||
if (shm == NULL || compositor == NULL || xdgWmBase == NULL) {
|
||||
std::cerr << "no wl_shm, wl_compositor or xdg_wm_base support" << std::endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
// Create a wl_surface, a xdg_surface and a xdg_toplevel
|
||||
surface = wl_compositor_create_surface(compositor);
|
||||
xdgSurface = xdg_wm_base_get_xdg_surface(xdgWmBase, surface);
|
||||
xdgToplevel = xdg_surface_get_toplevel(xdgSurface);
|
||||
|
||||
|
||||
xdg_surface_add_listener(xdgSurface, &xdg_surface_listener, this);
|
||||
xdg_toplevel_add_listener(xdgToplevel, &xdg_toplevel_listener, this);
|
||||
wl_surface_commit(surface);
|
||||
|
||||
while (wl_display_dispatch(display) != -1 && !configured) {
|
||||
// This space intentionally left blank
|
||||
}
|
||||
|
||||
// Create a wl_buffer, attach it to the surface and commit the surface
|
||||
int stride = width * 4;
|
||||
int size = stride * height;
|
||||
|
||||
// Allocate a shared memory file with the right size
|
||||
int fd = create_shm_file(size);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "creating a buffer file for %d B failed: %m\n", size);
|
||||
}
|
||||
|
||||
// Map the shared memory file
|
||||
shm_data = reinterpret_cast<Pixel*>(mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0));
|
||||
if (shm_data == MAP_FAILED) {
|
||||
fprintf(stderr, "mmap failed: %m\n");
|
||||
close(fd);
|
||||
}
|
||||
|
||||
// Create a wl_buffer from our shared memory file descriptor
|
||||
wl_shm_pool *pool = wl_shm_create_pool(shm, fd, size);
|
||||
buffer = wl_shm_pool_create_buffer(pool, 0, width, height, stride, WL_SHM_FORMAT_ARGB8888);
|
||||
wl_shm_pool_destroy(pool);
|
||||
|
||||
// Now that we've mapped the file and created the wl_buffer, we no longer
|
||||
// need to keep file descriptor opened
|
||||
close(fd);
|
||||
|
||||
|
||||
if (buffer == NULL) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
wl_surface_attach(surface, buffer, 0, 0);
|
||||
wl_surface_commit(surface);
|
||||
|
||||
for(std::uint32_t x = 0; x < 128; x++) {
|
||||
for(std::uint32_t y = 0; y < 128; y++) {
|
||||
shm_data[x*128+y].r = 0;
|
||||
shm_data[x*128+y].g = 0;
|
||||
shm_data[x*128+y].b = 0;
|
||||
shm_data[x*128+y].a = 255;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
zxdg_toplevel_decoration_v1* decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(manager, xdgToplevel); // toplevel is from xdg_surface_get_toplevel
|
||||
zxdg_toplevel_decoration_v1_set_mode(decoration, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
}
|
||||
|
||||
|
||||
void ScaleBitmapR8G8B8(Pixel* dst, const Pixel* src, std::uint32_t srcWidth, std::uint32_t srcHeight, std::uint32_t dstWidth, std::uint32_t dstHeight) {
|
||||
for (std::uint32_t y = 0; y < dstHeight; y++) {
|
||||
std::uint32_t srcY = y * srcHeight / dstHeight;
|
||||
for (std::uint32_t x = 0; x < dstWidth; x++) {
|
||||
std::uint32_t srcX = x * srcWidth / dstWidth;
|
||||
const Pixel* srcPixel = src + (srcY * srcWidth + srcX);
|
||||
Pixel* dstPixel = dst + (y * dstWidth + x);
|
||||
dstPixel[0] = srcPixel[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Window::Start() {
|
||||
while (wl_display_dispatch(display) != -1) {
|
||||
wl_surface_attach(surface, buffer, 0, 0);
|
||||
for(UiElement* element : elements.components) {
|
||||
std::int32_t realX;
|
||||
std::int32_t realY;
|
||||
std::int32_t elementWidth;
|
||||
std::int32_t elementHeight;
|
||||
if(element->ignoreScaling) {
|
||||
if(element->useRelativeSize) {
|
||||
elementWidth = element->relativeWidth*width;
|
||||
elementHeight = element->relativeHeight*height;
|
||||
} else {
|
||||
elementWidth = element->absoluteWidth;
|
||||
elementHeight = element->absoluteHeight;
|
||||
}
|
||||
} else {
|
||||
if(element->useRelativeSize) {
|
||||
elementWidth = element->relativeWidth*width*scale;
|
||||
elementHeight = element->relativeHeight*height*scale;
|
||||
} else {
|
||||
elementWidth = element->absoluteWidth*scale;
|
||||
elementHeight = element->absoluteHeight*scale;
|
||||
}
|
||||
}
|
||||
realX = (element->anchorX*width)-(element->anchorOffsetX*elementWidth);
|
||||
realY = (element->anchorY*height)-(element->anchorOffsetY*elementHeight);
|
||||
std::vector<Pixel> scaled(elementWidth*elementHeight);
|
||||
ScaleBitmapR8G8B8(scaled.data(), element->buffer.data(), element->bufferWidth, element->bufferHeight, elementWidth, elementHeight);
|
||||
for(std::int32_t x = realX; x-realX < elementWidth; x++) {
|
||||
for(std::int32_t y = realY; y-realY < elementHeight; y++) {
|
||||
if(x > 0 && x < width && y > 0 && y < height) {
|
||||
shm_data[x*width+y] = scaled[(x-realX)*elementWidth+(y-realY)];
|
||||
}
|
||||
}
|
||||
}
|
||||
wl_surface_damage(surface, realX, realY, elementWidth, elementHeight);
|
||||
}
|
||||
wl_surface_commit(surface);
|
||||
}
|
||||
}
|
||||
|
||||
Window::~Window() {
|
||||
xdg_toplevel_destroy(xdgToplevel);
|
||||
xdg_surface_destroy(xdgSurface);
|
||||
wl_surface_destroy(surface);
|
||||
wl_buffer_destroy(buffer);
|
||||
}
|
||||
71
Crafter.Graphics-Window.cppm
Normal file
71
Crafter.Graphics-Window.cppm
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
module;
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <wayland-client.h>
|
||||
#include "xdg-shell-client-protocol.h"
|
||||
#include "wayland-xdg-decoration-unstable-v1-client-protocol.h"
|
||||
|
||||
export module Crafter.Graphics:Window;
|
||||
import Crafter.Event;
|
||||
import :UiElement;
|
||||
import :Types;
|
||||
import Crafter.Component;
|
||||
|
||||
export namespace Crafter {
|
||||
class Window {
|
||||
public:
|
||||
Event<MousePoint> onMouseRightClick;
|
||||
Event<MousePoint> onMouseLeftClick;
|
||||
Event<MousePoint> onMouseRightHold;
|
||||
Event<MousePoint> onMouseLeftHold;
|
||||
Event<MousePoint> onMouseRightRelease;
|
||||
Event<MousePoint> onMouseLeftRelease;
|
||||
Event<MouseMoveEvent> onMouseMove;
|
||||
Event<MouseMoveEvent> onMouseEnter;
|
||||
Event<MouseMoveEvent> onMouseLeave;
|
||||
Event<double> onMouseScroll;
|
||||
Event<void> onClose;
|
||||
MousePoint currentMousePos;
|
||||
MousePoint lastMousePos;
|
||||
MousePoint mouseDelta;
|
||||
bool mouseLeftHeld = false;
|
||||
bool mouseRightHeld = false;
|
||||
ComponentRefVectorOwning<UiElement> elements;
|
||||
std::uint32_t width;
|
||||
std::uint32_t height;
|
||||
float scale = 1;
|
||||
Window(std::string name, std::uint32_t width, std::uint32_t height);
|
||||
~Window();
|
||||
void Start();
|
||||
void Draw(std::uint32_t x, std::uint32_t y, std::uint32_t right, std::uint32_t down);
|
||||
private:
|
||||
Pixel* shm_data = NULL;
|
||||
bool configured = false;
|
||||
wl_shm* shm = NULL;
|
||||
wl_seat* seat = NULL;
|
||||
xdg_toplevel* xdgToplevel = NULL;
|
||||
xdg_wm_base* xdgWmBase = NULL;
|
||||
zxdg_decoration_manager_v1* manager = NULL;
|
||||
wl_surface* surface = NULL;
|
||||
wl_buffer* buffer = NULL;
|
||||
xdg_surface* xdgSurface = NULL;
|
||||
wl_display* display = NULL;
|
||||
inline static wl_compositor* compositor = NULL;
|
||||
static wl_pointer_listener pointer_listener;
|
||||
static wl_seat_listener seat_listener;
|
||||
static wl_registry_listener registry_listener;
|
||||
static xdg_surface_listener xdg_surface_listener;
|
||||
static xdg_toplevel_listener xdg_toplevel_listener;
|
||||
static void PointerListenerHandleMotion(void* data, wl_pointer* wl_pointer, uint time, wl_fixed_t surface_x, wl_fixed_t surface_y);
|
||||
static void PointerListenerHandleAxis(void*, wl_pointer*, std::uint32_t, std::uint32_t, wl_fixed_t value);
|
||||
static void PointerListenerHandleEnter(void* data, wl_pointer* wl_pointer, uint serial, wl_surface* surface, wl_fixed_t surface_x, wl_fixed_t surface_y);
|
||||
static void PointerListenerHandleLeave(void*, wl_pointer*, std::uint32_t, wl_surface*);
|
||||
static void xdg_toplevel_handle_close(void* data, xdg_toplevel*);
|
||||
static void handle_global(void* data, wl_registry* registry, std::uint32_t name, const char* interface, std::uint32_t version);
|
||||
static void pointer_handle_button(void* data, wl_pointer* pointer, std::uint32_t serial, std::uint32_t time, std::uint32_t button, std::uint32_t state);
|
||||
static void seat_handle_capabilities(void* data, wl_seat* seat, uint32_t capabilities);
|
||||
static void xdg_surface_handle_configure(void* data, xdg_surface* xdg_surface, std::uint32_t serial);
|
||||
};
|
||||
}
|
||||
6
Crafter.Graphics.cppm
Normal file
6
Crafter.Graphics.cppm
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
export module Crafter.Graphics;
|
||||
|
||||
export import :Window;
|
||||
export import :UiElement;
|
||||
export import :Types;
|
||||
// export import :UiImage;
|
||||
BIN
bin/Crafter.Graphics-Window.pcm
Normal file
BIN
bin/Crafter.Graphics-Window.pcm
Normal file
Binary file not shown.
BIN
bin/Crafter.Graphics.pcm
Normal file
BIN
bin/Crafter.Graphics.pcm
Normal file
Binary file not shown.
BIN
bin/crafter-graphics
Executable file
BIN
bin/crafter-graphics
Executable file
Binary file not shown.
BIN
bin/libcrafter-graphics.a
Normal file
BIN
bin/libcrafter-graphics.a
Normal file
Binary file not shown.
BIN
build/Crafter.Component-Component.pcm
Normal file
BIN
build/Crafter.Component-Component.pcm
Normal file
Binary file not shown.
BIN
build/Crafter.Component-ComponentRef.pcm
Normal file
BIN
build/Crafter.Component-ComponentRef.pcm
Normal file
Binary file not shown.
BIN
build/Crafter.Component.pcm
Normal file
BIN
build/Crafter.Component.pcm
Normal file
Binary file not shown.
BIN
build/Crafter.Event.pcm
Normal file
BIN
build/Crafter.Event.pcm
Normal file
Binary file not shown.
BIN
build/Crafter.Graphics-Types.o
Normal file
BIN
build/Crafter.Graphics-Types.o
Normal file
Binary file not shown.
BIN
build/Crafter.Graphics-Types.pcm
Normal file
BIN
build/Crafter.Graphics-Types.pcm
Normal file
Binary file not shown.
BIN
build/Crafter.Graphics-UiElement.o
Normal file
BIN
build/Crafter.Graphics-UiElement.o
Normal file
Binary file not shown.
BIN
build/Crafter.Graphics-UiElement.pcm
Normal file
BIN
build/Crafter.Graphics-UiElement.pcm
Normal file
Binary file not shown.
BIN
build/Crafter.Graphics-UiElement_source.o
Normal file
BIN
build/Crafter.Graphics-UiElement_source.o
Normal file
Binary file not shown.
BIN
build/Crafter.Graphics-UiImage.o
Normal file
BIN
build/Crafter.Graphics-UiImage.o
Normal file
Binary file not shown.
BIN
build/Crafter.Graphics-UiImage.pcm
Normal file
BIN
build/Crafter.Graphics-UiImage.pcm
Normal file
Binary file not shown.
BIN
build/Crafter.Graphics-Window.o
Normal file
BIN
build/Crafter.Graphics-Window.o
Normal file
Binary file not shown.
BIN
build/Crafter.Graphics-Window.pcm
Normal file
BIN
build/Crafter.Graphics-Window.pcm
Normal file
Binary file not shown.
BIN
build/Crafter.Graphics-Window_source.o
Normal file
BIN
build/Crafter.Graphics-Window_source.o
Normal file
Binary file not shown.
BIN
build/Crafter.Graphics.o
Normal file
BIN
build/Crafter.Graphics.o
Normal file
Binary file not shown.
BIN
build/Crafter.Graphics.pcm
Normal file
BIN
build/Crafter.Graphics.pcm
Normal file
Binary file not shown.
BIN
build/Crafter.Thread-ThreadPool.pcm
Normal file
BIN
build/Crafter.Thread-ThreadPool.pcm
Normal file
Binary file not shown.
BIN
build/Crafter.Thread.pcm
Normal file
BIN
build/Crafter.Thread.pcm
Normal file
Binary file not shown.
BIN
build/libcrafter-component.a
Normal file
BIN
build/libcrafter-component.a
Normal file
Binary file not shown.
BIN
build/libcrafter-event.a
Normal file
BIN
build/libcrafter-event.a
Normal file
Binary file not shown.
BIN
build/libcrafter-thread.a
Normal file
BIN
build/libcrafter-thread.a
Normal file
Binary file not shown.
BIN
build/main_source.o
Normal file
BIN
build/main_source.o
Normal file
Binary file not shown.
BIN
build/shm_source.o
Normal file
BIN
build/shm_source.o
Normal file
Binary file not shown.
Binary file not shown.
BIN
build/xdg-shell-protocol_source.o
Normal file
BIN
build/xdg-shell-protocol_source.o
Normal file
Binary file not shown.
24
main.cpp
Normal file
24
main.cpp
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#include <iostream>
|
||||
#include <exception>
|
||||
import Crafter.Graphics;
|
||||
using namespace Crafter;
|
||||
|
||||
int main() {
|
||||
Window window("test", 128, 128);
|
||||
UiElement test(
|
||||
0.5, //anchorX
|
||||
0.5, //anchorY
|
||||
2, //bufferWidth
|
||||
1, //bufferHeight
|
||||
std::uint32_t(30), //absoluteSizeX
|
||||
std::uint32_t(30), //absoluteSizeY
|
||||
0.5, //anchorOffsetX
|
||||
0.5, //anchorOffsetY
|
||||
0, //z
|
||||
false //ignoreScaling
|
||||
);
|
||||
window.scale = 1;
|
||||
test.buffer = {{255, 0, 0 ,255}, {0, 255, 0 ,255}};
|
||||
window.elements.AddComponent(&test);
|
||||
window.Start();
|
||||
}
|
||||
44
project.json
Normal file
44
project.json
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"name": "crafter-graphics",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "base",
|
||||
"standard": "c++26",
|
||||
"source_files": ["Crafter.Graphics-Window", "Crafter.Graphics-UiElement"],
|
||||
"c_files": ["wayland-xdg-decoration-unstable-v1-client-protocol", "xdg-shell-protocol", "shm"],
|
||||
"module_files": ["Crafter.Graphics-Window", "Crafter.Graphics", "Crafter.Graphics-UiElement", "Crafter.Graphics-Types"],
|
||||
"build_dir": "./build",
|
||||
"output_dir": "./bin",
|
||||
"type":"library",
|
||||
"libs": ["wayland-client"],
|
||||
"flags": ["-Wno-uninitialized"]
|
||||
},
|
||||
{
|
||||
"name": "debug",
|
||||
"extends": ["base"],
|
||||
"optimization_level": "0",
|
||||
"debug": true
|
||||
},
|
||||
{
|
||||
"name": "test",
|
||||
"extends": ["debug"],
|
||||
"source_files": ["main"],
|
||||
"type":"executable",
|
||||
"dependencies": [
|
||||
{
|
||||
"path":"../Crafter.Event/project.json",
|
||||
"configuration":"debug"
|
||||
},
|
||||
{
|
||||
"path":"/home/jorijn/repos/Crafter/Crafter.Component/project.json",
|
||||
"configuration":"debug"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "release",
|
||||
"extends": ["base"],
|
||||
"optimization_level": "3"
|
||||
}
|
||||
]
|
||||
}
|
||||
56
shm.c
Normal file
56
shm.c
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#define _POSIX_C_SOURCE 200809L
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/**
|
||||
* Boilerplate to create an in-memory shared file.
|
||||
*
|
||||
* Link with `-lrt`.
|
||||
*/
|
||||
|
||||
static void randname(char *buf) {
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
long r = ts.tv_nsec;
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
buf[i] = 'A'+(r&15)+(r&16)*2;
|
||||
r >>= 5;
|
||||
}
|
||||
}
|
||||
|
||||
static int anonymous_shm_open(void) {
|
||||
char name[] = "/hello-wayland-XXXXXX";
|
||||
int retries = 100;
|
||||
|
||||
do {
|
||||
randname(name + strlen(name) - 6);
|
||||
|
||||
--retries;
|
||||
// shm_open guarantees that O_CLOEXEC is set
|
||||
int fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||
if (fd >= 0) {
|
||||
shm_unlink(name);
|
||||
return fd;
|
||||
}
|
||||
} while (retries > 0 && errno == EEXIST);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int create_shm_file(off_t size) {
|
||||
int fd = anonymous_shm_open();
|
||||
if (fd < 0) {
|
||||
return fd;
|
||||
}
|
||||
|
||||
if (ftruncate(fd, size) < 0) {
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
10
shm.h
Normal file
10
shm.h
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#ifndef SHM_H
|
||||
#define SHM_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
extern "C" {
|
||||
int create_shm_file(off_t size);
|
||||
}
|
||||
|
||||
#endif
|
||||
1
wayland-vulkan-example
Submodule
1
wayland-vulkan-example
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 4d8d086f62864257abc98da3ce259298b2e46874
|
||||
76
wayland-xdg-decoration-unstable-v1-client-protocol.c
Normal file
76
wayland-xdg-decoration-unstable-v1-client-protocol.c
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/* Generated by wayland-scanner 1.23.1 */
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface xdg_toplevel_interface;
|
||||
extern const struct wl_interface zxdg_toplevel_decoration_v1_interface;
|
||||
|
||||
static const struct wl_interface *xdg_decoration_unstable_v1_types[] = {
|
||||
NULL,
|
||||
&zxdg_toplevel_decoration_v1_interface,
|
||||
&xdg_toplevel_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_decoration_manager_v1_requests[] = {
|
||||
{ "destroy", "", xdg_decoration_unstable_v1_types + 0 },
|
||||
{ "get_toplevel_decoration", "no", xdg_decoration_unstable_v1_types + 1 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zxdg_decoration_manager_v1_interface = {
|
||||
"zxdg_decoration_manager_v1", 1,
|
||||
2, zxdg_decoration_manager_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_toplevel_decoration_v1_requests[] = {
|
||||
{ "destroy", "", xdg_decoration_unstable_v1_types + 0 },
|
||||
{ "set_mode", "u", xdg_decoration_unstable_v1_types + 0 },
|
||||
{ "unset_mode", "", xdg_decoration_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_toplevel_decoration_v1_events[] = {
|
||||
{ "configure", "u", xdg_decoration_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zxdg_toplevel_decoration_v1_interface = {
|
||||
"zxdg_toplevel_decoration_v1", 1,
|
||||
3, zxdg_toplevel_decoration_v1_requests,
|
||||
1, zxdg_toplevel_decoration_v1_events,
|
||||
};
|
||||
|
||||
384
wayland-xdg-decoration-unstable-v1-client-protocol.h
Normal file
384
wayland-xdg-decoration-unstable-v1-client-protocol.h
Normal file
|
|
@ -0,0 +1,384 @@
|
|||
/* Generated by wayland-scanner 1.23.1 */
|
||||
|
||||
#ifndef XDG_DECORATION_UNSTABLE_V1_CLIENT_PROTOCOL_H
|
||||
#define XDG_DECORATION_UNSTABLE_V1_CLIENT_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-client.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @page page_xdg_decoration_unstable_v1 The xdg_decoration_unstable_v1 protocol
|
||||
* @section page_ifaces_xdg_decoration_unstable_v1 Interfaces
|
||||
* - @subpage page_iface_zxdg_decoration_manager_v1 - window decoration manager
|
||||
* - @subpage page_iface_zxdg_toplevel_decoration_v1 - decoration object for a toplevel surface
|
||||
* @section page_copyright_xdg_decoration_unstable_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* 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.
|
||||
* </pre>
|
||||
*/
|
||||
struct xdg_toplevel;
|
||||
struct zxdg_decoration_manager_v1;
|
||||
struct zxdg_toplevel_decoration_v1;
|
||||
|
||||
#ifndef ZXDG_DECORATION_MANAGER_V1_INTERFACE
|
||||
#define ZXDG_DECORATION_MANAGER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zxdg_decoration_manager_v1 zxdg_decoration_manager_v1
|
||||
* @section page_iface_zxdg_decoration_manager_v1_desc Description
|
||||
*
|
||||
* 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.
|
||||
* @section page_iface_zxdg_decoration_manager_v1_api API
|
||||
* See @ref iface_zxdg_decoration_manager_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zxdg_decoration_manager_v1 The zxdg_decoration_manager_v1 interface
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
extern const struct wl_interface zxdg_decoration_manager_v1_interface;
|
||||
#endif
|
||||
#ifndef ZXDG_TOPLEVEL_DECORATION_V1_INTERFACE
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zxdg_toplevel_decoration_v1 zxdg_toplevel_decoration_v1
|
||||
* @section page_iface_zxdg_toplevel_decoration_v1_desc Description
|
||||
*
|
||||
* 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.
|
||||
* @section page_iface_zxdg_toplevel_decoration_v1_api API
|
||||
* See @ref iface_zxdg_toplevel_decoration_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zxdg_toplevel_decoration_v1 The zxdg_toplevel_decoration_v1 interface
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
extern const struct wl_interface zxdg_toplevel_decoration_v1_interface;
|
||||
#endif
|
||||
|
||||
#define ZXDG_DECORATION_MANAGER_V1_DESTROY 0
|
||||
#define ZXDG_DECORATION_MANAGER_V1_GET_TOPLEVEL_DECORATION 1
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_decoration_manager_v1
|
||||
*/
|
||||
#define ZXDG_DECORATION_MANAGER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_decoration_manager_v1
|
||||
*/
|
||||
#define ZXDG_DECORATION_MANAGER_V1_GET_TOPLEVEL_DECORATION_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_zxdg_decoration_manager_v1 */
|
||||
static inline void
|
||||
zxdg_decoration_manager_v1_set_user_data(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) zxdg_decoration_manager_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_zxdg_decoration_manager_v1 */
|
||||
static inline void *
|
||||
zxdg_decoration_manager_v1_get_user_data(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_decoration_manager_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
zxdg_decoration_manager_v1_get_version(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) zxdg_decoration_manager_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_decoration_manager_v1
|
||||
*
|
||||
* Destroy the decoration manager. This doesn't destroy objects created
|
||||
* with the manager.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_decoration_manager_v1_destroy(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_decoration_manager_v1,
|
||||
ZXDG_DECORATION_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_decoration_manager_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_decoration_manager_v1
|
||||
*
|
||||
* Create a new decoration object associated with the given toplevel.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
static inline struct zxdg_toplevel_decoration_v1 *
|
||||
zxdg_decoration_manager_v1_get_toplevel_decoration(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1, struct xdg_toplevel *toplevel)
|
||||
{
|
||||
struct wl_proxy *id;
|
||||
|
||||
id = wl_proxy_marshal_flags((struct wl_proxy *) zxdg_decoration_manager_v1,
|
||||
ZXDG_DECORATION_MANAGER_V1_GET_TOPLEVEL_DECORATION, &zxdg_toplevel_decoration_v1_interface, wl_proxy_get_version((struct wl_proxy *) zxdg_decoration_manager_v1), 0, NULL, toplevel);
|
||||
|
||||
return (struct zxdg_toplevel_decoration_v1 *) id;
|
||||
}
|
||||
|
||||
#ifndef ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ENUM
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ENUM
|
||||
enum zxdg_toplevel_decoration_v1_error {
|
||||
/**
|
||||
* xdg_toplevel has a buffer attached before configure
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_ERROR_UNCONFIGURED_BUFFER = 0,
|
||||
/**
|
||||
* xdg_toplevel already has a decoration object
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ALREADY_CONSTRUCTED = 1,
|
||||
/**
|
||||
* xdg_toplevel destroyed before the decoration object
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ORPHANED = 2,
|
||||
/**
|
||||
* invalid mode
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_ERROR_INVALID_MODE = 3,
|
||||
};
|
||||
#endif /* ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ENUM */
|
||||
|
||||
#ifndef ZXDG_TOPLEVEL_DECORATION_V1_MODE_ENUM
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_MODE_ENUM
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
* window decoration modes
|
||||
*
|
||||
* These values describe window decoration modes.
|
||||
*/
|
||||
enum zxdg_toplevel_decoration_v1_mode {
|
||||
/**
|
||||
* no server-side window decoration
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE = 1,
|
||||
/**
|
||||
* server-side window decoration
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE = 2,
|
||||
};
|
||||
#endif /* ZXDG_TOPLEVEL_DECORATION_V1_MODE_ENUM */
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
* @struct zxdg_toplevel_decoration_v1_listener
|
||||
*/
|
||||
struct zxdg_toplevel_decoration_v1_listener {
|
||||
/**
|
||||
* 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.
|
||||
* @param mode the decoration mode
|
||||
*/
|
||||
void (*configure)(void *data,
|
||||
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
|
||||
uint32_t mode);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
static inline int
|
||||
zxdg_toplevel_decoration_v1_add_listener(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
|
||||
const struct zxdg_toplevel_decoration_v1_listener *listener, void *data)
|
||||
{
|
||||
return wl_proxy_add_listener((struct wl_proxy *) zxdg_toplevel_decoration_v1,
|
||||
(void (**)(void)) listener, data);
|
||||
}
|
||||
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_DESTROY 0
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_SET_MODE 1
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_UNSET_MODE 2
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_CONFIGURE_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_SET_MODE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_UNSET_MODE_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_zxdg_toplevel_decoration_v1 */
|
||||
static inline void
|
||||
zxdg_toplevel_decoration_v1_set_user_data(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) zxdg_toplevel_decoration_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_zxdg_toplevel_decoration_v1 */
|
||||
static inline void *
|
||||
zxdg_toplevel_decoration_v1_get_user_data(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_toplevel_decoration_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
zxdg_toplevel_decoration_v1_get_version(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*
|
||||
* Switch back to a mode without any server-side decorations at the next
|
||||
* commit.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_toplevel_decoration_v1_destroy(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_toplevel_decoration_v1,
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_toplevel_decoration_v1_set_mode(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, uint32_t mode)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_toplevel_decoration_v1,
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_SET_MODE, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1), 0, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_toplevel_decoration_v1_unset_mode(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_toplevel_decoration_v1,
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_UNSET_MODE, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1), 0);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
2325
xdg-shell-client-protocol.h
Normal file
2325
xdg-shell-client-protocol.h
Normal file
File diff suppressed because it is too large
Load diff
184
xdg-shell-protocol.c
Normal file
184
xdg-shell-protocol.c
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
/* Generated by wayland-scanner 1.23.1 */
|
||||
|
||||
/*
|
||||
* Copyright © 2008-2013 Kristian Høgsberg
|
||||
* Copyright © 2013 Rafael Antognolli
|
||||
* Copyright © 2013 Jasper St. Pierre
|
||||
* Copyright © 2010-2013 Intel Corporation
|
||||
* Copyright © 2015-2017 Samsung Electronics Co., Ltd
|
||||
* Copyright © 2015-2017 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.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface wl_output_interface;
|
||||
extern const struct wl_interface wl_seat_interface;
|
||||
extern const struct wl_interface wl_surface_interface;
|
||||
extern const struct wl_interface xdg_popup_interface;
|
||||
extern const struct wl_interface xdg_positioner_interface;
|
||||
extern const struct wl_interface xdg_surface_interface;
|
||||
extern const struct wl_interface xdg_toplevel_interface;
|
||||
|
||||
static const struct wl_interface *xdg_shell_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&xdg_positioner_interface,
|
||||
&xdg_surface_interface,
|
||||
&wl_surface_interface,
|
||||
&xdg_toplevel_interface,
|
||||
&xdg_popup_interface,
|
||||
&xdg_surface_interface,
|
||||
&xdg_positioner_interface,
|
||||
&xdg_toplevel_interface,
|
||||
&wl_seat_interface,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&wl_seat_interface,
|
||||
NULL,
|
||||
&wl_seat_interface,
|
||||
NULL,
|
||||
NULL,
|
||||
&wl_output_interface,
|
||||
&wl_seat_interface,
|
||||
NULL,
|
||||
&xdg_positioner_interface,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_wm_base_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "create_positioner", "n", xdg_shell_types + 4 },
|
||||
{ "get_xdg_surface", "no", xdg_shell_types + 5 },
|
||||
{ "pong", "u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_wm_base_events[] = {
|
||||
{ "ping", "u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_wm_base_interface = {
|
||||
"xdg_wm_base", 6,
|
||||
4, xdg_wm_base_requests,
|
||||
1, xdg_wm_base_events,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_positioner_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "set_size", "ii", xdg_shell_types + 0 },
|
||||
{ "set_anchor_rect", "iiii", xdg_shell_types + 0 },
|
||||
{ "set_anchor", "u", xdg_shell_types + 0 },
|
||||
{ "set_gravity", "u", xdg_shell_types + 0 },
|
||||
{ "set_constraint_adjustment", "u", xdg_shell_types + 0 },
|
||||
{ "set_offset", "ii", xdg_shell_types + 0 },
|
||||
{ "set_reactive", "3", xdg_shell_types + 0 },
|
||||
{ "set_parent_size", "3ii", xdg_shell_types + 0 },
|
||||
{ "set_parent_configure", "3u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_positioner_interface = {
|
||||
"xdg_positioner", 6,
|
||||
10, xdg_positioner_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_surface_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "get_toplevel", "n", xdg_shell_types + 7 },
|
||||
{ "get_popup", "n?oo", xdg_shell_types + 8 },
|
||||
{ "set_window_geometry", "iiii", xdg_shell_types + 0 },
|
||||
{ "ack_configure", "u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_surface_events[] = {
|
||||
{ "configure", "u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_surface_interface = {
|
||||
"xdg_surface", 6,
|
||||
5, xdg_surface_requests,
|
||||
1, xdg_surface_events,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_toplevel_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "set_parent", "?o", xdg_shell_types + 11 },
|
||||
{ "set_title", "s", xdg_shell_types + 0 },
|
||||
{ "set_app_id", "s", xdg_shell_types + 0 },
|
||||
{ "show_window_menu", "ouii", xdg_shell_types + 12 },
|
||||
{ "move", "ou", xdg_shell_types + 16 },
|
||||
{ "resize", "ouu", xdg_shell_types + 18 },
|
||||
{ "set_max_size", "ii", xdg_shell_types + 0 },
|
||||
{ "set_min_size", "ii", xdg_shell_types + 0 },
|
||||
{ "set_maximized", "", xdg_shell_types + 0 },
|
||||
{ "unset_maximized", "", xdg_shell_types + 0 },
|
||||
{ "set_fullscreen", "?o", xdg_shell_types + 21 },
|
||||
{ "unset_fullscreen", "", xdg_shell_types + 0 },
|
||||
{ "set_minimized", "", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_toplevel_events[] = {
|
||||
{ "configure", "iia", xdg_shell_types + 0 },
|
||||
{ "close", "", xdg_shell_types + 0 },
|
||||
{ "configure_bounds", "4ii", xdg_shell_types + 0 },
|
||||
{ "wm_capabilities", "5a", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_toplevel_interface = {
|
||||
"xdg_toplevel", 6,
|
||||
14, xdg_toplevel_requests,
|
||||
4, xdg_toplevel_events,
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_popup_requests[] = {
|
||||
{ "destroy", "", xdg_shell_types + 0 },
|
||||
{ "grab", "ou", xdg_shell_types + 22 },
|
||||
{ "reposition", "3ou", xdg_shell_types + 24 },
|
||||
};
|
||||
|
||||
static const struct wl_message xdg_popup_events[] = {
|
||||
{ "configure", "iiii", xdg_shell_types + 0 },
|
||||
{ "popup_done", "", xdg_shell_types + 0 },
|
||||
{ "repositioned", "3u", xdg_shell_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface xdg_popup_interface = {
|
||||
"xdg_popup", 6,
|
||||
3, xdg_popup_requests,
|
||||
3, xdg_popup_events,
|
||||
};
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue