From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.bugs Subject: bug#44415: 27.1; Child frame loses focus on app switching Date: Tue, 3 Nov 2020 16:57:04 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19001"; mail-complaints-to="usenet@ciao.gmane.io" To: Andrii Kolomoiets , 44415@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 03 16:58:35 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kZyhf-0004q2-2J for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Nov 2020 16:58:35 +0100 Original-Received: from localhost ([::1]:41050 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZyhd-0001XB-UG for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 03 Nov 2020 10:58:34 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59754) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZyh8-0001Vf-Do for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2020 10:58:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34627) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kZyh8-0001nW-0S for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2020 10:58:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kZyh7-0002Ez-UZ for bug-gnu-emacs@gnu.org; Tue, 03 Nov 2020 10:58:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: martin rudalics Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 Nov 2020 15:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44415 X-GNU-PR-Package: emacs Original-Received: via spool by 44415-submit@debbugs.gnu.org id=B44415.16044190388558 (code B ref 44415); Tue, 03 Nov 2020 15:58:01 +0000 Original-Received: (at 44415) by debbugs.gnu.org; 3 Nov 2020 15:57:18 +0000 Original-Received: from localhost ([127.0.0.1]:46173 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZygP-0002Dy-UE for submit@debbugs.gnu.org; Tue, 03 Nov 2020 10:57:18 -0500 Original-Received: from mout.gmx.net ([212.227.17.22]:35379) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZygN-0002Dj-Kn for 44415@debbugs.gnu.org; Tue, 03 Nov 2020 10:57:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1604419028; bh=zeZO5oaot9FHs3DOJZeQfJaObkvijsTU8PdM+UDCUfk=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=ePnloM2KklhRpcfSLNHoO8E/E/SQ5XFhwFfBKtcoRoqh4KcabsnJaBNfU1w0/niAp e317w0lhF4/m02TQKF5bm51ATRw1ol3PfHqSDsfdZlruZDsCyoIT2L5/qsAr2/vIN8 LGwUnfSOkaU3Bogjq1DaY0gYZ2ymBAQkdTR0F6Q0= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [192.168.1.102] ([46.125.249.34]) by mail.gmx.com (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MZkpb-1koQbM3fWh-00WoML; Tue, 03 Nov 2020 16:57:07 +0100 In-Reply-To: Content-Language: en-US X-Provags-ID: V03:K1:ofCN/DyljRaWOzy/OtvzWUMzDH/u0VGgcg8CxzlMGoQ3H9bOQ2D ZSIwGiOw61QvrxuRjB9SjxI/+oGDeYkzV0rCxDWaMeZNWNZ2AoVoO51n8qwOUyzLHLG7jsJ 1TiT7mC/0VM1gYe/AVcSjhL5rR1avIdUrl0MH9SF1PrT59aKnZPCwY/mns+yLT0bdroNzvq z2Zlsizceg9LXShSm0V7g== X-UI-Out-Filterresults: notjunk:1;V03:K0:Mt1EyZ7tro4=:ridzpYkmFx5qPOjZ1mdCHW bAD0cnRMfztLZZ5wdwqoOmtmYwwITpTb0lkyMFu6QLfELeAklQTYGX+gEACo3m8v47nwjG7h9 kOwkumsXUZplX8Q/JnF2C2zocXtQPD8iR/bwQ6+XITDRFnEL+D+KFswE9CredJj9l+yqEmjEi ZA2BK2jDZZQgN7gp3cr1DmiTL+uE971Xqsnojuyr6gUX/zJA5DZWYJuk/Um2NzL+J1ORrjBD0 EoqDOUeiVdmoTYA197aBzwO4P6YjLuUA984yPM1wVbSMj6rN8kBW2r3vuqpixaEWRWyWlvhYU RgVotWRTRVuBGaA1tJZVLmgMKwNiEV5Y3UqZsMK+P1yyY0SXb54a+EjvfEZ43uf8G9uc7h+Ed nKJ40u4dMZsudn4cfG6fRnW3Jq6F0k06DFU0fkq0Hksj3bI2TJlnuc93vxv1N0H/fs3S/cQ+S O7njZzUBrAg9/Ku5Dscr/ANXrG5+OmilyoCZMtl41ljvwV/iTjNw3jckOZL2Jv4XL+1vvZ8Am kk+oOJjcFDq4piMO3EBtknlzgpE7oyrJtxoMIu+t7hjCxcz1syhjOPjZh6Nxeb2x8b2OKEoMd hPjjv/aKwkOEWM/E/0zCsJxlU+eEui2QpLVr96SiK2VngEAy2CNm/R/SsBAEbGlEhu8eM6XeP anwzEFepUD6LWtTi4TPU/njohPvGdyWpuWykaOltuMF0picvHoIU5OcNCashgSSQYwUI+WPsv ZtwXGi4Zd5oCIJJr3g0ZMA+5ulY5TXSKTWNIWT3WF+vHTS2NYKFodmu8WBWUzdnCIRcPzOEX X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:192619 Archived-At: > 1. emacs -Q > 2. Evaluate: > (select-frame-set-input-focus > (make-frame `((parent-frame . ,(selected-frame))))) > 3. Alt-TAB > 4. If Emacs is not the only running app Alt-TAB to return to Emacs > > Child frame became unfocused. > > In GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.22, cairo version 1.17.3) > Windowing system distributor 'The X.Org Foundation', version 11.0.12009000 > > Same issue on Windows. IIRC the focus is never given to a child frame in such cases. A similar thing happens when you have a child frame focused and you iconify its parent. When you deiconify the parent, the child frame loses focus too. Maybe your problem could be solved under X as follows: According to https://tronche.com/gui/x/xlib/events/input-focus/normal-and-grabbed.html When the focus moves from window A to window B, window C is their least common ancestor, and the pointer is in window P, the X server does the following: If window P is an inferior of window A, it generates a FocusOut event on each window from window P up to but not including window A, with the detail member of the XFocusOutEvent structure set to NotifyPointer. It generates a FocusOut event on window A, with the detail member of the XFocusOutEvent structure set to NotifyNonlinear. It generates a FocusOut event on each window between window A and window C, exclusive, with the detail member of each XFocusOutEvent structure set to NotifyNonlinearVirtual. We would first have to check under X whether all of the above really happen in your case. If so, we could remember that in some variable. Hopefully, the third above will cover the case where the pointer is not in the child frame but the child frame has focus. Now the next time we get a focus-in event for the parent frame we could then try to focus the child frame ourselves. The tricky parts of this are when and how to flush the above variable and how to disregard it whenever users click with the mouse into some part of the parent frame that is not covered by the child frame thus explicitly stating their wish to focus the parent. On Windows the situation looks more difficult. But if WM_KILLFOCUS at least does name the child frame that loses focus, we could maybe try to emulate something similar to X. In either case I can assure you that writing the corresponding code will be quite tricky and require some understanding of the sequence of events that may happen when focus changes. But if you want to give it a try, I will certainly try to help you. martin