summaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authorBert <ber.t@gmx.com>2011-02-17 16:22:54 +0100
committerBert <ber.t@gmx.com>2011-02-17 16:22:54 +0100
commitef24ded6afeb185192e815868c28a31c4c2e6d97 (patch)
tree54d055b7dcdc7ea064df57e56eafc0452dcd9d8b /window.c
parent095217b26f43b711c8ebc281110553ec788f7ebe (diff)
downloadnsxiv-ef24ded6afeb185192e815868c28a31c4c2e6d97.tar.zst
Highlight selected thumbnail
Diffstat (limited to 'window.c')
-rw-r--r--window.c59
1 files changed, 42 insertions, 17 deletions
diff --git a/window.c b/window.c
index 38501ca..857b3b5 100644
--- a/window.c
+++ b/window.c
@@ -29,7 +29,7 @@
static Cursor carrow;
static Cursor chand;
static Cursor cwatch;
-static GC bgc;
+static GC gc;
Atom wm_delete_win;
@@ -50,7 +50,8 @@ void win_set_sizehints(win_t *win) {
void win_open(win_t *win) {
win_env_t *e;
XClassHint classhint;
- XColor bgcol;
+ XColor col;
+ XGCValues gcval;
int gmask;
if (!win)
@@ -67,13 +68,18 @@ void win_open(win_t *win) {
e->cmap = DefaultColormap(e->dpy, e->scr);
e->depth = DefaultDepth(e->dpy, e->scr);
- if (!XAllocNamedColor(e->dpy, DefaultColormap(e->dpy, e->scr), BG_COLOR,
- &bgcol, &bgcol))
+ 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->bgcol = bgcol.pixel;
win->pm = 0;
-
win->fullscreen = 0;
/* determine window offsets, width & height */
@@ -112,7 +118,8 @@ void win_open(win_t *win) {
chand = XCreateFontCursor(e->dpy, XC_fleur);
cwatch = XCreateFontCursor(e->dpy, XC_watch);
- bgc = XCreateGC(e->dpy, win->xwin, 0, None);
+ gcval.line_width = 2;
+ gc = XCreateGC(e->dpy, win->xwin, GCLineWidth, &gcval);
win_set_title(win, "sxiv");
@@ -141,7 +148,7 @@ void win_close(win_t *win) {
XFreeCursor(win->env.dpy, chand);
XFreeCursor(win->env.dpy, cwatch);
- XFreeGC(win->env.dpy, bgc);
+ XFreeGC(win->env.dpy, gc);
XDestroyWindow(win->env.dpy, win->xwin);
XCloseDisplay(win->env.dpy);
@@ -226,11 +233,6 @@ void win_free_pixmap(win_t *win, Pixmap pm) {
XFreePixmap(win->env.dpy, pm);
}
-void win_draw_pixmap(win_t *win, Pixmap pm, int x, int y, int w, int h) {
- if (win)
- XCopyArea(win->env.dpy, pm, win->pm, bgc, 0, 0, w, h, x, y);
-}
-
void win_clear(win_t *win) {
win_env_t *e;
XGCValues gcval;
@@ -239,14 +241,37 @@ void win_clear(win_t *win) {
return;
e = &win->env;
- gcval.foreground = win->fullscreen ? BlackPixel(e->dpy, e->scr) : win->bgcol;
-
+ gcval.foreground = win->fullscreen ? BlackPixel(e->dpy, e->scr) :
+ win->bgcol;
if (win->pm)
XFreePixmap(e->dpy, win->pm);
win->pm = XCreatePixmap(e->dpy, win->xwin, e->scrw, e->scrh, e->depth);
- XChangeGC(e->dpy, bgc, GCForeground, &gcval);
- XFillRectangle(e->dpy, win->pm, bgc, 0, 0, e->scrw, e->scrh);
+ XChangeGC(e->dpy, gc, GCForeground, &gcval);
+ XFillRectangle(e->dpy, win->pm, gc, 0, 0, e->scrw, e->scrh);
+}
+
+void win_draw_pixmap(win_t *win, Pixmap pm, int x, int y, int w, int h) {
+ if (win)
+ XCopyArea(win->env.dpy, pm, win->pm, gc, 0, 0, w, h, x, y);
+}
+
+void win_draw_rect(win_t *win, int x, int y, int w, int h, Bool sel) {
+ win_env_t *e;
+ XGCValues gcval;
+
+ if (!win)
+ return;
+
+ e = &win->env;
+
+ if (sel)
+ gcval.foreground = win->selcol;
+ else
+ gcval.foreground = win->fullscreen ? BlackPixel(e->dpy, e->scr) :
+ win->bgcol;
+ XChangeGC(e->dpy, gc, GCForeground, &gcval);
+ XDrawRectangle(e->dpy, win->pm, gc, x, y, w, h);
}
void win_draw(win_t *win) {