unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob 0927f1c4c1071e8f6e5cbff62bf83d1680876742 2878 bytes (raw)
name: lisp/touch-screen.el 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
 
;;; touch-screen.el --- Touchscreen support for GNU Emacs. -*- lexical-binding: t -*-

;; Copyright (C) 2020 Free Software Foundation, Inc.

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; This package provides touch-screen support for GNU Emacs on GTK 4 terminals.
;; This relies on several GTK 4-specific event handling changes, and is unlikely
;; to work well on other platforms.

;;; Code:

(unless (and (or (string-prefix-p "3.98" gtk-version-string)
                 (string-prefix-p "4." gtk-version-string)))
  (error "Trying to load touch-screen.el on an incompatible terminal"))

(require 'widget)

(defvar touch-screen--idle-timer nil
  "The timer that will be used for action popovers.")

(defun touch-screen-pop-up-actions-frame ()
  "Display the selection items popover."
  (interactive)
  (pgtk-show-selection-options (selected-frame)))

(define-minor-mode touch-screen-mode
  "A mode for touchscreen device that displays
several graphical elements suitable for use on touchscreens."
  :global t
  :lighter nil)

(defun touch-screen--after-mark-set ()
  "Internal function for `touch-screen-after-mark-set'."
  (when (and pgtk-last-event-from-touchscreen
             touch-screen-mode
             (region-active-p)
             (window-system)
             (> (abs (- (mark) (point))) 5))
    (touch-screen-pop-up-actions-frame)))

(defun touch-screen-after-mark-set ()
  "This function will be run after the mark is set.
It will display the pop-up frame if `pgtk-last-event-from-touchscreen'
is non-nil."
  (when (window-system)
    (when touch-screen--idle-timer
      (cancel-timer touch-screen--idle-timer))
    (setq touch-screen--idle-timer
          (run-with-idle-timer 1 nil #'touch-screen--after-mark-set))))

(defun touch-screen--safe-kill ()
  "Kill the region, without raising errors if it is not possible."
  (when (not (and buffer-read-only
                  (not inhibit-read-only)
                  (not (get-text-property (point) 'inhibit-read-only))))
    (unwind-protect
        (kill-region (mark) (point))
      nil)))

(add-hook 'activate-mark-hook #'touch-screen-after-mark-set)
(add-hook 'post-command-hook #'touch-screen-after-mark-set)

(provide 'touch-screen)
;;; touch-screen.el ends here

debug log:

solving 0927f1c4c1 ...
found 0927f1c4c1 in https://yhetil.org/emacs-devel/87zhaxjpea.fsf@yahoo.com/

applying [1/1] https://yhetil.org/emacs-devel/87zhaxjpea.fsf@yahoo.com/
diff --git a/lisp/touch-screen.el b/lisp/touch-screen.el
new file mode 100644
index 0000000000..0927f1c4c1

Checking patch lisp/touch-screen.el...
Applied patch lisp/touch-screen.el cleanly.

index at:
100644 0927f1c4c1071e8f6e5cbff62bf83d1680876742	lisp/touch-screen.el

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).