Back to index

libsfml  1.6+dfsg2
WindowImplX11.hpp
Go to the documentation of this file.
00001 
00002 //
00003 // SFML - Simple and Fast Multimedia Library
00004 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
00005 //
00006 // This software is provided 'as-is', without any express or implied warranty.
00007 // In no event will the authors be held liable for any damages arising from the use of this software.
00008 //
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it freely,
00011 // subject to the following restrictions:
00012 //
00013 // 1. The origin of this software must not be misrepresented;
00014 //    you must not claim that you wrote the original software.
00015 //    If you use this software in a product, an acknowledgment
00016 //    in the product documentation would be appreciated but is not required.
00017 //
00018 // 2. Altered source versions must be plainly marked as such,
00019 //    and must not be misrepresented as being the original software.
00020 //
00021 // 3. This notice may not be removed or altered from any source distribution.
00022 //
00024 
00025 #ifndef SFML_WINDOWIMPLX11_HPP
00026 #define SFML_WINDOWIMPLX11_HPP
00027 
00029 // Headers
00031 #include <SFML/Window/Event.hpp>
00032 #include <SFML/Window/WindowImpl.hpp>
00033 #include <X11/Xlib.h>
00034 #include <GL/glx.h>
00035 #include <set>
00036 #include <string>
00037 
00038 
00039 namespace sf
00040 {
00041 namespace priv
00042 {
00043 class VideoModeSupport;
00044 
00048 class WindowImplX11 : public WindowImpl
00049 {
00050 public :
00051 
00057     WindowImplX11();
00058 
00066     WindowImplX11(WindowHandle Handle, WindowSettings& Params);
00067 
00077     WindowImplX11(VideoMode Mode, const std::string& Title, unsigned long WindowStyle, WindowSettings& Params);
00078 
00083     ~WindowImplX11();
00084 
00091     static bool IsContextActive();
00092 
00093 private :
00094 
00095     friend class VideoModeSupport;
00096 
00101     virtual void Display();
00102 
00107     virtual void ProcessEvents();
00108 
00113     virtual void SetActive(bool Active = true) const;
00114 
00119     virtual void UseVerticalSync(bool Enabled);
00120 
00125     virtual void ShowMouseCursor(bool Show);
00126 
00131     virtual void SetCursorPosition(unsigned int Left, unsigned int Top);
00132 
00137     virtual void SetPosition(int Left, int Top);
00138 
00143     virtual void SetSize(unsigned int Width, unsigned int Height);
00144 
00149     virtual void Show(bool State);
00150 
00155     virtual void EnableKeyRepeat(bool Enabled);
00156 
00161     virtual void SetIcon(unsigned int Width, unsigned int Height, const Uint8* Pixels);
00162 
00169     void SwitchToFullscreen(const VideoMode& Mode);
00170 
00183     bool CreateContext(const VideoMode& Mode, XVisualInfo& ChosenVisual, WindowSettings& Params, XVisualInfo Template = XVisualInfo(), unsigned long Mask = 0);
00184 
00189     void Initialize();
00190 
00195     void CreateHiddenCursor();
00196 
00201     void CleanUp();
00202 
00209     void ProcessEvent(XEvent WinEvent);
00210 
00219     static Key::Code KeysymToSF(KeySym Sym);
00220 
00229     static bool OpenDisplay(bool AddWindow = true);
00230 
00235     static void CloseDisplay();
00236 
00238     // Static member data
00240     static ::Display*     ourDisplay;          
00241     static int            ourScreen;           
00242     static WindowImplX11* ourFullscreenWindow; 
00243     static unsigned int   ourWindowsCount;     
00244     static unsigned long  ourEventMask;        
00245     static XIM            ourInputMethod;      
00246 
00248     // Member data
00250     ::Window   myWindow;              
00251     bool       myIsExternal;          
00252     GLXContext myGLContext;           
00253     Atom       myAtomClose;           
00254     int        myOldVideoMode;        
00255     Cursor     myHiddenCursor;        
00256     XIC        myInputContext;        
00257     bool       myKeyRepeat;           
00258     XEvent     myLastKeyReleaseEvent; 
00259 };
00260 
00261 } // namespace priv
00262 
00263 } // namespace sf
00264 
00265 
00266 #endif // SFML_WINDOWIMPLX11_HPP