diff --git a/src/osx/cocoa/utils.mm b/src/osx/cocoa/utils.mm index 97b3a8822c..d73bffe8b6 100644 --- a/src/osx/cocoa/utils.mm +++ b/src/osx/cocoa/utils.mm @@ -485,6 +485,24 @@ wxRect wxOSXGetMainDisplayClientArea() return wxFromNSRect( NULL, displayRect ); } +static NSScreen* wxOSXGetScreenFromDisplay( CGDirectDisplayID ID) +{ + for (NSScreen* screen in [NSScreen screens]) + { + CGDirectDisplayID displayID = [[[screen deviceDescription] objectForKey:@"NSScreenNumber"] intValue]; + if ( displayID == ID ) + return screen; + } + return NULL; +} + +extern // used from src/osx/core/display.cpp +wxRect wxOSXGetDisplayClientArea(CGDirectDisplayID ID) +{ + NSRect displayRect = [wxOSXGetScreenFromDisplay(ID) visibleFrame]; + return wxFromNSRect( NULL, displayRect ); +} + void wxGetMousePosition( int* x, int* y ) { wxPoint pt = wxFromNSPoint(NULL, [NSEvent mouseLocation]); diff --git a/src/osx/core/display.cpp b/src/osx/core/display.cpp index b85cc3e081..9d1131dc4e 100644 --- a/src/osx/core/display.cpp +++ b/src/osx/core/display.cpp @@ -40,6 +40,7 @@ // This one is defined in Objective C++ code. extern wxRect wxOSXGetMainDisplayClientArea(); +extern wxRect wxOSXGetDisplayClientArea(CGDirectDisplayID id); namespace { @@ -297,13 +298,7 @@ wxRect wxDisplayImplMacOSX::GetGeometry() const wxRect wxDisplayImplMacOSX::GetClientArea() const { - // VZ: I don't know how to get client area for arbitrary display but - // wxGetClientDisplayRect() does work correctly for at least the main - // one (TODO: do it correctly for the other displays too) - if ( IsPrimary() ) - return wxOSXGetMainDisplayClientArea(); - - return wxDisplayImpl::GetClientArea(); + return wxOSXGetDisplayClientArea(m_id); } int wxDisplayImplMacOSX::GetDepth() const