mirror of https://gitee.com/openkylin/qemu.git
gtk: refresh rate fix.
cocoa: drop pre-10.12 support. ui: rework show-cursor option. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJeRCVJAAoJEEy22O7T6HE4F+QP/1Uq69IJUuSAHf9LbrGp3S1J bbAP2bTT72Buqg8AByAZI370EiH5Iqbbb3YVagWqgsMcW0NREPRNvKIQUFrsuo9Z UX+f5Rik8OxA/ZtfNT8InuyVosgjjZchS3JF2SvF4QK8NDuYLjaCCipcVmBtpivE ZnybH84ubMUsLaDtU44hOcAqlNb/FvvcVLOnbf3SLAL+leWTRg1qvndmx/9C4VW1 MZK9LmglRQsb955p/JrkCu3ied72H5F3i7ZNUQ1orn/QIkIb2f30IRal2WtUdnKF N7ICeq1AVjhC8LysuzDiQWLfQ4xjlOOluH88FV0eoJCOT3vjgjH5eKWwFRkZROkS qvymxxdd9KDuPGWD2qeZnJfHayLo4JSCxVCYQuhxxuBNBzVruiOEpUVXQy1Zibn8 8FCyGL0hXM5ZuY1egrTosXIHVKYTSk2xoooDSzpNPCtW59PZlbe4za7rnZYxmE36 uBW4YNPrkNepFVJ0QrMccSvjGgSKFESXEwOAfmcfqjd7xv6rGheE9IUuTGuXFKFG BfESBm1qs3uSDdM3B+ec37BkBqNrxvUn/OJ1BZd8RHYcaxlXp13tlS9yhlP2RtV1 6zCztPwe6JZDieDJYr8QY8teKxGM4JybKzkVRXQgVM8LegphFMk5e37gcu3iUWSF 1+Wvs0gYKJ5Dt3gWpGJW =7GVK -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/kraxel/tags/ui-20200212-pull-request' into staging gtk: refresh rate fix. cocoa: drop pre-10.12 support. ui: rework show-cursor option. # gpg: Signature made Wed 12 Feb 2020 16:18:17 GMT # gpg: using RSA key 4CB6D8EED3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" [full] # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" [full] # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" [full] # Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138 * remotes/kraxel/tags/ui-20200212-pull-request: ui/cocoa: Drop workarounds for pre-10.12 OSX ui: deprecate legacy -show-cursor option ui: drop curor_hide global variable. ui/gtk: implement show-cursor option ui/cocoa: switch to new show-cursor option ui/sdl: switch to new show-cursor option ui: wire up legacy -show-cursor option ui: add show-cursor option ui/gtk: Fix gd_refresh_rate_millihz() when widget window is not realized ui/gtk: Update gd_refresh_rate_millihz() to handle VirtualConsole Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
7ce9ce8993
|
@ -41,7 +41,6 @@ extern const char *keyboard_layout;
|
|||
extern int win2k_install_hack;
|
||||
extern int alt_grab;
|
||||
extern int ctrl_grab;
|
||||
extern int cursor_hide;
|
||||
extern int graphic_rotate;
|
||||
extern int no_shutdown;
|
||||
extern int old_param;
|
||||
|
|
|
@ -1144,6 +1144,8 @@
|
|||
# @type: Which DisplayType qemu should use.
|
||||
# @full-screen: Start user interface in fullscreen mode (default: off).
|
||||
# @window-close: Allow to quit qemu with window close button (default: on).
|
||||
# @show-cursor: Force showing the mouse cursor (default: off).
|
||||
# (since: 5.0)
|
||||
# @gl: Enable OpenGL support (default: off).
|
||||
#
|
||||
# Since: 2.12
|
||||
|
@ -1153,6 +1155,7 @@
|
|||
'base' : { 'type' : 'DisplayType',
|
||||
'*full-screen' : 'bool',
|
||||
'*window-close' : 'bool',
|
||||
'*show-cursor' : 'bool',
|
||||
'*gl' : 'DisplayGLMode' },
|
||||
'discriminator' : 'type',
|
||||
'data' : { 'gtk' : 'DisplayGTK',
|
||||
|
|
|
@ -148,6 +148,11 @@ QEMU 5.0 introduced an alternative syntax to specify the size of the translation
|
|||
block cache, @option{-accel tcg,tb-size=}. The new syntax deprecates the
|
||||
previously available @option{-tb-size} option.
|
||||
|
||||
@subsection -show-cursor option (since 5.0)
|
||||
|
||||
Use @option{-display sdl,show-cursor=on} or
|
||||
@option{-display gtk,show-cursor=on} instead.
|
||||
|
||||
@section QEMU Machine Protocol (QMP) commands
|
||||
|
||||
@subsection change (since 2.5.0)
|
||||
|
|
63
ui/cocoa.m
63
ui/cocoa.m
|
@ -42,60 +42,10 @@
|
|||
#include <Carbon/Carbon.h>
|
||||
#include "hw/core/cpu.h"
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_5
|
||||
#define MAC_OS_X_VERSION_10_5 1050
|
||||
#endif
|
||||
#ifndef MAC_OS_X_VERSION_10_6
|
||||
#define MAC_OS_X_VERSION_10_6 1060
|
||||
#endif
|
||||
#ifndef MAC_OS_X_VERSION_10_9
|
||||
#define MAC_OS_X_VERSION_10_9 1090
|
||||
#endif
|
||||
#ifndef MAC_OS_X_VERSION_10_10
|
||||
#define MAC_OS_X_VERSION_10_10 101000
|
||||
#endif
|
||||
#ifndef MAC_OS_X_VERSION_10_12
|
||||
#define MAC_OS_X_VERSION_10_12 101200
|
||||
#endif
|
||||
#ifndef MAC_OS_X_VERSION_10_13
|
||||
#define MAC_OS_X_VERSION_10_13 101300
|
||||
#endif
|
||||
|
||||
/* macOS 10.12 deprecated many constants, #define the new names for older SDKs */
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
|
||||
#define NSEventMaskAny NSAnyEventMask
|
||||
#define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask
|
||||
#define NSEventModifierFlagShift NSShiftKeyMask
|
||||
#define NSEventModifierFlagCommand NSCommandKeyMask
|
||||
#define NSEventModifierFlagControl NSControlKeyMask
|
||||
#define NSEventModifierFlagOption NSAlternateKeyMask
|
||||
#define NSEventTypeFlagsChanged NSFlagsChanged
|
||||
#define NSEventTypeKeyUp NSKeyUp
|
||||
#define NSEventTypeKeyDown NSKeyDown
|
||||
#define NSEventTypeMouseMoved NSMouseMoved
|
||||
#define NSEventTypeLeftMouseDown NSLeftMouseDown
|
||||
#define NSEventTypeRightMouseDown NSRightMouseDown
|
||||
#define NSEventTypeOtherMouseDown NSOtherMouseDown
|
||||
#define NSEventTypeLeftMouseDragged NSLeftMouseDragged
|
||||
#define NSEventTypeRightMouseDragged NSRightMouseDragged
|
||||
#define NSEventTypeOtherMouseDragged NSOtherMouseDragged
|
||||
#define NSEventTypeLeftMouseUp NSLeftMouseUp
|
||||
#define NSEventTypeRightMouseUp NSRightMouseUp
|
||||
#define NSEventTypeOtherMouseUp NSOtherMouseUp
|
||||
#define NSEventTypeScrollWheel NSScrollWheel
|
||||
#define NSTextAlignmentCenter NSCenterTextAlignment
|
||||
#define NSWindowStyleMaskBorderless NSBorderlessWindowMask
|
||||
#define NSWindowStyleMaskClosable NSClosableWindowMask
|
||||
#define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
|
||||
#define NSWindowStyleMaskTitled NSTitledWindowMask
|
||||
#endif
|
||||
/* 10.13 deprecates NSFileHandlingPanelOKButton in favour of
|
||||
* NSModalResponseOK, which was introduced in 10.9. Define
|
||||
* it for older versions.
|
||||
*/
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9
|
||||
#define NSModalResponseOK NSFileHandlingPanelOKButton
|
||||
#endif
|
||||
/* 10.14 deprecates NSOnState and NSOffState in favor of
|
||||
* NSControlStateValueOn/Off, which were introduced in 10.13.
|
||||
* Define for older versions
|
||||
|
@ -125,6 +75,7 @@
|
|||
NSWindow *normalWindow, *about_window;
|
||||
static DisplayChangeListener *dcl;
|
||||
static int last_buttons;
|
||||
static int cursor_hide = 1;
|
||||
|
||||
int gArgc;
|
||||
char **gArgv;
|
||||
|
@ -465,11 +416,7 @@ - (void) drawRect:(NSRect) rect
|
|||
COCOA_DEBUG("QemuCocoaView: drawRect\n");
|
||||
|
||||
// get CoreGraphic context
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10
|
||||
CGContextRef viewContextRef = [[NSGraphicsContext currentContext] graphicsPort];
|
||||
#else
|
||||
CGContextRef viewContextRef = [[NSGraphicsContext currentContext] CGContext];
|
||||
#endif
|
||||
|
||||
CGContextSetInterpolationQuality (viewContextRef, kCGInterpolationNone);
|
||||
CGContextSetShouldAntialias (viewContextRef, NO);
|
||||
|
@ -1075,9 +1022,7 @@ - (void) raiseAllKeys
|
|||
------------------------------------------------------
|
||||
*/
|
||||
@interface QemuCocoaAppController : NSObject
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
|
||||
<NSWindowDelegate, NSApplicationDelegate>
|
||||
#endif
|
||||
{
|
||||
}
|
||||
- (void)doToggleFullScreen:(id)sender;
|
||||
|
@ -1126,9 +1071,6 @@ - (id) init
|
|||
[normalWindow setAcceptsMouseMovedEvents:YES];
|
||||
[normalWindow setTitle:@"QEMU"];
|
||||
[normalWindow setContentView:cocoaView];
|
||||
#if (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10)
|
||||
[normalWindow useOptimizedDrawing:YES];
|
||||
#endif
|
||||
[normalWindow makeKeyAndOrderFront:self];
|
||||
[normalWindow center];
|
||||
[normalWindow setDelegate: self];
|
||||
|
@ -1918,6 +1860,9 @@ static void cocoa_display_init(DisplayState *ds, DisplayOptions *opts)
|
|||
[(QemuCocoaAppController *)[[NSApplication sharedApplication] delegate] toggleFullScreen: nil];
|
||||
});
|
||||
}
|
||||
if (opts->has_show_cursor && opts->show_cursor) {
|
||||
cursor_hide = 0;
|
||||
}
|
||||
|
||||
dcl = g_malloc0(sizeof(DisplayChangeListener));
|
||||
|
||||
|
|
27
ui/gtk.c
27
ui/gtk.c
|
@ -1965,17 +1965,19 @@ static GtkWidget *gd_create_menu_machine(GtkDisplayState *s)
|
|||
* If available, return the refresh rate of the display in milli-Hertz,
|
||||
* else return 0.
|
||||
*/
|
||||
static int gd_refresh_rate_millihz(GtkDisplayState *s)
|
||||
static int gd_refresh_rate_millihz(GtkWidget *window)
|
||||
{
|
||||
#ifdef GDK_VERSION_3_22
|
||||
GdkDisplay *dpy = gtk_widget_get_display(s->window);
|
||||
GdkWindow *win = gtk_widget_get_window(s->window);
|
||||
GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win);
|
||||
GdkWindow *win = gtk_widget_get_window(window);
|
||||
|
||||
return gdk_monitor_get_refresh_rate(monitor);
|
||||
#else
|
||||
return 0;
|
||||
if (win) {
|
||||
GdkDisplay *dpy = gtk_widget_get_display(window);
|
||||
GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win);
|
||||
|
||||
return gdk_monitor_get_refresh_rate(monitor);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
|
||||
|
@ -2045,7 +2047,8 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc,
|
|||
vc->gfx.kbd = qkbd_state_init(con);
|
||||
vc->gfx.dcl.con = con;
|
||||
|
||||
refresh_rate_millihz = gd_refresh_rate_millihz(s);
|
||||
refresh_rate_millihz = gd_refresh_rate_millihz(vc->window ?
|
||||
vc->window : s->window);
|
||||
if (refresh_rate_millihz) {
|
||||
vc->gfx.dcl.update_interval = MILLISEC_PER_SEC / refresh_rate_millihz;
|
||||
}
|
||||
|
@ -2243,8 +2246,12 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
|
|||
textdomain("qemu");
|
||||
|
||||
window_display = gtk_widget_get_display(s->window);
|
||||
s->null_cursor = gdk_cursor_new_for_display(window_display,
|
||||
GDK_BLANK_CURSOR);
|
||||
if (s->opts->has_show_cursor && s->opts->show_cursor) {
|
||||
s->null_cursor = NULL; /* default pointer */
|
||||
} else {
|
||||
s->null_cursor = gdk_cursor_new_for_display(window_display,
|
||||
GDK_BLANK_CURSOR);
|
||||
}
|
||||
|
||||
s->mouse_mode_notifier.notify = gd_mouse_mode_change;
|
||||
qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);
|
||||
|
|
16
ui/sdl2.c
16
ui/sdl2.c
|
@ -161,9 +161,9 @@ static void sdl_update_caption(struct sdl2_console *scon)
|
|||
}
|
||||
}
|
||||
|
||||
static void sdl_hide_cursor(void)
|
||||
static void sdl_hide_cursor(struct sdl2_console *scon)
|
||||
{
|
||||
if (!cursor_hide) {
|
||||
if (scon->opts->has_show_cursor && scon->opts->show_cursor) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -175,9 +175,9 @@ static void sdl_hide_cursor(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void sdl_show_cursor(void)
|
||||
static void sdl_show_cursor(struct sdl2_console *scon)
|
||||
{
|
||||
if (!cursor_hide) {
|
||||
if (scon->opts->has_show_cursor && scon->opts->show_cursor) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ static void sdl_grab_start(struct sdl2_console *scon)
|
|||
SDL_WarpMouseInWindow(scon->real_window, guest_x, guest_y);
|
||||
}
|
||||
} else {
|
||||
sdl_hide_cursor();
|
||||
sdl_hide_cursor(scon);
|
||||
}
|
||||
SDL_SetWindowGrab(scon->real_window, SDL_TRUE);
|
||||
gui_grab = 1;
|
||||
|
@ -227,7 +227,7 @@ static void sdl_grab_end(struct sdl2_console *scon)
|
|||
{
|
||||
SDL_SetWindowGrab(scon->real_window, SDL_FALSE);
|
||||
gui_grab = 0;
|
||||
sdl_show_cursor();
|
||||
sdl_show_cursor(scon);
|
||||
sdl_update_caption(scon);
|
||||
}
|
||||
|
||||
|
@ -658,7 +658,7 @@ static void sdl_mouse_warp(DisplayChangeListener *dcl,
|
|||
|
||||
if (on) {
|
||||
if (!guest_cursor) {
|
||||
sdl_show_cursor();
|
||||
sdl_show_cursor(scon);
|
||||
}
|
||||
if (gui_grab || qemu_input_is_absolute() || absolute_enabled) {
|
||||
SDL_SetCursor(guest_sprite);
|
||||
|
@ -667,7 +667,7 @@ static void sdl_mouse_warp(DisplayChangeListener *dcl,
|
|||
}
|
||||
}
|
||||
} else if (gui_grab) {
|
||||
sdl_hide_cursor();
|
||||
sdl_hide_cursor(scon);
|
||||
}
|
||||
guest_cursor = on;
|
||||
guest_x = x, guest_y = y;
|
||||
|
|
16
vl.c
16
vl.c
|
@ -168,7 +168,6 @@ int no_hpet = 0;
|
|||
int fd_bootchk = 1;
|
||||
static int no_reboot;
|
||||
int no_shutdown = 0;
|
||||
int cursor_hide = 1;
|
||||
int graphic_rotate = 0;
|
||||
const char *watchdog;
|
||||
QEMUOptionRom option_rom[MAX_OPTION_ROMS];
|
||||
|
@ -1931,6 +1930,16 @@ static void parse_display(const char *p)
|
|||
} else {
|
||||
goto invalid_sdl_args;
|
||||
}
|
||||
} else if (strstart(opts, ",show-cursor=", &nextopt)) {
|
||||
opts = nextopt;
|
||||
dpy.has_show_cursor = true;
|
||||
if (strstart(opts, "on", &nextopt)) {
|
||||
dpy.show_cursor = true;
|
||||
} else if (strstart(opts, "off", &nextopt)) {
|
||||
dpy.show_cursor = false;
|
||||
} else {
|
||||
goto invalid_sdl_args;
|
||||
}
|
||||
} else if (strstart(opts, ",gl=", &nextopt)) {
|
||||
opts = nextopt;
|
||||
dpy.has_gl = true;
|
||||
|
@ -3553,7 +3562,10 @@ int main(int argc, char **argv, char **envp)
|
|||
no_shutdown = 1;
|
||||
break;
|
||||
case QEMU_OPTION_show_cursor:
|
||||
cursor_hide = 0;
|
||||
warn_report("The -show-cursor option is deprecated, "
|
||||
"use -display {sdl,gtk},show-cursor=on instead");
|
||||
dpy.has_show_cursor = true;
|
||||
dpy.show_cursor = true;
|
||||
break;
|
||||
case QEMU_OPTION_uuid:
|
||||
if (qemu_uuid_parse(optarg, &qemu_uuid) < 0) {
|
||||
|
|
Loading…
Reference in New Issue