Changeset 15113


Ignore:
Timestamp:
Dec 6, 2011, 11:28:58 AM (8 years ago)
Author:
gfoy
Message:

#/saveDocument revisited.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cocoa-ide-contrib/foy/window-parking-cm/window-parking.lisp

    r14985 r15113  
    1414;;;
    1515;;;      Mod History (most recent edit first)
    16 ;;;      9/17/9 Fix bogus move after #/saveDocument.
    17 ;;;      9/16/9 Park new window.
    18 ;;;      9/9/9  first cut
     16;;;      12/6/11  #/saveDocument revisited.
     17;;;      9/17/9   Fix bogus move after #/saveDocument.
     18;;;      9/16/9   Park new window.
     19;;;      9/9/9    first cut
    1920;;;
    2021;;; ----------------------------------------------------------------------------
     
    108109(defClass PARKABLE-HEMLOCK-FRAME (gui::hemlock-frame)
    109110  ((parked-p :initform nil :accessor parked-p)
    110    (front-p :initform nil :accessor front-p))
     111   (front-p :initform nil :accessor front-p)
     112   (new-window-p :initform t :accessor new-window-p))
    111113  (:metaclass ns:+ns-object))
    112114
     
    149151;;; Why is the frame being set on a save operation?
    150152(objc:defmethod (#/saveDocument: :void) ((self gui::hemlock-editor-document) (sender :id))
    151   (let* ((url (#/fileURL self))
    152          (path (ccl::lisp-string-from-nsstring (#/path url)))
    153          (window (cmenu:window-with-path path)))
    154     (when window (init-parking window))
    155     (call-next-method sender)
    156     (when window (setf (parked-p window) t))))
     153  (let ((url (#/fileURL self)))
     154    (cond ((ccl::%null-ptr-p url)
     155           (call-next-method sender))
     156          (t
     157           (let* ((path (ccl::lisp-string-from-nsstring (#/path url)))
     158                  (window (cmenu:window-with-path path)))
     159             (when window (init-parking window))
     160             (call-next-method sender)
     161             (when window (setf (parked-p window) t)))))))
    157162
    158163;;; ----------------------------------------------------------------------------
     
    174179
    175180(objc:defmethod (#/setFrame:display: :void) ((w parkable-hemlock-frame) (rect :<NSR>ect) (display-p :<BOOL>))
    176  (cond ((parked-p w)
    177          (call-next-method rect display-p))
     181 (cond ((and w (not (ccl::%null-ptr-p w)) (parked-p w))
     182        (let ((spot (get-window-parking-spot *window-parker* w)))
     183          ;; This is an ugly hack for saving a new window:
     184          (cond ((and (new-window-p w) spot)
     185                 (ns:with-ns-rect (r (ps-h-position spot) (ps-v-position spot)
     186                                     (ps-h-dimension spot) (ps-v-dimension spot))
     187                   (setf (new-window-p w) nil)
     188                   (call-next-method r display-p)))
     189                (t
     190                 (call-next-method rect display-p)))))
    178191        (t
    179192         (when (front-p w) (setf (parked-p w) t))
     
    276289        (or (setf position (get-empty-position wp))
    277290            (setf position (bump-position wp (1- (length (wp-parking-spots wp)))))))
    278       (cond (position
    279              (setq spot (nth position (wp-parking-spots wp)))
    280              (move-position-to-front wp position)
    281              (setf (ps-tenant spot) window)
    282              (values (ps-h-position spot) (ps-v-position spot)
    283                      (ps-h-dimension spot) (ps-v-dimension spot)))
    284             (t
    285              ;; only try to park it once
    286              (setf (parked-p window) t))))))
     291      (when position
     292        (setq spot (nth position (wp-parking-spots wp)))
     293        (move-position-to-front wp position)
     294        (setf (ps-tenant spot) window)
     295        (values (ps-h-position spot) (ps-v-position spot)
     296                (ps-h-dimension spot) (ps-v-dimension spot))))))
    287297
    288298;;; Test to make sure that POSITION is on screen.  If not, call recursively with
     
    317327(defMethod parking-spot-with-function-key ((wp window-parker) function-key)
    318328  (find  function-key (wp-parking-spots wp) :test #'= :key #'ps-function-key))
     329
     330(defMethod get-window-parking-spot ((wp window-parker) window)
     331  (find-if #'(lambda (spot)
     332               (equal (ps-tenant spot) window))
     333           (wp-parking-spots wp)))
    319334
    320335;;; Find the lowest number parking-spot that has no tenant.
Note: See TracChangeset for help on using the changeset viewer.