| @@ -49,7 +49,7 @@ typedef struct { |
| 49 | 49 | | |
| 50 | 50 | | /* timeout handler functions: */ |
| 51 | 51 | | void redraw(); |
| 52 | | − | void hide_cursor(); |
| 52 | + | void reset_cursor(); |
| 53 | 53 | | void animate(); |
| 54 | 54 | | |
| 55 | 55 | | appmode_t mode; |
| @@ -65,7 +65,7 @@ char win_title[TITLE_LEN]; |
| 65 | 65 | | |
| 66 | 66 | | timeout_t timeouts[] = { |
| 67 | 67 | | { { 0, 0 }, False, redraw }, |
| 68 | | − | { { 0, 0 }, False, hide_cursor }, |
| 68 | + | { { 0, 0 }, False, reset_cursor }, |
| 69 | 69 | | { { 0, 0 }, False, animate } |
| 70 | 70 | | }; |
| 71 | 71 | | |
| @@ -189,10 +189,9 @@ void load_image(int new) { |
| 189 | 189 | | if (new < 0 || new >= filecnt) |
| 190 | 190 | | return; |
| 191 | 191 | | |
| 192 | | − | /* cursor gets reset in redraw() */ |
| 193 | 192 | | win_set_cursor(&win, CURSOR_WATCH); |
| 193 | + | |
| 194 | 194 | | img_close(&img, 0); |
| 195 | | − | |
| 196 | 195 | | while (!img_load(&img, &files[new])) { |
| 197 | 196 | | remove_file(new, 0); |
| 198 | 197 | | if (new >= filecnt) |
| @@ -247,23 +246,34 @@ void update_title() { |
| 247 | 246 | | } |
| 248 | 247 | | |
| 249 | 248 | | void redraw() { |
| 250 | | − | if (mode == MODE_IMAGE) { |
| 249 | + | if (mode == MODE_IMAGE) |
| 251 | 250 | | img_render(&img, &win); |
| 252 | | − | if (img.multi.animate) { |
| 253 | | − | win_set_cursor(&win, CURSOR_NONE); |
| 254 | | − | } else { |
| 255 | | − | win_set_cursor(&win, CURSOR_ARROW); |
| 256 | | − | set_timeout(hide_cursor, TO_CURSOR_HIDE, 1); |
| 257 | | − | } |
| 258 | | − | } else { |
| 251 | + | else |
| 259 | 252 | | tns_render(&tns, &win); |
| 260 | | − | } |
| 261 | 253 | | update_title(); |
| 262 | 254 | | reset_timeout(redraw); |
| 255 | + | reset_cursor(); |
| 263 | 256 | | } |
| 264 | 257 | | |
| 265 | | − | void hide_cursor() { |
| 266 | | − | win_set_cursor(&win, CURSOR_NONE); |
| 258 | + | void reset_cursor() { |
| 259 | + | int i; |
| 260 | + | cursor_t cursor = CURSOR_NONE; |
| 261 | + | |
| 262 | + | if (mode == MODE_IMAGE) { |
| 263 | + | for (i = 0; i < LEN(timeouts); i++) { |
| 264 | + | if (timeouts[i].handler == reset_cursor) { |
| 265 | + | if (timeouts[i].active) |
| 266 | + | cursor = CURSOR_ARROW; |
| 267 | + | break; |
| 268 | + | } |
| 269 | + | } |
| 270 | + | } else { |
| 271 | + | if (tns.cnt != filecnt) |
| 272 | + | cursor = CURSOR_WATCH; |
| 273 | + | else |
| 274 | + | cursor = CURSOR_ARROW; |
| 275 | + | } |
| 276 | + | win_set_cursor(&win, cursor); |
| 267 | 277 | | } |
| 268 | 278 | | |
| 269 | 279 | | void animate() { |
| @@ -312,7 +322,7 @@ void on_buttonpress(XButtonEvent *bev) { |
| 312 | 322 | | |
| 313 | 323 | | if (mode == MODE_IMAGE) { |
| 314 | 324 | | win_set_cursor(&win, CURSOR_ARROW); |
| 315 | | − | set_timeout(hide_cursor, TO_CURSOR_HIDE, 1); |
| 325 | + | set_timeout(reset_cursor, TO_CURSOR_HIDE, 1); |
| 316 | 326 | | |
| 317 | 327 | | for (i = 0; i < LEN(buttons); i++) { |
| 318 | 328 | | if (buttons[i].button == bev->button && |
| @@ -329,15 +339,15 @@ void on_buttonpress(XButtonEvent *bev) { |
| 329 | 339 | | case Button1: |
| 330 | 340 | | if ((sel = tns_translate(&tns, bev->x, bev->y)) >= 0) { |
| 331 | 341 | | if (sel == tns.sel) { |
| 332 | | − | load_image(tns.sel); |
| 333 | 342 | | mode = MODE_IMAGE; |
| 334 | | − | set_timeout(hide_cursor, TO_CURSOR_HIDE, 1); |
| 343 | + | set_timeout(reset_cursor, TO_CURSOR_HIDE, 1); |
| 344 | + | load_image(tns.sel); |
| 345 | + | redraw(); |
| 335 | 346 | | } else { |
| 336 | 347 | | tns_highlight(&tns, &win, tns.sel, False); |
| 337 | 348 | | tns_highlight(&tns, &win, sel, True); |
| 338 | 349 | | tns.sel = sel; |
| 339 | 350 | | } |
| 340 | | − | redraw(); |
| 341 | 351 | | break; |
| 342 | 352 | | } |
| 343 | 353 | | break; |
| @@ -363,18 +373,15 @@ void run() { |
| 363 | 373 | | !XPending(win.env.dpy)) |
| 364 | 374 | | { |
| 365 | 375 | | /* load thumbnails */ |
| 366 | | − | win_set_cursor(&win, CURSOR_WATCH); |
| 367 | 376 | | set_timeout(redraw, TO_REDRAW_THUMBS, 0); |
| 368 | 377 | | if (tns_load(&tns, tns.cnt, &files[tns.cnt], False, False)) |
| 369 | 378 | | tns.cnt++; |
| 370 | 379 | | else |
| 371 | 380 | | remove_file(tns.cnt, 0); |
| 372 | | − | if (tns.cnt == filecnt) { |
| 381 | + | if (tns.cnt == filecnt) |
| 373 | 382 | | redraw(); |
| 374 | | − | win_set_cursor(&win, CURSOR_ARROW); |
| 375 | | − | } else { |
| 383 | + | else |
| 376 | 384 | | check_timeouts(NULL); |
| 377 | | − | } |
| 378 | 385 | | } |
| 379 | 386 | | |
| 380 | 387 | | while (!XPending(win.env.dpy) && check_timeouts(&timeout)) { |
| @@ -410,7 +417,7 @@ void run() { |
| 410 | 417 | | case MotionNotify: |
| 411 | 418 | | if (mode == MODE_IMAGE) { |
| 412 | 419 | | win_set_cursor(&win, CURSOR_ARROW); |
| 413 | | − | set_timeout(hide_cursor, TO_CURSOR_HIDE, 1); |
| 420 | + | set_timeout(reset_cursor, TO_CURSOR_HIDE, 1); |
| 414 | 421 | | } |
| 415 | 422 | | break; |
| 416 | 423 | | } |