X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/580616706f52835ee5ee48e6ef2ad15b822df971..88594d02eb59a55ac85d3210a49d02918124617b:/src/mgl/window.cpp diff --git a/src/mgl/window.cpp b/src/mgl/window.cpp index 08ad332bce..217508e325 100644 --- a/src/mgl/window.cpp +++ b/src/mgl/window.cpp @@ -118,7 +118,7 @@ static void CaptureScreenshot() // MGL_WM hooks: // --------------------------------------------------------------------------- -static void wxWindowPainter(window_t *wnd, MGLDC *dc) +static void MGLAPI wxWindowPainter(window_t *wnd, MGLDC *dc) { wxWindowMGL *w = (wxWindow*) wnd->userData; @@ -127,13 +127,12 @@ static void wxWindowPainter(window_t *wnd, MGLDC *dc) MGLDevCtx ctx(dc); w->HandlePaint(&ctx); } - // FIXME_MGL -- root window should be a regular window so that - // enter/leave and activate/deactivate events work correctly } -static ibool wxWindowMouseHandler(window_t *wnd, event_t *e) +static ibool MGLAPI wxWindowMouseHandler(window_t *wnd, event_t *e) { wxWindowMGL *win = (wxWindowMGL*)MGL_wmGetWindowUserData(wnd); + wxPoint orig(win->GetClientAreaOrigin()); wxPoint where; MGL_wmCoordGlobalToLocal(win->GetHandle(), @@ -151,8 +150,8 @@ static ibool wxWindowMouseHandler(window_t *wnd, event_t *e) wxMouseEvent event; event.SetEventObject(win); event.SetTimestamp(e->when); - event.m_x = where.x; - event.m_y = where.y; + event.m_x = where.x - orig.x; + event.m_y = where.y - orig.y; event.m_shiftDown = e->modifiers & EVT_SHIFTKEY; event.m_controlDown = e->modifiers & EVT_CTRLSTATE; event.m_altDown = e->modifiers & EVT_LEFTALT; @@ -196,6 +195,10 @@ static ibool wxWindowMouseHandler(window_t *wnd, event_t *e) e->where_x, e->where_y, &event2.m_x, &event2.m_y); + wxPoint orig(gs_windowUnderMouse->GetClientAreaOrigin()); + event2.m_x -= orig.x; + event2.m_y -= orig.y; + event2.SetEventObject(gs_windowUnderMouse); event2.SetEventType(wxEVT_LEAVE_WINDOW); gs_windowUnderMouse->GetEventHandler()->ProcessEvent(event2); @@ -371,7 +374,7 @@ static long wxAsciiToKeyCode(event_t *event) return (long)EVT_asciiCode(event->message); } -static ibool wxWindowKeybHandler(window_t *wnd, event_t *e) +static ibool MGLAPI wxWindowKeybHandler(window_t *wnd, event_t *e) { wxWindowMGL *win = (wxWindowMGL*)MGL_wmGetWindowUserData(wnd); @@ -468,6 +471,11 @@ END_EVENT_TABLE() void wxWindowMGL::Init() { + // First of all, make sure window manager is up and running. If it is + // not the case, initialize it in default display mode + if ( !g_winMng ) + wxTheApp->SetDisplayMode(wxDisplayModeInfo(640, 480, 16)); + // generic: InitBase(); @@ -926,11 +934,15 @@ void wxWindowMGL::DoSetSize(int x, int y, int width, int height, int sizeFlags) } } - DoMoveWindow(x, y, width, height); + if ( m_wnd->x != x || m_wnd->y != y || + (int)m_wnd->width != width || (int)m_wnd->height != height ) + { + DoMoveWindow(x, y, width, height); - wxSizeEvent event(wxSize(width, height), GetId()); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); + wxSizeEvent event(wxSize(width, height), GetId()); + event.SetEventObject(this); + GetEventHandler()->ProcessEvent(event); + } } void wxWindowMGL::DoSetClientSize(int width, int height)