win32 fixes

This commit is contained in:
Eduardo Bart 2012-03-27 18:33:58 -03:00
parent 8ea154016b
commit 668c4d98d9
5 changed files with 35 additions and 14 deletions

View File

@ -35,11 +35,11 @@ function Client.init()
g_window.setIcon(resolvepath('clienticon.png')) g_window.setIcon(resolvepath('clienticon.png'))
-- show the only window after the first frame is rendered -- show the only window after the first frame is rendered
addEvent(function() scheduleEvent(function()
addEvent(function() scheduleEvent(function()
g_window.show() g_window.show()
end) end, 0)
end) end, 0)
end end
function Client.terminate() function Client.terminate()

View File

@ -56,8 +56,8 @@ UIWidget
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
relative-margin: bottom relative-margin: bottom
margin-bottom: 172 margin-bottom: 172
@canUpdateMargin: function(self, newMargin) return math.min(math.max(newMargin, 100), self:getParent():getHeight() - 300) end @canUpdateMargin: function(self, newMargin) return math.max(math.min(newMargin, self:getParent():getHeight() - 300), 100) end
@onGeometryChange: function(self) self:setMarginBottom(math.min(self:getParent():getHeight() - 300, self:getMarginBottom())) end @onGeometryChange: function(self) self:setMarginBottom(math.min(math.max(self:getParent():getHeight() - 300, 100), self:getMarginBottom())) end
Splitter Splitter
id: rightSplitter id: rightSplitter
@ -66,8 +66,8 @@ UIWidget
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
relative-margin: right relative-margin: right
margin-right: 190 margin-right: 190
@canUpdateMargin: function(self, newMargin) return math.min(math.max(newMargin, 150), self:getParent():getWidth() - 300) end @canUpdateMargin: function(self, newMargin) return math.max(math.min(newMargin, self:getParent():getWidth() - 300), 150) end
@onGeometryChange: function(self) self:setMarginRight(math.min(self:getParent():getWidth() - 300, self:getMarginRight())) end @onGeometryChange: function(self) self:setMarginRight(math.min(math.max(self:getParent():getWidth() - 300, 150), self:getMarginRight())) end
UIWidget UIWidget
id: mouseGrabber id: mouseGrabber

View File

@ -55,7 +55,7 @@ MiniWindow < UIMiniWindow
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
height: 1 height: 4
minimum: 70 minimum: 70
background: #ffffff88 background: #ffffff88

View File

@ -226,7 +226,7 @@ void Application::poll()
Connection::poll(); Connection::poll();
//g_eventDispatcher.poll(true); //g_eventDispatcher.poll(true);
g_eventDispatcher.poll(); g_eventDispatcher.poll(true);
} }
void Application::close() void Application::close()

View File

@ -287,6 +287,8 @@ void WIN32Window::internalCreateWindow()
if(!m_window) if(!m_window)
logFatal("Unable to create window"); logFatal("Unable to create window");
ShowWindow(m_window, SW_HIDE);
m_deviceContext = GetDC(m_window); m_deviceContext = GetDC(m_window);
if(!m_deviceContext) if(!m_deviceContext)
logFatal("GetDC failed"); logFatal("GetDC failed");
@ -456,7 +458,7 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
if(m_cursor) if(m_cursor)
SetCursor(m_cursor); SetCursor(m_cursor);
else else
SetCursor(m_defaultCursor); DefWindowProc(hWnd, uMsg, wParam, lParam);
break; break;
} }
case WM_ACTIVATE: { case WM_ACTIVATE: {
@ -485,6 +487,7 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
break; break;
} }
case WM_LBUTTONDOWN: { case WM_LBUTTONDOWN: {
SetCapture(m_window);
m_inputEvent.reset(Fw::MousePressInputEvent); m_inputEvent.reset(Fw::MousePressInputEvent);
m_inputEvent.mouseButton = Fw::MouseLeftButton; m_inputEvent.mouseButton = Fw::MouseLeftButton;
if(m_onInputEvent) if(m_onInputEvent)
@ -492,6 +495,7 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
break; break;
} }
case WM_LBUTTONUP: { case WM_LBUTTONUP: {
SetCapture(NULL);
m_inputEvent.reset(Fw::MouseReleaseInputEvent); m_inputEvent.reset(Fw::MouseReleaseInputEvent);
m_inputEvent.mouseButton = Fw::MouseLeftButton; m_inputEvent.mouseButton = Fw::MouseLeftButton;
if(m_onInputEvent) if(m_onInputEvent)
@ -499,6 +503,7 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
break; break;
} }
case WM_MBUTTONDOWN: { case WM_MBUTTONDOWN: {
SetCapture(m_window);
m_inputEvent.reset(Fw::MousePressInputEvent); m_inputEvent.reset(Fw::MousePressInputEvent);
m_inputEvent.mouseButton = Fw::MouseMidButton; m_inputEvent.mouseButton = Fw::MouseMidButton;
if(m_onInputEvent) if(m_onInputEvent)
@ -506,6 +511,7 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
break; break;
} }
case WM_MBUTTONUP: { case WM_MBUTTONUP: {
SetCapture(NULL);
m_inputEvent.reset(Fw::MouseReleaseInputEvent); m_inputEvent.reset(Fw::MouseReleaseInputEvent);
m_inputEvent.mouseButton = Fw::MouseMidButton; m_inputEvent.mouseButton = Fw::MouseMidButton;
if(m_onInputEvent) if(m_onInputEvent)
@ -513,6 +519,7 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
break; break;
} }
case WM_RBUTTONDOWN: { case WM_RBUTTONDOWN: {
SetCapture(m_window);
m_inputEvent.reset(Fw::MousePressInputEvent); m_inputEvent.reset(Fw::MousePressInputEvent);
m_inputEvent.mouseButton = Fw::MouseRightButton; m_inputEvent.mouseButton = Fw::MouseRightButton;
if(m_onInputEvent) if(m_onInputEvent)
@ -520,6 +527,7 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
break; break;
} }
case WM_RBUTTONUP: { case WM_RBUTTONUP: {
SetCapture(NULL);
m_inputEvent.reset(Fw::MouseReleaseInputEvent); m_inputEvent.reset(Fw::MouseReleaseInputEvent);
m_inputEvent.mouseButton = Fw::MouseRightButton; m_inputEvent.mouseButton = Fw::MouseRightButton;
if(m_onInputEvent) if(m_onInputEvent)
@ -528,7 +536,18 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
} }
case WM_MOUSEMOVE: { case WM_MOUSEMOVE: {
m_inputEvent.reset(Fw::MouseMoveInputEvent); m_inputEvent.reset(Fw::MouseMoveInputEvent);
Point newMousePos(LOWORD(lParam), HIWORD(lParam)); 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.mouseMoved = newMousePos - m_inputEvent.mousePos;
m_inputEvent.mousePos = newMousePos; m_inputEvent.mousePos = newMousePos;
if(m_onInputEvent) if(m_onInputEvent)
@ -564,10 +583,12 @@ LRESULT WIN32Window::windowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
} }
m_visible = !(wParam == SIZE_MINIMIZED); m_visible = !(wParam == SIZE_MINIMIZED);
if(m_visible) {
m_size.setWidth(LOWORD(lParam)); m_size.setWidth(LOWORD(lParam));
m_size.setHeight(HIWORD(lParam)); m_size.setHeight(HIWORD(lParam));
m_onResize(m_size); m_onResize(m_size);
}
break; break;
} }
default: default: