Subject: Re: bug#11513: 24.1.50; raise-frame never raise the foreground window on Windows

From: Kazuhiro Ito <[email-masked]>
Date: Sat, 19 May 2012 21:02:21 +0900

> > When I start Emacs with -Q option nd evaluate the below code, I get
> > unexpected result.
> > 
> > (let ((frame (selected-frame)))
> >   (lower-frame frame)
> >   ;; If we change the foreground window while sleeping, raise-frame
> >   ;; correctly works.
> >   (sleep-for 5)
> >   (raise-frame frame))
> > 
> > Result: raise-frame never raise the frame if the selected frame is the
> > foreground window.
> 
> I cannot reproduce this on my Windows XP system.  When I evaluate the
> above, the Emacs frame is correctly lowered (i.e. goes behind the
> other window(s)), and then is brought into the foreground several
> seconds later.

The problem also occurs with pre-compiled pretest binary (*1) on
Windows XP and Windows 7 (Professional, x64) system.  In my
environment, when I evaluate the above code, Emacs frame is correctly
lowered too, but is not brought into the foreground.  Emacs frame
keeps behind the other application window(s).

(*1) http://alpha.gnu.org/gnu/emacs/pretest/windows/emacs-24.0.97-bin-i386.zip

> > If other frame or application is the foreground window, raise-frame
> > works as expected.
>
> What exactly do you mean by "If other frame or application is the
> foreground window"?

If I change foreground application from Emacs to other application via
ALT + TAB or mouse click while Emacs runs sleep-for function in the
above code, Emacs frame is brought into the foreground several seconds
later.  that is the expected result.

> So please specify more precisely the conditions for reproducing this
> problem, in terms of what other windows should or should not be
> present on the display before evaluating the recipe code.  Perhaps the
> recipe lacks some specific mouse gestures to achieve the required
> effect?

1. Launch other Windows application (e.g. explorer, Command Prompt).
2. Start Emacs with -Q option.
3. Move Emacs frame to make it to overlap other application window(s)
 with mouse drag.
4. Yank the below code into *scratch* buffer.

(let ((frame (selected-frame)))
  (lower-frame frame)
  (sleep-for 5)
  (raise-frame frame))

5. Evaluate it with C-j.
6. Keep away from keyboard and mouse until Emacs finishes evaluation.

Result: Emacs frame is behind other application window(s).

Expected result: Emacs frame is in front of other application
window(s).

> Also, please provide the details normally collected by
> "M-x report-emacs-bug RET".

Here is the details with pretest binary.

This bug report will be sent to the Bug-GNU-Emacs mailing list
and the GNU bug tracker at debbugs.gnu.org.  Please check that
the From: line contains a valid email address.  After a delay of up
to one day, you should receive an acknowledgement at that address.

Please write in English if possible, as the Emacs maintainers
usually do not have translators for other languages.

Please describe exactly what actions triggered the bug, and
the precise symptoms of the bug.  If you can, give a recipe
starting from `emacs -Q':

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    `bt full' and `xbacktrace'.
For information about debugging Emacs, please read the file
f:/emacs-24.0.97/etc/DEBUG.

In GNU Emacs 24.0.97.1 (i386-mingw-nt6.1.7601)
 of 2012-05-17 on MARVIN
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --with-gcc (4.6) --no-opt --enable-checking --cflags
 -ID:/devel/emacs/libs/libXpm-3.5.8/include
 -ID:/devel/emacs/libs/libXpm-3.5.8/src
 -ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include
 -ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include
 -ID:/devel/emacs/libs/giflib-4.1.4-1/include
 -ID:/devel/emacs/libs/jpeg-6b-4/include
 -ID:/devel/emacs/libs/tiff-3.8.2-1/include
 -ID:/devel/emacs/libs/gnutls-3.0.9/include'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: JPN
  value of $XMODIFIERS: nil
  locale-coding-system: cp932
  default enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<language-change> C-y C-j <escape> x r e p o r t <
return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Mark set

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail regexp-opt rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils time-date japan-util tooltip
ediff-hook vc-hooks lisp-float-type mwheel dos-w32 disp-table ls-lisp
w32-win w32-vars tool-bar dnd fontset image fringe lisp-mode register
page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core frame cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew
greek romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs
button faces cus-face files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process multi-tty emacs)

-- 
Kazuhiro Ito