Skip to content

Commit

Permalink
fixed Leopard compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin committed Oct 25, 2009
1 parent 9c85d1e commit 5a62168
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions src/Visor.m
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,8 @@ - (void)resetWindowPlacement {
[self cachePosition];
[self applyVisorPositioning];
[self slideWindows:!isHidden fast:YES];
} else {
LOG(@"resetWindowPlacement called for nil window");
}
}

Expand Down Expand Up @@ -768,18 +770,7 @@ - (void)placeWindow:(id)win offset:(float)offset {

- (void)resetVisorWindowSize:(id)win {
LOG(@"resetVisorWindowSize");

// this block is needed to prevent "<NSSplitView>: the delegate <InterfaceController> was sent -splitView:resizeSubviewsWithOldSize: and left the subview frames in an inconsistent state" type of message
// http://cocoadev.com/forums/comments.php?DiscussionID=1092
// this issue is only on Snow Leopard (10.6), because it is newly using NSSplitViews
NSRect safeFrame;
safeFrame.origin.x = 0;
safeFrame.origin.y = 0;
safeFrame.size.width = 1000;
safeFrame.size.height = 1000;
[win setFrame:safeFrame display:NO];

if (!runningOnLeopard_) {
if (runningOnLeopard_) {
// 10.5 path
// this is kind of a hack
// I'm using scripting API to update main window geometry according to profile settings
Expand All @@ -789,10 +780,24 @@ - (void)resetVisorWindowSize:(id)win {

NSNumber *cols = [visorProfile scriptNumberOfColumns];
NSNumber *rows = [visorProfile scriptNumberOfRows];
LOG(@" 10.5 path: setting window dimmensions to %@, %@ via scripting interface", cols, rows);
[visorProfile setScriptNumberOfColumns:cols];
[visorProfile setScriptNumberOfRows:rows];
} else {
// 10.6 path
// this block is needed to prevent "<NSSplitView>: the delegate <InterfaceController> was sent -splitView:resizeSubviewsWithOldSize: and left the subview frames in an inconsistent state" type of message
// http://cocoadev.com/forums/comments.php?DiscussionID=1092
// this issue is only on Snow Leopard (10.6), because it is newly using NSSplitViews
NSRect safeFrame;
safeFrame.origin.x = 0;
safeFrame.origin.y = 0;
safeFrame.size.width = 1000;
safeFrame.size.height = 1000;
[win setFrame:safeFrame display:NO];

// this is a better way of 10.5 path for Terminal on Snow Leopard
// we may call returnToDefaultSize method on our window's view
// no more resizing issues like described here: http://github.com/darwin/visor/issues/#issue/1
id controller = [window_ windowController];
id tabc = [controller selectedTabController];
id pane = [tabc activePane];
Expand Down Expand Up @@ -929,7 +934,7 @@ - (void)applyVisorPositioning {

- (void)storePreviouslyActiveApp {
LOG(@"storePreviouslyActiveApp");
if (!runningOnLeopard_) {
if (runningOnLeopard_) {
// 10.5 path
NSDictionary *activeAppDict = [[NSWorkspace sharedWorkspace] activeApplication];
previouslyActiveAppPath = nil;
Expand All @@ -949,7 +954,7 @@ - (void)storePreviouslyActiveApp {
}

- (void)restorePreviouslyActiveApp {
if (!runningOnLeopard_) {
if (runningOnLeopard_) {
if (!previouslyActiveAppPath) return;
LOG(@"restorePreviouslyActiveApp %@", previouslyActiveAppPath);
// 10.5 path
Expand Down

0 comments on commit 5a62168

Please sign in to comment.