CGDisplayCapture question
CGDisplayCapture question
- Subject: CGDisplayCapture question
- From: "Jim O'Connor" <email@hidden>
- Date: Wed, 14 Jul 2004 21:45:54 -0500
I need to find the screen a window is on, reset its resolution, then
position the window so that the content area of the window covers the
screen.
If I don't need to change resolution then this works:
mWindowLevel = [[mView window] level];
mFrame = [[mView window] frame];
[[mView window] setLevel:NSScreenSaverWindowLevel];
[[mView window] setFrame:[NSWindow frameRectForContentRect:[[[mView
window] screen] frame] styleMask:[[mView window] styleMask]] display:true
animate:true];
And then to restore the window state, at some time later:
[[mView window] setLevel:mWindowLevel];
[[mView window] setFrame:mFrame display:true animate:true];
However, if I want to reset the screen resolution then things don't go
properly when I want to reposition the window.
CGGetDisplaysWithRect(cgRect, 1, &sDisplayID, &count);
sOldDict = CGDisplayCurrentMode(sDisplayID);
CFDictionaryRef dict = CGDisplayBestModeForParameters(sDisplayID,
CGDisplayBitsPerPixel(sDisplayID), 832, 624, NULL);
bool capture = CGDisplayCapture(sDisplayID) == kCGErrorSuccess;
CGDisplaySwitchToMode(sDisplayID, dict);
[[mView window] setLevel:NSScreenSaverWindowLevel];
[[mView window] setFrame:[NSWindow frameRectForContentRect:[[[mView
window] screen] frame] styleMask:[[mView window] styleMask]] display:true
animate:/*true*/false];
CGDisplayRelease(sDisplayID);
I've tried to release at the end, as shown here, and immediately after
calling SwitchToMdoe (which is where I would expect it to work). In either
case, [[[mView window] screen] frame] returns the original size of the
monitor, not 832,624. This makes my window resize incorrectly, and the
window title bar is visible, so it looks like the system is repositioning my
window after Release returns, which isn't handy for me.
I thought that Capturing and Releasing the display would force synchronous
behavior so I can mangle my window as if the display was always at the new
resolution, but that doesn't appear to be the case.
The obvious hack solution is to set up a timer to wait until the display
admits to its new resolution and then munge my window, but that seems like,
well, a hack.
Any suggestions?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.