unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* raise-frame sends lowers another Windows app's frame
@ 2006-08-08  0:52 Drew Adams
  2006-08-08  8:35 ` Jason Rumney
  0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2006-08-08  0:52 UTC (permalink / raw)


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
things).

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;
{
  BLOCK_INPUT;
  /* ... */
  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),
  			  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);
	}
    }
  else
    {
      my_set_foreground_window (FRAME_W32_WINDOW (f));
    }

  UNBLOCK_INPUT;
}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: raise-frame sends lowers another Windows app's frame
  2006-08-08  0:52 raise-frame sends lowers another Windows app's frame Drew Adams
@ 2006-08-08  8:35 ` Jason Rumney
  2006-08-08 14:00   ` Drew Adams
  2006-08-12 12:20   ` Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Jason Rumney @ 2006-08-08  8:35 UTC (permalink / raw)
  Cc: Emacs-Devel

Drew Adams wrote:
>       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);
> 	}
>   

Does it make a difference if you replace the above code with:

      HDWP handle = BeginDeferWindowPos (2);
      if (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);
	}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: raise-frame sends lowers another Windows app's frame
  2006-08-08  8:35 ` Jason Rumney
@ 2006-08-08 14:00   ` Drew Adams
  2006-08-12 12:20   ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Drew Adams @ 2006-08-08 14:00 UTC (permalink / raw)
  Cc: Emacs-Devel

    >       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);
    > 	}

    Does it make a difference if you replace the above code with:
    ...

I don't know. I can't build Emacs here. When I can get a binary I will
check. Thx.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: raise-frame sends lowers another Windows app's frame
  2006-08-08  8:35 ` Jason Rumney
  2006-08-08 14:00   ` Drew Adams
@ 2006-08-12 12:20   ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Eli Zaretskii @ 2006-08-12 12:20 UTC (permalink / raw)
  Cc: drew.adams, emacs-devel

> Date: Tue, 08 Aug 2006 09:35:00 +0100
> From: Jason Rumney <jasonr@gnu.org>
> Cc: Emacs-Devel <emacs-devel@gnu.org>
> 
> Does it make a difference if you replace the above code with:
> 
>       HDWP handle = BeginDeferWindowPos (2);
>       if (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);
> 	}

This change wasn't committed.  Drew, can you post a simple test case
to reproduce the problem?  Then I could try it before and after the
change, and see if Jason's suggestion helps.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-08-12 12:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-08  0:52 raise-frame sends lowers another Windows app's frame Drew Adams
2006-08-08  8:35 ` Jason Rumney
2006-08-08 14:00   ` Drew Adams
2006-08-12 12:20   ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).