Handle image remove/rename while running
This commit is contained in:
parent
9be4734439
commit
8e5835d1fd
2
config.h
2
config.h
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
/* default color to use for window background: *
|
/* default color to use for window background: *
|
||||||
* (see X(7) "COLOR NAMES" section for valid values) */
|
* (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?: *
|
/* how should images be scaled when they are loaded?: *
|
||||||
* (also controllable via -d/-s/-Z/-z options) *
|
* (also controllable via -d/-s/-Z/-z options) *
|
||||||
|
|
|
@ -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 */
|
35
image.c
35
image.c
|
@ -16,9 +16,11 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
#include <Imlib2.h>
|
#include <Imlib2.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "icon.h"
|
||||||
#include "image.h"
|
#include "image.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -57,7 +59,7 @@ int _imlib_load_image(const char *filename) {
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return 0;
|
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);
|
warn("could not open file: %s", filename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -77,18 +79,25 @@ int img_check(const char *filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int img_load(img_t *img, const char *filename) {
|
int img_load(img_t *img, const char *filename) {
|
||||||
|
Imlib_Image *im_warn;
|
||||||
|
|
||||||
if (!img || !filename)
|
if (!img || !filename)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (imlib_context_get_image())
|
if (imlib_context_get_image())
|
||||||
imlib_free_image();
|
imlib_free_image();
|
||||||
|
|
||||||
if (!_imlib_load_image(filename))
|
if ((img->valid = _imlib_load_image(filename))) {
|
||||||
return 0;
|
|
||||||
|
|
||||||
imlib_context_set_anti_alias(img->aa);
|
imlib_context_set_anti_alias(img->aa);
|
||||||
|
|
||||||
img->scalemode = options->scalemode;
|
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->re = 0;
|
img->re = 0;
|
||||||
img->checkpan = 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) {
|
int img_fit_win(img_t *img, win_t *win) {
|
||||||
if (!img || !win)
|
if (!img || !img->valid || !win)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
img->scalemode = SCALE_FIT;
|
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) {
|
int img_zoom(img_t *img, float z) {
|
||||||
if (!img)
|
if (!img || !img->valid)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
z = MAX(z, zoom_min);
|
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 img_zoom_in(img_t *img) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!img)
|
if (!img || !img->valid)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i = 1; i < zl_cnt; ++i) {
|
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 img_zoom_out(img_t *img) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!img)
|
if (!img || !img->valid)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
for (i = zl_cnt - 2; i >= 0; --i) {
|
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 img_move(img_t *img, win_t *win, int dx, int dy) {
|
||||||
int ox, oy;
|
int ox, oy;
|
||||||
|
|
||||||
if (!img || !win)
|
if (!img || !img->valid || !win)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ox = img->x;
|
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) {
|
int img_pan(img_t *img, win_t *win, pandir_t dir) {
|
||||||
if (!img || !win)
|
if (!img || !img->valid || !win)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (dir) {
|
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) {
|
void img_rotate(img_t *img, win_t *win, int d) {
|
||||||
int ox, oy, tmp;
|
int ox, oy, tmp;
|
||||||
|
|
||||||
if (!img || !win)
|
if (!img || !img->valid || !win)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ox = d == 1 ? img->x : win->w - img->x - img->w * img->zoom;
|
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) {
|
void img_toggle_antialias(img_t *img) {
|
||||||
if (!img)
|
if (!img || !img->valid)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
img->aa ^= 1;
|
img->aa ^= 1;
|
||||||
|
|
1
image.h
1
image.h
|
@ -38,6 +38,7 @@ typedef struct img_s {
|
||||||
float zoom;
|
float zoom;
|
||||||
scalemode_t scalemode;
|
scalemode_t scalemode;
|
||||||
|
|
||||||
|
unsigned char valid;
|
||||||
unsigned char re;
|
unsigned char re;
|
||||||
unsigned char checkpan;
|
unsigned char checkpan;
|
||||||
unsigned char aa;
|
unsigned char aa;
|
||||||
|
|
8
main.c
8
main.c
|
@ -128,12 +128,17 @@ void update_title() {
|
||||||
float size;
|
float size;
|
||||||
const char *unit;
|
const char *unit;
|
||||||
|
|
||||||
|
if (img.valid) {
|
||||||
size = filesize;
|
size = filesize;
|
||||||
size_readable(&size, &unit);
|
size_readable(&size, &unit);
|
||||||
|
|
||||||
n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] <%d%%> (%.2f%s) %s",
|
n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] <%d%%> (%.2f%s) %s",
|
||||||
fileidx + 1, filecnt, (int) (img.zoom * 100.0), size, unit,
|
fileidx + 1, filecnt, (int) (img.zoom * 100.0), size, unit,
|
||||||
filenames[fileidx]);
|
filenames[fileidx]);
|
||||||
|
} else {
|
||||||
|
n = snprintf(win_title, TITLE_LEN, "sxiv: [%d/%d] broken: %s",
|
||||||
|
fileidx + 1, filecnt, filenames[fileidx]);
|
||||||
|
}
|
||||||
|
|
||||||
if (n >= TITLE_LEN) {
|
if (n >= TITLE_LEN) {
|
||||||
win_title[TITLE_LEN - 2] = '.';
|
win_title[TITLE_LEN - 2] = '.';
|
||||||
win_title[TITLE_LEN - 3] = '.';
|
win_title[TITLE_LEN - 3] = '.';
|
||||||
|
@ -350,7 +355,6 @@ void on_keypress(XKeyEvent *kev) {
|
||||||
case XK_r:
|
case XK_r:
|
||||||
changed = load_image();
|
changed = load_image();
|
||||||
break;
|
break;
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
|
Loading…
Reference in New Issue