# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1348715283 0 # Node ID 165f6ffa8176c5697201fdd357a75a9ac96dad45 # Parent 9fb8339ae458d9c6fec16b9618c72c0d34eb115e Attempted fix at dw_window_set_focus() from non-main threads on Windows. Also change to allow dw_window_function() to be called on non-toplevel windows. diff -r 9fb8339ae458 -r 165f6ffa8176 win/dw.c --- a/win/dw.c Wed Sep 26 06:19:06 2012 +0000 +++ b/win/dw.c Thu Sep 27 03:08:03 2012 +0000 @@ -11595,6 +11595,12 @@ } } +/* Internal function to set the focus from the window thread */ +void _dw_set_focus(HWND handle) +{ + SetFocus(handle); +} + /* * Sets the current focus item for a window/dialog. * Parameters: @@ -11604,7 +11610,10 @@ */ void API dw_window_set_focus(HWND handle) { - SetFocus(handle); + if(_dwtid == (DWTID)-1) + SetFocus(handle); + else + dw_window_function(handle, (void *)_dw_set_focus, handle); } /* @@ -12161,7 +12170,7 @@ */ void API dw_window_function(HWND handle, void *function, void *data) { - SendMessage(handle, WM_USER, (WPARAM)function, (LPARAM)data); + SendMessage(_toplevel_window(handle), WM_USER, (WPARAM)function, (LPARAM)data); } /* Functions for managing the user data lists that are associated with