aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO1
-rw-r--r--config.h2
-rw-r--r--icon.h178
-rw-r--r--image.c37
-rw-r--r--image.h1
-rw-r--r--main.c16
6 files changed, 213 insertions, 22 deletions
diff --git a/TODO b/TODO
deleted file mode 100644
index b4e9732..0000000
--- a/TODO
+++ /dev/null
@@ -1 +0,0 @@
-- update filelist if image is removed or renamed while running
diff --git a/config.h b/config.h
index 6105599..8f773d5 100644
--- a/config.h
+++ b/config.h
@@ -5,7 +5,7 @@
/* default color to use for window background: *
* (see X(7) "COLOR NAMES" section for valid values) */
-#define BG_COLOR "#888888"
+#define BG_COLOR "#999999"
/* how should images be scaled when they are loaded?: *
* (also controllable via -d/-s/-Z/-z options) *
diff --git a/icon.h b/icon.h
new file mode 100644
index 0000000..4059a08
--- /dev/null
+++ b/icon.h
@@ -0,0 +1,178 @@
+#ifndef ICON_H
+#define ICON_H
+
+static DATA32 icon_warn[] = {
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xff000000, 0xff000000, 0xff000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xff000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xff000000, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xff666666, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xff000000,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000,
+ 0xff666666, 0xff666666, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xff000000, 0xff666666, 0xff666666, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xff666666,
+ 0xff666666, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xff000000, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xff000000, 0xff666666, 0xff666666, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xff000000,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xff666666, 0xff666666,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xff000000, 0xff666666, 0xff666666, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xff000000, 0xff000000, 0xff000000, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xff000000, 0xff666666, 0xff666666, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xff000000, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
+ 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000,
+ 0xff666666, 0xff666666, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xff000000,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xff000000,
+ 0xff000000, 0xff000000, 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xff000000, 0xff666666, 0xff666666, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xff666666,
+ 0xff666666, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
+ 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xff000000, 0xff666666, 0xff666666, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xff000000, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xff000000,
+ 0xff000000, 0xff000000, 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xff666666, 0xff666666,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xff000000,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000,
+ 0xff666666, 0xff666666, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xff000000, 0xff000000,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xff000000, 0xff666666, 0xff666666, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000,
+ 0xff000000, 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xff666666,
+ 0xff666666, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xff000000, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xff000000, 0xff000000, 0xff000000, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xff000000, 0xff666666, 0xff666666, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xff000000,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xff666666, 0xff666666,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xff000000, 0xff666666, 0xff666666, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xff000000, 0xff666666, 0xff666666, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0xff000000, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xff000000,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000,
+ 0xff666666, 0xff666666, 0x00000000, 0x00000000, 0x00000000, 0xff000000,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000,
+ 0xff000000, 0xff000000, 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xff000000, 0xff666666, 0xff666666, 0x00000000, 0x00000000,
+ 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xff666666,
+ 0xff666666, 0x00000000, 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xff000000,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xff000000, 0xff666666, 0xff666666, 0x00000000, 0xff000000, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xff000000, 0xff666666, 0xff666666, 0xff666666,
+ 0xff000000, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000, 0xff666666,
+ 0xff666666, 0xff666666, 0x00000000, 0xff000000, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00,
+ 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xffffff00, 0xff000000,
+ 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0x00000000, 0x00000000,
+ 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
+ 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
+ 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
+ 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000, 0xff000000,
+ 0xff000000, 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0xff666666, 0xff666666,
+ 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666,
+ 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666,
+ 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666,
+ 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666,
+ 0xff666666, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666,
+ 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666,
+ 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666,
+ 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666, 0xff666666,
+ 0xff666666, 0xff666666, 0x00000000, 0x00000000
+};
+
+#endif /* ICON_H */
diff --git a/image.c b/image.c
index d4b59c9..d68eb52 100644
--- a/image.c
+++ b/image.c
@@ -16,9 +16,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include <unistd.h>
#include <Imlib2.h>
#include "config.h"
+#include "icon.h"
#include "image.h"
#include "options.h"
#include "util.h"
@@ -57,7 +59,7 @@ int _imlib_load_image(const char *filename) {
if (!filename)
return 0;
- if (!(im = imlib_load_image(filename))) {
+ if (access(filename, F_OK) || !(im = imlib_load_image(filename))) {
warn("could not open file: %s", filename);
return 0;
}
@@ -77,18 +79,25 @@ int img_check(const char *filename) {
}
int img_load(img_t *img, const char *filename) {
+ Imlib_Image *im_warn;
+
if (!img || !filename)
return 0;
if (imlib_context_get_image())
imlib_free_image();
- if (!_imlib_load_image(filename))
- return 0;
-
- imlib_context_set_anti_alias(img->aa);
+ if ((img->valid = _imlib_load_image(filename))) {
+ imlib_context_set_anti_alias(img->aa);
+ img->scalemode = options->scalemode;
+ } else {
+ im_warn = imlib_create_image_using_data(32, 32, icon_warn);
+ imlib_context_set_image(im_warn);
+ imlib_image_set_has_alpha(1);
+ imlib_context_set_anti_alias(0);
+ img->scalemode = SCALE_DOWN;
+ }
- img->scalemode = options->scalemode;
img->re = 0;
img->checkpan = 0;
@@ -194,7 +203,7 @@ void img_render(img_t *img, win_t *win) {
}
int img_fit_win(img_t *img, win_t *win) {
- if (!img || !win)
+ if (!img || !img->valid || !win)
return 0;
img->scalemode = SCALE_FIT;
@@ -217,7 +226,7 @@ int img_center(img_t *img, win_t *win) {
}
int img_zoom(img_t *img, float z) {
- if (!img)
+ if (!img || !img->valid)
return 0;
z = MAX(z, zoom_min);
@@ -239,7 +248,7 @@ int img_zoom(img_t *img, float z) {
int img_zoom_in(img_t *img) {
int i;
- if (!img)
+ if (!img || !img->valid)
return 0;
for (i = 1; i < zl_cnt; ++i) {
@@ -252,7 +261,7 @@ int img_zoom_in(img_t *img) {
int img_zoom_out(img_t *img) {
int i;
- if (!img)
+ if (!img || !img->valid)
return 0;
for (i = zl_cnt - 2; i >= 0; --i) {
@@ -265,7 +274,7 @@ int img_zoom_out(img_t *img) {
int img_move(img_t *img, win_t *win, int dx, int dy) {
int ox, oy;
- if (!img || !win)
+ if (!img || !img->valid || !win)
return 0;
ox = img->x;
@@ -280,7 +289,7 @@ int img_move(img_t *img, win_t *win, int dx, int dy) {
}
int img_pan(img_t *img, win_t *win, pandir_t dir) {
- if (!img || !win)
+ if (!img || !img->valid || !win)
return 0;
switch (dir) {
@@ -300,7 +309,7 @@ int img_pan(img_t *img, win_t *win, pandir_t dir) {
void img_rotate(img_t *img, win_t *win, int d) {
int ox, oy, tmp;
- if (!img || !win)
+ if (!img || !img->valid || !win)
return;
ox = d == 1 ? img->x : win->w - img->x - img->w * img->zoom;
@@ -327,7 +336,7 @@ void img_rotate_right(img_t *img, win_t *win) {
}
void img_toggle_antialias(img_t *img) {
- if (!img)
+ if (!img || !img->valid)
return;
img->aa ^= 1;
diff --git a/image.h b/image.h
index 95ba949..fd5b0fe 100644
--- a/image.h
+++ b/image.h
@@ -38,6 +38,7 @@ typedef struct img_s {
float zoom;
scalemode_t scalemode;
+ unsigned char valid;
unsigned char re;
unsigned char checkpan;
unsigned char aa;
diff --git a/main.c b/main.c
index b0efc68..f449df9 100644
--- a/main.c
+++ b/main.c
@@ -128,12 +128,17 @@ void update_title() {
float size;
const char *unit;
- size = filesize;
- size_readable(&size, &unit);
+ if (img.valid) {
+ size = filesize;
+ size_readable(&size, &unit);
+ n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] <%d%%> (%.2f%s) %s",
+ fileidx + 1, filecnt, (int) (img.zoom * 100.0), size, unit,
+ filenames[fileidx]);
+ } else {
+ n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] broken: %s",
+ fileidx + 1, filecnt, filenames[fileidx]);
+ }
- n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] <%d%%> (%.2f%s) %s",
- fileidx + 1, filecnt, (int) (img.zoom * 100.0), size, unit,
- filenames[fileidx]);
if (n >= TITLE_LEN) {
win_title[TITLE_LEN - 2] = '.';
win_title[TITLE_LEN - 3] = '.';
@@ -350,7 +355,6 @@ void on_keypress(XKeyEvent *kev) {
case XK_r:
changed = load_image();
break;
-;
}
if (changed) {