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, 28 Sep 2020 22:04:50 +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="23229"; 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 Sep 28 22:06:37 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 1kMzPw-0005vo-6G for ged-emacs-devel@m.gmane-mx.org; Mon, 28 Sep 2020 22:06:36 +0200 Original-Received: from localhost ([::1]:55848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMzPv-0006QO-7j for ged-emacs-devel@m.gmane-mx.org; Mon, 28 Sep 2020 16:06:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kMzOL-0005pn-MR for emacs-devel@gnu.org; Mon, 28 Sep 2020 16:04:59 -0400 Original-Received: from mail-am7eur06olkn2104.outbound.protection.outlook.com ([40.92.16.104]:2017 helo=EUR06-AM7-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 1kMzOJ-0006hH-4q for emacs-devel@gnu.org; Mon, 28 Sep 2020 16:04:57 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KVhBLpfiOU9TE5jyf11hI1/Kpb/m5Uc1fecjD5/mTdXR2c5wOpx2Wo1E1CCTrA2LY1Re92ynnc20d1Ysn+VPcNGVnnuW1hJaKCjkb/jsLRdFp/n2HkoDr4hLcvTyZaSR/aBIiMgQUmkFRaGsHIydL4dVmLNIfN/CS2eD6AVzrC8ZLosjRgo5zDFsbbmsFYu84deWKhLM8pq6rh1WvVZpIdCc+B8/f/5cF13Ok6ZyX9tYni8YKTkoF5494qjqwb60y7OgU9sivl1I8jTQ6I/VLFab5LqXrIAjnOBVFPZvu07QC8pnKoLyLwDyw/fhJn/tMJTJROTbX0mfl2zGuZ55VA== 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=94iWxxdBsVUvVgRfNeVNlGpMwujxHNmx8kSrEvl9xQk=; b=T6SgGzTY53fpERGUhwenvsxQlIoHJ53cWFawfZ1ofPGZpbIovc82Hq+T5XVQ4ApnQghMZsLCb436IK4oyyk8IhPmVro0GlYzvIBw+VSkP4GmwmIcUB+wdC8aCIANe17rzgnGLxJEF20TVe8nS8aG9T6K+fK9OOhXJW80upQDJoRaDU/CwnjgxHgsYV4qckrHzD7m7H86sg28hyLUrofFaEVCbg/MtAwdkh9Zp+tEeAaeo3+5EEUh//6Jq/+y/OtIad+dRMtKB15dYG5Z1uTm70uIOe7lrSRbmxYMFia7LtRncY2baF31C2PbR9DiIgwrBBW79YcfcdOuKDURthL1zA== 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=94iWxxdBsVUvVgRfNeVNlGpMwujxHNmx8kSrEvl9xQk=; b=fgZb1pqi7kMtqjbkYv5qYb/46dhXElF9urRDnPUxzAK8smkzGThTpzD3Dfe3bzNpUL/qJayZWe9eSzr7hqMUYxPVEajrNgP+kGPGgCxAqHi/tiEUQxntYCA/RC1eZWhCv6LmxJ3zu225pEoriRLORuDYOsDheIOnzAq1OK17F5EznHqf1JWvwtG9AsTI9Qip7nrMYWPJTJ2riGJA3D7XKjT1NphFPAXpKZcvZ+OWzfGVPYML8yTv9v+y8UARZCTVYhwUtm5UiRWufAZZ7Tp2rK1hUYDQCfQMhaMqlmRf3l+yb1l3Ko827PFWsJTUjhaNZmOXt4UtbdEgit6T1fimNw== Original-Received: from DB8EUR06FT011.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc35::4b) by DB8EUR06HT024.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc35::448) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.25; Mon, 28 Sep 2020 20:04:52 +0000 Original-Received: from VI1PR06MB4526.eurprd06.prod.outlook.com (2a01:111:e400:fc35::4b) by DB8EUR06FT011.mail.protection.outlook.com (2a01:111:e400:fc35::223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.21 via Frontend Transport; Mon, 28 Sep 2020 20:04:52 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:400EBBCCDA0F1FB4B91C0AF88B34E7CB04033C9D61ECB760704CFAD9AF133C0E; UpperCasedChecksum:94384B9DFC57D3B611E4B83CAE22A37A6E1632A6349B6ACB03A20768103864B1; SizeAsReceived:7247; Count:44 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.3412.028; Mon, 28 Sep 2020 20:04:51 +0000 X-ClientProxiedBy: AM5PR0601CA0039.eurprd06.prod.outlook.com (2603:10a6:203:68::25) To VI1PR06MB4526.eurprd06.prod.outlook.com (2603:10a6:803:ac::17) X-Microsoft-Original-Message-ID: <875z7xy8f1.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from pascal.homepc (90.230.29.56) by AM5PR0601CA0039.eurprd06.prod.outlook.com (2603:10a6:203:68::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.20 via Frontend Transport; Mon, 28 Sep 2020 20:04:51 +0000 X-Microsoft-Original-Message-ID: <875z7xy8f1.fsf@live.com> X-TMN: [3CUXxBUXPkdQtP+LyOS5TjsIhxxZv4hm] X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 44 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: aec905f0-d429-49a1-eb3b-08d863e9c25c X-MS-TrafficTypeDiagnostic: DB8EUR06HT024: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KinCG6NAVtC0yK9F4f3oNYTT6zpyTYfsBBANKr8UMVveh22zC7WnSPjjDPVghzq5do3R1l5o2V4AP1JkfXWqvp0s6/H4D7gTiqn9B70Qfy3vyhVJfdHuBdDS3/PSQ5QwEFoxYzXh6DhpjT4qHrgzq5nVHExfAHg8maiqHCweeVEoOrBAPOCvXWsEQ1EazpMk3XubeUQ1brueAS80PpF5lQ== X-MS-Exchange-AntiSpam-MessageData: lTJiONf8uB2LDtICzymdVyB7EiUzjhN4URZUgRf2Q2BTljqjTWVLYbjb6ryrvHeYH3XBV8qSrONsQY7CDnM0WBXh7hrNSNKDseTk8Dju+550Yc5B5KlJCN5RQpSVmASQv7Q4oOjoBCGmQkzTEuamPw== X-OriginatorOrg: live.com X-MS-Exchange-CrossTenant-Network-Message-Id: aec905f0-d429-49a1-eb3b-08d863e9c25c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2020 20:04:51.8630 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: DB8EUR06FT011.eop-eur06.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: DB8EUR06HT024 Received-SPF: pass client-ip=40.92.16.104; envelope-from=arthur.miller@live.com; helo=EUR06-AM7-obe.outbound.protection.outlook.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/28 16:04:52 X-ACL-Warn: Detected OS = Windows NT kernel [generic] [fuzzy] X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 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.614, 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:256637 Archived-At: --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=poor-man-tooltip.el Content-Description: test ;;; poor-man-tooltip.el --- -*- lexical-binding: t; -*- (require 'widget) (defvar pm-tooltip-duration) (setq pm-tooltip-duration 4) (defun pm-test () (interactive) (pm-tooltip "Here is some tootip text.")) (define-minor-mode pm-minor-mode "" :keymap (let ((map (make-sparse-keymap))) (define-key map (kbd "C-g") 'pm-quit-tooltip) map)) (defun pm-tooltip (tooltip-text) (let ((cur-line 0) (lng-line 0) (tooltip-timer nil) (tooltip-frame nil)) (with-current-buffer (get-buffer-create "tooltip-buffer") (kill-all-local-variables) (let ((inhibit-read-only t)) (erase-buffer)) (remove-overlays) (insert " ") (insert tooltip-text) (goto-char (point-min)) (while (not (eobp)) (setq cur-line (- (line-end-position) (line-beginning-position))) (when (> cur-line lng-line) (setq lng-line cur-line)) (forward-line)) (newline) (insert-char ?- (- lng-line 6)) (widget-insert " Sticky ") (widget-create 'checkbox :notify (lambda (s &rest ignore) (if (widget-value s) (progn (when tooltip-timer (cancel-timer tooltip-timer) (setq tooltip-timer nil)) (message "Sticky tooltip enabled!")) ;; else (progn (when tooltip-frame (setq tooltip-timer (pm-start-timer tooltip-frame))) (message "Sticky tooltip disabled!"))))) (use-local-map widget-keymap) (widget-setup)) (setq tooltip-frame (pm-show-at-cursor "tooltip-buffer")) (setq tooltip-timer (pm-start-timer tooltip-frame)))) (defun pm-quit-tooltip (tooltip-frame) (with-current-buffer (get-buffer "tooltip-buffer") (kill-buffer)) (delete-frame tooltip-frame)) (defun pm-start-timer (tooltip-frame) (let ((tooltip-timer (run-with-timer pm-tooltip-duration nil (apply-partially #'pm-quit-tooltip tooltip-frame)))) tooltip-timer)) (defun pm-show-at-point (menuname) (let ((position (pos-visible-in-window-p nil nil t))) (pm-create-tooltip menuname (nth 0 position) (nth 1 position)))) (defun pm-show-at-cursor (menuname) (let ((cursor-pos (mouse-pixel-position))) (pm-create-tooltip menuname (cadr cursor-pos) (cddr cursor-pos)))) (defun pm-create-tooltip (menuname x y) (with-current-buffer (get-buffer menuname) (pm-minor-mode) (setq tab-line-format nil) (setq mode-line-format nil) (setq cursor-type nil) (setq buffer-read-only t) (let ((parent (selected-frame)) (child-frame (make-frame '((visible . 0) (border-width . 2) (internal-border-width . 2) (undecorated . 0) (keep-ratio . t) (menu-bar-lines . 0) (tool-bar-lines . 0) (left-fringe . 0) (right-fringe . 0) (line-spacing . 0) (unsplittable . t) (minibuffer . nil) (no-other-frame . t) (drag-internal-border . t) (inhibit-double-buffering . t) (desktop-dont-save . t))))) (set-frame-parameter child-frame 'parent-frame parent) (fit-frame-to-buffer child-frame) ;; seems that afte fit-frame-to-buff there is few pixels missing (set-frame-width child-frame (+ 1 (frame-width child-frame))) (set-frame-position child-frame x y) child-frame))) (provide 'poor-man-tooltip) --=-=-= Content-Type: text/plain Somebody suggested for sticky tooltips the other day; Mr. Eli Z. explained about tooltips, when compiled in Gtk are controlled by Gtk. So I wonder - do they need to be? A tooltip is just a small pop-up window showing some text (usually). Emacs is already very good at showing text in all kind of windows so question is, is Gtk really needed to render tooltips? Even if Emacs is compiled with Gtk? Is there any special advantage over an "Emacs frame"? I tested idea with a sticky tooltip based on just ordinary buffer displayed in a child frame. I haven't done any text styling/propertizing, faces, colors etc. The frame is displayed at mouse cursor (just for test) and it starts a timer which deletes frame after an (customizable) interval. There is a small checkbox to make it "sticky" (it just removed the expiration timer); toggling it on will start timer again. It is just a sketch of the idea; i just wonder if such similar tooltip implementatation (all Emacs) would be interesting. It seems to be quite trivial and if it is done all in Elisp then I guess it would be same on all gui platforms? --=-=-=--