From 45a0da8293672a8b99218c86d7525e44064696f7 Mon Sep 17 00:00:00 2001 From: Jeremy Attali Date: Sat, 28 Dec 2019 21:38:38 -0500 Subject: [PATCH] chore: cleanup --- include/swappy.h | 1 - src/box.c | 20 +++++++++++--------- src/clipboard.c | 4 ++-- src/config.c | 3 --- src/main.c | 10 ---------- src/screencopy.c | 8 +------- 6 files changed, 14 insertions(+), 32 deletions(-) diff --git a/include/swappy.h b/include/swappy.h index 17f56b0..08accdf 100644 --- a/include/swappy.h +++ b/include/swappy.h @@ -116,7 +116,6 @@ struct swappy_state { struct zxdg_output_manager_v1 *xdg_output_manager; struct zwlr_screencopy_manager_v1 *zwlr_screencopy_manager; struct wl_list outputs; // mako_output::link - struct wl_list seats; // mako_seat::link size_t n_done; diff --git a/src/box.c b/src/box.c index b0f238d..b4e1f5e 100644 --- a/src/box.c +++ b/src/box.c @@ -1,28 +1,30 @@ #include "box.h" -#include "swappy.h" +static int32_t lmax(int32_t a, int32_t b) { return a > b ? a : b; } + +static int32_t lmin(int32_t a, int32_t b) { return a < b ? a : b; } bool box_parse(struct swappy_box *box, const char *str) { char *end = NULL; - box->x = strtol(str, &end, 10); + box->x = (int32_t) strtol(str, &end, 10); if (end[0] != ',') { return false; } char *next = end + 1; - box->y = strtol(next, &end, 10); + box->y = (int32_t) strtol(next, &end, 10); if (end[0] != ' ') { return false; } next = end + 1; - box->width = strtol(next, &end, 10); + box->width = (int32_t) strtol(next, &end, 10); if (end[0] != 'x') { return false; } next = end + 1; - box->height = strtol(next, &end, 10); + box->height = (int32_t) strtol(next, &end, 10); if (end[0] != '\0') { return false; } @@ -39,10 +41,10 @@ bool intersect_box(struct swappy_box *a, struct swappy_box *b) { return false; } - int x1 = fmax(a->x, b->x); - int y1 = fmax(a->y, b->y); - int x2 = fmin(a->x + a->width, b->x + b->width); - int y2 = fmin(a->y + a->height, b->y + b->height); + int32_t x1 = lmax(a->x, b->x); + int32_t y1 = lmax(a->y, b->y); + int32_t x2 = lmin(a->x + a->width, b->x + b->width); + int32_t y2 = lmin(a->y + a->height, b->y + b->height); struct swappy_box box = { .x = x1, diff --git a/src/clipboard.c b/src/clipboard.c index c77a755..118b4b8 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -4,8 +4,8 @@ bool clipboard_copy_drawing_area_to_selection(struct swappy_state *state) { GtkClipboard *clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD); - guint width = gtk_widget_get_allocated_width(state->ui->area); - guint height = gtk_widget_get_allocated_height(state->ui->area); + int width = gtk_widget_get_allocated_width(state->ui->area); + int height = gtk_widget_get_allocated_height(state->ui->area); GdkPixbuf *pixbuf = gdk_pixbuf_get_from_surface(state->cairo_surface, 0, 0, width, height); diff --git a/src/config.c b/src/config.c index 683af7a..bdacdfa 100644 --- a/src/config.c +++ b/src/config.c @@ -2,10 +2,7 @@ #include #include -#include #include -#include -#include #include #include "swappy.h" diff --git a/src/main.c b/src/main.c index 14fc436..cbb5edb 100644 --- a/src/main.c +++ b/src/main.c @@ -1,17 +1,7 @@ #define _POSIX_C_SOURCE 2 -#include -#include -#include -#include -#include -#include -#include -#include -#include #include "application.h" #include "config.h" -#include "swappy.h" #include "wayland.h" int main(int argc, char *argv[]) { diff --git a/src/screencopy.c b/src/screencopy.c index 873f07d..d58a563 100644 --- a/src/screencopy.c +++ b/src/screencopy.c @@ -2,15 +2,9 @@ #include #include -#include -#include -#include #include -#include #include "box.h" -#include "swappy.h" -#include "wlr-screencopy-unstable-v1-client-protocol.h" static void randname(char *buf) { struct timespec ts; @@ -173,7 +167,7 @@ bool screencopy_init(struct swappy_state *state) { done = (state->n_done == n_pending); } if (!done) { - g_warning("failed to screenshoot all outputs"); + g_warning("failed to screenshot all outputs"); return EXIT_FAILURE; }