From c666d30eeacd6faf41dce50b301ad2fe3195fdb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bert=20M=C3=BCnnich?= Date: Wed, 15 Feb 2012 22:33:39 +0100 Subject: [PATCH] Added it_toggle_bar command; default mapping: XK_b --- README.md | 1 + commands.c | 10 ++++++++++ commands.h | 1 + config.def.h | 1 + sxiv.1 | 3 +++ window.c | 13 +++++++++++++ window.h | 1 + 7 files changed, 30 insertions(+) diff --git a/README.md b/README.md index d51da55..b651044 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ The following general key commands are available: f Toggle fullscreen mode (requires an EWMH/NetWM compliant window manager) + b Toggle visibility of info bar on bottom of window A Toggle visibility of alpha-channel, i.e. transparency r Reload image diff --git a/commands.c b/commands.c index 921019b..0461f01 100644 --- a/commands.c +++ b/commands.c @@ -76,6 +76,7 @@ bool it_switch_mode(arg_t a) { bool it_toggle_fullscreen(arg_t a) { win_toggle_fullscreen(&win); + /* redraw after next ConfigureNotify event */ set_timeout(redraw, TO_REDRAW_RESIZE, false); if (mode == MODE_IMAGE) img.checkpan = true; @@ -84,6 +85,15 @@ bool it_toggle_fullscreen(arg_t a) { return false; } +bool it_toggle_bar(arg_t a) { + win_toggle_bar(&win); + if (mode == MODE_IMAGE) + img.checkpan = img.dirty = true; + else + tns.dirty = true; + return true; +} + bool it_reload_image(arg_t a) { if (mode == MODE_IMAGE) { load_image(fileidx); diff --git a/commands.h b/commands.h index ffba5a5..aeaf884 100644 --- a/commands.h +++ b/commands.h @@ -44,6 +44,7 @@ typedef struct { bool it_quit(arg_t); bool it_switch_mode(arg_t); bool it_toggle_fullscreen(arg_t); +bool it_toggle_bar(arg_t); bool it_reload_image(arg_t); bool it_remove_image(arg_t); bool i_navigate(arg_t); diff --git a/config.def.h b/config.def.h index 9dbd74d..1a38e84 100644 --- a/config.def.h +++ b/config.def.h @@ -60,6 +60,7 @@ static const keymap_t keys[] = { { false, XK_q, it_quit, (arg_t) None }, { false, XK_Return, it_switch_mode, (arg_t) None }, { false, XK_f, it_toggle_fullscreen, (arg_t) None }, + { false, XK_b, it_toggle_bar, (arg_t) None }, { false, XK_r, it_reload_image, (arg_t) None }, { false, XK_D, it_remove_image, (arg_t) None }, diff --git a/sxiv.1 b/sxiv.1 index c2d20db..f9d7331 100644 --- a/sxiv.1 +++ b/sxiv.1 @@ -105,6 +105,9 @@ Go to the last image, or image number .B f Toggle fullscreen mode. .TP +.B b +Toggle visibility of info bar on bottom of window. +.TP .B A Toggle visibility of alpha-channel, i.e. image transparency. .TP diff --git a/window.c b/window.c index 7f36281..673852c 100644 --- a/window.c +++ b/window.c @@ -306,6 +306,19 @@ void win_toggle_fullscreen(win_t *win) { SubstructureNotifyMask | SubstructureRedirectMask, &ev); } +void win_toggle_bar(win_t *win) { + if (win == NULL || win->xwin == None) + return; + + if (win->barh != 0) { + win->h += win->barh; + win->barh = 0; + } else { + win->barh = font.ascent + font.descent + 2 * V_TEXT_PAD; + win->h -= win->barh; + } +} + void win_clear(win_t *win) { win_env_t *e; diff --git a/window.h b/window.h index 8485b61..0b4fae7 100644 --- a/window.h +++ b/window.h @@ -69,6 +69,7 @@ bool win_configure(win_t*, XConfigureEvent*); bool win_moveresize(win_t*, int, int, unsigned int, unsigned int); void win_toggle_fullscreen(win_t*); +void win_toggle_bar(win_t*); void win_clear(win_t*); void win_draw(win_t*);