From 6d8e1abfc0a266e8ff1a8c9ba1a004faeaac79d5 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 4 Nov 2017 01:35:12 -0400 Subject: Improve input sensitivity We now use doubles until the last minute, which makes it so we can move the pointer more precisely. This also includes a fix for tablet tools, which move absolutely and sometimes do not update the X or Y axis. --- backend/libinput/tablet_tool.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'backend') diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c index 3caaf3f7..3d5fafc3 100644 --- a/backend/libinput/tablet_tool.c +++ b/backend/libinput/tablet_tool.c @@ -70,6 +70,8 @@ void handle_tablet_tool_axis(struct libinput_event *event, wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_WHEEL; wlr_event.wheel_delta = libinput_event_tablet_tool_get_wheel_delta(tevent); } + wlr_log(L_DEBUG, "Tablet tool axis event %d @ %f,%f", + wlr_event.updated_axes, wlr_event.x_mm, wlr_event.y_mm); wl_signal_emit(&wlr_dev->tablet_tool->events.axis, &wlr_event); } -- cgit v1.2.3 From 2f6cfe4057fbef41977159e24fea0d19fbeeb052 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sat, 4 Nov 2017 11:47:34 -0400 Subject: Fix software cursors on scaled outputs There was an issue where it would only work within the boundaries of the unscaled resolution. --- backend/wayland/output.c | 2 +- types/wlr_output.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'backend') diff --git a/backend/wayland/output.c b/backend/wayland/output.c index 90f8b39a..c4301617 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -249,7 +249,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) { wlr_output_init(&output->wlr_output, &backend->backend, &output_impl); struct wlr_output *wlr_output = &output->wlr_output; - wlr_output_update_size(wlr_output, 640, 480); + wlr_output_update_size(wlr_output, 1280, 720); strncpy(wlr_output->make, "wayland", sizeof(wlr_output->make)); strncpy(wlr_output->model, "wayland", sizeof(wlr_output->model)); snprintf(wlr_output->name, sizeof(wlr_output->name), "WL-%d", diff --git a/types/wlr_output.c b/types/wlr_output.c index 3ad69ce3..df02afec 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -270,6 +270,8 @@ static void output_cursor_render(struct wlr_output_cursor *cursor) { output_box.x = output_box.y = 0; wlr_output_effective_resolution(cursor->output, &output_box.width, &output_box.height); + output_box.width *= cursor->output->scale; + output_box.height *= cursor->output->scale; struct wlr_box cursor_box; output_cursor_get_box(cursor, &cursor_box); @@ -476,7 +478,6 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, double x, double y) { x *= cursor->output->scale; y *= cursor->output->scale; - wlr_log(L_DEBUG, "Moving cursor to %f,%f", x, y); cursor->x = x; cursor->y = y; -- cgit v1.2.3 From 1cee782fec090a19a390aec96e88475303dacafc Mon Sep 17 00:00:00 2001 From: emersion Date: Sun, 5 Nov 2017 13:00:27 +0100 Subject: Fix pointer axis delta in Wayland backend --- backend/wayland/wl_seat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backend') diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c index deed215e..a2da8df5 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -90,7 +90,7 @@ static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer, struct wlr_event_pointer_axis wlr_event; wlr_event.device = dev; - wlr_event.delta = value; + wlr_event.delta = wl_fixed_to_double(value); wlr_event.orientation = axis; wlr_event.time_msec = time; wlr_event.source = wlr_wl_pointer->axis_source; -- cgit v1.2.3 From 5be11a5c95457c6d4f6cd9720162f962286c2258 Mon Sep 17 00:00:00 2001 From: Eric Molitor Date: Fri, 10 Nov 2017 15:12:00 +0000 Subject: Remove VLA from session.h VLAs are optional C11 features and not supported by C++. --- backend/session/session.c | 2 +- include/wlr/backend/session.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'backend') diff --git a/backend/session/session.c b/backend/session/session.c index b14ca4d0..760830c3 100644 --- a/backend/session/session.c +++ b/backend/session/session.c @@ -257,7 +257,7 @@ static size_t explicit_find_gpus(struct wlr_session *session, * If it's not found, it returns the first valid GPU it finds. */ size_t wlr_session_find_gpus(struct wlr_session *session, - size_t ret_len, int ret[static ret_len]) { + size_t ret_len, int *ret) { const char *explicit = getenv("WLR_DRM_DEVICES"); if (explicit) { return explicit_find_gpus(session, ret_len, ret, explicit); diff --git a/include/wlr/backend/session.h b/include/wlr/backend/session.h index 94002bc5..5c822ea9 100644 --- a/include/wlr/backend/session.h +++ b/include/wlr/backend/session.h @@ -79,6 +79,6 @@ void wlr_session_signal_add(struct wlr_session *session, int fd, bool wlr_session_change_vt(struct wlr_session *session, unsigned vt); size_t wlr_session_find_gpus(struct wlr_session *session, - size_t ret_len, int ret[static ret_len]); + size_t ret_len, int *ret); #endif -- cgit v1.2.3 From f092a379556ed3bbca2043445305eee28ab8c850 Mon Sep 17 00:00:00 2001 From: Stefano Ragni Date: Sat, 11 Nov 2017 00:45:52 +0100 Subject: Fix typos --- backend/session/logind.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'backend') diff --git a/backend/session/logind.c b/backend/session/logind.c index 42b48e94..daff75b6 100644 --- a/backend/session/logind.c +++ b/backend/session/logind.c @@ -123,7 +123,7 @@ static bool logind_change_vt(struct wlr_session *base, unsigned vt) { return ret >= 0; } -static bool find_sesion_path(struct logind_session *session) { +static bool find_session_path(struct logind_session *session) { int ret; sd_bus_message *msg = NULL; sd_bus_error error = SD_BUS_ERROR_NULL; @@ -303,7 +303,7 @@ static bool add_signal_matches(struct logind_session *session) { "member='%s'," "path='%s'"; - snprintf(str, sizeof(str), fmt, "Manager", "SesssionRemoved", "/org/freedesktop/login1"); + snprintf(str, sizeof(str), fmt, "Manager", "SessionRemoved", "/org/freedesktop/login1"); ret = sd_bus_add_match(session->bus, NULL, str, session_removed, session); if (ret < 0) { wlr_log(L_ERROR, "Failed to add D-Bus match: %s", strerror(-ret)); @@ -368,7 +368,7 @@ static struct wlr_session *logind_session_create(struct wl_display *disp) { goto error; } - if (!find_sesion_path(session)) { + if (!find_session_path(session)) { sd_bus_unref(session->bus); goto error; } -- cgit v1.2.3 From 09279b90a63c5fdb2e28a61f2dfc936285126177 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 11 Nov 2017 19:09:34 +0100 Subject: Add wlr_output.serial --- backend/drm/util.c | 9 ++++++++- include/wlr/types/wlr_output.h | 1 + rootston/output.c | 5 +++-- 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'backend') diff --git a/backend/drm/util.c b/backend/drm/util.c index 656c070a..c27d7b67 100644 --- a/backend/drm/util.c +++ b/backend/drm/util.c @@ -106,8 +106,15 @@ void parse_edid(struct wlr_output *restrict output, size_t len, const uint8_t *d if (nl) { *nl = '\0'; } + } else if (flag == 0 && data[i + 3] == 0xFF) { + sprintf(output->serial, "%.13s", &data[i + 5]); - break; + // Monitor serial numbers are terminated by newline if they're too + // short + char *nl = strchr(output->serial, '\n'); + if (nl) { + *nl = '\0'; + } } } } diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index df123639..cf000019 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -43,6 +43,7 @@ struct wlr_output { char name[16]; char make[48]; char model[16]; + char serial[16]; uint32_t scale; int32_t width, height; int32_t phys_width, phys_height; // mm diff --git a/rootston/output.c b/rootston/output.c index d853c45f..a929e6be 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -210,8 +210,9 @@ void output_add_notify(struct wl_listener *listener, void *data) { struct roots_config *config = desktop->config; wlr_log(L_DEBUG, "Output '%s' added", wlr_output->name); - wlr_log(L_DEBUG, "%s %s %"PRId32"mm x %"PRId32"mm", wlr_output->make, - wlr_output->model, wlr_output->phys_width, wlr_output->phys_height); + wlr_log(L_DEBUG, "%s %s %s %"PRId32"mm x %"PRId32"mm", wlr_output->make, + wlr_output->model, wlr_output->serial, wlr_output->phys_width, + wlr_output->phys_height); if (wl_list_length(&wlr_output->modes) > 0) { struct wlr_output_mode *mode = NULL; mode = wl_container_of((&wlr_output->modes)->prev, mode, link); -- cgit v1.2.3 From 73c48f2f35ffea2f4fb03f54e652559be4bfe658 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 16 Nov 2017 09:33:47 +0100 Subject: Terminate local display on remote Wayland display error --- backend/wayland/backend.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'backend') diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c index 532935b8..bfc73e05 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -12,10 +12,15 @@ #include "backend/wayland.h" #include "xdg-shell-unstable-v6-client-protocol.h" - static int dispatch_events(int fd, uint32_t mask, void *data) { struct wlr_wl_backend *backend = data; int count = 0; + + if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) { + wl_display_terminate(backend->local_display); + return 0; + } + if (mask & WL_EVENT_READABLE) { count = wl_display_dispatch(backend->remote_display); } -- cgit v1.2.3 From 7d847efe403c01a842a3e237b49249c95372d9de Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 16 Nov 2017 09:38:24 +0100 Subject: Terminate local display on remote X11 server error --- backend/wayland/backend.c | 7 +++---- backend/x11/backend.c | 10 ++++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'backend') diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c index bfc73e05..1801f3e0 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -41,7 +41,7 @@ static bool wlr_wl_backend_start(struct wlr_backend *_backend) { wlr_log(L_INFO, "Initializating wayland backend"); wlr_wl_registry_poll(backend); - if (!(backend->compositor) || (!(backend->shell))) { + if (!backend->compositor || !backend->shell) { wlr_log_errno(L_ERROR, "Could not obtain retrieve required globals"); return false; } @@ -54,10 +54,9 @@ static bool wlr_wl_backend_start(struct wlr_backend *_backend) { struct wl_event_loop *loop = wl_display_get_event_loop(backend->local_display); int fd = wl_display_get_fd(backend->remote_display); - int events = WL_EVENT_READABLE | WL_EVENT_ERROR | - WL_EVENT_HANGUP; + int events = WL_EVENT_READABLE | WL_EVENT_ERROR | WL_EVENT_HANGUP; backend->remote_display_src = wl_event_loop_add_fd(loop, fd, events, - dispatch_events, backend); + dispatch_events, backend); wl_event_source_check(backend->remote_display_src); return true; diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 97b0dd8c..b798daf6 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -155,9 +155,14 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e static int x11_event(int fd, uint32_t mask, void *data) { struct wlr_x11_backend *x11 = data; + + if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) { + wl_display_terminate(x11->wl_display); + return 0; + } + xcb_generic_event_t *e; bool quit = false; - while (!quit && (e = xcb_poll_for_event(x11->xcb_conn))) { quit = handle_x11_event(x11, e); free(e); @@ -205,7 +210,8 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display, int fd = xcb_get_file_descriptor(x11->xcb_conn); struct wl_event_loop *ev = wl_display_get_event_loop(display); - x11->event_source = wl_event_loop_add_fd(ev, fd, WL_EVENT_READABLE, x11_event, x11); + int events = WL_EVENT_READABLE | WL_EVENT_ERROR | WL_EVENT_HANGUP; + x11->event_source = wl_event_loop_add_fd(ev, fd, events, x11_event, x11); if (!x11->event_source) { wlr_log(L_ERROR, "Could not create event source"); goto error_x11; -- cgit v1.2.3 From bb79ada49f43be5417bdd55fda3a7cf07c2a69df Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 16 Nov 2017 10:30:54 +0100 Subject: Fix a bunch of mistakes detected with scan-build --- backend/libinput/events.c | 5 +++-- backend/session/session.c | 2 +- rootston/config.c | 2 +- rootston/cursor.c | 2 +- rootston/keyboard.c | 1 + rootston/seat.c | 1 - types/wlr_data_device.c | 5 ++++- types/wlr_keyboard.c | 5 ++++- types/wlr_screenshooter.c | 3 +++ types/wlr_wl_shell.c | 2 +- 10 files changed, 19 insertions(+), 9 deletions(-) (limited to 'backend') diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 5da45c67..3ca41124 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -66,10 +66,11 @@ static void handle_device_added(struct wlr_libinput_backend *backend, int product = libinput_device_get_id_product(libinput_dev); const char *name = libinput_device_get_name(libinput_dev); struct wl_list *wlr_devices = calloc(1, sizeof(struct wl_list)); - wl_list_init(wlr_devices); if (!wlr_devices) { - goto fail; + wlr_log(L_ERROR, "Allocation failed"); + return; } + wl_list_init(wlr_devices); wlr_log(L_DEBUG, "Added %s [%d:%d]", name, vendor, product); if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_KEYBOARD)) { diff --git a/backend/session/session.c b/backend/session/session.c index 760830c3..657558fd 100644 --- a/backend/session/session.c +++ b/backend/session/session.c @@ -249,7 +249,7 @@ static size_t explicit_find_gpus(struct wlr_session *session, } } while ((ptr = strtok_r(NULL, ":", &save))); - free(ptr); + free(gpus); return i; } diff --git a/rootston/config.c b/rootston/config.c index 7ffbb786..727b52d0 100644 --- a/rootston/config.c +++ b/rootston/config.c @@ -405,7 +405,7 @@ void roots_config_destroy(struct roots_config *config) { } struct roots_keyboard_config *kc, *ktmp = NULL; - wl_list_for_each_safe(kc, ktmp, &config->bindings, link) { + wl_list_for_each_safe(kc, ktmp, &config->keyboards, link) { free(kc->name); free(kc->rules); free(kc->model); diff --git a/rootston/cursor.c b/rootston/cursor.c index ecd5e9a0..5949a364 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -18,9 +18,9 @@ struct roots_cursor *roots_cursor_create(struct roots_seat *seat) { } cursor->cursor = wlr_cursor_create(); if (!cursor->cursor) { + free(cursor); return NULL; } - return cursor; } diff --git a/rootston/keyboard.c b/rootston/keyboard.c index c118e55c..fb648ae5 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -141,6 +141,7 @@ static bool keyboard_keysyms_xkb(struct roots_keyboard *keyboard, uint32_t consumed = xkb_state_key_get_consumed_mods2( keyboard->device->keyboard->xkb_state, keycode, XKB_CONSUMED_MODE_XKB); + // TODO: actually use this value modifiers = modifiers & ~consumed; bool handled = false; diff --git a/rootston/seat.c b/rootston/seat.c index 6d8dc749..1fa37c44 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -252,7 +252,6 @@ struct roots_seat *roots_seat_create(struct roots_input *input, char *name) { seat->seat = wlr_seat_create(input->server->wl_display, name); if (!seat->seat) { free(seat); - roots_cursor_destroy(seat->cursor); return NULL; } diff --git a/types/wlr_data_device.c b/types/wlr_data_device.c index df18317b..4d926236 100644 --- a/types/wlr_data_device.c +++ b/types/wlr_data_device.c @@ -636,7 +636,10 @@ static void data_device_start_drag(struct wl_client *client, if (!seat_client_start_drag(seat_client, source, icon)) { wl_resource_post_no_memory(device_resource); - } else { + return; + } + + if (source) { source->seat_client = seat_client; } } diff --git a/types/wlr_keyboard.c b/types/wlr_keyboard.c index 98ebeed5..c4f2ed52 100644 --- a/types/wlr_keyboard.c +++ b/types/wlr_keyboard.c @@ -105,7 +105,10 @@ void wlr_keyboard_init(struct wlr_keyboard *kb, } void wlr_keyboard_destroy(struct wlr_keyboard *kb) { - if (kb && kb->impl && kb->impl->destroy) { + if (kb == NULL) { + return; + } + if (kb->impl && kb->impl->destroy) { kb->impl->destroy(kb); } else { wl_list_remove(&kb->events.key.listener_list); diff --git a/types/wlr_screenshooter.c b/types/wlr_screenshooter.c index a78c7ad7..94b45384 100644 --- a/types/wlr_screenshooter.c +++ b/types/wlr_screenshooter.c @@ -85,6 +85,7 @@ static void screenshooter_shoot(struct wl_client *client, struct wlr_screenshot *screenshot = calloc(1, sizeof(struct wlr_screenshot)); if (!screenshot) { + free(pixels); wl_resource_post_no_memory(screenshooter_resource); return; } @@ -96,6 +97,7 @@ static void screenshooter_shoot(struct wl_client *client, wl_resource_get_version(screenshooter_resource), id); if (screenshot->resource == NULL) { free(screenshot); + free(pixels); wl_resource_post_no_memory(screenshooter_resource); return; } @@ -109,6 +111,7 @@ static void screenshooter_shoot(struct wl_client *client, if (!state) { wl_resource_destroy(screenshot->resource); free(screenshot); + free(pixels); wl_resource_post_no_memory(screenshooter_resource); return; } diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index 31032fef..abe967d7 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -347,7 +347,7 @@ static void shell_surface_protocol_set_popup(struct wl_client *client, transient_state->flags = flags; struct wlr_wl_shell_surface_popup_state *popup_state = - calloc(1, sizeof(struct wlr_wl_shell_surface_transient_state)); + calloc(1, sizeof(struct wlr_wl_shell_surface_popup_state)); if (popup_state == NULL) { free(transient_state); wl_client_post_no_memory(client); -- cgit v1.2.3