feat(core+backend/X11): 实现窗口边框管理和焦点跟随鼠标

This commit is contained in:
2026-05-02 00:46:13 +08:00
parent 1cfa2c4505
commit d90cebe0c2
23 changed files with 272 additions and 87 deletions

View File

@@ -21,6 +21,7 @@
#include "base/log.h"
#include "base/macros.h"
#include "base/memory.h"
#include "base/window_list.h"
#include "core/plan.h"
#include "core/types.h"
#include "internal.h"
@@ -177,14 +178,9 @@ void backend_destroy(backend_t *backend) {
p_delete(&backend->config_list.cfgs);
p_clear(&backend->config_list, 1);
p_delete(&backend->unmap.windows);
p_clear(&backend->unmap, 1);
p_delete(&backend->map.windows);
p_clear(&backend->map, 1);
p_delete(&backend->kill.windows);
p_clear(&backend->kill, 1);
window_list_cleanup(&backend->unmap);
window_list_cleanup(&backend->map);
window_list_cleanup(&backend->kill);
xcb_key_symbols_free(backend->key_symbols);
backend->key_symbols = nullptr;

View File

@@ -264,6 +264,17 @@ static bool handle_key_press(
return true;
}
static bool handle_enter_notify(
backend_t *backend,
event_t *event,
const xcb_enter_notify_event_t *xcb_event
) {
event->type = ZDWM_EVENT_POINTER_ENTER;
event->as.pointer_enter.window = xcb_event->event;
return true;
}
bool backend_next_event(backend_t *backend, event_t *event) {
if (!backend || !backend->conn || !event) return false;
@@ -289,6 +300,7 @@ bool backend_next_event(backend_t *backend, event_t *event) {
EVENT(XCB_DESTROY_NOTIFY, handle_destroy_notify);
EVENT(XCB_CONFIGURE_REQUEST, handle_configure_request);
EVENT(XCB_KEY_PRESS, handle_key_press);
EVENT(XCB_ENTER_NOTIFY, handle_enter_notify);
#undef EVENT

View File

@@ -6,6 +6,8 @@
#include <xcb/xcb_keysyms.h>
#include <xcb/xproto.h>
#include "base/window_list.h"
#define ATOM_LIST(X) \
X(COMPOUND_TEXT) \
X(UTF8_STRING) \
@@ -70,12 +72,6 @@ typedef struct window_configure_list_t {
size_t capacity;
} window_configure_list_t;
typedef struct window_list_t {
xcb_window_t *windows;
size_t count;
size_t capacity;
} window_list_t;
struct backend_t {
xcb_key_symbols_t *key_symbols;
xcb_connection_t *conn;

View File

@@ -7,7 +7,6 @@
#include <xcb/xcb_keysyms.h>
#include <xcb/xproto.h>
#include "base/array.h"
#include "base/macros.h"
#include "base/memory.h"
#include "core/backend.h"
@@ -358,17 +357,6 @@ void window_set_net_wm_state(
);
}
void window_list_push(window_list_t *window_list, xcb_window_t window) {
xcb_window_t *win =
array_push(window_list->windows, window_list->count, window_list->capacity);
*win = window;
}
void window_list_reset(window_list_t *window_list) {
p_clear(window_list->windows, window_list->count);
window_list->count = 0;
}
static uint16_t get_xcb_modifier(modifier_mask_t modifiers) {
typedef struct modifier_map_t {
modifier_bit_t modifier;

View File

@@ -97,9 +97,6 @@ void window_set_net_wm_state(
xcb_atom_t *atoms
);
void window_list_push(window_list_t *window_list, xcb_window_t window);
void window_list_reset(window_list_t *window_list);
void window_grab_keys(
backend_t *backend,
xcb_window_t window,