src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 54503 e64a8477cd71
child 58679 9c3209ff7550
--- a/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c	Thu Oct 17 20:27:44 2019 +0100
+++ b/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c	Thu Oct 17 20:53:35 2019 +0100
@@ -398,6 +398,8 @@
         } else {
             fp_gdk_window_create_similar_image_surface =
                        dl_symbol("gdk_window_create_similar_image_surface");
+            fp_gdk_window_get_scale_factor =
+                    dl_symbol("gdk_window_get_scale_factor");
         }
         gtk3_version_3_14 = !fp_gtk_check_version(3, 14, 0);
 
@@ -477,8 +479,7 @@
         fp_gtk_fixed_new = dl_symbol("gtk_fixed_new");
         fp_gtk_handle_box_new = dl_symbol("gtk_handle_box_new");
         fp_gtk_image_new = dl_symbol("gtk_image_new");
-        fp_gtk_hpaned_new = dl_symbol("gtk_hpaned_new");
-        fp_gtk_vpaned_new = dl_symbol("gtk_vpaned_new");
+        fp_gtk_paned_new = dl_symbol("gtk_paned_new");
         fp_gtk_scale_new = dl_symbol("gtk_scale_new");
         fp_gtk_hscrollbar_new = dl_symbol("gtk_hscrollbar_new");
         fp_gtk_vscrollbar_new = dl_symbol("gtk_vscrollbar_new");
@@ -1081,7 +1082,7 @@
         case SPLIT_PANE:
             if (init_result = (NULL == gtk3_widgets[_GTK_HPANED_TYPE]))
             {
-                gtk3_widgets[_GTK_HPANED_TYPE] = (*fp_gtk_hpaned_new)();
+                gtk3_widgets[_GTK_HPANED_TYPE] = (*fp_gtk_paned_new)(GTK_ORIENTATION_HORIZONTAL);
             }
             result = gtk3_widgets[_GTK_HPANED_TYPE];
             break;
@@ -1314,7 +1315,7 @@
         case VSPLIT_PANE_DIVIDER:
             if (init_result = (NULL == gtk3_widgets[_GTK_VPANED_TYPE]))
             {
-                gtk3_widgets[_GTK_VPANED_TYPE] = (*fp_gtk_vpaned_new)();
+                gtk3_widgets[_GTK_VPANED_TYPE] = (*fp_gtk_paned_new)(GTK_ORIENTATION_VERTICAL);
             }
             result = gtk3_widgets[_GTK_VPANED_TYPE];
             break;
@@ -1434,6 +1435,10 @@
             } else if (strcmp(detail, "option") == 0) {
                 path = createWidgetPath (NULL);
                 append_element(path, "radio");
+            } else if (strcmp(detail, "paned") == 0) {
+                path = createWidgetPath (fp_gtk_style_context_get_path (widget_context));
+                append_element(path, "paned");
+                append_element(path, "separator");
             } else {
                 path = createWidgetPath (fp_gtk_style_context_get_path (widget_context));
                 append_element(path, detail);
@@ -1832,22 +1837,30 @@
 {
     gtk3_widget = gtk3_get_widget(widget_type);
 
-    GtkStyleContext* context = fp_gtk_widget_get_style_context (gtk3_widget);
-
-    fp_gtk_style_context_save (context);
+    GtkStyleContext* context = get_style(widget_type, detail);
 
     GtkStateFlags flags = get_gtk_flags(state_type);
     fp_gtk_style_context_set_state(context, GTK_STATE_FLAG_PRELIGHT);
 
-    if (detail != 0) {
+    if (detail != 0 && !(strcmp(detail, "paned") == 0)) {
         transform_detail_string(detail, context);
         fp_gtk_style_context_add_class (context, "handlebox_bin");
     }
 
-    fp_gtk_render_handle(context, cr, x, y, width, height);
-    fp_gtk_render_background(context, cr, x, y, width, height);
-
-    fp_gtk_style_context_restore (context);
+    if (!(strcmp(detail, "paned") == 0)) {
+        fp_gtk_render_handle(context, cr, x, y, width, height);
+        fp_gtk_render_background(context, cr, x, y, width, height);
+    } else {
+        if (orientation == GTK_ORIENTATION_VERTICAL) {
+            fp_gtk_render_handle(context, cr, x+width/2, y, 2, height);
+            fp_gtk_render_background(context, cr, x+width/2, y, 2, height);
+        } else {
+            fp_gtk_render_handle(context, cr, x, y+height/2, width, 2);
+            fp_gtk_render_background(context, cr, x, y+height/2, width, 2);
+        }
+    }
+
+    disposeOrRestoreContext(context);
 }
 
 static void gtk3_paint_hline(WidgetType widget_type, GtkStateType state_type,
@@ -2888,7 +2901,14 @@
     jint *ary;
 
     GdkWindow *root = (*fp_gdk_get_default_root_window)();
-    pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(root, x, y, width, height);
+    if (gtk3_version_3_10) {
+        int win_scale = (*fp_gdk_window_get_scale_factor)(root);
+        pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(
+            root, x, y, (int) (width / (float) win_scale + 0.5), (int) (height / (float) win_scale + 0.5));
+    } else {
+        pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(root, x, y, width, height);
+    }
+
     if (pixbuf && scale != 1) {
         GdkPixbuf *scaledPixbuf;
         x /= scale;
@@ -2906,8 +2926,8 @@
     if (pixbuf) {
         int nchan = (*fp_gdk_pixbuf_get_n_channels)(pixbuf);
         int stride = (*fp_gdk_pixbuf_get_rowstride)(pixbuf);
-        if ((*fp_gdk_pixbuf_get_width)(pixbuf) == width
-                && (*fp_gdk_pixbuf_get_height)(pixbuf) == height
+        if ((*fp_gdk_pixbuf_get_width)(pixbuf) >= width
+                && (*fp_gdk_pixbuf_get_height)(pixbuf) >= height
                 && (*fp_gdk_pixbuf_get_bits_per_sample)(pixbuf) == 8
                 && (*fp_gdk_pixbuf_get_colorspace)(pixbuf) == GDK_COLORSPACE_RGB
                 && nchan >= 3