Krolyxon
Commit 783213c

Branches

Refs →

nsxiv783213c

Use watch-cursor while loading thumbnails

Author
Bert
Date
2011-02-17 11:08 +0100
Parent
bcc70bd
Commit
783213c0bbc1b52504c346588742095a766f052d

+20 −10

3 files changed

  1. M main.c +4 −1
  2. M window.c +14 −8
  3. M window.h +2 −1
M main.c View
@@ -476,9 +476,12 @@ void run() {
476476
477477 while (1) {
478478 if (mode == MODE_THUMBS && tns_loaded < filecnt) {
479+ win_set_cursor(&win, CURSOR_WATCH);
479480 tns_load(&tns, &win, filenames[tns_loaded++]);
480481 tns_render(&tns, &win);
481− if (!XPending(win.env.dpy))
482+ if (tns_loaded == filecnt)
483+ win_set_cursor(&win, CURSOR_ARROW);
484+ else if (!XPending(win.env.dpy))
482485 continue;
483486 } else if (timeout) {
484487 t.tv_sec = 0;
M window.c View
@@ -26,8 +26,9 @@
2626 #include "util.h"
2727 #include "window.h"
2828
29−static Cursor arrow;
30−static Cursor hand;
29+static Cursor carrow;
30+static Cursor chand;
31+static Cursor cwatch;
3132 static GC bgc;
3233
3334 Atom wm_delete_win;
@@ -107,8 +108,9 @@ void win_open(win_t *win) {
107108 XSelectInput(e->dpy, win->xwin, StructureNotifyMask | KeyPressMask |
108109 ButtonPressMask | ButtonReleaseMask | Button2MotionMask);
109110
110− arrow = XCreateFontCursor(e->dpy, XC_left_ptr);
111− hand = XCreateFontCursor(e->dpy, XC_fleur);
111+ carrow = XCreateFontCursor(e->dpy, XC_left_ptr);
112+ chand = XCreateFontCursor(e->dpy, XC_fleur);
113+ cwatch = XCreateFontCursor(e->dpy, XC_watch);
112114
113115 bgc = XCreateGC(e->dpy, win->xwin, 0, None);
114116
@@ -135,8 +137,9 @@ void win_close(win_t *win) {
135137 if (!win)
136138 return;
137139
138− XFreeCursor(win->env.dpy, arrow);
139− XFreeCursor(win->env.dpy, hand);
140+ XFreeCursor(win->env.dpy, carrow);
141+ XFreeCursor(win->env.dpy, chand);
142+ XFreeCursor(win->env.dpy, cwatch);
140143
141144 XFreeGC(win->env.dpy, bgc);
142145
@@ -281,11 +284,14 @@ void win_set_cursor(win_t *win, win_cur_t cursor) {
281284
282285 switch (cursor) {
283286 case CURSOR_HAND:
284− XDefineCursor(win->env.dpy, win->xwin, hand);
287+ XDefineCursor(win->env.dpy, win->xwin, chand);
288+ break;
289+ case CURSOR_WATCH:
290+ XDefineCursor(win->env.dpy, win->xwin, cwatch);
285291 break;
286292 case CURSOR_ARROW:
287293 default:
288− XDefineCursor(win->env.dpy, win->xwin, arrow);
294+ XDefineCursor(win->env.dpy, win->xwin, carrow);
289295 break;
290296 }
291297 }
M window.h View
@@ -25,7 +25,8 @@
2525
2626 typedef enum win_cur_e {
2727 CURSOR_ARROW = 0,
28− CURSOR_HAND
28+ CURSOR_HAND,
29+ CURSOR_WATCH
2930 } win_cur_t;
3031
3132 typedef struct win_env_s {