goldberg_emulator/overlay_experimental/linux/X11_Hook.h

64 lines
1.6 KiB
C
Raw Normal View History

2019-09-01 18:53:16 +00:00
#ifndef __INCLUDED_X11_HOOK_H__
#define __INCLUDED_X11_HOOK_H__
#include "../Base_Hook.h"
#ifdef __LINUX__
#ifndef NO_OVERLAY
#include <X11/X.h> // XEvent types
#include <X11/Xlib.h> // XEvent structure
2019-11-08 14:54:48 +00:00
extern "C" int XEventsQueued(Display *display, int mode);
extern "C" int XPending(Display *display);
2019-09-01 18:53:16 +00:00
class X11_Hook : public Base_Hook
{
public:
2019-11-08 14:54:48 +00:00
friend int XEventsQueued(Display *display, int mode);
friend int XPending(Display *display);
2019-09-01 18:53:16 +00:00
static constexpr const char* DLL_NAME = "libX11.so";
private:
static X11_Hook* _inst;
// Variables
bool hooked;
bool initialized;
Window game_wnd;
2019-09-01 18:53:16 +00:00
// Functions
X11_Hook();
int check_for_overlay(Display *d, int num_events);
2019-09-01 18:53:16 +00:00
// Hook to X11 window messages
decltype(XEventsQueued)* _XEventsQueued;
2019-09-01 18:53:16 +00:00
decltype(XPeekEvent)* _XPeekEvent;
decltype(XNextEvent)* _XNextEvent;
decltype(XPending)* _XPending;
//decltype(XKeysymToKeycode)* _XKeysymToKeycode;
//decltype(XLookupKeysym)* _XLookupKeysym;
//decltype(XGetGeometry)* _XGetGeometry;
2019-09-01 18:53:16 +00:00
static int MyXEventsQueued(Display * display, int mode);
static int MyXNextEvent(Display* display, XEvent *event);
static int MyXPeekEvent(Display* display, XEvent *event);
static int MyXPending(Display* display);
2019-11-08 14:54:48 +00:00
public:
2019-09-01 18:53:16 +00:00
virtual ~X11_Hook();
void resetRenderState();
void prepareForOverlay(Display *display, Window wnd);
Window get_game_wnd() const{ return game_wnd; }
2019-09-01 18:53:16 +00:00
bool start_hook();
static X11_Hook* Inst();
virtual const char* get_lib_name() const;
};
#endif//NO_OVERLAY
#endif//__LINUX__
#endif//__INCLUDED_X11_HOOK_H__