添加鼠标事件拦截

This commit is contained in:
2025-09-02 22:42:47 +08:00
parent ac91ebbed3
commit 55c3fa1156
5 changed files with 60 additions and 0 deletions

View File

@@ -361,3 +361,15 @@ void set_window_fullscreen_state(xcb_window_t window, bool fullscreen) {
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, window, atom,
XCB_ATOM_WINDOW, 32, data_len, &atom);
}
void ungrab_any_button(xcb_window_t window) {
xcb_ungrab_button(conn, XCB_BUTTON_INDEX_ANY, window, XCB_MOD_MASK_ANY);
}
void grab_button(xcb_window_t window, uint8_t button, uint16_t modifiers) {
uint8_t owner_events = false; /* 事件仅发送给抓取者,不发送给其他窗口 */
uint16_t event_mask =
XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE;
xcb_grab_button(conn, owner_events, window, event_mask, XCB_GRAB_MODE_SYNC,
XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, button, modifiers);
}