Implement disabling the workspace buttons („thx“ sECuRE)
This commit is contained in:
parent
26993574f5
commit
ed5ac7f41d
|
@ -14,6 +14,7 @@ typedef struct config_t {
|
||||||
dockpos_t dockpos;
|
dockpos_t dockpos;
|
||||||
int verbose;
|
int verbose;
|
||||||
xcb_colors_t *colors;
|
xcb_colors_t *colors;
|
||||||
|
int disable_ws;
|
||||||
} config_t;
|
} config_t;
|
||||||
|
|
||||||
config_t config;
|
config_t config;
|
||||||
|
|
|
@ -121,7 +121,9 @@ void got_workspace_event(char *event) {
|
||||||
void got_output_event(char *event) {
|
void got_output_event(char *event) {
|
||||||
DLOG("Got Output Event!\n");
|
DLOG("Got Output Event!\n");
|
||||||
i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_OUTPUTS, NULL);
|
i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_OUTPUTS, NULL);
|
||||||
|
if (!config.disable_ws) {
|
||||||
i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_WORKSPACES, NULL);
|
i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_WORKSPACES, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Data-structure to easily call the reply-handlers later */
|
/* Data-structure to easily call the reply-handlers later */
|
||||||
|
@ -311,5 +313,9 @@ void destroy_connection() {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void subscribe_events() {
|
void subscribe_events() {
|
||||||
|
if (config.disable_ws) {
|
||||||
|
i3_send_msg(I3_IPC_MESSAGE_TYPE_SUBSCRIBE, "[ \"output\" ]");
|
||||||
|
} else {
|
||||||
i3_send_msg(I3_IPC_MESSAGE_TYPE_SUBSCRIBE, "[ \"workspace\", \"output\" ]");
|
i3_send_msg(I3_IPC_MESSAGE_TYPE_SUBSCRIBE, "[ \"workspace\", \"output\" ]");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,7 @@ void print_usage(char *elf_name) {
|
||||||
printf("\t\tIf -c is specified, the childprocess is sent a SIGSTOP on hiding,\n");
|
printf("\t\tIf -c is specified, the childprocess is sent a SIGSTOP on hiding,\n");
|
||||||
printf("\t\tand a SIGCONT on unhiding of the bars\n");
|
printf("\t\tand a SIGCONT on unhiding of the bars\n");
|
||||||
printf("-f <font>\tUse X-Core-Font <font> for display\n");
|
printf("-f <font>\tUse X-Core-Font <font> for display\n");
|
||||||
|
printf("-w\t\tDisable workspace-buttons\n");
|
||||||
printf("-V\t\tBe (very) verbose with the debug-output\n");
|
printf("-V\t\tBe (very) verbose with the debug-output\n");
|
||||||
printf("-h\t\tDisplay this help-message and exit\n");
|
printf("-h\t\tDisplay this help-message and exit\n");
|
||||||
}
|
}
|
||||||
|
@ -125,6 +126,7 @@ int main(int argc, char **argv) {
|
||||||
/* Definition of the standard-config */
|
/* Definition of the standard-config */
|
||||||
config.hide_on_modifier = 0;
|
config.hide_on_modifier = 0;
|
||||||
config.dockpos = DOCKPOS_NONE;
|
config.dockpos = DOCKPOS_NONE;
|
||||||
|
config.disable_ws = 0;
|
||||||
|
|
||||||
static struct option long_opt[] = {
|
static struct option long_opt[] = {
|
||||||
{ "socket", required_argument, 0, 's' },
|
{ "socket", required_argument, 0, 's' },
|
||||||
|
@ -132,6 +134,7 @@ int main(int argc, char **argv) {
|
||||||
{ "hide", no_argument, 0, 'm' },
|
{ "hide", no_argument, 0, 'm' },
|
||||||
{ "dock", optional_argument, 0, 'd' },
|
{ "dock", optional_argument, 0, 'd' },
|
||||||
{ "font", required_argument, 0, 'f' },
|
{ "font", required_argument, 0, 'f' },
|
||||||
|
{ "nows", no_argument, 0, 'w' },
|
||||||
{ "help", no_argument, 0, 'h' },
|
{ "help", no_argument, 0, 'h' },
|
||||||
{ "version", no_argument, 0, 'v' },
|
{ "version", no_argument, 0, 'v' },
|
||||||
{ "verbose", no_argument, 0, 'V' },
|
{ "verbose", no_argument, 0, 'V' },
|
||||||
|
@ -148,7 +151,7 @@ int main(int argc, char **argv) {
|
||||||
{ NULL, 0, 0, 0}
|
{ NULL, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
while ((opt = getopt_long(argc, argv, "s:c:d::mf:hvVA:B:C:D:E:F:G:H:I:J:", long_opt, &option_index)) != -1) {
|
while ((opt = getopt_long(argc, argv, "s:c:d::mf:whvVA:B:C:D:E:F:G:H:I:J:", long_opt, &option_index)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 's':
|
case 's':
|
||||||
socket_path = expand_path(optarg);
|
socket_path = expand_path(optarg);
|
||||||
|
@ -177,6 +180,9 @@ int main(int argc, char **argv) {
|
||||||
case 'f':
|
case 'f':
|
||||||
fontname = strdup(optarg);
|
fontname = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'w':
|
||||||
|
config.disable_ws = 1;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
printf("i3bar version " I3BAR_VERSION " © 2010 Axel Wagner and contributors\n");
|
printf("i3bar version " I3BAR_VERSION " © 2010 Axel Wagner and contributors\n");
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
@ -263,7 +269,9 @@ int main(int argc, char **argv) {
|
||||||
* workspaces. Everything else (creating the bars, showing the right workspace-
|
* workspaces. Everything else (creating the bars, showing the right workspace-
|
||||||
* buttons and more) is taken care of by the event-driveniness of the code */
|
* buttons and more) is taken care of by the event-driveniness of the code */
|
||||||
i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_OUTPUTS, NULL);
|
i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_OUTPUTS, NULL);
|
||||||
|
if (!config.disable_ws) {
|
||||||
i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_WORKSPACES, NULL);
|
i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_WORKSPACES, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* The name of this function is actually misleading. Even if no -c is specified,
|
/* The name of this function is actually misleading. Even if no -c is specified,
|
||||||
* this function initiates the watchers to listen on stdin and react accordingly */
|
* this function initiates the watchers to listen on stdin and react accordingly */
|
||||||
|
|
|
@ -744,8 +744,10 @@ void reconfig_windows() {
|
||||||
/* If hide_on_modifier is set, 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] = config.hide_on_modifier;
|
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;
|
if (!config.disable_ws) {
|
||||||
|
values[2] |= XCB_EVENT_MASK_BUTTON_PRESS;
|
||||||
|
}
|
||||||
xcb_void_cookie_t win_cookie = xcb_create_window_checked(xcb_connection,
|
xcb_void_cookie_t win_cookie = xcb_create_window_checked(xcb_connection,
|
||||||
xcb_screen->root_depth,
|
xcb_screen->root_depth,
|
||||||
walk->bar,
|
walk->bar,
|
||||||
|
@ -932,6 +934,10 @@ void draw_bars() {
|
||||||
MIN(outputs_walk->rect.w - 4, statusline_width), font_height);
|
MIN(outputs_walk->rect.w - 4, statusline_width), font_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.disable_ws) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
i3_ws *ws_walk;
|
i3_ws *ws_walk;
|
||||||
TAILQ_FOREACH(ws_walk, outputs_walk->workspaces, tailq) {
|
TAILQ_FOREACH(ws_walk, outputs_walk->workspaces, tailq) {
|
||||||
DLOG("Drawing Button for WS %s at x = %d\n", ws_walk->name, i);
|
DLOG("Drawing Button for WS %s at x = %d\n", ws_walk->name, i);
|
||||||
|
@ -978,10 +984,10 @@ void draw_bars() {
|
||||||
i += 10 + ws_walk->name_width;
|
i += 10 + ws_walk->name_width;
|
||||||
}
|
}
|
||||||
|
|
||||||
redraw_bars();
|
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
redraw_bars();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue