From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.devel Subject: Sticky tooltips Date: Mon, 05 Oct 2020 02:55:07 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14773"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 05 02:56:59 2020 Return-path: Envelope-to: ged-emacs-devel@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 1kPEoF-0003iF-Eq for ged-emacs-devel@m.gmane-mx.org; Mon, 05 Oct 2020 02:56:59 +0200 Original-Received: from localhost ([::1]:40456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kPEoE-0005A6-EQ for ged-emacs-devel@m.gmane-mx.org; Sun, 04 Oct 2020 20:56:58 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47990) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPEmY-0004P8-Jf for emacs-devel@gnu.org; Sun, 04 Oct 2020 20:55:16 -0400 Original-Received: from mail-am6eur05olkn2060.outbound.protection.outlook.com ([40.92.91.60]:3456 helo=EUR05-AM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kPEmW-000257-5i for emacs-devel@gnu.org; Sun, 04 Oct 2020 20:55:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X6SZPqUEPYXh4T/RgbWj4HUKwMxJYJf5D1S2/X7M5gXSc/EJtbW0+AUOKxL2wNzqYFGFa4WBsAEWbzJ9gI8BVQ4czFpr7sLhQlUd3TAO7nGW/5h0VOJJml3vL0k1TDOTqSHSZSBwpNi+o/CQ7QR8gv7nOP1E6EOInZItFHsjvwY9g7rLtq7QacqmtyzvH6c4sJhZT6gDRIz6hak1VR3TA7hWHQTxQG29mVQZSyxwCKd571ct7wpvOe/ZMVhbQQLjtVMboVbvPjyk2xAVW4N1+Hte8CvELQK88KYJR17Y3RIjP0D2kscPbDKTddNeVXz3ZITGcrZHahUSC7GMRj0Vkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hL/ZKNvaRY0cTYHDmt1uy3phWqCLPzb2/cBQEBtNxqg=; b=HCXpTZ50L/069XGRnGvxg+giaelBWdDRbbT2GUsHwKs5z3IvsMzhsSfoQVm1xBeTU9ykxgdOHgmX7RFlk4fAGNOdVpScz3Qk4Ai5YvIe/9AvxlIHG0u6SsEVCo17mvMq+IuJh9sgp4BQ8bwARDFI+ZO+rHfEMyDfZLSe1gccm7v45Xd78ZUhGPTXH4vayocc9ccUKv+prCJNZYU4UVjV3rxGjhjCwif3PQCL3PjSC941fr5aLlioXo/Q3NeYggulIgKFCVHeK4RL1XLi0U7IKex5AH9vVZgKlF4UFZRvYeRmM1/7GYVtLSBSvztz6LHpup0IpdTLeWyfq+gnjkN/4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hL/ZKNvaRY0cTYHDmt1uy3phWqCLPzb2/cBQEBtNxqg=; b=F689DCTyFFcW194kTZl5ezKnmMPNZxmgHEcGIfVmPc5G3X1ISJti/Tdmz8c118YYZeYOSF24LYq5PmI4tmvzfQdG69ZJPc1pTjjOSjgvlgAVdeI5QudML2qOTcCJv3+4KK1j220YRfl7Rf5gWiYmKK8FlvmIYgvmxGUYvBhny/JIgszJ/HiHRHK+7F5aNo2XVwnDoWXNzbj63DVTSUUCi98eh1ragbNWn1rbrfWoU0GBSl2tc/Euv4DVAK2E3b97m+uJYYtQOo2k4gB3sxYbQKktZ/QRUnruXeKQ/qI9jXvBOsGFzx04C7+Ff+HaM+1+h5+/0q93NaaVufD2IOCPrA== Original-Received: from VI1EUR05FT025.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc12::52) by VI1EUR05HT049.eop-eur05.prod.protection.outlook.com (2a01:111:e400:fc12::76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.34; Mon, 5 Oct 2020 00:55:09 +0000 Original-Received: from VI1PR06MB4526.eurprd06.prod.outlook.com (2a01:111:e400:fc12::43) by VI1EUR05FT025.mail.protection.outlook.com (2a01:111:e400:fc12::123) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.34 via Frontend Transport; Mon, 5 Oct 2020 00:55:09 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:A489F406C9C2A4A76DF020367BED4D7D2227E4A351A36776492DB37CCEAD786B; UpperCasedChecksum:85F5780477C982E467FA13BDB4DC3356BC4562C7184725BEFDD9C63031AAC3FC; SizeAsReceived:7196; Count:43 Original-Received: from VI1PR06MB4526.eurprd06.prod.outlook.com ([fe80::b547:51cd:16c5:4487]) by VI1PR06MB4526.eurprd06.prod.outlook.com ([fe80::b547:51cd:16c5:4487%7]) with mapi id 15.20.3433.044; Mon, 5 Oct 2020 00:55:09 +0000 X-TMN: [N8BatQOmN3fXh2Z667Q/wgfbp8iG7ZyV] X-ClientProxiedBy: AM5PR0101CA0004.eurprd01.prod.exchangelabs.com (2603:10a6:206:16::17) To VI1PR06MB4526.eurprd06.prod.outlook.com (2603:10a6:803:ac::17) X-Microsoft-Original-Message-ID: <87v9fpbifo.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (90.230.29.56) by AM5PR0101CA0004.eurprd01.prod.exchangelabs.com (2603:10a6:206:16::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3433.32 via Frontend Transport; Mon, 5 Oct 2020 00:55:08 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 43 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 73c11f1f-ea60-47f8-2194-08d868c94e78 X-MS-TrafficTypeDiagnostic: VI1EUR05HT049: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6IAXkgo/17uH+6yOJXQwK2S9AFbTKZfXE1cIpKy6hP2axh25hdLvULC4WUvErQOiE/IwPBTcS1BNwEq0VATRfBM2PReMAXFY+lHBLfBOGF4LvzQv/XmHbQatx9GVhc+zcsxco9+UwgbHeqNZvibDXyK8+DH7Lyv2kVqm7On01LQe0LJoe3zHrjZVEu3uQCxJ4L7wL2isSV6WskIJ+jZaGA== X-MS-Exchange-AntiSpam-MessageData: rHF9yVjaTkyUCWpfshlkxjs9F2NOYTuXaqyJG1qLek1nIEjT/b0CeYx2N5JERfuXyhk5GKbUQRmwPUGUDpPpEJ3k7bTTmyT6jA7eGgAf1obGxCRCimvsak5V3UpfCfZl3I6LzAAuoXr2+Pko6T25CQ== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73c11f1f-ea60-47f8-2194-08d868c94e78 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2020 00:55:09.5001 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VI1EUR05FT025.eop-eur05.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1EUR05HT049 Received-SPF: pass client-ip=40.92.91.60; envelope-from=arthur.miller@live.com; helo=EUR05-AM6-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/04 20:55:10 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] 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, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:257059 Archived-At: --=-=-= Content-Type: text/plain I played a bit, and it does not look so bad actually. I have played both with 'propertized' widget and one with 'plain' text; the latter takes less space on the screen; but it is just to switch comments and test the propertized version in the patch. Adding a checkbox wasn't difficult part and modifiying x-show-tip accordingly wasn't the hard part. x-show-tip in xfns.c is almost unchanged minus the part for creating a new buffer and inserting the string. However, I don't know where to look for mouse motion callback to turn off automatic hiding on mouse move. Anyway, with patch it is possible to see how it looks like, even if callback itself does not work. I added a customize option tooltip-enable-sticky (off by default) which takes effect only if gtk tooltips are disabled: (setq x-gtk-use-system-tooltips nil tooltip-enable-sticky t) It is just an idea how it might look and work to see if it is interesting to have. --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=tooltip.el.patch Content-Transfer-Encoding: quoted-printable Content-Description: tooltip.el.patch --- tooltip.el 2020-08-21 15:12:24.108484748 +0200 +++ lisp/tooltip.el 2020-10-05 02:47:13.662826815 +0200 @@ -26,6 +26,7 @@ ;;; Code: =20 (require 'syntax) +(require 'widget) ; for "sticky" tooltips =20 (defvar comint-prompt-regexp) =20 @@ -164,6 +165,14 @@ :group 'tooltip :version "27.1") =20 +(defcustom tooltip-enable-sticky nil + "Set this variable to true to enable `sticky' tooltip interface. +This variable does not have effect when Gtk tooltips are enabled + (requires Emacs to be compiled with Gtk suppoart and + x-gtk-use-system-tootlip to be set to true)." + :type 'boolean + :group 'tooltip) + =0C ;;; Variables that are not customizable. =20 @@ -258,12 +267,61 @@ (setf (alist-get 'border-color params) fg)) (when (stringp bg) (setf (alist-get 'background-color params) bg)) - (x-show-tip (propertize text 'face 'tooltip) - (selected-frame) - params - tooltip-hide-delay - tooltip-x-offset - tooltip-y-offset)) + (if x-gtk-use-system-tooltips + (x-show-tip (propertize text 'face 'tooltip) + (selected-frame) + params + tooltip-hide-delay + tooltip-x-offset + tooltip-y-offset) + + ;; we are not using gtk + (with-current-buffer (get-buffer-create " *tip*") + (let ((inhibit-read-only t)) + (erase-buffer) + (remove-overlays) + (insert (propertize text 'face 'tooltip)) + + (when tooltip-enable-sticky + (goto-char (point-min)) + (let ((cur-line 0) + (lng-line 0)) + (while (not (eobp)) + (setq cur-line (- (line-end-position) (line-beginnin= g-position))) + (when (> cur-line lng-line) + (setq lng-line cur-line)) + (forward-line)) + + (newline) + + ;; (insert (propertize + ;; (make-string (- lng-line 6) ?=E2=94= =80) + ;; 'face 'tooltip)) + ;; (widget-insert (propertize " Sticky " 'face + ;; 'tooltip)) + (insert (make-string (- lng-line 6) ?=E2=94=80)) + (widget-insert " Sticky ") + (widget-create 'checkbox + :notify (lambda (s &rest ignore) + (if (widget-value s) + (progn ;; OBS nothing her= e yet + ;; (when tooltip-timer + ;; (cancel-timer tool= tip-timer) + ;; (setq tooltip-time= r nil)) + ) + ;; else + (tooltip-hide)))) + (use-local-map widget-keymap) + (widget-setup))) + + ;; this (propertize text ... ) here is unnecessary + ;; ... but this is just a fast hack + (x-show-tip (propertize text 'face 'tooltip) + (selected-frame) + params + tooltip-hide-delay + tooltip-x-offset + tooltip-y-offset))))) (error (message "Error while displaying tooltip: %s" error) (sit-for 1) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=xfns.c.patch Content-Description: xfns.c.patch --- xfns.c 2020-09-27 12:07:36.298841349 +0200 +++ src/xfns.c 2020-10-05 02:15:01.690628616 +0200 @@ -7081,7 +7081,11 @@ buffer. */ count_1 = SPECPDL_INDEX (); old_buffer = current_buffer; + /* set_buffer_internal_1 (XBUFFER (w->contents)); + specbind (Qinhibit_read_only, Qt); + specbind (Qinhibit_modification_hooks, Qt); + specbind (Qinhibit_point_motion_hooks, Qt); bset_truncate_lines (current_buffer, Qnil); specbind (Qinhibit_read_only, Qt); specbind (Qinhibit_modification_hooks, Qt); @@ -7092,6 +7096,7 @@ clear_glyph_matrix (w->current_matrix); SET_TEXT_POS (pos, BEGV, BEGV_BYTE); try_window (window, pos, TRY_WINDOW_IGNORE_FONTS_CHANGE); + */ /* Calculate size of tooltip window. */ size = Fwindow_text_pixel_size (window, Qnil, Qnil, Qnil, make_fixnum (w->pixel_height), Qnil); --=-=-=--