< prev index next >

modules/graphics/src/main/native-glass/gtk/glass_general.h

Print this page


   1 /*
   2  * Copyright (c) 2011, 2014, 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 #ifndef GLASS_GENERAL_H
  26 #define        GLASS_GENERAL_H
  27 
  28 #include <jni.h>
  29 
  30 
  31 #include <stdint.h>
  32 #include <X11/Xlib.h>
  33 #include <gdk/gdk.h>

  34 #include <gtk/gtk.h>
  35 









  36 #define JLONG_TO_PTR(value) ((void*)(intptr_t)(value))
  37 #define PTR_TO_JLONG(value) ((jlong)(intptr_t)(value))
  38 
  39 #define FILE_PREFIX "file://"
  40 #define URI_LIST_COMMENT_PREFIX "#"
  41 #define URI_LIST_LINE_BREAK "\r\n"
  42 
  43 extern JNIEnv* mainEnv; // Use only with main loop thread!!!
  44 


  45 #include <exception>
  46 
  47 struct jni_exception: public std::exception {
  48     jni_exception(jthrowable _th): throwable(_th), message() {
  49             jclass jc = mainEnv->FindClass("java/lang/Throwable");
  50             if (mainEnv->ExceptionOccurred()) {
  51                 mainEnv->ExceptionDescribe();
  52                 mainEnv->ExceptionClear();
  53             }
  54             jmethodID jmid = mainEnv->GetMethodID(jc, "getMessage", "()Ljava/lang/String;");
  55             if (mainEnv->ExceptionOccurred()) {
  56                 mainEnv->ExceptionDescribe();
  57                 mainEnv->ExceptionClear();
  58             }
  59             jmessage = (jstring)mainEnv->CallObjectMethod(throwable, jmid);
  60             message = jmessage == NULL ? "" : mainEnv->GetStringUTFChars(jmessage, NULL);
  61     }
  62     const char *what() const throw()
  63     {
  64         return message;


 229 #endif
 230 
 231 #define LOG_EXCEPTION(env) check_and_clear_exception(env);
 232 
 233     gchar* get_application_name();
 234     void glass_throw_exception(JNIEnv * env,
 235             const char * exceptionClass,
 236             const char * exceptionMessage);
 237     int glass_throw_oom(JNIEnv * env, const char * exceptionMessage);
 238     void dump_jstring_array(JNIEnv*, jobjectArray);
 239 
 240     guint8* convert_BGRA_to_RGBA(const int* pixels, int stride, int height);
 241 
 242     gboolean check_and_clear_exception(JNIEnv *env);
 243 
 244     jboolean is_display_valid();
 245 
 246     gsize get_files_count(gchar **uris);
 247 
 248     jobject uris_to_java(JNIEnv *env, gchar **uris, gboolean files);



























































































 249 
 250 #endif        /* GLASS_GENERAL_H */
 251 
   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 #ifndef GLASS_GENERAL_H
  26 #define        GLASS_GENERAL_H
  27 
  28 #include <jni.h>
  29 

  30 #include <stdint.h>
  31 #include <X11/Xlib.h>
  32 #include <gdk/gdk.h>
  33 #include <gdk/gdkx.h>
  34 #include <gtk/gtk.h>
  35 
  36 #include "wrapped.h"
  37 
  38 #if GTK_CHECK_VERSION(3, 0, 0)
  39 #if ! GTK_CHECK_VERSION(3, 8, 0)
  40 #error GTK development version is not the minimum 3.8
  41 #endif
  42 #define GLASS_GTK3
  43 #endif
  44 
  45 #define JLONG_TO_PTR(value) ((void*)(intptr_t)(value))
  46 #define PTR_TO_JLONG(value) ((jlong)(intptr_t)(value))
  47 
  48 #define FILE_PREFIX "file://"
  49 #define URI_LIST_COMMENT_PREFIX "#"
  50 #define URI_LIST_LINE_BREAK "\r\n"
  51 
  52 extern JNIEnv* mainEnv; // Use only with main loop thread!!!
  53 
  54 #define GLASS_GDK_KEY_CONSTANT(key) (GDK_KEY_ ## key)
  55 
  56 #include <exception>
  57 
  58 struct jni_exception: public std::exception {
  59     jni_exception(jthrowable _th): throwable(_th), message() {
  60             jclass jc = mainEnv->FindClass("java/lang/Throwable");
  61             if (mainEnv->ExceptionOccurred()) {
  62                 mainEnv->ExceptionDescribe();
  63                 mainEnv->ExceptionClear();
  64             }
  65             jmethodID jmid = mainEnv->GetMethodID(jc, "getMessage", "()Ljava/lang/String;");
  66             if (mainEnv->ExceptionOccurred()) {
  67                 mainEnv->ExceptionDescribe();
  68                 mainEnv->ExceptionClear();
  69             }
  70             jmessage = (jstring)mainEnv->CallObjectMethod(throwable, jmid);
  71             message = jmessage == NULL ? "" : mainEnv->GetStringUTFChars(jmessage, NULL);
  72     }
  73     const char *what() const throw()
  74     {
  75         return message;


 240 #endif
 241 
 242 #define LOG_EXCEPTION(env) check_and_clear_exception(env);
 243 
 244     gchar* get_application_name();
 245     void glass_throw_exception(JNIEnv * env,
 246             const char * exceptionClass,
 247             const char * exceptionMessage);
 248     int glass_throw_oom(JNIEnv * env, const char * exceptionMessage);
 249     void dump_jstring_array(JNIEnv*, jobjectArray);
 250 
 251     guint8* convert_BGRA_to_RGBA(const int* pixels, int stride, int height);
 252 
 253     gboolean check_and_clear_exception(JNIEnv *env);
 254 
 255     jboolean is_display_valid();
 256 
 257     gsize get_files_count(gchar **uris);
 258 
 259     jobject uris_to_java(JNIEnv *env, gchar **uris, gboolean files);
 260 
 261 #ifdef __cplusplus
 262 extern "C" {
 263 #endif
 264 
 265 extern jboolean gtk_verbose;
 266 
 267 void
 268 glass_widget_set_visual (GtkWidget *widget, GdkVisual *visual);
 269 
 270 gint
 271 glass_gdk_visual_get_depth (GdkVisual * visual);
 272 
 273 GdkScreen *
 274 glass_gdk_window_get_screen(GdkWindow * gdkWindow);
 275 
 276 gboolean
 277 glass_gdk_mouse_devices_grab(GdkWindow * gdkWindow);
 278 
 279 gboolean
 280 glass_gdk_mouse_devices_grab_with_cursor(GdkWindow * gdkWindow, GdkCursor *cursor, gboolean owner_events);
 281 
 282 void
 283 glass_gdk_mouse_devices_ungrab();
 284 
 285 void
 286 glass_gdk_master_pointer_grab(GdkWindow *window, GdkCursor *cursor);
 287 
 288 void
 289 glass_gdk_master_pointer_ungrab();
 290 
 291 void
 292 glass_gdk_master_pointer_get_position(gint *x, gint *y);
 293 
 294 gboolean
 295 glass_gdk_device_is_grabbed(GdkDevice *device);
 296 
 297 void
 298 glass_gdk_device_ungrab(GdkDevice *device);
 299 
 300 GdkWindow *
 301 glass_gdk_device_get_window_at_position(
 302                GdkDevice *device, gint *x, gint *y);
 303 
 304 void
 305 glass_gtk_configure_transparency_and_realize(GtkWidget *window,
 306                                                   gboolean transparent);
 307 
 308 const guchar *
 309 glass_gtk_selection_data_get_data_with_length(
 310         GtkSelectionData * selectionData,
 311         gint * length);
 312 
 313 void
 314 glass_gtk_window_configure_from_visual(GtkWidget *widget, GdkVisual *visual);
 315 
 316 void
 317 glass_gdk_window_get_size(GdkWindow *window, gint *w, gint *h);
 318 
 319 void
 320 glass_gdk_display_get_pointer(GdkDisplay* display, gint* x, gint *y);
 321 
 322 void
 323 glass_gdk_x11_display_set_window_scale(GdkDisplay *display, gint scale);
 324 
 325 gboolean
 326 glass_configure_window_transparency(GtkWidget *window, gboolean transparent);
 327 
 328 GdkPixbuf *
 329 glass_pixbuf_from_window(GdkWindow *window,
 330     gint srcx, gint srcy,
 331     gint width, gint height);
 332 
 333 void
 334 glass_window_apply_shape_mask(GdkWindow *window,
 335     void* data, uint width, uint height);
 336 
 337 void
 338 glass_window_reset_input_shape_mask(GdkWindow *window);
 339 
 340 GdkWindow *
 341 glass_gdk_drag_context_get_dest_window (GdkDragContext * context);
 342 
 343 guint
 344 glass_settings_get_guint_opt (const gchar *schema_name,
 345                     const gchar *key_name,
 346                     int defval);
 347 
 348 #ifdef __cplusplus
 349 }
 350 #endif
 351 
 352 #endif        /* GLASS_GENERAL_H */
 353 
< prev index next >