Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2019-01-28 19:16:17 +0000
committerEric Williams2019-02-05 18:32:20 +0000
commit57bf06c97e40f91329e6be80495fe2623d90e25a (patch)
tree25c3b7ae55b23e60d9442da60332104a000175d8
parent1befbecaf4583e81f9dfab38ecc4517fbaf36373 (diff)
downloadeclipse.platform.swt-57bf06c97e40f91329e6be80495fe2623d90e25a.tar.gz
eclipse.platform.swt-57bf06c97e40f91329e6be80495fe2623d90e25a.tar.xz
eclipse.platform.swt-57bf06c97e40f91329e6be80495fe2623d90e25a.zip
Bug 543908: [GTK4] Get ControlExample to launch and run on GTK4
Fix TabFolder display issue, as well as pixbuf crashes due to cairo_image_surface_create() being fed incorrect parameters. Snippet76 no works as expected on GTK4 just as it does on GTK3. Change-Id: Ie1d3504eca532fdb9e33763c98434e33ca53be01 Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java14
7 files changed, 38 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c
index a09e7d521b..79ce6890a6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c
@@ -976,8 +976,26 @@ static AtkObject *swt_fixed_get_accessible (GtkWidget *widget) {
static void swt_fixed_measure (GtkWidget *widget, GtkOrientation orientation, int for_size, int *minimum,
int *natural, int *minimum_baseline, int *natural_baseline) {
+ SwtFixed *fixed = SWT_FIXED (widget);
+ SwtFixedPrivate *priv = fixed->priv;
+ GList *list;
+ int total_nat, child_nat;
+
+ total_nat = 0;
+
+ list = priv->children;
+
+ while (list) {
+ SwtFixedChild *child_data = list->data;
+ GtkWidget *child = child_data->widget;
+
+ gtk_widget_measure(child, orientation, -1, NULL, &child_nat, NULL, NULL);
+ total_nat = total_nat + child_nat;
+
+ list = list->next;
+ }
if (minimum) *minimum = 0;
- if (natural) *natural = 0;
+ if (natural) *natural = total_nat;
if (minimum_baseline) *minimum_baseline = -1;
if (natural_baseline) *natural_baseline = -1;
return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
index 740cf4cc7b..7ca6a7a9e6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
@@ -664,7 +664,7 @@ protected void init () {
long /*int*/ gdkResource;
long /*int*/ surface;
if (GTK.GTK4) {
- surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_CONTENT_COLOR, 10, 10);
+ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_RGB24, 10, 10);
} else {
gdkResource = GDK.gdk_get_default_root_window();
surface = GDK.gdk_window_create_similar_surface(gdkResource, Cairo.CAIRO_CONTENT_COLOR, 10, 10);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
index 01532de632..05fd1a2872 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
@@ -2618,7 +2618,7 @@ void initCairo() {
if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
long /*int*/ surface;
if (GTK.GTK4) {
- surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
+ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_A8, data.width, data.height);
} else {
surface = GDK.gdk_window_create_similar_surface(data.drawable, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
index 259d4a01e2..5b344f7f3c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
@@ -1250,7 +1250,7 @@ void init(int width, int height) {
/* Create the pixmap */
if (GTK.GTK4) {
- surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_CONTENT_COLOR, width, height);
+ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_RGB24, width, height);
} else {
surface = GDK.gdk_window_create_similar_surface(GDK.gdk_get_default_root_window(), Cairo.CAIRO_CONTENT_COLOR, width, height);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
index 0224ce8895..8dd55fcf1d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java
@@ -118,7 +118,7 @@ static int checkStyle (int style) {
static GtkBorder getBorder (byte[] border, long /*int*/ handle, int defaultBorder) {
GtkBorder gtkBorder = new GtkBorder();
long /*int*/ [] borderPtr = new long /*int*/ [1];
- GTK.gtk_widget_style_get (handle, border, borderPtr,0);
+ if (!GTK.GTK4) GTK.gtk_widget_style_get (handle, border, borderPtr,0);
if (borderPtr[0] != 0) {
OS.memmove (gtkBorder, borderPtr[0], GtkBorder.sizeof);
GTK.gtk_border_free(borderPtr[0]);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index afc2da5fea..6c2730e000 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -1499,7 +1499,7 @@ static long /*int*/ rendererClassInitProc (long /*int*/ g_class, long /*int*/ cl
static long /*int*/ snapshotDrawProc (long /*int*/ handle, long /*int*/ snapshot) {
Display display = getCurrent ();
Widget widget = display.getWidget (handle);
- widget.snapshotToDraw(handle, snapshot);
+ if (widget != null) widget.snapshotToDraw(handle, snapshot);
return 0;
}
@@ -3975,7 +3975,7 @@ public long /*int*/ internal_new_GC (GCData data) {
long /*int*/ gc = 0;
long /*int*/ root = 0;
if (GTK.GTK4) {
- long /*int*/ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
+ long /*int*/ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_A8, data.width, data.height);
gc = Cairo.cairo_create(surface);
} else {
root = GDK.gdk_get_default_root_window();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
index b6f0e4afee..c8560f1135 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabItem.java
@@ -304,7 +304,19 @@ public void setControl (Control control) {
if (control != null) {
// To understand why we reparent, see implementation note about bug 454936 at the start of TabFolder.
- Control.gtk_widget_reparent (control, pageHandle);
+ if (GTK.GTK4) {
+ long /*int*/ widget = control.topHandle();
+ long /*int*/ parentContainer = GTK.gtk_widget_get_parent (widget);
+ if (parentContainer != 0) {
+ OS.g_object_ref (widget); //so that it won't get destroyed due to lack of references.
+ GTK.gtk_container_remove (parentContainer, widget);
+ GTK.gtk_container_add (pageHandle, widget);
+ OS.g_object_unref (widget);
+ GTK.gtk_widget_show(widget);
+ }
+ } else {
+ Control.gtk_widget_reparent (control, pageHandle);
+ }
}
Control oldControl = this.control, newControl = control;

Back to the top