mirror of
https://github.com/jtheoof/swappy.git
synced 2024-08-17 02:30:47 +03:00
chore: cleanup
This commit is contained in:
parent
d1dfcccccb
commit
45a0da8293
@ -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;
|
||||
|
||||
|
20
src/box.c
20
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,
|
||||
|
@ -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);
|
||||
|
||||
|
@ -2,10 +2,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <wordexp.h>
|
||||
|
||||
#include "swappy.h"
|
||||
|
10
src/main.c
10
src/main.c
@ -1,17 +1,7 @@
|
||||
#define _POSIX_C_SOURCE 2
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <linux/input-event-codes.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <wayland-cursor.h>
|
||||
#include <wlr/util/log.h>
|
||||
|
||||
#include "application.h"
|
||||
#include "config.h"
|
||||
#include "swappy.h"
|
||||
#include "wayland.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
@ -2,15 +2,9 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <wayland-client.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user