提交 054e8f42 编写于 作者: C coffeys

Merge

/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
package sun.lwawt.macosx; package sun.lwawt.macosx;
import java.awt.geom.Rectangle2D;
public final class CWrapper { public final class CWrapper {
private CWrapper() { } private CWrapper() { }
...@@ -61,8 +59,6 @@ public final class CWrapper { ...@@ -61,8 +59,6 @@ public final class CWrapper {
public static native void addChildWindow(long parent, long child, int ordered); public static native void addChildWindow(long parent, long child, int ordered);
public static native void removeChildWindow(long parent, long child); public static native void removeChildWindow(long parent, long child);
public static native void setFrame(long window, int x, int y, int w, int h, boolean display);
public static native void setAlphaValue(long window, float alpha); public static native void setAlphaValue(long window, float alpha);
public static native void setOpaque(long window, boolean opaque); public static native void setOpaque(long window, boolean opaque);
public static native void setBackgroundColor(long window, long color); public static native void setBackgroundColor(long window, long color);
...@@ -80,7 +76,6 @@ public final class CWrapper { ...@@ -80,7 +76,6 @@ public final class CWrapper {
public static native void removeFromSuperview(long view); public static native void removeFromSuperview(long view);
public static native void setFrame(long view, int x, int y, int w, int h); public static native void setFrame(long view, int x, int y, int w, int h);
public static native Rectangle2D frame(long view);
public static native long window(long view); public static native long window(long view);
public static native void setHidden(long view, boolean hidden); public static native void setHidden(long view, boolean hidden);
...@@ -88,10 +83,6 @@ public final class CWrapper { ...@@ -88,10 +83,6 @@ public final class CWrapper {
public static native void setToolTip(long view, String msg); public static native void setToolTip(long view, String msg);
} }
public static final class NSObject {
public static native void release(long object);
}
public static final class NSColor { public static final class NSColor {
public static native long clearColor(); public static native long clearColor();
} }
......
/* /*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#import "CDragSource.h" #import "CDragSource.h"
#import "CDropTarget.h" #import "CDropTarget.h"
@interface AWTView : NSView<NSTextInputClient> { @interface AWTView : NSView<NSTextInputClient, CDragSourceHolder, CDropTargetHolder> {
@private @private
jobject m_cPlatformView; jobject m_cPlatformView;
...@@ -61,14 +61,8 @@ ...@@ -61,14 +61,8 @@
- (id) initWithRect:(NSRect) rect platformView:(jobject)cPlatformView windowLayer:(CALayer*)windowLayer; - (id) initWithRect:(NSRect) rect platformView:(jobject)cPlatformView windowLayer:(CALayer*)windowLayer;
- (void) deliverJavaMouseEvent: (NSEvent *) event; - (void) deliverJavaMouseEvent: (NSEvent *) event;
- (void) resetTrackingArea;
- (void) deliverJavaKeyEventHelper: (NSEvent *) event;
- (jobject) awtComponent:(JNIEnv *)env; - (jobject) awtComponent:(JNIEnv *)env;
- (void) setDragSource:(CDragSource *)source;
- (void) setDropTarget:(CDropTarget *)target;
// Input method-related events // Input method-related events
- (void)setInputMethod:(jobject)inputMethod; - (void)setInputMethod:(jobject)inputMethod;
- (void)abandonInput; - (void)abandonInput;
......
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -42,6 +42,10 @@ ...@@ -42,6 +42,10 @@
@interface AWTView() @interface AWTView()
@property (retain) CDropTarget *_dropTarget; @property (retain) CDropTarget *_dropTarget;
@property (retain) CDragSource *_dragSource; @property (retain) CDragSource *_dragSource;
-(void) deliverResize: (NSRect) rect;
-(void) resetTrackingArea;
-(void) deliverJavaKeyEventHelper: (NSEvent*) event;
@end @end
// Uncomment this line to see fprintfs of each InputMethod API being called on this View // Uncomment this line to see fprintfs of each InputMethod API being called on this View
......
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -29,9 +29,15 @@ ...@@ -29,9 +29,15 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#include <jni.h> #include <jni.h>
@class CDragSource;
@protocol CDragSourceHolder
- (void) setDragSource:(CDragSource *)source;
@end
@interface CDragSource : NSObject { @interface CDragSource : NSObject {
@private @private
NSView* fView; NSView<CDragSourceHolder>* fView;
jobject fComponent; jobject fComponent;
jobject fDragSourceContextPeer; jobject fDragSourceContextPeer;
...@@ -53,8 +59,6 @@ ...@@ -53,8 +59,6 @@
jint fDragMouseModifiers; jint fDragMouseModifiers;
} }
+ (CDragSource *) currentDragSource;
// Common methods: // Common methods:
- (id) init:(jobject)jDragSourceContextPeer - (id) init:(jobject)jDragSourceContextPeer
component:(jobject)jComponent component:(jobject)jComponent
...@@ -84,13 +88,6 @@ ...@@ -84,13 +88,6 @@
- (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenPoint; - (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenPoint;
- (BOOL)ignoreModifierKeysWhileDragging; - (BOOL)ignoreModifierKeysWhileDragging;
// Updates from the destination to the source
- (void) postDragEnter;
- (void) postDragExit;
// Utility
- (NSPoint) mapNSScreenPointToJavaWithOffset:(NSPoint) point;
@end @end
#endif // CDragSource_h #endif // CDragSource_h
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -75,14 +75,17 @@ JNF_CLASS_CACHE(CImageClass, "sun/lwawt/macosx/CImage"); ...@@ -75,14 +75,17 @@ JNF_CLASS_CACHE(CImageClass, "sun/lwawt/macosx/CImage");
static NSDragOperation sDragOperation; static NSDragOperation sDragOperation;
static NSPoint sDraggingLocation; static NSPoint sDraggingLocation;
static CDragSource* sCurrentDragSource;
static BOOL sNeedsEnter; static BOOL sNeedsEnter;
@implementation CDragSource @interface CDragSource ()
// Updates from the destination to the source
- (void) postDragEnter;
- (void) postDragExit;
// Utility
- (NSPoint) mapNSScreenPointToJavaWithOffset:(NSPoint) point;
@end
+ (CDragSource *) currentDragSource { @implementation CDragSource
return sCurrentDragSource;
}
- (id) init:(jobject)jDragSourceContextPeer - (id) init:(jobject)jDragSourceContextPeer
component:(jobject)jComponent component:(jobject)jComponent
...@@ -515,8 +518,6 @@ static BOOL sNeedsEnter; ...@@ -515,8 +518,6 @@ static BOOL sNeedsEnter;
fDragKeyModifiers = [DnDUtilities extractJavaExtKeyModifiersFromJavaExtModifiers:fModifiers]; fDragKeyModifiers = [DnDUtilities extractJavaExtKeyModifiersFromJavaExtModifiers:fModifiers];
fDragMouseModifiers = [DnDUtilities extractJavaExtMouseModifiersFromJavaExtModifiers:fModifiers]; fDragMouseModifiers = [DnDUtilities extractJavaExtMouseModifiersFromJavaExtModifiers:fModifiers];
// Set the current DragSource
sCurrentDragSource = self;
sNeedsEnter = YES; sNeedsEnter = YES;
@try { @try {
...@@ -566,8 +567,6 @@ static BOOL sNeedsEnter; ...@@ -566,8 +567,6 @@ static BOOL sNeedsEnter;
JNF_MEMBER_CACHE(resetHoveringMethod, CDragSourceContextPeerClass, "resetHovering", "()V"); JNF_MEMBER_CACHE(resetHoveringMethod, CDragSourceContextPeerClass, "resetHovering", "()V");
JNFCallVoidMethod(env, fDragSourceContextPeer, resetHoveringMethod); // Hust reset static variable JNFCallVoidMethod(env, fDragSourceContextPeer, resetHoveringMethod); // Hust reset static variable
} @finally { } @finally {
// Clear the current DragSource
sCurrentDragSource = nil;
sNeedsEnter = NO; sNeedsEnter = NO;
} }
......
/* /*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -31,9 +31,15 @@ ...@@ -31,9 +31,15 @@
@class ControlModel; @class ControlModel;
@class CDropTarget;
@protocol CDropTargetHolder
- (void) setDropTarget:(CDropTarget *)target;
@end
@interface CDropTarget : NSObject { @interface CDropTarget : NSObject {
@private @private
NSView* fView; NSView<CDropTargetHolder>* fView;
jobject fComponent; jobject fComponent;
jobject fDropTarget; jobject fDropTarget;
jobject fDropTargetContextPeer; jobject fDropTargetContextPeer;
......
/*
* Copyright (c) 2011, 2012, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* /*
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -23,37 +23,10 @@ ...@@ -23,37 +23,10 @@
* questions. * questions.
*/ */
#import "CWrapper.h"
#import <JavaNativeFoundation/JavaNativeFoundation.h> #import <JavaNativeFoundation/JavaNativeFoundation.h>
#import "AWTWindow.h"
#import "LWCToolkit.h"
#import "GeomUtilities.h"
#import "ThreadUtilities.h" #import "ThreadUtilities.h"
#import "sun_lwawt_macosx_CWrapper_NSWindow.h" #import "sun_lwawt_macosx_CWrapper_NSWindow.h"
/*
* Class: sun_lwawt_macosx_CWrapper$NSObject
* Method: release
* Signature: (J)V
*/
JNIEXPORT void JNICALL
Java_sun_lwawt_macosx_CWrapper_00024NSObject_release
(JNIEnv *env, jclass cls, jlong objectPtr)
{
JNF_COCOA_ENTER(env);
id obj = (id)jlong_to_ptr(objectPtr);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
CFRelease(obj);
}];
JNF_COCOA_EXIT(env);
}
/* /*
* Class: sun_lwawt_macosx_CWrapper$NSWindow * Class: sun_lwawt_macosx_CWrapper$NSWindow
* Method: makeKeyAndOrderFront * Method: makeKeyAndOrderFront
...@@ -309,8 +282,8 @@ Java_sun_lwawt_macosx_CWrapper_00024NSWindow_removeChildWindow ...@@ -309,8 +282,8 @@ Java_sun_lwawt_macosx_CWrapper_00024NSWindow_removeChildWindow
{ {
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
AWTWindow *parent = (AWTWindow *)jlong_to_ptr(parentPtr); NSWindow *parent = (NSWindow *)jlong_to_ptr(parentPtr);
AWTWindow *child = (AWTWindow *)jlong_to_ptr(childPtr); NSWindow *child = (NSWindow *)jlong_to_ptr(childPtr);
[ThreadUtilities performOnMainThread:@selector(removeChildWindow:) [ThreadUtilities performOnMainThread:@selector(removeChildWindow:)
on:parent on:parent
withObject:child withObject:child
...@@ -319,26 +292,6 @@ JNF_COCOA_ENTER(env); ...@@ -319,26 +292,6 @@ JNF_COCOA_ENTER(env);
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
} }
/*
* Class: sun_lwawt_macosx_CWrapper$NSWindow
* Method: setFrame
* Signature: (JIIIIZ)V
*/
JNIEXPORT void JNICALL
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setFrame
(JNIEnv *env, jclass cls, jlong windowPtr, jint x, jint y, jint w, jint h, jboolean display)
{
JNF_COCOA_ENTER(env);
AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
NSRect frame = NSMakeRect(x, y, w, h);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
[window setFrame:frame display:display];
}];
JNF_COCOA_EXIT(env);
}
/* /*
* Class: sun_lwawt_macosx_CWrapper$NSWindow * Class: sun_lwawt_macosx_CWrapper$NSWindow
* Method: setAlphaValue * Method: setAlphaValue
...@@ -350,7 +303,7 @@ Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setAlphaValue ...@@ -350,7 +303,7 @@ Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setAlphaValue
{ {
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
[window setAlphaValue:(CGFloat)alpha]; [window setAlphaValue:(CGFloat)alpha];
}]; }];
...@@ -369,7 +322,7 @@ Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setOpaque ...@@ -369,7 +322,7 @@ Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setOpaque
{ {
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
[window setOpaque:(BOOL)opaque]; [window setOpaque:(BOOL)opaque];
}]; }];
...@@ -388,7 +341,7 @@ Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setBackgroundColor ...@@ -388,7 +341,7 @@ Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setBackgroundColor
{ {
JNF_COCOA_ENTER(env); JNF_COCOA_ENTER(env);
AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr); NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
NSColor *color = (NSColor *)jlong_to_ptr(colorPtr); NSColor *color = (NSColor *)jlong_to_ptr(colorPtr);
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){ [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
[window setBackgroundColor:color]; [window setBackgroundColor:color];
...@@ -398,6 +351,7 @@ JNF_COCOA_EXIT(env); ...@@ -398,6 +351,7 @@ JNF_COCOA_EXIT(env);
} }
/* /*
* Class: sun_lwawt_macosx_CWrapper$NSWindow
* Method: miniaturize * Method: miniaturize
* Signature: (J)V * Signature: (J)V
*/ */
...@@ -559,33 +513,6 @@ JNF_COCOA_ENTER(env); ...@@ -559,33 +513,6 @@ JNF_COCOA_ENTER(env);
JNF_COCOA_EXIT(env); JNF_COCOA_EXIT(env);
} }
/*
* Class: sun_lwawt_macosx_CWrapper$NSView
* Method: frame
* Signature: (J)Ljava/awt/Rectangle;
*/
JNIEXPORT jobject JNICALL
Java_sun_lwawt_macosx_CWrapper_00024NSView_frame
(JNIEnv *env, jclass cls, jlong viewPtr)
{
jobject jRect = NULL;
JNF_COCOA_ENTER(env);
__block NSRect rect = NSZeroRect;
NSView *view = (NSView *)jlong_to_ptr(viewPtr);
[ThreadUtilities performOnMainThreadWaiting:YES block:^(){
rect = [view frame];
}];
jRect = NSToJavaRect(env, rect);
JNF_COCOA_EXIT(env);
return jRect;
}
/* /*
* Class: sun_lwawt_macosx_CWrapper$NSView * Class: sun_lwawt_macosx_CWrapper$NSView
* Method: window * Method: window
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册