处理 expose 事件

This commit is contained in:
2025-08-24 11:44:56 +08:00
parent 0039cd2c43
commit 165dd0733c
3 changed files with 17 additions and 2 deletions

View File

@@ -89,6 +89,8 @@ typedef struct destroy_notify_event_t {
typedef struct expose_event_t {
event_type_t type;
xcb_window_t window;
uint32_t count;
} expose_event_t;
typedef struct motion_notify_event_t {

View File

@@ -40,6 +40,7 @@ static void configure_request(configure_request_event_t *event);
static void map_request(map_request_event_t *event);
static void unmap_notify(unmap_notify_event_t *event);
static void destroy_notify(destroy_notify_event_t *event);
static void expose(expose_event_t *event);
static void motion_notify(motion_notify_event_t *event);
static void enter_notify(enter_notify_event_t *event);
static void focus_in(focus_in_event_t *event);
@@ -468,6 +469,7 @@ void xcb_event_handler(generic_event_t *event, void *user_data) {
EVENT(EVENT_TYPE_MAP_REQUEST, map_request);
EVENT(EVENT_TYPE_UNMAP_NOTIFY, unmap_notify);
EVENT(EVENT_TYPE_DESTROY_NOTIFY, destroy_notify);
EVENT(EVENT_TYPE_EXPOSE, expose);
EVENT(EVENT_TYPE_MOTION_NOTIFY, motion_notify);
EVENT(EVENT_TYPE_ENTER_NOTIFY, enter_notify);
EVENT(EVENT_TYPE_FOCUS_IN, focus_in);
@@ -528,6 +530,13 @@ void destroy_notify(destroy_notify_event_t *event) {
if (c) unmanage_client(c, true);
}
void expose(expose_event_t *event) {
monitor_t *m = NULL;
if (event->count == 0 && (m = get_monitor_of_window(event->window))) {
draw_monitor_bar(m);
}
}
void motion_notify(motion_notify_event_t *event) {
logger("motion: window: 0x%x, root: 0x%x\n", event->window, event->root);
logger("x: %d, y: %d, root_x: %d, root_y: %d\n", event->x, event->y,

View File

@@ -73,9 +73,13 @@ static void convert_event(xcb_generic_event_t *xcb_event,
event->destroy_notify.window = ev->window;
break;
}
case XCB_EXPOSE:
event->type = EVENT_TYPE_EXPOSE;
case XCB_EXPOSE: {
xcb_expose_event_t *ev = (xcb_expose_event_t *)xcb_event;
event->expose.type = EVENT_TYPE_EXPOSE;
event->expose.window = ev->window;
event->expose.count = ev->count;
break;
}
case XCB_MOTION_NOTIFY: {
xcb_motion_notify_event_t *ev = (xcb_motion_notify_event_t *)xcb_event;
event->motiion_notify.type = EVENT_TYPE_MOTION_NOTIFY;