mirror of
https://github.com/gnustep/libs-back.git
synced 2025-04-22 23:42:16 +00:00
Added Win32 multi-screen support lookup
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/branches/gnustep_testplant_branch@35240 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
2e3bdfbd01
commit
999c436296
3 changed files with 117 additions and 11 deletions
|
@ -1,3 +1,12 @@
|
|||
2012-06-27 Marcian Lytwyn <marcian.lytwyn@advcsi.com>
|
||||
|
||||
*** Modifications to Win32 server backend to support multiple
|
||||
monitors.
|
||||
* Headers/win32/WIN32Server.h - Added a mutable array for storing
|
||||
multiple screen information from GDI screen lookup
|
||||
* Source/win32/WIN32Server.m - Added startup sequence to invoke
|
||||
GDI functions to look up multiple screen/monitor information
|
||||
|
||||
2012-05-14 Quentin Mathe <quentin.mathe@gmail.com>
|
||||
|
||||
* Source/gsc/GSContext.m (+initialize): Protected +initialize from being
|
||||
|
|
|
@ -93,6 +93,7 @@ typedef struct w32serverFlags {
|
|||
HWND desiredFocus;
|
||||
HWND currentActive;
|
||||
HICON currentAppIcon;
|
||||
NSMutableArray *monitorInfo;
|
||||
}
|
||||
|
||||
- (BOOL) handlesWindowDecorations;
|
||||
|
|
|
@ -62,6 +62,61 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
@interface W32DisplayMonitorInfo : NSObject
|
||||
{
|
||||
HMONITOR _hMonitor;
|
||||
RECT _rect;
|
||||
NSRect _frame;
|
||||
}
|
||||
|
||||
- (id)initWithHMonitor:(HMONITOR)hMonitor rect:(LPRECT)lprcMonitor;
|
||||
- (HMONITOR)hMonitor;
|
||||
- (RECT)rect;
|
||||
- (NSRect)frame;
|
||||
- (void)setFrame:(NSRect)frame;
|
||||
|
||||
@end
|
||||
|
||||
@implementation W32DisplayMonitorInfo
|
||||
|
||||
- (id)initWithHMonitor:(HMONITOR)hMonitor rect:(LPRECT)lprcMonitor
|
||||
{
|
||||
self = [self init];
|
||||
if (self)
|
||||
{
|
||||
CGFloat w = lprcMonitor->right - lprcMonitor->left;
|
||||
CGFloat h = lprcMonitor->bottom - lprcMonitor->top;
|
||||
CGFloat x = lprcMonitor->left;
|
||||
CGFloat y = h - lprcMonitor->bottom;
|
||||
_frame = NSMakeRect(x, y, w, h);
|
||||
memcpy(&_rect, lprcMonitor, sizeof(RECT));
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (HMONITOR)hMonitor
|
||||
{
|
||||
return _hMonitor;
|
||||
}
|
||||
|
||||
- (RECT)rect
|
||||
{
|
||||
return _rect;
|
||||
}
|
||||
|
||||
- (NSRect)frame
|
||||
{
|
||||
return _frame;
|
||||
}
|
||||
|
||||
- (void)setFrame:(NSRect)frame
|
||||
{
|
||||
_frame = frame;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
static BOOL _enableCallbacks = YES;
|
||||
|
||||
static NSEvent *process_key_event(WIN32Server *svr,
|
||||
|
@ -75,6 +130,26 @@ static NSEvent *process_mouse_event(WIN32Server *svr,
|
|||
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
||||
WPARAM wParam, LPARAM lParam);
|
||||
|
||||
BOOL CALLBACK LoadDisplayMonitorInfo(HMONITOR hMonitor,
|
||||
HDC hdcMonitor,
|
||||
LPRECT lprcMonitor,
|
||||
LPARAM dwData)
|
||||
{
|
||||
NSMutableArray *monitors = (NSMutableArray*)dwData;
|
||||
W32DisplayMonitorInfo *info = [[W32DisplayMonitorInfo alloc] initWithHMonitor:hMonitor rect:lprcMonitor];
|
||||
|
||||
NSLog(@"screen %ld:hdc: %ld frame:top:%ld left:%ld right:%ld bottom:%ld frame:x:%f y:%f w:%f h:%f\n",
|
||||
[monitors count], (long)hMonitor,
|
||||
lprcMonitor->top, lprcMonitor->left,
|
||||
lprcMonitor->right, lprcMonitor->bottom,
|
||||
[info frame].origin.x, [info frame].origin.y,
|
||||
[info frame].size.width, [info frame].size.height);
|
||||
[monitors addObject:info];
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@implementation WIN32Server
|
||||
|
||||
- (BOOL) handlesWindowDecorations
|
||||
|
@ -257,6 +332,9 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
|||
{
|
||||
[self _initWin32Context];
|
||||
[super initWithAttributes: info];
|
||||
|
||||
monitorInfo = [NSMutableArray array];
|
||||
EnumDisplayMonitors(NULL, NULL, (MONITORENUMPROC)LoadDisplayMonitorInfo, (LPARAM)monitorInfo);
|
||||
|
||||
[self setupRunLoopInputSourcesForMode: NSDefaultRunLoopMode];
|
||||
[self setupRunLoopInputSourcesForMode: NSConnectionReplyMode];
|
||||
|
@ -375,21 +453,34 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
|||
|
||||
- (NSRect) boundsForScreen: (int)screen
|
||||
{
|
||||
return NSMakeRect(0, 0, GetSystemMetrics(SM_CXSCREEN),
|
||||
GetSystemMetrics(SM_CYSCREEN));
|
||||
if (screen < [monitorInfo count])
|
||||
{
|
||||
return [[monitorInfo objectAtIndex:screen] frame];
|
||||
}
|
||||
return NSZeroRect;
|
||||
}
|
||||
|
||||
- (NSWindowDepth) windowDepthForScreen: (int)screen
|
||||
{
|
||||
HDC hdc;
|
||||
int bits;
|
||||
HDC hdc = 0;
|
||||
int bits = 0;
|
||||
//int planes;
|
||||
|
||||
hdc = GetDC(NULL);
|
||||
bits = GetDeviceCaps(hdc, BITSPIXEL) / 3;
|
||||
//planes = GetDeviceCaps(hdc, PLANES);
|
||||
//NSLog(@"bits %d planes %d", bits, planes);
|
||||
ReleaseDC(NULL, hdc);
|
||||
|
||||
if (screen < [monitorInfo count])
|
||||
{
|
||||
MONITORINFOEX mix = { 0 };
|
||||
mix.cbSize = sizeof(MONITORINFOEX);
|
||||
HMONITOR hMonitor = [[monitorInfo objectAtIndex:screen] hMonitor];
|
||||
|
||||
if (GetMonitorInfo(hMonitor, (LPMONITORINFO)&mix))
|
||||
{
|
||||
hdc = CreateDC("DISPLAY", mix.szDevice, NULL, NULL);
|
||||
bits = GetDeviceCaps(hdc, BITSPIXEL) / 3;
|
||||
//planes = GetDeviceCaps(hdc, PLANES);
|
||||
//NSLog(@"bits %d planes %d", bits, planes);
|
||||
ReleaseDC(NULL, hdc);
|
||||
}
|
||||
}
|
||||
|
||||
return (_GSRGBBitValue | bits);
|
||||
}
|
||||
|
@ -410,7 +501,12 @@ LRESULT CALLBACK MainWndProc(HWND hwnd, UINT uMsg,
|
|||
|
||||
- (NSArray *) screenList
|
||||
{
|
||||
return [NSArray arrayWithObject: [NSNumber numberWithInt: 0]];
|
||||
NSInteger index;
|
||||
NSInteger nMonitors = [monitorInfo count];
|
||||
NSMutableArray *screenList = [NSMutableArray arrayWithCapacity:nMonitors];
|
||||
for (index = 0; index < nMonitors; ++index)
|
||||
[screenList addObject:[NSNumber numberWithInt:index]];
|
||||
return [[screenList copy] autorelease];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue