mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
* Source/NSScreen.m: (_initWithScreenNumber): observe notification from
baackend on screen changes (display resolution). * Source/NSScreen.m: (_updateScreenInfo): initial implementation.
This commit is contained in:
parent
22612a641c
commit
b3113cd66f
2 changed files with 40 additions and 0 deletions
25
Source/NSMenu.m
Normal file → Executable file
25
Source/NSMenu.m
Normal file → Executable file
|
@ -254,6 +254,26 @@ static BOOL menuBarVisible = YES;
|
|||
forModes: [NSArray arrayWithObject: NSDefaultRunLoopMode]];
|
||||
}
|
||||
|
||||
/**
|
||||
Screen (monitor) properties was changed. We need to update our poistion
|
||||
in (possibly) new dimensions.
|
||||
*/
|
||||
- (void) _screenChanged: (id) notification
|
||||
{
|
||||
NSRect windowFrame, screenFrame;
|
||||
fprintf(stderr, "[NSMenu] NSScreen was changed.\n");
|
||||
if ([self _isVisible] != NO) {
|
||||
windowFrame = [[self window] frame];
|
||||
screenFrame = [[self window] convertRectToScreen:NSMakeRect(0,0,1,1)];
|
||||
fprintf(stderr, " Will update origin. Window: %.0f,%.0f Screen: %.0f,%.0f",
|
||||
windowFrame.origin.x, windowFrame.origin.y,
|
||||
screenFrame.origin.x, screenFrame.origin.y);
|
||||
// [self nestedSetFrameOrigin: [[self window] frame].origin];
|
||||
// [self _updateUserDefaults: notification];
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
- (void) _organizeMenu
|
||||
{
|
||||
NSString *infoString = _(@"Info");
|
||||
|
@ -712,6 +732,11 @@ static BOOL menuBarVisible = YES;
|
|||
name: NSEnqueuedMenuMoveName
|
||||
object: self];
|
||||
|
||||
[nc addObserver: self
|
||||
selector: @selector (_screenChanged:)
|
||||
name: NSApplicationDidChangeScreenParametersNotification
|
||||
object: NSApp];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
15
Source/NSScreen.m
Normal file → Executable file
15
Source/NSScreen.m
Normal file → Executable file
|
@ -197,6 +197,14 @@ static NSMutableArray *screenArray = nil;
|
|||
/**
|
||||
* Get all of the infomation for a given screen.
|
||||
*/
|
||||
- (void) _updateScreenInfo
|
||||
{
|
||||
GSDisplayServer *srv = GSCurrentServer();
|
||||
_frame = [srv boundsForScreen: _screenNumber];
|
||||
_depth = [srv windowDepthForScreen: _screenNumber];
|
||||
NSLog(@"NSScreen: screen info was updated.");
|
||||
}
|
||||
|
||||
- (id) _initWithScreenNumber: (int)screen
|
||||
{
|
||||
GSDisplayServer *srv;
|
||||
|
@ -228,6 +236,12 @@ static NSMutableArray *screenArray = nil;
|
|||
_depth = [srv windowDepthForScreen: _screenNumber];
|
||||
_supportedWindowDepths = NULL;
|
||||
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver: self
|
||||
selector: @selector(_updateScreenInfo)
|
||||
name: NSApplicationDidChangeScreenParametersNotification
|
||||
object: NSApp];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -404,6 +418,7 @@ static NSMutableArray *screenArray = nil;
|
|||
// Release the memory for the depths array.
|
||||
- (void) dealloc
|
||||
{
|
||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||
// _supportedWindowDepths can be NULL since it may or may not
|
||||
// be necessary to get this info. The most common use of NSScreen
|
||||
// is to get the depth and frame attributes.
|
||||
|
|
Loading…
Reference in a new issue