mirror of
https://github.com/DreamMaoMao/maomaowm.git
synced 2026-06-19 14:33:16 -04:00
opt: make sure the node init to null
This commit is contained in:
parent
75e88f0faf
commit
347f994ed0
6 changed files with 78 additions and 56 deletions
|
|
@ -98,7 +98,8 @@ void client_pending_force_kill(Client *c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void client_add_jump_label_node(Client *c) {
|
void client_add_jump_label_node(Client *c) {
|
||||||
c->jump_label_node = mango_jump_label_node_create(c->scene, config.jumplabeldata);
|
c->jump_label_node =
|
||||||
|
mango_jump_label_node_create(c->scene, config.jumplabeldata);
|
||||||
wlr_scene_node_lower_to_bottom(&c->jump_label_node->scene_buffer->node);
|
wlr_scene_node_lower_to_bottom(&c->jump_label_node->scene_buffer->node);
|
||||||
wlr_scene_node_set_enabled(&c->jump_label_node->scene_buffer->node, false);
|
wlr_scene_node_set_enabled(&c->jump_label_node->scene_buffer->node, false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3497,8 +3497,10 @@ void override_config(void) {
|
||||||
CLAMP_INT(config.jumplabeldata.border_width, 0, 100);
|
CLAMP_INT(config.jumplabeldata.border_width, 0, 100);
|
||||||
config.jumplabeldata.corner_radius =
|
config.jumplabeldata.corner_radius =
|
||||||
CLAMP_INT(config.jumplabeldata.corner_radius, 0, 100);
|
CLAMP_INT(config.jumplabeldata.corner_radius, 0, 100);
|
||||||
config.jumplabeldata.padding_x = CLAMP_INT(config.jumplabeldata.padding_x, 0, 100);
|
config.jumplabeldata.padding_x =
|
||||||
config.jumplabeldata.padding_y = CLAMP_INT(config.jumplabeldata.padding_y, 0, 100);
|
CLAMP_INT(config.jumplabeldata.padding_x, 0, 100);
|
||||||
|
config.jumplabeldata.padding_y =
|
||||||
|
CLAMP_INT(config.jumplabeldata.padding_y, 0, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_value_default() {
|
void set_value_default() {
|
||||||
|
|
@ -3952,7 +3954,8 @@ void reapply_property(void) {
|
||||||
c->bw = config.borderpx;
|
c->bw = config.borderpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
mango_jump_label_node_apply_config(c->jump_label_node, &config.jumplabeldata);
|
mango_jump_label_node_apply_config(c->jump_label_node,
|
||||||
|
&config.jumplabeldata);
|
||||||
mango_tab_bar_node_apply_config(c->tab_bar_node, &config.tabdata);
|
mango_tab_bar_node_apply_config(c->tab_bar_node, &config.tabdata);
|
||||||
|
|
||||||
wlr_scene_rect_set_color(c->droparea, config.dropcolor);
|
wlr_scene_rect_set_color(c->droparea, config.dropcolor);
|
||||||
|
|
|
||||||
|
|
@ -59,8 +59,9 @@ static const struct wlr_buffer_impl text_buffer_impl = {
|
||||||
.end_data_ptr_access = text_buffer_end_data_ptr_access,
|
.end_data_ptr_access = text_buffer_end_data_ptr_access,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct mango_jump_label_node *mango_jump_label_node_create(struct wlr_scene_tree *parent,
|
struct mango_jump_label_node *
|
||||||
DecorateDrawData data) {
|
mango_jump_label_node_create(struct wlr_scene_tree *parent,
|
||||||
|
DecorateDrawData data) {
|
||||||
struct mango_jump_label_node *node = calloc(1, sizeof(*node));
|
struct mango_jump_label_node *node = calloc(1, sizeof(*node));
|
||||||
if (!node)
|
if (!node)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -135,8 +136,8 @@ void mango_jump_label_node_destroy(struct mango_jump_label_node *node) {
|
||||||
free(node);
|
free(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mango_jump_label_node_set_background(struct mango_jump_label_node *node, float r,
|
void mango_jump_label_node_set_background(struct mango_jump_label_node *node,
|
||||||
float g, float b, float a) {
|
float r, float g, float b, float a) {
|
||||||
if (!node)
|
if (!node)
|
||||||
return;
|
return;
|
||||||
node->bg_color[0] = r;
|
node->bg_color[0] = r;
|
||||||
|
|
@ -145,9 +146,9 @@ void mango_jump_label_node_set_background(struct mango_jump_label_node *node, fl
|
||||||
node->bg_color[3] = a;
|
node->bg_color[3] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mango_jump_label_node_set_border(struct mango_jump_label_node *node, float r, float g,
|
void mango_jump_label_node_set_border(struct mango_jump_label_node *node,
|
||||||
float b, float a, int32_t width,
|
float r, float g, float b, float a,
|
||||||
int32_t radius) {
|
int32_t width, int32_t radius) {
|
||||||
if (!node)
|
if (!node)
|
||||||
return;
|
return;
|
||||||
node->border_color[0] = r;
|
node->border_color[0] = r;
|
||||||
|
|
@ -158,16 +159,17 @@ void mango_jump_label_node_set_border(struct mango_jump_label_node *node, float
|
||||||
node->corner_radius = radius;
|
node->corner_radius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mango_jump_label_node_set_padding(struct mango_jump_label_node *node, int32_t pad_x,
|
void mango_jump_label_node_set_padding(struct mango_jump_label_node *node,
|
||||||
int32_t pad_y) {
|
int32_t pad_x, int32_t pad_y) {
|
||||||
if (!node)
|
if (!node)
|
||||||
return;
|
return;
|
||||||
node->padding_x = pad_x >= 0 ? pad_x : 0;
|
node->padding_x = pad_x >= 0 ? pad_x : 0;
|
||||||
node->padding_y = pad_y >= 0 ? pad_y : 0;
|
node->padding_y = pad_y >= 0 ? pad_y : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_text_pixel_size(struct mango_jump_label_node *node, const char *text,
|
static void get_text_pixel_size(struct mango_jump_label_node *node,
|
||||||
float scale, int32_t *out_w, int32_t *out_h) {
|
const char *text, float scale, int32_t *out_w,
|
||||||
|
int32_t *out_h) {
|
||||||
if (node->measure_scale != scale) {
|
if (node->measure_scale != scale) {
|
||||||
pango_cairo_context_set_resolution(node->measure_context, 96.0 * scale);
|
pango_cairo_context_set_resolution(node->measure_context, 96.0 * scale);
|
||||||
node->measure_scale = scale;
|
node->measure_scale = scale;
|
||||||
|
|
@ -191,8 +193,8 @@ static void draw_rounded_rect(cairo_t *cr, double x, double y, double w,
|
||||||
cairo_close_path(cr);
|
cairo_close_path(cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mango_jump_label_node_update(struct mango_jump_label_node *node, const char *text,
|
void mango_jump_label_node_update(struct mango_jump_label_node *node,
|
||||||
float scale) {
|
const char *text, float scale) {
|
||||||
if (!node || !text)
|
if (!node || !text)
|
||||||
return;
|
return;
|
||||||
if (scale <= 0.0f)
|
if (scale <= 0.0f)
|
||||||
|
|
@ -405,19 +407,22 @@ void mango_jump_label_node_update(struct mango_jump_label_node *node, const char
|
||||||
node->logical_height);
|
node->logical_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mango_jump_label_node_set_focus(struct mango_jump_label_node *node, bool focused) {
|
void mango_jump_label_node_set_focus(struct mango_jump_label_node *node,
|
||||||
|
bool focused) {
|
||||||
if (!node || node->focused == focused)
|
if (!node || node->focused == focused)
|
||||||
return;
|
return;
|
||||||
node->focused = focused;
|
node->focused = focused;
|
||||||
// 使用缓存的文本和缩放触发重绘(如果无文本则不重绘)
|
// 使用缓存的文本和缩放触发重绘(如果无文本则不重绘)
|
||||||
if (node->cached_text && node->cached_scale > 0.0f) {
|
if (node->cached_text && node->cached_scale > 0.0f) {
|
||||||
mango_jump_label_node_update(node, node->cached_text, node->cached_scale);
|
mango_jump_label_node_update(node, node->cached_text,
|
||||||
|
node->cached_scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mango_tab_bar_node *
|
struct mango_tab_bar_node *
|
||||||
mango_tab_bar_node_create(void *mango_node_data, struct wlr_scene_tree *parent,
|
mango_tab_bar_node_create(void *mango_node_data, struct wlr_scene_tree *parent,
|
||||||
DecorateDrawData data, int32_t width, int32_t height) {
|
DecorateDrawData data, int32_t width,
|
||||||
|
int32_t height) {
|
||||||
struct mango_tab_bar_node *node = calloc(1, sizeof(*node));
|
struct mango_tab_bar_node *node = calloc(1, sizeof(*node));
|
||||||
if (!node)
|
if (!node)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -498,8 +503,8 @@ void mango_tab_bar_node_destroy(struct mango_tab_bar_node *node) {
|
||||||
free(node);
|
free(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mango_tab_bar_node_set_size(struct mango_tab_bar_node *node,
|
void mango_tab_bar_node_set_size(struct mango_tab_bar_node *node, int32_t width,
|
||||||
int32_t width, int32_t height) {
|
int32_t height) {
|
||||||
if (!node)
|
if (!node)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -521,7 +526,7 @@ void mango_tab_bar_node_set_size(struct mango_tab_bar_node *node,
|
||||||
}
|
}
|
||||||
|
|
||||||
void mango_tab_bar_node_update(struct mango_tab_bar_node *node,
|
void mango_tab_bar_node_update(struct mango_tab_bar_node *node,
|
||||||
const char *text, float scale) {
|
const char *text, float scale) {
|
||||||
if (!node || !text)
|
if (!node || !text)
|
||||||
return;
|
return;
|
||||||
if (scale <= 0.0f)
|
if (scale <= 0.0f)
|
||||||
|
|
@ -761,7 +766,7 @@ void mango_tab_bar_node_update(struct mango_tab_bar_node *node,
|
||||||
}
|
}
|
||||||
|
|
||||||
void mango_tab_bar_node_set_focus(struct mango_tab_bar_node *node,
|
void mango_tab_bar_node_set_focus(struct mango_tab_bar_node *node,
|
||||||
bool focused) {
|
bool focused) {
|
||||||
if (!node || node->focused == focused)
|
if (!node || node->focused == focused)
|
||||||
return;
|
return;
|
||||||
node->focused = focused;
|
node->focused = focused;
|
||||||
|
|
@ -772,7 +777,7 @@ void mango_tab_bar_node_set_focus(struct mango_tab_bar_node *node,
|
||||||
}
|
}
|
||||||
|
|
||||||
void mango_tab_bar_node_set_colors(struct mango_tab_bar_node *node,
|
void mango_tab_bar_node_set_colors(struct mango_tab_bar_node *node,
|
||||||
const float fg[4], const float bg[4]) {
|
const float fg[4], const float bg[4]) {
|
||||||
if (!node)
|
if (!node)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -786,7 +791,7 @@ void mango_tab_bar_node_set_colors(struct mango_tab_bar_node *node,
|
||||||
}
|
}
|
||||||
|
|
||||||
void mango_jump_label_node_apply_config(struct mango_jump_label_node *node,
|
void mango_jump_label_node_apply_config(struct mango_jump_label_node *node,
|
||||||
const DecorateDrawData *data) {
|
const DecorateDrawData *data) {
|
||||||
if (!node || !data)
|
if (!node || !data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -807,12 +812,13 @@ void mango_jump_label_node_apply_config(struct mango_jump_label_node *node,
|
||||||
g_strdup(data->font_desc ? data->font_desc : "monospace Bold 16");
|
g_strdup(data->font_desc ? data->font_desc : "monospace Bold 16");
|
||||||
|
|
||||||
if (node->cached_text && node->cached_scale > 0.0f) {
|
if (node->cached_text && node->cached_scale > 0.0f) {
|
||||||
mango_jump_label_node_update(node, node->cached_text, node->cached_scale);
|
mango_jump_label_node_update(node, node->cached_text,
|
||||||
|
node->cached_scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mango_tab_bar_node_apply_config(struct mango_tab_bar_node *node,
|
void mango_tab_bar_node_apply_config(struct mango_tab_bar_node *node,
|
||||||
const DecorateDrawData *data) {
|
const DecorateDrawData *data) {
|
||||||
if (!node || !data)
|
if (!node || !data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,36 +129,38 @@ struct mango_tab_bar_node {
|
||||||
};
|
};
|
||||||
|
|
||||||
void mango_text_global_finish(void);
|
void mango_text_global_finish(void);
|
||||||
struct mango_jump_label_node *mango_jump_label_node_create(struct wlr_scene_tree *parent,
|
struct mango_jump_label_node *
|
||||||
DecorateDrawData data);
|
mango_jump_label_node_create(struct wlr_scene_tree *parent,
|
||||||
|
DecorateDrawData data);
|
||||||
void mango_jump_label_node_destroy(struct mango_jump_label_node *node);
|
void mango_jump_label_node_destroy(struct mango_jump_label_node *node);
|
||||||
void mango_jump_label_node_set_background(struct mango_jump_label_node *node, float r,
|
void mango_jump_label_node_set_background(struct mango_jump_label_node *node,
|
||||||
float g, float b, float a);
|
float r, float g, float b, float a);
|
||||||
void mango_jump_label_node_set_border(struct mango_jump_label_node *node, float r, float g,
|
void mango_jump_label_node_set_border(struct mango_jump_label_node *node,
|
||||||
float b, float a, int32_t width,
|
float r, float g, float b, float a,
|
||||||
int32_t radius);
|
int32_t width, int32_t radius);
|
||||||
void mango_jump_label_node_set_padding(struct mango_jump_label_node *node, int32_t pad_x,
|
void mango_jump_label_node_set_padding(struct mango_jump_label_node *node,
|
||||||
int32_t pad_y);
|
int32_t pad_x, int32_t pad_y);
|
||||||
void mango_jump_label_node_update(struct mango_jump_label_node *node, const char *text,
|
void mango_jump_label_node_update(struct mango_jump_label_node *node,
|
||||||
float scale);
|
const char *text, float scale);
|
||||||
|
|
||||||
struct mango_tab_bar_node *
|
struct mango_tab_bar_node *
|
||||||
mango_tab_bar_node_create(void *mango_node_data, struct wlr_scene_tree *parent,
|
mango_tab_bar_node_create(void *mango_node_data, struct wlr_scene_tree *parent,
|
||||||
DecorateDrawData data, int32_t width, int32_t height);
|
DecorateDrawData data, int32_t width, int32_t height);
|
||||||
void mango_tab_bar_node_destroy(struct mango_tab_bar_node *node);
|
void mango_tab_bar_node_destroy(struct mango_tab_bar_node *node);
|
||||||
void mango_tab_bar_node_set_size(struct mango_tab_bar_node *node,
|
void mango_tab_bar_node_set_size(struct mango_tab_bar_node *node, int32_t width,
|
||||||
int32_t width, int32_t height);
|
int32_t height);
|
||||||
void mango_tab_bar_node_update(struct mango_tab_bar_node *node,
|
void mango_tab_bar_node_update(struct mango_tab_bar_node *node,
|
||||||
const char *text, float scale);
|
const char *text, float scale);
|
||||||
|
|
||||||
void mango_jump_label_node_set_focus(struct mango_jump_label_node *node, bool focused);
|
void mango_jump_label_node_set_focus(struct mango_jump_label_node *node,
|
||||||
|
bool focused);
|
||||||
void mango_tab_bar_node_set_focus(struct mango_tab_bar_node *node,
|
void mango_tab_bar_node_set_focus(struct mango_tab_bar_node *node,
|
||||||
bool focused);
|
bool focused);
|
||||||
|
|
||||||
void mango_tab_bar_node_set_colors(struct mango_tab_bar_node *node,
|
void mango_tab_bar_node_set_colors(struct mango_tab_bar_node *node,
|
||||||
const float fg[4], const float bg[4]);
|
const float fg[4], const float bg[4]);
|
||||||
void mango_jump_label_node_apply_config(struct mango_jump_label_node *node,
|
void mango_jump_label_node_apply_config(struct mango_jump_label_node *node,
|
||||||
const DecorateDrawData *data);
|
const DecorateDrawData *data);
|
||||||
void mango_tab_bar_node_apply_config(struct mango_tab_bar_node *node,
|
void mango_tab_bar_node_apply_config(struct mango_tab_bar_node *node,
|
||||||
const DecorateDrawData *data);
|
const DecorateDrawData *data);
|
||||||
#endif // jump_label_node_H
|
#endif // jump_label_node_H
|
||||||
|
|
@ -369,8 +369,10 @@ void create_jump_hints(Monitor *m) {
|
||||||
char label_text[2] = {c_char, '\0'};
|
char label_text[2] = {c_char, '\0'};
|
||||||
|
|
||||||
mango_jump_label_node_update(c->jump_label_node, label_text, 1.0f);
|
mango_jump_label_node_update(c->jump_label_node, label_text, 1.0f);
|
||||||
wlr_scene_node_set_enabled(&c->jump_label_node->scene_buffer->node, true);
|
wlr_scene_node_set_enabled(&c->jump_label_node->scene_buffer->node,
|
||||||
wlr_scene_node_raise_to_top(&c->jump_label_node->scene_buffer->node);
|
true);
|
||||||
|
wlr_scene_node_raise_to_top(
|
||||||
|
&c->jump_label_node->scene_buffer->node);
|
||||||
wlr_scene_node_set_position(
|
wlr_scene_node_set_position(
|
||||||
&c->jump_label_node->scene_buffer->node,
|
&c->jump_label_node->scene_buffer->node,
|
||||||
c->geom.width / 2 - c->jump_label_node->logical_width / 2,
|
c->geom.width / 2 - c->jump_label_node->logical_width / 2,
|
||||||
|
|
@ -393,8 +395,8 @@ void finish_jump_mode(Monitor *m) {
|
||||||
if (VISIBLEON(c, m)) {
|
if (VISIBLEON(c, m)) {
|
||||||
if (c->jump_label_node->scene_buffer->node.enabled) {
|
if (c->jump_label_node->scene_buffer->node.enabled) {
|
||||||
c->jump_char = '\0';
|
c->jump_char = '\0';
|
||||||
wlr_scene_node_set_enabled(&c->jump_label_node->scene_buffer->node,
|
wlr_scene_node_set_enabled(
|
||||||
false);
|
&c->jump_label_node->scene_buffer->node, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
src/mango.c
16
src/mango.c
|
|
@ -1296,8 +1296,7 @@ void swallow(Client *c, Client *w) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w->tab_bar_node) {
|
if (w->tab_bar_node) {
|
||||||
wlr_scene_node_set_enabled(&w->tab_bar_node->scene_buffer->node,
|
wlr_scene_node_set_enabled(&w->tab_bar_node->scene_buffer->node, false);
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 全局链表替换 */
|
/* 全局链表替换 */
|
||||||
|
|
@ -4348,6 +4347,8 @@ void init_client_properties(Client *c) {
|
||||||
c->grid_col_per = 1.0f;
|
c->grid_col_per = 1.0f;
|
||||||
c->grid_row_per = 1.0f;
|
c->grid_row_per = 1.0f;
|
||||||
c->is_monocle_hide = false;
|
c->is_monocle_hide = false;
|
||||||
|
c->jump_label_node = NULL;
|
||||||
|
c->tab_bar_node = NULL;
|
||||||
c->overview_scene_surface = NULL;
|
c->overview_scene_surface = NULL;
|
||||||
c->drop_direction = UNDIR;
|
c->drop_direction = UNDIR;
|
||||||
c->enable_drop_area_draw = false;
|
c->enable_drop_area_draw = false;
|
||||||
|
|
@ -6594,8 +6595,15 @@ void unmapnotify(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
c->stack_proportion = 0.0f;
|
c->stack_proportion = 0.0f;
|
||||||
|
|
||||||
mango_jump_label_node_destroy(c->jump_label_node);
|
if (c->jump_label_node) {
|
||||||
mango_tab_bar_node_destroy(c->tab_bar_node);
|
mango_jump_label_node_destroy(c->jump_label_node);
|
||||||
|
c->jump_label_node = NULL;
|
||||||
|
}
|
||||||
|
if (c->tab_bar_node) {
|
||||||
|
mango_tab_bar_node_destroy(c->tab_bar_node);
|
||||||
|
c->tab_bar_node = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
wlr_scene_node_destroy(&c->scene->node);
|
wlr_scene_node_destroy(&c->scene->node);
|
||||||
printstatus(IPC_WATCH_ARRANGGE);
|
printstatus(IPC_WATCH_ARRANGGE);
|
||||||
motionnotify(0, NULL, 0, 0, 0, 0);
|
motionnotify(0, NULL, 0, 0, 0, 0);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue