aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2013-06-13 18:38:33 +0000
committerrowanbeentje <rowan@beent.je>2013-06-13 18:38:33 +0000
commit33dbe8d35c3e681c5a8cfd223be50ae7c769cf15 (patch)
treecfc51a04f989bbb7db3555c5243b4f6b4cc5e483 /Frameworks
parent08036ae8c5e62d843831b43447f12ad6613e728b (diff)
downloadsequelpro-33dbe8d35c3e681c5a8cfd223be50ae7c769cf15.tar.gz
sequelpro-33dbe8d35c3e681c5a8cfd223be50ae7c769cf15.tar.bz2
sequelpro-33dbe8d35c3e681c5a8cfd223be50ae7c769cf15.zip
- Fix window update notification action within PSMTabBar, only redrawing the tab bar if the window state has changed. This significantly reduces CPU usage when mousing around the window by avoiding needless draws, and also addresses graphics corruption/artefacts when drawing above a blurred background, addressing Issue #1678
Diffstat (limited to 'Frameworks')
-rw-r--r--Frameworks/PSMTabBar/PSMTabBarControl.h7
-rw-r--r--Frameworks/PSMTabBar/PSMTabBarControl.m24
2 files changed, 25 insertions, 6 deletions
diff --git a/Frameworks/PSMTabBar/PSMTabBarControl.h b/Frameworks/PSMTabBar/PSMTabBarControl.h
index d2cbc534..9aebddad 100644
--- a/Frameworks/PSMTabBar/PSMTabBarControl.h
+++ b/Frameworks/PSMTabBar/PSMTabBarControl.h
@@ -111,7 +111,12 @@ enum {
BOOL _awakenedFromNib;
NSInteger _tabBarWidth;
NSTimer *_showHideAnimationTimer;
-
+
+ // Tracking last window state for update draws
+ BOOL _lastWindowIsMainCheck;
+ BOOL _lastAttachedWindowIsMainCheck;
+ BOOL _lastAppIsActiveCheck;
+
// drag and drop
NSEvent *_lastMouseDownEvent; // keep this for dragging reference
BOOL _didDrag;
diff --git a/Frameworks/PSMTabBar/PSMTabBarControl.m b/Frameworks/PSMTabBar/PSMTabBarControl.m
index ffac0255..2cc9334a 100644
--- a/Frameworks/PSMTabBar/PSMTabBarControl.m
+++ b/Frameworks/PSMTabBar/PSMTabBarControl.m
@@ -118,6 +118,10 @@
_cells = [[NSMutableArray alloc] initWithCapacity:10];
_controller = [[PSMTabBarController alloc] initWithTabBarControl:self];
_animationTimer = nil;
+ _lastWindowIsMainCheck = NO;
+ _lastAttachedWindowIsMainCheck = NO;
+ _lastAppIsActiveCheck = NO;
+ _lastMouseDownEvent = nil;
// default config
_currentStep = kPSMIsNotBeingResized;
@@ -1805,13 +1809,23 @@
if ([[self delegate] respondsToSelector:@selector(tabView:tabBarDidHide:)]) {
[[self delegate] tabView:[self tabView] tabBarDidHide:self];
}
- }
- // The above tasks only needs to be run once, so set a flag to ensure that
- _awakenedFromNib = YES;
+ // The above tasks only needs to be run once, so set a flag to ensure that
+ _awakenedFromNib = YES;
+ }
- // Allow the tab bar to redraw itself in result to window ordering/sheet/etc changes
- [self setNeedsDisplay:YES];
+ // Determine whether a draw update in response to window state change might be required
+ BOOL isMainWindow = [[self window] isMainWindow];
+ BOOL attachedWindowIsMainWindow = [[[self window] attachedSheet] isMainWindow];
+ BOOL isActiveApplication = [NSApp isActive];
+ if (_lastWindowIsMainCheck != isMainWindow || _lastAttachedWindowIsMainCheck != attachedWindowIsMainWindow || _lastAppIsActiveCheck != isActiveApplication) {
+ _lastWindowIsMainCheck = isMainWindow;
+ _lastAttachedWindowIsMainCheck = attachedWindowIsMainWindow;
+ _lastAppIsActiveCheck = isActiveApplication;
+
+ // Allow the tab bar to redraw itself in result to window ordering/sheet/etc changes
+ [self setNeedsDisplay:YES];
+ }
}
#pragma mark -