CXWindowsUtil.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2002 Chris Schoeneman
00004  * 
00005  * This package is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * found in the file COPYING that should have accompanied this file.
00008  * 
00009  * This package is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  */
00014 
00015 #ifndef CXWINDOWSUTIL_H
00016 #define CXWINDOWSUTIL_H
00017 
00018 #include "CString.h"
00019 #include "BasicTypes.h"
00020 #include "stdmap.h"
00021 #include "stdvector.h"
00022 #if X_DISPLAY_MISSING
00023 #   error X11 is required to build synergy
00024 #else
00025 #   include <X11/Xlib.h>
00026 #endif
00027 
00029 class CXWindowsUtil {
00030 public:
00031     typedef std::vector<KeySym> KeySyms;
00032 
00034 
00041     static bool         getWindowProperty(Display*,
00042                             Window window, Atom property,
00043                             CString* data, Atom* type,
00044                             SInt32* format, bool deleteProperty);
00045 
00047 
00051     static bool         setWindowProperty(Display*,
00052                             Window window, Atom property,
00053                             const void* data, UInt32 size,
00054                             Atom type, SInt32 format);
00055 
00057 
00060     static Time         getCurrentTime(Display*, Window);
00061 
00063 
00067     static UInt32       mapKeySymToKeyID(KeySym);
00068 
00070 
00074     static UInt32       getModifierBitForKeySym(KeySym keysym);
00075 
00077 
00080     static CString      atomToString(Display*, Atom atom);
00081 
00083 
00087     static CString      atomsToString(Display* display,
00088                             const Atom* atom, UInt32 num);
00089 
00091 
00095     static void         convertAtomProperty(CString& data);
00096 
00098 
00102     static void         appendAtomData(CString& data, Atom atom);
00103 
00105 
00109     static void         replaceAtomData(CString& data,
00110                             UInt32 index, Atom atom);
00111 
00113 
00117     static void         appendTimeData(CString& data, Time time);
00118 
00120 
00128     class CErrorLock {
00129     public:
00131         typedef void (*ErrorHandler)(Display*, XErrorEvent*, void* userData);
00132 
00136         CErrorLock(Display*);
00137 
00141         CErrorLock(Display*, bool* errorFlag);
00142 
00146         CErrorLock(Display*, ErrorHandler handler, void* userData);
00147 
00148         ~CErrorLock();
00149 
00150     private:
00151         void            install(ErrorHandler, void*);
00152         static int      internalHandler(Display*, XErrorEvent*);
00153         static void     ignoreHandler(Display*, XErrorEvent*, void*);
00154         static void     saveHandler(Display*, XErrorEvent*, void*);
00155 
00156     private:
00157         typedef int (*XErrorHandler)(Display*, XErrorEvent*);
00158 
00159         Display*        m_display;
00160         ErrorHandler    m_handler;
00161         void*           m_userData;
00162         XErrorHandler   m_oldXHandler;
00163         CErrorLock*     m_next;
00164         static CErrorLock*  s_top;
00165     };
00166 
00167 private:
00168     class CPropertyNotifyPredicateInfo {
00169     public:
00170         Window          m_window;
00171         Atom            m_property;
00172     };
00173 
00174     static Bool         propertyNotifyPredicate(Display*,
00175                             XEvent* xevent, XPointer arg);
00176 
00177     static void         initKeyMaps();
00178 
00179 private:
00180     typedef std::map<KeySym, UInt32> CKeySymMap;
00181 
00182     static CKeySymMap   s_keySymToUCS4;
00183 };
00184 
00185 #endif

Generated on Fri Nov 6 00:18:46 2009 for synergy-plus by  doxygen 1.4.7