Revision: 12664
          http://sourceforge.net/p/skim-app/code/12664
Author:   hofman
Date:     2021-12-30 14:59:43 +0000 (Thu, 30 Dec 2021)
Log Message:
-----------
Always observe key state changes, we may need to reset temp toolmode

Modified Paths:
--------------
    trunk/SKPDFView.m

Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m   2021-12-29 19:59:44 UTC (rev 12663)
+++ trunk/SKPDFView.m   2021-12-30 14:59:43 UTC (rev 12664)
@@ -3073,14 +3073,17 @@
 
 - (void)handleKeyStateChangedNotification:(NSNotification *)notification {
     pdfvFlags.inKeyWindow = [[self window] isKeyWindow];
-    if (selectionPageIndex != NSNotFound) {
-        CGFloat margin = HANDLE_SIZE / [self scaleFactor];
-        for (PDFPage *page in [self displayedPages])
-            [self setNeedsDisplayInRect:NSInsetRect(selectionRect, -margin, 
-margin) ofPage:page];
+    if (RUNNING_BEFORE(10_12) || RUNNING_AFTER(10_14)) {
+        if (selectionPageIndex != NSNotFound) {
+            CGFloat margin = HANDLE_SIZE / [self scaleFactor];
+            for (PDFPage *page in [self displayedPages])
+                [self setNeedsDisplayInRect:NSInsetRect(selectionRect, 
-margin, -margin) ofPage:page];
+        }
+        if (activeAnnotation)
+            [self setNeedsDisplayForAnnotation:activeAnnotation];
     }
-    if (activeAnnotation)
-        [self setNeedsDisplayForAnnotation:activeAnnotation];
-    [self setTemporaryToolMode:SKNoToolMode];
+    if (notification)
+        [self setTemporaryToolMode:SKNoToolMode];
 }
 
 #pragma mark Key and window changes
@@ -3101,19 +3104,17 @@
     
     [self setTemporaryToolMode:SKNoToolMode];
     
-    if (RUNNING_BEFORE(10_12) || RUNNING_AFTER(10_14)) {
-        NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
-        NSWindow *oldWindow = [self window];
-        if (oldWindow) {
-            [nc removeObserver:self name:NSWindowDidBecomeKeyNotification 
object:oldWindow];
-            [nc removeObserver:self name:NSWindowDidResignKeyNotification 
object:oldWindow];
-        }
-        if (newWindow) {
-            pdfvFlags.inKeyWindow = [newWindow isKeyWindow];
-            [nc addObserver:self 
selector:@selector(handleKeyStateChangedNotification:) 
name:NSWindowDidBecomeKeyNotification object:newWindow];
-            [nc addObserver:self 
selector:@selector(handleKeyStateChangedNotification:) 
name:NSWindowDidResignKeyNotification object:newWindow];
-        }
+    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+    NSWindow *oldWindow = [self window];
+    if (oldWindow) {
+        [nc removeObserver:self name:NSWindowDidBecomeKeyNotification 
object:oldWindow];
+        [nc removeObserver:self name:NSWindowDidResignKeyNotification 
object:oldWindow];
     }
+    if (newWindow) {
+        pdfvFlags.inKeyWindow = [newWindow isKeyWindow];
+        [nc addObserver:self 
selector:@selector(handleKeyStateChangedNotification:) 
name:NSWindowDidBecomeKeyNotification object:newWindow];
+        [nc addObserver:self 
selector:@selector(handleKeyStateChangedNotification:) 
name:NSWindowDidResignKeyNotification object:newWindow];
+    }
     
     [super viewWillMoveToWindow:newWindow];
 }

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to