# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1325778311 0 # Node ID 5facb53809440d608daec23de3e0952463db9c33 # Parent 9bab702bd6c12fe2f3ac0f7f4424f0b04370a455 Added dw_main_quit() function for exiting the dw_main() loop. Also some cleanups added to dw_exit() on OS/2 and Windows. Changed OS/2 to no longer destroy the message queue when leaving dw_main()... it should be done in dw_exit(). diff -r 9bab702bd6c1 -r 5facb5380944 dw.h --- a/dw.h Tue Jan 03 15:59:00 2012 +0000 +++ b/dw.h Thu Jan 05 15:45:11 2012 +0000 @@ -1456,6 +1456,7 @@ int API dw_init(int newthread, int argc, char *argv[]); #endif void API dw_main(void); +void API dw_main_quit(void); void API dw_main_sleep(int seconds); void API dw_main_iteration(void); void API dw_free(void *ptr); diff -r 9bab702bd6c1 -r 5facb5380944 gtk/dw.c --- a/gtk/dw.c Tue Jan 03 15:59:00 2012 +0000 +++ b/gtk/dw.c Thu Jan 05 15:45:11 2012 +0000 @@ -2214,7 +2214,7 @@ /* * Runs a message loop for Dynamic Windows. */ -void dw_main(void) +void API dw_main(void) { gdk_threads_enter(); _dw_thread = pthread_self(); @@ -2224,11 +2224,19 @@ } /* + * Causes running dw_main() to return. + */ +void API dw_main_quit(void) +{ + gtk_main_quit(); +} + +/* * Runs a message loop for Dynamic Windows, for a period of milliseconds. * Parameters: * milliseconds: Number of milliseconds to run the loop for. */ -void dw_main_sleep(int milliseconds) +void API dw_main_sleep(int milliseconds) { struct timeval tv, start; pthread_t curr = pthread_self(); @@ -2278,7 +2286,7 @@ /* * Processes a single message iteration and returns. */ -void dw_main_iteration(void) +void API dw_main_iteration(void) { pthread_t orig = _dw_thread; pthread_t curr = pthread_self(); diff -r 9bab702bd6c1 -r 5facb5380944 gtk3/dw.c --- a/gtk3/dw.c Tue Jan 03 15:59:00 2012 +0000 +++ b/gtk3/dw.c Thu Jan 05 15:45:11 2012 +0000 @@ -1857,7 +1857,7 @@ /* * Runs a message loop for Dynamic Windows. */ -void dw_main(void) +void API dw_main(void) { gdk_threads_enter(); _dw_thread = pthread_self(); @@ -1867,11 +1867,19 @@ } /* + * Causes running dw_main() to return. + */ +void API dw_main_quit(void) +{ + gtk_main_quit(); +} + +/* * Runs a message loop for Dynamic Windows, for a period of milliseconds. * Parameters: * milliseconds: Number of milliseconds to run the loop for. */ -void dw_main_sleep(int milliseconds) +void API dw_main_sleep(int milliseconds) { struct timeval tv, start; pthread_t curr = pthread_self(); @@ -1921,7 +1929,7 @@ /* * Processes a single message iteration and returns. */ -void dw_main_iteration(void) +void API dw_main_iteration(void) { pthread_t orig = _dw_thread; pthread_t curr = pthread_self(); diff -r 9bab702bd6c1 -r 5facb5380944 mac/dw.m --- a/mac/dw.m Tue Jan 03 15:59:00 2012 +0000 +++ b/mac/dw.m Thu Jan 05 15:45:11 2012 +0000 @@ -2816,6 +2816,14 @@ } /* + * Causes running dw_main() to return. + */ +void API dw_main_quit(void) +{ + [DWApp stop]; +} + +/* * Runs a message loop for Dynamic Windows, for a period of milliseconds. * Parameters: * milliseconds: Number of milliseconds to run the loop for. diff -r 9bab702bd6c1 -r 5facb5380944 os2/dw.c --- a/os2/dw.c Tue Jan 03 15:59:00 2012 +0000 +++ b/os2/dw.c Thu Jan 05 15:45:11 2012 +0000 @@ -4015,6 +4015,8 @@ return rc; } +static int _dw_main_running = FALSE; + /* * Runs a message loop for Dynamic Windows. */ @@ -4026,15 +4028,24 @@ /* Make sure any queued redraws are handled */ _dw_redraw(0, FALSE); - while(WinGetMsg(dwhab, &qmsg, 0, 0, 0)) + /* Set the running flag to TRUE */ + _dw_main_running = TRUE; + + /* Run the loop until the flag is unset... or error */ + while(_dw_main_running && WinGetMsg(dwhab, &qmsg, 0, 0, 0)) { if(qmsg.msg == WM_TIMER && qmsg.hwnd == NULLHANDLE) _run_event(qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2); WinDispatchMsg(dwhab, &qmsg); } - - WinDestroyMsgQueue(dwhmq); - WinTerminate(dwhab); +} + +/* + * Causes running dw_main() to return. + */ +void API dw_main_quit(void) +{ + _dw_main_running = FALSE; } /* @@ -10521,7 +10532,16 @@ */ Root = NULL; + /* Destroy the main message queue and anchor block */ + WinDestroyMsgQueue(dwhmq); + WinTerminate(dwhab); + + /* Free any in use modules */ DosFreeModule(wpconfig); + DosFreeModule(pmprintf); + DosFreeModule(pmmerge); + + /* And finally exit */ exit(exitcode); } diff -r 9bab702bd6c1 -r 5facb5380944 os2/dw.def --- a/os2/dw.def Tue Jan 03 15:59:00 2012 +0000 +++ b/os2/dw.def Thu Jan 05 15:45:11 2012 +0000 @@ -25,6 +25,7 @@ dw_main_sleep @23 dw_main_iteration @24 dw_app_dir @25 + dw_main_quit @26 dw_box_new @40 dw_groupbox_new @41 diff -r 9bab702bd6c1 -r 5facb5380944 os2/dw.lnk --- a/os2/dw.lnk Tue Jan 03 15:59:00 2012 +0000 +++ b/os2/dw.lnk Thu Jan 05 15:45:11 2012 +0000 @@ -18,6 +18,7 @@ export dw_main_sleep.23 export dw_main_iteration.24 export dw_app_dir.25 +export dw_main_quit.26 export dw_box_new.40 export dw_groupbox_new.41 diff -r 9bab702bd6c1 -r 5facb5380944 readme --- a/readme Tue Jan 03 15:59:00 2012 +0000 +++ b/readme Thu Jan 05 15:45:11 2012 +0000 @@ -52,6 +52,7 @@ Added auto-positioning on Mac; reimplemented auto-positioning on OS/2. Added DW_DRAW_NOAA which can be passed to dw_draw_*() API functions that accept the flags parameter to disable anti-aliasing. +Added dw_main_quit() to cause the dw_main() message loop to return. Fixed auto-sizing top-level windows on Windows; added on OS/2 and Mac. Fixed bubble help not being displayed on Windows. Fixed menu bar items remaining highlighted on Mac. diff -r 9bab702bd6c1 -r 5facb5380944 win/dw-mingw.def --- a/win/dw-mingw.def Tue Jan 03 15:59:00 2012 +0000 +++ b/win/dw-mingw.def Thu Jan 05 15:45:11 2012 +0000 @@ -22,6 +22,7 @@ dw_main_sleep @23 dw_main_iteration @24 dw_app_dir @25 + dw_main_quit @26 dw_box_new @40 dw_groupbox_new @41 diff -r 9bab702bd6c1 -r 5facb5380944 win/dw.c --- a/win/dw.c Tue Jan 03 15:59:00 2012 +0000 +++ b/win/dw.c Thu Jan 05 15:45:11 2012 +0000 @@ -109,6 +109,7 @@ HRESULT (WINAPI *_DwmIsCompositionEnabled)(BOOL *pfEnabled) = 0; BOOL _dw_composition = FALSE; COLORREF _dw_transparencykey = RGB(200,201,202); +HANDLE hdwm = 0; #endif /* @@ -419,7 +420,7 @@ /* Section for loading files of types besides BMP and ICO and return HBITMAP or HICON */ void *_dw_load_gpbitmap( char *filename ) { - int found_ext = 0,i, wclen = (strlen(filename) + 6) * sizeof(wchar_t); + int i, wclen = (strlen(filename) + 6) * sizeof(wchar_t); char *file = _alloca(strlen(filename) + 6); wchar_t *wfile = _alloca(wclen); void *image; @@ -3520,9 +3521,6 @@ #ifdef GDIPLUS struct GdiplusStartupInput si; #endif -#ifdef AEROGLASS - HANDLE hdwm; -#endif /* Setup the private data directory */ if(argc > 0 && argv[0]) @@ -3709,6 +3707,8 @@ return 0; } +static int _dw_main_running = FALSE; + /* * Runs a message loop for Dynamic Windows. */ @@ -3720,7 +3720,11 @@ /* Make sure any queued redraws are handled */ _dw_redraw(0, FALSE); - while(GetMessage(&msg, NULL, 0, 0)) + /* Set the running flag to TRUE */ + _dw_main_running = TRUE; + + /* Run the loop until the flag is unset... or error */ + while(_dw_main_running && GetMessage(&msg, NULL, 0, 0)) { if(msg.hwnd == NULL && msg.message == WM_TIMER) _wndproc(msg.hwnd, msg.message, msg.wParam, msg.lParam); @@ -3733,6 +3737,14 @@ } /* + * Causes running dw_main() to return. + */ +void API dw_main_quit(void) +{ + _dw_main_running = FALSE; +} + +/* * Runs a message loop for Dynamic Windows, for a period of milliseconds. * Parameters: * milliseconds: Number of milliseconds to run the loop for. @@ -10274,6 +10286,10 @@ void API dw_exit(int exitcode) { OleUninitialize(); +#ifdef AEROGLASS + /* Free any in use libraries */ + FreeLibrary(hdwm); +#endif exit(exitcode); } diff -r 9bab702bd6c1 -r 5facb5380944 win/dw.def --- a/win/dw.def Tue Jan 03 15:59:00 2012 +0000 +++ b/win/dw.def Thu Jan 05 15:45:11 2012 +0000 @@ -22,6 +22,7 @@ dw_main_sleep @23 dw_main_iteration @24 dw_app_dir @25 + dw_main_quit @26 dw_box_new @40 dw_groupbox_new @41