diff --git a/cage.c b/cage.c index 691024e..74fa6a7 100644 --- a/cage.c +++ b/cage.c @@ -33,8 +33,8 @@ #include #endif #include -#include #include +#include #include #if CAGE_HAS_XWAYLAND #include @@ -153,8 +153,8 @@ drop_permissions(void) } if (setuid(0) != -1) { - wlr_log(WLR_ERROR, "Unable to drop root (we shouldn't be able to " - "restore it after setuid), refusing to start"); + wlr_log(WLR_ERROR, + "Unable to drop root (we shouldn't be able to restore it after setuid), refusing to start"); return false; } @@ -180,7 +180,8 @@ handle_signal(int signal, void *data) static void usage(FILE *file, const char *cage) { - fprintf(file, "Usage: %s [OPTIONS] [--] APPLICATION\n" + fprintf(file, + "Usage: %s [OPTIONS] [--] APPLICATION\n" "\n" " -d\t Don't draw client side decorations, when possible\n" " -r\t Rotate the output 90 degrees clockwise, specify up to three times\n" @@ -383,10 +384,9 @@ main(int argc, char *argv[]) ret = 1; goto end; } - wlr_server_decoration_manager_set_default_mode(server_decoration_manager, - server.xdg_decoration ? - WLR_SERVER_DECORATION_MANAGER_MODE_SERVER : - WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT); + wlr_server_decoration_manager_set_default_mode( + server_decoration_manager, server.xdg_decoration ? WLR_SERVER_DECORATION_MANAGER_MODE_SERVER + : WLR_SERVER_DECORATION_MANAGER_MODE_CLIENT); export_dmabuf_manager = wlr_export_dmabuf_manager_v1_create(server.wl_display); if (!export_dmabuf_manager) { @@ -434,8 +434,7 @@ main(int argc, char *argv[]) } if (setenv("DISPLAY", xwayland->display_name, true) < 0) { - wlr_log_errno(WLR_ERROR, "Unable to set DISPLAY for XWayland.", - "Clients may not be able to connect"); + wlr_log_errno(WLR_ERROR, "Unable to set DISPLAY for XWayland. Clients may not be able to connect"); } else { wlr_log(WLR_DEBUG, "XWayland is running on display %s", xwayland->display_name); } @@ -443,12 +442,10 @@ main(int argc, char *argv[]) if (wlr_xcursor_manager_load(xcursor_manager, 1)) { wlr_log(WLR_ERROR, "Cannot load XWayland XCursor theme"); } - struct wlr_xcursor *xcursor = - wlr_xcursor_manager_get_xcursor(xcursor_manager, DEFAULT_XCURSOR, 1); + struct wlr_xcursor *xcursor = wlr_xcursor_manager_get_xcursor(xcursor_manager, DEFAULT_XCURSOR, 1); if (xcursor) { struct wlr_xcursor_image *image = xcursor->images[0]; - wlr_xwayland_set_cursor(xwayland, image->buffer, - image->width * 4, image->width, image->height, + wlr_xwayland_set_cursor(xwayland, image->buffer, image->width * 4, image->width, image->height, image->hotspot_x, image->hotspot_y); } #endif @@ -467,8 +464,7 @@ main(int argc, char *argv[]) } if (setenv("WAYLAND_DISPLAY", socket, true) < 0) { - wlr_log_errno(WLR_ERROR, "Unable to set WAYLAND_DISPLAY.", - "Clients may not be able to connect"); + wlr_log_errno(WLR_ERROR, "Unable to set WAYLAND_DISPLAY. Clients may not be able to connect"); } else { wlr_log(WLR_DEBUG, "Cage " CAGE_VERSION " is running on Wayland display %s", socket); } diff --git a/idle_inhibit_v1.c b/idle_inhibit_v1.c index 1d0e167..5aba865 100644 --- a/idle_inhibit_v1.c +++ b/idle_inhibit_v1.c @@ -1,6 +1,6 @@ /* * Cage: A Wayland kiosk. - * + * * Copyright (C) 2018-2019 Jente Hidskes * * See the LICENSE file accompanying this file. diff --git a/output.c b/output.c index 15773e2..1ce90b3 100644 --- a/output.c +++ b/output.c @@ -10,13 +10,13 @@ #define _POSIX_C_SOURCE 200112L #include "config.h" -#include #include #include #include #include #include +#include #if WLR_HAS_X11_BACKEND #include #endif @@ -91,9 +91,8 @@ output_for_each_surface_iterator(struct wlr_surface *surface, int sx, int sy, vo } void -output_surface_for_each_surface(struct cg_output *output, struct wlr_surface *surface, - double ox, double oy, cg_surface_iterator_func_t iterator, - void *user_data) +output_surface_for_each_surface(struct cg_output *output, struct wlr_surface *surface, double ox, double oy, + cg_surface_iterator_func_t iterator, void *user_data) { struct surface_iterator_data data = { .user_iterator = iterator, @@ -107,8 +106,8 @@ output_surface_for_each_surface(struct cg_output *output, struct wlr_surface *su } static void -output_view_for_each_surface(struct cg_output *output, struct cg_view *view, - cg_surface_iterator_func_t iterator, void *user_data) +output_view_for_each_surface(struct cg_output *output, struct cg_view *view, cg_surface_iterator_func_t iterator, + void *user_data) { struct surface_iterator_data data = { .user_iterator = iterator, @@ -123,8 +122,8 @@ output_view_for_each_surface(struct cg_output *output, struct cg_view *view, } void -output_view_for_each_popup(struct cg_output *output, struct cg_view *view, - cg_surface_iterator_func_t iterator, void *user_data) +output_view_for_each_popup(struct cg_output *output, struct cg_view *view, cg_surface_iterator_func_t iterator, + void *user_data) { struct surface_iterator_data data = { .user_iterator = iterator, @@ -148,8 +147,8 @@ output_drag_icons_for_each_surface(struct cg_output *output, struct wl_list *dra double ox = drag_icon->lx; double oy = drag_icon->ly; wlr_output_layout_output_coords(output->server->output_layout, output->wlr_output, &ox, &oy); - output_surface_for_each_surface(output, drag_icon->wlr_drag_icon->surface, - ox, oy, iterator, user_data); + output_surface_for_each_surface(output, drag_icon->wlr_drag_icon->surface, ox, oy, iterator, + user_data); } } } @@ -183,8 +182,7 @@ send_frame_done(struct cg_output *output, struct send_frame_done_data *data) } static void -count_surface_iterator(struct cg_output *output, struct wlr_surface *surface, - struct wlr_box *_box, void *data) +count_surface_iterator(struct cg_output *output, struct wlr_surface *surface, struct wlr_box *_box, void *data) { size_t *n = data; n++; @@ -229,7 +227,8 @@ scan_out_primary_view(struct cg_output *output) return false; } - if ((float) surface->current.scale != wlr_output->scale || surface->current.transform != wlr_output->transform) { + if ((float) surface->current.scale != wlr_output->scale || + surface->current.transform != wlr_output->transform) { return false; } @@ -260,8 +259,7 @@ damage_surface_iterator(struct cg_output *output, struct wlr_surface *surface, s /* When scaling up a surface it'll become blurry, so we need to expand the damage region. */ - wlr_region_expand(&damage, &damage, - ceil(wlr_output->scale) - surface->current.scale); + wlr_region_expand(&damage, &damage, ceil(wlr_output->scale) - surface->current.scale); } pixman_region32_translate(&damage, box->x, box->y); wlr_output_damage_add(output->damage, &damage); @@ -270,8 +268,7 @@ damage_surface_iterator(struct cg_output *output, struct wlr_surface *surface, s } void -output_damage_surface(struct cg_output *output, struct wlr_surface *surface, - double lx, double ly, bool whole) +output_damage_surface(struct cg_output *output, struct wlr_surface *surface, double lx, double ly, bool whole) { double ox = lx, oy = ly; wlr_output_layout_output_coords(output->server->output_layout, output->wlr_output, &ox, &oy); @@ -319,10 +316,10 @@ handle_output_damage_frame(struct wl_listener *listener, void *data) output_render(output, &damage); - damage_finish: +damage_finish: pixman_region32_fini(&damage); - frame_done: +frame_done: clock_gettime(CLOCK_MONOTONIC, &frame_data.when); send_frame_done(output, &frame_data); } @@ -439,8 +436,7 @@ handle_new_output(struct wl_listener *listener, void *data) } if (wlr_xcursor_manager_load(server->seat->xcursor_manager, wlr_output->scale)) { - wlr_log(WLR_ERROR, "Cannot load XCursor theme for output '%s' with scale %f", - wlr_output->name, + wlr_log(WLR_ERROR, "Cannot load XCursor theme for output '%s' with scale %f", wlr_output->name, wlr_output->scale); } diff --git a/output.h b/output.h index 9e6a0dd..687b45c 100644 --- a/output.h +++ b/output.h @@ -22,14 +22,16 @@ struct cg_output { struct wl_list link; // cg_server::outputs }; -typedef void (*cg_surface_iterator_func_t)(struct cg_output *output, struct wlr_surface *surface, struct wlr_box *box, void *user_data); +typedef void (*cg_surface_iterator_func_t)(struct cg_output *output, struct wlr_surface *surface, struct wlr_box *box, + void *user_data); void handle_new_output(struct wl_listener *listener, void *data); -void output_surface_for_each_surface(struct cg_output *output, struct wlr_surface *surface, - double ox, double oy, cg_surface_iterator_func_t iterator, +void output_surface_for_each_surface(struct cg_output *output, struct wlr_surface *surface, double ox, double oy, + cg_surface_iterator_func_t iterator, void *user_data); +void output_view_for_each_popup(struct cg_output *output, struct cg_view *view, cg_surface_iterator_func_t iterator, void *user_data); -void output_view_for_each_popup(struct cg_output *output, struct cg_view *view, cg_surface_iterator_func_t iterator, void *user_data); -void output_drag_icons_for_each_surface(struct cg_output *output, struct wl_list *drag_icons, cg_surface_iterator_func_t iterator, void *user_data); +void output_drag_icons_for_each_surface(struct cg_output *output, struct wl_list *drag_icons, + cg_surface_iterator_func_t iterator, void *user_data); void output_damage_surface(struct cg_output *output, struct wlr_surface *surface, double lx, double ly, bool whole); void output_set_window_title(struct cg_output *output, const char *title); diff --git a/render.c b/render.c index 2fd309a..c4b375e 100644 --- a/render.c +++ b/render.c @@ -49,9 +49,8 @@ struct render_data { }; static void -render_texture(struct wlr_output *wlr_output, pixman_region32_t *output_damage, - struct wlr_texture *texture, const struct wlr_box *box, - const float matrix[static 9]) +render_texture(struct wlr_output *wlr_output, pixman_region32_t *output_damage, struct wlr_texture *texture, + const struct wlr_box *box, const float matrix[static 9]) { struct wlr_renderer *renderer = wlr_backend_get_renderer(wlr_output->backend); @@ -70,13 +69,12 @@ render_texture(struct wlr_output *wlr_output, pixman_region32_t *output_damage, wlr_render_texture_with_matrix(renderer, texture, matrix, 1.0f); } - damage_finish: +damage_finish: pixman_region32_fini(&damage); } static void -render_surface_iterator(struct cg_output *output, struct wlr_surface *surface, - struct wlr_box *box, void *user_data) +render_surface_iterator(struct cg_output *output, struct wlr_surface *surface, struct wlr_box *box, void *user_data) { struct render_data *data = user_data; struct wlr_output *wlr_output = output->wlr_output; @@ -118,20 +116,17 @@ render_view_toplevels(struct cg_view *view, struct cg_output *output, pixman_reg double ox = view->lx; double oy = view->ly; wlr_output_layout_output_coords(output->server->output_layout, output->wlr_output, &ox, &oy); - output_surface_for_each_surface(output, view->wlr_surface, ox, oy, - render_surface_iterator, &data); + output_surface_for_each_surface(output, view->wlr_surface, ox, oy, render_surface_iterator, &data); } static void -render_popup_iterator(struct cg_output *output, struct wlr_surface *surface, - struct wlr_box *box, void *data) +render_popup_iterator(struct cg_output *output, struct wlr_surface *surface, struct wlr_box *box, void *data) { /* Render this popup's surface. */ render_surface_iterator(output, surface, box, data); /* Render this popup's child toplevels. */ - output_surface_for_each_surface(output, surface, box->x, box->y, - render_surface_iterator, data); + output_surface_for_each_surface(output, surface, box->x, box->y, render_surface_iterator, data); } static void @@ -189,7 +184,7 @@ output_render(struct cg_output *output, pixman_region32_t *damage) render_drag_icons(output, damage, &server->seat->drag_icons); - renderer_end: +renderer_end: /* Draw software cursor in case hardware cursors aren't available. This is a no-op when they are. */ wlr_output_render_software_cursors(wlr_output, damage); diff --git a/seat.c b/seat.c index f08cfae..9fc8f0b 100644 --- a/seat.c +++ b/seat.c @@ -8,8 +8,8 @@ #include "config.h" -#include #include +#include #include #include #include @@ -40,8 +40,7 @@ static void drag_icon_update_position(struct cg_drag_icon *drag_icon); * surface pointer to that wlr_surface and the sx and sy coordinates to the * coordinates relative to that surface's top-left corner. */ static bool -view_at(struct cg_view *view, double lx, double ly, - struct wlr_surface **surface, double *sx, double *sy) +view_at(struct cg_view *view, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { double view_sx = lx - view->lx; double view_sy = ly - view->ly; @@ -64,8 +63,7 @@ view_at(struct cg_view *view, double lx, double ly, * surface. There cannot be a surface without a view, either. It's * both or nothing. */ static struct cg_view * -desktop_view_at(struct cg_server *server, double lx, double ly, - struct wlr_surface **surface, double *sx, double *sy) +desktop_view_at(struct cg_server *server, double lx, double ly, struct wlr_surface **surface, double *sx, double *sy) { struct cg_view *view; @@ -79,17 +77,15 @@ desktop_view_at(struct cg_server *server, double lx, double ly, } static void -press_cursor_button(struct cg_seat *seat, struct wlr_input_device *device, - uint32_t time, uint32_t button, uint32_t state, - double lx, double ly) +press_cursor_button(struct cg_seat *seat, struct wlr_input_device *device, uint32_t time, uint32_t button, + uint32_t state, double lx, double ly) { struct cg_server *server = seat->server; if (state == WLR_BUTTON_PRESSED) { double sx, sy; struct wlr_surface *surface; - struct cg_view *view = desktop_view_at(server, lx, ly, - &surface, &sx, &sy); + struct cg_view *view = desktop_view_at(server, lx, ly, &surface, &sx, &sy); struct cg_view *current = seat_get_focus(seat); if (view == current) { return; @@ -104,7 +100,8 @@ press_cursor_button(struct cg_seat *seat, struct wlr_input_device *device, } static void -update_capabilities(struct cg_seat *seat) { +update_capabilities(struct cg_seat *seat) +{ uint32_t caps = 0; if (!wl_list_empty(&seat->keyboards)) { @@ -122,14 +119,13 @@ update_capabilities(struct cg_seat *seat) { if ((caps & WL_SEAT_CAPABILITY_POINTER) == 0) { wlr_cursor_set_image(seat->cursor, NULL, 0, 0, 0, 0, 0, 0); } else { - wlr_xcursor_manager_set_cursor_image(seat->xcursor_manager, - DEFAULT_XCURSOR, - seat->cursor); + wlr_xcursor_manager_set_cursor_image(seat->xcursor_manager, DEFAULT_XCURSOR, seat->cursor); } } static void -handle_touch_destroy(struct wl_listener *listener, void *data) { +handle_touch_destroy(struct wl_listener *listener, void *data) +{ struct cg_touch *touch = wl_container_of(listener, touch, destroy); struct cg_seat *seat = touch->seat; @@ -217,8 +213,7 @@ handle_keyboard_modifiers(struct wl_listener *listener, void *data) struct cg_keyboard *keyboard = wl_container_of(listener, keyboard, modifiers); wlr_seat_set_keyboard(keyboard->seat->seat, keyboard->device); - wlr_seat_keyboard_notify_modifiers(keyboard->seat->seat, - &keyboard->device->keyboard->modifiers); + wlr_seat_keyboard_notify_modifiers(keyboard->seat->seat, &keyboard->device->keyboard->modifiers); wlr_idle_notify_activity(keyboard->seat->server->idle, keyboard->seat->seat); } @@ -266,8 +261,7 @@ handle_keyboard_key(struct wl_listener *listener, void *data) if (!handled) { /* Otherwise, we pass it along to the client. */ wlr_seat_set_keyboard(seat->seat, keyboard->device); - wlr_seat_keyboard_notify_key(seat->seat, event->time_msec, - event->keycode, event->state); + wlr_seat_keyboard_notify_key(seat->seat, event->time_msec, event->keycode, event->state); } wlr_idle_notify_activity(seat->server->idle, seat->seat); @@ -304,14 +298,13 @@ handle_new_keyboard(struct cg_seat *seat, struct wlr_input_device *device) return; } - struct xkb_rule_names rules = { 0 }; + struct xkb_rule_names rules = {0}; rules.rules = getenv("XKB_DEFAULT_RULES"); rules.model = getenv("XKB_DEFAULT_MODEL"); rules.layout = getenv("XKB_DEFAULT_LAYOUT"); rules.variant = getenv("XKB_DEFAULT_VARIANT"); rules.options = getenv("XKB_DEFAULT_OPTIONS"); - struct xkb_keymap *keymap = xkb_map_new_from_names(context, &rules, - XKB_KEYMAP_COMPILE_NO_FLAGS); + struct xkb_keymap *keymap = xkb_map_new_from_names(context, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS); if (!keymap) { wlr_log(WLR_ERROR, "Unable to configure keyboard: keymap does not exist"); free(keyboard); @@ -399,8 +392,7 @@ handle_request_set_cursor(struct wl_listener *listener, void *data) /* This can be sent by any client, so we check to make sure * this one actually has pointer focus first. */ if (focused_client == event->seat_client->client) { - wlr_cursor_set_surface(seat->cursor, event->surface, - event->hotspot_x, event->hotspot_y); + wlr_cursor_set_surface(seat->cursor, event->surface, event->hotspot_x, event->hotspot_y); } } @@ -411,27 +403,22 @@ handle_touch_down(struct wl_listener *listener, void *data) struct wlr_event_touch_down *event = data; double lx, ly; - wlr_cursor_absolute_to_layout_coords(seat->cursor, event->device, - event->x, event->y, &lx, &ly); + wlr_cursor_absolute_to_layout_coords(seat->cursor, event->device, event->x, event->y, &lx, &ly); double sx, sy; struct wlr_surface *surface; - struct cg_view *view = desktop_view_at(seat->server, lx, ly, - &surface, &sx, &sy); + struct cg_view *view = desktop_view_at(seat->server, lx, ly, &surface, &sx, &sy); uint32_t serial = 0; if (view) { - serial = wlr_seat_touch_notify_down(seat->seat, surface, - event->time_msec, event->touch_id, - sx, sy); + serial = wlr_seat_touch_notify_down(seat->seat, surface, event->time_msec, event->touch_id, sx, sy); } if (serial && wlr_seat_touch_num_points(seat->seat) == 1) { seat->touch_id = event->touch_id; seat->touch_lx = lx; seat->touch_ly = ly; - press_cursor_button(seat, event->device, event->time_msec, - BTN_LEFT, WLR_BUTTON_PRESSED, lx, ly); + press_cursor_button(seat, event->device, event->time_msec, BTN_LEFT, WLR_BUTTON_PRESSED, lx, ly); } wlr_idle_notify_activity(seat->server->idle, seat->seat); @@ -448,8 +435,7 @@ handle_touch_up(struct wl_listener *listener, void *data) } if (wlr_seat_touch_num_points(seat->seat) == 1) { - press_cursor_button(seat, event->device, event->time_msec, - BTN_LEFT, WLR_BUTTON_RELEASED, + press_cursor_button(seat, event->device, event->time_msec, BTN_LEFT, WLR_BUTTON_RELEASED, seat->touch_lx, seat->touch_ly); } @@ -468,22 +454,17 @@ handle_touch_motion(struct wl_listener *listener, void *data) } double lx, ly; - wlr_cursor_absolute_to_layout_coords(seat->cursor, event->device, - event->x, event->y, &lx, &ly); + wlr_cursor_absolute_to_layout_coords(seat->cursor, event->device, event->x, event->y, &lx, &ly); double sx, sy; struct wlr_surface *surface; - struct cg_view *view = desktop_view_at(seat->server, lx, ly, - &surface, &sx, &sy); + struct cg_view *view = desktop_view_at(seat->server, lx, ly, &surface, &sx, &sy); if (view) { - wlr_seat_touch_point_focus(seat->seat, surface, - event->time_msec, event->touch_id, sx, sy); - wlr_seat_touch_notify_motion(seat->seat, event->time_msec, - event->touch_id, sx, sy); + wlr_seat_touch_point_focus(seat->seat, surface, event->time_msec, event->touch_id, sx, sy); + wlr_seat_touch_notify_motion(seat->seat, event->time_msec, event->touch_id, sx, sy); } else { - wlr_seat_touch_point_clear_focus(seat->seat, event->time_msec, - event->touch_id); + wlr_seat_touch_point_clear_focus(seat->seat, event->time_msec, event->touch_id); } if (event->touch_id == seat->touch_id) { @@ -509,8 +490,7 @@ handle_cursor_axis(struct wl_listener *listener, void *data) struct cg_seat *seat = wl_container_of(listener, seat, cursor_axis); struct wlr_event_pointer_axis *event = data; - wlr_seat_pointer_notify_axis(seat->seat, - event->time_msec, event->orientation, event->delta, + wlr_seat_pointer_notify_axis(seat->seat, event->time_msec, event->orientation, event->delta, event->delta_discrete, event->source); wlr_idle_notify_activity(seat->server->idle, seat->seat); } @@ -521,11 +501,9 @@ handle_cursor_button(struct wl_listener *listener, void *data) struct cg_seat *seat = wl_container_of(listener, seat, cursor_button); struct wlr_event_pointer_button *event = data; - wlr_seat_pointer_notify_button(seat->seat, event->time_msec, - event->button, event->state); - press_cursor_button(seat, event->device, event->time_msec, - event->button, event->state, - seat->cursor->x, seat->cursor->y); + wlr_seat_pointer_notify_button(seat->seat, event->time_msec, event->button, event->state); + press_cursor_button(seat, event->device, event->time_msec, event->button, event->state, seat->cursor->x, + seat->cursor->y); wlr_idle_notify_activity(seat->server->idle, seat->seat); } @@ -536,9 +514,7 @@ process_cursor_motion(struct cg_seat *seat, uint32_t time) struct wlr_seat *wlr_seat = seat->seat; struct wlr_surface *surface = NULL; - struct cg_view *view = desktop_view_at(seat->server, - seat->cursor->x, seat->cursor->y, - &surface, &sx, &sy); + struct cg_view *view = desktop_view_at(seat->server, seat->cursor->x, seat->cursor->y, &surface, &sx, &sy); if (!view) { wlr_seat_pointer_clear_focus(wlr_seat); @@ -586,8 +562,7 @@ drag_icon_damage(struct cg_drag_icon *drag_icon) { struct cg_output *output; wl_list_for_each(output, &drag_icon->seat->server->outputs, link) { - output_damage_surface(output, drag_icon->wlr_drag_icon->surface, - drag_icon->lx, drag_icon->ly, true); + output_damage_surface(output, drag_icon->wlr_drag_icon->surface, drag_icon->lx, drag_icon->ly, true); } } @@ -636,23 +611,20 @@ handle_request_start_drag(struct wl_listener *listener, void *data) struct cg_seat *seat = wl_container_of(listener, seat, request_start_drag); struct wlr_seat_request_start_drag_event *event = data; - if (wlr_seat_validate_pointer_grab_serial(seat->seat, - event->origin, event->serial)) { + if (wlr_seat_validate_pointer_grab_serial(seat->seat, event->origin, event->serial)) { wlr_seat_start_pointer_drag(seat->seat, event->drag, event->serial); return; } struct wlr_touch_point *point; - if (wlr_seat_validate_touch_grab_serial(seat->seat, - event->origin, event->serial, &point)) { - wlr_seat_start_touch_drag(seat->seat, - event->drag, event->serial, point); + if (wlr_seat_validate_touch_grab_serial(seat->seat, event->origin, event->serial, &point)) { + wlr_seat_start_touch_drag(seat->seat, event->drag, event->serial, point); return; } // TODO: tablet grabs - wlr_log(WLR_DEBUG, "Ignoring start_drag request: " - "could not validate pointer/touch serial %" PRIu32, event->serial); + wlr_log(WLR_DEBUG, "Ignoring start_drag request: could not validate pointer/touch serial %" PRIu32, + event->serial); wlr_data_source_destroy(event->drag->source); } @@ -792,8 +764,7 @@ seat_create(struct cg_server *server, struct wlr_backend *backend) wl_list_init(&seat->drag_icons); seat->request_start_drag.notify = handle_request_start_drag; - wl_signal_add(&seat->seat->events.request_start_drag, - &seat->request_start_drag); + wl_signal_add(&seat->seat->events.request_start_drag, &seat->request_start_drag); seat->start_drag.notify = handle_start_drag; wl_signal_add(&seat->seat->events.start_drag, &seat->start_drag); @@ -863,13 +834,10 @@ seat_set_focus(struct cg_seat *seat, struct cg_view *view) struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(wlr_seat); if (keyboard) { - wlr_seat_keyboard_notify_enter(wlr_seat, view->wlr_surface, - keyboard->keycodes, - keyboard->num_keycodes, + wlr_seat_keyboard_notify_enter(wlr_seat, view->wlr_surface, keyboard->keycodes, keyboard->num_keycodes, &keyboard->modifiers); } else { - wlr_seat_keyboard_notify_enter(wlr_seat, view->wlr_surface, - NULL, 0, NULL); + wlr_seat_keyboard_notify_enter(wlr_seat, view->wlr_surface, NULL, 0, NULL); } process_cursor_motion(seat, -1); diff --git a/view.c b/view.c index 5f9bed0..b227121 100644 --- a/view.c +++ b/view.c @@ -131,7 +131,8 @@ view_is_primary(struct cg_view *view) } bool -view_is_transient_for(struct cg_view *child, struct cg_view *parent) { +view_is_transient_for(struct cg_view *child, struct cg_view *parent) +{ return child->impl->is_transient_for(child, parent); } @@ -286,8 +287,7 @@ view_destroy(struct cg_view *view) } void -view_init(struct cg_view *view, struct cg_server *server, enum cg_view_type type, - const struct cg_view_impl *impl) +view_init(struct cg_view *view, struct cg_server *server, enum cg_view_type type, const struct cg_view_impl *impl) { view->server = server; view->type = type; diff --git a/view.h b/view.h index 1da861c..1b0e90f 100644 --- a/view.h +++ b/view.h @@ -44,12 +44,9 @@ struct cg_view_impl { void (*activate)(struct cg_view *view, bool activate); void (*maximize)(struct cg_view *view, int output_width, int output_height); void (*destroy)(struct cg_view *view); - void (*for_each_surface)(struct cg_view *view, wlr_surface_iterator_func_t iterator, - void *data); - void (*for_each_popup)(struct cg_view *view, wlr_surface_iterator_func_t iterator, - void *data); - struct wlr_surface *(*wlr_surface_at)(struct cg_view *view, double sx, double sy, - double *sub_x, double *sub_y); + void (*for_each_surface)(struct cg_view *view, wlr_surface_iterator_func_t iterator, void *data); + void (*for_each_popup)(struct cg_view *view, wlr_surface_iterator_func_t iterator, void *data); + struct wlr_surface *(*wlr_surface_at)(struct cg_view *view, double sx, double sy, double *sub_x, double *sub_y); }; struct cg_view_child { @@ -82,12 +79,10 @@ void view_for_each_popup(struct cg_view *view, wlr_surface_iterator_func_t itera void view_unmap(struct cg_view *view); void view_map(struct cg_view *view, struct wlr_surface *surface); void view_destroy(struct cg_view *view); -void view_init(struct cg_view *view, struct cg_server *server, enum cg_view_type type, - const struct cg_view_impl *impl); +void view_init(struct cg_view *view, struct cg_server *server, enum cg_view_type type, const struct cg_view_impl *impl); struct cg_view *view_from_wlr_surface(struct cg_server *server, struct wlr_surface *surface); -struct wlr_surface *view_wlr_surface_at(struct cg_view *view, double sx, double sy, - double *sub_x, double *sub_y); +struct wlr_surface *view_wlr_surface_at(struct cg_view *view, double sx, double sy, double *sub_x, double *sub_y); void view_child_finish(struct cg_view_child *child); void view_child_init(struct cg_view_child *child, struct cg_view *view, struct wlr_surface *wlr_surface); diff --git a/xdg_shell.c b/xdg_shell.c index 4c6d0ee..26fe860 100644 --- a/xdg_shell.c +++ b/xdg_shell.c @@ -97,14 +97,15 @@ popup_unconstrain(struct cg_xdg_popup *popup) struct wlr_box *popup_box = &popup->wlr_popup->geometry; struct wlr_output_layout *output_layout = server->output_layout; - struct wlr_output *wlr_output = wlr_output_layout_output_at(output_layout, view->lx + popup_box->x, view->ly + popup_box->y); + struct wlr_output *wlr_output = + wlr_output_layout_output_at(output_layout, view->lx + popup_box->x, view->ly + popup_box->y); struct wlr_box *output_box = wlr_output_layout_get_box(output_layout, wlr_output); struct wlr_box output_toplevel_box = { .x = output_box->x - view->lx, .y = output_box->y - view->ly, .width = output_box->width, - .height = output_box->height + .height = output_box->height, }; wlr_xdg_popup_unconstrain_from_box(popup->wlr_popup, &output_toplevel_box); diff --git a/xwayland.c b/xwayland.c index cfc33f9..1aca1cc 100644 --- a/xwayland.c +++ b/xwayland.c @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include #include "server.h" #include "view.h" @@ -84,7 +84,8 @@ static void maximize(struct cg_view *view, int output_width, int output_height) { struct cg_xwayland_view *xwayland_view = xwayland_view_from_view(view); - wlr_xwayland_surface_configure(xwayland_view->xwayland_surface, view->lx, view->ly, output_width, output_height); + wlr_xwayland_surface_configure(xwayland_view->xwayland_surface, view->lx, view->ly, output_width, + output_height); wlr_xwayland_surface_set_maximized(xwayland_view->xwayland_surface, true); }