From nobody Thu Apr 25 17:33:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552659169215672.7551740729019; Fri, 15 Mar 2019 07:12:49 -0700 (PDT) Received: from localhost ([127.0.0.1]:55813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4nZk-0001Gt-2y for importer@patchew.org; Fri, 15 Mar 2019 10:12:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53505) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4mZ1-0007Yz-UT for qemu-devel@nongnu.org; Fri, 15 Mar 2019 09:07:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4mYw-0003Ev-0b for qemu-devel@nongnu.org; Fri, 15 Mar 2019 09:07:53 -0400 Received: from pv50p00im-ztdg10021801.me.com ([17.58.6.56]:42161) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h4mYo-00035N-N6 for qemu-devel@nongnu.org; Fri, 15 Mar 2019 09:07:45 -0400 Received: from [172.18.2.102] (unknown [36.106.166.130]) by pv50p00im-ztdg10021801.me.com (Postfix) with ESMTPSA id 9DD15360180; Fri, 15 Mar 2019 10:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=04042017; t=1552646885; bh=cg8FVp4FCStkcMl7bDfA07oj9oVPo60rBiaCL+hC8Pw=; h=From:Message-Id:Content-Type:Mime-Version:Subject:Date:To; b=5Rtj9E5sOhOudFeB39mmR7MCW2PGwnWNL3shxrKtDVZizHNMMM+Wl4OtfyGMUmn73 gH66LuMYucADRcsmS7AvwBE6qbDSw3e1EHzxwMCe/3NrlONnA4+z4XYnIxUGIpqKSc rUUAIKFLzXqWwjSSy5V8zpYiEazOFWYhNd4sJYDVF+ei6+LAG7vewG01EJTXampmV5 HnDgXs6G7t/M3acN6odUa6w7ud6KvERR7bbU85AHbFEV9Gkqjd7cqoH7qbZIxUtyIc cSuSKDvRIk8Ibq4oHq/45QHxUUaSWujdFzQ2aaRVvzlPDTCO/xeKw0ViBRRxRbyo5Q s1rKTpKY3rp6g== Message-Id: <3F771462-AC5B-4CAC-939F-6E24F43B9FF5@me.com> Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Date: Fri, 15 Mar 2019 18:47:59 +0800 In-Reply-To: To: qemu-devel@nongnu.org References: X-Mailer: Apple Mail (2.3445.102.3) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-15_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1812120000 definitions=main-1903150078 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 17.58.6.56 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: [Qemu-devel] [PATCH 1/2] ui/cocoa: Fix absolute input device grabbing issues on Mojave X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Chen Zhang via Qemu-devel Reply-To: Chen Zhang Cc: Peter Maydell , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Chen Zhang > --- ui/cocoa.m | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 420b2411c1..5d0a6599d9 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -405,6 +405,24 @@ QemuCocoaView *cocoaView; return (p.x > -1 && p.x < screen.width && p.y > -1 && p.y < screen.heig= ht); } +/* Get location of event and convert to virtual screen coordinate */ +- (CGPoint) screenLocationOfEvent:(NSEvent *)ev +{ + NSWindow *eventWindow =3D [ev window]; + if (!eventWindow) { + return [self.window convertPointFromScreen:[ev locationInWindow]]; + } else if ([self.window isEqual:eventWindow]) { + return [ev locationInWindow]; + } else { + return [self.window convertPointFromScreen:[eventWindow convertPoi= ntToScreen:[ev locationInWindow]]]; + } +} + +- (BOOL) screenContainsPointOfEvent:(NSEvent *)ev +{ + return [self screenContainsPoint:[self screenLocationOfEvent:ev]]; +} + - (void) hideCursor { if (!cursor_hide) { @@ -815,7 +833,9 @@ QemuCocoaView *cocoaView; break; case NSEventTypeMouseMoved: if (isAbsoluteEnabled) { - if (![self screenContainsPoint:p] || ![[self window] isKey= Window]) { + BOOL is_key_window =3D [[self window] isKeyWindow]; + BOOL is_in_screen =3D [self screenContainsPointOfEvent: e= vent]; + if (!is_in_screen || !is_key_window) { if (isMouseGrabbed) { [self ungrabMouse]; } @@ -927,9 +947,10 @@ QemuCocoaView *cocoaView; * The check on screenContainsPoint is to avoid sending out= of range values for * clicks in the titlebar. */ - if ([self screenContainsPoint:p]) { - qemu_input_queue_abs(dcl->con, INPUT_AXIS_X, p.x, 0, s= creen.width); - qemu_input_queue_abs(dcl->con, INPUT_AXIS_Y, screen.he= ight - p.y, 0, screen.height); + if ([self screenContainsPointOfEvent:event]) { + CGPoint loc =3D [self screenLocationOfEvent: event]; + qemu_input_queue_abs(dcl->con, INPUT_AXIS_X, loc.x, 0,= screen.width); + qemu_input_queue_abs(dcl->con, INPUT_AXIS_Y, screen.he= ight - loc.y, 0, screen.height); } } else { qemu_input_queue_rel(dcl->con, INPUT_AXIS_X, (int)[event de= ltaX]); --=20 2.19.2 From nobody Thu Apr 25 17:33:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1552658517106941.9408396664622; Fri, 15 Mar 2019 07:01:57 -0700 (PDT) Received: from localhost ([127.0.0.1]:55616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4nPG-00007E-1T for importer@patchew.org; Fri, 15 Mar 2019 10:01:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:53609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h4mZ7-0007bl-R9 for qemu-devel@nongnu.org; Fri, 15 Mar 2019 09:08:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h4mZ2-0003Gf-N9 for qemu-devel@nongnu.org; Fri, 15 Mar 2019 09:08:01 -0400 Received: from pv50p00im-ztdg10021801.me.com ([17.58.6.56]:42160) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h4mZ2-00035O-4O for qemu-devel@nongnu.org; Fri, 15 Mar 2019 09:07:56 -0400 Received: from [172.18.2.102] (unknown [36.106.166.130]) by pv50p00im-ztdg10021801.me.com (Postfix) with ESMTPSA id 73FBE36011C; Fri, 15 Mar 2019 10:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=me.com; s=04042017; t=1552646910; bh=QPkcVTp1ytyY5hxk+SU1bl0Z8xjT0bDimQpGJvrt/aM=; h=From:Message-Id:Content-Type:Mime-Version:Subject:Date:To; b=w3fYmotj4tER0ZtI6mdLfvZfhvLfCL1cz/osEvS3AWChzYeq3SNLhDNemsRNxtYxm Mo5dh2t2s/ipx3MgD0G62mucNXBdFME6T3aJ9Sf05JUk/infVs9lRb/WIRIUYTGgcF A5z24VjCVM8OlxToENhMhYQ1PFg5dgcSX2/mng4BgnKLtN60jCP7DY7jnWgwPJQbq6 aUVngEQaL4XVptbi1yHDTahH+ds1TtmTi39Hwkc2McIx8phga2vrsAzxKrBCAFVWF8 7nsxE19fg5ERuPq0euK93f0n/8ovqs/qjuBzuHX0W6qLIGL86sX0aICIxucquxyz2d s1rjRD4cuDblQ== Message-Id: <3C058793-9AAE-4C01-B099-1ED4D713243F@me.com> Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Date: Fri, 15 Mar 2019 18:48:29 +0800 In-Reply-To: To: qemu-devel@nongnu.org References: X-Mailer: Apple Mail (2.3445.102.3) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-03-15_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1812120000 definitions=main-1903150078 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 17.58.6.56 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: [Qemu-devel] [PATCH 2/2] ui/cocoa: fix grabbing issue in fullscreen mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Chen Zhang via Qemu-devel Reply-To: Chen Zhang Cc: Peter Maydell , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Chen Zhang > --- ui/cocoa.m | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 5d0a6599d9..8e74f6e283 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -410,11 +410,31 @@ QemuCocoaView *cocoaView; { NSWindow *eventWindow =3D [ev window]; if (!eventWindow) { - return [self.window convertPointFromScreen:[ev locationInWindow]]; - } else if ([self.window isEqual:eventWindow]) { - return [ev locationInWindow]; + if (!isFullscreen) { + return [[self window] convertPointFromScreen:[ev locationInWin= dow]]; + } else { + CGPoint loc =3D [self convertPoint:[[self window] convertPoint= FromScreen:[ev locationInWindow]] fromView:nil]; + if (!stretch_video) { + return loc; + } + loc.x /=3D cdx; + loc.y /=3D cdy; + return loc; + } + } else if ([[self window] isEqual:eventWindow]) { + if (!isFullscreen) { + return [ev locationInWindow]; + } else { + CGPoint loc =3D [self convertPoint:[ev locationInWindow] fromV= iew:nil]; + if (!stretch_video) { + return loc; + } + loc.x /=3D cdx; + loc.y /=3D cdy; + return loc; + } } else { - return [self.window convertPointFromScreen:[eventWindow convertPoi= ntToScreen:[ev locationInWindow]]]; + return [[self window] convertPointFromScreen:[eventWindow convertP= ointToScreen:[ev locationInWindow]]]; } } @@ -722,7 +742,6 @@ QemuCocoaView *cocoaView; int keycode =3D 0; bool mouse_event =3D false; static bool switched_to_fullscreen =3D false; - NSPoint p =3D [event locationInWindow]; switch ([event type]) { case NSEventTypeFlagsChanged: @@ -835,7 +854,7 @@ QemuCocoaView *cocoaView; if (isAbsoluteEnabled) { BOOL is_key_window =3D [[self window] isKeyWindow]; BOOL is_in_screen =3D [self screenContainsPointOfEvent: ev= ent]; - if (!is_in_screen || !is_key_window) { + if (!is_in_screen || !(is_key_window || isFullscreen)) { if (isMouseGrabbed) { [self ungrabMouse]; } @@ -881,7 +900,7 @@ QemuCocoaView *cocoaView; break; case NSEventTypeLeftMouseUp: mouse_event =3D true; - if (!isMouseGrabbed && [self screenContainsPoint:p]) { + if (!isMouseGrabbed && [self screenContainsPointOfEvent:event]= ) { if([[self window] isKeyWindow]) { [self grabMouse]; } @@ -944,7 +963,7 @@ QemuCocoaView *cocoaView; if (isMouseGrabbed) { if (isAbsoluteEnabled) { /* Note that the origin for Cocoa mouse coords is bottom le= ft, not top left. - * The check on screenContainsPoint is to avoid sending ou= t of range values for + * The check on screenContainsPointOfEvent is to avoid sen= ding out of range values for * clicks in the titlebar. */ if ([self screenContainsPointOfEvent:event]) { --=20 2.19.2