1 /*
2 * Copyright (c) 2010, 2013, 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
23 * questions.
24 */
25 package com.sun.glass.events.mac;
26
27 import java.util.Map;
28 import com.sun.glass.ui.Window;
29
30 // https://wiki.mozilla.org/NPAPI:CocoaEventModel
31
32 // used by Mac OS X impl for handling an NPAPI event sent from plugin to Glass process
33 public class NpapiEvent {
34
35 // draw
36 final static public int NPCocoaEventDrawRect = 1;
37 // mouse
38 final static public int NPCocoaEventMouseDown = 2;
39 final static public int NPCocoaEventMouseUp = 3;
40 final static public int NPCocoaEventMouseMoved = 4;
41 final static public int NPCocoaEventMouseEntered = 5;
42 final static public int NPCocoaEventMouseExited = 6;
43 final static public int NPCocoaEventMouseDragged = 7;
44 // key
45 final static public int NPCocoaEventKeyDown = 8;
46 final static public int NPCocoaEventKeyUp = 9;
47 final static public int NPCocoaEventFlagsChanged = 10;
48 // focus
49 final static public int NPCocoaEventFocusChanged = 11;
50 final static public int NPCocoaEventWindowFocusChanged = 12;
51 // mouse
52 final static public int NPCocoaEventScrollWheel = 13;
53 // text input
54 final static public int NPCocoaEventTextInput = 14;
55
56 private native static void _dispatchCocoaNpapiDrawEvent(long windowPtr, int type,
57 long context, double x, double y, double width, double height);
58 private native static void _dispatchCocoaNpapiMouseEvent(long windowPtr, int type,
59 int modifierFlags, double pluginX, double pluginY, int buttonNumber, int clickCount,
60 double deltaX, double deltaY, double deltaZ);
61 private native static void _dispatchCocoaNpapiKeyEvent(long windowPtr, int type,
62 int modifierFlags, String characters, String charactersIgnoringModifiers,
63 boolean isARepeat, int keyCode, boolean needsKeyTyped);
64 private native static void _dispatchCocoaNpapiFocusEvent(long windowPtr, int type,
65 boolean hasFocus);
66 private native static void _dispatchCocoaNpapiTextInputEvent(long windowPtr, int type,
67 String text);
68
69 final private static boolean getBoolean(Map eventInfo, String key) {
70 boolean value = false;
71 {
72 if (eventInfo.containsKey(key) == true ) {
73 try {
74 value = ((Boolean)eventInfo.get(key)).booleanValue();
|
1 /*
2 * Copyright (c) 2010, 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
23 * questions.
24 */
25 package com.sun.glass.events.mac;
26
27 import java.lang.annotation.Native;
28 import java.util.Map;
29 import com.sun.glass.ui.Window;
30
31 // https://wiki.mozilla.org/NPAPI:CocoaEventModel
32
33 // used by Mac OS X impl for handling an NPAPI event sent from plugin to Glass process
34 public class NpapiEvent {
35
36 // draw
37 @Native final static public int NPCocoaEventDrawRect = 1;
38 // mouse
39 @Native final static public int NPCocoaEventMouseDown = 2;
40 @Native final static public int NPCocoaEventMouseUp = 3;
41 @Native final static public int NPCocoaEventMouseMoved = 4;
42 @Native final static public int NPCocoaEventMouseEntered = 5;
43 @Native final static public int NPCocoaEventMouseExited = 6;
44 @Native final static public int NPCocoaEventMouseDragged = 7;
45 // key
46 @Native final static public int NPCocoaEventKeyDown = 8;
47 @Native final static public int NPCocoaEventKeyUp = 9;
48 @Native final static public int NPCocoaEventFlagsChanged = 10;
49 // focus
50 @Native final static public int NPCocoaEventFocusChanged = 11;
51 @Native final static public int NPCocoaEventWindowFocusChanged = 12;
52 // mouse
53 @Native final static public int NPCocoaEventScrollWheel = 13;
54 // text input
55 @Native final static public int NPCocoaEventTextInput = 14;
56
57 private native static void _dispatchCocoaNpapiDrawEvent(long windowPtr, int type,
58 long context, double x, double y, double width, double height);
59 private native static void _dispatchCocoaNpapiMouseEvent(long windowPtr, int type,
60 int modifierFlags, double pluginX, double pluginY, int buttonNumber, int clickCount,
61 double deltaX, double deltaY, double deltaZ);
62 private native static void _dispatchCocoaNpapiKeyEvent(long windowPtr, int type,
63 int modifierFlags, String characters, String charactersIgnoringModifiers,
64 boolean isARepeat, int keyCode, boolean needsKeyTyped);
65 private native static void _dispatchCocoaNpapiFocusEvent(long windowPtr, int type,
66 boolean hasFocus);
67 private native static void _dispatchCocoaNpapiTextInputEvent(long windowPtr, int type,
68 String text);
69
70 final private static boolean getBoolean(Map eventInfo, String key) {
71 boolean value = false;
72 {
73 if (eventInfo.containsKey(key) == true ) {
74 try {
75 value = ((Boolean)eventInfo.get(key)).booleanValue();
|