From a60856373a7a651fa860462891c3282fec80ad76 Mon Sep 17 00:00:00 2001 From: Karl Heuer Date: Fri, 12 Jul 1996 00:25:27 +0000 Subject: [PATCH] (win32_wnd_proc): Handle WM_ERASEBKGND and WM_PALETTECHANGED messages inline (as they should be). --- src/w32fns.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/src/w32fns.c b/src/w32fns.c index 29ce4c70cd5..741b6c4da67 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -2932,25 +2932,41 @@ win32_wnd_proc (hwnd, msg, wParam, lParam) 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: -- 2.39.2