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 Window::SetCursor changing cursor even if window was in foreground 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:
|
||||
- Added ImageWidget (#139)
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Nz
|
||||
inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default);
|
||||
inline explicit Window(WindowHandle handle);
|
||||
Window(const Window&) = delete;
|
||||
Window(Window&&) = default;
|
||||
Window(Window&& window);
|
||||
virtual ~Window();
|
||||
|
||||
inline void Close();
|
||||
@@ -78,6 +78,8 @@ namespace Nz
|
||||
NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system")
|
||||
bool PollEvent(WindowEvent* event);
|
||||
|
||||
void PushEvent(const WindowEvent& event);
|
||||
|
||||
void ProcessEvents(bool block = false);
|
||||
|
||||
void SetCursor(CursorRef cursor);
|
||||
@@ -101,7 +103,7 @@ namespace Nz
|
||||
bool WaitEvent(WindowEvent* event);
|
||||
|
||||
Window& operator=(const Window&) = delete;
|
||||
Window& operator=(Window&&) = default;
|
||||
Window& operator=(Window&& window);
|
||||
|
||||
protected:
|
||||
virtual bool OnWindowCreated();
|
||||
@@ -111,13 +113,17 @@ namespace Nz
|
||||
MovablePtr<WindowImpl> m_impl;
|
||||
|
||||
private:
|
||||
void ConnectSlots();
|
||||
void DisconnectSlots();
|
||||
|
||||
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;
|
||||
inline void HandleEvent(const WindowEvent& event);
|
||||
inline void PushEvent(const WindowEvent& event);
|
||||
void HandleEvent(const WindowEvent& event);
|
||||
|
||||
static bool Initialize();
|
||||
static void Uninitialize();
|
||||
|
||||
NazaraSlot(CursorController, OnCursorUpdated, m_cursorUpdateSlot);
|
||||
|
||||
std::queue<WindowEvent> m_events;
|
||||
std::vector<WindowEvent> m_pendingEvents;
|
||||
ConditionVariable m_eventCondition;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// This file is part of the "Nazara Engine - Platform module"
|
||||
// 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/LockGuard.hpp>
|
||||
#include <Nazara/Platform/Debug.hpp>
|
||||
@@ -90,20 +91,6 @@ namespace Nz
|
||||
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)
|
||||
{
|
||||
if (!m_asyncWindow)
|
||||
|
||||
@@ -269,6 +269,11 @@ namespace Nz
|
||||
return IsWindowVisible(m_handle) == TRUE;
|
||||
}
|
||||
|
||||
void WindowImpl::RefreshCursor()
|
||||
{
|
||||
::SetCursor(m_cursor);
|
||||
}
|
||||
|
||||
void WindowImpl::ProcessEvents(bool block)
|
||||
{
|
||||
if (m_ownsWindow)
|
||||
@@ -289,9 +294,8 @@ namespace Nz
|
||||
{
|
||||
m_cursor = cursor.m_impl->GetCursor();
|
||||
|
||||
// Applies cursor only if we have focus
|
||||
if (GetForegroundWindow() == m_handle)
|
||||
::SetCursor(m_cursor);
|
||||
if (HasFocus())
|
||||
RefreshCursor();
|
||||
}
|
||||
|
||||
void WindowImpl::SetEventListener(bool listener)
|
||||
@@ -405,12 +409,12 @@ namespace Nz
|
||||
|
||||
break;
|
||||
|
||||
case WM_SETCURSOR:
|
||||
/*case WM_SETCURSOR:
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/ms648382(v=vs.85).aspx
|
||||
if (LOWORD(lParam) == HTCLIENT)
|
||||
::SetCursor(m_cursor);
|
||||
|
||||
break;
|
||||
break;*/
|
||||
|
||||
case WM_WINDOWPOSCHANGING:
|
||||
{
|
||||
|
||||
@@ -58,6 +58,8 @@ namespace Nz
|
||||
bool IsMinimized() const;
|
||||
bool IsVisible() const;
|
||||
|
||||
void RefreshCursor();
|
||||
|
||||
void ProcessEvents(bool block);
|
||||
|
||||
void SetCursor(const Cursor& cursor);
|
||||
|
||||
@@ -33,11 +33,28 @@ namespace Nz
|
||||
m_eventPolling(false),
|
||||
m_waitForEvent(false)
|
||||
{
|
||||
m_cursorController.OnCursorUpdated.Connect([this](const CursorController*, const CursorRef& cursor)
|
||||
{
|
||||
if (IsValid())
|
||||
SetCursor(cursor);
|
||||
});
|
||||
ConnectSlots();
|
||||
}
|
||||
|
||||
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()
|
||||
@@ -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()
|
||||
{
|
||||
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
|
||||
{
|
||||
#if NAZARA_PLATFORM_SAFE
|
||||
@@ -608,6 +663,34 @@ namespace Nz
|
||||
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()
|
||||
{
|
||||
return WindowImpl::Initialize();
|
||||
|
||||
@@ -412,6 +412,10 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
void WindowImpl::RefreshCursor()
|
||||
{
|
||||
}
|
||||
|
||||
void WindowImpl::SetCursor(const Cursor& cursor)
|
||||
{
|
||||
xcb_cursor_t cursorImpl = cursor.m_impl->GetCursor();
|
||||
|
||||
@@ -58,6 +58,8 @@ namespace Nz
|
||||
bool IsMinimized() const;
|
||||
bool IsVisible() const;
|
||||
|
||||
void RefreshCursor();
|
||||
|
||||
void ProcessEvents(bool block);
|
||||
|
||||
void SetCursor(const Cursor& cursor);
|
||||
|
||||
Reference in New Issue
Block a user