< prev index next >

modules/graphics/src/main/native-glass/gtk/glass_dnd.cpp

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -21,11 +21,10 @@
  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
 #include "glass_dnd.h"
-#include "glass_gtkcompat.h"
 #include "glass_general.h"
 #include "glass_evloop.h"
 
 #include "com_sun_glass_events_DndEvent.h"
 #include "com_sun_glass_ui_gtk_GtkDnDClipboard.h"

@@ -33,10 +32,11 @@
 #include <jni.h>
 #include <cstring>
 
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
 
 /************************* COMMON *********************************************/
 static jint translate_gdk_action_to_glass(GdkDragAction action)
 {
     jint result = 0;

@@ -163,11 +163,11 @@
     if (!enter_ctx.ctx) {
         gdk_drag_status(event->context, static_cast<GdkDragAction>(0), GDK_CURRENT_TIME);
         return; // Do not process motion events if no enter event was received
     }
     jmethodID method = enter_ctx.just_entered ? jViewNotifyDragEnter : jViewNotifyDragOver;
-    GdkDragAction suggested = GLASS_GDK_DRAG_CONTEXT_GET_SUGGESTED_ACTION(event->context);
+    GdkDragAction suggested = gdk_drag_context_get_suggested_action(event->context);
     GdkDragAction result = translate_glass_action_to_gdk(mainEnv->CallIntMethod(ctx->get_jview(), method,
             (jint)event->x_root - enter_ctx.dx, (jint)event->y_root - enter_ctx.dy,
             (jint)event->x_root, (jint)event->y_root,
             translate_gdk_action_to_glass(suggested)));
     CHECK_JNI_EXCEPTION(mainEnv)

@@ -191,11 +191,11 @@
     if (!enter_ctx.ctx || enter_ctx.just_entered) {
         gdk_drop_finish(event->context, FALSE, GDK_CURRENT_TIME);
         gdk_drop_reply(event->context, FALSE, GDK_CURRENT_TIME);
         return; // Do not process drop events if no enter event and subsequent motion event were received
     }
-    GdkDragAction selected = GLASS_GDK_DRAG_CONTEXT_GET_SELECTED_ACTION(event->context);
+    GdkDragAction selected = gdk_drag_context_get_selected_action(event->context);
 
     mainEnv->CallIntMethod(ctx->get_jview(), jViewNotifyDragDrop,
             (jint)event->x_root - enter_ctx.dx, (jint)event->y_root - enter_ctx.dy,
             (jint)event->x_root, (jint)event->y_root,
             translate_gdk_action_to_glass(selected));

@@ -243,11 +243,11 @@
 {
     if (check_state_in_drag(env)) {
         return NULL;
     }
     if (!enter_ctx.mimes) {
-        GList* targets = GLASS_GDK_DRAG_CONTEXT_LIST_TARGETS(enter_ctx.ctx);
+        GList* targets = gdk_drag_context_list_targets(enter_ctx.ctx);
         jobject set = env->NewObject(jHashSetCls, jHashSetInit, NULL);
         EXCEPTION_OCCURED(env);
 
         while (targets) {
             GdkAtom target = GDK_POINTER_TO_ATOM(targets->data);

@@ -310,17 +310,17 @@
 jint dnd_target_get_supported_actions(JNIEnv *env)
 {
     if (check_state_in_drag(env)) {
         return 0;
     }
-    return translate_gdk_action_to_glass(GLASS_GDK_DRAG_CONTEXT_GET_ACTIONS(enter_ctx.ctx));
+    return translate_gdk_action_to_glass(gdk_drag_context_get_actions(enter_ctx.ctx));
 }
 
 static void wait_for_selection_data_hook(GdkEvent * event, void * data)
 {
     selection_data_ctx *ctx = (selection_data_ctx*)data;
-    GdkWindow *dest = GLASS_GDK_DRAG_CONTEXT_GET_DEST_WINDOW(enter_ctx.ctx);
+    GdkWindow *dest = glass_gdk_drag_context_get_dest_window(enter_ctx.ctx);
     if (event->type == GDK_SELECTION_NOTIFY &&
             event->selection.window == dest) {
         if (event->selection.property) { // if 0, that we received negative response
             ctx->length = gdk_selection_property_get(dest, &(ctx->data), &(ctx->type), &(ctx->format));
         }

@@ -332,11 +332,11 @@
 {
     GevlHookRegistration hookReg;
 
     memset(selection_ctx, 0, sizeof(selection_data_ctx));
 
-    gdk_selection_convert(GLASS_GDK_DRAG_CONTEXT_GET_DEST_WINDOW(enter_ctx.ctx), gdk_drag_get_selection(enter_ctx.ctx), target,
+    gdk_selection_convert(glass_gdk_drag_context_get_dest_window(enter_ctx.ctx), gdk_drag_get_selection(enter_ctx.ctx), target,
                           GDK_CURRENT_TIME);
 
     hookReg =
             glass_evloop_hook_add(
                     (GevlHookFunction) wait_for_selection_data_hook,

@@ -558,11 +558,11 @@
 
 static gboolean dnd_finish_callback() {
     if (dnd_window) {
         dnd_set_performed_action(
                 translate_gdk_action_to_glass(
-                    GLASS_GDK_DRAG_CONTEXT_GET_SELECTED_ACTION(
+                    gdk_drag_context_get_selected_action(
                         get_drag_context())));
 
         gdk_window_destroy(dnd_window);
         dnd_window = NULL;
         DragView::reset_drag_view();

@@ -783,11 +783,16 @@
 
 static void process_dnd_source_selection_req(GdkWindow *window, GdkEventSelection* event)
 {
     (void)window;
 
-    GdkWindow *requestor = GLASS_GDK_SELECTION_EVENT_GET_REQUESTOR(event);
+#ifdef GLASS_GTK3
+    GdkWindow *requestor = (event->requestor);
+#else
+    GdkWindow *requestor =
+        gdk_x11_window_foreign_new_for_display(gdk_display_get_default(), event->requestor);
+#endif
 
     gboolean is_data_set = FALSE;
     if (event->target == TARGET_UTF8_STRING_ATOM
             || event->target == TARGET_MIME_TEXT_PLAIN_ATOM) {
         is_data_set = dnd_source_set_utf8_string(requestor, event->property);

@@ -810,11 +815,11 @@
     (void)window;
     (void)event;
 
     glass_gdk_master_pointer_ungrab();
 
-    if (GLASS_GDK_DRAG_CONTEXT_GET_SELECTED_ACTION(get_drag_context())) {
+    if (gdk_drag_context_get_selected_action(get_drag_context())) {
         gdk_drag_drop(get_drag_context(), GDK_CURRENT_TIME);
     } else {
         gdk_drag_abort(get_drag_context(), GDK_CURRENT_TIME);
         /* let the gdk_drag_abort messages handled before finish */
         gdk_threads_add_idle((GSourceFunc) dnd_finish_callback, NULL);

@@ -879,11 +884,11 @@
 
 static void process_dnd_source_drag_status(GdkWindow *window, GdkEventDND *event)
 {
     (void)window;
 
-    GdkDragAction selected = GLASS_GDK_DRAG_CONTEXT_GET_SELECTED_ACTION(event->context);
+    GdkDragAction selected = gdk_drag_context_get_selected_action(event->context);
     GdkCursor* cursor;
 
     if (selected & GDK_ACTION_COPY) {
         cursor = gdk_cursor_new_from_name(gdk_display_get_default(), "dnd-copy");
         if (cursor == NULL) {

@@ -1210,14 +1215,10 @@
 
     screen_changed();
 
     gtk_widget_realize(widget);
 
-    GdkRegion* region = gdk_region_new();
-    gdk_window_input_shape_combine_region(gtk_widget_get_window(widget), region, 0,0);
-    gdk_region_destroy(region);
-
     gtk_widget_set_app_paintable(widget, TRUE);
 
     g_signal_connect(G_OBJECT(widget), "expose-event", G_CALLBACK(on_expose), this);
     g_signal_connect(G_OBJECT(widget), "screen-changed", G_CALLBACK(on_screen_changed), this);
 

@@ -1229,27 +1230,22 @@
     gtk_widget_show_all(widget);
 }
 
 void DragView::View::screen_changed() {
     GdkScreen *screen = gtk_widget_get_screen(widget);
-    GdkColormap *colormap = gdk_screen_get_rgba_colormap(screen);
+    glass_configure_window_transparency(widget, true);
 
-    if (!colormap || !gdk_screen_is_composited(screen)) {
+    if (!gdk_screen_is_composited(screen)) {
         if (!is_offset_set) {
             offset_x = 1;
             offset_y = 1;
         }
     }
-
-    if (!colormap) {
-        colormap = gdk_screen_get_rgb_colormap(screen);
-    }
-    gtk_widget_set_colormap(widget, colormap);
 }
 
 void DragView::View::expose() {
-    cairo_t *context = gdk_cairo_create(widget->window);
+    cairo_t *context = gdk_cairo_create(gtk_widget_get_window(widget));
 
     cairo_surface_t* cairo_surface;
 
     guchar* pixels = is_raw_image
             ? (guchar*) convert_BGRA_to_RGBA((const int*) gdk_pixbuf_get_pixels(pixbuf),
< prev index next >