]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix bug #11513 with raise-frame on MS-Windows.
authorEli Zaretskii <eliz@gnu.org>
Mon, 28 May 2012 17:22:40 +0000 (20:22 +0300)
committerEli Zaretskii <eliz@gnu.org>
Mon, 28 May 2012 17:22:40 +0000 (20:22 +0300)
 src/w32term.c (my_bring_window_to_top): New function.
 (x_raise_frame): Use handle returned by DeferWindowPos, which
 could be different from the original one.  Call
 my_bring_window_to_top instead of my_set_foreground_window.
 src/w32fns.c (w32_wnd_proc): Accept and process WM_EMACS_BRINGTOTOP
 by calling BringWindowToTop.
 src/w32term.h (WM_EMACS_BRINGTOTOP): New message.
 (WM_EMACS_END): Increase by one.

src/ChangeLog
src/w32fns.c
src/w32term.c
src/w32term.h

index f4447da7010704a48cd2e64c179e82162d97b0b9..374da4692034501dc54a9596035ec86d3df85739 100644 (file)
@@ -1,3 +1,17 @@
+2012-05-28  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32term.c (my_bring_window_to_top): New function.
+       (x_raise_frame): Use handle returned by DeferWindowPos, which
+       could be different from the original one.  Call
+       my_bring_window_to_top instead of my_set_foreground_window.
+       (Bug#11513)
+
+       * w32fns.c (w32_wnd_proc): Accept and process WM_EMACS_BRINGTOTOP
+       by calling BringWindowToTop.
+
+       * w32term.h (WM_EMACS_BRINGTOTOP): New message.
+       (WM_EMACS_END): Increase by one.
+
 2012-05-28  Paul Eggert  <eggert@cs.ucla.edu>
 
        * bidi.c (bidi_mirror_char): Put eassert before conversion to int.
index d7114f19b900a56abe17dd7f94be1f8e70424ca0..b8dc62f52503ad89afbd8108b755da58296e34bf 100644 (file)
@@ -3663,6 +3663,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
     case WM_EMACS_SHOWWINDOW:
       return ShowWindow ((HWND) wParam, (WPARAM) lParam);
 
+    case WM_EMACS_BRINGTOTOP:
     case WM_EMACS_SETFOREGROUND:
       {
         HWND foreground_window;
@@ -3680,6 +3681,8 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
           foreground_thread = 0;
 
         retval = SetForegroundWindow ((HWND) wParam);
+        if (msg == WM_EMACS_BRINGTOTOP)
+          retval = BringWindowToTop ((HWND) wParam);
 
         /* Detach from the previous foreground thread.  */
         if (foreground_thread)
index 2ccd75743324ca5c425c5428a6597e705c38b19e..a90e067a3fdc5e89559b984c2e16d39738d463dd 100644 (file)
@@ -3492,6 +3492,12 @@ my_destroy_window (struct frame * f, HWND hwnd)
               (WPARAM) hwnd, 0);
 }
 
+static void
+my_bring_window_to_top (HWND hwnd)
+{
+  SendMessage (hwnd, WM_EMACS_BRINGTOTOP, (WPARAM) hwnd, 0);
+}
+
 /* Create a scroll bar and return the scroll bar vector for it.  W is
    the Emacs window on which to create the scroll bar. TOP, LEFT,
    WIDTH and HEIGHT are the pixel coordinates and dimensions of the
@@ -5600,24 +5606,27 @@ x_raise_frame (struct frame *f)
       HDWP handle = BeginDeferWindowPos (2);
       if (handle)
        {
-         DeferWindowPos (handle,
-                         FRAME_W32_WINDOW (f),
-                         HWND_TOP,
-                         0, 0, 0, 0,
-                         SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
-
-         DeferWindowPos (handle,
-                         GetForegroundWindow (),
-                         FRAME_W32_WINDOW (f),
-                         0, 0, 0, 0,
-                         SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
-
-         EndDeferWindowPos (handle);
+         handle = DeferWindowPos (handle,
+                                  FRAME_W32_WINDOW (f),
+                                  HWND_TOP,
+                                  0, 0, 0, 0,
+                                  SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
+         if (handle)
+           {
+             handle = DeferWindowPos (handle,
+                                      GetForegroundWindow (),
+                                      FRAME_W32_WINDOW (f),
+                                      0, 0, 0, 0,
+                                      SWP_NOSIZE | SWP_NOMOVE |
+                                      SWP_NOACTIVATE);
+             if (handle)
+               EndDeferWindowPos (handle);
+           }
        }
     }
   else
     {
-      my_set_foreground_window (FRAME_W32_WINDOW (f));
+      my_bring_window_to_top (FRAME_W32_WINDOW (f));
     }
 
   UNBLOCK_INPUT;
index 4528bbd5c0a4448bfee13e9a6abad8d9c22a9b6d..68e62b241443bac827cfa49a527c6593a1e52448 100644 (file)
@@ -576,7 +576,8 @@ do { \
 #define WM_EMACS_HIDE_CARET            (WM_EMACS_START + 18)
 #define WM_EMACS_SETCURSOR             (WM_EMACS_START + 19)
 #define WM_EMACS_PAINT                 (WM_EMACS_START + 20)
-#define WM_EMACS_END                   (WM_EMACS_START + 21)
+#define WM_EMACS_BRINGTOTOP            (WM_EMACS_START + 21)
+#define WM_EMACS_END                   (WM_EMACS_START + 22)
 
 #define WND_FONTWIDTH_INDEX    (0)
 #define WND_LINEHEIGHT_INDEX   (4)