From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#69083: Emacs's keyboard hook state is not reset on session lock (Windows) Date: Sun, 03 Mar 2024 19:23:05 +0200 Message-ID: <868r2znsau.fsf@gnu.org> References: <86cyt1qvmt.fsf@gnu.org> <861q9exmhe.fsf@gnu.org> <86v86im1r9.fsf@gnu.org> <868r36uzdh.fsf@gnu.org> <86bk7ysbbz.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29701"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69083@debbugs.gnu.org To: Raffael Stocker Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 03 18:26:58 2024 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 1rgpc1-0007VS-Dn for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 03 Mar 2024 18:26:57 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rgpbe-0004Fc-Mz; Sun, 03 Mar 2024 12:26:34 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rgpbd-0004FI-Gg for bug-gnu-emacs@gnu.org; Sun, 03 Mar 2024 12:26:33 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rgpbd-0000nP-82 for bug-gnu-emacs@gnu.org; Sun, 03 Mar 2024 12:26:33 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rgpc6-0001QD-AW for bug-gnu-emacs@gnu.org; Sun, 03 Mar 2024 12:27:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 03 Mar 2024 17:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69083 X-GNU-PR-Package: emacs Original-Received: via spool by 69083-submit@debbugs.gnu.org id=B69083.17094867705391 (code B ref 69083); Sun, 03 Mar 2024 17:27:02 +0000 Original-Received: (at 69083) by debbugs.gnu.org; 3 Mar 2024 17:26:10 +0000 Original-Received: from localhost ([127.0.0.1]:41229 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rgpbG-0001Os-Do for submit@debbugs.gnu.org; Sun, 03 Mar 2024 12:26:10 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:35208) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rgpbD-0001Nx-4U for 69083@debbugs.gnu.org; Sun, 03 Mar 2024 12:26:08 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rgpYW-0008Nq-Ju; Sun, 03 Mar 2024 12:23:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=WEslZgsYmuq8ZSVOcf9Yo58RMaieJ00zKwmk1aM/WVU=; b=IZ6qkzePnFwIjk5oSPLh gs4I+H9LHr2mz4ifGZK5ahcijgaogdj73HjSE1gLdIGeNY7jkrHhYm4gdvUlh1zHV4nthDHS7Mhqt HFkrvodgTZahIEiT1M0GvC6miIyo7kUjhGgDUM5DTGVHRdXHdqJ02iPbXT5dNhH3r6w5GFuarbdUb IbOYkfg3fbwewbBM3QBSCwNow2mIjKuz3kOxYxyhJcVZfyytgxoSkcnjHARLqGwYI7UDjOqTfD6hQ XmhvNX2daLd3biSvekm3ldfzWMLz2pTxVbEFGxChclqb0mMWzEuI7UhUusB9fIBFMo9W5p8KiVYhm hoqLHBAqTF1BWg==; In-Reply-To: (message from Raffael Stocker on Sun, 03 Mar 2024 17:43:56 +0100) 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:280954 Archived-At: > From: Raffael Stocker > Cc: 69083@debbugs.gnu.org > Date: Sun, 03 Mar 2024 17:43:56 +0100 > > >> I don't know much about the internals of Emacs frame handling. > >> Could ‘w32_frame_list_z_order’ be used (from the input thread) for > >> something like that? Or is there a better approach? > > > > Why is the order important? Can't you "hand" the registration to some > > other frame, no matter which one? > > The order is not important, I just didn't know where to look to get > a frame; sorry for the noise. I now use ‘Fnext_frame’. Unfortunately, I don't think you cannot use Fnext_frame here. The function which calls it, w32_wnd_proc, runs in a separate thread, so it generally cannot access Lisp objects safely. However, it is okay to traverse the list of the frames, as w32_window_to_frame does, see the comment at the beginning of w32_wnd_proc. So I think you could use a similar loop with FOR_EACH_FRAME, and use some frame from there, perhaps the first one? Alternatively, and maybe more safely, you could call maybe_pass_notification from w32_destroy_window, which is called from the main (a.k.a. "Lisp") thread, so then you can use Fnext_frame (actually, I would make next_frame extern instead of static and call it directly). This means the notifications are passed a bit before the frame is actually deleted by the OS, but I think this is okay? Otherwise, I think the patch is fine, at least from reading it. Thanks.