mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-04 06:06:17 +00:00
comp: Properly service Windows message queue.
This commit is contained in:
parent
607eae4fdd
commit
c81ae4670b
|
@ -35,9 +35,11 @@ struct comp_window_mswin
|
||||||
|
|
||||||
|
|
||||||
bool fullscreen_requested;
|
bool fullscreen_requested;
|
||||||
|
bool should_exit;
|
||||||
};
|
};
|
||||||
|
|
||||||
static WCHAR szWindowClass[] = L"Monado";
|
static WCHAR szWindowClass[] = L"Monado";
|
||||||
|
static WCHAR szWindowData[] = L"MonadoWindow";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -45,23 +47,30 @@ static WCHAR szWindowClass[] = L"Monado";
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
draw_window(HWND hWnd, struct comp_window_mswin *cwm)
|
||||||
|
{
|
||||||
|
ValidateRect(hWnd, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK
|
static LRESULT CALLBACK
|
||||||
WndProc(HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam)
|
WndProc(HWND hWnd, unsigned int message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
struct comp_window_mswin *cwm = GetPropW(hWnd, szWindowData);
|
||||||
|
if (!cwm) {
|
||||||
|
// This is before we've set up our window, or for some other helper window...
|
||||||
|
// We might want to handle messages differently in here.
|
||||||
|
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||||
|
}
|
||||||
switch (message) {
|
switch (message) {
|
||||||
case WM_PAINT: {
|
case WM_PAINT: draw_window(hWnd, cwm); return 0;
|
||||||
// paint the main window
|
case WM_CLOSE: cwm->should_exit = true; return 0;
|
||||||
PAINTSTRUCT ps;
|
|
||||||
HDC hdc = BeginPaint(hWnd, &ps);
|
|
||||||
// TODO: Add any drawing code that uses hdc here...
|
|
||||||
EndPaint(hWnd, &ps);
|
|
||||||
} break;
|
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
// Post a quit message and return.
|
// Post a quit message and return.
|
||||||
//! @todo set quit flag
|
cwm->should_exit = true;
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
break;
|
return 0;
|
||||||
default: return DefWindowProc(hWnd, message, wParam, lParam);
|
default: return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -140,6 +149,12 @@ static void
|
||||||
comp_window_mswin_flush(struct comp_target *ct)
|
comp_window_mswin_flush(struct comp_target *ct)
|
||||||
{
|
{
|
||||||
struct comp_window_mswin *cwm = (struct comp_window_mswin *)ct;
|
struct comp_window_mswin *cwm = (struct comp_window_mswin *)ct;
|
||||||
|
// force handling messages.
|
||||||
|
MSG msg;
|
||||||
|
while (PeekMessageW(&msg, cwm->window, 0, 0, PM_REMOVE)) {
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessageW(&msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,6 +186,9 @@ comp_window_mswin_init(struct comp_target *ct)
|
||||||
cwm->window = CreateWindowW(szWindowClass, L"Monado (Windowed)", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0,
|
cwm->window = CreateWindowW(szWindowClass, L"Monado (Windowed)", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0,
|
||||||
CW_USEDEFAULT, 0, NULL, NULL, cwm->instance, NULL);
|
CW_USEDEFAULT, 0, NULL, NULL, cwm->instance, NULL);
|
||||||
|
|
||||||
|
SetPropW(cwm->window, szWindowData, cwm);
|
||||||
|
ShowWindow(cwm->window, SW_SHOWDEFAULT);
|
||||||
|
UpdateWindow(cwm->window);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue