martanne / dvtm

dvtm brings the concept of tiling window management, popularized by X11-window managers like dwm to the console. As a console window manager it tries to make it easy to work with multiple console based programs.
MIT License
843 stars 108 forks source link

togglebar() doesn't work with #define BAR_POS BAR_OFF in config.h #136

Open thomas3120 opened 1 year ago

thomas3120 commented 1 year ago

I like to have the bar disabled by default, but want to be able to switch it back on if necessary (i.e. if I use tags). However, if you configure BAR_POS as BAR_OFF in config.h, the togglebar() function (MOD-s by default) doesn't work, because both bar.pos and bar.lastpos are set to BAR_POS in line 249 of dvtm.c, so togglebar() switches form BAR_OFF to BAR_OFF.

To fix this, I have added a default position (BAR_DEF) for the bar in config.h:

#define BAR_DEF BAR_TOP /* BAR_TOP or BAR_BOTTOM for default values, or BAR_OFF to completely disable the bar */

and updated the togglebar() funtion in dvtm.c:

togglebar(const char *args[]) {
    if (bar.pos == BAR_OFF) {
        if (bar.lastpos == BAR_OFF)
            bar.lastpos = BAR_DEF;
        showbar();
    }
    else
        hidebar();
    bar.autohide = false;
    updatebarpos();
    redraw(NULL);
}

Hope this helps others.