From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: [ELISP] Detect focus on emacs. Date: Tue, 03 May 2005 19:24:11 -0400 Organization: Bell Sympatico Message-ID: <87br7rq4le.fsf-monnier+gnu.emacs.help@gnu.org> References: <87acnm5v9h.fsf@mahaena.lrde> <87mzreqx7f.fsf-monnier+gnu.emacs.help@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1115234492 28998 80.91.229.2 (4 May 2005 19:21:32 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 4 May 2005 19:21:32 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 04 21:21:31 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DTPQL-0006nA-4S for geh-help-gnu-emacs@m.gmane.org; Wed, 04 May 2005 21:20:45 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DTPXL-0004ZR-HT for geh-help-gnu-emacs@m.gmane.org; Wed, 04 May 2005 15:27:59 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!wns13feed!worldnet.att.net!207.35.177.252!nf3.bellglobal.com!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:yUsByMCvK7YQIAItFD2W+hk3xqs= Original-Lines: 26 Original-NNTP-Posting-Host: 67.71.118.90 Original-X-Complaints-To: abuse@sympatico.ca Original-X-Trace: news20.bellglobal.com 1115162648 67.71.118.90 (Tue, 03 May 2005 19:24:08 EDT) Original-NNTP-Posting-Date: Tue, 03 May 2005 19:24:08 EDT Original-Xref: shelby.stanford.edu gnu.emacs.help:130636 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:26288 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:26288 >>> I need to know if emacs has the global input focus, that's to say, >>> if emacs' window is the selected one in the wm. >> >> I don't think you can do that from elisp as of Emacs-22. >> Patches are welcome to add the functionality, of course, > A function like `window-focus-p', that will check with > XGetInputFocus(3x)/GetForegroundWindow(w32) if the current window > has the input focus ? BTW, you might want to use other info than focus. E.g. you might just want to check whether one of Emacs's frames is currently visible (rather than obscured by another window). Of course it depends on the actual application you have in mind. In any case, whatever you use will be fragile, since you might lose focus between the moment you ask whether you have focus and the moment you act on it. > So I'll have a try. BTW, is there guidelines for emacs patches, > some must-know coding style or whatever like that somewhere ? Try to mimick the rest of the code ;-) Stefan