Newer
Older
/* winwidget.c
Copyright (C) 1999-2003 Tom Gilbert.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies of the Software and its documentation and acknowledgment shall be
given in the documentation and software packages that this Software was
used.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "feh.h"
#include "filelist.h"
#include "winwidget.h"
#include "options.h"
static void winwidget_unregister(winwidget win);
static void winwidget_register(winwidget win);
static winwidget winwidget_allocate(void);
static char bm_no_data[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
int window_num = 0; /* For window list */
winwidget *windows = NULL; /* List of windows to loop though */
static winwidget winwidget_allocate(void)
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
winwidget ret = NULL;
D_ENTER(4);
ret = emalloc(sizeof(_winwidget));
ret->win = 0;
ret->w = 0;
ret->h = 0;
ret->full_screen = 0;
ret->im_w = 0;
ret->im_h = 0;
ret->im_angle = 0;
ret->bg_pmap = 0;
ret->bg_pmap_cache = 0;
ret->im = NULL;
ret->name = NULL;
ret->file = NULL;
ret->type = WIN_TYPE_UNSET;
ret->visible = 0;
ret->caption_entry = 0;
/* Zoom stuff */
ret->mode = MODE_NORMAL;
ret->gc = None;
/* New stuff */
ret->im_x = 0;
ret->im_y = 0;
ret->zoom = 1.0;
ret->click_offset_x = 0;
ret->click_offset_y = 0;
ret->im_click_offset_x = 0;
ret->im_click_offset_y = 0;
ret->has_rotated = 0;
D_RETURN(4, ret);
winwidget winwidget_create_from_image(Imlib_Image im, char *name, char type)
winwidget ret = NULL;
D_ENTER(4);
if (im == NULL)
D_RETURN(4, NULL);
ret = winwidget_allocate();
ret->type = type;
ret->im = im;
ret->w = ret->im_w = gib_imlib_image_get_width(ret->im);
ret->h = ret->im_h = gib_imlib_image_get_height(ret->im);
if (name)
ret->name = estrdup(name);
else
ret->name = estrdup(PACKAGE);
if (opt.full_screen)
ret->full_screen = True;
winwidget_create_window(ret, ret->w, ret->h);
winwidget_render_image(ret, 1, 1);
D_RETURN(4, ret);
winwidget winwidget_create_from_file(gib_list * list, char *name, char type)
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
winwidget ret = NULL;
feh_file *file = FEH_FILE(list->data);
D_ENTER(4);
if (!file || !file->filename)
D_RETURN(4, NULL);
ret = winwidget_allocate();
ret->file = list;
ret->type = type;
if (name)
ret->name = estrdup(name);
else
ret->name = estrdup(file->filename);
if (winwidget_loadimage(ret, file) == 0) {
winwidget_destroy(ret);
D_RETURN(4, NULL);
}
if (!ret->win) {
ret->w = ret->im_w = gib_imlib_image_get_width(ret->im);
ret->h = ret->im_h = gib_imlib_image_get_height(ret->im);
D(3, ("image is %dx%d pixels, format %s\n", ret->w, ret->h, gib_imlib_image_format(ret->im)));
if (opt.full_screen)
ret->full_screen = True;
winwidget_create_window(ret, ret->w, ret->h);
winwidget_render_image(ret, 1, 1);
}
D_RETURN(4, ret);
void winwidget_create_window(winwidget ret, int w, int h)
XSetWindowAttributes attr;
XEvent ev;
XClassHint *xch;
MWMHints mwmhints;
Atom prop = None;
int x = 0;
int y = 0;
D_ENTER(4);
if (ret->full_screen) {
w = scr->width;
h = scr->height;
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
if (opt.xinerama && xinerama_screens) {
w = xinerama_screens[xinerama_screen].width;
h = xinerama_screens[xinerama_screen].height;
}
#endif /* HAVE_LIBXINERAMA */
} else if (opt.geom_flags) {
if (opt.geom_flags & WidthValue) {
w = opt.geom_w;
}
if (opt.geom_flags & HeightValue) {
h = opt.geom_h;
}
if (opt.geom_flags & XValue) {
if (opt.geom_flags & XNegative) {
x = scr->width - opt.geom_x;
} else {
x = opt.geom_x;
}
}
if (opt.geom_flags & YValue) {
if (opt.geom_flags & YNegative) {
y = scr->height - opt.geom_y;
} else {
y = opt.geom_y;
}
}
} else if (opt.screen_clip) {
if (w > scr->width)
w = scr->width;
if (h > scr->height)
h = scr->height;
if (opt.xinerama && xinerama_screens) {
if (w > xinerama_screens[xinerama_screen].width)
w = xinerama_screens[xinerama_screen].width;
if (h > xinerama_screens[xinerama_screen].height)
Loading
Loading full blame...