From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!.POSTED!not-for-mail
From: Eli Zaretskii <eliz@gnu.org>
Newsgroups: gmane.emacs.bugs
Subject: bug#11732: Follow-up to bug#11732
Date: Wed, 27 Jun 2018 18:54:04 +0300
Message-ID: <83y3f0p6n7.fsf@gnu.org>
References: <87obohkxga.fsf@XAVIER-PC.i-did-not-set--mail-host-address--so-tickle-me>
	<CAECZVPAXjLje9ED6fp1hJa4OPbBLd9nVsNMPB4xZ9njuDamF0Q@mail.gmail.com>
NNTP-Posting-Host: blaine.gmane.org
X-Trace: blaine.gmane.org 1530114790 22534 195.159.176.226 (27 Jun 2018 15:53:10 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 27 Jun 2018 15:53:10 +0000 (UTC)
Cc: 11732@debbugs.gnu.org
To: Masayuki Hatta <mhatta@gmail.com>, martin rudalics <rudalics@gmx.at>
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jun 27 17:53:05 2018
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org>
Envelope-to: geb-bug-gnu-emacs@m.gmane.org
Original-Received: from lists.gnu.org ([208.118.235.17])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org>)
	id 1fYCkj-0005lF-1E
	for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Jun 2018 17:53:05 +0200
Original-Received: from localhost ([::1]:60147 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org>)
	id 1fYCmq-00070i-7e
	for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Jun 2018 11:55:16 -0400
Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33491)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1fYCmg-00070H-A2
	for bug-gnu-emacs@gnu.org; Wed, 27 Jun 2018 11:55:07 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1fYCmc-0000Wg-DN
	for bug-gnu-emacs@gnu.org; Wed, 27 Jun 2018 11:55:06 -0400
Original-Received: from debbugs.gnu.org ([208.118.235.43]:58164)
	by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
	(Exim 4.71) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
	id 1fYCmc-0000WQ-9t
	for bug-gnu-emacs@gnu.org; Wed, 27 Jun 2018 11:55:02 -0400
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
	(envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1fYCmb-0002LP-SM
	for bug-gnu-emacs@gnu.org; Wed, 27 Jun 2018 11:55:01 -0400
X-Loop: help-debbugs@gnu.org
Resent-From: Eli Zaretskii <eliz@gnu.org>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Wed, 27 Jun 2018 15:55:01 +0000
Resent-Message-ID: <handler.11732.B11732.15301148558954@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 11732
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
Original-Received: via spool by 11732-submit@debbugs.gnu.org id=B11732.15301148558954
	(code B ref 11732); Wed, 27 Jun 2018 15:55:01 +0000
Original-Received: (at 11732) by debbugs.gnu.org; 27 Jun 2018 15:54:15 +0000
Original-Received: from localhost ([127.0.0.1]:37828 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
	id 1fYClq-0002KL-Mc
	for submit@debbugs.gnu.org; Wed, 27 Jun 2018 11:54:14 -0400
Original-Received: from eggs.gnu.org ([208.118.235.92]:41670)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <eliz@gnu.org>) id 1fYClm-0002K6-Li
	for 11732@debbugs.gnu.org; Wed, 27 Jun 2018 11:54:10 -0400
Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eliz@gnu.org>) id 1fYCld-0007lN-9P
	for 11732@debbugs.gnu.org; Wed, 27 Jun 2018 11:54:05 -0400
Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:50123)
	by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@gnu.org>)
	id 1fYClc-0007kc-W3; Wed, 27 Jun 2018 11:54:01 -0400
Original-Received: from [176.228.60.248] (port=4149 helo=home-c4e4a596f7)
	by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
	(Exim 4.82) (envelope-from <eliz@gnu.org>)
	id 1fYClc-0002CO-CX; Wed, 27 Jun 2018 11:54:00 -0400
In-reply-to: <CAECZVPAXjLje9ED6fp1hJa4OPbBLd9nVsNMPB4xZ9njuDamF0Q@mail.gmail.com>
	(message from Masayuki Hatta on Tue, 26 Jun 2018 18:10:26 +0900)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 208.118.235.43
X-BeenThere: bug-gnu-emacs@gnu.org
List-Id: "Bug reports for GNU Emacs,
	the Swiss army knife of text editors" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
	<mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-gnu-emacs/>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
	<mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org
Original-Sender: "bug-gnu-emacs"
	<bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org>
Xref: news.gmane.org gmane.emacs.bugs:147873
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/147873>

> From: Masayuki Hatta <mhatta@gmail.com>
> Date: Tue, 26 Jun 2018 18:10:26 +0900
> 
> Recently I built Emacs 26.1 on Windows 10 (w/ MSYS2 64bit) with the
> patch as mentioned earlier.  It works as expected and seems to bring
> no lousy side effects anymore.
> 
> This problem has been making Emacs on Windows almost unusable for
> Japanese users (so most of them use their patched binary).  Thus I
> appreciate if you apply the patch again.
> 
> Tested with "File -> Open File" dialog and "(w32-font-select)" dialog.
> Both seem to work.

By "work", do you mean that clicking on anywhere inside these dialogs
leaves the dialogs visible?  On 2 different systems where I tried
this, after applying the patch, clicking anywhere in the dialog box
after it opens causes the dialog box to disappear: it is moved in z
order behind the frame from which the dialog was started.

It's possible that this is somehow related to the fact that I have my
Windows systems configured to enable "active window tracking"
(a.k.a. "focus follows mouse"), but even so, I'd like to be able to
avoid that adverse side effect on systems that are so configured.

Martin, could you perhaps look into this?  I tried various
"solutions", and the best I could come up with is the patch below.  If
it looks right to you (I'm really out of my depth here), then how do
we solve a similar problem in x-select-font?  It doesn't have a
callback function, and if I try adding one, the appearance of the
dialog changes(??) and the OK and CANCEL buttons no longer work.

Also, w32_dialog_in_progress seems to try to solve some similar
problem, but is not really working?  I guess I simply don't understand
why the dialog is lowered when I click on it.

Here's the patch for file_dialog_callback I came up with:

--- src/w32fns.c~	2018-06-11 06:32:21.000000000 +0300
+++ src/w32fns.c	2018-06-27 18:22:27.104228200 +0300
@@ -7520,6 +7520,12 @@ file_dialog_callback (HWND hwnd, UINT ms
 	  HWND list = GetDlgItem (dialog, FILE_NAME_LIST);
 	  int hdr_code;
 
+	  SetWindowPos (dialog, HWND_TOPMOST, 0, 0, 0, 0,
+			SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE
+			| SWP_NOOWNERZORDER);
+	  SetWindowPos (FRAME_W32_WINDOW (SELECTED_FRAME ()),
+			dialog, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+
 	  /* At least on Windows 7, the above attempt to get the window handle
 	     to the File Name Text Field fails.	 The following code does the
 	     job though.  Note that this code is based on my examination of the