From patchwork Tue Dec 24 02:51:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 22743 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8B28D20540 for ; Tue, 24 Dec 2013 02:51:51 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id i4sf27381952oah.6 for ; Mon, 23 Dec 2013 18:51:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=8TZmTm2CbR4hgjaTd5aNJ/ljXECEIgxwnfpNffnJPkY=; b=e4vxcTPCZJ6p9tVqkH7gQMz10ui1J7aDZyTgWmc/8mBwOo17z+s8Rhd2G3FBq/skVw SZ02ww91X2V6MsITXjuYtm7WKdgL9bw8jz4fFeK27TZoypN5R8uk6nsD1gGNLja0NRMY O345VmzV3oer0wduS9wcFrNqBPlAuSE6lQZVucaL9x+UVpl1dneeHYdjpmLA5Sx70Ra7 e49n2qtMOLnOQTmsM4rUgvPisCZey9YwrSmZJEn6Vl8m2YDyzy8qjwQSZUUIZESmD87x xz8r5Kq/uSzy84/qX7T3CYH64NrLVONqnsOqCeP4wT55n9zkwxm3w4lDWFDduaE+v/+S aIXQ== X-Gm-Message-State: ALoCoQl/18lYKKDJ+j7tMFJX2Ezhgxiffv220hYo1XKstnfgKrYJ4simyBzXGT3Z/7yFPPicMIlW X-Received: by 10.182.161.105 with SMTP id xr9mr12163601obb.31.1387853510638; Mon, 23 Dec 2013 18:51:50 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.12.11 with SMTP id u11ls1755584qeb.25.gmail; Mon, 23 Dec 2013 18:51:50 -0800 (PST) X-Received: by 10.52.171.79 with SMTP id as15mr12458094vdc.1.1387853510535; Mon, 23 Dec 2013 18:51:50 -0800 (PST) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id vo6si1229329vcb.125.2013.12.23.18.51.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Dec 2013 18:51:50 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id ht17so3166170vcb.18 for ; Mon, 23 Dec 2013 18:51:50 -0800 (PST) X-Received: by 10.58.39.97 with SMTP id o1mr4471867vek.15.1387853510447; Mon, 23 Dec 2013 18:51:50 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp266947ved; Mon, 23 Dec 2013 18:51:49 -0800 (PST) X-Received: by 10.180.9.235 with SMTP id d11mr5192669wib.33.1387853508535; Mon, 23 Dec 2013 18:51:48 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id pr7si7921858wjc.164.2013.12.23.18.51.48 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 23 Dec 2013 18:51:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1VvI5z-0006qg-3n; Tue, 24 Dec 2013 02:51:47 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH 1/2] ui/cocoa: Redraw at correct size when switching surface Date: Tue, 24 Dec 2013 02:51:46 +0000 Message-Id: <1387853507-26298-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1387853507-26298-1-git-send-email-peter.maydell@linaro.org> References: <1387853507-26298-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , If the surface switch involved a resize, we were doing the redraw at the old size rather than the new, because the update of screen.width and screen.height was being done after the setFrame method calls which triggered a redraw. Normally this isn't very noticeable because typically after the guest triggers the window resize it also draws something to it, which will in turn cause us to redraw. However, the combination of a guest which never draws to the display and a command line setting of a screen size larger than the default can reveal odd effects. Move most of the handling of resizes to the top of the method, and guard it with a check that the surface size actually changed, to avoid unnecessary operations (including some user visible ones like "recenter the window on the screen") if the surface is the same size as the old one. Signed-off-by: Peter Maydell --- ui/cocoa.m | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 94bf729..9e22d21 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -406,6 +406,17 @@ QemuCocoaView *cocoaView; int w = surface_width(surface); int h = surface_height(surface); + 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 + COCOA_DEBUG("switchSurface: new size %d x %d\n", w, h); + screen.width = w; + screen.height = h; + [self setContentDimensions]; + [self setFrame:NSMakeRect(cx, cy, cw, ch)]; + } // update screenBuffer if (dataProviderRef) @@ -420,17 +431,16 @@ QemuCocoaView *cocoaView; // update windows if (isFullscreen) { [[fullScreenWindow contentView] setFrame:[[NSScreen mainScreen] frame]]; - [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:NO animate:NO]; + [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + oldh, w, h + [normalWindow frame].size.height - oldh) display:NO animate:NO]; } else { if (qemu_name) [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s", qemu_name]]; - [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + screen.height, w, h + [normalWindow frame].size.height - screen.height) display:YES animate:NO]; + [normalWindow setFrame:NSMakeRect([normalWindow frame].origin.x, [normalWindow frame].origin.y - h + oldh, w, h + [normalWindow frame].size.height - oldh) display:YES animate:NO]; + } + + if (isResize) { + [normalWindow center]; } - screen.width = w; - screen.height = h; - [normalWindow center]; - [self setContentDimensions]; - [self setFrame:NSMakeRect(cx, cy, cw, ch)]; } - (void) toggleFullScreen:(id)sender