/[mcclim]/mcclim/frames.lisp
ViewVC logotype

Contents of /mcclim/frames.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.133 - (hide annotations)
Tue Feb 5 08:53:09 2008 UTC (6 years, 2 months ago) by thenriksen
Branch: MAIN
CVS Tags: McCLIM-0-9-6
Changes since 1.132: +7 -1 lines
Added restart for re-executing commands.
1 mikemac 1.1 ;;; -*- Mode: Lisp; Package: CLIM-INTERNALS -*-
2    
3     ;;; (c) copyright 1998,1999,2000 by Michael McDonald (mikemac@mikemac.com)
4 cvs 1.4 ;;; (c) copyright 2000 by
5     ;;; Iban Hatchondo (hatchond@emi.u-bordeaux.fr)
6     ;;; Julien Boninfante (boninfan@emi.u-bordeaux.fr)
7     ;;; Robert Strandh (strandh@labri.u-bordeaux.fr)
8 gilbert 1.95 ;;; (c) copyright 2004 by
9     ;;; Gilbert Baumann <unk6@rz.uni-karlsruhe.de>
10 mikemac 1.1
11     ;;; This library is free software; you can redistribute it and/or
12     ;;; modify it under the terms of the GNU Library General Public
13     ;;; License as published by the Free Software Foundation; either
14     ;;; version 2 of the License, or (at your option) any later version.
15     ;;;
16     ;;; This library is distributed in the hope that it will be useful,
17     ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18     ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19     ;;; Library General Public License for more details.
20     ;;;
21     ;;; You should have received a copy of the GNU Library General Public
22     ;;; License along with this library; if not, write to the
23     ;;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24     ;;; Boston, MA 02111-1307 USA.
25    
26 mikemac 1.60 (in-package :clim-internals)
27 mikemac 1.1
28 gilbert 1.33 ;; *application-frame* is in decls.lisp
29 mikemac 1.1 (defvar *default-frame-manager* nil)
30    
31 cvs 1.5 ;;; Frame-Manager class
32    
33 ahefner 1.122 ;; FIXME: The spec says the port must "conform to options".
34     ;; I've added a check that the ports match, but we've no
35     ;; protocol for testing the other options. -Hefner
36 cvs 1.5 (defun find-frame-manager (&rest options &key port &allow-other-keys)
37     (declare (special *frame-manager*))
38 ahefner 1.122 (if (and (boundp '*frame-manager*)
39     (or (null port)
40     (eql port (frame-manager-port *frame-manager*))))
41 cvs 1.5 *frame-manager*
42     (if (and *default-frame-manager*
43 ahefner 1.122 (frame-manager-p *default-frame-manager*)
44     (or (null port)
45     (eql port (frame-manager-port *default-frame-manager*))))
46 cvs 1.5 *default-frame-manager*
47 ahefner 1.122 (first (frame-managers (or port (apply #'find-port options)))))))
48 cvs 1.5
49     (defmacro with-frame-manager ((frame-manager) &body body)
50 adejneka 1.43 `(let ((*frame-manager* ,frame-manager))
51 cvs 1.5 (declare (special *frame-manager*))
52 adejneka 1.43 (locally ,@body)))
53    
54 moore 1.94 ;;; XXX These should force the redisplay of the menu bar. They don't
55     ;;; yet.
56    
57     (defmethod note-command-enabled (frame-manager frame command-name)
58     (declare (ignore frame-manager frame command-name))
59     nil)
60    
61     (defmethod note-command-disabled (frame-manager frame command-name)
62     (declare (ignore frame-manager frame command-name))
63     nil)
64    
65 mikemac 1.1 ;;; Application-Frame class
66 moore 1.38 ;;; XXX All these slots should move to a mixin or to standard-application-frame.
67     ;;; -- moore
68 mikemac 1.1
69 brian 1.54 ; extension
70     (defgeneric frame-schedule-timer-event (frame sheet delay token))
71 adejneka 1.13
72 hefner1 1.68 (defgeneric note-input-focus-changed (pane state)
73     (:documentation "Called when a pane receives or loses the keyboard
74     input focus. This is a McCLIM extension."))
75 tmoore 1.114
76     (defclass standard-application-frame (application-frame
77     presentation-history-mixin)
78 moore 1.90 ((port :initform nil
79     :initarg :port
80     :accessor port)
81     (graft :initform nil
82     :initarg :graft
83     :accessor graft)
84     (name :initarg :name
85     :reader frame-name)
86     (pretty-name :initarg :pretty-name
87     :accessor frame-pretty-name)
88     (command-table :initarg :command-table
89     :initform nil
90     :accessor frame-command-table)
91     (named-panes :accessor frame-named-panes :initform nil)
92     (panes :initform nil :reader frame-panes
93     :documentation "The tree of panes in the current layout.")
94     (layouts :initform nil
95     :initarg :layouts
96     :reader frame-layouts)
97     (current-layout :initform nil
98     :initarg :current-layout
99     :accessor frame-current-layout)
100     (panes-for-layout :initform nil :accessor frame-panes-for-layout
101     :documentation "alist of names and panes (as returned by make-pane)")
102     (top-level-sheet :initform nil
103     :reader frame-top-level-sheet)
104     (menu-bar :initarg :menu-bar
105     :initform nil)
106     (state :initarg :state
107     :initform :disowned
108     :reader frame-state)
109     (manager :initform nil
110     :reader frame-manager
111     :accessor %frame-manager)
112     (properties :accessor %frame-properties
113     :initarg :properties
114     :initform nil)
115     (top-level :initform '(default-frame-top-level)
116     :initarg :top-level
117     :reader frame-top-level)
118     (top-level-lambda :initarg :top-level-lambda
119     :reader frame-top-level-lambda)
120     (hilited-presentation :initform nil
121     :initarg :hilited-presentation
122 ahefner 1.127 :accessor frame-hilited-presentation)
123 tmoore 1.111 (process :accessor frame-process :initform nil)
124 tmoore 1.114 (client-settings :accessor client-settings :initform nil)
125     (event-queue :initarg :frame-event-queue
126 hefner1 1.66 :initarg :input-buffer
127     :initform nil
128 moore 1.38 :accessor frame-event-queue
129     :documentation "The event queue that, by default, will be
130 moore 1.47 shared by all panes in the stream")
131     (documentation-state :accessor frame-documentation-state
132     :initform nil
133     :documentation "Used to keep of track of what
134 moore 1.89 needs to be rendered in the pointer documentation frame.")
135     (calling-frame :reader frame-calling-frame
136     :initarg :calling-frame
137     :initform nil
138     :documentation "The frame that is the parent of this
139 moore 1.94 frame, if any")
140     (disabled-commands :accessor disabled-commands
141 tmoore 1.114 :accessor frame-disabled-commands
142     :initarg :disabled-commands
143 moore 1.94 :initform nil
144     :documentation "A list of command names that have been
145 tmoore 1.114 disabled in this frame")
146     (documentation-record :accessor documentation-record
147     :initform nil
148     :documentation "updating output record for pointer
149 ahefner 1.127 documentation produced by presentations.")
150     (geometry-left :accessor geometry-left
151     :initarg :left
152     :initform nil)
153     (geometry-right :accessor geometry-right
154     :initarg :right
155     :initform nil)
156     (geometry-top :accessor geometry-top
157     :initarg :top
158     :initform nil)
159     (geometry-bottom :accessor geometry-bottom
160     :initarg :bottom
161     :initform nil)
162     (geometry-width :accessor geometry-width
163     :initarg :width
164     :initform nil)
165     (geometry-height :accessor geometry-height
166     :initarg :height
167     :initform nil)))
168    
169     (defmethod frame-geometry* ((frame standard-application-frame))
170     "-> width height &optional top left"
171     (let ((pane (frame-top-level-sheet frame)))
172     ;(destructuring-bind (&key left top right bottom width height) (frame-geometry frame)
173     (with-slots (geometry-left geometry-top geometry-right
174     geometry-bottom geometry-width
175     geometry-height) frame
176     ;; Find width and height from looking at the respective options
177     ;; first, then at left/right and top/bottom and finally at what
178     ;; compose-space says.
179     (let* ((width (or geometry-width
180     (and geometry-left geometry-right
181     (- geometry-right geometry-left))
182     (space-requirement-width (compose-space pane))))
183     (height (or geometry-height
184     (and geometry-top geometry-bottom (- geometry-bottom geometry-top))
185     (space-requirement-height (compose-space pane))))
186     ;; See if a position is wanted and return left, top.
187     (left (or geometry-left
188     (and geometry-right (- geometry-right geometry-width))))
189     (top (or geometry-top
190     (and geometry-bottom (- geometry-bottom geometry-height)))))
191     (values width height left top)))))
192 moore 1.38
193     ;;; Support the :input-buffer initarg for compatibility with "real CLIM"
194    
195     (defmethod initialize-instance :after ((obj standard-application-frame)
196 moore 1.89 &key &allow-other-keys)
197     (when (and (frame-calling-frame obj)
198     (null (frame-event-queue obj)))
199     (setf (frame-event-queue obj)
200     (frame-event-queue (frame-calling-frame obj))))
201 hefner1 1.66 (unless (frame-event-queue obj)
202 hefner1 1.72 (setf (frame-event-queue obj)
203 hefner1 1.79 (make-instance 'port-event-queue))))
204 mikemac 1.1
205     (defmethod (setf frame-manager) (fm (frame application-frame))
206     (let ((old-manager (frame-manager frame)))
207 adejneka 1.46 (setf (%frame-manager frame) nil)
208 mikemac 1.1 (when old-manager
209     (disown-frame old-manager frame)
210     (setf (slot-value frame 'panes) nil)
211     (setf (slot-value frame 'layouts) nil))
212 adejneka 1.46 (setf (%frame-manager frame) fm)))
213 mikemac 1.1
214 moore 1.90 (define-condition frame-layout-changed (condition)
215     ((frame :initarg :frame :reader frame-layout-changed-frame)))
216    
217     (defmethod (setf frame-current-layout) :after (name (frame application-frame))
218 mikemac 1.1 (declare (ignore name))
219 ahefner 1.107 (when (frame-manager frame)
220     (generate-panes (frame-manager frame) frame)
221     (multiple-value-bind (w h) (frame-geometry* frame)
222     (layout-frame frame w h))
223     (signal 'frame-layout-changed :frame frame)))
224 mikemac 1.1
225     (defmethod generate-panes :before (fm (frame application-frame))
226     (declare (ignore fm))
227 moore 1.101 (when (and (frame-panes frame)
228     (eq (sheet-parent (frame-panes frame))
229     (frame-top-level-sheet frame)))
230 moore 1.90 (sheet-disown-child (frame-top-level-sheet frame) (frame-panes frame)))
231     (loop
232     for (nil . pane) in (frame-panes-for-layout frame)
233     for parent = (sheet-parent pane)
234     if parent
235     do (sheet-disown-child parent pane)))
236 mikemac 1.1
237     (defmethod generate-panes :after (fm (frame application-frame))
238     (declare (ignore fm))
239 moore 1.90 (sheet-adopt-child (frame-top-level-sheet frame) (frame-panes frame))
240     (unless (sheet-parent (frame-top-level-sheet frame))
241     (sheet-adopt-child (graft frame) (frame-top-level-sheet frame)))
242 gilbert 1.95 ;; Find the size of the new frame
243     (multiple-value-bind (w h x y) (frame-geometry* frame)
244 crhodes 1.119 (declare (ignore x y))
245 cvs 1.5 ;; automatically generates a window-configuation-event
246     ;; which then calls allocate-space
247 gilbert 1.39 ;;
248 crhodes 1.119 ;; Not any longer, we turn off CONFIGURE-NOTIFY events until the
249 gilbert 1.39 ;; window is mapped and do the space allocation now, so that all
250     ;; sheets will have their correct geometry at once. --GB
251 mikemac 1.1 (setf (sheet-region (frame-top-level-sheet frame))
252 gilbert 1.95 (make-bounding-rectangle 0 0 w h))
253     (allocate-space (frame-top-level-sheet frame) w h) ))
254 mikemac 1.1
255     (defmethod layout-frame ((frame application-frame) &optional width height)
256 moore 1.90 (let ((pane (frame-panes frame)))
257 ahefner 1.124 (when (and (or width height)
258     (not (and width height)))
259     (error "LAYOUT-FRAME must be called with both WIDTH and HEIGHT or neither"))
260 mikemac 1.1 (if (and (null width) (null height))
261 gilbert 1.95 (let ((space (compose-space pane))) ;I guess, this might be wrong. --GB 2004-06-01
262 mikemac 1.1 (setq width (space-requirement-width space))
263     (setq height (space-requirement-height space))))
264 gilbert 1.63 (let ((tpl-sheet (frame-top-level-sheet frame)))
265     (unless (and (= width (bounding-rectangle-width tpl-sheet))
266     (= height (bounding-rectangle-height tpl-sheet)))
267     (resize-sheet (frame-top-level-sheet frame) width height)))
268 mikemac 1.1 (allocate-space pane width height)))
269    
270 adejneka 1.13 (defun find-pane-if (predicate panes)
271     "Returns a pane satisfying PREDICATE in the forest growing from PANES"
272 moore 1.90 (map-over-sheets #'(lambda (p)
273     (when (funcall predicate p)
274     (return-from find-pane-if p)))
275     panes)
276     nil)
277 moore 1.27
278 adejneka 1.13 (defun find-pane-of-type (panes type)
279     (find-pane-if #'(lambda (pane) (typep pane type)) panes))
280 adejneka 1.40
281 moore 1.90 ;;; There are several ways to do this; this isn't particularly efficient, but
282     ;;; it shouldn't matter much. If it does, it might be better to map over the
283     ;;; panes in frame-named-panes looking for panes with parents.
284 adejneka 1.13 (defmethod frame-current-panes ((frame application-frame))
285 moore 1.90 (let ((panes nil)
286     (named-panes (frame-named-panes frame)))
287     (map-over-sheets #'(lambda (p)
288     (when (member p named-panes)
289     (push p panes)))
290     (frame-panes frame))
291     panes))
292 adejneka 1.13
293     (defmethod get-frame-pane ((frame application-frame) pane-name)
294 moore 1.90 (let ((pane (find-pane-named frame pane-name)))
295     (if (typep pane 'clim-stream-pane)
296     pane
297     nil)))
298 adejneka 1.13
299     (defmethod find-pane-named ((frame application-frame) pane-name)
300 moore 1.90 (find pane-name (frame-named-panes frame) :key #'pane-name))
301 adejneka 1.13
302 mikemac 1.1 (defmethod frame-standard-output ((frame application-frame))
303 cvs 1.6 (or (find-pane-of-type (frame-panes frame) 'application-pane)
304     (find-pane-of-type (frame-panes frame) 'interactor-pane)))
305 mikemac 1.1
306     (defmethod frame-standard-input ((frame application-frame))
307 cvs 1.6 (or (find-pane-of-type (frame-panes frame) 'interactor-pane)
308 mikemac 1.1 (frame-standard-output frame)))
309    
310     (defmethod frame-query-io ((frame application-frame))
311     (or (frame-standard-input frame)
312     (frame-standard-output frame)))
313    
314     (defmethod frame-error-output ((frame application-frame))
315     (frame-standard-output frame))
316    
317     (defvar *pointer-documentation-output* nil)
318    
319     (defmethod frame-pointer-documentation-output ((frame application-frame))
320 adejneka 1.13 (find-pane-of-type (frame-panes frame) 'pointer-documentation-pane))
321 mikemac 1.1
322 moore 1.93 #+nil
323 hefner1 1.70 (defmethod redisplay-frame-panes ((frame application-frame) &key force-p)
324     (map-over-sheets
325     (lambda (sheet)
326     (when (typep sheet 'pane)
327     (when (and (typep sheet 'clim-stream-pane)
328     (not (eq :no-clear (pane-redisplay-needed sheet))))
329     (window-clear sheet))
330     (redisplay-frame-pane frame sheet :force-p force-p)))
331     (frame-top-level-sheet frame)))
332    
333 moore 1.93 (defmethod redisplay-frame-panes ((frame application-frame) &key force-p)
334     (map-over-sheets (lambda (sheet)
335     (redisplay-frame-pane frame sheet :force-p force-p))
336     (frame-top-level-sheet frame)))
337    
338    
339 moore 1.82 (defmethod frame-replay (frame stream &optional region)
340     (declare (ignore frame))
341     (stream-replay stream region))
342    
343     (defmethod frame-properties ((frame application-frame) property)
344     (getf (%frame-properties frame) property))
345    
346     (defmethod (setf frame-properties) (value (frame application-frame) property)
347     (setf (getf (%frame-properties frame) property) value))
348    
349 mikemac 1.1 ;;; Command loop interface
350    
351 mikemac 1.22 (define-condition frame-exit (condition)
352 moore 1.26 ((frame :initarg :frame :reader %frame-exit-frame)))
353 mikemac 1.22
354 hefner1 1.66 ;; I make the assumption here that the contents of *application-frame* is
355     ;; the frame the top-level loop is running. With the introduction of
356     ;; window-stream frames that may be sharing the event queue with the main
357     ;; application frame, we need to discriminate between them here to avoid
358     ;; shutting down the application at the wrong time.
359     ;; ...
360     ;; A better way to do this would be to make the handler bound in
361     ;; run-frame-top-level check whether the frame signalled is the one
362     ;; it was invoked on.. -- Hefner
363    
364 mikemac 1.22 (defmethod frame-exit ((frame standard-application-frame))
365 hefner1 1.66 (if (eq *application-frame* frame)
366     (signal 'frame-exit :frame frame)
367 ahefner 1.128 (disown-frame (frame-manager frame) frame)))
368 moore 1.26
369     (defmethod frame-exit-frame ((c frame-exit))
370     (%frame-exit-frame c))
371 mikemac 1.22
372 moore 1.59 (defmethod redisplay-frame-pane ((frame application-frame) pane &key force-p)
373     (declare (ignore pane force-p))
374     nil)
375    
376 rstrandh 1.109 (defgeneric medium-invoke-with-possible-double-buffering (frame pane medium continuation))
377    
378     (defmethod medium-invoke-with-possible-double-buffering (frame pane medium continuation)
379     (funcall continuation))
380    
381     (defgeneric invoke-with-possible-double-buffering (frame pane continuation))
382    
383     (defmethod invoke-with-possible-double-buffering (frame pane continuation)
384     (declare (ignore frame pane))
385     (funcall continuation))
386    
387     (defmethod invoke-with-possible-double-buffering (frame (pane sheet-with-medium-mixin) continuation)
388     (medium-invoke-with-possible-double-buffering frame pane (sheet-medium pane) continuation))
389    
390     (defmacro with-possible-double-buffering ((frame pane) &body body)
391     `(invoke-with-possible-double-buffering ,frame ,pane (lambda () ,@body)))
392    
393 moore 1.93 (defmethod redisplay-frame-pane :around ((frame application-frame) pane
394     &key force-p)
395 thenriksen 1.121 (let ((pane-object (if (typep pane 'pane)
396     pane
397     (find-pane-named frame pane))))
398 thenriksen 1.132 (restart-case
399     (multiple-value-bind (redisplayp clearp)
400     (pane-needs-redisplay pane-object)
401     (when force-p
402     (setq redisplayp (or redisplayp t)
403     clearp t))
404     (when redisplayp
405     (let ((hilited (frame-hilited-presentation frame)))
406     (when hilited
407     (highlight-presentation-1 (car hilited) (cdr hilited) :unhighlight)
408     (setf (frame-hilited-presentation frame) nil)))
409     (with-possible-double-buffering (frame pane-object)
410     (when clearp
411     (window-clear pane-object))
412     (call-next-method))
413     (unless (or (eq redisplayp :command-loop) (eq redisplayp :no-clear))
414     (setf (pane-needs-redisplay pane-object) nil))))
415     (clear-pane-try-again ()
416     :report "Clear the output history of the pane and reattempt forceful redisplay"
417     (window-clear pane)
418     (redisplay-frame-pane frame pane :force-p t))
419     (clear-pane ()
420     :report "Clear the output history of the pane, but don't redisplay"
421     (window-clear pane))
422     (skip-redisplay ()
423     :report "Skip this redisplay"))))
424 moore 1.93
425 moore 1.90 (defmethod run-frame-top-level ((frame application-frame)
426     &key &allow-other-keys)
427 tmoore 1.111 (letf (((frame-process frame) (current-process)))
428     (handler-case
429     (funcall (frame-top-level-lambda frame) frame)
430     (frame-exit ()
431     nil))))
432    
433 mikemac 1.1
434 adejneka 1.44 (defmethod run-frame-top-level :around ((frame application-frame) &key)
435 mikemac 1.1 (let ((*application-frame* frame)
436     (*input-context* nil)
437     (*input-wait-test* nil)
438     (*input-wait-handler* nil)
439 moore 1.52 (*pointer-button-press-handler* nil)
440     (original-state (frame-state frame)))
441 mikemac 1.1 (declare (special *input-context* *input-wait-test* *input-wait-handler*
442     *pointer-button-press-handler*))
443 hefner1 1.74 (when (eq (frame-state frame) :disowned) ; Adopt frame into frame manager
444 moore 1.52 (adopt-frame (or (frame-manager frame) (find-frame-manager))
445     frame))
446     (unless (or (eq (frame-state frame) :enabled)
447     (eq (frame-state frame) :shrunk))
448     (enable-frame frame))
449 moore 1.90 (unwind-protect
450     (loop
451     for query-io = (frame-query-io frame)
452     for *default-frame-manager* = (frame-manager frame)
453     do (handler-case
454     (return (if query-io
455     (with-input-focus (query-io)
456     (call-next-method))
457     (call-next-method)))
458     (frame-layout-changed () nil)))
459     (let ((fm (frame-manager frame)))
460 ahefner 1.128 (case original-state
461     (:disabled
462     (disable-frame frame))
463     (:disowned
464     (disown-frame fm frame)))))))
465 mikemac 1.1
466 moore 1.85 (defparameter +default-prompt-style+ (make-text-style :fix :italic :normal))
467    
468 mikemac 1.1 (defmethod default-frame-top-level
469     ((frame application-frame)
470     &key (command-parser 'command-line-command-parser)
471     (command-unparser 'command-line-command-unparser)
472     (partial-command-parser
473     'command-line-read-remaining-arguments-for-partial-command)
474 moore 1.35 (prompt "Command: "))
475 moore 1.93 ;; Give each pane a fresh start first time through.
476     (let ((first-time t))
477     (loop
478     ;; The variables are rebound each time through the loop because the
479     ;; values of frame-standard-input et al. might be changed by a command.
480     (let* ((*standard-input* (or (frame-standard-input frame)
481     *standard-input*))
482     (*standard-output* (or (frame-standard-output frame)
483     *standard-output*))
484     (query-io (frame-query-io frame))
485     (*query-io* (or query-io *query-io*))
486     (*pointer-documentation-output*
487     (frame-pointer-documentation-output frame))
488     ;; during development, don't alter *error-output*
489     ;; (*error-output* (frame-error-output frame))
490     (*command-parser* command-parser)
491     (*command-unparser* command-unparser)
492     (*partial-command-parser* partial-command-parser)
493     (interactorp (typep *query-io* 'interactor-pane)))
494     (restart-case
495     (progn
496     (redisplay-frame-panes frame :force-p first-time)
497     (setq first-time nil)
498     (if query-io
499 ahefner 1.120 ;; For frames with an interactor:
500 hefner1 1.100 (progn
501 ahefner 1.120 ;; Hide cursor, so we don't need to toggle it during
502     ;; command output.
503 moore 1.93 (setf (cursor-visibility (stream-text-cursor *query-io*))
504     nil)
505     (when (and prompt interactorp)
506     (with-text-style (*query-io* +default-prompt-style+)
507     (if (stringp prompt)
508     (write-string prompt *query-io*)
509     (funcall prompt *query-io* frame))
510     (finish-output *query-io*)))
511     (let ((command (read-frame-command frame
512     :stream *query-io*)))
513     (when interactorp
514     (fresh-line *query-io*))
515     (when command
516     (execute-frame-command frame command))
517     (when interactorp
518     (fresh-line *query-io*))))
519 ahefner 1.120 ;; Frames without an interactor:
520     (let ((command (read-frame-command frame :stream nil)))
521     (when command (execute-frame-command frame command)))))
522 moore 1.93 (abort ()
523     :report "Return to application command loop"
524     (if interactorp
525     (format *query-io* "~&Command aborted.~&")
526     (beep))))))))
527 moore 1.85
528 moore 1.87 (defmethod read-frame-command :around ((frame application-frame)
529 ahefner 1.120 &key (stream *standard-input*))
530 moore 1.64 (with-input-context ('menu-item)
531 moore 1.92 (object)
532     (call-next-method)
533 moore 1.64 (menu-item
534 thenriksen 1.129 (let ((command (command-menu-item-value object))
535     (table (frame-command-table frame)))
536 moore 1.92 (unless (listp command)
537 thenriksen 1.129 (setq command (partial-command-from-name command table)))
538 moore 1.92 (if (and (typep stream 'interactor-pane)
539 thenriksen 1.126 (partial-command-p command))
540 moore 1.92 (command-line-read-remaining-arguments-for-partial-command
541 thenriksen 1.129 table stream command 0)
542 moore 1.92 command)))))
543 moore 1.64
544 moore 1.87 (defmethod read-frame-command ((frame application-frame)
545     &key (stream *standard-input*))
546 ahefner 1.107 ;; The following is the correct interpretation according to the spec.
547     ;; I think it is terribly counterintuitive and want to look into
548     ;; what existing CLIMs do before giving in to it.
549     ;; If we do things as the spec says, command accelerators will
550     ;; appear to not work, confusing new users.
551     #+NIL (read-command (frame-command-table frame) :use-keystrokes nil :stream stream)
552 ahefner 1.120 (if stream
553     (read-command (frame-command-table frame) :use-keystrokes t :stream stream)
554     (simple-event-loop frame)))
555 mikemac 1.1
556 tmoore 1.118 (define-event-class execute-command-event (window-manager-event)
557 gbaumann 1.110 ((sheet :initarg :sheet :reader event-sheet)
558     (command :initarg :command :reader execute-command-event-command)))
559    
560 mikemac 1.1 (defmethod execute-frame-command ((frame application-frame) command)
561 gbaumann 1.110 ;; ### FIXME: I'd like a different method than checking for
562     ;; *application-frame* to decide, which process processes which
563     ;; frames command loop. Perhaps looking ath the process slot?
564     ;; --GB 2005-11-28
565     (cond ((eq *application-frame* frame)
566 thenriksen 1.133 (restart-case
567     (apply (command-name command) (command-arguments command))
568     (try-again ()
569     :report (lambda (stream)
570     (format stream "Try executing the command ~A again"
571     (command-name command)))
572     (execute-frame-command frame command))))
573 gbaumann 1.110 (t
574     (let ((eq (sheet-event-queue (frame-top-level-sheet frame))))
575     (event-queue-append eq (make-instance 'execute-command-event
576     :sheet frame
577     :command command))))))
578    
579     (defmethod handle-event ((frame application-frame) (event execute-command-event))
580     (execute-frame-command frame (execute-command-event-command event)))
581 moore 1.94
582     (defmethod command-enabled (command-name (frame standard-application-frame))
583     (and (command-accessible-in-command-table-p command-name
584     (frame-command-table frame))
585     (not (member command-name (disabled-commands frame)))))
586    
587     (defmethod (setf command-enabled)
588     (enabled command-name (frame standard-application-frame))
589     (unless (command-accessible-in-command-table-p command-name
590     (frame-command-table frame))
591     (return-from command-enabled nil))
592     (with-accessors ((disabled-commands disabled-commands))
593     frame
594     (if enabled
595     (progn
596     (setf disabled-commands (delete command-name disabled-commands))
597     (note-command-enabled (frame-manager frame)
598     frame
599     command-name)
600     enabled)
601     (progn
602     (pushnew command-name disabled-commands)
603     (note-command-disabled (frame-manager frame)
604     frame
605     command-name)
606     nil))))
607    
608 moore 1.38 (defmethod make-pane-1 :around (fm (frame standard-application-frame) type
609     &rest args
610 moore 1.51 &key (input-buffer nil input-buffer-p)
611 moore 1.90 (name nil namep)
612 moore 1.51 &allow-other-keys)
613 moore 1.90 (declare (ignore name input-buffer))
614 moore 1.38 "Default input-buffer to the frame event queue."
615 moore 1.90 (let ((pane (if input-buffer-p
616     (call-next-method)
617     (apply #'call-next-method fm frame type
618     :input-buffer (frame-event-queue frame)
619     args))))
620     (when namep
621     (push pane (frame-named-panes frame)))
622 mikemac 1.91 pane))
623 mikemac 1.1
624     (defmethod adopt-frame ((fm frame-manager) (frame application-frame))
625     (setf (slot-value fm 'frames) (cons frame (slot-value fm 'frames)))
626     (setf (frame-manager frame) fm)
627 moore 1.52 (setf (port frame) (frame-manager-port fm))
628     (setf (graft frame) (find-graft :port (port frame)))
629 mikemac 1.1 (let* ((*application-frame* frame)
630 cvs 1.4 (t-l-s (make-pane-1 fm frame 'top-level-sheet-pane
631 moore 1.52 :name 'top-level-sheet
632     ;; enabling should be left to enable-frame
633 hefner1 1.79 :enabled-p nil))
634 hefner1 1.80 #+clim-mp (event-queue (sheet-event-queue t-l-s)))
635 mikemac 1.1 (setf (slot-value frame 'top-level-sheet) t-l-s)
636 moore 1.52 (generate-panes fm frame)
637 ahefner 1.124 (setf (slot-value frame 'state) :disabled)
638 hefner1 1.80 #+clim-mp
639 hefner1 1.79 (when (typep event-queue 'port-event-queue)
640     (setf (event-queue-port event-queue)
641     (frame-manager-port fm)))
642 moore 1.52 frame))
643 brian 1.28
644 mikemac 1.1 (defmethod disown-frame ((fm frame-manager) (frame application-frame))
645 hefner1 1.84 #+CLIM-MP
646 hefner1 1.79 (let* ((t-l-s (frame-top-level-sheet frame))
647     (queue (sheet-event-queue t-l-s)))
648     (when (typep queue 'port-event-queue)
649     (setf (event-queue-port queue) nil)))
650 mikemac 1.1 (setf (slot-value fm 'frames) (remove frame (slot-value fm 'frames)))
651     (sheet-disown-child (graft frame) (frame-top-level-sheet frame))
652 moore 1.52 (setf (%frame-manager frame) nil)
653     (setf (slot-value frame 'state) :disowned)
654 hefner1 1.79 (port-force-output (frame-manager-port fm))
655 moore 1.52 frame)
656    
657     (defmethod enable-frame ((frame application-frame))
658     (setf (sheet-enabled-p (frame-top-level-sheet frame)) t)
659     (setf (slot-value frame 'state) :enabled)
660     (note-frame-enabled (frame-manager frame) frame))
661    
662     (defmethod disable-frame ((frame application-frame))
663 ahefner 1.128 (let ((t-l-s (frame-top-level-sheet frame)))
664     (setf (sheet-enabled-p t-l-s) nil)
665     (when (port t-l-s)
666     (port-force-output (port t-l-s))))
667 moore 1.52 (setf (slot-value frame 'state) :disabled)
668     (note-frame-disabled (frame-manager frame) frame))
669    
670 tmoore 1.111 (defmethod destroy-frame ((frame application-frame))
671     (when (eq (frame-state frame) :enabled)
672     (disable-frame frame))
673     (disown-frame (frame-manager frame) frame))
674    
675 tmoore 1.113 (defmethod raise-frame ((frame application-frame))
676     (raise-sheet (frame-top-level-sheet frame)))
677    
678     (defmethod bury-frame ((frame application-frame))
679     (bury-sheet (frame-top-level-sheet frame)))
680    
681 moore 1.52 (defmethod note-frame-enabled ((fm frame-manager) frame)
682     (declare (ignore frame))
683     t)
684    
685     (defmethod note-frame-disabled ((fm frame-manager) frame)
686 moore 1.75 (declare (ignore frame))
687 moore 1.52 t)
688 mikemac 1.1
689 tmoore 1.111 (defun map-over-frames (function &key port frame-manager)
690     (cond (frame-manager
691     (mapc function (frame-manager-frames frame-manager)))
692     (port
693     (loop for manager in (frame-managers port)
694     do (map-over-frames function :frame-manager manager)))
695     (t (loop for p in *all-ports*
696     do (map-over-frames function :port p)))))
697    
698 cvs 1.8 (defvar *pane-realizer* nil)
699    
700 mikemac 1.1 (defmacro with-look-and-feel-realization ((frame-manager frame) &body body)
701 cvs 1.8 `(let ((*pane-realizer* ,frame-manager)
702     (*application-frame* ,frame))
703 adejneka 1.45 (locally
704     ,@body)))
705 mikemac 1.1
706 brian 1.28 ; The menu-bar code in the following two functions is incorrect.
707     ; it needs to be moved to somewhere after the backend, since
708     ; it depends on the backend chosen.
709     ;
710     ; This hack slaps a menu-bar into the start of the application-frame,
711     ; in such a way that it is hard to find.
712     ;
713     ; FIXME
714     (defun make-single-pane-generate-panes-form (class-name menu-bar pane)
715 moore 1.90 `(progn
716     (defmethod generate-panes ((fm frame-manager) (frame ,class-name))
717     ;; v-- hey, how can this be?
718     (with-look-and-feel-realization (fm frame)
719     (let ((pane ,(cond
720     ((eq menu-bar t)
721     `(vertically () (clim-internals::make-menu-bar
722 brian 1.28 ',class-name)
723 moore 1.90 ,pane))
724     ((consp menu-bar)
725     `(vertically () (clim-internals::make-menu-bar
726 brian 1.28 (make-command-table nil
727 moore 1.90 :menu ',menu-bar))
728     ,pane))
729     (menu-bar
730     `(vertically () (clim-internals::make-menu-bar
731     ',menu-bar)
732     ,pane))
733     ;; The form below is unreachable with (listp
734     ;; menu-bar) instead of (consp menu-bar) above
735     ;; --GB
736     (t pane))))
737     (setf (slot-value frame 'panes) pane))))
738     (defmethod frame-all-layouts ((frame ,class-name))
739     nil)))
740    
741     (defun find-pane-for-layout (name frame)
742     (cdr (assoc name (frame-panes-for-layout frame) :test #'eq)))
743    
744     (defun save-pane-for-layout (name pane frame)
745     (push (cons name pane) (frame-panes-for-layout frame))
746     pane)
747    
748 hefner1 1.96 (defun coerce-pane-name (pane name)
749 crhodes 1.123 (when pane
750 hefner1 1.96 (setf (slot-value pane 'name) name)
751     (push pane (frame-named-panes (pane-frame pane))))
752     pane)
753    
754     (defun do-pane-creation-form (name form)
755 moore 1.90 (cond
756     ((and (= (length form) 1)
757     (listp (first form)))
758 hefner1 1.96 `(coerce-pane-name ,(first form) ',name))
759 moore 1.90 ((keywordp (first form))
760     (let ((maker (intern (concatenate 'string
761     (symbol-name '#:make-clim-)
762     (symbol-name (first form))
763     (symbol-name '#:-pane))
764     :clim)))
765     (if (fboundp maker)
766     `(,maker :name ',name ,@(cdr form))
767     `(make-pane ',(first form)
768     :name ',name ,@(cdr form)))))
769     (t `(make-pane ',(first form) :name ',name ,@(cdr form)))))
770 mikemac 1.1
771 moore 1.47 (defun make-panes-generate-panes-form (class-name menu-bar panes layouts
772     pointer-documentation)
773     (when pointer-documentation
774     (setf panes (append panes
775     '((%pointer-documentation%
776     pointer-documentation-pane)))))
777 moore 1.90 `(progn
778     (defmethod generate-panes ((fm frame-manager) (frame ,class-name))
779     (let ((*application-frame* frame))
780     (with-look-and-feel-realization (fm frame)
781     (let ,(loop
782     for (name . form) in panes
783     collect `(,name (or (find-pane-for-layout ',name frame)
784     (save-pane-for-layout
785     ',name
786     ,(do-pane-creation-form name form)
787     frame))))
788     ;; [BTS] added this, but is not sure that this is correct for
789     ;; adding a menu-bar transparently, should also only be done
790     ;; where the exterior window system does not support menus
791     ,(if (or menu-bar pointer-documentation)
792     `(setf (slot-value frame 'panes)
793     (ecase (frame-current-layout frame)
794     ,@(mapcar (lambda (layout)
795     `(,(first layout)
796     (vertically ()
797     ,@(cond
798     ((eq menu-bar t)
799     `((clim-internals::make-menu-bar
800     ',class-name)))
801     ((consp menu-bar)
802     `((clim-internals::make-menu-bar
803     (make-command-table
804     nil
805     :menu ',menu-bar))))
806     (menu-bar
807     `((clim-internals::make-menu-bar
808     ',menu-bar)))
809     (t nil))
810     ,@(rest layout)
811     ,@(when pointer-documentation
812     '(%pointer-documentation%)))))
813     layouts)))
814     `(setf (slot-value frame 'panes)
815     (ecase (frame-current-layout frame)
816     ,@layouts)))))))
817     (defmethod frame-all-layouts ((frame ,class-name))
818     ',(mapcar #'car layouts))))
819 mikemac 1.1
820     (defmacro define-application-frame (name superclasses slots &rest options)
821     (if (null superclasses)
822     (setq superclasses '(standard-application-frame)))
823     (let ((pane nil)
824     (panes nil)
825     (layouts nil)
826     (current-layout nil)
827 mikemac 1.23 (command-table (list name))
828 mikemac 1.1 (menu-bar t)
829     (disabled-commands nil)
830     (command-definer t)
831     (top-level '(default-frame-top-level))
832 hefner1 1.86 (others nil)
833 mikemac 1.69 (pointer-documentation nil)
834 moore 1.87 (geometry nil)
835 ahefner 1.124 (user-default-initargs nil)
836 moore 1.87 (frame-arg (gensym "FRAME-ARG")))
837 mikemac 1.1 (loop for (prop . values) in options
838     do (case prop
839     (:pane (setq pane (first values)))
840     (:panes (setq panes values))
841     (:layouts (setq layouts values))
842     (:command-table (setq command-table (first values)))
843 brian 1.28 (:menu-bar (setq menu-bar (if (listp values)
844     (first values)
845     values)))
846 mikemac 1.1 (:disabled-commands (setq disabled-commands values))
847     (:command-definer (setq command-definer (first values)))
848     (:top-level (setq top-level (first values)))
849 moore 1.47 (:pointer-documentation (setq pointer-documentation (car values)))
850 mikemac 1.69 (:geometry (setq geometry values))
851 ahefner 1.124 (:default-initargs (setq user-default-initargs values))
852 ahefner 1.127 (t (push (cons prop values) others))))
853 hefner1 1.86 (when (eq command-definer t)
854     (setf command-definer
855     (intern (concatenate 'string
856     (symbol-name '#:define-)
857     (symbol-name name)
858     (symbol-name '#:-command)))))
859 mikemac 1.1 (if (or (and pane panes)
860     (and pane layouts))
861     (error ":pane cannot be specified along with either :panes or :layouts"))
862     (if pane
863     (setq panes (list 'single-pane pane)
864 moore 1.17 layouts `((:default ,(car pane)))))
865 mikemac 1.1 (setq current-layout (first (first layouts)))
866     `(progn
867 gilbert 1.95 (defclass ,name ,superclasses
868     ,slots
869     (:default-initargs
870     :name ',name
871     :pretty-name ,(string-capitalize name)
872     :command-table (find-command-table ',(first command-table))
873     :disabled-commands ',disabled-commands
874     :menu-bar ',menu-bar
875     :current-layout ',current-layout
876     :layouts ',layouts
877     :top-level (list ',(car top-level) ,@(cdr top-level))
878     :top-level-lambda (lambda (,frame-arg)
879     (,(car top-level) ,frame-arg
880 ahefner 1.124 ,@(cdr top-level)))
881 ahefner 1.127 ,@geometry
882 ahefner 1.124 ,@user-default-initargs)
883 gilbert 1.95 ,@others)
884     ,(if pane
885     (make-single-pane-generate-panes-form name menu-bar pane)
886     (make-panes-generate-panes-form name menu-bar panes layouts
887     pointer-documentation))
888     ,@(if command-table
889     `((define-command-table ,@command-table)))
890     ,@(if command-definer
891 ahefner 1.107 `((defmacro ,command-definer (name-and-options arguments &rest body)
892 gilbert 1.95 (let ((name (if (listp name-and-options) (first name-and-options) name-and-options))
893     (options (if (listp name-and-options) (cdr name-and-options) nil))
894     (command-table ',(first command-table)))
895 ahefner 1.107 `(define-command (,name :command-table ,command-table ,@options) ,arguments ,@body))))))))
896 gilbert 1.95
897 mikemac 1.1 (defun make-application-frame (frame-name
898     &rest options
899 moore 1.52 &key (pretty-name
900     (string-capitalize frame-name))
901     (frame-manager nil frame-manager-p)
902     enable
903     (state nil state-supplied-p)
904     save-under (frame-class frame-name)
905 mikemac 1.1 &allow-other-keys)
906 mikemac 1.69 (declare (ignore save-under))
907 moore 1.52 (with-keywords-removed (options (:pretty-name :frame-manager :enable :state
908 moore 1.53 :save-under :frame-class))
909 moore 1.52 (let ((frame (apply #'make-instance frame-class
910 mikemac 1.69 :name frame-name
911     :pretty-name pretty-name
912     options)))
913 moore 1.52 (when frame-manager-p
914     (adopt-frame frame-manager frame))
915     (cond ((or enable (eq state :enabled))
916     (enable-frame frame))
917     ((and (eq state :disowned)
918     (not (eq (frame-state frame) :disowned)))
919     (disown-frame (frame-manager frame) frame))
920     (state-supplied-p
921     (warn ":state ~S not supported yet." state)))
922     frame)))
923 cvs 1.4
924 tmoore 1.111 ;;; From Franz Users Guide
925    
926     (defun find-application-frame (frame-name &rest initargs
927     &key (create t) (activate t)
928     (own-process *multiprocessing-p*) port
929     frame-manager frame-class
930     &allow-other-keys)
931 tmoore 1.112 (declare (ignorable frame-class))
932 tmoore 1.111 (let ((frame (unless (eq create :force)
933     (block
934     found-frame
935     (map-over-frames
936     #'(lambda (frame)
937     (when (eq (frame-name frame) frame-name)
938     (return-from found-frame frame)))
939     :port port
940     :frame-manager frame-manager)))))
941     (unless (or frame create)
942     (return-from find-application-frame nil))
943     (unless frame
944     (with-keywords-removed (initargs (:create :activate :own-process))
945     (setq frame (apply #'make-application-frame frame-name initargs))))
946     (when (and frame activate)
947     (cond ((frame-process frame)
948 tmoore 1.113 (raise-frame frame))
949 tmoore 1.111 (own-process
950     (clim-sys:make-process #'(lambda ()
951     (run-frame-top-level frame))
952     :name (format nil "~A" frame-name)))
953     (t (run-frame-top-level frame))))
954     frame))
955    
956    
957    
958 cvs 1.7 ;;; Menu frame class
959    
960     (defclass menu-frame ()
961     ((left :initform 0 :initarg :left)
962     (top :initform 0 :initarg :top)
963 hefner1 1.103 (min-width :initform nil :initarg :min-width)
964 cvs 1.7 (top-level-sheet :initform nil :reader frame-top-level-sheet)
965 moore 1.90 (panes :reader frame-panes :initarg :panes)
966 cvs 1.7 (graft :initform nil :accessor graft)
967     (manager :initform nil :accessor frame-manager)))
968 adejneka 1.46
969 ahefner 1.124 (defclass menu-unmanaged-top-level-sheet-pane (unmanaged-top-level-sheet-pane)
970     ())
971    
972 cvs 1.7 (defmethod adopt-frame ((fm frame-manager) (frame menu-frame))
973     (setf (slot-value fm 'frames) (cons frame (slot-value fm 'frames)))
974 adejneka 1.46 (setf (frame-manager frame) fm)
975 brian 1.54 (let* ((t-l-s (make-pane-1 fm *application-frame*
976 ahefner 1.124 'menu-unmanaged-top-level-sheet-pane
977 cvs 1.7 :name 'top-level-sheet)))
978     (setf (slot-value frame 'top-level-sheet) t-l-s)
979 moore 1.90 (sheet-adopt-child t-l-s (frame-panes frame))
980 cvs 1.7 (let ((graft (find-graft :port (frame-manager-port fm))))
981     (sheet-adopt-child graft t-l-s)
982     (setf (graft frame) graft))
983 hefner1 1.103 (let ((pre-space (compose-space t-l-s))
984     (frame-min-width (slot-value frame 'min-width)))
985     (multiple-value-bind (width min-width max-width height min-height max-height)
986     (space-requirement-components pre-space)
987     (flet ((foomax (x y) (max (or x 1) (or y 1))))
988     (let ((space (make-space-requirement :min-width (foomax frame-min-width min-width)
989     :width (foomax frame-min-width width)
990     :max-width (foomax frame-min-width max-width)
991     :min-height min-height
992     :height height
993     :max-height max-height)))
994     (allocate-space (frame-panes frame)
995     (space-requirement-width space)
996     (space-requirement-height space))
997     (setf (sheet-region t-l-s)
998     (make-bounding-rectangle 0 0
999     (space-requirement-width space)
1000     (space-requirement-height space))))
1001     (setf (sheet-transformation t-l-s)
1002     (make-translation-transformation (slot-value frame 'left)
1003     (slot-value frame 'top))))))))
1004 cvs 1.7
1005     (defmethod disown-frame ((fm frame-manager) (frame menu-frame))
1006     (setf (slot-value fm 'frames) (remove frame (slot-value fm 'frames)))
1007     (sheet-disown-child (graft frame) (frame-top-level-sheet frame))
1008     (setf (frame-manager frame) nil))
1009    
1010 hefner1 1.103 (defun make-menu-frame (pane &key (left 0) (top 0) (min-width 1))
1011     (make-instance 'menu-frame :panes pane :left left :top top :min-width min-width))
1012 moore 1.18
1013     ;;; Frames and presentations
1014 moore 1.88 (defmethod frame-maintain-presentation-histories
1015     ((frame standard-application-frame))
1016     (if (find-pane-of-type (frame-panes frame) 'interactor-pane)
1017     t
1018     nil))
1019 moore 1.18
1020     (defmethod frame-find-innermost-applicable-presentation
1021     ((frame standard-application-frame) input-context stream x y
1022     &key event)
1023     (find-innermost-applicable-presentation input-context stream
1024     x y
1025     :frame frame :event event))
1026    
1027 adejneka 1.41 (defmethod frame-input-context-button-press-handler
1028 moore 1.18 ((frame standard-application-frame)
1029     (stream output-recording-stream)
1030     button-press-event)
1031     (let ((presentation (find-innermost-applicable-presentation
1032     *input-context*
1033     stream
1034     (pointer-event-x button-press-event)
1035     (pointer-event-y button-press-event)
1036 moore 1.37 :frame frame
1037     :event button-press-event)))
1038 moore 1.18 (when presentation
1039     (throw-highlighted-presentation presentation
1040     *input-context*
1041     button-press-event))))
1042    
1043     (defmethod frame-input-context-button-press-handler
1044     ((frame standard-application-frame) stream button-press-event)
1045 mikemac 1.36 (declare (ignore stream button-press-event))
1046 moore 1.27 nil)
1047 moore 1.18
1048 moore 1.47 (defgeneric frame-update-pointer-documentation
1049     (frame input-context stream event))
1050    
1051     (defconstant +button-documentation+ '((#.+pointer-left-button+ "L")
1052     (#.+pointer-middle-button+ "M")
1053 hefner1 1.96 (#.+pointer-right-button+ "R")
1054     (#.+pointer-wheel-up+ "WheelUp")
1055     (#.+pointer-wheel-down+ "WheelDown")))
1056 moore 1.47
1057 moore 1.48 (defconstant +modifier-documentation+
1058     '((#.+shift-key+ "sh" "Shift")
1059     (#.+control-key+ "c" "Control")
1060     (#.+meta-key+ "m" "Meta")
1061     (#.+super-key+ "s" "Super")
1062     (#.+hyper-key+ "h" "Hyper")))
1063    
1064     ;;; Give a coherent order to sets of modifier combinations. Multi-key combos
1065     ;;; come after single keys.
1066    
1067     (defun cmp-modifiers (a b)
1068     (let ((cnt-a (logcount a))
1069     (cnt-b (logcount b)))
1070     (cond ((eql cnt-a cnt-b)
1071     (< a b))
1072     (t (< cnt-a cnt-b)))))
1073    
1074     (defun print-modifiers (stream modifiers style)
1075 moore 1.49 (if (zerop modifiers)
1076     (when (eq style :long)
1077     (write-string "<nothing>" stream))
1078     (loop with trailing = nil
1079     for (bit short long) in +modifier-documentation+
1080     when (logtest bit modifiers)
1081     do (progn
1082     (format stream "~:[~;-~]~A" trailing (if (eq style :short)
1083     short
1084     long))
1085     (setq trailing t)))))
1086 moore 1.48
1087 tmoore 1.114 ;;; XXX Warning: Changing rapidly!
1088     ;;;
1089 moore 1.48 ;;; We don't actually want to print out the translator documentation and redraw
1090     ;;; the pointer documentation window on every motion event. So, we compute a
1091     ;;; state object (basically modifier state and a list of the applicable
1092     ;;; presentation, translator and input context on each mouse button),
1093     ;;; compare it to the previous state object, and only write out documentation
1094     ;;; if they are different. I suppose it's possible that this state object
1095     ;;; doesn't capture all possible documentation changes -- the doc generator is
1096     ;;; a function, after all -- but that's just tough.
1097     ;;;
1098     ;;; It would be nice to evolve this into a protocol so that elements other than
1099     ;;; presentations -- menu choices, for example -- could influence pointer
1100     ;;; documentation window.
1101    
1102 moore 1.50 (defgeneric frame-compute-pointer-documentation-state
1103     (frame input-context stream event)
1104     (:documentation
1105     "Compute a state object that will be used to generate pointer documentation."))
1106    
1107     (defmethod frame-compute-pointer-documentation-state
1108     ((frame standard-application-frame) input-context stream event)
1109     (let* ((current-modifier (event-modifier-state event))
1110     (x (device-event-x event))
1111     (y (device-event-y event))
1112     (new-translators
1113     (loop for (button) in +button-documentation+
1114     for context-list = (multiple-value-list
1115     (find-innermost-presentation-context
1116     input-context
1117     stream
1118     x y
1119     :modifier-state current-modifier
1120     :button button))
1121     when (car context-list)
1122     collect (cons button context-list))))
1123     (list current-modifier new-translators)))
1124    
1125     (defgeneric frame-compare-pointer-documentation-state
1126     (frame input-context stream old-state new-state))
1127    
1128     (defmethod frame-compare-pointer-documentation-state
1129     ((frame standard-application-frame) input-context stream
1130     old-state new-state)
1131 moore 1.78 (declare (ignore input-context stream))
1132 moore 1.50 (equal old-state new-state))
1133    
1134 thenriksen 1.130 (defun record-on-display (stream record)
1135     "Return true if `record' is part of the output history of
1136     `stream', false otherwise."
1137     (labels ((worker (record)
1138     (or (eq record (stream-output-history stream))
1139     (and (not (null (output-record-parent record)))
1140     (worker (output-record-parent record))))))
1141     (worker record)))
1142    
1143 moore 1.50 (defgeneric frame-print-pointer-documentation
1144     (frame input-context stream state event))
1145    
1146     (defmethod frame-print-pointer-documentation
1147     ((frame standard-application-frame) input-context stream state event)
1148     (unless state
1149     (return-from frame-print-pointer-documentation nil))
1150     (destructuring-bind (current-modifier new-translators)
1151     state
1152     (let ((x (device-event-x event))
1153     (y (device-event-y event))
1154     (pstream *pointer-documentation-output*))
1155 thenriksen 1.130 (if (null new-translators)
1156     (when (and (background-message pstream)
1157     (not (record-on-display pstream (background-message pstream))))
1158     (cond ((> (get-universal-time)
1159     (+ (background-message-time pstream)
1160     *background-message-minimum-lifetime*))
1161     (setf (background-message pstream) nil))
1162     (t
1163     (setf (output-record-parent (background-message pstream)) nil)
1164     (stream-add-output-record pstream (background-message pstream))
1165     (replay (background-message pstream) pstream))))
1166     (loop for (button presentation translator context)
1167     in new-translators
1168     for name = (cadr (assoc button +button-documentation+))
1169     for first-one = t then nil
1170     do (progn
1171     (unless first-one
1172     (write-string "; " pstream))
1173     (unless (zerop current-modifier)
1174     (print-modifiers pstream current-modifier :short)
1175     (write-string "-" pstream))
1176     (format pstream "~A: " name)
1177     (document-presentation-translator translator
1178     presentation
1179     (input-context-type context)
1180     *application-frame*
1181     event
1182     stream
1183     x y
1184     :stream pstream
1185     :documentation-type
1186     :pointer))
1187     finally (when new-translators
1188     (write-char #\. pstream))))
1189 moore 1.50 ;; Wasteful to do this after doing
1190     ;; find-innermost-presentation-context above... look at doing this
1191     ;; first and then doing the innermost test.
1192     (let ((all-translators (find-applicable-translators
1193 thenriksen 1.130 (stream-output-history stream)
1194     input-context
1195     *application-frame*
1196     stream
1197     x y
1198     :for-menu t))
1199     (other-modifiers nil))
1200     (loop for (translator) in all-translators
1201     for gesture = (gesture translator)
1202     unless (eq gesture t)
1203     do (loop for (name type modifier) in gesture
1204     unless (eql modifier current-modifier)
1205     do (pushnew modifier other-modifiers)))
1206     (when other-modifiers
1207     (setf other-modifiers (sort other-modifiers #'cmp-modifiers))
1208     (terpri pstream)
1209     (write-string "To see other commands, press " pstream)
1210     (loop for modifier-tail on other-modifiers
1211     for (modifier) = modifier-tail
1212     for count from 0
1213     do (progn
1214     (if (null (cdr modifier-tail))
1215     (progn
1216     (when (> count 1)
1217     (write-char #\, pstream))
1218     (when (> count 0)
1219     (write-string " or " pstream)))
1220     (when (> count 0)
1221     (write-string ", " pstream)))
1222     (print-modifiers pstream modifier :long)))
1223     (write-char #\. pstream))))))
1224 moore 1.50
1225 moore 1.47 (defmethod frame-update-pointer-documentation
1226     ((frame standard-application-frame) input-context stream event)
1227     (when *pointer-documentation-output*
1228 tmoore 1.114 (with-accessors ((frame-documentation-state frame-documentation-state)
1229     (documentation-record documentation-record))
1230 thenriksen 1.130 frame
1231 tmoore 1.114 (setf frame-documentation-state
1232     (frame-compute-pointer-documentation-state frame
1233     input-context
1234     stream
1235     event))
1236     ;; These ugly special bindings work around the fact that the outer
1237     ;; updating-output form closes over its body and allow the inner
1238     ;; form to see the correct, current values of those variables.
1239     (let ((%input-context% input-context)
1240     (%stream% stream)
1241     (%doc-state% frame-documentation-state)
1242     (%event% event))
1243     (declare (special %input-context% %stream% %doc-state% %event&))
1244     (if (and documentation-record
1245 thenriksen 1.130 (output-record-parent documentation-record))
1246 tmoore 1.114 (redisplay documentation-record *pointer-documentation-output*)
1247     (progn
1248     (setf documentation-record
1249 thenriksen 1.130 (updating-output (*pointer-documentation-output*)
1250     (updating-output (*pointer-documentation-output*
1251     :cache-value %doc-state%
1252     :cache-test #'equal)
1253     (frame-print-pointer-documentation frame
1254     %input-context%
1255     %stream%
1256     %doc-state%
1257     %event%))))))))))
1258    
1259     (defgeneric invoke-with-output-to-pointer-documentation (frame continuation)
1260     (:documentation "Invoke `continuation' with a single argument -
1261     a stream that the continuation can write to, the output of which
1262     will be used as the background message of the pointer
1263     documentation pane of `frame'. If the pointer-documentation of
1264     `frame' is not a `pointer-documentation-pane', `continuation'
1265     will not be called."))
1266    
1267     (defmethod invoke-with-output-to-pointer-documentation
1268     ((frame standard-application-frame) continuation)
1269     (with-accessors ((pointer-documentation frame-pointer-documentation-output)) frame
1270     (when (typep pointer-documentation 'pointer-documentation-pane)
1271     (setf (background-message pointer-documentation)
1272     (with-output-to-output-record (pointer-documentation)
1273     (funcall continuation pointer-documentation))
1274     (background-message-time pointer-documentation) (get-universal-time)))))
1275    
1276     (defmacro with-output-to-pointer-documentation ((stream frame) &body body)
1277     "Bind `stream' to the pointer-documentation pane of `frame' and
1278     capture the output of `body' on `stream' as the background
1279     message of the pointer documentation pane. If `frame' does not
1280     have a `pointer-documentation-pane' as pointer documentation,
1281     `body' will not be evaluated."
1282     `(invoke-with-output-to-pointer-documentation
1283     ,frame #'(lambda (,stream)
1284     ,@body)))
1285 moore 1.47
1286 moore 1.78 ;;; A hook for applications to draw random strings in the
1287     ;;; *pointer-documentation-output* without screwing up the real pointer
1288     ;;; documentation too badly.
1289    
1290 thenriksen 1.130 (defun frame-display-pointer-documentation-string (frame string)
1291     (with-output-to-pointer-documentation (stream frame)
1292     (write-string string stream)))
1293 moore 1.78
1294 moore 1.18 (defmethod frame-input-context-track-pointer
1295     ((frame standard-application-frame)
1296     input-context
1297     (stream output-recording-stream) event)
1298     (declare (ignore input-context event))
1299     nil)
1300    
1301     (defmethod frame-input-context-track-pointer
1302     ((frame standard-application-frame) input-context stream event)
1303 mikemac 1.36 (declare (ignore input-context stream event))
1304 moore 1.27 nil)
1305 moore 1.18
1306 moore 1.98 (defun frame-highlight-at-position (frame stream x y modifier input-context
1307     &key (highlight t))
1308     "Given stream x,y; key modifiers; input-context, find the applicable
1309     presentation and maybe highlight it."
1310 moore 1.47 (flet ((maybe-unhighlight (presentation)
1311     (when (and (frame-hilited-presentation frame)
1312 moore 1.98 (or (not highlight)
1313     (not (eq presentation
1314     (car (frame-hilited-presentation frame))))))
1315 moore 1.47 (highlight-presentation-1 (car (frame-hilited-presentation frame))
1316     (cdr (frame-hilited-presentation frame))
1317 moore 1.98 :unhighlight)
1318     (setf (frame-hilited-presentation frame) nil))))
1319 moore 1.18 (if (output-recording-stream-p stream)
1320     (let ((presentation (find-innermost-applicable-presentation
1321     input-context
1322 hefner1 1.76 stream
1323     x y
1324 moore 1.37 :frame frame
1325 hefner1 1.76 :modifier-state modifier)))
1326 moore 1.47 (maybe-unhighlight presentation)
1327 moore 1.98 (when (and presentation
1328     highlight
1329     (not (eq presentation
1330     (car (frame-hilited-presentation frame)))))
1331     (setf (frame-hilited-presentation frame)
1332     (cons presentation stream))
1333     (highlight-presentation-1 presentation stream :highlight))
1334     presentation)
1335 moore 1.47 (progn
1336     (maybe-unhighlight nil)
1337 moore 1.98 nil))))
1338 moore 1.78
1339 hefner1 1.76 (defmethod frame-input-context-track-pointer :before
1340     ((frame standard-application-frame) input-context
1341     (stream output-recording-stream) event)
1342     (frame-highlight-at-position frame stream
1343     (device-event-x event)
1344     (device-event-y event)
1345     (event-modifier-state event)
1346     input-context)
1347 moore 1.47 (frame-update-pointer-documentation frame input-context stream event))
1348 moore 1.27
1349 ahefner 1.120 (defun simple-event-loop (&optional (frame *application-frame*))
1350 moore 1.27 "An simple event loop for applications that want all events to be handled by
1351     handle-event methods"
1352 ahefner 1.120 (let ((queue (frame-event-queue frame)))
1353 adejneka 1.41 (loop for event = (event-queue-read queue)
1354     ;; EVENT-QUEUE-READ in single-process mode calls PROCESS-NEXT-EVENT itself.
1355     do (handle-event (event-sheet event) event))))
1356 moore 1.57
1357     ;;; Am I missing something? Does this need to do more? - moore
1358     (defmacro with-application-frame ((frame) &body body)
1359     `(let ((,frame *application-frame*))
1360     ,@body))
1361 hefner1 1.67
1362 hefner1 1.68 (defmethod note-input-focus-changed (pane state)
1363     (declare (ignore pane state)))
1364    
1365 moore 1.82 (defmethod (setf client-setting) (value frame setting)
1366     (setf (getf (client-settings frame) setting) value))
1367 moore 1.81
1368 moore 1.82 (defmethod reset-frame (frame &rest client-settings)
1369     (loop for (setting value) on client-settings by #'cddr
1370     do (setf (client-setting frame setting) value)))
1371 moore 1.98
1372     ;;; tracking-pointer stuff related to presentations
1373    
1374     (defclass frame-tracking-pointer-state (tracking-pointer-state)
1375     ((presentation-handler :reader presentation-handler :initarg :presentation)
1376     (presentation-button-release-handler
1377     :reader presentation-button-release-handler
1378     :initarg :presentation-button-release)
1379     (presentation-button-press-handler :reader presentation-button-press-handler
1380     :initarg :presentation-button-press)
1381     (applicable-presentation :accessor applicable-presentation :initform nil)
1382     (input-context :reader input-context)
1383     (highlight :reader highlight))
1384     (:default-initargs :presentation nil
1385     :presentation-button-press nil
1386     :presentation-button-release nil
1387     :context-type t))
1388    
1389     (defmethod initialize-instance :after
1390     ((obj frame-tracking-pointer-state)
1391     &key presentation presentation-button-press presentation-button-release
1392 moore 1.99 (highlight nil highlightp) context-type
1393     multiple-window)
1394     (declare (ignore multiple-window))
1395 tmoore 1.114 (let ((presentation-clauses-p (or presentation
1396     presentation-button-press
1397     presentation-button-release)))
1398     (setf (slot-value obj 'highlight) (if highlightp
1399     highlight
1400     presentation-clauses-p))
1401 moore 1.98 (setf (slot-value obj 'input-context)
1402 tmoore 1.114 (if (or presentation-clauses-p highlight)
1403     (make-fake-input-context context-type)
1404     nil))))
1405 moore 1.98
1406     (defmethod make-tracking-pointer-state
1407     ((frame standard-application-frame) sheet args)
1408     (declare (ignore sheet))
1409     (apply #'make-instance 'frame-tracking-pointer-state
1410     args))
1411    
1412     (defmethod tracking-pointer-loop :before
1413     ((state frame-tracking-pointer-state) frame sheet &rest args)
1414     (declare (ignore args))
1415     (if (highlight state)
1416     (highlight-current-presentation frame (input-context state))
1417     (let ((hilited (frame-hilited-presentation frame)))
1418     (when hilited
1419     (highlight-presentation-1 (car hilited)
1420     (cdr hilited)
1421     :unhighlight)))))
1422    
1423 tmoore 1.104 ;;; Poor man's find-applicable-translators. tracking-pointer doesn't want to
1424     ;;; see any results from presentation translators.
1425 tmoore 1.114 ;;;
1426     ;;; XXX I don't see why not (even though I wrote the above comment :) and
1427     ;;; Classic CLIM seems to agree. -- moore
1428     (defun highlight-for-tracking-pointer (frame stream event input-context
1429     highlight)
1430 tmoore 1.117 (let ((presentation nil)
1431 tmoore 1.104 (current-hilited (frame-hilited-presentation frame)))
1432 tmoore 1.114 (when (output-recording-stream-p stream)
1433 tmoore 1.117 ;; XXX Massive hack to prevent the presentation action for completions
1434     ;; from being applicable. After the .9.2.2 release that action will have
1435     ;; a more restrictive context type.
1436     (let ((*completion-possibilities-continuation* nil))
1437     (setq presentation (find-innermost-applicable-presentation
1438     input-context
1439     stream
1440     (device-event-x event)
1441     (device-event-y event)
1442     :frame frame))))
1443 tmoore 1.114 (when (and current-hilited (not (eq (car current-hilited) presentation)))
1444     (highlight-presentation-1 (car current-hilited)
1445     (cdr current-hilited)
1446     :unhighlight))
1447     (when (and presentation highlight)
1448     (setf (frame-hilited-presentation frame) (cons presentation stream))
1449     (highlight-presentation-1 presentation stream :highlight))
1450     presentation))
1451 tmoore 1.104
1452 moore 1.98 (defmethod tracking-pointer-loop-step :before
1453     ((state frame-tracking-pointer-state) (event pointer-event) x y)
1454     (declare (ignore x y))
1455 tmoore 1.114 (when (input-context state)
1456 moore 1.98 (let ((stream (event-sheet event)))
1457     (setf (applicable-presentation state)
1458 tmoore 1.104 (highlight-for-tracking-pointer *application-frame* stream
1459 tmoore 1.114 event
1460     (input-context state)
1461     (highlight state))))))
1462 tmoore 1.104
1463 moore 1.98
1464     (macrolet ((frob (event handler)
1465     `(defmethod tracking-pointer-loop-step
1466     ((state frame-tracking-pointer-state) (event ,event) x y)
1467     (let ((handler (,handler state))
1468     (presentation (applicable-presentation state)))
1469     (if (and handler presentation)
1470     (funcall handler :presentation presentation
1471 hefner1 1.102 :event event
1472 moore 1.98 :window (event-sheet event)
1473     :x x :y y)
1474     (call-next-method))))))
1475     (frob pointer-motion-event presentation-handler)
1476     (frob pointer-button-press-event presentation-button-press-handler)
1477     (frob pointer-button-release-event presentation-button-release-handler))
1478    
1479 tmoore 1.105 (defun make-drag-bounding (old-highlighting new-highlighting
1480     old-presentation new-presentation)
1481     (let (x1 y1 x2 y2)
1482     (flet ((union-with-bounds (rect)
1483     (cond ((null rect)
1484     nil)
1485     ((null x1)
1486     (setf (values x1 y1 x2 y2) (bounding-rectangle* rect)))
1487     (t (with-bounding-rectangle* (r-x1 r-y1 r-x2 r-y2)
1488     rect
1489     (setf (values x1 y1 x2 y2)
1490     (bound-rectangles x1 y1 x2 y2
1491     r-x1 r-y1 r-x2 r-y2)))))))
1492     (union-with-bounds old-highlighting)
1493     (union-with-bounds new-highlighting)
1494     (union-with-bounds old-presentation)
1495     (union-with-bounds new-presentation)
1496     (values x1 y1 x2 y2))))
1497    
1498     (defun make-drag-and-drop-feedback-function (from-presentation)
1499     (multiple-value-bind (record-x record-y)
1500     (output-record-position from-presentation)
1501     (let ((current-to-presentation nil)
1502     (current-from-higlighting nil))
1503     (lambda (frame from-presentation to-presentation initial-x initial-y
1504     x y event)
1505     (let ((dx (- record-x initial-x))
1506     (dy (- record-y initial-y)))
1507     (typecase event
1508     (null
1509     ())))))))
1510 moore 1.98
1511 tmoore 1.114 (defmethod frame-drag-and-drop-feedback
1512     ((frame standard-application-frame) from-presentation stream
1513     initial-x initial-y x y state)
1514     (with-bounding-rectangle* (fp-x1 fp-y1 fp-x2 fp-y2)
1515     from-presentation
1516     ;; Offset from origin of presentation is preserved throughout
1517     (let* ((x-off (- fp-x1 initial-x))
1518     (y-off (- fp-y1 initial-y))
1519     (hilite-x1 (+ x-off x))
1520     (hilite-y1 (+ y-off y))
1521     (hilite-x2 (+ hilite-x1 (- fp-x2 fp-x1)))
1522     (hilite-y2 (+ hilite-y1 (- fp-y2 fp-y1))))
1523     (with-identity-transformation (stream)
1524     (ecase state
1525     (:highlight
1526     (with-output-recording-options (stream :record nil)
1527     (draw-rectangle* stream hilite-x1 hilite-y1 hilite-x2 hilite-y2
1528     :filled nil :line-dashes #(4 4))))
1529     (:unhighlight
1530     (with-double-buffering
1531 tmoore 1.116 ((stream hilite-x1 hilite-y1 (1+ hilite-x2) (1+ hilite-y2))
1532 tmoore 1.114 (buffer-rectangle))
1533     (stream-replay stream buffer-rectangle))))))))
1534    
1535     (defmethod frame-drag-and-drop-highlighting
1536 tmoore 1.115 ((frame standard-application-frame) to-presentation stream state)
1537     (highlight-presentation-1 to-presentation stream state))
1538 tmoore 1.114
1539 tmoore 1.115 (defun frame-drag-and-drop (translator-name command-table
1540     from-presentation context-type frame event window
1541     x y)
1542     (declare (ignore command-table))
1543     (let* ((*dragged-presentation* from-presentation)
1544     (*dragged-object* (presentation-object from-presentation))
1545     (translators (mapcan (lambda (trans)
1546 tmoore 1.114 (and (typep trans 'drag-n-drop-translator)
1547 tmoore 1.115 (funcall (tester trans)
1548     (presentation-object
1549     from-presentation)
1550     :presentation from-presentation
1551     :context-type context-type
1552     :frame frame
1553     :window window
1554     :x x
1555     :y y
1556 tmoore 1.116 :event event)
1557     (list trans)))
1558 tmoore 1.114 (find-presentation-translators
1559 tmoore 1.115 (presentation-type from-presentation)
1560 tmoore 1.114 context-type
1561     (frame-command-table frame))))
1562 tmoore 1.115 ;; Try to run the feedback and highlight functions of the translator
1563     ;; that got us here.
1564 tmoore 1.114 (translator (or (find translator-name translators :key #'name)
1565     (car translators)))
1566 tmoore 1.115 (initial-feedback-fn (feedback translator))
1567     (initial-hilite-fn (highlighting translator))
1568     (destination-presentation nil)
1569     (initial-x x)
1570     (initial-y y)
1571     (last-presentation nil)
1572     (feedback-activated nil)
1573     (feedback-fn initial-feedback-fn)
1574     (hilite-fn initial-hilite-fn)
1575     (last-event nil))
1576     ;; We shouldn't need to use find-innermost-presentation-match
1577     ;; This repeats what tracking-pointer has already done, but what are you
1578     ;; gonna do?
1579     (flet ((find-dest-translator (presentation window x y)
1580     (loop for translator in translators
1581     when (and (presentation-subtypep
1582     (presentation-type presentation)
1583     (destination-ptype translator))
1584     (test-presentation-translator translator
1585     presentation
1586     context-type frame
1587     window x y))
1588     do (return-from find-dest-translator translator))
1589     nil)
1590 tmoore 1.116 (do-feedback (window x y state)
1591     (funcall feedback-fn frame from-presentation window
1592     initial-x initial-y x y state))
1593 tmoore 1.115 (do-hilite (presentation window state)
1594 tmoore 1.116 (funcall hilite-fn frame presentation window state))
1595 tmoore 1.115 (last-window ()
1596     (event-sheet last-event))
1597     (last-x ()
1598     (pointer-event-x last-event))
1599     (last-y ()
1600     (pointer-event-y last-event)))
1601     ;; :highlight nil will cause the presentation that is the source of the
1602     ;; dragged object to be unhighlighted initially.
1603     (block do-tracking
1604     (tracking-pointer (window :context-type `(or ,(mapcar #'from-type
1605     translators))
1606     :highlight nil
1607 tmoore 1.117 :multiple-window nil) ;XXX
1608 tmoore 1.115 (:presentation (&key presentation window event x y)
1609     (let ((dest-translator (find-dest-translator presentation window
1610     x y)))
1611 tmoore 1.116 (when feedback-activated
1612     (do-feedback (last-window) (last-x) (last-y) :unhighlight))
1613 tmoore 1.115 (setq feedback-activated t
1614     last-event event)
1615 tmoore 1.116 (when last-presentation
1616     (do-hilite last-presentation (last-window) :unhighlight))
1617 tmoore 1.115 (setq last-presentation presentation
1618     feedback-fn (feedback dest-translator)
1619     hilite-fn (highlighting dest-translator))
1620     (do-hilite presentation window :highlight)
1621 tmoore 1.116 (do-feedback window x y :highlight)
1622 tmoore 1.115 (document-drag-n-drop dest-translator presentation
1623     context-type frame event window
1624     x y)))
1625     (:pointer-motion (&key event window x y)
1626 tmoore 1.116 (when feedback-activated
1627     (do-feedback (last-window) (last-x) (last-y) :unhighlight))
1628 tmoore 1.115 (setq feedback-activated t
1629     last-event event)
1630 tmoore 1.116 (when last-presentation
1631     (do-hilite last-presentation (last-window) :unhighlight))
1632 tmoore 1.115 (setq last-presentation nil)
1633 tmoore 1.116 (do-feedback window x y :highlight)
1634 tmoore 1.115 (document-drag-n-drop translator nil
1635     context-type frame event window
1636     x y))
1637     ;; XXX only support finish-on-release for now.
1638     #-(and)(:presentation-button-press ())
1639     (:presentation-button-release (&key presentation event)
1640     (setq destination-presentation presentation
1641     last-event event)
1642     (return-from do-tracking nil))
1643     #-(and)(:button-press ())
1644     (:button-release (&key event)
1645     (setq last-event event)
1646     (return-from do-tracking nil))))
1647     ;;
1648     ;; XXX Assumes x y from :button-release are the same as for the preceding
1649     ;; button-motion; is that correct?
1650 tmoore 1.116 (when feedback-activated
1651     (do-feedback (last-window) (last-x) (last-y) :unhighlight))
1652     (when last-presentation
1653     (do-hilite last-presentation (last-window) :unhighlight))
1654 tmoore 1.115 (if destination-presentation
1655     (let ((final-translator (find-dest-translator destination-presentation
1656     (last-window)
1657     (last-x)
1658     (last-y))))
1659     (if final-translator
1660     (funcall (destination-translator final-translator)
1661     *dragged-object*
1662     :presentation *dragged-presentation*
1663     :destination-object (presentation-object
1664     destination-presentation)
1665     :destination-presentation destination-presentation
1666     :context-type context-type
1667     :frame frame
1668     :event event
1669     :window window
1670     :x x
1671     :y y)
1672     (values nil nil)))
1673     (values nil nil)))))
1674    
1675     (defun document-drag-n-drop
1676     (translator presentation context-type frame event window x y)
1677     (when *pointer-documentation-output*
1678     (let ((s *pointer-documentation-output*))
1679     (window-clear s)
1680     (with-end-of-page-action (s :allow)
1681     (with-end-of-line-action (s :allow)
1682 tmoore 1.116 (funcall (pointer-documentation translator)
1683     *dragged-object*
1684     :presentation *dragged-presentation*
1685     :destination-object (and presentation
1686     (presentation-object presentation))
1687     :destination-presentation presentation
1688     :context-type context-type
1689     :frame frame
1690     :event event
1691     :window window
1692     :x x
1693     :y y
1694     :stream s))))))
1695    
1696 tmoore 1.115
1697    

  ViewVC Help
Powered by ViewVC 1.1.5