all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Yuri Khan <yuri.v.khan@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: How to determine (from Elisp) whether the Emacs frame has focus?
Date: Sat, 14 Nov 2015 16:54:35 +0600	[thread overview]
Message-ID: <CAP_d_8XL=DYyM1dsjP27m62EMp_Zsz-QxtLP0gET_LiipuPV9w@mail.gmail.com> (raw)
In-Reply-To: <83io55dkim.fsf@gnu.org>

On Sat, Nov 14, 2015 at 2:59 PM, Eli Zaretskii <eliz@gnu.org> wrote:
>>
>> "Focus" in the window manager sense, not in Emacs sense.  I.e., I want
>> to determine whether it is Emacs which receives keystrokes, or some
>> other X application.
>>
>> Hope that clarifies the question.
>
> Not really, sorry.  The function selected-frame returns the frame that
> receives keystrokes, at least as far as I understand what you are
> saying.  The ELisp manual explicitly says:
>
>    -- Function: selected-frame
>        This function returns the selected frame.

OK, simple demonstration.

I have a couple Emacs frames on my desktop, along with a Firefox and
an Xterm, all under the i3 window manager (but the concepts should
apply to any wm).

In one of the Emacs frames, I bring up *scratch* and type:

(progn (sit-for 3) (message "%s" (selected-frame)))

I press C-x C-e on that and wait for three seconds. It says: "#<frame
*scratch* – Emacs 0x1140678>".

Now I press C-x C-e again, and before three seconds elapse, I switch
the wm focus to Firefox. However, after three seconds, the minibuffer
says again: "#<frame *scratch* – Emacs #1140678>", although this frame
doesn’t have focus. Neither does any, in fact.


Now let’s imagine a situation where there is a single Emacs server,
and a couple of emacsclients connected to it, both displaying their
respective frames *on different X servers*. I believe in that setup
both frames could simultaneously have focus in their respective wms.
Which of them is “the” selected frame, from Emacs’ point of view?



  reply	other threads:[~2015-11-14 10:54 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-13 21:45 How to determine (from Elisp) whether the Emacs frame has focus? Marcin Borkowski
2015-11-14  3:48 ` Emanuel Berg
2015-11-14  4:05 ` John Mastro
2015-11-14  7:30   ` tomas
2015-11-14  8:44     ` Marcin Borkowski
2015-11-14 10:45       ` tomas
2015-11-14 20:28         ` Marcin Borkowski
2015-11-14  8:06 ` Eli Zaretskii
2015-11-14  8:36   ` Random832
2015-11-14  9:36     ` Eli Zaretskii
2015-11-14 12:34       ` Marcin Borkowski
2015-11-14 13:40         ` Eli Zaretskii
2015-11-15  7:45           ` Marcin Borkowski
2015-11-15 19:45             ` Eli Zaretskii
2015-11-16 14:08             ` Nicolas Richard
2015-11-16 16:58               ` Marcin Borkowski
2015-11-14 21:10         ` Stefan Monnier
2015-11-16 17:00           ` Marcin Borkowski
2015-11-14  8:42   ` Marcin Borkowski
2015-11-14  8:59     ` Eli Zaretskii
2015-11-14 10:54       ` Yuri Khan [this message]
2015-11-14 11:04         ` Eli Zaretskii
2015-11-14  8:44   ` Michael Heerdegen
2015-11-14 10:15     ` Marcin Borkowski
     [not found] <mailman.2293.1447451126.7904.help-gnu-emacs@gnu.org>
2015-11-16  6:53 ` Dan Espen
2015-11-17  0:10   ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP_d_8XL=DYyM1dsjP27m62EMp_Zsz-QxtLP0gET_LiipuPV9w@mail.gmail.com' \
    --to=yuri.v.khan@gmail.com \
    --cc=eliz@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.