aboutsummaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/cocoa.m63
-rw-r--r--ui/gtk.c27
-rw-r--r--ui/sdl2.c16
3 files changed, 29 insertions, 77 deletions
diff --git a/ui/cocoa.m b/ui/cocoa.m
index fbb5b1b45f..747a70839a 100644
--- a/ui/cocoa.m
+++ b/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 @@ typedef struct {
NSWindow *normalWindow, *about_window;
static DisplayChangeListener *dcl;
static int last_buttons;
+static int cursor_hide = 1;
int gArgc;
char **gArgv;
@@ -465,11 +416,7 @@ QemuCocoaView *cocoaView;
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 @@ QemuCocoaView *cocoaView;
------------------------------------------------------
*/
@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 @@ QemuCocoaView *cocoaView;
[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));
diff --git a/ui/gtk.c b/ui/gtk.c
index d18892d1de..f3f0af8921 100644
--- a/ui/gtk.c
+++ b/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);
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 9030f1c42e..3c9424eb42 100644
--- a/ui/sdl2.c
+++ b/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;