diff --git a/CMakeLists.txt b/CMakeLists.txt index 58226d5f9..765925b30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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 diff --git a/include/vsg/platform/wayland/Wayland_Window.h b/include/vsg/platform/wayland/Wayland_Window.h index dd6c25d14..59afe2023 100644 --- a/include/vsg/platform/wayland/Wayland_Window.h +++ b/include/vsg/platform/wayland/Wayland_Window.h @@ -10,8 +10,8 @@ #include #include -#include -#include +#include "wayland-xdg-shell-client-protocol.h" +#include "xdg-decoration-client.h" #include #include @@ -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, @@ -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, @@ -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}; @@ -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); diff --git a/src/vsg/CMakeLists.txt b/src/vsg/CMakeLists.txt index 345af292f..a0f91e382 100644 --- a/src/vsg/CMakeLists.txt +++ b/src/vsg/CMakeLists.txt @@ -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) @@ -445,6 +445,7 @@ target_include_directories(vsg PUBLIC $ $ + $ ) target_link_libraries(vsg ${LIBRARIES}) diff --git a/src/vsg/platform/wayland/Wayland_Window.cpp b/src/vsg/platform/wayland/Wayland_Window.cpp index 0a792d981..28424ab5d 100644 --- a/src/vsg/platform/wayland/Wayland_Window.cpp +++ b/src/vsg/platform/wayland/Wayland_Window.cpp @@ -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(data); if(format == WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) @@ -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) { @@ -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) { @@ -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, @@ -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(data); @@ -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(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(data); Wayland_Window *window = static_cast(wl_surface_get_user_data(surface)); window->_currentSurface = surface; @@ -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(data); state->currentWindow->cursor_x = wl_fixed_to_int(x); @@ -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(data); vsg::clock::time_point event_time = vsg::clock::now(); @@ -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(data); vsg::clock::time_point event_time = vsg::clock::now(); if(value > 0) @@ -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(data); vsg::clock::time_point event_time = vsg::clock::now(); if(width != window->_width || height != window->_height) @@ -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): @@ -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);