All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] Fixes several full screen issues on Mac OS X
@ 2015-01-04 23:44 Programmingkid
  2015-01-14 17:19 ` Peter Maydell
  0 siblings, 1 reply; 6+ messages in thread
From: Programmingkid @ 2015-01-04 23:44 UTC (permalink / raw)
  To: qemu-devel qemu-devel; +Cc: Peter Maydell

This patch makes several changes:
- Fixes issue of returning to window mode and QEMU not setting
 the right graphic settings if there was a change during full screen mode.
- Eliminated distorted full screen display.
- Makes full screen mode available on Mac OS 10.7 and higher.
- Removes unneeded global variables cdx, and cdy.
- Changes a few comments to make them clearer.

Signed-off-by: John Arbuckle <programmingkidx@gmail.com>

---
 ui/cocoa.m |  106 ++++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 65 insertions(+), 41 deletions(-)

diff --git a/ui/cocoa.m b/ui/cocoa.m
index d37c29b..704d199 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -40,7 +40,6 @@
 #define MAC_OS_X_VERSION_10_6 1060
 #endif
 
-
 //#define DEBUG
 
 #ifdef DEBUG
@@ -250,13 +249,14 @@ static int cocoa_keycode_to_qemu(int keycode)
 {
     QEMUScreen screen;
     NSWindow *fullScreenWindow;
-    float cx,cy,cw,ch,cdx,cdy;
+    float cx,cy,cw,ch;
     CGDataProviderRef dataProviderRef;
     int modifiers_state[256];
     BOOL isMouseGrabbed;
     BOOL isFullscreen;
     BOOL isAbsoluteEnabled;
     BOOL isMouseDeassociated;
+    NSDictionary * window_mode_dict; /* keeps track of the guest' graphic settings */
 }
 - (void) switchSurface:(DisplaySurface *)surface;
 - (void) grabMouse;
@@ -279,9 +279,10 @@ static int cocoa_keycode_to_qemu(int keycode)
 - (BOOL) isMouseGrabbed;
 - (BOOL) isAbsoluteEnabled;
 - (BOOL) isMouseDeassociated;
-- (float) cdx;
-- (float) cdy;
 - (QEMUScreen) gscreen;
+- (void) updateWindowModeSettings;
+- (void) switchDisplayToWindowMode;
+- (void) switchDisplayToFullScreenMode;
 @end
 
 QemuCocoaView *cocoaView;
@@ -293,12 +294,11 @@ QemuCocoaView *cocoaView;
 
     self = [super initWithFrame:frameRect];
     if (self) {
-
         screen.bitsPerComponent = 8;
         screen.bitsPerPixel = 32;
         screen.width = frameRect.size.width;
         screen.height = frameRect.size.height;
-
+        [self updateWindowModeSettings];
     }
     return self;
 }
@@ -394,10 +394,10 @@ QemuCocoaView *cocoaView;
 
             [self getRectsBeingDrawn:&rectList count:&rectCount];
             for (i = 0; i < rectCount; i++) {
-                clipRect.origin.x = rectList[i].origin.x / cdx;
-                clipRect.origin.y = (float)screen.height - (rectList[i].origin.y + rectList[i].size.height) / cdy;
-                clipRect.size.width = rectList[i].size.width / cdx;
-                clipRect.size.height = rectList[i].size.height / cdy;
+                clipRect.origin.x = rectList[i].origin.x;
+                clipRect.origin.y = (float)screen.height - (rectList[i].origin.y + rectList[i].size.height);
+                clipRect.size.width = rectList[i].size.width;
+                clipRect.size.height = rectList[i].size.height;
                 clipImageRef = CGImageCreateWithImageInRect(
                     imageRef,
                     clipRect
@@ -416,10 +416,8 @@ QemuCocoaView *cocoaView;
     COCOA_DEBUG("QemuCocoaView: setContentDimensions\n");
 
     if (isFullscreen) {
-        cdx = [[NSScreen mainScreen] frame].size.width / (float)screen.width;
-        cdy = [[NSScreen mainScreen] frame].size.height / (float)screen.height;
-        cw = screen.width * cdx;
-        ch = screen.height * cdy;
+        cw = screen.width;
+        ch = screen.height;        
         cx = ([[NSScreen mainScreen] frame].size.width - cw) / 2.0;
         cy = ([[NSScreen mainScreen] frame].size.height - ch) / 2.0;
     } else {
@@ -427,23 +425,15 @@ QemuCocoaView *cocoaView;
         cy = 0;
         cw = screen.width;
         ch = screen.height;
-        cdx = 1.0;
-        cdy = 1.0;
     }
 }
 
 - (void) switchSurface:(DisplaySurface *)surface
 {
     COCOA_DEBUG("QemuCocoaView: switchSurface\n");
-
     int w = surface_width(surface);
     int h = surface_height(surface);
-    /* cdx == 0 means this is our very first surface, in which case we need
-     * to recalculate the content dimensions even if it happens to be the size
-     * of the initial empty window.
-     */
-    bool isResize = (w != screen.width || h != screen.height || cdx == 0.0);
-
+    bool isResize = (w != screen.width || h != screen.height);
     int oldh = screen.height;
     if (isResize) {
         // Resize before we trigger the redraw, or we'll redraw at the wrong size
@@ -452,6 +442,16 @@ QemuCocoaView *cocoaView;
         screen.height = h;
         [self setContentDimensions];
         [self setFrame:NSMakeRect(cx, cy, cw, ch)];
+
+        if (isFullscreen) {
+         /* I know, calling toggleFullScreen: looks like a mistake, but
+            it is the solution that works. I spent a long time looking 
+            for another way. This way is simple and works very well. */
+            [self toggleFullScreen: nil];
+            [self toggleFullScreen: nil];
+        }
+        else /* !isFullscreen */
+            [self updateWindowModeSettings];
     }
 
     // update screenBuffer
@@ -482,8 +482,8 @@ QemuCocoaView *cocoaView;
 - (void) toggleFullScreen:(id)sender
 {
     COCOA_DEBUG("QemuCocoaView: toggleFullScreen\n");
-
-    if (isFullscreen) { // switch from fullscreen to desktop
+    if (isFullscreen) { // switch from fullscreen to window mode
+        [self switchDisplayToWindowMode];
         isFullscreen = FALSE;
         [self ungrabMouse];
         [self setContentDimensions];
@@ -500,7 +500,8 @@ QemuCocoaView *cocoaView;
 #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
         }
 #endif
-    } else { // switch from desktop to fullscreen
+    } else { // switch from window to fullscreen mode
+        [self switchDisplayToFullScreenMode];
         isFullscreen = TRUE;
         [self grabMouse];
         [self setContentDimensions];
@@ -561,7 +562,7 @@ QemuCocoaView *cocoaView;
             }
 
             // release Mouse grab when pressing ctrl+alt
-            if (!isFullscreen && ([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) {
+            if (([event modifierFlags] & NSControlKeyMask) && ([event modifierFlags] & NSAlternateKeyMask)) {
                 [self ungrabMouse];
             }
             break;
@@ -781,9 +782,33 @@ QemuCocoaView *cocoaView;
 - (BOOL) isMouseGrabbed {return isMouseGrabbed;}
 - (BOOL) isAbsoluteEnabled {return isAbsoluteEnabled;}
 - (BOOL) isMouseDeassociated {return isMouseDeassociated;}
-- (float) cdx {return cdx;}
-- (float) cdy {return cdy;}
 - (QEMUScreen) gscreen {return screen;}
+
+/* Learn the guest' graphic settings when in window mode */
+- (void) updateWindowModeSettings
+{
+    window_mode_dict = CGDisplayCurrentMode(kCGDirectMainDisplay);
+}
+
+/* Switches the monitor's display settings for using QEMU in a window mode */
+- (void) switchDisplayToWindowMode
+{
+    CGDisplaySwitchToMode(kCGDirectMainDisplay, window_mode_dict);
+}
+
+/* Switches the monitor's display settings for using QEMU in full screen mode */
+- (void) switchDisplayToFullScreenMode
+{
+    size_t desired_bit_depth = 32;
+    boolean_t exact_match;
+    NSDictionary * mode = CGDisplayBestModeForParameters(kCGDirectMainDisplay, desired_bit_depth, (size_t)cw, (size_t)ch, &exact_match);
+    COCOA_DEBUG("switching to full screen: %d x %d\n", [[mode valueForKey: @"Width"] intValue], [[mode valueForKey: @"Height"] intValue]);
+    if (mode != nil)
+        CGDisplaySwitchToMode(kCGDirectMainDisplay, mode);
+    else
+        printf("ERROR: failed to determine best mode for display!\n");
+}
+
 @end
 
 
@@ -832,7 +857,6 @@ QemuCocoaView *cocoaView;
         [normalWindow useOptimizedDrawing:YES];
         [normalWindow makeKeyAndOrderFront:self];
         [normalWindow center];
-
     }
     return self;
 }
@@ -921,6 +945,15 @@ QemuCocoaView *cocoaView;
         [self startEmulationWithArgc:3 argv:(char**)argv];
     }
 }
+
+/* We abstract the method called by the Enter Fullscreen menu item
+because Mac OS 10.7 and higher disables it. This is because of the 
+menu item's old selector's name toggleFullScreen: */
+- (void) doToggleFullScreen:(id)sender
+{
+    [self toggleFullScreen:(id)sender];
+}
+
 - (void)toggleFullScreen:(id)sender
 {
     COCOA_DEBUG("QemuCocoaAppController: toggleFullScreen\n");
@@ -1005,7 +1038,7 @@ int main (int argc, const char * argv[]) {
 
     // View menu
     menu = [[NSMenu alloc] initWithTitle:@"View"];
-    [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Enter Fullscreen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"] autorelease]]; // Fullscreen
+    [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Enter Fullscreen" action:@selector(doToggleFullScreen:) keyEquivalent:@"f"] autorelease]]; // Fullscreen
     menuItem = [[[NSMenuItem alloc] initWithTitle:@"View" action:nil keyEquivalent:@""] autorelease];
     [menuItem setSubmenu:menu];
     [[NSApp mainMenu] addItem:menuItem];
@@ -1050,17 +1083,8 @@ static void cocoa_update(DisplayChangeListener *dcl,
     COCOA_DEBUG("qemu_cocoa: cocoa_update\n");
 
     NSRect rect;
-    if ([cocoaView cdx] == 1.0) {
-        rect = NSMakeRect(x, [cocoaView gscreen].height - y - h, w, h);
-    } else {
-        rect = NSMakeRect(
-            x * [cocoaView cdx],
-            ([cocoaView gscreen].height - y - h) * [cocoaView cdy],
-            w * [cocoaView cdx],
-            h * [cocoaView cdy]);
-    }
+    rect = NSMakeRect(x, [cocoaView gscreen].height - y - h, w, h);
     [cocoaView setNeedsDisplayInRect:rect];
-
     [pool release];
 }
 
-- 
1.7.5.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] Fixes several full screen issues on Mac OS X
  2015-01-04 23:44 [Qemu-devel] [PATCH] Fixes several full screen issues on Mac OS X Programmingkid
@ 2015-01-14 17:19 ` Peter Maydell
  2015-01-14 18:18   ` Programmingkid
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2015-01-14 17:19 UTC (permalink / raw)
  To: Programmingkid; +Cc: qemu-devel qemu-devel

On 4 January 2015 at 23:44, Programmingkid <programmingkidx@gmail.com> wrote:
> This patch makes several changes:
> - Fixes issue of returning to window mode and QEMU not setting
>  the right graphic settings if there was a change during full screen mode.
> - Eliminated distorted full screen display.
> - Makes full screen mode available on Mac OS 10.7 and higher.
> - Removes unneeded global variables cdx, and cdy.
> - Changes a few comments to make them clearer.
>
> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>

I'm afraid this patch is badly broken for me.

(1) If I go into full screen then I can't get out again because the
menubar isn't displayed even when I use ctrl+alt to release the
mouse grab. I have to use my second monitor to get at the Dock so I
can kill QEMU.

(2) Having done this I find that all my other application windows
have been squashed down into a corner of my screen, presumably because
we've told MacOSX "the screen is 640x480" and it's rearranged the
app windows to suit. We mustn't mess things up like this.

(3) I managed to get at the underlying "QEMU" window with its title
bar somehow even when in full screen mode: I could move it about the
screen with the mouse...

(4) I get a lot of compile warnings for this patch:

  OBJC  ui/cocoa.o
/Users/pm215/src/qemu/ui/cocoa.m:790:24: warning:
'CGDisplayCurrentMode' is deprecated: first deprecated in OS X 10.6
      [-Wdeprecated-declarations]
    window_mode_dict = CGDisplayCurrentMode(kCGDirectMainDisplay);
                       ^
/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDirectDisplay.h:455:27:
note: 'CGDisplayCurrentMode' has been explicitly
      marked deprecated here
CG_EXTERN CFDictionaryRef CGDisplayCurrentMode(CGDirectDisplayID display)
                          ^
/Users/pm215/src/qemu/ui/cocoa.m:790:22: warning: incompatible pointer
types assigning to 'NSDictionary *' from 'CFDictionaryRef'
      (aka 'const struct __CFDictionary *') [-Wincompatible-pointer-types]
    window_mode_dict = CGDisplayCurrentMode(kCGDirectMainDisplay);
                     ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/pm215/src/qemu/ui/cocoa.m:796:5: warning:
'CGDisplaySwitchToMode' is deprecated: first deprecated in OS X 10.6
      [-Wdeprecated-declarations]
    CGDisplaySwitchToMode(kCGDirectMainDisplay, window_mode_dict);
    ^
/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDirectDisplay.h:460:19:
note: 'CGDisplaySwitchToMode' has been explicitly
      marked deprecated here
CG_EXTERN CGError CGDisplaySwitchToMode(CGDirectDisplayID display,
                  ^
/Users/pm215/src/qemu/ui/cocoa.m:796:49: warning: incompatible pointer
types passing 'NSDictionary *' to parameter of type
      'CFDictionaryRef' (aka 'const struct __CFDictionary *')
[-Wincompatible-pointer-types]
    CGDisplaySwitchToMode(kCGDirectMainDisplay, window_mode_dict);
                                                ^~~~~~~~~~~~~~~~
/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDirectDisplay.h:461:19:
note: passing argument to parameter 'mode' here
  CFDictionaryRef mode) CG_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_6,
                  ^
/Users/pm215/src/qemu/ui/cocoa.m:804:20: warning: incompatible pointer
types initializing 'NSDictionary *' with an expression of type
      'CFDictionaryRef' (aka 'const struct __CFDictionary *')
[-Wincompatible-pointer-types]
  ...* mode = CGDisplayBestModeForParameters(kCGDirectMainDisplay,
desired_bit_depth, (size_t)cw, (size_t)ch, &exact_match);
       ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/pm215/src/qemu/ui/cocoa.m:804:27: warning:
'CGDisplayBestModeForParameters' is deprecated: first deprecated in OS
X 10.6
      [-Wdeprecated-declarations]
    NSDictionary * mode =
CGDisplayBestModeForParameters(kCGDirectMainDisplay,
desired_bit_depth, (size_t)cw, (size_t)ch, &ex...
                          ^
/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDirectDisplay.h:442:27:
note: 'CGDisplayBestModeForParameters' has been
      explicitly marked deprecated here
CG_EXTERN CFDictionaryRef CGDisplayBestModeForParameters(CGDirectDisplayID
                          ^
/Users/pm215/src/qemu/ui/cocoa.m:807:9: warning:
'CGDisplaySwitchToMode' is deprecated: first deprecated in OS X 10.6
      [-Wdeprecated-declarations]
        CGDisplaySwitchToMode(kCGDirectMainDisplay, mode);
        ^
/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDirectDisplay.h:460:19:
note: 'CGDisplaySwitchToMode' has been explicitly
      marked deprecated here
CG_EXTERN CGError CGDisplaySwitchToMode(CGDirectDisplayID display,
                  ^
/Users/pm215/src/qemu/ui/cocoa.m:807:53: warning: incompatible pointer
types passing 'NSDictionary *' to parameter of type
      'CFDictionaryRef' (aka 'const struct __CFDictionary *')
[-Wincompatible-pointer-types]
        CGDisplaySwitchToMode(kCGDirectMainDisplay, mode);
                                                    ^~~~
/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDirectDisplay.h:461:19:
note: passing argument to parameter 'mode' here
  CFDictionaryRef mode) CG_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_6,
                  ^
8 warnings generated.

(5) checkpatch also complains about trailing whitespace:

ERROR: trailing whitespace
#97: FILE: ui/cocoa.m:420:
+        ch = screen.height;        $

ERROR: trailing whitespace
#133: FILE: ui/cocoa.m:448:
+            it is the solution that works. I spent a long time looking $

ERROR: trailing whitespace
#223: FILE: ui/cocoa.m:950:
+because Mac OS 10.7 and higher disables it. This is because of the $

total: 3 errors, 0 warnings, 223 lines checked


>  - (void) switchSurface:(DisplaySurface *)surface
>  {
>      COCOA_DEBUG("QemuCocoaView: switchSurface\n");
> -
>      int w = surface_width(surface);
>      int h = surface_height(surface);
> -    /* cdx == 0 means this is our very first surface, in which case we need
> -     * to recalculate the content dimensions even if it happens to be the size
> -     * of the initial empty window.
> -     */
> -    bool isResize = (w != screen.width || h != screen.height || cdx == 0.0);
> -
> +    bool isResize = (w != screen.width || h != screen.height);

(6) This looks like you've just dropped a bug fix. How are you
dealing with this case if not by the method described in the
now-deleted comment?

thanks
-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] Fixes several full screen issues on Mac OS X
  2015-01-14 17:19 ` Peter Maydell
