1 /*
2 * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
117
118 [view setImage:imagePtr];
119 }
120
121 - (NSPoint) getLocationOnScreen {
122 return [[view window] convertBaseToScreen: NSZeroPoint];
123 }
124
125 -(void) deliverJavaMouseEvent: (NSEvent *) event {
126 [AWTToolkit eventCountPlusPlus];
127
128 JNIEnv *env = [ThreadUtilities getJNIEnv];
129
130 NSPoint eventLocation = [event locationInWindow];
131 NSPoint localPoint = [view convertPoint: eventLocation fromView: nil];
132 localPoint.y = [view bounds].size.height - localPoint.y;
133
134 NSPoint absP = [NSEvent mouseLocation];
135 NSEventType type = [event type];
136
137 NSRect screenRect = [[NSScreen mainScreen] frame];
138 absP.y = screenRect.size.height - absP.y;
139 jint clickCount;
140
141 clickCount = [event clickCount];
142
143 jdouble deltaX = [event deltaX];
144 jdouble deltaY = [event deltaY];
145 if ([AWTToolkit hasPreciseScrollingDeltas: event]) {
146 deltaX = [event scrollingDeltaX] * 0.1;
147 deltaY = [event scrollingDeltaY] * 0.1;
148 }
149
150 static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
151 static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDDI)V");
152 jobject jEvent = JNFNewObject(env, jctor_NSEvent,
153 [event type],
154 [event modifierFlags],
155 clickCount,
156 [event buttonNumber],
157 (jint)localPoint.x, (jint)localPoint.y,
158 (jint)absP.x, (jint)absP.y,
|
1 /*
2 * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
117
118 [view setImage:imagePtr];
119 }
120
121 - (NSPoint) getLocationOnScreen {
122 return [[view window] convertBaseToScreen: NSZeroPoint];
123 }
124
125 -(void) deliverJavaMouseEvent: (NSEvent *) event {
126 [AWTToolkit eventCountPlusPlus];
127
128 JNIEnv *env = [ThreadUtilities getJNIEnv];
129
130 NSPoint eventLocation = [event locationInWindow];
131 NSPoint localPoint = [view convertPoint: eventLocation fromView: nil];
132 localPoint.y = [view bounds].size.height - localPoint.y;
133
134 NSPoint absP = [NSEvent mouseLocation];
135 NSEventType type = [event type];
136
137 absP = ConvertNSScreenPoint(NULL, absP);
138 jint clickCount;
139
140 clickCount = [event clickCount];
141
142 jdouble deltaX = [event deltaX];
143 jdouble deltaY = [event deltaY];
144 if ([AWTToolkit hasPreciseScrollingDeltas: event]) {
145 deltaX = [event scrollingDeltaX] * 0.1;
146 deltaY = [event scrollingDeltaY] * 0.1;
147 }
148
149 static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
150 static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDDI)V");
151 jobject jEvent = JNFNewObject(env, jctor_NSEvent,
152 [event type],
153 [event modifierFlags],
154 clickCount,
155 [event buttonNumber],
156 (jint)localPoint.x, (jint)localPoint.y,
157 (jint)absP.x, (jint)absP.y,
|