Platform/Window: Make PushEvent public
This commit is contained in:
@@ -164,6 +164,8 @@ Nazara Engine:
|
|||||||
- Fixed MouseButtonEvent and MouseMoveEvent mouse absolute position being unsigned (now signed)
|
- Fixed MouseButtonEvent and MouseMoveEvent mouse absolute position being unsigned (now signed)
|
||||||
- Fixed Window::SetCursor changing cursor even if window was in foreground on Windows
|
- Fixed Window::SetCursor changing cursor even if window was in foreground on Windows
|
||||||
- Fixed SystemCursor_Move not showing up on Windows
|
- Fixed SystemCursor_Move not showing up on Windows
|
||||||
|
- Fixed Window movement constructor/assignation operator
|
||||||
|
- Window::PushEvent is now public (useful for pushing external events ie. when using Qt or similar framework controlling window)
|
||||||
|
|
||||||
Nazara Development Kit:
|
Nazara Development Kit:
|
||||||
- Added ImageWidget (#139)
|
- Added ImageWidget (#139)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace Nz
|
|||||||
inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
|
inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
|
||||||
inline explicit Window(WindowHandle handle);
|
inline explicit Window(WindowHandle handle);
|
||||||
Window(const Window&) = delete;
|
Window(const Window&) = delete;
|
||||||
Window(Window&&) = default;
|
Window(Window&& window);
|
||||||
virtual ~Window();
|
virtual ~Window();
|
||||||
|
|
||||||
inline void Close();
|
inline void Close();
|
||||||
@@ -78,6 +78,8 @@ namespace Nz
|
|||||||
NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system")
|
NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system")
|
||||||
bool PollEvent(WindowEvent* event);
|
bool PollEvent(WindowEvent* event);
|
||||||
|
|
||||||
|
void PushEvent(const WindowEvent& event);
|
||||||
|
|
||||||
void ProcessEvents(bool block = false);
|
void ProcessEvents(bool block = false);
|
||||||
|
|
||||||
void SetCursor(CursorRef cursor);
|
void SetCursor(CursorRef cursor);
|
||||||
@@ -101,7 +103,7 @@ namespace Nz
|
|||||||
bool WaitEvent(WindowEvent* event);
|
bool WaitEvent(WindowEvent* event);
|
||||||
|
|
||||||
Window& operator=(const Window&) = delete;
|
Window& operator=(const Window&) = delete;
|
||||||
Window& operator=(Window&&) = default;
|
Window& operator=(Window&& window);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool OnWindowCreated();
|
virtual bool OnWindowCreated();
|
||||||
@@ -111,13 +113,17 @@ namespace Nz
|
|||||||
MovablePtr<WindowImpl> m_impl;
|
MovablePtr<WindowImpl> m_impl;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void ConnectSlots();
|
||||||
|
void DisconnectSlots();
|
||||||
|
|
||||||
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;
|
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;
|
||||||
inline void HandleEvent(const WindowEvent& event);
|
void HandleEvent(const WindowEvent& event);
|
||||||
inline void PushEvent(const WindowEvent& event);
|
|
||||||
|
|
||||||
static bool Initialize();
|
static bool Initialize();
|
||||||
static void Uninitialize();
|
static void Uninitialize();
|
||||||
|
|
||||||
|
NazaraSlot(CursorController, OnCursorUpdated, m_cursorUpdateSlot);
|
||||||
|
|
||||||
std::queue<WindowEvent> m_events;
|
std::queue<WindowEvent> m_events;
|
||||||
std::vector<WindowEvent> m_pendingEvents;
|
std::vector<WindowEvent> m_pendingEvents;
|
||||||
ConditionVariable m_eventCondition;
|
ConditionVariable m_eventCondition;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// This file is part of the "Nazara Engine - Platform module"
|
// This file is part of the "Nazara Engine - Platform module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
|
#include <Nazara/Platform/Window.hpp>
|
||||||
#include <Nazara/Core/ErrorFlags.hpp>
|
#include <Nazara/Core/ErrorFlags.hpp>
|
||||||
#include <Nazara/Core/LockGuard.hpp>
|
#include <Nazara/Core/LockGuard.hpp>
|
||||||
#include <Nazara/Platform/Debug.hpp>
|
#include <Nazara/Platform/Debug.hpp>
|
||||||
@@ -90,20 +91,6 @@ namespace Nz
|
|||||||
SetCursor(Cursor::Get(systemCursor));
|
SetCursor(Cursor::Get(systemCursor));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Window::HandleEvent(const WindowEvent& event)
|
|
||||||
{
|
|
||||||
if (m_eventPolling)
|
|
||||||
m_events.push(event);
|
|
||||||
|
|
||||||
m_eventHandler.Dispatch(event);
|
|
||||||
|
|
||||||
if (event.type == WindowEventType_Resized)
|
|
||||||
OnWindowResized();
|
|
||||||
|
|
||||||
if (event.type == WindowEventType_Quit && m_closeOnQuit)
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Window::PushEvent(const WindowEvent& event)
|
inline void Window::PushEvent(const WindowEvent& event)
|
||||||
{
|
{
|
||||||
if (!m_asyncWindow)
|
if (!m_asyncWindow)
|
||||||
|
|||||||
@@ -269,6 +269,11 @@ namespace Nz
|
|||||||
return IsWindowVisible(m_handle) == TRUE;
|
return IsWindowVisible(m_handle) == TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowImpl::RefreshCursor()
|
||||||
|
{
|
||||||
|
::SetCursor(m_cursor);
|
||||||
|
}
|
||||||
|
|
||||||
void WindowImpl::ProcessEvents(bool block)
|
void WindowImpl::ProcessEvents(bool block)
|
||||||
{
|
{
|
||||||
if (m_ownsWindow)
|
if (m_ownsWindow)
|
||||||
@@ -289,9 +294,8 @@ namespace Nz
|
|||||||
{
|
{
|
||||||
m_cursor = cursor.m_impl->GetCursor();
|
m_cursor = cursor.m_impl->GetCursor();
|
||||||
|
|
||||||
// Applies cursor only if we have focus
|
if (HasFocus())
|
||||||
if (GetForegroundWindow() == m_handle)
|
RefreshCursor();
|
||||||
::SetCursor(m_cursor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowImpl::SetEventListener(bool listener)
|
void WindowImpl::SetEventListener(bool listener)
|
||||||
@@ -405,12 +409,12 @@ namespace Nz
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SETCURSOR:
|
/*case WM_SETCURSOR:
|
||||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms648382(v=vs.85).aspx
|
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms648382(v=vs.85).aspx
|
||||||
if (LOWORD(lParam) == HTCLIENT)
|
if (LOWORD(lParam) == HTCLIENT)
|
||||||
::SetCursor(m_cursor);
|
::SetCursor(m_cursor);
|
||||||
|
|
||||||
break;
|
break;*/
|
||||||
|
|
||||||
case WM_WINDOWPOSCHANGING:
|
case WM_WINDOWPOSCHANGING:
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ namespace Nz
|
|||||||
bool IsMinimized() const;
|
bool IsMinimized() const;
|
||||||
bool IsVisible() const;
|
bool IsVisible() const;
|
||||||
|
|
||||||
|
void RefreshCursor();
|
||||||
|
|
||||||
void ProcessEvents(bool block);
|
void ProcessEvents(bool block);
|
||||||
|
|
||||||
void SetCursor(const Cursor& cursor);
|
void SetCursor(const Cursor& cursor);
|
||||||
|
|||||||
@@ -33,11 +33,28 @@ namespace Nz
|
|||||||
m_eventPolling(false),
|
m_eventPolling(false),
|
||||||
m_waitForEvent(false)
|
m_waitForEvent(false)
|
||||||
{
|
{
|
||||||
m_cursorController.OnCursorUpdated.Connect([this](const CursorController*, const CursorRef& cursor)
|
ConnectSlots();
|
||||||
{
|
}
|
||||||
if (IsValid())
|
|
||||||
SetCursor(cursor);
|
Window::Window(Window&& window) :
|
||||||
});
|
m_events(std::move(window.m_events)),
|
||||||
|
m_pendingEvents(std::move(window.m_pendingEvents)),
|
||||||
|
m_eventCondition(std::move(window.m_eventCondition)),
|
||||||
|
m_cursorController(std::move(window.m_cursorController)),
|
||||||
|
m_cursor(std::move(window.m_cursor)),
|
||||||
|
m_eventHandler(std::move(window.m_eventHandler)),
|
||||||
|
m_icon(std::move(window.m_icon)),
|
||||||
|
m_eventMutex(std::move(window.m_eventMutex)),
|
||||||
|
m_eventConditionMutex(std::move(window.m_eventConditionMutex)),
|
||||||
|
m_asyncWindow(window.m_asyncWindow),
|
||||||
|
m_closed(window.m_asyncWindow),
|
||||||
|
m_closeOnQuit(window.m_closeOnQuit),
|
||||||
|
m_eventPolling(window.m_eventPolling),
|
||||||
|
m_ownsWindow(window.m_asyncWindow),
|
||||||
|
m_waitForEvent(window.m_waitForEvent)
|
||||||
|
{
|
||||||
|
window.DisconnectSlots();
|
||||||
|
ConnectSlots();
|
||||||
}
|
}
|
||||||
|
|
||||||
Window::~Window()
|
Window::~Window()
|
||||||
@@ -582,6 +599,30 @@ namespace Nz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Window& Window::operator=(Window&& window)
|
||||||
|
{
|
||||||
|
m_events = std::move(window.m_events);
|
||||||
|
m_pendingEvents = std::move(window.m_pendingEvents);
|
||||||
|
m_eventCondition = std::move(window.m_eventCondition);
|
||||||
|
m_cursorController = std::move(window.m_cursorController);
|
||||||
|
m_cursor = std::move(window.m_cursor);
|
||||||
|
m_eventHandler = std::move(window.m_eventHandler);
|
||||||
|
m_icon = std::move(window.m_icon);
|
||||||
|
m_eventMutex = std::move(window.m_eventMutex);
|
||||||
|
m_eventConditionMutex = std::move(window.m_eventConditionMutex);
|
||||||
|
m_asyncWindow = window.m_asyncWindow;
|
||||||
|
m_closed = window.m_asyncWindow;
|
||||||
|
m_closeOnQuit = window.m_closeOnQuit;
|
||||||
|
m_eventPolling = window.m_eventPolling;
|
||||||
|
m_ownsWindow = window.m_asyncWindow;
|
||||||
|
m_waitForEvent = window.m_waitForEvent;
|
||||||
|
|
||||||
|
window.DisconnectSlots();
|
||||||
|
ConnectSlots();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
bool Window::OnWindowCreated()
|
bool Window::OnWindowCreated()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -595,6 +636,20 @@ namespace Nz
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::ConnectSlots()
|
||||||
|
{
|
||||||
|
m_cursorUpdateSlot.Connect(m_cursorController.OnCursorUpdated, [this](const CursorController*, const CursorRef& cursor)
|
||||||
|
{
|
||||||
|
if (IsValid())
|
||||||
|
SetCursor(cursor);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::DisconnectSlots()
|
||||||
|
{
|
||||||
|
m_cursorUpdateSlot.Disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
void Window::IgnoreNextMouseEvent(int mouseX, int mouseY) const
|
void Window::IgnoreNextMouseEvent(int mouseX, int mouseY) const
|
||||||
{
|
{
|
||||||
#if NAZARA_PLATFORM_SAFE
|
#if NAZARA_PLATFORM_SAFE
|
||||||
@@ -608,6 +663,34 @@ namespace Nz
|
|||||||
m_impl->IgnoreNextMouseEvent(mouseX, mouseY);
|
m_impl->IgnoreNextMouseEvent(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::HandleEvent(const WindowEvent& event)
|
||||||
|
{
|
||||||
|
if (m_eventPolling)
|
||||||
|
m_events.push(event);
|
||||||
|
|
||||||
|
m_eventHandler.Dispatch(event);
|
||||||
|
|
||||||
|
switch (event.type)
|
||||||
|
{
|
||||||
|
case WindowEventType_MouseEntered:
|
||||||
|
m_impl->RefreshCursor();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WindowEventType_Resized:
|
||||||
|
OnWindowResized();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WindowEventType_Quit:
|
||||||
|
if (m_closeOnQuit)
|
||||||
|
Close();
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Window::Initialize()
|
bool Window::Initialize()
|
||||||
{
|
{
|
||||||
return WindowImpl::Initialize();
|
return WindowImpl::Initialize();
|
||||||
|
|||||||
@@ -412,6 +412,10 @@ namespace Nz
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowImpl::RefreshCursor()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void WindowImpl::SetCursor(const Cursor& cursor)
|
void WindowImpl::SetCursor(const Cursor& cursor)
|
||||||
{
|
{
|
||||||
xcb_cursor_t cursorImpl = cursor.m_impl->GetCursor();
|
xcb_cursor_t cursorImpl = cursor.m_impl->GetCursor();
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ namespace Nz
|
|||||||
bool IsMinimized() const;
|
bool IsMinimized() const;
|
||||||
bool IsVisible() const;
|
bool IsVisible() const;
|
||||||
|
|
||||||
|
void RefreshCursor();
|
||||||
|
|
||||||
void ProcessEvents(bool block);
|
void ProcessEvents(bool block);
|
||||||
|
|
||||||
void SetCursor(const Cursor& cursor);
|
void SetCursor(const Cursor& cursor);
|
||||||
|
|||||||
Reference in New Issue
Block a user