From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: raise-frame sends lowers another Windows app's frame Date: Mon, 7 Aug 2006 17:52:58 -0700 Message-ID: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1154998417 25133 80.91.229.2 (8 Aug 2006 00:53:37 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 8 Aug 2006 00:53:37 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 08 02:53:35 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GAFqa-0007s0-Ab for ged-emacs-devel@m.gmane.org; Tue, 08 Aug 2006 02:53:28 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GAFqZ-0002vl-UD for ged-emacs-devel@m.gmane.org; Mon, 07 Aug 2006 20:53:27 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GAFqP-0002vS-7L for emacs-devel@gnu.org; Mon, 07 Aug 2006 20:53:17 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GAFqN-0002v0-1M for emacs-devel@gnu.org; Mon, 07 Aug 2006 20:53:16 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GAFqM-0002uw-Rp for emacs-devel@gnu.org; Mon, 07 Aug 2006 20:53:14 -0400 Original-Received: from [148.87.113.118] (helo=rgminet01.oracle.com) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.52) id 1GAFui-0002o9-Co for emacs-devel@gnu.org; Mon, 07 Aug 2006 20:57:44 -0400 Original-Received: from rcsmt251.oracle.com (rcsmt251.oracle.com [148.87.90.196]) by rgminet01.oracle.com (Switch-3.1.6/Switch-3.1.6) with ESMTP id k773LSkm030616 for ; Mon, 7 Aug 2006 18:53:10 -0600 Original-Received: from dhcp-amer-csvpn-gw1-141-144-65-230.vpn.oracle.com by rcsmt250.oracle.com with ESMTP id 1720970441154998380; Mon, 07 Aug 2006 18:53:00 -0600 Original-To: "Emacs-Devel" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 X-Whitelist: TRUE X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:58168 Archived-At: 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; }