2002-05-27 20:51:07 +04:00
|
|
|
#ifndef CXWINDOWSUTIL_H
|
|
|
|
#define CXWINDOWSUTIL_H
|
|
|
|
|
|
|
|
#include "CString.h"
|
2002-06-11 02:06:45 +04:00
|
|
|
#include "BasicTypes.h"
|
2002-05-27 20:51:07 +04:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
|
|
|
|
class CXWindowsUtil {
|
|
|
|
public:
|
|
|
|
static bool getWindowProperty(Display*,
|
2002-06-11 02:06:45 +04:00
|
|
|
Window window, Atom property,
|
|
|
|
CString* data, Atom* type,
|
|
|
|
SInt32* format, bool deleteProperty);
|
2002-05-27 20:51:07 +04:00
|
|
|
static bool setWindowProperty(Display*,
|
2002-06-11 02:06:45 +04:00
|
|
|
Window window, Atom property,
|
|
|
|
const void* data, UInt32 size,
|
|
|
|
Atom type, SInt32 format);
|
2002-05-27 20:51:07 +04:00
|
|
|
static Time getCurrentTime(Display*, Window);
|
|
|
|
|
2002-05-27 22:30:13 +04: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 20:51:07 +04:00
|
|
|
private:
|
|
|
|
class CPropertyNotifyPredicateInfo {
|
|
|
|
public:
|
|
|
|
Window m_window;
|
|
|
|
Atom m_property;
|
|
|
|
};
|
|
|
|
|
|
|
|
static Bool propertyNotifyPredicate(Display*,
|
2002-06-11 02:06:45 +04:00
|
|
|
XEvent* xevent, XPointer arg);
|
2002-05-27 20:51:07 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|