From 668c4d98d9aa386e137b7199c68ee9df08adca99 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Tue, 27 Mar 2012 18:33:58 -0300 Subject: [PATCH] win32 fixes --- modules/client/client.lua | 8 +++---- modules/game/gameinterface.otui | 8 +++---- modules/game/styles/miniwindow.otui | 2 +- src/framework/application.cpp | 2 +- src/framework/platform/win32window.cpp | 29 ++++++++++++++++++++++---- 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/modules/client/client.lua b/modules/client/client.lua index d0d5a078..8c140a08 100644 --- a/modules/client/client.lua +++ b/modules/client/client.lua @@ -35,11 +35,11 @@ function Client.init() g_window.setIcon(resolvepath('clienticon.png')) -- show the only window after the first frame is rendered - addEvent(function() - addEvent(function() + scheduleEvent(function() + scheduleEvent(function() g_window.show() - end) - end) + end, 0) + end, 0) end function Client.terminate() diff --git a/modules/game/gameinterface.otui b/modules/game/gameinterface.otui index d68117cd..8e003060 100644 --- a/modules/game/gameinterface.otui +++ b/modules/game/gameinterface.otui @@ -56,8 +56,8 @@ UIWidget anchors.bottom: parent.bottom relative-margin: bottom margin-bottom: 172 - @canUpdateMargin: function(self, newMargin) return math.min(math.max(newMargin, 100), self:getParent():getHeight() - 300) end - @onGeometryChange: function(self) self:setMarginBottom(math.min(self:getParent():getHeight() - 300, self:getMarginBottom())) end + @canUpdateMargin: function(self, newMargin) return math.max(math.min(newMargin, self:getParent():getHeight() - 300), 100) end + @onGeometryChange: function(self) self:setMarginBottom(math.min(math.max(self:getParent():getHeight() - 300, 100), self:getMarginBottom())) end Splitter id: rightSplitter @@ -66,8 +66,8 @@ UIWidget anchors.bottom: parent.bottom relative-margin: right margin-right: 190 - @canUpdateMargin: function(self, newMargin) return math.min(math.max(newMargin, 150), self:getParent():getWidth() - 300) end - @onGeometryChange: function(self) self:setMarginRight(math.min(self:getParent():getWidth() - 300, self:getMarginRight())) end + @canUpdateMargin: function(self, newMargin) return math.max(math.min(newMargin, self:getParent():getWidth() - 300), 150) end + @onGeometryChange: function(self) self:setMarginRight(math.min(math.max(self:getParent():getWidth() - 300, 150), self:getMarginRight())) end UIWidget id: mouseGrabber diff --git a/modules/game/styles/miniwindow.otui b/modules/game/styles/miniwindow.otui index 344920e1..29513b6c 100644 --- a/modules/game/styles/miniwindow.otui +++ b/modules/game/styles/miniwindow.otui @@ -55,7 +55,7 @@ MiniWindow < UIMiniWindow anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right - height: 1 + height: 4 minimum: 70 background: #ffffff88 diff --git a/src/framework/application.cpp b/src/framework/application.cpp index 4df647e7..9980c2d6 100644 --- a/src/framework/application.cpp +++ b/src/framework/application.cpp @@ -226,7 +226,7 @@ void Application::poll() Connection::poll(); //g_eventDispatcher.poll(true); - g_eventDispatcher.poll(); + g_eventDispatcher.poll(true); } void Application::close() diff --git a/src/framework/platform/win32window.cpp b/src/framework/platform/win32window.cpp index f498591d..7ca1f5b6 100644 --- a/src/framework/platform/win32window.cpp +++ b/src/framework/platform/win32window.cpp @@ -287,6 +287,8 @@ void WIN32Window::internalCreateWindow() if(!m_window) logFatal("Unable to create window"); + ShowWindow(m_window, SW_HIDE); + m_deviceContext = GetDC(m_window); if(!m_deviceContext) logFatal("GetDC failed"); @@ -456,7 +458,7 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar if(m_cursor) SetCursor(m_cursor); else - SetCursor(m_defaultCursor); + DefWindowProc(hWnd, uMsg, wParam, lParam); break; } case WM_ACTIVATE: { @@ -485,6 +487,7 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar break; } case WM_LBUTTONDOWN: { + SetCapture(m_window); m_inputEvent.reset(Fw::MousePressInputEvent); m_inputEvent.mouseButton = Fw::MouseLeftButton; if(m_onInputEvent) @@ -492,6 +495,7 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar break; } case WM_LBUTTONUP: { + SetCapture(NULL); m_inputEvent.reset(Fw::MouseReleaseInputEvent); m_inputEvent.mouseButton = Fw::MouseLeftButton; if(m_onInputEvent) @@ -499,6 +503,7 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar break; } case WM_MBUTTONDOWN: { + SetCapture(m_window); m_inputEvent.reset(Fw::MousePressInputEvent); m_inputEvent.mouseButton = Fw::MouseMidButton; if(m_onInputEvent) @@ -506,6 +511,7 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar break; } case WM_MBUTTONUP: { + SetCapture(NULL); m_inputEvent.reset(Fw::MouseReleaseInputEvent); m_inputEvent.mouseButton = Fw::MouseMidButton; if(m_onInputEvent) @@ -513,6 +519,7 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar break; } case WM_RBUTTONDOWN: { + SetCapture(m_window); m_inputEvent.reset(Fw::MousePressInputEvent); m_inputEvent.mouseButton = Fw::MouseRightButton; if(m_onInputEvent) @@ -520,6 +527,7 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar break; } case WM_RBUTTONUP: { + SetCapture(NULL); m_inputEvent.reset(Fw::MouseReleaseInputEvent); m_inputEvent.mouseButton = Fw::MouseRightButton; if(m_onInputEvent) @@ -528,7 +536,18 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar } case WM_MOUSEMOVE: { m_inputEvent.reset(Fw::MouseMoveInputEvent); + Point newMousePos(LOWORD(lParam), HIWORD(lParam)); + if(newMousePos.x >= 32767) + newMousePos.x = 0; + else + newMousePos.x = std::min(newMousePos.x, m_size.width()); + + if(newMousePos.y >= 32767) + newMousePos.y = 0; + else + newMousePos.y = std::min(newMousePos.y, m_size.height()); + m_inputEvent.mouseMoved = newMousePos - m_inputEvent.mousePos; m_inputEvent.mousePos = newMousePos; if(m_onInputEvent) @@ -564,10 +583,12 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar } m_visible = !(wParam == SIZE_MINIMIZED); - m_size.setWidth(LOWORD(lParam)); - m_size.setHeight(HIWORD(lParam)); + if(m_visible) { + m_size.setWidth(LOWORD(lParam)); + m_size.setHeight(HIWORD(lParam)); - m_onResize(m_size); + m_onResize(m_size); + } break; } default: