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#73559: [PATCH] fix NS build focus-in event processing Date: Mon, 30 Sep 2024 18:38:18 +0300 Message-ID: <86h69x2lud.fsf@gnu.org> References: <871q113lil.fsf@dancol.org> <86v7yd2wsi.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40677"; mail-complaints-to="usenet@ciao.gmane.io" Cc: luangruo@yahoo.com, 73559@debbugs.gnu.org To: Daniel Colascione Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Sep 30 17:57:44 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 1svImN-000ANF-OJ for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 30 Sep 2024 17:57:44 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1svImA-0006aJ-Rn; Mon, 30 Sep 2024 11:57:30 -0400 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 1svIm9-0006Zo-Ev for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2024 11:57:29 -0400 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 1svIm9-00011J-5b for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2024 11:57:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=UdQW3UnXMXvTSeilMm7ltI9Zu9aJMA9tEYSDFrjCqmw=; b=LcD5b4zf/CqmnjMHneB0OZnAPnUb6/Jo89o5Jnh0iEjaiL/aP1OpblOwFfmxP4df8IQ9OTyg1E93+ctiJnVxbKhQDzqQGChSrgznjp4kHAPEsZHZuvkbyC/2Rt56vJfb9RqkSGeqmKvYdR+hB5tmL7ddpG1Ap/numMLwij8D7H4SxYY5C6ojfV7ubuP2XBWa/FRXN6bvWwYkXbCtpJzukFrnC7cm1870ZvgXrUMcuaUZMcsXoD6qZZtU59YaHjJrg64LSfJjfRdXPc1nLZRfBq2hTiLPDnRfqNOn4m9wk14fRHh1x5kAjnxYBvTqvfSSGvkc+6DGeJ4+Dh8ngvDRyg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1svImg-0000uH-0n for bug-gnu-emacs@gnu.org; Mon, 30 Sep 2024 11:58:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 30 Sep 2024 15:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73559 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 73559-submit@debbugs.gnu.org id=B73559.17277118433469 (code B ref 73559); Mon, 30 Sep 2024 15:58:01 +0000 Original-Received: (at 73559) by debbugs.gnu.org; 30 Sep 2024 15:57:23 +0000 Original-Received: from localhost ([127.0.0.1]:45605 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1svIm3-0000tt-5q for submit@debbugs.gnu.org; Mon, 30 Sep 2024 11:57:23 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:58220) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1svIUH-0006v3-Vp for 73559@debbugs.gnu.org; Mon, 30 Sep 2024 11:39:54 -0400 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 1svITd-0007jo-Pt; Mon, 30 Sep 2024 11:38:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=UdQW3UnXMXvTSeilMm7ltI9Zu9aJMA9tEYSDFrjCqmw=; b=F5wIzimcejMX ZhbBc9PpilXYJs3bE802TsqjayDFOwils4HWUBklELxNRlJFLyOOjSIjw5VIVOKW4czh2YTCOpxj6 jsp2zMy94Co52z58WuLxVZioHWavZTcOqBvq+q33DInLY5wH/CgCcxiI2A1UnzKHeFECJSf7i1joA 9KKMfNhUa7PyoZO4QWeR4t8MbMwJZbY6rmvkMifV8w8bqhgUUId90Z8tPkNkmyF6gJpUWrv7755KG /cuUP5ibRj5DtqC5rqGM9DQcbNjAg4SJ+U3aCkZtp2HB/xX7j2kSIiwUSJDvSnfKVTL0jfDuJolKE UVfbJMhKVWOhU9Cy3ve9vw==; In-Reply-To: (message from Daniel Colascione on Mon, 30 Sep 2024 07:20:26 -0700) 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:292726 Archived-At: > Date: Mon, 30 Sep 2024 07:20:26 -0700 > From: Daniel Colascione > CC: 73559@debbugs.gnu.org > > > > On September 30, 2024 4:41:49 AM PDT, Eli Zaretskii wrote: > >> From: Daniel Colascione > >> Date: Sun, 29 Sep 2024 22:47:46 -0400 > >> > >> > >> In Emacs NS build, frames don't respond to focus-in events right away. > >> Instead, they store the focus-in event and process it (and other queued > >> events) whenever some other event happens to occur on that frame. > > > >Hmm... isn't this the same on all other GUI systems? > >kbd_buffer_store_event adds the event to the Emacs input queue, and > >AFAIU it will be processed as soon as Emacs gets back to its main loop > >and calls read_char. No other event should be needed, AFAIK. Po Lu, > >am I missing something here? > > > >> This patch kicks the NS event loop immediately when a focus-in event > >> happens, allowing Emacs to respond to focus-in events without some other > >> event triggering the processing. > > I don't recall what we do for other systems, but for NS, we don't wake up the event loop as a side effect of kbd_buffer_store_event by itself. We rely on something else waking up the loop draining events from the queue. Changing the kbd_buffer_store_to_event to wake the main thread unconditionally would be another option, but seemed like a bigger change. That's not what I meant. kbd_buffer_store_event doesn't trigger reading from the queue, AFAIU. Emacs does that itself, when it becomes idle: it calls read_char as part of its main loop, and that reads from the input queue.