common.h - croptool - Image cropping tool
HTML git clone git://lumidify.org/croptool.git (fast, but not encrypted)
HTML git clone https://lumidify.org/croptool.git (encrypted, but very slow)
HTML git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/croptool.git (over tor)
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
common.h (3048B)
---
1 /*
2 * Copyright (c) 2021-2024 lumidify <nobody@lumidify.org>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef CROPTOOL_COMMON
18 #define CROPTOOL_COMMON
19
20 #include <X11/X.h>
21 #include <X11/Xlib.h>
22 #ifndef NODB
23 #include <X11/extensions/Xdbe.h>
24 #endif
25 #include <Imlib2.h>
26
27 typedef struct {
28 int orig_w;
29 int orig_h;
30 int scaled_w;
31 int scaled_h;
32 } ImageSize;
33
34 typedef struct {
35 Display *dpy;
36 GC gc;
37 Window win;
38 Visual *vis;
39 Drawable drawable;
40 #ifndef NODB
41 XdbeBackBuffer back_buf;
42 int db_enabled;
43 #endif
44 Colormap cm;
45 int screen;
46 int depth;
47
48 int window_w;
49 int window_h;
50 char dirty;
51 Atom wm_delete_msg;
52 Imlib_Image cur_image;
53 Imlib_Updates updates;
54 } GraphicsContext;
55
56 void setup_x(GraphicsContext *ctx, int window_w, int window_h, int line_height, int cache_size);
57 void cleanup_x(GraphicsContext *ctx);
58 /* Parse integer between min and max (inclusive).
59 Returns 1 on error, 0 otherwise.
60 The result is stored in *value.
61 Based on OpenBSD's strtonum. */
62 int parse_int(const char *str, int min, int max, int *value);
63 /* queue a part of the image for redrawing */
64 void queue_area_update(GraphicsContext *ctx, ImageSize *sz, int x, int y, int w, int h);
65 void clear_screen(GraphicsContext *ctx);
66 void draw_image_updates(GraphicsContext *ctx, ImageSize *sz);
67 void wipe_around_image(GraphicsContext *ctx, ImageSize *sz);
68 void swap_buffers(GraphicsContext *ctx);
69 void get_scaled_size(GraphicsContext *ctx, int orig_w, int orig_h, int *scaled_w, int *scaled_h);
70 /* show the next image in the argument list - unloadable files are skipped
71 * copy_box determines whether the current selection is copied
72 * (only relevant in croptool, not in selectool) */
73 void next_picture(int cur_selection, char **filenames, int num_files, int copy_box);
74 /* show the previous image in the argument list - unloadable files are skipped
75 * copy_box determines whether the current selection is copied
76 * (only relevant in croptool, not in selectool) */
77 void last_picture(int cur_selection, char **filenames, int copy_box);
78
79 /* these are actually defined in croptool.c and selectool.c */
80 void cleanup(void);
81 void change_picture(Imlib_Image new_image, int new_selection, int copy_box);
82
83 #endif /* CROPTOOL_COMMON */