/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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.
*/
#import "CGLGraphicsConfig.h"
#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
#import "ThreadUtilities.h"
#import "AWTView.h"
#import "AWTEvent.h"
#import "AWTWindow.h"
#import "LWCToolkit.h"
#import "JavaComponentAccessibility.h"
#import "JavaTextAccessibility.h"
#import "GeomUtilities.h"
#import "OSVersion.h"
#import "CGLLayer.h"
@interface AWTView()
@end
// Uncomment this line to see fprintfs of each InputMethod API being called on this View
//#define IM_DEBUG TRUE
//#define EXTRA_DEBUG
static BOOL shouldUsePressAndHold() {
static int shouldUsePressAndHold = -1;
return shouldUsePressAndHold;
}
// Note: Must be called on main (AppKit) thread only
{
// Initialize ourselves
mouseIsOver = NO;
if (windowLayer != nil) {
//Layer hosting view
//Layer backed view
//[self.layer addSublayer: (CALayer *)cglLayer];
//[self setLayerContentsRedrawPolicy: NSViewLayerContentsRedrawDuringViewResize];
//[self setLayerContentsPlacement: NSViewLayerContentsPlacementTopLeft];
//[self setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
}
#endif /* REMOTELAYER */
}
return self;
}
- (void) dealloc {
if (fInputMethodLOCKABLE != NULL)
{
}
[super dealloc];
}
- (void) viewDidMoveToWindow {
}];
}
}
return YES;
}
- (BOOL) acceptsFirstResponder {
return YES;
}
- (BOOL) becomeFirstResponder {
return YES;
}
return YES;
}
/*
* Automatically triggered functions.
*/
[super resizeWithOldSuperviewSize: oldBoundsSize];
}
/*
* MouseEvents support
*/
if ([inputManager wantsToHandleMouseEvents]) {
#if IM_DEBUG
NSLog(@"-> IM wants to handle event");
} else {
#if IM_DEBUG
NSLog(@"-> Event was handled.");
}
} else {
#if IM_DEBUG
NSLog(@"-> IM does not want to handle event");
}
}
}
}
}
}
}
// TODO: better way to redirect move events to the "under" view
} else {
}
}
}
}
}
//[[self window] makeFirstResponder:self];
}
//Restore the cursor back.
//[CCursorManager _setCursor: [NSCursor arrowCursor]];
}
}
/*
* KeyEvents support
*/
// Allow TSM to look at the event and potentially send back NSTextInputClient messages.
if (!fInPressAndHold) {
}
return;
}
}
}
}
}
return NO;
}
/**
* Utility methods and accessors
*/
if ([window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]]) {
}
if (!isEnabled) {
return;
}
return;
}
// Convert global numbers between Cocoa's coordinate system and Java.
// TODO: need consitent way for doing that both with global as well as with local coordinates.
// The reason to do it here is one more native method for getting screen dimension otherwise.
if (type == NSMouseEntered ||
type == NSMouseExited ||
type == NSScrollWheel ||
type == NSMouseMoved) {
clickCount = 0;
} else {
}
// Unable to create event by some reason.
return;
}
static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/event/NSEvent;)V");
}
- (void) clearTrackingRect {
if (rolloverTrackingRectTag > 0) {
}
}
- (void) resetTrackingRect {
}
- (void)updateTrackingAreas {
[super updateTrackingAreas];
}
- (void) resetCursorRects {
[super resetCursorRects];
}
if (event == sLastKeyEvent) {
// The event is repeatedly delivered by keyDown: after performKeyEquivalent:
return;
}
}
if (characters != NULL) {
}
}
}
/*
if ([self inLiveResize]) {
NSRect rs[4];
NSInteger count;
[self getRectsExposedDuringLiveResize:rs count:&count];
for (int i = 0; i < count; i++) {
JNU_CallMethodByName(env, NULL, [m_awtWindow cPlatformView],
"deliverWindowDidExposeEvent", "(FFFF)V",
(jfloat)rs[i].origin.x, (jfloat)rs[i].origin.y,
(jfloat)rs[i].size.width, (jfloat)rs[i].size.height);
if ((*env)->ExceptionOccurred(env)) {
(*env)->ExceptionDescribe(env);
(*env)->ExceptionClear(env);
}
}
} else {
*/
static JNF_MEMBER_CACHE(jm_deliverWindowDidExposeEvent, jc_CPlatformView, "deliverWindowDidExposeEvent", "()V");
/*
}
*/
}
}
// NSAccessibility support
{
NSLog(@"Apple AWT : Error AWTView:awtComponent given bad parameters.");
{
}
return NULL;
}
NSLog(@"Apple AWT : Error AWTView:awtComponent got null peer from CPlatformView");
return NULL;
}
}
{
return [[[JavaComponentAccessibility alloc] initWithParent:self withEnv:env withAccessible:[self awtComponent:env] withIndex:-1 withView:self withJavaRole:nil] autorelease];
}
{
}
// NSAccessibility messages
// attribute methods
{
{
return result;
}
else
{
return [super accessibilityAttributeValue:attribute];
}
}
{
return YES;
}
{
return result;
}
{
return result;
}
// --- Services menu support for lightweights ---
// finds the focused accessable element, and if it's a text element, obtains the text from it
{
}
// same as above, but converts to RTFD
{
NSData *rtfdData = [styledText RTFDFromRange:NSMakeRange(0, [styledText length]) documentAttributes:nil];
return rtfdData;
}
// finds the focused accessable element, and if it's a text element, sets the text in it
{
return YES;
}
// called for each service in the Services menu - only handle text for now
{
if (selectedText) return self;
}
return nil;
}
// fetch text from Java and hand off to the service
{
{
}
{
}
return NO;
}
// write text back to Java from the service
{
{
}
{
NSAttributedString *styledText = [[NSAttributedString alloc] initWithRTFD:rtfdData documentAttributes:nil];
}
return NO;
}
}
[ThreadUtilities performOnMainThread:@selector(controlModelControlValid) on:self._dropTarget withObject:nil waitUntilDone:YES];
}
/******************************** BEGIN NSDraggingSource Interface ********************************/
{
// If draggingSource is nil route the message to the superclass (if responding to the selector):
if (dragSource != nil)
return dragOp;
}
{
// If draggingSource is nil route the message to the superclass (if responding to the selector):
if (dragSource != nil)
return array;
}
{
// If draggingSource is nil route the message to the superclass (if responding to the selector):
if (dragSource != nil)
}
- (void)draggedImage:(NSImage *)image endedAt:(NSPoint)screenPoint operation:(NSDragOperation)operation
{
// If draggingSource is nil route the message to the superclass (if responding to the selector):
if (dragSource != nil)
}
{
// If draggingSource is nil route the message to the superclass (if responding to the selector):
if (dragSource != nil)
}
{
// If draggingSource is nil route the message to the superclass (if responding to the selector):
if (dragSource != nil)
result = [super ignoreModifierKeysWhileDragging];
return result;
}
/******************************** END NSDraggingSource Interface ********************************/
/******************************** BEGIN NSDraggingDestination Interface ********************************/
{
// If draggingDestination is nil route the message to the superclass:
if (dropTarget != nil)
return dragOp;
}
{
// If draggingDestination is nil route the message to the superclass:
if (dropTarget != nil)
return dragOp;
}
{
// If draggingDestination is nil route the message to the superclass:
if (dropTarget != nil)
[super draggingExited:sender];
}
{
// If draggingDestination is nil route the message to the superclass:
if (dropTarget != nil)
return result;
}
{
// If draggingDestination is nil route the message to the superclass:
if (dropTarget != nil)
return result;
}
{
// If draggingDestination is nil route the message to the superclass:
if (dropTarget != nil)
[super concludeDragOperation:sender];
}
{
// If draggingDestination is nil route the message to the superclass:
if (dropTarget != nil)
[super draggingEnded:sender];
}
/******************************** END NSDraggingDestination Interface ********************************/
/******************************** BEGIN NSTextInputClient Protocol ********************************/
{
#endif // IM_DEBUG
if (fInputMethodLOCKABLE == NULL) {
return;
}
// Insert happens at the end of PAH
// insertText gets called when the user commits text generated from an input method. It also gets
// called during ordinary input as well. We only need to send an input method event when we have marked
// text, or 'text in progress'. We also need to send the event if we get an insert text out of the blue!
// (i.e., when the user uses the Character palette or Inkwell), or when the string to insert is a complex
// Unicode value.
// We need to select the previous glyph so that it is overwritten.
if (fPAHNeedsToSelect) {
}
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText); // AWT_THREADING Safe (AWTRunLoopMode)
// The input method event will create psuedo-key events for each character in the committed string.
// We also don't want to send the character that triggered the insertText, usually a return. [3337563]
}
}
{
#endif // IM_DEBUG
if (@selector(insertNewline:) == aSelector || @selector(insertTab:) == aSelector || @selector(deleteBackward:) == aSelector)
{
}
}
// setMarkedText: cannot take a nil first argument. aString can be NSString or NSAttributedString
- (void) setMarkedText:(id)aString selectedRange:(NSRange)selectionRange replacementRange:(NSRange)replacementRange
{
if (!fInputMethodLOCKABLE)
return;
fprintf(stderr, "AWTView InputMethod Selector Called : [setMarkedText] \"%s\", loc=%lu, length=%lu\n", [incomingString UTF8String], (unsigned long)selectionRange.location, (unsigned long)selectionRange.length);
#endif // IM_DEBUG
static JNF_MEMBER_CACHE(jm_startIMUpdate, jc_CInputMethod, "startIMUpdate", "(Ljava/lang/String;)V");
// NSInputContext already did the analysis of the TSM event and created attributes indicating
// the underlining and color that should be done to the string. We need to look at the underline
// style and color to determine what kind of Java hilighting needs to be done.
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_startIMUpdate, inProcessText); // AWT_THREADING Safe (AWTRunLoopMode)
if (isAttributedString) {
if (attributes) {
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_addAttribute, isThickUnderline, isGray, effectiveRange.location, effectiveRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
}
}
}
// We need to select the previous glyph so that it is overwritten.
if (fPAHNeedsToSelect) {
}
JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_dispatchText, selectionRange.location, selectionRange.length, JNI_FALSE); // AWT_THREADING Safe (AWTRunLoopMode)
// If the marked text is being cleared (zero-length string) don't handle the key event.
}
}
- (void) unmarkText
{
#endif // IM_DEBUG
if (!fInputMethodLOCKABLE) {
return;
}
// unmarkText cancels any input in progress and commits it to the text field.
}
- (BOOL) hasMarkedText
{
#endif // IM_DEBUG
if (!fInputMethodLOCKABLE) {
return NO;
}
static JNF_MEMBER_CACHE(jf_fCurrentText, jc_CInputMethod, "fCurrentText", "Ljava/text/AttributedString;");
if (currentText != NULL) {
}
return hasMarkedText;
}
{
#endif // IM_DEBUG
}
/* Returns attributed string at the range. This allows input mangers to
query any range in backing-store (Andy's request)
*/
- (NSAttributedString *) attributedSubstringForProposedRange:(NSRange)theRange actualRange:(NSRangePointer)actualRange
{
fprintf(stderr, "AWTView InputMethod Selector Called : [attributedSubstringFromRange] location=%lu, length=%lu\n", (unsigned long)theRange.location, (unsigned long)theRange.length);
#endif // IM_DEBUG
static JNF_MEMBER_CACHE(jm_substringFromRange, jc_CInputMethod, "attributedSubstringFromRange", "(II)Ljava/lang/String;");
jobject theString = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_substringFromRange, theRange.location, theRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
id result = [[[NSAttributedString alloc] initWithString:JNFJavaToNSString(env, theString)] autorelease];
#endif // IM_DEBUG
return result;
}
/* This method returns the range for marked region. If hasMarkedText == false,
it'll return NSNotFound location & 0 length range.
*/
- (NSRange) markedRange
{
#endif // IM_DEBUG
if (!fInputMethodLOCKABLE) {
}
array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_markedRange); // AWT_THREADING Safe (AWTRunLoopMode)
if (array) {
fprintf(stderr, "markedRange returning (%lu, %lu)\n", (unsigned long)range.location, (unsigned long)range.length);
#endif // IM_DEBUG
} else {
}
return range;
}
/* This method returns the range for selected region. Just like markedRange method,
its location field contains char index from the text beginning.
*/
- (NSRange) selectedRange
{
if (!fInputMethodLOCKABLE) {
}
#endif // IM_DEBUG
array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_selectedRange); // AWT_THREADING Safe (AWTRunLoopMode)
if (array) {
} else {
}
return range;
}
/* This method returns the first frame of rects for theRange in screen coordindate system.
*/
{
if (!fInputMethodLOCKABLE) {
}
"firstRectForCharacterRange", "(I)[I");
fprintf(stderr, "AWTView InputMethod Selector Called : [firstRectForCharacterRange:] location=%lu, length=%lu\n", (unsigned long)theRange.location, (unsigned long)theRange.length);
#endif // IM_DEBUG
array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_firstRectForCharacterRange, theRange.location); // AWT_THREADING Safe (AWTRunLoopMode)
fprintf(stderr, "firstRectForCharacterRange returning x=%f, y=%f, width=%f, height=%f\n", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
#endif // IM_DEBUG
return rect;
}
/* This method returns the index for character that is nearest to thePoint. thPoint is in
screen coordinate system.
*/
{
if (!fInputMethodLOCKABLE) {
return NSNotFound;
}
"characterIndexForPoint", "(II)I");
fprintf(stderr, "AWTView InputMethod Selector Called : [characterIndexForPoint:(NSPoint)thePoint] x=%f, y=%f\n", flippedLocation.x, flippedLocation.y);
#endif // IM_DEBUG
jint index = JNFCallIntMethod(env, fInputMethodLOCKABLE, jm_characterIndexForPoint, (jint)flippedLocation.x, (jint)flippedLocation.y); // AWT_THREADING Safe (AWTRunLoopMode)
#endif // IM_DEBUG
if (index == -1) {
return NSNotFound;
} else {
return (NSUInteger)index;
}
}
{
#endif // IM_DEBUG
}
{
#endif // IM_DEBUG
// Get rid of the old one
if (fInputMethodLOCKABLE) {
}
// Save a global ref to the new input method.
if (inputMethod != NULL)
else
}
- (void)abandonInput
{
#endif // IM_DEBUG
[ThreadUtilities performOnMainThread:@selector(markedTextAbandoned:) on:[NSInputManager currentInputManager] withObject:self waitUntilDone:YES];
[self unmarkText];
}
/******************************** END NSTextInputClient Protocol ********************************/
@end // AWTView
/*
* Class: sun_lwawt_macosx_CPlatformView
* Method: nativeCreateView
* Signature: (IIII)J
*/
(JNIEnv *env, jobject obj, jint originX, jint originY, jint width, jint height, jlong windowLayerPtr)
{
}];
return ptr_to_jlong(newView);
}
/*
* Class: sun_lwawt_macosx_CPlatformView
* Method: nativeSetAutoResizable
* Signature: (JZ)V;
*/
{
if (toResize) {
} else {
}
}
}];
}
/*
* Class: sun_lwawt_macosx_CPlatformView
* Method: nativeGetNSViewDisplayID
* Signature: (J)I;
*/
{
}];
return ret;
}
/*
* Class: sun_lwawt_macosx_CPlatformView
* Method: nativeGetLocationOnScreen
*/
{
//Convert coordinates to top-left corner origin
}];
return jRect;
}
/*
* Class: sun_lwawt_macosx_CPlatformView
* Method: nativeIsViewUnderMouse
* Signature: (J)Z;
*/
{
}];
return underMouse;
}