Fix WindowHandles
This commit is contained in:
@@ -32,13 +32,14 @@ namespace Nz
|
||||
class NAZARA_PLATFORM_API Window
|
||||
{
|
||||
friend WindowImpl;
|
||||
friend class EventImpl;
|
||||
friend class Mouse;
|
||||
friend class Platform;
|
||||
|
||||
public:
|
||||
Window();
|
||||
inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
|
||||
inline explicit Window(WindowHandle handle);
|
||||
inline explicit Window(void* handle);
|
||||
Window(const Window&) = delete;
|
||||
Window(Window&& window);
|
||||
virtual ~Window();
|
||||
@@ -46,7 +47,7 @@ namespace Nz
|
||||
inline void Close();
|
||||
|
||||
bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
|
||||
bool Create(WindowHandle handle);
|
||||
bool Create(void* handle);
|
||||
|
||||
void Destroy();
|
||||
|
||||
@@ -61,10 +62,10 @@ namespace Nz
|
||||
inline const CursorRef& GetCursor() const;
|
||||
inline CursorController& GetCursorController();
|
||||
inline EventHandler& GetEventHandler();
|
||||
WindowHandle GetHandle() const;
|
||||
Vector2i GetPosition() const;
|
||||
Vector2ui GetSize() const;
|
||||
WindowStyleFlags GetStyle() const;
|
||||
WindowHandle GetSystemHandle() const;
|
||||
String GetTitle() const;
|
||||
|
||||
bool HasFocus() const;
|
||||
@@ -106,6 +107,8 @@ namespace Nz
|
||||
Window& operator=(Window&& window);
|
||||
|
||||
protected:
|
||||
void* GetHandle();
|
||||
|
||||
virtual bool OnWindowCreated();
|
||||
virtual void OnWindowDestroy();
|
||||
virtual void OnWindowResized();
|
||||
@@ -116,6 +119,9 @@ namespace Nz
|
||||
void ConnectSlots();
|
||||
void DisconnectSlots();
|
||||
|
||||
inline WindowImpl* GetImpl();
|
||||
inline const WindowImpl* GetImpl() const;
|
||||
|
||||
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;
|
||||
void HandleEvent(const WindowEvent& event);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Nz
|
||||
Create(mode, title, style);
|
||||
}
|
||||
|
||||
inline Window::Window(WindowHandle handle) :
|
||||
inline Window::Window(void* handle) :
|
||||
Window()
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
@@ -111,6 +111,16 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline WindowImpl* Window::GetImpl()
|
||||
{
|
||||
return m_impl;
|
||||
}
|
||||
|
||||
inline const WindowImpl* Window::GetImpl() const
|
||||
{
|
||||
return m_impl;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Platform/DebugOff.hpp>
|
||||
|
||||
@@ -8,11 +8,44 @@
|
||||
#define NAZARA_WINDOWHANDLE_HPP
|
||||
|
||||
#include <Nazara/Prerequisites.hpp>
|
||||
#include <Nazara/Utility/Config.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
// Real type is SDL_Window
|
||||
using WindowHandle = void*;
|
||||
enum class WindowManager
|
||||
{
|
||||
None,
|
||||
|
||||
X11,
|
||||
Wayland,
|
||||
Windows
|
||||
};
|
||||
|
||||
struct WindowHandle
|
||||
{
|
||||
WindowManager type = WindowManager::None;
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
void* display; //< Display*
|
||||
void* window; //< Window
|
||||
} x11;
|
||||
|
||||
struct
|
||||
{
|
||||
void* display; //< wl_display*
|
||||
void* surface; //< wl_surface*
|
||||
void* shellSurface; //< wl_shell_surface*
|
||||
} wayland;
|
||||
|
||||
struct
|
||||
{
|
||||
void* window; //< HWND
|
||||
} windows;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif // NAZARA_WINDOWHANDLE_HPP
|
||||
|
||||
@@ -122,14 +122,12 @@
|
||||
#define NAZARA_EXPORT __attribute__((visibility ("default")))
|
||||
#define NAZARA_IMPORT __attribute__((visibility ("default")))
|
||||
/*#elif defined(__APPLE__) && defined(__MACH__)
|
||||
#define NAZARA_CORE_API
|
||||
#define NAZARA_PLATFORM_MACOSX
|
||||
#define NAZARA_PLATFORM_POSIX*/
|
||||
#else
|
||||
#error This operating system is not fully supported by the Nazara Engine
|
||||
|
||||
#define NAZARA_PLATFORM_UNKNOWN
|
||||
#define NAZARA_CORE_API
|
||||
#endif
|
||||
|
||||
// Detect 64 bits
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Nz
|
||||
minorVersion(defaultMinorVersion),
|
||||
stencilBits(parameters.stencilBits),
|
||||
shareContext(defaultShareContext),
|
||||
window(0),
|
||||
window(nullptr),
|
||||
compatibilityProfile(defaultCompatibilityProfile),
|
||||
debugMode(defaultDebugMode),
|
||||
doubleBuffered(defaultDoubleBuffered),
|
||||
@@ -41,7 +41,7 @@ namespace Nz
|
||||
UInt8 minorVersion;
|
||||
UInt8 stencilBits;
|
||||
const Context* shareContext;
|
||||
WindowHandle window;
|
||||
void* window;
|
||||
bool compatibilityProfile;
|
||||
bool debugMode;
|
||||
bool doubleBuffered;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Nz
|
||||
public:
|
||||
RenderWindow() = default;
|
||||
RenderWindow(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters());
|
||||
explicit RenderWindow(WindowHandle handle, const ContextParameters& parameters = ContextParameters());
|
||||
explicit RenderWindow(void* handle, const ContextParameters& parameters = ContextParameters());
|
||||
RenderWindow(const RenderWindow&) = delete;
|
||||
RenderWindow(RenderWindow&&) = delete; ///TODO
|
||||
virtual ~RenderWindow();
|
||||
@@ -38,7 +38,7 @@ namespace Nz
|
||||
bool CopyToImage(AbstractImage* image, const Rectui& rect, const Vector3ui& dstPos = Vector3ui(0U)) const;
|
||||
|
||||
bool Create(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default, const ContextParameters& parameters = ContextParameters());
|
||||
bool Create(WindowHandle handle, const ContextParameters& parameters = ContextParameters());
|
||||
bool Create(void* handle, const ContextParameters& parameters = ContextParameters());
|
||||
|
||||
void Display();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user