From ec83d9df58b0a3b31ea24c01f2df16c10dcad936 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Wed, 18 Oct 2017 05:05:21 -0400 Subject: xdg-shell: send same-as-current configure if needed --- types/wlr_xdg_shell_v6.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index f057025a..b14f5862 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -845,6 +845,10 @@ static bool wlr_xdg_surface_v6_toplevel_state_compare( return false; } + if (!wl_list_empty(&state->base->configure_list)) { + return false; + } + if (state->pending.activated != state->current.activated) { return false; } @@ -947,7 +951,7 @@ static void wlr_xdg_surface_send_configure(void *user_data) { } static void wlr_xdg_surface_v6_schedule_configure( - struct wlr_xdg_surface_v6 *surface, bool force) { + struct wlr_xdg_surface_v6 *surface) { struct wl_display *display = wl_client_get_display(surface->client->client); struct wl_event_loop *loop = wl_display_get_event_loop(display); bool pending_same = false; @@ -957,7 +961,7 @@ static void wlr_xdg_surface_v6_schedule_configure( assert(0 && "not reached"); break; case WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL: - pending_same = !force && + pending_same = wlr_xdg_surface_v6_toplevel_state_compare(surface->toplevel_state); break; case WLR_XDG_SURFACE_V6_ROLE_POPUP: @@ -1001,7 +1005,7 @@ static void wlr_xdg_surface_v6_toplevel_committed( if (!surface->surface->texture->valid && !surface->toplevel_state->added) { // on the first commit, send a configure request to tell the client it // is added - wlr_xdg_surface_v6_schedule_configure(surface, true); + wlr_xdg_surface_v6_schedule_configure(surface); surface->toplevel_state->added = true; return; } @@ -1018,7 +1022,7 @@ static void wlr_xdg_surface_v6_popup_committed( assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_POPUP); if (!surface->popup_state->committed) { - wlr_xdg_surface_v6_schedule_configure(surface, true); + wlr_xdg_surface_v6_schedule_configure(surface); surface->popup_state->committed = true; } } @@ -1265,49 +1269,42 @@ void wlr_xdg_surface_v6_ping(struct wlr_xdg_surface_v6 *surface) { void wlr_xdg_toplevel_v6_set_size(struct wlr_xdg_surface_v6 *surface, uint32_t width, uint32_t height) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - bool force = - (surface->toplevel_state->pending.width != width || - surface->toplevel_state->pending.height != height); surface->toplevel_state->pending.width = width; surface->toplevel_state->pending.height = height; - wlr_xdg_surface_v6_schedule_configure(surface, force); + wlr_xdg_surface_v6_schedule_configure(surface); } void wlr_xdg_toplevel_v6_set_activated(struct wlr_xdg_surface_v6 *surface, bool activated) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - bool force = surface->toplevel_state->pending.activated != activated; surface->toplevel_state->pending.activated = activated; - wlr_xdg_surface_v6_schedule_configure(surface, force); + wlr_xdg_surface_v6_schedule_configure(surface); } void wlr_xdg_toplevel_v6_set_maximized(struct wlr_xdg_surface_v6 *surface, bool maximized) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - bool force = surface->toplevel_state->pending.maximized != maximized; surface->toplevel_state->pending.maximized = maximized; - wlr_xdg_surface_v6_schedule_configure(surface, force); + wlr_xdg_surface_v6_schedule_configure(surface); } void wlr_xdg_toplevel_v6_set_fullscreen(struct wlr_xdg_surface_v6 *surface, bool fullscreen) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - bool force = surface->toplevel_state->pending.fullscreen != fullscreen; surface->toplevel_state->pending.fullscreen = fullscreen; - wlr_xdg_surface_v6_schedule_configure(surface, force); + wlr_xdg_surface_v6_schedule_configure(surface); } void wlr_xdg_toplevel_v6_set_resizing(struct wlr_xdg_surface_v6 *surface, bool resizing) { assert(surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL); - bool force = surface->toplevel_state->pending.resizing != resizing; surface->toplevel_state->pending.resizing = resizing; - wlr_xdg_surface_v6_schedule_configure(surface, force); + wlr_xdg_surface_v6_schedule_configure(surface); } void wlr_xdg_toplevel_v6_send_close(struct wlr_xdg_surface_v6 *surface) { -- cgit v1.2.3 From fcf4724da94056cfe71f69359f94f39334102fc6 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Thu, 19 Oct 2017 10:15:56 -0400 Subject: xdg-shell: improve configure request change detection --- types/wlr_xdg_shell_v6.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index b14f5862..efa6bb3a 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -840,30 +840,46 @@ static const struct zxdg_surface_v6_interface zxdg_surface_v6_implementation = { static bool wlr_xdg_surface_v6_toplevel_state_compare( struct wlr_xdg_toplevel_v6 *state) { + struct { + struct wlr_xdg_toplevel_v6_state state; + uint32_t width; + uint32_t height; + + } configured; + // is pending state different from current state? if (!state->base->configured) { return false; } - if (!wl_list_empty(&state->base->configure_list)) { - return false; + if (wl_list_empty(&state->base->configure_list)) { + // last configure is actually the current state, just use it + configured.state = state->current; + configured.width = state->base->surface->current->width; + configured.height = state->base->surface->current->width; + } else { + struct wlr_xdg_surface_v6_configure *configure = + wl_container_of(state->base->configure_list.prev, configure, link); + configured.state = configure->state; + configured.width = configure->state.width; + configured.height = configure->state.height; } - if (state->pending.activated != state->current.activated) { + if (state->pending.activated != configured.state.activated) { return false; } - if (state->pending.fullscreen != state->current.fullscreen) { + if (state->pending.fullscreen != configured.state.fullscreen) { return false; } - if (state->pending.maximized != state->current.maximized) { + if (state->pending.maximized != configured.state.maximized) { return false; } - if (state->pending.resizing != state->current.resizing) { + if (state->pending.resizing != configured.state.resizing) { return false; } - if ((uint32_t)state->base->geometry->width == state->pending.width && - (uint32_t)state->base->geometry->height == state->pending.height) { + if (state->pending.width == configured.width && + state->pending.height == configured.height) { return true; } -- cgit v1.2.3 From eaed6b6d294e82124cd4f7a70387f590e3910552 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Thu, 19 Oct 2017 12:57:45 -0400 Subject: wl-output: send layout position --- include/wlr/types/wlr_output.h | 4 ++++ types/wlr_output.c | 16 +++++++++++++++- types/wlr_output_layout.c | 4 ++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index dc637e26..312b51f8 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -56,6 +56,9 @@ struct wlr_output { struct wl_listener surface_destroy; } cursor; + // the output position in layout space reported to clients + int32_t lx, ly; + void *data; }; @@ -66,6 +69,7 @@ bool wlr_output_set_mode(struct wlr_output *output, struct wlr_output_mode *mode); void wlr_output_transform(struct wlr_output *output, enum wl_output_transform transform); +void wlr_output_set_position(struct wlr_output *output, int32_t lx, int32_t ly); bool wlr_output_set_cursor(struct wlr_output *output, const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height, int32_t hotspot_x, int32_t hotspot_y); diff --git a/types/wlr_output.c b/types/wlr_output.c index eb969b9a..5e10509e 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -21,7 +21,7 @@ static void wl_output_send_to_resource(struct wl_resource *resource) { assert(output); const uint32_t version = wl_resource_get_version(resource); if (version >= WL_OUTPUT_GEOMETRY_SINCE_VERSION) { - wl_output_send_geometry(resource, 0, 0, // TODO: get position from layout? + wl_output_send_geometry(resource, output->lx, output->ly, output->phys_width, output->phys_height, output->subpixel, output->make, output->model, output->transform); } @@ -122,6 +122,20 @@ void wlr_output_transform(struct wlr_output *output, wlr_output_update_matrix(output); } +void wlr_output_set_position(struct wlr_output *output, int32_t lx, int32_t ly) { + if (lx == output->lx && ly == output->ly) { + return; + } + + output->lx = lx; + output->ly = ly; + + struct wl_resource *resource; + wl_resource_for_each(resource, &output->wl_resources) { + wl_output_send_to_resource(resource); + } +} + static bool set_cursor(struct wlr_output *output, const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height, int32_t hotspot_x, int32_t hotspot_y) { diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index 8c3f1d88..8a50e331 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -115,6 +115,10 @@ static void wlr_output_layout_reconfigure(struct wlr_output_layout *layout) { max_x += box->width; } + wl_list_for_each(l_output, &layout->outputs, link) { + wlr_output_set_position(l_output->output, l_output->x, l_output->y); + } + wl_signal_emit(&layout->events.change, layout); } -- cgit v1.2.3 From 8c759d7abe4ea732fddb2f258d318b32591d1e73 Mon Sep 17 00:00:00 2001 From: "D.B" Date: Fri, 20 Oct 2017 17:49:04 +0200 Subject: Add startup command option to rootston Allows specifying a command to run at startup. --- include/rootston/config.h | 1 + rootston/config.c | 10 +++++++--- rootston/main.c | 13 +++++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/include/rootston/config.h b/include/rootston/config.h index 66347c3c..5fa4890f 100644 --- a/include/rootston/config.h +++ b/include/rootston/config.h @@ -42,6 +42,7 @@ struct roots_config { struct wl_list devices; struct wl_list bindings; char *config_path; + char *startup_cmd; }; struct roots_config *parse_args(int argc, char *argv[]); diff --git a/rootston/config.c b/rootston/config.c index 5ed299a7..71a4731b 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -16,12 +16,13 @@ static void usage(const char *name, int ret) { fprintf(stderr, - "usage: %s [-C ]\n" + "usage: %s [-C ] [-E ]\n" "\n" " -C Path to the configuration file\n" " (default: rootston.ini).\n" " See `rootston.ini.example` for config\n" - " file documentation.\n", name); + " file documentation.\n" + " -E Command that will be ran at startup.\n" , name); exit(ret); } @@ -273,11 +274,14 @@ struct roots_config *parse_args(int argc, char *argv[]) { wl_list_init(&config->bindings); int c; - while ((c = getopt(argc, argv, "C:h")) != -1) { + while ((c = getopt(argc, argv, "C:E:h")) != -1) { switch (c) { case 'C': config->config_path = strdup(optarg); break; + case 'E': + config->startup_cmd = strdup(optarg); + break; case 'h': case '?': usage(argv[0], c != 'h'); diff --git a/rootston/main.c b/rootston/main.c index 5a60000c..b80c2efd 100644 --- a/rootston/main.c +++ b/rootston/main.c @@ -1,6 +1,7 @@ #define _POSIX_C_SOURCE 200112L #include #include +#include #include #include #include @@ -42,6 +43,18 @@ int main(int argc, char **argv) { } setenv("WAYLAND_DISPLAY", socket, true); + + if (server.config->startup_cmd != NULL) { + const char *cmd = server.config->startup_cmd; + pid_t pid = fork(); + if (pid < 0) { + wlr_log(L_ERROR, "cannot execute binding command: fork() failed"); + return 1; + } else if (pid == 0) { + execl("/bin/sh", "/bin/sh", "-c", cmd, (void *)NULL); + } + } + wl_display_run(server.wl_display); wlr_backend_destroy(server.backend); return 0; -- cgit v1.2.3 From 1782d5e7b7dc5e494cfee72b758d5fa8114aecc8 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 20 Oct 2017 23:19:41 -0400 Subject: Implement simple touch support for rootston --- include/rootston/input.h | 22 ++++++++++----- rootston/cursor.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++-- rootston/input.c | 4 +-- rootston/meson.build | 1 + rootston/touch.c | 26 ++++++++++++++++++ 5 files changed, 113 insertions(+), 10 deletions(-) create mode 100644 rootston/touch.c diff --git a/include/rootston/input.h b/include/rootston/input.h index 516104a7..ddd5a05d 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -24,18 +24,12 @@ struct roots_keyboard { struct roots_pointer { struct roots_input *input; struct wlr_input_device *device; - // We don't listen to any pointer events directly - they go through - // wlr_cursor struct wl_list link; }; struct roots_touch { struct roots_input *input; struct wlr_input_device *device; - struct wl_listener down; - struct wl_listener up; - struct wl_listener motion; - struct wl_listener cancel; struct wl_list link; }; @@ -70,6 +64,13 @@ struct roots_input_event { struct wlr_input_device *device; }; +struct roots_touch_point { + struct roots_touch *device; + int32_t slot; + double x, y; + struct wl_list link; +}; + struct roots_input { struct roots_config *config; struct roots_server *server; @@ -104,9 +105,16 @@ struct roots_input { struct wl_listener cursor_motion_absolute; struct wl_listener cursor_button; struct wl_listener cursor_axis; + + struct wl_listener cursor_touch_down; + struct wl_listener cursor_touch_up; + struct wl_listener cursor_touch_motion; + struct wl_listener cursor_tool_axis; struct wl_listener cursor_tool_tip; + struct wl_list touch_points; + struct wl_listener pointer_grab_end; struct wl_listener request_set_cursor; @@ -120,6 +128,8 @@ void pointer_add(struct wlr_input_device *device, struct roots_input *input); void pointer_remove(struct wlr_input_device *device, struct roots_input *input); void keyboard_add(struct wlr_input_device *device, struct roots_input *input); void keyboard_remove(struct wlr_input_device *device, struct roots_input *input); +void touch_add(struct wlr_input_device *device, struct roots_input *input); +void touch_remove(struct wlr_input_device *device, struct roots_input *input); void tablet_tool_add(struct wlr_input_device *device, struct roots_input *input); void tablet_tool_remove(struct wlr_input_device *device, struct roots_input *input); diff --git a/rootston/cursor.c b/rootston/cursor.c index b312392d..27a6006b 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -1,4 +1,5 @@ #define _XOPEN_SOURCE 700 +#include #include #include #include @@ -82,8 +83,8 @@ void cursor_update_position(struct roots_input *input, uint32_t time) { double sx, sy; switch (input->mode) { case ROOTS_CURSOR_PASSTHROUGH: - view = view_at(desktop, input->cursor->x, input->cursor->y, &surface, - &sx, &sy); + view = view_at(desktop, input->cursor->x, input->cursor->y, + &surface, &sx, &sy); bool set_compositor_cursor = !view && input->cursor_client; if (view) { struct wl_client *view_client = @@ -286,6 +287,56 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { (uint32_t)(event->time_usec / 1000), event->button, event->state); } +static void handle_touch_down(struct wl_listener *listener, void *data) { + struct wlr_event_touch_down *event = data; + struct roots_input *input = + wl_container_of(listener, input, cursor_touch_down); + struct roots_touch_point *point = + calloc(1, sizeof(struct roots_touch_point)); + point->device = event->device->data; + point->slot = event->slot; + point->x = event->x_mm / event->width_mm; + point->y = event->y_mm / event->height_mm; + wlr_cursor_warp_absolute(input->cursor, event->device, point->x, point->y); + cursor_update_position(input, (uint32_t)(event->time_usec / 1000)); + wl_list_insert(&input->touch_points, &point->link); + do_cursor_button_press(input, input->cursor, event->device, + (uint32_t)(event->time_usec / 1000), BTN_LEFT, 1); +} + +static void handle_touch_up(struct wl_listener *listener, void *data) { + struct wlr_event_touch_up *event = data; + struct roots_input *input = + wl_container_of(listener, input, cursor_touch_up); + struct roots_touch_point *point; + wl_list_for_each(point, &input->touch_points, link) { + if (point->slot == event->slot) { + wl_list_remove(&point->link); + break; + } + } + do_cursor_button_press(input, input->cursor, event->device, + (uint32_t)(event->time_usec / 1000), BTN_LEFT, 0); +} + +static void handle_touch_motion(struct wl_listener *listener, void *data) { + struct wlr_event_touch_motion *event = data; + struct roots_input *input = + wl_container_of(listener, input, cursor_touch_motion); + struct roots_touch_point *point; + wl_list_for_each(point, &input->touch_points, link) { + if (point->slot == event->slot) { + point->x = event->x_mm / event->width_mm; + point->y = event->y_mm / event->height_mm; + wlr_cursor_warp_absolute(input->cursor, event->device, + point->x, point->y); + cursor_update_position(input, + (uint32_t)(event->time_usec / 1000)); + break; + } + } +} + static void handle_tool_axis(struct wl_listener *listener, void *data) { struct roots_input *input = wl_container_of(listener, input, cursor_tool_axis); struct wlr_event_tablet_tool_axis *event = data; @@ -342,6 +393,9 @@ static void handle_request_set_cursor(struct wl_listener *listener, void cursor_initialize(struct roots_input *input) { struct wlr_cursor *cursor = input->cursor; + + // TODO: Does this belong here + wl_list_init(&input->touch_points); wl_list_init(&input->cursor_motion.link); wl_signal_add(&cursor->events.motion, &input->cursor_motion); @@ -360,6 +414,18 @@ void cursor_initialize(struct roots_input *input) { wl_signal_add(&cursor->events.axis, &input->cursor_axis); input->cursor_axis.notify = handle_cursor_axis; + wl_list_init(&input->cursor_touch_down.link); + wl_signal_add(&cursor->events.touch_down, &input->cursor_touch_down); + input->cursor_touch_down.notify = handle_touch_down; + + wl_list_init(&input->cursor_touch_up.link); + wl_signal_add(&cursor->events.touch_up, &input->cursor_touch_up); + input->cursor_touch_up.notify = handle_touch_up; + + wl_list_init(&input->cursor_touch_motion.link); + wl_signal_add(&cursor->events.touch_motion, &input->cursor_touch_motion); + input->cursor_touch_motion.notify = handle_touch_motion; + wl_list_init(&input->cursor_tool_axis.link); wl_signal_add(&cursor->events.tablet_tool_axis, &input->cursor_tool_axis); input->cursor_tool_axis.notify = handle_tool_axis; diff --git a/rootston/input.c b/rootston/input.c index 86a87e24..1784040c 100644 --- a/rootston/input.c +++ b/rootston/input.c @@ -37,7 +37,7 @@ static void input_add_notify(struct wl_listener *listener, void *data) { pointer_add(device, input); break; case WLR_INPUT_DEVICE_TOUCH: - //touch_add(device, input); + touch_add(device, input); break; case WLR_INPUT_DEVICE_TABLET_TOOL: tablet_tool_add(device, input); @@ -58,7 +58,7 @@ static void input_remove_notify(struct wl_listener *listener, void *data) { pointer_remove(device, input); break; case WLR_INPUT_DEVICE_TOUCH: - //touch_remove(device, input); + touch_remove(device, input); break; case WLR_INPUT_DEVICE_TABLET_TOOL: tablet_tool_remove(device, input); diff --git a/rootston/meson.build b/rootston/meson.build index 7ff79f8e..f2621450 100644 --- a/rootston/meson.build +++ b/rootston/meson.build @@ -9,6 +9,7 @@ sources = [ 'output.c', 'pointer.c', 'tablet_tool.c', + 'touch.c', 'xdg_shell_v6.c', 'wl_shell.c', ] diff --git a/rootston/touch.c b/rootston/touch.c new file mode 100644 index 00000000..f6d9b11a --- /dev/null +++ b/rootston/touch.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include "rootston/input.h" + +// TODO: we'll likely want touch events to both control the cursor *and* be +// submitted directly to the seat. + +void touch_add(struct wlr_input_device *device, struct roots_input *input) { + struct roots_touch *touch = calloc(sizeof(struct roots_touch), 1); + device->data = touch; + touch->device = device; + touch->input = input; + wl_list_insert(&input->touch, &touch->link); + wlr_cursor_attach_input_device(input->cursor, device); + cursor_load_config(input->server->config, input->cursor, + input, input->server->desktop); +} + +void touch_remove(struct wlr_input_device *device, struct roots_input *input) { + struct roots_touch *touch = device->data; + wlr_cursor_detach_input_device(input->cursor, device); + wl_list_remove(&touch->link); + free(touch); +} -- cgit v1.2.3 From c8570d0e426c60fb66fba4ccc8e74af73933e615 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 21 Oct 2017 12:35:51 +0200 Subject: Remove wl_list_init when using wl_signal_add --- backend/multi/backend.c | 5 ----- examples/pointer.c | 4 ++-- examples/shared.c | 19 ------------------- include/rootston/view.h | 7 ++----- rootston/cursor.c | 12 +----------- rootston/desktop.c | 7 +++---- rootston/input.c | 9 ++------- rootston/keyboard.c | 1 - rootston/output.c | 1 - rootston/wl_shell.c | 19 ++++++------------- rootston/xdg_shell_v6.c | 11 +---------- rootston/xwayland.c | 2 -- types/wlr_seat.c | 4 ---- 13 files changed, 17 insertions(+), 84 deletions(-) diff --git a/backend/multi/backend.c b/backend/multi/backend.c index 5f745c40..ae1d6803 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -130,11 +130,6 @@ void wlr_multi_backend_add(struct wlr_backend *_multi, sub->output_add.notify = output_add_reemit; sub->output_remove.notify = output_remove_reemit; - wl_list_init(&sub->input_add.link); - wl_list_init(&sub->input_remove.link); - wl_list_init(&sub->output_add.link); - wl_list_init(&sub->output_remove.link); - wl_signal_add(&backend->events.input_add, &sub->input_add); wl_signal_add(&backend->events.input_remove, &sub->input_remove); wl_signal_add(&backend->events.output_add, &sub->output_add); diff --git a/examples/pointer.c b/examples/pointer.c index 238be9b3..92faaf0c 100644 --- a/examples/pointer.c +++ b/examples/pointer.c @@ -284,7 +284,7 @@ int main(int argc, char *argv[]) { state.cursor_motion.notify = handle_cursor_motion; wl_signal_add(&state.cursor->events.motion_absolute, - &state.cursor_motion_absolute); + &state.cursor_motion_absolute); state.cursor_motion_absolute.notify = handle_cursor_motion_absolute; wl_signal_add(&state.cursor->events.button, &state.cursor_button); @@ -308,7 +308,7 @@ int main(int argc, char *argv[]) { // tool events wl_signal_add(&state.cursor->events.tablet_tool_axis, - &state.tablet_tool_axis); + &state.tablet_tool_axis); state.tablet_tool_axis.notify = handle_tablet_tool_axis; struct compositor_state compositor = { 0 }; diff --git a/examples/shared.c b/examples/shared.c index bb1d2737..1fdd5775 100644 --- a/examples/shared.c +++ b/examples/shared.c @@ -60,7 +60,6 @@ static void keyboard_add(struct wlr_input_device *device, struct compositor_stat struct keyboard_state *kbstate = calloc(sizeof(struct keyboard_state), 1); kbstate->device = device; kbstate->compositor = state; - wl_list_init(&kbstate->key.link); kbstate->key.notify = keyboard_key_notify; wl_signal_add(&device->keyboard->events.key, &kbstate->key); wl_list_insert(&state->keyboards, &kbstate->link); @@ -122,10 +121,6 @@ static void pointer_add(struct wlr_input_device *device, struct compositor_state struct pointer_state *pstate = calloc(sizeof(struct pointer_state), 1); pstate->device = device; pstate->compositor = state; - wl_list_init(&pstate->motion.link); - wl_list_init(&pstate->motion_absolute.link); - wl_list_init(&pstate->button.link); - wl_list_init(&pstate->axis.link); pstate->motion.notify = pointer_motion_notify; pstate->motion_absolute.notify = pointer_motion_absolute_notify; pstate->button.notify = pointer_button_notify; @@ -175,10 +170,6 @@ static void touch_add(struct wlr_input_device *device, struct compositor_state * struct touch_state *tstate = calloc(sizeof(struct touch_state), 1); tstate->device = device; tstate->compositor = state; - wl_list_init(&tstate->down.link); - wl_list_init(&tstate->motion.link); - wl_list_init(&tstate->up.link); - wl_list_init(&tstate->cancel.link); tstate->down.notify = touch_down_notify; tstate->motion.notify = touch_motion_notify; tstate->up.notify = touch_up_notify; @@ -219,10 +210,6 @@ static void tablet_tool_add(struct wlr_input_device *device, struct tablet_tool_state *tstate = calloc(sizeof(struct tablet_tool_state), 1); tstate->device = device; tstate->compositor = state; - wl_list_init(&tstate->axis.link); - wl_list_init(&tstate->proximity.link); - wl_list_init(&tstate->tip.link); - wl_list_init(&tstate->button.link); tstate->axis.notify = tablet_tool_axis_notify; tstate->proximity.notify = tablet_tool_proximity_notify; //tstate->tip.notify = tablet_tool_tip_notify; @@ -247,7 +234,6 @@ static void tablet_pad_add(struct wlr_input_device *device, struct tablet_pad_state *pstate = calloc(sizeof(struct tablet_pad_state), 1); pstate->device = device; pstate->compositor = state; - wl_list_init(&pstate->button.link); pstate->button.notify = tablet_pad_button_notify; wl_signal_add(&device->tablet_pad->events.button, &pstate->button); wl_list_insert(&state->tablet_pads, &pstate->link); @@ -436,7 +422,6 @@ static void output_add_notify(struct wl_listener *listener, void *data) { ostate->compositor = state; ostate->frame.notify = output_frame_notify; ostate->resolution.notify = output_resolution_notify; - wl_list_init(&ostate->frame.link); wl_signal_add(&output->events.frame, &ostate->frame); wl_signal_add(&output->events.resolution, &ostate->resolution); wl_list_insert(&state->outputs, &ostate->link); @@ -476,15 +461,11 @@ void compositor_init(struct compositor_state *state) { wl_list_init(&state->touch); wl_list_init(&state->tablet_tools); wl_list_init(&state->tablet_pads); - wl_list_init(&state->input_add.link); state->input_add.notify = input_add_notify; - wl_list_init(&state->input_remove.link); state->input_remove.notify = input_remove_notify; wl_list_init(&state->outputs); - wl_list_init(&state->output_add.link); state->output_add.notify = output_add_notify; - wl_list_init(&state->output_remove.link); state->output_remove.notify = output_remove_notify; struct wlr_backend *wlr = wlr_backend_autocreate(state->display); diff --git a/include/rootston/view.h b/include/rootston/view.h index ad722225..7d297329 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -8,13 +8,12 @@ struct roots_wl_shell_surface { struct roots_view *view; + // TODO: Maybe destroy listener should go in roots_view struct wl_listener destroy; struct wl_listener ping_timeout; struct wl_listener request_move; struct wl_listener request_resize; - struct wl_listener request_set_fullscreen; - struct wl_listener request_set_maximized; struct wl_listener surface_commit; }; @@ -25,15 +24,13 @@ struct roots_xdg_surface_v6 { // TODO: Maybe destroy listener should go in roots_view struct wl_listener commit; struct wl_listener destroy; - struct wl_listener ping_timeout; - struct wl_listener request_minimize; struct wl_listener request_move; struct wl_listener request_resize; - struct wl_listener request_show_window_menu; }; struct roots_xwayland_surface { struct roots_view *view; + // TODO: Maybe destroy listener should go in roots_view struct wl_listener destroy; struct wl_listener request_configure; diff --git a/rootston/cursor.c b/rootston/cursor.c index 27a6006b..3be4c2a6 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -393,51 +393,41 @@ static void handle_request_set_cursor(struct wl_listener *listener, void cursor_initialize(struct roots_input *input) { struct wlr_cursor *cursor = input->cursor; - + // TODO: Does this belong here wl_list_init(&input->touch_points); - wl_list_init(&input->cursor_motion.link); wl_signal_add(&cursor->events.motion, &input->cursor_motion); input->cursor_motion.notify = handle_cursor_motion; - wl_list_init(&input->cursor_motion_absolute.link); wl_signal_add(&cursor->events.motion_absolute, &input->cursor_motion_absolute); input->cursor_motion_absolute.notify = handle_cursor_motion_absolute; - wl_list_init(&input->cursor_button.link); wl_signal_add(&cursor->events.button, &input->cursor_button); input->cursor_button.notify = handle_cursor_button; - wl_list_init(&input->cursor_axis.link); wl_signal_add(&cursor->events.axis, &input->cursor_axis); input->cursor_axis.notify = handle_cursor_axis; - wl_list_init(&input->cursor_touch_down.link); wl_signal_add(&cursor->events.touch_down, &input->cursor_touch_down); input->cursor_touch_down.notify = handle_touch_down; - wl_list_init(&input->cursor_touch_up.link); wl_signal_add(&cursor->events.touch_up, &input->cursor_touch_up); input->cursor_touch_up.notify = handle_touch_up; - wl_list_init(&input->cursor_touch_motion.link); wl_signal_add(&cursor->events.touch_motion, &input->cursor_touch_motion); input->cursor_touch_motion.notify = handle_touch_motion; - wl_list_init(&input->cursor_tool_axis.link); wl_signal_add(&cursor->events.tablet_tool_axis, &input->cursor_tool_axis); input->cursor_tool_axis.notify = handle_tool_axis; - wl_list_init(&input->cursor_tool_tip.link); wl_signal_add(&cursor->events.tablet_tool_tip, &input->cursor_tool_tip); input->cursor_tool_tip.notify = handle_tool_tip; wl_signal_add(&input->wl_seat->events.pointer_grab_end, &input->pointer_grab_end); input->pointer_grab_end.notify = handle_pointer_grab_end; - wl_list_init(&input->request_set_cursor.link); wl_signal_add(&input->wl_seat->events.request_set_cursor, &input->request_set_cursor); input->request_set_cursor.notify = handle_request_set_cursor; diff --git a/rootston/desktop.c b/rootston/desktop.c index 641315a8..bf556131 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -203,16 +203,15 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, struct roots_desktop *desktop_create(struct roots_server *server, struct roots_config *config) { struct roots_desktop *desktop = calloc(1, sizeof(struct roots_desktop)); + assert(desktop); wlr_log(L_DEBUG, "Initializing roots desktop"); assert(desktop->views = list_create()); wl_list_init(&desktop->outputs); - wl_list_init(&desktop->output_add.link); - desktop->output_add.notify = output_add_notify; - wl_list_init(&desktop->output_remove.link); - desktop->output_remove.notify = output_remove_notify; + 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); diff --git a/rootston/input.c b/rootston/input.c index 1784040c..28af67a6 100644 --- a/rootston/input.c +++ b/rootston/input.c @@ -91,15 +91,10 @@ struct roots_input *input_create(struct roots_server *server, wl_list_init(&input->touch); wl_list_init(&input->tablet_tools); - wl_list_init(&input->input_add.link); input->input_add.notify = input_add_notify; - wl_list_init(&input->input_remove.link); + 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_add, - &input->input_add); - wl_signal_add(&server->backend->events.input_remove, - &input->input_remove); + wl_signal_add(&server->backend->events.input_remove, &input->input_remove); input->cursor = wlr_cursor_create(); cursor_initialize(input); diff --git a/rootston/keyboard.c b/rootston/keyboard.c index aee6b098..f2075d26 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -130,7 +130,6 @@ void keyboard_add(struct wlr_input_device *device, struct roots_input *input) { device->data = keyboard; keyboard->device = device; keyboard->input = input; - wl_list_init(&keyboard->key.link); keyboard->key.notify = keyboard_key_notify; wl_signal_add(&device->keyboard->events.key, &keyboard->key); wl_list_insert(&input->keyboards, &keyboard->link); diff --git a/rootston/output.c b/rootston/output.c index 39a90fe3..5b7297ae 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -175,7 +175,6 @@ void output_add_notify(struct wl_listener *listener, void *data) { output->desktop = desktop; output->wlr_output = wlr_output; output->frame.notify = output_frame_notify; - wl_list_init(&output->frame.link); wl_signal_add(&wlr_output->events.frame, &output->frame); wl_list_insert(&desktop->outputs, &output->link); diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index 2c6047b1..248514f0 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -57,11 +57,8 @@ static void handle_destroy(struct wl_listener *listener, void *data) { struct roots_wl_shell_surface *roots_surface = wl_container_of(listener, roots_surface, destroy); wl_list_remove(&roots_surface->destroy.link); - wl_list_remove(&roots_surface->ping_timeout.link); wl_list_remove(&roots_surface->request_move.link); wl_list_remove(&roots_surface->request_resize.link); - wl_list_remove(&roots_surface->request_set_fullscreen.link); - wl_list_remove(&roots_surface->request_set_maximized.link); view_destroy(roots_surface->view); free(roots_surface); } @@ -88,25 +85,22 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { if (!roots_surface) { return; } - wl_list_init(&roots_surface->destroy.link); roots_surface->destroy.notify = handle_destroy; wl_signal_add(&surface->events.destroy, &roots_surface->destroy); - wl_list_init(&roots_surface->ping_timeout.link); - wl_list_init(&roots_surface->request_move.link); roots_surface->request_move.notify = handle_request_move; wl_signal_add(&surface->events.request_move, &roots_surface->request_move); - wl_list_init(&roots_surface->request_resize.link); roots_surface->request_resize.notify = handle_request_resize; wl_signal_add(&surface->events.request_resize, &roots_surface->request_resize); - wl_list_init(&roots_surface->request_set_fullscreen.link); - wl_list_init(&roots_surface->request_set_maximized.link); - wl_list_init(&roots_surface->surface_commit.link); roots_surface->surface_commit.notify = handle_surface_commit; wl_signal_add(&surface->surface->events.commit, &roots_surface->surface_commit); struct roots_view *view = calloc(1, sizeof(struct roots_view)); + if (!view) { + free(roots_surface); + return; + } view->type = ROOTS_WL_SHELL_VIEW; view->wl_shell_surface = surface; @@ -121,9 +115,8 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) { // we need to map it relative to the parent - int i = - list_seq_find(desktop->views, - shell_surface_compare_equals, surface->parent); + int i = list_seq_find(desktop->views, shell_surface_compare_equals, + surface->parent); if (i != -1) { struct roots_view *parent = desktop->views->items[i]; view_set_position(view, diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c index 1e21fa02..028545df 100644 --- a/rootston/xdg_shell_v6.c +++ b/rootston/xdg_shell_v6.c @@ -74,12 +74,10 @@ static void handle_commit(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) { struct roots_xdg_surface_v6 *roots_xdg_surface = wl_container_of(listener, roots_xdg_surface, destroy); + wl_list_remove(&roots_xdg_surface->commit.link); wl_list_remove(&roots_xdg_surface->destroy.link); - wl_list_remove(&roots_xdg_surface->ping_timeout.link); wl_list_remove(&roots_xdg_surface->request_move.link); wl_list_remove(&roots_xdg_surface->request_resize.link); - wl_list_remove(&roots_xdg_surface->request_show_window_menu.link); - wl_list_remove(&roots_xdg_surface->request_minimize.link); view_destroy(roots_xdg_surface->view); free(roots_xdg_surface); } @@ -105,22 +103,15 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { if (!roots_surface) { return; } - wl_list_init(&roots_surface->commit.link); roots_surface->commit.notify = handle_commit; wl_signal_add(&surface->events.commit, &roots_surface->commit); - wl_list_init(&roots_surface->destroy.link); roots_surface->destroy.notify = handle_destroy; wl_signal_add(&surface->events.destroy, &roots_surface->destroy); - wl_list_init(&roots_surface->ping_timeout.link); - wl_list_init(&roots_surface->request_minimize.link); - wl_list_init(&roots_surface->request_move.link); roots_surface->request_move.notify = handle_request_move; wl_signal_add(&surface->events.request_move, &roots_surface->request_move); - wl_list_init(&roots_surface->request_resize.link); roots_surface->request_resize.notify = handle_request_resize; wl_signal_add(&surface->events.request_resize, &roots_surface->request_resize); - wl_list_init(&roots_surface->request_show_window_menu.link); struct roots_view *view = calloc(1, sizeof(struct roots_view)); view->type = ROOTS_XDG_SHELL_V6_VIEW; diff --git a/rootston/xwayland.c b/rootston/xwayland.c index d7885e94..6ef33403 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -75,10 +75,8 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { if (roots_surface == NULL) { return; } - wl_list_init(&roots_surface->destroy.link); roots_surface->destroy.notify = handle_destroy; wl_signal_add(&surface->events.destroy, &roots_surface->destroy); - wl_list_init(&roots_surface->request_configure.link); roots_surface->request_configure.notify = handle_request_configure; wl_signal_add(&surface->events.request_configure, &roots_surface->request_configure); diff --git a/types/wlr_seat.c b/types/wlr_seat.c index ce055520..362c696a 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -635,17 +635,13 @@ void wlr_seat_attach_keyboard(struct wlr_seat *seat, calloc(1, sizeof(struct wlr_seat_keyboard)); seat_kb->keyboard = kb; seat_kb->seat = seat; - wl_list_init(&seat_kb->key.link); seat_kb->key.notify = keyboard_key_notify; wl_signal_add(&kb->events.key, &seat_kb->key); - wl_list_init(&seat_kb->modifiers.link); seat_kb->modifiers.notify = keyboard_modifiers_notify; wl_signal_add(&kb->events.modifiers, &seat_kb->modifiers); - wl_list_init(&seat_kb->keymap.link); seat_kb->keymap.notify = keyboard_keymap_notify; wl_signal_add(&kb->events.keymap, &seat_kb->keymap); // TODO: update keymap as necessary - wl_list_init(&seat_kb->destroy.link); seat_kb->destroy.notify = keyboard_destroy_notify; wl_signal_add(&dev->events.destroy, &seat_kb->destroy); wl_list_insert(&seat->keyboards, &seat_kb->link); -- cgit v1.2.3 From f2c4b80620337e8533ce0986186cc914d45b6dce Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 21 Oct 2017 13:25:39 +0200 Subject: Remove calls to assert to check runtime errors in rootston --- rootston/desktop.c | 13 ++++++++++--- rootston/input.c | 27 +++++++++++++++++++++++---- rootston/keyboard.c | 13 ++++++++++--- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/rootston/desktop.c b/rootston/desktop.c index bf556131..70767f92 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -202,11 +202,18 @@ struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly, struct roots_desktop *desktop_create(struct roots_server *server, struct roots_config *config) { - struct roots_desktop *desktop = calloc(1, sizeof(struct roots_desktop)); - assert(desktop); wlr_log(L_DEBUG, "Initializing roots desktop"); - assert(desktop->views = list_create()); + struct roots_desktop *desktop = calloc(1, sizeof(struct roots_desktop)); + if (desktop == NULL) { + return NULL; + } + + desktop->views = list_create(); + if (desktop->views == NULL) { + free(desktop); + return NULL; + } wl_list_init(&desktop->outputs); desktop->output_add.notify = output_add_notify; diff --git a/rootston/input.c b/rootston/input.c index 28af67a6..5dc7d16d 100644 --- a/rootston/input.c +++ b/rootston/input.c @@ -74,15 +74,34 @@ struct roots_input *input_create(struct roots_server *server, assert(server->desktop); struct roots_input *input = calloc(1, sizeof(struct roots_input)); - assert(input); + if (input == NULL) { + return NULL; + } input->config = config; input->server = server; - assert(input->theme = wlr_xcursor_theme_load("default", 16)); - assert(input->xcursor = wlr_xcursor_theme_get_cursor(input->theme, "left_ptr")); + input->theme = wlr_xcursor_theme_load("default", 16); + if (input->theme == NULL) { + wlr_log(L_ERROR, "Cannot load xcursor theme"); + free(input); + return NULL; + } + input->xcursor = wlr_xcursor_theme_get_cursor(input->theme, "left_ptr"); + if (input->xcursor == NULL) { + wlr_log(L_ERROR, "Cannot load xcursor from theme"); + wlr_xcursor_theme_destroy(input->theme); + free(input); + return NULL; + } - assert(input->wl_seat = wlr_seat_create(server->wl_display, "seat0")); + input->wl_seat = wlr_seat_create(server->wl_display, "seat0"); + if (input->wl_seat == NULL) { + wlr_log(L_ERROR, "Cannot create seat"); + wlr_xcursor_theme_destroy(input->theme); + free(input); + return NULL; + } wlr_seat_set_capabilities(input->wl_seat, WL_SEAT_CAPABILITY_KEYBOARD | WL_SEAT_CAPABILITY_POINTER | WL_SEAT_CAPABILITY_TOUCH); diff --git a/rootston/keyboard.c b/rootston/keyboard.c index f2075d26..61604da0 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -127,6 +127,9 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) { void keyboard_add(struct wlr_input_device *device, struct roots_input *input) { struct roots_keyboard *keyboard = calloc(sizeof(struct roots_keyboard), 1); + if (keyboard == NULL) { + return; + } device->data = keyboard; keyboard->device = device; keyboard->input = input; @@ -141,11 +144,15 @@ void keyboard_add(struct wlr_input_device *device, struct roots_input *input) { rules.layout = getenv("XKB_DEFAULT_LAYOUT"); rules.variant = getenv("XKB_DEFAULT_VARIANT"); rules.options = getenv("XKB_DEFAULT_OPTIONS"); - struct xkb_context *context; - assert(context = xkb_context_new(XKB_CONTEXT_NO_FLAGS)); + struct xkb_context *context = xkb_context_new(XKB_CONTEXT_NO_FLAGS); + if (context == NULL) { + wlr_log(L_ERROR, "Cannot create XKB context"); + return; + } wlr_keyboard_set_keymap(device->keyboard, xkb_map_new_from_names(context, - &rules, XKB_KEYMAP_COMPILE_NO_FLAGS)); + &rules, XKB_KEYMAP_COMPILE_NO_FLAGS)); xkb_context_unref(context); + wlr_seat_attach_keyboard(input->wl_seat, device); } -- cgit v1.2.3 From 613c7929010560611894e7d583b7c4331cdaf61e Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 21 Oct 2017 14:31:54 +0100 Subject: Moved comments in rootston keybinding example config The comment strings are not stripped so the commands are not currently recognised. --- rootston/rootston.ini.example | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/rootston/rootston.ini.example b/rootston/rootston.ini.example index 4774108a..c33b0f04 100644 --- a/rootston/rootston.ini.example +++ b/rootston/rootston.ini.example @@ -34,8 +34,12 @@ meta-key = Logo # Keybindings # Maps key combinations with commands to execute -# Use the prefix "exec" to execute a shell command +# Commands include: +# - "exit" to stop the compositor +# - "exec" to execute a shell command +# - "close" to close the current view +# - "next_window" to cycle through windows [bindings] -Logo+Shift+e = exit # Stop the compositor -Logo+q = close # Close the current view -Alt+Tab = next_window # Cycle through windows +Logo+Shift+e = exit +Logo+q = close +Alt+Tab = next_window -- cgit v1.2.3 From 9b984253e2b878128d2042836a8c86228700b1ee Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Sat, 21 Oct 2017 14:48:58 +1300 Subject: Move egl.h to render/egl.h --- backend/drm/backend.c | 2 +- backend/drm/renderer.c | 2 +- backend/wayland/backend.c | 2 +- backend/x11/backend.c | 2 +- include/backend/drm/drm.h | 2 +- include/backend/wayland.h | 2 +- include/backend/x11.h | 2 +- include/render/gles2.h | 2 +- include/wlr/backend.h | 2 +- include/wlr/backend/interface.h | 2 +- include/wlr/egl.h | 66 ----------------------------------------- include/wlr/render/egl.h | 66 +++++++++++++++++++++++++++++++++++++++++ render/egl.c | 2 +- render/gles2/renderer.c | 2 +- render/gles2/texture.c | 2 +- types/wlr_surface.c | 2 +- 16 files changed, 80 insertions(+), 80 deletions(-) delete mode 100644 include/wlr/egl.h create mode 100644 include/wlr/render/egl.h diff --git a/backend/drm/backend.c b/backend/drm/backend.c index d7e2e616..ab66adf5 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include "backend/drm/drm.h" static bool wlr_drm_backend_start(struct wlr_backend *backend) { diff --git a/backend/drm/renderer.c b/backend/drm/renderer.c index 0d338490..d53acaa8 100644 --- a/backend/drm/renderer.c +++ b/backend/drm/renderer.c @@ -8,8 +8,8 @@ #include #include -#include #include +#include #include #include #include diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c index e57f3583..5018eeb0 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 11dd8568..4ecca325 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -15,7 +15,7 @@ #endif #include #include -#include +#include #include #include #include diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h index 6106a85a..7a0e43ea 100644 --- a/include/backend/drm/drm.h +++ b/include/backend/drm/drm.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include "iface.h" diff --git a/include/backend/wayland.h b/include/backend/wayland.h index 508a7f52..88aeabca 100644 --- a/include/backend/wayland.h +++ b/include/backend/wayland.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/backend/x11.h b/include/backend/x11.h index b4284b63..f5ec56bc 100644 --- a/include/backend/x11.h +++ b/include/backend/x11.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/render/gles2.h b/include/render/gles2.h index 688a51dd..0b7032cc 100644 --- a/include/render/gles2.h +++ b/include/render/gles2.h @@ -8,9 +8,9 @@ #include #include #include -#include #include #include +#include #include #include diff --git a/include/wlr/backend.h b/include/wlr/backend.h index 6c11152f..78d01edf 100644 --- a/include/wlr/backend.h +++ b/include/wlr/backend.h @@ -3,7 +3,7 @@ #include #include -#include +#include struct wlr_backend_impl; diff --git a/include/wlr/backend/interface.h b/include/wlr/backend/interface.h index ea41400a..3f0aaadb 100644 --- a/include/wlr/backend/interface.h +++ b/include/wlr/backend/interface.h @@ -3,7 +3,7 @@ #include #include -#include +#include struct wlr_backend_impl { bool (*start)(struct wlr_backend *backend); diff --git a/include/wlr/egl.h b/include/wlr/egl.h deleted file mode 100644 index 9ab4d9ce..00000000 --- a/include/wlr/egl.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef WLR_EGL_H -#define WLR_EGL_H - -#include -#include -#include - -struct wlr_egl { - EGLDisplay display; - EGLConfig config; - EGLContext context; - - const char *egl_exts; - const char *gl_exts; - - struct wl_display *wl_display; -}; - -// TODO: Allocate and return a wlr_egl -/** - * Initializes an egl context for the given platform and remote display. - * Will attempt to load all possibly required api functions. - */ -bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, EGLint visual_id, void *display); - -/** - * Frees all related egl resources, makes the context not-current and - * unbinds a bound wayland display. - */ -void wlr_egl_free(struct wlr_egl *egl); - -/** - * Binds the given display to the egl instance. - * This will allow clients to create egl surfaces from wayland ones and render to it. - */ -bool wlr_egl_bind_display(struct wlr_egl *egl, struct wl_display *local_display); - -/** - * Refer to the eglQueryWaylandBufferWL extension function. - */ -bool wlr_egl_query_buffer(struct wlr_egl *egl, struct wl_resource *buf, - EGLint attrib, EGLint *value); - -/** - * Returns a surface for the given native window - * The window must match the remote display the wlr_egl was created with. - */ -EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window); - -/** - * Creates an egl image from the given client buffer and attributes. - */ -EGLImageKHR wlr_egl_create_image(struct wlr_egl *egl, - EGLenum target, EGLClientBuffer buffer, const EGLint *attribs); - -/** - * Destroys an egl image created with the given wlr_egl. - */ -bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImageKHR image); - -/** - * Returns a string for the last error ocurred with egl. - */ -const char *egl_error(void); - -#endif diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h new file mode 100644 index 00000000..9ab4d9ce --- /dev/null +++ b/include/wlr/render/egl.h @@ -0,0 +1,66 @@ +#ifndef WLR_EGL_H +#define WLR_EGL_H + +#include +#include +#include + +struct wlr_egl { + EGLDisplay display; + EGLConfig config; + EGLContext context; + + const char *egl_exts; + const char *gl_exts; + + struct wl_display *wl_display; +}; + +// TODO: Allocate and return a wlr_egl +/** + * Initializes an egl context for the given platform and remote display. + * Will attempt to load all possibly required api functions. + */ +bool wlr_egl_init(struct wlr_egl *egl, EGLenum platform, EGLint visual_id, void *display); + +/** + * Frees all related egl resources, makes the context not-current and + * unbinds a bound wayland display. + */ +void wlr_egl_free(struct wlr_egl *egl); + +/** + * Binds the given display to the egl instance. + * This will allow clients to create egl surfaces from wayland ones and render to it. + */ +bool wlr_egl_bind_display(struct wlr_egl *egl, struct wl_display *local_display); + +/** + * Refer to the eglQueryWaylandBufferWL extension function. + */ +bool wlr_egl_query_buffer(struct wlr_egl *egl, struct wl_resource *buf, + EGLint attrib, EGLint *value); + +/** + * Returns a surface for the given native window + * The window must match the remote display the wlr_egl was created with. + */ +EGLSurface wlr_egl_create_surface(struct wlr_egl *egl, void *window); + +/** + * Creates an egl image from the given client buffer and attributes. + */ +EGLImageKHR wlr_egl_create_image(struct wlr_egl *egl, + EGLenum target, EGLClientBuffer buffer, const EGLint *attribs); + +/** + * Destroys an egl image created with the given wlr_egl. + */ +bool wlr_egl_destroy_image(struct wlr_egl *egl, EGLImageKHR image); + +/** + * Returns a string for the last error ocurred with egl. + */ +const char *egl_error(void); + +#endif diff --git a/render/egl.c b/render/egl.c index 9815b923..08612125 100644 --- a/render/egl.c +++ b/render/egl.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include "render/glapi.h" // Extension documentation diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index 94c50b9a..cf4a0aab 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -5,9 +5,9 @@ #include #include #include -#include #include #include +#include #include #include #include diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 5e934aa4..ff71cb08 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -5,8 +5,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 9e38d701..68c21468 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -2,9 +2,9 @@ #include #include #include -#include #include #include +#include #include static void wlr_surface_state_reset_buffer(struct wlr_surface_state *state) { -- cgit v1.2.3 From 4ea84c5765b138153aa313f23288935192b75c42 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Sat, 21 Oct 2017 17:35:37 +1300 Subject: Remove unnecesary wlr_renderers --- backend/drm/drm.c | 12 ++---------- include/backend/drm/drm.h | 1 - 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index ff4dc7f6..0e898d3f 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -177,9 +177,6 @@ void wlr_drm_resources_free(struct wlr_drm_backend *drm) { if (plane->wlr_tex) { wlr_texture_destroy(plane->wlr_tex); } - if (plane->wlr_rend) { - wlr_renderer_destroy(plane->wlr_rend); - } } free(drm->crtcs); @@ -525,12 +522,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, // TODO the image needs to be rotated depending on the output rotation - plane->wlr_rend = wlr_gles2_renderer_create(&drm->backend); - if (!plane->wlr_rend) { - return false; - } - - plane->wlr_tex = wlr_render_texture_create(plane->wlr_rend); + plane->wlr_tex = wlr_render_texture_create(plane->surf.renderer->wlr_rend); if (!plane->wlr_tex) { return false; } @@ -595,7 +587,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, float matrix[16]; wlr_texture_get_matrix(plane->wlr_tex, &matrix, &plane->matrix, 0, 0); - wlr_render_with_matrix(plane->wlr_rend, plane->wlr_tex, &matrix); + wlr_render_with_matrix(plane->surf.renderer->wlr_rend, plane->wlr_tex, &matrix); glFinish(); glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, bo_stride); diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h index 7a0e43ea..2ef3cf92 100644 --- a/include/backend/drm/drm.h +++ b/include/backend/drm/drm.h @@ -30,7 +30,6 @@ struct wlr_drm_plane { // Only used by cursor float matrix[16]; - struct wlr_renderer *wlr_rend; struct wlr_texture *wlr_tex; struct gbm_bo *cursor_bo; -- cgit v1.2.3 From 822a9f65a4f965a7561de287013c2a5c159453ab Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Sat, 21 Oct 2017 17:37:25 +1300 Subject: Add pointer to backend inside wlr_output --- backend/drm/drm.c | 2 +- backend/wayland/output.c | 2 +- backend/x11/backend.c | 2 +- include/wlr/interfaces/wlr_output.h | 6 ++++-- include/wlr/types/wlr_output.h | 4 +++- types/wlr_output.c | 3 ++- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 0e898d3f..b3057166 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -707,7 +707,7 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) { drmModeFreeConnector(drm_conn); continue; } - wlr_output_init(&wlr_conn->output, &output_impl); + wlr_output_init(&wlr_conn->output, &drm->backend, &output_impl); struct wl_event_loop *ev = wl_display_get_event_loop(drm->display); wlr_conn->retry_pageflip = wl_event_loop_add_timer(ev, retry_pageflip, diff --git a/backend/wayland/output.c b/backend/wayland/output.c index e1138ee1..0216823e 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -241,7 +241,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) { wlr_log(L_ERROR, "Failed to allocate wlr_wl_backend_output"); return NULL; } - wlr_output_init(&output->wlr_output, &output_impl); + wlr_output_init(&output->wlr_output, &backend->backend, &output_impl); struct wlr_output *wlr_output = &output->wlr_output; wlr_output->width = 640; diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 4ecca325..d30ec376 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -264,7 +264,7 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) { output->x11 = x11; - wlr_output_init(&output->wlr_output, &output_impl); + wlr_output_init(&output->wlr_output, &x11->backend, &output_impl); snprintf(output->wlr_output.name, sizeof(output->wlr_output.name), "X11-1"); output->win = xcb_generate_id(x11->xcb_conn); diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h index b7927569..17dd5538 100644 --- a/include/wlr/interfaces/wlr_output.h +++ b/include/wlr/interfaces/wlr_output.h @@ -1,8 +1,9 @@ #ifndef WLR_INTERFACES_WLR_OUTPUT_H #define WLR_INTERFACES_WLR_OUTPUT_H -#include #include +#include +#include struct wlr_output_impl { void (*enable)(struct wlr_output *output, bool enable); @@ -21,7 +22,8 @@ struct wlr_output_impl { uint16_t (*get_gamma_size)(struct wlr_output *output); }; -void wlr_output_init(struct wlr_output *output, const struct wlr_output_impl *impl); +void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, + const struct wlr_output_impl *impl); void wlr_output_free(struct wlr_output *output); void wlr_output_update_matrix(struct wlr_output *output); struct wl_global *wlr_output_create_global( diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 312b51f8..a2d595ea 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -1,9 +1,10 @@ #ifndef WLR_TYPES_WLR_OUTPUT_H #define WLR_TYPES_WLR_OUTPUT_H +#include #include +#include #include -#include struct wlr_output_mode { uint32_t flags; // enum wl_output_mode @@ -15,6 +16,7 @@ struct wlr_output_impl; struct wlr_output { const struct wlr_output_impl *impl; + struct wlr_backend *backend; struct wl_global *wl_global; struct wl_list wl_resources; diff --git a/types/wlr_output.c b/types/wlr_output.c index 5e10509e..c89c5c45 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -307,8 +307,9 @@ bool wlr_output_move_cursor(struct wlr_output *output, int x, int y) { return output->impl->move_cursor(output, x, y); } -void wlr_output_init(struct wlr_output *output, +void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, const struct wlr_output_impl *impl) { + output->backend = backend; output->impl = impl; output->modes = list_create(); output->transform = WL_OUTPUT_TRANSFORM_NORMAL; -- cgit v1.2.3 From bdeffad7e5cacd2d1e27ddc0d44b3d9e2c19587d Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Sat, 21 Oct 2017 17:44:49 +1300 Subject: Remove drm field from wlr_drm_connector --- backend/drm/drm.c | 20 ++++++++++---------- include/backend/drm/drm.h | 1 - 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index b3057166..04d7ea77 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -190,7 +190,7 @@ static void wlr_drm_connector_make_current(struct wlr_output *output) { static void wlr_drm_connector_swap_buffers(struct wlr_output *output) { struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output; - struct wlr_drm_backend *drm = conn->drm; + struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend; struct wlr_drm_crtc *crtc = conn->crtc; struct wlr_drm_plane *plane = crtc->primary; @@ -213,7 +213,8 @@ static void wlr_drm_connector_swap_buffers(struct wlr_output *output) { static void wlr_drm_connector_set_gamma(struct wlr_output *output, uint16_t size, uint16_t *r, uint16_t *g, uint16_t *b) { struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output; - drmModeCrtcSetGamma(conn->drm->fd, conn->crtc->id, size, r, g, b); + struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend; + drmModeCrtcSetGamma(drm->fd, conn->crtc->id, size, r, g, b); } static uint16_t wlr_drm_connector_get_gamma_size(struct wlr_output *output) { @@ -227,7 +228,7 @@ void wlr_drm_connector_start_renderer(struct wlr_drm_connector *conn) { return; } - struct wlr_drm_backend *drm = conn->drm; + struct wlr_drm_backend *drm = (struct wlr_drm_backend *)conn->output.backend; struct wlr_drm_crtc *crtc = conn->crtc; struct wlr_drm_plane *plane = crtc->primary; @@ -250,7 +251,7 @@ static void wlr_drm_connector_enable(struct wlr_output *output, bool enable) { return; } - struct wlr_drm_backend *drm = conn->drm; + struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend; drm->iface->conn_enable(drm, conn, enable); if (enable) { @@ -403,7 +404,7 @@ error_conn: static bool wlr_drm_connector_set_mode(struct wlr_output *output, struct wlr_output_mode *mode) { struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output; - struct wlr_drm_backend *drm = conn->drm; + struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend; wlr_log(L_INFO, "Modesetting '%s' with '%ux%u@%u mHz'", conn->output.name, mode->width, mode->height, mode->refresh); @@ -469,7 +470,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height, int32_t hotspot_x, int32_t hotspot_y, bool update_pixels) { struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output; - struct wlr_drm_backend *drm = conn->drm; + struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend; struct wlr_drm_renderer *renderer = &drm->renderer; struct wlr_drm_crtc *crtc = conn->crtc; @@ -604,7 +605,7 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, static bool wlr_drm_connector_move_cursor(struct wlr_output *output, int x, int y) { struct wlr_drm_connector *conn = (struct wlr_drm_connector *)output; - struct wlr_drm_backend *drm = conn->drm; + struct wlr_drm_backend *drm = (struct wlr_drm_backend *)output->backend; int width, height, tmp; wlr_output_effective_resolution(output, &width, &height); @@ -714,7 +715,6 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) { wlr_conn); - wlr_conn->drm = drm; wlr_conn->state = WLR_DRM_CONN_DISCONNECTED; wlr_conn->id = drm_conn->connector_id; @@ -820,7 +820,7 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) { static void page_flip_handler(int fd, unsigned seq, unsigned tv_sec, unsigned tv_usec, void *user) { struct wlr_drm_connector *conn = user; - struct wlr_drm_backend *drm = conn->drm; + struct wlr_drm_backend *drm = (struct wlr_drm_backend *)conn->output.backend; conn->pageflip_pending = false; if (conn->state != WLR_DRM_CONN_CONNECTED) { @@ -891,7 +891,7 @@ void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn) { return; } - struct wlr_drm_backend *drm = conn->drm; + struct wlr_drm_backend *drm = (struct wlr_drm_backend *)conn->output.backend; switch (conn->state) { case WLR_DRM_CONN_CONNECTED: diff --git a/include/backend/drm/drm.h b/include/backend/drm/drm.h index 2ef3cf92..b0f5838e 100644 --- a/include/backend/drm/drm.h +++ b/include/backend/drm/drm.h @@ -112,7 +112,6 @@ struct wlr_drm_mode { struct wlr_drm_connector { struct wlr_output output; - struct wlr_drm_backend *drm; enum wlr_drm_connector_state state; uint32_t id; -- cgit v1.2.3 From 37b8a096a9907ea9c9991750c75d9fb15e445681 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Sun, 22 Oct 2017 10:20:26 +1300 Subject: Pass backend to render --- render/gles2/renderer.c | 7 +++---- types/wlr_output.c | 3 +-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/render/gles2/renderer.c b/render/gles2/renderer.c index cf4a0aab..646d69ec 100644 --- a/render/gles2/renderer.c +++ b/render/gles2/renderer.c @@ -246,9 +246,8 @@ struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend) { return NULL; } wlr_renderer_init(&renderer->wlr_renderer, &wlr_renderer_impl); - if (backend) { - struct wlr_egl *egl = wlr_backend_get_egl(backend); - renderer->egl = egl; - } + + renderer->egl = wlr_backend_get_egl(backend); + return &renderer->wlr_renderer; } diff --git a/types/wlr_output.c b/types/wlr_output.c index c89c5c45..03cff0bb 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -153,8 +153,7 @@ static bool set_cursor(struct wlr_output *output, const uint8_t *buf, output->cursor.height = height; if (!output->cursor.renderer) { - /* NULL egl is okay given that we are only using pixel buffers */ - output->cursor.renderer = wlr_gles2_renderer_create(NULL); + output->cursor.renderer = wlr_gles2_renderer_create(output->backend); if (!output->cursor.renderer) { return false; } -- cgit v1.2.3 From b5ed6dd6fc53b7a686334838964046f0a3ad70fd Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 21 Oct 2017 23:05:55 +0100 Subject: Changed broken default rootston keybinding --- rootston/rootston.ini.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootston/rootston.ini.example b/rootston/rootston.ini.example index c33b0f04..433dc78f 100644 --- a/rootston/rootston.ini.example +++ b/rootston/rootston.ini.example @@ -40,6 +40,6 @@ meta-key = Logo # - "close" to close the current view # - "next_window" to cycle through windows [bindings] -Logo+Shift+e = exit +Logo+Shift+E = exit Logo+q = close Alt+Tab = next_window -- cgit v1.2.3 From 844f4387c73fe438d60344a85a7a74fe8f8e7687 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Sat, 21 Oct 2017 23:17:39 +0100 Subject: Fixed default keybinding in config.c --- rootston/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rootston/config.c b/rootston/config.c index 71a4731b..c9c892f9 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -306,7 +306,7 @@ struct roots_config *parse_args(int argc, char *argv[]) { if (result == -1) { wlr_log(L_DEBUG, "No config file found. Using sensible defaults."); config->keyboard.meta_key = WLR_MODIFIER_LOGO; - add_binding_config(&config->bindings, "Logo+Shift+e", "exit"); + add_binding_config(&config->bindings, "Logo+Shift+E", "exit"); add_binding_config(&config->bindings, "Ctrl+q", "close"); add_binding_config(&config->bindings, "Alt+Tab", "next_window"); } else if (result == -2) { -- cgit v1.2.3