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 */
|
|
57
image.c
57
image.c
@ -16,8 +16,9 @@
|
|||||||
* 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 "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"
|
||||||
@ -26,15 +27,11 @@ int zl_cnt;
|
|||||||
float zoom_min;
|
float zoom_min;
|
||||||
float zoom_max;
|
float zoom_max;
|
||||||
|
|
||||||
Imlib_Image *im_invalid;
|
|
||||||
|
|
||||||
void img_init(img_t *img, win_t *win) {
|
void img_init(img_t *img, win_t *win) {
|
||||||
zl_cnt = sizeof(zoom_levels) / sizeof(zoom_levels[0]);
|
zl_cnt = sizeof(zoom_levels) / sizeof(zoom_levels[0]);
|
||||||
zoom_min = zoom_levels[0] / 100.0;
|
zoom_min = zoom_levels[0] / 100.0;
|
||||||
zoom_max = zoom_levels[zl_cnt - 1] / 100.0;
|
zoom_max = zoom_levels[zl_cnt - 1] / 100.0;
|
||||||
|
|
||||||
im_invalid = imlib_create_image_using_data(32, 32, icon_invalid);
|
|
||||||
|
|
||||||
if (img) {
|
if (img) {
|
||||||
img->im = NULL;
|
img->im = NULL;
|
||||||
img->zoom = options->zoom;
|
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) {
|
int img_load(img_t *img, const char *filename) {
|
||||||
if (!img || !filename)
|
if (!img || !filename)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ((img->im = imlib_load_image(filename))) {
|
if (access(filename, R_OK) || !(img->im = imlib_load_image(filename))) {
|
||||||
imlib_context_set_image(img->im);
|
warn("could not open image: %s", filename);
|
||||||
imlib_image_set_changes_on_disk();
|
return 0;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
imlib_context_set_image(img->im);
|
||||||
|
imlib_image_set_changes_on_disk();
|
||||||
|
imlib_context_set_anti_alias(img->aa);
|
||||||
|
|
||||||
|
img->scalemode = options->scalemode;
|
||||||
img->re = 0;
|
img->re = 0;
|
||||||
img->checkpan = 0;
|
img->checkpan = 0;
|
||||||
|
|
||||||
@ -151,12 +125,12 @@ void img_render(img_t *img, win_t *win) {
|
|||||||
int sx, sy, sw, sh;
|
int sx, sy, sw, sh;
|
||||||
int dx, dy, dw, dh;
|
int dx, dy, dw, dh;
|
||||||
|
|
||||||
if (!img || !win)
|
if (!img || !img->im || !win)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!img->im || img->scalemode != SCALE_ZOOM) {
|
if (img->scalemode != SCALE_ZOOM) {
|
||||||
img_fit(img, win);
|
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;
|
img->zoom = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,10 +178,7 @@ void img_render(img_t *img, win_t *win) {
|
|||||||
|
|
||||||
win_clear(win);
|
win_clear(win);
|
||||||
|
|
||||||
if (img->im)
|
imlib_context_set_image(img->im);
|
||||||
imlib_context_set_image(img->im);
|
|
||||||
else
|
|
||||||
imlib_context_set_image(im_invalid);
|
|
||||||
|
|
||||||
if (imlib_image_has_alpha() && !img->alpha)
|
if (imlib_image_has_alpha() && !img->alpha)
|
||||||
win_draw_rect(win, win->pm, dx, dy, dw, dh, True, 0, win->white);
|
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;
|
} img_t;
|
||||||
|
|
||||||
void img_init(img_t*, win_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*);
|
int img_load(img_t*, const char*);
|
||||||
void img_close(img_t*, int);
|
void img_close(img_t*, int);
|
||||||
|
|
||||||
|
154
main.c
154
main.c
@ -40,6 +40,14 @@
|
|||||||
#include "commands.h"
|
#include "commands.h"
|
||||||
#endif
|
#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 {
|
typedef enum {
|
||||||
MODE_NORMAL = 0,
|
MODE_NORMAL = 0,
|
||||||
MODE_THUMBS
|
MODE_THUMBS
|
||||||
@ -52,42 +60,74 @@ img_t img;
|
|||||||
tns_t tns;
|
tns_t tns;
|
||||||
win_t win;
|
win_t win;
|
||||||
|
|
||||||
#define FNAME_CNT 1024
|
|
||||||
const char **filenames;
|
const char **filenames;
|
||||||
int filecnt, fileidx;
|
int filecnt, fileidx;
|
||||||
size_t filesize;
|
size_t filesize;
|
||||||
|
|
||||||
#define TITLE_LEN 256
|
|
||||||
char win_title[TITLE_LEN];
|
char win_title[TITLE_LEN];
|
||||||
|
|
||||||
|
int timo_cursor;
|
||||||
|
int timo_redraw;
|
||||||
|
unsigned char drag;
|
||||||
|
int mox, moy;
|
||||||
|
|
||||||
void cleanup() {
|
void cleanup() {
|
||||||
static int in = 0;
|
static int in = 0;
|
||||||
|
|
||||||
if (!in++) {
|
if (!in++) {
|
||||||
img_close(&img, 0);
|
img_close(&img, 0);
|
||||||
img_free(&img);
|
tns_free(&tns);
|
||||||
tns_free(&tns, &win);
|
|
||||||
win_close(&win);
|
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 load_image(int new) {
|
||||||
int ret = 0;
|
|
||||||
struct stat fstats;
|
struct stat fstats;
|
||||||
|
|
||||||
if (new >= 0 && new < filecnt) {
|
if (new >= 0 && new < filecnt) {
|
||||||
win_set_cursor(&win, CURSOR_WATCH);
|
win_set_cursor(&win, CURSOR_WATCH);
|
||||||
img_close(&img, 0);
|
img_close(&img, 0);
|
||||||
|
|
||||||
|
while (!img_load(&img, filenames[new])) {
|
||||||
|
remove_file(new, 0);
|
||||||
|
if (new >= filecnt)
|
||||||
|
new = filecnt - 1;
|
||||||
|
}
|
||||||
fileidx = new;
|
fileidx = new;
|
||||||
if (!stat(filenames[fileidx], &fstats))
|
if (!stat(filenames[new], &fstats))
|
||||||
filesize = fstats.st_size;
|
filesize = fstats.st_size;
|
||||||
else
|
else
|
||||||
filesize = 0;
|
filesize = 0;
|
||||||
if (!(ret = img_load(&img, filenames[fileidx])))
|
|
||||||
|
if (!timo_cursor)
|
||||||
win_set_cursor(&win, CURSOR_NONE);
|
win_set_cursor(&win, CURSOR_NONE);
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_title() {
|
void update_title() {
|
||||||
@ -100,16 +140,11 @@ void update_title() {
|
|||||||
tns.cnt ? tns.sel + 1 : 0, tns.cnt,
|
tns.cnt ? tns.sel + 1 : 0, tns.cnt,
|
||||||
tns.cnt ? filenames[tns.sel] : "");
|
tns.cnt ? filenames[tns.sel] : "");
|
||||||
} else {
|
} else {
|
||||||
if (img.im) {
|
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] invalid: %s",
|
|
||||||
fileidx + 1, filecnt, filenames[fileidx]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n >= TITLE_LEN) {
|
if (n >= TITLE_LEN) {
|
||||||
@ -128,7 +163,7 @@ int check_append(const char *filename) {
|
|||||||
if (access(filename, R_OK)) {
|
if (access(filename, R_OK)) {
|
||||||
warn("could not open file: %s", filename);
|
warn("could not open file: %s", filename);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (options->all || img_check(filename)) {
|
} else {
|
||||||
if (fileidx == filecnt) {
|
if (fileidx == filecnt) {
|
||||||
filecnt *= 2;
|
filecnt *= 2;
|
||||||
filenames = (const char**) s_realloc(filenames,
|
filenames = (const char**) s_realloc(filenames,
|
||||||
@ -136,8 +171,6 @@ int check_append(const char *filename) {
|
|||||||
}
|
}
|
||||||
filenames[fileidx++] = filename;
|
filenames[fileidx++] = filename;
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +188,7 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
if (options->clean_cache) {
|
if (options->clean_cache) {
|
||||||
tns_init(&tns, 0);
|
tns_init(&tns, 0);
|
||||||
tns_clear_cache(&tns);
|
tns_clean_cache(&tns);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,26 +241,27 @@ int main(int argc, char **argv) {
|
|||||||
fileidx = 0;
|
fileidx = 0;
|
||||||
|
|
||||||
if (!filecnt) {
|
if (!filecnt) {
|
||||||
fprintf(stderr, "sxiv: no valid image filename given, aborting\n");
|
fprintf(stderr, "sxiv: no valid image file given, aborting\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
win_open(&win);
|
win_init(&win);
|
||||||
img_init(&img, &win);
|
img_init(&img, &win);
|
||||||
|
|
||||||
if (options->thumbnails) {
|
if (options->thumbnails) {
|
||||||
mode = MODE_THUMBS;
|
mode = MODE_THUMBS;
|
||||||
tns_init(&tns, filecnt);
|
tns_init(&tns, filecnt);
|
||||||
win_clear(&win);
|
while (!tns_load(&tns, 0, filenames[0], 0))
|
||||||
win_draw(&win);
|
remove_file(0, 0);
|
||||||
|
tns.cnt = 1;
|
||||||
} else {
|
} else {
|
||||||
mode = MODE_NORMAL;
|
mode = MODE_NORMAL;
|
||||||
tns.thumbs = NULL;
|
tns.thumbs = NULL;
|
||||||
load_image(fileidx);
|
load_image(fileidx);
|
||||||
img_render(&img, &win);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update_title();
|
win_open(&win);
|
||||||
|
|
||||||
run();
|
run();
|
||||||
cleanup();
|
cleanup();
|
||||||
|
|
||||||
@ -292,42 +326,9 @@ int run_command(const char *cline, Bool reload) {
|
|||||||
}
|
}
|
||||||
#endif /* EXT_COMMANDS */
|
#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 */
|
/* 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() {
|
void redraw() {
|
||||||
if (mode == MODE_NORMAL) {
|
if (mode == MODE_NORMAL) {
|
||||||
img_render(&img, &win);
|
img_render(&img, &win);
|
||||||
@ -363,16 +364,24 @@ void on_keypress(XKeyEvent *kev) {
|
|||||||
win_set_cursor(&win, CURSOR_WATCH);
|
win_set_cursor(&win, CURSOR_WATCH);
|
||||||
if (run_command(commands[x].cmdline, commands[x].reload)) {
|
if (run_command(commands[x].cmdline, commands[x].reload)) {
|
||||||
if (mode == MODE_NORMAL) {
|
if (mode == MODE_NORMAL) {
|
||||||
|
if (fileidx < tns.cnt)
|
||||||
|
tns_load(&tns, fileidx, filenames[fileidx], 1);
|
||||||
img_close(&img, 1);
|
img_close(&img, 1);
|
||||||
load_image(fileidx);
|
load_image(fileidx);
|
||||||
tns_load(&tns, &win, fileidx, filenames[fileidx]);
|
|
||||||
} else {
|
} 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();
|
redraw();
|
||||||
}
|
}
|
||||||
if (mode == MODE_THUMBS)
|
if (mode == MODE_THUMBS)
|
||||||
win_set_cursor(&win, CURSOR_ARROW);
|
win_set_cursor(&win, CURSOR_ARROW);
|
||||||
|
else if (!timo_cursor)
|
||||||
|
win_set_cursor(&win, CURSOR_NONE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -487,7 +496,7 @@ void on_keypress(XKeyEvent *kev) {
|
|||||||
changed = 1;
|
changed = 1;
|
||||||
break;
|
break;
|
||||||
case XK_D:
|
case XK_D:
|
||||||
remove_file(fileidx);
|
remove_file(fileidx, 1);
|
||||||
changed = load_image(fileidx >= filecnt ? filecnt - 1 : fileidx);
|
changed = load_image(fileidx >= filecnt ? filecnt - 1 : fileidx);
|
||||||
break;
|
break;
|
||||||
case XK_r:
|
case XK_r:
|
||||||
@ -532,11 +541,12 @@ void on_keypress(XKeyEvent *kev) {
|
|||||||
tns.sel = tns.cnt - 1;
|
tns.sel = tns.cnt - 1;
|
||||||
changed = tns.dirty = 1;
|
changed = tns.dirty = 1;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
/* miscellaneous */
|
/* miscellaneous */
|
||||||
case XK_D:
|
case XK_D:
|
||||||
if (tns.sel < tns.cnt) {
|
if (tns.sel < tns.cnt) {
|
||||||
remove_file(tns.sel);
|
remove_file(tns.sel, 1);
|
||||||
changed = tns.dirty = 1;
|
changed = tns.dirty = 1;
|
||||||
if (tns.sel >= tns.cnt)
|
if (tns.sel >= tns.cnt)
|
||||||
tns.sel = tns.cnt - 1;
|
tns.sel = tns.cnt - 1;
|
||||||
@ -663,17 +673,21 @@ void run() {
|
|||||||
struct timeval tt, t0, t1;
|
struct timeval tt, t0, t1;
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
timo_cursor = timo_redraw = 0;
|
|
||||||
drag = 0;
|
drag = 0;
|
||||||
|
timo_cursor = mode == MODE_NORMAL ? TO_CURSOR_HIDE : 0;
|
||||||
|
|
||||||
|
redraw();
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (mode == MODE_THUMBS && tns.cnt < filecnt) {
|
if (mode == MODE_THUMBS && tns.cnt < filecnt) {
|
||||||
win_set_cursor(&win, CURSOR_WATCH);
|
win_set_cursor(&win, CURSOR_WATCH);
|
||||||
gettimeofday(&t0, 0);
|
gettimeofday(&t0, 0);
|
||||||
|
|
||||||
while (!XPending(win.env.dpy) && tns.cnt < filecnt) {
|
while (tns.cnt < filecnt && !XPending(win.env.dpy)) {
|
||||||
/* tns.cnt is increased inside tns_load */
|
if (tns_load(&tns, tns.cnt, filenames[tns.cnt], 0))
|
||||||
tns_load(&tns, &win, tns.cnt, filenames[tns.cnt]);
|
++tns.cnt;
|
||||||
|
else
|
||||||
|
remove_file(tns.cnt, 0);
|
||||||
gettimeofday(&t1, 0);
|
gettimeofday(&t1, 0);
|
||||||
if (TV_TO_DOUBLE(t1) - TV_TO_DOUBLE(t0) >= 0.25)
|
if (TV_TO_DOUBLE(t1) - TV_TO_DOUBLE(t0) >= 0.25)
|
||||||
break;
|
break;
|
||||||
|
54
thumbs.c
54
thumbs.c
@ -27,8 +27,6 @@
|
|||||||
#include "thumbs.h"
|
#include "thumbs.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
extern Imlib_Image *im_invalid;
|
|
||||||
|
|
||||||
const int thumb_dim = THUMB_SIZE + 10;
|
const int thumb_dim = THUMB_SIZE + 10;
|
||||||
char *cache_dir = NULL;
|
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;
|
int dirlen, delete;
|
||||||
char *cfile, *filename, *tpos;
|
char *cfile, *filename, *tpos;
|
||||||
r_dir_t dir;
|
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;
|
int i;
|
||||||
|
|
||||||
if (!tns)
|
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 w, h;
|
||||||
int use_cache, cached = 0;
|
int use_cache, cached = 0;
|
||||||
float z, zw, zh;
|
float z, zw, zh;
|
||||||
thumb_t *t;
|
thumb_t *t;
|
||||||
Imlib_Image *im;
|
Imlib_Image *im;
|
||||||
|
|
||||||
if (!tns || !tns->thumbs || !win || !filename)
|
if (!tns || !tns->thumbs || !filename)
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
if (n >= tns->cap)
|
if (n < 0 || n >= tns->cap)
|
||||||
return;
|
return 0;
|
||||||
else if (n >= tns->cnt)
|
|
||||||
tns->cnt = n + 1;
|
|
||||||
|
|
||||||
t = &tns->thumbs[n];
|
t = &tns->thumbs[n];
|
||||||
|
t->filename = filename;
|
||||||
|
|
||||||
if (t->im) {
|
if (t->im) {
|
||||||
imlib_context_set_image(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;
|
cached = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cached || (im = imlib_load_image(filename)))
|
if (!cached &&
|
||||||
imlib_context_set_image(im);
|
(access(filename, R_OK) || !(im = imlib_load_image(filename))))
|
||||||
else
|
{
|
||||||
imlib_context_set_image(im_invalid);
|
if (!silent)
|
||||||
|
warn("could not open image: %s", filename);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
imlib_context_set_image(im);
|
||||||
|
imlib_context_set_anti_alias(1);
|
||||||
|
|
||||||
w = imlib_image_get_width();
|
w = imlib_image_get_width();
|
||||||
h = imlib_image_get_height();
|
h = imlib_image_get_height();
|
||||||
|
zw = (float) THUMB_SIZE / (float) w;
|
||||||
if (im) {
|
zh = (float) THUMB_SIZE / (float) h;
|
||||||
t->filename = filename;
|
z = MIN(zw, zh);
|
||||||
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->w = z * w;
|
||||||
t->h = z * h;
|
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)))
|
if (!(t->im = imlib_create_cropped_scaled_image(0, 0, w, h, t->w, t->h)))
|
||||||
die("could not allocate memory");
|
die("could not allocate memory");
|
||||||
if (im)
|
|
||||||
imlib_free_image_and_decache();
|
imlib_free_image_and_decache();
|
||||||
|
|
||||||
if (use_cache && !cached)
|
if (use_cache && !cached)
|
||||||
tns_cache_write(t, False);
|
tns_cache_write(t, False);
|
||||||
|
|
||||||
tns->dirty = 1;
|
tns->dirty = 1;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tns_check_view(tns_t *tns, Bool scrolled) {
|
void tns_check_view(tns_t *tns, Bool scrolled) {
|
||||||
|
6
thumbs.h
6
thumbs.h
@ -52,12 +52,12 @@ typedef struct {
|
|||||||
unsigned char dirty;
|
unsigned char dirty;
|
||||||
} tns_t;
|
} tns_t;
|
||||||
|
|
||||||
void tns_clear_cache(tns_t*);
|
void tns_clean_cache(tns_t*);
|
||||||
|
|
||||||
void tns_init(tns_t*, int);
|
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_render(tns_t*, win_t*);
|
||||||
void tns_highlight(tns_t*, win_t*, int, Bool);
|
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;
|
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) {
|
void win_set_sizehints(win_t *win) {
|
||||||
XSizeHints sizehints;
|
XSizeHints sizehints;
|
||||||
|
|
||||||
if (!win)
|
if (!win || !win->xwin)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sizehints.flags = PMinSize | PMaxSize;
|
sizehints.flags = PMinSize | PMaxSize;
|
||||||
@ -60,33 +102,7 @@ void win_open(win_t *win) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
e = &win->env;
|
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 */
|
/* determine window offsets, width & height */
|
||||||
if (!options->geometry)
|
if (!options->geometry)
|
||||||
gmask = 0;
|
gmask = 0;
|
||||||
@ -125,7 +141,9 @@ void win_open(win_t *win) {
|
|||||||
|
|
||||||
if (!XAllocNamedColor(e->dpy, DefaultColormap(e->dpy, e->scr), "black",
|
if (!XAllocNamedColor(e->dpy, DefaultColormap(e->dpy, e->scr), "black",
|
||||||
&col, &col))
|
&col, &col))
|
||||||
|
{
|
||||||
die("could not allocate color: black");
|
die("could not allocate color: black");
|
||||||
|
}
|
||||||
none = XCreateBitmapFromData(e->dpy, win->xwin, none_data, 8, 8);
|
none = XCreateBitmapFromData(e->dpy, win->xwin, none_data, 8, 8);
|
||||||
cnone = XCreatePixmapCursor(e->dpy, none, none, &col, &col, 0, 0);
|
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) {
|
void win_close(win_t *win) {
|
||||||
if (!win)
|
if (!win || !win->xwin)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
XFreeCursor(win->env.dpy, carrow);
|
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) {
|
int win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h) {
|
||||||
if (!win)
|
if (!win || !win->xwin)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
x = MAX(0, x);
|
x = MAX(0, x);
|
||||||
@ -211,7 +229,7 @@ void win_toggle_fullscreen(win_t *win) {
|
|||||||
XEvent ev;
|
XEvent ev;
|
||||||
XClientMessageEvent *cm;
|
XClientMessageEvent *cm;
|
||||||
|
|
||||||
if (!win)
|
if (!win || !win->xwin)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
win->fullscreen ^= 1;
|
win->fullscreen ^= 1;
|
||||||
@ -236,7 +254,7 @@ void win_clear(win_t *win) {
|
|||||||
win_env_t *e;
|
win_env_t *e;
|
||||||
XGCValues gcval;
|
XGCValues gcval;
|
||||||
|
|
||||||
if (!win)
|
if (!win || !win->xwin)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
e = &win->env;
|
e = &win->env;
|
||||||
@ -251,7 +269,7 @@ void win_clear(win_t *win) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void win_draw(win_t *win) {
|
void win_draw(win_t *win) {
|
||||||
if (!win)
|
if (!win || !win->xwin)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
XSetWindowBackgroundPixmap(win->env.dpy, win->xwin, win->pm);
|
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) {
|
void win_set_title(win_t *win, const char *title) {
|
||||||
if (!win)
|
if (!win || !win->xwin)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!title)
|
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) {
|
void win_set_cursor(win_t *win, win_cur_t cursor) {
|
||||||
if (!win)
|
if (!win || !win->xwin)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (cursor) {
|
switch (cursor) {
|
||||||
|
Loading…
Reference in New Issue
Block a user