Skip to content

Commit

Permalink
Update to build against wlroots 0.16.0 (#1624)
Browse files Browse the repository at this point in the history
* CI: Add hwdata dependency to alpine build

Required by wlroots.

* Update wlroots subproject to 0.16.0

* Update to build against wlroots 0.16.0
  • Loading branch information
soreau committed Nov 24, 2022
1 parent 3c28e9a commit 93b7c82
Show file tree
Hide file tree
Showing 39 changed files with 252 additions and 178 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
container: alpine:edge
steps:
- run: apk --no-cache add git gcc g++ binutils pkgconf meson ninja musl-dev wayland-dev wayland-protocols libinput-dev libevdev-dev libxkbcommon-dev pixman-dev glm-dev libdrm-dev mesa-dev cairo-dev pango-dev eudev-dev libxml2-dev libseat-dev libxcb-dev xcb-util-wm-dev xwayland doctest doctest-dev cmake
- run: apk --no-cache add git gcc g++ binutils pkgconf meson ninja musl-dev wayland-dev wayland-protocols libinput-dev libevdev-dev libxkbcommon-dev pixman-dev glm-dev libdrm-dev mesa-dev cairo-dev pango-dev eudev-dev libxml2-dev libseat-dev libxcb-dev xcb-util-wm-dev xwayland doctest doctest-dev cmake hwdata
- uses: actions/checkout@v1
- run: git config --global --add safe.directory /__w/wayfire/wayfire
- run: git submodule sync --recursive && git submodule update --init --force --recursive
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pixman = dependency('pixman-1')
threads = dependency('threads')
xkbcommon = dependency('xkbcommon')
libdl = meson.get_compiler('cpp').find_library('dl')
wlroots = dependency('wlroots', version: ['>=0.15.0', '<0.16.0'], required: get_option('use_system_wlroots'))
wlroots = dependency('wlroots', version: ['>=0.16.0', '<0.17.0'], required: get_option('use_system_wlroots'))
wfconfig = dependency('wf-config', version: ['>=0.8.0', '<0.9.0'], required: get_option('use_system_wfconfig'))

use_system_wlroots = not get_option('use_system_wlroots').disabled() and wlroots.found()
Expand Down
6 changes: 3 additions & 3 deletions plugins/cube/cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class wayfire_cube : public wf::plugin_interface_t
};

