Initial Commit
[packages] / xemacs-packages / hyperbole / h-skip-bytec.lsp
1 ;;; h-skip-bytec.lsp --- Functions that should not be byte-compiled.
2
3 ;; Copyright (C) 1992-1995, 2006, 2007 Free Software Foundation, Inc.
4 ;; Developed with support from Motorola Inc.
5
6 ;; Author: Bob Weiner, Brown U.
7 ;; Maintainer: Mats Lidell <matsl@contactor.se>
8 ;; Keywords: mouse, hypermedia
9
10 ;; This file is part of GNU Hyperbole.
11
12 ;; GNU Hyperbole is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 3, or (at
15 ;; your option) any later version.
16
17 ;; GNU Hyperbole is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 ;; General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
26
27 ;;; Commentary:
28 ;;
29 ;;   DON'T byte-compile this file or its functions may not work.
30 ;;   If we knew why they won't work, they wouldn't be in here.
31 ;;
32
33 ;;; Code:
34
35 ;;;
36 ;;; Public functions
37 ;;;
38
39 ;;; For some reason, using this in byte-compiled form causes first character
40 ;;; after mouse key depress to be dropped from input queue when running
41 ;;; Emacs under X.  The non-byte-compiled form works fine.
42
43 (defun hmouse-set-point (args)
44   "Sets point to Smart Key press/release location given by ARGS.
45 Returns argument list including x and y frame coordinates in characters and
46 lines."
47   (and (car args) (listp (car args)) (setq args (car args)))
48   (if (not hyperb:window-system)
49       (point-marker)
50     (let ((point-args (hmouse-set-point-at args)))
51       (cond (hyperb:xemacs-p
52              (if (eventp current-mouse-event)
53                  (copy-event current-mouse-event)))
54             (hyperb:xemacs-p
55              (cond ((and (fboundp 'mouse-position)
56                          ;; mouse-position returns nil coords when not over
57                          ;; existing text within a window, so we can only use
58                          ;; its coordinates when non-nil.  It returns a cons
59                          ;; of (device X . Y) in chars.  We drop the device
60                          ;; and assume the selected frame.
61                          (car (cdr (setq point-args (mouse-position)))))
62                     (cdr point-args))
63                    ((and (fboundp 'read-mouse-position)
64                          ;; read-mouse-position returns nil coords when not
65                          ;; over existing text within a window, so we can
66                          ;; only use its coordinates when non-nil.  It
67                          ;; returns a cons of (X . Y) in chars.
68                          (car (setq point-args (read-mouse-position
69                                                 (selected-frame)))))
70                     point-args)
71                    (t
72                     ;; We just compute X and Y from event's location.
73                     (cons (event-x current-mouse-event)
74                           (event-y current-mouse-event)))))
75             (hyperb:epoch-p
76               ;; Modeline clicks return nil for point position so we
77               ;; must compute it instead of using the arguments given.
78               (let ((x-char (/ (* mouse::x (window-width))
79                                (window-pixwidth)))
80                     (y-char (/ (* mouse::y (window-height))
81                                (window-pixheight))))
82                 (apply 'list x-char y-char args)))
83             ((or (equal hyperb:window-system "next")
84                  (equal hyperb:window-system "sun"))
85              (let ((win (car args)))
86                (list win
87                      (+ (nth 1 args) (nth 0 (window-edges win)))
88                      (+ (nth 2 args) (nth 1 (window-edges win))))))
89             ((equal hyperb:window-system "apollo") point-args)
90             (t args)))))
91
92 (provide 'h-skip-bytec)
93
94 ;;; h-skip-bytec.lsp ends here