This commit is contained in:
Branimir Karadžić 2014-10-12 11:51:58 -07:00
parent 42c9dafd03
commit cd2d643522

View file

@ -268,8 +268,11 @@ namespace entry
{ {
const SDL_MouseMotionEvent& mev = event.motion; const SDL_MouseMotionEvent& mev = event.motion;
WindowHandle handle = findHandle(mev.windowID); WindowHandle handle = findHandle(mev.windowID);
if (isValid(handle) )
{
m_eventQueue.postMouseEvent(handle, mev.x, mev.y, 0); m_eventQueue.postMouseEvent(handle, mev.x, mev.y, 0);
} }
}
break; break;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
@ -277,8 +280,11 @@ namespace entry
{ {
const SDL_MouseButtonEvent& mev = event.button; const SDL_MouseButtonEvent& mev = event.button;
WindowHandle handle = findHandle(mev.windowID); WindowHandle handle = findHandle(mev.windowID);
if (isValid(handle) )
{
m_eventQueue.postMouseEvent(handle, mev.x, mev.y, 0, MouseButton::Left, mev.type == SDL_MOUSEBUTTONDOWN); m_eventQueue.postMouseEvent(handle, mev.x, mev.y, 0, MouseButton::Left, mev.type == SDL_MOUSEBUTTONDOWN);
} }
}
break; break;
case SDL_KEYDOWN: case SDL_KEYDOWN:
@ -286,10 +292,13 @@ namespace entry
{ {
const SDL_KeyboardEvent& kev = event.key; const SDL_KeyboardEvent& kev = event.key;
WindowHandle handle = findHandle(kev.windowID); WindowHandle handle = findHandle(kev.windowID);
if (isValid(handle) )
{
uint8_t modifiers = translateKeyModifiers(kev.keysym.mod); uint8_t modifiers = translateKeyModifiers(kev.keysym.mod);
Key::Enum key = translateKey(kev.keysym.scancode); Key::Enum key = translateKey(kev.keysym.scancode);
m_eventQueue.postKeyEvent(handle, key, modifiers, kev.state == SDL_PRESSED); m_eventQueue.postKeyEvent(handle, key, modifiers, kev.state == SDL_PRESSED);
} }
}
break; break;
case SDL_WINDOWEVENT: case SDL_WINDOWEVENT:
@ -367,17 +376,23 @@ namespace entry
case SDL_USER_WINDOW_DESTROY: case SDL_USER_WINDOW_DESTROY:
{ {
WindowHandle handle = getWindowHandle(uev); WindowHandle handle = getWindowHandle(uev);
if (isValid(handle) )
{
m_eventQueue.postWindowEvent(handle); m_eventQueue.postWindowEvent(handle);
SDL_DestroyWindow(m_window[handle.idx]); SDL_DestroyWindow(m_window[handle.idx]);
m_window[handle.idx] = NULL; m_window[handle.idx] = NULL;
} }
}
break; break;
case SDL_USER_WINDOW_SET_TITLE: case SDL_USER_WINDOW_SET_TITLE:
{ {
WindowHandle handle = getWindowHandle(uev); WindowHandle handle = getWindowHandle(uev);
Msg* msg = (Msg*)uev.data2; Msg* msg = (Msg*)uev.data2;
if (isValid(handle) )
{
SDL_SetWindowTitle(m_window[handle.idx], msg->m_title.c_str()); SDL_SetWindowTitle(m_window[handle.idx], msg->m_title.c_str());
}
delete msg; delete msg;
} }
break; break;
@ -395,16 +410,23 @@ namespace entry
{ {
WindowHandle handle = getWindowHandle(uev); WindowHandle handle = getWindowHandle(uev);
Msg* msg = (Msg*)uev.data2; Msg* msg = (Msg*)uev.data2;
if (isValid(handle) )
{
setWindowSize(handle, msg->m_width, msg->m_height); setWindowSize(handle, msg->m_width, msg->m_height);
} }
delete msg;
}
break; break;
case SDL_USER_WINDOW_TOGGLE_FRAME: case SDL_USER_WINDOW_TOGGLE_FRAME:
{ {
WindowHandle handle = getWindowHandle(uev); WindowHandle handle = getWindowHandle(uev);
if (isValid(handle) )
{
m_flags[handle.idx] ^= ENTRY_WINDOW_FLAG_FRAME; m_flags[handle.idx] ^= ENTRY_WINDOW_FLAG_FRAME;
SDL_SetWindowBordered(m_window[handle.idx], (SDL_bool)!!(m_flags[handle.idx] & ENTRY_WINDOW_FLAG_FRAME) ); SDL_SetWindowBordered(m_window[handle.idx], (SDL_bool)!!(m_flags[handle.idx] & ENTRY_WINDOW_FLAG_FRAME) );
} }
}
break; break;
case SDL_USER_WINDOW_MOUSE_LOCK: case SDL_USER_WINDOW_MOUSE_LOCK: