1 /* winwidget.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 WINWIDGET_H
28 #define WINWIDGET_H
29 
30 /* This MWM stuff pinched from Eterm/src/command.h */
31 
32 # include <X11/X.h>
33 # include <X11/Xproto.h>
34 
35 /* Motif window hints */
36 #define MWM_HINTS_FUNCTIONS     (1L << 0)
37 #define MWM_HINTS_DECORATIONS   (1L << 1)
38 #define MWM_HINTS_INPUT_MODE    (1L << 2)
39 #define MWM_HINTS_STATUS        (1L << 3)
40 /* bit definitions for MwmHints.functions */
41 #define MWM_FUNC_ALL            (1L << 0)
42 #define MWM_FUNC_RESIZE         (1L << 1)
43 #define MWM_FUNC_MOVE           (1L << 2)
44 #define MWM_FUNC_MINIMIZE       (1L << 3)
45 #define MWM_FUNC_MAXIMIZE       (1L << 4)
46 #define MWM_FUNC_CLOSE          (1L << 5)
47 /* bit definitions for MwmHints.decorations */
48 #define MWM_DECOR_ALL           (1L << 0)
49 #define MWM_DECOR_BORDER        (1L << 1)
50 #define MWM_DECOR_RESIZEH       (1L << 2)
51 #define MWM_DECOR_TITLE         (1L << 3)
52 #define MWM_DECOR_MENU          (1L << 4)
53 #define MWM_DECOR_MINIMIZE      (1L << 5)
54 #define MWM_DECOR_MAXIMIZE      (1L << 6)
55 /* bit definitions for MwmHints.inputMode */
56 #define MWM_INPUT_MODELESS                  0
57 #define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
58 #define MWM_INPUT_SYSTEM_MODAL              2
59 #define MWM_INPUT_FULL_APPLICATION_MODAL    3
60 #define PROP_MWM_HINTS_ELEMENTS             5
61 
62 /* Motif window hints */
63 typedef struct _mwmhints {
64 	unsigned long flags;
65 	unsigned long functions;
66 	unsigned long decorations;
67 	long input_mode;
68 	unsigned long status;
69 } MWMHints;
70 
71 enum win_type {
72 	WIN_TYPE_UNSET, WIN_TYPE_SLIDESHOW, WIN_TYPE_SINGLE,
73 	WIN_TYPE_THUMBNAIL, WIN_TYPE_THUMBNAIL_VIEWER
74 };
75 
76 struct __winwidget {
77 	Window win;
78 	int x;
79 	int y;
80 	int w;
81 	int h;
82 	int im_w;
83 	int im_h;
84 	int force_aliasing;
85 	double im_angle;
86 	enum win_type type;
87 	unsigned char had_resize, full_screen;
88 	Imlib_Image im;
89 	GC gc;
90 	Pixmap bg_pmap;
91 	Pixmap bg_pmap_cache;
92 	char *name;
93 	gib_list *file;
94 	unsigned char visible;
95 	char *errstr;
96 
97 	/* panning, zooming, etc. */
98 	unsigned char mode;
99 
100 	unsigned char caption_entry;
101 
102 	/* image offset from window top left */
103 	int im_x;
104 	int im_y;
105 
106 	/* From 0 (not visible) to 1.00 (actual size)
107 	 * all the way up to INT_MAX (eww)
108 	 */
109 	double zoom;
110 	double old_zoom;
111 
112 	int click_offset_x;
113 	int click_offset_y;
114 	int im_click_offset_x;
115 	int im_click_offset_y;
116 	time_t click_start_time;
117 
118 	unsigned char has_rotated;
119 
120 #ifdef HAVE_INOTIFY
121 	int inotify_wd;
122 #endif
123 };
124 
125 #ifdef HAVE_INOTIFY
126 void winwidget_inotify_remove(winwidget winwid);
127 void winwidget_inotify_add(winwidget winwid, feh_file * file);
128 #endif
129 
130 int winwidget_loadimage(winwidget winwid, feh_file * filename);
131 void winwidget_show(winwidget winwid);
132 void winwidget_show_menu(winwidget winwid);
133 void winwidget_hide(winwidget winwid);
134 void winwidget_destroy_all(void);
135 void winwidget_free_image(winwidget w);
136 void winwidget_center_image(winwidget w);
137 void winwidget_render_image(winwidget winwid, int resize, int force_alias);
138 void winwidget_rotate_image(winwidget winid, double angle);
139 void winwidget_move(winwidget winwid, int x, int y);
140 void winwidget_resize(winwidget winwid, int w, int h, int force_resize);
141 void winwidget_setup_pixmaps(winwidget winwid);
142 void winwidget_update_title(winwidget ret);
143 void winwidget_update_caption(winwidget winwid);
144 void winwidget_rerender_all(int resize);
145 void winwidget_destroy_xwin(winwidget winwid);
146 
147 void winwidget_set_pointer(winwidget winwid, int visible);
148 
149 void winwidget_get_geometry(winwidget winwid, int *rect);
150 int winwidget_get_width(winwidget winwid);
151 int winwidget_get_height(winwidget winwid);
152 winwidget winwidget_get_from_window(Window win);
153 winwidget winwidget_create_from_file(gib_list * filename, char type);
154 winwidget winwidget_create_from_image(Imlib_Image im, char type);
155 void winwidget_rename(winwidget winwid, char *newname);
156 void winwidget_destroy(winwidget winwid);
157 void winwidget_create_window(winwidget ret, int w, int h);
158 Pixmap feh_create_checks(void);
159 double feh_calc_needed_zoom(double *zoom, int orig_w, int orig_h, int dest_w, int dest_h);
160 void feh_debug_print_winwid(winwidget winwid);
161 winwidget winwidget_get_first_window_of_type(unsigned int type);
162 void winwidget_reset_image(winwidget winwid);
163 void winwidget_sanitise_offsets(winwidget winwid);
164 void winwidget_size_to_image(winwidget winwid);
165 void winwidget_render_image_cached(winwidget winwid);
166 
167 extern int window_num;		/* For window list */
168 extern winwidget *windows;	/* List of windows to loop though */
169 
170 #endif
171