@ 2015-01-14 18:18   ` Programmingkid
  2015-01-14 18:29     ` Peter Maydell
  0 siblings, 1 reply; 6+ messages in thread
From: Programmingkid @ 2015-01-14 18:18 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel qemu-devel


On Jan 14, 2015, at 12:19 PM, Peter Maydell wrote:

> On 4 January 2015 at 23:44, Programmingkid <programmingkidx@gmail.com> wrote:
>> This patch makes several changes:
>> - Fixes issue of returning to window mode and QEMU not setting
>> the right graphic settings if there was a change during full screen mode.
>> - Eliminated distorted full screen display.
>> - Makes full screen mode available on Mac OS 10.7 and higher.
>> - Removes unneeded global variables cdx, and cdy.
>> - Changes a few comments to make them clearer.
>> 
>> Signed-off-by: John Arbuckle <programmingkidx@gmail.com>
> 
> I'm afraid this patch is badly broken for me.
> 
> (1) If I go into full screen then I can't get out again because the
> menubar isn't displayed even when I use ctrl+alt to release the
> mouse grab. I have to use my second monitor to get at the Dock so I
> can kill QEMU.

You would use Command - F after you have released the mouse grab to return to window mode.


> (2) Having done this I find that all my other application windows
> have been squashed down into a corner of my screen, presumably because
> we've told MacOSX "the screen is 640x480" and it's rearranged the
> app windows to suit. We mustn't mess things up like this.

