mirror of
https://github.com/AxioDL/boo.git
synced 2025-05-14 19:31:20 +00:00
Make resized() lock platform-dependent
This commit is contained in:
parent
5982a3825d
commit
f9ed2ba5b8
@ -24,12 +24,13 @@ struct DeferredWindowEvents : public IWindowCallback
|
|||||||
|
|
||||||
bool m_hasResize = false;
|
bool m_hasResize = false;
|
||||||
SWindowRect m_latestResize;
|
SWindowRect m_latestResize;
|
||||||
void resized(const SWindowRect& rect)
|
void resized(const SWindowRect& rect, bool sync)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lk(m_mt);
|
std::unique_lock<std::mutex> lk(m_mt);
|
||||||
m_latestResize = rect;
|
m_latestResize = rect;
|
||||||
m_hasResize = true;
|
m_hasResize = true;
|
||||||
m_resizeCv.wait_for(lk, std::chrono::milliseconds(500));
|
if (sync)
|
||||||
|
m_resizeCv.wait_for(lk, std::chrono::milliseconds(500));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Command
|
struct Command
|
||||||
|
@ -173,7 +173,7 @@ struct ITextInputCallback
|
|||||||
class IWindowCallback
|
class IWindowCallback
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void resized(const SWindowRect& rect)
|
virtual void resized(const SWindowRect& rect, bool sync)
|
||||||
{(void)rect;}
|
{(void)rect;}
|
||||||
virtual void mouseDown(const SWindowCoord& coord, EMouseButton button, EModifierKey mods)
|
virtual void mouseDown(const SWindowCoord& coord, EMouseButton button, EModifierKey mods)
|
||||||
{(void)coord;(void)button;(void)mods;}
|
{(void)coord;(void)button;(void)mods;}
|
||||||
|
@ -8,8 +8,7 @@
|
|||||||
#include "boo/IWindow.hpp"
|
#include "boo/IWindow.hpp"
|
||||||
#include "boo/IGraphicsContext.hpp"
|
#include "boo/IGraphicsContext.hpp"
|
||||||
#include "boo/audiodev/IAudioVoiceEngine.hpp"
|
#include "boo/audiodev/IAudioVoiceEngine.hpp"
|
||||||
|
#include "logvisor/logvisor.hpp"
|
||||||
#include <LogVisor/LogVisor.hpp>
|
|
||||||
|
|
||||||
#if !__has_feature(objc_arc)
|
#if !__has_feature(objc_arc)
|
||||||
#error ARC Required
|
#error ARC Required
|
||||||
@ -1146,7 +1145,7 @@ static boo::ESpecialKey translateKeycode(short code)
|
|||||||
boo::SWindowRect rect = {int(frame.origin.x), int(frame.origin.y),
|
boo::SWindowRect rect = {int(frame.origin.x), int(frame.origin.y),
|
||||||
int(frame.size.width), int(frame.size.height)};
|
int(frame.size.width), int(frame.size.height)};
|
||||||
if (resp->booContext->m_callback)
|
if (resp->booContext->m_callback)
|
||||||
resp->booContext->m_callback->resized(rect);
|
resp->booContext->m_callback->resized(rect, true);
|
||||||
[super reshape];
|
[super reshape];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1224,7 +1223,7 @@ static boo::ESpecialKey translateKeycode(short code)
|
|||||||
boo::MetalContext::Window& w = m_ctx->m_windows[m_window];
|
boo::MetalContext::Window& w = m_ctx->m_windows[m_window];
|
||||||
std::unique_lock<std::mutex> lk(w.m_resizeLock);
|
std::unique_lock<std::mutex> lk(w.m_resizeLock);
|
||||||
if (resp->booContext->m_callback)
|
if (resp->booContext->m_callback)
|
||||||
resp->booContext->m_callback->resized(rect);
|
resp->booContext->m_callback->resized(rect, false);
|
||||||
w.m_size = CGSizeMake(rect.size[0], rect.size[1]);
|
w.m_size = CGSizeMake(rect.size[0], rect.size[1]);
|
||||||
w.m_needsResize = YES;
|
w.m_needsResize = YES;
|
||||||
}
|
}
|
||||||
|
@ -934,6 +934,7 @@ class WindowWin32 : public IWindow
|
|||||||
IWindowCallback* m_callback = nullptr;
|
IWindowCallback* m_callback = nullptr;
|
||||||
EMouseCursor m_cursor = EMouseCursor::None;
|
EMouseCursor m_cursor = EMouseCursor::None;
|
||||||
bool m_cursorWait = false;
|
bool m_cursorWait = false;
|
||||||
|
bool m_openGL = false;
|
||||||
static HCURSOR GetWin32Cursor(EMouseCursor cur)
|
static HCURSOR GetWin32Cursor(EMouseCursor cur)
|
||||||
{
|
{
|
||||||
switch (cur)
|
switch (cur)
|
||||||
@ -971,6 +972,7 @@ public:
|
|||||||
{
|
{
|
||||||
m_gfxCtx.reset(new GraphicsContextWin32GL(IGraphicsContext::EGraphicsAPI::OpenGL3_3,
|
m_gfxCtx.reset(new GraphicsContextWin32GL(IGraphicsContext::EGraphicsAPI::OpenGL3_3,
|
||||||
this, m_hwnd, b3dCtx, sampleCount));
|
this, m_hwnd, b3dCtx, sampleCount));
|
||||||
|
m_openGL = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if BOO_HAS_VULKAN
|
#if BOO_HAS_VULKAN
|
||||||
@ -1289,7 +1291,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
m_gfxCtx->m_3dCtx.resize(this, rect.size[0], rect.size[1]);
|
m_gfxCtx->m_3dCtx.resize(this, rect.size[0], rect.size[1]);
|
||||||
if (m_callback)
|
if (m_callback)
|
||||||
m_callback->resized(rect);
|
m_callback->resized(rect, m_openGL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
case WM_MOVING:
|
case WM_MOVING:
|
||||||
|
@ -911,6 +911,8 @@ class WindowXlib : public IWindow
|
|||||||
return X_CURSORS.m_pointer;
|
return X_CURSORS.m_pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool m_openGL = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
WindowXlib(const std::string& title,
|
WindowXlib(const std::string& title,
|
||||||
Display* display, void* xcbConn,
|
Display* display, void* xcbConn,
|
||||||
@ -936,6 +938,7 @@ public:
|
|||||||
i = 0;
|
i = 0;
|
||||||
m_gfxCtx.reset(new GraphicsContextXlibGLX(IGraphicsContext::EGraphicsAPI::OpenGL3_3,
|
m_gfxCtx.reset(new GraphicsContextXlibGLX(IGraphicsContext::EGraphicsAPI::OpenGL3_3,
|
||||||
this, display, defaultScreen, lastCtx, m_visualId, drawSamples));
|
this, display, defaultScreen, lastCtx, m_visualId, drawSamples));
|
||||||
|
m_openGL = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Default screen */
|
/* Default screen */
|
||||||
@ -1601,7 +1604,7 @@ public:
|
|||||||
{
|
{
|
||||||
XUnlockDisplay(m_xDisp);
|
XUnlockDisplay(m_xDisp);
|
||||||
m_gfxCtx->resized(m_wrect);
|
m_gfxCtx->resized(m_wrect);
|
||||||
m_callback->resized(m_wrect);
|
m_callback->resized(m_wrect, m_openGL);
|
||||||
XLockDisplay(m_xDisp);
|
XLockDisplay(m_xDisp);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user