grab_interface->callbacks.pointer.axis = [=] (
wlr_event_pointer_axis *ev)
wlr_pointer_axis_event *ev)
{
if (ev->orientation == WLR_AXIS_ORIENTATION_VERTICAL)
{
Expand Down Expand Up @@ -573,7 +573,7 @@ class wayfire_cube : public wf::plugin_interface_t
wf::signal_connection_t on_motion_event = [=] (wf::signal_data_t *data)
{
auto ev = static_cast<
wf::input_event_signal<wlr_event_pointer_motion>*>(data);
wf::input_event_signal<wlr_pointer_motion_event>*>(data);

pointer_moved(ev->event);

Expand All @@ -583,7 +583,7 @@ class wayfire_cube : public wf::plugin_interface_t
ev->event->unaccel_dy = 0;
};

void pointer_moved(wlr_event_pointer_motion *ev)
void pointer_moved(wlr_pointer_motion_event *ev)
{
if (animation.in_exit)
{
Expand Down
92 changes: 60 additions & 32 deletions plugins/ipc/stipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ extern "C" {
#include <wlr/backend/headless.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/interfaces/wlr_touch.h>
#include <wlr/types/wlr_virtual_pointer_v1.h>
#include <wlr/types/wlr_virtual_keyboard_v1.h>
#include <wlr/types/wlr_output_layout.h>
#include <libevdev/libevdev.h>
}
Expand Down Expand Up @@ -89,23 +93,43 @@ static std::string layer_to_string(uint32_t layer)
return "none";
}

static const struct wlr_pointer_impl pointer_impl = {
.name = "stipc-pointer",
};

static void led_update(wlr_keyboard *keyboard, uint32_t leds)
{}

static const struct wlr_keyboard_impl keyboard_impl = {
.name = "stipc-keyboard",
.led_update = led_update,
};

static const struct wlr_touch_impl touch_impl = {
.name = "stipc-touch-device",
};

class headless_input_backend_t
{
public:
wlr_backend *backend;
wlr_input_device *pointer;
wlr_input_device *keyboard;
wlr_input_device *touch;
wlr_pointer pointer;
wlr_keyboard keyboard;
wlr_touch touch;

headless_input_backend_t()
{
auto& core = wf::get_core();
backend = wlr_headless_backend_create(core.display);
wlr_multi_backend_add(core.backend, backend);

pointer = wlr_headless_add_input_device(backend, WLR_INPUT_DEVICE_POINTER);
keyboard = wlr_headless_add_input_device(backend, WLR_INPUT_DEVICE_KEYBOARD);
touch = wlr_headless_add_input_device(backend, WLR_INPUT_DEVICE_TOUCH);
wlr_pointer_init(&pointer, &pointer_impl, "stipc_pointer");
wlr_keyboard_init(&keyboard, &keyboard_impl, "stipc_keyboard");
wlr_touch_init(&touch, &touch_impl, "stipc_touch");

wl_signal_emit_mutable(&backend->events.new_input, &pointer.base);
wl_signal_emit_mutable(&backend->events.new_input, &keyboard.base);
wl_signal_emit_mutable(&backend->events.new_input, &touch.base);

if (core.get_current_state() == compositor_state_t::RUNNING)
{
Expand All @@ -116,80 +140,84 @@ class headless_input_backend_t
~headless_input_backend_t()
{
auto& core = wf::get_core();
wlr_pointer_finish(&pointer);
wlr_keyboard_finish(&keyboard);
wlr_touch_finish(&touch);
wlr_multi_backend_remove(core.backend, backend);
wlr_backend_destroy(backend);
}

void do_key(uint32_t key, wl_keyboard_key_state state)
{
wlr_event_keyboard_key ev;
wlr_keyboard_key_event ev;
ev.keycode = key;
ev.state = state;
ev.update_state = true;
ev.time_msec = get_current_time();
wlr_keyboard_notify_key(keyboard->keyboard, &ev);
wlr_keyboard_notify_key(&keyboard, &ev);
}

void do_button(uint32_t button, wlr_button_state state)
{
wlr_event_pointer_button ev;
ev.device = pointer;
wlr_pointer_button_event ev;
ev.pointer = &pointer;
ev.button = button;
ev.state = state;
ev.time_msec = get_current_time();
wl_signal_emit(&pointer->pointer->events.button, &ev);
wl_signal_emit(&pointer->pointer->events.frame, NULL);
wl_signal_emit(&pointer.events.button, &ev);
wl_signal_emit(&pointer.events.frame, NULL);
}

void do_motion(double x, double y)
{
auto cursor = wf::get_core().get_cursor_position();

wlr_event_pointer_motion ev;
ev.device = pointer;
wlr_pointer_motion_event ev;
ev.pointer = &pointer;
ev.time_msec = get_current_time();
ev.delta_x = ev.unaccel_dx = x - cursor.x;
ev.delta_y = ev.unaccel_dy = y - cursor.y;
wl_signal_emit(&pointer->pointer->events.motion, &ev);
wl_signal_emit(&pointer->pointer->events.frame, NULL);
wl_signal_emit(&pointer.events.motion, &ev);
wl_signal_emit(&pointer.events.frame, NULL);
}

void do_touch(int finger, double x, double y)
{
auto layout = wf::get_core().output_layout->get_handle();
auto box = wlr_output_layout_get_box(layout, NULL);
wlr_box box;
wlr_output_layout_get_box(layout, NULL, &box);

if (!wf::get_core().get_touch_state().fingers.count(finger))
{
wlr_event_touch_down ev;
ev.device = touch;
wlr_touch_down_event ev;
ev.touch = &touch;
ev.time_msec = get_current_time();
ev.x = 1.0 * (x - box->x) / box->width;
ev.y = 1.0 * (y - box->y) / box->height;
ev.x = 1.0 * (x - box.x) / box.width;
ev.y = 1.0 * (y - box.y) / box.height;
ev.touch_id = finger;
wl_signal_emit(&touch->touch->events.down, &ev);
wl_signal_emit(&touch.events.down, &ev);
} else
{
wlr_event_touch_motion ev;
ev.device = touch;
wlr_touch_motion_event ev;
ev.touch = &touch;
ev.time_msec = get_current_time();
ev.x = 1.0 * (x - box->x) / box->width;
ev.y = 1.0 * (y - box->y) / box->height;
ev.x = 1.0 * (x - box.x) / box.width;
ev.y = 1.0 * (y - box.y) / box.height;
ev.touch_id = finger;
wl_signal_emit(&touch->touch->events.motion, &ev);
wl_signal_emit(&touch.events.motion, &ev);
}

wl_signal_emit(&touch->touch->events.frame, NULL);
wl_signal_emit(&touch.events.frame, NULL);
}

void do_touch_release(int finger)
{
wlr_event_touch_up ev;
ev.device = touch;
wlr_touch_up_event ev;
ev.touch = &touch;
ev.time_msec = get_current_time();
ev.touch_id = finger;
wl_signal_emit(&touch->touch->events.up, &ev);
wl_signal_emit(&touch->touch->events.frame, NULL);
wl_signal_emit(&touch.events.up, &ev);
wl_signal_emit(&touch.events.frame, NULL);
}

headless_input_backend_t(const headless_input_backend_t&) = delete;
Expand Down
2 changes: 1 addition & 1 deletion plugins/scale/scale-title-filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class scale_title_filter : public wf::singleton_plugin_t<scale_title_filter_text
wf::signal_connection_t scale_key = [this] (wf::signal_data_t *data)
{
auto k =
static_cast<wf::input_event_signal<wlr_event_keyboard_key>*>(data);
static_cast<wf::input_event_signal<wlr_keyboard_key_event>*>(data);
if (k->event->state == WL_KEYBOARD_KEY_STATE_RELEASED)
{
keys.erase(k->event->keycode);
Expand Down
6 changes: 3 additions & 3 deletions plugins/scale/scale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class wayfire_scale : public wf::plugin_interface_t
wf::signal_connection_t on_button_event = [=] (wf::signal_data_t *data)
{
auto ev = static_cast<
wf::input_event_signal<wlr_event_pointer_button>*>(data);
wf::input_event_signal<wlr_pointer_button_event>*>(data);

process_input(ev->event->button, ev->event->state,
wf::get_core().get_cursor_position());
Expand All @@ -343,7 +343,7 @@ class wayfire_scale : public wf::plugin_interface_t
wf::signal_connection_t on_touch_down_event = [=] (wf::signal_data_t *data)
{
auto ev = static_cast<
wf::input_event_signal<wlr_event_touch_down>*>(data);
wf::input_event_signal<wlr_touch_down_event>*>(data);
if (ev->event->touch_id == 0)
{
process_input(BTN_LEFT, WLR_BUTTON_PRESSED,
Expand All @@ -354,7 +354,7 @@ class wayfire_scale : public wf::plugin_interface_t
wf::signal_connection_t on_touch_up_event = [=] (wf::signal_data_t *data)
{
auto ev = static_cast<
wf::input_event_signal<wlr_event_touch_up>*>(data);
wf::input_event_signal<wlr_touch_up_event>*>(data);
if (ev->event->touch_id == 0)
{
process_input(BTN_LEFT, WLR_BUTTON_RELEASED,
Expand Down
2 changes: 1 addition & 1 deletion plugins/single_plugins/alpha.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class wayfire_alpha : public wf::plugin_interface_t
}
}

wf::axis_callback axis_cb = [=] (wlr_event_pointer_axis *ev)
wf::axis_callback axis_cb = [=] (wlr_pointer_axis_event *ev)
{
if (!output->activate_plugin(grab_interface))
{
Expand Down
4 changes: 2 additions & 2 deletions plugins/single_plugins/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class wayfire_command : public wf::plugin_interface_t
wf::signal_connection_t on_button_event = [=] (wf::signal_data_t *data)
{
auto ev = static_cast<
wf::input_event_signal<wlr_event_pointer_button>*>(data);
wf::input_event_signal<wlr_pointer_button_event>*>(data);
if ((ev->event->button == repeat.pressed_button) &&
(ev->event->state == WLR_BUTTON_RELEASED))
{
Expand All @@ -163,7 +163,7 @@ class wayfire_command : public wf::plugin_interface_t
wf::signal_connection_t on_key_event = [=] (wf::signal_data_t *data)
{
auto ev = static_cast<
wf::input_event_signal<wlr_event_keyboard_key>*>(data);
wf::input_event_signal<wlr_keyboard_key_event>*>(data);
if ((ev->event->keycode == repeat.pressed_key) &&
(ev->event->state == WLR_KEY_RELEASED))
{
Expand Down
4 changes: 2 additions & 2 deletions plugins/single_plugins/vswipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class vswipe : public wf::plugin_interface_t
}

auto ev = static_cast<
event<wlr_event_pointer_swipe_begin>*>(data)->event;
event<wlr_pointer_swipe_begin_event>*>(data)->event;
if (static_cast<int>(ev->fingers) != fingers)
{
return;
Expand Down Expand Up @@ -257,7 +257,7 @@ class vswipe : public wf::plugin_interface_t
}

auto ev = static_cast<
event<wlr_event_pointer_swipe_update>*>(data)->event;
event<wlr_pointer_swipe_update_event>*>(data)->event;

state.delta_sum.x += ev->dx / speed_factor;
state.delta_sum.y += ev->dy / speed_factor;
Expand Down
2 changes: 1 addition & 1 deletion plugins/single_plugins/zoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class wayfire_zoom_screen : public wf::plugin_interface_t
}
}

wf::axis_callback axis = [=] (wlr_event_pointer_axis *ev)
wf::axis_callback axis = [=] (wlr_pointer_axis_event *ev)
{
if (!output->can_activate_plugin(grab_interface))
{
Expand Down
2 changes: 1 addition & 1 deletion src/api/wayfire/bindings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ using button_callback = std::function<bool (const wf::buttonbinding_t&)>;
* case it will not be sent to clients (but may still be received by other
* plugins).
*/
using axis_callback = std::function<bool (wlr_event_pointer_axis*)>;
using axis_callback = std::function<bool (wlr_pointer_axis_event*)>;

/**
* Describes the possible event sources that can activate an activator binding.
Expand Down
3 changes: 2 additions & 1 deletion src/api/wayfire/nonstd/wlroots-full.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ extern "C"
#include <wlr/types/wlr_xdg_shell.h>
#include <wlr/types/wlr_xdg_decoration_v1.h>
#endif
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_subcompositor.h>

#include <wlr/types/wlr_foreign_toplevel_management_v1.h>
#include <wlr/types/wlr_server_decoration.h>
Expand Down
4 changes: 2 additions & 2 deletions src/api/wayfire/nonstd/wlroots.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ extern "C"
struct wlr_xdg_foreign_v2;
struct wlr_xdg_foreign_registry;

struct wlr_event_pointer_axis;
struct wlr_event_pointer_motion;
struct wlr_pointer_axis_event;
struct wlr_pointer_motion_event;
struct wlr_output_layout;
struct wlr_surface;
struct wlr_texture;
Expand Down
4 changes: 2 additions & 2 deletions src/api/wayfire/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ struct plugin_grab_interface_t
{
struct
{
std::function<void(wlr_event_pointer_axis*)> axis;
std::function<void(wlr_pointer_axis_event*)> axis;
std::function<void(uint32_t, uint32_t)> button; // button, state
std::function<void(int32_t, int32_t)> motion; // x, y
std::function<void(wlr_event_pointer_motion*)> relative_motion;
std::function<void(wlr_pointer_motion_event*)> relative_motion;
} pointer;

struct
Expand Down
6 changes: 3 additions & 3 deletions src/api/wayfire/scene-input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class keyboard_interaction_t
*
* @return What should happen with the further processing of the event.
*/
virtual void handle_keyboard_key(wlr_event_keyboard_key event)
virtual void handle_keyboard_key(wlr_keyboard_key_event event)
{}

keyboard_interaction_t() = default;
Expand Down Expand Up @@ -103,7 +103,7 @@ class pointer_interaction_t
* @param button The wlr event describing the event.
*/
virtual void handle_pointer_button(
const wlr_event_pointer_button& event)
const wlr_pointer_button_event& event)
{}

/**
Expand All @@ -122,7 +122,7 @@ class pointer_interaction_t
* @param pointer_position The position where the pointer is currently at.
* @param event A structure describing the event.
*/
virtual void handle_pointer_axis(const wlr_event_pointer_axis& event)
virtual void handle_pointer_axis(const wlr_pointer_axis_event& event)
{}
};

Expand Down
2 changes: 1 addition & 1 deletion src/api/wayfire/signal-definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ enum class input_event_processing_mode_t
* by core has finished.
*
* example: The pointer_motion event is emitted with data of type
* input_event_signal<wlr_event_pointer_motion>
* input_event_signal<wlr_pointer_motion_event>
*/
template<class wlr_event_t>
struct input_event_signal : public wf::signal_data_t
Expand Down
Loading

0 comments on commit 93b7c82

Please sign in to comment.