mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 12:58:08 +01:00
util/wmiv: correct errors and warnings
This patch is correcting all errors and almost all warnings reported by checkpatch.
This commit is contained in:
committed by
Carlos R. Mafra
parent
057048e09b
commit
5ee39b7a27
294
util/wmiv.c
294
util/wmiv.c
@@ -18,7 +18,9 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if !defined(_GNU_SOURCE)
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#endif
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
@@ -38,8 +40,8 @@
|
|||||||
|
|
||||||
#ifdef USE_XPM
|
#ifdef USE_XPM
|
||||||
extern int XpmCreatePixmapFromData(Display *, Drawable, char **, Pixmap *, Pixmap *, void *);
|
extern int XpmCreatePixmapFromData(Display *, Drawable, char **, Pixmap *, Pixmap *, void *);
|
||||||
/* this is the icon from eog project
|
/* this is the icon from eog project
|
||||||
git.gnome.org/browse/eog
|
git.gnome.org/browse/eog
|
||||||
*/
|
*/
|
||||||
#include "wmiv.h"
|
#include "wmiv.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -82,7 +84,7 @@ RColor red;
|
|||||||
|
|
||||||
typedef struct link link_t;
|
typedef struct link link_t;
|
||||||
struct link {
|
struct link {
|
||||||
const void * data;
|
const void *data;
|
||||||
link_t *prev;
|
link_t *prev;
|
||||||
link_t *next;
|
link_t *next;
|
||||||
};
|
};
|
||||||
@@ -100,7 +102,8 @@ link_t *current_link;
|
|||||||
change_title: used to change window title
|
change_title: used to change window title
|
||||||
return EXIT_SUCCESS on success, 1 on failure
|
return EXIT_SUCCESS on success, 1 on failure
|
||||||
*/
|
*/
|
||||||
int change_title(XTextProperty *prop, char *filename) {
|
int change_title(XTextProperty *prop, char *filename)
|
||||||
|
{
|
||||||
char *combined_title = NULL;
|
char *combined_title = NULL;
|
||||||
if (!asprintf(&combined_title, "%s - %u/%u - %s", APPNAME, current_index, max_index, filename))
|
if (!asprintf(&combined_title, "%s - %u/%u - %s", APPNAME, current_index, max_index, filename))
|
||||||
if (!asprintf(&combined_title, "%s - %u/%u", APPNAME, current_index, max_index))
|
if (!asprintf(&combined_title, "%s - %u/%u", APPNAME, current_index, max_index))
|
||||||
@@ -117,7 +120,8 @@ int change_title(XTextProperty *prop, char *filename) {
|
|||||||
rescale_image: used to rescale the current image based on the screen size
|
rescale_image: used to rescale the current image based on the screen size
|
||||||
return EXIT_SUCCESS on success
|
return EXIT_SUCCESS on success
|
||||||
*/
|
*/
|
||||||
int rescale_image() {
|
int rescale_image(void)
|
||||||
|
{
|
||||||
long final_width = img->width;
|
long final_width = img->width;
|
||||||
long final_height = img->height;
|
long final_height = img->height;
|
||||||
|
|
||||||
@@ -168,9 +172,11 @@ int rescale_image() {
|
|||||||
maximize_image: find the best image size for the current display
|
maximize_image: find the best image size for the current display
|
||||||
return EXIT_SUCCESS on success
|
return EXIT_SUCCESS on success
|
||||||
*/
|
*/
|
||||||
int maximize_image() {
|
int maximize_image(void)
|
||||||
|
{
|
||||||
rescale_image();
|
rescale_image();
|
||||||
XCopyArea(dpy, pix, win, ctx->copy_gc, 0, 0, img->width, img->height, max_width/2-img->width/2, max_height/2-img->height/2);
|
XCopyArea(dpy, pix, win, ctx->copy_gc, 0, 0,
|
||||||
|
img->width, img->height, max_width/2-img->width/2, max_height/2-img->height/2);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,22 +184,23 @@ int maximize_image() {
|
|||||||
merge_with_background: merge the current image with with a checkboard background
|
merge_with_background: merge the current image with with a checkboard background
|
||||||
return EXIT_SUCCESS on success, 1 on failure
|
return EXIT_SUCCESS on success, 1 on failure
|
||||||
*/
|
*/
|
||||||
int merge_with_background(RImage *i) {
|
int merge_with_background(RImage *i)
|
||||||
|
{
|
||||||
if (i) {
|
if (i) {
|
||||||
RImage *back;
|
RImage *back;
|
||||||
back = RCreateImage(i->width, i->height, True);
|
back = RCreateImage(i->width, i->height, True);
|
||||||
if (back) {
|
if (back) {
|
||||||
int opaq = 255;
|
int opaq = 255;
|
||||||
int x=0, y=0;
|
int x = 0, y = 0;
|
||||||
|
|
||||||
RFillImage(back, &lightGray);
|
RFillImage(back, &lightGray);
|
||||||
for (x=0; x <= i->width; x+=8) {
|
for (x = 0; x <= i->width; x += 8) {
|
||||||
if (x/8 % 2)
|
if (x/8 % 2)
|
||||||
y = 8;
|
y = 8;
|
||||||
else
|
else
|
||||||
y = 0;
|
y = 0;
|
||||||
for (; y <= i->height; y+=16)
|
for (; y <= i->height; y += 16)
|
||||||
ROperateRectangle(back, RAddOperation, x,y,x+8,y+8, &darkGray);
|
ROperateRectangle(back, RAddOperation, x, y, x+8, y+8, &darkGray);
|
||||||
}
|
}
|
||||||
|
|
||||||
RCombineImagesWithOpaqueness(i, back, opaq);
|
RCombineImagesWithOpaqueness(i, back, opaq);
|
||||||
@@ -209,15 +216,15 @@ int merge_with_background(RImage *i) {
|
|||||||
return the image on success, NULL on failure
|
return the image on success, NULL on failure
|
||||||
|
|
||||||
*/
|
*/
|
||||||
RImage* draw_failed_image() {
|
RImage *draw_failed_image(void)
|
||||||
|
{
|
||||||
RImage *failed_image = NULL;
|
RImage *failed_image = NULL;
|
||||||
XWindowAttributes attr;
|
XWindowAttributes attr;
|
||||||
|
|
||||||
if (win && (XGetWindowAttributes(dpy, win, &attr) >= 0)) {
|
if (win && (XGetWindowAttributes(dpy, win, &attr) >= 0))
|
||||||
failed_image = RCreateImage(attr.width, attr.height, False);
|
failed_image = RCreateImage(attr.width, attr.height, False);
|
||||||
} else {
|
else
|
||||||
failed_image = RCreateImage(50, 50, False);
|
failed_image = RCreateImage(50, 50, False);
|
||||||
}
|
|
||||||
if (!failed_image)
|
if (!failed_image)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -232,7 +239,8 @@ RImage* draw_failed_image() {
|
|||||||
full_screen: sending event to the window manager to switch from/to full screen mode
|
full_screen: sending event to the window manager to switch from/to full screen mode
|
||||||
return EXIT_SUCCESS on success, 1 on failure
|
return EXIT_SUCCESS on success, 1 on failure
|
||||||
*/
|
*/
|
||||||
int full_screen() {
|
int full_screen(void)
|
||||||
|
{
|
||||||
XEvent xev;
|
XEvent xev;
|
||||||
|
|
||||||
Atom wm_state = XInternAtom(dpy, "_NET_WM_STATE", True);
|
Atom wm_state = XInternAtom(dpy, "_NET_WM_STATE", True);
|
||||||
@@ -268,7 +276,8 @@ int full_screen() {
|
|||||||
arg: 1 to zoom in, 0 to zoom out
|
arg: 1 to zoom in, 0 to zoom out
|
||||||
return EXIT_SUCCESS on success, 1 on failure
|
return EXIT_SUCCESS on success, 1 on failure
|
||||||
*/
|
*/
|
||||||
int zoom_in_out(int z) {
|
int zoom_in_out(int z)
|
||||||
|
{
|
||||||
RImage *old_img = img;
|
RImage *old_img = img;
|
||||||
RImage *tmp = RLoadImage(ctx, current_link->data, 0);
|
RImage *tmp = RLoadImage(ctx, current_link->data, 0);
|
||||||
if (!tmp)
|
if (!tmp)
|
||||||
@@ -276,7 +285,8 @@ int zoom_in_out(int z) {
|
|||||||
|
|
||||||
if (z) {
|
if (z) {
|
||||||
zoom_factor += 0.2;
|
zoom_factor += 0.2;
|
||||||
img = RScaleImage(tmp, tmp->width + (int)(tmp->width * zoom_factor), tmp->height + (int)(tmp->height * zoom_factor));
|
img = RScaleImage(tmp, tmp->width + (int)(tmp->width * zoom_factor),
|
||||||
|
tmp->height + (int)(tmp->height * zoom_factor));
|
||||||
if (!img) {
|
if (!img) {
|
||||||
img = old_img;
|
img = old_img;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@@ -313,7 +323,8 @@ int zoom_in_out(int z) {
|
|||||||
zoom_in: transitional fct used to call zoom_in_out with zoom in flag
|
zoom_in: transitional fct used to call zoom_in_out with zoom in flag
|
||||||
return EXIT_SUCCESS on success, 1 on failure
|
return EXIT_SUCCESS on success, 1 on failure
|
||||||
*/
|
*/
|
||||||
int zoom_in() {
|
int zoom_in(void)
|
||||||
|
{
|
||||||
return zoom_in_out(1);
|
return zoom_in_out(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,7 +332,8 @@ int zoom_in() {
|
|||||||
zoom_out: transitional fct used to call zoom_in_out with zoom out flag
|
zoom_out: transitional fct used to call zoom_in_out with zoom out flag
|
||||||
return EXIT_SUCCESS on success, 1 on failure
|
return EXIT_SUCCESS on success, 1 on failure
|
||||||
*/
|
*/
|
||||||
int zoom_out() {
|
int zoom_out(void)
|
||||||
|
{
|
||||||
return zoom_in_out(0);
|
return zoom_in_out(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -330,7 +342,8 @@ int zoom_out() {
|
|||||||
arg: way which could be PREV or NEXT constant
|
arg: way which could be PREV or NEXT constant
|
||||||
return EXIT_SUCCESS on success, 1 on failure
|
return EXIT_SUCCESS on success, 1 on failure
|
||||||
*/
|
*/
|
||||||
int change_image(int way) {
|
int change_image(int way)
|
||||||
|
{
|
||||||
if (img && current_link) {
|
if (img && current_link) {
|
||||||
int old_img_width = img->width;
|
int old_img_width = img->width;
|
||||||
int old_img_height = img->height;
|
int old_img_height = img->height;
|
||||||
@@ -358,22 +371,23 @@ int change_image(int way) {
|
|||||||
img = RLoadImage(ctx, current_link->data, 0);
|
img = RLoadImage(ctx, current_link->data, 0);
|
||||||
|
|
||||||
if (!img) {
|
if (!img) {
|
||||||
fprintf(stderr, "Error: %s %s\n", (char *)current_link->data, RMessageForError(RErrorCode));
|
fprintf(stderr, "Error: %s %s\n", (char *)current_link->data,
|
||||||
|
RMessageForError(RErrorCode));
|
||||||
img = draw_failed_image();
|
img = draw_failed_image();
|
||||||
} else {
|
} else {
|
||||||
merge_with_background(img);
|
merge_with_background(img);
|
||||||
}
|
}
|
||||||
rescale_image();
|
rescale_image();
|
||||||
if (!fullscreen_flag) {
|
if (!fullscreen_flag) {
|
||||||
if ((old_img_width != img->width) || (old_img_height != img->height)) {
|
if ((old_img_width != img->width) || (old_img_height != img->height))
|
||||||
XResizeWindow(dpy, win, img->width, img->height);
|
XResizeWindow(dpy, win, img->width, img->height);
|
||||||
} else {
|
else
|
||||||
XCopyArea(dpy, pix, win, ctx->copy_gc, 0, 0, img->width, img->height, 0, 0);
|
XCopyArea(dpy, pix, win, ctx->copy_gc, 0, 0, img->width, img->height, 0, 0);
|
||||||
}
|
|
||||||
change_title(&title_property, (char *)current_link->data);
|
change_title(&title_property, (char *)current_link->data);
|
||||||
} else {
|
} else {
|
||||||
XClearWindow(dpy, win);
|
XClearWindow(dpy, win);
|
||||||
XCopyArea(dpy, pix, win, ctx->copy_gc, 0, 0, img->width, img->height, max_width/2-img->width/2, max_height/2-img->height/2);
|
XCopyArea(dpy, pix, win, ctx->copy_gc, 0, 0,
|
||||||
|
img->width, img->height, max_width/2-img->width/2, max_height/2-img->height/2);
|
||||||
}
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
@@ -386,7 +400,8 @@ int change_image(int way) {
|
|||||||
arg: not used
|
arg: not used
|
||||||
return void
|
return void
|
||||||
*/
|
*/
|
||||||
void* diaporama(void *arg) {
|
void *diaporama(void *arg)
|
||||||
|
{
|
||||||
(void) arg;
|
(void) arg;
|
||||||
|
|
||||||
XKeyEvent event;
|
XKeyEvent event;
|
||||||
@@ -404,7 +419,7 @@ void* diaporama(void *arg) {
|
|||||||
event.state = 0;
|
event.state = 0;
|
||||||
event.type = KeyPress;
|
event.type = KeyPress;
|
||||||
|
|
||||||
while(diaporama_flag) {
|
while (diaporama_flag) {
|
||||||
int r;
|
int r;
|
||||||
r = XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event);
|
r = XSendEvent(event.display, event.window, True, KeyPressMask, (XEvent *)&event);
|
||||||
if (!r)
|
if (!r)
|
||||||
@@ -421,7 +436,8 @@ void* diaporama(void *arg) {
|
|||||||
/*
|
/*
|
||||||
linked_list_init: init the linked list
|
linked_list_init: init the linked list
|
||||||
*/
|
*/
|
||||||
void linked_list_init (linked_list_t *list) {
|
void linked_list_init(linked_list_t *list)
|
||||||
|
{
|
||||||
list->first = list->last = 0;
|
list->first = list->last = 0;
|
||||||
list->count = 0;
|
list->count = 0;
|
||||||
}
|
}
|
||||||
@@ -430,13 +446,14 @@ void linked_list_init (linked_list_t *list) {
|
|||||||
linked_list_add: add an element to the linked list
|
linked_list_add: add an element to the linked list
|
||||||
return EXIT_SUCCESS on success, 1 otherwise
|
return EXIT_SUCCESS on success, 1 otherwise
|
||||||
*/
|
*/
|
||||||
int linked_list_add (linked_list_t *list, const void *data) {
|
int linked_list_add(linked_list_t *list, const void *data)
|
||||||
|
{
|
||||||
link_t *link;
|
link_t *link;
|
||||||
|
|
||||||
/* calloc sets the "next" field to zero. */
|
/* calloc sets the "next" field to zero. */
|
||||||
link = calloc (1, sizeof (link_t));
|
link = calloc(1, sizeof(link_t));
|
||||||
if (! link) {
|
if (!link) {
|
||||||
fprintf (stderr, "calloc failed.\n");
|
fprintf(stderr, "calloc failed.\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
link->data = data;
|
link->data = data;
|
||||||
@@ -456,7 +473,8 @@ int linked_list_add (linked_list_t *list, const void *data) {
|
|||||||
/*
|
/*
|
||||||
linked_list_free: deallocate the whole linked list
|
linked_list_free: deallocate the whole linked list
|
||||||
*/
|
*/
|
||||||
void linked_list_free (linked_list_t *list) {
|
void linked_list_free(linked_list_t *list)
|
||||||
|
{
|
||||||
link_t *link;
|
link_t *link;
|
||||||
link_t *next;
|
link_t *next;
|
||||||
for (link = list->first; link; link = next) {
|
for (link = list->first; link; link = next) {
|
||||||
@@ -464,7 +482,7 @@ void linked_list_free (linked_list_t *list) {
|
|||||||
next = link->next;
|
next = link->next;
|
||||||
if (link->data)
|
if (link->data)
|
||||||
free((char *)link->data);
|
free((char *)link->data);
|
||||||
free (link);
|
free(link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,7 +491,8 @@ void linked_list_free (linked_list_t *list) {
|
|||||||
arg: the directory path that contains images, the linked list where to add the new file refs
|
arg: the directory path that contains images, the linked list where to add the new file refs
|
||||||
return: the first argument of the list or NULL on failure
|
return: the first argument of the list or NULL on failure
|
||||||
*/
|
*/
|
||||||
link_t* connect_dir(char *dirpath, linked_list_t *li) {
|
link_t *connect_dir(char *dirpath, linked_list_t *li)
|
||||||
|
{
|
||||||
struct dirent **dir;
|
struct dirent **dir;
|
||||||
int dv, idx;
|
int dv, idx;
|
||||||
char path[PATH_MAX] = "";
|
char path[PATH_MAX] = "";
|
||||||
@@ -486,7 +505,7 @@ link_t* connect_dir(char *dirpath, linked_list_t *li) {
|
|||||||
/* maybe it's a file */
|
/* maybe it's a file */
|
||||||
struct stat stDirInfo;
|
struct stat stDirInfo;
|
||||||
if (lstat(dirpath, &stDirInfo) == 0) {
|
if (lstat(dirpath, &stDirInfo) == 0) {
|
||||||
linked_list_add (li, strdup(dirpath));
|
linked_list_add(li, strdup(dirpath));
|
||||||
return li->first;
|
return li->first;
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -500,9 +519,8 @@ link_t* connect_dir(char *dirpath, linked_list_t *li) {
|
|||||||
snprintf(path, PATH_MAX, "%s%c%s", dirpath, FILE_SEPARATOR, dir[idx]->d_name);
|
snprintf(path, PATH_MAX, "%s%c%s", dirpath, FILE_SEPARATOR, dir[idx]->d_name);
|
||||||
|
|
||||||
free(dir[idx]);
|
free(dir[idx]);
|
||||||
if ((lstat(path, &stDirInfo) == 0) && !S_ISDIR(stDirInfo.st_mode)) {
|
if ((lstat(path, &stDirInfo) == 0) && !S_ISDIR(stDirInfo.st_mode))
|
||||||
linked_list_add (li, strdup(path));
|
linked_list_add(li, strdup(path));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
free(dir);
|
free(dir);
|
||||||
return li->first;
|
return li->first;
|
||||||
@@ -511,7 +529,8 @@ link_t* connect_dir(char *dirpath, linked_list_t *li) {
|
|||||||
/*
|
/*
|
||||||
main
|
main
|
||||||
*/
|
*/
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
int option = -1;
|
int option = -1;
|
||||||
RContextAttributes attr;
|
RContextAttributes attr;
|
||||||
XEvent e;
|
XEvent e;
|
||||||
@@ -525,8 +544,8 @@ int main(int argc, char **argv) {
|
|||||||
#ifdef USE_XPM
|
#ifdef USE_XPM
|
||||||
Pixmap icon_pixmap, icon_shape;
|
Pixmap icon_pixmap, icon_shape;
|
||||||
#endif
|
#endif
|
||||||
|
class_hints = XAllocClassHint();
|
||||||
if (!(class_hints = XAllocClassHint())) {
|
if (!class_hints) {
|
||||||
fprintf(stderr, "Error: failure allocating memory\n");
|
fprintf(stderr, "Error: failure allocating memory\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
@@ -541,38 +560,39 @@ int main(int argc, char **argv) {
|
|||||||
red.red = 255;
|
red.red = 255;
|
||||||
red.green = red.blue = 0;
|
red.green = red.blue = 0;
|
||||||
|
|
||||||
if ((option = getopt(argc, argv, "hv")) != -1) {
|
option = getopt(argc, argv, "hv");
|
||||||
|
if (option != -1) {
|
||||||
switch (option) {
|
switch (option) {
|
||||||
case 'h':
|
case 'h':
|
||||||
fprintf(stderr, "Usage: %s [image(s)|directory]\n"
|
fprintf(stderr, "Usage: %s [image(s)|directory]\n"
|
||||||
"Keys:\n"
|
"Keys:\n"
|
||||||
"+: zoom in\n"
|
"+: zoom in\n"
|
||||||
"-: zoom out\n"
|
"-: zoom out\n"
|
||||||
"esc: actual size\n"
|
"esc: actual size\n"
|
||||||
#ifdef HAVE_PTHREAD
|
#ifdef HAVE_PTHREAD
|
||||||
"d: launch diaporama mode\n"
|
"d: launch diaporama mode\n"
|
||||||
#endif
|
#endif
|
||||||
"q: quit\n"
|
"q: quit\n"
|
||||||
"right: next image\n"
|
"right: next image\n"
|
||||||
"left: previous image\n"
|
"left: previous image\n"
|
||||||
"up: first image\n"
|
"up: first image\n"
|
||||||
"down: last image\n",
|
"down: last image\n",
|
||||||
argv[0]);
|
argv[0]);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
case 'v':
|
case 'v':
|
||||||
fprintf(stderr, "%s version %d.%d\n", APPNAME, APPVERSION_MAJOR, APPVERSION_MINOR);
|
fprintf(stderr, "%s version %d.%d\n", APPNAME, APPVERSION_MAJOR, APPVERSION_MINOR);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
case '?':
|
case '?':
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
linked_list_init (&list);
|
linked_list_init(&list);
|
||||||
|
|
||||||
dpy = XOpenDisplay(NULL);
|
dpy = XOpenDisplay(NULL);
|
||||||
if (!dpy) {
|
if (!dpy) {
|
||||||
fprintf(stderr, "Error: can't open display");
|
fprintf(stderr, "Error: can't open display");
|
||||||
linked_list_free (&list);
|
linked_list_free(&list);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -613,10 +633,12 @@ int main(int argc, char **argv) {
|
|||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
fprintf(stderr, "display size: %dx%d\n", max_width, max_height);
|
fprintf(stderr, "display size: %dx%d\n", max_width, max_height);
|
||||||
|
|
||||||
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, img->width, img->height, 0, 0, BlackPixel(dpy, screen));
|
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0,
|
||||||
|
img->width, img->height, 0, 0, BlackPixel(dpy, screen));
|
||||||
XSelectInput(dpy, win, KeyPressMask|StructureNotifyMask|ExposureMask|ButtonPressMask|FocusChangeMask);
|
XSelectInput(dpy, win, KeyPressMask|StructureNotifyMask|ExposureMask|ButtonPressMask|FocusChangeMask);
|
||||||
|
|
||||||
if (!(size_hints = XAllocSizeHints())) {
|
size_hints = XAllocSizeHints();
|
||||||
|
if (!size_hints) {
|
||||||
fprintf(stderr, "Error: failure allocating memory\n");
|
fprintf(stderr, "Error: failure allocating memory\n");
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
@@ -706,28 +728,28 @@ int main(int argc, char **argv) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (e.type == ButtonPress) {
|
if (e.type == ButtonPress) {
|
||||||
switch(e.xbutton.button) {
|
switch (e.xbutton.button) {
|
||||||
case Button1: {
|
case Button1: {
|
||||||
if (focus) {
|
if (focus) {
|
||||||
if (img && (e.xbutton.x > img->width/2))
|
if (img && (e.xbutton.x > img->width/2))
|
||||||
change_image(NEXT);
|
change_image(NEXT);
|
||||||
else
|
else
|
||||||
change_image(PREV);
|
change_image(PREV);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case Button4:
|
break;
|
||||||
zoom_in();
|
case Button4:
|
||||||
break;
|
zoom_in();
|
||||||
case Button5:
|
break;
|
||||||
zoom_out();
|
case Button5:
|
||||||
break;
|
zoom_out();
|
||||||
case 8:
|
break;
|
||||||
change_image(PREV);
|
case 8:
|
||||||
break;
|
change_image(PREV);
|
||||||
case 9:
|
break;
|
||||||
change_image(NEXT);
|
case 9:
|
||||||
break;
|
change_image(NEXT);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -738,60 +760,60 @@ int main(int argc, char **argv) {
|
|||||||
diaporama_flag = False;
|
diaporama_flag = False;
|
||||||
#endif
|
#endif
|
||||||
switch (keysym) {
|
switch (keysym) {
|
||||||
case XK_Right:
|
case XK_Right:
|
||||||
|
change_image(NEXT);
|
||||||
|
break;
|
||||||
|
case XK_Left:
|
||||||
|
change_image(PREV);
|
||||||
|
break;
|
||||||
|
case XK_Up:
|
||||||
|
if (current_link) {
|
||||||
|
current_link = list.last;
|
||||||
change_image(NEXT);
|
change_image(NEXT);
|
||||||
break;
|
}
|
||||||
case XK_Left:
|
break;
|
||||||
|
case XK_Down:
|
||||||
|
if (current_link) {
|
||||||
|
current_link = list.first;
|
||||||
change_image(PREV);
|
change_image(PREV);
|
||||||
break;
|
}
|
||||||
case XK_Up:
|
break;
|
||||||
if (current_link) {
|
|
||||||
current_link = list.last;
|
|
||||||
change_image(NEXT);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case XK_Down:
|
|
||||||
if (current_link) {
|
|
||||||
current_link = list.first;
|
|
||||||
change_image(PREV);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#ifdef HAVE_PTHREAD
|
#ifdef HAVE_PTHREAD
|
||||||
case XK_F5:
|
case XK_F5:
|
||||||
case XK_d:
|
case XK_d:
|
||||||
if (!tid) {
|
if (!tid) {
|
||||||
if (current_link && !diaporama_flag) {
|
if (current_link && !diaporama_flag) {
|
||||||
diaporama_flag = True;
|
diaporama_flag = True;
|
||||||
pthread_create(&tid, NULL, &diaporama, NULL);
|
pthread_create(&tid, NULL, &diaporama, NULL);
|
||||||
} else {
|
|
||||||
fprintf(stderr, "Can't use diaporama mode, need a picture directory\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case XK_q:
|
|
||||||
quit = 1;
|
|
||||||
break;
|
|
||||||
case XK_Escape:
|
|
||||||
if (!fullscreen_flag) {
|
|
||||||
zoom_factor = -0.2;
|
|
||||||
/* zoom_in will increase the zoom factor by 0.2 */
|
|
||||||
zoom_in();
|
|
||||||
} else {
|
} else {
|
||||||
/* we are in fullscreen mode already, want to return to normal size */
|
fprintf(stderr, "Can't use diaporama mode\n");
|
||||||
full_screen();
|
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case XK_plus:
|
break;
|
||||||
|
#endif
|
||||||
|
case XK_q:
|
||||||
|
quit = 1;
|
||||||
|
break;
|
||||||
|
case XK_Escape:
|
||||||
|
if (!fullscreen_flag) {
|
||||||
|
zoom_factor = -0.2;
|
||||||
|
/* zoom_in will increase the zoom factor by 0.2 */
|
||||||
zoom_in();
|
zoom_in();
|
||||||
break;
|
} else {
|
||||||
case XK_minus:
|
/* we are in fullscreen mode already, want to return to normal size */
|
||||||
zoom_out();
|
|
||||||
break;
|
|
||||||
case XK_F11:
|
|
||||||
case XK_f:
|
|
||||||
full_screen();
|
full_screen();
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
case XK_plus:
|
||||||
|
zoom_in();
|
||||||
|
break;
|
||||||
|
case XK_minus:
|
||||||
|
zoom_out();
|
||||||
|
break;
|
||||||
|
case XK_F11:
|
||||||
|
case XK_f:
|
||||||
|
full_screen();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user