Files
pumpitupdev_pumptools/src/main/hook/patch/block-keyboard-grab.c
T
icex2 eafb2909d1 Appl new code style on whole code base
Use a similar code style to bemanitools though reduce indentation
to 2 spaces. Also some other tweaks to be more similar to google
style.
2021-03-19 15:52:34 +01:00

49 lines
1.0 KiB
C

#define LOG_MODULE "block-keyboard-grab"
#include <X11/Xutil.h>
#include <stdbool.h>
#include "capnhook/hook/lib.h"
#include "util/log.h"
typedef int (*XGrabKeyboard_t)(
Display *display,
Window window,
Bool owner_events,
int pointer_mode,
int keyboard_mode,
Time time);
static XGrabKeyboard_t _patch_main_loop_real_XGrabKeyboard;
static bool _patch_block_keyboard_grab_enable;
int XGrabKeyboard(
Display *display,
Window window,
Bool owner_events,
int pointer_mode,
int keyboard_mode,
Time time)
{
if (!_patch_main_loop_real_XGrabKeyboard) {
_patch_main_loop_real_XGrabKeyboard =
(XGrabKeyboard_t) cnh_lib_get_func_addr("XGrabKeyboard");
}
if (_patch_block_keyboard_grab_enable) {
log_debug("Block keyboard grabbing");
return 0;
}
return _patch_main_loop_real_XGrabKeyboard(
display, window, owner_events, pointer_mode, keyboard_mode, time);
}
void patch_block_keyboard_grab_init()
{
_patch_block_keyboard_grab_enable = true;
log_info("Initialized");
}