feat(tray): tray_init 传入背景颜色
This commit is contained in:
@@ -848,7 +848,15 @@ backend_bar_window_t backend_create_bar_window(
|
|||||||
fatal("cannot create cairo context: %s", cairo_status_to_string(statue));
|
fatal("cannot create cairo context: %s", cairo_status_to_string(statue));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enable_tray) tray_init(backend, window_id, width, height);
|
if (enable_tray) {
|
||||||
|
tray_host_window_t host_window = {
|
||||||
|
.window = window_id,
|
||||||
|
.width = width,
|
||||||
|
.height = height,
|
||||||
|
.bg_pixel = bg_pixel,
|
||||||
|
};
|
||||||
|
tray_init(backend, host_window);
|
||||||
|
}
|
||||||
|
|
||||||
return (backend_bar_window_t){
|
return (backend_bar_window_t){
|
||||||
.window_id = window_id,
|
.window_id = window_id,
|
||||||
|
|||||||
@@ -238,12 +238,6 @@ static bool tray_intern_selection_atom(tray_host_t *tray, backend_t *backend) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct tray_host_window_t {
|
|
||||||
xcb_window_t window;
|
|
||||||
int32_t width;
|
|
||||||
int32_t height;
|
|
||||||
} tray_host_window_t;
|
|
||||||
|
|
||||||
static bool tray_create_container_window(
|
static bool tray_create_container_window(
|
||||||
tray_host_t *tray,
|
tray_host_t *tray,
|
||||||
backend_t *backend,
|
backend_t *backend,
|
||||||
@@ -266,7 +260,7 @@ static bool tray_create_container_window(
|
|||||||
XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK |
|
XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK |
|
||||||
XCB_CW_COLORMAP;
|
XCB_CW_COLORMAP;
|
||||||
xcb_create_window_value_list_t value_list = {
|
xcb_create_window_value_list_t value_list = {
|
||||||
.background_pixel = 0,
|
.background_pixel = host_window.bg_pixel,
|
||||||
.border_pixel = 0,
|
.border_pixel = 0,
|
||||||
.override_redirect = true,
|
.override_redirect = true,
|
||||||
.event_mask =
|
.event_mask =
|
||||||
@@ -360,12 +354,7 @@ static void tray_broadcast_manager(tray_host_t *tray, backend_t *backend) {
|
|||||||
xcb_send_event(conn, false, root, event_mask, (char *)&event);
|
xcb_send_event(conn, false, root, event_mask, (char *)&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tray_init(
|
void tray_init(backend_t *backend, tray_host_window_t host_window) {
|
||||||
backend_t *backend,
|
|
||||||
xcb_window_t host_window,
|
|
||||||
int32_t host_width,
|
|
||||||
int32_t host_height
|
|
||||||
) {
|
|
||||||
auto tray = get_tray_host(backend);
|
auto tray = get_tray_host(backend);
|
||||||
if (!tray) {
|
if (!tray) {
|
||||||
tray = p_new(tray_host_t, 1);
|
tray = p_new(tray_host_t, 1);
|
||||||
@@ -376,12 +365,7 @@ void tray_init(
|
|||||||
|
|
||||||
if (!tray_intern_selection_atom(tray, backend)) return;
|
if (!tray_intern_selection_atom(tray, backend)) return;
|
||||||
|
|
||||||
tray_host_window_t host_window_params = {
|
if (!tray_create_container_window(tray, backend, host_window)) return;
|
||||||
.window = host_window,
|
|
||||||
.width = host_width,
|
|
||||||
.height = host_height
|
|
||||||
};
|
|
||||||
if (!tray_create_container_window(tray, backend, host_window_params)) return;
|
|
||||||
if (!tray_take_selection_owner(tray, backend)) {
|
if (!tray_take_selection_owner(tray, backend)) {
|
||||||
tray_cleanup(backend);
|
tray_cleanup(backend);
|
||||||
return;
|
return;
|
||||||
@@ -389,11 +373,11 @@ void tray_init(
|
|||||||
|
|
||||||
tray->enabled = true;
|
tray->enabled = true;
|
||||||
tray->initialized = true;
|
tray->initialized = true;
|
||||||
tray->host_window = host_window;
|
tray->host_window = host_window.window;
|
||||||
tray->icon_size = host_height;
|
tray->icon_size = host_window.height;
|
||||||
|
|
||||||
tray_broadcast_manager(tray, backend);
|
tray_broadcast_manager(tray, backend);
|
||||||
tray_layout_icons(backend, host_width);
|
tray_layout_icons(backend, host_window.width);
|
||||||
xcb_flush(backend->conn);
|
xcb_flush(backend->conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,14 @@ extern const tray_api_t tray_api;
|
|||||||
|
|
||||||
typedef struct backend_t backend_t;
|
typedef struct backend_t backend_t;
|
||||||
|
|
||||||
/* TODO: 添加窗口背景色 */
|
typedef struct tray_host_window_t {
|
||||||
void tray_init(
|
xcb_window_t window;
|
||||||
backend_t *backend,
|
int32_t width;
|
||||||
xcb_window_t host_window,
|
int32_t height;
|
||||||
int32_t host_width,
|
uint32_t bg_pixel;
|
||||||
int32_t host_height
|
} tray_host_window_t;
|
||||||
);
|
|
||||||
|
void tray_init(backend_t *backend, tray_host_window_t host_window);
|
||||||
void tray_cleanup(backend_t *backend);
|
void tray_cleanup(backend_t *backend);
|
||||||
|
|
||||||
bool tray_handle_client_message(
|
bool tray_handle_client_message(
|
||||||
|
|||||||
Reference in New Issue
Block a user