Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-58
[bpt/emacs.git] / src / w32fns.c
index 1bb23cf..4da5271 100644 (file)
@@ -2695,6 +2695,24 @@ w32_msg_worker (dw)
   return 0;
 }
 
+static void
+signal_user_input ()
+{
+  /* Interrupt any lisp that wants to be interrupted by input.  */
+  if (!NILP (Vthrow_on_input))
+    {
+      Vquit_flag = Vthrow_on_input;
+      /* If we're inside a function that wants immediate quits,
+        do it now.  */
+      if (immediate_quit && NILP (Vinhibit_quit))
+       {
+         immediate_quit = 0;
+         QUIT;
+       }
+    }
+}
+
+
 static void
 post_character_message (hwnd, msg, wParam, lParam, modifiers)
      HWND hwnd;
@@ -2752,6 +2770,8 @@ post_character_message (hwnd, msg, wParam, lParam, modifiers)
           to receive C-g to interrupt the lisp thread.  */
        cancel_all_deferred_msgs ();
       }
+    else
+      signal_user_input ();
   }
 
   my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
@@ -3171,6 +3191,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
              }
            wmsg.dwModifiers = w32_get_modifiers ();
            my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
+           signal_user_input ();
 
            /* Clear message buffer. */
            saved_mouse_button_msg.msg.hwnd = 0;
@@ -3228,6 +3249,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
          }
        wmsg.dwModifiers = w32_get_modifiers ();
        my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
+       signal_user_input ();
 
        /* Always clear message buffer and cancel timer. */
        saved_mouse_button_msg.msg.hwnd = 0;
@@ -3251,6 +3273,11 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
        BOOL up;
        int button;
 
+       /* Ignore middle and extra buttons as long as the menu is active.  */
+       f = x_window_to_frame (dpyinfo, hwnd);
+       if (f && f->output_data.w32->menubar_active)
+         return 0;
+
        if (parse_button (msg, HIWORD (wParam), &button, &up))
          {
            if (up) ReleaseCapture ();
@@ -3266,12 +3293,21 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
 
       wmsg.dwModifiers = w32_get_modifiers ();
       my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
+      signal_user_input ();
 
       /* Need to return true for XBUTTON messages, false for others,
          to indicate that we processed the message.  */
       return (msg == WM_XBUTTONDOWN || msg == WM_XBUTTONUP);
 
     case WM_MOUSEMOVE:
+      /* Ignore mouse movements as long as the menu is active.  These
+        movements are processed by the window manager anyway, and
+        it's wrong to handle them as if they happened on the
+        underlying frame.  */
+      f = x_window_to_frame (dpyinfo, hwnd);
+      if (f && f->output_data.w32->menubar_active)
+       return 0;
+
       /* If the mouse has just moved into the frame, start tracking
         it, so we will be notified when it leaves the frame.  Mouse
         tracking only works under W98 and NT4 and later. On earlier
@@ -3320,11 +3356,13 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
     case WM_MOUSEWHEEL:
       wmsg.dwModifiers = w32_get_modifiers ();
       my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
+      signal_user_input ();
       return 0;
 
     case WM_DROPFILES:
       wmsg.dwModifiers = w32_get_modifiers ();
       my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
+      signal_user_input ();
       return 0;
 
     case WM_TIMER:
@@ -3334,6 +3372,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
          if (saved_mouse_button_msg.msg.hwnd)
            {
              post_msg (&saved_mouse_button_msg);
+             signal_user_input ();
              saved_mouse_button_msg.msg.hwnd = 0;
            }
          KillTimer (hwnd, mouse_button_timer);
@@ -3836,6 +3875,7 @@ w32_wnd_proc (hwnd, msg, wParam, lParam)
        {
          wmsg.dwModifiers = w32_get_modifiers ();
          my_post_msg (&wmsg, hwnd, msg, wParam, lParam);
+         signal_user_input ();
          return 0;
        }
 
@@ -4340,17 +4380,6 @@ This function is an internal primitive--use `make-frame' instead.  */)
   x_wm_set_size_hint (f, window_prompting, 0);
   UNBLOCK_INPUT;
 
-  /* Avoid a bug that causes the new frame to never become visible if
-     an echo area message is displayed during the following call1.  */
-  specbind(Qredisplay_dont_pause, Qt);
-
-  /* Set up faces after all frame parameters are known.  This call
-     also merges in face attributes specified for new frames.  If we
-     don't do this, the `menu' face for instance won't have the right
-     colors, and the menu bar won't appear in the specified colors for
-     new frames.  */
-  call1 (Qface_set_after_frame_default, frame);
-
   /* Make the window appear on the frame and enable display, unless
      the caller says not to.  However, with explicit parent, Emacs
      cannot control visibility, so don't try.  */
@@ -7711,9 +7740,12 @@ Text larger than the specified size is clipped.  */)
     AdjustWindowRect (&rect, f->output_data.w32->dwStyle,
                      FRAME_EXTERNAL_MENU_BAR (f));
 
-    /* Position and size tooltip, and put it in the topmost group.  */
+    /* Position and size tooltip, and put it in the topmost group.
+       The add-on of 3 to the 5th argument is a kludge: without it,
+       some fonts cause the last character of the tip to be truncated,
+       for some obscure reason.  */
     SetWindowPos (FRAME_W32_WINDOW (f), HWND_TOPMOST,
-                 root_x, root_y, rect.right - rect.left,
+                 root_x, root_y, rect.right - rect.left + 3,
                  rect.bottom - rect.top, SWP_NOACTIVATE);
 
     /* Ensure tooltip is on top of other topmost windows (eg menus).  */
@@ -7980,8 +8012,12 @@ If ONLY-DIR-P is non-nil, the user can only select directories.  */)
  ***********************************************************************/
 
 DEFUN ("w32-select-font", Fw32_select_font, Sw32_select_font, 0, 2, 0,
-       doc: /* Select a font using the W32 font dialog.
-Returns an X font string corresponding to the selection.  */)
+       doc: /* Select a font for the named FRAME using the W32 font dialog.
+Returns an X-style font string corresponding to the selection.
+
+If FRAME is omitted or nil, it defaults to the selected frame.
+If INCLUDE-PROPORTIONAL is non-nil, include proportional fonts
+in the font selection dialog. */)
   (frame, include_proportional)
      Lisp_Object frame, include_proportional;
 {