Skip to content

Commit

Permalink
rearrange functions in main
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronan Pigott authored and emersion committed Aug 3, 2020
1 parent 74a7cff commit 809cf0a
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ bool box_intersect(const struct slurp_box *a, const struct slurp_box *b) {
a->height + a->y > b->y;
}

static bool in_box(const struct slurp_box *box, int32_t x, int32_t y) {
return box->x <= x
&& box->x + box->width >= x
&& box->y <= y
&& box->y + box->height >= y;
}

static int32_t box_size(const struct slurp_box *box) {
return box->width * box->height;
}

static int min(int a, int b) {
return (a < b) ? a : b;
}

static int max(int a, int b) {
return (a > b) ? a : b;
}

static struct slurp_output *output_from_surface(struct slurp_state *state,
struct wl_surface *surface);

Expand All @@ -45,6 +64,18 @@ static void move_seat(struct slurp_seat *seat, wl_fixed_t surface_x,
current_selection->y = y;
}

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) ||
box_intersect(&output->logical_geometry,
&seat->touch_selection.selection)) {
set_output_dirty(output);
}
}
}

static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, struct wl_surface *surface,
wl_fixed_t surface_x, wl_fixed_t surface_y) {
Expand Down Expand Up @@ -75,37 +106,6 @@ static void pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
seat->pointer_selection.current_output = NULL;
}

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) ||
box_intersect(&output->logical_geometry,
&seat->touch_selection.selection)) {
set_output_dirty(output);
}
}
}

static bool in_box(const struct slurp_box *box, int32_t x, int32_t y) {
return box->x <= x
&& box->x + box->width >= x
&& box->y <= y
&& box->y + box->height >= y;
}

static int32_t box_size(const struct slurp_box *box) {
return box->width * box->height;
}

static int min(int a, int b) {
return (a < b) ? a : b;
}

static int max(int a, int b) {
return (a > b) ? a : b;
}

static void handle_active_selection_motion(struct slurp_seat *seat, struct slurp_selection *current_selection) {
int32_t anchor_x = max(0, current_selection->anchor_x);
int32_t anchor_y = max(0, current_selection->anchor_y);
Expand Down

0 comments on commit 809cf0a

Please sign in to comment.