退出时清理 xcb 按键资源避免内存泄露
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <xcb/xcb_ewmh.h>
|
||||
#include <xcb/xcb_icccm.h>
|
||||
#include <xcb/xcb_image.h>
|
||||
#include <xcb/xcb_keysyms.h>
|
||||
#include <xcb/xinerama.h>
|
||||
#include <xcb/xproto.h>
|
||||
|
||||
@@ -288,9 +289,11 @@ void clean_xcb(void) {
|
||||
focus_window(XCB_WINDOW_NONE);
|
||||
clean_xcb_cursor();
|
||||
clean_ewmh_extension();
|
||||
if (key_symbols) xcb_key_symbols_free(key_symbols);
|
||||
xcb_disconnect(conn);
|
||||
conn = NULL;
|
||||
screen = NULL;
|
||||
key_symbols = NULL;
|
||||
}
|
||||
|
||||
void grab_keybindings(const keybinding_t *keys, const size_t length) {
|
||||
@@ -310,6 +313,7 @@ void grab_keybindings(const keybinding_t *keys, const size_t length) {
|
||||
keycode = xcb_key_symbols_get_keycode(key_symbols, keysym);
|
||||
modifiers = keys[i].modifiers;
|
||||
cookie = xcb_grab_key(conn, key, root, modifiers, *keycode, mode, mode);
|
||||
free(keycode);
|
||||
error = xcb_request_check(conn, cookie);
|
||||
if (error) {
|
||||
clean_xcb();
|
||||
|
||||
Reference in New Issue
Block a user