[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

raise-frame sends lowers another Windows app's frame

From: Drew Adams
Subject: raise-frame sends lowers another Windows app's frame
Date: Mon, 7 Aug 2006 17:52:58 -0700

I do this:

(define-key special-event-map [iconify-frame] 'foo), where foo does
`select-frame-set-input-focus' and `raise-frame' (after doing some other

I can then click the minimize window-manager button on an Emacs frame to
call `foo' to do some stuff, including raise that frame to the front and
give it the input selection.

A problem arises if Emacs is not the foreground Windows app. In that case,
clicking the minimize button of an Emacs frame raises that frame and gives
it focus (good), but it also sends the Windows app that was in the
foreground to the bottom of the window (frame) stack; that is, it lowers
that app all the way to the bottom.

Since that Window app was the foreground app, it is now the last-used app,
before Emacs, and it is probably also the app I want to use next, after
Emacs. I don't want it to move to the bottom of the stack; I just want the
Emacs frame to rise to the top. All other app windows remain in stack order,
BTW: it is just the foreground app that is moved (to the bottom).

To me, this seems like an Emacs bug, but I'm not sure where it happens or
how it could be fixed. I came across the code and comment below (in
w32term.c), which might be pertinent (but I'm no C expert, so I can't tell).
Can someone advise whether this is a bug that could be fixed, or else
provide a workaround? Thx.

The only alternative I can see is to not let `foo' raise the Emacs frame,
which just moves it behind other apps (because `foo' also changes the frame
position), making it inaccessible. In that case, I then need to use the task
bar to bring the Emacs frame to the front. That is what I've been doing, as
an alternative to moving the foreground app to the bottom of the stack.

x_raise_frame (f)
     struct frame *f;
  /* ... */
  if (NILP (Vw32_grab_focus_on_raise))
      /* The obvious call to my_set_window_pos doesn't work if Emacs is
         not already the foreground application: the frame is raised
         above all other frames belonging to us, but not above the
         current top window.  To achieve that, we have to resort to this
         more cumbersome method.  */

      HDWP handle = BeginDeferWindowPos (2);
      if (handle)
          DeferWindowPos (handle,
                          FRAME_W32_WINDOW (f),
                          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);
      my_set_foreground_window (FRAME_W32_WINDOW (f));


reply via email to

[Prev in Thread] Current Thread [Next in Thread]