add wip query support, hidebar/hidebars instead of showbar/showbars
This commit is contained in:
parent
a8bee89741
commit
f8eb16beff
22
queries.h
Normal file
22
queries.h
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
/* Queries
|
||||||
|
*
|
||||||
|
* Queries allow you to return the output of almost any function using the '-q' argument.
|
||||||
|
*/
|
||||||
|
static Query queries[] = {
|
||||||
|
/* queries functions */
|
||||||
|
{ "get_tags", get_tags },
|
||||||
|
{ "get_numtags", get_numtags },
|
||||||
|
{ "get_layouts", get_layouts },
|
||||||
|
{ "get_numlayouts", get_numlayouts },
|
||||||
|
{ "get_barpos", get_barpos },
|
||||||
|
{ "get_bordersize", get_bordersize },
|
||||||
|
{ "get_hidebar", get_hidebar },
|
||||||
|
{ "get_snap", get_snap },
|
||||||
|
{ "get_queries", get_queries },
|
||||||
|
{ "get_font", get_font },
|
||||||
|
{ "get_mfact", get_mfact },
|
||||||
|
{ "get_mastercount", get_mastercount },
|
||||||
|
{ "get_resizehints", get_resizehints },
|
||||||
|
{ "get_lockfullscreen", get_lockfullscreen },
|
||||||
|
};
|
||||||
|
|
41
speedwm.c
41
speedwm.c
|
@ -163,6 +163,13 @@ struct ClientState {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if USEQUERY
|
||||||
|
typedef struct {
|
||||||
|
const char *query_text;
|
||||||
|
int (*func)();
|
||||||
|
} Query;
|
||||||
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
bar_align_left,
|
bar_align_left,
|
||||||
bar_align_center,
|
bar_align_center,
|
||||||
|
@ -345,7 +352,7 @@ struct Monitor {
|
||||||
#if USEIPC
|
#if USEIPC
|
||||||
TagState tagstate;
|
TagState tagstate;
|
||||||
#endif
|
#endif
|
||||||
int showbar;
|
int hidebar;
|
||||||
|
|
||||||
/* bar items */
|
/* bar items */
|
||||||
int hidelayout;
|
int hidelayout;
|
||||||
|
@ -939,6 +946,9 @@ static xcb_connection_t *xcon;
|
||||||
#include <X11/XF86keysym.h> /* Enable multimedia button support */
|
#include <X11/XF86keysym.h> /* Enable multimedia button support */
|
||||||
|
|
||||||
/* Configuration */
|
/* Configuration */
|
||||||
|
#if USEQUERY
|
||||||
|
#include "toggle/query.h"
|
||||||
|
#endif
|
||||||
#include "options.h" /* Include options */
|
#include "options.h" /* Include options */
|
||||||
|
|
||||||
/* Shell command */
|
/* Shell command */
|
||||||
|
@ -981,6 +991,11 @@ static const char *clickstatus[] = { shell, "-c", NULL, NULL }; /* for running c
|
||||||
|
|
||||||
#include "bar/items.c"
|
#include "bar/items.c"
|
||||||
|
|
||||||
|
#if USEQUERY
|
||||||
|
#include "queries.h"
|
||||||
|
#include "toggle/query.c"
|
||||||
|
#endif
|
||||||
|
|
||||||
unsigned int tagw[LENGTH(ftags)];
|
unsigned int tagw[LENGTH(ftags)];
|
||||||
|
|
||||||
struct Pertag {
|
struct Pertag {
|
||||||
|
@ -991,7 +1006,7 @@ struct Pertag {
|
||||||
int stackcounts[LENGTH(ftags) + 1]; /* number of windows in primary stack area */
|
int stackcounts[LENGTH(ftags) + 1]; /* number of windows in primary stack area */
|
||||||
int ltaxis[LENGTH(ftags) + 1][ltaxislast];
|
int ltaxis[LENGTH(ftags) + 1][ltaxislast];
|
||||||
const Layout *ltidxs[LENGTH(ftags) + 1][3]; /* matrix of tags and layouts indexes */
|
const Layout *ltidxs[LENGTH(ftags) + 1][3]; /* matrix of tags and layouts indexes */
|
||||||
int showbars[LENGTH(ftags) + 1]; /* display bar for the current tag */
|
int hidebars[LENGTH(ftags) + 1]; /* display bar for the current tag */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* compile-time check if all tags fit into an unsigned int bit array. */
|
/* compile-time check if all tags fit into an unsigned int bit array. */
|
||||||
|
@ -1719,7 +1734,7 @@ createmon(void)
|
||||||
m->mfact = mfact;
|
m->mfact = mfact;
|
||||||
m->mastercount = mastercount;
|
m->mastercount = mastercount;
|
||||||
m->stackcount = stackcount;
|
m->stackcount = stackcount;
|
||||||
m->showbar = !hidebar;
|
m->hidebar = hidebar;
|
||||||
m->scalepreview = scalepreview;
|
m->scalepreview = scalepreview;
|
||||||
|
|
||||||
/* bar items */
|
/* bar items */
|
||||||
|
@ -1794,7 +1809,7 @@ createmon(void)
|
||||||
m->pertag->ltidxs[i][0] = m->lt[0];
|
m->pertag->ltidxs[i][0] = m->lt[0];
|
||||||
m->pertag->ltidxs[i][1] = m->lt[1];
|
m->pertag->ltidxs[i][1] = m->lt[1];
|
||||||
m->pertag->sellts[i] = m->sellt;
|
m->pertag->sellts[i] = m->sellt;
|
||||||
m->pertag->showbars[i] = m->showbar;
|
m->pertag->hidebars[i] = m->hidebar;
|
||||||
m->pertag->ltaxis[i][layout] = m->ltaxis[layout];
|
m->pertag->ltaxis[i][layout] = m->ltaxis[layout];
|
||||||
m->pertag->ltaxis[i][master] = m->ltaxis[master];
|
m->pertag->ltaxis[i][master] = m->ltaxis[master];
|
||||||
m->pertag->ltaxis[i][stack] = m->ltaxis[stack];
|
m->pertag->ltaxis[i][stack] = m->ltaxis[stack];
|
||||||
|
@ -3851,8 +3866,8 @@ moveresizeedge(const Arg *arg) {
|
||||||
nw = c->w;
|
nw = c->w;
|
||||||
nh = c->h;
|
nh = c->h;
|
||||||
|
|
||||||
starty = selmon->showbar && barposition ? bh : 0;
|
starty = !selmon->hidebar && barposition ? bh : 0;
|
||||||
bp = selmon->showbar && !barposition ? bh : 0;
|
bp = !selmon->hidebar && !barposition ? bh : 0;
|
||||||
|
|
||||||
if (!c || !arg)
|
if (!c || !arg)
|
||||||
return;
|
return;
|
||||||
|
@ -5450,7 +5465,7 @@ togglebar(const Arg *arg)
|
||||||
|
|
||||||
Bar *bar;
|
Bar *bar;
|
||||||
|
|
||||||
selmon->showbar = selmon->pertag->showbars[selmon->pertag->curtag] = !selmon->showbar;
|
selmon->hidebar = selmon->pertag->hidebars[selmon->pertag->curtag] = !selmon->hidebar;
|
||||||
updatebarpos(selmon);
|
updatebarpos(selmon);
|
||||||
for (bar = selmon->bar; bar; bar = bar->next)
|
for (bar = selmon->bar; bar; bar = bar->next)
|
||||||
XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh);
|
XMoveResizeWindow(dpy, bar->win, bar->bx, bar->by, bar->bw, bar->bh);
|
||||||
|
@ -5757,7 +5772,7 @@ updatebarpos(Monitor *m)
|
||||||
bar->bh = bh;
|
bar->bh = bh;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m->showbar) {
|
if (m->hidebar) {
|
||||||
for (bar = m->bar; bar; bar = bar->next)
|
for (bar = m->bar; bar; bar = bar->next)
|
||||||
bar->by = -bh - y_pad;
|
bar->by = -bh - y_pad;
|
||||||
return;
|
return;
|
||||||
|
@ -6164,7 +6179,7 @@ view(const Arg *arg)
|
||||||
selmon->ltaxis[stack] = selmon->pertag->ltaxis[selmon->pertag->curtag][stack];
|
selmon->ltaxis[stack] = selmon->pertag->ltaxis[selmon->pertag->curtag][stack];
|
||||||
selmon->ltaxis[stack2] = selmon->pertag->ltaxis[selmon->pertag->curtag][stack2];
|
selmon->ltaxis[stack2] = selmon->pertag->ltaxis[selmon->pertag->curtag][stack2];
|
||||||
|
|
||||||
if (selmon->showbar != selmon->pertag->showbars[selmon->pertag->curtag])
|
if (!selmon->hidebar != !selmon->pertag->hidebars[selmon->pertag->curtag])
|
||||||
togglebar(NULL);
|
togglebar(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6493,6 +6508,14 @@ main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (argc == 2 && !strcmp("-v", argv[1]))
|
if (argc == 2 && !strcmp("-v", argv[1]))
|
||||||
die("speedwm-"VERSION);
|
die("speedwm-"VERSION);
|
||||||
|
#if USEQUERY
|
||||||
|
if (argc > 1 && !strcmp("-q", argv[1])) {
|
||||||
|
if (argc == 2)
|
||||||
|
die("speedwm: You must specify a query");
|
||||||
|
char *args = argv[2];
|
||||||
|
return query(args);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else if (argc != 1 && strcmp("-s", argv[1]))
|
else if (argc != 1 && strcmp("-s", argv[1]))
|
||||||
die("Invalid argument.");
|
die("Invalid argument.");
|
||||||
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
||||||
|
|
1
toggle.h
1
toggle.h
|
@ -18,6 +18,7 @@ Not compatible with BSDs so for those, set this to 0. */
|
||||||
#define USEFADE 1 /* Include fading windows */
|
#define USEFADE 1 /* Include fading windows */
|
||||||
|
|
||||||
/* Miscellanious */
|
/* Miscellanious */
|
||||||
|
#define USEQUERY 1 /* Include support for queries */
|
||||||
#define USESWITCHER 1 /* Include the switcher */
|
#define USESWITCHER 1 /* Include the switcher */
|
||||||
#define USESYSTRAY 1 /* Include the systray */
|
#define USESYSTRAY 1 /* Include the systray */
|
||||||
#define USEMOUSE 1 /* Include mouse binds */
|
#define USEMOUSE 1 /* Include mouse binds */
|
||||||
|
|
|
@ -150,7 +150,7 @@ dump_monitor(yajl_gen gen, Monitor *mon, int is_selected)
|
||||||
|
|
||||||
YSTR("bar"); YMAP(
|
YSTR("bar"); YMAP(
|
||||||
YSTR("y"); YINT(mon->bar->by);
|
YSTR("y"); YINT(mon->bar->by);
|
||||||
YSTR("is_shown"); YBOOL(mon->showbar);
|
YSTR("is_shown"); YBOOL(!mon->hidebar);
|
||||||
YSTR("is_top"); YBOOL(mon->bar->barposition);
|
YSTR("is_top"); YBOOL(mon->bar->barposition);
|
||||||
YSTR("window_id"); YINT(mon->bar->win);
|
YSTR("window_id"); YINT(mon->bar->win);
|
||||||
)
|
)
|
||||||
|
|
152
toggle/query.c
Normal file
152
toggle/query.c
Normal file
|
@ -0,0 +1,152 @@
|
||||||
|
/* This contains functions for getting speedwm queries.
|
||||||
|
*
|
||||||
|
* If you don't need some of these, you can simply remove them from this file and query.h.
|
||||||
|
* query handles all the other functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
query(char *args)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < LENGTH(queries); i++) {
|
||||||
|
if (strcmp(queries[i].query_text, args) == 0) {
|
||||||
|
return queries[i].func();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ps = fprintf(stderr, "speedwm: Not a valid query.\n");
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_queries()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
int ps = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < LENGTH(queries); i++) {
|
||||||
|
ps = fprintf(stdout, "%s\n", queries[i].query_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_font()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
int ps = 0;
|
||||||
|
|
||||||
|
ps = fprintf(stdout, "%s\n", font);
|
||||||
|
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_barpos()
|
||||||
|
{
|
||||||
|
int ps = fprintf(stdout, "%d\n", barposition);
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_mfact()
|
||||||
|
{
|
||||||
|
int ps = fprintf(stdout, "%f\n", mfact);
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_mastercount()
|
||||||
|
{
|
||||||
|
int ps = fprintf(stdout, "%d\n", mastercount);
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_resizehints()
|
||||||
|
{
|
||||||
|
int ps = fprintf(stdout, "%d\n", mastercount);
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_lockfullscreen()
|
||||||
|
{
|
||||||
|
int ps = fprintf(stdout, "%d\n", lockfullscreen);
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_snap()
|
||||||
|
{
|
||||||
|
int ps = fprintf(stdout, "%d\n", snap);
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_hidebar()
|
||||||
|
{
|
||||||
|
int ps = fprintf(stdout, "%d\n", hidebar);
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_bordersize()
|
||||||
|
{
|
||||||
|
int ps = fprintf(stdout, "%d\n", bordersize);
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_layouts()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
int ps = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < LENGTH(layouts); i++) {
|
||||||
|
ps = fprintf(stdout, "%s\n", layouts[i].symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_numlayouts()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
int ps = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < LENGTH(layouts); i++) {}
|
||||||
|
|
||||||
|
ps = fprintf(stdout, "%d\n", i);
|
||||||
|
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_numtags()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
int ps = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < LENGTH(tags); i++) {}
|
||||||
|
|
||||||
|
ps = fprintf(stdout, "%d\n", i);
|
||||||
|
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
get_tags()
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
int ps = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < LENGTH(tags); i++) {
|
||||||
|
ps = fprintf(stdout, "%s\n", tags[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ps) return 0; else return 1;
|
||||||
|
}
|
17
toggle/query.h
Normal file
17
toggle/query.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
static int query(char *args);
|
||||||
|
|
||||||
|
/* queries */
|
||||||
|
static int get_numtags();
|
||||||
|
static int get_tags();
|
||||||
|
static int get_layouts();
|
||||||
|
static int get_numlayouts();
|
||||||
|
static int get_barpos();
|
||||||
|
static int get_bordersize();
|
||||||
|
static int get_hidebar();
|
||||||
|
static int get_snap();
|
||||||
|
static int get_queries();
|
||||||
|
static int get_font();
|
||||||
|
static int get_mfact();
|
||||||
|
static int get_mastercount();
|
||||||
|
static int get_resizehints();
|
||||||
|
static int get_lockfullscreen();
|
Loading…
Reference in a new issue