1 /*
   2  * Copyright (c) 2011, 2015, 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_GTKCOMPAT_H
  26 #define        GLASS_GTKCOMPAT_H
  27 
  28 #include <gtk/gtk.h>
  29 #include <gdk/gdkx.h>
  30 #include <gdk/gdkkeysyms.h>
  31 
  32 #if GTK_CHECK_VERSION(2, 22, 0)
  33 
  34 #define GLASS_GDK_DRAG_CONTEXT_GET_SELECTED_ACTION(context) \
  35     gdk_drag_context_get_selected_action(context)
  36 
  37 #define GLASS_GDK_DRAG_CONTEXT_GET_ACTIONS(context) \
  38     gdk_drag_context_get_actions(context)
  39 
  40 #define GLASS_GDK_DRAG_CONTEXT_LIST_TARGETS(context) \
  41     gdk_drag_context_list_targets(context)
  42 
  43 #define GLASS_GDK_DRAG_CONTEXT_GET_SUGGESTED_ACTION(context) \
  44     gdk_drag_context_get_suggested_action(context)
  45 
  46 #else /* GTK_CHECK_VERSION(2, 22, 0) */
  47 
  48 #define GLASS_GDK_DRAG_CONTEXT_GET_SELECTED_ACTION(context) \
  49     (context->action)
  50 
  51 #define GLASS_GDK_DRAG_CONTEXT_GET_ACTIONS(context) \
  52     (context->actions)
  53 
  54 #define GLASS_GDK_DRAG_CONTEXT_LIST_TARGETS(context) \
  55     (context->targets)
  56 
  57 #define GLASS_GDK_DRAG_CONTEXT_GET_SUGGESTED_ACTION(context) \
  58     (context->suggested_action)
  59 
  60 #endif /* GTK_CHECK_VERSION(2, 22, 0) */
  61 
  62 #if GTK_CHECK_VERSION(2, 24, 0)
  63 
  64 #define GLASS_GDK_KEY_CONSTANT(key) (GDK_KEY_ ## key)
  65 
  66 #define GLASS_GDK_WINDOW_FOREIGN_NEW_FOR_DISPLAY(display, anid) \
  67     gdk_x11_window_foreign_new_for_display(display, anid)
  68 
  69 #define GLASS_GDK_WINDOW_LOOKUP_FOR_DISPLAY(display, anid) \
  70     gdk_x11_window_lookup_for_display(display, anid)
  71 
  72 #else /* GTK_CHECK_VERSION(2, 24, 0) */
  73 
  74 #define GLASS_GDK_KEY_CONSTANT(key) (GDK_ ## key)
  75 
  76 #define GLASS_GDK_WINDOW_FOREIGN_NEW_FOR_DISPLAY(display, anid) \
  77     gdk_window_foreign_new_for_display(display, anid)
  78 
  79 #define GLASS_GDK_WINDOW_LOOKUP_FOR_DISPLAY(display, anid) \
  80     gdk_window_lookup_for_display(display, anid)
  81 
  82 #endif /* GTK_CHECK_VERSION(2, 24, 0) */
  83 
  84 #if GTK_CHECK_VERSION(3, 0, 0)
  85 
  86 #define GLASS_GTK_WINDOW_SET_HAS_RESIZE_GRIP(window, value) \
  87     gtk_window_set_has_resize_grip(window, TRUE)
  88 
  89 #define GLASS_GDK_SELECTION_EVENT_GET_REQUESTOR(event) \
  90     (event->requestor)
  91 
  92 #define GLASS_GDK_DRAG_CONTEXT_GET_DEST_WINDOW(context) \
  93     gdk_drag_context_get_dest_window(context)
  94 
  95 #else /* GTK_CHECK_VERSION(3, 0, 0) */
  96 
  97 #define GLASS_GTK_WINDOW_SET_HAS_RESIZE_GRIP(window, value) \
  98     (void) window;                                          \
  99     (void) value;
 100 
 101 #define GLASS_GDK_SELECTION_EVENT_GET_REQUESTOR(event) \
 102     GLASS_GDK_WINDOW_FOREIGN_NEW_FOR_DISPLAY(          \
 103         gdk_display_get_default(), event->requestor)
 104 
 105 #define GLASS_GDK_DRAG_CONTEXT_GET_DEST_WINDOW(context) \
 106     ((context != NULL) ? gdk_drag_context_get_dest_window(context) : NULL)
 107 
 108 #endif /* GTK_CHECK_VERSION(3, 0, 0) */
 109 
 110 GdkScreen * glass_gdk_window_get_screen(GdkWindow * gdkWindow);
 111 GdkDisplay * glass_gdk_window_get_display(GdkWindow * gdkWindow);
 112 
 113 gboolean glass_gdk_mouse_devices_grab(GdkWindow * gdkWindow);
 114 gboolean glass_gdk_mouse_devices_grab_with_cursor(GdkWindow * gdkWindow, GdkCursor *cursor);
 115 gboolean glass_gdk_mouse_devices_grab_with_cursor(GdkWindow * gdkWindow, GdkCursor *cursor, gboolean owner_events);
 116 void glass_gdk_mouse_devices_ungrab();
 117 
 118 void glass_gdk_master_pointer_grab(GdkWindow *window, GdkCursor *cursor);
 119 void glass_gdk_master_pointer_ungrab();
 120 void glass_gdk_master_pointer_get_position(gint *x, gint *y);
 121 
 122 gboolean glass_gdk_device_is_grabbed(GdkDevice *device);
 123 void glass_gdk_device_ungrab(GdkDevice *device);
 124 GdkWindow *glass_gdk_device_get_window_at_position(
 125                GdkDevice *device, gint *x, gint *y);
 126 
 127 void glass_gtk_configure_transparency_and_realize(GtkWidget *window,
 128                                                   gboolean transparent);
 129 
 130 const guchar * glass_gtk_selection_data_get_data_with_length(
 131         GtkSelectionData * selectionData,
 132         gint * length);
 133 
 134 void glass_gtk_window_configure_from_visual(GtkWidget *widget, GdkVisual *visual);
 135 
 136 int glass_gtk_fixup_typed_key(int key, int keyval);
 137 
 138 void glass_gdk_window_get_size(GdkWindow *window, gint *w, gint *h);
 139 
 140 void glass_gdk_display_get_pointer(GdkDisplay* display, gint* x, gint *y);
 141 
 142 
 143 #endif        /* GLASS_GTKCOMPAT_H */
 144