Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul D'Pong2021-05-12 16:01:39 +0000
committerAlexander Kurtakov2021-05-12 16:23:27 +0000
commit3c8cc4b34f7c682fabb7c419ba1a12a20a5798c8 (patch)
treef1bcb3ac835607d6e99cf480732375a3164e61d4
parentd47f9eca8e2b9cb2883d2b315554d05206174ca4 (diff)
downloadeclipse.platform.swt-3c8cc4b34f7c682fabb7c419ba1a12a20a5798c8.tar.gz
eclipse.platform.swt-3c8cc4b34f7c682fabb7c419ba1a12a20a5798c8.tar.xz
eclipse.platform.swt-3c8cc4b34f7c682fabb7c419ba1a12a20a5798c8.zip
Bug 570533 - [GTK4] Make separate GTK3.java and GTK4.java native
wrappers - gtk_style_context_invalidate - Moved gtk_styke_context_invalidate to gtk3 - Place guards to places that the function is called in gtk4 Change-Id: Idb1e7fce842d4a69f875a8052543e0e340107bb5 Signed-off-by: Paul D'Pong <sdamrong@redhat.com> Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/180545 Tested-by: Platform Bot <platform-bot@eclipse.org> Reviewed-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.c1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java2
14 files changed, 43 insertions, 41 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c
index 5a85e5761a..f8c621e66e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c
@@ -1438,6 +1438,18 @@ JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1status_1icon_1set_1visible)
G_GNUC_END_IGNORE_DEPRECATIONS
#endif
+#ifndef NO_gtk_1style_1context_1invalidate
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1style_1context_1invalidate)
+ (JNIEnv *env, jclass that, jlong arg0)
+{
+ GTK3_NATIVE_ENTER(env, that, gtk_1style_1context_1invalidate_FUNC);
+ gtk_style_context_invalidate((GtkStyleContext *)arg0);
+ GTK3_NATIVE_EXIT(env, that, gtk_1style_1context_1invalidate_FUNC);
+}
+G_GNUC_END_IGNORE_DEPRECATIONS
+#endif
+
#ifndef NO_gtk_1target_1list_1new
JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1target_1list_1new)
(JNIEnv *env, jclass that, jlong arg0, jint arg1)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.c
index 7940fffa07..6a0227c89e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.c
@@ -140,6 +140,7 @@ char * GTK3_nativeFunctionNames[] = {
"gtk_1status_1icon_1set_1from_1pixbuf",
"gtk_1status_1icon_1set_1tooltip_1text",
"gtk_1status_1icon_1set_1visible",
+ "gtk_1style_1context_1invalidate",
"gtk_1target_1list_1new",
"gtk_1target_1list_1unref",
"gtk_1toggle_1tool_1button_1get_1active",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h
index 3de493ea04..7cc5e94e40 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h
@@ -150,6 +150,7 @@ typedef enum {
gtk_1status_1icon_1set_1from_1pixbuf_FUNC,
gtk_1status_1icon_1set_1tooltip_1text_FUNC,
gtk_1status_1icon_1set_1visible_FUNC,
+ gtk_1style_1context_1invalidate_FUNC,
gtk_1target_1list_1new_FUNC,
gtk_1target_1list_1unref_FUNC,
gtk_1toggle_1tool_1button_1get_1active_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index c8129360c5..8851b4f46b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -7905,24 +7905,6 @@ JNIEXPORT jlong JNICALL GTK_NATIVE(gtk_1style_1context_1get_1parent)
}
#endif
-#ifndef NO_gtk_1style_1context_1invalidate
-JNIEXPORT void JNICALL GTK_NATIVE(gtk_1style_1context_1invalidate)
- (JNIEnv *env, jclass that, jlong arg0)
-{
- GTK_NATIVE_ENTER(env, that, gtk_1style_1context_1invalidate_FUNC);
-/*
- gtk_style_context_invalidate(arg0);
-*/
- {
- GTK_LOAD_FUNCTION(fp, gtk_style_context_invalidate)
- if (fp) {
- ((void (CALLING_CONVENTION*)(jlong))fp)(arg0);
- }
- }
- GTK_NATIVE_EXIT(env, that, gtk_1style_1context_1invalidate_FUNC);
-}
-#endif
-
#ifndef NO_gtk_1style_1context_1remove_1class
JNIEXPORT void JNICALL GTK_NATIVE(gtk_1style_1context_1remove_1class)
(JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index aba908dbf8..23de79f683 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -631,7 +631,6 @@ char * GTK_nativeFunctionNames[] = {
"gtk_1style_1context_1get_1padding__JILorg_eclipse_swt_internal_gtk_GtkBorder_2",
"gtk_1style_1context_1get_1padding__JLorg_eclipse_swt_internal_gtk_GtkBorder_2",
"gtk_1style_1context_1get_1parent",
- "gtk_1style_1context_1invalidate",
"gtk_1style_1context_1remove_1class",
"gtk_1style_1context_1restore",
"gtk_1style_1context_1save",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index 8fb967b877..ac06375040 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -629,7 +629,6 @@ typedef enum {
gtk_1style_1context_1get_1padding__JILorg_eclipse_swt_internal_gtk_GtkBorder_2_FUNC,
gtk_1style_1context_1get_1padding__JLorg_eclipse_swt_internal_gtk_GtkBorder_2_FUNC,
gtk_1style_1context_1get_1parent_FUNC,
- gtk_1style_1context_1invalidate_FUNC,
gtk_1style_1context_1remove_1class_FUNC,
gtk_1style_1context_1restore_FUNC,
gtk_1style_1context_1save_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
index d2da25a4e7..a5f4879ee8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
@@ -1657,9 +1657,6 @@ public class GTK extends OS {
*/
/* [GTK4 only] */
public static final native void gtk_style_context_get_border(long context, GtkBorder padding);
- /** @method flags=dynamic */
- /* [GTK3; 3.12 deprecated] */
- public static final native void gtk_style_context_invalidate(long context);
/**
* @param self cast=(GtkStyleContext *)
*/
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java
index 7e18b17b53..cc2cd2fab7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java
@@ -864,4 +864,11 @@ public class GTK3 {
* @param error cast=(GError **)
*/
public static final native boolean gtk_css_provider_load_from_data(long css_provider, byte[] data, long length, long error[]);
+
+ /* GtkStyleContext */
+ /**
+ * @method flags=ignore_deprecations
+ * @param context cast=(GtkStyleContext *)
+ */
+ public static final native void gtk_style_context_invalidate(long context);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 7d64bfcc93..5c3a376c02 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -5146,17 +5146,16 @@ void setBackgroundGdkRGBA (long handle, GdkRGBA rgba) {
if (control == null) control = this;
rgba = control.getBackgroundGdkRGBA();
}
- }
- else {
+ } else {
alpha = backgroundAlpha;
}
if (rgba != null) {
rgba.alpha = alpha / (float)255;
}
- long context = GTK.gtk_widget_get_style_context (handle);
- setBackgroundGdkRGBA (context, handle, rgba);
- GTK.gtk_style_context_invalidate (context);
- return;
+
+ long context = GTK.gtk_widget_get_style_context(handle);
+ setBackgroundGdkRGBA(context, handle, rgba);
+ if (!GTK.GTK4) GTK3.gtk_style_context_invalidate(context);
}
/**
* Sets the receiver's background image to the image specified
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 9994726f1b..c9880df040 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
@@ -3250,7 +3250,7 @@ void initializeSystemColorsList(long shellContext) {
GTK.gtk_style_context_save (shellContext);
GTK.gtk_style_context_add_class(shellContext, GTK.GTK_STYLE_CLASS_VIEW);
GTK.gtk_style_context_add_class(shellContext, GTK.GTK_STYLE_CLASS_CELL);
- GTK.gtk_style_context_invalidate(shellContext);
+ if (!GTK.GTK4) GTK3.gtk_style_context_invalidate(shellContext);
COLOR_LIST_FOREGROUND_RGBA = styleContextGetColor (shellContext, GTK.GTK_STATE_FLAG_NORMAL);
COLOR_LIST_BACKGROUND_RGBA = styleContextEstimateBackgroundColor(shellContext, GTK.GTK_STATE_FLAG_NORMAL);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
index 7d000b17ec..851bfa5606 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
@@ -247,7 +247,7 @@ void createHandle (int index) {
long context = GTK.gtk_widget_get_style_context(handle);
String background = display.gtk_rgba_to_css_string(display.COLOR_LIST_BACKGROUND_RGBA);
gtk_css_provider_load_from_css(context, "entry {border: solid; background: " + background + ";}");
- GTK.gtk_style_context_invalidate(context);
+ if (!GTK.GTK4) GTK3.gtk_style_context_invalidate(context);
}
float alignment = 0.0f;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
index 17851e57f3..964833e172 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java
@@ -290,14 +290,18 @@ void configure () {
void createHandle (int index) {
if ((style & SWT.BALLOON) != 0) {
state |= HANDLE;
- handle = GTK3.gtk_window_new (GTK.GTK_WINDOW_POPUP);
- Color background = display.getSystemColor (SWT.COLOR_INFO_BACKGROUND);
- long context = GTK.gtk_widget_get_style_context (handle);
- GdkRGBA bgRGBA = background.handle;
- String css = "window {background-color: " + display.gtk_rgba_to_css_string(bgRGBA) + ";}";
- gtk_css_provider_load_from_css (context, css);
- GTK.gtk_style_context_invalidate (context);
- GTK3.gtk_window_set_type_hint (handle, GDK.GDK_WINDOW_TYPE_HINT_TOOLTIP);
+ if (GTK.GTK4) {
+ //TODO: GTK4 implementation of ToolTips
+ } else {
+ handle = GTK3.gtk_window_new (GTK.GTK_WINDOW_POPUP);
+ Color background = display.getSystemColor (SWT.COLOR_INFO_BACKGROUND);
+ long context = GTK.gtk_widget_get_style_context (handle);
+ GdkRGBA bgRGBA = background.handle;
+ String css = "window {background-color: " + display.gtk_rgba_to_css_string(bgRGBA) + ";}";
+ gtk_css_provider_load_from_css (context, css);
+ GTK3.gtk_style_context_invalidate (context);
+ GTK3.gtk_window_set_type_hint (handle, GDK.GDK_WINDOW_TYPE_HINT_TOOLTIP);
+ }
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
index 6fc5a6f34c..d1b5d9eb81 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
@@ -919,8 +919,9 @@ private void setTrackerBackground(boolean opaque) {
GTK4.gtk_css_provider_load_from_data (provider, Converter.wcsToMbcs (css, true), -1);
} else {
GTK3.gtk_css_provider_load_from_data (provider, Converter.wcsToMbcs (css, true), -1, null);
+ GTK3.gtk_style_context_invalidate (context);
}
- GTK.gtk_style_context_invalidate (context);
+
long region = Cairo.cairo_region_create ();
if (GTK.GTK4) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
index 8b2dacc6eb..35c4afa5bc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java
@@ -1745,7 +1745,7 @@ void setFontDescription(long widget, long fontDescription) {
// and does not remember the pointer passed to it.
GTK3.gtk_widget_override_font(widget, fontDescription);
long context = GTK.gtk_widget_get_style_context(widget);
- GTK.gtk_style_context_invalidate(context);
+ GTK3.gtk_style_context_invalidate(context);
}
}

Back to the top