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: Thu, 22 Oct 2020 18:17:53 +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="18612"; 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 Thu Oct 22 18:19:03 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 1kVdIt-0004h9-0A for ged-emacs-devel@m.gmane-mx.org; Thu, 22 Oct 2020 18:19:03 +0200 Original-Received: from localhost ([::1]:41142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVdIs-0005YI-2E for ged-emacs-devel@m.gmane-mx.org; Thu, 22 Oct 2020 12:19:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVdHv-0004FN-Jn for emacs-devel@gnu.org; Thu, 22 Oct 2020 12:18:04 -0400 Original-Received: from mail-oln040092075059.outbound.protection.outlook.com ([40.92.75.59]:53988 helo=EUR04-VI1-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 1kVdHr-0003RK-DV for emacs-devel@gnu.org; Thu, 22 Oct 2020 12:18:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EcTKBmuhoNsSa0xZHWN9rgP69+2LEP2vQK8go48SU+my/2pA1JnOHDDTpSe2e49BR0+CGX6mBkzQ71ZvF6WCJeoSavayYGphje4pk1pVXj1F5XEGXMelnRcnv0TWiilLmqI9qCNJ75in3q03Vk+s7UaF3sx4pca0udhrUX8zi8WI7udh+5Nr7syuMDfsooNXxzktVuykal0LsW0YgniUoKP1jxlsESQxuamTz6WjV9IifrKXA1DOKukczridbK6nKjnWAVGseO0pSxOAsR+Wxx9zq/8gjwL2l4MVFgOjuWUGJcZbq5EX9BRJkbgyPiO/20rHSImyuMmdZxUfurqTaw== 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=zBQ5A2f8TwLIZqj7qKDO+6RglQmmjGkTfR5z9GvGSUs=; b=lGbJTohqE/n68MYBZsYpd5Nue7YzByNF1Xy3DIARB2a2KtvFbgm0sGjmEV3nPE8PNC6RlC7c5B8xUyBmFPaA002QT4zoppVsHo6LcDu/aBQQDiqz70QlXr4Hqmf9B2eq7k48ZEV6/0qAMmL3LTXhSCXtNqSq0gSormNkW/YThihmF/Qy2vRbFDzfKRa2uIMYqbUMn0nT2QY38WwL03uvRc2Z+5bBVntbDUAvXCJW5qHJfxaT0WqcftfG9+caIRAMUI0Hcl47WNH6fFI1JL0S1kN+s59ORx7UWWohM325XhQu11gKRrJeKfIVtAGyJTO/SFG6WGlhBEG6gf3nVuCq5w== 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=zBQ5A2f8TwLIZqj7qKDO+6RglQmmjGkTfR5z9GvGSUs=; b=VmlmM4vxcUVwmzU70scXUXF0kYp1J4NWTN2F3zZZwcAc/YNB/euPOi2LScBCcb1erFINeJ16X0PCfbjpgnm4K6WFYP9r+0IrrhlZr0bzoniCU/PznmiROZM0izyrwmUh8zBLrytZpUmhMRJ4LhTyx8NoCEgbIXodsXYoGvn1KkAw8/dDc6QNy6yphyEFX8gmRDh/Z/kTYKXHddQw8OSSzucJf7rdMtAM9z9WNm6suKjAN7EE/BPBjh3Y+0vvhRDz6f6BDYBFfcNSvoi4LPlBKQYBMDzveeYyklhu3KwIG7Dg+RFXWrRyQC644HP18SUHk0onfoUx9ZtOZDd4xSaF0Q== Original-Received: from HE1EUR04FT008.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::51) by HE1EUR04HT225.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0d::410) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Thu, 22 Oct 2020 16:17:55 +0000 Original-Received: from VI1PR06MB4526.eurprd06.prod.outlook.com (2a01:111:e400:7e0d::51) by HE1EUR04FT008.mail.protection.outlook.com (2a01:111:e400:7e0d::278) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Thu, 22 Oct 2020 16:17:55 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:EE07F81810A7F8F3075C8367E3BFD43F2F62F37A8B2FC15F681D6665F2FE10AD; UpperCasedChecksum:E2F2E7FF014A3C98EAEF794E04F06A141EF0323C17A20EF7C48F71FC27B081B5; SizeAsReceived:8304; Count:43 Original-Received: from VI1PR06MB4526.eurprd06.prod.outlook.com ([fe80::187b:196a:cb2d:adf1]) by VI1PR06MB4526.eurprd06.prod.outlook.com ([fe80::187b:196a:cb2d:adf1%5]) with mapi id 15.20.3477.028; Thu, 22 Oct 2020 16:17:54 +0000 X-TMN: [J+X7sqhhWH1X0DUOj5ps1GximvIqNFjc] X-ClientProxiedBy: AM6P195CA0002.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:81::15) To VI1PR06MB4526.eurprd06.prod.outlook.com (2603:10a6:803:ac::17) X-Microsoft-Original-Message-ID: <875z722q1a.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (90.230.29.56) by AM6P195CA0002.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:81::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18 via Frontend Transport; Thu, 22 Oct 2020 16:17:54 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 43 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 3ac2d7c1-8a4d-4449-5388-08d876a607e1 X-MS-TrafficTypeDiagnostic: HE1EUR04HT225: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lRD1jRnDNYKmXT6gEJ5By+VxAPjyqkaCPcVCGOqsu6GHzRjzngUfhBlMGA0TOoZLby1ExlLU8gYtk8VTfN1Zf3ejZBhNajd+dQjpBfP2QuyDAOdf9+rrXMvEvI42kp9Y8RssAROiaUpygTGJsAK4aljfuG9oT2+4X58DRVZDvaLbPFRWAOoFd3FTUT44SWSwCcC9JqPXxocP/mwX0X6VKg== X-MS-Exchange-AntiSpam-MessageData: 1K64zd/x4TIDgjiXuuFEHUyLUnW57AsxAnm4j0mbHGaDtNTqJRKONUqo4bWpwu3qwlffpjkwO1jotyPdmxU40PQgyeDFfoQoQQP18KX2Cl94skpM2CgaCCRfmXMcDZwUqtrOooAT7azyE12OMJqkAg== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ac2d7c1-8a4d-4449-5388-08d876a607e1 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Oct 2020 16:17:54.9547 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR04FT008.eop-eur04.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: HE1EUR04HT225 Received-SPF: pass client-ip=40.92.75.59; envelope-from=arthur.miller@live.com; helo=EUR04-VI1-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/22 12:17:55 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:258309 Archived-At: --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=sticky-tips.patch Content-Transfer-Encoding: quoted-printable diff --git a/lisp/tooltip.el b/lisp/tooltip.el index ffc3d499e3..8ca56f2100 100644 --- a/lisp/tooltip.el +++ b/lisp/tooltip.el @@ -67,6 +67,10 @@ tooltip-mode =20 =0C ;;; Customizable settings +;; keep true while testing, will be default nil +(defcustom tooltip-enable-sticky-tips t + "Seconds to wait before displaying a tooltip the first time." + :type 'boolean) =20 (defcustom tooltip-delay 0.7 "Seconds to wait before displaying a tooltip the first time." @@ -175,6 +179,9 @@ tooltip-hide-time =20 (defvar gud-tooltip-mode) ;; Prevent warning. =20 +(defvar sticky-tooltip-timer nil + "Time during which sticky tooltip is not hidden.") + ;;; Event accessors =20 (defun tooltip-event-buffer (event) @@ -210,6 +217,10 @@ tooltip-timeout (run-hook-with-args-until-success 'tooltip-functions tooltip-last-mouse-motion-event)) =20 +(defun tooltip-start-sticky-timer () + (setq sticky-tooltip-timer + (run-with-timer tooltip-hide-delay nil 'tooltip-hide) + sticky-is-up t)) =0C ;;; Displaying tips =20 @@ -237,6 +248,8 @@ tooltip-show =20 Optional second arg USE-ECHO-AREA non-nil means to show tooltip in echo area." + ;; while testing keep gtk tips off + (setq x-gtk-use-system-tooltips nil) (if use-echo-area (tooltip-show-help-non-mode text) (condition-case error @@ -248,12 +261,47 @@ tooltip-show (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) + + (unless x-gtk-use-system-tooltips + (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-tips + (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 (make-string (- lng-line 6) ?=E2=94=80)) + (widget-insert " Sticky ") + (widget-create 'checkbox + :notify + (lambda (s &rest ignore) + (if (widget-value s) + (message "START WIDGET") + (message "EXIT WIDGET")))) + (use-local-map widget-keymap) + (widget-setup)))))) + + ;; text properties are now handled, in buffer, and + ;; 'text' argument is only needed for gtk-tooltips + ;; (not used if we are here) + (x-show-tip text + (selected-frame) params tooltip-hide-delay tooltip-x-offset - tooltip-y-offset)) + tooltip-y-offset) + + (when tooltip-enable-sticky-tips + (tooltip-start-sticky-timer))) (error (message "Error while displaying tooltip: %s" error) (sit-for 1) @@ -368,7 +416,8 @@ tooltip-show-help (cond ((null msg) ;; Cancel display. This also cancels a delayed tip, if ;; there is one. - (tooltip-hide)) + (unless sticky-tooltip-timer + (tooltip-hide))) ((equal-including-properties previous-help msg) ;; Same help as before (but possibly the mouse has moved). ;; Keep what we have. @@ -376,6 +425,8 @@ tooltip-show-help (t ;; A different help. Remove a previous tooltip, and ;; display a new one, with some delay. + (when sticky-tooltip-timer + (cancel-timer sticky-tooltip-timer)) (tooltip-hide) (tooltip-start-delayed-tip)))) ;; On text-only displays, try `tooltip-show-help-non-mode'. diff --git a/src/xfns.c b/src/xfns.c index 46e4bd73a6..afb26b6b94 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -6909,7 +6909,6 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, = 0, dy =3D make_fixnum (-10); else CHECK_FIXNUM (dy); - #ifdef USE_GTK if (x_gtk_use_system_tooltips) { @@ -6930,6 +6929,7 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, = 0, unblock_input (); if (ok) goto start_timer; } + #endif /* USE_GTK */ =20 if (FRAMEP (tip_frame) && FRAME_LIVE_P (XFRAME (tip_frame))) @@ -7081,20 +7081,20 @@ DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6= , 0, buffer. */ count_1 =3D SPECPDL_INDEX (); old_buffer =3D current_buffer; - set_buffer_internal_1 (XBUFFER (w->contents)); - bset_truncate_lines (current_buffer, Qnil); - specbind (Qinhibit_read_only, Qt); - specbind (Qinhibit_modification_hooks, Qt); - specbind (Qinhibit_point_motion_hooks, Qt); - Ferase_buffer (); - Finsert (1, &string); - clear_glyph_matrix (w->desired_matrix); - 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. */ + // set_buffer_internal_1 (XBUFFER (w->contents)); + // bset_truncate_lines (current_buffer, Qnil); + // specbind (Qinhibit_read_only, Qt); + // specbind (Qinhibit_modification_hooks, Qt); + // specbind (Qinhibit_point_motion_hooks, Qt); + // Ferase_buffer (); + // Finsert (1, &string); + // clear_glyph_matrix (w->desired_matrix); + // 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 =3D Fwindow_text_pixel_size (window, Qnil, Qnil, Qnil, - make_fixnum (w->pixel_height), Qnil); + make_fixnum (w->pixel_height), Qnil); /* Add the frame's internal border to calculated size. */ width =3D XFIXNUM (Fcar (size)) + 2 * FRAME_INTERNAL_BORDER_WIDTH (tip_f= ); height =3D XFIXNUM (Fcdr (size)) + 2 * FRAME_INTERNAL_BORDER_WIDTH (tip_= f); --=-=-= Content-Type: text/plain I had a bit of time today to play with the idea of sticky tooltips. I am still testing the interaction between tooltips and frame; so I tried with a timer to keep a tooltip alive long enough so that user can move mouse into the frame to enable a frame to be sticky (no functionality yet). I am having a little bit of a problem there; and I am not really sure why. When I move mouse slow enough, it works for the most part; but if mouse is moved quickly it sometimes work, sometimes not, and sometimes a bit jerky: the tip frame "jumps" after the mouse. I guess it all depends on timers and how Emacs delivers events. I am not sure what would be the best strategy to go about this, so I appreciate if someone can give me a tip (pun intended). --=-=-=--