]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/backend/cocoa/views/views.factor
core-text: remove retina? flag in favor of gl-scale-factor
[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 PRIVATE>
275
276 <CLASS: FactorView < NSOpenGLView
277     COCOA-PROTOCOL: NSTextInputClient
278
279     METHOD: void prepareOpenGL [
280
281         self -> backingScaleFactor
282         [ 1.0 > ] keep f ? gl-scale-factor set-global
283
284         cached-lines get-global clear-assoc
285
286         self -> update
287     ] ;
288
289     METHOD: void reshape [
290         self window :> window
291         window [
292             self view-dim window dim<<
293         ] when
294     ] ;
295
296     ! TouchBar
297     METHOD: void touchBarCommand0 [ 0 touchbar-invoke-command ] ;
298     METHOD: void touchBarCommand1 [ 1 touchbar-invoke-command ] ;
299     METHOD: void touchBarCommand2 [ 2 touchbar-invoke-command ] ;
300     METHOD: void touchBarCommand3 [ 3 touchbar-invoke-command ] ;
301     METHOD: void touchBarCommand4 [ 4 touchbar-invoke-command ] ;
302     METHOD: void touchBarCommand5 [ 5 touchbar-invoke-command ] ;
303     METHOD: void touchBarCommand6 [ 6 touchbar-invoke-command ] ;
304     METHOD: void touchBarCommand7 [ 7 touchbar-invoke-command ] ;
305
306     METHOD: id makeTouchBar [
307         touchbar-commands drop [
308             length 8 min <iota> [ number>string ] map
309         ] [ { } ] if* self make-touchbar
310     ] ;
311
312     METHOD: id touchBar: id touchbar makeItemForIdentifier: id string [
313         touchbar-commands drop [
314             [ self string CF>string dup string>number ] dip nth
315             second name>> "com-" ?head drop over
316             "touchBarCommand" prepend make-NSTouchBar-button
317         ] [ f ] if*
318     ] ;
319
320     ! Rendering
321     METHOD: void drawRect: NSRect rect [
322         self window [
323             [ draw-world yield ] [ print-error drop ] recover
324         ] when*
325     ] ;
326
327     ! Light/Dark Mode
328
329 !     METHOD: void viewDidChangeEffectiveAppearance [
330 !         self -> effectiveAppearance -> name [
331 !             CF>string "NSAppearanceNameDarkAqua" =
332 !             dark-theme light-theme ? switch-theme-if-default
333 !         ] when*
334 !     ] ;
335
336     ! Events
337     METHOD: char acceptsFirstMouse: id event [ 0 ] ;
338
339     METHOD: void mouseEntered: id event [ self event send-mouse-moved ] ;
340
341     METHOD: void mouseExited: id event [ forget-rollover ] ;
342
343     METHOD: void mouseMoved: id event [ self event send-mouse-moved ] ;
344
345     METHOD: void mouseDragged: id event [ self event send-mouse-moved ] ;
346
347     METHOD: void rightMouseDragged: id event [ self event send-mouse-moved ] ;
348
349     METHOD: void otherMouseDragged: id event [ self event send-mouse-moved ] ;
350
351     METHOD: void mouseDown: id event [ self event send-button-down$ ] ;
352
353     METHOD: void mouseUp: id event [ self event send-button-up$ ] ;
354
355     METHOD: void rightMouseDown: id event [ self event send-button-down$ ] ;
356
357     METHOD: void rightMouseUp: id event [ self event send-button-up$ ] ;
358
359     METHOD: void otherMouseDown: id event [ self event send-button-down$ ] ;
360
361     METHOD: void otherMouseUp: id event [ self event send-button-up$ ] ;
362
363     METHOD: void scrollWheel: id event [ self event send-scroll$ ] ;
364
365     METHOD: void keyDown: id event [ self event send-key-down-event ] ;
366
367     METHOD: void keyUp: id event [ self event send-key-up-event ] ;
368
369     METHOD: char validateUserInterfaceItem: id event
370     [
371         self window :> window
372         window [
373             window world-focus :> gadget
374             gadget [
375                 gadget preedit? not [
376                     window event -> action utf8 alien>string validate-action
377                     [ >c-bool ] [ drop self event SUPER-> validateUserInterfaceItem: ] if
378                 ] [ 0 ] if
379             ] [ 0 ] if
380         ] [ 0 ] if
381     ] ;
382
383     METHOD: void undo: id event [ self event undo-action send-action$ ] ;
384
385     METHOD: void redo: id event [ self event redo-action send-action$ ] ;
386
387     METHOD: void cut: id event [ self event cut-action send-action$ ] ;
388
389     METHOD: void copy: id event [ self event copy-action send-action$ ] ;
390
391     METHOD: void paste: id event [ self event paste-action send-action$ ] ;
392
393     METHOD: void delete: id event [ self event delete-action send-action$ ] ;
394
395     METHOD: void selectAll: id event [ self event select-all-action send-action$ ] ;
396
397     METHOD: void newDocument: id event [ self event new-action send-action$ ] ;
398
399     METHOD: void openDocument: id event [ self event open-action send-action$ ] ;
400
401     METHOD: void saveDocument: id event [ self event save-action send-action$ ] ;
402
403     METHOD: void saveDocumentAs: id event [ self event save-as-action send-action$ ] ;
404
405     METHOD: void revertDocumentToSaved: id event [ self event revert-action send-action$ ] ;
406
407     ! Multi-touch gestures
408     METHOD: void magnifyWithEvent: id event
409     [
410         self event
411         dup -> deltaZ sgn {
412             {  1 [ zoom-in-action send-action$ ] }
413             { -1 [ zoom-out-action send-action$ ] }
414             {  0 [ 2drop ] }
415         } case
416     ] ;
417
418     METHOD: void swipeWithEvent: id event
419     [
420         self event
421         dup -> deltaX sgn {
422             {  1 [ left-action send-action$ ] }
423             { -1 [ right-action send-action$ ] }
424             {  0
425                 [
426                     dup -> deltaY sgn {
427                         {  1 [ up-action send-action$ ] }
428                         { -1 [ down-action send-action$ ] }
429                         {  0 [ 2drop ] }
430                     } case
431                 ]
432             }
433         } case
434     ] ;
435
436     METHOD: char acceptsFirstResponder [ 1 ] ;
437
438     ! Services
439     METHOD: id validRequestorForSendType: id sendType returnType: id returnType
440     [
441         ! We return either self or nil
442         self window [
443             world-focus sendType returnType
444             valid-service? [ self ] [ f ] if
445         ] [ f ] if*
446     ] ;
447
448     METHOD: char writeSelectionToPasteboard: id pboard types: id types
449     [
450         NSStringPboardType types CF>string-array member? [
451             self window [
452                 world-focus gadget-selection
453                 [ pboard set-pasteboard-string 1 ] [ 0 ] if*
454             ] [ 0 ] if*
455         ] [ 0 ] if
456     ] ;
457
458     METHOD: char readSelectionFromPasteboard: id pboard
459     [
460         self window :> window
461         window [
462             pboard pasteboard-string
463             [ window user-input 1 ] [ 0 ] if*
464         ] [ 0 ] if
465     ] ;
466
467     ! Text input
468     METHOD: void insertText: id text replacementRange: NSRange replacementRange [
469         self window :> window
470         window [
471             "" clone :> str!
472             text NSString -> class -> isKindOfClass: 0 = not [
473                 text CF>string str!
474             ] [
475                 text -> string CF>string str!
476             ] if
477             window world-focus :> gadget
478             gadget [
479                 gadget support-input-methods? [
480                     replacementRange location>> NSNotFound = [
481                         gadget editor-caret first
482                         dup gadget editor-line
483                         [ 
484                             replacementRange location>> >codepoint-index
485                             2array gadget set-caret
486                         ] [
487                             replacementRange [ location>> ] [ length>> ] bi +
488                             >codepoint-index
489                             2array gadget set-mark
490                         ] 2bi
491                     ] unless
492                     gadget preedit? [
493                         gadget remove-preedit-text
494                         gadget remove-preedit-info
495                         str gadget user-input* drop
496                         f gadget preedit-selection-mode?<<
497                     ] [
498                         str window user-input
499                     ] if
500                 ] [ 
501                     str window user-input
502                 ] if
503             ] when
504         ] when
505     ] ;
506
507     METHOD: char hasMarkedText [
508         self window :> window
509         window [
510             window world-focus :> gadget
511             gadget [
512                 gadget preedit? 1 0 ?
513             ] [ 0 ] if
514         ] [ 0 ] if
515     ] ;
516
517     METHOD: NSRange markedRange [
518         self window :> window
519         window [
520             window world-focus :> gadget
521             gadget [
522                 gadget preedit? [
523                     gadget preedit-start>> second
524                     gadget preedit-end>> second < [
525                         gadget preedit-start>> first gadget editor-line :> str
526                         gadget preedit-start>> second           ! location
527                         gadget preedit-end>> second
528                         [ str swap >utf16-index ] bi@ over -    ! length
529                     ] [ NSNotFound 0 ] if
530                 ] [ NSNotFound 0 ] if
531             ] [ NSNotFound 0 ] if
532         ] [ NSNotFound 0 ] if
533         <NSRange>
534     ] ;
535
536     METHOD: NSRange selectedRange [
537         self window :> window
538         window [
539             window world-focus :> gadget
540             gadget [
541                 gadget support-input-methods? [
542                     gadget editor-caret first gadget editor-line :> str
543                     gadget preedit? [
544                         str
545                         gadget preedit-selected-start>> second
546                         gadget preedit-start>> second
547                         - >utf16-index                        ! location
548                         gadget preedit-selected-end>> second
549                         gadget preedit-selected-start>> second
550                         [ str swap >utf16-index ] bi@ -       ! length
551                     ] [
552                         str gadget editor-caret second >utf16-index 0
553                     ] if
554                 ] [ 0 0 ] if
555             ] [ 0 0 ] if
556         ] [ 0 0 ] if 
557         <NSRange>
558     ] ;
559
560     METHOD: void setMarkedText: id text selectedRange: NSRange selectedRange
561                                      replacementRange: NSRange replacementRange [
562         self window :> window
563         window [
564             window world-focus :> gadget
565             gadget [
566                 { } clone :> underlines!
567                 "" clone :> str!
568                 text NSString -> class -> isKindOfClass: 0 = not [
569                     text CF>string str!
570                 ] [
571                     text -> string CF>string str!
572                     gadget support-input-methods? [
573                         gadget text selectedRange make-preedit-underlines underlines!
574                     ] when
575                 ] if
576                 gadget support-input-methods? [
577                     gadget str selectedRange replacementRange update-marked-text
578                     underlines gadget preedit-underlines<<
579                 ] when
580             ] when
581         ] when
582     ] ;
583
584     METHOD: void unmarkText [
585         self window :> window
586         window [
587             window world-focus :> gadget
588             gadget [
589                 gadget support-input-methods? [
590                     gadget preedit? [
591                         gadget {
592                             [ preedit-start>> second ]
593                             [ preedit-end>> second ]
594                             [ preedit-start>> first ]
595                             [ editor-line ]
596                         } cleave subseq
597                         gadget remove-preedit-text
598                         gadget remove-preedit-info
599                         gadget user-input* drop
600                     ] when
601                     f gadget preedit-selection-mode?<<
602                 ] when
603             ] when
604         ] when
605     ] ;
606
607     METHOD: id validAttributesForMarkedText [
608         NSArray "NSMarkedClauseSegment" <NSString> -> arrayWithObject:
609     ] ;
610
611     METHOD: id attributedSubstringForProposedRange: NSRange aRange
612                                        actualRange: id actualRange [ f ] ;
613
614     METHOD: NSUInteger characterIndexForPoint: NSPoint point [ 0 ] ;
615
616     METHOD: NSRect firstRectForCharacterRange: NSRange aRange
617                                   actualRange: NSRange actualRange [
618         self window :> window
619         window [
620             window world-focus :> gadget
621             gadget [
622                 gadget support-input-methods? [
623                     gadget editor-caret first gadget editor-line :> str
624                     str aRange location>> >codepoint-index :> start-pos
625                     gadget editor-caret first start-pos 2array gadget loc>x
626                     gadget caret-loc second gadget caret-dim second + 
627                     2array                     ! character pos
628                     gadget screen-loc v+       ! + gadget pos
629                     { 1 -1 } v*
630                     window handle>> window>> dup -> frame -> contentRectForFrameRect:
631                     CGRect-top-left 2array v+  ! + window pos
632                     first2 [ >fixnum ] bi@ 0 gadget line-height >fixnum
633                 ] [ 0 0 0 0 ] if
634             ] [ 0 0 0 0 ] if
635         ] [ 0 0 0 0 ] if
636         <CGRect>
637     ] ;
638
639     METHOD: void doCommandBySelector: SEL selector [ ] ;
640
641     ! Initialization
642     METHOD: id initWithFrame: NSRect frame pixelFormat: id pixelFormat
643     [
644         self frame pixelFormat SUPER-> initWithFrame:pixelFormat:
645     ] ;
646
647     METHOD: char isOpaque [ 0 ] ;
648
649     METHOD: void dealloc
650     [
651         self remove-observer
652         self SUPER-> dealloc
653     ] ;
654 ;CLASS>
655
656 : sync-refresh-to-screen ( GLView -- )
657     -> openGLContext -> CGLContextObj NSOpenGLCPSwapInterval 1 int <ref>
658     CGLSetParameter drop ;
659
660 : <FactorView> ( dim pixel-format -- view )
661     [ FactorView ] 2dip <GLView> [ sync-refresh-to-screen ] keep ;
662
663 : save-position ( world window -- )
664     -> frame CGRect-top-left 2array >>window-loc drop ;
665
666 <CLASS: FactorWindowDelegate < NSObject
667
668     METHOD: void windowDidMove: id notification
669     [
670         notification -> object -> contentView window
671         [ notification -> object save-position ] when*
672     ] ;
673
674     METHOD: void windowDidBecomeKey: id notification
675     [
676         notification -> object -> contentView window
677         [ focus-world ] when*
678     ] ;
679
680     METHOD: void windowDidResignKey: id notification
681     [
682         forget-rollover
683         notification -> object -> contentView :> view
684         view window :> window
685         window [
686             view -> isInFullScreenMode 0 =
687             [ window unfocus-world ] when
688         ] when
689     ] ;
690
691     METHOD: char windowShouldClose: id notification [ 1 ] ;
692
693     METHOD: void windowWillClose: id notification
694     [
695         notification -> object -> contentView
696         [ window ungraft ] [ unregister-window ] bi
697     ] ;
698
699     METHOD: void windowDidChangeBackingProperties: id notification
700     [
701         notification -> object -> backingScaleFactor
702         [ 1.0 > ] keep f ? gl-scale-factor set-global
703     ] ;
704 ;CLASS>
705
706 : install-window-delegate ( window -- )
707     FactorWindowDelegate install-delegate ;