feat(window): 无标题窗口标题按优先级回退显示 instance/class/app_id
新增 window_get_showing_title,按 title → instance_name → class_name → app_id 优先级取显示标题,窗口快照改用该函数, 避免标题缺失时显示为空。
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "core/binding.h"
|
||||
#include "core/layout.h"
|
||||
#include "core/state.h"
|
||||
#include "core/window.h"
|
||||
|
||||
#define FOR_EACH_LISTENER(FIELD, BODY) \
|
||||
do { \
|
||||
@@ -117,7 +118,7 @@ static bool listeners_window_snapshot(
|
||||
*out = (zdwm_window_t){
|
||||
.workspace = window->workspace_id,
|
||||
.id = window->id,
|
||||
.title = window->title,
|
||||
.title = window_get_showing_title(window),
|
||||
.focused = workspace->focused_window_id == window->id,
|
||||
.urgent = window->urgent,
|
||||
.skip_taskbar = window->skip_taskbar,
|
||||
|
||||
@@ -145,3 +145,11 @@ bool window_can_resize(const window_t *window) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const char *window_get_showing_title(const window_t *window) {
|
||||
if (window->title) return window->title;
|
||||
if (window->instance_name) return window->instance_name;
|
||||
if (window->class_name) return window->class_name;
|
||||
if (window->app_id) return window->app_id;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -67,3 +67,4 @@ bool window_need_resize(const window_t *window, int32_t width, int32_t height);
|
||||
bool window_should_has_border(const window_t *window);
|
||||
bool window_should_fix_size(const window_t *window);
|
||||
bool window_can_resize(const window_t *window);
|
||||
const char *window_get_showing_title(const window_t *window);
|
||||
|
||||
Reference in New Issue
Block a user