绘制布局标志
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
static const char *const font_family = "monospace";
|
static const char *const font_family = "monospace";
|
||||||
static const int font_size = 10;
|
static const int font_size = 10;
|
||||||
@@ -32,3 +33,8 @@ static const keyboard_t key_list[] = {
|
|||||||
{modifier_alt, XK_q, quit, {.b = false}},
|
{modifier_alt, XK_q, quit, {.b = false}},
|
||||||
{modifier_alt, XK_r, quit, {.b = true}},
|
{modifier_alt, XK_r, quit, {.b = true}},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const layout_t layout_list[] = {
|
||||||
|
{.symbol = "[M]", .arrange = nullptr},
|
||||||
|
{.symbol = "><=", .arrange = nullptr},
|
||||||
|
};
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ uint32_t monitor_initialize_tag(monitor_t *monitor, const char **tags,
|
|||||||
tag->mask = 1u << i;
|
tag->mask = 1u << i;
|
||||||
tag->index = tag_index_start_at + tag_count;
|
tag->index = tag_index_start_at + tag_count;
|
||||||
|
|
||||||
|
if (wm.layout_count > 0 && wm.layout_list) {
|
||||||
|
tag->layout = &wm.layout_list[0];
|
||||||
|
}
|
||||||
|
|
||||||
if (prev_tag) {
|
if (prev_tag) {
|
||||||
prev_tag->next = tag;
|
prev_tag->next = tag;
|
||||||
} else {
|
} else {
|
||||||
@@ -174,6 +178,24 @@ static void monitor_draw_tags(monitor_t *monitor) {
|
|||||||
monitor->tag_extent.end = x;
|
monitor->tag_extent.end = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void monitor_draw_layout_symbol(monitor_t *monitor) {
|
||||||
|
const layout_t *layout = monitor->selected_tag->layout;
|
||||||
|
if (layout && layout->symbol) {
|
||||||
|
color_t *color = &wm.color_set.tag_color;
|
||||||
|
int width = 0;
|
||||||
|
text_get_size(layout->symbol, &width, nullptr);
|
||||||
|
area_t area = {
|
||||||
|
.x = monitor->tag_extent.end,
|
||||||
|
.y = monitor->geometry.y,
|
||||||
|
.width = width + 2 * wm.padding.tag_x,
|
||||||
|
.height = wm.bar_height,
|
||||||
|
};
|
||||||
|
monitor->layout_symbol_extent.start = area.x;
|
||||||
|
monitor->layout_symbol_extent.end = area.x + area.width;
|
||||||
|
draw_text(monitor->bar_cr, layout->symbol, color, area, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void monitor_draw_bar(monitor_t *monitor) {
|
void monitor_draw_bar(monitor_t *monitor) {
|
||||||
cairo_t *cr = monitor->bar_cr;
|
cairo_t *cr = monitor->bar_cr;
|
||||||
uint16_t height = wm.bar_height;
|
uint16_t height = wm.bar_height;
|
||||||
@@ -186,4 +208,5 @@ void monitor_draw_bar(monitor_t *monitor) {
|
|||||||
draw_background(cr, &wm.color_set.bar_bg, bar_area);
|
draw_background(cr, &wm.color_set.bar_bg, bar_area);
|
||||||
|
|
||||||
monitor_draw_tags(monitor);
|
monitor_draw_tags(monitor);
|
||||||
|
monitor_draw_layout_symbol(monitor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ struct monitor_t {
|
|||||||
cairo_t *bar_cr;
|
cairo_t *bar_cr;
|
||||||
|
|
||||||
extent_in_bar_t tag_extent;
|
extent_in_bar_t tag_extent;
|
||||||
|
extent_in_bar_t layout_symbol_extent;
|
||||||
|
|
||||||
xcb_window_t bar_window;
|
xcb_window_t bar_window;
|
||||||
};
|
};
|
||||||
@@ -68,7 +69,7 @@ struct tag_t {
|
|||||||
extent_in_bar_t bar_extent;
|
extent_in_bar_t bar_extent;
|
||||||
tag_t *next;
|
tag_t *next;
|
||||||
char *name;
|
char *name;
|
||||||
layout_t *layout;
|
const layout_t *layout;
|
||||||
task_in_tag_t *task_list;
|
task_in_tag_t *task_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
2
src/wm.c
2
src/wm.c
@@ -273,6 +273,8 @@ void wm_clean(void) {
|
|||||||
|
|
||||||
static void wm_setup(void) {
|
static void wm_setup(void) {
|
||||||
wm.padding.tag_x = tag_x_padding;
|
wm.padding.tag_x = tag_x_padding;
|
||||||
|
wm.layout_list = layout_list;
|
||||||
|
wm.layout_count = (uint16_t)countof(layout_list);
|
||||||
|
|
||||||
wm_init_color_set();
|
wm_init_color_set();
|
||||||
|
|
||||||
|
|||||||
2
src/wm.h
2
src/wm.h
@@ -9,6 +9,7 @@
|
|||||||
typedef struct wm_t {
|
typedef struct wm_t {
|
||||||
padding_t padding;
|
padding_t padding;
|
||||||
uint16_t bar_height;
|
uint16_t bar_height;
|
||||||
|
uint16_t layout_count;
|
||||||
|
|
||||||
bool need_restart;
|
bool need_restart;
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
@@ -18,6 +19,7 @@ typedef struct wm_t {
|
|||||||
client_t *client_focused;
|
client_t *client_focused;
|
||||||
monitor_t *monitor_list;
|
monitor_t *monitor_list;
|
||||||
monitor_t *current_monitor;
|
monitor_t *current_monitor;
|
||||||
|
const layout_t *layout_list;
|
||||||
|
|
||||||
xcb_connection_t *xcb_conn;
|
xcb_connection_t *xcb_conn;
|
||||||
xcb_screen_t *screen;
|
xcb_screen_t *screen;
|
||||||
|
|||||||
Reference in New Issue
Block a user