jdk/src/macosx/native/sun/awt/AWTWindow.m
author leonidr
Fri, 02 Nov 2012 19:20:03 +0400
changeset 14311 b2492ea8d08e
parent 14165 dcb1f9388f85
child 14648 2ef7c7edb4b0
permissions -rw-r--r--
7124310: [macosx] "opposite" seems always null in focus events Reviewed-by: anthony
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
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
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
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    26
#import <Cocoa/Cocoa.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    27
#import <JavaNativeFoundation/JavaNativeFoundation.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    28
#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    29
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    30
#import "sun_lwawt_macosx_CPlatformWindow.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    31
#import "com_apple_eawt_event_GestureHandler.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    32
#import "com_apple_eawt_FullScreenHandler.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    33
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    34
#import "AWTWindow.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    35
#import "AWTView.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    36
#import "CMenu.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    37
#import "CMenuBar.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    38
#import "LWCToolkit.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    39
#import "GeomUtilities.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    40
#import "ThreadUtilities.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    41
#import "OSVersion.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    42
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    43
#define MASK(KEY) \
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    44
    (sun_lwawt_macosx_CPlatformWindow_ ## KEY)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    45
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    46
#define IS(BITS, KEY) \
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    47
    ((BITS & MASK(KEY)) != 0)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    48
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    49
#define SET(BITS, KEY, VALUE) \
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    50
    BITS = VALUE ? BITS | MASK(KEY) : BITS & ~MASK(KEY)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    51
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    52
static JNF_CLASS_CACHE(jc_CPlatformWindow, "sun/lwawt/macosx/CPlatformWindow");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    53
14311
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
    54
// Cocoa windowDidBecomeKey/windowDidResignKey notifications
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
    55
// doesn't provide information about "opposite" window, so we
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
    56
// have to do a bit of tracking. This variable points to a window
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
    57
// which had been the key window just before a new key window
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
    58
// was set. It would be nil if the new key window isn't an AWT 
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
    59
// window or the app currently has no key window.
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
    60
static AWTWindow* lastKeyWindow = nil;
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
    61
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    62
// --------------------------------------------------------------
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    63
// NSWindow/NSPanel descendants implementation
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    64
#define AWT_NS_WINDOW_IMPLEMENTATION                            \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    65
- (id) initWithDelegate:(AWTWindow *)delegate                   \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    66
              frameRect:(NSRect)contectRect                     \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    67
              styleMask:(NSUInteger)styleMask                   \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    68
            contentView:(NSView *)view                          \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    69
{                                                               \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    70
    self = [super initWithContentRect:contectRect               \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    71
                            styleMask:styleMask                 \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    72
                              backing:NSBackingStoreBuffered    \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    73
                                defer:NO];                      \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    74
                                                                \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    75
    if (self == nil) return nil;                                \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    76
                                                                \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    77
    [self setDelegate:delegate];                                \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    78
    [self setContentView:view];                                 \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    79
    [self setInitialFirstResponder:view];                       \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    80
    [self setReleasedWhenClosed:NO];                            \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    81
    [self setPreservesContentDuringLiveResize:YES];             \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    82
                                                                \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    83
    return self;                                                \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    84
}                                                               \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    85
                                                                \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    86
/* NSWindow overrides */                                        \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    87
- (BOOL) canBecomeKeyWindow {                                   \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    88
    return [(AWTWindow*)[self delegate] canBecomeKeyWindow];    \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    89
}                                                               \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    90
                                                                \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    91
- (BOOL) canBecomeMainWindow {                                  \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    92
    return [(AWTWindow*)[self delegate] canBecomeMainWindow];   \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    93
}                                                               \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    94
                                                                \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    95
- (BOOL) worksWhenModal {                                       \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    96
    return [(AWTWindow*)[self delegate] worksWhenModal];        \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    97
}                                                               \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    98
                                                                \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
    99
- (void)sendEvent:(NSEvent *)event {                            \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   100
    [(AWTWindow*)[self delegate] sendEvent:event];              \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   101
    [super sendEvent:event];                                    \
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   102
}
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   103
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   104
@implementation AWTWindow_Normal
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   105
AWT_NS_WINDOW_IMPLEMENTATION
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   106
@end
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   107
@implementation AWTWindow_Panel
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   108
AWT_NS_WINDOW_IMPLEMENTATION
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   109
@end
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   110
// END of NSWindow/NSPanel descendants implementation
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   111
// --------------------------------------------------------------
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   112
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   113
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   114
@implementation AWTWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   115
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   116
@synthesize nsWindow;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   117
@synthesize javaPlatformWindow;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   118
@synthesize javaMenuBar;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   119
@synthesize javaMinSize;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   120
@synthesize javaMaxSize;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   121
@synthesize styleBits;
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   122
@synthesize isEnabled;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   123
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   124
- (void) updateMinMaxSize:(BOOL)resizable {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   125
    if (resizable) {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   126
        [self.nsWindow setMinSize:self.javaMinSize];
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   127
        [self.nsWindow setMaxSize:self.javaMaxSize];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   128
    } else {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   129
        NSRect currentFrame = [self.nsWindow frame];
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   130
        [self.nsWindow setMinSize:currentFrame.size];
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   131
        [self.nsWindow setMaxSize:currentFrame.size];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   132
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   133
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   134
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   135
// creates a new NSWindow style mask based on the _STYLE_PROP_BITMASK bits
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   136
+ (NSUInteger) styleMaskForStyleBits:(jint)styleBits {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   137
    NSUInteger type = 0;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   138
    if (IS(styleBits, DECORATED)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   139
        type |= NSTitledWindowMask;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   140
        if (IS(styleBits, CLOSEABLE))   type |= NSClosableWindowMask;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   141
        if (IS(styleBits, MINIMIZABLE)) type |= NSMiniaturizableWindowMask;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   142
        if (IS(styleBits, RESIZABLE))   type |= NSResizableWindowMask;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   143
    } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   144
        type |= NSBorderlessWindowMask;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   145
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   146
12177
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12047
diff changeset
   147
    if (IS(styleBits, TEXTURED))      type |= NSTexturedBackgroundWindowMask;
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12047
diff changeset
   148
    if (IS(styleBits, UNIFIED))       type |= NSUnifiedTitleAndToolbarWindowMask;
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12047
diff changeset
   149
    if (IS(styleBits, UTILITY))       type |= NSUtilityWindowMask;
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12047
diff changeset
   150
    if (IS(styleBits, HUD))           type |= NSHUDWindowMask;
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12047
diff changeset
   151
    if (IS(styleBits, SHEET))         type |= NSDocModalWindowMask;
7b84ed7d0efa 7150349: [macosx] Applets attempting to show popup menus activate the applet process
dcherepanov
parents: 12047
diff changeset
   152
    if (IS(styleBits, NONACTIVATING)) type |= NSNonactivatingPanelMask;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   153
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   154
    return type;
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
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   157
// updates _METHOD_PROP_BITMASK based properties on the window
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   158
- (void) setPropertiesForStyleBits:(jint)bits mask:(jint)mask {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   159
    if (IS(mask, RESIZABLE)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   160
        BOOL resizable = IS(bits, RESIZABLE);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   161
        [self updateMinMaxSize:resizable];
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   162
        [self.nsWindow setShowsResizeIndicator:resizable];
12047
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
    if (IS(mask, HAS_SHADOW)) {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   166
        [self.nsWindow setHasShadow:IS(bits, HAS_SHADOW)];
12047
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
    if (IS(mask, ZOOMABLE)) {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   170
        [[self.nsWindow standardWindowButton:NSWindowZoomButton] setEnabled:IS(bits, ZOOMABLE)];
12047
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
    if (IS(mask, ALWAYS_ON_TOP)) {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   174
        [self.nsWindow setLevel:IS(bits, ALWAYS_ON_TOP) ? NSFloatingWindowLevel : NSNormalWindowLevel];
12047
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
    if (IS(mask, HIDES_ON_DEACTIVATE)) {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   178
        [self.nsWindow setHidesOnDeactivate:IS(bits, HIDES_ON_DEACTIVATE)];
12047
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
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   181
    if (IS(mask, DRAGGABLE_BACKGROUND)) {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   182
        [self.nsWindow setMovableByWindowBackground:IS(bits, DRAGGABLE_BACKGROUND)];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   183
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   184
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   185
    if (IS(mask, DOCUMENT_MODIFIED)) {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   186
        [self.nsWindow setDocumentEdited:IS(bits, DOCUMENT_MODIFIED)];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   187
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   188
13777
c94cf7e1bac2 7197320: [macosx] Full Screen option missing when Window.documentModified
alexsch
parents: 13647
diff changeset
   189
    if (IS(mask, FULLSCREENABLE) && [self.nsWindow respondsToSelector:@selector(toggleFullScreen:)]) {
c94cf7e1bac2 7197320: [macosx] Full Screen option missing when Window.documentModified
alexsch
parents: 13647
diff changeset
   190
        if (IS(bits, FULLSCREENABLE)) {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   191
            [self.nsWindow setCollectionBehavior:(1 << 7) /*NSWindowCollectionBehaviorFullScreenPrimary*/];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   192
        } else {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   193
            [self.nsWindow setCollectionBehavior:NSWindowCollectionBehaviorDefault];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   194
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   195
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   196
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   197
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   198
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   199
- (id) initWithPlatformWindow:(JNFWeakJObjectWrapper *)platformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   200
                    styleBits:(jint)bits
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   201
                    frameRect:(NSRect)rect
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   202
                  contentView:(NSView *)view
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   203
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   204
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   205
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   206
    NSUInteger styleMask = [AWTWindow styleMaskForStyleBits:bits];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   207
    NSRect contentRect = rect; //[NSWindow contentRectForFrameRect:rect styleMask:styleMask];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   208
    if (contentRect.size.width <= 0.0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   209
        contentRect.size.width = 1.0;
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
    if (contentRect.size.height <= 0.0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   212
        contentRect.size.height = 1.0;
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
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   215
    self = [super init];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   216
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   217
    if (self == nil) return nil; // no hope
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   218
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   219
    if (IS(bits, UTILITY) ||
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   220
        IS(bits, NONACTIVATING) ||
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   221
        IS(bits, HUD) ||
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   222
        IS(bits, HIDES_ON_DEACTIVATE))
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   223
    {
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   224
        self.nsWindow = [[AWTWindow_Panel alloc] initWithDelegate:self
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   225
                            frameRect:contentRect
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   226
                            styleMask:styleMask
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   227
                          contentView:view];
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   228
    }
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   229
    else
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   230
    {
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   231
        // These windows will appear in the window list in the dock icon menu
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   232
        self.nsWindow = [[AWTWindow_Normal alloc] initWithDelegate:self
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   233
                            frameRect:contentRect
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   234
                            styleMask:styleMask
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   235
                          contentView:view];
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   236
    }
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   237
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   238
    if (self.nsWindow == nil) return nil; // no hope either
13009
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
   239
    [self.nsWindow release]; // the property retains the object already
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   240
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   241
    self.isEnabled = YES;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   242
    self.javaPlatformWindow = platformWindow;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   243
    self.styleBits = bits;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   244
    [self setPropertiesForStyleBits:styleBits mask:MASK(_METHOD_PROP_BITMASK)];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   245
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   246
    return self;
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
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   249
+ (BOOL) isAWTWindow:(NSWindow *)window {
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   250
    return [window isKindOfClass: [AWTWindow_Panel class]] || [window isKindOfClass: [AWTWindow_Normal class]];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   251
}
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   252
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   253
// returns id for the topmost window under mouse
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   254
+ (NSInteger) getTopmostWindowUnderMouseID {
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   255
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   256
    NSRect screenRect = [[NSScreen mainScreen] frame];
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   257
    NSPoint nsMouseLocation = [NSEvent mouseLocation];
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   258
    CGPoint cgMouseLocation = CGPointMake(nsMouseLocation.x, screenRect.size.height - nsMouseLocation.y);
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   259
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   260
    NSMutableArray *windows = (NSMutableArray *)CGWindowListCopyWindowInfo(kCGWindowListOptionOnScreenOnly | kCGWindowListExcludeDesktopElements, kCGNullWindowID);
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   261
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   262
    for (NSDictionary *window in windows) {
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   263
        NSInteger layer = [[window objectForKey:(id)kCGWindowLayer] integerValue];
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   264
        if (layer == 0) {
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   265
            CGRect rect;
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   266
            CGRectMakeWithDictionaryRepresentation((CFDictionaryRef)[window objectForKey:(id)kCGWindowBounds], &rect);
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   267
            if (CGRectContainsPoint(rect, cgMouseLocation)) {
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   268
                return [[window objectForKey:(id)kCGWindowNumber] integerValue];
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   269
            }
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   270
        }
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   271
    }
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   272
    return -1;
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   273
}
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   274
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   275
// checks that this window is under the mouse cursor and this point is not overlapped by others windows
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   276
- (BOOL) isTopmostWindowUnderMouse {
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   277
    return [self.nsWindow windowNumber] == [AWTWindow getTopmostWindowUnderMouseID];
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   278
}
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   279
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   280
+ (AWTWindow *) getTopmostWindowUnderMouse {
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   281
    NSEnumerator *windowEnumerator = [[NSApp windows] objectEnumerator];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   282
    NSWindow *window;
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   283
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   284
    NSInteger topmostWindowUnderMouseID = [AWTWindow getTopmostWindowUnderMouseID];
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   285
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   286
    while ((window = [windowEnumerator nextObject]) != nil) {
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   287
        if ([window windowNumber] == topmostWindowUnderMouseID) {
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   288
            BOOL isAWTWindow = [AWTWindow isAWTWindow: window];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   289
            return isAWTWindow ? (AWTWindow *) [window delegate] : nil;
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   290
        }
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   291
    }
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   292
    return nil;
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   293
}
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   294
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   295
+ (void) synthesizeMouseEnteredExitedEvents:(NSWindow*)window withType:(NSEventType)eventType {
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   296
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   297
    NSPoint screenLocation = [NSEvent mouseLocation];
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   298
    NSPoint windowLocation = [window convertScreenToBase: screenLocation];
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   299
    int modifierFlags = (eventType == NSMouseEntered) ? NSMouseEnteredMask : NSMouseExitedMask;
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   300
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   301
    NSEvent *mouseEvent = [NSEvent enterExitEventWithType: eventType
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   302
                                                 location: windowLocation
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   303
                                            modifierFlags: modifierFlags
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   304
                                                timestamp: 0
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   305
                                             windowNumber: [window windowNumber]
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   306
                                                  context: nil
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   307
                                              eventNumber: 0
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   308
                                           trackingNumber: 0
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   309
                                                 userData: nil
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   310
                           ];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   311
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   312
    [[window contentView] deliverJavaMouseEvent: mouseEvent];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   313
}
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   314
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   315
+ (void) synthesizeMouseEnteredExitedEventsForAllWindows {
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   316
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   317
    NSInteger topmostWindowUnderMouseID = [AWTWindow getTopmostWindowUnderMouseID];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   318
    NSArray *windows = [NSApp windows];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   319
    NSWindow *window;
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   320
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   321
    NSEnumerator *windowEnumerator = [windows objectEnumerator];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   322
    while ((window = [windowEnumerator nextObject]) != nil) {
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   323
        if ([AWTWindow isAWTWindow: window]) {
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   324
            BOOL isUnderMouse = ([window windowNumber] == topmostWindowUnderMouseID);
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   325
            BOOL mouseIsOver = [[window contentView] mouseIsOver];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   326
            if (isUnderMouse && !mouseIsOver) {
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   327
                [AWTWindow synthesizeMouseEnteredExitedEvents:window withType:NSMouseEntered];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   328
            } else if (!isUnderMouse && mouseIsOver) {
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   329
                [AWTWindow synthesizeMouseEnteredExitedEvents:window withType:NSMouseExited];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   330
            }
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   331
        }
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   332
    }
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   333
}
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
   334
14165
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
   335
+ (NSNumber *) getNSWindowDisplayID_AppKitThread:(NSWindow *)window {
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
   336
    AWT_ASSERT_APPKIT_THREAD;
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
   337
    NSScreen *screen = [window screen];
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
   338
    NSDictionary *deviceDescription = [screen deviceDescription];
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
   339
    return [deviceDescription objectForKey:@"NSScreenNumber"];
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
   340
}
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
   341
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   342
- (void) dealloc {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   343
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   344
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   345
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   346
    [self.javaPlatformWindow setJObject:nil withEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   347
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   348
    self.nsWindow = nil;
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   349
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   350
    [super dealloc];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   351
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   352
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   353
// NSWindow overrides
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   354
- (BOOL) canBecomeKeyWindow {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   355
AWT_ASSERT_APPKIT_THREAD;
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   356
    return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_KEY);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   357
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   358
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   359
- (BOOL) canBecomeMainWindow {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   360
AWT_ASSERT_APPKIT_THREAD;
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   361
    return self.isEnabled && IS(self.styleBits, SHOULD_BECOME_MAIN);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   362
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   363
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   364
- (BOOL) worksWhenModal {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   365
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   366
    return IS(self.styleBits, MODAL_EXCLUDED);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   367
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   368
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   369
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   370
// Gesture support
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   371
- (void)postGesture:(NSEvent *)event as:(jint)type a:(jdouble)a b:(jdouble)b {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   372
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   373
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   374
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   375
    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   376
    if (platformWindow != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   377
        // extract the target AWT Window object out of the CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   378
        static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   379
        jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   380
        if (awtWindow != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   381
            // translate the point into Java coordinates
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   382
            NSPoint loc = [event locationInWindow];
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   383
            loc.y = [self.nsWindow frame].size.height - loc.y;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   384
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   385
            // send up to the GestureHandler to recursively dispatch on the AWT event thread
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   386
            static JNF_CLASS_CACHE(jc_GestureHandler, "com/apple/eawt/event/GestureHandler");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   387
            static JNF_STATIC_MEMBER_CACHE(sjm_handleGestureFromNative, jc_GestureHandler, "handleGestureFromNative", "(Ljava/awt/Window;IDDDD)V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   388
            JNFCallStaticVoidMethod(env, sjm_handleGestureFromNative, awtWindow, type, (jdouble)loc.x, (jdouble)loc.y, (jdouble)a, (jdouble)b);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   389
            (*env)->DeleteLocalRef(env, awtWindow);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   390
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   391
        (*env)->DeleteLocalRef(env, platformWindow);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   392
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   393
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   394
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   395
- (void)beginGestureWithEvent:(NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   396
    [self postGesture:event
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   397
                   as:com_apple_eawt_event_GestureHandler_PHASE
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   398
                    a:-1.0
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   399
                    b:0.0];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   400
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   401
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   402
- (void)endGestureWithEvent:(NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   403
    [self postGesture:event
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   404
                   as:com_apple_eawt_event_GestureHandler_PHASE
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   405
                    a:1.0
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   406
                    b:0.0];
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
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   409
- (void)magnifyWithEvent:(NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   410
    [self postGesture:event
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   411
                   as:com_apple_eawt_event_GestureHandler_MAGNIFY
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   412
                    a:[event magnification]
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   413
                    b:0.0];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   414
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   415
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   416
- (void)rotateWithEvent:(NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   417
    [self postGesture:event
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   418
                   as:com_apple_eawt_event_GestureHandler_ROTATE
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   419
                    a:[event rotation]
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   420
                    b:0.0];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   421
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   422
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   423
- (void)swipeWithEvent:(NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   424
    [self postGesture:event
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   425
                   as:com_apple_eawt_event_GestureHandler_SWIPE
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   426
                    a:[event deltaX]
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   427
                    b:[event deltaY]];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   428
}
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
// NSWindowDelegate methods
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   432
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   433
- (void) _deliverMoveResizeEvent {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   434
AWT_ASSERT_APPKIT_THREAD;
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
    // deliver the event if this is a user-initiated live resize or as a side-effect
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   437
    // of a Java initiated resize, because AppKit can override the bounds and force
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   438
    // the bounds of the window to avoid the Dock or remain on screen.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   439
    [AWTToolkit eventCountPlusPlus];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   440
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   441
    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   442
    if (platformWindow == NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   443
        // TODO: create generic AWT assert
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   444
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   445
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   446
    NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   447
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   448
    static JNF_MEMBER_CACHE(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIII)V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   449
    JNFCallVoidMethod(env, platformWindow, jm_deliverMoveResizeEvent,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   450
                      (jint)frame.origin.x,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   451
                      (jint)frame.origin.y,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   452
                      (jint)frame.size.width,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   453
                      (jint)frame.size.height);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   454
    (*env)->DeleteLocalRef(env, platformWindow);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   455
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   456
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   457
- (void)windowDidMove:(NSNotification *)notification {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   458
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   459
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   460
    [self _deliverMoveResizeEvent];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   461
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   462
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   463
- (void)windowDidResize:(NSNotification *)notification {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   464
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   465
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   466
    [self _deliverMoveResizeEvent];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   467
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   468
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   469
- (void)windowDidExpose:(NSNotification *)notification {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   470
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   471
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   472
    [AWTToolkit eventCountPlusPlus];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   473
    // TODO: don't see this callback invoked anytime so we track
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   474
    // window exposing in _setVisible:(BOOL)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   475
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   476
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   477
- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)proposedFrame {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   478
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   479
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   480
    [AWTToolkit eventCountPlusPlus];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   481
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   482
    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   483
    if (platformWindow != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   484
        static JNF_MEMBER_CACHE(jm_deliverZoom, jc_CPlatformWindow, "deliverZoom", "(Z)V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   485
        JNFCallVoidMethod(env, platformWindow, jm_deliverZoom, ![window isZoomed]);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   486
        (*env)->DeleteLocalRef(env, platformWindow);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   487
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   488
    return YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   489
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   490
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   491
- (void) _deliverIconify:(BOOL)iconify {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   492
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   493
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   494
    [AWTToolkit eventCountPlusPlus];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   495
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   496
    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   497
    if (platformWindow != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   498
        static JNF_MEMBER_CACHE(jm_deliverIconify, jc_CPlatformWindow, "deliverIconify", "(Z)V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   499
        JNFCallVoidMethod(env, platformWindow, jm_deliverIconify, iconify);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   500
        (*env)->DeleteLocalRef(env, platformWindow);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   501
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   502
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   503
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   504
- (void)windowDidMiniaturize:(NSNotification *)notification {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   505
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   506
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   507
    [self _deliverIconify:JNI_TRUE];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   508
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   509
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   510
- (void)windowDidDeminiaturize:(NSNotification *)notification {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   511
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   512
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   513
    [self _deliverIconify:JNI_FALSE];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   514
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   515
14311
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   516
- (void) _deliverWindowFocusEvent:(BOOL)focused oppositeWindow:(AWTWindow *)opposite {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   517
//AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   518
    JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   519
    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   520
    if (platformWindow != NULL) {
14311
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   521
        jobject oppositeWindow = [opposite.javaPlatformWindow jObjectWithEnv:env];
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   522
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   523
        static JNF_MEMBER_CACHE(jm_deliverWindowFocusEvent, jc_CPlatformWindow, "deliverWindowFocusEvent", "(ZLsun/lwawt/macosx/CPlatformWindow;)V");
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   524
        JNFCallVoidMethod(env, platformWindow, jm_deliverWindowFocusEvent, (jboolean)focused, oppositeWindow);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   525
        (*env)->DeleteLocalRef(env, platformWindow);
14311
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   526
        (*env)->DeleteLocalRef(env, oppositeWindow);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   527
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   528
}
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
- (void) windowDidBecomeKey: (NSNotification *) notification {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   532
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   533
    [AWTToolkit eventCountPlusPlus];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   534
    [CMenuBar activate:self.javaMenuBar modallyDisabled:NO];
14311
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   535
    AWTWindow *opposite = [AWTWindow lastKeyWindow];
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   536
    [AWTWindow setLastKeyWindow:nil];
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   537
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   538
    [self _deliverWindowFocusEvent:YES oppositeWindow: opposite];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   539
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   540
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   541
- (void) windowDidResignKey: (NSNotification *) notification {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   542
    // TODO: check why sometimes at start is invoked *not* on AppKit main thread.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   543
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   544
    [AWTToolkit eventCountPlusPlus];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   545
    [self.javaMenuBar deactivate];
14311
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   546
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   547
    // the new key window
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   548
    NSWindow *keyWindow = [NSApp keyWindow];
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   549
    AWTWindow *opposite = nil;
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   550
    if ([AWTWindow isAWTWindow: keyWindow]) {
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   551
        opposite = (AWTWindow *)[keyWindow delegate];
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   552
        [AWTWindow setLastKeyWindow: self];
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   553
    } else {
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   554
        [AWTWindow setLastKeyWindow: nil];
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   555
    }
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   556
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   557
    [self _deliverWindowFocusEvent:NO oppositeWindow: opposite];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   558
}
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
- (void) windowDidBecomeMain: (NSNotification *) notification {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   561
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   562
    [AWTToolkit eventCountPlusPlus];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   563
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   564
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   565
    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   566
    if (platformWindow != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   567
        static JNF_MEMBER_CACHE(jm_windowDidBecomeMain, jc_CPlatformWindow, "windowDidBecomeMain", "()V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   568
        JNFCallVoidMethod(env, platformWindow, jm_windowDidBecomeMain);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   569
        (*env)->DeleteLocalRef(env, platformWindow);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   570
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   571
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   572
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   573
- (BOOL)windowShouldClose:(id)sender {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   574
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   575
    [AWTToolkit eventCountPlusPlus];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   576
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   577
    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   578
    if (platformWindow != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   579
        static JNF_MEMBER_CACHE(jm_deliverWindowClosingEvent, jc_CPlatformWindow, "deliverWindowClosingEvent", "()V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   580
        JNFCallVoidMethod(env, platformWindow, jm_deliverWindowClosingEvent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   581
        (*env)->DeleteLocalRef(env, platformWindow);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   582
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   583
    // The window will be closed (if allowed) as result of sending Java event
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   584
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   585
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   586
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   587
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   588
- (void)_notifyFullScreenOp:(jint)op withEnv:(JNIEnv *)env {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   589
    static JNF_CLASS_CACHE(jc_FullScreenHandler, "com/apple/eawt/FullScreenHandler");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   590
    static JNF_STATIC_MEMBER_CACHE(jm_notifyFullScreenOperation, jc_FullScreenHandler, "handleFullScreenEventFromNative", "(Ljava/awt/Window;I)V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   591
    static JNF_MEMBER_CACHE(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   592
    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   593
    if (platformWindow != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   594
        jobject awtWindow = JNFGetObjectField(env, platformWindow, jf_target);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   595
        if (awtWindow != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   596
            JNFCallStaticVoidMethod(env, jm_notifyFullScreenOperation, awtWindow, op);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   597
            (*env)->DeleteLocalRef(env, awtWindow);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   598
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   599
        (*env)->DeleteLocalRef(env, platformWindow);
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
}
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
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   604
- (void)windowWillEnterFullScreen:(NSNotification *)notification {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   605
    static JNF_MEMBER_CACHE(jm_windowWillEnterFullScreen, jc_CPlatformWindow, "windowWillEnterFullScreen", "()V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   606
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   607
    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   608
    if (platformWindow != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   609
        JNFCallVoidMethod(env, platformWindow, jm_windowWillEnterFullScreen);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   610
        [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_ENTER withEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   611
        (*env)->DeleteLocalRef(env, platformWindow);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   612
    }
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
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   615
- (void)windowDidEnterFullScreen:(NSNotification *)notification {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   616
    static JNF_MEMBER_CACHE(jm_windowDidEnterFullScreen, jc_CPlatformWindow, "windowDidEnterFullScreen", "()V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   617
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   618
    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   619
    if (platformWindow != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   620
        JNFCallVoidMethod(env, platformWindow, jm_windowDidEnterFullScreen);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   621
        [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_ENTER withEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   622
        (*env)->DeleteLocalRef(env, platformWindow);
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
}
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
- (void)windowWillExitFullScreen:(NSNotification *)notification {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   627
    static JNF_MEMBER_CACHE(jm_windowWillExitFullScreen, jc_CPlatformWindow, "windowWillExitFullScreen", "()V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   628
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   629
    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   630
    if (platformWindow != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   631
        JNFCallVoidMethod(env, platformWindow, jm_windowWillExitFullScreen);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   632
        [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_WILL_EXIT withEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   633
        (*env)->DeleteLocalRef(env, platformWindow);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   634
    }
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
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   637
- (void)windowDidExitFullScreen:(NSNotification *)notification {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   638
    static JNF_MEMBER_CACHE(jm_windowDidExitFullScreen, jc_CPlatformWindow, "windowDidExitFullScreen", "()V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   639
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   640
    jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   641
    if (platformWindow != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   642
        JNFCallVoidMethod(env, platformWindow, jm_windowDidExitFullScreen);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   643
        [self _notifyFullScreenOp:com_apple_eawt_FullScreenHandler_FULLSCREEN_DID_EXIT withEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   644
        (*env)->DeleteLocalRef(env, platformWindow);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   645
    }
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
- (void)sendEvent:(NSEvent *)event {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   649
        if ([event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   650
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   651
            NSPoint p = [NSEvent mouseLocation];
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   652
            NSRect frame = [self.nsWindow frame];
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   653
            NSRect contentRect = [self.nsWindow contentRectForFrameRect:frame];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   654
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   655
            // Check if the click happened in the non-client area (title bar)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   656
            if (p.y >= (frame.origin.y + contentRect.size.height)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   657
                JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   658
                jobject platformWindow = [self.javaPlatformWindow jObjectWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   659
                // Currently, no need to deliver the whole NSEvent.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   660
                static JNF_MEMBER_CACHE(jm_deliverNCMouseDown, jc_CPlatformWindow, "deliverNCMouseDown", "()V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   661
                JNFCallVoidMethod(env, platformWindow, jm_deliverNCMouseDown);
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
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   664
}
12402
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   665
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   666
- (void)constrainSize:(NSSize*)size {
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   667
    float minWidth = 0.f, minHeight = 0.f;
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   668
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   669
    if (IS(self.styleBits, DECORATED)) {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   670
        NSRect frame = [self.nsWindow frame];
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   671
        NSRect contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[self.nsWindow styleMask]];
12402
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   672
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   673
        float top = frame.size.height - contentRect.size.height;
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   674
        float left = contentRect.origin.x - frame.origin.x;
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   675
        float bottom = contentRect.origin.y - frame.origin.y;
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   676
        float right = frame.size.width - (contentRect.size.width + left);
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   677
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   678
        // Speculative estimation: 80 - enough for window decorations controls
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   679
        minWidth += left + right + 80;
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   680
        minHeight += top + bottom;
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   681
    }
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   682
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   683
    minWidth = MAX(1.f, minWidth);
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   684
    minHeight = MAX(1.f, minHeight);
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   685
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   686
    size->width = MAX(size->width, minWidth);
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   687
    size->height = MAX(size->height, minHeight);
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   688
}
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   689
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   690
- (void) setEnabled: (BOOL)flag {
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   691
    self.isEnabled = flag;
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   692
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   693
    if (IS(self.styleBits, CLOSEABLE)) {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   694
        [[self.nsWindow standardWindowButton:NSWindowCloseButton] setEnabled: flag];
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   695
    }
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   696
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   697
    if (IS(self.styleBits, MINIMIZABLE)) {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   698
        [[self.nsWindow standardWindowButton:NSWindowMiniaturizeButton] setEnabled: flag];
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   699
    }
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   700
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   701
    if (IS(self.styleBits, ZOOMABLE)) {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   702
        [[self.nsWindow standardWindowButton:NSWindowZoomButton] setEnabled: flag];
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   703
    }
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   704
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   705
    if (IS(self.styleBits, RESIZABLE)) {
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   706
        [self updateMinMaxSize:flag];
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   707
        [self.nsWindow setShowsResizeIndicator:flag];
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   708
    }
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   709
}
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   710
14311
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   711
+ (void) setLastKeyWindow:(AWTWindow *)window {
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   712
    [window retain];
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   713
    [lastKeyWindow release];
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   714
    lastKeyWindow = window;
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   715
}
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   716
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   717
+ (AWTWindow *) lastKeyWindow {
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   718
    return lastKeyWindow;
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   719
}
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   720
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
   721
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   722
@end // AWTWindow
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
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   726
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   727
 * Method:    nativeCreateNSWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   728
 * Signature: (JJIIII)J
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
JNIEXPORT jlong JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeCreateNSWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   731
(JNIEnv *env, jobject obj, jlong contentViewPtr, jlong styleBits, jdouble x, jdouble y, jdouble w, jdouble h)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   732
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   733
    __block AWTWindow *window = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   734
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   735
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   736
AWT_ASSERT_NOT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   737
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   738
    JNFWeakJObjectWrapper *platformWindow = [JNFWeakJObjectWrapper wrapperWithJObject:obj withEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   739
    NSView *contentView = OBJC(contentViewPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   740
    NSRect frameRect = NSMakeRect(x, y, w, h);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   741
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   742
    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   743
        AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   744
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   745
        window = [[AWTWindow alloc] initWithPlatformWindow:platformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   746
                                                  styleBits:styleBits
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   747
                                                  frameRect:frameRect
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   748
                                                contentView:contentView];
13009
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
   749
        // the window is released is CPlatformWindow.nativeDispose()
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   750
13009
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
   751
        if (window) CFRetain(window.nsWindow);
12047
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
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   754
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   755
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   756
    return ptr_to_jlong(window ? window.nsWindow : nil);
12047
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
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
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   761
 * Method:    nativeSetNSWindowStyleBits
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   762
 * Signature: (JII)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   763
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   764
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowStyleBits
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   765
(JNIEnv *env, jclass clazz, jlong windowPtr, jint mask, jint bits)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   766
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   767
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   768
AWT_ASSERT_NOT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   769
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   770
    NSWindow *nsWindow = OBJC(windowPtr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   771
    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   772
        AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   773
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   774
        AWTWindow *window = (AWTWindow*)[nsWindow delegate];
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   775
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   776
        // scans the bit field, and only updates the values requested by the mask
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   777
        // (this implicity handles the _CALLBACK_PROP_BITMASK case, since those are passive reads)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   778
        jint newBits = window.styleBits & ~mask | bits & mask;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   779
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   780
        // resets the NSWindow's style mask if the mask intersects any of those bits
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   781
        if (mask & MASK(_STYLE_PROP_BITMASK)) {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   782
            [nsWindow setStyleMask:[AWTWindow styleMaskForStyleBits:newBits]];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   783
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   784
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   785
        // calls methods on NSWindow to change other properties, based on the mask
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   786
        if (mask & MASK(_METHOD_PROP_BITMASK)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   787
            [window setPropertiesForStyleBits:bits mask:mask];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   788
        }
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
        window.styleBits = newBits;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   791
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   792
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   793
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   794
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   795
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   796
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   797
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   798
 * Method:    nativeSetNSWindowMenuBar
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   799
 * Signature: (JJ)V
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
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMenuBar
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   802
(JNIEnv *env, jclass clazz, jlong windowPtr, jlong menuBarPtr)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   803
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   804
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   805
AWT_ASSERT_NOT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   806
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   807
    NSWindow *nsWindow = OBJC(windowPtr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   808
    CMenuBar *menuBar = OBJC(menuBarPtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   809
    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   810
        AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   811
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   812
        AWTWindow *window = (AWTWindow*)[nsWindow delegate];
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   813
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   814
        if ([nsWindow isKeyWindow]) [window.javaMenuBar deactivate];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   815
        window.javaMenuBar = menuBar;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   816
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   817
        // if ([self isKeyWindow]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   818
        [CMenuBar activate:window.javaMenuBar modallyDisabled:NO];
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
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   822
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   823
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   824
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   825
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   826
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   827
 * Method:    nativeGetNSWindowInsets
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   828
 * Signature: (J)Ljava/awt/Insets;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   829
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   830
JNIEXPORT jobject JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowInsets
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   831
(JNIEnv *env, jclass clazz, jlong windowPtr)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   832
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   833
    jobject ret = NULL;
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
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   836
AWT_ASSERT_NOT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   837
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   838
    NSWindow *nsWindow = OBJC(windowPtr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   839
    __block NSRect contentRect = NSZeroRect;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   840
    __block NSRect frame = NSZeroRect;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   841
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   842
    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   843
        AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   844
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   845
        frame = [nsWindow frame];
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   846
        contentRect = [NSWindow contentRectForFrameRect:frame styleMask:[nsWindow styleMask]];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   847
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   848
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   849
    jint top = (jint)(frame.size.height - contentRect.size.height);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   850
    jint left = (jint)(contentRect.origin.x - frame.origin.x);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   851
    jint bottom = (jint)(contentRect.origin.y - frame.origin.y);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   852
    jint right = (jint)(frame.size.width - (contentRect.size.width + left));
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   853
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   854
    static JNF_CLASS_CACHE(jc_Insets, "java/awt/Insets");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   855
    static JNF_CTOR_CACHE(jc_Insets_ctor, jc_Insets, "(IIII)V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   856
    ret = JNFNewObject(env, jc_Insets_ctor, top, left, bottom, right);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   857
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   858
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   859
    return ret;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   860
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   861
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   862
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   863
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   864
 * Method:    nativeSetNSWindowBounds
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   865
 * Signature: (JDDDD)V
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
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowBounds
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   868
(JNIEnv *env, jclass clazz, jlong windowPtr, jdouble originX, jdouble originY, jdouble width, jdouble height)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   869
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   870
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   871
AWT_ASSERT_NOT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   872
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   873
    NSRect jrect = NSMakeRect(originX, originY, width, height);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   874
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   875
    // TODO: not sure we need displayIfNeeded message in our view
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   876
    NSWindow *nsWindow = OBJC(windowPtr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   877
    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   878
        AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   879
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   880
        AWTWindow *window = (AWTWindow*)[nsWindow delegate];
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   881
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   882
        NSRect rect = ConvertNSScreenRect(NULL, jrect);
12402
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   883
        [window constrainSize:&rect.size];
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   884
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   885
        [nsWindow setFrame:rect display:YES];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   886
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   887
        // only start tracking events if pointer is above the toplevel
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   888
        // TODO: should post an Entered event if YES.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   889
        NSPoint mLocation = [NSEvent mouseLocation];
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   890
        [nsWindow setAcceptsMouseMovedEvents:NSPointInRect(mLocation, rect)];
12047
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
        // ensure we repaint the whole window after the resize operation
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   893
        // (this will also re-enable screen updates, which were disabled above)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   894
        // TODO: send PaintEvent
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
   895
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
   896
        [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   897
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   898
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   899
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   900
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   901
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   902
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   903
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   904
 * Method:    nativeSetNSWindowMinMax
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   905
 * Signature: (JDDDD)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   906
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   907
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMinMax
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   908
(JNIEnv *env, jclass clazz, jlong windowPtr, jdouble minW, jdouble minH, jdouble maxW, jdouble maxH)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   909
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   910
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   911
AWT_ASSERT_NOT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   912
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   913
    if (minW < 1) minW = 1;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   914
    if (minH < 1) minH = 1;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   915
    if (maxW < 1) maxW = 1;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   916
    if (maxH < 1) maxH = 1;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   917
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   918
    NSWindow *nsWindow = OBJC(windowPtr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   919
    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   920
        AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   921
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   922
        AWTWindow *window = (AWTWindow*)[nsWindow delegate];
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   923
12402
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   924
        NSSize min = { minW, minH };
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   925
        NSSize max = { maxW, maxH };
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   926
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   927
        [window constrainSize:&min];
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   928
        [window constrainSize:&max];
f3903de3fd9e 7124553: [macosx] Need minimum size for titled Frames and JFrames
anthony
parents: 12177
diff changeset
   929
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   930
        window.javaMinSize = min;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   931
        window.javaMaxSize = max;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   932
        [window updateMinMaxSize:IS(window.styleBits, RESIZABLE)];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   933
    }];
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
JNF_COCOA_EXIT(env);
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
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   938
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   939
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   940
 * Method:    nativePushNSWindowToBack
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   941
 * Signature: (J)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   942
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   943
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativePushNSWindowToBack
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   944
(JNIEnv *env, jclass clazz, jlong windowPtr)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   945
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   946
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   947
AWT_ASSERT_NOT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   948
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   949
    NSWindow *nsWindow = OBJC(windowPtr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   950
    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   951
        AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   952
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   953
        [nsWindow orderBack:nil];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   954
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   955
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   956
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   957
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   958
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   959
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   960
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   961
 * Method:    nativePushNSWindowToFront
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   962
 * Signature: (J)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   963
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   964
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativePushNSWindowToFront
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   965
(JNIEnv *env, jclass clazz, jlong windowPtr)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   966
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   967
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   968
AWT_ASSERT_NOT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   969
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   970
    NSWindow *nsWindow = OBJC(windowPtr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   971
    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   972
        AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   973
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   974
        if (![nsWindow isKeyWindow]) {
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   975
            [nsWindow makeKeyAndOrderFront:nsWindow];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   976
        } else {
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   977
            [nsWindow orderFront:nsWindow];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   978
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   979
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   980
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   981
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   982
}
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
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   986
 * Method:    nativeSetNSWindowTitle
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   987
 * Signature: (JLjava/lang/String;)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   988
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   989
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowTitle
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   990
(JNIEnv *env, jclass clazz, jlong windowPtr, jstring jtitle)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   991
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   992
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   993
AWT_ASSERT_NOT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   994
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   995
    NSWindow *nsWindow = OBJC(windowPtr);
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
   996
    [nsWindow performSelectorOnMainThread:@selector(setTitle:)
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   997
                              withObject:JNFJavaToNSString(env, jtitle)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   998
                           waitUntilDone:NO];
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
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1001
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1002
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1003
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1004
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1005
 * Method:    nativeRevalidateNSWindowShadow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1006
 * Signature: (J)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1007
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1008
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeRevalidateNSWindowShadow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1009
(JNIEnv *env, jclass clazz, jlong windowPtr)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1010
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1011
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1012
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1013
    NSWindow *nsWindow = OBJC(windowPtr);
13233
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
  1014
    if ([NSThread isMainThread]) {
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
  1015
        [nsWindow invalidateShadow];
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
  1016
    } else {
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
  1017
        [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
  1018
            AWT_ASSERT_APPKIT_THREAD;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1019
13233
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
  1020
            [nsWindow invalidateShadow];
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
  1021
        }];
4d45f7ebc0d7 7124244: [macosx] Shaped windows support
serb
parents: 13143
diff changeset
  1022
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1023
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1024
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1025
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1026
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1027
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1028
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1029
 * Method:    nativeScreenOn_AppKitThread
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1030
 * Signature: (J)I
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1031
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1032
JNIEXPORT jint JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeScreenOn_1AppKitThread
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1033
(JNIEnv *env, jclass clazz, jlong windowPtr)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1034
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1035
    jint ret = 0;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1036
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1037
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1038
AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1039
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1040
    NSWindow *nsWindow = OBJC(windowPtr);
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1041
    NSDictionary *props = [[nsWindow screen] deviceDescription];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1042
    ret = [[props objectForKey:@"NSScreenNumber"] intValue];
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
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1045
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1046
    return ret;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1047
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1048
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1049
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1050
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1051
 * Method:    nativeSetNSWindowMinimizedIcon
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1052
 * Signature: (JJ)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1053
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1054
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowMinimizedIcon
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1055
(JNIEnv *env, jclass clazz, jlong windowPtr, jlong nsImagePtr)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1056
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1057
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1058
AWT_ASSERT_NOT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1059
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1060
    NSWindow *nsWindow = OBJC(windowPtr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1061
    NSImage *image = OBJC(nsImagePtr);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1062
    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1063
        AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1064
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1065
        [nsWindow setMiniwindowImage:image];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1066
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1067
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1068
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1069
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1070
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1071
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1072
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1073
 * Method:    nativeSetNSWindowRepresentedFilename
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1074
 * Signature: (JLjava/lang/String;)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1075
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1076
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowRepresentedFilename
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1077
(JNIEnv *env, jclass clazz, jlong windowPtr, jstring filename)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1078
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1079
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1080
AWT_ASSERT_NOT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1081
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1082
    NSWindow *nsWindow = OBJC(windowPtr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1083
    NSURL *url = (filename == NULL) ? nil : [NSURL fileURLWithPath:JNFNormalizedNSStringForPath(env, filename)];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1084
    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1085
        AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1086
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1087
        [nsWindow setRepresentedURL:url];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1088
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1089
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1090
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1091
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1092
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1093
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1094
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1095
 * Method:    nativeSetNSWindowSecurityWarningPositioning
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1096
 * Signature: (JDDFF)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1097
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1098
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetNSWindowSecurityWarningPositioning
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1099
(JNIEnv *env, jclass clazz, jlong windowPtr, jdouble x, jdouble y, jfloat biasX, jfloat biasY)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1100
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1101
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1102
AWT_ASSERT_NOT_APPKIT_THREAD;
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
    [JNFException raise:env as:kRuntimeException reason:"unimplemented"];
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
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1107
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1108
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1109
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1110
 * Class:     sun_lwawt_macosx_CPlatformWindow
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1111
 * Method:    nativeGetTopmostPlatformWindowUnderMouse
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1112
 * Signature: (J)V
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1113
 */
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1114
JNIEXPORT jobject
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1115
JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeGetTopmostPlatformWindowUnderMouse
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1116
(JNIEnv *env, jclass clazz)
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1117
{
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1118
    jobject topmostWindowUnderMouse = nil;
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1119
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1120
    JNF_COCOA_ENTER(env);
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1121
    AWT_ASSERT_APPKIT_THREAD;
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1122
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1123
    AWTWindow *awtWindow = [AWTWindow getTopmostWindowUnderMouse];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1124
    if (awtWindow != nil) {
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1125
        topmostWindowUnderMouse = [awtWindow.javaPlatformWindow jObject];
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1126
    }
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1127
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1128
    JNF_COCOA_EXIT(env);
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1129
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1130
    return topmostWindowUnderMouse;
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1131
}
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1132
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1133
/*
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1134
 * Class:     sun_lwawt_macosx_CPlatformWindow
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1135
 * Method:    nativeSynthesizeMouseEnteredExitedEvents
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1136
 * Signature: (J)V
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1137
 */
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1138
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSynthesizeMouseEnteredExitedEvents
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1139
(JNIEnv *env, jclass clazz)
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1140
{
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1141
    JNF_COCOA_ENTER(env);
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1142
    AWT_ASSERT_NOT_APPKIT_THREAD;
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1143
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1144
    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1145
        AWT_ASSERT_APPKIT_THREAD;
13647
de61414bbcf2 7171045: [macosx] There are no enter or exit events reported against 8b39 for MouseEventsDuringDrag.
alexsch
parents: 13233
diff changeset
  1146
        [AWTWindow synthesizeMouseEnteredExitedEventsForAllWindows];
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1147
    }];
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1148
12535
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1149
    JNF_COCOA_EXIT(env);
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1150
}
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1151
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1152
/*
6d2ee83614e8 7154048: [macosx] At least drag twice, the toolbar can be dragged to the left side
alexsch
parents: 12402
diff changeset
  1153
 * Class:     sun_lwawt_macosx_CPlatformWindow
12816
b4cabffcb0de 7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents: 12648
diff changeset
  1154
 * Method:    nativeGetDisplayID_AppKitThread
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1155
 * Signature: (J)I
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1156
 */
12816
b4cabffcb0de 7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents: 12648
diff changeset
  1157
JNIEXPORT jint JNICALL
14165
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
  1158
Java_sun_lwawt_macosx_CPlatformWindow_nativeGetNSWindowDisplayID
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1159
(JNIEnv *env, jclass clazz, jlong windowPtr)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1160
{
14165
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
  1161
    __block jint ret; // CGDirectDisplayID
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1162
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1163
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1164
12816
b4cabffcb0de 7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents: 12648
diff changeset
  1165
    NSWindow *window = OBJC(windowPtr);
14165
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
  1166
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
  1167
    if ([NSThread isMainThread]) {
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
  1168
        ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue];
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
  1169
    } else {
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
  1170
        [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^(){
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
  1171
            ret = (jint)[[AWTWindow getNSWindowDisplayID_AppKitThread: window] intValue];
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
  1172
        }];
dcb1f9388f85 7175707: [macosx] PIT: 8 b43 Not running on AppKit thread issue again
alexsch
parents: 13777
diff changeset
  1173
    }
12047
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
JNF_COCOA_EXIT(env);
12816
b4cabffcb0de 7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents: 12648
diff changeset
  1176
b4cabffcb0de 7160293: [macosx] FileDialog appears on secondary display
dcherepanov
parents: 12648
diff changeset
  1177
    return ret;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1178
}
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
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1181
 * Class:     sun_lwawt_macosx_CPlatformWindow
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1182
 * Method:    _toggleFullScreenMode
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1183
 * Signature: (J)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1184
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1185
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow__1toggleFullScreenMode
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1186
(JNIEnv *env, jobject peer, jlong windowPtr)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1187
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1188
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1189
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1190
    NSWindow *nsWindow = OBJC(windowPtr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1191
    SEL toggleFullScreenSelector = @selector(toggleFullScreen:);
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1192
    if (![nsWindow respondsToSelector:toggleFullScreenSelector]) return;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1193
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1194
    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1195
        [nsWindow performSelector:toggleFullScreenSelector withObject:nil];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1196
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1197
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1198
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1199
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1200
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1201
JNIEXPORT jboolean JNICALL Java_sun_lwawt_macosx_CMouseInfoPeer_nativeIsWindowUnderMouse
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1202
(JNIEnv *env, jclass clazz, jlong windowPtr)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1203
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1204
    __block jboolean underMouse = JNI_FALSE;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1205
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1206
JNF_COCOA_ENTER(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1207
AWT_ASSERT_NOT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1208
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1209
    NSWindow *nsWindow = OBJC(windowPtr);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1210
    [JNFRunLoop performOnMainThreadWaiting:YES withBlock:^() {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1211
        AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1212
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1213
        NSPoint pt = [nsWindow mouseLocationOutsideOfEventStream];
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1214
        underMouse = [[nsWindow contentView] hitTest:pt] != nil;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1215
    }];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1216
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1217
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1218
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1219
    return underMouse;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1220
}
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1221
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1222
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetEnabled
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1223
(JNIEnv *env, jclass clazz, jlong windowPtr, jboolean isEnabled)
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1224
{
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1225
JNF_COCOA_ENTER(env);
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1226
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1227
    NSWindow *nsWindow = OBJC(windowPtr);
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1228
    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
12648
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1229
        AWTWindow *window = (AWTWindow*)[nsWindow delegate];
00c38c393e11 7149062: [macosx] dock menu don't show available frames
anthony
parents: 12640
diff changeset
  1230
12640
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1231
        [window setEnabled: isEnabled];
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1232
    }];
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1233
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1234
JNF_COCOA_EXIT(env);
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1235
}
5ea775607d72 7124376: [macosx] Modal dialog lost focus
leonidr
parents: 12535
diff changeset
  1236
13009
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1237
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeDispose
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1238
(JNIEnv *env, jclass clazz, jlong windowPtr)
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1239
{
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1240
JNF_COCOA_ENTER(env);
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1241
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1242
    NSWindow *nsWindow = OBJC(windowPtr);
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1243
    [JNFRunLoop performOnMainThreadWaiting:NO withBlock:^(){
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1244
        AWTWindow *window = (AWTWindow*)[nsWindow delegate];
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1245
14311
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
  1246
        if ([AWTWindow lastKeyWindow] == window) {
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
  1247
            [AWTWindow setLastKeyWindow: nil];
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
  1248
        }
b2492ea8d08e 7124310: [macosx] "opposite" seems always null in focus events
leonidr
parents: 14165
diff changeset
  1249
13009
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1250
        // AWTWindow holds a reference to the NSWindow in its nsWindow
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1251
        // property. Unsetting the delegate allows it to be deallocated
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1252
        // which releases the reference. This, in turn, allows the window
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1253
        // itself be deallocated.
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1254
        [nsWindow setDelegate: nil];
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1255
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1256
        [window release];
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1257
    }];
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1258
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1259
JNF_COCOA_EXIT(env);
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1260
}
f409e6ef0185 7174718: [macosx] Regression in 7u6 b12: PopupFactory leaks DefaultFrames.
anthony
parents: 12816
diff changeset
  1261