changeset 5845:8fd1e1131277

RT-34196 [Controls, Menus] Gtk: JAVAFX default menu items are difficult to click Reviewed-by: anthony, msladecek
author azvegint <alexander.zvegintsev@oracle.com>
date Thu, 28 Nov 2013 16:18:16 +0400
parents 22039a8a6341
children 4455a18dd959
files modules/graphics/src/main/native-glass/gtk/glass_window.cpp modules/graphics/src/main/native-glass/gtk/glass_window.h
diffstat 2 files changed, 18 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/native-glass/gtk/glass_window.cpp	Thu Nov 28 13:08:56 2013 +0200
+++ b/modules/graphics/src/main/native-glass/gtk/glass_window.cpp	Thu Nov 28 16:18:16 2013 +0400
@@ -456,7 +456,7 @@
             CAIRO_FORMAT_ARGB32,
             width, height, width * 4);
 
-    applyShapeMask(cairo_surface, width, height);
+    applyShapeMask(data, width, height);
 
     cairo_set_source_surface(context, cairo_surface, 0, 0);
     cairo_set_operator (context, CAIRO_OPERATOR_SOURCE);
@@ -619,7 +619,6 @@
             geometry(),
             stale_config_notifications(),
             resizable(),
-            xshape(),
             frame_extents_initialized(),
             map_received(false),
             location_assigned(false),
@@ -1194,58 +1193,26 @@
             windowChanges);
 }
 
-void WindowContextTop::applyShapeMask(cairo_surface_t* cairo_surface, uint width, uint height)
+void WindowContextTop::applyShapeMask(void* data, uint width, uint height)
 {
     if (frame_type != TRANSPARENT) {
         return;
     }
-    Display *display = GDK_DISPLAY_XDISPLAY(glass_gdk_window_get_display(gdk_window));
-    Screen *screen = GDK_SCREEN_XSCREEN(glass_gdk_window_get_screen(gdk_window));
 
-    if (xshape.surface == NULL || width != xshape.width || height != xshape.height) {
-        if (xshape.surface != NULL) {
-            cairo_surface_destroy(xshape.surface);
-            XFreePixmap(display,
-                    xshape.pixmap);
+    GdkPixbuf* pixbuf = gdk_pixbuf_new_from_data((guchar *) data,
+            GDK_COLORSPACE_RGB, TRUE, 8, width, height, width * 4, NULL, NULL);
+
+    if (GDK_IS_PIXBUF(pixbuf)) {
+        GdkBitmap* mask = NULL;
+        gdk_pixbuf_render_pixmap_and_mask(pixbuf, NULL, &mask, 128);
+
+        gdk_window_input_shape_combine_mask(gdk_window, mask, 0, 0);
+
+        g_object_unref(pixbuf);
+        if (mask) {
+            g_object_unref(mask);
         }
-        xshape.pixmap = XCreatePixmap(
-                display,
-                GDK_WINDOW_XID(gdk_window),
-                width, height, 1
-                );
-        xshape.surface = cairo_xlib_surface_create_for_bitmap(
-                display,
-                xshape.pixmap,
-                screen,
-                width,
-                height
-                );
-        xshape.width = width;
-        xshape.height = height;
     }
-
-    cairo_t *xshape_context = cairo_create(xshape.surface);
-
-    cairo_set_operator(xshape_context, CAIRO_OPERATOR_SOURCE);
-    cairo_set_source_surface(xshape_context, cairo_surface, 0, 0);
-
-    cairo_paint(xshape_context);
-
-    int type;
-    if (gdk_display_supports_composite(glass_gdk_window_get_display(gdk_window))
-            && gdk_screen_is_composited(glass_gdk_window_get_screen(gdk_window))) {
-        type = ShapeInput;
-    } else {
-        type = ShapeBounding;
-    }
-
-    XShapeCombineMask(display,
-            GDK_WINDOW_XID(gdk_window),
-            type,
-            0, 0, xshape.pixmap, ShapeSet
-            );
-
-    cairo_destroy(xshape_context);
 }
 
 void WindowContextTop::set_minimized(bool minimize) {
@@ -1371,13 +1338,6 @@
     WindowContextBase::process_destroy();
 }
 
-WindowContextTop::~WindowContextTop() {
-    if (xshape.surface) {
-        cairo_surface_destroy(xshape.surface);
-        XFreePixmap(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), xshape.pixmap);
-    }
-}
-
 ////////////////////////////// WindowContextPlug ////////////////////////////////
 
 static gboolean plug_configure(GtkWidget *widget, GdkEvent *event, gpointer user_data) {
--- a/modules/graphics/src/main/native-glass/gtk/glass_window.h	Thu Nov 28 13:08:56 2013 +0200
+++ b/modules/graphics/src/main/native-glass/gtk/glass_window.h	Thu Nov 28 16:18:16 2013 +0400
@@ -264,7 +264,7 @@
 
     ~WindowContextBase();
 protected:
-    virtual void applyShapeMask(cairo_surface_t*, uint width, uint height) = 0;
+    virtual void applyShapeMask(void*, uint width, uint height) = 0;
 private:
     bool im_filter_keypress(GdkEventKey*);
 };
@@ -297,7 +297,7 @@
     void process_configure(GdkEventConfigure*);
     void process_gtk_configure(GdkEventConfigure*);
 
-    void applyShapeMask(cairo_surface_t*, uint width, uint height) {}
+    void applyShapeMask(void*, uint width, uint height) {}
     GtkWindow *get_gtk_window(); // TODO, get window from parent
 
     WindowContextPlug(jobject, void*);
@@ -345,7 +345,7 @@
     int getEmbeddedX();
     int getEmbeddedY();
 
-    void applyShapeMask(cairo_surface_t*, uint width, uint height) {}
+    void applyShapeMask(void*, uint width, uint height) {}
     GtkWindow *get_gtk_window(); // TODO, get window from parent
 
     WindowContextChild(jobject, void*, GtkWidget *parent_widget, WindowContextPlug *parent_context);
@@ -368,11 +368,6 @@
         bool prev; //former resizable value (used in setEnabled for parents of modal window)
         int minw, minh, maxw, maxh; //minimum and maximum window width/height;
     } resizable;
-    struct {
-        Pixmap pixmap; //Pixmap for the xshape mask
-        cairo_surface_t *surface; //surface for the pixmap
-        uint width, height; //bounds of the pixmap
-    } xshape;
 
     bool frame_extents_initialized;
     bool map_received;
@@ -413,9 +408,8 @@
 
     GtkWindow *get_gtk_window();
     void detach_from_java();
-    ~WindowContextTop();
 protected:
-    void applyShapeMask(cairo_surface_t*, uint width, uint height);
+    void applyShapeMask(void*, uint width, uint height);
 private:
     bool get_frame_extents_property(int *, int *, int *, int *);
     void request_frame_extents();