Remove invalid images when loading them; refactorings
This commit is contained in:
parent
5cb6d12a94
commit
d15264ea32
180
icon.h
180
icon.h
|
@ -1,180 +0,0 @@
|
|||
#ifndef ICON_H
|
||||
#define ICON_H
|
||||
|
||||
#include <Imlib2.h>
|
||||
|
||||
static DATA32 icon_invalid[] = {
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb,
|
||||
0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xffbbbbbb, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444, 0xff444444,
|
||||
0xff444444, 0xff444444, 0xff444444, 0xff444444
|
||||
};
|
||||
|
||||
#endif /* ICON_H */
|
51
image.c
51
image.c
|
@ -16,8 +16,9 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "icon.h"
|
||||
#include "image.h"
|
||||
#include "options.h"
|
||||
#include "util.h"
|
||||
|
@ -26,15 +27,11 @@ int zl_cnt;
|
|||
float zoom_min;
|
||||
float zoom_max;
|
||||
|
||||
Imlib_Image *im_invalid;
|
||||
|
||||
void img_init(img_t *img, win_t *win) {
|
||||
zl_cnt = sizeof(zoom_levels) / sizeof(zoom_levels[0]);
|
||||
zoom_min = zoom_levels[0] / 100.0;
|
||||
zoom_max = zoom_levels[zl_cnt - 1] / 100.0;
|
||||
|
||||
im_invalid = imlib_create_image_using_data(32, 32, icon_invalid);
|
||||
|
||||
if (img) {
|
||||
img->im = NULL;
|
||||
img->zoom = options->zoom;
|
||||
|
@ -51,43 +48,20 @@ void img_init(img_t *img, win_t *win) {
|
|||
}
|
||||
}
|
||||
|
||||
void img_free(img_t* img) {
|
||||
imlib_context_set_image(im_invalid);
|
||||
imlib_free_image();
|
||||
}
|
||||
|
||||
int img_check(const char *filename) {
|
||||
Imlib_Image *im;
|
||||
|
||||
if (!filename)
|
||||
return 0;
|
||||
|
||||
if ((im = imlib_load_image(filename))) {
|
||||
imlib_context_set_image(im);
|
||||
imlib_image_set_changes_on_disk();
|
||||
imlib_free_image();
|
||||
return 1;
|
||||
} else {
|
||||
warn("invalid file: %s", filename);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int img_load(img_t *img, const char *filename) {
|
||||
if (!img || !filename)
|
||||
return 0;
|
||||
|
||||
if ((img->im = imlib_load_image(filename))) {
|
||||
if (access(filename, R_OK) || !(img->im = imlib_load_image(filename))) {
|
||||
warn("could not open image: %s", filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
imlib_context_set_image(img->im);
|
||||
imlib_image_set_changes_on_disk();
|
||||
imlib_context_set_anti_alias(img->aa);
|
||||
img->scalemode = options->scalemode;
|
||||
} else {
|
||||
warn("invalid file: %s", filename);
|
||||
imlib_context_set_image(im_invalid);
|
||||
imlib_context_set_anti_alias(0);
|
||||
}
|
||||
|
||||
img->scalemode = options->scalemode;
|
||||
img->re = 0;
|
||||
img->checkpan = 0;
|
||||
|
||||
|
@ -151,12 +125,12 @@ void img_render(img_t *img, win_t *win) {
|
|||
int sx, sy, sw, sh;
|
||||
int dx, dy, dw, dh;
|
||||
|
||||
if (!img || !win)
|
||||
if (!img || !img->im || !win)
|
||||
return;
|
||||
|
||||
if (!img->im || img->scalemode != SCALE_ZOOM) {
|
||||
if (img->scalemode != SCALE_ZOOM) {
|
||||
img_fit(img, win);
|
||||
if ((!img->im || img->scalemode == SCALE_DOWN) && img->zoom > 1.0)
|
||||
if (img->scalemode == SCALE_DOWN && img->zoom > 1.0)
|
||||
img->zoom = 1.0;
|
||||
}
|
||||
|
||||
|
@ -204,10 +178,7 @@ void img_render(img_t *img, win_t *win) {
|
|||
|
||||
win_clear(win);
|
||||
|
||||
if (img->im)
|
||||
imlib_context_set_image(img->im);
|
||||
else
|
||||
imlib_context_set_image(im_invalid);
|
||||
|
||||
if (imlib_image_has_alpha() && !img->alpha)
|
||||
win_draw_rect(win, win->pm, dx, dy, dw, dh, True, 0, win->white);
|
||||
|
|
2
image.h
2
image.h
|
@ -54,9 +54,7 @@ typedef struct {
|
|||
} img_t;
|
||||
|
||||
void img_init(img_t*, win_t*);
|
||||
void img_free(img_t*);
|
||||
|
||||
int img_check(const char*);
|
||||
int img_load(img_t*, const char*);
|
||||
void img_close(img_t*, int);
|
||||
|
||||
|
|
144
main.c
144
main.c
|
@ -40,6 +40,14 @@
|
|||
#include "commands.h"
|
||||
#endif
|
||||
|
||||
#define FNAME_CNT 1024
|
||||
#define TITLE_LEN 256
|
||||
|
||||
#define TO_WIN_RESIZE 75000
|
||||
#define TO_IMAGE_DRAG 1000
|
||||
#define TO_CURSOR_HIDE 1500000
|
||||
#define TO_THUMBS_LOAD 75000
|
||||
|
||||
typedef enum {
|
||||
MODE_NORMAL = 0,
|
||||
MODE_THUMBS
|
||||
|
@ -52,42 +60,74 @@ img_t img;
|
|||
tns_t tns;
|
||||
win_t win;
|
||||
|
||||
#define FNAME_CNT 1024
|
||||
const char **filenames;
|
||||
int filecnt, fileidx;
|
||||
size_t filesize;
|
||||
|
||||
#define TITLE_LEN 256
|
||||
char win_title[TITLE_LEN];
|
||||
|
||||
int timo_cursor;
|
||||
int timo_redraw;
|
||||
unsigned char drag;
|
||||
int mox, moy;
|
||||
|
||||
void cleanup() {
|
||||
static int in = 0;
|
||||
|
||||
if (!in++) {
|
||||
img_close(&img, 0);
|
||||
img_free(&img);
|
||||
tns_free(&tns, &win);
|
||||
tns_free(&tns);
|
||||
win_close(&win);
|
||||
}
|
||||
}
|
||||
|
||||
void remove_file(int n, unsigned char silent) {
|
||||
if (n < 0 || n >= filecnt)
|
||||
return;
|
||||
|
||||
if (filecnt == 1) {
|
||||
if (!silent)
|
||||
fprintf(stderr, "sxiv: no more files to display\n");
|
||||
cleanup();
|
||||
exit(!silent);
|
||||
}
|
||||
|
||||
if (n + 1 < filecnt)
|
||||
memmove(filenames + n, filenames + n + 1, (filecnt - n - 1) *
|
||||
sizeof(const char*));
|
||||
if (n + 1 < tns.cnt) {
|
||||
memmove(tns.thumbs + n, tns.thumbs + n + 1, (tns.cnt - n - 1) *
|
||||
sizeof(thumb_t));
|
||||
memset(tns.thumbs + tns.cnt - 1, 0, sizeof(thumb_t));
|
||||
}
|
||||
|
||||
--filecnt;
|
||||
if (n < tns.cnt)
|
||||
--tns.cnt;
|
||||
}
|
||||
|
||||
int load_image(int new) {
|
||||
int ret = 0;
|
||||
struct stat fstats;
|
||||
|
||||
if (new >= 0 && new < filecnt) {
|
||||
win_set_cursor(&win, CURSOR_WATCH);
|
||||
img_close(&img, 0);
|
||||
|
||||
while (!img_load(&img, filenames[new])) {
|
||||
remove_file(new, 0);
|
||||
if (new >= filecnt)
|
||||
new = filecnt - 1;
|
||||
}
|
||||
fileidx = new;
|
||||
if (!stat(filenames[fileidx], &fstats))
|
||||
if (!stat(filenames[new], &fstats))
|
||||
filesize = fstats.st_size;
|
||||
else
|
||||
filesize = 0;
|
||||
if (!(ret = img_load(&img, filenames[fileidx])))
|
||||
|
||||
if (!timo_cursor)
|
||||
win_set_cursor(&win, CURSOR_NONE);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void update_title() {
|
||||
|
@ -100,16 +140,11 @@ void update_title() {
|
|||
tns.cnt ? tns.sel + 1 : 0, tns.cnt,
|
||||
tns.cnt ? filenames[tns.sel] : "");
|
||||
} else {
|
||||
if (img.im) {
|
||||
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] invalid: %s",
|
||||
fileidx + 1, filecnt, filenames[fileidx]);
|
||||
}
|
||||
}
|
||||
|
||||
if (n >= TITLE_LEN) {
|
||||
|
@ -128,7 +163,7 @@ int check_append(const char *filename) {
|
|||
if (access(filename, R_OK)) {
|
||||
warn("could not open file: %s", filename);
|
||||
return 0;
|
||||
} else if (options->all || img_check(filename)) {
|
||||
} else {
|
||||
if (fileidx == filecnt) {
|
||||
filecnt *= 2;
|
||||
filenames = (const char**) s_realloc(filenames,
|
||||
|
@ -136,8 +171,6 @@ int check_append(const char *filename) {
|
|||
}
|
||||
filenames[fileidx++] = filename;
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,7 +188,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
if (options->clean_cache) {
|
||||
tns_init(&tns, 0);
|
||||
tns_clear_cache(&tns);
|
||||
tns_clean_cache(&tns);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -208,26 +241,27 @@ int main(int argc, char **argv) {
|
|||
fileidx = 0;
|
||||
|
||||
if (!filecnt) {
|
||||
fprintf(stderr, "sxiv: no valid image filename given, aborting\n");
|
||||
fprintf(stderr, "sxiv: no valid image file given, aborting\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
win_open(&win);
|
||||
win_init(&win);
|
||||
img_init(&img, &win);
|
||||
|
||||
if (options->thumbnails) {
|
||||
mode = MODE_THUMBS;
|
||||
tns_init(&tns, filecnt);
|
||||
win_clear(&win);
|
||||
win_draw(&win);
|
||||
while (!tns_load(&tns, 0, filenames[0], 0))
|
||||
remove_file(0, 0);
|
||||
tns.cnt = 1;
|
||||
} else {
|
||||
mode = MODE_NORMAL;
|
||||
tns.thumbs = NULL;
|
||||
load_image(fileidx);
|
||||
img_render(&img, &win);
|
||||
}
|
||||
|
||||
update_title();
|
||||
win_open(&win);
|
||||
|
||||
run();
|
||||
cleanup();
|
||||
|
||||
|
@ -292,42 +326,9 @@ int run_command(const char *cline, Bool reload) {
|
|||
}
|
||||
#endif /* EXT_COMMANDS */
|
||||
|
||||
void remove_file(int n) {
|
||||
if (n < 0 || n >= filecnt)
|
||||
return;
|
||||
|
||||
if (filecnt == 1) {
|
||||
cleanup();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (n + 1 < filecnt)
|
||||
memmove(filenames + n, filenames + n + 1, (filecnt - n - 1) *
|
||||
sizeof(const char*));
|
||||
if (n + 1 < tns.cnt) {
|
||||
memmove(tns.thumbs + n, tns.thumbs + n + 1, (tns.cnt - n - 1) *
|
||||
sizeof(thumb_t));
|
||||
memset(tns.thumbs + tns.cnt - 1, 0, sizeof(thumb_t));
|
||||
}
|
||||
|
||||
--filecnt;
|
||||
if (n < tns.cnt)
|
||||
--tns.cnt;
|
||||
}
|
||||
|
||||
|
||||
/* event handling */
|
||||
|
||||
#define TO_WIN_RESIZE 75000;
|
||||
#define TO_IMAGE_DRAG 1000;
|
||||
#define TO_CURSOR_HIDE 1500000;
|
||||
#define TO_THUMBS_LOAD 75000;
|
||||
int timo_cursor;
|
||||
int timo_redraw;
|
||||
|
||||
unsigned char drag;
|
||||
int mox, moy;
|
||||
|
||||
void redraw() {
|
||||
if (mode == MODE_NORMAL) {
|
||||
img_render(&img, &win);
|
||||
|
@ -363,16 +364,24 @@ void on_keypress(XKeyEvent *kev) {
|
|||
win_set_cursor(&win, CURSOR_WATCH);
|
||||
if (run_command(commands[x].cmdline, commands[x].reload)) {
|
||||
if (mode == MODE_NORMAL) {
|
||||
if (fileidx < tns.cnt)
|
||||
tns_load(&tns, fileidx, filenames[fileidx], 1);
|
||||
img_close(&img, 1);
|
||||
load_image(fileidx);
|
||||
tns_load(&tns, &win, fileidx, filenames[fileidx]);
|
||||
} else {
|
||||
tns_load(&tns, &win, tns.sel, filenames[tns.sel]);
|
||||
if (!tns_load(&tns, tns.sel, filenames[tns.sel], 0)) {
|
||||
remove_file(tns.sel, 0);
|
||||
tns.dirty = 1;
|
||||
if (tns.sel >= tns.cnt)
|
||||
tns.sel = tns.cnt - 1;
|
||||
}
|
||||
}
|
||||
redraw();
|
||||
}
|
||||
if (mode == MODE_THUMBS)
|
||||
win_set_cursor(&win, CURSOR_ARROW);
|
||||
else if (!timo_cursor)
|
||||
win_set_cursor(&win, CURSOR_NONE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -487,7 +496,7 @@ void on_keypress(XKeyEvent *kev) {
|
|||
changed = 1;
|
||||
break;
|
||||
case XK_D:
|
||||
remove_file(fileidx);
|
||||
remove_file(fileidx, 1);
|
||||
changed = load_image(fileidx >= filecnt ? filecnt - 1 : fileidx);
|
||||
break;
|
||||
case XK_r:
|
||||
|
@ -532,11 +541,12 @@ void on_keypress(XKeyEvent *kev) {
|
|||
tns.sel = tns.cnt - 1;
|
||||
changed = tns.dirty = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
/* miscellaneous */
|
||||
case XK_D:
|
||||
if (tns.sel < tns.cnt) {
|
||||
remove_file(tns.sel);
|
||||
remove_file(tns.sel, 1);
|
||||
changed = tns.dirty = 1;
|
||||
if (tns.sel >= tns.cnt)
|
||||
tns.sel = tns.cnt - 1;
|
||||
|
@ -663,17 +673,21 @@ void run() {
|
|||
struct timeval tt, t0, t1;
|
||||
XEvent ev;
|
||||
|
||||
timo_cursor = timo_redraw = 0;
|
||||
drag = 0;
|
||||
timo_cursor = mode == MODE_NORMAL ? TO_CURSOR_HIDE : 0;
|
||||
|
||||
redraw();
|
||||
|
||||
while (1) {
|
||||
if (mode == MODE_THUMBS && tns.cnt < filecnt) {
|
||||
win_set_cursor(&win, CURSOR_WATCH);
|
||||
gettimeofday(&t0, 0);
|
||||
|
||||
while (!XPending(win.env.dpy) && tns.cnt < filecnt) {
|
||||
/* tns.cnt is increased inside tns_load */
|
||||
tns_load(&tns, &win, tns.cnt, filenames[tns.cnt]);
|
||||
while (tns.cnt < filecnt && !XPending(win.env.dpy)) {
|
||||
if (tns_load(&tns, tns.cnt, filenames[tns.cnt], 0))
|
||||
++tns.cnt;
|
||||
else
|
||||
remove_file(tns.cnt, 0);
|
||||
gettimeofday(&t1, 0);
|
||||
if (TV_TO_DOUBLE(t1) - TV_TO_DOUBLE(t0) >= 0.25)
|
||||
break;
|
||||
|
|
44
thumbs.c
44
thumbs.c
|
@ -27,8 +27,6 @@
|
|||
#include "thumbs.h"
|
||||
#include "util.h"
|
||||
|
||||
extern Imlib_Image *im_invalid;
|
||||
|
||||
const int thumb_dim = THUMB_SIZE + 10;
|
||||
char *cache_dir = NULL;
|
||||
|
||||
|
@ -131,7 +129,7 @@ void tns_cache_write(thumb_t *t, Bool force) {
|
|||
}
|
||||
}
|
||||
|
||||
void tns_clear_cache(tns_t *tns) {
|
||||
void tns_clean_cache(tns_t *tns) {
|
||||
int dirlen, delete;
|
||||
char *cfile, *filename, *tpos;
|
||||
r_dir_t dir;
|
||||
|
@ -195,7 +193,7 @@ void tns_init(tns_t *tns, int cnt) {
|
|||
}
|
||||
}
|
||||
|
||||
void tns_free(tns_t *tns, win_t *win) {
|
||||
void tns_free(tns_t *tns) {
|
||||
int i;
|
||||
|
||||
if (!tns)
|
||||
|
@ -218,22 +216,21 @@ void tns_free(tns_t *tns, win_t *win) {
|
|||
}
|
||||
}
|
||||
|
||||
void tns_load(tns_t *tns, win_t *win, int n, const char *filename) {
|
||||
int tns_load(tns_t *tns, int n, const char *filename, unsigned char silent) {
|
||||
int w, h;
|
||||
int use_cache, cached = 0;
|
||||
float z, zw, zh;
|
||||
thumb_t *t;
|
||||
Imlib_Image *im;
|
||||
|
||||
if (!tns || !tns->thumbs || !win || !filename)
|
||||
return;
|
||||
if (!tns || !tns->thumbs || !filename)
|
||||
return 0;
|
||||
|
||||
if (n >= tns->cap)
|
||||
return;
|
||||
else if (n >= tns->cnt)
|
||||
tns->cnt = n + 1;
|
||||
if (n < 0 || n >= tns->cap)
|
||||
return 0;
|
||||
|
||||
t = &tns->thumbs[n];
|
||||
t->filename = filename;
|
||||
|
||||
if (t->im) {
|
||||
imlib_context_set_image(t->im);
|
||||
|
@ -245,36 +242,35 @@ void tns_load(tns_t *tns, win_t *win, int n, const char *filename) {
|
|||
cached = 1;
|
||||
}
|
||||
|
||||
if (cached || (im = imlib_load_image(filename)))
|
||||
if (!cached &&
|
||||
(access(filename, R_OK) || !(im = imlib_load_image(filename))))
|
||||
{
|
||||
if (!silent)
|
||||
warn("could not open image: %s", filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
imlib_context_set_image(im);
|
||||
else
|
||||
imlib_context_set_image(im_invalid);
|
||||
imlib_context_set_anti_alias(1);
|
||||
|
||||
w = imlib_image_get_width();
|
||||
h = imlib_image_get_height();
|
||||
|
||||
if (im) {
|
||||
t->filename = filename;
|
||||
zw = (float) THUMB_SIZE / (float) w;
|
||||
zh = (float) THUMB_SIZE / (float) h;
|
||||
z = MIN(zw, zh);
|
||||
} else {
|
||||
t->filename = NULL;
|
||||
z = 1.0;
|
||||
}
|
||||
|
||||
t->w = z * w;
|
||||
t->h = z * h;
|
||||
|
||||
imlib_context_set_anti_alias(1);
|
||||
if (!(t->im = imlib_create_cropped_scaled_image(0, 0, w, h, t->w, t->h)))
|
||||
die("could not allocate memory");
|
||||
if (im)
|
||||
|
||||
imlib_free_image_and_decache();
|
||||
|
||||
if (use_cache && !cached)
|
||||
tns_cache_write(t, False);
|
||||
|
||||
tns->dirty = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void tns_check_view(tns_t *tns, Bool scrolled) {
|
||||
|
|
6
thumbs.h
6
thumbs.h
|
@ -52,12 +52,12 @@ typedef struct {
|
|||
unsigned char dirty;
|
||||
} tns_t;
|
||||
|
||||
void tns_clear_cache(tns_t*);
|
||||
void tns_clean_cache(tns_t*);
|
||||
|
||||
void tns_init(tns_t*, int);
|
||||
void tns_free(tns_t*, win_t*);
|
||||
void tns_free(tns_t*);
|
||||
|
||||
void tns_load(tns_t*, win_t*, int, const char*);
|
||||
int tns_load(tns_t*, int, const char*, unsigned char);
|
||||
|
||||
void tns_render(tns_t*, win_t*);
|
||||
void tns_highlight(tns_t*, win_t*, int, Bool);
|
||||
|
|
86
window.c
86
window.c
|
@ -34,10 +34,52 @@ static GC gc;
|
|||
|
||||
Atom wm_delete_win;
|
||||
|
||||
void win_init(win_t *win) {
|
||||
win_env_t *e;
|
||||
XColor col;
|
||||
|
||||
if (!win)
|
||||
return;
|
||||
|
||||
e = &win->env;
|
||||
if (!(e->dpy = XOpenDisplay(NULL)))
|
||||
die("could not open display");
|
||||
|
||||
e->scr = DefaultScreen(e->dpy);
|
||||
e->scrw = DisplayWidth(e->dpy, e->scr);
|
||||
e->scrh = DisplayHeight(e->dpy, e->scr);
|
||||
e->vis = DefaultVisual(e->dpy, e->scr);
|
||||
e->cmap = DefaultColormap(e->dpy, e->scr);
|
||||
e->depth = DefaultDepth(e->dpy, e->scr);
|
||||
|
||||
win->black = BlackPixel(e->dpy, e->scr);
|
||||
win->white = WhitePixel(e->dpy, e->scr);
|
||||
|
||||
if (XAllocNamedColor(e->dpy, DefaultColormap(e->dpy, e->scr), BG_COLOR,
|
||||
&col, &col))
|
||||
{
|
||||
win->bgcol = col.pixel;
|
||||
} else {
|
||||
die("could not allocate color: %s", BG_COLOR);
|
||||
}
|
||||
|
||||
if (XAllocNamedColor(e->dpy, DefaultColormap(e->dpy, e->scr), SEL_COLOR,
|
||||
&col, &col))
|
||||
{
|
||||
win->selcol = col.pixel;
|
||||
} else {
|
||||
die("could not allocate color: %s", SEL_COLOR);
|
||||
}
|
||||
|
||||
win->xwin = 0;
|
||||
win->pm = 0;
|
||||
win->fullscreen = 0;
|
||||
}
|
||||
|
||||
void win_set_sizehints(win_t *win) {
|
||||
XSizeHints sizehints;
|
||||
|
||||
if (!win)
|
||||
if (!win || !win->xwin)
|
||||
return;
|
||||
|
||||
sizehints.flags = PMinSize | PMaxSize;
|
||||
|
@ -60,32 +102,6 @@ void win_open(win_t *win) {
|
|||
return;
|
||||
|
||||
e = &win->env;
|
||||
if (!(e->dpy = XOpenDisplay(NULL)))
|
||||
die("could not open display");
|
||||
|
||||
e->scr = DefaultScreen(e->dpy);
|
||||
e->scrw = DisplayWidth(e->dpy, e->scr);
|
||||
e->scrh = DisplayHeight(e->dpy, e->scr);
|
||||
e->vis = DefaultVisual(e->dpy, e->scr);
|
||||
e->cmap = DefaultColormap(e->dpy, e->scr);
|
||||
e->depth = DefaultDepth(e->dpy, e->scr);
|
||||
|
||||
win->black = BlackPixel(e->dpy, e->scr);
|
||||
win->white = WhitePixel(e->dpy, e->scr);
|
||||
|
||||
if (XAllocNamedColor(e->dpy, DefaultColormap(e->dpy, e->scr), BG_COLOR,
|
||||
&col, &col))
|
||||
win->bgcol = col.pixel;
|
||||
else
|
||||
die("could not allocate color: %s", BG_COLOR);
|
||||
if (XAllocNamedColor(e->dpy, DefaultColormap(e->dpy, e->scr), SEL_COLOR,
|
||||
&col, &col))
|
||||
win->selcol = col.pixel;
|
||||
else
|
||||
die("could not allocate color: %s", BG_COLOR);
|
||||
|
||||
win->pm = 0;
|
||||
win->fullscreen = 0;
|
||||
|
||||
/* determine window offsets, width & height */
|
||||
if (!options->geometry)
|
||||
|
@ -125,7 +141,9 @@ void win_open(win_t *win) {
|
|||
|
||||
if (!XAllocNamedColor(e->dpy, DefaultColormap(e->dpy, e->scr), "black",
|
||||
&col, &col))
|
||||
{
|
||||
die("could not allocate color: black");
|
||||
}
|
||||
none = XCreateBitmapFromData(e->dpy, win->xwin, none_data, 8, 8);
|
||||
cnone = XCreatePixmapCursor(e->dpy, none, none, &col, &col, 0, 0);
|
||||
|
||||
|
@ -151,7 +169,7 @@ void win_open(win_t *win) {
|
|||
}
|
||||
|
||||
void win_close(win_t *win) {
|
||||
if (!win)
|
||||
if (!win || !win->xwin)
|
||||
return;
|
||||
|
||||
XFreeCursor(win->env.dpy, carrow);
|
||||
|
@ -183,7 +201,7 @@ int win_configure(win_t *win, XConfigureEvent *c) {
|
|||
}
|
||||
|
||||
int win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h) {
|
||||
if (!win)
|
||||
if (!win || !win->xwin)
|
||||
return 0;
|
||||
|
||||
x = MAX(0, x);
|
||||
|
@ -211,7 +229,7 @@ void win_toggle_fullscreen(win_t *win) {
|
|||
XEvent ev;
|
||||
XClientMessageEvent *cm;
|
||||
|
||||
if (!win)
|
||||
if (!win || !win->xwin)
|
||||
return;
|
||||
|
||||
win->fullscreen ^= 1;
|
||||
|
@ -236,7 +254,7 @@ void win_clear(win_t *win) {
|
|||
win_env_t *e;
|
||||
XGCValues gcval;
|
||||
|
||||
if (!win)
|
||||
if (!win || !win->xwin)
|
||||
return;
|
||||
|
||||
e = &win->env;
|
||||
|
@ -251,7 +269,7 @@ void win_clear(win_t *win) {
|
|||
}
|
||||
|
||||
void win_draw(win_t *win) {
|
||||
if (!win)
|
||||
if (!win || !win->xwin)
|
||||
return;
|
||||
|
||||
XSetWindowBackgroundPixmap(win->env.dpy, win->xwin, win->pm);
|
||||
|
@ -276,7 +294,7 @@ void win_draw_rect(win_t *win, Pixmap pm, int x, int y, int w, int h,
|
|||
}
|
||||
|
||||
void win_set_title(win_t *win, const char *title) {
|
||||
if (!win)
|
||||
if (!win || !win->xwin)
|
||||
return;
|
||||
|
||||
if (!title)
|
||||
|
@ -296,7 +314,7 @@ void win_set_title(win_t *win, const char *title) {
|
|||
}
|
||||
|
||||
void win_set_cursor(win_t *win, win_cur_t cursor) {
|
||||
if (!win)
|
||||
if (!win || !win->xwin)
|
||||
return;
|
||||
|
||||
switch (cursor) {
|
||||
|
|
Loading…
Reference in New Issue