all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Subject: raise-frame sends lowers another Windows app's frame
Date: Mon, 7 Aug 2006 17:52:58 -0700	[thread overview]
Message-ID: <MEEKKIABFKKDFJMPIOEBAEONDDAA.drew.adams@oracle.com> (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;
}

             reply	other threads:[~2006-08-08  0:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-08  0:52 Drew Adams [this message]
2006-08-08  8:35 ` raise-frame sends lowers another Windows app's frame Jason Rumney
2006-08-08 14:00   ` Drew Adams
2006-08-12 12:20   ` Eli Zaretskii

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=MEEKKIABFKKDFJMPIOEBAEONDDAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    /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.