diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-19 13:25:52 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-19 13:25:52 -0400 |
| commit | a3ff63490b80c9f744978f3cf6e096a066c626e3 (patch) | |
| tree | 309b82732f09d858beaa7c79fd34410fb3411417 /redo/uitask_windows.c | |
| parent | e5759d80de62958b24d5fe18c7e8b2d4a8241cc0 (diff) | |
Split the modal queue stuff into its own files.
Diffstat (limited to 'redo/uitask_windows.c')
| -rw-r--r-- | redo/uitask_windows.c | 47 |
1 files changed, 6 insertions, 41 deletions
diff --git a/redo/uitask_windows.c b/redo/uitask_windows.c index 3732270..ac8141b 100644 --- a/redo/uitask_windows.c +++ b/redo/uitask_windows.c @@ -2,6 +2,7 @@ #include "winapi_windows.h" #include "_cgo_export.h" +#include "modalqueue.h" // note that this includes the terminating '\0' // this also assumes WC_TABCONTROL is longer than areaWindowClass @@ -71,13 +72,6 @@ HWND msgwin; #define msgwinclass L"gouimsgwin" -struct modalqueue { - BOOL inmodal; - void **modals; - size_t len; - size_t cap; -}; - static BOOL CALLBACK beginEndModalAll(HWND hwnd, LPARAM lParam) { if (hwnd != msgwin) @@ -88,24 +82,8 @@ static BOOL CALLBACK beginEndModalAll(HWND hwnd, LPARAM lParam) static LRESULT CALLBACK msgwinproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT shared; - struct modalqueue *mq; size_t i; - mq = (struct modalqueue *) GetWindowLongPtrW(hwnd, GWLP_USERDATA); - if (mq == NULL) { - mq = (struct modalqueue *) malloc(sizeof (struct modalqueue)); - if (mq == NULL) - xpanic("error allocating modal queue structure", GetLastError()); - ZeroMemory(mq, sizeof (struct modalqueue)); - mq->inmodal = FALSE; - mq->len = 0; - mq->cap = 128; - mq->modals = (void **) malloc(mq->cap * sizeof (void *)); - if (mq->modals == NULL) - xpanic("error allocating modal quque", GetLastError()); - SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) mq); - } - if (sharedWndProc(hwnd, uMsg, wParam, lParam, &shared)) return shared; switch (uMsg) { @@ -116,29 +94,16 @@ static LRESULT CALLBACK msgwinproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l // TODO respond to WM_THEMECHANGED case msgRequest: // in modal? - if (mq->inmodal) { - mq->modals[mq->len] = (void *) lParam; - mq->len++; - if (mq->len >= mq->cap) { - mq->cap *= 2; - mq->modals = (void **) realloc(mq->modals, mq->cap * sizeof (void *)); - if (mq->modals == NULL) - xpanic("error growing modal queue", GetLastError()); - } - return; - } - // nope, we can run now - doissue((void *) lParam); + if (!queueIfModal((void *) lParam)) + // nope, we can run now + doissue((void *) lParam); return 0; case msgBeginModal: - mq->inmodal = TRUE; + beginModal(); EnumThreadWindows(GetCurrentThreadId(), beginEndModalAll, msgBeginModal); return 0; case msgEndModal: - mq->inmodal = FALSE; - for (i = 0; i < mq->len; i++) - doissue(mq->modals[i]); - mq->len = 0; + endModal(); EnumThreadWindows(GetCurrentThreadId(), beginEndModalAll, msgEndModal); return 0; default: |
