ui/cocoa: Set UI information
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> Message-Id: <20210616141910.54188-1-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
b22726abdf
commit
15280e85d7
49
ui/cocoa.m
49
ui/cocoa.m
@ -518,6 +518,43 @@ QemuCocoaView *cocoaView;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) updateUIInfo
|
||||
{
|
||||
NSSize frameSize;
|
||||
QemuUIInfo info;
|
||||
|
||||
if (!qemu_console_is_graphic(dcl.con)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ([self window]) {
|
||||
NSDictionary *description = [[[self window] screen] deviceDescription];
|
||||
CGDirectDisplayID display = [[description objectForKey:@"NSScreenNumber"] unsignedIntValue];
|
||||
NSSize screenSize = [[[self window] screen] frame].size;
|
||||
CGSize screenPhysicalSize = CGDisplayScreenSize(display);
|
||||
|
||||
frameSize = isFullscreen ? screenSize : [self frame].size;
|
||||
info.width_mm = frameSize.width / screenSize.width * screenPhysicalSize.width;
|
||||
info.height_mm = frameSize.height / screenSize.height * screenPhysicalSize.height;
|
||||
} else {
|
||||
frameSize = [self frame].size;
|
||||
info.width_mm = 0;
|
||||
info.height_mm = 0;
|
||||
}
|
||||
|
||||
info.xoff = 0;
|
||||
info.yoff = 0;
|
||||
info.width = frameSize.width;
|
||||
info.height = frameSize.height;
|
||||
|
||||
dpy_set_ui_info(dcl.con, &info);
|
||||
}
|
||||
|
||||
- (void)viewDidMoveToWindow
|
||||
{
|
||||
[self updateUIInfo];
|
||||
}
|
||||
|
||||
- (void) switchSurface:(pixman_image_t *)image
|
||||
{
|
||||
COCOA_DEBUG("QemuCocoaView: switchSurface\n");
|
||||
@ -1172,6 +1209,16 @@ QemuCocoaView *cocoaView;
|
||||
return [self verifyQuit];
|
||||
}
|
||||
|
||||
- (void)windowDidChangeScreen:(NSNotification *)notification
|
||||
{
|
||||
[cocoaView updateUIInfo];
|
||||
}
|
||||
|
||||
- (void)windowDidResize:(NSNotification *)notification
|
||||
{
|
||||
[cocoaView updateUIInfo];
|
||||
}
|
||||
|
||||
/* Called when the user clicks on a window's close button */
|
||||
- (BOOL)windowShouldClose:(id)sender
|
||||
{
|
||||
@ -1836,6 +1883,8 @@ static void cocoa_switch(DisplayChangeListener *dcl,
|
||||
|
||||
COCOA_DEBUG("qemu_cocoa: cocoa_switch\n");
|
||||
|
||||
[cocoaView updateUIInfo];
|
||||
|
||||
// The DisplaySurface will be freed as soon as this callback returns.
|
||||
// We take a reference to the underlying pixman image here so it does
|
||||
// not disappear from under our feet; the switchSurface method will
|
||||
|
Loading…
Reference in New Issue
Block a user