mirror of
https://github.com/AxioDL/boo.git
synced 2025-12-09 13:37:48 +00:00
Windows bug fixes
This commit is contained in:
@@ -57,6 +57,7 @@ static bool FindBestD3DCompile()
|
||||
namespace boo
|
||||
{
|
||||
static LogVisor::LogModule Log("boo::ApplicationWin32");
|
||||
Win32Cursors WIN32_CURSORS;
|
||||
|
||||
IWindow* _WindowWin32New(const SystemString& title, Boo3DAppContext& d3dCtx);
|
||||
|
||||
@@ -92,6 +93,11 @@ public:
|
||||
m_args(args),
|
||||
m_singleInstance(singleInstance)
|
||||
{
|
||||
WIN32_CURSORS.m_arrow = LoadCursor(nullptr, IDC_ARROW);
|
||||
WIN32_CURSORS.m_hResize = LoadCursor(nullptr, IDC_SIZEWE);
|
||||
WIN32_CURSORS.m_vResize = LoadCursor(nullptr, IDC_SIZENS);
|
||||
WIN32_CURSORS.m_wait = LoadCursor(nullptr, IDC_WAIT);
|
||||
|
||||
HMODULE dxgilib = LoadLibraryW(L"dxgi.dll");
|
||||
if (!dxgilib)
|
||||
Log.report(LogVisor::FatalError, "unable to load dxgi.dll");
|
||||
@@ -299,6 +305,10 @@ public:
|
||||
/* Quit message from client thread */
|
||||
PostQuitMessage(0);
|
||||
continue;
|
||||
case WM_USER+2:
|
||||
/* SetCursor call from client thread */
|
||||
SetCursor(HCURSOR(msg.wParam));
|
||||
continue;
|
||||
default:
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
|
||||
@@ -255,4 +255,16 @@ struct HWNDEvent
|
||||
: uMsg(m), wParam(w), lParam(l) {}
|
||||
};
|
||||
|
||||
struct Win32Cursors
|
||||
{
|
||||
HCURSOR m_arrow;
|
||||
HCURSOR m_hResize;
|
||||
HCURSOR m_vResize;
|
||||
HCURSOR m_wait;
|
||||
};
|
||||
namespace boo
|
||||
{
|
||||
extern Win32Cursors WIN32_CURSORS;
|
||||
}
|
||||
|
||||
#endif // BOO_WIN32COMMON_HPP
|
||||
|
||||
@@ -442,6 +442,22 @@ class WindowWin32 : public IWindow
|
||||
HWND m_hwnd;
|
||||
std::unique_ptr<GraphicsContextWin32> m_gfxCtx;
|
||||
IWindowCallback* m_callback = nullptr;
|
||||
EMouseCursor m_cursor = EMouseCursor::None;
|
||||
bool m_cursorWait = false;
|
||||
static HCURSOR GetWin32Cursor(EMouseCursor cur)
|
||||
{
|
||||
switch (cur)
|
||||
{
|
||||
case EMouseCursor::Pointer:
|
||||
return WIN32_CURSORS.m_arrow;
|
||||
case EMouseCursor::HorizontalArrow:
|
||||
return WIN32_CURSORS.m_hResize;
|
||||
case EMouseCursor::VerticalArrow:
|
||||
return WIN32_CURSORS.m_vResize;
|
||||
default: break;
|
||||
}
|
||||
return WIN32_CURSORS.m_arrow;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
@@ -495,6 +511,33 @@ public:
|
||||
SetWindowTextW(m_hwnd, title.c_str());
|
||||
}
|
||||
|
||||
static void _setCursor(HCURSOR cur)
|
||||
{
|
||||
PostThreadMessageW(g_mainThreadId, WM_USER+2, WPARAM(cur), 0);
|
||||
}
|
||||
|
||||
void setCursor(EMouseCursor cursor)
|
||||
{
|
||||
if (cursor == m_cursor && !m_cursorWait)
|
||||
return;
|
||||
m_cursor = cursor;
|
||||
_setCursor(GetWin32Cursor(cursor));
|
||||
}
|
||||
|
||||
void setWaitCursor(bool wait)
|
||||
{
|
||||
if (wait && !m_cursorWait)
|
||||
{
|
||||
_setCursor(WIN32_CURSORS.m_wait);
|
||||
m_cursorWait = true;
|
||||
}
|
||||
else if (!wait && m_cursorWait)
|
||||
{
|
||||
setCursor(m_cursor);
|
||||
m_cursorWait = false;
|
||||
}
|
||||
}
|
||||
|
||||
void setWindowFrameDefault()
|
||||
{
|
||||
MONITORINFO monInfo;
|
||||
@@ -576,9 +619,9 @@ public:
|
||||
EModifierKey modifierMask = translateModifiers(e.uMsg);
|
||||
SWindowCoord coord =
|
||||
{
|
||||
{(unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam)},
|
||||
{(unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam)},
|
||||
{float(GET_X_LPARAM(e.lParam)) / float(w), float(GET_Y_LPARAM(e.lParam)) / float(h)}
|
||||
{(unsigned)GET_X_LPARAM(e.lParam), (unsigned)(h-GET_Y_LPARAM(e.lParam))},
|
||||
{(unsigned)GET_X_LPARAM(e.lParam), (unsigned)(h-GET_Y_LPARAM(e.lParam))},
|
||||
{float(GET_X_LPARAM(e.lParam)) / float(w), float(h-GET_Y_LPARAM(e.lParam)) / float(h)}
|
||||
};
|
||||
m_callback->mouseDown(coord, button, modifierMask);
|
||||
}
|
||||
@@ -593,9 +636,9 @@ public:
|
||||
EModifierKey modifierMask = translateModifiers(e.uMsg);
|
||||
SWindowCoord coord =
|
||||
{
|
||||
{(unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam)},
|
||||
{(unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam)},
|
||||
{float(GET_X_LPARAM(e.lParam)) / float(w), float(GET_Y_LPARAM(e.lParam)) / float(h)}
|
||||
{(unsigned)GET_X_LPARAM(e.lParam), (unsigned)(h-GET_Y_LPARAM(e.lParam))},
|
||||
{(unsigned)GET_X_LPARAM(e.lParam), (unsigned)(h-GET_Y_LPARAM(e.lParam))},
|
||||
{float(GET_X_LPARAM(e.lParam)) / float(w), float(h-GET_Y_LPARAM(e.lParam)) / float(h)}
|
||||
};
|
||||
m_callback->mouseUp(coord, button, modifierMask);
|
||||
}
|
||||
@@ -732,9 +775,9 @@ public:
|
||||
getWindowFrame(x, y, w, h);
|
||||
SWindowCoord coord =
|
||||
{
|
||||
{(unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam)},
|
||||
{(unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam)},
|
||||
{float(GET_X_LPARAM(e.lParam)) / float(w), float(GET_Y_LPARAM(e.lParam)) / float(h)}
|
||||
{(unsigned)GET_X_LPARAM(e.lParam), (unsigned)(h-GET_Y_LPARAM(e.lParam))},
|
||||
{(unsigned)GET_X_LPARAM(e.lParam), (unsigned)(h-GET_Y_LPARAM(e.lParam))},
|
||||
{float(GET_X_LPARAM(e.lParam)) / float(w), float(h-GET_Y_LPARAM(e.lParam)) / float(h)}
|
||||
};
|
||||
if (!mouseTracking)
|
||||
{
|
||||
@@ -757,9 +800,9 @@ public:
|
||||
getWindowFrame(x, y, w, h);
|
||||
SWindowCoord coord =
|
||||
{
|
||||
{ (unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam) },
|
||||
{ (unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam) },
|
||||
{ float(GET_X_LPARAM(e.lParam)) / float(w), float(GET_Y_LPARAM(e.lParam)) / float(h) }
|
||||
{ (unsigned)GET_X_LPARAM(e.lParam), (unsigned)(h-GET_Y_LPARAM(e.lParam)) },
|
||||
{ (unsigned)GET_X_LPARAM(e.lParam), (unsigned)(h-GET_Y_LPARAM(e.lParam)) },
|
||||
{ float(GET_X_LPARAM(e.lParam)) / float(w), float(h-GET_Y_LPARAM(e.lParam)) / float(h) }
|
||||
};
|
||||
m_callback->mouseLeave(coord);
|
||||
mouseTracking = false;
|
||||
@@ -775,9 +818,9 @@ public:
|
||||
getWindowFrame(x, y, w, h);
|
||||
SWindowCoord coord =
|
||||
{
|
||||
{ (unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam) },
|
||||
{ (unsigned)GET_X_LPARAM(e.lParam), (unsigned)GET_Y_LPARAM(e.lParam) },
|
||||
{ float(GET_X_LPARAM(e.lParam)) / float(w), float(GET_Y_LPARAM(e.lParam)) / float(h) }
|
||||
{ (unsigned)GET_X_LPARAM(e.lParam), (unsigned)(h-GET_Y_LPARAM(e.lParam)) },
|
||||
{ (unsigned)GET_X_LPARAM(e.lParam), (unsigned)(h-GET_Y_LPARAM(e.lParam)) },
|
||||
{ float(GET_X_LPARAM(e.lParam)) / float(w), float(h-GET_Y_LPARAM(e.lParam)) / float(h) }
|
||||
};
|
||||
m_callback->mouseEnter(coord);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user