diff --git a/include/slurp.h b/include/slurp.h index ebf5e75..94d7a9d 100644 --- a/include/slurp.h +++ b/include/slurp.h @@ -88,14 +88,8 @@ struct slurp_seat { // keyboard: 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 +105,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..2632b28 100644 --- a/main.c +++ b/main.c @@ -26,7 +26,7 @@ bool box_intersect(const struct slurp_box *a, const struct slurp_box *b) { a->height + a->y > b->y; } -struct slurp_selection *seat_get_current_selection(struct slurp_seat *seat) { +struct slurp_selection* seat_get_current_selection(struct slurp_seat *seat) { if (seat->pointer_selection.has_selection) { return &seat->pointer_selection; } else if (seat->touch_selection.has_selection) { @@ -44,8 +44,7 @@ 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 y = wl_fixed_to_int(surface_y) + current_selection->current_output->logical_geometry.y; @@ -154,8 +153,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 +211,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 +279,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..4ce5c28 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,14 @@ 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) - continue; - if (!seat->wl_pointer) - continue; - if (!current_selection->has_selection) { + seat_get_current_selection(seat); + if (!seat->wl_pointer) { continue; } - if (!box_intersect(&output->logical_geometry, - ¤t_selection->selection)) { + ¤t_selection->selection)) { continue; } struct slurp_box b = current_selection->selection;