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