aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
Diffstat (limited to 'rootston')
-rw-r--r--rootston/config.c10
-rw-r--r--rootston/cursor.c10
-rw-r--r--rootston/desktop.c17
-rw-r--r--rootston/input.c24
-rw-r--r--rootston/keyboard.c8
-rw-r--r--rootston/main.c2
-rw-r--r--rootston/meson.build2
-rw-r--r--rootston/output.c61
-rw-r--r--rootston/seat.c153
-rw-r--r--rootston/wl_shell.c4
-rw-r--r--rootston/xdg_shell_v6.c4
-rw-r--r--rootston/xwayland.c4
12 files changed, 129 insertions, 170 deletions
diff --git a/rootston/config.c b/rootston/config.c
index 26cbd12d..e63efc0b 100644
--- a/rootston/config.c
+++ b/rootston/config.c
@@ -2,20 +2,20 @@
#define _POSIX_C_SOURCE 200809L
#endif
#include <assert.h>
-#include <stdlib.h>
-#include <limits.h>
#include <getopt.h>
+#include <limits.h>
+#include <stdlib.h>
#include <string.h>
#include <strings.h>
-#include <unistd.h>
#include <sys/param.h>
+#include <unistd.h>
#include <wlr/config.h>
-#include <wlr/util/log.h>
#include <wlr/types/wlr_box.h>
+#include <wlr/util/log.h>
#include "rootston/config.h"
+#include "rootston/ini.h"
#include "rootston/input.h"
#include "rootston/keyboard.h"
-#include "rootston/ini.h"
static void usage(const char *name, int ret) {
fprintf(stderr,
diff --git a/rootston/cursor.c b/rootston/cursor.c
index ab32a5de..aa94daeb 100644
--- a/rootston/cursor.c
+++ b/rootston/cursor.c
@@ -1,16 +1,16 @@
#define _XOPEN_SOURCE 700
-#include <stdlib.h>
#include <math.h>
+#include <stdlib.h>
+#include <wlr/types/wlr_xcursor_manager.h>
+#include <wlr/util/edges.h>
+#include <wlr/util/log.h>
#ifdef __linux__
#include <linux/input-event-codes.h>
#elif __FreeBSD__
#include <dev/evdev/input-event-codes.h>
#endif
-#include <wlr/types/wlr_xcursor_manager.h>
-#include <wlr/util/log.h>
-#include <wlr/util/edges.h>
-#include "rootston/xcursor.h"
#include "rootston/cursor.h"
+#include "rootston/xcursor.h"
struct roots_cursor *roots_cursor_create(struct roots_seat *seat) {
struct roots_cursor *cursor = calloc(1, sizeof(struct roots_cursor));
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 91661c05..80ccbc25 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -1,25 +1,25 @@
#define _POSIX_C_SOURCE 199309L
#include <assert.h>
-#include <time.h>
-#include <stdlib.h>
#include <math.h>
+#include <stdlib.h>
+#include <time.h>
#include <wlr/config.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_gamma_control.h>
#include <wlr/types/wlr_idle.h>
+#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_server_decoration.h>
-#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_wl_shell.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/types/wlr_xdg_shell_v6.h>
#include <wlr/util/log.h>
-#include "rootston/server.h"
#include "rootston/seat.h"
-#include "rootston/xcursor.h"
+#include "rootston/server.h"
#include "rootston/view.h"
+#include "rootston/xcursor.h"
void view_get_box(const struct roots_view *view, struct wlr_box *box) {
box->x = view->x;
@@ -621,11 +621,8 @@ struct roots_desktop *desktop_create(struct roots_server *server,
wl_list_init(&desktop->views);
wl_list_init(&desktop->outputs);
- desktop->output_add.notify = output_add_notify;
- wl_signal_add(&server->backend->events.output_add, &desktop->output_add);
- desktop->output_remove.notify = output_remove_notify;
- wl_signal_add(&server->backend->events.output_remove,
- &desktop->output_remove);
+ desktop->new_output.notify = handle_new_output;
+ wl_signal_add(&server->backend->events.new_output, &desktop->new_output);
desktop->server = server;
desktop->config = config;
diff --git a/rootston/input.c b/rootston/input.c
index 74ce59d0..657b0946 100644
--- a/rootston/input.c
+++ b/rootston/input.c
@@ -1,16 +1,16 @@
#include <assert.h>
#include <stdlib.h>
#include <wayland-server.h>
+#include <wlr/backend/libinput.h>
#include <wlr/types/wlr_cursor.h>
#include <wlr/util/log.h>
#include <wlr/xcursor.h>
#include <wlr/xwayland.h>
-#include <wlr/backend/libinput.h>
-#include "rootston/server.h"
#include "rootston/config.h"
#include "rootston/input.h"
#include "rootston/keyboard.h"
#include "rootston/seat.h"
+#include "rootston/server.h"
static const char *device_type(enum wlr_input_device_type type) {
switch (type) {
@@ -40,9 +40,9 @@ struct roots_seat *input_get_seat(struct roots_input *input, char *name) {
return seat;
}
-static void input_add_notify(struct wl_listener *listener, void *data) {
+static void handle_new_input(struct wl_listener *listener, void *data) {
struct wlr_input_device *device = data;
- struct roots_input *input = wl_container_of(listener, input, input_add);
+ struct roots_input *input = wl_container_of(listener, input, new_input);
char *seat_name = ROOTS_CONFIG_DEFAULT_SEAT_NAME;
struct roots_device_config *dc =
@@ -74,16 +74,6 @@ static void input_add_notify(struct wl_listener *listener, void *data) {
}
}
-static void input_remove_notify(struct wl_listener *listener, void *data) {
- struct wlr_input_device *device = data;
- struct roots_input *input = wl_container_of(listener, input, input_remove);
-
- struct roots_seat *seat;
- wl_list_for_each(seat, &input->seats, link) {
- roots_seat_remove_device(seat, device);
- }
-}
-
struct roots_input *input_create(struct roots_server *server,
struct roots_config *config) {
wlr_log(L_DEBUG, "Initializing roots input");
@@ -99,10 +89,8 @@ struct roots_input *input_create(struct roots_server *server,
wl_list_init(&input->seats);
- input->input_add.notify = input_add_notify;
- wl_signal_add(&server->backend->events.input_add, &input->input_add);
- input->input_remove.notify = input_remove_notify;
- wl_signal_add(&server->backend->events.input_remove, &input->input_remove);
+ input->new_input.notify = handle_new_input;
+ wl_signal_add(&server->backend->events.new_input, &input->new_input);
return input;
}
diff --git a/rootston/keyboard.c b/rootston/keyboard.c
index ddf541b4..6ec90c31 100644
--- a/rootston/keyboard.c
+++ b/rootston/keyboard.c
@@ -1,18 +1,18 @@
#include <assert.h>
+#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
-#include <stdbool.h>
#include <wayland-server.h>
-#include <wlr/types/wlr_input_device.h>
-#include <wlr/types/wlr_pointer.h>
#include <wlr/backend/multi.h>
#include <wlr/backend/session.h>
+#include <wlr/types/wlr_input_device.h>
+#include <wlr/types/wlr_pointer.h>
#include <wlr/util/log.h>
#include <xkbcommon/xkbcommon.h>
#include "rootston/input.h"
-#include "rootston/seat.h"
#include "rootston/keyboard.h"
+#include "rootston/seat.h"
static ssize_t pressed_keysyms_index(xkb_keysym_t *pressed_keysyms,
xkb_keysym_t keysym) {
diff --git a/rootston/main.c b/rootston/main.c
index 3273c53f..5450ade2 100644
--- a/rootston/main.c
+++ b/rootston/main.c
@@ -3,10 +3,10 @@
#include <stdlib.h>
#include <unistd.h>
#include <wayland-server.h>
-#include <wlr/config.h>
#include <wlr/backend.h>
#include <wlr/backend/headless.h>
#include <wlr/backend/multi.h>
+#include <wlr/config.h>
#include <wlr/render.h>
#include <wlr/util/log.h>
#include "rootston/config.h"
diff --git a/rootston/meson.build b/rootston/meson.build
index 973f93a4..a53812e3 100644
--- a/rootston/meson.build
+++ b/rootston/meson.build
@@ -8,8 +8,8 @@ sources = [
'main.c',
'output.c',
'seat.c',
- 'xdg_shell_v6.c',
'wl_shell.c',
+ 'xdg_shell_v6.c',
]
if get_option('enable_xwayland')
sources += ['xwayland.c']
diff --git a/rootston/output.c b/rootston/output.c
index fce875da..1ea4412e 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -1,18 +1,18 @@
#define _POSIX_C_SOURCE 200809L
-#include <time.h>
-#include <stdlib.h>
-#include <stdbool.h>
#include <assert.h>
-#include <wlr/types/wlr_output_layout.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <time.h>
+#include <wlr/render/matrix.h>
#include <wlr/types/wlr_compositor.h>
+#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_wl_shell.h>
#include <wlr/types/wlr_xdg_shell_v6.h>
-#include <wlr/render/matrix.h>
#include <wlr/util/log.h>
#include <wlr/util/region.h>
-#include "rootston/server.h"
-#include "rootston/output.h"
#include "rootston/config.h"
+#include "rootston/output.h"
+#include "rootston/server.h"
typedef void (*surface_iterator_func_t)(struct wlr_surface *surface,
double lx, double ly, float rotation, void *data);
@@ -644,9 +644,22 @@ static void set_mode(struct wlr_output *output,
}
}
-void output_add_notify(struct wl_listener *listener, void *data) {
+static void output_handle_destroy(struct wl_listener *listener, void *data) {
+ struct roots_output *output = wl_container_of(listener, output, destroy);
+
+ // TODO: cursor
+ //example_config_configure_cursor(sample->config, sample->cursor,
+ // sample->compositor);
+
+ wl_list_remove(&output->link);
+ wl_list_remove(&output->destroy.link);
+ wl_list_remove(&output->frame.link);
+ free(output);
+}
+
+void handle_new_output(struct wl_listener *listener, void *data) {
struct roots_desktop *desktop = wl_container_of(listener, desktop,
- output_add);
+ new_output);
struct wlr_output *wlr_output = data;
struct roots_input *input = desktop->server->input;
struct roots_config *config = desktop->config;
@@ -670,6 +683,8 @@ void output_add_notify(struct wl_listener *listener, void *data) {
output->damage = wlr_output_damage_create(wlr_output);
+ output->destroy.notify = output_handle_destroy;
+ wl_signal_add(&wlr_output->events.destroy, &output->destroy);
output->frame.notify = output_damage_handle_frame;
wl_signal_add(&output->damage->events.frame, &output->frame);
@@ -699,31 +714,3 @@ void output_add_notify(struct wl_listener *listener, void *data) {
output_damage_whole(output);
}
-
-void output_remove_notify(struct wl_listener *listener, void *data) {
- struct wlr_output *wlr_output = data;
- struct roots_desktop *desktop =
- wl_container_of(listener, desktop, output_remove);
-
- struct roots_output *output = NULL, *_output;
- wl_list_for_each(_output, &desktop->outputs, link) {
- if (_output->wlr_output == wlr_output) {
- output = _output;
- break;
- }
- }
- if (!output) {
- return; // We are unfamiliar with this output
- }
-
- wlr_output_layout_remove(desktop->layout, output->wlr_output);
-
- // TODO: cursor
- //example_config_configure_cursor(sample->config, sample->cursor,
- // sample->compositor);
-
- wl_list_remove(&output->link);
- wl_list_remove(&output->frame.link);
- wlr_output_damage_destroy(output->damage);
- free(output);
-}
diff --git a/rootston/seat.c b/rootston/seat.c
index 45e42d7d..38c26628 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -3,14 +3,14 @@
#include <string.h>
#include <wayland-server.h>
#include <wlr/config.h>
+#include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/util/log.h>
-#include <wlr/types/wlr_idle.h>
-#include "rootston/xcursor.h"
+#include "rootston/cursor.h"
#include "rootston/input.h"
-#include "rootston/seat.h"
#include "rootston/keyboard.h"
-#include "rootston/cursor.h"
+#include "rootston/seat.h"
+#include "rootston/xcursor.h"
static void handle_keyboard_key(struct wl_listener *listener, void *data) {
struct roots_keyboard *keyboard =
@@ -404,6 +404,17 @@ static void seat_update_capabilities(struct roots_seat *seat) {
}
}
+static void handle_keyboard_destroy(struct wl_listener *listener, void *data) {
+ struct roots_keyboard *keyboard =
+ wl_container_of(listener, keyboard, device_destroy);
+ struct roots_seat *seat = keyboard->seat;
+ roots_keyboard_destroy(keyboard);
+ wl_list_remove(&keyboard->device_destroy.link);
+ wl_list_remove(&keyboard->keyboard_key.link);
+ wl_list_remove(&keyboard->keyboard_modifiers.link);
+ seat_update_capabilities(seat);
+}
+
static void seat_add_keyboard(struct roots_seat *seat,
struct wlr_input_device *device) {
assert(device->type == WLR_INPUT_DEVICE_KEYBOARD);
@@ -418,10 +429,11 @@ static void seat_add_keyboard(struct roots_seat *seat,
wl_list_insert(&seat->keyboards, &keyboard->link);
+ keyboard->device_destroy.notify = handle_keyboard_destroy;
+ wl_signal_add(&keyboard->device->events.destroy, &keyboard->device_destroy);
keyboard->keyboard_key.notify = handle_keyboard_key;
wl_signal_add(&keyboard->device->keyboard->events.key,
&keyboard->keyboard_key);
-
keyboard->keyboard_modifiers.notify = handle_keyboard_modifiers;
wl_signal_add(&keyboard->device->keyboard->events.modifiers,
&keyboard->keyboard_modifiers);
@@ -429,6 +441,19 @@ static void seat_add_keyboard(struct roots_seat *seat,
wlr_seat_set_keyboard(seat->seat, device);
}
+static void handle_pointer_destroy(struct wl_listener *listener, void *data) {
+ struct roots_pointer *pointer =
+ wl_container_of(listener, pointer, device_destroy);
+ struct roots_seat *seat = pointer->seat;
+
+ wl_list_remove(&pointer->link);
+ wlr_cursor_detach_input_device(seat->cursor->cursor, pointer->device);
+ wl_list_remove(&pointer->device_destroy.link);
+ free(pointer);
+
+ seat_update_capabilities(seat);
+}
+
static void seat_add_pointer(struct roots_seat *seat,
struct wlr_input_device *device) {
struct roots_pointer *pointer = calloc(sizeof(struct roots_pointer), 1);
@@ -441,10 +466,27 @@ static void seat_add_pointer(struct roots_seat *seat,
pointer->device = device;
pointer->seat = seat;
wl_list_insert(&seat->pointers, &pointer->link);
+
+ pointer->device_destroy.notify = handle_pointer_destroy;
+ wl_signal_add(&pointer->device->events.destroy, &pointer->device_destroy);
+
wlr_cursor_attach_input_device(seat->cursor->cursor, device);
roots_seat_configure_cursor(seat);
}
+static void handle_touch_destroy(struct wl_listener *listener, void *data) {
+ struct roots_pointer *touch =
+ wl_container_of(listener, touch, device_destroy);
+ struct roots_seat *seat = touch->seat;
+
+ wl_list_remove(&touch->link);
+ wlr_cursor_detach_input_device(seat->cursor->cursor, touch->device);
+ wl_list_remove(&touch->device_destroy.link);
+ free(touch);
+
+ seat_update_capabilities(seat);
+}
+
static void seat_add_touch(struct roots_seat *seat,
struct wlr_input_device *device) {
struct roots_touch *touch = calloc(sizeof(struct roots_touch), 1);
@@ -457,6 +499,10 @@ static void seat_add_touch(struct roots_seat *seat,
touch->device = device;
touch->seat = seat;
wl_list_insert(&seat->touch, &touch->link);
+
+ touch->device_destroy.notify = handle_touch_destroy;
+ wl_signal_add(&touch->device->events.destroy, &touch->device_destroy);
+
wlr_cursor_attach_input_device(seat->cursor->cursor, device);
roots_seat_configure_cursor(seat);
}
@@ -466,6 +512,20 @@ static void seat_add_tablet_pad(struct roots_seat *seat,
// TODO
}
+static void handle_tablet_tool_destroy(struct wl_listener *listener,
+ void *data) {
+ struct roots_pointer *tablet_tool =
+ wl_container_of(listener, tablet_tool, device_destroy);
+ struct roots_seat *seat = tablet_tool->seat;
+
+ wl_list_remove(&tablet_tool->link);
+ wlr_cursor_detach_input_device(seat->cursor->cursor, tablet_tool->device);
+ wl_list_remove(&tablet_tool->device_destroy.link);
+ free(tablet_tool);
+
+ seat_update_capabilities(seat);
+}
+
static void seat_add_tablet_tool(struct roots_seat *seat,
struct wlr_input_device *device) {
struct roots_tablet_tool *tablet_tool =
@@ -479,6 +539,11 @@ static void seat_add_tablet_tool(struct roots_seat *seat,
tablet_tool->device = device;
tablet_tool->seat = seat;
wl_list_insert(&seat->tablet_tools, &tablet_tool->link);
+
+ tablet_tool->device_destroy.notify = handle_tablet_tool_destroy;
+ wl_signal_add(&tablet_tool->device->events.destroy,
+ &tablet_tool->device_destroy);
+
wlr_cursor_attach_input_device(seat->cursor->cursor, device);
roots_seat_configure_cursor(seat);
}
@@ -506,84 +571,6 @@ void roots_seat_add_device(struct roots_seat *seat,
seat_update_capabilities(seat);
}
-static void seat_remove_keyboard(struct roots_seat *seat,
- struct wlr_input_device *device) {
- struct roots_keyboard *keyboard;
- wl_list_for_each(keyboard, &seat->keyboards, link) {
- if (keyboard->device == device) {
- roots_keyboard_destroy(keyboard);
- return;
- }
- }
-}
-
-static void seat_remove_pointer(struct roots_seat *seat,
- struct wlr_input_device *device) {
- struct roots_pointer *pointer;
- wl_list_for_each(pointer, &seat->pointers, link) {
- if (pointer->device == device) {
- wl_list_remove(&pointer->link);
- wlr_cursor_detach_input_device(seat->cursor->cursor, device);
- free(pointer);
- return;
- }
- }
-}
-
-static void seat_remove_touch(struct roots_seat *seat,
- struct wlr_input_device *device) {
- struct roots_touch *touch;
- wl_list_for_each(touch, &seat->touch, link) {
- if (touch->device == device) {
- wl_list_remove(&touch->link);
- wlr_cursor_detach_input_device(seat->cursor->cursor, device);
- free(touch);
- return;
- }
- }
-}
-
-static void seat_remove_tablet_pad(struct roots_seat *seat,
- struct wlr_input_device *device) {
- // TODO
-}
-
-static void seat_remove_tablet_tool(struct roots_seat *seat,
- struct wlr_input_device *device) {
- struct roots_tablet_tool *tablet_tool;
- wl_list_for_each(tablet_tool, &seat->tablet_tools, link) {
- if (tablet_tool->device == device) {
- wl_list_remove(&tablet_tool->link);
- wlr_cursor_detach_input_device(seat->cursor->cursor, device);
- free(tablet_tool);
- return;
- }
- }
-}
-
-void roots_seat_remove_device(struct roots_seat *seat,
- struct wlr_input_device *device) {
- switch (device->type) {
- case WLR_INPUT_DEVICE_KEYBOARD:
- seat_remove_keyboard(seat, device);
- break;
- case WLR_INPUT_DEVICE_POINTER:
- seat_remove_pointer(seat, device);
- break;
- case WLR_INPUT_DEVICE_TOUCH:
- seat_remove_touch(seat, device);
- break;
- case WLR_INPUT_DEVICE_TABLET_PAD:
- seat_remove_tablet_pad(seat, device);
- break;
- case WLR_INPUT_DEVICE_TABLET_TOOL:
- seat_remove_tablet_tool(seat, device);
- break;
- }
-
- seat_update_capabilities(seat);
-}
-
void roots_seat_configure_xcursor(struct roots_seat *seat) {
const char *cursor_theme = NULL;
struct roots_cursor_config *cc =
diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c
index 267e2cf5..44a65cf5 100644
--- a/rootston/wl_shell.c
+++ b/rootston/wl_shell.c
@@ -1,14 +1,14 @@
#include <assert.h>
-#include <stdlib.h>
#include <stdbool.h>
+#include <stdlib.h>
#include <wayland-server.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_wl_shell.h>
#include <wlr/util/log.h>
#include "rootston/desktop.h"
-#include "rootston/server.h"
#include "rootston/input.h"
+#include "rootston/server.h"
static void popup_destroy(struct roots_view_child *child) {
assert(child->destroy == popup_destroy);
diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c
index 9bd6f76a..8e6674ab 100644
--- a/rootston/xdg_shell_v6.c
+++ b/rootston/xdg_shell_v6.c
@@ -1,14 +1,14 @@
#include <assert.h>
-#include <stdlib.h>
#include <stdbool.h>
+#include <stdlib.h>
#include <wayland-server.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_xdg_shell_v6.h>
#include <wlr/util/log.h>
#include "rootston/desktop.h"
-#include "rootston/server.h"
#include "rootston/input.h"
+#include "rootston/server.h"
static void popup_destroy(struct roots_view_child *child) {
assert(child->destroy == popup_destroy);
diff --git a/rootston/xwayland.c b/rootston/xwayland.c
index 36be9793..e9e0d5e0 100644
--- a/rootston/xwayland.c
+++ b/rootston/xwayland.c
@@ -1,12 +1,12 @@
#include <assert.h>
-#include <stdlib.h>
#include <stdbool.h>
+#include <stdlib.h>
#include <wayland-server.h>
#include <wlr/config.h>
#include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_surface.h>
-#include <wlr/xwayland.h>
#include <wlr/util/log.h>
+#include <wlr/xwayland.h>
#include "rootston/server.h"
#include "rootston/server.h"