Diff

Differences From Artifact [15a8b2bdaa]:

To Artifact [aa378915f6]:


843
844
845
846
847
848
849









850
851
852
853
854


855
856
857
858
859
860
861
862
863
864

865
866
867
868
869
870

871
872
873


874
875
876
877
878
879
880
881
882
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861


862
863
864
865
866
867
868
869
870



871
872
873
874
875
876

877



878
879


880
881
882
883
884
885
886







+
+
+
+
+
+
+
+
+



-
-
+
+







-
-
-
+





-
+
-
-
-
+
+
-
-








    term_set_focus(term, GetForegroundWindow() == hwnd);
    UpdateWindow(hwnd);

    while (1) {
	HANDLE *handles;
	int nhandles, n;
        DWORD timeout;

        if (toplevel_callback_pending()) {
            timeout = 0;
        } else {
            timeout = INFINITE;
            /* The messages seem unreliable; especially if we're being tricky */
            term_set_focus(term, GetForegroundWindow() == hwnd);
        }

	handles = handle_get_events(&nhandles);

	n = MsgWaitForMultipleObjects(nhandles, handles, FALSE, INFINITE,
				      QS_ALLINPUT);
	n = MsgWaitForMultipleObjects(nhandles, handles, FALSE,
                                      timeout, QS_ALLINPUT);

	if ((unsigned)(n - WAIT_OBJECT_0) < (unsigned)nhandles) {
	    handle_got_event(handles[n - WAIT_OBJECT_0]);
	    sfree(handles);
	} else
	    sfree(handles);

        run_toplevel_callbacks();

	while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
	if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
	    if (msg.message == WM_QUIT)
		goto finished;	       /* two-level break */

	    if (!(IsWindow(logbox) && IsDialogMessage(logbox, &msg)))
		DispatchMessage(&msg);

	}
            run_toplevel_callbacks();
	}


        run_toplevel_callbacks();
	/* The messages seem unreliable; especially if we're being tricky */
	term_set_focus(term, GetForegroundWindow() == hwnd);
    }

    finished:
    cleanup_exit(msg.wParam);	       /* this doesn't return... */
    return msg.wParam;		       /* ... but optimiser doesn't know */
}