<commit_before>// 6 april 2015
#include "uipriv_windows.h"

// TODO
// - [18:19] <ZeroOne> Though, if you minimise it and bring it back up, the buttons disappear until you resize the window. Not sure if you care about that or not.

struct uiWindow {
	HWND hwnd;
	uiControl *child;
	BOOL shownOnce;
	int (*onClosing)(uiWindow *, void *);
	void *onClosingData;
};

#define uiWindowClass L"uiWindowClass"

static LRESULT CALLBACK uiWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	uiWindow *w;
	CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam;
	LRESULT lResult;
	WINDOWPOS *wp = (WINDOWPOS *) lParam;
	RECT r;

	w = (uiWindow *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
	if (w == NULL) {
		if (uMsg == WM_CREATE)
			SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) (cs->lpCreateParams));
		// fall through to DefWindowProc() anyway
		return DefWindowProcW(hwnd, uMsg, wParam, lParam);
	}
	if (sharedWndProc(hwnd, uMsg, wParam, lParam, &lResult) != FALSE)
		return lResult;
	switch (uMsg) {
	case WM_WINDOWPOSCHANGING:
		if (w->child == NULL)
			break;
		if ((wp->flags & SWP_NOSIZE) != 0)
			break;
		if (GetClientRect(w->hwnd, &r) == 0)
			logLastError("error getting window client rect for resize in uiWindowWndProc()");
		resize(w->child, w->hwnd, r);
		return 0;
	case WM_CLOSE:
		if (!(*(w->onClosing))(w, w->onClosingData))
			return 0;
		break;		// fall through to DefWindowProcW()
	case WM_DESTROY:
		if (w->child != NULL)
			uiControlDestroy(w->child);
		uiFree(w);
		break;		// fall through to DefWindowProcW()
	}<commit_msg>Fixed flicker and minimize issues on Windows. Simple mistake; should have used WM_WINDOWPOSCHANGED instead of WM_WINDOWPOSCHANGING. Startup looks wrong; will fix that next.<commit_after>// 6 april 2015
#include "uipriv_windows.h"

struct uiWindow {
	HWND hwnd;
	uiControl *child;
	BOOL shownOnce;
	int (*onClosing)(uiWindow *, void *);
	void *onClosingData;
};

#define uiWindowClass L"uiWindowClass"

static LRESULT CALLBACK uiWindowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	uiWindow *w;
	CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam;
	LRESULT lResult;
	WINDOWPOS *wp = (WINDOWPOS *) lParam;
	RECT r;

	w = (uiWindow *) GetWindowLongPtrW(hwnd, GWLP_USERDATA);
	if (w == NULL) {
		if (uMsg == WM_CREATE)
			SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) (cs->lpCreateParams));
		// fall through to DefWindowProc() anyway
		return DefWindowProcW(hwnd, uMsg, wParam, lParam);
	}
	if (sharedWndProc(hwnd, uMsg, wParam, lParam, &lResult) != FALSE)
		return lResult;
	switch (uMsg) {
	case WM_WINDOWPOSCHANGED:
		if (w->child == NULL)
			break;
		if ((wp->flags & SWP_NOSIZE) != 0)
			break;
		if (GetClientRect(w->hwnd, &r) == 0)
			logLastError("error getting window client rect for resize in uiWindowWndProc()");
		resize(w->child, w->hwnd, r);
		return 0;
	case WM_CLOSE:
		if (!(*(w->onClosing))(w, w->onClosingData))
			return 0;
		break;		// fall through to DefWindowProcW()
	case WM_DESTROY:
		if (w->child != NULL)
			uiControlDestroy(w->child);
		uiFree(w);
		break;		// fall through to DefWindowProcW()
	}
{'fraction_non_alphanumeric': 0.13197146562905318, 'fraction_numerical': 0.007133592736705577, 'mean_word_length': 4.440917107583775, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '73483', 'n_tokens_mistral': 1240, 'n_tokens_neox': 1171, 'n_words': 322}