Blender  V2.59
GHOST_WindowX11.h
Go to the documentation of this file.
00001 /*
00002  * $Id: GHOST_WindowX11.h 36985 2011-05-28 15:34:02Z campbellbarton $
00003  * ***** BEGIN GPL LICENSE BLOCK *****
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software Foundation,
00017  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00018  *
00019  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00020  * All rights reserved.
00021  *
00022  * The Original Code is: all of this file.
00023  *
00024  * Contributor(s): none yet.
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00034 #ifndef _GHOST_WINDOWX11_H_
00035 #define _GHOST_WINDOWX11_H_
00036 
00037 #include "GHOST_Window.h"
00038 #include <X11/Xlib.h>
00039 #include <GL/glx.h>
00040 // For tablets
00041 #ifdef WITH_X11_XINPUT
00042 #  include <X11/extensions/XInput.h>
00043 #endif
00044 
00045 #include <map>
00046 
00047 class STR_String;
00048 class GHOST_SystemX11;
00049 
00057 class GHOST_WindowX11 : public GHOST_Window
00058 {
00059 public:
00075         GHOST_WindowX11(
00076                 GHOST_SystemX11 *system,
00077                 Display * display,
00078                 const STR_String& title, 
00079                 GHOST_TInt32 left,
00080                 GHOST_TInt32 top,
00081                 GHOST_TUns32 width,     
00082                 GHOST_TUns32 height,
00083                 GHOST_TWindowState state,
00084                 const GHOST_TEmbedderWindowID parentWindow,
00085                 GHOST_TDrawingContextType type = GHOST_kDrawingContextTypeNone,
00086                 const bool stereoVisual = false,
00087                 const GHOST_TUns16 numOfAASamples = 0
00088         );
00089 
00090                 bool 
00091         getValid(
00092         ) const;
00093 
00094                 void 
00095         setTitle(const STR_String& title);
00096 
00097                 void 
00098         getTitle(
00099                 STR_String& title
00100         ) const;
00101 
00102                 void 
00103         getWindowBounds(
00104                 GHOST_Rect& bounds
00105         ) const;
00106         
00107                 void 
00108         getClientBounds(
00109                 GHOST_Rect& bounds
00110         ) const;
00111 
00112                 GHOST_TSuccess 
00113         setClientWidth(
00114                 GHOST_TUns32 width
00115         );
00116 
00117                 GHOST_TSuccess 
00118         setClientHeight(
00119                 GHOST_TUns32 height
00120         );
00121 
00122                 GHOST_TSuccess 
00123         setClientSize(
00124                 GHOST_TUns32 width,
00125                 GHOST_TUns32 height
00126         );
00127 
00128                 void 
00129         screenToClient(
00130                 GHOST_TInt32 inX,
00131                 GHOST_TInt32 inY,
00132                 GHOST_TInt32& outX,
00133                 GHOST_TInt32& outY
00134         ) const;
00135 
00136                 void 
00137         clientToScreen(
00138                 GHOST_TInt32 inX,
00139                 GHOST_TInt32 inY,
00140                 GHOST_TInt32& outX,
00141                 GHOST_TInt32& outY
00142         ) const;
00143         
00144                 GHOST_TWindowState 
00145         getState(
00146         ) const ;
00147 
00148                 GHOST_TSuccess 
00149         setState(
00150                 GHOST_TWindowState state
00151         );
00152         
00153                 GHOST_TSuccess 
00154         setOrder(
00155                 GHOST_TWindowOrder order
00156         );
00157         
00158                 GHOST_TSuccess 
00159         swapBuffers(
00160         );
00161         
00162                 GHOST_TSuccess 
00163         activateDrawingContext(
00164         );
00165                 GHOST_TSuccess 
00166         invalidate(
00167         );
00168 
00173          ~GHOST_WindowX11();
00174 
00185                 void
00186         validate(
00187         );      
00188 
00192                 Window 
00193         getXWindow(
00194         );      
00195 #ifdef WITH_X11_XINPUT
00196         class XTablet
00197         {
00198         public:
00199                 GHOST_TabletData CommonData;
00200 
00201                 XDevice* StylusDevice;
00202                 XDevice* EraserDevice;
00203 
00204                 XID StylusID, EraserID;
00205 
00206                 int MotionEvent;
00207                 int ProxInEvent;
00208                 int ProxOutEvent;
00209 
00210                 int PressureLevels;
00211                 int XtiltLevels, YtiltLevels;
00212         };
00213 
00214         XTablet& GetXTablet()
00215         { return m_xtablet; }
00216 
00217         const GHOST_TabletData* GetTabletData()
00218         { return &m_xtablet.CommonData; }
00219 #else // WITH_X11_XINPUT
00220         const GHOST_TabletData* GetTabletData()
00221         { return NULL; }
00222 #endif // WITH_X11_XINPUT
00223 
00224         /*
00225          * Need this in case that we want start the window
00226          * in FullScree or Maximized state.
00227          * Check GHOST_WindowX11.cpp
00228          */
00229         bool m_post_init;
00230         GHOST_TWindowState m_post_state;
00231 
00232 protected:
00238                 GHOST_TSuccess 
00239         installDrawingContext(
00240                 GHOST_TDrawingContextType type
00241         );
00242 
00247                 GHOST_TSuccess 
00248         removeDrawingContext(
00249         );
00250 
00255                 GHOST_TSuccess 
00256         setWindowCursorVisibility(
00257                 bool visible
00258         );
00259         
00265                 GHOST_TSuccess 
00266         setWindowCursorGrab(
00267                 GHOST_TGrabCursorMode mode
00268         );
00269 
00270                 GHOST_TGrabCursorMode
00271         getWindowCursorGrab() const;
00272 
00277                 GHOST_TSuccess 
00278         setWindowCursorShape(
00279                 GHOST_TStandardCursor shape
00280         );
00281 
00286                 GHOST_TSuccess
00287         setWindowCustomCursorShape(
00288                 GHOST_TUns8 bitmap[16][2], 
00289                 GHOST_TUns8 mask[16][2], 
00290                 int hotX, 
00291                 int hotY
00292         );
00293         
00298                 GHOST_TSuccess
00299         setWindowCustomCursorShape(
00300                 GHOST_TUns8 *bitmap, 
00301                 GHOST_TUns8 *mask, 
00302                 int sizex, 
00303                 int sizey,
00304                 int hotX, 
00305                 int hotY,
00306                 int fg_color, 
00307                 int bg_color
00308         );
00309 
00310 private :
00311 
00313         
00314         GHOST_WindowX11(
00315         );
00316 
00317         GHOST_WindowX11(
00318                 const GHOST_WindowX11 &
00319         );
00320 
00321                 Cursor
00322         getStandardCursor(
00323                 GHOST_TStandardCursor g_cursor
00324         );
00325         
00326                 Cursor 
00327         getEmptyCursor(
00328         );
00329 
00330 #ifdef WITH_X11_XINPUT
00331         void initXInputDevices();
00332 #endif
00333         
00334         GLXContext      m_context;
00335         Window  m_window;
00336         Display         *m_display;
00337         XVisualInfo     *m_visual;
00338         GHOST_TWindowState m_normal_state;
00339 
00341         static GLXContext s_firstContext;
00342 
00344         
00345         GHOST_SystemX11 * m_system;
00346 
00347         bool m_valid_setup;
00348 
00350         bool m_invalid_window;
00351 
00353         Cursor m_empty_cursor;
00354         
00356         Cursor m_custom_cursor;
00357         
00359         std::map<unsigned int, Cursor> m_standard_cursors;
00360 
00361 #ifdef WITH_X11_XINPUT
00362         /* Tablet devices */
00363         XTablet m_xtablet;
00364 #endif
00365 
00366         void icccmSetState(int state);
00367         int icccmGetState() const;
00368 
00369         void netwmMaximized(bool set);
00370         bool netwmIsMaximized() const;
00371 
00372         void netwmFullScreen(bool set);
00373         bool netwmIsFullScreen() const;
00374 
00375         void motifFullScreen(bool set);
00376         bool motifIsFullScreen() const;
00377 };
00378 
00379 
00380 #endif // _GHOST_WINDOWX11_H_