diff options
author | Eric Williams | 2019-03-04 19:34:19 +0000 |
---|---|---|
committer | Eric Williams | 2019-03-11 13:24:36 +0000 |
commit | e922c105b5d2826d4b0b6f8931462051e4e7973e (patch) | |
tree | 3ff2aedf824c3a5f79c52c531e95c4427392dcf4 | |
parent | b5fb9da32d06cd10c4d1a76aaac00439682396ef (diff) | |
download | eclipse.platform.swt-e922c105b5d2826d4b0b6f8931462051e4e7973e.tar.gz eclipse.platform.swt-e922c105b5d2826d4b0b6f8931462051e4e7973e.tar.xz eclipse.platform.swt-e922c105b5d2826d4b0b6f8931462051e4e7973e.zip |
Bug 540807: [GTK4] Remove references to GdkScreen
Remove references to GdkScreen API.
Change-Id: I3fd6f2dfbbf917e4cedf0724f4b5d72dfe448423
Signed-off-by: Eric Williams <ericwill@redhat.com>
8 files changed, 66 insertions, 39 deletions
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 37473e69d2..be3954156a 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 @@ -838,6 +838,18 @@ JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1display_1get_1primary_1monitor) } #endif +#ifndef NO__1gdk_1display_1is_1composited +JNIEXPORT jboolean JNICALL GDK_NATIVE(_1gdk_1display_1is_1composited) + (JNIEnv *env, jclass that, jintLong arg0) +{ + jboolean rc = 0; + GDK_NATIVE_ENTER(env, that, _1gdk_1display_1is_1composited_FUNC); + rc = (jboolean)gdk_display_is_composited((GdkDisplay *)arg0); + GDK_NATIVE_EXIT(env, that, _1gdk_1display_1is_1composited_FUNC); + return rc; +} +#endif + #ifndef NO__1gdk_1display_1peek_1event JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1display_1peek_1event) (JNIEnv *env, jclass that, jintLong arg0) @@ -1991,18 +2003,6 @@ JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1screen_1get_1system_1visual) } #endif -#ifndef NO__1gdk_1screen_1get_1window_1stack -JNIEXPORT jintLong JNICALL GDK_NATIVE(_1gdk_1screen_1get_1window_1stack) - (JNIEnv *env, jclass that, jintLong arg0) -{ - jintLong rc = 0; - GDK_NATIVE_ENTER(env, that, _1gdk_1screen_1get_1window_1stack_FUNC); - rc = (jintLong)gdk_screen_get_window_stack((GdkScreen *)arg0); - GDK_NATIVE_EXIT(env, that, _1gdk_1screen_1get_1window_1stack_FUNC); - return rc; -} -#endif - #ifndef NO__1gdk_1screen_1height JNIEXPORT jint JNICALL GDK_NATIVE(_1gdk_1screen_1height) (JNIEnv *env, jclass that) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h index 388942cbc6..f01e14fff2 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h @@ -443,7 +443,7 @@ #define NO__1gtk_1widget_1get_1first_1child #define NO__1gtk_1css_1provider_1load_1from_1data__I_3BI #define NO__1gtk_1css_1provider_1load_1from_1data__J_3BJ - +#define NO__1gdk_1display_1is_1composited #define NO__1gtk_1gesture_1multi_1press_1new // GdkCursor API changes from GTK3 -> GTK4 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 9acda3e557..4037f46cdb 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 @@ -92,6 +92,7 @@ char * GDK_nativeFunctionNames[] = { "_1gdk_1display_1get_1monitor_1at_1window", "_1gdk_1display_1get_1n_1monitors", "_1gdk_1display_1get_1primary_1monitor", + "_1gdk_1display_1is_1composited", "_1gdk_1display_1peek_1event", "_1gdk_1display_1supports_1cursor_1color", "_1gdk_1drag_1context_1get_1actions", @@ -166,7 +167,6 @@ char * GDK_nativeFunctionNames[] = { "_1gdk_1screen_1get_1primary_1monitor", "_1gdk_1screen_1get_1resolution", "_1gdk_1screen_1get_1system_1visual", - "_1gdk_1screen_1get_1window_1stack", "_1gdk_1screen_1height", "_1gdk_1screen_1is_1composited", "_1gdk_1screen_1width", 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 130e9204c9..ac7c94921d 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 @@ -102,6 +102,7 @@ typedef enum { _1gdk_1display_1get_1monitor_1at_1window_FUNC, _1gdk_1display_1get_1n_1monitors_FUNC, _1gdk_1display_1get_1primary_1monitor_FUNC, + _1gdk_1display_1is_1composited_FUNC, _1gdk_1display_1peek_1event_FUNC, _1gdk_1display_1supports_1cursor_1color_FUNC, _1gdk_1drag_1context_1get_1actions_FUNC, @@ -176,7 +177,6 @@ typedef enum { _1gdk_1screen_1get_1primary_1monitor_FUNC, _1gdk_1screen_1get_1resolution_FUNC, _1gdk_1screen_1get_1system_1visual_FUNC, - _1gdk_1screen_1get_1window_1stack_FUNC, _1gdk_1screen_1height_FUNC, _1gdk_1screen_1is_1composited_FUNC, _1gdk_1screen_1width_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java index 564f80db17..9cb1686d54 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java @@ -1736,17 +1736,6 @@ public class GDK extends OS { lock.unlock(); } } - /** @param screen cast=(GdkScreen *) */ - public static final native long /*int*/ _gdk_screen_get_window_stack(long /*int*/ screen); - /** [GTK3 only, if-def'd in os.h] */ - public static final long /*int*/ gdk_screen_get_window_stack(long /*int*/ screen) { - lock.lock(); - try { - return _gdk_screen_get_window_stack(screen); - } finally { - lock.unlock(); - } - } /** * @param screen cast=(GdkScreen *) */ @@ -1907,6 +1896,19 @@ public class GDK extends OS { lock.unlock(); } } + /** + * @param display cast=(GdkDisplay *) + */ + public static final native boolean _gdk_display_is_composited(long /*int*/ display); + /** [GTK4 only, if-def'd in os.h] */ + public static final boolean gdk_display_is_composited(long /*int*/ display) { + lock.lock(); + try { + return _gdk_display_is_composited(display); + } finally { + lock.unlock(); + } + } /** @param display cast=(GdkDisplay *) */ public static final native long /*int*/ _gdk_display_peek_event(long /*int*/ display); public static final long /*int*/ gdk_display_peek_event(long /*int*/ display) { 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 62d6c3e6fb..81cb8a0cb4 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 @@ -1641,7 +1641,11 @@ Rectangle getBoundsInPixels () { return bounds; } } - return new Rectangle (0, 0, GDK.gdk_screen_width (), GDK.gdk_screen_height ()); + if (GTK.GTK4) { + return new Rectangle (0, 0, 0, 0); + } else { + return new Rectangle (0, 0, GDK.gdk_screen_width (), GDK.gdk_screen_height ()); + } } /** @@ -2591,9 +2595,14 @@ public boolean getHighContrast () { @Override public int getDepth () { checkDevice (); - long /*int*/ screen = GDK.gdk_screen_get_default(); - long /*int*/ visual = GDK.gdk_screen_get_system_visual(screen); - return GDK.gdk_visual_get_depth(visual); + if (GTK.GTK4) { + // Bit depth is always 32 in GTK4 + return 32; + } else { + long /*int*/ screen = GDK.gdk_screen_get_default(); + long /*int*/ visual = GDK.gdk_screen_get_system_visual(screen); + return GDK.gdk_visual_get_depth(visual); + } } /** @@ -5217,9 +5226,13 @@ public void setCursorLocation (int x, int y) { void setCursorLocationInPixels (Point location) { long /*int*/ gdkDisplay = GDK.gdk_display_get_default(); - long /*int*/ gdkScreen = GDK.gdk_screen_get_default(); long /*int*/ gdkPointer = GDK.gdk_get_pointer(gdkDisplay); - GDK.gdk_device_warp(gdkPointer, gdkScreen, location.x, location.y); + if (GTK.GTK4) { + GDK.gdk_device_warp(gdkPointer, location.x, location.y); + } else { + long /*int*/ gdkScreen = GDK.gdk_screen_get_default(); + GDK.gdk_device_warp(gdkPointer, gdkScreen, location.x, location.y); + } } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java index 0755828069..7cd0190f17 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java @@ -1146,8 +1146,14 @@ void forceResize (int width, int height) { */ public int getAlpha () { checkWidget (); - long /*int*/ screen = GTK.gtk_widget_get_screen(shellHandle); - boolean composited = GDK.gdk_screen_is_composited(screen); + boolean composited; + if (GTK.GTK4) { + long /*int*/ display = GDK.gdk_display_get_default(); + composited = GDK.gdk_display_is_composited(display); + } else { + long /*int*/ screen = GTK.gtk_widget_get_screen(shellHandle); + composited = GDK.gdk_screen_is_composited(screen); + } if (composited) { return (int) (GTK.gtk_widget_get_opacity(shellHandle) * 255); } @@ -2058,8 +2064,14 @@ void setActiveControl (Control control, int type) { */ public void setAlpha (int alpha) { checkWidget (); - long /*int*/ screen = GTK.gtk_widget_get_screen(shellHandle); - boolean composited = GDK.gdk_screen_is_composited(screen); + boolean composited; + if (GTK.GTK4) { + long /*int*/ display = GDK.gdk_display_get_default(); + composited = GDK.gdk_display_is_composited(display); + } else { + long /*int*/ screen = GTK.gtk_widget_get_screen(shellHandle); + composited = GDK.gdk_screen_is_composited(screen); + } if (composited) { GTK.gtk_widget_set_opacity (shellHandle, (double) alpha / 255); } @@ -2335,7 +2347,7 @@ void setInitialBounds () { if (display != 0) { long /*int*/ monitor; if (GTK.GTK4) { - monitor = GDK.gdk_display_get_monitor_at_surface(display, paintWindow()); + monitor = GDK.gdk_display_get_monitor_at_surface(display, paintSurface()); } else { monitor = GDK.gdk_display_get_monitor_at_window(display, paintWindow()); } @@ -2354,7 +2366,7 @@ void setInitialBounds () { } } } - if (width == 0 && height == 0) { + if (width == 0 && height == 0 && !GTK.GTK4) { // if the above failed, use gdk_screen_height/width as a fallback width = GDK.gdk_screen_width () * 5 / 8; height = GDK.gdk_screen_height () * 5 / 8; 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 cf25e2a9b0..620f01975a 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 @@ -168,7 +168,7 @@ void configure () { GTK.gtk_window_resize (handle, w, h + TIP_HEIGHT); int[] polyline; Rectangle bounds = display.getBounds(); - int width = bounds != null ? bounds.width : GDK.gdk_screen_width(); + int width = bounds != null && GTK.GTK4 ? bounds.width : GDK.gdk_screen_width(); spikeAbove = dest.height >= y + h + TIP_HEIGHT; if ((dest.width >= x + w) || (multipleMonitors && width >= x + w)) { if (dest.height >= y + h + TIP_HEIGHT) { |