From ae083cf024fb4a81606109bd6ae7e54e7545e8bb Mon Sep 17 00:00:00 2001 From: vanfanel Date: Wed, 3 Jan 2024 18:52:45 +0100 Subject: [PATCH] Use clang-format to ensure correct format of the changed files. --- cage.c | 2 +- seat.c | 117 ++++++++++++++++++++++++++++++--------------------------- seat.h | 4 +- 3 files changed, 64 insertions(+), 59 deletions(-) diff --git a/cage.c b/cage.c index 5ea18c04..bddca887 100644 --- a/cage.c +++ b/cage.c @@ -29,9 +29,9 @@ #include #include #include +#include #include #include -#include #include #include #include diff --git a/seat.c b/seat.c index 34d73267..f5ada005 100644 --- a/seat.c +++ b/seat.c @@ -630,21 +630,20 @@ process_cursor_motion(struct cg_seat *seat, uint32_t time_msec, double *dx, doub dy_unaccel); } - /* Apply pointer constraints. It has to be done before calling wlr_cursor_move() */ + /* Apply pointer constraints. It has to be done before calling wlr_cursor_move() */ if (seat->active_constraint) { double sx_confined, sy_confined; - /* wlr_region_confine() checks if the current position is within a confinement region. - * If it is, returns true and takes the next position after a move and ajusts it - * to the confinement region. - * It it's not, it returns false and does nothing. - * seat->confine: confinement region. - * sx/sy:current position. - * sx+dx/sy+dy: next position after a move. - * sx_confined/sy_confined: next position, but confined to the region. - */ - if (!wlr_region_confine(&seat->confine, sx, sy, sx + *dx, sy + *dy, - &sx_confined, &sy_confined)) { - return; + /* wlr_region_confine() checks if the current position is within a confinement region. + * If it is, returns true and takes the next position after a move and ajusts it + * to the confinement region. + * It it's not, it returns false and does nothing. + * seat->confine: confinement region. + * sx/sy:current position. + * sx+dx/sy+dy: next position after a move. + * sx_confined/sy_confined: next position, but confined to the region. + */ + if (!wlr_region_confine(&seat->confine, sx, sy, sx + *dx, sy + *dy, &sx_confined, &sy_confined)) { + return; } *dx = sx_confined - sx; @@ -659,11 +658,12 @@ process_cursor_motion(struct cg_seat *seat, uint32_t time_msec, double *dx, doub wlr_idle_notifier_v1_notify_activity(seat->server->idle, seat->seat); } -static void warp_to_constraint_cursor_hint(struct cg_seat *seat) { +static void +warp_to_constraint_cursor_hint(struct cg_seat *seat) +{ struct wlr_pointer_constraint_v1 *constraint = seat->active_constraint; - if (constraint->current.committed & - WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT) { + if (constraint->current.committed & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT) { double sx = constraint->current.cursor_hint.x; double sy = constraint->current.cursor_hint.y; @@ -680,7 +680,9 @@ static void warp_to_constraint_cursor_hint(struct cg_seat *seat) { } } -static void check_constraint_region(struct cg_seat *seat) { +static void +check_constraint_region(struct cg_seat *seat) +{ struct wlr_pointer_constraint_v1 *constraint = seat->active_constraint; pixman_region32_t *region = &constraint->region; if (seat->active_confine_requires_warp) { @@ -689,8 +691,7 @@ static void check_constraint_region(struct cg_seat *seat) { double sx = seat->cursor->x; double sy = seat->cursor->y; - if (!pixman_region32_contains_point(region, - floor(sx), floor(sy), NULL)) { + if (!pixman_region32_contains_point(region, floor(sx), floor(sy), NULL)) { int nboxes; pixman_box32_t *boxes = pixman_region32_rectangles(region, &nboxes); if (nboxes > 0) { @@ -698,7 +699,7 @@ static void check_constraint_region(struct cg_seat *seat) { double sy = (boxes[0].y1 + boxes[0].y2) / 2.; wlr_cursor_warp_closest(seat->cursor, NULL, sx, sy); - //cursor_rebase(seat); + // cursor_rebase(seat); } } } @@ -711,10 +712,10 @@ static void check_constraint_region(struct cg_seat *seat) { } } -static void handle_constraint_commit(struct wl_listener *listener, - void *data) { - struct cg_seat *seat = - wl_container_of(listener, seat, constraint_commit); +static void +handle_constraint_commit(struct wl_listener *listener, void *data) +{ + struct cg_seat *seat = wl_container_of(listener, seat, constraint_commit); struct wlr_pointer_constraint_v1 *constraint = seat->active_constraint; assert(constraint->surface == data); @@ -723,8 +724,9 @@ static void handle_constraint_commit(struct wl_listener *listener, /* This is where active_constraint is assigned. Also remember that everything * Sway has in sway_cursor is in cg_seat, because in Cage there's only a cursor per seat. */ -void cg_cursor_constrain(struct cg_seat *seat, - struct wlr_pointer_constraint_v1 *constraint) { +void +cg_cursor_constrain(struct cg_seat *seat, struct wlr_pointer_constraint_v1 *constraint) +{ if (seat->active_constraint == constraint) { return; @@ -735,8 +737,7 @@ void cg_cursor_constrain(struct cg_seat *seat, if (constraint == NULL) { warp_to_constraint_cursor_hint(seat); } - wlr_pointer_constraint_v1_send_deactivated( - seat->active_constraint); + wlr_pointer_constraint_v1_send_deactivated(seat->active_constraint); } seat->active_constraint = constraint; @@ -754,11 +755,10 @@ void cg_cursor_constrain(struct cg_seat *seat, // since this code will be run *after* the focus has been set. // That is why we duplicate the code here. if (pixman_region32_not_empty(&constraint->current.region)) { - pixman_region32_intersect(&constraint->region, - &constraint->surface->input_region, &constraint->current.region); + pixman_region32_intersect(&constraint->region, &constraint->surface->input_region, + &constraint->current.region); } else { - pixman_region32_copy(&constraint->region, - &constraint->surface->input_region); + pixman_region32_copy(&constraint->region, &constraint->surface->input_region); } check_constraint_region(seat); @@ -766,23 +766,22 @@ void cg_cursor_constrain(struct cg_seat *seat, wlr_pointer_constraint_v1_send_activated(constraint); seat->constraint_commit.notify = handle_constraint_commit; - wl_signal_add(&constraint->surface->events.commit, - &seat->constraint_commit); - + wl_signal_add(&constraint->surface->events.commit, &seat->constraint_commit); } -static void handle_pointer_constraint_set_region(struct wl_listener *listener, - void *data) { - struct cg_pointer_constraint *cg_constraint = - wl_container_of(listener, cg_constraint, set_region); +static void +handle_pointer_constraint_set_region(struct wl_listener *listener, void *data) +{ + struct cg_pointer_constraint *cg_constraint = wl_container_of(listener, cg_constraint, set_region); struct cg_seat *seat = cg_constraint->seat; seat->active_confine_requires_warp = true; } -void handle_constraint_destroy(struct wl_listener *listener, void *data) { - struct cg_pointer_constraint *cg_constraint = - wl_container_of(listener, cg_constraint, destroy); +void +handle_constraint_destroy(struct wl_listener *listener, void *data) +{ + struct cg_pointer_constraint *cg_constraint = wl_container_of(listener, cg_constraint, destroy); struct wlr_pointer_constraint_v1 *constraint = data; struct cg_seat *seat = cg_constraint->seat; @@ -802,25 +801,26 @@ void handle_constraint_destroy(struct wl_listener *listener, void *data) { free(cg_constraint); } -void handle_pointer_constraint(struct wl_listener *listener, void *data) { +void +handle_pointer_constraint(struct wl_listener *listener, void *data) +{ struct wlr_pointer_constraint_v1 *constraint = data; - - /* Recover cg_seat from a wlr_seat's data field. Every wlr_seat has it's data field - set to the cg_seat containing it, in seat_create(). */ - struct cg_seat *seat = constraint->seat->data; - struct cg_pointer_constraint *cg_constraint = - calloc(1, sizeof(struct cg_pointer_constraint)); + /* Recover cg_seat from a wlr_seat's data field. Every wlr_seat has it's data field + set to the cg_seat containing it, in seat_create(). */ + struct cg_seat *seat = constraint->seat->data; + + struct cg_pointer_constraint *cg_constraint = calloc(1, sizeof(struct cg_pointer_constraint)); cg_constraint->constraint = constraint; cg_constraint->seat = seat; cg_constraint->set_region.notify = handle_pointer_constraint_set_region; wl_signal_add(&constraint->events.set_region, &cg_constraint->set_region); - cg_constraint->destroy.notify = handle_constraint_destroy; + cg_constraint->destroy.notify = handle_constraint_destroy; wl_signal_add(&constraint->events.destroy, &cg_constraint->destroy); - struct wlr_surface *surface = seat->seat->keyboard_state.focused_surface; + struct wlr_surface *surface = seat->seat->keyboard_state.focused_surface; if (surface && surface == constraint->surface) { cg_cursor_constrain(seat, constraint); } @@ -848,11 +848,16 @@ handle_cursor_motion_relative(struct wl_listener *listener, void *data) { struct cg_seat *seat = wl_container_of(listener, seat, cursor_motion_relative); struct wlr_pointer_motion_event *event = data; - double dx = event->delta_x; - double dy = event->delta_y; + double dx = event->delta_x; + double dy = event->delta_y; +<<<<<<< HEAD process_cursor_motion(seat, event->time_msec, &dx, &dy, event->unaccel_dx, event->unaccel_dy); +======= + process_cursor_motion(seat, event->time_msec, &dx, &dy, event->unaccel_dx, event->unaccel_dy); + +>>>>>>> c490ac1 (Use clang-format to ensure correct format of the changed files.) wlr_cursor_move(seat->cursor, &event->pointer->base, dx, dy); wlr_idle_notifier_v1_notify_activity(seat->server->idle, seat->seat); } @@ -1003,7 +1008,7 @@ seat_create(struct cg_server *server, struct wlr_backend *backend) free(seat); return NULL; } - seat->seat->data = seat; + seat->seat->data = seat; seat->server = server; seat->destroy.notify = handle_destroy; wl_signal_add(&seat->seat->events.destroy, &seat->destroy); @@ -1149,8 +1154,8 @@ seat_set_focus(struct cg_seat *seat, struct cg_view *view) wlr_seat_keyboard_notify_enter(wlr_seat, view->wlr_surface, NULL, 0, NULL); } - double dx = 0, dy = 0; - process_cursor_motion(seat, -1, &dx, &dy, 0, 0); + double dx = 0, dy = 0; + process_cursor_motion(seat, -1, &dx, &dy, 0, 0); } void diff --git a/seat.h b/seat.h index a2180d96..a7ae090b 100644 --- a/seat.h +++ b/seat.h @@ -5,9 +5,9 @@ #include #include #include +#include #include #include -#include #include "server.h" #include "view.h" @@ -50,7 +50,7 @@ struct cg_seat { struct wl_listener request_set_selection; struct wl_listener request_set_primary_selection; - struct wl_listener constraint_commit; + struct wl_listener constraint_commit; struct wlr_pointer_constraint_v1 *active_constraint; pixman_region32_t confine; // invalid if active_constraint == NULL bool active_confine_requires_warp;