This can't be avoided. When the screen resolution changes, all the applications usually adjust to the new size. It is the same thing that happens when you use a full screen game. 

> 
> (3) I managed to get at the underlying "QEMU" window with its title
> bar somehow even when in full screen mode: I could move it about the
> screen with the mouse...

Really? I think you said you had Mac OS 10.7. I don't have that, but I do have access to Mac OS 10.9. Just send me the instructions on how to reproduce this. 

> 
> (4) I get a lot of compile warnings for this patch:
> 
>  OBJC  ui/cocoa.o
> /Users/pm215/src/qemu/ui/cocoa.m:790:24: warning:
> 'CGDisplayCurrentMode' is deprecated: first deprecated in OS X 10.6
>      [-Wdeprecated-declarations]
>    window_mode_dict = CGDisplayCurrentMode(kCGDirectMainDisplay);
>                       ^
> /System/Library/Frameworks/CoreGraphics.framework/Headers/CGDirectDisplay.h:455:27:
> note: 'CGDisplayCurrentMode' has been explicitly
>      marked deprecated here
> CG_EXTERN CFDictionaryRef CGDisplayCurrentMode(CGDirectDisplayID display)
>                          ^
> /Users/pm215/src/qemu/ui/cocoa.m:790:22: warning: incompatible pointer
> types assigning to 'NSDictionary *' from 'CFDictionaryRef'
>      (aka 'const struct __CFDictionary *') [-Wincompatible-pointer-types]
>    window_mode_dict = CGDisplayCurrentMode(kCGDirectMainDisplay);
>                     ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /Users/pm215/src/qemu/ui/cocoa.m:796:5: warning:
> 'CGDisplaySwitchToMode' is deprecated: first deprecated in OS X 10.6
>      [-Wdeprecated-declarations]
>    CGDisplaySwitchToMode(kCGDirectMainDisplay, window_mode_dict);
>    ^
> /System/Library/Frameworks/CoreGraphics.framework/Headers/CGDirectDisplay.h:460:19:
> note: 'CGDisplaySwitchToMode' has been explicitly
>      marked deprecated here
> CG_EXTERN CGError CGDisplaySwitchToMode(CGDirectDisplayID display,
>                  ^
> /Users/pm215/src/qemu/ui/cocoa.m:796:49: warning: incompatible pointer
> types passing 'NSDictionary *' to parameter of type
>      'CFDictionaryRef' (aka 'const struct __CFDictionary *')
> [-Wincompatible-pointer-types]
>    CGDisplaySwitchToMode(kCGDirectMainDisplay, window_mode_dict);
>                                                ^~~~~~~~~~~~~~~~
> /System/Library/Frameworks/CoreGraphics.framework/Headers/CGDirectDisplay.h:461:19:
> note: passing argument to parameter 'mode' here
>  CFDictionaryRef mode) CG_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_6,
>                  ^
> /Users/pm215/src/qemu/ui/cocoa.m:804:20: warning: incompatible pointer
> types initializing 'NSDictionary *' with an expression of type
>      'CFDictionaryRef' (aka 'const struct __CFDictionary *')
> [-Wincompatible-pointer-types]
>  ...* mode = CGDisplayBestModeForParameters(kCGDirectMainDisplay,
> desired_bit_depth, (size_t)cw, (size_t)ch, &exact_match);
>       ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /Users/pm215/src/qemu/ui/cocoa.m:804:27: warning:
> 'CGDisplayBestModeForParameters' is deprecated: first deprecated in OS
> X 10.6
>      [-Wdeprecated-declarations]
>    NSDictionary * mode =
> CGDisplayBestModeForParameters(kCGDirectMainDisplay,
> desired_bit_depth, (size_t)cw, (size_t)ch, &ex...
>                          ^
> /System/Library/Frameworks/CoreGraphics.framework/Headers/CGDirectDisplay.h:442:27:
> note: 'CGDisplayBestModeForParameters' has been
>      explicitly marked deprecated here
> CG_EXTERN CFDictionaryRef CGDisplayBestModeForParameters(CGDirectDisplayID
>                          ^
> /Users/pm215/src/qemu/ui/cocoa.m:807:9: warning:
> 'CGDisplaySwitchToMode' is deprecated: first deprecated in OS X 10.6
>      [-Wdeprecated-declarations]
>        CGDisplaySwitchToMode(kCGDirectMainDisplay, mode);
>        ^
> /System/Library/Frameworks/CoreGraphics.framework/Headers/CGDirectDisplay.h:460:19:
> note: 'CGDisplaySwitchToMode' has been explicitly
>      marked deprecated here
> CG_EXTERN CGError CGDisplaySwitchToMode(CGDirectDisplayID display,
>                  ^
> /Users/pm215/src/qemu/ui/cocoa.m:807:53: warning: incompatible pointer
> types passing 'NSDictionary *' to parameter of type
>      'CFDictionaryRef' (aka 'const struct __CFDictionary *')
> [-Wincompatible-pointer-types]
>        CGDisplaySwitchToMode(kCGDirectMainDisplay, mode);
>                                                    ^~~~
> /System/Library/Frameworks/CoreGraphics.framework/Headers/CGDirectDisplay.h:461:19:
> note: passing argument to parameter 'mode' here
>  CFDictionaryRef mode) CG_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_6,
>                  ^
> 8 warnings generated.

Disabling the depreciation warning would eliminate these errors. 


> 
> (5) checkpatch also complains about trailing whitespace:
> 
> ERROR: trailing whitespace
> #97: FILE: ui/cocoa.m:420:
> +        ch = screen.height;        $
> 
> ERROR: trailing whitespace
> #133: FILE: ui/cocoa.m:448:
> +            it is the solution that works. I spent a long time looking $
> 
> ERROR: trailing whitespace
> #223: FILE: ui/cocoa.m:950:
> +because Mac OS 10.7 and higher disables it. This is because of the $
> 
> total: 3 errors, 0 warnings, 223 lines checked

I thought I did use checkpatch.pl on this. Will correct this issue.

> 
> 
>> - (void) switchSurface:(DisplaySurface *)surface
>> {
>>     COCOA_DEBUG("QemuCocoaView: switchSurface\n");
>> -
>>     int w = surface_width(surface);
>>     int h = surface_height(surface);
>> -    /* cdx == 0 means this is our very first surface, in which case we need
>> -     * to recalculate the content dimensions even if it happens to be the size
>> -     * of the initial empty window.
>> -     */
>> -    bool isResize = (w != screen.width || h != screen.height || cdx == 0.0);
>> -
>> +    bool isResize = (w != screen.width || h != screen.height);
> 
> (6) This looks like you've just dropped a bug fix. How are you
> dealing with this case if not by the method described in the
> now-deleted comment?

If the guest does change its resolution, then we try to match it in the host. When I eliminated this code, it made the guest look so much better. I was actually able to read documents in the guest at full screen. 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] Fixes several full screen issues on Mac OS X
  2015-01-14 18:18   ` Programmingkid
@ 2015-01-14 18:29     ` Peter Maydell
  2015-01-14 18:59       ` Programmingkid
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2015-01-14 18:29 UTC (permalink / raw)
  To: Programmingkid; +Cc: qemu-devel qemu-devel

On 14 January 2015 at 18:18, Programmingkid <programmingkidx@gmail.com> wrote:
>
> On Jan 14, 2015, at 12:19 PM, Peter Maydell wrote:
>> (2) Having done this I find that all my other application windows
>> have been squashed down into a corner of my screen, presumably because
>> we've told MacOSX "the screen is 640x480" and it's rearranged the
>> app windows to suit. We mustn't mess things up like this.
>
> This can't be avoided. When the screen resolution changes, all the
> applications usually adjust to the new size. It is the same thing
> that happens when you use a full screen game.

No, when I use other full screen programs this doesn't happen at all.
QEMU with this patch is the first time I've ever seen this from
any OSX app.

>> (3) I managed to get at the underlying "QEMU" window with its title
>> bar somehow even when in full screen mode: I could move it about the
>> screen with the mouse...
>
> Really? I think you said you had Mac OS 10.7. I don't have that, but
> I do have access to Mac OS 10.9. Just send me the instructions on how
> to reproduce this.

I run 10.9.5. I don't know exactly how I got to that window,
and I don't really want to mess about with this patch because
behaviour (2) above is so obnoxious.

>> (4) I get a lot of compile warnings for this patch:
>>

> Disabling the depreciation warning would eliminate these errors.

Not all of them are deprecation warnings. Also I would prefer not
to disable deprecation warnings, as then we'll have no notice
of what might break on future OSX versions.

>>>     int w = surface_width(surface);
>>>     int h = surface_height(surface);
>>> -    /* cdx == 0 means this is our very first surface, in which case we need
>>> -     * to recalculate the content dimensions even if it happens to be the size
>>> -     * of the initial empty window.
>>> -     */
>>> -    bool isResize = (w != screen.width || h != screen.height || cdx == 0.0);
>>> -
>>> +    bool isResize = (w != screen.width || h != screen.height);
>>
>> (6) This looks like you've just dropped a bug fix. How are you
>> dealing with this case if not by the method described in the
>> now-deleted comment?
>
> If the guest does change its resolution, then we try to match it
> in the host. When I eliminated this code, it made the guest look
> so much better. I was actually able to read documents in the guest
> at full screen.

The point is that you've dropped a bugfix which isn't related to
full screen at all -- if this is the first call to switchSurface
we *must* display it, which is what the cdx check does. See
commit 381600dad.

-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] Fixes several full screen issues on Mac OS X
  2015-01-14 18:29     ` Peter Maydell
@ 2015-01-14 18:59       ` Programmingkid
  2015-01-14 20:22         ` Peter Maydell
  0 siblings, 1 reply; 6+ messages in thread
From: Programmingkid @ 2015-01-14 18:59 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel qemu-devel


On Jan 14, 2015, at 1:29 PM, Peter Maydell wrote:

> On 14 January 2015 at 18:18, Programmingkid <programmingkidx@gmail.com> wrote:
>> 
>> On Jan 14, 2015, at 12:19 PM, Peter Maydell wrote:
>>> (2) Having done this I find that all my other application windows
>>> have been squashed down into a corner of my screen, presumably because
>>> we've told MacOSX "the screen is 640x480" and it's rearranged the
>>> app windows to suit. We mustn't mess things up like this.
>> 
>> This can't be avoided. When the screen resolution changes, all the
>> applications usually adjust to the new size. It is the same thing
>> that happens when you use a full screen game.
> 
> No, when I use other full screen programs this doesn't happen at all.
> QEMU with this patch is the first time I've ever seen this from
> any OSX app.

How long have you been a Mac user? I am shocked you have never seen this before. I'm guessing full screen gaming was never your thing. 

> 
>>> (3) I managed to get at the underlying "QEMU" window with its title
>>> bar somehow even when in full screen mode: I could move it about the
>>> screen with the mouse...
>> 
>> Really? I think you said you had Mac OS 10.7. I don't have that, but
>> I do have access to Mac OS 10.9. Just send me the instructions on how
>> to reproduce this.
> 
> I run 10.9.5. I don't know exactly how I got to that window,
> and I don't really want to mess about with this patch because
> behaviour (2) above is so obnoxious.
> 
>>> (4) I get a lot of compile warnings for this patch:
>>> 
> 
>> Disabling the depreciation warning would eliminate these errors.
> 
> Not all of them are deprecation warnings. Also I would prefer not
> to disable deprecation warnings, as then we'll have no notice
> of what might break on future OSX versions.

I'm sure we will know exactly when a depreciated function isn't implemented anymore. We will probably see some message in the Console. Or a backtrace to a crash will show us where and when QEMU crashed. I guess I could also use non-depreciated functions in the patch. The thing is QEMU will determine what to use at runtime, so the depreciation messages might not go away. 

> 
>>>>    int w = surface_width(surface);
>>>>    int h = surface_height(surface);
>>>> -    /* cdx == 0 means this is our very first surface, in which case we need
>>>> -     * to recalculate the content dimensions even if it happens to be the size
>>>> -     * of the initial empty window.
>>>> -     */
>>>> -    bool isResize = (w != screen.width || h != screen.height || cdx == 0.0);
>>>> -
>>>> +    bool isResize = (w != screen.width || h != screen.height);
>>> 
>>> (6) This looks like you've just dropped a bug fix. How are you
>>> dealing with this case if not by the method described in the
>>> now-deleted comment?
>> 
>> If the guest does change its resolution, then we try to match it
>> in the host. When I eliminated this code, it made the guest look
>> so much better. I was actually able to read documents in the guest
>> at full screen.
> 
> The point is that you've dropped a bugfix which isn't related to
> full screen at all -- if this is the first call to switchSurface
> we *must* display it, which is what the cdx check does. See
> commit 381600dad.

This bugfix does change the appearance of full screen mode. Have you seen a guest at full screen? The cdx and cdy variables make the guest OS look very distorted. 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Qemu-devel] [PATCH] Fixes several full screen issues on Mac OS X
  2015-01-14 18:59       ` Programmingkid
@ 2015-01-14 20:22         ` Peter Maydell
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2015-01-14 20:22 UTC (permalink / raw)
  To: Programmingkid; +Cc: qemu-devel qemu-devel

On 14 January 2015 at 18:59, Programmingkid <programmingkidx@gmail.com> wrote:
>
> On Jan 14, 2015, at 1:29 PM, Peter Maydell wrote:
>
>> On 14 January 2015 at 18:18, Programmingkid <programmingkidx@gmail.com> wrote:
>>>
>>> On Jan 14, 2015, at 12:19 PM, Peter Maydell wrote:
>>>> (2) Having done this I find that all my other application windows
>>>> have been squashed down into a corner of my screen, presumably because
>>>> we've told MacOSX "the screen is 640x480" and it's rearranged the
>>>> app windows to suit. We mustn't mess things up like this.
>>>
>>> This can't be avoided. When the screen resolution changes, all the
>>> applications usually adjust to the new size. It is the same thing
>>> that happens when you use a full screen game.
>>
>> No, when I use other full screen programs this doesn't happen at all.
>> QEMU with this patch is the first time I've ever seen this from
>> any OSX app.
>
> How long have you been a Mac user? I am shocked you have never seen
> this before. I'm guessing full screen gaming was never your thing.

Three years or so. I don't do much full screen stuff but I have
played a few games that fullscreen. In any case I think the
behaviour is definitely not something we can accept.

>> The point is that you've dropped a bugfix which isn't related to
>> full screen at all -- if this is the first call to switchSurface
>> we *must* display it, which is what the cdx check does. See
>> commit 381600dad.

> This bugfix does change the appearance of full screen mode.
> Have you seen a guest at full screen? The cdx and cdy variables
> make the guest OS look very distorted.

For me with current trunk the fullscreen is just "usual display,
not expanded at all, as only thing on the screen". Regardless,
this code your patch deletes was added *to fix a bug* and you
cannot simply delete it because it happens to get in the way of
a different fix you want to make. You must come up with something
that fixes both problems.

-- PMM

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-01-14 20:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-04 23:44 [Qemu-devel] [PATCH] Fixes several full screen issues on Mac OS X Programmingkid
2015-01-14 17:19 ` Peter Maydell
2015-01-14 18:18   ` Programmingkid
2015-01-14 18:29     ` Peter Maydell
2015-01-14 18:59       ` Programmingkid
2015-01-14 20:22         ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.