00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __RE_XServer__
00020 #define __RE_XServer__
00021
00022 #include "RE_API.h"
00023 #include <stddef.h>
00024 #include <X11/Xlib.h>
00025 #include <UT/UT_Lock.h>
00026 #include <UT/UT_RefArray.h>
00027 #include "RE_Server.h"
00028
00029 enum RE_XWinManager
00030 {
00031 RE_XWM_UNINIT,
00032 RE_XWM_UNKNOWN,
00033
00034 RE_XWM_KDE,
00035 RE_XWM_METACITY,
00036 RE_XWM_SAWFISH
00037 };
00038
00039 struct RE_TabletDevice;
00040
00041 class RE_API RE_XServer : public RE_Server
00042 {
00043 public:
00044 RE_XServer();
00045 virtual ~RE_XServer();
00046
00047 virtual char initServer(char *hostSystem = 0);
00048 virtual void flush() const;
00049
00050 virtual void lock(const char *msg=0);
00051 virtual void unlock(const char *msg=0);
00052
00053 virtual Display *getDisplay() const { return myDisplay; }
00054
00055 unsigned char *getProperty( OGLWindow wid, Atom property,
00056 Atom target, unsigned long *size );
00057
00058 void setProperty( OGLWindow wid, Atom property,
00059 Atom target, int unitsize,
00060 unsigned long size,
00061 char *data);
00062
00063 void freeServerData(void *data);
00064
00065 int getDefaultScreen() const
00066 { return myDefaultScreen; }
00067 OGLWindow getRoot(int screen) const
00068 { return RootWindow(myDisplay, screen); }
00069 OGLWindow getRoot() const
00070 { return RootWindow(myDisplay, myDefaultScreen); }
00071
00072 virtual short getWidth() const;
00073 virtual short getHeight() const;
00074 virtual short getWidthMM() const;
00075 virtual short getHeightMM() const;
00076
00077 virtual UT_DimRect getWorkArea();
00078
00079 unsigned short getWhitePixel() const
00080 { return (unsigned short)WhitePixel(myDisplay, myDefaultScreen); }
00081 unsigned short getBlackPixel() const
00082 { return (unsigned short)BlackPixel(myDisplay, myDefaultScreen); }
00083
00084 void redirectEvents(const OGLWindow from,
00085 const OGLWindow to );
00086 void stopRedirectingEvents(const OGLWindow from,
00087 const OGLWindow to);
00088 void redirectEventWindow( XEvent &event );
00089 void mapWindowNotify( const OGLWindow from, int state );
00090
00091 void findLocation(OGLWindow wid,
00092 short *x, short *y, short *w, short *h,
00093 short *_leftBorder = NULL,
00094 short *_rightBorder = NULL,
00095 short *_bottomBorder = NULL,
00096 short *_topBorder = NULL,
00097 char topMostParent = 0);
00098
00099 virtual bool GLMakeCurrent( OGLDrawable draw,
00100 RE_OGLContext context );
00101
00102 virtual int GLMakeCopyCurrent( OGLDrawable draw,
00103 RE_OGLContext sourceContext,
00104 RE_OGLContext targetContext );
00105 virtual void GLSwapBuffers(RE_Window *currentWindow);
00106 virtual OGLDrawable GLGetCurrentDrawable();
00107 virtual void GLWaitGL();
00108
00109 virtual bool windowUnderCursor(RE_IDType, int x, int y);
00110
00111 virtual bool getColorUnderCursor(float color[3]);
00112
00113 void selectTabletInputEvents(Window wid);
00114 void handleTabletInputEvent(XEvent *event);
00115
00116 RE_XWinManager getWindowManager();
00117 private:
00118 Display *myDisplay;
00119 UT_Lock myLock;
00120 UT_DimRect myWorkArea;
00121 int myDefaultScreen;
00122 UT_RefArray<OGLWindow> myRedirectFroms;
00123 UT_RefArray<RE_TabletDevice> myTabletDevices;
00124 OGLWindow myRedirectTo;
00125 int myToHasFocus;
00126 short myXTo, myYTo, myWidthTo, myHeightTo;
00127 short myLBTo, myRBTo, myBBTo, myTBTo;
00128 char myRedirectEnable;
00129 RE_XWinManager myWindowManager;
00130 };
00131
00132 #endif