From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Brian Jenkins Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] frame.c: focus hooks Date: Mon, 18 Nov 2013 08:24:25 -0500 Message-ID: References: <183af97b-53d1-45b8-8a24-5ab6bd84f362@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8ffbac1d62504f04eb737826 X-Trace: ger.gmane.org 1384781110 23228 80.91.229.3 (18 Nov 2013 13:25:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 Nov 2013 13:25:10 +0000 (UTC) Cc: emacs-devel To: Drew Adams Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Nov 18 14:25:14 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ViOpE-0005J5-U5 for ged-emacs-devel@m.gmane.org; Mon, 18 Nov 2013 14:25:13 +0100 Original-Received: from localhost ([::1]:43246 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViOpE-0006Wq-H8 for ged-emacs-devel@m.gmane.org; Mon, 18 Nov 2013 08:25:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViOoy-0006M3-Sd for emacs-devel@gnu.org; Mon, 18 Nov 2013 08:25:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ViOoj-00085B-Ku for emacs-devel@gnu.org; Mon, 18 Nov 2013 08:24:56 -0500 Original-Received: from mail-pb0-x22f.google.com ([2607:f8b0:400e:c01::22f]:49309) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ViOoj-00084d-AR for emacs-devel@gnu.org; Mon, 18 Nov 2013 08:24:41 -0500 Original-Received: by mail-pb0-f47.google.com with SMTP id um1so287123pbc.34 for ; Mon, 18 Nov 2013 05:24:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=tqxO47W2LzlprH2h4wvmry+bq6KE5gPAhm0CmjLl0qc=; b=fiFXkZl4XHg2iye+vQsU5FHHmnBg1avK87B4UMrVtDwB5PCP1k/oa9b/C27K9CiaVQ d/RawUF5+UPmNo1i5spsEBh9ueVMC9gB2QVIjjGSk4SQPOlNYaoCgY7dYEAbx01xr+Xs CZKORTUKBsURr8ulJrdxafzISEU8AZNiQ7Suxh2LZ5eX3mCj/Qmg0Gh4iVjv2jqcEBzA Vb/Epkn0QCvcZ+d8dFbcM2SrAngy4aSJIMHYnsl+tu5pKisHtP9FgIATiI4bMhlenmSj dNp8xS5RC9yR7fwYKI6qG29HCBNydCUxNXWUTGY0929xXknwJkQsbxkAdEEy/wXgCyyp TpOA== X-Received: by 10.66.119.172 with SMTP id kv12mr20879802pab.34.1384781080315; Mon, 18 Nov 2013 05:24:40 -0800 (PST) Original-Received: by 10.68.29.202 with HTTP; Mon, 18 Nov 2013 05:24:25 -0800 (PST) In-Reply-To: <183af97b-53d1-45b8-8a24-5ab6bd84f362@default> X-Google-Sender-Auth: vsWvmRJAbSos3qm6LTUrBSeESbA X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c01::22f X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:165320 Archived-At: --e89a8ffbac1d62504f04eb737826 Content-Type: text/plain; charset=ISO-8859-1 Hi, Drew. Thanks for the feedback. Unfortunately, no. The "focus in" and "focus out" events in Emacs fire per frame. So alt-tabbing between Emacs frames will trigger a focus loss event for the origin frame and focus gain for the destination frame Initially I tried hacking in at the terminal level (nsterm.c, xterm.c, and w32term.c) but I had difficulty figuring out how application (opposed to frame) focus works under X. It's not clear to me that X itself even *has* a concept of "active application" distinct from "frame that has input focus". (Perhaps this concept exists at the window manager level, but there are a lot of window managers...) I'm not even a beginner at X programming, though, so maybe someone could point me in the right direction? The convenient thing about patching into the "focus in" and "focus out" events is that they live up in frame.c, which appears to be cross-platform. Best, Brian On Sun, Nov 17, 2013 at 5:33 PM, Drew Adams wrote: > > I'd like to contribute the attached patch, which adds hooks into > > gain and loss of focus events. > > > > This allows saving all buffers on loss of focus. (Alt-tabbing > > between an editor and browser is a popular workflow for web > > programmers.) > > > > It also allows reversion of buffers on regain of focus, convenient > > if one is switching between Emacs and another editor. > > > > People will probably find other handy uses for these hooks. > > Sounds useful. > > Is this only for a focus switch between Emacs (any frame) and some > other application? Or is it also for a focus switch from one Emacs > frame to another. > > (I hope it is the former, which is what you describe in your example > use cases.) > --e89a8ffbac1d62504f04eb737826 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hi, Drew.

Thanks for th= e feedback.

Unfortunately, no. =A0The "focus = in" and "focus out" events in Emacs fire
per frame= . =A0So alt-tabbing between Emacs frames will trigger a focus loss
event for the origin frame and focus gain for the destination frame

Initially I tried hacking in at the terminal level (= nsterm.c, xterm.c,
and w32term.c) but I had difficulty figuring o= ut how application
(opposed to frame) focus works under X. =A0It's not clear to me th= at X
itself even *has* a concept of "active application"= ; distinct from "frame
that has input focus". =A0(Perha= ps this concept exists at the window
manager level, but there are a lot of window managers...) I'm not = even a
beginner at X programming, though, so maybe someone could = point me in
the right direction?

The con= venient thing about patching into the "focus in" and "focus = out"
events is that they live up in frame.c, which appears to be
= cross-platform.

Best,
Brian
<= /div>


On Sun, = Nov 17, 2013 at 5:33 PM, Drew Adams <drew.adams@oracle.com> wrote:
> I'd like to contr= ibute the attached patch, which adds hooks into
> gain and loss of focus events.
>
> This allows saving all buffers on loss of focus. =A0(Alt-tabbing
> between an editor and browser is a popular workflow for web
> programmers.)
>
> It also allows reversion of buffers on regain of focus, convenient
> if one is switching between Emacs and another editor.
>
> People will probably find other handy uses for these hooks.

Sounds useful.

Is this only for a focus switch between Emacs (any frame) and some
other application? =A0Or is it also for a focus switch from one Emacs
frame to another.

(I hope it is the former, which is what you describe in your example
use cases.)

--e89a8ffbac1d62504f04eb737826--