Blender  V2.59
GHOST_SystemX11.h
Go to the documentation of this file.
00001 /*
00002  * $Id: GHOST_SystemX11.h 38908 2011-08-02 04:28:05Z merwin $
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_SYSTEM_X11_H_
00035 #define _GHOST_SYSTEM_X11_H_
00036 
00037 #include <X11/Xlib.h>
00038 #include <GL/glx.h>
00039 
00040 #include "GHOST_System.h"
00041 #include "../GHOST_Types.h"
00042 
00043 class GHOST_WindowX11;
00044 
00052 class GHOST_SystemX11 : public GHOST_System {
00053 public:
00054 
00060         GHOST_SystemX11(
00061         );
00062         
00066         virtual ~GHOST_SystemX11();
00067 
00068 
00069                 GHOST_TSuccess 
00070         init(
00071         );
00072 
00073 
00083                 GHOST_TUns64 
00084         getMilliSeconds(
00085         ) const;
00086         
00087 
00092                 GHOST_TUns8 
00093         getNumDisplays(
00094         ) const;
00095 
00100                 void 
00101         getMainDisplayDimensions(
00102                 GHOST_TUns32& width,
00103                 GHOST_TUns32& height
00104         ) const;
00105 
00121                 GHOST_IWindow* 
00122         createWindow(
00123                 const STR_String& title,
00124                 GHOST_TInt32 left,
00125                 GHOST_TInt32 top,
00126                 GHOST_TUns32 width,
00127                 GHOST_TUns32 height,
00128                 GHOST_TWindowState state,
00129                 GHOST_TDrawingContextType type,
00130                 const bool stereoVisual,
00131                 const GHOST_TUns16 numOfAASamples = 0,
00132                 const GHOST_TEmbedderWindowID parentWindow = 0 
00133         );
00134 
00144                 bool 
00145         processEvents(
00146                 bool waitForEvent
00147         );
00148 
00152                 GHOST_TSuccess 
00153         getCursorPosition(
00154                 GHOST_TInt32& x,
00155                 GHOST_TInt32& y
00156         ) const;
00157         
00158                 GHOST_TSuccess 
00159         setCursorPosition(
00160                 GHOST_TInt32 x,
00161                 GHOST_TInt32 y
00162         );
00163 
00169                 GHOST_TSuccess 
00170         getModifierKeys(
00171                 GHOST_ModifierKeys& keys
00172         ) const ;
00173 
00179                 GHOST_TSuccess 
00180         getButtons(
00181                 GHOST_Buttons& buttons
00182         ) const;
00183 
00190                 void
00191         addDirtyWindow(
00192                 GHOST_WindowX11 * bad_wind
00193         );
00194   
00195  
00200                 Display *
00201         getXDisplay(
00202         ) {
00203                 return m_display;
00204         }       
00205 
00206         /* Helped function for get data from the clipboard. */
00207         void getClipboard_xcout(XEvent evt, Atom sel, Atom target,
00208                          unsigned char **txt, unsigned long *len,
00209                          unsigned int *context) const;
00210 
00216         GHOST_TUns8 *getClipboard(bool selection) const;
00217         
00223         void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
00224 
00228         int toggleConsole(int action) { return 0; }
00229 
00236         Atom m_wm_state;
00237         Atom m_wm_change_state;
00238         Atom m_net_state;
00239         Atom m_net_max_horz;
00240         Atom m_net_max_vert;
00241         Atom m_net_fullscreen;
00242         Atom m_motif;
00243         Atom m_wm_take_focus;
00244         Atom m_wm_protocols;
00245         Atom m_delete_window_atom;
00246 
00247         /* Atoms for Selection, copy & paste. */
00248         Atom m_targets;
00249         Atom m_string;
00250         Atom m_compound_text;
00251         Atom m_text;
00252         Atom m_clipboard;
00253         Atom m_primary;
00254         Atom m_xclip_out;
00255         Atom m_incr;
00256         Atom m_utf8_string;
00257 
00258 private :
00259 
00260         Display * m_display;
00261 
00263         std::vector<GHOST_WindowX11 *> m_dirty_windows;
00264 
00266         GHOST_TUns64 m_start_time;
00267 
00269         char m_keyboard_vector[32];
00270 
00271         /* to prevent multiple warp, we store the time of the last warp event
00272          *  and stop accumulating all events generated before that */
00273         Time m_last_warp;
00274 
00280                 GHOST_WindowX11 * 
00281         findGhostWindow(
00282                 Window xwind
00283         ) const ;
00284 
00285                 void
00286         processEvent(
00287                 XEvent *xe
00288         );
00289 
00290                 Time
00291         lastEventTime(
00292                 Time default_time
00293         );
00294 
00295                 bool
00296         generateWindowExposeEvents(
00297         );
00298 };
00299 
00300 #endif
00301