From a7a849761fed7f829da3874ef6a5b5097a7b9e6a Mon Sep 17 00:00:00 2001 From: Bert Date: Sat, 3 Sep 2011 17:01:39 +0200 Subject: Simplified cursor resetting --- commands.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) (limited to 'commands.c') diff --git a/commands.c b/commands.c index 1bf95af..20ffd42 100644 --- a/commands.c +++ b/commands.c @@ -33,7 +33,7 @@ void cleanup(); void remove_file(int, unsigned char); void load_image(int); void redraw(); -void hide_cursor(); +void reset_cursor(); void animate(); void set_timeout(timeout_f, int, int); void reset_timeout(timeout_f); @@ -56,8 +56,7 @@ int it_switch_mode(arg_t a) { if (!tns.thumbs) tns_init(&tns, filecnt); img_close(&img, 0); - win_set_cursor(&win, CURSOR_ARROW); - reset_timeout(hide_cursor); + reset_timeout(reset_cursor); tns.sel = fileidx; tns.dirty = 1; mode = MODE_THUMB; @@ -81,11 +80,14 @@ int it_toggle_fullscreen(arg_t a) { int it_reload_image(arg_t a) { if (mode == MODE_IMAGE) { load_image(fileidx); - } else if (!tns_load(&tns, tns.sel, &files[tns.sel], True, False)) { - remove_file(tns.sel, 0); - tns.dirty = 1; - if (tns.sel >= tns.cnt) - tns.sel = tns.cnt - 1; + } else { + win_set_cursor(&win, CURSOR_WATCH); + if (!tns_load(&tns, tns.sel, &files[tns.sel], True, False)) { + remove_file(tns.sel, 0); + tns.dirty = 1; + if (tns.sel >= tns.cnt) + tns.sel = tns.cnt - 1; + } } return 1; } @@ -250,7 +252,7 @@ int i_drag(arg_t a) { } win_set_cursor(&win, CURSOR_ARROW); - set_timeout(hide_cursor, TO_CURSOR_HIDE, 1); + set_timeout(reset_cursor, TO_CURSOR_HIDE, 1); reset_timeout(redraw); return 0; @@ -369,17 +371,17 @@ int it_shell_cmd(arg_t a) { return 0; } - win_set_cursor(&win, CURSOR_WATCH); - if ((pid = fork()) == 0) { execl("/bin/sh", "/bin/sh", "-c", cmdline, NULL); warn("could not exec: /bin/sh"); exit(1); } else if (pid < 0) { warn("could not fork. command line was: %s", cmdline); - goto end; + return 0; } + win_set_cursor(&win, CURSOR_WATCH); + waitpid(pid, &status, 0); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) warn("child exited with non-zero return value: %d. command line was: %s", @@ -398,10 +400,5 @@ int it_shell_cmd(arg_t a) { tns.sel = tns.cnt - 1; } -end: - if (mode == MODE_THUMB) - win_set_cursor(&win, CURSOR_ARROW); - /* else: cursor gets reset in redraw() */ - return 1; } -- cgit v1.2.3