From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Greselin Newsgroups: gmane.emacs.help Subject: =?UTF-8?Q?Re=3A_Ignore_spurious_focus_events_for_=E2=80=98after=2Dfocus=2D?= =?UTF-8?Q?change=2Dfunction=E2=80=99?= Date: Sat, 16 Jan 2021 10:56:51 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14934"; mail-complaints-to="usenet@ciao.gmane.io" To: Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 16 10:57:59 2021 Return-path: Envelope-to: geh-help-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 1l0iLG-0003m6-Jp for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 16 Jan 2021 10:57:58 +0100 Original-Received: from localhost ([::1]:55792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l0iLF-0005AA-Ld for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 16 Jan 2021 04:57:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l0iKq-00059q-JV for help-gnu-emacs@gnu.org; Sat, 16 Jan 2021 04:57:33 -0500 Original-Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]:42114) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l0iKo-0005bK-CO for help-gnu-emacs@gnu.org; Sat, 16 Jan 2021 04:57:32 -0500 Original-Received: by mail-pf1-x42d.google.com with SMTP id h10so7101638pfo.9 for ; Sat, 16 Jan 2021 01:57:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=N6WOZOtbFq31FatBrE11b9NI//7EeXSsKYg9wcUW9ic=; b=WOJXPlg3z9/378FdUi33ZYvArQxM7MeGjdaHQ1d741N7JKH3g3lH7gq7tl2gG+npNM NSp4/KUl8o5+euRcIOeT6gEh302VnGx4Ev4OeLkBN48nr81ke+lUYMbemnpw5LnmPCQb rn7PerPzg5IR6lLnxzltGssCG+Ujwylj22+79BjCBSutLlOEKNj3exfLaSa7YgM3jD2X GDSga0Ybeb1biFmUrxgL1PKu3ZWAwvrSIG/B1XmPzB57UBHycBWq8qQha7vfWVh+QqdM nwFQNMlAHoNHrAAog51HL/UGfx2MCUWjrohqyxoCh6+5YNUAbDZ/IKDACpTvlul3vlW4 gJVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=N6WOZOtbFq31FatBrE11b9NI//7EeXSsKYg9wcUW9ic=; b=QLUmKBrNVc7+b/wgf+XRBGqUks/7kjzyPw+hskO3Jj3+nD0nuOC8Wl4l54aC5dLh9f gUfjdQH7r1ACuCyUlgskU4XGgdki3hVyAsi3ts8elZllWPYandkrjJIic+DjOnDsADSJ nxenzV9EQJuLWPPGeqApL6ZudZVk2PEQ6ukE+yl4l+e7qkewN5ArPt8x+uA01GIDMy8G Qm5hyczqs8YmVGBQSYa7ImeSO5Zp0Lbo2UEfBMH+vZjhd3YbsPDn3P0vTPI6b8ekfT4F s/dtuLiDmoRSmSSJH7lqE26to5Ec9SC+oDLUQKK3FBdrflpf8rpPY6dJjVEuJ4g+b+eM 65VQ== X-Gm-Message-State: AOAM531CkeIQecCoZmtuidB1Q9SaQYLc6VwYVfgoTm7jTs6O8sQli+WG Aol2d5Ec8EwqLB6k4sKaiWCYKCApm/gGI3bBP8gSnJuLxiGISQ== X-Google-Smtp-Source: ABdhPJwnVN/8did9sYBBGz7zHQk/p2b9b6h88hooh3m+zXfJaq41exQBdQI1wdwyjqp9++zBF9U0okI9fws3Tt+ys2Y= X-Received: by 2002:a65:48cb:: with SMTP id o11mr16621614pgs.121.1610791047677; Sat, 16 Jan 2021 01:57:27 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=greselin.andrea@gmail.com; helo=mail-pf1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.23 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:127274 Archived-At: Hi Eli, I need it for triggering auto-save on focus-out and functions that dim some colours on focus-out and restore them on focus-in. Auto-save works when it should, and also when it shouldn't. Changing the colours on focus out works well but there's some flickering when they're restored on focus in, which I think may be due to the excess focus events triggering it repeatedly. Also, I have an issue with the tab-bar when the Solarized theme is enabled (the GUI keys -- new tab, close tab, the tab itself -- don't work when I click on them) and I'm trying to debug it. It must be something in my configuration because there are no problems with Solarized in =E2=80=98emacs -Q=E2=80=99. I wanted to ignore the spurious fo= cus events as part of debugging this issue. > In any case, I very much doubt that "deferring work until redisplay" > meant that you should _trigger_ redisplay by calling sit-for. I had tried with =E2=80=98(sit-for 0 t)=E2=80=99 first, wich *maybe* was bi= t cleverer but yes, it was naive. Now I have something that seems to be working, from a suggestion on Reddit [1] (defvar focus-out-auto-save-timer nil) (defun focus-test () (message "ffs: %s" (frame-focus-state)) (setq focus-out-auto-save-timer nil)) (defun focus-test-wrapper () (setq focus-out-auto-save-timer (unless (timerp focus-out-auto-save-timer) (run-at-time "0.05 sec" nil #'focus-test)))) (add-function :after after-focus-change-function #'focus-test-wrapper) It's not super-robust (works with delay >=3D 0.05 s, doesn't work if it's <=3D 0.01 s) but it's done its job for the couple of times I tested it. In particular, it does not see focus-out events unless one actually happens. I still hope there is a cleaner way, I don't like this one very much. 1 https://www.reddit.com/r/emacs/comments/kxsgtn/ignore_spurious_focus_events= _for/