1 /*
   2  * Copyright (c) 2011, 2018, 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 #include <com_sun_glass_ui_gtk_GtkWindow.h>
  26 #include <com_sun_glass_events_WindowEvent.h>
  27 #include <com_sun_glass_events_ViewEvent.h>
  28 
  29 #include <cstdlib>
  30 #include <cstring>
  31 #include "glass_general.h"
  32 #include "glass_evloop.h"
  33 #include "glass_window.h"
  34 
  35 #define JLONG_TO_WINDOW_CTX(ptr) ((WindowContext*)JLONG_TO_PTR(ptr))
  36 
  37 static WindowFrameType glass_mask_to_window_frame_type(jint mask) {
  38     if (mask & com_sun_glass_ui_gtk_GtkWindow_TRANSPARENT) {
  39         return TRANSPARENT;
  40     }
  41     if (mask & com_sun_glass_ui_gtk_GtkWindow_TITLED) {
  42         return TITLED;
  43     }
  44     return UNTITLED;
  45 }
  46 
  47 static WindowType glass_mask_to_window_type(jint mask) {
  48     if (mask & com_sun_glass_ui_gtk_GtkWindow_POPUP) {
  49         return POPUP;
  50     }
  51     if (mask & com_sun_glass_ui_gtk_GtkWindow_UTILITY) {
  52         return UTILITY;
  53     }
  54     return NORMAL;
  55 }
  56 
  57 static GdkWMFunction glass_mask_to_wm_function(jint mask) {
  58     int func = GDK_FUNC_RESIZE | GDK_FUNC_MOVE;
  59 
  60     if (mask & com_sun_glass_ui_gtk_GtkWindow_CLOSABLE) {
  61         func |= GDK_FUNC_CLOSE;
  62     }
  63     if (mask & com_sun_glass_ui_gtk_GtkWindow_MAXIMIZABLE) {
  64         func |= GDK_FUNC_MAXIMIZE;
  65     }
  66     if (mask & com_sun_glass_ui_gtk_GtkWindow_MINIMIZABLE) {
  67         func |= GDK_FUNC_MINIMIZE;
  68     }
  69 
  70     return (GdkWMFunction) func;
  71 }
  72 
  73 extern "C" {
  74 
  75 /*
  76  * Class:     com_sun_glass_ui_gtk_GtkWindow
  77  * Method:    _createWindow
  78  * Signature: (JJI)J
  79  */
  80 JNIEXPORT jlong JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1createWindow
  81   (JNIEnv * env, jobject obj, jlong owner, jlong screen, jint mask)
  82 {
  83     (void)env;
  84 
  85     WindowContext* parent = JLONG_TO_WINDOW_CTX(owner);
  86     WindowContext* ctx = new WindowContextTop(obj,
  87             parent,
  88             screen,
  89             glass_mask_to_window_frame_type(mask),
  90             glass_mask_to_window_type(mask),
  91             glass_mask_to_wm_function(mask)
  92             );
  93 
  94     return PTR_TO_JLONG(ctx);
  95 }
  96 
  97 /*
  98  * Class:     com_sun_glass_ui_gtk_GtkWindow
  99  * Method:    _createChildWindow
 100  * Signature: (J)J
 101  */
 102 JNIEXPORT jlong JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1createChildWindow
 103   (JNIEnv * env, jobject obj , jlong owner)
 104 {
 105     (void)env;
 106 
 107     GdkWindow *parent_window = NULL;
 108     GtkWidget *parent_widget = NULL;
 109     WindowContextPlug *parent_ctx = NULL;
 110     WindowContext *ctx = NULL;
 111 
 112     WindowContext* parent = JLONG_TO_WINDOW_CTX(owner);
 113 
 114     parent_window = gdk_x11_window_lookup_for_display(
 115                         gdk_display_get_default(),
 116                         GDK_WINDOW_XID(ctx->get_gdk_window()));
 117 
 118     if (parent_window != NULL) {
 119         parent_ctx = (WindowContextPlug *)g_object_get_data(G_OBJECT(parent_window), GDK_WINDOW_DATA_CONTEXT);
 120         // HACK: do not use get_gtk_window()
 121         // the method is intended to return GtkWindow that can be used for FileChooser
 122         // (OK, that's also a hack, but still...)
 123         if (parent_ctx != NULL) {
 124             parent_widget = GTK_WIDGET(parent_ctx->get_gtk_window());
 125         }
 126     }
 127 
 128     if (parent_widget == NULL) {
 129         // If 'owner' is a bad handle, then the child window is created unparented
 130         ctx = new WindowContextPlug(obj, JLONG_TO_PTR(owner));
 131     } else {
 132         ctx = new WindowContextChild(obj,
 133                         JLONG_TO_PTR(owner),
 134                         parent_ctx->gtk_container,
 135                         parent_ctx);
 136     }
 137 
 138     return PTR_TO_JLONG(ctx);
 139 }
 140 
 141 /*
 142  * Class:     com_sun_glass_ui_gtk_GtkWindow
 143  * Method:    _close
 144  * Signature: (J)Z
 145  */
 146 JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1close
 147   (JNIEnv * env, jobject obj, jlong ptr)
 148 {
 149     (void)env;
 150     (void)obj;
 151 
 152     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 153     destroy_and_delete_ctx(ctx);
 154     return JNI_TRUE; // return value not used
 155 }
 156 /*
 157  * Class:     com_sun_glass_ui_gtk_GtkWindow
 158  * Method:    _setView
 159  * Signature: (JLcom/sun/glass/ui/View;)Z
 160  */
 161 JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1setView
 162   (JNIEnv * env, jobject obj, jlong ptr, jobject view)
 163 {
 164     (void)env;
 165     (void)obj;
 166 
 167     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 168     return (ctx->set_view(view)) ? JNI_TRUE : JNI_FALSE;
 169 }
 170 /*
 171  * Class:     com_sun_glass_ui_gtk_GtkWindow
 172  * Method:    _showOrHideChildren
 173  * Signature: (JZ)V
 174  */
 175 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1showOrHideChildren
 176   (JNIEnv *env, jobject obj, jlong ptr, jboolean show)
 177 {
 178     (void)env;
 179     (void)obj;
 180 
 181     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 182     ctx->show_or_hide_children(show);
 183 }
 184 
 185 /*
 186  * Class:     com_sun_glass_ui_gtk_GtkWindow
 187  * Method:    minimizeImpl
 188  * Signature: (JZ)V
 189  */
 190 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow_minimizeImpl
 191   (JNIEnv * env, jobject obj, jlong ptr, jboolean minimize)
 192 {
 193     (void)env;
 194     (void)obj;
 195 
 196     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 197     ctx->set_minimized(minimize);
 198 }
 199 
 200 /*
 201  * Class:     com_sun_glass_ui_gtk_GtkWindow
 202  * Method:    maximizeImpl
 203  * Signature: (JZZ)V
 204  */
 205 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow_maximizeImpl
 206   (JNIEnv * env, jobject obj, jlong ptr, jboolean maximize, jboolean wasMaximized)
 207 {
 208     (void)env;
 209     (void)obj;
 210     (void)wasMaximized;
 211 
 212     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 213     ctx->set_maximized(maximize);
 214 }
 215 
 216 /*
 217  * Class:     com_sun_glass_ui_gtk_GtkWindow
 218  * Method:    setBoundsImpl
 219  * Signature: (JIIZZIIII)V
 220  */
 221 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow_setBoundsImpl
 222   (JNIEnv * env, jobject obj, jlong ptr, jint x, jint y, jboolean xSet, jboolean ySet, jint w, jint h, jint cw, jint ch)
 223 {
 224     (void)env;
 225     (void)obj;
 226 
 227     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 228     ctx->set_bounds(x, y, xSet, ySet, w, h, cw, ch);
 229 }
 230 
 231 /*
 232  * Class:     com_sun_glass_ui_gtk_GtkWindow
 233  * Method:    setVisibleImpl
 234  * Signature: (JZ)V
 235  */
 236 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow_setVisibleImpl
 237     (JNIEnv * env, jobject obj, jlong ptr, jboolean visible)
 238 {
 239     (void)env;
 240     (void)obj;
 241 
 242     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 243     ctx->set_visible(visible);
 244 }
 245 
 246 /*
 247  * Class:     com_sun_glass_ui_gtk_GtkWindow
 248  * Method:    _setResizable
 249  * Signature: (JZ)Z
 250  */
 251 JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1setResizable
 252   (JNIEnv * env, jobject obj, jlong ptr, jboolean resizable)
 253 {
 254     (void)env;
 255     (void)obj;
 256 
 257     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 258     ctx->set_resizable(resizable);
 259     return JNI_TRUE;
 260 }
 261 
 262 /*
 263  * Class:     com_sun_glass_ui_gtk_GtkWindow
 264  * Method:    _requestFocus
 265  * Signature: (JI)Z
 266  */
 267 JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1requestFocus
 268   (JNIEnv * env, jobject obj, jlong ptr, jint focus)
 269 {
 270     (void)env;
 271     (void)obj;
 272     (void)focus;
 273 
 274     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 275     ctx->request_focus();
 276     return JNI_TRUE; //not used
 277 }
 278 
 279 /*
 280  * Class:     com_sun_glass_ui_gtk_GtkWindow
 281  * Method:    _setFocusable
 282  * Signature: (JZ)V
 283  */
 284 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1setFocusable
 285   (JNIEnv * env, jobject obj, jlong ptr, jboolean focusable)
 286 {
 287     (void)env;
 288     (void)obj;
 289 
 290     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 291     ctx->set_focusable(focusable);
 292 }
 293 
 294 /*
 295  * Class:     com_sun_glass_ui_gtk_GtkWindow
 296  * Method:    _grabFocus
 297  * Signature: (J)Z
 298  */
 299 JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1grabFocus
 300   (JNIEnv * env, jobject obj, jlong ptr)
 301 {
 302     (void)env;
 303     (void)obj;
 304 
 305     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 306     return ctx->grab_focus();
 307 }
 308 
 309 /*
 310  * Class:     com_sun_glass_ui_gtk_GtkWindow
 311  * Method:    _ungrabFocus
 312  * Signature: (J)V
 313  */
 314 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1ungrabFocus
 315   (JNIEnv * env, jobject obj, jlong ptr)
 316 {
 317     (void)env;
 318     (void)obj;
 319 
 320     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 321     ctx->ungrab_focus();
 322 }
 323 
 324 /*
 325  * Class:     com_sun_glass_ui_gtk_GtkWindow
 326  * Method:    _setTitle
 327  * Signature: (JLjava/lang/String;)Z
 328  */
 329 JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1setTitle
 330   (JNIEnv * env, jobject obj, jlong ptr, jstring title)
 331 {
 332     (void)env;
 333     (void)obj;
 334 
 335     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 336     const char* ctitle = mainEnv->GetStringUTFChars(title, NULL);
 337     ctx->set_title(ctitle);
 338     mainEnv->ReleaseStringUTFChars(title, ctitle);
 339 
 340     return JNI_TRUE;
 341 }
 342 
 343 /*
 344  * Class:     com_sun_glass_ui_gtk_GtkWindow
 345  * Method:    _setLevel
 346  * Signature: (JI)V
 347  */
 348 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1setLevel
 349   (JNIEnv * env, jobject obj, jlong ptr, jint level)
 350 {
 351     (void)env;
 352     (void)obj;
 353 
 354     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 355     ctx->set_level(level);
 356 }
 357 
 358 /*
 359  * Class:     com_sun_glass_ui_gtk_GtkWindow
 360  * Method:    _setAlpha
 361  * Signature: (JF)V
 362  */
 363 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1setAlpha
 364   (JNIEnv * env, jobject obj, jlong ptr, jfloat alpha)
 365 {
 366     (void)env;
 367     (void)obj;
 368 
 369     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 370     ctx->set_alpha(alpha);
 371 }
 372 
 373 /*
 374  * Class:     com_sun_glass_ui_gtk_GtkWindow
 375  * Method:    _setBackground
 376  * Signature: (JFFF)Z
 377  */
 378 JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1setBackground
 379   (JNIEnv * env, jobject obj, jlong ptr, jfloat r, jfloat g, jfloat b)
 380 {
 381     (void)env;
 382     (void)obj;
 383 
 384     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 385     ctx->set_background(r, g, b);
 386     return JNI_TRUE;
 387 }
 388 
 389 /*
 390  * Class:     com_sun_glass_ui_gtk_GtkWindow
 391  * Method:    _setEnabled
 392  * Signature: (JZ)V
 393  */
 394 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1setEnabled
 395   (JNIEnv * env, jobject obj, jlong ptr, jboolean enabled)
 396 {
 397     (void)env;
 398     (void)obj;
 399 
 400     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 401     ctx->set_enabled(enabled);
 402 }
 403 
 404 /*
 405  * Class:     com_sun_glass_ui_gtk_GtkWindow
 406  * Method:    _setMinimumSize
 407  * Signature: (JII)Z
 408  */
 409 JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1setMinimumSize
 410   (JNIEnv * env, jobject obj, jlong ptr, jint w, jint h)
 411 {
 412     (void)env;
 413     (void)obj;
 414 
 415     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 416     if (w < 0 || h < 0) return JNI_FALSE;
 417     ctx->set_minimum_size(w, h);
 418     return JNI_TRUE;
 419 }
 420 
 421 /*
 422  * Class:     com_sun_glass_ui_gtk_GtkWindow
 423  * Method:    _setMaximumSize
 424  * Signature: (JII)Z
 425  */
 426 JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1setMaximumSize
 427   (JNIEnv * env, jobject obj, jlong ptr, jint w, jint h)
 428 {
 429     (void)env;
 430     (void)obj;
 431 
 432     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 433     if (w == 0 || h == 0) return JNI_FALSE;
 434     if (w == -1) w = G_MAXSHORT;
 435     if (h == -1) h = G_MAXSHORT;
 436 
 437     ctx->set_maximum_size(w, h);
 438     return JNI_TRUE;
 439 }
 440 
 441 /*
 442  * Class:     com_sun_glass_ui_gtk_GtkWindow
 443  * Method:    _setIcon
 444  * Signature: (JLcom/sun/glass/ui/Pixels;)V
 445  */
 446 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1setIcon
 447   (JNIEnv * env, jobject obj, jlong ptr, jobject pixels)
 448 {
 449     (void)obj;
 450 
 451     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 452     GdkPixbuf *pixbuf = NULL;
 453     if (pixels != NULL) {
 454         env->CallVoidMethod(pixels, jPixelsAttachData, PTR_TO_JLONG(&pixbuf));
 455     }
 456     if (!EXCEPTION_OCCURED(env)) {
 457         ctx->set_icon(pixbuf);
 458     }
 459     if (pixbuf != NULL) g_object_unref(pixbuf);
 460 }
 461 
 462 /*
 463  * Class:     com_sun_glass_ui_gtk_GtkWindow
 464  * Method:    _toFront
 465  * Signature: (J)V
 466  */
 467 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1toFront
 468   (JNIEnv * env, jobject obj, jlong ptr)
 469 {
 470     (void)env;
 471     (void)obj;
 472 
 473     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 474     ctx->restack(true);
 475 }
 476 
 477 /*
 478  * Class:     com_sun_glass_ui_gtk_GtkWindow
 479  * Method:    _toBack
 480  * Signature: (J)V
 481  */
 482 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1toBack
 483   (JNIEnv * env, jobject obj, jlong ptr)
 484 {
 485     (void)env;
 486     (void)obj;
 487 
 488     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 489     ctx->restack(false);
 490 
 491 }
 492 
 493 /*
 494  * Class:     com_sun_glass_ui_gtk_GtkWindow
 495  * Method:    _enterModal
 496  * Signature: (J)V
 497  */
 498 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1enterModal
 499   (JNIEnv * env, jobject obj, jlong ptr)
 500 {
 501     (void)env;
 502     (void)obj;
 503 
 504     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 505     ctx->set_modal(true);
 506 }
 507 
 508 /*
 509  * Class:     com_sun_glass_ui_gtk_GtkWindow
 510  * Method:    _enterModalWithWindow
 511  * Signature: (JJ)V
 512  */
 513 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1enterModalWithWindow
 514   (JNIEnv * env, jobject obj, jlong ptrDialog, jlong ptrWindow)
 515 {
 516     (void)env;
 517     (void)obj;
 518 
 519     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptrDialog);
 520     WindowContext* parent_ctx = JLONG_TO_WINDOW_CTX(ptrWindow);
 521     ctx->set_modal(true, parent_ctx);
 522 }
 523 
 524 /*
 525  * Class:     com_sun_glass_ui_gtk_GtkWindow
 526  * Method:    _exitModal
 527  * Signature: (J)V
 528  */
 529 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1exitModal
 530   (JNIEnv * env, jobject obj, jlong ptr)
 531 {
 532     (void)env;
 533     (void)obj;
 534 
 535     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 536     ctx->set_modal(false);
 537 }
 538 
 539 /*
 540  * Class:     com_sun_glass_ui_gtk_GtkCursor
 541  * Method:    _setCursorType
 542  * Signature: (JI)V
 543  */
 544 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1setCursorType
 545   (JNIEnv * env, jobject obj, jlong ptr, jint type)
 546 {
 547     (void)env;
 548     (void)obj;
 549 
 550     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 551     GdkCursor *cursor = get_native_cursor(type);
 552     ctx->set_cursor(cursor);
 553 }
 554 
 555 /*
 556  * Class:     com_sun_glass_ui_gtk_GtkCursor
 557  * Method:    _setCustomCursor
 558  * Signature: (JLcom/sun/glass/ui/Cursor;)V
 559  */
 560 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1setCustomCursor
 561   (JNIEnv * env, jobject obj, jlong ptr, jobject jCursor)
 562 {
 563     (void)obj;
 564 
 565     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 566     GdkCursor *cursor = (GdkCursor*)JLONG_TO_PTR(env->GetLongField(jCursor, jCursorPtr));
 567 
 568     ctx->set_cursor(cursor);
 569 }
 570 
 571 /*
 572  * Class:     com_sun_glass_ui_gtk_GtkWindow
 573  * Method:    isVisible
 574  * Signature: (J)Z
 575  */
 576 JNIEXPORT jboolean JNICALL Java_com_sun_glass_ui_gtk_GtkWindow_isVisible
 577     (JNIEnv * env, jobject obj, jlong ptr)
 578 {
 579     (void)env;
 580     (void)obj;
 581 
 582     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 583     return ctx->is_visible() ? JNI_TRUE : JNI_FALSE;
 584 }
 585 JNIEXPORT jlong JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1getNativeWindowImpl
 586     (JNIEnv * env, jobject obj, jlong ptr)
 587 {
 588     (void)env;
 589     (void)obj;
 590 
 591     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 592     return GDK_WINDOW_XID(ctx->get_gdk_window());
 593 }
 594 /*
 595  * Class:     com_sun_glass_ui_gtk_GtkWindow
 596  * Method:    getFrameExtents
 597  * Signature: (J[I)V
 598  */
 599 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow_getFrameExtents
 600     (JNIEnv * env, jobject obj, jlong ptr, jintArray extarr)
 601 {
 602     (void)obj;
 603 
 604     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 605     WindowFrameExtents extents = ctx->get_frame_extents();
 606 
 607     env->SetIntArrayRegion(extarr, 0, 1, &extents.left);
 608     env->SetIntArrayRegion(extarr, 1, 1, &extents.right);
 609     env->SetIntArrayRegion(extarr, 2, 1, &extents.top);
 610     env->SetIntArrayRegion(extarr, 3, 1, &extents.bottom);
 611 }
 612 
 613 /*
 614  * Class:     com_sun_glass_ui_gtk_GtkWindow
 615  * Method:    _setGravity
 616  * Signature: (JFF)V
 617  */
 618 JNIEXPORT void JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1setGravity
 619     (JNIEnv * env, jobject obj, jlong ptr, jfloat xGravity, jfloat yGravity)
 620 {
 621     (void)env;
 622     (void)obj;
 623 
 624     WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 625     ctx->set_gravity(xGravity, yGravity);
 626 
 627 }
 628 
 629 
 630 /*
 631  * Class:     com_sun_glass_ui_gtk_GtkWindow
 632  * Method:    _getEmbeddedX
 633  * Signature: (J)I
 634  */
 635 JNIEXPORT jint JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1getEmbeddedX
 636   (JNIEnv *env, jobject obj, jlong ptr) {
 637     (void)env;
 638     (void)obj;
 639 
 640     if (ptr) {
 641         WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 642         return (jint) ctx->getEmbeddedX();
 643     }
 644     return 0;
 645 }
 646 
 647 /*
 648  * Class:     com_sun_glass_ui_gtk_GtkWindow
 649  * Method:    _getEmbeddedY
 650  * Signature: (J)I
 651  */
 652 JNIEXPORT jint JNICALL Java_com_sun_glass_ui_gtk_GtkWindow__1getEmbeddedY
 653   (JNIEnv *env, jobject obj, jlong ptr) {
 654     (void)env;
 655     (void)obj;
 656 
 657     if (ptr) {
 658         WindowContext* ctx = JLONG_TO_WINDOW_CTX(ptr);
 659         return (jint) ctx->getEmbeddedY();
 660     }
 661     return 0;
 662 }
 663 
 664 } // extern "C"