Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ if (VSG_SUPPORTS_Windowing)
find_library(QUARTZCORE_LIBRARY QuartzCore)
elseif (UNIX)
if(BUILD_WAYLAND)
set(WAYLAND_GENERATED ${PROJECT_BINARY_DIR}/wayland_generated)
file(MAKE_DIRECTORY ${WAYLAND_GENERATED})
set(FIND_DEPENDENCY_WINDOWING "find_package(PkgConfig REQUIRED)\npkg_check_modules(wayland-client REQUIRED IMPORTED_TARGET wayland-client)\npkg_check_modules(wayland-cursor REQUIRED IMPORTED_TARGET wayland-cursor)\npkg_check_modules(xkbcommon REQUIRED IMPORTED_TARGET xkbcommon)\n")
find_package(PkgConfig REQUIRED)
pkg_check_modules(wayland-client REQUIRED IMPORTED_TARGET wayland-client)
Expand All @@ -95,10 +97,10 @@ if (VSG_SUPPORTS_Windowing)
OUTPUT_VARIABLE WAYLAND_PROTOCOLS_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)

execute_process(COMMAND wayland-scanner client-header ${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml ${PROJECT_SOURCE_DIR}/include/vsg/platform/wayland/wayland-xdg-shell-client-protocol.h)
execute_process(COMMAND wayland-scanner private-code ${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml ${PROJECT_SOURCE_DIR}/src/vsg/platform/wayland/wayland-xdg-shell-protocol.c)
execute_process(COMMAND wayland-scanner client-header ${WAYLAND_PROTOCOLS_DIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml ${PROJECT_SOURCE_DIR}/include/vsg/platform/wayland/xdg-decoration-client.h)
execute_process(COMMAND wayland-scanner private-code ${WAYLAND_PROTOCOLS_DIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml ${PROJECT_SOURCE_DIR}/src/vsg/platform/wayland/xdg-decoration-client.c)
execute_process(COMMAND wayland-scanner client-header ${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml ${WAYLAND_GENERATED}/wayland-xdg-shell-client-protocol.h)
execute_process(COMMAND wayland-scanner private-code ${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml ${WAYLAND_GENERATED}/wayland-xdg-shell-protocol.c)
execute_process(COMMAND wayland-scanner client-header ${WAYLAND_PROTOCOLS_DIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml ${WAYLAND_GENERATED}/xdg-decoration-client.h)
execute_process(COMMAND wayland-scanner private-code ${WAYLAND_PROTOCOLS_DIR}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml ${WAYLAND_GENERATED}/xdg-decoration-client.c)
else()
set(FIND_DEPENDENCY_WINDOWING "find_package(PkgConfig REQUIRED)\npkg_check_modules(xcb REQUIRED IMPORTED_TARGET xcb)\n")
# just use Xcb for native windowing
Expand Down
34 changes: 20 additions & 14 deletions include/vsg/platform/wayland/Wayland_Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

#include <vector>
#include <vsg/core/Objects.h>
#include <vsg/platform/wayland/wayland-xdg-shell-client-protocol.h>
#include <vsg/platform/wayland/xdg-decoration-client.h>
#include "wayland-xdg-shell-client-protocol.h"
#include "xdg-decoration-client.h"
#include <vsg/ui/PointerEvent.h>
#include <vulkan/vulkan_wayland.h>

Expand Down Expand Up @@ -54,10 +54,10 @@ namespace vsgWayland
*/
static void keymapEvent(void* data, wl_keyboard* wl_keyboard, uint32_t format, int32_t fd, uint32_t size);
static void kbd_enter_event(void* data, struct wl_keyboard* wl_keyboard, uint32_t serial, struct wl_surface* surface, struct wl_array* keys);
static void kbd_leave_event(void* data, struct wl_keyboard* wl_keyboard, uint32_t serial, struct wl_surface* surface){};
static void kbd_leave_event(void* /*data*/, struct wl_keyboard* /*wl_keyboard*/, uint32_t /*serial*/, struct wl_surface* /*surface*/){};
static void kbd_key_event(void* data, struct wl_keyboard* wl_keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state);
static void kbd_modifier_event(void* data, struct wl_keyboard* wl_keyboard, uint32_t serial, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group);
static void kbd_repeat_event(void* data, wl_keyboard* wl_keyboard, int rate, int delay){};
static void kbd_repeat_event(void* /*data*/, wl_keyboard* /*wl_keyboard*/, int /*rate*/, int /*delay*/){};
constexpr static struct wl_keyboard_listener wl_keyboard_listener = {
.keymap = keymapEvent,
.enter = kbd_enter_event,
Expand All @@ -67,14 +67,16 @@ namespace vsgWayland
.repeat_info = kbd_repeat_event};

static void pointer_enter(void* data, struct wl_pointer* pointer, uint32_t serial, struct wl_surface* surface, wl_fixed_t surface_x, wl_fixed_t surface_y);
static void pointer_leave(void* data, struct wl_pointer* pointer, uint32_t serial, struct wl_surface* surface){};
static void pointer_leave(void* /*data*/, struct wl_pointer* /*pointer*/, uint32_t /*serial*/, struct wl_surface* /*surface*/){};
static void pointer_motion(void* data, struct wl_pointer* pointer, uint32_t time, wl_fixed_t x, wl_fixed_t y);
static void pointer_button(void* data, struct wl_pointer* pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state);
static void pointer_axis(void* data, struct wl_pointer* pointer, uint32_t time, uint32_t axis, wl_fixed_t value);
static void pointer_frame(void* data, wl_pointer* wl_pointer){};
static void pointer_axis_source(void* data, wl_pointer* wl_pointer, uint axis_source){};
static void pointer_axis_stop(void* data, wl_pointer* wl_pointer, uint time, uint axis){};
static void pointer_axis_discrete(void* data, wl_pointer* wl_pointer, uint axis, int discrete){};
static void pointer_frame(void* /*data*/, wl_pointer* /*wl_pointer*/){};
static void pointer_axis_source(void* /*data*/, wl_pointer* /*wl_pointer*/, uint /*axis_source*/){};
static void pointer_axis_stop(void* /*data*/, wl_pointer* /*wl_pointer*/, uint /*time*/, uint /*axis*/){};
static void pointer_axis_discrete(void* /*data*/, wl_pointer* /*wl_pointer*/, uint /*axis*/, int /*discrete*/){};
static void pointer_axis_value120(void* /*data*/, struct wl_pointer* /*wl_pointer*/, uint32_t /*axis*/, int32_t /*value120*/){};
static void pointer_axis_relative_direction(void* /*data*/, struct wl_pointer* /*wl_pointer*/, uint32_t /*axis*/, uint32_t /*direction*/){};
constexpr static struct wl_pointer_listener pointer_listener = {
.enter = pointer_enter,
.leave = pointer_leave,
Expand All @@ -84,16 +86,18 @@ namespace vsgWayland
.frame = pointer_frame,
.axis_source = pointer_axis_source,
.axis_stop = pointer_axis_stop,
.axis_discrete = pointer_axis_discrete};
.axis_discrete = pointer_axis_discrete,
.axis_value120 = pointer_axis_value120,
.axis_relative_direction = pointer_axis_relative_direction};

static void seat_capabilities(void* data, struct wl_seat* seat, uint32_t capabilities);
static void seat_name(void* data, wl_seat* wl_seat, const char* name){};
static void seat_name(void* /*data*/, wl_seat* /*wl_seat*/, const char* /*name*/){};
constexpr static struct wl_seat_listener seat_listener = {
.capabilities = seat_capabilities,
.name = seat_name};

static void registry_add_object(void* data, struct wl_registry* registry, uint32_t id, const char* interface, uint32_t version);
static void registry_remove_object(void* data, struct wl_registry* registry, uint32_t id){};
static void registry_remove_object(void* /*data*/, struct wl_registry* /*registry*/, uint32_t /*id*/){};
constexpr static struct wl_registry_listener registry_listener = {
.global = registry_add_object,
.global_remove = registry_remove_object};
Expand Down Expand Up @@ -162,11 +166,13 @@ namespace vsgWayland

static void xdg_toplevel_handle_configure(void* data, struct xdg_toplevel* xdg_toplevel, int32_t width, int32_t height, struct wl_array* states);
static void xdg_toplevel_handle_close(void* data, struct xdg_toplevel* xdg_toplevel);
static void xdg_toplevel_handle_configure_bounds(void* data, struct xdg_toplevel* xdg_toplevel, int32_t width, int32_t height){};
static void xdg_toplevel_handle_configure_bounds(void* /*data*/, struct xdg_toplevel* /*xdg_toplevel*/, int32_t /*width*/, int32_t /*height*/){};
static void xdg_toplevel_handle_wm_capabilities(void* /*data*/, struct xdg_toplevel* /*xdg_toplevel*/, struct wl_array* /*capabilities*/){};
constexpr static struct xdg_toplevel_listener xdg_toplevel_listener = {
.configure = xdg_toplevel_handle_configure,
.close = xdg_toplevel_handle_close,
.configure_bounds = xdg_toplevel_handle_configure_bounds};
.configure_bounds = xdg_toplevel_handle_configure_bounds,
.wm_capabilities = xdg_toplevel_handle_wm_capabilities};

static void shell_surface_ping(void* data, struct wl_shell_surface* shell_surface, uint32_t serial);
static void shell_surface_configure(void* data, struct wl_shell_surface* shell_surface, uint32_t edges, int32_t width, int32_t height);
Expand Down
3 changes: 2 additions & 1 deletion src/vsg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ if (VSG_SUPPORTS_Windowing)
set(LIBRARIES ${LIBRARIES} PRIVATE ${COCOA_LIBRARY} PRIVATE ${QUARTZCORE_LIBRARY})
elseif (UNIX)
if(BUILD_WAYLAND)
set(SOURCES ${SOURCES} platform/wayland/Wayland_Window.cpp platform/wayland/wayland-xdg-shell-protocol.c platform/wayland/xdg-decoration-client.c)
set(SOURCES ${SOURCES} platform/wayland/Wayland_Window.cpp ${WAYLAND_GENERATED}/wayland-xdg-shell-protocol.c ${WAYLAND_GENERATED}/xdg-decoration-client.c)
set(LIBRARIES ${LIBRARIES} PRIVATE PkgConfig::wayland-client PkgConfig::wayland-cursor PkgConfig::xkbcommon)
else()
set(SOURCES ${SOURCES} platform/xcb/Xcb_Window.cpp)
Expand Down Expand Up @@ -445,6 +445,7 @@ target_include_directories(vsg
PUBLIC
$<BUILD_INTERFACE:${VSG_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${VSG_BINARY_DIR}/include>
$<BUILD_INTERFACE:${VSG_BINARY_DIR}/wayland_generated>
)

target_link_libraries(vsg ${LIBRARIES})
Expand Down
39 changes: 20 additions & 19 deletions src/vsg/platform/wayland/Wayland_Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace vsg
using namespace vsg;
using namespace vsgWayland;

void WaylandRegistryState::keymapEvent(void* data, wl_keyboard *wl_keyboard, uint32_t format, int32_t fd, uint32_t size)
void WaylandRegistryState::keymapEvent(void* data, wl_keyboard* /*wl_keyboard*/, uint32_t format, int32_t fd, uint32_t size)
{
WaylandRegistryState *state = static_cast<WaylandRegistryState*>(data);
if(format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
Expand All @@ -50,8 +50,8 @@ void WaylandRegistryState::keymapEvent(void* data, wl_keyboard *wl_keyboard, uin
}

void WaylandRegistryState::kbd_enter_event(void *data,
struct wl_keyboard *wl_keyboard,
uint32_t serial,
struct wl_keyboard* /*wl_keyboard*/,
uint32_t /*serial*/,
struct wl_surface *surface,
struct wl_array *keys)
{
Expand All @@ -70,9 +70,9 @@ void WaylandRegistryState::kbd_enter_event(void *data,
}

void WaylandRegistryState::kbd_key_event(void *data,
struct wl_keyboard *wl_keyboard,
uint32_t serial,
uint32_t time,
struct wl_keyboard* /*wl_keyboard*/,
uint32_t /*serial*/,
uint32_t /*time*/,
uint32_t key,
uint32_t state)
{
Expand Down Expand Up @@ -100,8 +100,8 @@ void WaylandRegistryState::kbd_key_event(void *data,
}

void WaylandRegistryState::kbd_modifier_event(void *data,
struct wl_keyboard *wl_keyboard,
uint32_t serial,
struct wl_keyboard* /*wl_keyboard*/,
uint32_t /*serial*/,
uint32_t mods_depressed,
uint32_t mods_latched,
uint32_t mods_locked,
Expand All @@ -112,13 +112,13 @@ void WaylandRegistryState::kbd_modifier_event(void *data,
}


void Wayland_Window::xdg_surface_handle_configure(void *data,
void Wayland_Window::xdg_surface_handle_configure(void* /*data*/,
struct xdg_surface *xdg_surface, uint32_t serial) {
xdg_surface_ack_configure(xdg_surface, serial);
}


void Wayland_Window::xdg_toplevel_handle_configure(void *data, struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height, struct wl_array *states) {
void Wayland_Window::xdg_toplevel_handle_configure(void *data, struct xdg_toplevel* /*xdg_toplevel*/, int32_t width, int32_t height, struct wl_array* /*states*/) {
if (width==0 || height==0)
return;
Wayland_Window *window = static_cast<Wayland_Window*>(data);
Expand All @@ -133,19 +133,19 @@ void Wayland_Window::xdg_toplevel_handle_configure(void *data, struct xdg_toplev
}
}

void Wayland_Window::xdg_toplevel_handle_close(void *data, struct xdg_toplevel *xdg_toplevel) {
void Wayland_Window::xdg_toplevel_handle_close(void *data, struct xdg_toplevel* /*xdg_toplevel*/) {
Wayland_Window *window = static_cast<Wayland_Window*>(data);
vsg::clock::time_point event_time = vsg::clock::now();
window->_state->currentWindow = nullptr;
window->bufferedEvents.emplace_back(vsg::CloseWindowEvent::create(window, event_time));
}

void Wayland_Window::xdg_wm_base_ping(void *data, struct xdg_wm_base *xdg_wm_base, uint32_t serial) {
void Wayland_Window::xdg_wm_base_ping(void* /*data*/, struct xdg_wm_base *xdg_wm_base, uint32_t serial) {
xdg_wm_base_pong(xdg_wm_base, serial);
}


void WaylandRegistryState::pointer_enter(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, wl_fixed_t surface_y) {
void WaylandRegistryState::pointer_enter(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t /*surface_x*/, wl_fixed_t /*surface_y*/) {
WaylandRegistryState *state = static_cast<WaylandRegistryState*>(data);
Wayland_Window *window = static_cast<Wayland_Window*>(wl_surface_get_user_data(surface));
window->_currentSurface = surface;
Expand All @@ -161,7 +161,7 @@ void WaylandRegistryState::pointer_enter(void *data, struct wl_pointer *pointer,
state->currentWindow->bufferedEvents.emplace_back(vsg::FocusInEvent::create(window, event_time));
}

void WaylandRegistryState::pointer_motion(void *data, struct wl_pointer *pointer, uint32_t time, wl_fixed_t x, wl_fixed_t y) {
void WaylandRegistryState::pointer_motion(void *data, struct wl_pointer* /*pointer*/, uint32_t /*time*/, wl_fixed_t x, wl_fixed_t y) {
vsg::clock::time_point event_time = vsg::clock::now();
WaylandRegistryState *state = static_cast<WaylandRegistryState*>(data);
state->currentWindow->cursor_x = wl_fixed_to_int(x);
Expand All @@ -173,7 +173,7 @@ void WaylandRegistryState::pointer_motion(void *data, struct wl_pointer *pointer
vsg::ButtonMask(state->maskButtons)));
}

void WaylandRegistryState::pointer_button(void *data, struct wl_pointer *pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state) {
void WaylandRegistryState::pointer_button(void *data, struct wl_pointer* /*pointer*/, uint32_t /*serial*/, uint32_t /*time*/, uint32_t button, uint32_t state) {

WaylandRegistryState *waylandState = static_cast<WaylandRegistryState*>(data);
vsg::clock::time_point event_time = vsg::clock::now();
Expand Down Expand Up @@ -215,7 +215,7 @@ void WaylandRegistryState::pointer_button(void *data, struct wl_pointer *pointer

}

void WaylandRegistryState::pointer_axis(void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value) {
void WaylandRegistryState::pointer_axis(void *data, struct wl_pointer* /*pointer*/, uint32_t /*time*/, uint32_t /*axis*/, wl_fixed_t value) {
WaylandRegistryState *state = static_cast<WaylandRegistryState*>(data);
vsg::clock::time_point event_time = vsg::clock::now();
if(value > 0)
Expand Down Expand Up @@ -264,11 +264,11 @@ void WaylandRegistryState::registry_add_object(void *data, struct wl_registry *r
}
}

void Wayland_Window::shell_surface_ping (void *data, struct wl_shell_surface *shell_surface, uint32_t serial) {
void Wayland_Window::shell_surface_ping (void* /*data*/, struct wl_shell_surface *shell_surface, uint32_t serial) {
wl_shell_surface_pong (shell_surface, serial);
}

void Wayland_Window::shell_surface_configure(void *data, struct wl_shell_surface *shell_surface, uint32_t edges, int32_t width, int32_t height) {
void Wayland_Window::shell_surface_configure(void *data, struct wl_shell_surface* /*shell_surface*/, uint32_t /*edges*/, int32_t width, int32_t height) {
Wayland_Window *window = static_cast<Wayland_Window*>(data);
vsg::clock::time_point event_time = vsg::clock::now();
if(width != window->_width || height != window->_height)
Expand All @@ -281,7 +281,7 @@ void Wayland_Window::shell_surface_configure(void *data, struct wl_shell_surface
}
}

void Wayland_Window::shell_surface_popup_done (void *data, struct wl_shell_surface *shell_surface) {
void Wayland_Window::shell_surface_popup_done (void* /*data*/, struct wl_shell_surface* /*shell_surface*/) {
}

Wayland_surface::Wayland_surface(Instance* instance, wl_display* wlDisplay, wl_surface* wlSurface):
Expand Down Expand Up @@ -398,6 +398,7 @@ void Wayland_Window::_initSurface()
throw Exception{"failed to create Wayland window"};
}

wl_surface_commit(_wlSurface);
wl_display_roundtrip(_state->_wlDisplay);
if(!_surface)
_surface = new Wayland_surface(_instance,_state->_wlDisplay,_wlSurface);
Expand Down
Loading