+ case WM_ACTIVATE:
+ {
+ /*
+ * If we receive a WM_ACTIVATE message that indicates that our frame
+ * is being activated, make sure that the frame is marked visible
+ * if the window itself is visible. This seems to fix the problem
+ * where XEmacs appears to lock-up after switching desktops with
+ * some virtual window managers.
+ */
+ int state = (int)(short) LOWORD(wParam);
+#ifdef DEBUG_XEMACS
+ if (debug_mswindows_events)
+ stderr_out("state = %d\n", state);
+#endif /* DEBUG_XEMACS */
+ if (state == WA_ACTIVE || state == WA_CLICKACTIVE)
+ {
+#ifdef DEBUG_XEMACS
+ if (debug_mswindows_events)
+ stderr_out(" activating\n");
+#endif /* DEBUG_XEMACS */
+
+ fobj = mswindows_find_frame (hwnd);
+ frame = XFRAME (fobj);
+ if (IsWindowVisible (hwnd))
+ {
+#ifdef DEBUG_XEMACS
+ if (debug_mswindows_events)
+ stderr_out(" window is visible\n");
+#endif /* DEBUG_XEMACS */
+ if (!FRAME_VISIBLE_P (frame))
+ {
+#ifdef DEBUG_XEMACS
+ if (debug_mswindows_events)
+ stderr_out(" frame is not visible\n");
+#endif /* DEBUG_XEMACS */
+ /*
+ * It seems that we have to enqueue the XM_MAPFRAME event
+ * prior to setting the frame visible so that
+ * suspend-or-iconify-emacs works properly.
+ */
+ mswindows_enqueue_magic_event (hwnd, XM_MAPFRAME);
+ FRAME_VISIBLE_P (frame) = 1;
+ FRAME_ICONIFIED_P (frame) = 0;
+ }
+#ifdef DEBUG_XEMACS
+ else
+ {
+ if (debug_mswindows_events)
+ stderr_out(" frame is visible\n");
+ }
+#endif /* DEBUG_XEMACS */
+ }
+#ifdef DEBUG_XEMACS
+ else
+ {
+ if (debug_mswindows_events)
+ stderr_out(" window is not visible\n");
+ }
+#endif /* DEBUG_XEMACS */
+ }
+ return DefWindowProc (hwnd, message_, wParam, lParam);
+ }
+ break;
+