From 3747d96b22c1ae2eff19edefcec9e28605e558e7 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 13 May 2018 11:12:03 -0400 Subject: [PATCH] Corrects Mac paste pathway. Also updates documentation around CSOpenGLView. --- .../Documents/MachineDocument.swift | 2 +- .../Mac/Clock Signal/Views/CSOpenGLView.h | 22 ++++++++++++------- .../Mac/Clock Signal/Views/CSOpenGLView.m | 5 +++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift index 9444ff2c7..dc1aeb5c4 100644 --- a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift +++ b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift @@ -167,7 +167,7 @@ class MachineDocument: } // MARK: the pasteboard - func paste(_ sender: AnyObject!) { + func paste(_ sender: Any) { let pasteboard = NSPasteboard.general if let string = pasteboard.string(forType: .string) { self.machine.paste(string) diff --git a/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.h b/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.h index 12daa4fb1..17f2ed89b 100644 --- a/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.h +++ b/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.h @@ -32,31 +32,33 @@ @protocol CSOpenGLViewResponderDelegate /*! - Supplies a keyDown event to the delegate. Will always be called on the same queue as the other - @c CSOpenGLViewResponderDelegate methods and as -[CSOpenGLViewDelegate openGLView:didUpdateToTime:]. + Supplies a keyDown event to the delegate. @param event The @c NSEvent describing the keyDown. */ - (void)keyDown:(nonnull NSEvent *)event; /*! - Supplies a keyUp event to the delegate. Will always be called on the same queue as the other - @c CSOpenGLViewResponderDelegate methods and as -[CSOpenGLViewDelegate openGLView:didUpdateToTime:]. + Supplies a keyUp event to the delegate. @param event The @c NSEvent describing the keyUp. */ - (void)keyUp:(nonnull NSEvent *)event; /*! - Supplies a flagsChanged event to the delegate. Will always be called on the same queue as the other - @c CSOpenGLViewResponderDelegate methods and as -[CSOpenGLViewDelegate openGLView:didUpdateToTime:]. + Supplies a flagsChanged event to the delegate. @param event The @c NSEvent describing the flagsChanged. */ - (void)flagsChanged:(nonnull NSEvent *)event; +/*! + Supplies a paste event to the delegate. +*/ +- (void)paste:(nonnull id)sender; + @end /*! - Provides an OpenGL canvas with a refresh-linked update timer and manages a serial dispatch queue - such that a delegate may produce video and respond to keyboard events. + Provides an OpenGL canvas with a refresh-linked update timer that can forward a subset + of typical first-responder actions. */ @interface CSOpenGLView : NSOpenGLView @@ -72,6 +74,10 @@ /// The size in pixels of the OpenGL canvas, factoring in screen pixel density and view size in points. @property (nonatomic, readonly) CGSize backingSize; +/*! + Locks this view's OpenGL context and makes it current, performs @c action and then unlocks + the context. @c action is performed on the calling queue. +*/ - (void)performWithGLContext:(nonnull dispatch_block_t)action; @end diff --git a/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.m b/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.m index 596dd9daa..a6b90dc82 100644 --- a/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.m +++ b/OSBindings/Mac/Clock Signal/Views/CSOpenGLView.m @@ -162,6 +162,11 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt [self.responderDelegate flagsChanged:theEvent]; } +- (void)paste:(id)sender +{ + [self.responderDelegate paste:sender]; +} + #pragma mark - NSDraggingDestination - (BOOL)performDragOperation:(id )sender