changeset 15650:bc9525478463

(win32_wnd_proc): Handle WM_ERASEBKGND and WM_PALETTECHANGED messages inline (as they should be).
author Karl Heuer <kwzh@gnu.org>
date Fri, 12 Jul 1996 00:25:27 +0000
parents 3ee2f3ce0a07
children b055a4ec9351
files src/w32fns.c
diffstat 1 files changed, 27 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/w32fns.c	Fri Jul 12 00:22:51 1996 +0000
+++ b/src/w32fns.c	Fri Jul 12 00:25:27 1996 +0000
@@ -2932,25 +2932,41 @@
   Win32Msg wmsg;
   int windows_translate;
 
+  /* Note that it is okay to call x_window_to_frame, even though we are
+     not running in the main lisp thread, because frame deletion
+     requires the lisp thread to synchronize with this thread.  Thus, if
+     a frame struct is returned, it can be used without concern that the
+     lisp thread might make it disappear while we are using it.
+
+     NB. Walking the frame list in this thread is safe (as long as
+     writes of Lisp_Object slots are atomic, which they are on Windows).
+     Although delete-frame can destructively modify the frame list while
+     we are walking it, a garbage collection cannot occur until after
+     delete-frame has synchronized with this thread.
+
+     It is also safe to use functions that make GDI calls, such as
+     win32_clear_rect, because these functions must obtain a DC handle
+     from the frame struct using get_frame_dc which is thread-aware.  */
+
   switch (msg) 
     {
     case WM_ERASEBKGND:
-      /* This is (always?) generated by BeginPaint, so there is no gain
-	 in forwarding this message to the main thread - it can simply
-	 erase the background before repainting. */
-#if 0
-      enter_crit ();
-      GetUpdateRect (hwnd, &wmsg.rect, FALSE);
-      leave_crit ();
-      my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
-#endif
+      f = x_window_to_frame (dpyinfo, hwnd);
+      if (f)
+	{
+	  GetUpdateRect (hwnd, &wmsg.rect, FALSE);
+	  win32_clear_rect (f, NULL, &wmsg.rect);
+	}
       return 1;
     case WM_PALETTECHANGED:
       /* ignore our own changes */
       if ((HWND)wParam != hwnd)
         {
-	  /* simply notify main thread it may need to update frames */
-	  my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
+	  f = x_window_to_frame (dpyinfo, hwnd);
+	  if (f)
+	    /* get_frame_dc will realize our palette and force all
+	       frames to be redrawn if needed. */
+	    release_frame_dc (f, get_frame_dc (f));
 	}
       return 0;
     case WM_PAINT: