Files

65 lines
3.0 KiB
C

#ifndef CTHULHU_COMMANDS_NATIVE_H
#define CTHULHU_COMMANDS_NATIVE_H
#include <X11/Xlib.h>
typedef struct { unsigned long symbol; unsigned int modifiers; int browseOnly, activate, probe; } NativeBinding;
typedef struct {
NativeBinding *bindings;
int bindingCount, probeBindings;
unsigned int extraModifierMask;
Display *display;
Window root;
int insertCode, keypadCode, capsCode, numlockMask;
unsigned int ignoredModifierMask;
int xkbEvent, capsLocked;
struct xkb_context *textContext;
struct xkb_compose_table *composeTable;
struct xkb_compose_state *composeState;
unsigned int lockIndicators[3];
int commands;
int active;
int internalUI;
int browse;
int nativeButtonFocus;
Window browseWindow;
} CommandDevice;
typedef struct { int pressed, code, symbol, textSymbol, modifiers, locks; unsigned long timestamp; char text[64]; } CommandKey;
typedef struct {
int known, pid, x, y, width, height, outerX, outerY, outerWidth, outerHeight;
int frameX, frameY, frameWidth, frameHeight;
unsigned long window;
} Foreground;
typedef struct { int known, pid, x, y; unsigned long window; } PointerPosition;
typedef struct { int known, pid, steam, innerFocus; Window window, focus; } SteamFocusSample;
typedef struct { int xterm; SteamFocusSample steam; } CommandFocusSample;
int cthulhu_active_window_is_xterm(void);
int cthulhu_display_active_window_xterm_match(Display *display);
Foreground read_foreground(Display *display);
int cthulhu_xres_client_pids_supported(Display *display);
int cthulhu_xres_client_pid(Display *display, Window window);
PointerPosition cthulhu_read_pointer(Display *display);
// Caller holds the X11 read guard; optional Steam metadata shares the same
// active-window and WM_CLASS reads as the XTerm match.
int cthulhu_focus_metadata_unchecked(Display *display, SteamFocusSample *steam);
CommandFocusSample cthulhu_read_command_focus(Display *display, int steam_enabled);
int cthulhu_restore_steam_focus(Display *display, Window wrapper, int pid, Window target);
void cthulhu_x11_begin_read(Display *display);
int cthulhu_x11_end_read(Display *display);
int set_command_keys(CommandDevice *device, int enabled);
int configure_command_bindings(CommandDevice *device, NativeBinding *bindings, int count, unsigned int extraModifierMask, int insertCode, int keypadCode, int capsCode);
int set_browse_keys(CommandDevice *device, int enabled);
CommandDevice *open_commands(int useInsert, int useKeypad, int useCaps, int *error);
int command_lock_state(CommandDevice *device);
void toggle_command_caps_lock(CommandDevice *device);
int next_command_key(CommandDevice *device, CommandKey *key);
int acquire_internal_keyboard(CommandDevice *device);
void reset_internal_compose(CommandDevice *device);
void release_command_keyboard(CommandDevice *device);
int replay_command_keys(CommandDevice *device, CommandKey *keys, int count);
void close_commands(CommandDevice *device);
int cthulhu_ocr_click(unsigned long foreground, int x, int y, int root_width, int root_height);
#endif