diff options
author | Akihiko Odaki <akihiko.odaki@gmail.com> | 2022-07-02 23:25:19 +0900 |
---|---|---|
committer | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2022-07-13 00:06:02 +0200 |
commit | 52eaefd36c33d17c5c52de0d02f1edf7400c0abb (patch) | |
tree | ba6e52b6b87e8fa55231cd840ae9cb8967a472ba /ui/cocoa.m | |
parent | 713911a10752642564ff9b7c9c0bd1a5498105a5 (diff) | |
download | qemu-52eaefd36c33d17c5c52de0d02f1edf7400c0abb.zip qemu-52eaefd36c33d17c5c52de0d02f1edf7400c0abb.tar.gz qemu-52eaefd36c33d17c5c52de0d02f1edf7400c0abb.tar.bz2 |
ui/cocoa: Take refresh rate into account
Retrieve the refresh rate of the display and reflect it with
dpy_set_ui_info() and update_displaychangelistener(), allowing the
guest and DisplayChangeListener to consume the information.
The information will be used as a hint how often the display should
be updated. For example, when we run 30 Hz physical display updates
it is pointless for the guest to update the screen at 60Hz
frequency, the guest can spare some work instead.
Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20220702142519.12188-1-akihiko.odaki@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Diffstat (limited to 'ui/cocoa.m')
-rw-r--r-- | ui/cocoa.m | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -561,8 +561,20 @@ static CGEventRef handleTapEvent(CGEventTapProxy proxy, CGEventType type, CGEven CGDirectDisplayID display = [[description objectForKey:@"NSScreenNumber"] unsignedIntValue]; NSSize screenSize = [[[self window] screen] frame].size; CGSize screenPhysicalSize = CGDisplayScreenSize(display); + CVDisplayLinkRef displayLink; frameSize = isFullscreen ? screenSize : [self frame].size; + + if (!CVDisplayLinkCreateWithCGDisplay(display, &displayLink)) { + CVTime period = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(displayLink); + CVDisplayLinkRelease(displayLink); + if (!(period.flags & kCVTimeIsIndefinite)) { + update_displaychangelistener(&dcl, + 1000 * period.timeValue / period.timeScale); + info.refresh_rate = (int64_t)1000 * period.timeScale / period.timeValue; + } + } + info.width_mm = frameSize.width / screenSize.width * screenPhysicalSize.width; info.height_mm = frameSize.height / screenSize.height * screenPhysicalSize.height; } else { |