From patchwork Sun Jan 12 22:52:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 23147 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 76FA820A64 for ; Sun, 12 Jan 2014 23:19:27 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id o6sf26620739oag.11 for ; Sun, 12 Jan 2014 15:19:26 -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:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=3BLgSFzWazjN6SgTdBdN6mM7bMG4qvszwNv9Q/I0nsc=; b=BvFaphlps6K7AYeQClz6zcrFeGFE7S2SEctW3YjxxVKa0A9vbWCyaD+DMey3OGcAmB aglDvo79XDTdV3UYGYHtYp8j/xLIfK8VsxU9M4Icd+2exR/u+fTBdXUqMFhTar0NP+iF QbBaLjo9zD0KYW+VMsnRWo8e1CBeISGI2HiSy6jGfeKyo5FSgKTR+sDl915UwkDmy50F PcKGyilJbHkZ/ngJDuPO1LOJNqDPSlnFcXt/S82/370K3XcNDGFazBvelOA6v0W9esbW AuEOkLVQBj7Ax+xn/5eawnWhdZFlGOL6Du7c5z1nUVvrt2PZY6zdfR4d0otx6ue+wUtd BzNQ== X-Gm-Message-State: ALoCoQmDGSAItcLyJYHpVgPNv500K/test/Fc+KeRHswqSrNazpuNydJ2ITUilfjtz/pIZwmDUmE X-Received: by 10.182.55.102 with SMTP id r6mr8540335obp.7.1389568766568; Sun, 12 Jan 2014 15:19:26 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.99.71 with SMTP id eo7ls484743qeb.20.gmail; Sun, 12 Jan 2014 15:19:26 -0800 (PST) X-Received: by 10.52.76.105 with SMTP id j9mr12404vdw.52.1389568766441; Sun, 12 Jan 2014 15:19:26 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id er6si9840876vdc.153.2014.01.12.15.19.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 12 Jan 2014 15:19:26 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id cz12so1802559veb.2 for ; Sun, 12 Jan 2014 15:19:26 -0800 (PST) X-Received: by 10.52.251.68 with SMTP id zi4mr13446709vdc.25.1389568766329; Sun, 12 Jan 2014 15:19:26 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp93623ved; Sun, 12 Jan 2014 15:19:26 -0800 (PST) X-Received: by 10.224.128.4 with SMTP id i4mr33648208qas.63.1389568765896; Sun, 12 Jan 2014 15:19:25 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x8si7797976qch.112.2014.01.12.15.19.25 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 12 Jan 2014 15:19:25 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:39761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2Tvw-00014C-Uy for patch@linaro.org; Sun, 12 Jan 2014 17:55:08 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2Ttl-00063k-Sd for qemu-devel@nongnu.org; Sun, 12 Jan 2014 17:52:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2Ttk-00056K-JY for qemu-devel@nongnu.org; Sun, 12 Jan 2014 17:52:53 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:44745) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2Ttk-00055e-CF for qemu-devel@nongnu.org; Sun, 12 Jan 2014 17:52:52 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1W2TtX-00085v-6X; Sun, 12 Jan 2014 22:52:39 +0000 From: Peter Maydell To: Anthony Liguori Date: Sun, 12 Jan 2014 22:52:35 +0000 Message-Id: <1389567158-31066-7-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1389567158-31066-1-git-send-email-peter.maydell@linaro.org> References: <1389567158-31066-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Cc: Blue Swirl , =?UTF-8?q?Andreas=20F=C3=A4rber?= , qemu-devel@nongnu.org, Aurelien Jarno Subject: [Qemu-devel] [PULL 6/9] ui/cocoa: Redraw at correct size when switching surface X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.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.128.171 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 Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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 Message-id: 1387853507-26298-2-git-send-email-peter.maydell@linaro.org --- ui/cocoa.m | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index b90b782..6a1f6b6 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -405,6 +405,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) @@ -419,17 +430,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