绘制 tag 标识
This commit is contained in:
24
src/main.c
24
src/main.c
@@ -27,12 +27,14 @@ static void init_color_set(void);
|
||||
static void parse_color(const char *hex, color_t *color);
|
||||
static void init_monitor_bar(void);
|
||||
static void get_xresource_config(void);
|
||||
static void update_bars(void);
|
||||
static void init_xcb_event_loop(void);
|
||||
static gboolean handle_xcb_event(GIOChannel *channel, GIOCondition condition,
|
||||
gpointer userdata);
|
||||
static void cleanup(void);
|
||||
|
||||
static monitor_t *monitors = NULL;
|
||||
static monitor_t *current_monitor = NULL;
|
||||
static wallpaper_config_t *wallpaper_config = NULL;
|
||||
static color_set_t *color_set = NULL;
|
||||
static GMainLoop *loop = NULL;
|
||||
@@ -64,6 +66,8 @@ static void print_color(const char *prompt, const color_t *color) {
|
||||
}
|
||||
static void print_color_set(color_set_t *set) {
|
||||
print_color("== bar bg:", &set->bar_bg);
|
||||
print_color("== tag bg:", &set->tag_bg);
|
||||
print_color("== active tag bg:", &set->active_tag_bg);
|
||||
print_color("== tag color:", &set->tag_color);
|
||||
print_color("== active tag color:", &set->active_tag_color);
|
||||
print_color("== layout bg:", &set->layout_color);
|
||||
@@ -112,6 +116,7 @@ void init_monitors(void) {
|
||||
prev_monitor->next = m;
|
||||
} else {
|
||||
monitors = m;
|
||||
current_monitor = m;
|
||||
}
|
||||
prev_monitor = m;
|
||||
|
||||
@@ -122,6 +127,7 @@ void init_monitors(void) {
|
||||
}
|
||||
for (monitor_t *m = monitors; m; m = m->next) {
|
||||
m->tags = get_monitor_tags(i, m->index);
|
||||
m->selected_tag = 0x1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,6 +242,8 @@ void free_wallpaper_config(wallpaper_config_t *wallpaper_config) {
|
||||
void init_color_set(void) {
|
||||
color_set = ecalloc(1, sizeof(color_set_t));
|
||||
char *bar_background = NULL;
|
||||
char *tag_background = NULL;
|
||||
char *active_tag_background = NULL;
|
||||
char *tag = NULL;
|
||||
char *active_tag = NULL;
|
||||
char *layout = NULL;
|
||||
@@ -246,6 +254,9 @@ void init_color_set(void) {
|
||||
char *active_border = NULL;
|
||||
|
||||
get_xresource_string("zswm.color.bar_bg", &bar_background, bar_bg);
|
||||
get_xresource_string("zswm.color.tag_bg", &tag_background, tag_bg);
|
||||
get_xresource_string("zswm.color.active_tag_bg", &active_tag_background,
|
||||
active_tag_bg);
|
||||
get_xresource_string("zswm.color.tag", &tag, tag_color);
|
||||
get_xresource_string("zswm.color.active_tag", &active_tag, active_tag_color);
|
||||
get_xresource_string("zswm.color.layout", &layout, layout_color);
|
||||
@@ -259,6 +270,8 @@ void init_color_set(void) {
|
||||
active_border_color);
|
||||
|
||||
parse_color(bar_background, &color_set->bar_bg);
|
||||
parse_color(tag_background, &color_set->tag_bg);
|
||||
parse_color(active_tag_background, &color_set->active_tag_bg);
|
||||
parse_color(tag, &color_set->tag_color);
|
||||
parse_color(active_tag, &color_set->active_tag_color);
|
||||
parse_color(layout, &color_set->layout_color);
|
||||
@@ -269,6 +282,8 @@ void init_color_set(void) {
|
||||
parse_color(active_border, &color_set->active_border_color);
|
||||
|
||||
free(bar_background);
|
||||
free(tag_background);
|
||||
free(active_tag_background);
|
||||
free(tag);
|
||||
free(active_tag);
|
||||
free(layout);
|
||||
@@ -330,6 +345,13 @@ void get_xresource_config(void) {
|
||||
clean_xresource();
|
||||
}
|
||||
|
||||
void update_bars(void) {
|
||||
for (monitor_t *m = monitors; m; m = m->next) {
|
||||
draw_bar(m, m == current_monitor, color_set, bar_height, tag_x_padding);
|
||||
}
|
||||
flush_xcb_connection();
|
||||
}
|
||||
|
||||
void init_xcb_event_loop(void) {
|
||||
GIOChannel *channel = g_io_channel_unix_new(get_xcb_connection_fd());
|
||||
g_io_channel_set_encoding(channel, NULL, NULL);
|
||||
@@ -392,6 +414,8 @@ int main(int argc, char *argv[]) {
|
||||
set_root_cursor(cursor_normal);
|
||||
init_wallpaper();
|
||||
|
||||
update_bars();
|
||||
|
||||
window_list_t *window_list = scan_window_list();
|
||||
|
||||
print_monitor_list_info(monitors);
|
||||
|
||||
Reference in New Issue
Block a user