From e2fa0a6392717c6458097836540d351def70b4f0 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Fri, 22 May 2020 08:23:20 -0700 Subject: [PATCH] ui.backend.cocoa.views: fix jittery resize. This could still be improved since this current approach pauses Factor execution when the window is being resized, and it could instead maybe detect inLiveResize or something and be smoother. --- basis/ui/backend/cocoa/views/views.factor | 28 ++++++++++------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/basis/ui/backend/cocoa/views/views.factor b/basis/ui/backend/cocoa/views/views.factor index 0d79bbe36c..820b4831dd 100644 --- a/basis/ui/backend/cocoa/views/views.factor +++ b/basis/ui/backend/cocoa/views/views.factor @@ -125,12 +125,6 @@ CONSTANT: key-codes : send-action$ ( view event gesture -- ) [ drop window ] dip over [ send-action ] [ 2drop ] if ; -: add-resize-observer ( observer object -- ) - [ - "updateFactorGadgetSize:" - "NSViewFrameDidChangeNotification" - ] dip add-observer ; - : string-or-nil? ( NSString -- ? ) [ CF>string NSStringPboardType = ] [ t ] if* ; @@ -299,6 +293,13 @@ PRIVATE> ] when ] ; + METHOD: void reshape [ + self window :> window + window [ + self view-dim window dim<< + ] when + ] ; + ! TouchBar METHOD: void touchBarCommand0 [ 0 touchbar-invoke-command ] ; METHOD: void touchBarCommand1 [ 1 touchbar-invoke-command ] ; @@ -324,7 +325,11 @@ PRIVATE> ] ; ! Rendering - METHOD: void drawRect: NSRect rect [ self window [ draw-world ] when* ] ; + METHOD: void drawRect: NSRect rect [ + self window [ + draw-world yield + ] when* + ] ; ! Events METHOD: char acceptsFirstMouse: id event [ 0 ] ; @@ -632,18 +637,9 @@ PRIVATE> METHOD: void doCommandBySelector: SEL selector [ ] ; ! Initialization - METHOD: void updateFactorGadgetSize: id notification - [ - self window :> window - window [ - self view-dim window dim<< yield - ] when - ] ; - METHOD: id initWithFrame: NSRect frame pixelFormat: id pixelFormat [ self frame pixelFormat SUPER-> initWithFrame:pixelFormat: - dup dup add-resize-observer ] ; METHOD: char isOpaque [ 0 ] ;