ui/cocoa: Fixed modeswitching glitch in zoomed fullscreen mode
PATCH 1/1 ui/cocoa: Fixed modeswitching glitch in zoomed fullscreen mode
This applies only on macOS using cocoa UI library.
In zoom-to-fit fullscreen mode, upon graphics mode switch, the viewport size is wrong, and the usual consequence is only a part of the screen is visible. One have to exit and reenter fullscreen mode to fix this.
This is reproducible by setting up a Windows 3.11 system, booting into DOS, enable zoom-to-fit, enter fullscreen mode and start Windows by 'win'. Then you can see only part of the screen.
This commit fixes this problem, by including one line of code which is from the fullscreen mode initialization.
--- ui/cocoa.m | 1 + 1 file changed, 1 insertion(+)
ui/cocoa.m +1 -0
@@ -636,6 +636,7 @@ - (void) switchSurface:(pixman_image_t *)image if (isFullscreen) { [[fullScreenWindow contentView] setFrame:[[NSScreen mainScreen] frame]]; [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + oldh, w, h + [normalWindow frame].size.height - oldh) display:NO animate:NO]; + [self setFrame:NSMakeRect(cx, cy, cw, ch)]; } else { if (qemu_name) [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]];
Signature · 1 line
2.24.3 (Apple Git-128)
Quoted 24 lines · Imran Yusuff
This applies only on macOS using cocoa UI library.
In zoom-to-fit fullscreen mode, upon graphics mode switch, the viewport size is wrong, and the usual consequence is only a part of the screen is visible. One have to exit and reenter fullscreen mode to fix this.
This is reproducible by setting up a Windows 3.11 system, booting into DOS, enable zoom-to-fit, enter fullscreen mode and start Windows by 'win'. Then you can see only part of the screen.
This commit fixes this problem, by including one line of code which is from the fullscreen mode initialization.
Signed-off-by Imran Yusuff <[email protected]>--- ui/cocoa.m | 1 + 1 file changed, 1 insertion(+)ui/cocoa.m +0
-0
ui/cocoa.m - (void) switchSurface:(pixman_image_t *)image · line 642
Quoted 7 lines
ui/cocoa.m +1
-0@@ -636,6 +636,7 @@ - (void) switchSurface:(pixman_image_t *)image if (isFullscreen) { [[fullScreenWindow contentView] setFrame:[[NSScreen mainScreen] frame]]; [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + oldh, w, h + [normalWindow frame].size.height - oldh) display:NO animate:NO]; + [self setFrame:NSMakeRect(cx, cy, cw, ch)]; } else { if (qemu_name) [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]];
[self setFrame:NSMakeRect(cx, cy, cw, ch)] already exist in the earlier part of the method. It is redundant and not a proper way to fix. It is necessary to understand why adding the same statement fixes the problem, and to fix it without duplicate statements. I can think of two possibilities:
1. The isResize variable is not enough to cover all the situations when the statement needs to be executed.
2. The statement needs to be executed after [normalWindow setFrame:].
In case 1, you need to assign a correct value to isResize or add [self setFrame:] to somewhere else, but not in [-CocoaView switchSurface]. Putting the statement in [-CocoaView switchSurface] may cause redundant execution of the statement when isResize is true as I explained.
In case 2, the existing statement should be simply moved.
By the way, I have a patch to rewrite the code implementing full screen so you may try it. If you tested the patch, please give Tested-by.
https://patchew.org/QEMU/[email protected]/
Regards,
Akihiko Odaki
Hi,
Many thanks for the feedback. Actually I have investigated this by writing printfs in between statements to print out the 'self rect' values, and apparently the statement [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, ... modifies this 'self rect' values, for reason I am not sure why, hence the suggested additional statement to undo this. So yes, case 2 seems to make more sense, but it will not be executed in windowed (non-fullscreen) mode.
Many thanks for the code rewrite patch. It seems like a more proper work and I will definitely test this. I will get back to you soon once done.
Regards,
Imran Yusuff
Quoted 60 lines · Akihiko Odaki
Quoted 24 lines · Imran Yusuff
This applies only on macOS using cocoa UI library.
In zoom-to-fit fullscreen mode, upon graphics mode switch, the viewport size is wrong, and the usual consequence is only a part of the screen is visible. One have to exit and reenter fullscreen mode to fix this.
This is reproducible by setting up a Windows 3.11 system, booting into DOS, enable zoom-to-fit, enter fullscreen mode and start Windows by 'win'. Then you can see only part of the screen.
This commit fixes this problem, by including one line of code which is from the fullscreen mode initialization.
Signed-off-by Imran Yusuff <[email protected]>--- ui/cocoa.m | 1 + 1 file changed, 1 insertion(+)ui/cocoa.m +0
-0ui/cocoa.m - (void) switchSurface:(pixman_image_t *)image · line 637
Quoted 2 lines
ui/cocoa.m +0
-0@@ -636,6 +636,7 @@ - (void) switchSurface:(pixman_image_t *)image if (isFullscreen) { [[fullScreenWindow contentView] setFrame:[[NSScreenmainScreen] frame]];
ui/cocoa.m - (void) switchSurface:(pixman_image_t *)image · line 638
Quoted 1 line
ui/cocoa.m +0
-0[normalWindow setFrame:NSMakeRect([normalWindowframe].origin.x, [normalWindow frame].origin.y - h + oldh, w, h + [normalWindow frame].size.height - oldh) display:NO animate:NO];
ui/cocoa.m - (void) switchSurface:(pixman_image_t *)image
Quoted 4 lines
ui/cocoa.m +1
-0+ [self setFrame:NSMakeRect(cx, cy, cw, ch)]; } else { if (qemu_name) [normalWindow setTitle:[NSString stringWithFormat:@"QEMU%s",
qemu_name]];[self setFrame:NSMakeRect(cx, cy, cw, ch)] already exist in the earlier part of the method. It is redundant and not a proper way to fix. It is necessary to understand why adding the same statement fixes the problem, and to fix it without duplicate statements. I can think of two possibilities:
1. The isResize variable is not enough to cover all the situations when the statement needs to be executed.
2. The statement needs to be executed after [normalWindow setFrame:].In case 1, you need to assign a correct value to isResize or add [self setFrame:] to somewhere else, but not in [-CocoaView switchSurface]. Putting the statement in [-CocoaView switchSurface] may cause redundant execution of the statement when isResize is true as I explained.
In case 2, the existing statement should be simply moved.
By the way, I have a patch to rewrite the code implementing full screen so you may try it. If you tested the patch, please give Tested-by.
https://patchew.org/QEMU/[email protected]/Regards,
Akihiko Odaki