1 /* feh.h 2 3 Copyright (C) 1999-2003 Tom Gilbert. 4 Copyright (C) 2010-2020 Daniel Friesel. 5 6 Permission is hereby granted, free of charge, to any person obtaining a copy 7 of this software and associated documentation files (the "Software"), to 8 deal in the Software without restriction, including without limitation the 9 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 sell copies of the Software, and to permit persons to whom the Software is 11 furnished to do so, subject to the following conditions: 12 13 The above copyright notice and this permission notice shall be included in 14 all copies of the Software and its documentation and acknowledgment shall be 15 given in the documentation and software packages that this Software was 16 used. 17 18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 22 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 23 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 25 */ 26 27 #ifndef FEH_H 28 #define FEH_H 29 30 /* 31 * strverscmp(3) is a GNU extension. In most supporting C libraries it 32 * requires _GNU_SOURCE to be defined. 33 */ 34 #ifdef HAVE_STRVERSCMP 35 #define _GNU_SOURCE 36 #endif 37 38 #include <X11/Xlib.h> 39 #include <X11/Xutil.h> 40 #include <X11/Xatom.h> 41 #include <X11/Xos.h> 42 #include <X11/keysym.h> 43 #include <X11/Xresource.h> 44 #ifdef HAVE_LIBXINERAMA 45 #include <X11/extensions/Xinerama.h> 46 #include <X11/X.h> 47 #endif /* HAVE_LIBXINERAMA */ 48 #include <stdio.h> 49 #include <string.h> 50 #include <stdlib.h> 51 #include <limits.h> 52 #include <unistd.h> 53 #include <ctype.h> 54 #include <sys/stat.h> 55 #include <pwd.h> 56 #include <sys/types.h> 57 #include <sys/time.h> 58 #include <sys/socket.h> 59 #include <sys/un.h> 60 #include <errno.h> 61 #include <dirent.h> 62 #include <stdarg.h> 63 #include <signal.h> 64 #include <sys/wait.h> 65 #include <math.h> 66 67 #include <Imlib2.h> 68 #include "gib_hash.h" 69 #include "gib_imlib.h" 70 #include "gib_list.h" 71 #include "gib_style.h" 72 73 #include "structs.h" 74 #include "menu.h" 75 76 #include "utils.h" 77 #include "getopt.h" 78 79 #include "debug.h" 80 81 #define SLIDESHOW_RELOAD_MAX 4096 82 83 #ifndef TRUE 84 #define FALSE 0 85 #define TRUE !FALSE 86 #endif 87 88 #ifndef __GNUC__ 89 # define __attribute__(x) 90 #endif 91 92 #define XY_IN_RECT(x, y, rx, ry, rw, rh) \ 93 (((x) >= (rx)) && ((y) >= (ry)) && ((x) < ((rx) + (rw))) && ((y) < ((ry) + (rh)))) 94 95 #define DEFAULT_FONT "yudit/11" 96 #define DEFAULT_MENU_FONT "yudit/10" 97 #define DEFAULT_FONT_BIG "yudit/12" 98 #define DEFAULT_FONT_TITLE "yudit/14" 99 100 enum mode_type { MODE_NORMAL = 0, MODE_PAN, MODE_ZOOM, MODE_ROTATE, MODE_BLUR, MODE_NEXT 101 }; 102 103 enum bgmode_type { BG_MODE_NONE = 0, BG_MODE_TILE, BG_MODE_CENTER, 104 BG_MODE_SCALE, BG_MODE_FILL, BG_MODE_MAX 105 }; 106 107 enum zoom_mode { ZOOM_MODE_FILL = 1, ZOOM_MODE_MAX }; 108 109 enum text_bg { TEXT_BG_CLEAR = 0, TEXT_BG_TINTED }; 110 111 enum slide_change { SLIDE_NEXT, SLIDE_PREV, SLIDE_RAND, SLIDE_FIRST, SLIDE_LAST, 112 SLIDE_JUMP_FWD, 113 SLIDE_JUMP_BACK, 114 SLIDE_JUMP_NEXT_DIR, 115 SLIDE_JUMP_PREV_DIR 116 }; 117 118 #define INPLACE_EDIT_FLIP -1 119 #define INPLACE_EDIT_MIRROR -2 120 121 #define ZOOM_MIN 0.002 122 #define ZOOM_MAX 2000 123 124 typedef void (*sighandler_t) (int); 125 126 int feh_main_iteration(int block); 127 void feh_handle_event(XEvent * ev); 128 void init_imlib_fonts(void); 129 void init_x_and_imlib(void); 130 #ifdef HAVE_LIBXINERAMA 131 void init_xinerama(void); 132 #endif /* HAVE_LIBXINERAMA */ 133 void init_multiwindow_mode(void); 134 void init_thumbnail_mode(void); 135 void init_index_mode(void); 136 void init_slideshow_mode(void); 137 void init_list_mode(void); 138 void init_loadables_mode(void); 139 void init_unloadables_mode(void); 140 void feh_clean_exit(void); 141 int feh_should_ignore_image(Imlib_Image * im); 142 int feh_load_image(Imlib_Image * im, feh_file * file); 143 void show_mini_usage(void); 144 void slideshow_change_image(winwidget winwid, int change, int render); 145 void slideshow_pause_toggle(winwidget w); 146 void init_keyevents(void); 147 void init_buttonbindings(void); 148 void setup_stdin(void); 149 void restore_stdin(void); 150 void feh_event_handle_keypress(XEvent * ev); 151 void feh_event_handle_stdin(); 152 void feh_event_handle_generic(winwidget winwid, unsigned int state, KeySym keysym, unsigned int button); 153 fehkey *feh_str_to_kb(char * action); 154 void feh_action_run(feh_file * file, char *action, winwidget winwid); 155 char *format_size(double size); 156 char *feh_printf(char *str, feh_file * file, winwidget winwid); 157 void im_weprintf(winwidget w, char *fmt, ...); 158 void feh_draw_zoom(winwidget w); 159 void feh_draw_checks(winwidget win); 160 void cb_slide_timer(void *data); 161 void cb_reload_timer(void *data); 162 int feh_load_image_char(Imlib_Image * im, char *filename); 163 void feh_draw_filename(winwidget w); 164 #ifdef HAVE_LIBEXIF 165 void feh_draw_exif(winwidget w); 166 #endif 167 void feh_draw_actions(winwidget w); 168 void feh_draw_caption(winwidget w); 169 void feh_draw_info(winwidget w); 170 void feh_draw_errstr(winwidget w); 171 void feh_display_status(char stat); 172 void real_loadables_mode(int loadable); 173 void feh_reload_image(winwidget w, int resize, int force_new); 174 void feh_filelist_image_remove(winwidget winwid, char do_delete); 175 void feh_imlib_print_load_error(char *file, winwidget w, Imlib_Load_Error err); 176 void slideshow_save_image(winwidget win); 177 void feh_edit_inplace(winwidget w, int orientation); 178 void feh_edit_inplace_lossless(winwidget w, int orientation); 179 gib_list *feh_wrap_string(char *text, int wrap_width, Imlib_Font fn, gib_style * style); 180 char *build_caption_filename(feh_file * file, short create_dir); 181 gib_list *feh_list_jump(gib_list * root, gib_list * l, int direction, int num); 182 #ifdef HAVE_INOTIFY 183 void feh_event_handle_inotify(void); 184 #endif 185 #ifndef HAVE_STRVERSCMP 186 int strverscmp(const char *l0, const char *r0); 187 #endif 188 189 /* Imlib stuff */ 190 extern Display *disp; 191 extern Visual *vis; 192 extern Colormap cm; 193 extern int depth; 194 extern Atom wmDeleteWindow; 195 196 #ifdef HAVE_LIBXINERAMA 197 extern int num_xinerama_screens; 198 extern XineramaScreenInfo *xinerama_screens; 199 extern int xinerama_screen; 200 #endif /* HAVE_LIBXINERAMA */ 201 202 /* Thumbnail sizes */ 203 extern int cmdargc; 204 extern char **cmdargv; 205 extern Window root; 206 extern XContext xid_context; 207 extern Screen *scr; 208 extern unsigned char reset_output; 209 extern feh_menu *menu_main; 210 extern feh_menu *menu_close; 211 extern char *mode; /* label for the current mode */ 212 213 /* to terminate long-running children with SIGALRM */ 214 extern int childpid; 215 216 extern unsigned char control_via_stdin; 217 218 #endif 219