Skip to content

Commit

Permalink
Fixed an issue displaying two screens of different size in the arrang…
Browse files Browse the repository at this point in the history
…ement preference pane.
  • Loading branch information
Alex Ernst committed Oct 26, 2011
1 parent 34bf9b4 commit b348bcd
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ArrangementPreviewView.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,29 @@ - (void)drawRect:(NSRect)dirtyRect {

NSArray *screens = [NSScreen screens];
CGFloat xMax = 0, yMax = 0;
CGFloat xMin = 0, yMin = 0;
for (NSScreen *screen in screens) {
NSRect frame = [screen frame];
CGFloat x = frame.origin.x + frame.size.width;
CGFloat y = frame.origin.y + frame.size.height;
xMax = MAX(xMax, x);
yMax = MAX(yMax, y);
xMin = MIN(xMin, frame.origin.x);
yMin = MIN(yMin, frame.origin.y);
}

double xScale = [self frame].size.width / xMax;
double yScale = [self frame].size.height / yMax;
double xScale = [self frame].size.width / (xMax - xMin);
double yScale = [self frame].size.height / (yMax - yMin);
double scale = MIN(xScale, yScale);
double yCorrection = MAX(0, ([self frame].size.height - yMax * scale) / 2);
double xCorrection = MAX(0, ([self frame].size.width - xMax * scale) / 2);
double yCorrection = MAX(0, ([self frame].size.height - (yMax - yMin) * scale) / 2);
double xCorrection = MAX(0, ([self frame].size.width - (xMax - xMin) * scale) / 2);

NSMutableArray *screenFrames = [NSMutableArray array];
for (NSScreen *screen in screens) {
NSRect frame = [screen frame];

NSRect rect = NSMakeRect(frame.origin.x * scale + xCorrection,
frame.origin.y * scale + yCorrection,
NSRect rect = NSMakeRect((frame.origin.x - xMin) * scale + xCorrection,
(yMax - frame.size.height - frame.origin.y) * scale + yCorrection,
frame.size.width * scale,
frame.size.height * scale);
[[NSColor blackColor] set];
Expand Down

0 comments on commit b348bcd

Please sign in to comment.