< prev index next >

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

Print this page




  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 <gtk/gtk.h>
  34 
  35 #include "glass_wrapper.h"



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


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


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






























































































  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 #if GTK_CHECK_VERSION(3, 0, 0)
  37 #define GLASS_GTK3
  38 #endif
  39 
  40 
  41 #define JLONG_TO_PTR(value) ((void*)(intptr_t)(value))
  42 #define PTR_TO_JLONG(value) ((jlong)(intptr_t)(value))
  43 
  44 #define FILE_PREFIX "file://"
  45 #define URI_LIST_COMMENT_PREFIX "#"
  46 #define URI_LIST_LINE_BREAK "\r\n"
  47 
  48 extern JNIEnv* mainEnv; // Use only with main loop thread!!!
  49 extern JavaVM* javaVM;
  50 
  51 #define GLASS_GDK_KEY_CONSTANT(key) (GDK_KEY_ ## key)
  52 
  53 #include <exception>
  54 
  55 struct jni_exception: public std::exception {
  56     jni_exception(jthrowable _th): throwable(_th), message() {
  57             jclass jc = mainEnv->FindClass("java/lang/Throwable");
  58             if (mainEnv->ExceptionOccurred()) {
  59                 mainEnv->ExceptionDescribe();
  60                 mainEnv->ExceptionClear();
  61             }
  62             jmethodID jmid = mainEnv->GetMethodID(jc, "getMessage", "()Ljava/lang/String;");
  63             if (mainEnv->ExceptionOccurred()) {
  64                 mainEnv->ExceptionDescribe();
  65                 mainEnv->ExceptionClear();
  66             }
  67             jmessage = (jstring)mainEnv->CallObjectMethod(throwable, jmid);
  68             message = jmessage == NULL ? "" : mainEnv->GetStringUTFChars(jmessage, NULL);
  69     }
  70     const char *what() const throw()
  71     {
  72         return message;


 238 
 239 #define LOG_EXCEPTION(env) check_and_clear_exception(env);
 240 
 241     gchar* get_application_name();
 242     void glass_throw_exception(JNIEnv * env,
 243             const char * exceptionClass,
 244             const char * exceptionMessage);
 245     int glass_throw_oom(JNIEnv * env, const char * exceptionMessage);
 246     void dump_jstring_array(JNIEnv*, jobjectArray);
 247 
 248     guint8* convert_BGRA_to_RGBA(const int* pixels, int stride, int height);
 249 
 250     gboolean check_and_clear_exception(JNIEnv *env);
 251 
 252     jboolean is_display_valid();
 253 
 254     gsize get_files_count(gchar **uris);
 255 
 256     jobject uris_to_java(JNIEnv *env, gchar **uris, gboolean files);
 257 

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