初始化每个屏幕的 tag
This commit is contained in:
3
src/default_config.h
Normal file
3
src/default_config.h
Normal file
@@ -0,0 +1,3 @@
|
||||
static const char *const tags[] = {
|
||||
"1", "2", "3", "4", "5", "6", "7", "8", "9", nullptr,
|
||||
};
|
||||
@@ -1,3 +1,27 @@
|
||||
#include "monitor.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
|
||||
void monitor_initialize_tag(monitor_t *monitor, const char **tags) {
|
||||
int i = 0;
|
||||
const char *tag_name = nullptr;
|
||||
tag_t *prev_tag = nullptr;
|
||||
for (tag_name = tags[i]; tag_name; tag_name = tags[++i]) {
|
||||
tag_t *tag = p_new(tag_t, 1);
|
||||
tag->name = strdup(tag_name);
|
||||
tag->mask = 1u << i;
|
||||
|
||||
if (prev_tag) {
|
||||
prev_tag->next = tag;
|
||||
} else {
|
||||
monitor->tag_list = tag;
|
||||
}
|
||||
|
||||
prev_tag = tag;
|
||||
}
|
||||
|
||||
monitor->selected_tag = monitor->tag_list;
|
||||
}
|
||||
|
||||
@@ -4,4 +4,5 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
void monitor_initialize_tag(monitor_t *monitor, const char **tags);
|
||||
void monitor_select_tag(monitor_t *monitor, uint32_t tag_mask);
|
||||
|
||||
8
src/wm.c
8
src/wm.c
@@ -18,6 +18,8 @@
|
||||
|
||||
#include "backtrace.h"
|
||||
#include "buffer.h"
|
||||
#include "default_config.h"
|
||||
#include "monitor.h"
|
||||
#include "types.h"
|
||||
#include "utils.h"
|
||||
|
||||
@@ -255,6 +257,9 @@ static void debug_show_monitor_list(void) {
|
||||
printf("x: %4d, y: %4d, width: %4u, height: %4u -> monitor[%s]\n",
|
||||
m->geometry.x, m->geometry.y, m->geometry.width, m->geometry.height,
|
||||
m->name);
|
||||
for (const tag_t *tag = m->tag_list; tag; tag = tag->next) {
|
||||
printf("tag[\"%s\"]: 0b%09b\n", tag->name, tag->mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,6 +272,9 @@ int main(int argc, char *argv[]) {
|
||||
wm_check_xcb_extensions();
|
||||
|
||||
wm_detect_monitor();
|
||||
for (monitor_t *m = wm.monitor_list; m; m = m->next) {
|
||||
monitor_initialize_tag(m, (const char **)tags);
|
||||
}
|
||||
|
||||
debug_show_monitor_list();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user