1 /*
   2  * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #import "CWrapper.h"
  27 
  28 #import <JavaNativeFoundation/JavaNativeFoundation.h>
  29 
  30 #import "AWTWindow.h"
  31 #import "LWCToolkit.h"
  32 #import "GeomUtilities.h"
  33 #import "ThreadUtilities.h"
  34 
  35 #import "sun_lwawt_macosx_CWrapper_NSWindow.h"
  36 
  37 /*
  38  * Class:     sun_lwawt_macosx_CWrapper$NSObject
  39  * Method:    release
  40  * Signature: (J)V
  41  */
  42 JNIEXPORT void JNICALL
  43 Java_sun_lwawt_macosx_CWrapper_00024NSObject_release
  44 (JNIEnv *env, jclass cls, jlong objectPtr)
  45 {
  46 JNF_COCOA_ENTER(env);
  47 
  48     id obj = (id)jlong_to_ptr(objectPtr);
  49     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
  50         CFRelease(obj);
  51     }];
  52 
  53 JNF_COCOA_EXIT(env);
  54 }
  55 
  56 
  57 /*
  58  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
  59  * Method:    makeKeyAndOrderFront
  60  * Signature: (J)V
  61  */
  62 JNIEXPORT void JNICALL
  63 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_makeKeyAndOrderFront
  64 (JNIEnv *env, jclass cls, jlong windowPtr)
  65 {
  66 JNF_COCOA_ENTER(env);
  67 
  68     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
  69     [ThreadUtilities performOnMainThread:@selector(makeKeyAndOrderFront:)
  70                                       on:window
  71                               withObject:nil
  72                            waitUntilDone:NO];
  73 
  74 JNF_COCOA_EXIT(env);
  75 }
  76 
  77 /*
  78  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
  79  * Method:    makeKeyWindow
  80  * Signature: (J)V
  81  */
  82 JNIEXPORT void JNICALL
  83 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_makeKeyWindow
  84 (JNIEnv *env, jclass cls, jlong windowPtr)
  85 {
  86 JNF_COCOA_ENTER(env);
  87 
  88     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
  89     [ThreadUtilities performOnMainThread:@selector(makeKeyWindow)
  90                                       on:window
  91                               withObject:nil
  92                            waitUntilDone:NO];
  93 
  94 JNF_COCOA_EXIT(env);
  95 }
  96 
  97 /*
  98  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
  99  * Method:    makeMainWindow
 100  * Signature: (J)V
 101  */
 102 JNIEXPORT void JNICALL
 103 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_makeMainWindow
 104 (JNIEnv *env, jclass cls, jlong windowPtr)
 105 {
 106 JNF_COCOA_ENTER(env);
 107 
 108     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
 109     [ThreadUtilities performOnMainThread:@selector(makeMainWindow)
 110                                       on:window
 111                               withObject:nil
 112                            waitUntilDone:NO];
 113 
 114 JNF_COCOA_EXIT(env);
 115 }
 116 
 117 /*
 118  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 119  * Method:    canBecomeMainWindow
 120  * Signature: (J)V
 121  */
 122 JNIEXPORT jboolean JNICALL
 123 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_canBecomeMainWindow
 124 (JNIEnv *env, jclass cls, jlong windowPtr)
 125 {
 126     __block jboolean canBecomeMainWindow = JNI_FALSE;
 127 
 128 JNF_COCOA_ENTER(env);
 129 
 130     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
 131     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
 132         canBecomeMainWindow = [window canBecomeMainWindow];
 133     }];
 134 
 135 JNF_COCOA_EXIT(env);
 136 
 137     return canBecomeMainWindow;
 138 }
 139 
 140 /*
 141  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 142  * Method:    isKeyWindow
 143  * Signature: (J)Z
 144  */
 145 JNIEXPORT jboolean JNICALL
 146 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_isKeyWindow
 147 (JNIEnv *env, jclass cls, jlong windowPtr)
 148 {
 149     __block jboolean isKeyWindow = JNI_FALSE;
 150 
 151 JNF_COCOA_ENTER(env);
 152 
 153     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
 154     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
 155         isKeyWindow = [window isKeyWindow];
 156     }];
 157 
 158 JNF_COCOA_EXIT(env);
 159 
 160     return isKeyWindow;
 161 }
 162 
 163 /*
 164  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 165  * Method:    orderFront
 166  * Signature: (J)V
 167  */
 168 JNIEXPORT void JNICALL
 169 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_orderFront
 170 (JNIEnv *env, jclass cls, jlong windowPtr)
 171 {
 172 JNF_COCOA_ENTER(env);
 173 
 174     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
 175     [ThreadUtilities performOnMainThread:@selector(orderFront:)
 176                                       on:window
 177                               withObject:window
 178                            waitUntilDone:NO];
 179 
 180 JNF_COCOA_EXIT(env);
 181 }
 182 
 183 /*
 184  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 185  * Method:    orderOut
 186  * Signature: (J)V
 187  */
 188 JNIEXPORT void JNICALL
 189 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_orderOut
 190 (JNIEnv *env, jclass cls, jlong windowPtr)
 191 {
 192 JNF_COCOA_ENTER(env);
 193 
 194     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
 195     [ThreadUtilities performOnMainThread:@selector(orderOut:)
 196                                       on:window
 197                               withObject:window
 198                            waitUntilDone:NO];
 199 
 200 JNF_COCOA_EXIT(env);
 201 }
 202 
 203 /*
 204  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 205  * Method:    orderFrontRegardless
 206  * Signature: (J)V
 207  */
 208 JNIEXPORT void JNICALL
 209 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_orderFrontRegardless
 210 (JNIEnv *env, jclass cls, jlong windowPtr)
 211 {
 212 JNF_COCOA_ENTER(env);
 213 
 214     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
 215     [ThreadUtilities performOnMainThread:@selector(orderFrontRegardless)
 216                                       on:window
 217                               withObject:nil
 218                            waitUntilDone:NO];
 219 
 220 JNF_COCOA_EXIT(env);
 221 }
 222 
 223 /*
 224  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 225  * Method:    orderWindow
 226  * Signature: (JIJ)V
 227  */
 228 JNIEXPORT void JNICALL
 229 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_orderWindow
 230 (JNIEnv *env, jclass cls, jlong windowPtr, jint order, jlong relativeToPtr)
 231 {
 232 JNF_COCOA_ENTER(env);
 233 
 234     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
 235     NSWindow *relativeTo = (NSWindow *)jlong_to_ptr(relativeToPtr);
 236     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 237         [window orderWindow:(NSWindowOrderingMode)order relativeTo:[relativeTo windowNumber]];
 238     }];
 239 
 240 JNF_COCOA_EXIT(env);
 241 }
 242 
 243 // Used for CWrapper.NSWindow.setLevel() (and level() which isn't implemented yet)
 244 static NSInteger LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_MAX_WINDOW_LEVELS];
 245 static void initLevels()
 246 {
 247     static dispatch_once_t pred;
 248 
 249     dispatch_once(&pred, ^{
 250         LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_NSNormalWindowLevel] = NSNormalWindowLevel;
 251         LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_NSFloatingWindowLevel] = NSFloatingWindowLevel;
 252     });
 253 }
 254 
 255 /*
 256  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 257  * Method:    setLevel
 258  * Signature: (JI)V
 259  */
 260 JNIEXPORT void JNICALL
 261 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setLevel
 262 (JNIEnv *env, jclass cls, jlong windowPtr, jint level)
 263 {
 264 JNF_COCOA_ENTER(env);
 265 
 266     if (level >= 0 && level < sun_lwawt_macosx_CWrapper_NSWindow_MAX_WINDOW_LEVELS) {
 267         initLevels();
 268 
 269         NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
 270         [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 271             [window setLevel: LEVELS[level]];
 272         }];
 273     } else {
 274         [JNFException raise:env as:kIllegalArgumentException reason:"unknown level"];
 275     }
 276 
 277 JNF_COCOA_EXIT(env);
 278 }
 279 
 280 /*
 281  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 282  * Method:    addChildWindow
 283  * Signature: (JJI)V
 284  */
 285 JNIEXPORT void JNICALL
 286 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_addChildWindow
 287 (JNIEnv *env, jclass cls, jlong parentPtr, jlong childPtr, jint order)
 288 {
 289 JNF_COCOA_ENTER(env);
 290 
 291     NSWindow *parent = (NSWindow *)jlong_to_ptr(parentPtr);
 292     NSWindow *child = (NSWindow *)jlong_to_ptr(childPtr);
 293     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 294         [parent addChildWindow:child ordered:order];
 295     }];
 296 
 297 JNF_COCOA_EXIT(env);
 298 }
 299 
 300 /*
 301  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 302  * Method:    removeChildWindow
 303  * Signature: (JJ)V
 304  */
 305 JNIEXPORT void JNICALL
 306 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_removeChildWindow
 307 (JNIEnv *env, jclass cls, jlong parentPtr, jlong childPtr)
 308 {
 309 JNF_COCOA_ENTER(env);
 310 
 311     AWTWindow *parent = (AWTWindow *)jlong_to_ptr(parentPtr);
 312     AWTWindow *child = (AWTWindow *)jlong_to_ptr(childPtr);
 313     [ThreadUtilities performOnMainThread:@selector(removeChildWindow:)
 314                                       on:parent
 315                               withObject:child
 316                            waitUntilDone:NO];
 317 
 318 JNF_COCOA_EXIT(env);
 319 }
 320 
 321 /*
 322  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 323  * Method:    setFrame
 324  * Signature: (JIIIIZ)V
 325  */
 326 JNIEXPORT void JNICALL
 327 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setFrame
 328 (JNIEnv *env, jclass cls, jlong windowPtr, jint x, jint y, jint w, jint h, jboolean display)
 329 {
 330 JNF_COCOA_ENTER(env);
 331 
 332     AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
 333     NSRect frame = NSMakeRect(x, y, w, h);
 334     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 335         [window setFrame:frame display:display];
 336     }];
 337 
 338 JNF_COCOA_EXIT(env);
 339 }
 340 
 341 /*
 342  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 343  * Method:    setAlphaValue
 344  * Signature: (JF)V
 345  */
 346 JNIEXPORT void JNICALL
 347 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setAlphaValue
 348 (JNIEnv *env, jclass cls, jlong windowPtr, jfloat alpha)
 349 {
 350 JNF_COCOA_ENTER(env);
 351 
 352     AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
 353     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 354         [window setAlphaValue:(CGFloat)alpha];
 355     }];
 356 
 357 JNF_COCOA_EXIT(env);
 358 }
 359 
 360 /*
 361  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 362  * Method:    setOpaque
 363  * Signature: (Z)V
 364  */
 365 JNIEXPORT void JNICALL
 366 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setOpaque
 367 (JNIEnv *env, jclass cls, jlong windowPtr, jboolean opaque)
 368 {
 369 JNF_COCOA_ENTER(env);
 370 
 371     AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
 372     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 373         [window setOpaque:(BOOL)opaque];
 374     }];
 375 
 376 JNF_COCOA_EXIT(env);
 377 }
 378 
 379 /*
 380  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 381  * Method:    setBackgroundColor
 382  * Signature: (J)V
 383  */
 384 JNIEXPORT void JNICALL
 385 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_setBackgroundColor
 386 (JNIEnv *env, jclass cls, jlong windowPtr, jlong colorPtr)
 387 {
 388 JNF_COCOA_ENTER(env);
 389 
 390     AWTWindow *window = (AWTWindow *)jlong_to_ptr(windowPtr);
 391     NSColor *color = (NSColor *)jlong_to_ptr(colorPtr);
 392     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 393         [window setBackgroundColor:color];
 394     }];
 395 
 396 JNF_COCOA_EXIT(env);
 397 }
 398 
 399 /*
 400  * Method:    miniaturize
 401  * Signature: (J)V
 402  */
 403 JNIEXPORT void JNICALL
 404 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_miniaturize
 405 (JNIEnv *env, jclass cls, jlong windowPtr)
 406 {
 407 JNF_COCOA_ENTER(env);
 408 
 409     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
 410     [ThreadUtilities performOnMainThread:@selector(miniaturize:)
 411                                       on:window
 412                               withObject:nil
 413                            waitUntilDone:NO];
 414 
 415 JNF_COCOA_EXIT(env);
 416 }
 417 
 418 /*
 419  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 420  * Method:    deminiaturize
 421  * Signature: (J)V
 422  */
 423 JNIEXPORT void JNICALL
 424 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_deminiaturize
 425 (JNIEnv *env, jclass cls, jlong windowPtr)
 426 {
 427 JNF_COCOA_ENTER(env);
 428 
 429     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
 430     [ThreadUtilities performOnMainThread:@selector(deminiaturize:)
 431                                       on:window
 432                               withObject:nil
 433                            waitUntilDone:NO];
 434 
 435 JNF_COCOA_EXIT(env);
 436 }
 437 
 438 /*
 439  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 440  * Method:    isZoomed
 441  * Signature: (J)Z
 442  */
 443 JNIEXPORT jboolean JNICALL
 444 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_isZoomed
 445 (JNIEnv *env, jclass cls, jlong windowPtr)
 446 {
 447     __block jboolean isZoomed = JNI_FALSE;
 448     
 449 JNF_COCOA_ENTER(env);
 450     
 451     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
 452     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
 453         isZoomed = [window isZoomed];
 454     }];
 455     
 456 JNF_COCOA_EXIT(env);
 457     
 458     return isZoomed;
 459 }
 460 
 461 /*
 462  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 463  * Method:    zoom
 464  * Signature: (J)V
 465  */
 466 JNIEXPORT void JNICALL
 467 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_zoom
 468 (JNIEnv *env, jclass cls, jlong windowPtr)
 469 {
 470 JNF_COCOA_ENTER(env);
 471 
 472     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
 473     [ThreadUtilities performOnMainThread:@selector(zoom:)
 474                                       on:window
 475                               withObject:nil
 476                            waitUntilDone:NO];
 477 
 478 JNF_COCOA_EXIT(env);
 479 }
 480 
 481 /*
 482  * Class:     sun_lwawt_macosx_CWrapper$NSWindow
 483  * Method:    makeFirstResponder
 484  * Signature: (JJ)V
 485  */
 486 JNIEXPORT void JNICALL
 487 Java_sun_lwawt_macosx_CWrapper_00024NSWindow_makeFirstResponder
 488 (JNIEnv *env, jclass cls, jlong windowPtr, jlong responderPtr)
 489 {
 490 JNF_COCOA_ENTER(env);
 491 
 492     NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
 493     NSResponder *responder = (NSResponder *)jlong_to_ptr(responderPtr);
 494     [ThreadUtilities performOnMainThread:@selector(makeFirstResponder:)
 495                                       on:window
 496                               withObject:responder
 497                            waitUntilDone:NO];
 498 
 499 JNF_COCOA_EXIT(env);
 500 }
 501 
 502 /*
 503  * Class:     sun_lwawt_macosx_CWrapper$NSView
 504  * Method:    addSubview
 505  * Signature: (JJ)V
 506  */
 507 JNIEXPORT void JNICALL
 508 Java_sun_lwawt_macosx_CWrapper_00024NSView_addSubview
 509 (JNIEnv *env, jclass cls, jlong viewPtr, jlong subviewPtr)
 510 {
 511 JNF_COCOA_ENTER(env);
 512 
 513     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
 514     NSView *subview = (NSView *)jlong_to_ptr(subviewPtr);
 515     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
 516         [view addSubview:subview];
 517     }];
 518 
 519 JNF_COCOA_EXIT(env);
 520 }
 521 
 522 /*
 523  * Class:     sun_lwawt_macosx_CWrapper$NSView
 524  * Method:    removeFromSuperview
 525  * Signature: (J)V
 526  */
 527 JNIEXPORT void JNICALL
 528 Java_sun_lwawt_macosx_CWrapper_00024NSView_removeFromSuperview
 529 (JNIEnv *env, jclass cls, jlong viewPtr)
 530 {
 531 JNF_COCOA_ENTER(env);
 532 
 533     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
 534     [ThreadUtilities performOnMainThread:@selector(removeFromSuperview)
 535                                       on:view
 536                               withObject:nil
 537                            waitUntilDone:NO];
 538 
 539 JNF_COCOA_EXIT(env);
 540 }
 541 
 542 /*
 543  * Class:     sun_lwawt_macosx_CWrapper$NSView
 544  * Method:    setFrame
 545  * Signature: (JIIII)V
 546  */
 547 JNIEXPORT void JNICALL
 548 Java_sun_lwawt_macosx_CWrapper_00024NSView_setFrame
 549 (JNIEnv *env, jclass cls, jlong viewPtr, jint x, jint y, jint w, jint h)
 550 {
 551 JNF_COCOA_ENTER(env);
 552 
 553     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
 554     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 555         [view setFrame:NSMakeRect(x, y, w, h)];
 556     }];
 557 
 558 JNF_COCOA_EXIT(env);
 559 }
 560 
 561 /*
 562  * Class:     sun_lwawt_macosx_CWrapper$NSView
 563  * Method:    frame
 564  * Signature: (J)Ljava/awt/Rectangle;
 565  */
 566 JNIEXPORT jobject JNICALL
 567 Java_sun_lwawt_macosx_CWrapper_00024NSView_frame
 568 (JNIEnv *env, jclass cls, jlong viewPtr)
 569 {
 570     jobject jRect = NULL;
 571 
 572 JNF_COCOA_ENTER(env);
 573 
 574     __block NSRect rect = NSZeroRect;
 575 
 576     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
 577     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
 578         rect = [view frame];
 579     }];
 580 
 581     jRect = NSToJavaRect(env, rect);
 582 
 583 JNF_COCOA_EXIT(env);
 584 
 585     return jRect;
 586 }
 587 
 588 /*
 589  * Class:     sun_lwawt_macosx_CWrapper$NSView
 590  * Method:    enterFullScreenMode
 591  * Signature: (J)V
 592  */
 593 JNIEXPORT void JNICALL
 594 Java_sun_lwawt_macosx_CWrapper_00024NSView_enterFullScreenMode
 595 (JNIEnv *env, jclass cls, jlong viewPtr)
 596 {
 597 JNF_COCOA_ENTER(env);
 598 
 599     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
 600     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 601         NSScreen *screen = [[view window] screen];
 602         NSDictionary *opts = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:NO], NSFullScreenModeAllScreens, nil];
 603         [view enterFullScreenMode:screen withOptions:opts];
 604     }];
 605 
 606 JNF_COCOA_EXIT(env);
 607 }
 608 
 609 /*
 610  * Class:     sun_lwawt_macosx_CWrapper$NSView
 611  * Method:    exitFullScreenMode
 612  * Signature: (J)V
 613  */
 614 JNIEXPORT void JNICALL
 615 Java_sun_lwawt_macosx_CWrapper_00024NSView_exitFullScreenMode
 616 (JNIEnv *env, jclass cls, jlong viewPtr)
 617 {
 618 JNF_COCOA_ENTER(env);
 619 
 620     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
 621     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 622         [view exitFullScreenModeWithOptions:nil];
 623     }];
 624 
 625 JNF_COCOA_EXIT(env);
 626 }
 627 
 628 /*
 629  * Class:     sun_lwawt_macosx_CWrapper$NSView
 630  * Method:    window
 631  * Signature: (J)J
 632  */
 633 JNIEXPORT jlong JNICALL
 634 Java_sun_lwawt_macosx_CWrapper_00024NSView_window
 635 (JNIEnv *env, jclass cls, jlong viewPtr)
 636 {
 637     __block jlong windowPtr = 0L;
 638 
 639 JNF_COCOA_ENTER(env);
 640 
 641     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
 642     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
 643         windowPtr = ptr_to_jlong([view window]);
 644     }];
 645 
 646 JNF_COCOA_EXIT(env);
 647 
 648     return windowPtr;
 649 }
 650 
 651 /*
 652  * Class:     sun_lwawt_macosx_CWrapper$NSView
 653  * Method:    setHidden
 654  * Signature: (JZ)V
 655  */
 656 JNIEXPORT void JNICALL
 657 Java_sun_lwawt_macosx_CWrapper_00024NSView_setHidden
 658 (JNIEnv *env, jclass cls, jlong viewPtr, jboolean toHide)
 659 {    
 660     JNF_COCOA_ENTER(env);
 661     
 662     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
 663     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 664         [view setHidden:(BOOL)toHide];
 665     }];
 666     
 667     JNF_COCOA_EXIT(env);
 668 }
 669 
 670 /*
 671  * Class:     sun_lwawt_macosx_CWrapper$NSView
 672  * Method:    setToolTip
 673  * Signature: (JLjava/lang/String;)V
 674  */
 675 JNIEXPORT void JNICALL
 676 Java_sun_lwawt_macosx_CWrapper_00024NSView_setToolTip
 677 (JNIEnv *env, jclass cls, jlong viewPtr, jstring msg)
 678 {
 679 
 680 JNF_COCOA_ENTER(env);
 681 
 682     NSView *view = (NSView *)jlong_to_ptr(viewPtr);
 683     NSString* s = JNFJavaToNSString(env, msg); 
 684     [ThreadUtilities performOnMainThreadWaiting:NO block:^(){
 685         [view setToolTip: s];
 686     }];
 687 
 688 JNF_COCOA_EXIT(env);
 689 }
 690 
 691 /*
 692  * Class:     sun_lwawt_macosx_CWrapper$NSColor
 693  * Method:    clearColor
 694  * Signature: ()J
 695  */
 696 JNIEXPORT jlong JNICALL
 697 Java_sun_lwawt_macosx_CWrapper_00024NSColor_clearColor
 698 (JNIEnv *env, jclass cls)
 699 {
 700     __block jlong clearColorPtr = 0L;
 701 
 702 JNF_COCOA_ENTER(env);
 703 
 704     [ThreadUtilities performOnMainThreadWaiting:YES block:^(){
 705         clearColorPtr = ptr_to_jlong([NSColor clearColor]);
 706     }];
 707 
 708 JNF_COCOA_EXIT(env);
 709 
 710     return clearColorPtr;
 711 }
 712 
--- EOF ---