]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/backend/cocoa/views/views.factor
dda758f11d005d2b9b87536f87063e2762e27d78
[factor.git] / basis / ui / backend / cocoa / views / views.factor
1 ! Copyright (C) 2006, 2010 Slava Pestov
2 ! See http://factorcode.org/license.txt for BSD license.
3
4 USING: accessors alien alien.c-types alien.data alien.strings
5 arrays assocs classes cocoa cocoa.application cocoa.classes
6 cocoa.pasteboard cocoa.runtime cocoa.subclassing cocoa.touchbar
7 cocoa.types cocoa.views combinators continuations
8 core-foundation.strings core-graphics core-graphics.types
9 core-text debugger io.encodings.string io.encodings.utf16n
10 io.encodings.utf8 kernel literals math math.order math.parser
11 math.rectangles math.vectors namespaces opengl sequences
12 splitting threads ui.backend.cocoa.input-methods ui.commands
13 ui.gadgets ui.gadgets.editors ui.gadgets.line-support
14 ui.gadgets.private ui.gadgets.worlds ui.gestures ui.private
15 words ;
16
17 IN: ui.backend.cocoa.views
18
19 SLOT: window
20
21 : send-mouse-moved ( view event -- )
22     [ mouse-location ] [ drop window ] 2bi
23     [ move-hand fire-motion yield ] [ drop ] if* ;
24
25 ! Issue #1453
26 : button ( event -- n )
27     ! Cocoa -> Factor UI button mapping
28     -> buttonNumber {
29         { 0 [ 1 ] }
30         { 1 [ 3 ] }
31         { 2 [ 2 ] }
32         [ ]
33     } case ;
34
35 CONSTANT: NSAlphaShiftKeyMask 0x10000
36 CONSTANT: NSShiftKeyMask      0x20000
37 CONSTANT: NSControlKeyMask    0x40000
38 CONSTANT: NSAlternateKeyMask  0x80000
39 CONSTANT: NSCommandKeyMask    0x100000
40 CONSTANT: NSNumericPadKeyMask 0x200000
41 CONSTANT: NSHelpKeyMask       0x400000
42 CONSTANT: NSFunctionKeyMask   0x800000
43
44 CONSTANT: modifiers {
45         { S+ $ NSShiftKeyMask }
46         { C+ $ NSControlKeyMask }
47         { M+ $ NSCommandKeyMask }
48         { A+ $ NSAlternateKeyMask }
49     }
50
51 CONSTANT: key-codes
52     H{
53         { 71 "CLEAR" }
54         { 36 "RET" }
55         { 76 "ENTER" }
56         { 53 "ESC" }
57         { 48 "TAB" }
58         { 51 "BACKSPACE" }
59         { 115 "HOME" }
60         { 117 "DELETE" }
61         { 119 "END" }
62         { 122 "F1" }
63         { 120 "F2" }
64         { 99 "F3" }
65         { 118 "F4" }
66         { 96 "F5" }
67         { 97 "F6" }
68         { 98 "F7" }
69         { 100 "F8" }
70         { 123 "LEFT" }
71         { 124 "RIGHT" }
72         { 125 "DOWN" }
73         { 126 "UP" }
74         { 116 "PAGE_UP" }
75         { 121 "PAGE_DOWN" }
76     }
77
78 : key-code ( event -- string ? )
79     dup -> keyCode key-codes at
80     [ t ] [ -> charactersIgnoringModifiers CF>string f ] ?if ;
81
82 : event-modifiers ( event -- modifiers )
83     -> modifierFlags modifiers modifier ;
84
85 : key-event>gesture ( event -- modifiers keycode action? )
86     [ event-modifiers ] [ key-code ] bi ;
87
88 : send-key-event ( view gesture -- )
89     swap window [ propagate-key-gesture ] [ drop ] if* ;
90
91 : interpret-key-event ( view event -- )
92     NSArray swap -> arrayWithObject: -> interpretKeyEvents: ;
93
94 : send-key-down-event ( view event -- )
95     [ key-event>gesture <key-down> send-key-event ]
96     [ interpret-key-event ]
97     2bi ;
98
99 : send-key-up-event ( view event -- )
100     key-event>gesture <key-up> send-key-event ;
101
102 : mouse-event>gesture ( event -- modifiers button )
103     [ event-modifiers ] [ button ] bi ;
104
105 : send-button-down$ ( view event -- )
106     [ nip mouse-event>gesture <button-down> ]
107     [ mouse-location ]
108     [ drop window ]
109     2tri
110     [ send-button-down ] [ 2drop ] if* ;
111
112 : send-button-up$ ( view event -- )
113     [ nip mouse-event>gesture <button-up> ]
114     [ mouse-location ]
115     [ drop window ]
116     2tri
117     [ send-button-up ] [ 2drop ] if* ;
118
119 : send-scroll$ ( view event -- )
120     [ nip [ -> deltaX ] [ -> deltaY ] bi [ neg ] bi@ 2array ]
121     [ mouse-location ]
122     [ drop window ]
123     2tri
124     [ send-scroll ] [ 2drop ] if* ;
125
126 : send-action$ ( view event gesture -- )
127     [ drop window ] dip over [ send-action ] [ 2drop ] if ;
128
129 : string-or-nil? ( NSString -- ? )
130     [ CF>string NSStringPboardType = ] [ t ] if* ;
131
132 : valid-service? ( gadget send-type return-type -- ? )
133     2dup [ string-or-nil? ] [ string-or-nil? ] bi* and
134     [ drop [ gadget-selection? ] [ drop t ] if ] [ 3drop f ] if ;
135
136 : NSRect>rect ( NSRect world -- rect )
137     [ [ [ CGRect-x ] [ CGRect-y ] bi ] [ dim>> second ] bi* swap - 2array ]
138     [ drop [ CGRect-w ] [ CGRect-h ] bi 2array ]
139     2bi <rect> ;
140
141 : rect>NSRect ( rect world -- NSRect )
142     [ [ loc>> first2 ] [ dim>> second ] bi* swap - ]
143     [ drop dim>> first2 ]
144     2bi <CGRect> ;
145
146 CONSTANT: selector>action H{
147     { "undo:" undo-action }
148     { "redo:" redo-action }
149     { "cut:" cut-action }
150     { "copy:" copy-action }
151     { "paste:" paste-action }
152     { "delete:" delete-action }
153     { "selectAll:" select-all-action }
154     { "newDocument:" new-action }
155     { "openDocument:" open-action }
156     { "saveDocument:" save-action }
157     { "saveDocumentAs:" save-as-action }
158     { "revertDocumentToSaved:" revert-action }
159 }
160
161 : validate-action ( world selector -- ? validated? )
162     selector>action at
163     [ swap world-focus parents-handle-gesture? t ] [ drop f f ] if* ;
164
165 : touchbar-commands ( -- commands/f gadget )
166     world get-global [
167         children>> [
168             class-of "commands" word-prop
169             "touchbar" of dup [ commands>> ] when
170         ] map-find
171     ] [ f f ] if* ;
172
173 TUPLE: send-touchbar-command target command ;
174
175 M: send-touchbar-command send-queued-gesture
176     [ target>> ] [ command>> ] bi invoke-command ;
177
178 : touchbar-invoke-command ( n -- )
179     [ touchbar-commands ] dip over [
180         rot nth second
181         send-touchbar-command queue-gesture notify-ui-thread
182         yield
183     ] [ 3drop ] if ;
184
185 IMPORT: NSAttributedString
186
187 <PRIVATE
188
189 :: >codepoint-index ( str utf16-index -- codepoint-index )
190     0 utf16-index 2 * str utf16n encode subseq utf16n decode length ;
191
192 :: >utf16-index ( str codepoint-index -- utf16-index )
193     0 codepoint-index str subseq utf16n encode length 2 /i ;
194
195 :: earlier-caret/mark ( editor -- loc )
196     editor editor-caret :> caret
197     editor editor-mark :> mark
198     caret first mark first = [
199         caret second mark second < [ caret ] [ mark ] if
200     ] [
201         caret first mark first < [ caret ] [ mark ] if
202     ] if ;
203
204 :: make-preedit-underlines ( gadget text range -- underlines )
205     f gadget preedit-selection-mode?<<
206     { } clone :> underlines!
207     text -> length :> text-length
208     0 0 <NSRange> :> effective-range
209     text -> string CF>string :> str
210     str utf16n encode :> byte-16n
211     0 :> cp-loc!
212     "NSMarkedClauseSegment" <NSString> :> segment-attr
213     [ effective-range [ location>> ] [ length>> ] bi + text-length < ] [
214         text
215         segment-attr
216         effective-range [ location>> ] [ length>> ] bi +
217         effective-range >c-ptr
218         -> attribute:atIndex:effectiveRange: drop
219         1 :> thickness!
220         range location>> effective-range location>> = [
221             2 thickness!
222             t gadget preedit-selection-mode?<<
223         ] when
224         underlines
225         effective-range [ location>> ] [ length>> ] bi over +
226         [ str swap >codepoint-index ] bi@ swap - :> len
227         cp-loc cp-loc len + dup cp-loc!
228         2array thickness 2array
229         suffix underlines!
230     ] while 
231     underlines length 1 = [
232         underlines first first 2 2array 1array  ! thickness: 2
233     ] [ underlines ] if ;
234
235 :: update-marked-text ( gadget str selectedRange replacementRange -- )
236     replacementRange location>> NSNotFound = [
237         gadget editor-caret first
238         dup gadget editor-line
239         [ 
240             replacementRange location>>
241             >codepoint-index
242             2array gadget set-caret
243         ] [
244             replacementRange [ location>> ] [ length>> ] bi +
245             >codepoint-index
246             2array gadget set-mark
247         ] 2bi
248         gadget earlier-caret/mark dup
249         gadget preedit-start<<
250         0 1 2array v+ gadget preedit-end<<
251     ] unless
252
253     gadget preedit? [
254         gadget remove-preedit-text
255     ] when
256
257     gadget earlier-caret/mark dup
258     gadget preedit-start<<
259     0 str length 2array v+ gadget preedit-end<<
260     str gadget temp-im-input drop
261     gadget preedit-start>>
262     0 str selectedRange location>> >codepoint-index 2array v+
263     dup gadget preedit-selected-start<<
264     0
265     selectedRange [ location>> ] [ length>> ] bi + selectedRange location>>
266     [ str swap >codepoint-index ] bi@ -
267     2array v+
268     dup gadget preedit-selected-end<<
269     dup gadget set-caret gadget set-mark
270     gadget preedit-start>> gadget preedit-end>> = [
271         gadget remove-preedit-info 
272     ] when ;
273
274 : set-scale-factor ( n -- )
275     [ 1.0 > ] keep f ? gl-scale-factor set-global
276     cached-lines get-global clear-assoc ;
277
278 PRIVATE>
279
280 <CLASS: FactorView < NSOpenGLView
281     COCOA-PROTOCOL: NSTextInputClient
282
283     METHOD: void prepareOpenGL [
284         self -> backingScaleFactor set-scale-factor
285         self -> update
286     ] ;
287
288     METHOD: void reshape [
289         self window :> window
290         window [
291             self view-dim window dim<<
292         ] when
293     ] ;
294
295     ! TouchBar
296     METHOD: void touchBarCommand0 [ 0 touchbar-invoke-command ] ;
297     METHOD: void touchBarCommand1 [ 1 touchbar-invoke-command ] ;
298     METHOD: void touchBarCommand2 [ 2 touchbar-invoke-command ] ;
299     METHOD: void touchBarCommand3 [ 3 touchbar-invoke-command ] ;
300     METHOD: void touchBarCommand4 [ 4 touchbar-invoke-command ] ;
301     METHOD: void touchBarCommand5 [ 5 touchbar-invoke-command ] ;
302     METHOD: void touchBarCommand6 [ 6 touchbar-invoke-command ] ;
303     METHOD: void touchBarCommand7 [ 7 touchbar-invoke-command ] ;
304
305     METHOD: id makeTouchBar [
306         touchbar-commands drop [
307             length 8 min <iota> [ number>string ] map
308         ] [ { } ] if* self make-touchbar
309     ] ;
310
311     METHOD: id touchBar: id touchbar makeItemForIdentifier: id string [
312         touchbar-commands drop [
313             [ self string CF>string dup string>number ] dip nth
314             second name>> "com-" ?head drop over
315             "touchBarCommand" prepend make-NSTouchBar-button
316         ] [ f ] if*
317     ] ;
318
319     ! Rendering
320     METHOD: void drawRect: NSRect rect [
321         self window [
322             [ draw-world yield ] [ print-error drop ] recover
323         ] when*
324     ] ;
325
326     ! Light/Dark Mode
327
328 !     METHOD: void viewDidChangeEffectiveAppearance [
329 !         self -> effectiveAppearance -> name [
330 !             CF>string "NSAppearanceNameDarkAqua" =
331 !             dark-theme light-theme ? switch-theme-if-default
332 !         ] when*
333 !     ] ;
334
335     ! Events
336     METHOD: char acceptsFirstMouse: id event [ 0 ] ;
337
338     METHOD: void mouseEntered: id event [ self event send-mouse-moved ] ;
339
340     METHOD: void mouseExited: id event [ forget-rollover ] ;
341
342     METHOD: void mouseMoved: id event [ self event send-mouse-moved ] ;
343
344     METHOD: void mouseDragged: id event [ self event send-mouse-moved ] ;
345
346     METHOD: void rightMouseDragged: id event [ self event send-mouse-moved ] ;
347
348     METHOD: void otherMouseDragged: id event [ self event send-mouse-moved ] ;
349
350     METHOD: void mouseDown: id event [ self event send-button-down$ ] ;
351
352     METHOD: void mouseUp: id event [ self event send-button-up$ ] ;
353
354     METHOD: void rightMouseDown: id event [ self event send-button-down$ ] ;
355
356     METHOD: void rightMouseUp: id event [ self event send-button-up$ ] ;
357
358     METHOD: void otherMouseDown: id event [ self event send-button-down$ ] ;
359
360     METHOD: void otherMouseUp: id event [ self event send-button-up$ ] ;
361
362     METHOD: void scrollWheel: id event [ self event send-scroll$ ] ;
363
364     METHOD: void keyDown: id event [ self event send-key-down-event ] ;
365
366     METHOD: void keyUp: id event [ self event send-key-up-event ] ;
367
368     METHOD: char validateUserInterfaceItem: id event
369     [
370         self window :> window
371         window [
372             window world-focus :> gadget
373             gadget [
374                 gadget preedit? not [
375                     window event -> action utf8 alien>string validate-action
376                     [ >c-bool ] [ drop self event SUPER-> validateUserInterfaceItem: ] if
377                 ] [ 0 ] if
378             ] [ 0 ] if
379         ] [ 0 ] if
380     ] ;
381
382     METHOD: void undo: id event [ self event undo-action send-action$ ] ;
383
384     METHOD: void redo: id event [ self event redo-action send-action$ ] ;
385
386     METHOD: void cut: id event [ self event cut-action send-action$ ] ;
387
388     METHOD: void copy: id event [ self event copy-action send-action$ ] ;
389
390     METHOD: void paste: id event [ self event paste-action send-action$ ] ;
391
392     METHOD: void delete: id event [ self event delete-action send-action$ ] ;
393
394     METHOD: void selectAll: id event [ self event select-all-action send-action$ ] ;
395
396     METHOD: void newDocument: id event [ self event new-action send-action$ ] ;
397
398     METHOD: void openDocument: id event [ self event open-action send-action$ ] ;
399
400     METHOD: void saveDocument: id event [ self event save-action send-action$ ] ;
401
402     METHOD: void saveDocumentAs: id event [ self event save-as-action send-action$ ] ;
403
404     METHOD: void revertDocumentToSaved: id event [ self event revert-action send-action$ ] ;
405
406     ! Multi-touch gestures
407     METHOD: void magnifyWithEvent: id event
408     [
409         self event
410         dup -> deltaZ sgn {
411             {  1 [ zoom-in-action send-action$ ] }
412             { -1 [ zoom-out-action send-action$ ] }
413             {  0 [ 2drop ] }
414         } case
415     ] ;
416
417     METHOD: void swipeWithEvent: id event
418     [
419         self event
420         dup -> deltaX sgn {
421             {  1 [ left-action send-action$ ] }
422             { -1 [ right-action send-action$ ] }
423             {  0
424                 [
425                     dup -> deltaY sgn {
426                         {  1 [ up-action send-action$ ] }
427                         { -1 [ down-action send-action$ ] }
428                         {  0 [ 2drop ] }
429                     } case
430                 ]
431             }
432         } case
433     ] ;
434
435     METHOD: char acceptsFirstResponder [ 1 ] ;
436
437     ! Services
438     METHOD: id validRequestorForSendType: id sendType returnType: id returnType
439     [
440         ! We return either self or nil
441         self window [
442             world-focus sendType returnType
443             valid-service? [ self ] [ f ] if
444         ] [ f ] if*
445     ] ;
446
447     METHOD: char writeSelectionToPasteboard: id pboard types: id types
448     [
449         NSStringPboardType types CF>string-array member? [
450             self window [
451                 world-focus gadget-selection
452                 [ pboard set-pasteboard-string 1 ] [ 0 ] if*
453             ] [ 0 ] if*
454         ] [ 0 ] if
455     ] ;
456
457     METHOD: char readSelectionFromPasteboard: id pboard
458     [
459         self window :> window
460         window [
461             pboard pasteboard-string
462             [ window user-input 1 ] [ 0 ] if*
463         ] [ 0 ] if
464     ] ;
465
466     ! Text input
467     METHOD: void insertText: id text replacementRange: NSRange replacementRange [
468         self window :> window
469         window [
470             "" clone :> str!
471             text NSString -> class -> isKindOfClass: 0 = not [
472                 text CF>string str!
473             ] [
474                 text -> string CF>string str!
475             ] if
476             window world-focus :> gadget
477             gadget [
478                 gadget support-input-methods? [
479                     replacementRange location>> NSNotFound = [
480                         gadget editor-caret first
481                         dup gadget editor-line
482                         [ 
483                             replacementRange location>> >codepoint-index
484                             2array gadget set-caret
485                         ] [
486                             replacementRange [ location>> ] [ length>> ] bi +
487                             >codepoint-index
488                             2array gadget set-mark
489                         ] 2bi
490                     ] unless
491                     gadget preedit? [
492                         gadget remove-preedit-text
493                         gadget remove-preedit-info
494                         str gadget user-input* drop
495                         f gadget preedit-selection-mode?<<
496                     ] [
497                         str window user-input
498                     ] if
499                 ] [ 
500                     str window user-input
501                 ] if
502             ] when
503         ] when
504     ] ;
505
506     METHOD: char hasMarkedText [
507         self window :> window
508         window [
509             window world-focus :> gadget
510             gadget [
511                 gadget preedit? 1 0 ?
512             ] [ 0 ] if
513         ] [ 0 ] if
514     ] ;
515
516     METHOD: NSRange markedRange [
517         self window :> window
518         window [
519             window world-focus :> gadget
520             gadget [
521                 gadget preedit? [
522                     gadget preedit-start>> second
523                     gadget preedit-end>> second < [
524                         gadget preedit-start>> first gadget editor-line :> str
525                         gadget preedit-start>> second           ! location
526                         gadget preedit-end>> second
527                         [ str swap >utf16-index ] bi@ over -    ! length
528                     ] [ NSNotFound 0 ] if
529                 ] [ NSNotFound 0 ] if
530             ] [ NSNotFound 0 ] if
531         ] [ NSNotFound 0 ] if
532         <NSRange>
533     ] ;
534
535     METHOD: NSRange selectedRange [
536         self window :> window
537         window [
538             window world-focus :> gadget
539             gadget [
540                 gadget support-input-methods? [
541                     gadget editor-caret first gadget editor-line :> str
542                     gadget preedit? [
543                         str
544                         gadget preedit-selected-start>> second
545                         gadget preedit-start>> second
546                         - >utf16-index                        ! location
547                         gadget preedit-selected-end>> second
548                         gadget preedit-selected-start>> second
549                         [ str swap >utf16-index ] bi@ -       ! length
550                     ] [
551                         str gadget editor-caret second >utf16-index 0
552                     ] if
553                 ] [ 0 0 ] if
554             ] [ 0 0 ] if
555         ] [ 0 0 ] if 
556         <NSRange>
557     ] ;
558
559     METHOD: void setMarkedText: id text selectedRange: NSRange selectedRange
560                                      replacementRange: NSRange replacementRange [
561         self window :> window
562         window [
563             window world-focus :> gadget
564             gadget [
565                 { } clone :> underlines!
566                 "" clone :> str!
567                 text NSString -> class -> isKindOfClass: 0 = not [
568                     text CF>string str!
569                 ] [
570                     text -> string CF>string str!
571                     gadget support-input-methods? [
572                         gadget text selectedRange make-preedit-underlines underlines!
573                     ] when
574                 ] if
575                 gadget support-input-methods? [
576                     gadget str selectedRange replacementRange update-marked-text
577                     underlines gadget preedit-underlines<<
578                 ] when
579             ] when
580         ] when
581     ] ;
582
583     METHOD: void unmarkText [
584         self window :> window
585         window [
586             window world-focus :> gadget
587             gadget [
588                 gadget support-input-methods? [
589                     gadget preedit? [
590                         gadget {
591                             [ preedit-start>> second ]
592                             [ preedit-end>> second ]
593                             [ preedit-start>> first ]
594                             [ editor-line ]
595                         } cleave subseq
596                         gadget remove-preedit-text
597                         gadget remove-preedit-info
598                         gadget user-input* drop
599                     ] when
600                     f gadget preedit-selection-mode?<<
601                 ] when
602             ] when
603         ] when
604     ] ;
605
606     METHOD: id validAttributesForMarkedText [
607         NSArray "NSMarkedClauseSegment" <NSString> -> arrayWithObject:
608     ] ;
609
610     METHOD: id attributedSubstringForProposedRange: NSRange aRange
611                                        actualRange: id actualRange [ f ] ;
612
613     METHOD: NSUInteger characterIndexForPoint: NSPoint point [ 0 ] ;
614
615     METHOD: NSRect firstRectForCharacterRange: NSRange aRange
616                                   actualRange: NSRange actualRange [
617         self window :> window
618         window [
619             window world-focus :> gadget
620             gadget [
621                 gadget support-input-methods? [
622                     gadget editor-caret first gadget editor-line :> str
623                     str aRange location>> >codepoint-index :> start-pos
624                     gadget editor-caret first start-pos 2array gadget loc>x
625                     gadget caret-loc second gadget caret-dim second + 
626                     2array                     ! character pos
627                     gadget screen-loc v+       ! + gadget pos
628                     { 1 -1 } v*
629                     window handle>> window>> dup -> frame -> contentRectForFrameRect:
630                     CGRect-top-left 2array v+  ! + window pos
631                     first2 [ >fixnum ] bi@ 0 gadget line-height >fixnum
632                 ] [ 0 0 0 0 ] if
633             ] [ 0 0 0 0 ] if
634         ] [ 0 0 0 0 ] if
635         <CGRect>
636     ] ;
637
638     METHOD: void doCommandBySelector: SEL selector [ ] ;
639
640     ! Initialization
641     METHOD: id initWithFrame: NSRect frame pixelFormat: id pixelFormat
642     [
643         self frame pixelFormat SUPER-> initWithFrame:pixelFormat:
644     ] ;
645
646     METHOD: char isOpaque [ 0 ] ;
647
648     METHOD: void dealloc
649     [
650         self remove-observer
651         self SUPER-> dealloc
652     ] ;
653 ;CLASS>
654
655 : sync-refresh-to-screen ( GLView -- )
656     -> openGLContext -> CGLContextObj NSOpenGLCPSwapInterval 1 int <ref>
657     CGLSetParameter drop ;
658
659 : <FactorView> ( dim pixel-format -- view )
660     [ FactorView ] 2dip <GLView>
661     [ -> backingScaleFactor set-scale-factor ] keep
662     [ sync-refresh-to-screen ] keep ;
663
664 : save-position ( world window -- )
665     -> frame CGRect-top-left 2array >>window-loc drop ;
666
667 <CLASS: FactorWindowDelegate < NSObject
668
669     METHOD: void windowDidMove: id notification
670     [
671         notification -> object -> contentView window
672         [ notification -> object save-position ] when*
673     ] ;
674
675     METHOD: void windowDidBecomeKey: id notification
676     [
677         notification -> object -> contentView window
678         [ focus-world ] when*
679     ] ;
680
681     METHOD: void windowDidResignKey: id notification
682     [
683         forget-rollover
684         notification -> object -> contentView :> view
685         view window :> window
686         window [
687             view -> isInFullScreenMode 0 =
688             [ window unfocus-world ] when
689         ] when
690     ] ;
691
692     METHOD: char windowShouldClose: id notification [ 1 ] ;
693
694     METHOD: void windowWillClose: id notification
695     [
696         notification -> object -> contentView
697         [ window ungraft ] [ unregister-window ] bi
698     ] ;
699
700     METHOD: void windowDidChangeBackingProperties: id notification
701     [
702         notification -> object -> backingScaleFactor set-scale-factor
703     ] ;
704 ;CLASS>
705
706 : install-window-delegate ( window -- )
707     FactorWindowDelegate install-delegate ;