2
* synergy -- mouse and keyboard sharing utility
3
* Copyright (C) 2002 Chris Schoeneman
5
* This package is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* found in the file COPYING that should have accompanied this file.
9
* This package is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
15
#ifndef CXWINDOWSUTIL_H
16
#define CXWINDOWSUTIL_H
19
#include "BasicTypes.h"
21
#if defined(X_DISPLAY_MISSING)
22
# error X11 is required to build synergy
24
# include <X11/Xlib.h>
27
//! X11 utility functions
32
Gets property \c property on \c window. \b Appends the data to
33
\c *data if \c data is not NULL, saves the property type in \c *type
34
if \c type is not NULL, and saves the property format in \c *format
35
if \c format is not NULL. If \c deleteProperty is true then the
36
property is deleted after being read.
38
static bool getWindowProperty(Display*,
39
Window window, Atom property,
40
CString* data, Atom* type,
41
SInt32* format, bool deleteProperty);
45
Sets property \c property on \c window to \c size bytes of data from
48
static bool setWindowProperty(Display*,
49
Window window, Atom property,
50
const void* data, UInt32 size,
51
Atom type, SInt32 format);
55
Returns the current X server time.
57
static Time getCurrentTime(Display*, Window);
59
//! Convert KeySym to UCS-4
61
Converts a KeySym to the equivalent UCS-4 character. Returns
62
0x0000ffff if the KeySym cannot be mapped.
64
static UInt32 mapKeySymToUCS4(KeySym);
66
//! Convert UCS-4 to KeySym
68
Converts a UCS-4 character to the equivalent KeySym. Returns
69
NoSymbol (0) if the character cannot be mapped.
71
static KeySym mapUCS4ToKeySym(UInt32);
75
This class sets an X error handler in the c'tor and restores the
76
previous error handler in the d'tor. A lock should only be
77
installed while the display is locked by the thread.
79
CErrorLock() ignores errors
80
CErrorLock(bool* flag) sets *flag to true if any error occurs
84
//! Error handler type
85
typedef void (*ErrorHandler)(Display*, XErrorEvent*, void* userData);
93
Set \c *errorFlag if any error occurs.
95
CErrorLock(Display*, bool* errorFlag);
98
Call \c handler on each error.
100
CErrorLock(Display*, ErrorHandler handler, void* userData);
105
void install(ErrorHandler, void*);
106
static int internalHandler(Display*, XErrorEvent*);
107
static void ignoreHandler(Display*, XErrorEvent*, void*);
108
static void saveHandler(Display*, XErrorEvent*, void*);
111
typedef int (*XErrorHandler)(Display*, XErrorEvent*);
114
ErrorHandler m_handler;
116
XErrorHandler m_oldXHandler;
118
static CErrorLock* s_top;
122
class CPropertyNotifyPredicateInfo {
128
static Bool propertyNotifyPredicate(Display*,
129
XEvent* xevent, XPointer arg);
131
static void initKeyMaps();
134
typedef std::map<KeySym, UInt32> CKeySymMap;
135
typedef std::map<UInt32, KeySym> CUCS4Map;
137
static CKeySymMap s_keySymToUCS4;
138
static CUCS4Map s_UCS4ToKeySym;