diff --git a/docs/visuals/theming.md b/docs/visuals/theming.md index 16bfe4ec..3876a7a5 100644 --- a/docs/visuals/theming.md +++ b/docs/visuals/theming.md @@ -57,13 +57,15 @@ You can also color-code windows based on their state: | Setting | Default | Description | | :--- | :--- | :--- | | `text_decorate_fg_color` | `0xc4939dff` | label text color. | -| `text_decorate_bg_color` | `0x201b14ff` | label background color. -| `text_decorate_border_color` | `0x8BAA9Bff` | label border color. -| `text_decorate_border_width` | `4` | label border width. -| `text_decorate_corner_radius` | `5` | label corner radius. -| `text_decorate_padding_x` | `10` | label horizontal padding. -| `text_decorate_padding_y` | `10` | label vertical padding. -| `text_decorate_font_desc` | `monospace Bold 24` | label font set.| +| `text_decorate_bg_color` | `0x201b14ff` | label background color.| +| `text_decorate_focus_fg_color` | `0x201b14ff` | label text color for focus. | +| `text_decorate_focus_bg_color` | `0xc4939dff` | label background color for focus.| +| `text_decorate_border_color` | `0x8BAA9Bff` | label border color.| +| `text_decorate_border_width` | `4` | label border width.| +| `text_decorate_corner_radius` | `5` | label corner radius.| +| `text_decorate_padding_x` | `10` | label horizontal padding.| +| `text_decorate_padding_y` | `10` | label vertical padding.| +| `text_decorate_font_desc` | `monospace Bold 12` | label font set.| ## Cursor Theme diff --git a/src/draw/text-node.c b/src/draw/text-node.c index 5a7b5046..c42cdf72 100644 --- a/src/draw/text-node.c +++ b/src/draw/text-node.c @@ -83,7 +83,7 @@ struct mango_text_node *mango_text_node_create(struct wlr_scene_tree *parent, node->padding_x = data.padding_x; node->padding_y = data.padding_y; node->font_desc = - g_strdup(data.font_desc ? data.font_desc : "monospace Bold 24"); + g_strdup(data.font_desc ? data.font_desc : "monospace Bold 12"); node->cached_text = NULL; node->cached_scale = -1.0f; @@ -98,6 +98,8 @@ struct mango_text_node *mango_text_node_create(struct wlr_scene_tree *parent, node->measure_layout = pango_layout_new(node->measure_context); node->measure_scale = 1.0f; + node->scene_buffer->node.data = NULL; + return node; } @@ -414,8 +416,8 @@ void mango_text_node_set_focus(struct mango_text_node *node, bool focused) { } struct mango_titlebar_node * -mango_titlebar_node_create(struct wlr_scene_tree *parent, TextDrawData data, - int32_t width, int32_t height) { +mango_titlebar_node_create(void *mango_node_data, struct wlr_scene_tree *parent, + TextDrawData data, int32_t width, int32_t height) { struct mango_titlebar_node *node = calloc(1, sizeof(*node)); if (!node) return NULL; @@ -438,7 +440,7 @@ mango_titlebar_node_create(struct wlr_scene_tree *parent, TextDrawData data, node->padding_x = data.padding_x; node->padding_y = data.padding_y; node->font_desc = - g_strdup(data.font_desc ? data.font_desc : "monospace Bold 24"); + g_strdup(data.font_desc ? data.font_desc : "monospace Bold 12"); node->target_width = width; node->target_height = height; @@ -455,6 +457,7 @@ mango_titlebar_node_create(struct wlr_scene_tree *parent, TextDrawData data, node->cached_scale = -1.0f; node->last_text = NULL; node->last_scale = 0.0f; + node->scene_buffer->node.data = mango_node_data; return node; } @@ -484,13 +487,14 @@ void mango_titlebar_node_destroy(struct mango_titlebar_node *node) { if (node->measure_cr) cairo_destroy(node->measure_cr); + void *data = node->scene_buffer->node.data; wlr_scene_node_destroy(&node->scene_buffer->node); g_free(node->font_desc); g_free(node->cached_text); g_free(node->cached_font_desc); g_free(node->last_text); - + free(data); free(node); } diff --git a/src/draw/text-node.h b/src/draw/text-node.h index 06ffce8a..e0de8e7e 100644 --- a/src/draw/text-node.h +++ b/src/draw/text-node.h @@ -143,8 +143,8 @@ void mango_text_node_update(struct mango_text_node *node, const char *text, float scale); struct mango_titlebar_node * -mango_titlebar_node_create(struct wlr_scene_tree *parent, TextDrawData data, - int32_t width, int32_t height); +mango_titlebar_node_create(void *mango_node_data, struct wlr_scene_tree *parent, + TextDrawData data, int32_t width, int32_t height); void mango_titlebar_node_destroy(struct mango_titlebar_node *node); void mango_titlebar_node_set_size(struct mango_titlebar_node *node, int32_t width, int32_t height); diff --git a/src/mango.c b/src/mango.c index 9f5aeb0d..146b9448 100644 --- a/src/mango.c +++ b/src/mango.c @@ -170,6 +170,7 @@ enum { LyrBlur, LyrBottom, LyrTile, + LyrDecorate, LyrTop, LyrFadeOut, LyrOverlay, @@ -177,6 +178,9 @@ enum { LyrBlock, NUM_LAYERS }; /* scene layers */ + +enum mango_node_type { MANGO_TITLE_NODE, MANGO_TEXT_NODE }; + #ifdef XWAYLAND enum { NetWMWindowTypeDialog, @@ -243,6 +247,11 @@ typedef struct { Client *tc; } Arg; +typedef struct { + enum mango_node_type type; + void *node_data; +} MangoNodeData; + typedef struct { uint32_t mod; uint32_t button; @@ -2379,6 +2388,17 @@ bool handle_buttonpress(struct wlr_pointer_button_event *event) { return true; } + // handle click on tile node + struct wlr_scene_node *node = wlr_scene_node_at( + &layers[LyrDecorate]->node, cursor->x, cursor->y, NULL, NULL); + if (node && node->data) { + MangoNodeData *mangonodedata = (MangoNodeData *)node->data; + if (mangonodedata->type == MANGO_TITLE_NODE) { + Client *c = mangonodedata->node_data; + focusclient(c, 1); + } + } + // 当鼠标焦点在layer上的时候,不检测虚拟键盘的mod状态, // 避免layer虚拟键盘锁死mod按键状态 hard_keyboard = &kb_group->wlr_group->keyboard; @@ -4557,8 +4577,12 @@ mapnotify(struct wl_listener *listener, void *data) { wlr_scene_node_lower_to_bottom(&c->text_node->scene_buffer->node); wlr_scene_node_set_enabled(&c->text_node->scene_buffer->node, false); - c->titlebar_node = - mango_titlebar_node_create(layers[LyrTile], config.textdata, 0, 0); + MangoNodeData *mangonodedata = ecalloc(1, sizeof(MangoNodeData)); + mangonodedata->node_data = c; + mangonodedata->type = MANGO_TITLE_NODE; + + c->titlebar_node = mango_titlebar_node_create( + mangonodedata, layers[LyrDecorate], config.textdata, 0, 0); wlr_scene_node_lower_to_bottom(&c->titlebar_node->scene_buffer->node); wlr_scene_node_set_enabled(&c->titlebar_node->scene_buffer->node, false);