changeset 1799:165f6ffa8176

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.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 27 Sep 2012 03:08:03 +0000
parents 9fb8339ae458
children 68e37fee2b05
files win/dw.c
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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