Make compatible with wlroots 0.16

This commit is contained in:
project-repo 2023-01-05 18:42:23 +01:00
commit 4e1c085568
14 changed files with 177 additions and 244 deletions

View file

@ -39,6 +39,7 @@
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_screencopy_v1.h>
#include <wlr/types/wlr_server_decoration.h>
#include <wlr/types/wlr_subcompositor.h>
#include <wlr/types/wlr_viewporter.h>
#include <wlr/types/wlr_xdg_decoration_v1.h>
#include <wlr/types/wlr_xdg_output_v1.h>
@ -260,6 +261,7 @@ main(int argc, char *argv[]) {
struct wl_event_source *sigpipe_source = NULL;
struct wlr_backend *backend = NULL;
struct wlr_compositor *compositor = NULL;
struct wlr_subcompositor *subcompositor = NULL;
struct wlr_data_device_manager *data_device_manager = NULL;
struct wlr_server_decoration_manager *server_decoration_manager = NULL;
struct wlr_xdg_decoration_manager_v1 *xdg_decoration_manager = NULL;
@ -429,6 +431,13 @@ main(int argc, char *argv[]) {
goto end;
}
subcompositor = wlr_subcompositor_create(server.wl_display);
if (!subcompositor) {
wlr_log(WLR_ERROR, "Unable to create the wlroots subcompositor");
ret = 1;
goto end;
}
data_device_manager = wlr_data_device_manager_create(server.wl_display);
if(!data_device_manager) {
wlr_log(WLR_ERROR, "Unable to create the data device manager");
@ -477,7 +486,7 @@ main(int argc, char *argv[]) {
&server.new_idle_inhibitor_v1);
wl_list_init(&server.inhibitors);
xdg_shell = wlr_xdg_shell_create(server.wl_display);
xdg_shell = wlr_xdg_shell_create(server.wl_display,3);
if(!xdg_shell) {
wlr_log(WLR_ERROR, "Unable to create the XDG shell interface");
ret = 1;

View file

@ -335,7 +335,7 @@ LLVMFuzzerInitialize(int *argc, char ***argv) {
&server.new_idle_inhibitor_v1);
wl_list_init(&server.inhibitors);
xdg_shell = wlr_xdg_shell_create(server.wl_display);
xdg_shell = wlr_xdg_shell_create(server.wl_display,3);
if(!xdg_shell) {
wlr_log(WLR_ERROR, "Unable to create the XDG shell interface");
ret = 1;
@ -490,27 +490,6 @@ end:
return ret;
}
void
move_cursor(char *line, struct cg_server *server) {
return; // TODO
long del = 0;
char *delstr = strtok_r(NULL, ";", &line);
enum wlr_axis_orientation orientation =
(*(line++) == '0') ? WLR_AXIS_ORIENTATION_VERTICAL
: WLR_AXIS_ORIENTATION_HORIZONTAL;
if(delstr == NULL) {
return;
}
del = strtol(delstr, NULL, 10);
struct wlr_event_pointer_axis event = {.device = NULL,
.time_msec = 0,
.source = WLR_AXIS_SOURCE_WHEEL,
.orientation = orientation,
.delta = del * 15,
.delta_discrete = del};
// TODO dispatch_cursor_axis(server->seat->cursor, &event);
}
void
add_output_callback(struct wlr_backend *backend, void *data) {
long *dims = data;
@ -542,73 +521,6 @@ create_output(char *line, struct cg_server *server) {
wlr_multi_for_each_backend(server->backend, add_output_callback, dims);
}
void
add_input_device_callback(struct wlr_backend *backend, void *data) {
enum wlr_input_device_type *type = data;
wlr_headless_add_input_device(backend, *type);
}
void
create_input_device(char *line, struct cg_server *server) {
enum wlr_input_device_type type;
if(*line != '\0') {
if(strncmp(line, "kbd", 3) == 0) {
type = WLR_INPUT_DEVICE_KEYBOARD;
wlr_multi_for_each_backend(server->backend,
add_input_device_callback, &type);
} else if(strncmp(line, "ptr", 3) == 0) {
type = WLR_INPUT_DEVICE_POINTER;
wlr_multi_for_each_backend(server->backend,
add_input_device_callback, &type);
} else if(strncmp(line, "tch", 3) == 0) {
type = WLR_INPUT_DEVICE_TOUCH;
wlr_multi_for_each_backend(server->backend,
add_input_device_callback, &type);
}
}
}
void
destroy_input_device(char *line, struct cg_server *server) {
long devn = 0;
if(line[0] != '\0') {
devn = strtol(line + 1, NULL, 10);
}
if(line != NULL) {
if(strncmp(line, "k", 1) == 0) {
if(wl_list_empty(&server->seat->keyboard_groups)) {
return;
}
devn = devn % wl_list_length(&server->seat->keyboard_groups);
struct cg_keyboard_group *group, *group_tmp;
wl_list_for_each_safe(group, group_tmp,
&server->seat->keyboard_groups, link) {
if(devn == 0) {
wl_list_remove(&group->link);
wlr_keyboard_group_destroy(group->wlr_group);
wl_event_source_remove(group->key_repeat_timer);
free(group);
break;
}
--devn;
}
} else if(strncmp(line, "p", 1) == 0) {
if(wl_list_empty(&server->input->devices)) {
return;
}
devn = devn % wl_list_length(&server->input->devices);
struct cg_input_device *dev, *dev_tmp;
wl_list_for_each_safe(dev, dev_tmp, &server->input->devices, link) {
if(devn == 0) {
dev->device_destroy.notify(&dev->device_destroy, NULL);
break;
}
--devn;
}
}
}
}
void
destroy_output(char *line, struct cg_server *server) {
if(wl_list_length(&server->outputs) < 2) {

View file

@ -341,7 +341,7 @@ handle_virtual_keyboard(struct wl_listener *listener, void *data) {
struct cg_input_manager *input =
wl_container_of(listener, input, virtual_keyboard_new);
struct wlr_virtual_keyboard_v1 *keyboard = data;
struct wlr_input_device *device = &keyboard->input_device;
struct wlr_input_device *device = &keyboard->keyboard.base;
new_input(input,device,true);
}
@ -352,7 +352,7 @@ handle_virtual_pointer(struct wl_listener *listener, void *data) {
wl_container_of(listener, input_manager, virtual_pointer_new);
struct wlr_virtual_pointer_v1_new_pointer_event *event = data;
struct wlr_virtual_pointer_v1 *pointer = event->new_pointer;
struct wlr_input_device *device = &pointer->input_device;
struct wlr_input_device *device = &pointer->pointer.base;
new_input(input_manager,device,true);

View file

@ -446,17 +446,17 @@ resize_vertical(struct cg_tile *tile, struct cg_tile *parent, int y_offset,
void
resize_tile(struct cg_server *server, int hpixs, int vpixs) {
struct cg_output *output = server->curr_output;
struct wlr_box *output_box = wlr_output_layout_get_box(
output->server->output_layout, output->wlr_output);
struct wlr_box output_box;
wlr_output_layout_get_box(output->server->output_layout, output->wlr_output,&output_box);
struct cg_tile *focused =
output->workspaces[output->curr_workspace]->focused_tile;
/* First do the horizontal adjustment */
if(hpixs != 0 && focused->tile.width < output_box->width &&
is_between_strict(0, output_box->width, focused->tile.width + hpixs)) {
if(hpixs != 0 && focused->tile.width < output_box.width &&
is_between_strict(0, output_box.width, focused->tile.width + hpixs)) {
int x_offset = 0;
/* In case we are on the total right, move the left edge of the tile */
if(focused->tile.x + focused->tile.width == output_box->width) {
if(focused->tile.x + focused->tile.width == output_box.width) {
x_offset = -hpixs;
}
bool resize_allowed =
@ -466,10 +466,10 @@ resize_tile(struct cg_server *server, int hpixs, int vpixs) {
}
}
/* Repeat for vertical */
if(vpixs != 0 && focused->tile.height < output_box->height &&
is_between_strict(0, output_box->height, focused->tile.height + vpixs)) {
if(vpixs != 0 && focused->tile.height < output_box.height &&
is_between_strict(0, output_box.height, focused->tile.height + vpixs)) {
int y_offset = 0;
if(focused->tile.y + focused->tile.height == output_box->height) {
if(focused->tile.y + focused->tile.height == output_box.height) {
y_offset = -vpixs;
}
bool resize_allowed =
@ -986,13 +986,12 @@ print_output(struct cg_output *outp) {
outp_str.len = 0;
outp_str.cur_pos = 0;
uint32_t nmemb = 8;
struct wlr_box *outp_box=wlr_output_layout_get_box(outp->server->output_layout,outp->wlr_output);
struct wlr_box outp_box;
wlr_output_layout_get_box(outp->server->output_layout,outp->wlr_output,&outp_box);
outp_str.str_arr = calloc(nmemb, sizeof(char *));
print_str(&outp_str, "\"%s\": {\n", outp->wlr_output->name);
print_str(&outp_str, "\"priority\": %d,\n", outp->priority);
if(outp_box!=NULL) {
print_str(&outp_str, "\"coords\": {\"x\":%d,\"y\":%d},\n", outp_box->x,outp_box->y);
}
print_str(&outp_str, "\"coords\": {\"x\":%d,\"y\":%d},\n", outp_box.x,outp_box.y);
print_str(&outp_str, "\"size\": {\"width\":%d,\"height\":%d},\n", outp->wlr_output->width,outp->wlr_output->height);
print_str(&outp_str, "\"refresh_rate\": %f,\n", (float) outp->wlr_output->refresh/1000.0);
print_str(&outp_str, "\"curr_workspace\": %d,\n", outp->curr_workspace);
@ -1219,7 +1218,7 @@ keybinding_move_view_to_cycle_output(struct cg_server *server, bool reverse) {
server->curr_output
->workspaces[server->curr_output->curr_workspace];
wl_list_insert(&ws->views, &view->link);
wlr_scene_node_reparent(view->scene_node, &ws->scene->node);
wlr_scene_node_reparent(&view->scene_tree->node, ws->scene);
workspace_tile_update_view(ws->focused_tile,view);
view->workspace = ws;
seat_set_focus(server->seat, view);
@ -1384,7 +1383,7 @@ keybinding_move_view_to_output(struct cg_server *server, int output_num) {
->workspaces[server->curr_output->curr_workspace];
view->workspace = ws;
wl_list_insert(&ws->views, &view->link);
wlr_scene_node_reparent(view->scene_node, &ws->scene->node);
wlr_scene_node_reparent(&view->scene_tree->node, ws->scene);
workspace_tile_update_view(ws->focused_tile,view);
seat_set_focus(server->seat, view);
}
@ -1423,7 +1422,7 @@ keybinding_move_view_to_workspace(struct cg_server *server, uint32_t ws) {
->workspaces[server->curr_output->curr_workspace];
view->workspace = ws;
wl_list_insert(&ws->views, &view->link);
wlr_scene_node_reparent(view->scene_node, &ws->scene->node);
wlr_scene_node_reparent(&view->scene_tree->node, ws->scene);
workspace_tile_update_view(ws->focused_tile,view);
seat_set_focus(server->seat, view);
}

View file

@ -52,7 +52,7 @@ if is_freebsd
)
endif
wlroots = dependency('wlroots', version: ['>=0.14.1', '< 0.16.0'])
wlroots = dependency('wlroots', version: ['>=0.16.1', '< 0.17.0'])
wayland_protos = dependency('wayland-protocols', version: '>=1.14')
wayland_server = dependency('wayland-server')
wayland_cursor = dependency('wayland-cursor')

View file

@ -11,6 +11,7 @@
#include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/interfaces/wlr_buffer.h>
#include <wlr/util/log.h>
#include "message.h"
@ -229,15 +230,15 @@ message_set_output(struct cg_output *output, const char *string,
return;
}
message->message =
wlr_scene_buffer_create(&scene_output->scene->node, &buf->base);
wlr_scene_buffer_create(&scene_output->scene->tree, &buf->base);
wlr_scene_node_raise_to_top(&message->message->node);
wlr_scene_node_set_enabled(&message->message->node, true);
struct wlr_box *outp_box = wlr_output_layout_get_box(
output->server->output_layout, output->wlr_output);
struct wlr_box outp_box;
wlr_output_layout_get_box(output->server->output_layout, output->wlr_output,&outp_box);
wlr_scene_buffer_set_dest_size(message->message, width, height);
wlr_scene_node_set_position(&message->message->node,
message->position->x + outp_box->x,
message->position->y + outp_box->y);
message->position->x + outp_box.x,
message->position->y + outp_box.y);
}
void
@ -257,10 +258,10 @@ message_printf(struct cg_output *output, const char *fmt, ...) {
free(buffer);
return;
}
struct wlr_box *output_box = wlr_output_layout_get_box(
output->server->output_layout, output->wlr_output);
struct wlr_box output_box;
wlr_output_layout_get_box(output->server->output_layout, output->wlr_output,&output_box);
box->x = output_box->width;
box->x = output_box.width;
box->y = 0;
box->width = 0;
box->height = 0;

View file

@ -26,7 +26,7 @@
#include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/util/log.h>
#include <wlr/util/region.h>
@ -81,7 +81,7 @@ output_clear(struct cg_output *output) {
view->impl->destroy(view);
} else {
wl_list_insert(&ws->views, &view->link);
wlr_scene_node_reparent(view->scene_node, &ws->scene->node);
wlr_scene_node_reparent(&view->scene_tree->node, ws->scene);
view->workspace = ws;
view->tile = ws->focused_tile;
if(server->seat->focused_view == NULL) {
@ -96,7 +96,7 @@ output_clear(struct cg_output *output) {
view->impl->destroy(view);
} else {
wl_list_insert(&ws->unmanaged_views, &view->link);
wlr_scene_node_reparent(view->scene_node, &ws->scene->node);
wlr_scene_node_reparent(&view->scene_tree->node, ws->scene);
view->workspace = ws;
view->tile = ws->focused_tile;
}
@ -314,11 +314,11 @@ output_apply_config(struct cg_server *server, struct cg_output *output, struct c
return;
}
output->bg = wlr_scene_rect_create(
&scene_output->scene->node, output->wlr_output->width,
&scene_output->scene->tree, output->wlr_output->width,
output->wlr_output->height, server->bg_color);
struct wlr_box *box =
wlr_output_layout_get_box(server->output_layout, output->wlr_output);
wlr_scene_node_set_position(&output->bg->node, box->x, box->y);
struct wlr_box box;
wlr_output_layout_get_box(server->output_layout, output->wlr_output,&box);
wlr_scene_node_set_position(&output->bg->node, box.x, box.y);
wlr_scene_node_lower_to_bottom(&output->bg->node);
}

121
seat.c
View file

@ -24,7 +24,7 @@
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_seat.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_touch.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/util/log.h>
@ -84,6 +84,7 @@ remove_touch(struct cg_seat *seat, struct cg_touch *touch) {
static void
new_touch(struct cg_seat *seat, struct cg_input_device *input_device) {
struct wlr_input_device *device = input_device->wlr_device;
struct wlr_touch *wlr_touch = wlr_touch_from_input_device(device);
struct cg_touch *touch = calloc(1, sizeof(struct cg_touch));
if(!touch) {
wlr_log(WLR_ERROR, "Cannot allocate touch");
@ -96,10 +97,10 @@ new_touch(struct cg_seat *seat, struct cg_input_device *input_device) {
input_device->touch = touch;
++seat->num_touch;
if(device->output_name != NULL) {
if(wlr_touch->output_name != NULL) {
struct cg_output *output;
wl_list_for_each(output, &seat->server->outputs, link) {
if(strcmp(device->output_name, output->wlr_output->name) == 0) {
if(strcmp(wlr_touch->output_name, output->wlr_output->name) == 0) {
wlr_cursor_map_input_to_output(seat->cursor, device,
output->wlr_output);
break;
@ -121,6 +122,7 @@ remove_pointer(struct cg_seat *seat, struct cg_pointer *pointer) {
static void
new_pointer(struct cg_seat *seat, struct cg_input_device *input_device) {
struct wlr_input_device *device = input_device->wlr_device;
struct wlr_pointer *wlr_pointer = wlr_pointer_from_input_device(device);
struct cg_pointer *pointer = calloc(1, sizeof(struct cg_pointer));
if(!pointer) {
wlr_log(WLR_ERROR, "Cannot allocate pointer");
@ -133,10 +135,10 @@ new_pointer(struct cg_seat *seat, struct cg_input_device *input_device) {
input_device->pointer = pointer;
++seat->num_pointers;
if(device->output_name != NULL) {
if(wlr_pointer->output_name != NULL) {
struct cg_output *output;
wl_list_for_each(output, &seat->server->outputs, link) {
if(strcmp(device->output_name, output->wlr_output->name) == 0) {
if(strcmp(wlr_pointer->output_name, output->wlr_output->name) == 0) {
wlr_cursor_map_input_to_output(seat->cursor, device,
output->wlr_output);
break;
@ -149,7 +151,7 @@ static int
handle_keyboard_repeat(void *data) {
struct cg_keyboard_group *cg_group = data;
struct wlr_keyboard *wlr_device =
cg_group->wlr_group->input_device->keyboard;
&cg_group->wlr_group->keyboard;
if(cg_group->repeat_keybinding != NULL) {
if(wlr_device->repeat_info.rate > 0) {
if(wl_event_source_timer_update(
@ -168,9 +170,10 @@ handle_keyboard_repeat(void *data) {
static void
handle_modifier_event(struct wlr_input_device *device, struct cg_seat *seat) {
wlr_seat_set_keyboard(seat->seat, device);
struct wlr_keyboard *keyboard=wlr_keyboard_from_input_device(device);
wlr_seat_set_keyboard(seat->seat, keyboard);
wlr_seat_keyboard_notify_modifiers(seat->seat,
&device->keyboard->modifiers);
&keyboard->modifiers);
wlr_idle_notify_activity(seat->server->idle, seat->seat);
}
@ -205,10 +208,10 @@ handle_command_key_bindings(struct cg_server *server, xkb_keysym_t sym,
struct wlr_surface *surface = NULL;
struct wlr_scene_node *node = wlr_scene_node_at(
&server->scene->node, server->seat->cursor->x, server->seat->cursor->y, &sx, &sy);
&server->scene->tree.node, server->seat->cursor->x, server->seat->cursor->y, &sx, &sy);
if(server->seat->enable_cursor) {
if(node && node->type == WLR_SCENE_NODE_SURFACE) {
surface = wlr_scene_surface_from_node(node)->surface;
if(node && node->type == WLR_SCENE_NODE_BUFFER) {
surface = wlr_scene_surface_from_buffer(wlr_scene_buffer_from_node(node))->surface;
wlr_seat_pointer_notify_enter(wlr_seat, surface, sx, sy);
} else {
wlr_xcursor_manager_set_cursor_image(server->seat->xcursor_manager,
@ -224,11 +227,10 @@ handle_command_key_bindings(struct cg_server *server, xkb_keysym_t sym,
"Recognized keybinding pressed (key: %d, mode: %d, modifiers: %d)",
sym, mode, modifiers);
if(group->wlr_group->input_device->keyboard->repeat_info.delay > 0) {
if(group->wlr_group->keyboard.repeat_info.delay > 0) {
group->repeat_keybinding = keybinding;
if(wl_event_source_timer_update(group->key_repeat_timer,
group->wlr_group->input_device
->keyboard->repeat_info.delay) <
group->wlr_group->keyboard.repeat_info.delay) <
0) {
wlr_log(WLR_DEBUG, "failed to set key repeat timer");
}
@ -271,26 +273,26 @@ key_is_modifier(const xkb_keysym_t key) {
static void
handle_key_event(struct cg_keyboard_group *group, struct cg_seat *seat,
void *data) {
struct wlr_event_keyboard_key *event = data;
struct wlr_input_device *device = group->wlr_group->input_device;
struct wlr_keyboard_key_event *event = data;
struct wlr_keyboard *keyboard = &group->wlr_group->keyboard;
/* Translate from libinput keycode to an xkbcommon keycode. */
xkb_keycode_t keycode = event->keycode + 8;
const xkb_keysym_t *syms;
int nsyms =
xkb_state_key_get_syms(device->keyboard->xkb_state, keycode, &syms);
xkb_state_key_get_syms(keyboard->xkb_state, keycode, &syms);
bool handled = false;
for(int i = 0; i < nsyms; ++i) {
if(event->state == WL_KEYBOARD_KEY_STATE_PRESSED &&
!key_is_modifier(syms[i])) {
uint32_t modifiers = wlr_keyboard_get_modifiers(device->keyboard);
uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard);
/* Get the consumed_modifiers and remove them from the modifier list
*/
xkb_mod_mask_t consumed_modifiers =
xkb_state_key_get_consumed_mods2(device->keyboard->xkb_state,
xkb_state_key_get_consumed_mods2(keyboard->xkb_state,
keycode,
XKB_CONSUMED_MODE_GTK);
if(handle_command_key_bindings(seat->server, syms[i],
@ -305,7 +307,7 @@ handle_key_event(struct cg_keyboard_group *group, struct cg_seat *seat,
if(!handled) {
/* Otherwise, we pass it along to the client. */
wlr_seat_set_keyboard(seat->seat, device);
wlr_seat_set_keyboard(seat->seat, keyboard);
wlr_seat_keyboard_notify_key(seat->seat, event->time_msec,
event->keycode, event->state);
}
@ -324,7 +326,7 @@ static void
handle_keyboard_group_modifiers(struct wl_listener *listener, void *_data) {
struct cg_keyboard_group *group =
wl_container_of(listener, group, modifiers);
handle_modifier_event(group->wlr_group->input_device, group->seat);
handle_modifier_event(&group->wlr_group->keyboard.base, group->seat);
}
static bool repeat_info_match(struct wlr_keyboard *a, struct wlr_keyboard *b) {
@ -335,7 +337,7 @@ static bool repeat_info_match(struct wlr_keyboard *a, struct wlr_keyboard *b) {
static void
cg_keyboard_group_add(struct cg_input_device *input_device, struct cg_seat *seat) {
struct wlr_input_device *device=input_device->wlr_device;
struct wlr_keyboard *wlr_keyboard = device->keyboard;
struct wlr_keyboard *wlr_keyboard = wlr_keyboard_from_input_device(device);
// Virtual devices should not be grouped
if(!input_device->is_virtual) {
struct cg_keyboard_group *group;
@ -364,10 +366,10 @@ cg_keyboard_group_add(struct cg_input_device *input_device, struct cg_seat *seat
cg_group->wlr_group->data = cg_group;
wlr_keyboard_set_keymap(&cg_group->wlr_group->keyboard,
device->keyboard->keymap);
wlr_keyboard->keymap);
wlr_keyboard_set_repeat_info(&cg_group->wlr_group->keyboard,
device->keyboard->repeat_info.rate,
device->keyboard->repeat_info.delay);
wlr_keyboard->repeat_info.rate,
wlr_keyboard->repeat_info.delay);
if(input_device->identifier != NULL) {
cg_group->identifier=strdup(input_device->identifier);
} else {
@ -420,7 +422,7 @@ new_keyboard(struct cg_seat *seat, struct cg_input_device *input_device) {
return;
}
wlr_keyboard_set_keymap(device->keyboard, keymap);
wlr_keyboard_set_keymap(wlr_keyboard_from_input_device(device), keymap);
xkb_keymap_unref(keymap);
xkb_context_unref(context);
@ -428,7 +430,7 @@ new_keyboard(struct cg_seat *seat, struct cg_input_device *input_device) {
cg_keyboard_group_add(input_device, seat);
++seat->num_keyboards;
wlr_seat_set_keyboard(seat->seat, device);
wlr_seat_set_keyboard(seat->seat, wlr_keyboard_from_input_device(device));
}
void
@ -465,14 +467,14 @@ remove_keyboard(struct cg_seat *seat, struct cg_input_device *keyboard) {
return;
}
struct wlr_seat *wlr_seat = seat->seat;
struct wlr_keyboard *wlr_keyboard = keyboard->wlr_device->keyboard;
struct wlr_keyboard *wlr_keyboard = wlr_keyboard_from_input_device(keyboard->wlr_device);
struct wlr_keyboard_group *wlr_group = wlr_keyboard->group;
if(wlr_group) {
wlr_keyboard_group_remove_keyboard(wlr_group, wlr_keyboard);
if (wl_list_empty(&wlr_group->devices)) {
wlr_log(WLR_DEBUG, "Destroying empty keyboard group %p",
wlr_group);
(void *)wlr_group);
struct cg_keyboard_group *group = wlr_group->data;
if(wlr_seat_get_keyboard(wlr_seat) == &wlr_group->keyboard) {
wlr_seat_set_keyboard(wlr_seat, NULL);
@ -568,20 +570,20 @@ handle_request_set_cursor(struct wl_listener *listener, void *data) {
static void
handle_touch_down(struct wl_listener *listener, void *data) {
struct cg_seat *seat = wl_container_of(listener, seat, touch_down);
struct wlr_event_touch_down *event = data;
struct wlr_touch_down_event *event = data;
double lx, ly;
wlr_cursor_absolute_to_layout_coords(seat->cursor, event->device, event->x,
wlr_cursor_absolute_to_layout_coords(seat->cursor, &event->touch->base, event->x,
event->y, &lx, &ly);
double sx, sy;
struct wlr_scene_node *node =
wlr_scene_node_at(&seat->server->scene->node, lx, ly, &sx, &sy);
wlr_scene_node_at(&seat->server->scene->tree.node, lx, ly, &sx, &sy);
uint32_t serial = 0;
if(node && node->type == WLR_SCENE_NODE_SURFACE) {
if(node && node->type == WLR_SCENE_NODE_BUFFER) {
serial = wlr_seat_touch_notify_down(
seat->seat, wlr_scene_surface_from_node(node)->surface,
seat->seat, wlr_scene_surface_from_buffer(wlr_scene_buffer_from_node(node))->surface,
event->time_msec, event->touch_id, sx, sy);
}
@ -597,7 +599,7 @@ handle_touch_down(struct wl_listener *listener, void *data) {
static void
handle_touch_up(struct wl_listener *listener, void *data) {
struct cg_seat *seat = wl_container_of(listener, seat, touch_up);
struct wlr_event_touch_up *event = data;
struct wlr_touch_up_event *event = data;
if(!wlr_seat_touch_get_point(seat->seat, event->touch_id)) {
return;
@ -610,23 +612,23 @@ handle_touch_up(struct wl_listener *listener, void *data) {
static void
handle_touch_motion(struct wl_listener *listener, void *data) {
struct cg_seat *seat = wl_container_of(listener, seat, touch_motion);
struct wlr_event_touch_motion *event = data;
struct wlr_touch_motion_event *event = data;
if(!wlr_seat_touch_get_point(seat->seat, event->touch_id)) {
return;
}
double lx, ly;
wlr_cursor_absolute_to_layout_coords(seat->cursor, event->device, event->x,
wlr_cursor_absolute_to_layout_coords(seat->cursor, &event->touch->base, event->x,
event->y, &lx, &ly);
double sx, sy;
struct wlr_scene_node *node =
wlr_scene_node_at(&seat->server->scene->node, lx, ly, &sx, &sy);
wlr_scene_node_at(&seat->server->scene->tree.node, lx, ly, &sx, &sy);
if(node && node->type == WLR_SCENE_NODE_SURFACE) {
if(node && node->type == WLR_SCENE_NODE_BUFFER) {
wlr_seat_touch_point_focus(seat->seat,
wlr_scene_surface_from_node(node)->surface,
wlr_scene_surface_from_buffer(wlr_scene_buffer_from_node(node))->surface,
event->time_msec, event->touch_id, sx, sy);
wlr_seat_touch_notify_motion(seat->seat, event->time_msec,
event->touch_id, sx, sy);
@ -654,7 +656,7 @@ handle_cursor_frame(struct wl_listener *listener, void *_data) {
static void
handle_cursor_axis(struct wl_listener *listener, void *data) {
struct cg_seat *seat = wl_container_of(listener, seat, cursor_axis);
struct wlr_event_pointer_axis *event = data;
struct wlr_pointer_axis_event *event = data;
wlr_seat_pointer_notify_axis(seat->seat, event->time_msec,
event->orientation, event->delta,
@ -665,7 +667,7 @@ handle_cursor_axis(struct wl_listener *listener, void *data) {
static void
handle_cursor_button(struct wl_listener *listener, void *data) {
struct cg_seat *seat = wl_container_of(listener, seat, cursor_button);
struct wlr_event_pointer_button *event = data;
struct wlr_pointer_button_event *event = data;
wlr_seat_pointer_notify_button(seat->seat, event->time_msec, event->button,
event->state);
@ -679,10 +681,10 @@ process_cursor_motion(struct cg_seat *seat, uint32_t time) {
struct wlr_surface *surface = NULL;
struct wlr_scene_node *node = wlr_scene_node_at(
&seat->server->scene->node, seat->cursor->x, seat->cursor->y, &sx, &sy);
&seat->server->scene->tree.node, seat->cursor->x, seat->cursor->y, &sx, &sy);
if(node && node->type == WLR_SCENE_NODE_SURFACE) {
surface = wlr_scene_surface_from_node(node)->surface;
if(node && node->type == WLR_SCENE_NODE_BUFFER) {
surface = wlr_scene_surface_from_buffer(wlr_scene_buffer_from_node(node))->surface;
wlr_seat_pointer_notify_enter(wlr_seat, surface, sx, sy);
bool focus_changed = wlr_seat->pointer_state.focused_surface != surface;
@ -740,9 +742,9 @@ static void
handle_cursor_motion_absolute(struct wl_listener *listener, void *data) {
struct cg_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_cursor_warp_absolute(seat->cursor, event->device, event->x, event->y);
wlr_cursor_warp_absolute(seat->cursor, &event->pointer->base, event->x, event->y);
process_cursor_motion(seat, event->time_msec);
wlr_idle_notify_activity(seat->server->idle, seat->seat);
}
@ -750,9 +752,9 @@ handle_cursor_motion_absolute(struct wl_listener *listener, void *data) {
static void
handle_cursor_motion(struct wl_listener *listener, void *data) {
struct cg_seat *seat = wl_container_of(listener, seat, cursor_motion);
struct wlr_event_pointer_motion *event = data;
struct wlr_pointer_motion_event *event = data;
wlr_cursor_move(seat->cursor, event->device, event->delta_x,
wlr_cursor_move(seat->cursor, &event->pointer->base, event->delta_x,
event->delta_y);
process_cursor_motion(seat, event->time_msec);
wlr_idle_notify_activity(seat->server->idle, seat->seat);
@ -780,7 +782,7 @@ drag_icon_update_position(struct cg_drag_icon *drag_icon) {
drag_icon->ly = seat->touch_ly;
break;
}
wlr_scene_node_set_position(drag_icon->scene_node, drag_icon->lx,
wlr_scene_node_set_position(&drag_icon->scene_tree->node, drag_icon->lx,
drag_icon->ly);
}
@ -791,7 +793,7 @@ handle_drag_icon_destroy(struct wl_listener *listener, void *_data) {
wl_list_remove(&drag_icon->link);
wl_list_remove(&drag_icon->destroy.link);
wlr_scene_node_destroy(drag_icon->scene_node);
wlr_scene_node_destroy(&drag_icon->scene_tree->node);
free(drag_icon);
}
@ -837,9 +839,9 @@ handle_start_drag(struct wl_listener *listener, void *data) {
}
drag_icon->seat = seat;
drag_icon->wlr_drag_icon = wlr_drag_icon;
drag_icon->scene_node = wlr_scene_subsurface_tree_create(
&seat->server->scene->node, wlr_drag_icon->surface);
if(!drag_icon->scene_node) {
drag_icon->scene_tree = wlr_scene_subsurface_tree_create(
&seat->server->scene->tree, wlr_drag_icon->surface);
if(!drag_icon->scene_tree) {
free(drag_icon);
return;
}
@ -1057,10 +1059,11 @@ seat_set_focus(struct cg_seat *seat, struct cg_view *view) {
NULL);
}
wlr_scene_node_raise_to_top(view->scene_node);
wlr_scene_node_raise_to_top(&view->scene_tree->node);
process_cursor_motion(seat, -1);
struct wlr_box *box = wlr_output_layout_get_box(
server->output_layout, view->workspace->output->wlr_output);
wlr_scene_node_set_position(&view->workspace->output->bg->node, box->x,
box->y);
struct wlr_box box;
wlr_output_layout_get_box(
server->output_layout, view->workspace->output->wlr_output,&box);
wlr_scene_node_set_position(&view->workspace->output->bg->node, box.x,
box.y);
}

2
seat.h
View file

@ -91,7 +91,7 @@ struct cg_drag_icon {
struct wl_list link; // seat::drag_icons
struct cg_seat *seat;
struct wlr_drag_icon *wlr_drag_icon;
struct wlr_scene_node *scene_node;
struct wlr_scene_tree *scene_tree;
/* The drag icon has a position in layout coordinates. */
double lx, ly;

31
view.c
View file

@ -17,7 +17,7 @@
#include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_scene.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/util/box.h>
#include "ipc_server.h"
@ -88,13 +88,14 @@ void
view_maximize(struct cg_view *view, struct cg_tile *tile) {
view->ox = tile->tile.x;
view->oy = tile->tile.y;
struct wlr_box *box = wlr_output_layout_get_box(
view->server->output_layout, view->workspace->output->wlr_output);
wlr_scene_node_set_position(view->scene_node, view->ox + box->x,
view->oy + box->y);
struct wlr_box box;
wlr_output_layout_get_box(
view->server->output_layout, view->workspace->output->wlr_output,&box);
wlr_scene_node_set_position(&view->scene_tree->node, view->ox + box.x,
view->oy + box.y);
view->impl->maximize(view, tile->tile.width, tile->tile.height);
view->tile = tile;
wlr_scene_node_raise_to_top(view->scene_node);
wlr_scene_node_raise_to_top(&view->scene_tree->node);
}
void
@ -116,7 +117,7 @@ view_unmap(struct cg_view *view) {
tile_id = view->tile->id;
}
wlr_scene_node_destroy(view->scene_node);
wlr_scene_node_destroy(&view->scene_tree->node);
#if CG_HAS_XWAYLAND
if((view->type != CG_XWAYLAND_VIEW || xwayland_view_should_manage(view)))
@ -163,13 +164,13 @@ view_map(struct cg_view *view, struct wlr_surface *surface,
struct cg_output *output = ws->output;
view->wlr_surface = surface;
view->scene_node =
wlr_scene_subsurface_tree_create(&ws->scene->node, surface);
if(!view->scene_node) {
view->scene_tree =
wlr_scene_subsurface_tree_create(ws->scene, surface);
if(!view->scene_tree) {
wl_resource_post_no_memory(surface->resource);
return;
}
view->scene_node->data = view;
view->scene_tree->node.data = view;
view->workspace = ws;
#if CG_HAS_XWAYLAND
@ -177,10 +178,10 @@ view_map(struct cg_view *view, struct wlr_surface *surface,
their own (x,y) coordinates in handle_wayland_surface_map. */
if(view->type == CG_XWAYLAND_VIEW && !xwayland_view_should_manage(view)) {
wl_list_insert(&ws->unmanaged_views, &view->link);
struct wlr_box *box = wlr_output_layout_get_box(
view->server->output_layout, view->workspace->output->wlr_output);
wlr_scene_node_set_position(view->scene_node, view->ox + box->x,
view->oy + box->y);
struct wlr_box box;
wlr_output_layout_get_box(view->server->output_layout, view->workspace->output->wlr_output,&box);
wlr_scene_node_set_position(&view->scene_tree->node, view->ox + box.x,
view->oy + box.y);
} else
#endif
{

4
view.h
View file

@ -5,7 +5,7 @@
#include <stdbool.h>
#include <wayland-server-core.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_compositor.h>
struct cg_server;
struct wlr_box;
@ -23,7 +23,7 @@ struct cg_view {
struct wl_list link; // server::views
struct wlr_surface *wlr_surface;
struct cg_tile *tile;
struct wlr_scene_node *scene_node;
struct wlr_scene_tree *scene_tree;
/* The view has a position in output coordinates. */
int ox, oy;

View file

@ -25,13 +25,13 @@
void
workspace_tile_update_view(struct cg_tile *tile, struct cg_view *view) {
if(tile->view!=NULL) {
wlr_scene_node_set_enabled(tile->view->scene_node,false);
wlr_scene_node_set_enabled(&tile->view->scene_tree->node,false);
tile->view->tile=NULL;
}
tile->view=view;
if(view!=NULL) {
view_maximize(view,tile);
wlr_scene_node_set_enabled(view->scene_node,true);
wlr_scene_node_set_enabled(&view->scene_tree->node,true);
}
}
@ -53,9 +53,10 @@ full_screen_workspace_tiles(struct wlr_output_layout *layout,
workspace->focused_tile->prev = workspace->focused_tile;
workspace->focused_tile->tile.x = 0;
workspace->focused_tile->tile.y = 0;
struct wlr_box *output_box = wlr_output_layout_get_box(layout, output);
workspace->focused_tile->tile.width = output_box->width;
workspace->focused_tile->tile.height = output_box->height;
struct wlr_box output_box;
wlr_output_layout_get_box(layout, output,&output_box);
workspace->focused_tile->tile.width = output_box.width;
workspace->focused_tile->tile.height = output_box.height;
workspace_tile_update_view(workspace->focused_tile,NULL);
workspace->focused_tile->id = *tiles_curr_id;
++(*tiles_curr_id);
@ -79,7 +80,7 @@ full_screen_workspace(struct cg_output *output) {
}
workspace->server = output->server;
workspace->num = -1;
workspace->scene = wlr_scene_tree_create(&scene_output->scene->node);
workspace->scene = wlr_scene_tree_create(&scene_output->scene->tree);
if(full_screen_workspace_tiles(output->server->output_layout,
output->wlr_output, workspace,
&output->server->tiles_curr_id) != 0) {

View file

@ -77,21 +77,22 @@ xdg_decoration_handle_request_mode(struct wl_listener *listener, void *_data) {
static void
popup_unconstrain(struct cg_view *view, struct wlr_xdg_popup *popup) {
struct wlr_box *popup_box = &popup->geometry;
struct wlr_box *popup_box = &popup->current.geometry;
struct wlr_output_layout *output_layout = view->server->output_layout;
struct wlr_box *view_output_box = wlr_output_layout_get_box(
output_layout, view->workspace->output->wlr_output);
struct wlr_box view_output_box;
wlr_output_layout_get_box(
output_layout, view->workspace->output->wlr_output,&view_output_box);
struct wlr_output *wlr_output = wlr_output_layout_output_at(
output_layout, view_output_box->x + view->ox + popup_box->x,
view_output_box->y + view->oy + popup_box->y);
struct wlr_box *output_box =
wlr_output_layout_get_box(output_layout, wlr_output);
output_layout, view_output_box.x + view->ox + popup_box->x,
view_output_box.y + view->oy + popup_box->y);
struct wlr_box output_box;
wlr_output_layout_get_box(output_layout, wlr_output,&output_box);
struct wlr_box output_toplevel_box = {.x = -view->ox,
.y = -view->oy,
.width = output_box->width,
.height = output_box->height};
.width = output_box.width,
.height = output_box.height};
wlr_xdg_popup_unconstrain_from_box(popup, &output_toplevel_box);
}
@ -119,16 +120,15 @@ static bool
is_primary(const struct cg_view *view) {
const struct cg_xdg_shell_view *xdg_shell_view =
xdg_shell_view_from_const_view(view);
struct wlr_xdg_surface *parent =
struct wlr_xdg_toplevel *parent =
xdg_shell_view->xdg_surface->toplevel->parent;
/* FIXME: role is 0? */
return parent == NULL; /*&& role == WLR_XDG_SURFACE_ROLE_TOPLEVEL */
return parent == NULL;
}
static void
activate(struct cg_view *view, bool activate) {
struct cg_xdg_shell_view *xdg_shell_view = xdg_shell_view_from_view(view);
wlr_xdg_toplevel_set_activated(xdg_shell_view->xdg_surface, activate);
wlr_xdg_toplevel_set_activated(xdg_shell_view->xdg_surface->toplevel, activate);
}
static void
@ -136,17 +136,17 @@ close(struct cg_view *view) {
struct cg_xdg_shell_view *xdg_shell_view = xdg_shell_view_from_view(view);
struct wlr_xdg_surface *surface = xdg_shell_view->xdg_surface;
if(surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
wlr_xdg_toplevel_send_close(surface);
wlr_xdg_toplevel_send_close(surface->toplevel);
}
}
static void
maximize(struct cg_view *view, int width, int height) {
struct cg_xdg_shell_view *xdg_shell_view = xdg_shell_view_from_view(view);
wlr_xdg_toplevel_set_size(xdg_shell_view->xdg_surface, width, height);
wlr_xdg_toplevel_set_size(xdg_shell_view->xdg_surface->toplevel, width, height);
enum wlr_edges edges =
WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP | WLR_EDGE_BOTTOM;
wlr_xdg_toplevel_set_tiled(xdg_shell_view->xdg_surface, edges);
wlr_xdg_toplevel_set_tiled(xdg_shell_view->xdg_surface->toplevel, edges);
}
static void
@ -158,11 +158,18 @@ destroy(struct cg_view *view) {
static void
handle_xdg_shell_surface_request_fullscreen(struct wl_listener *listener,
void *data) {
struct cg_xdg_shell_view *xdg_shell_view =
wl_container_of(listener, xdg_shell_view, request_fullscreen);
struct wlr_xdg_toplevel_set_fullscreen_event *event = data;
wlr_xdg_toplevel_set_fullscreen(xdg_shell_view->xdg_surface,
event->fullscreen);
struct cg_xdg_shell_view *xdg_shell_view = wl_container_of(listener, xdg_shell_view, request_fullscreen);
/**
* Certain clients do not like figuring out their own window geometry if they
* display in fullscreen mode, so we set it here.
*/
struct wlr_box layout_box;
wlr_output_layout_get_box(xdg_shell_view->view.server->output_layout, NULL, &layout_box);
wlr_xdg_toplevel_set_size(xdg_shell_view->xdg_surface->toplevel, layout_box.width, layout_box.height);
wlr_xdg_toplevel_set_fullscreen(xdg_shell_view->xdg_surface->toplevel,
xdg_shell_view->xdg_surface->toplevel->requested.fullscreen);
}
static void
@ -248,26 +255,26 @@ handle_xdg_shell_surface_new(struct wl_listener *listener, void *data) {
return;
}
struct wlr_scene_node *parent_scene_node = NULL;
struct wlr_scene_tree *parent_scene_tree = NULL;
struct wlr_xdg_surface *parent =
wlr_xdg_surface_from_wlr_surface(popup->parent);
switch(parent->role) {
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:;
parent_scene_node = view->scene_node;
parent_scene_tree = view->scene_tree;
break;
case WLR_XDG_SURFACE_ROLE_POPUP:
parent_scene_node = parent->data;
parent_scene_tree = parent->data;
break;
case WLR_XDG_SURFACE_ROLE_NONE:
break;
}
if(parent_scene_node == NULL) {
if(parent_scene_tree == NULL) {
return;
}
struct wlr_scene_node *popup_scene_node =
wlr_scene_xdg_surface_create(parent_scene_node, xdg_surface);
if(popup_scene_node == NULL) {
struct wlr_scene_tree *popup_scene_tree =
wlr_scene_xdg_surface_create(parent_scene_tree, xdg_surface);
if(popup_scene_tree == NULL) {
wlr_log(WLR_ERROR,
"Failed to allocate scene-graph node for XDG popup");
return;
@ -275,7 +282,7 @@ handle_xdg_shell_surface_new(struct wl_listener *listener, void *data) {
popup_unconstrain(view, popup);
xdg_surface->data = popup_scene_node;
xdg_surface->data = popup_scene_tree;
break;
case WLR_XDG_SURFACE_ROLE_NONE:
assert(false); // unreachable

View file

@ -79,7 +79,7 @@ close(struct cg_view *view) {
static void
maximize(struct cg_view *view, int width, int height) {
struct cg_xwayland_view *xwayland_view = xwayland_view_from_view(view);
struct wlr_xwayland_surface_size_hints *hints =
xcb_size_hints_t *hints =
xwayland_view->xwayland_surface->size_hints;
if(hints != NULL && hints->flags & PMaxSize) {
@ -92,11 +92,11 @@ maximize(struct cg_view *view, int width, int height) {
}
}
struct wlr_box *output_box = wlr_output_layout_get_box(
view->server->output_layout, view->server->curr_output->wlr_output);
struct wlr_box output_box;
wlr_output_layout_get_box(view->server->output_layout, view->server->curr_output->wlr_output,&output_box);
wlr_xwayland_surface_configure(xwayland_view->xwayland_surface,
view->ox + output_box->x,
view->oy + output_box->y, width, height);
view->ox + output_box.x,
view->oy + output_box.y, width, height);
wlr_xwayland_surface_set_maximized(xwayland_view->xwayland_surface, true);
}
@ -133,10 +133,10 @@ handle_xwayland_surface_map(struct wl_listener *listener, void *_data) {
struct cg_view *view = &xwayland_view->view;
if(!xwayland_view_should_manage(view)) {
struct wlr_output_layout *output_layout = view->server->output_layout;
struct wlr_box *output_box = wlr_output_layout_get_box(
output_layout, view->server->curr_output->wlr_output);
view->ox = xwayland_view->xwayland_surface->x - output_box->x;
view->oy = xwayland_view->xwayland_surface->y - output_box->y;
struct wlr_box output_box;
wlr_output_layout_get_box(output_layout, view->server->curr_output->wlr_output,&output_box);
view->ox = xwayland_view->xwayland_surface->x - output_box.x;
view->oy = xwayland_view->xwayland_surface->y - output_box.y;
}
view_map(view, xwayland_view->xwayland_surface->surface,