Compare commits
2 Commits
adf839bf21
...
b510b7b473
| Author | SHA1 | Date | |
|---|---|---|---|
|
b510b7b473
|
|||
|
c30c7d0698
|
@@ -648,8 +648,7 @@ backend_scan_result_t *backend_scan_windows(backend_t *backend) {
|
|||||||
backend_scan_result_t *result = p_new(backend_scan_result_t, 1);
|
backend_scan_result_t *result = p_new(backend_scan_result_t, 1);
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
auto slot = (window_map_request_event_t *)
|
auto slot = array_push(result->windows, result->count, result->capacity);
|
||||||
array_push(result->windows, result->count, result->capacity);
|
|
||||||
if (!populate_window_event(backend, list[i], slot)) {
|
if (!populate_window_event(backend, list[i], slot)) {
|
||||||
window_layer_props_cleanup(&slot->props);
|
window_layer_props_cleanup(&slot->props);
|
||||||
window_metadata_cleanup(&slot->metadata);
|
window_metadata_cleanup(&slot->metadata);
|
||||||
@@ -690,19 +689,28 @@ backend_bar_window_t backend_create_bar_window(
|
|||||||
auto root = backend->screen->root;
|
auto root = backend->screen->root;
|
||||||
auto visual = window_get_visual(backend, true);
|
auto visual = window_get_visual(backend, true);
|
||||||
|
|
||||||
xcb_grab_server(conn);
|
static xcb_colormap_t colormap = XCB_NONE;
|
||||||
|
if (colormap == XCB_NONE) {
|
||||||
|
colormap = xcb_generate_id(conn);
|
||||||
|
uint8_t alloc = XCB_COLORMAP_ALLOC_NONE;
|
||||||
|
xcb_create_colormap(conn, alloc, colormap, root, visual->visual->visual_id);
|
||||||
|
}
|
||||||
|
|
||||||
window_clean_event_mask(conn, root);
|
window_clean_event_mask(conn, root);
|
||||||
|
xcb_grab_server(conn);
|
||||||
|
|
||||||
auto window_id = xcb_generate_id(conn);
|
auto window_id = xcb_generate_id(conn);
|
||||||
uint16_t _class = XCB_WINDOW_CLASS_INPUT_OUTPUT;
|
uint16_t _class = XCB_WINDOW_CLASS_INPUT_OUTPUT;
|
||||||
uint32_t event_mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_BACK_PIXEL |
|
uint32_t value_mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_BACK_PIXEL |
|
||||||
XCB_CW_BORDER_PIXEL | XCB_CW_EVENT_MASK;
|
XCB_CW_BORDER_PIXEL | XCB_CW_EVENT_MASK |
|
||||||
|
XCB_CW_COLORMAP;
|
||||||
|
|
||||||
const xcb_create_window_value_list_t value_list = {
|
const xcb_create_window_value_list_t value_list = {
|
||||||
.override_redirect = true,
|
.override_redirect = true,
|
||||||
.background_pixel = bg_pixel,
|
.background_pixel = bg_pixel,
|
||||||
.border_pixel = 0,
|
.border_pixel = 0,
|
||||||
.event_mask = XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_EXPOSURE,
|
.event_mask = XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_EXPOSURE,
|
||||||
|
.colormap = colormap,
|
||||||
};
|
};
|
||||||
auto cookie = xcb_create_window_aux_checked(
|
auto cookie = xcb_create_window_aux_checked(
|
||||||
conn,
|
conn,
|
||||||
@@ -716,7 +724,7 @@ backend_bar_window_t backend_create_bar_window(
|
|||||||
0,
|
0,
|
||||||
_class,
|
_class,
|
||||||
visual->visual->visual_id,
|
visual->visual->visual_id,
|
||||||
event_mask,
|
value_mask,
|
||||||
&value_list
|
&value_list
|
||||||
);
|
);
|
||||||
if (xcb_request_check(conn, cookie)) fatal("cannot create bar window");
|
if (xcb_request_check(conn, cookie)) fatal("cannot create bar window");
|
||||||
@@ -727,8 +735,8 @@ backend_bar_window_t backend_create_bar_window(
|
|||||||
window_set_class_instance(conn, window_id);
|
window_set_class_instance(conn, window_id);
|
||||||
window_set_name_static(conn, window_id, APP_NAME "_bar");
|
window_set_name_static(conn, window_id, APP_NAME "_bar");
|
||||||
|
|
||||||
root_set_event_mask(backend);
|
|
||||||
xcb_ungrab_server(conn);
|
xcb_ungrab_server(conn);
|
||||||
|
root_set_event_mask(backend);
|
||||||
xcb_aux_sync(conn);
|
xcb_aux_sync(conn);
|
||||||
|
|
||||||
auto width = geometry.width;
|
auto width = geometry.width;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <zdwm/types.h>
|
#include <zdwm/types.h>
|
||||||
|
|
||||||
#include "bar/types.h"
|
#include "bar/types.h"
|
||||||
|
#include "base/color.h"
|
||||||
|
|
||||||
typedef struct bar_output_t {
|
typedef struct bar_output_t {
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
@@ -14,6 +15,10 @@ typedef struct bar_output_t {
|
|||||||
bar_side_t sides[ZDWM_BAR_SIDE_COUNT];
|
bar_side_t sides[ZDWM_BAR_SIDE_COUNT];
|
||||||
} bar_output_t;
|
} bar_output_t;
|
||||||
|
|
||||||
|
typedef struct bar_palette_t {
|
||||||
|
color_t bg;
|
||||||
|
} bar_palette_t;
|
||||||
|
|
||||||
typedef struct bar_t {
|
typedef struct bar_t {
|
||||||
bar_output_t *bars;
|
bar_output_t *bars;
|
||||||
size_t count;
|
size_t count;
|
||||||
@@ -21,4 +26,5 @@ typedef struct bar_t {
|
|||||||
bool visible;
|
bool visible;
|
||||||
|
|
||||||
zdwm_bar_config_t config;
|
zdwm_bar_config_t config;
|
||||||
|
bar_palette_t palette;
|
||||||
} bar_t;
|
} bar_t;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <zdwm/action.h>
|
#include <zdwm/action.h>
|
||||||
|
#include <zdwm/bar.h>
|
||||||
#include <zdwm/types.h>
|
#include <zdwm/types.h>
|
||||||
|
|
||||||
#include "base/log.h"
|
#include "base/log.h"
|
||||||
@@ -167,5 +168,18 @@ bool config_defaults_build(
|
|||||||
api->set_initial_mode(builder, default_mode);
|
api->set_initial_mode(builder, default_mode);
|
||||||
api->set_border_config(builder, 2, "#1c2022", "#606060");
|
api->set_border_config(builder, 2, "#1c2022", "#606060");
|
||||||
|
|
||||||
|
zdwm_bar_config_t bar_config = {
|
||||||
|
.height = 28,
|
||||||
|
.show_top = true,
|
||||||
|
.padding_x = 10,
|
||||||
|
.fps = 30,
|
||||||
|
.font_family = "Terminus, Sarasa Term SC",
|
||||||
|
.font_size = 10,
|
||||||
|
.dpi = 144,
|
||||||
|
|
||||||
|
.bg = "#222222",
|
||||||
|
};
|
||||||
|
api->set_bar_config(builder, bar_config);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "bar/bar.h"
|
#include "bar/bar.h"
|
||||||
#include "base/array.h"
|
#include "base/array.h"
|
||||||
|
#include "base/color.h"
|
||||||
#include "base/log.h"
|
#include "base/log.h"
|
||||||
#include "base/memory.h"
|
#include "base/memory.h"
|
||||||
#include "base/window_list.h"
|
#include "base/window_list.h"
|
||||||
@@ -186,6 +187,46 @@ static void runtime_notify_initial_state(runtime_t *runtime) {
|
|||||||
listeners_notify_binding_mode(listeners, runtime->binding_table);
|
listeners_notify_binding_mode(listeners, runtime->binding_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void runtime_init_bar(runtime_t *runtime) {
|
||||||
|
auto bar_height = runtime->bar.config.height;
|
||||||
|
if (bar_height <= 0) return;
|
||||||
|
|
||||||
|
auto show_top = runtime->bar.config.show_top;
|
||||||
|
inset_t inset = {
|
||||||
|
.top = show_top ? bar_height : 0,
|
||||||
|
.bottom = show_top ? 0 : bar_height,
|
||||||
|
};
|
||||||
|
|
||||||
|
auto state = &runtime->state;
|
||||||
|
auto count = state_output_count(state);
|
||||||
|
|
||||||
|
auto bar = &runtime->bar;
|
||||||
|
bar->bars = p_new(bar_output_t, count);
|
||||||
|
bar->count = count;
|
||||||
|
bar->visible = true;
|
||||||
|
|
||||||
|
color_parse(bar->config.bg, &bar->palette.bg);
|
||||||
|
|
||||||
|
auto backend = runtime->backend;
|
||||||
|
for (size_t i = 0; i < count; ++i) {
|
||||||
|
auto output = state_output_at(state, i);
|
||||||
|
state_output_inset_workarea(state, output->id, inset);
|
||||||
|
auto geometry = output->geometry;
|
||||||
|
rect_t bar_rect = {
|
||||||
|
.x = geometry.x,
|
||||||
|
.y = show_top ? 0 : geometry.y + geometry.height - bar_height,
|
||||||
|
.width = geometry.width,
|
||||||
|
.height = bar_height,
|
||||||
|
};
|
||||||
|
auto color = bar->palette.bg.argb;
|
||||||
|
auto bar_window = backend_create_bar_window(backend, bar_rect, color);
|
||||||
|
auto bar_output = &bar->bars[i];
|
||||||
|
bar_output->cr = bar_window.cr;
|
||||||
|
bar_output->window_id = bar_window.window_id;
|
||||||
|
bar_output->output_id = output->id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void runtime_setup(runtime_t *runtime) {
|
static void runtime_setup(runtime_t *runtime) {
|
||||||
size_t bind_count = 0;
|
size_t bind_count = 0;
|
||||||
auto bindings =
|
auto bindings =
|
||||||
@@ -211,6 +252,8 @@ static void runtime_setup(runtime_t *runtime) {
|
|||||||
backend_apply_effect(backend, plan->effects, plan->count);
|
backend_apply_effect(backend, plan->effects, plan->count);
|
||||||
plan_reset(plan);
|
plan_reset(plan);
|
||||||
runtime_notify_initial_state(runtime);
|
runtime_notify_initial_state(runtime);
|
||||||
|
|
||||||
|
runtime_init_bar(runtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const layout_result_t *runtime_layout_calc(runtime_t *runtime) {
|
static const layout_result_t *runtime_layout_calc(runtime_t *runtime) {
|
||||||
|
|||||||
Reference in New Issue
Block a user