And wrote it on Windows. Okay, now we can FINALLY start working on controls!!!!!
This commit is contained in:
parent
4815629eef
commit
84a4fd8915
|
@ -1,5 +1,10 @@
|
||||||
// 28 may 2019
|
// 28 may 2019
|
||||||
|
// TODO get rid of the need for this (it temporarily silences noise so I can find actual build issues)
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include "lib/thread.h"
|
#include "lib/thread.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,9 @@ const char **uiprivSysInitErrors(void)
|
||||||
return initErrors;
|
return initErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DWORD mainThread;
|
||||||
|
static BOOL initialized = FALSE; // TODO deduplicate this from common/init.c
|
||||||
|
|
||||||
int uiprivSysInit(void *options, uiInitError *err)
|
int uiprivSysInit(void *options, uiInitError *err)
|
||||||
{
|
{
|
||||||
STARTUPINFOW si;
|
STARTUPINFOW si;
|
||||||
|
@ -110,6 +113,8 @@ int uiprivSysInit(void *options, uiInitError *err)
|
||||||
// LONGTERM initialize COM security
|
// LONGTERM initialize COM security
|
||||||
// LONGTERM turn off COM exception handling
|
// LONGTERM turn off COM exception handling
|
||||||
*/
|
*/
|
||||||
|
mainThread = GetCurrentThreadId();
|
||||||
|
initialized = TRUE;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +123,8 @@ void uiMain(void)
|
||||||
MSG msg;
|
MSG msg;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
|
if (!uiprivCheckInitializedAndThread())
|
||||||
|
return;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
hr = uiprivHrGetMessageW(&msg, NULL, 0, 0);
|
hr = uiprivHrGetMessageW(&msg, NULL, 0, 0);
|
||||||
if (hr == S_FALSE) // WM_QUIT
|
if (hr == S_FALSE) // WM_QUIT
|
||||||
|
@ -134,6 +141,8 @@ void uiMain(void)
|
||||||
|
|
||||||
void uiQuit(void)
|
void uiQuit(void)
|
||||||
{
|
{
|
||||||
|
if (!uiprivCheckInitializedAndThread())
|
||||||
|
return;
|
||||||
PostQuitMessage(0);
|
PostQuitMessage(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,12 +150,21 @@ void uiQueueMain(void (*f)(void *data), void *data)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
|
if (!initialized) {
|
||||||
|
uiprivProgrammerError(uiprivProgrammerErrorNotInitialized, uiprivFunc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
hr = uiprivHrPostMessageW(uiprivUtilWindow, uiprivUtilWindowMsgQueueMain, (WPARAM) f, (LPARAM) data);
|
hr = uiprivHrPostMessageW(uiprivUtilWindow, uiprivUtilWindowMsgQueueMain, (WPARAM) f, (LPARAM) data);
|
||||||
if (hr != S_OK) {
|
if (hr != S_OK) {
|
||||||
// TODO handle error
|
// TODO handle error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool uiprivSysCheckThread(void)
|
||||||
|
{
|
||||||
|
return GetCurrentThreadId() == mainThread;
|
||||||
|
}
|
||||||
|
|
||||||
void uiprivReportError(const char *prefix, const char *msg, const char *suffix, bool internal)
|
void uiprivReportError(const char *prefix, const char *msg, const char *suffix, bool internal)
|
||||||
{
|
{
|
||||||
// Print to both stderr and the debugger; the former handles the case of a console and the latter handles the case of not.
|
// Print to both stderr and the debugger; the former handles the case of a console and the latter handles the case of not.
|
||||||
|
|
Loading…
Reference in New Issue