From d03a8ef98de27e13c829ef4daacd5abd8730ad1f Mon Sep 17 00:00:00 2001 From: Some Chinese Guy Date: Tue, 14 Apr 2020 16:16:01 +0300 Subject: [PATCH] fixed formatting --- include/slurp.h | 12 ++++-------- main.c | 17 ++++++++--------- render.c | 23 +++++++++++------------ 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/include/slurp.h b/include/slurp.h index ebf5e75..17d4321 100644 --- a/include/slurp.h +++ b/include/slurp.h @@ -89,13 +89,9 @@ struct slurp_seat { struct wl_keyboard *wl_keyboard; //selection (pointer/touch): - /*struct slurp_output *current_output; - int32_t x, y; - int32_t anchor_x, anchor_y; - struct slurp_box selection; - bool has_selection;*/ - struct slurp_selection pointer_selection; - struct slurp_selection touch_selection; + + struct slurp_selection pointer_selection; + struct slurp_selection touch_selection; // pointer: struct wl_pointer *wl_pointer; @@ -111,5 +107,5 @@ struct slurp_seat { }; bool box_intersect(const struct slurp_box *a, const struct slurp_box *b); -struct slurp_selection* seat_get_current_selection(struct slurp_seat* seat); +struct slurp_selection* seat_get_current_selection(struct slurp_seat *seat); #endif diff --git a/main.c b/main.c index 019292d..4dacfca 100644 --- a/main.c +++ b/main.c @@ -44,10 +44,10 @@ static void move_seat(struct slurp_seat *seat, wl_fixed_t surface_x, struct slurp_selection *current_selection = seat_get_current_selection(seat); if (current_selection == NULL) { - //return; - current_selection = &seat->pointer_selection; //still need to track the mouse coordinates; + current_selection = &seat->pointer_selection; } - int x = wl_fixed_to_int(surface_x) + current_selection->current_output->logical_geometry.x; + int x = wl_fixed_to_int(surface_x) + + current_selection->current_output->logical_geometry.x; int y = wl_fixed_to_int(surface_y) + current_selection->current_output->logical_geometry.y; if (seat->state->edit_anchor) { @@ -93,9 +93,9 @@ static void seat_set_outputs_dirty(struct slurp_seat *seat) { struct slurp_output *output; wl_list_for_each(output, &seat->state->outputs, link) { if (box_intersect(&output->logical_geometry, - &seat->pointer_selection.selection) || + &seat->pointer_selection.selection) || box_intersect(&output->logical_geometry, - &seat->touch_selection.selection)) { + &seat->touch_selection.selection)) { set_output_dirty(output); } } @@ -154,8 +154,7 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer, // find smallest box intersecting the cursor struct slurp_box *box; - wl_list_for_each(box, &seat->state->boxes, link) - { + wl_list_for_each(box, &seat->state->boxes, link) { if (in_box(box, seat->pointer_selection.x, seat->pointer_selection.y)) { if (seat->pointer_selection.has_selection && @@ -213,7 +212,7 @@ static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer, uint32_t button_state) { struct slurp_seat *seat = data; if (seat->touch_selection.has_selection) { - return; + return; } seat->button_state = button_state; @@ -281,7 +280,7 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *wl_keyboard, case XKB_KEY_space: if (!seat->pointer_selection.has_selection && - !seat->touch_selection.has_selection) { + !seat->touch_selection.has_selection) { break; } state->edit_anchor = true; diff --git a/render.c b/render.c index 6633339..b8df0da 100644 --- a/render.c +++ b/render.c @@ -6,16 +6,14 @@ #include "render.h" #include "slurp.h" -static void set_source_u32(cairo_t *cairo, uint32_t color) -{ +static void set_source_u32(cairo_t *cairo, uint32_t color) { cairo_set_source_rgba(cairo, (color >> (3 * 8) & 0xFF) / 255.0, - (color >> (2 * 8) & 0xFF) / 255.0, - (color >> (1 * 8) & 0xFF) / 255.0, - (color >> (0 * 8) & 0xFF) / 255.0); + (color >> (2 * 8) & 0xFF) / 255.0, + (color >> (1 * 8) & 0xFF) / 255.0, + (color >> (0 * 8) & 0xFF) / 255.0); } -void render(struct slurp_output *output) -{ +void render(struct slurp_output *output) { struct slurp_state *state = output->state; struct pool_buffer *buffer = output->current_buffer; cairo_t *cairo = buffer->cairo; @@ -27,20 +25,21 @@ void render(struct slurp_output *output) cairo_paint(cairo); struct slurp_seat *seat; - wl_list_for_each(seat, &state->seats, link) - { + wl_list_for_each(seat, &state->seats, link) { struct slurp_selection *current_selection = seat_get_current_selection(seat); - if (current_selection == NULL) + if (current_selection == NULL) { continue; - if (!seat->wl_pointer) + } + if (!seat->wl_pointer) { continue; + } if (!current_selection->has_selection) { continue; } if (!box_intersect(&output->logical_geometry, - ¤t_selection->selection)) { + ¤t_selection->selection)) { continue; } struct slurp_box b = current_selection->selection;