jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTView.m
author alexsch
Wed, 05 Oct 2016 18:29:18 +0400
changeset 41773 58254fa6487a
parent 39551 7eaf6bb9bc67
child 43823 bf04b9310757
permissions -rw-r--r--
8166591: [macos 10.12] Trackpad scrolling of text on OS X 10.12 Sierra is very fast (Trackpad, Retina only) Reviewed-by: malenkov, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     1
/*
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     4
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    10
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    15
 * accompanied this code).
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    16
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    20
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    23
 * questions.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    24
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    25
32872
abca6234313d 8079965: Stop ignoring warnings for libawt_lwawt
serb
parents: 32427
diff changeset
    26
#import "jni_util.h"
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    27
#import "CGLGraphicsConfig.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    28
#import "AWTView.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    29
#import "AWTWindow.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    30
#import "JavaComponentAccessibility.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    31
#import "JavaTextAccessibility.h"
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
    32
#import "JavaAccessibilityUtilities.h"
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    33
#import "GeomUtilities.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    34
#import "OSVersion.h"
32872
abca6234313d 8079965: Stop ignoring warnings for libawt_lwawt
serb
parents: 32427
diff changeset
    35
#import "ThreadUtilities.h"
abca6234313d 8079965: Stop ignoring warnings for libawt_lwawt
serb
parents: 32427
diff changeset
    36
abca6234313d 8079965: Stop ignoring warnings for libawt_lwawt
serb
parents: 32427
diff changeset
    37
#import <JavaNativeFoundation/JavaNativeFoundation.h>
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    38
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    39
@interface AWTView()
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    40
@property (retain) CDropTarget *_dropTarget;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    41
@property (retain) CDragSource *_dragSource;
23255
ebd69e3d93c5 8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents: 21278
diff changeset
    42
ebd69e3d93c5 8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents: 21278
diff changeset
    43
-(void) deliverResize: (NSRect) rect;
ebd69e3d93c5 8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents: 21278
diff changeset
    44
-(void) resetTrackingArea;
ebd69e3d93c5 8027561: [macosx] Cleanup "may not respond to selector" warnings in native code
pchelko
parents: 21278
diff changeset
    45
-(void) deliverJavaKeyEventHelper: (NSEvent*) event;
33858
7554d0e25d7f 8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents: 32872
diff changeset
    46
-(BOOL) isCodePointInUnicodeBlockNeedingIMEvent: (unichar) codePoint;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
    47
-(NSMutableString *) parseString : (id) complexString;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    48
@end
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    49
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    50
// Uncomment this line to see fprintfs of each InputMethod API being called on this View
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    51
//#define IM_DEBUG TRUE
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    52
//#define EXTRA_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    53
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    54
static BOOL shouldUsePressAndHold() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    55
    static int shouldUsePressAndHold = -1;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    56
    if (shouldUsePressAndHold != -1) return shouldUsePressAndHold;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    57
    shouldUsePressAndHold = !isSnowLeopardOrLower();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    58
    return shouldUsePressAndHold;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    59
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    60
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    61
@implementation AWTView
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    62
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    63
@synthesize _dropTarget;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    64
@synthesize _dragSource;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    65
@synthesize cglLayer;
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12178
diff changeset
    66
@synthesize mouseIsOver;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    67
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    68
// Note: Must be called on main (AppKit) thread only
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    69
- (id) initWithRect: (NSRect) rect
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    70
       platformView: (jobject) cPlatformView
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
    71
        windowLayer: (CALayer*) windowLayer
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    72
{
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
    73
    AWT_ASSERT_APPKIT_THREAD;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    74
    // Initialize ourselves
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    75
    self = [super initWithFrame: rect];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    76
    if (self == nil) return self;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
    77
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    78
    m_cPlatformView = cPlatformView;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    79
    fInputMethodLOCKABLE = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    80
    fKeyEventsNeeded = NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    81
    fProcessingKeystroke = NO;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
    82
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    83
    fEnablePressAndHold = shouldUsePressAndHold();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    84
    fInPressAndHold = NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    85
    fPAHNeedsToSelect = NO;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
    86
    
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12178
diff changeset
    87
    mouseIsOver = NO;
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
    88
    [self resetTrackingArea];
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
    89
    [self setAutoresizesSubviews:NO];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
    90
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    91
    if (windowLayer != nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    92
        self.cglLayer = windowLayer;
14306
8d823e84507a 7198229: Painting during resizing of the frame should be more smooth
serb
parents: 13990
diff changeset
    93
        //Layer hosting view
8d823e84507a 7198229: Painting during resizing of the frame should be more smooth
serb
parents: 13990
diff changeset
    94
        [self setLayer: cglLayer];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    95
        [self setWantsLayer: YES];
14306
8d823e84507a 7198229: Painting during resizing of the frame should be more smooth
serb
parents: 13990
diff changeset
    96
        //Layer backed view
8d823e84507a 7198229: Painting during resizing of the frame should be more smooth
serb
parents: 13990
diff changeset
    97
        //[self.layer addSublayer: (CALayer *)cglLayer];
8d823e84507a 7198229: Painting during resizing of the frame should be more smooth
serb
parents: 13990
diff changeset
    98
        //[self setLayerContentsRedrawPolicy: NSViewLayerContentsRedrawDuringViewResize];
8d823e84507a 7198229: Painting during resizing of the frame should be more smooth
serb
parents: 13990
diff changeset
    99
        //[self setLayerContentsPlacement: NSViewLayerContentsPlacementTopLeft];
8d823e84507a 7198229: Painting during resizing of the frame should be more smooth
serb
parents: 13990
diff changeset
   100
        //[self setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   101
        
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   102
#ifdef REMOTELAYER
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   103
        CGLLayer *parentLayer = (CGLLayer*)self.cglLayer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   104
        parentLayer.parentLayer = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   105
        parentLayer.remoteLayer = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   106
        if (JRSRemotePort != 0 && remoteSocketFD > 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   107
            CGLLayer *remoteLayer = [[CGLLayer alloc] initWithJavaLayer: parentLayer.javaLayer];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   108
            remoteLayer.target = GL_TEXTURE_2D;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   109
            NSLog(@"Creating Parent=%p, Remote=%p", parentLayer, remoteLayer);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   110
            parentLayer.remoteLayer = remoteLayer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   111
            remoteLayer.parentLayer = parentLayer;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   112
            remoteLayer.remoteLayer = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   113
            remoteLayer.jrsRemoteLayer = [remoteLayer createRemoteLayerBoundTo:JRSRemotePort];
23651
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23625
diff changeset
   114
            [remoteLayer retain];  // REMIND
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   115
            remoteLayer.frame = CGRectMake(0, 0, 720, 500); // REMIND
23651
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23625
diff changeset
   116
            [remoteLayer.jrsRemoteLayer retain]; // REMIND
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   117
            int layerID = [remoteLayer.jrsRemoteLayer layerID];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   118
            NSLog(@"layer id to send = %d", layerID);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   119
            sendLayerID(layerID);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   120
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   121
#endif /* REMOTELAYER */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   122
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   123
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   124
    return self;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   125
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   126
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   127
- (void) dealloc {
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   128
    AWT_ASSERT_APPKIT_THREAD;
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   129
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   130
    self.cglLayer = nil;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   131
    
20139
53e1e07a811e 8024779: [macosx] SwingNode crashes on exit
pchelko
parents: 20134
diff changeset
   132
    JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   133
    (*env)->DeleteWeakGlobalRef(env, m_cPlatformView);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   134
    m_cPlatformView = NULL;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   135
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   136
    if (fInputMethodLOCKABLE != NULL)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   137
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   138
        JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   139
        
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   140
        JNFDeleteGlobalRef(env, fInputMethodLOCKABLE);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   141
        fInputMethodLOCKABLE = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   142
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   143
    
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   144
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   145
    [super dealloc];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   146
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   147
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   148
- (void) viewDidMoveToWindow {
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   149
    AWT_ASSERT_APPKIT_THREAD;
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   150
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   151
    [AWTToolkit eventCountPlusPlus];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   152
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   153
    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   154
        [[self window] makeFirstResponder: self];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   155
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   156
    if ([self window] != NULL) {
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
   157
        [self resetTrackingArea];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   158
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   159
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   160
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   161
- (BOOL) acceptsFirstMouse: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   162
    return YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   163
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   164
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   165
- (BOOL) acceptsFirstResponder {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   166
    return YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   167
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   168
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   169
- (BOOL) becomeFirstResponder {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   170
    return YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   171
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   172
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   173
- (BOOL) preservesContentDuringLiveResize {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   174
    return YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   175
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   176
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   177
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   178
 * Automatically triggered functions.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   179
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   180
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   181
- (void)resizeWithOldSuperviewSize:(NSSize)oldBoundsSize {
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   182
    [super resizeWithOldSuperviewSize: oldBoundsSize];
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   183
    [self deliverResize: [self frame]];
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   184
}
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   185
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   186
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   187
 * MouseEvents support
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   188
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   189
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   190
- (void) mouseDown: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   191
    NSInputManager *inputManager = [NSInputManager currentInputManager];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   192
    if ([inputManager wantsToHandleMouseEvents]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   193
#if IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   194
        NSLog(@"-> IM wants to handle event");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   195
#endif
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   196
        if (![inputManager handleMouseEvent:event]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   197
            [self deliverJavaMouseEvent: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   198
        } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   199
#if IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   200
            NSLog(@"-> Event was handled.");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   201
#endif
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   202
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   203
    } else {
13007
f6bf3300b455 7172430: [macosx] debug message in non debug jdk build
kizune
parents: 12660
diff changeset
   204
#if IM_DEBUG
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   205
        NSLog(@"-> IM does not want to handle event");
13007
f6bf3300b455 7172430: [macosx] debug message in non debug jdk build
kizune
parents: 12660
diff changeset
   206
#endif
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   207
        [self deliverJavaMouseEvent: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   208
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   209
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   210
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   211
- (void) mouseUp: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   212
    [self deliverJavaMouseEvent: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   213
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   214
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   215
- (void) rightMouseDown: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   216
    [self deliverJavaMouseEvent: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   217
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   218
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   219
- (void) rightMouseUp: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   220
    [self deliverJavaMouseEvent: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   221
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   222
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   223
- (void) otherMouseDown: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   224
    [self deliverJavaMouseEvent: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   225
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   226
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   227
- (void) otherMouseUp: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   228
    [self deliverJavaMouseEvent: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   229
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   230
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   231
- (void) mouseMoved: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   232
    // TODO: better way to redirect move events to the "under" view
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   233
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   234
    NSPoint eventLocation = [event locationInWindow];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   235
    NSPoint localPoint = [self convertPoint: eventLocation fromView: nil];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   236
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   237
    if  ([self mouse: localPoint inRect: [self bounds]]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   238
        [self deliverJavaMouseEvent: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   239
    } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   240
        [[self nextResponder] mouseDown:event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   241
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   242
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   243
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   244
- (void) mouseDragged: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   245
    [self deliverJavaMouseEvent: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   246
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   247
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   248
- (void) rightMouseDragged: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   249
    [self deliverJavaMouseEvent: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   250
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   251
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   252
- (void) otherMouseDragged: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   253
    [self deliverJavaMouseEvent: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   254
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   255
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   256
- (void) mouseEntered: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   257
    [[self window] setAcceptsMouseMovedEvents:YES];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   258
    //[[self window] makeFirstResponder:self];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   259
    [self deliverJavaMouseEvent: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   260
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   261
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   262
- (void) mouseExited: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   263
    [[self window] setAcceptsMouseMovedEvents:NO];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   264
    [self deliverJavaMouseEvent: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   265
    //Restore the cursor back.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   266
    //[CCursorManager _setCursor: [NSCursor arrowCursor]];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   267
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   268
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   269
- (void) scrollWheel: (NSEvent*) event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   270
    [self deliverJavaMouseEvent: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   271
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   272
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   273
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   274
 * KeyEvents support
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   275
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   276
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   277
- (void) keyDown: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   278
    fProcessingKeystroke = YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   279
    fKeyEventsNeeded = YES;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   280
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   281
    // Allow TSM to look at the event and potentially send back NSTextInputClient messages.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   282
    [self interpretKeyEvents:[NSArray arrayWithObject:event]];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   283
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   284
    if (fEnablePressAndHold && [event willBeHandledByComplexInputMethod]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   285
        fProcessingKeystroke = NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   286
        if (!fInPressAndHold) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   287
            fInPressAndHold = YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   288
            fPAHNeedsToSelect = YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   289
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   290
        return;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   291
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   292
    
13990
3e72145fd93a 7199180: [macosx] Dead keys handling for input methods
alexsch
parents: 13647
diff changeset
   293
    NSString *eventCharacters = [event characters];
3e72145fd93a 7199180: [macosx] Dead keys handling for input methods
alexsch
parents: 13647
diff changeset
   294
    BOOL isDeadKey = (eventCharacters != nil && [eventCharacters length] == 0);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   295
    
13990
3e72145fd93a 7199180: [macosx] Dead keys handling for input methods
alexsch
parents: 13647
diff changeset
   296
    if ((![self hasMarkedText] && fKeyEventsNeeded) || isDeadKey) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   297
        [self deliverJavaKeyEventHelper: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   298
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   299
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   300
    fProcessingKeystroke = NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   301
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   302
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   303
- (void) keyUp: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   304
    [self deliverJavaKeyEventHelper: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   305
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   306
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   307
- (void) flagsChanged: (NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   308
    [self deliverJavaKeyEventHelper: event];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   309
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   310
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   311
- (BOOL) performKeyEquivalent: (NSEvent *) event {
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   312
    // if IM is active key events should be ignored
29727
34e49b091c62 8073008: press-and-hold input method for accented characters works incorrectly on OS X
anashaty
parents: 28990
diff changeset
   313
    if (![self hasMarkedText] && !fInPressAndHold) {
34e49b091c62 8073008: press-and-hold input method for accented characters works incorrectly on OS X
anashaty
parents: 28990
diff changeset
   314
        [self deliverJavaKeyEventHelper: event];
34e49b091c62 8073008: press-and-hold input method for accented characters works incorrectly on OS X
anashaty
parents: 28990
diff changeset
   315
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   316
    
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   317
    // Workaround for 8020209: special case for "Cmd =" and "Cmd ."
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   318
    // because Cocoa calls performKeyEquivalent twice for these keystrokes
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   319
    NSUInteger modFlags = [event modifierFlags] &
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   320
    (NSCommandKeyMask | NSAlternateKeyMask | NSShiftKeyMask | NSControlKeyMask);
21268
b3298f607368 8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents: 20139
diff changeset
   321
    if (modFlags == NSCommandKeyMask) {
b3298f607368 8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents: 20139
diff changeset
   322
        NSString *eventChars = [event charactersIgnoringModifiers];
b3298f607368 8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents: 20139
diff changeset
   323
        if ([eventChars length] == 1) {
b3298f607368 8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents: 20139
diff changeset
   324
            unichar ch = [eventChars characterAtIndex:0];
b3298f607368 8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents: 20139
diff changeset
   325
            if (ch == '=' || ch == '.') {
b3298f607368 8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents: 20139
diff changeset
   326
                [[NSApp mainMenu] performKeyEquivalent: event];
b3298f607368 8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents: 20139
diff changeset
   327
                return YES;
b3298f607368 8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents: 20139
diff changeset
   328
            }
b3298f607368 8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents: 20139
diff changeset
   329
        }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   330
        
21268
b3298f607368 8020209: [macosx] Mac OS X key event confusion for "COMMAND PLUS"
leonidr
parents: 20139
diff changeset
   331
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   332
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   333
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   334
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   335
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   336
/**
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   337
 * Utility methods and accessors
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   338
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   339
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   340
-(void) deliverJavaMouseEvent: (NSEvent *) event {
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   341
    BOOL isEnabled = YES;
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   342
    NSWindow* window = [self window];
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   343
    if ([window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]]) {
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   344
        isEnabled = [(AWTWindow*)[window delegate] isEnabled];
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   345
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   346
    
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   347
    if (!isEnabled) {
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   348
        return;
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   349
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   350
    
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   351
    NSEventType type = [event type];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   352
    
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12178
diff changeset
   353
    // check synthesized mouse entered/exited events
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12178
diff changeset
   354
    if ((type == NSMouseEntered && mouseIsOver) || (type == NSMouseExited && !mouseIsOver)) {
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12178
diff changeset
   355
        return;
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12178
diff changeset
   356
    }else if ((type == NSMouseEntered && !mouseIsOver) || (type == NSMouseExited && mouseIsOver)) {
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12178
diff changeset
   357
        mouseIsOver = !mouseIsOver;
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12178
diff changeset
   358
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   359
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   360
    [AWTToolkit eventCountPlusPlus];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   361
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   362
    JNIEnv *env = [ThreadUtilities getJNIEnv];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   363
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   364
    NSPoint eventLocation = [event locationInWindow];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   365
    NSPoint localPoint = [self convertPoint: eventLocation fromView: nil];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   366
    NSPoint absP = [NSEvent mouseLocation];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   367
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   368
    // Convert global numbers between Cocoa's coordinate system and Java.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   369
    // TODO: need consitent way for doing that both with global as well as with local coordinates.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   370
    // The reason to do it here is one more native method for getting screen dimension otherwise.
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   371
    
23316
e14d8640b158 8017472: [macosx] Transparency demo is not correctly dragged on the second monitor
azvegint
parents: 23268
diff changeset
   372
    NSRect screenRect = [[[NSScreen screens] objectAtIndex:0] frame];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   373
    absP.y = screenRect.size.height - absP.y;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   374
    jint clickCount;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   375
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   376
    if (type == NSMouseEntered ||
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   377
        type == NSMouseExited ||
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   378
        type == NSScrollWheel ||
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   379
        type == NSMouseMoved) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   380
        clickCount = 0;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   381
    } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   382
        clickCount = [event clickCount];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   383
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   384
    
23268
2cdb715ff32d 8029868: Fix KSS issues in sun.lwawt.macosx
pchelko
parents: 23255
diff changeset
   385
    static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
41773
58254fa6487a 8166591: [macos 10.12] Trackpad scrolling of text on OS X 10.12 Sierra is very fast (Trackpad, Retina only)
alexsch
parents: 39551
diff changeset
   386
    static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IIIIIIIIDDI)V");
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   387
    jobject jEvent = JNFNewObject(env, jctor_NSEvent,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   388
                                  [event type],
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   389
                                  [event modifierFlags],
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   390
                                  clickCount,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   391
                                  [event buttonNumber],
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   392
                                  (jint)localPoint.x, (jint)localPoint.y,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   393
                                  (jint)absP.x, (jint)absP.y,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   394
                                  [event deltaY],
41773
58254fa6487a 8166591: [macos 10.12] Trackpad scrolling of text on OS X 10.12 Sierra is very fast (Trackpad, Retina only)
alexsch
parents: 39551
diff changeset
   395
                                  [event deltaX],
58254fa6487a 8166591: [macos 10.12] Trackpad scrolling of text on OS X 10.12 Sierra is very fast (Trackpad, Retina only)
alexsch
parents: 39551
diff changeset
   396
                                  [AWTToolkit scrollStateWithEvent: event]);
24555
42926c558bc8 8042752: [macosx] NSEvent instances leak throw JNI local references
pchelko
parents: 23651
diff changeset
   397
    CHECK_NULL(jEvent);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   398
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   399
    static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
23268
2cdb715ff32d 8029868: Fix KSS issues in sun.lwawt.macosx
pchelko
parents: 23255
diff changeset
   400
    static JNF_MEMBER_CACHE(jm_deliverMouseEvent, jc_PlatformView, "deliverMouseEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   401
    jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   402
    if (!(*env)->IsSameObject(env, jlocal, NULL)) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   403
        JNFCallVoidMethod(env, jlocal, jm_deliverMouseEvent, jEvent);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   404
        (*env)->DeleteLocalRef(env, jlocal);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   405
    }
24555
42926c558bc8 8042752: [macosx] NSEvent instances leak throw JNI local references
pchelko
parents: 23651
diff changeset
   406
    (*env)->DeleteLocalRef(env, jEvent);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   407
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   408
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
   409
- (void) resetTrackingArea {
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
   410
    if (rolloverTrackingArea != nil) {
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
   411
        [self removeTrackingArea:rolloverTrackingArea];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
   412
        [rolloverTrackingArea release];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   413
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   414
    
20134
8711b271f96c 8012026: [macosx] Component.getMousePosition() does not work in an applet on MacOS
pchelko
parents: 15985
diff changeset
   415
    int options = (NSTrackingActiveAlways | NSTrackingMouseEnteredAndExited |
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
   416
                   NSTrackingMouseMoved | NSTrackingEnabledDuringMouseDrag);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   417
    
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
   418
    rolloverTrackingArea = [[NSTrackingArea alloc] initWithRect:[self visibleRect]
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
   419
                                                        options: options
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
   420
                                                          owner:self
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
   421
                                                       userInfo:nil
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
   422
                            ];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
   423
    [self addTrackingArea:rolloverTrackingArea];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   424
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   425
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   426
- (void)updateTrackingAreas {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   427
    [super updateTrackingAreas];
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
   428
    [self resetTrackingArea];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   429
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   430
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   431
- (void) resetCursorRects {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   432
    [super resetCursorRects];
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13007
diff changeset
   433
    [self resetTrackingArea];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   434
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   435
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   436
-(void) deliverJavaKeyEventHelper: (NSEvent *) event {
12660
76c54631149e 7154072: [macosx] swallowing key events
ant
parents: 12659
diff changeset
   437
    static NSEvent* sLastKeyEvent = nil;
76c54631149e 7154072: [macosx] swallowing key events
ant
parents: 12659
diff changeset
   438
    if (event == sLastKeyEvent) {
12659
fa378682b3cb 7142565: [macosx] Many special keys processed twice in text fields
ant
parents: 12648
diff changeset
   439
        // The event is repeatedly delivered by keyDown: after performKeyEquivalent:
fa378682b3cb 7142565: [macosx] Many special keys processed twice in text fields
ant
parents: 12648
diff changeset
   440
        return;
fa378682b3cb 7142565: [macosx] Many special keys processed twice in text fields
ant
parents: 12648
diff changeset
   441
    }
12660
76c54631149e 7154072: [macosx] swallowing key events
ant
parents: 12659
diff changeset
   442
    [sLastKeyEvent release];
76c54631149e 7154072: [macosx] swallowing key events
ant
parents: 12659
diff changeset
   443
    sLastKeyEvent = [event retain];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   444
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   445
    [AWTToolkit eventCountPlusPlus];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   446
    JNIEnv *env = [ThreadUtilities getJNIEnv];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   447
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   448
    jstring characters = NULL;
25114
cafd0de74734 8028617: Dvorak keyboard mapping not honored when ctrl key pressed
anashaty
parents: 24555
diff changeset
   449
    jstring charactersIgnoringModifiers = NULL;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   450
    if ([event type] != NSFlagsChanged) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   451
        characters = JNFNSToJavaString(env, [event characters]);
25114
cafd0de74734 8028617: Dvorak keyboard mapping not honored when ctrl key pressed
anashaty
parents: 24555
diff changeset
   452
        charactersIgnoringModifiers = JNFNSToJavaString(env, [event charactersIgnoringModifiers]);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   453
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   454
    
23268
2cdb715ff32d 8029868: Fix KSS issues in sun.lwawt.macosx
pchelko
parents: 23255
diff changeset
   455
    static JNF_CLASS_CACHE(jc_NSEvent, "sun/lwawt/macosx/NSEvent");
25114
cafd0de74734 8028617: Dvorak keyboard mapping not honored when ctrl key pressed
anashaty
parents: 24555
diff changeset
   456
    static JNF_CTOR_CACHE(jctor_NSEvent, jc_NSEvent, "(IISLjava/lang/String;Ljava/lang/String;)V");
24555
42926c558bc8 8042752: [macosx] NSEvent instances leak throw JNI local references
pchelko
parents: 23651
diff changeset
   457
    jobject jEvent = JNFNewObject(env, jctor_NSEvent,
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   458
                                  [event type],
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   459
                                  [event modifierFlags],
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   460
                                  [event keyCode],
25114
cafd0de74734 8028617: Dvorak keyboard mapping not honored when ctrl key pressed
anashaty
parents: 24555
diff changeset
   461
                                  characters,
cafd0de74734 8028617: Dvorak keyboard mapping not honored when ctrl key pressed
anashaty
parents: 24555
diff changeset
   462
                                  charactersIgnoringModifiers);
24555
42926c558bc8 8042752: [macosx] NSEvent instances leak throw JNI local references
pchelko
parents: 23651
diff changeset
   463
    CHECK_NULL(jEvent);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   464
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   465
    static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   466
    static JNF_MEMBER_CACHE(jm_deliverKeyEvent, jc_PlatformView,
23268
2cdb715ff32d 8029868: Fix KSS issues in sun.lwawt.macosx
pchelko
parents: 23255
diff changeset
   467
                            "deliverKeyEvent", "(Lsun/lwawt/macosx/NSEvent;)V");
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   468
    jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   469
    if (!(*env)->IsSameObject(env, jlocal, NULL)) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   470
        JNFCallVoidMethod(env, jlocal, jm_deliverKeyEvent, jEvent);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   471
        (*env)->DeleteLocalRef(env, jlocal);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   472
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   473
    if (characters != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   474
        (*env)->DeleteLocalRef(env, characters);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   475
    }
24555
42926c558bc8 8042752: [macosx] NSEvent instances leak throw JNI local references
pchelko
parents: 23651
diff changeset
   476
    (*env)->DeleteLocalRef(env, jEvent);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   477
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   478
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   479
-(void) deliverResize: (NSRect) rect {
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   480
    jint x = (jint) rect.origin.x;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   481
    jint y = (jint) rect.origin.y;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   482
    jint w = (jint) rect.size.width;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   483
    jint h = (jint) rect.size.height;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   484
    JNIEnv *env = [ThreadUtilities getJNIEnv];
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   485
    static JNF_CLASS_CACHE(jc_PlatformView, "sun/lwawt/macosx/CPlatformView");
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   486
    static JNF_MEMBER_CACHE(jm_deliverResize, jc_PlatformView, "deliverResize", "(IIII)V");
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   487
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   488
    jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   489
    if (!(*env)->IsSameObject(env, jlocal, NULL)) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   490
        JNFCallVoidMethod(env, jlocal, jm_deliverResize, x,y,w,h);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   491
        (*env)->DeleteLocalRef(env, jlocal);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   492
    }
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   493
}
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   494
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
   495
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   496
- (void) drawRect:(NSRect)dirtyRect {
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   497
    AWT_ASSERT_APPKIT_THREAD;
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   498
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   499
    [super drawRect:dirtyRect];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   500
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   501
    if (env != NULL) {
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   502
        /*
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   503
         if ([self inLiveResize]) {
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   504
         NSRect rs[4];
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   505
         NSInteger count;
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   506
         [self getRectsExposedDuringLiveResize:rs count:&count];
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   507
         for (int i = 0; i < count; i++) {
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   508
         JNU_CallMethodByName(env, NULL, [m_awtWindow cPlatformView],
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   509
         "deliverWindowDidExposeEvent", "(FFFF)V",
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   510
         (jfloat)rs[i].origin.x, (jfloat)rs[i].origin.y,
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   511
         (jfloat)rs[i].size.width, (jfloat)rs[i].size.height);
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   512
         if ((*env)->ExceptionOccurred(env)) {
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   513
         (*env)->ExceptionDescribe(env);
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   514
         (*env)->ExceptionClear(env);
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   515
         }
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   516
         }
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   517
         } else {
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   518
         */
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   519
        static JNF_CLASS_CACHE(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   520
        static JNF_MEMBER_CACHE(jm_deliverWindowDidExposeEvent, jc_CPlatformView, "deliverWindowDidExposeEvent", "()V");
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   521
        jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   522
        if (!(*env)->IsSameObject(env, jlocal, NULL)) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   523
            JNFCallVoidMethod(env, jlocal, jm_deliverWindowDidExposeEvent);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   524
            (*env)->DeleteLocalRef(env, jlocal);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   525
        }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   526
        /*
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   527
         }
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   528
         */
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   529
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   530
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   531
33858
7554d0e25d7f 8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents: 32872
diff changeset
   532
-(BOOL) isCodePointInUnicodeBlockNeedingIMEvent: (unichar) codePoint {
39551
7eaf6bb9bc67 8148984: [macosx] Chinese Comma cannot be entered using Pinyin Input Method on OS X
dmarkov
parents: 37787
diff changeset
   533
    if (((codePoint >= 0x3000) && (codePoint <= 0x303F)) ||
7eaf6bb9bc67 8148984: [macosx] Chinese Comma cannot be entered using Pinyin Input Method on OS X
dmarkov
parents: 37787
diff changeset
   534
        ((codePoint >= 0xFF00) && (codePoint <= 0xFFEF))) {
7eaf6bb9bc67 8148984: [macosx] Chinese Comma cannot be entered using Pinyin Input Method on OS X
dmarkov
parents: 37787
diff changeset
   535
        // Code point is in 'CJK Symbols and Punctuation' or
7eaf6bb9bc67 8148984: [macosx] Chinese Comma cannot be entered using Pinyin Input Method on OS X
dmarkov
parents: 37787
diff changeset
   536
        // 'Halfwidth and Fullwidth Forms' Unicode block.
33858
7554d0e25d7f 8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents: 32872
diff changeset
   537
        return YES;
7554d0e25d7f 8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents: 32872
diff changeset
   538
    }
7554d0e25d7f 8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents: 32872
diff changeset
   539
    return NO;
7554d0e25d7f 8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents: 32872
diff changeset
   540
}
7554d0e25d7f 8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents: 32872
diff changeset
   541
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   542
-(NSMutableString *) parseString : (id) complexString {
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   543
    if ([complexString isKindOfClass:[NSString class]]) {
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   544
        return [complexString mutableCopy];
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   545
    }
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   546
    else {
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   547
        return [complexString mutableString];
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   548
    }
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   549
}
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   550
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   551
// NSAccessibility support
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   552
- (jobject)awtComponent:(JNIEnv*)env
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   553
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   554
    static JNF_CLASS_CACHE(jc_CPlatformView, "sun/lwawt/macosx/CPlatformView");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   555
    static JNF_MEMBER_CACHE(jf_Peer, jc_CPlatformView, "peer", "Lsun/lwawt/LWWindowPeer;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   556
    if ((env == NULL) || (m_cPlatformView == NULL)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   557
        NSLog(@"Apple AWT : Error AWTView:awtComponent given bad parameters.");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   558
        if (env != NULL)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   559
        {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   560
            JNFDumpJavaStack(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   561
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   562
        return NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   563
    }
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   564
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   565
    jobject peer = NULL;
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   566
    jobject jlocal = (*env)->NewLocalRef(env, m_cPlatformView);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   567
    if (!(*env)->IsSameObject(env, jlocal, NULL)) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   568
        peer = JNFGetObjectField(env, jlocal, jf_Peer);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   569
        (*env)->DeleteLocalRef(env, jlocal);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   570
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   571
    static JNF_CLASS_CACHE(jc_LWWindowPeer, "sun/lwawt/LWWindowPeer");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   572
    static JNF_MEMBER_CACHE(jf_Target, jc_LWWindowPeer, "target", "Ljava/awt/Component;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   573
    if (peer == NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   574
        NSLog(@"Apple AWT : Error AWTView:awtComponent got null peer from CPlatformView");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   575
        JNFDumpJavaStack(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   576
        return NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   577
    }
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   578
    jobject comp = JNFGetObjectField(env, peer, jf_Target);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   579
    (*env)->DeleteLocalRef(env, peer);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   580
    return comp;
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   581
}
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   582
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   583
+ (AWTView *) awtView:(JNIEnv*)env ofAccessible:(jobject)jaccessible
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   584
{
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   585
    static JNF_STATIC_MEMBER_CACHE(jm_getAWTView, sjc_CAccessibility, "getAWTView", "(Ljavax/accessibility/Accessible;)J");
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   586
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   587
    jlong jptr = JNFCallStaticLongMethod(env, jm_getAWTView, jaccessible);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   588
    if (jptr == 0) return nil;
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   589
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   590
    return (AWTView *)jlong_to_ptr(jptr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   591
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   592
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   593
- (id)getAxData:(JNIEnv*)env
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   594
{
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   595
    jobject jcomponent = [self awtComponent:env];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   596
    id ax = [[[JavaComponentAccessibility alloc] initWithParent:self withEnv:env withAccessible:jcomponent withIndex:-1 withView:self withJavaRole:nil] autorelease];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   597
    (*env)->DeleteLocalRef(env, jcomponent);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
   598
    return ax;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   599
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   600
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   601
- (NSArray *)accessibilityAttributeNames
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   602
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   603
    return [[super accessibilityAttributeNames] arrayByAddingObject:NSAccessibilityChildrenAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   604
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   605
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   606
// NSAccessibility messages
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   607
// attribute methods
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   608
- (id)accessibilityAttributeValue:(NSString *)attribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   609
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   610
    AWT_ASSERT_APPKIT_THREAD;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   611
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   612
    if ([attribute isEqualToString:NSAccessibilityChildrenAttribute])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   613
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   614
        JNIEnv *env = [ThreadUtilities getJNIEnv];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   615
        
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   616
        (*env)->PushLocalFrame(env, 4);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   617
        
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   618
        id result = NSAccessibilityUnignoredChildrenForOnlyChild([self getAxData:env]);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   619
        
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   620
        (*env)->PopLocalFrame(env, NULL);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   621
        
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   622
        return result;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   623
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   624
    else
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   625
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   626
        return [super accessibilityAttributeValue:attribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   627
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   628
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   629
- (BOOL)accessibilityIsIgnored
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   630
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   631
    return YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   632
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   633
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   634
- (id)accessibilityHitTest:(NSPoint)point
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   635
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   636
    AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   637
    JNIEnv *env = [ThreadUtilities getJNIEnv];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   638
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   639
    (*env)->PushLocalFrame(env, 4);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   640
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   641
    id result = [[self getAxData:env] accessibilityHitTest:point withEnv:env];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   642
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   643
    (*env)->PopLocalFrame(env, NULL);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   644
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   645
    return result;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   646
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   647
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   648
- (id)accessibilityFocusedUIElement
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   649
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   650
    AWT_ASSERT_APPKIT_THREAD;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   651
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   652
    JNIEnv *env = [ThreadUtilities getJNIEnv];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   653
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   654
    (*env)->PushLocalFrame(env, 4);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   655
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   656
    id result = [[self getAxData:env] accessibilityFocusedUIElement];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   657
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   658
    (*env)->PopLocalFrame(env, NULL);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   659
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   660
    return result;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   661
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   662
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   663
// --- Services menu support for lightweights ---
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   664
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 21268
diff changeset
   665
// finds the focused accessible element, and if it is a text element, obtains the text from it
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   666
- (NSString *)accessibleSelectedText
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   667
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   668
    id focused = [self accessibilityFocusedUIElement];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   669
    if (![focused isKindOfClass:[JavaTextAccessibility class]]) return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   670
    return [(JavaTextAccessibility *)focused accessibilitySelectedTextAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   671
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   672
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   673
// same as above, but converts to RTFD
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   674
- (NSData *)accessibleSelectedTextAsRTFD
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   675
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   676
    NSString *selectedText = [self accessibleSelectedText];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   677
    NSAttributedString *styledText = [[NSAttributedString alloc] initWithString:selectedText];
36462
dee5ee6606e2 8141553: [macosx] JDK fails to build with Xcode 7 on 10.11
serb
parents: 33858
diff changeset
   678
    NSData *rtfdData = [styledText RTFDFromRange:NSMakeRange(0, [styledText length])
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   679
                              documentAttributes:
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   680
                                @{NSDocumentTypeDocumentAttribute: NSRTFTextDocumentType}];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   681
    [styledText release];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   682
    return rtfdData;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   683
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   684
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 21268
diff changeset
   685
// finds the focused accessible element, and if it is a text element, sets the text in it
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   686
- (BOOL)replaceAccessibleTextSelection:(NSString *)text
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   687
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   688
    id focused = [self accessibilityFocusedUIElement];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   689
    if (![focused isKindOfClass:[JavaTextAccessibility class]]) return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   690
    [(JavaTextAccessibility *)focused accessibilitySetSelectedTextAttribute:text];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   691
    return YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   692
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   693
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   694
// called for each service in the Services menu - only handle text for now
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   695
- (id)validRequestorForSendType:(NSString *)sendType returnType:(NSString *)returnType
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   696
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   697
    if ([[self window] firstResponder] != self) return nil; // let AWT components handle themselves
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   698
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   699
    if ([sendType isEqual:NSStringPboardType] || [returnType isEqual:NSStringPboardType]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   700
        NSString *selectedText = [self accessibleSelectedText];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   701
        if (selectedText) return self;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   702
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   703
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   704
    return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   705
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   706
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   707
// fetch text from Java and hand off to the service
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   708
- (BOOL)writeSelectionToPasteboard:(NSPasteboard *)pboard types:(NSArray *)types
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   709
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   710
    if ([types containsObject:NSStringPboardType])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   711
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   712
        [pboard declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   713
        return [pboard setString:[self accessibleSelectedText] forType:NSStringPboardType];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   714
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   715
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   716
    if ([types containsObject:NSRTFDPboardType])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   717
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   718
        [pboard declareTypes:[NSArray arrayWithObject:NSRTFDPboardType] owner:nil];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   719
        return [pboard setData:[self accessibleSelectedTextAsRTFD] forType:NSRTFDPboardType];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   720
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   721
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   722
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   723
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   724
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   725
// write text back to Java from the service
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   726
- (BOOL)readSelectionFromPasteboard:(NSPasteboard *)pboard
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   727
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   728
    if ([[pboard types] containsObject:NSStringPboardType])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   729
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   730
        NSString *text = [pboard stringForType:NSStringPboardType];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   731
        return [self replaceAccessibleTextSelection:text];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   732
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   733
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   734
    if ([[pboard types] containsObject:NSRTFDPboardType])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   735
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   736
        NSData *rtfdData = [pboard dataForType:NSRTFDPboardType];
36462
dee5ee6606e2 8141553: [macosx] JDK fails to build with Xcode 7 on 10.11
serb
parents: 33858
diff changeset
   737
        NSAttributedString *styledText = [[NSAttributedString alloc] initWithRTFD:rtfdData documentAttributes:NULL];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   738
        NSString *text = [styledText string];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   739
        [styledText release];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   740
        
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   741
        return [self replaceAccessibleTextSelection:text];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   742
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   743
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   744
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   745
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   746
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   747
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   748
-(void) setDragSource:(CDragSource *)source {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   749
    self._dragSource = source;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   750
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   751
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   752
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   753
- (void) setDropTarget:(CDropTarget *)target {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   754
    self._dropTarget = target;
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
   755
    [ThreadUtilities performOnMainThread:@selector(controlModelControlValid) on:self._dropTarget withObject:nil waitUntilDone:YES];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   756
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   757
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   758
/********************************  BEGIN NSDraggingSource Interface  ********************************/
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   759
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   760
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)flag
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   761
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   762
    // If draggingSource is nil route the message to the superclass (if responding to the selector):
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   763
    CDragSource *dragSource = self._dragSource;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   764
    NSDragOperation dragOp = NSDragOperationNone;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   765
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   766
    if (dragSource != nil)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   767
        dragOp = [dragSource draggingSourceOperationMaskForLocal:flag];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   768
    else if ([super respondsToSelector:@selector(draggingSourceOperationMaskForLocal:)])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   769
        dragOp = [super draggingSourceOperationMaskForLocal:flag];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   770
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   771
    return dragOp;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   772
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   773
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   774
- (NSArray *)namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   775
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   776
    // If draggingSource is nil route the message to the superclass (if responding to the selector):
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   777
    CDragSource *dragSource = self._dragSource;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   778
    NSArray* array = nil;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   779
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   780
    if (dragSource != nil)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   781
        array = [dragSource namesOfPromisedFilesDroppedAtDestination:dropDestination];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   782
    else if ([super respondsToSelector:@selector(namesOfPromisedFilesDroppedAtDestination:)])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   783
        array = [super namesOfPromisedFilesDroppedAtDestination:dropDestination];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   784
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   785
    return array;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   786
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   787
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   788
- (void)draggedImage:(NSImage *)image beganAt:(NSPoint)screenPoint
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   789
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   790
    // If draggingSource is nil route the message to the superclass (if responding to the selector):
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   791
    CDragSource *dragSource = self._dragSource;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   792
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   793
    if (dragSource != nil)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   794
        [dragSource draggedImage:image beganAt:screenPoint];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   795
    else if ([super respondsToSelector:@selector(draggedImage::)])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   796
        [super draggedImage:image beganAt:screenPoint];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   797
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   798
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   799
- (void)draggedImage:(NSImage *)image endedAt:(NSPoint)screenPoint operation:(NSDragOperation)operation
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   800
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   801
    // If draggingSource is nil route the message to the superclass (if responding to the selector):
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   802
    CDragSource *dragSource = self._dragSource;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   803
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   804
    if (dragSource != nil)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   805
        [dragSource draggedImage:image endedAt:screenPoint operation:operation];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   806
    else if ([super respondsToSelector:@selector(draggedImage:::)])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   807
        [super draggedImage:image endedAt:screenPoint operation:operation];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   808
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   809
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   810
- (void)draggedImage:(NSImage *)image movedTo:(NSPoint)screenPoint
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   811
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   812
    // If draggingSource is nil route the message to the superclass (if responding to the selector):
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   813
    CDragSource *dragSource = self._dragSource;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   814
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   815
    if (dragSource != nil)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   816
        [dragSource draggedImage:image movedTo:screenPoint];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   817
    else if ([super respondsToSelector:@selector(draggedImage::)])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   818
        [super draggedImage:image movedTo:screenPoint];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   819
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   820
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   821
- (BOOL)ignoreModifierKeysWhileDragging
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   822
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   823
    // If draggingSource is nil route the message to the superclass (if responding to the selector):
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   824
    CDragSource *dragSource = self._dragSource;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   825
    BOOL result = FALSE;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   826
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   827
    if (dragSource != nil)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   828
        result = [dragSource ignoreModifierKeysWhileDragging];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   829
    else if ([super respondsToSelector:@selector(ignoreModifierKeysWhileDragging)])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   830
        result = [super ignoreModifierKeysWhileDragging];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   831
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   832
    return result;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   833
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   834
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   835
/********************************  END NSDraggingSource Interface  ********************************/
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   836
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   837
/********************************  BEGIN NSDraggingDestination Interface  ********************************/
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   838
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   839
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   840
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   841
    // If draggingDestination is nil route the message to the superclass:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   842
    CDropTarget *dropTarget = self._dropTarget;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   843
    NSDragOperation dragOp = NSDragOperationNone;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   844
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   845
    if (dropTarget != nil)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   846
        dragOp = [dropTarget draggingEntered:sender];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   847
    else if ([super respondsToSelector:@selector(draggingEntered:)])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   848
        dragOp = [super draggingEntered:sender];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   849
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   850
    return dragOp;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   851
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   852
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   853
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   854
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   855
    // If draggingDestination is nil route the message to the superclass:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   856
    CDropTarget *dropTarget = self._dropTarget;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   857
    NSDragOperation dragOp = NSDragOperationNone;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   858
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   859
    if (dropTarget != nil)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   860
        dragOp = [dropTarget draggingUpdated:sender];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   861
    else if ([super respondsToSelector:@selector(draggingUpdated:)])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   862
        dragOp = [super draggingUpdated:sender];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   863
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   864
    return dragOp;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   865
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   866
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   867
- (void)draggingExited:(id <NSDraggingInfo>)sender
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   868
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   869
    // If draggingDestination is nil route the message to the superclass:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   870
    CDropTarget *dropTarget = self._dropTarget;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   871
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   872
    if (dropTarget != nil)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   873
        [dropTarget draggingExited:sender];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   874
    else if ([super respondsToSelector:@selector(draggingExited:)])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   875
        [super draggingExited:sender];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   876
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   877
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   878
- (BOOL)prepareForDragOperation:(id <NSDraggingInfo>)sender
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   879
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   880
    // If draggingDestination is nil route the message to the superclass:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   881
    CDropTarget *dropTarget = self._dropTarget;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   882
    BOOL result = FALSE;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   883
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   884
    if (dropTarget != nil)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   885
        result = [dropTarget prepareForDragOperation:sender];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   886
    else if ([super respondsToSelector:@selector(prepareForDragOperation:)])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   887
        result = [super prepareForDragOperation:sender];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   888
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   889
    return result;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   890
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   891
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   892
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   893
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   894
    // If draggingDestination is nil route the message to the superclass:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   895
    CDropTarget *dropTarget = self._dropTarget;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   896
    BOOL result = FALSE;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   897
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   898
    if (dropTarget != nil)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   899
        result = [dropTarget performDragOperation:sender];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   900
    else if ([super respondsToSelector:@selector(performDragOperation:)])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   901
        result = [super performDragOperation:sender];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   902
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   903
    return result;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   904
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   905
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   906
- (void)concludeDragOperation:(id <NSDraggingInfo>)sender
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   907
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   908
    // If draggingDestination is nil route the message to the superclass:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   909
    CDropTarget *dropTarget = self._dropTarget;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   910
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   911
    if (dropTarget != nil)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   912
        [dropTarget concludeDragOperation:sender];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   913
    else if ([super respondsToSelector:@selector(concludeDragOperation:)])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   914
        [super concludeDragOperation:sender];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   915
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   916
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   917
- (void)draggingEnded:(id <NSDraggingInfo>)sender
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   918
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   919
    // If draggingDestination is nil route the message to the superclass:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   920
    CDropTarget *dropTarget = self._dropTarget;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   921
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   922
    if (dropTarget != nil)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   923
        [dropTarget draggingEnded:sender];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   924
    else if ([super respondsToSelector:@selector(draggingEnded:)])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   925
        [super draggingEnded:sender];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   926
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   927
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   928
/********************************  END NSDraggingDestination Interface  ********************************/
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   929
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   930
/********************************  BEGIN NSTextInputClient Protocol  ********************************/
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   931
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   932
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   933
JNF_CLASS_CACHE(jc_CInputMethod, "sun/lwawt/macosx/CInputMethod");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   934
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   935
- (void) insertText:(id)aString replacementRange:(NSRange)replacementRange
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   936
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   937
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   938
    fprintf(stderr, "AWTView InputMethod Selector Called : [insertText]: %s\n", [aString UTF8String]);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   939
#endif // IM_DEBUG
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   940
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   941
    if (fInputMethodLOCKABLE == NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   942
        return;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   943
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   944
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   945
    // Insert happens at the end of PAH
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   946
    fInPressAndHold = NO;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   947
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   948
    // insertText gets called when the user commits text generated from an input method.  It also gets
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   949
    // called during ordinary input as well.  We only need to send an input method event when we have marked
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   950
    // text, or 'text in progress'.  We also need to send the event if we get an insert text out of the blue!
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   951
    // (i.e., when the user uses the Character palette or Inkwell), or when the string to insert is a complex
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   952
    // Unicode value.
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   953
    
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   954
    NSMutableString * useString = [self parseString:aString];
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   955
    NSUInteger utf16Length = [useString lengthOfBytesUsingEncoding:NSUTF16StringEncoding];
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   956
    NSUInteger utf8Length = [useString lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
33858
7554d0e25d7f 8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents: 32872
diff changeset
   957
    BOOL aStringIsComplex = NO;
7554d0e25d7f 8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents: 32872
diff changeset
   958
    if ((utf16Length > 2) ||
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   959
        ((utf8Length > 1) && [self isCodePointInUnicodeBlockNeedingIMEvent:[useString characterAtIndex:0]])) {
33858
7554d0e25d7f 8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents: 32872
diff changeset
   960
        aStringIsComplex = YES;
7554d0e25d7f 8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents: 32872
diff changeset
   961
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   962
    
33858
7554d0e25d7f 8132503: [macosx] Chinese full stop symbol cannot be entered with Pinyin IM on OS X
alitvinov
parents: 32872
diff changeset
   963
    if ([self hasMarkedText] || !fProcessingKeystroke || aStringIsComplex) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   964
        JNIEnv *env = [ThreadUtilities getJNIEnv];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   965
        
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   966
        static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   967
        // We need to select the previous glyph so that it is overwritten.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   968
        if (fPAHNeedsToSelect) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   969
            JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   970
            fPAHNeedsToSelect = NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   971
        }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   972
        
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   973
        static JNF_MEMBER_CACHE(jm_insertText, jc_CInputMethod, "insertText", "(Ljava/lang/String;)V");
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   974
        jstring insertedText =  JNFNSToJavaString(env, useString);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   975
        JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_insertText, insertedText); // AWT_THREADING Safe (AWTRunLoopMode)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   976
        (*env)->DeleteLocalRef(env, insertedText);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
   977
        
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   978
        // The input method event will create psuedo-key events for each character in the committed string.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   979
        // We also don't want to send the character that triggered the insertText, usually a return. [3337563]
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   980
        fKeyEventsNeeded = NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   981
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   982
    fPAHNeedsToSelect = NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   983
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   984
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   985
- (void) doCommandBySelector:(SEL)aSelector
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   986
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   987
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   988
    fprintf(stderr, "AWTView InputMethod Selector Called : [doCommandBySelector]\n");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   989
    NSLog(@"%@", NSStringFromSelector(aSelector));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   990
#endif // IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   991
    if (@selector(insertNewline:) == aSelector || @selector(insertTab:) == aSelector || @selector(deleteBackward:) == aSelector)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   992
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   993
        fKeyEventsNeeded = YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   994
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   995
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   996
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   997
// setMarkedText: cannot take a nil first argument. aString can be NSString or NSAttributedString
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   998
- (void) setMarkedText:(id)aString selectedRange:(NSRange)selectionRange replacementRange:(NSRange)replacementRange
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   999
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1000
    if (!fInputMethodLOCKABLE)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1001
        return;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1002
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1003
    BOOL isAttributedString = [aString isKindOfClass:[NSAttributedString class]];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1004
    NSAttributedString *attrString = (isAttributedString ? (NSAttributedString *)aString : nil);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1005
    NSString *incomingString = (isAttributedString ? [aString string] : aString);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1006
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1007
    fprintf(stderr, "AWTView InputMethod Selector Called : [setMarkedText] \"%s\", loc=%lu, length=%lu\n", [incomingString UTF8String], (unsigned long)selectionRange.location, (unsigned long)selectionRange.length);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1008
#endif // IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1009
    static JNF_MEMBER_CACHE(jm_startIMUpdate, jc_CInputMethod, "startIMUpdate", "(Ljava/lang/String;)V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1010
    static JNF_MEMBER_CACHE(jm_addAttribute, jc_CInputMethod, "addAttribute", "(ZZII)V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1011
    static JNF_MEMBER_CACHE(jm_dispatchText, jc_CInputMethod, "dispatchText", "(IIZ)V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1012
    JNIEnv *env = [ThreadUtilities getJNIEnv];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1013
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1014
    // NSInputContext already did the analysis of the TSM event and created attributes indicating
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1015
    // the underlining and color that should be done to the string.  We need to look at the underline
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1016
    // style and color to determine what kind of Java hilighting needs to be done.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1017
    jstring inProcessText = JNFNSToJavaString(env, incomingString);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1018
    JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_startIMUpdate, inProcessText); // AWT_THREADING Safe (AWTRunLoopMode)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1019
    (*env)->DeleteLocalRef(env, inProcessText);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1020
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1021
    if (isAttributedString) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1022
        NSUInteger length;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1023
        NSRange effectiveRange;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1024
        NSDictionary *attributes;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1025
        length = [attrString length];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1026
        effectiveRange = NSMakeRange(0, 0);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1027
        while (NSMaxRange(effectiveRange) < length) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1028
            attributes = [attrString attributesAtIndex:NSMaxRange(effectiveRange)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1029
                                        effectiveRange:&effectiveRange];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1030
            if (attributes) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1031
                BOOL isThickUnderline, isGray;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1032
                NSNumber *underlineSizeObj =
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1033
                (NSNumber *)[attributes objectForKey:NSUnderlineStyleAttributeName];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1034
                NSInteger underlineSize = [underlineSizeObj integerValue];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1035
                isThickUnderline = (underlineSize > 1);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1036
                
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1037
                NSColor *underlineColorObj =
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1038
                (NSColor *)[attributes objectForKey:NSUnderlineColorAttributeName];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1039
                isGray = !([underlineColorObj isEqual:[NSColor blackColor]]);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1040
                
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1041
                JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_addAttribute, isThickUnderline, isGray, effectiveRange.location, effectiveRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1042
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1043
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1044
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1045
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1046
    static JNF_MEMBER_CACHE(jm_selectPreviousGlyph, jc_CInputMethod, "selectPreviousGlyph", "()V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1047
    // We need to select the previous glyph so that it is overwritten.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1048
    if (fPAHNeedsToSelect) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1049
        JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_selectPreviousGlyph);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1050
        fPAHNeedsToSelect = NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1051
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1052
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1053
    JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_dispatchText, selectionRange.location, selectionRange.length, JNI_FALSE); // AWT_THREADING Safe (AWTRunLoopMode)
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1054
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1055
    // If the marked text is being cleared (zero-length string) don't handle the key event.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1056
    if ([incomingString length] == 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1057
        fKeyEventsNeeded = NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1058
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1059
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1060
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1061
- (void) unmarkText
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1062
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1063
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1064
    fprintf(stderr, "AWTView InputMethod Selector Called : [unmarkText]\n");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1065
#endif // IM_DEBUG
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1066
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1067
    if (!fInputMethodLOCKABLE) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1068
        return;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1069
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1070
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1071
    // unmarkText cancels any input in progress and commits it to the text field.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1072
    static JNF_MEMBER_CACHE(jm_unmarkText, jc_CInputMethod, "unmarkText", "()V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1073
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1074
    JNFCallVoidMethod(env, fInputMethodLOCKABLE, jm_unmarkText); // AWT_THREADING Safe (AWTRunLoopMode)
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1075
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1076
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1077
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1078
- (BOOL) hasMarkedText
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1079
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1080
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1081
    fprintf(stderr, "AWTView InputMethod Selector Called : [hasMarkedText]\n");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1082
#endif // IM_DEBUG
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1083
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1084
    if (!fInputMethodLOCKABLE) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1085
        return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1086
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1087
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1088
    static JNF_MEMBER_CACHE(jf_fCurrentText, jc_CInputMethod, "fCurrentText", "Ljava/text/AttributedString;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1089
    static JNF_MEMBER_CACHE(jf_fCurrentTextLength, jc_CInputMethod, "fCurrentTextLength", "I");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1090
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1091
    jobject currentText = JNFGetObjectField(env, fInputMethodLOCKABLE, jf_fCurrentText);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1092
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1093
    jint currentTextLength = JNFGetIntField(env, fInputMethodLOCKABLE, jf_fCurrentTextLength);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1094
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1095
    BOOL hasMarkedText = (currentText != NULL && currentTextLength > 0);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1096
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1097
    if (currentText != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1098
        (*env)->DeleteLocalRef(env, currentText);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1099
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1100
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1101
    return hasMarkedText;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1102
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1103
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1104
- (NSInteger) conversationIdentifier
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1105
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1106
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1107
    fprintf(stderr, "AWTView InputMethod Selector Called : [conversationIdentifier]\n");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1108
#endif // IM_DEBUG
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1109
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1110
    return (NSInteger) self;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1111
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1112
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1113
/* Returns attributed string at the range.  This allows input mangers to
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1114
 query any range in backing-store (Andy's request)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1115
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1116
- (NSAttributedString *) attributedSubstringForProposedRange:(NSRange)theRange actualRange:(NSRangePointer)actualRange
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1117
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1118
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1119
    fprintf(stderr, "AWTView InputMethod Selector Called : [attributedSubstringFromRange] location=%lu, length=%lu\n", (unsigned long)theRange.location, (unsigned long)theRange.length);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1120
#endif // IM_DEBUG
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1121
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1122
    static JNF_MEMBER_CACHE(jm_substringFromRange, jc_CInputMethod, "attributedSubstringFromRange", "(II)Ljava/lang/String;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1123
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1124
    jobject theString = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_substringFromRange, theRange.location, theRange.length); // AWT_THREADING Safe (AWTRunLoopMode)
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1125
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1126
    id result = [[[NSAttributedString alloc] initWithString:JNFJavaToNSString(env, theString)] autorelease];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1127
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1128
    NSLog(@"attributedSubstringFromRange returning \"%@\"", result);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1129
#endif // IM_DEBUG
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1130
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1131
    (*env)->DeleteLocalRef(env, theString);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1132
    return result;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1133
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1134
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1135
/* This method returns the range for marked region.  If hasMarkedText == false,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1136
 it'll return NSNotFound location & 0 length range.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1137
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1138
- (NSRange) markedRange
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1139
{
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1140
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1141
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1142
    fprintf(stderr, "AWTView InputMethod Selector Called : [markedRange]\n");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1143
#endif // IM_DEBUG
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1144
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1145
    if (!fInputMethodLOCKABLE) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1146
        return NSMakeRange(NSNotFound, 0);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1147
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1148
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1149
    static JNF_MEMBER_CACHE(jm_markedRange, jc_CInputMethod, "markedRange", "()[I");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1150
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1151
    jarray array;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1152
    jboolean isCopy;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1153
    jint *_array;
23625
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1154
    NSRange range = NSMakeRange(NSNotFound, 0);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1155
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1156
    array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_markedRange); // AWT_THREADING Safe (AWTRunLoopMode)
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1157
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1158
    if (array) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1159
        _array = (*env)->GetIntArrayElements(env, array, &isCopy);
23625
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1160
        if (_array != NULL) {
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1161
            range.location = _array[0];
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1162
            range.length = _array[1];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1163
#ifdef IM_DEBUG
23625
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1164
            fprintf(stderr, "markedRange returning (%lu, %lu)\n",
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1165
                    (unsigned long)range.location, (unsigned long)range.length);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1166
#endif // IM_DEBUG
23625
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1167
            (*env)->ReleaseIntArrayElements(env, array, _array, 0);
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1168
        }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1169
        (*env)->DeleteLocalRef(env, array);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1170
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1171
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1172
    return range;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1173
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1174
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1175
/* This method returns the range for selected region.  Just like markedRange method,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1176
 its location field contains char index from the text beginning.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1177
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1178
- (NSRange) selectedRange
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1179
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1180
    if (!fInputMethodLOCKABLE) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1181
        return NSMakeRange(NSNotFound, 0);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1182
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1183
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1184
    static JNF_MEMBER_CACHE(jm_selectedRange, jc_CInputMethod, "selectedRange", "()[I");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1185
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1186
    jarray array;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1187
    jboolean isCopy;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1188
    jint *_array;
23625
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1189
    NSRange range = NSMakeRange(NSNotFound, 0);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1190
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1191
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1192
    fprintf(stderr, "AWTView InputMethod Selector Called : [selectedRange]\n");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1193
#endif // IM_DEBUG
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1194
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1195
    array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_selectedRange); // AWT_THREADING Safe (AWTRunLoopMode)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1196
    if (array) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1197
        _array = (*env)->GetIntArrayElements(env, array, &isCopy);
23625
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1198
        if (_array != NULL) {
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1199
            range.location = _array[0];
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1200
            range.length = _array[1];
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1201
            (*env)->ReleaseIntArrayElements(env, array, _array, 0);
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1202
        }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1203
        (*env)->DeleteLocalRef(env, array);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1204
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1205
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1206
    return range;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1207
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1208
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1209
/* This method returns the first frame of rects for theRange in screen coordindate system.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1210
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1211
- (NSRect) firstRectForCharacterRange:(NSRange)theRange actualRange:(NSRangePointer)actualRange
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1212
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1213
    if (!fInputMethodLOCKABLE) {
23625
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1214
        return NSZeroRect;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1215
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1216
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1217
    static JNF_MEMBER_CACHE(jm_firstRectForCharacterRange, jc_CInputMethod,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1218
                            "firstRectForCharacterRange", "(I)[I");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1219
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1220
    jarray array;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1221
    jboolean isCopy;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1222
    jint *_array;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1223
    NSRect rect;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1224
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1225
#ifdef IM_DEBUG
23625
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1226
    fprintf(stderr,
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1227
            "AWTView InputMethod Selector Called : [firstRectForCharacterRange:] location=%lu, length=%lu\n",
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1228
            (unsigned long)theRange.location, (unsigned long)theRange.length);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1229
#endif // IM_DEBUG
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1230
    
23625
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1231
    array = JNFCallObjectMethod(env, fInputMethodLOCKABLE, jm_firstRectForCharacterRange,
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1232
                                theRange.location); // AWT_THREADING Safe (AWTRunLoopMode)
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1233
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1234
    _array = (*env)->GetIntArrayElements(env, array, &isCopy);
23625
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1235
    if (_array) {
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1236
        rect = ConvertNSScreenRect(env, NSMakeRect(_array[0], _array[1], _array[2], _array[3]));
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1237
        (*env)->ReleaseIntArrayElements(env, array, _array, 0);
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1238
    } else {
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1239
        rect = NSZeroRect;
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1240
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1241
    (*env)->DeleteLocalRef(env, array);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1242
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1243
#ifdef IM_DEBUG
23625
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1244
    fprintf(stderr,
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1245
            "firstRectForCharacterRange returning x=%f, y=%f, width=%f, height=%f\n",
bb223c2c6fc0 8034037: [parfait] JNI exception pending in macosx/native/sun/awt/AWTEvent.m, AWTView.m
serb
parents: 23328
diff changeset
  1246
            rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1247
#endif // IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1248
    return rect;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1249
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1250
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1251
/* This method returns the index for character that is nearest to thePoint.  thPoint is in
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1252
 screen coordinate system.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1253
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1254
- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1255
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1256
    if (!fInputMethodLOCKABLE) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1257
        return NSNotFound;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1258
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1259
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1260
    static JNF_MEMBER_CACHE(jm_characterIndexForPoint, jc_CInputMethod,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1261
                            "characterIndexForPoint", "(II)I");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1262
    JNIEnv *env = [ThreadUtilities getJNIEnv];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1263
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1264
    NSPoint flippedLocation = ConvertNSScreenPoint(env, thePoint);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1265
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1266
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1267
    fprintf(stderr, "AWTView InputMethod Selector Called : [characterIndexForPoint:(NSPoint)thePoint] x=%f, y=%f\n", flippedLocation.x, flippedLocation.y);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1268
#endif // IM_DEBUG
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1269
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1270
    jint index = JNFCallIntMethod(env, fInputMethodLOCKABLE, jm_characterIndexForPoint, (jint)flippedLocation.x, (jint)flippedLocation.y); // AWT_THREADING Safe (AWTRunLoopMode)
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1271
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1272
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1273
    fprintf(stderr, "characterIndexForPoint returning %ld\n", index);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1274
#endif // IM_DEBUG
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1275
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1276
    if (index == -1) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1277
        return NSNotFound;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1278
    } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1279
        return (NSUInteger)index;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1280
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1281
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1282
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1283
- (NSArray*) validAttributesForMarkedText
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1284
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1285
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1286
    fprintf(stderr, "AWTView InputMethod Selector Called : [validAttributesForMarkedText]\n");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1287
#endif // IM_DEBUG
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1288
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1289
    return [NSArray array];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1290
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1291
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1292
- (void)setInputMethod:(jobject)inputMethod
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1293
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1294
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1295
    fprintf(stderr, "AWTView InputMethod Selector Called : [setInputMethod]\n");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1296
#endif // IM_DEBUG
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1297
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1298
    JNIEnv *env = [ThreadUtilities getJNIEnv];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1299
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1300
    // Get rid of the old one
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1301
    if (fInputMethodLOCKABLE) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1302
        JNFDeleteGlobalRef(env, fInputMethodLOCKABLE);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1303
    }
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1304
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1305
    // Save a global ref to the new input method.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1306
    if (inputMethod != NULL)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1307
        fInputMethodLOCKABLE = JNFNewGlobalRef(env, inputMethod);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1308
    else
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1309
        fInputMethodLOCKABLE = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1310
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1311
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1312
- (void)abandonInput
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1313
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1314
#ifdef IM_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1315
    fprintf(stderr, "AWTView InputMethod Selector Called : [abandonInput]\n");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1316
#endif // IM_DEBUG
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1317
    
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
  1318
    [ThreadUtilities performOnMainThread:@selector(markedTextAbandoned:) on:[NSInputManager currentInputManager] withObject:self waitUntilDone:YES];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1319
    [self unmarkText];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1320
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1321
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1322
/********************************   END NSTextInputClient Protocol   ********************************/
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1323
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1324
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1325
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1326
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1327
@end // AWTView
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1328
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1329
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1330
 * Class:     sun_lwawt_macosx_CPlatformView
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1331
 * Method:    nativeCreateView
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1332
 * Signature: (IIII)J
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1333
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1334
JNIEXPORT jlong JNICALL
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1335
Java_sun_lwawt_macosx_CPlatformView_nativeCreateView
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1336
(JNIEnv *env, jobject obj, jint originX, jint originY, jint width, jint height, jlong windowLayerPtr)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1337
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1338
    __block AWTView *newView = nil;
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1339
    
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1340
    JNF_COCOA_ENTER(env);
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1341
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1342
    NSRect rect = NSMakeRect(originX, originY, width, height);
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 36897
diff changeset
  1343
    jobject cPlatformView = (*env)->NewWeakGlobalRef(env, obj);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1344
    
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1345
    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1346
        
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1347
        CALayer *windowLayer = jlong_to_ptr(windowLayerPtr);
23651
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23625
diff changeset
  1348
        newView = [[AWTView alloc] initWithRect:rect
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23625
diff changeset
  1349
                                   platformView:cPlatformView
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23625
diff changeset
  1350
                                    windowLayer:windowLayer];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1351
    }];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1352
    
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1353
    JNF_COCOA_EXIT(env);
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1354
    
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1355
    return ptr_to_jlong(newView);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1356
}
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1357
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1358
/*
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1359
 * Class:     sun_lwawt_macosx_CPlatformView
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1360
 * Method:    nativeSetAutoResizable
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1361
 * Signature: (JZ)V;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1362
 */
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1363
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1364
JNIEXPORT void JNICALL
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1365
Java_sun_lwawt_macosx_CPlatformView_nativeSetAutoResizable
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1366
(JNIEnv *env, jclass cls, jlong viewPtr, jboolean toResize)
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1367
{
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1368
    JNF_COCOA_ENTER(env);
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1369
    
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1370
    NSView *view = (NSView *)jlong_to_ptr(viewPtr);
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1371
    
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1372
    [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1373
        
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1374
        if (toResize) {
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1375
            [view setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable];
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1376
        } else {
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1377
            [view setAutoresizingMask: NSViewMinYMargin | NSViewMaxXMargin];
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1378
        }
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1379
        
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1380
        if ([view superview] != nil) {
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1381
            [[view superview] setAutoresizesSubviews:(BOOL)toResize];
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1382
        }
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1383
        
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1384
    }];
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1385
    JNF_COCOA_EXIT(env);
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1386
}
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1387
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1388
/*
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1389
 * Class:     sun_lwawt_macosx_CPlatformView
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1390
 * Method:    nativeGetNSViewDisplayID
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1391
 * Signature: (J)I;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1392
 */
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1393
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1394
JNIEXPORT jint JNICALL
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1395
Java_sun_lwawt_macosx_CPlatformView_nativeGetNSViewDisplayID
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1396
(JNIEnv *env, jclass cls, jlong viewPtr)
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1397
{
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1398
    __block jint ret; //CGDirectDisplayID
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1399
    
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1400
    JNF_COCOA_ENTER(env);
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1401
    
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1402
    NSView *view = (NSView *)jlong_to_ptr(viewPtr);
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1403
    NSWindow *window = [view window];
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1404
    
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1405
    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1406
        
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1407
        ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue];
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1408
    }];
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1409
    
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1410
    JNF_COCOA_EXIT(env);
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1411
    
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1412
    return ret;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1413
}
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1414
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1415
/*
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1416
 * Class:     sun_lwawt_macosx_CPlatformView
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1417
 * Method:    nativeGetLocationOnScreen
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1418
 * Signature: (J)Ljava/awt/Rectangle;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1419
 */
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1420
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1421
JNIEXPORT jobject JNICALL
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1422
Java_sun_lwawt_macosx_CPlatformView_nativeGetLocationOnScreen
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1423
(JNIEnv *env, jclass cls, jlong viewPtr)
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1424
{
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1425
    jobject jRect = NULL;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1426
    
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1427
    JNF_COCOA_ENTER(env);
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1428
    
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1429
    __block NSRect rect = NSZeroRect;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1430
    
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1431
    NSView *view = (NSView *)jlong_to_ptr(viewPtr);
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1432
    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1433
        
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1434
        NSRect viewBounds = [view bounds];
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1435
        NSRect frameInWindow = [view convertRect:viewBounds toView:nil];
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1436
        rect = [[view window] convertRectToScreen:frameInWindow];
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1437
        NSRect screenRect = [[NSScreen mainScreen] frame];
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1438
        //Convert coordinates to top-left corner origin
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1439
        rect.origin.y = screenRect.size.height - rect.origin.y - viewBounds.size.height;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1440
    }];
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1441
    jRect = NSToJavaRect(env, rect);
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1442
    
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1443
    JNF_COCOA_EXIT(env);
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1444
    
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1445
    return jRect;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1446
}
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1447
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1448
/*
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1449
 * Class:     sun_lwawt_macosx_CPlatformView
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1450
 * Method:    nativeIsViewUnderMouse
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1451
 * Signature: (J)Z;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1452
 */
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1453
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1454
JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_CPlatformView_nativeIsViewUnderMouse
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1455
(JNIEnv *env, jclass clazz, jlong viewPtr)
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1456
{
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1457
    __block jboolean underMouse = JNI_FALSE;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1458
    
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1459
    JNF_COCOA_ENTER(env);
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1460
    
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1461
    NSView *nsView = OBJC(viewPtr);
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1462
    [ThreadUtilities performOnMainThreadWaiting:YES block:^(){       
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1463
        NSPoint ptWindowCoords = [[nsView window] mouseLocationOutsideOfEventStream];
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1464
        NSPoint ptViewCoords = [nsView convertPoint:ptWindowCoords fromView:nil];
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1465
        underMouse = [nsView hitTest:ptViewCoords] != nil;
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1466
    }];
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1467
    
36897
086e09a30b77 8148555: [macosx] An uncaught exception was raised entering Emoji into JTextArea
aniyogi
parents: 36462
diff changeset
  1468
    JNF_COCOA_EXIT(env);
14753
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1469
    
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1470
    return underMouse;
a56a685d137f 7154778: [macosx] NSView-based implementation of sun.awt.EmbeddedFrame
serb
parents: 14306
diff changeset
  1471
}