2002-05-27 16:51:07 +00:00
|
|
|
#ifndef CXWINDOWSUTIL_H
|
|
|
|
#define CXWINDOWSUTIL_H
|
|
|
|
|
|
|
|
#include "CString.h"
|
2002-06-10 22:06:45 +00:00
|
|
|
#include "BasicTypes.h"
|
2002-06-19 11:23:49 +00:00
|
|
|
#if defined(X_DISPLAY_MISSING)
|
|
|
|
# error X11 is required to build synergy
|
|
|
|
#else
|
|
|
|
# include <X11/Xlib.h>
|
|
|
|
#endif
|
2002-05-27 16:51:07 +00:00
|
|
|
|
|
|
|
class CXWindowsUtil {
|
|
|
|
public:
|
|
|
|
static bool getWindowProperty(Display*,
|
2002-06-10 22:06:45 +00:00
|
|
|
Window window, Atom property,
|
|
|
|
CString* data, Atom* type,
|
|
|
|
SInt32* format, bool deleteProperty);
|
2002-05-27 16:51:07 +00:00
|
|
|
static bool setWindowProperty(Display*,
|
2002-06-10 22:06:45 +00:00
|
|
|
Window window, Atom property,
|
|
|
|
const void* data, UInt32 size,
|
|
|
|
Atom type, SInt32 format);
|
2002-05-27 16:51:07 +00:00
|
|
|
static Time getCurrentTime(Display*, Window);
|
|
|
|
|
2002-05-27 18:30:13 +00:00
|
|
|
// class to set an X error handler in the c'tor and restore the
|
|
|
|
// previous error handler in the d'tor. a lock should only
|
|
|
|
// be installed while the display is locked by the thread.
|
|
|
|
//
|
|
|
|
// CErrorLock() ignores errors
|
|
|
|
// CErrorLock(bool* flag) sets *flag to true if any error occurs
|
|
|
|
class CErrorLock {
|
|
|
|
public:
|
|
|
|
typedef void (*ErrorHandler)(Display*, XErrorEvent*, void* userData);
|
|
|
|
CErrorLock();
|
|
|
|
CErrorLock(bool* errorFlag);
|
|
|
|
CErrorLock(ErrorHandler, void* userData);
|
|
|
|
~CErrorLock();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void install(ErrorHandler, void*);
|
|
|
|
static int internalHandler(Display*, XErrorEvent*);
|
|
|
|
static void ignoreHandler(Display*, XErrorEvent*, void*);
|
|
|
|
static void saveHandler(Display*, XErrorEvent*, void*);
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef int (*XErrorHandler)(Display*, XErrorEvent*);
|
|
|
|
|
|
|
|
ErrorHandler m_handler;
|
|
|
|
void* m_userData;
|
|
|
|
XErrorHandler m_oldXHandler;
|
|
|
|
CErrorLock* m_next;
|
|
|
|
static CErrorLock* s_top;
|
|
|
|
};
|
|
|
|
|
2002-05-27 16:51:07 +00:00
|
|
|
private:
|
|
|
|
class CPropertyNotifyPredicateInfo {
|
|
|
|
public:
|
|
|
|
Window m_window;
|
|
|
|
Atom m_property;
|
|
|
|
};
|
|
|
|
|
|
|
|
static Bool propertyNotifyPredicate(Display*,
|
2002-06-10 22:06:45 +00:00
|
|
|
XEvent* xevent, XPointer arg);
|
2002-05-27 16:51:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|