Make hide_on_modifier configurable
This commit is contained in:
parent
386abde4df
commit
c4c918cb06
|
@ -25,6 +25,7 @@ struct rect_t {
|
||||||
|
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "child.h"
|
#include "child.h"
|
||||||
|
#include "config.h"
|
||||||
#include "ipc.h"
|
#include "ipc.h"
|
||||||
#include "outputs.h"
|
#include "outputs.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
#ifndef CONFIG_H_
|
||||||
|
#define CONFIL_H_
|
||||||
|
|
||||||
|
typedef struct config_t {
|
||||||
|
int hide_on_modifier;
|
||||||
|
} config_t;
|
||||||
|
|
||||||
|
config_t config;
|
||||||
|
|
||||||
|
#endif
|
|
@ -53,16 +53,20 @@ int main(int argc, char **argv) {
|
||||||
char *command = NULL;
|
char *command = NULL;
|
||||||
char *fontname = NULL;
|
char *fontname = NULL;
|
||||||
|
|
||||||
|
/* Definition of the standard-config */
|
||||||
|
config.hide_on_modifier = 0;
|
||||||
|
|
||||||
static struct option long_opt[] = {
|
static struct option long_opt[] = {
|
||||||
{ "socket", required_argument, 0, 's' },
|
{ "socket", required_argument, 0, 's' },
|
||||||
{ "command", required_argument, 0, 'c' },
|
{ "command", required_argument, 0, 'c' },
|
||||||
|
{ "hide", no_argument, 0, 'm' },
|
||||||
{ "font", required_argument, 0, 'f' },
|
{ "font", required_argument, 0, 'f' },
|
||||||
{ "help", no_argument, 0, 'h' },
|
{ "help", no_argument, 0, 'h' },
|
||||||
{ "version", no_argument, 0, 'v' },
|
{ "version", no_argument, 0, 'v' },
|
||||||
{ NULL, 0, 0, 0}
|
{ NULL, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "s:c:f:hv", long_opt, &option_index)) != -1) {
|
while ((opt = getopt_long(argc, argv, "s:c:mf:hv", long_opt, &option_index)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 's':
|
case 's':
|
||||||
socket_path = expand_path(optarg);
|
socket_path = expand_path(optarg);
|
||||||
|
@ -70,6 +74,9 @@ int main(int argc, char **argv) {
|
||||||
case 'c':
|
case 'c':
|
||||||
command = strdup(optarg);
|
command = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
config.hide_on_modifier = 1;
|
||||||
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
fontname = strdup(optarg);
|
fontname = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -72,6 +72,10 @@ uint32_t get_colorpixel(const char *s) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void hide_bars() {
|
void hide_bars() {
|
||||||
|
if (!config.hide_on_modifier) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
i3_output *walk;
|
i3_output *walk;
|
||||||
SLIST_FOREACH(walk, outputs, slist) {
|
SLIST_FOREACH(walk, outputs, slist) {
|
||||||
xcb_unmap_window(xcb_connection, walk->bar);
|
xcb_unmap_window(xcb_connection, walk->bar);
|
||||||
|
@ -84,6 +88,10 @@ void hide_bars() {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void unhide_bars() {
|
void unhide_bars() {
|
||||||
|
if (!config.hide_on_modifier) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
i3_output *walk;
|
i3_output *walk;
|
||||||
xcb_void_cookie_t cookie;
|
xcb_void_cookie_t cookie;
|
||||||
xcb_generic_error_t *err;
|
xcb_generic_error_t *err;
|
||||||
|
@ -345,55 +353,57 @@ void init_xcb(char *fontname) {
|
||||||
strlen(fontname),
|
strlen(fontname),
|
||||||
fontname);
|
fontname);
|
||||||
|
|
||||||
int xkb_major, xkb_minor, xkb_errbase, xkb_err;
|
if (config.hide_on_modifier) {
|
||||||
xkb_major = XkbMajorVersion;
|
int xkb_major, xkb_minor, xkb_errbase, xkb_err;
|
||||||
xkb_minor = XkbMinorVersion;
|
xkb_major = XkbMajorVersion;
|
||||||
|
xkb_minor = XkbMinorVersion;
|
||||||
|
|
||||||
xkb_dpy = XkbOpenDisplay(":0",
|
xkb_dpy = XkbOpenDisplay(":0",
|
||||||
&xkb_event_base,
|
&xkb_event_base,
|
||||||
&xkb_errbase,
|
&xkb_errbase,
|
||||||
&xkb_major,
|
&xkb_major,
|
||||||
&xkb_minor,
|
&xkb_minor,
|
||||||
&xkb_err);
|
&xkb_err);
|
||||||
|
|
||||||
if (xkb_dpy == NULL) {
|
if (xkb_dpy == NULL) {
|
||||||
printf("ERROR: No XKB!\n");
|
printf("ERROR: No XKB!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fcntl(ConnectionNumber(xkb_dpy), F_SETFD, FD_CLOEXEC) == -1) {
|
if (fcntl(ConnectionNumber(xkb_dpy), F_SETFD, FD_CLOEXEC) == -1) {
|
||||||
fprintf(stderr, "Could not set FD_CLOEXEC on xkbdpy\n");
|
fprintf(stderr, "Could not set FD_CLOEXEC on xkbdpy\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i1;
|
int i1;
|
||||||
if (!XkbQueryExtension(xkb_dpy, &i1, &xkb_event_base, &xkb_errbase, &xkb_major, &xkb_minor)) {
|
if (!XkbQueryExtension(xkb_dpy, &i1, &xkb_event_base, &xkb_errbase, &xkb_major, &xkb_minor)) {
|
||||||
printf("ERROR: XKB not supported by X-server!\n");
|
printf("ERROR: XKB not supported by X-server!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!XkbSelectEvents(xkb_dpy, XkbUseCoreKbd, XkbStateNotifyMask, XkbStateNotifyMask)) {
|
if (!XkbSelectEvents(xkb_dpy, XkbUseCoreKbd, XkbStateNotifyMask, XkbStateNotifyMask)) {
|
||||||
printf("Could not grab Key!\n");
|
printf("Could not grab Key!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
xkb_io = malloc(sizeof(ev_io));
|
||||||
|
ev_io_init(xkb_io, &xkb_io_cb, ConnectionNumber(xkb_dpy), EV_READ);
|
||||||
|
ev_io_start(main_loop, xkb_io);
|
||||||
|
XFlush(xkb_dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The varios Watchers to communicate with xcb */
|
/* The varios Watchers to communicate with xcb */
|
||||||
xcb_io = malloc(sizeof(ev_io));
|
xcb_io = malloc(sizeof(ev_io));
|
||||||
xcb_prep = malloc(sizeof(ev_prepare));
|
xcb_prep = malloc(sizeof(ev_prepare));
|
||||||
xcb_chk = malloc(sizeof(ev_check));
|
xcb_chk = malloc(sizeof(ev_check));
|
||||||
xkb_io = malloc(sizeof(ev_io));
|
|
||||||
|
|
||||||
ev_io_init(xcb_io, &xcb_io_cb, xcb_get_file_descriptor(xcb_connection), EV_READ);
|
ev_io_init(xcb_io, &xcb_io_cb, xcb_get_file_descriptor(xcb_connection), EV_READ);
|
||||||
ev_prepare_init(xcb_prep, &xcb_prep_cb);
|
ev_prepare_init(xcb_prep, &xcb_prep_cb);
|
||||||
ev_check_init(xcb_chk, &xcb_chk_cb);
|
ev_check_init(xcb_chk, &xcb_chk_cb);
|
||||||
ev_io_init(xkb_io, &xkb_io_cb, ConnectionNumber(xkb_dpy), EV_READ);
|
|
||||||
|
|
||||||
ev_io_start(main_loop, xcb_io);
|
ev_io_start(main_loop, xcb_io);
|
||||||
ev_prepare_start(main_loop, xcb_prep);
|
ev_prepare_start(main_loop, xcb_prep);
|
||||||
ev_check_start(main_loop, xcb_chk);
|
ev_check_start(main_loop, xcb_chk);
|
||||||
ev_io_start(main_loop, xkb_io);
|
|
||||||
|
|
||||||
XFlush(xkb_dpy);
|
|
||||||
|
|
||||||
/* Now we get the atoms and save them in a nice data-structure */
|
/* Now we get the atoms and save them in a nice data-structure */
|
||||||
get_atoms();
|
get_atoms();
|
||||||
|
@ -492,8 +502,8 @@ void reconfig_windows() {
|
||||||
mask = XCB_CW_BACK_PIXEL | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK;
|
mask = XCB_CW_BACK_PIXEL | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK;
|
||||||
/* Black background */
|
/* Black background */
|
||||||
values[0] = xcb_screens->black_pixel;
|
values[0] = xcb_screens->black_pixel;
|
||||||
/* i3 is not supposed to manage our bar-windows */
|
/* If hide_on_modifier is set, i3 is not supposed to manage our bar-windows */
|
||||||
values[1] = 1;
|
values[1] = config.hide_on_modifier;
|
||||||
/* The events we want to receive */
|
/* The events we want to receive */
|
||||||
values[2] = XCB_EVENT_MASK_EXPOSURE |
|
values[2] = XCB_EVENT_MASK_EXPOSURE |
|
||||||
XCB_EVENT_MASK_BUTTON_PRESS;
|
XCB_EVENT_MASK_BUTTON_PRESS;
|
||||||
|
|
Loading…
Reference in New Issue