diff options
| author | Manolo Gouy <Manolo> | 2011-10-18 11:46:29 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2011-10-18 11:46:29 +0000 |
| commit | 55b744c225efac560894111bd608ab3904f5df37 (patch) | |
| tree | 0dc05089210c2aaec55abbc6719ad27faa7adcd9 | |
| parent | 3c8a18a57572676f834ceff3fa08654dfa7334be (diff) | |
When several screens, allow creation of window on secondary screen by Fl_Window::Fl_Window(x,y,w,h,title).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9134 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | src/Fl_cocoa.mm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index cf4853b7d..0519797a1 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -577,7 +577,21 @@ static void do_timer(CFRunLoopTimerRef timer, void* data) contentRect:(NSRect)rect styleMask:(NSUInteger)windowStyle { - self = [super initWithContentRect:rect styleMask:windowStyle backing:NSBackingStoreBuffered defer:NO]; + NSScreen *gd = nil; // gd will point to the screen containing the bottom-left of rect + NSArray *a = [NSScreen screens]; + for(NSUInteger i = 0; i < [a count]; i++) { + NSRect r = [[a objectAtIndex:i] frame]; + if (rect.origin.x >= r.origin.x && rect.origin.x <= r.origin.x + r.size.width + && rect.origin.y >= r.origin.y && rect.origin.y <= r.origin.y + r.size.height) { + gd = [a objectAtIndex:i]; + rect.origin.x -= r.origin.x; // express rect relatively to gd's origin + rect.origin.y -= r.origin.y; + break; + } + } + // attempt to create the window on screen gd + self = [super initWithContentRect:rect styleMask:windowStyle backing:NSBackingStoreBuffered defer:NO + screen:gd]; if (self) { w = flw; containsGLsubwindow = NO; |
