macOS clientRect implementation for non-primary displays

This commit is contained in:
Stefan Csomor
2020-08-07 18:52:37 +02:00
committed by Vadim Zeitlin
parent d5180d3604
commit 8bad3b5e80
2 changed files with 20 additions and 7 deletions

View File

@@ -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]);

View File

@@ -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