Skip to content

Commit

Permalink
fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gg-rewrite committed Apr 14, 2020
1 parent 8eb5a82 commit d03a8ef
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
12 changes: 4 additions & 8 deletions include/slurp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
17 changes: 8 additions & 9 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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 &&
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
23 changes: 11 additions & 12 deletions render.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
&current_selection->selection)) {
&current_selection->selection)) {
continue;
}
struct slurp_box b = current_selection->selection;
Expand Down

0 comments on commit d03a8ef

Please sign in to comment.