From 485c4cc3bd2799f069309e33c923e7f700426b70 Mon Sep 17 00:00:00 2001 From: serb Date: Wed, 3 Jan 2018 19:24:14 -0800 Subject: [PATCH] 8191696: Better mouse positioning Reviewed-by: skoivu, rhalade, prr, aghaisas --- .../classes/sun/awt/X11/XMouseInfoPeer.java | 22 +++++++++---------- src/windows/native/sun/windows/MouseInfo.cpp | 3 ++- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/solaris/classes/sun/awt/X11/XMouseInfoPeer.java b/src/solaris/classes/sun/awt/X11/XMouseInfoPeer.java index ea45452d2..eb36d5aeb 100644 --- a/src/solaris/classes/sun/awt/X11/XMouseInfoPeer.java +++ b/src/solaris/classes/sun/awt/X11/XMouseInfoPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,11 +25,10 @@ package sun.awt.X11; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; import java.awt.Point; import java.awt.Window; -import java.awt.GraphicsEnvironment; -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsDevice; import java.awt.peer.MouseInfoPeer; public class XMouseInfoPeer implements MouseInfoPeer { @@ -76,14 +75,15 @@ public class XMouseInfoPeer implements MouseInfoPeer { } public boolean isWindowUnderMouse(Window w) { - + if (w == null) { + return false; + } + XWindow peer = (XWindow) w.getPeer(); + if (peer == null) { + return false; + } long display = XToolkit.getDisplay(); - - // java.awt.Component.findUnderMouseInWindow checks that - // the peer is non-null by checking that the component - // is showing. - - long contentWindow = ((XWindow)w.getPeer()).getContentWindow(); + long contentWindow = peer.getContentWindow(); long parent = XlibUtil.getParentWindow(contentWindow); XToolkit.awtLock(); diff --git a/src/windows/native/sun/windows/MouseInfo.cpp b/src/windows/native/sun/windows/MouseInfo.cpp index b109f28de..5ff1a8ec0 100644 --- a/src/windows/native/sun/windows/MouseInfo.cpp +++ b/src/windows/native/sun/windows/MouseInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,6 +48,7 @@ Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse(JNIEnv *env, jclass cls, } jobject winPeer = AwtObject::GetPeerForTarget(env, window); + CHECK_NULL_RETURN(winPeer, JNI_FALSE); PDATA pData; pData = JNI_GET_PDATA(winPeer); env->DeleteLocalRef(winPeer); -- GitLab