From: Eli Zaretskii <eliz@gnu.org>
To: Kazuhiro Ito <kzhr@d1.dion.ne.jp>
Cc: 11513-done@debbugs.gnu.org
Subject: bug#11513: 24.1.50; raise-frame never raise the foreground window on Windows
Date: Mon, 28 May 2012 20:28:13 +0300 [thread overview]
Message-ID: <83fwak1ahe.fsf@gnu.org> (raw)
In-Reply-To: <20120524060731.184722C037@msa104.auone-net.jp>
> Date: Thu, 24 May 2012 15:04:59 +0900
> From: Kazuhiro Ito <kzhr@d1.dion.ne.jp>
> Cc: rudalics@gmx.at, 11513@debbugs.gnu.org, drew.adams@oracle.com
>
> > > raise-frame always make the unexpected result when Emacs frame is
> > > the foreground window (I mean Emacs frame is colored as active window)
> > > and behind of other application window(s). And, as I described
> > > previously, If Emacs frame is not the foreground window raise-frame
> > > correctly works.
> >
> > But the default behavior on Windows is that a window that is lowered
> > loses its focus. You need to click into it to get focus there. So
> > how come a lowered window still has focus for you?
>
> When I run lower-frame function in Emacs frame interactively, Emacs
> frame is brought behind of other application window(s) but has focus.
> Key inputs are passed to lowered frame. I tested 4 Windows PC, and
> all PCs show the same behavior.
Sorry, I was confused. You are right, the focus isn't lost.
Anyway, I don't think it is a good idea to modify the reaction to the
WM_EMACS_SETFOREGROUND message, because it is also used by
x-focus-frame, which is not supposed to raise the frame to the top of
the Z-order, unless it is strictly necessary. And if the frame is
already a foreground frame, raising it isn't necessary.
So instead I introduced a new message, WM_EMACS_BRINGTOTOP, and used
that in raise-frame. The diffs are below (installed as revision
108409 on the trunk).
Thanks. I'm closing this bug report.
=== modified file 'src/ChangeLog'
--- src/ChangeLog 2012-05-28 07:13:45 +0000
+++ src/ChangeLog 2012-05-28 17:22:40 +0000
@@ -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.
=== modified file 'src/w32fns.c'
--- src/w32fns.c 2012-05-25 18:19:24 +0000
+++ src/w32fns.c 2012-05-28 17:22:40 +0000
@@ -3663,6 +3663,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARA
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, WPARA
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)
=== modified file 'src/w32term.c'
--- src/w32term.c 2012-05-18 08:36:50 +0000
+++ src/w32term.c 2012-05-28 17:22:40 +0000
@@ -3492,6 +3492,12 @@ my_destroy_window (struct frame * f, HWN
(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;
=== modified file 'src/w32term.h'
--- src/w32term.h 2012-01-19 07:21:25 +0000
+++ src/w32term.h 2012-05-28 17:22:40 +0000
@@ -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)
prev parent reply other threads:[~2012-05-28 17:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-18 21:06 bug#11513: 24.1.50; raise-frame never raise the foreground window on Windows Kazuhiro Ito
2012-05-19 8:02 ` Eli Zaretskii
2012-05-19 12:02 ` Kazuhiro Ito
2012-05-19 12:42 ` Eli Zaretskii
2012-05-19 12:56 ` martin rudalics
2012-05-19 13:47 ` Eli Zaretskii
2012-05-21 19:12 ` Eli Zaretskii
2012-05-23 10:48 ` Kazuhiro Ito
2012-05-23 16:20 ` Eli Zaretskii
2012-05-23 16:38 ` Drew Adams
2012-05-24 6:04 ` Kazuhiro Ito
2012-05-24 16:01 ` Lennart Borgman
2012-05-28 17:28 ` Eli Zaretskii [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83fwak1ahe.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=11513-done@debbugs.gnu.org \
--cc=kzhr@d1.dion.ne.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.