From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: We should decouple focus and frame switching Date: Mon, 11 Jun 2018 18:56:55 +0300 Message-ID: <83d0wxqptk.fsf@gnu.org> References: <6d1bc582-29be-5df7-56b1-e82305ee477f@dancol.org> <726a268360567d598996f0080b71c0f8.squirrel@dancol.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1528732562 29220 195.159.176.226 (11 Jun 2018 15:56:02 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 11 Jun 2018 15:56:02 +0000 (UTC) Cc: emacs-devel@gnu.org, raman@google.com To: dancol@dancol.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jun 11 17:55:58 2018 Return-path: Envelope-to: ged-emacs-devel@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 ) id 1fSPAj-0007PK-D7 for ged-emacs-devel@m.gmane.org; Mon, 11 Jun 2018 17:55:57 +0200 Original-Received: from localhost ([::1]:49748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSPCo-0003To-IC for ged-emacs-devel@m.gmane.org; Mon, 11 Jun 2018 11:58:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSPBc-00032U-N7 for emacs-devel@gnu.org; Mon, 11 Jun 2018 11:56:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSPBX-0001LW-Tz for emacs-devel@gnu.org; Mon, 11 Jun 2018 11:56:52 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:46914) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSPBX-0001LQ-QZ; Mon, 11 Jun 2018 11:56:47 -0400 Original-Received: from [176.228.60.248] (port=2100 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fSPBX-0004OG-7z; Mon, 11 Jun 2018 11:56:47 -0400 In-reply-to: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:226222 Archived-At: > Date: Sun, 10 Jun 2018 17:20:34 -0700 > From: dancol@dancol.org > Cc: dancol@dancol.org, Emacs developers > > I don't even think we should have separate focus-in and focus-out hooks. > We should just have one extension point, some kind focus-change-function. > Modes would add-function a handler to focus-change-function, and each time > the handler is called, it'd re-scan all the frames and windows it's > interested in and do whatever it wants to do based on that snapshot of the > current focus state. That's why it's important to provide some kind of API > that lets a package ask Emacs, "To the best of your current knowledge, > does FRAME have input focus?" and not just rely on state change > notifications. > > Now, we already have focus-in-hook and focus-out-hook. Do we just apply > the new semantics to these hooks? Having two separate hooks encourages > people to use the fragile edge-triggered model instead of the > level-triggered one I described above. > > Maybe the right approach is to just declare focus-in-hook and > focus-out-hook obsolete and not call them anymore at all, then direct > people to this new focus-change-function extension point that has the > improved semantics I described. I normally don't like that sort of change, > but the existing hooks are hopelessly broken. I'd prefer to define a new hook with this new semantics. Historically, AFAIR the focus-in/out events were used by Emacs internally for the purposes of switching frames (surprise, surprise). They were exposed to Lisp relatively recently, and the reason was to allow us to stop and start the blink-cursor timer, depending on whether Emacs's frame's were in the foreground. Then other Lisp programs started using the hooks, and the rest is history. Having a new hook that is better suited to Lisp programs will allow us to encourage migration to it, and perhaps eventually we will be able to make focus-in/out internal events again, not exposed to Lisp. And in the meantime we won't break existing programs which use these hooks.