Port to wlroots 0.16
This commit is contained in:
parent
17814972ab
commit
7e120a28a1
19 changed files with 126 additions and 99 deletions
|
@ -20,7 +20,7 @@ struct kiwmi_desktop_surface {
|
|||
// The tree is where the config is supposed to put custom decorations (it
|
||||
// also contains the surface_node)
|
||||
struct wlr_scene_tree *tree;
|
||||
struct wlr_scene_node *surface_node;
|
||||
struct wlr_scene_tree *surface_tree;
|
||||
|
||||
struct wlr_scene_tree *popups_tree;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/util/box.h>
|
||||
|
||||
#include "desktop/desktop_surface.h"
|
||||
|
|
|
@ -50,7 +50,7 @@ struct kiwmi_cursor {
|
|||
};
|
||||
|
||||
struct kiwmi_cursor_button_event {
|
||||
struct wlr_event_pointer_button *wlr_event;
|
||||
struct wlr_pointer_button_event *wlr_event;
|
||||
bool handled;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
struct kiwmi_keyboard {
|
||||
struct wl_list link;
|
||||
struct kiwmi_server *server;
|
||||
struct wlr_input_device *device;
|
||||
struct wlr_keyboard *wlr_keyboard;
|
||||
struct wl_listener modifiers;
|
||||
struct wl_listener key;
|
||||
struct wl_listener device_destroy;
|
||||
|
@ -39,7 +39,7 @@ struct kiwmi_keyboard_key_event {
|
|||
};
|
||||
|
||||
struct kiwmi_keyboard *
|
||||
keyboard_create(struct kiwmi_server *server, struct wlr_input_device *device);
|
||||
keyboard_create(struct kiwmi_server *server, struct wlr_keyboard *device);
|
||||
void keyboard_destroy(struct kiwmi_keyboard *keyboard);
|
||||
|
||||
#endif /* KIWMI_INPUT_KEYBOARD_H */
|
||||
|
|
|
@ -9,19 +9,19 @@
|
|||
#define KIWMI_INPUT_POINTER_H
|
||||
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/types/wlr_pointer.h>
|
||||
|
||||
#include "server.h"
|
||||
|
||||
struct kiwmi_pointer {
|
||||
struct wlr_input_device *device;
|
||||
struct wlr_pointer *pointer;
|
||||
struct wl_list link;
|
||||
|
||||
struct wl_listener device_destroy;
|
||||
};
|
||||
|
||||
struct kiwmi_pointer *
|
||||
pointer_create(struct kiwmi_server *server, struct wlr_input_device *device);
|
||||
pointer_create(struct kiwmi_server *server, struct wlr_pointer *pointer);
|
||||
void pointer_destroy(struct kiwmi_pointer *pointer);
|
||||
|
||||
#endif /* KIWMI_INPUT_POINTER_H */
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#define KIWMI_INPUT_SEAT_H
|
||||
|
||||
#include <wayland-server.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
|
||||
#include "desktop/layer_shell.h"
|
||||
#include "desktop/view.h"
|
||||
|
|
|
@ -57,13 +57,13 @@ desktop_init(struct kiwmi_desktop *desktop)
|
|||
|
||||
const float bg_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
desktop->background_rect =
|
||||
wlr_scene_rect_create(&desktop->scene->node, 0, 0, bg_color);
|
||||
wlr_scene_rect_create(&desktop->scene->tree, 0, 0, bg_color);
|
||||
// No point in showing black
|
||||
wlr_scene_node_set_enabled(&desktop->background_rect->node, false);
|
||||
|
||||
// Create a scene-graph tree for each stratum
|
||||
for (size_t i = 0; i < KIWMI_STRATA_COUNT; ++i) {
|
||||
desktop->strata[i] = wlr_scene_tree_create(&desktop->scene->node);
|
||||
desktop->strata[i] = wlr_scene_tree_create(&desktop->scene->tree);
|
||||
}
|
||||
|
||||
wlr_scene_attach_output_layout(desktop->scene, desktop->output_layout);
|
||||
|
@ -72,7 +72,7 @@ desktop_init(struct kiwmi_desktop *desktop)
|
|||
wlr_presentation_create(server->wl_display, server->backend);
|
||||
wlr_scene_set_presentation(desktop->scene, presentation);
|
||||
|
||||
desktop->xdg_shell = wlr_xdg_shell_create(server->wl_display);
|
||||
desktop->xdg_shell = wlr_xdg_shell_create(server->wl_display, 5);
|
||||
desktop->xdg_shell_new_surface.notify = xdg_shell_new_surface_notify;
|
||||
wl_signal_add(
|
||||
&desktop->xdg_shell->events.new_surface,
|
||||
|
@ -114,7 +114,7 @@ desktop_fini(struct kiwmi_desktop *desktop)
|
|||
{
|
||||
wlr_output_layout_destroy(desktop->output_layout);
|
||||
desktop->output_layout = NULL;
|
||||
wlr_scene_node_destroy(&desktop->scene->node);
|
||||
wlr_scene_node_destroy(&desktop->scene->tree.node);
|
||||
desktop->scene = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_layer_shell_v1.h>
|
||||
#include <wlr/types/wlr_scene.h>
|
||||
#include <wlr/types/wlr_subcompositor.h>
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
|
||||
#include "desktop/desktop.h"
|
||||
|
@ -55,16 +55,23 @@ desktop_surface_from_wlr_surface(struct wlr_surface *surface)
|
|||
struct kiwmi_desktop_surface *
|
||||
desktop_surface_at(struct kiwmi_desktop *desktop, double lx, double ly)
|
||||
{
|
||||
double sx, sy; // unused
|
||||
double sx, sy;
|
||||
struct wlr_scene_node *node_at =
|
||||
wlr_scene_node_at(&desktop->scene->node, lx, ly, &sx, &sy);
|
||||
wlr_scene_node_at(&desktop->scene->tree.node, lx, ly, &sx, &sy);
|
||||
|
||||
if (!node_at || node_at->type != WLR_SCENE_NODE_SURFACE) {
|
||||
if (!node_at || node_at->type != WLR_SCENE_NODE_BUFFER) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct wlr_surface *surface = wlr_scene_surface_from_node(node_at)->surface;
|
||||
return desktop_surface_from_wlr_surface(surface);
|
||||
struct wlr_scene_buffer *scene_buffer = wlr_scene_buffer_from_node(node_at);
|
||||
struct wlr_scene_surface *scene_surface =
|
||||
wlr_scene_surface_from_buffer(scene_buffer);
|
||||
|
||||
if (!scene_surface) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return desktop_surface_from_wlr_surface(scene_surface->surface);
|
||||
}
|
||||
|
||||
struct kiwmi_output *
|
||||
|
|
|
@ -56,8 +56,7 @@ kiwmi_layer_commit_notify(struct wl_listener *listener, void *UNUSED(data))
|
|||
stratum_from_layer_shell_layer(layer->layer);
|
||||
|
||||
wlr_scene_node_reparent(
|
||||
&layer->desktop_surface.tree->node,
|
||||
&output->strata[new_stratum]->node);
|
||||
&layer->desktop_surface.tree->node, output->strata[new_stratum]);
|
||||
}
|
||||
|
||||
if (layer->layer_surface->current.committed != 0) {
|
||||
|
@ -432,11 +431,11 @@ layer_shell_new_surface_notify(struct wl_listener *listener, void *data)
|
|||
enum kiwmi_stratum stratum = stratum_from_layer_shell_layer(layer->layer);
|
||||
|
||||
layer->desktop_surface.tree =
|
||||
wlr_scene_tree_create(&output->strata[stratum]->node);
|
||||
wlr_scene_tree_create(output->strata[stratum]);
|
||||
layer->desktop_surface.popups_tree =
|
||||
wlr_scene_tree_create(&output->strata[KIWMI_STRATUM_POPUPS]->node);
|
||||
layer->desktop_surface.surface_node = wlr_scene_subsurface_tree_create(
|
||||
&layer->desktop_surface.tree->node, layer->layer_surface->surface);
|
||||
wlr_scene_tree_create(output->strata[KIWMI_STRATUM_POPUPS]);
|
||||
layer->desktop_surface.surface_tree = wlr_scene_subsurface_tree_create(
|
||||
layer->desktop_surface.tree, layer->layer_surface->surface);
|
||||
|
||||
wlr_scene_node_set_enabled(&layer->desktop_surface.tree->node, false);
|
||||
wlr_scene_node_set_enabled(
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
#include <wlr/backend.h>
|
||||
#include <wlr/render/allocator.h>
|
||||
#include <wlr/render/wlr_renderer.h>
|
||||
#include <wlr/types/wlr_compositor.h>
|
||||
#include <wlr/types/wlr_layer_shell_v1.h>
|
||||
#include <wlr/types/wlr_matrix.h>
|
||||
#include <wlr/types/wlr_output.h>
|
||||
#include <wlr/types/wlr_output_layout.h>
|
||||
#include <wlr/types/wlr_scene.h>
|
||||
#include <wlr/types/wlr_surface.h>
|
||||
#include <wlr/types/wlr_xcursor_manager.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
|
@ -180,10 +180,10 @@ new_output_notify(struct wl_listener *listener, void *data)
|
|||
|
||||
struct kiwmi_pointer *pointer;
|
||||
wl_list_for_each (pointer, &server->input.pointers, link) {
|
||||
if (pointer->device->output_name
|
||||
&& strcmp(pointer->device->output_name, wlr_output->name) == 0) {
|
||||
if (pointer->pointer->base.name
|
||||
&& strcmp(pointer->pointer->base.name, wlr_output->name) == 0) {
|
||||
wlr_cursor_map_input_to_output(
|
||||
cursor->cursor, pointer->device, wlr_output);
|
||||
cursor->cursor, &pointer->pointer->base, wlr_output);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ new_output_notify(struct wl_listener *listener, void *data)
|
|||
}
|
||||
|
||||
for (size_t i = 0; i < KIWMI_STRATA_COUNT; ++i) {
|
||||
output->strata[i] = wlr_scene_tree_create(&desktop->strata[i]->node);
|
||||
output->strata[i] = wlr_scene_tree_create(desktop->strata[i]);
|
||||
}
|
||||
|
||||
wl_signal_init(&output->events.destroy);
|
||||
|
@ -219,24 +219,25 @@ output_layout_change_notify(struct wl_listener *listener, void *UNUSED(data))
|
|||
struct kiwmi_desktop *desktop =
|
||||
wl_container_of(listener, desktop, output_layout_change);
|
||||
|
||||
struct wlr_box *ol_box =
|
||||
wlr_output_layout_get_box(desktop->output_layout, NULL);
|
||||
struct wlr_box ol_box;
|
||||
wlr_output_layout_get_box(desktop->output_layout, NULL, &ol_box);
|
||||
wlr_scene_node_set_position(
|
||||
&desktop->background_rect->node, ol_box->x, ol_box->y);
|
||||
&desktop->background_rect->node, ol_box.x, ol_box.y);
|
||||
wlr_scene_rect_set_size(
|
||||
desktop->background_rect, ol_box->width, ol_box->height);
|
||||
desktop->background_rect, ol_box.width, ol_box.height);
|
||||
|
||||
struct wlr_output_layout_output *ol_output;
|
||||
wl_list_for_each (ol_output, &desktop->output_layout->outputs, link) {
|
||||
struct kiwmi_output *output = ol_output->output->data;
|
||||
|
||||
struct wlr_box *box = wlr_output_layout_get_box(
|
||||
desktop->output_layout, output->wlr_output);
|
||||
struct wlr_box box;
|
||||
wlr_output_layout_get_box(
|
||||
desktop->output_layout, output->wlr_output, &box);
|
||||
|
||||
for (size_t i = 0; i < KIWMI_STRATA_COUNT; ++i) {
|
||||
if (output->strata[i]) {
|
||||
wlr_scene_node_set_position(
|
||||
&output->strata[i]->node, box->x, box->y);
|
||||
&output->strata[i]->node, box.x, box.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,10 @@ popup_get_desktop_surface(struct wlr_xdg_popup *popup)
|
|||
case WLR_XDG_SURFACE_ROLE_POPUP:
|
||||
parent = xdg_surface->popup->parent;
|
||||
break;
|
||||
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
|
||||
case WLR_XDG_SURFACE_ROLE_TOPLEVEL: {
|
||||
struct kiwmi_view *view = xdg_surface->data;
|
||||
return &view->desktop_surface;
|
||||
}
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
|
@ -109,11 +110,11 @@ popup_attach(
|
|||
|
||||
popup_unconstrain(popup, desktop_surface);
|
||||
|
||||
struct wlr_scene_node *node =
|
||||
wlr_scene_xdg_surface_create(&parent_tree->node, popup->base);
|
||||
if (!node) {
|
||||
struct wlr_scene_tree *tree =
|
||||
wlr_scene_xdg_surface_create(parent_tree, popup->base);
|
||||
if (!tree) {
|
||||
wlr_log(WLR_ERROR, "failed to attach popup to scene");
|
||||
return;
|
||||
}
|
||||
popup->base->data = node;
|
||||
popup->base->data = tree;
|
||||
}
|
||||
|
|
|
@ -202,8 +202,8 @@ view_desktop_surface_get_output(struct kiwmi_desktop_surface *desktop_surface)
|
|||
// Prefer view center
|
||||
struct wlr_output *output = wlr_output_layout_output_at(
|
||||
view->desktop->output_layout,
|
||||
lx + view->geom.width / 2,
|
||||
ly + view->geom.height / 2);
|
||||
lx + (float)view->geom.width / 2,
|
||||
ly + (float)view->geom.height / 2);
|
||||
if (output) {
|
||||
return (struct kiwmi_output *)output->data;
|
||||
}
|
||||
|
@ -248,10 +248,10 @@ view_create(
|
|||
wl_signal_init(&view->events.post_render);
|
||||
wl_signal_init(&view->events.pre_render);
|
||||
|
||||
view->desktop_surface.tree = wlr_scene_tree_create(
|
||||
&view->desktop->strata[KIWMI_STRATUM_NORMAL]->node);
|
||||
view->desktop_surface.popups_tree = wlr_scene_tree_create(
|
||||
&view->desktop->strata[KIWMI_STRATUM_POPUPS]->node);
|
||||
view->desktop_surface.tree =
|
||||
wlr_scene_tree_create(view->desktop->strata[KIWMI_STRATUM_NORMAL]);
|
||||
view->desktop_surface.popups_tree =
|
||||
wlr_scene_tree_create(view->desktop->strata[KIWMI_STRATUM_POPUPS]);
|
||||
|
||||
view_set_hidden(view, true);
|
||||
wlr_scene_node_lower_to_bottom(&view->desktop_surface.tree->node);
|
||||
|
|
|
@ -133,7 +133,7 @@ xdg_shell_view_close(struct kiwmi_view *view)
|
|||
struct wlr_xdg_surface *surface = view->xdg_surface;
|
||||
|
||||
if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL && surface->toplevel) {
|
||||
wlr_xdg_toplevel_send_close(surface);
|
||||
wlr_xdg_toplevel_send_close(surface->toplevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ xdg_shell_view_get_string_prop(
|
|||
static void
|
||||
xdg_shell_view_set_activated(struct kiwmi_view *view, bool activated)
|
||||
{
|
||||
wlr_xdg_toplevel_set_activated(view->xdg_surface, activated);
|
||||
wlr_xdg_toplevel_set_activated(view->xdg_surface->toplevel, activated);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -175,13 +175,13 @@ xdg_shell_view_set_size(
|
|||
uint32_t width,
|
||||
uint32_t height)
|
||||
{
|
||||
wlr_xdg_toplevel_set_size(view->xdg_surface, width, height);
|
||||
wlr_xdg_toplevel_set_size(view->xdg_surface->toplevel, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
xdg_shell_view_set_tiled(struct kiwmi_view *view, enum wlr_edges edges)
|
||||
{
|
||||
wlr_xdg_toplevel_set_tiled(view->xdg_surface, edges);
|
||||
wlr_xdg_toplevel_set_tiled(view->xdg_surface->toplevel, edges);
|
||||
}
|
||||
|
||||
static const struct kiwmi_view_impl xdg_shell_view_impl = {
|
||||
|
@ -233,8 +233,8 @@ xdg_shell_new_surface_notify(struct wl_listener *listener, void *data)
|
|||
view->xdg_surface = xdg_surface;
|
||||
view->wlr_surface = xdg_surface->surface;
|
||||
|
||||
view->desktop_surface.surface_node = wlr_scene_xdg_surface_create(
|
||||
&view->desktop_surface.tree->node, xdg_surface);
|
||||
view->desktop_surface.surface_tree =
|
||||
wlr_scene_xdg_surface_create(view->desktop_surface.tree, xdg_surface);
|
||||
|
||||
view->map.notify = xdg_surface_map_notify;
|
||||
wl_signal_add(&xdg_surface->events.map, &view->map);
|
||||
|
|
|
@ -102,7 +102,7 @@ cursor_motion_notify(struct wl_listener *listener, void *data)
|
|||
struct kiwmi_cursor *cursor =
|
||||
wl_container_of(listener, cursor, cursor_motion);
|
||||
struct kiwmi_server *server = cursor->server;
|
||||
struct wlr_event_pointer_motion *event = data;
|
||||
struct wlr_pointer_motion_event *event = data;
|
||||
|
||||
struct kiwmi_cursor_motion_event new_event = {
|
||||
.oldx = cursor->cursor->x,
|
||||
|
@ -110,7 +110,7 @@ cursor_motion_notify(struct wl_listener *listener, void *data)
|
|||
};
|
||||
|
||||
wlr_cursor_move(
|
||||
cursor->cursor, event->device, event->delta_x, event->delta_y);
|
||||
cursor->cursor, &event->pointer->base, event->delta_x, event->delta_y);
|
||||
|
||||
new_event.newx = cursor->cursor->x;
|
||||
new_event.newy = cursor->cursor->y;
|
||||
|
@ -126,14 +126,15 @@ cursor_motion_absolute_notify(struct wl_listener *listener, void *data)
|
|||
struct kiwmi_cursor *cursor =
|
||||
wl_container_of(listener, cursor, cursor_motion_absolute);
|
||||
struct kiwmi_server *server = cursor->server;
|
||||
struct wlr_event_pointer_motion_absolute *event = data;
|
||||
struct wlr_pointer_motion_absolute_event *event = data;
|
||||
|
||||
struct kiwmi_cursor_motion_event new_event = {
|
||||
.oldx = cursor->cursor->x,
|
||||
.oldy = cursor->cursor->y,
|
||||
};
|
||||
|
||||
wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
|
||||
wlr_cursor_warp_absolute(
|
||||
cursor->cursor, &event->pointer->base, event->x, event->y);
|
||||
|
||||
new_event.newx = cursor->cursor->x;
|
||||
new_event.newy = cursor->cursor->y;
|
||||
|
@ -150,7 +151,7 @@ cursor_button_notify(struct wl_listener *listener, void *data)
|
|||
wl_container_of(listener, cursor, cursor_button);
|
||||
struct kiwmi_server *server = cursor->server;
|
||||
struct kiwmi_input *input = &server->input;
|
||||
struct wlr_event_pointer_button *event = data;
|
||||
struct wlr_pointer_button_event *event = data;
|
||||
|
||||
struct kiwmi_cursor_button_event new_event = {
|
||||
.wlr_event = event,
|
||||
|
@ -176,10 +177,10 @@ cursor_axis_notify(struct wl_listener *listener, void *data)
|
|||
wl_container_of(listener, cursor, cursor_axis);
|
||||
struct kiwmi_server *server = cursor->server;
|
||||
struct kiwmi_input *input = &server->input;
|
||||
struct wlr_event_pointer_axis *event = data;
|
||||
struct wlr_pointer_axis_event *event = data;
|
||||
|
||||
struct kiwmi_cursor_scroll_event new_event = {
|
||||
.device_name = event->device->name,
|
||||
.device_name = event->pointer->base.name,
|
||||
.is_vertical = event->orientation == WLR_AXIS_ORIENTATION_VERTICAL,
|
||||
.length = event->delta,
|
||||
.handled = false,
|
||||
|
@ -290,11 +291,21 @@ cursor_refresh_focus(
|
|||
double sy;
|
||||
|
||||
struct wlr_scene_node *node_at = wlr_scene_node_at(
|
||||
&desktop->scene->node, cursor->cursor->x, cursor->cursor->y, &sx, &sy);
|
||||
&desktop->scene->tree.node,
|
||||
cursor->cursor->x,
|
||||
cursor->cursor->y,
|
||||
&sx,
|
||||
&sy);
|
||||
|
||||
if (node_at && node_at->type == WLR_SCENE_NODE_SURFACE) {
|
||||
if (node_at && node_at->type == WLR_SCENE_NODE_BUFFER) {
|
||||
struct wlr_scene_buffer *scene_buffer =
|
||||
wlr_scene_buffer_from_node(node_at);
|
||||
struct wlr_scene_surface *scene_surface =
|
||||
wlr_scene_surface_from_node(node_at);
|
||||
wlr_scene_surface_from_buffer(scene_buffer);
|
||||
|
||||
if (!scene_surface) {
|
||||
return;
|
||||
}
|
||||
surface = scene_surface->surface;
|
||||
|
||||
if (surface != seat->pointer_state.focused_surface) {
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "server.h"
|
||||
|
||||
static void
|
||||
new_pointer(struct kiwmi_input *input, struct wlr_input_device *device)
|
||||
new_pointer(struct kiwmi_input *input, struct wlr_pointer *device)
|
||||
{
|
||||
struct kiwmi_server *server = wl_container_of(input, server, input);
|
||||
|
||||
|
@ -37,7 +37,7 @@ new_pointer(struct kiwmi_input *input, struct wlr_input_device *device)
|
|||
}
|
||||
|
||||
static void
|
||||
new_keyboard(struct kiwmi_input *input, struct wlr_input_device *device)
|
||||
new_keyboard(struct kiwmi_input *input, struct wlr_keyboard *device)
|
||||
{
|
||||
struct kiwmi_server *server = wl_container_of(input, server, input);
|
||||
|
||||
|
@ -58,12 +58,16 @@ new_input_notify(struct wl_listener *listener, void *data)
|
|||
wlr_log(WLR_DEBUG, "New input %p: %s", device, device->name);
|
||||
|
||||
switch (device->type) {
|
||||
case WLR_INPUT_DEVICE_POINTER:
|
||||
new_pointer(input, device);
|
||||
case WLR_INPUT_DEVICE_POINTER: {
|
||||
struct wlr_pointer *pointer = wlr_pointer_from_input_device(device);
|
||||
new_pointer(input, pointer);
|
||||
break;
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||
new_keyboard(input, device);
|
||||
}
|
||||
case WLR_INPUT_DEVICE_KEYBOARD: {
|
||||
struct wlr_keyboard *keyboard = wlr_keyboard_from_input_device(device);
|
||||
new_keyboard(input, keyboard);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// NOT HANDLED
|
||||
break;
|
||||
|
|
|
@ -47,10 +47,10 @@ keyboard_modifiers_notify(struct wl_listener *listener, void *UNUSED(data))
|
|||
{
|
||||
struct kiwmi_keyboard *keyboard =
|
||||
wl_container_of(listener, keyboard, modifiers);
|
||||
wlr_seat_set_keyboard(keyboard->server->input.seat->seat, keyboard->device);
|
||||
wlr_seat_set_keyboard(
|
||||
keyboard->server->input.seat->seat, keyboard->wlr_keyboard);
|
||||
wlr_seat_keyboard_notify_modifiers(
|
||||
keyboard->server->input.seat->seat,
|
||||
&keyboard->device->keyboard->modifiers);
|
||||
keyboard->server->input.seat->seat, &keyboard->wlr_keyboard->modifiers);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -58,20 +58,20 @@ keyboard_key_notify(struct wl_listener *listener, void *data)
|
|||
{
|
||||
struct kiwmi_keyboard *keyboard = wl_container_of(listener, keyboard, key);
|
||||
struct kiwmi_server *server = keyboard->server;
|
||||
struct wlr_event_keyboard_key *event = data;
|
||||
struct wlr_input_device *device = keyboard->device;
|
||||
struct wlr_keyboard_key_event *event = data;
|
||||
struct wlr_keyboard *wlr_keyboard = keyboard->wlr_keyboard;
|
||||
|
||||
uint32_t keycode = event->keycode + 8;
|
||||
|
||||
const xkb_keysym_t *raw_syms;
|
||||
xkb_layout_index_t layout_index =
|
||||
xkb_state_key_get_layout(device->keyboard->xkb_state, keycode);
|
||||
xkb_state_key_get_layout(wlr_keyboard->xkb_state, keycode);
|
||||
int raw_syms_len = xkb_keymap_key_get_syms_by_level(
|
||||
device->keyboard->keymap, keycode, layout_index, 0, &raw_syms);
|
||||
wlr_keyboard->keymap, keycode, layout_index, 0, &raw_syms);
|
||||
|
||||
const xkb_keysym_t *translated_syms;
|
||||
int translated_syms_len = xkb_state_key_get_syms(
|
||||
keyboard->device->keyboard->xkb_state, keycode, &translated_syms);
|
||||
wlr_keyboard->xkb_state, keycode, &translated_syms);
|
||||
|
||||
bool handled = false;
|
||||
|
||||
|
@ -101,7 +101,7 @@ keyboard_key_notify(struct wl_listener *listener, void *data)
|
|||
}
|
||||
|
||||
if (!handled) {
|
||||
wlr_seat_set_keyboard(server->input.seat->seat, keyboard->device);
|
||||
wlr_seat_set_keyboard(server->input.seat->seat, wlr_keyboard);
|
||||
wlr_seat_keyboard_notify_key(
|
||||
server->input.seat->seat,
|
||||
event->time_msec,
|
||||
|
@ -120,7 +120,7 @@ keyboard_destroy_notify(struct wl_listener *listener, void *UNUSED(data))
|
|||
}
|
||||
|
||||
struct kiwmi_keyboard *
|
||||
keyboard_create(struct kiwmi_server *server, struct wlr_input_device *device)
|
||||
keyboard_create(struct kiwmi_server *server, struct wlr_keyboard *wlr_keyboard)
|
||||
{
|
||||
wlr_log(WLR_DEBUG, "Creating keyboard");
|
||||
|
||||
|
@ -129,28 +129,29 @@ keyboard_create(struct kiwmi_server *server, struct wlr_input_device *device)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
keyboard->server = server;
|
||||
keyboard->device = device;
|
||||
keyboard->server = server;
|
||||
keyboard->wlr_keyboard = wlr_keyboard;
|
||||
|
||||
keyboard->modifiers.notify = keyboard_modifiers_notify;
|
||||
wl_signal_add(&device->keyboard->events.modifiers, &keyboard->modifiers);
|
||||
wl_signal_add(&wlr_keyboard->events.modifiers, &keyboard->modifiers);
|
||||
|
||||
keyboard->key.notify = keyboard_key_notify;
|
||||
wl_signal_add(&device->keyboard->events.key, &keyboard->key);
|
||||
wl_signal_add(&wlr_keyboard->events.key, &keyboard->key);
|
||||
|
||||
keyboard->device_destroy.notify = keyboard_destroy_notify;
|
||||
wl_signal_add(&device->events.destroy, &keyboard->device_destroy);
|
||||
wl_signal_add(
|
||||
&wlr_keyboard->base.events.destroy, &keyboard->device_destroy);
|
||||
|
||||
struct xkb_rule_names rules = {0};
|
||||
struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
struct xkb_keymap *keymap =
|
||||
xkb_map_new_from_names(context, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||
wlr_keyboard_set_keymap(device->keyboard, keymap);
|
||||
wlr_keyboard_set_keymap(wlr_keyboard, keymap);
|
||||
xkb_keymap_unref(keymap);
|
||||
xkb_context_unref(context);
|
||||
wlr_keyboard_set_repeat_info(device->keyboard, 25, 600);
|
||||
wlr_keyboard_set_repeat_info(wlr_keyboard, 25, 600);
|
||||
|
||||
wlr_seat_set_keyboard(server->input.seat->seat, device);
|
||||
wlr_seat_set_keyboard(server->input.seat->seat, wlr_keyboard);
|
||||
|
||||
wl_signal_init(&keyboard->events.key_down);
|
||||
wl_signal_init(&keyboard->events.key_up);
|
||||
|
|
|
@ -29,26 +29,29 @@ pointer_destroy_notify(struct wl_listener *listener, void *UNUSED(data))
|
|||
}
|
||||
|
||||
struct kiwmi_pointer *
|
||||
pointer_create(struct kiwmi_server *server, struct wlr_input_device *device)
|
||||
pointer_create(struct kiwmi_server *server, struct wlr_pointer *device)
|
||||
{
|
||||
wlr_cursor_attach_input_device(server->input.cursor->cursor, device);
|
||||
wlr_cursor_attach_input_device(server->input.cursor->cursor, &device->base);
|
||||
|
||||
struct kiwmi_pointer *pointer = malloc(sizeof(*pointer));
|
||||
if (!pointer) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pointer->device = device;
|
||||
pointer->pointer = device;
|
||||
|
||||
pointer->device_destroy.notify = pointer_destroy_notify;
|
||||
wl_signal_add(&device->events.destroy, &pointer->device_destroy);
|
||||
wl_signal_add(&device->base.events.destroy, &pointer->device_destroy);
|
||||
|
||||
// FIXME: `wlr_input_device` doesn't contain `output_name`
|
||||
if (device->output_name) {
|
||||
struct kiwmi_output *output;
|
||||
wl_list_for_each (output, &server->desktop.outputs, link) {
|
||||
if (strcmp(device->output_name, output->wlr_output->name) == 0) {
|
||||
wlr_cursor_map_input_to_output(
|
||||
server->input.cursor->cursor, device, output->wlr_output);
|
||||
server->input.cursor->cursor,
|
||||
&device->base,
|
||||
output->wlr_output);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ l_kiwmi_keyboard_keymap(lua_State *L)
|
|||
struct xkb_keymap *keymap = xkb_keymap_new_from_names(
|
||||
context, &settings, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||
|
||||
wlr_keyboard_set_keymap(keyboard->device->keyboard, keymap);
|
||||
wlr_keyboard_set_keymap(keyboard->wlr_keyboard, keymap);
|
||||
|
||||
xkb_keymap_unref(keymap);
|
||||
xkb_context_unref(context);
|
||||
|
@ -83,7 +83,7 @@ l_kiwmi_keyboard_modifiers(lua_State *L)
|
|||
|
||||
struct kiwmi_keyboard *keyboard = obj->object;
|
||||
|
||||
uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->device->keyboard);
|
||||
uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->wlr_keyboard);
|
||||
|
||||
lua_newtable(L);
|
||||
|
||||
|
|
|
@ -89,11 +89,11 @@ l_kiwmi_output_pos(lua_State *L)
|
|||
struct kiwmi_output *output = obj->object;
|
||||
struct wlr_output_layout *output_layout = output->desktop->output_layout;
|
||||
|
||||
struct wlr_box *box =
|
||||
wlr_output_layout_get_box(output_layout, output->wlr_output);
|
||||
struct wlr_box box;
|
||||
wlr_output_layout_get_box(output_layout, output->wlr_output, &box);
|
||||
|
||||
lua_pushinteger(L, box->x);
|
||||
lua_pushinteger(L, box->y);
|
||||
lua_pushinteger(L, box.x);
|
||||
lua_pushinteger(L, box.y);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue