wip: Update for wlroots-git (0.16.0)

This commit is contained in:
John Lindgren 2022-05-21 11:18:33 -04:00
parent ae15be8555
commit a893d7854d
11 changed files with 80 additions and 76 deletions

View file

@ -33,6 +33,7 @@
#include <wlr/types/wlr_pointer_gestures_v1.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_server_decoration.h>
#include <wlr/types/wlr_subcompositor.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/types/wlr_xdg_decoration_v1.h>
#include <wlr/types/wlr_xdg_shell.h>

View file

@ -2,7 +2,6 @@
#ifndef __LABWC_LAYERS_H
#define __LABWC_LAYERS_H
#include <wayland-server.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_layer_shell_v1.h>
struct server;

View file

@ -40,7 +40,7 @@ add_project_arguments('-DLABWC_VERSION=@0@'.format(version), language: 'c')
wlroots = dependency(
'wlroots',
default_options: ['default_library=static', 'examples=false'],
version: ['>=0.15.0', '<0.16.0'],
version: ['>=0.15.0'],
)
wlroots_has_xwayland = wlroots.get_variable('have_xwayland') == 'true'

View file

@ -451,7 +451,7 @@ cursor_motion(struct wl_listener *listener, void *data)
*/
struct seat *seat = wl_container_of(listener, seat, cursor_motion);
struct server *server = seat->server;
struct wlr_event_pointer_motion *event = data;
struct wlr_pointer_motion_event *event = data;
wlr_idle_notify_activity(seat->wlr_idle, seat->seat);
wlr_relative_pointer_manager_v1_send_relative_motion(
@ -468,8 +468,8 @@ cursor_motion(struct wl_listener *listener, void *data)
* NULL for the device if you want to move the cursor around
* without any input.
*/
wlr_cursor_move(seat->cursor, event->device, event->delta_x,
event->delta_y);
wlr_cursor_move(seat->cursor, &event->pointer->base,
event->delta_x, event->delta_y);
}
process_cursor_motion(seat->server, event->time_msec);
}
@ -499,12 +499,12 @@ cursor_motion_absolute(struct wl_listener *listener, void *data)
*/
struct seat *seat = wl_container_of(
listener, seat, cursor_motion_absolute);
struct wlr_event_pointer_motion_absolute *event = data;
struct wlr_pointer_motion_absolute_event *event = data;
wlr_idle_notify_activity(seat->wlr_idle, seat->seat);
double lx, ly;
wlr_cursor_absolute_to_layout_coords(seat->cursor, event->device,
event->x, event->y, &lx, &ly);
wlr_cursor_absolute_to_layout_coords(seat->cursor,
&event->pointer->base, event->x, event->y, &lx, &ly);
double dx = lx - seat->cursor->x;
double dy = ly - seat->cursor->y;
@ -523,7 +523,8 @@ cursor_motion_absolute(struct wl_listener *listener, void *data)
* NULL for the device if you want to move the cursor around
* without any input.
*/
wlr_cursor_move(seat->cursor, event->device, dx, dy); }
wlr_cursor_move(seat->cursor, &event->pointer->base, dx, dy);
}
process_cursor_motion(seat->server, event->time_msec);
}
@ -648,7 +649,7 @@ cursor_button(struct wl_listener *listener, void *data)
*/
struct seat *seat = wl_container_of(listener, seat, cursor_button);
struct server *server = seat->server;
struct wlr_event_pointer_button *event = data;
struct wlr_pointer_button_event *event = data;
wlr_idle_notify_activity(seat->wlr_idle, seat->seat);
double sx, sy;
@ -664,8 +665,8 @@ cursor_button(struct wl_listener *listener, void *data)
&sx, &sy, &view_area);
/* get modifiers */
struct wlr_input_device *device = seat->keyboard_group->input_device;
uint32_t modifiers = wlr_keyboard_get_modifiers(device->keyboard);
struct wlr_keyboard *keyboard = &seat->keyboard_group->keyboard;
uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard);
/* handle _release_ */
if (event->state == WLR_BUTTON_RELEASED) {
@ -784,7 +785,7 @@ cursor_axis(struct wl_listener *listener, void *data)
* event, for example when you move the scroll wheel.
*/
struct seat *seat = wl_container_of(listener, seat, cursor_axis);
struct wlr_event_pointer_axis *event = data;
struct wlr_pointer_axis_event *event = data;
wlr_idle_notify_activity(seat->wlr_idle, seat->seat);
/* Notify the client with pointer focus of the axis event. */
@ -811,7 +812,7 @@ cursor_frame(struct wl_listener *listener, void *data)
static void handle_pointer_pinch_begin(struct wl_listener *listener, void *data)
{
struct seat *seat = wl_container_of(listener, seat, pinch_begin);
struct wlr_event_pointer_pinch_begin *event = data;
struct wlr_pointer_pinch_begin_event *event = data;
wlr_pointer_gestures_v1_send_pinch_begin(seat->pointer_gestures,
seat->seat, event->time_msec, event->fingers);
}
@ -819,7 +820,7 @@ static void handle_pointer_pinch_begin(struct wl_listener *listener, void *data)
static void handle_pointer_pinch_update(struct wl_listener *listener, void *data)
{
struct seat *seat = wl_container_of(listener, seat, pinch_update);
struct wlr_event_pointer_pinch_update *event = data;
struct wlr_pointer_pinch_update_event *event = data;
wlr_pointer_gestures_v1_send_pinch_update(seat->pointer_gestures,
seat->seat, event->time_msec, event->dx, event->dy,
event->scale, event->rotation);
@ -828,7 +829,7 @@ static void handle_pointer_pinch_update(struct wl_listener *listener, void *data
static void handle_pointer_pinch_end(struct wl_listener *listener, void *data)
{
struct seat *seat = wl_container_of(listener, seat, pinch_end);
struct wlr_event_pointer_pinch_end *event = data;
struct wlr_pointer_pinch_end_event *event = data;
wlr_pointer_gestures_v1_send_pinch_end(seat->pointer_gestures,
seat->seat, event->time_msec, event->cancelled);
}
@ -836,7 +837,7 @@ static void handle_pointer_pinch_end(struct wl_listener *listener, void *data)
static void handle_pointer_swipe_begin(struct wl_listener *listener, void *data)
{
struct seat *seat = wl_container_of(listener, seat, swipe_begin);
struct wlr_event_pointer_swipe_begin *event = data;
struct wlr_pointer_swipe_begin_event *event = data;
wlr_pointer_gestures_v1_send_swipe_begin(seat->pointer_gestures,
seat->seat, event->time_msec, event->fingers);
}
@ -844,7 +845,7 @@ static void handle_pointer_swipe_begin(struct wl_listener *listener, void *data)
static void handle_pointer_swipe_update(struct wl_listener *listener, void *data)
{
struct seat *seat = wl_container_of(listener, seat, swipe_update);
struct wlr_event_pointer_swipe_update *event = data;
struct wlr_pointer_swipe_update_event *event = data;
wlr_pointer_gestures_v1_send_swipe_update(seat->pointer_gestures,
seat->seat, event->time_msec, event->dx, event->dy);
}
@ -852,7 +853,7 @@ static void handle_pointer_swipe_update(struct wl_listener *listener, void *data
static void handle_pointer_swipe_end(struct wl_listener *listener, void *data)
{
struct seat *seat = wl_container_of(listener, seat, swipe_end);
struct wlr_event_pointer_swipe_end *event = data;
struct wlr_pointer_swipe_end_event *event = data;
wlr_pointer_gestures_v1_send_swipe_end(seat->pointer_gestures,
seat->seat, event->time_msec, event->cancelled);
}

View file

@ -39,11 +39,11 @@ keyboard_modifiers_notify(struct wl_listener *listener, void *data)
struct server *server = seat->server;
if (server->cycle_view) {
struct wlr_event_keyboard_key *event = data;
struct wlr_input_device *device = seat->keyboard_group->input_device;
struct wlr_keyboard_key_event *event = data;
struct wlr_keyboard *keyboard = &seat->keyboard_group->keyboard;
damage_all_outputs(server);
if ((event->state == WL_KEYBOARD_KEY_STATE_RELEASED)
&& !any_modifiers_pressed(device->keyboard)) {
&& !any_modifiers_pressed(keyboard)) {
/* end cycle */
desktop_focus_and_activate_view(&server->seat,
server->cycle_view);
@ -90,17 +90,17 @@ static bool is_modifier_key(xkb_keysym_t sym)
static bool
handle_compositor_keybindings(struct wl_listener *listener,
struct wlr_event_keyboard_key *event)
struct wlr_keyboard_key_event *event)
{
struct seat *seat = wl_container_of(listener, seat, keyboard_key);
struct server *server = seat->server;
struct wlr_input_device *device = seat->keyboard_group->input_device;
struct wlr_keyboard *keyboard = &seat->keyboard_group->keyboard;
/* Translate libinput keycode -> xkbcommon */
uint32_t keycode = event->keycode + 8;
/* Get a list of keysyms based on the keymap for this keyboard */
const xkb_keysym_t *syms;
int nsyms = xkb_state_key_get_syms(device->keyboard->xkb_state, keycode, &syms);
int nsyms = xkb_state_key_get_syms(keyboard->xkb_state, keycode, &syms);
bool handled = false;
@ -115,14 +115,13 @@ handle_compositor_keybindings(struct wl_listener *listener,
&& event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
int nr_bound_keys = key_state_bound_key_remove(keycode);
if (!nr_bound_keys) {
wlr_keyboard_set_repeat_info(device->keyboard,
wlr_keyboard_set_repeat_info(keyboard,
rc.repeat_rate, rc.repeat_delay);
}
return true;
}
uint32_t modifiers =
wlr_keyboard_get_modifiers(device->keyboard);
uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard);
/* Catch C-A-F1 to C-A-F12 to change tty */
if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
@ -186,9 +185,9 @@ keyboard_key_notify(struct wl_listener *listener, void *data)
/* This event is raised when a key is pressed or released. */
struct seat *seat = wl_container_of(listener, seat, keyboard_key);
struct server *server = seat->server;
struct wlr_event_keyboard_key *event = data;
struct wlr_keyboard_key_event *event = data;
struct wlr_seat *wlr_seat = server->seat.seat;
struct wlr_input_device *device = seat->keyboard_group->input_device;
struct wlr_keyboard *keyboard = &seat->keyboard_group->keyboard;
wlr_idle_notify_activity(seat->wlr_idle, seat->seat);
bool handled = false;
@ -199,7 +198,7 @@ keyboard_key_notify(struct wl_listener *listener, void *data)
}
if (!handled) {
wlr_seat_set_keyboard(wlr_seat, device);
wlr_seat_set_keyboard(wlr_seat, keyboard);
wlr_seat_keyboard_notify_key(wlr_seat, event->time_msec,
event->keycode, event->state);
}

View file

@ -1199,15 +1199,11 @@ wlr_output_configuration_v1 *create_output_config(struct server *server)
wlr_output_configuration_v1_destroy(config);
return NULL;
}
struct wlr_box *box =
wlr_output_layout_get_box(server->output_layout,
output->wlr_output);
if (box) {
head->state.x = box->x;
head->state.y = box->y;
} else {
wlr_log(WLR_ERROR, "failed to get output layout box");
}
struct wlr_box box = {0};
wlr_output_layout_get_box(server->output_layout,
output->wlr_output, &box);
head->state.x = box.x;
head->state.y = box.y;
}
return config;
}

View file

@ -1,7 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-only
#include <assert.h>
#include <stdbool.h>
#include <strings.h>
#include <wlr/backend/libinput.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/util/log.h>
#include "labwc.h"
@ -14,6 +16,18 @@ input_device_destroy(struct wl_listener *listener, void *data)
free(input);
}
static bool
is_touch_device(struct wlr_input_device *wlr_input_device)
{
switch (wlr_input_device->type) {
case WLR_INPUT_DEVICE_TOUCH:
case WLR_INPUT_DEVICE_TABLET_TOOL:
return true;
default:
return false;
}
}
static void
configure_libinput(struct wlr_input_device *wlr_input_device)
{
@ -29,16 +43,14 @@ configure_libinput(struct wlr_input_device *wlr_input_device)
}
enum device_type current_type;
if (wlr_input_device->width_mm) {
current_type = TOUCH_DEVICE;
} else {
current_type = NON_TOUCH_DEVICE;
}
current_type = is_touch_device(wlr_input_device)
? TOUCH_DEVICE : NON_TOUCH_DEVICE;
struct libinput_category *device_category, *dc = NULL;
wl_list_for_each(device_category, &rc.libinput_categories, link) {
if (device_category->name) {
if (!strcasecmp(wlr_input_device->name, device_category->name)) {
if (!strcasecmp(wlr_input_device->name,
device_category->name)) {
dc = device_category;
break;
}
@ -134,10 +146,13 @@ new_pointer(struct seat *seat, struct input *input)
wlr_cursor_attach_input_device(seat->cursor, dev);
/* In support of running with WLR_WL_OUTPUTS set to >=2 */
if (dev->output_name) {
wlr_log(WLR_INFO, "map pointer to output %s\n", dev->output_name);
struct wlr_output *output =
output_by_name(seat->server, dev->output_name);
if (dev->type == WLR_INPUT_DEVICE_POINTER) {
wlr_log(WLR_INFO, "map pointer to output %s\n",
dev->pointer->output_name);
struct wlr_output *output = NULL;
if (dev->pointer->output_name != NULL) {
output = output_by_name(seat->server, dev->pointer->output_name);
}
wlr_cursor_map_input_to_output(seat->cursor, dev, output);
wlr_cursor_map_input_to_region(seat->cursor, dev, NULL);
}
@ -149,7 +164,7 @@ new_keyboard(struct seat *seat, struct input *input)
struct wlr_keyboard *kb = input->wlr_input_device->keyboard;
wlr_keyboard_set_keymap(kb, seat->keyboard_group->keyboard.keymap);
wlr_keyboard_group_add_keyboard(seat->keyboard_group, kb);
wlr_seat_set_keyboard(seat->seat, input->wlr_input_device);
wlr_seat_set_keyboard(seat->seat, kb);
}
static void

View file

@ -253,7 +253,7 @@ server_init(struct server *server)
seat_init(server);
/* Init xdg-shell */
server->xdg_shell = wlr_xdg_shell_create(server->wl_display);
server->xdg_shell = wlr_xdg_shell_create(server->wl_display, 2);
if (!server->xdg_shell) {
wlr_log(WLR_ERROR, "unable to create the XDG shell interface");
exit(EXIT_FAILURE);

View file

@ -67,7 +67,7 @@ view_adjust_size(struct view *view, int *w, int *h)
int min_height = MIN_VIEW_HEIGHT;
#if HAVE_XWAYLAND
if (view->type == LAB_XWAYLAND_VIEW) {
struct wlr_xwayland_surface_size_hints *hints =
xcb_size_hints_t *hints =
view->xwayland_surface->size_hints;
if (hints) {
*w = round_to_increment(*w, hints->base_width,

View file

@ -63,14 +63,14 @@ popup_unconstrain(struct xdg_popup *popup)
struct wlr_output_layout *output_layout = server->output_layout;
struct wlr_output *wlr_output = wlr_output_layout_output_at(
output_layout, view->x + popup_box->x, view->y + popup_box->y);
struct wlr_box *output_box = wlr_output_layout_get_box(
output_layout, wlr_output);
struct wlr_box output_box = {0};
wlr_output_layout_get_box(output_layout, wlr_output, &output_box);
struct wlr_box output_toplevel_box = {
.x = output_box->x - view->x,
.y = output_box->y - view->y,
.width = output_box->width,
.height = output_box->height,
.x = output_box.x - view->x,
.y = output_box.y - view->y,
.width = output_box.width,
.height = output_box.height,
};
wlr_xdg_popup_unconstrain_from_box(
popup->wlr_popup, &output_toplevel_box);

View file

@ -142,29 +142,22 @@ static void
handle_request_minimize(struct wl_listener *listener, void *data)
{
struct view *view = wl_container_of(listener, view, request_minimize);
struct wlr_xdg_surface *surface = data;
if (view) {
view_minimize(view, surface->toplevel->requested.minimized);
}
view_minimize(view, view->xdg_surface->toplevel->requested.minimized);
}
static void
handle_request_maximize(struct wl_listener *listener, void *data)
{
struct view *view = wl_container_of(listener, view, request_maximize);
struct wlr_xdg_surface *surface = data;
if (view) {
view_maximize(view, surface->toplevel->requested.maximized);
}
view_maximize(view, view->xdg_surface->toplevel->requested.maximized);
}
static void
handle_request_fullscreen(struct wl_listener *listener, void *data)
{
struct view *view = wl_container_of(listener, view, request_fullscreen);
struct wlr_xdg_toplevel_set_fullscreen_event *e = data;
view_set_fullscreen(view, e->fullscreen, e->output);
view_set_fullscreen(view, view->xdg_surface->toplevel->requested.fullscreen,
view->xdg_surface->toplevel->requested.fullscreen_output);
}
static void
@ -195,7 +188,7 @@ xdg_toplevel_view_configure(struct view *view, struct wlr_box geo)
view->pending_move_resize.width = geo.width;
view->pending_move_resize.height = geo.height;
uint32_t serial = wlr_xdg_toplevel_set_size(view->xdg_surface,
uint32_t serial = wlr_xdg_toplevel_set_size(view->xdg_surface->toplevel,
(uint32_t)geo.width, (uint32_t)geo.height);
if (serial > 0) {
view->pending_move_resize.configure_serial = serial;
@ -219,7 +212,7 @@ xdg_toplevel_view_move(struct view *view, double x, double y)
static void
xdg_toplevel_view_close(struct view *view)
{
wlr_xdg_toplevel_send_close(view->xdg_surface);
wlr_xdg_toplevel_send_close(view->xdg_surface->toplevel);
}
static void
@ -248,7 +241,7 @@ update_padding(struct view *view)
static void
xdg_toplevel_view_maximize(struct view *view, bool maximized)
{
wlr_xdg_toplevel_set_maximized(view->xdg_surface, maximized);
wlr_xdg_toplevel_set_maximized(view->xdg_surface->toplevel, maximized);
}
static void
@ -256,14 +249,14 @@ xdg_toplevel_view_set_activated(struct view *view, bool activated)
{
struct wlr_xdg_surface *surface = view->xdg_surface;
if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
wlr_xdg_toplevel_set_activated(surface, activated);
wlr_xdg_toplevel_set_activated(surface->toplevel, activated);
}
}
static void
xdg_toplevel_view_set_fullscreen(struct view *view, bool fullscreen)
{
wlr_xdg_toplevel_set_fullscreen(view->xdg_surface, fullscreen);
wlr_xdg_toplevel_set_fullscreen(view->xdg_surface->toplevel, fullscreen);
}
static bool
@ -277,7 +270,7 @@ parent_of(struct view *view)
{
struct view *p;
wl_list_for_each (p, &view->server->views, link) {
if (p->xdg_surface == view->xdg_surface->toplevel->parent) {
if (p->xdg_surface->toplevel == view->xdg_surface->toplevel->parent) {
return p;
}
}