8329471: Remove GTK2

Reviewed-by: abhiscxk, prr, ihse
This commit is contained in:
Alexander Zvegintsev 2024-08-08 10:51:58 +00:00
parent 088871ce36
commit 12c553f128
17 changed files with 54 additions and 3348 deletions

View File

@ -237,7 +237,6 @@ ifeq ($(call isTargetOs, windows macosx)+$(ENABLE_HEADLESS_ONLY), false+false)
DISABLED_WARNINGS_gcc := int-to-pointer-cast, \
DISABLED_WARNINGS_gcc_awt_Taskbar.c := parentheses, \
DISABLED_WARNINGS_gcc_GLXSurfaceData.c := unused-function, \
DISABLED_WARNINGS_gcc_gtk2_interface.c := parentheses type-limits, \
DISABLED_WARNINGS_gcc_gtk3_interface.c := parentheses type-limits \
unused-function, \
DISABLED_WARNINGS_gcc_OGLBufImgOps.c := format-nonliteral, \
@ -252,7 +251,6 @@ ifeq ($(call isTargetOs, windows macosx)+$(ENABLE_HEADLESS_ONLY), false+false)
DISABLED_WARNINGS_gcc_XToolkit.c := unused-result, \
DISABLED_WARNINGS_gcc_XWindow.c := unused-function, \
DISABLED_WARNINGS_clang_awt_Taskbar.c := parentheses, \
DISABLED_WARNINGS_clang_gtk2_interface.c := parentheses, \
DISABLED_WARNINGS_clang_gtk3_interface.c := parentheses, \
DISABLED_WARNINGS_clang_OGLBufImgOps.c := format-nonliteral, \
DISABLED_WARNINGS_clang_OGLPaints.c := format-nonliteral, \
@ -262,8 +260,6 @@ ifeq ($(call isTargetOs, windows macosx)+$(ENABLE_HEADLESS_ONLY), false+false)
DISABLED_WARNINGS_clang_aix_awt_Taskbar.c := parentheses, \
DISABLED_WARNINGS_clang_aix_OGLPaints.c := format-nonliteral, \
DISABLED_WARNINGS_clang_aix_OGLBufImgOps.c := format-nonliteral, \
DISABLED_WARNINGS_clang_aix_gtk2_interface.c := parentheses \
logical-op-parentheses, \
DISABLED_WARNINGS_clang_aix_gtk3_interface.c := parentheses \
logical-op-parentheses, \
DISABLED_WARNINGS_clang_aix_sun_awt_X11_GtkFileDialogPeer.c := \

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -61,7 +61,7 @@ class GTKEngine {
/** Size of the image cache */
private static final int CACHE_SIZE = 50;
/** This enum mirrors that in gtk2_interface.h */
/** This enum mirrors that in gtk_interface.h */
static enum WidgetType {
BUTTON, CHECK_BOX, CHECK_BOX_MENU_ITEM, COLOR_CHOOSER,
COMBO_BOX, COMBO_BOX_ARROW_BUTTON, COMBO_BOX_TEXT_FIELD,
@ -493,13 +493,13 @@ class GTKEngine {
GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
int synthState = context.getComponentState();
Container parent = context.getComponent().getParent();
if(GTKLookAndFeel.is3()) {
if (parent != null && parent.getParent() instanceof JComboBox) {
if (parent.getParent().hasFocus()) {
synthState |= SynthConstants.FOCUSED;
}
if (parent != null && parent.getParent() instanceof JComboBox) {
if (parent.getParent().hasFocus()) {
synthState |= SynthConstants.FOCUSED;
}
}
int dir = getTextDirection(context);
int widget = getWidgetType(context.getComponent(), id).ordinal();
native_paint_shadow(widget, gtkState, shadowType.ordinal(), detail,
@ -628,7 +628,7 @@ class GTKEngine {
cache.flush();
}
/* GtkSettings enum mirrors that in gtk2_interface.h */
/* GtkSettings enum mirrors that in gtk_interface.h */
public Object getSetting(Settings property) {
synchronized(sun.awt.UNIXToolkit.GTK_LOCK) {
return native_get_gtk_setting(property.ordinal());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -44,7 +44,7 @@ class GTKIconFactory {
static final int CHECK_ICON_EXTRA_INSET = 1;
static final int DEFAULT_ICON_SPACING = 2;
static final int DEFAULT_ICON_SIZE = 13;
static final int DEFAULT_TOGGLE_MENU_ITEM_SIZE = 12; // For pre-gtk2.4
static final int DEFAULT_TOGGLE_MENU_ITEM_SIZE = 12;
private static final String RADIO_BUTTON_ICON = "paintRadioButtonIcon";
private static final String CHECK_BOX_ICON = "paintCheckBoxIcon";
@ -214,7 +214,7 @@ class GTKIconFactory {
Region region = context.getRegion();
GTKStyle style = (GTKStyle) context.getStyle();
if (GTKLookAndFeel.is3() && region == Region.MENU) {
if (region == Region.MENU) {
Object value = style.getClassSpecificValue("arrow-scaling");
if (value instanceof Number) {
iconDimension = (int)(((Number) value).floatValue() *

View File

@ -77,7 +77,6 @@ import sun.swing.SwingUtilities2;
*/
@SuppressWarnings("serial") // Superclass not serializable
public class GTKLookAndFeel extends SynthLookAndFeel {
private static boolean IS_22;
private static boolean IS_3;
/**
@ -124,17 +123,6 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
*/
private static String gtkThemeName = "Default";
/**
* Returns true if running on system containing at least 2.2.
*/
static boolean is2_2() {
// NOTE: We're currently hard coding to use 2.2.
// If we want to support both GTK 2.0 and 2.2, we'll
// need to get the major/minor/micro version from the .so.
// Refer to bug 4912613 for details.
return IS_22;
}
static boolean is3() {
return IS_3;
}
@ -1454,17 +1442,7 @@ public class GTKLookAndFeel extends SynthLookAndFeel {
throw new InternalError("Unable to load native GTK libraries");
}
if (UNIXToolkit.getGtkVersion() == UNIXToolkit.GtkVersions.GTK2) {
@SuppressWarnings("removal")
String version = AccessController.doPrivileged(
new GetPropertyAction("jdk.gtk.version"));
if (version != null) {
IS_22 = version.equals("2.2");
} else {
IS_22 = true;
}
} else if (UNIXToolkit.getGtkVersion() ==
UNIXToolkit.GtkVersions.GTK3) {
if (UNIXToolkit.getGtkVersion() == UNIXToolkit.GtkVersions.GTK3) {
IS_3 = true;
}

View File

@ -211,20 +211,7 @@ class GTKPainter extends SynthPainter {
int gtkState = GTKLookAndFeel.synthStateToGTKState(
id, context.getComponentState());
if (gtkState == SynthConstants.MOUSE_OVER) {
if (GTKLookAndFeel.is3()) {
paintComponentBackground(context, g, x, y, w, h);
return;
}
synchronized (UNIXToolkit.GTK_LOCK) {
if (! ENGINE.paintCachedImage(g, x, y, w, h, id)) {
ShadowType shadow = (GTKLookAndFeel.is2_2() ?
ShadowType.NONE : ShadowType.OUT);
ENGINE.startPainting(g, x, y, w, h, id);
ENGINE.paintBox(g, context, id, gtkState,
shadow, "menuitem", x, y, w, h);
ENGINE.finishPainting();
}
}
paintComponentBackground(context, g, x, y, w, h);
}
}
@ -570,21 +557,7 @@ class GTKPainter extends SynthPainter {
int gtkState = GTKLookAndFeel.synthStateToGTKState(
context.getRegion(), context.getComponentState());
if (gtkState == SynthConstants.MOUSE_OVER) {
if (GTKLookAndFeel.is3()) {
paintComponentBackground(context, g, x, y, w, h);
return;
}
Region id = Region.MENU_ITEM;
synchronized (UNIXToolkit.GTK_LOCK) {
if (! ENGINE.paintCachedImage(g, x, y, w, h, id)) {
ShadowType shadow = (GTKLookAndFeel.is2_2() ?
ShadowType.NONE : ShadowType.OUT);
ENGINE.startPainting(g, x, y, w, h, id);
ENGINE.paintBox(g, context, id, gtkState, shadow,
"menuitem", x, y, w, h);
ENGINE.finishPainting();
}
}
paintComponentBackground(context, g, x, y, w, h);
}
}
@ -698,17 +671,14 @@ class GTKPainter extends SynthPainter {
} else {
h -= (insets.top + insets.bottom);
}
if (GTKLookAndFeel.is3()) {
if (id == Region.POPUP_MENU_SEPARATOR) {
detail = "menuitem";
h -= (insets.top + insets.bottom);
} else {
detail = "separator";
}
if (id == Region.POPUP_MENU_SEPARATOR) {
detail = "menuitem";
h -= (insets.top + insets.bottom);
} else {
detail = orientation == JSeparator.HORIZONTAL ?
"hseparator" : "vseparator";
detail = "separator";
}
synchronized (UNIXToolkit.GTK_LOCK) {
if (! ENGINE.paintCachedImage(g, x, y, w, h, id, state,
detail, orientation)) {
@ -823,15 +793,15 @@ class GTKPainter extends SynthPainter {
// The ubuntulooks engine paints slider troughs differently depending
// on the current slider value and its component orientation.
JSlider slider = (JSlider)context.getComponent();
if (GTKLookAndFeel.is3()) {
if (slider.getOrientation() == JSlider.VERTICAL) {
y += 1;
h -= 2;
} else {
x += 1;
w -= 2;
}
if (slider.getOrientation() == JSlider.VERTICAL) {
y += 1;
h -= 2;
} else {
x += 1;
w -= 2;
}
double value = slider.getValue();
double min = slider.getMinimum();
double max = slider.getMaximum();
@ -865,7 +835,7 @@ class GTKPainter extends SynthPainter {
Region id = context.getRegion();
int gtkState = GTKLookAndFeel.synthStateToGTKState(
id, context.getComponentState());
boolean hasFocus = GTKLookAndFeel.is3() &&
boolean hasFocus =
((context.getComponentState() & SynthConstants.FOCUSED) != 0);
synchronized (UNIXToolkit.GTK_LOCK) {
if (! ENGINE.paintCachedImage(g, x, y, w, h, id, gtkState, dir,
@ -1059,21 +1029,10 @@ class GTKPainter extends SynthPainter {
int yThickness = style.getYThickness();
ENGINE.startPainting(g, x, y, w, h, id, state);
if (GTKLookAndFeel.is3()) {
ENGINE.paintBackground(g, context, id, gtkState, null,
x, y, w, h);
}
ENGINE.paintBackground(g, context, id, gtkState, null,
x, y, w, h);
ENGINE.paintShadow(g, context, id, gtkState,
ShadowType.IN, "entry", x, y, w, h);
if (!GTKLookAndFeel.is3()) {
ENGINE.paintFlatBox(g, context, id,
gtkState, ShadowType.NONE, "entry_bg",
x + xThickness,
y + yThickness,
w - (2 * xThickness),
h - (2 * yThickness),
ColorType.TEXT_BACKGROUND);
}
if (focusSize > 0 && (state & SynthConstants.FOCUSED) != 0) {
if (!interiorFocus) {
@ -1084,14 +1043,14 @@ class GTKPainter extends SynthPainter {
} else {
if (containerParent instanceof JComboBox) {
x += (focusSize + 2);
y += focusSize + (GTKLookAndFeel.is3() ? 3 : 1);
w -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 1);
h -= 2 * focusSize + (GTKLookAndFeel.is3() ? 6 : 2);
y += focusSize + 3;
w -= 2 * focusSize + 4;
h -= 2 * focusSize + 6;
} else {
x += focusSize + (GTKLookAndFeel.is3() ? 2 : 0);
y += focusSize + (GTKLookAndFeel.is3() ? 2 :0 );
w -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 0);
h -= 2 * focusSize + (GTKLookAndFeel.is3() ? 4 : 0);
x += focusSize + 2;
y += focusSize + 2;
w -= 2 * focusSize + 4;
h -= 2 * focusSize + 4;
}
}
ENGINE.paintFocus(g, context, id, gtkState,
@ -1437,11 +1396,6 @@ class GTKPainter extends SynthPainter {
if (gtkState == SynthConstants.MOUSE_OVER) {
shadow = ShadowType.IN;
}
if (!GTKLookAndFeel.is3()) {
x += 3;
y += 3;
w = h = 7;
}
ENGINE.paintArrow(g, context, Region.MENU_ITEM, gtkState, shadow,
dir, "menuitem", x, y, w, h);
}

View File

@ -751,14 +751,7 @@ class GTKStyle extends SynthStyle implements GTKConstants {
region == Region.EDITOR_PANE) {
return true;
}
if (!GTKLookAndFeel.is3()) {
if (region == Region.FORMATTED_TEXT_FIELD ||
region == Region.PASSWORD_FIELD ||
region == Region.SPINNER ||
region == Region.TEXT_FIELD) {
return true;
}
}
Component c = context.getComponent();
String name = c.getName();
if (name == "ComboBox.renderer" || name == "ComboBox.listRenderer") {
@ -884,7 +877,7 @@ class GTKStyle extends SynthStyle implements GTKConstants {
int focusPad =
getClassSpecificIntValue(context, "focus-padding", 1);
return indicatorSpacing + focusSize + focusPad;
} else if (GTKLookAndFeel.is3() && "ComboBox.forceOpaque".equals(key)) {
} else if ("ComboBox.forceOpaque".equals(key)) {
return true;
} else if ("Tree.expanderSize".equals(key)) {
Object value = getClassSpecificValue("expander-size");

View File

@ -70,19 +70,12 @@ public abstract class UNIXToolkit extends SunToolkit
private static final int[] BAND_OFFSETS_ALPHA = { 0, 1, 2, 3 };
private static final int DEFAULT_DATATRANSFER_TIMEOUT = 10000;
private static final String GTK2_DEPRECATION_MESSAGE =
"WARNING: the GTK 2 library is deprecated and " +
"its support will be removed in a future release";
private static volatile boolean gtk2WarningIssued = false;
// Allowed GTK versions
public enum GtkVersions {
ANY(0),
GTK2(Constants.GTK2_MAJOR_NUMBER),
GTK3(Constants.GTK3_MAJOR_NUMBER);
static class Constants {
static final int GTK2_MAJOR_NUMBER = 2;
static final int GTK3_MAJOR_NUMBER = 3;
}
@ -94,8 +87,6 @@ public abstract class UNIXToolkit extends SunToolkit
public static GtkVersions getVersion(int number) {
switch (number) {
case Constants.GTK2_MAJOR_NUMBER:
return GTK2;
case Constants.GTK3_MAJOR_NUMBER:
return GTK3;
default:
@ -498,15 +489,7 @@ public abstract class UNIXToolkit extends SunToolkit
@SuppressWarnings("removal")
String version = AccessController.doPrivileged(
new GetPropertyAction("jdk.gtk.version"));
if (version == null) {
return GtkVersions.ANY;
} else if (version.startsWith("2")) {
if (!gtk2WarningIssued) {
System.err.println(GTK2_DEPRECATION_MESSAGE);
gtk2WarningIssued = true;
}
return GtkVersions.GTK2;
} else if("3".equals(version) ){
if ("3".equals(version)) {
return GtkVersions.GTK3;
}
return GtkVersions.ANY;

File diff suppressed because it is too large Load Diff

View File

@ -1,448 +0,0 @@
/*
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#ifdef HEADLESS
#error This file should not be included in headless library
#endif
#ifndef _GTK2_INTERFACE_H
#define _GTK2_INTERFACE_H
#include <stdlib.h>
#include <jni.h>
#include <X11/X.h>
#include "gtk_interface.h"
#define GTK_HAS_FOCUS (1 << 12)
#define GTK_HAS_DEFAULT (1 << 14)
typedef enum
{
GTK_WINDOW_TOPLEVEL,
GTK_WINDOW_POPUP
} GtkWindowType;
typedef enum
{
G_PARAM_READABLE = 1 << 0,
G_PARAM_WRITABLE = 1 << 1,
G_PARAM_CONSTRUCT = 1 << 2,
G_PARAM_CONSTRUCT_ONLY = 1 << 3,
G_PARAM_LAX_VALIDATION = 1 << 4,
G_PARAM_PRIVATE = 1 << 5
} GParamFlags;
/* We define all structure pointers to be void* */
typedef void GVfs;
typedef void GdkColormap;
typedef void GdkDrawable;
typedef void GdkGC;
typedef void GdkPixmap;
typedef void GtkFixed;
typedef void GtkMenuItem;
typedef void GtkMenuShell;
typedef void GtkWidgetClass;
typedef void PangoFontDescription;
typedef void GtkSettings;
/* Some real structures */
typedef struct
{
guint32 pixel;
guint16 red;
guint16 green;
guint16 blue;
} GdkColor;
typedef struct {
gint fd;
gushort events;
gushort revents;
} GPollFD;
typedef struct {
gint x;
gint y;
gint width;
gint height;
} GtkAllocation;
typedef struct {
gint width;
gint height;
} GtkRequisition;
typedef struct {
GtkWidgetClass *g_class;
} GTypeInstance;
typedef struct {
gint left;
gint right;
gint top;
gint bottom;
} GtkBorder;
/******************************************************
* FIXME: it is more safe to include gtk headers for
* the precise type definition of GType and other
* structures. This is a place where getting rid of gtk
* headers may be dangerous.
******************************************************/
typedef struct
{
GType g_type;
union {
gint v_int;
guint v_uint;
glong v_long;
gulong v_ulong;
gint64 v_int64;
guint64 v_uint64;
gfloat v_float;
gdouble v_double;
gpointer v_pointer;
} data[2];
} GValue;
typedef struct
{
GTypeInstance g_type_instance;
gchar *name;
GParamFlags flags;
GType value_type;
GType owner_type;
} GParamSpec;
typedef struct {
GTypeInstance g_type_instance;
guint ref_count;
void *qdata;
} GObject;
typedef struct {
GObject parent_instance;
guint32 flags;
} GtkObject;
typedef struct
{
GObject parent_instance;
GdkColor fg[5];
GdkColor bg[5];
GdkColor light[5];
GdkColor dark[5];
GdkColor mid[5];
GdkColor text[5];
GdkColor base[5];
GdkColor text_aa[5]; /* Halfway between text/base */
GdkColor black;
GdkColor white;
PangoFontDescription *font_desc;
gint xthickness;
gint ythickness;
GdkGC *fg_gc[5];
GdkGC *bg_gc[5];
GdkGC *light_gc[5];
GdkGC *dark_gc[5];
GdkGC *mid_gc[5];
GdkGC *text_gc[5];
GdkGC *base_gc[5];
GdkGC *text_aa_gc[5];
GdkGC *black_gc;
GdkGC *white_gc;
GdkPixmap *bg_pixmap[5];
} GtkStyle;
typedef struct _GtkWidget GtkWidget;
struct _GtkWidget
{
GtkObject object;
guint16 private_flags;
guint8 state;
guint8 saved_state;
gchar *name;
GtkStyle *style;
GtkRequisition requisition;
GtkAllocation allocation;
GdkWindow *window;
GtkWidget *parent;
};
typedef struct
{
GtkWidget widget;
gfloat xalign;
gfloat yalign;
guint16 xpad;
guint16 ypad;
} GtkMisc;
typedef struct {
GtkWidget widget;
GtkWidget *focus_child;
guint border_width : 16;
guint need_resize : 1;
guint resize_mode : 2;
guint reallocate_redraws : 1;
guint has_focus_chain : 1;
} GtkContainer;
typedef struct {
GtkContainer container;
GtkWidget *child;
} GtkBin;
typedef struct {
GtkBin bin;
GdkWindow *event_window;
gchar *label_text;
guint activate_timeout;
guint constructed : 1;
guint in_button : 1;
guint button_down : 1;
guint relief : 2;
guint use_underline : 1;
guint use_stock : 1;
guint depressed : 1;
guint depress_on_activate : 1;
guint focus_on_click : 1;
} GtkButton;
typedef struct {
GtkButton button;
guint active : 1;
guint draw_indicator : 1;
guint inconsistent : 1;
} GtkToggleButton;
typedef struct _GtkAdjustment GtkAdjustment;
struct _GtkAdjustment
{
GtkObject parent_instance;
gdouble lower;
gdouble upper;
gdouble value;
gdouble step_increment;
gdouble page_increment;
gdouble page_size;
};
typedef enum
{
GTK_UPDATE_CONTINUOUS,
GTK_UPDATE_DISCONTINUOUS,
GTK_UPDATE_DELAYED
} GtkUpdateType;
typedef struct _GtkRange GtkRange;
struct _GtkRange
{
GtkWidget widget;
GtkAdjustment *adjustment;
GtkUpdateType update_policy;
guint inverted : 1;
/*< protected >*/
guint flippable : 1;
guint has_stepper_a : 1;
guint has_stepper_b : 1;
guint has_stepper_c : 1;
guint has_stepper_d : 1;
guint need_recalc : 1;
guint slider_size_fixed : 1;
gint min_slider_size;
GtkOrientation orientation;
GdkRectangle range_rect;
gint slider_start, slider_end;
gint round_digits;
/*< private >*/
guint trough_click_forward : 1;
guint update_pending : 1;
/*GtkRangeLayout * */ void *layout;
/*GtkRangeStepTimer * */ void* timer;
gint slide_initial_slider_position;
gint slide_initial_coordinate;
guint update_timeout_id;
GdkWindow *event_window;
};
typedef struct _GtkProgressBar GtkProgressBar;
typedef enum
{
GTK_PROGRESS_CONTINUOUS,
GTK_PROGRESS_DISCRETE
} GtkProgressBarStyle;
typedef enum
{
GTK_PROGRESS_LEFT_TO_RIGHT,
GTK_PROGRESS_RIGHT_TO_LEFT,
GTK_PROGRESS_BOTTOM_TO_TOP,
GTK_PROGRESS_TOP_TO_BOTTOM
} GtkProgressBarOrientation;
typedef struct _GtkProgress GtkProgress;
struct _GtkProgress
{
GtkWidget widget;
GtkAdjustment *adjustment;
GdkPixmap *offscreen_pixmap;
gchar *format;
gfloat x_align;
gfloat y_align;
guint show_text : 1;
guint activity_mode : 1;
guint use_text_format : 1;
};
struct _GtkProgressBar
{
GtkProgress progress;
GtkProgressBarStyle bar_style;
GtkProgressBarOrientation orientation;
guint blocks;
gint in_block;
gint activity_pos;
guint activity_step;
guint activity_blocks;
gdouble pulse_fraction;
guint activity_dir : 1;
guint ellipsize : 3;
};
/**
* Returns :
* NULL if the GLib library is compatible with the given version, or a string
* describing the version mismatch.
* Please note that the glib_check_version() is available since 2.6,
* so you should use GLIB_CHECK_VERSION macro instead.
*/
static gchar* (*fp_glib_check_version)(guint required_major, guint required_minor,
guint required_micro);
/**
* Returns :
* TRUE if the GLib library is compatible with the given version
*/
#define GLIB_CHECK_VERSION(major, minor, micro) \
(fp_glib_check_version && fp_glib_check_version(major, minor, micro) == NULL)
/**
* Returns :
* NULL if the GTK+ library is compatible with the given version, or a string
* describing the version mismatch.
*/
static gchar* (*fp_gtk_check_version)(guint required_major, guint required_minor,
guint required_micro);
static void gtk2_init(GtkApi* gtk);
static void (*fp_g_free)(gpointer mem);
static void (*fp_g_object_unref)(gpointer object);
static GdkWindow *(*fp_gdk_get_default_root_window) (void);
static int (*fp_gdk_pixbuf_get_bits_per_sample)(const GdkPixbuf *pixbuf);
static guchar *(*fp_gdk_pixbuf_get_pixels)(const GdkPixbuf *pixbuf);
static gboolean (*fp_gdk_pixbuf_get_has_alpha)(const GdkPixbuf *pixbuf);
static int (*fp_gdk_pixbuf_get_height)(const GdkPixbuf *pixbuf);
static int (*fp_gdk_pixbuf_get_n_channels)(const GdkPixbuf *pixbuf);
static int (*fp_gdk_pixbuf_get_rowstride)(const GdkPixbuf *pixbuf);
static int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);
static GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error);
static GdkColorspace (*fp_gdk_pixbuf_get_colorspace)(const GdkPixbuf *pixbuf);
static GdkPixbuf *(*fp_gdk_pixbuf_get_from_drawable)(GdkPixbuf *dest,
GdkDrawable *src, GdkColormap *cmap, int src_x, int src_y,
int dest_x, int dest_y, int width, int height);
static GdkPixbuf *(*fp_gdk_pixbuf_scale_simple)(GdkPixbuf *src,
int dest_width, int dest_heigh, GdkInterpType interp_type);
static void (*fp_gtk_widget_destroy)(void *widget);
static void (*fp_gtk_window_present)(GtkWindow *window);
static void (*fp_gtk_window_move)(GtkWindow *window, gint x, gint y);
static void (*fp_gtk_window_resize)(GtkWindow *window, gint width, gint height);
/**
* Function Pointers for GtkFileChooser
*/
static gchar* (*fp_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
static void (*fp_gtk_widget_hide)(void *widget);
static void (*fp_gtk_main_quit)(void);
static void* (*fp_gtk_file_chooser_dialog_new)(const gchar *title,
GtkWindow *parent, GtkFileChooserAction action,
const gchar *first_button_text, ...);
static gboolean (*fp_gtk_file_chooser_set_current_folder)(GtkFileChooser *chooser,
const gchar *filename);
static gboolean (*fp_gtk_file_chooser_set_filename)(GtkFileChooser *chooser,
const char *filename);
static void (*fp_gtk_file_chooser_set_current_name)(GtkFileChooser *chooser,
const gchar *name);
static void (*fp_gtk_file_filter_add_custom)(GtkFileFilter *filter,
GtkFileFilterFlags needed, GtkFileFilterFunc func, gpointer data,
GDestroyNotify notify);
static void (*fp_gtk_file_chooser_set_filter)(GtkFileChooser *chooser,
GtkFileFilter *filter);
static GType (*fp_gtk_file_chooser_get_type)(void);
static GtkFileFilter* (*fp_gtk_file_filter_new)(void);
static void (*fp_gtk_file_chooser_set_do_overwrite_confirmation)(
GtkFileChooser *chooser, gboolean do_overwrite_confirmation);
static void (*fp_gtk_file_chooser_set_select_multiple)(
GtkFileChooser *chooser, gboolean select_multiple);
static gchar* (*fp_gtk_file_chooser_get_current_folder)(GtkFileChooser *chooser);
static GSList* (*fp_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
static guint (*fp_gtk_g_slist_length)(GSList *list);
static gulong (*fp_g_signal_connect_data)(gpointer instance,
const gchar *detailed_signal, GCallback c_handler, gpointer data,
GClosureNotify destroy_data, GConnectFlags connect_flags);
static void (*fp_gtk_widget_show)(void *widget);
static void (*fp_gtk_main)(void);
static guint (*fp_gtk_main_level)(void);
static gchar* (*fp_g_path_get_dirname) (const gchar *file_name);
static XID (*fp_gdk_x11_drawable_get_xid) (GdkWindow *drawable);
static GList* (*fp_g_list_append) (GList *list, gpointer data);
static void (*fp_g_list_free) (GList *list);
static void (*fp_g_list_free_full) (GList *list, GDestroyNotify free_func);
static gboolean (*fp_gtk_show_uri)(GdkScreen *screen, const gchar *uri,
guint32 timestamp, GError **error);
#endif /* !_GTK2_INTERFACE_H */

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -32,10 +32,8 @@
#include "jvm_md.h"
#include "gtk_interface.h"
GtkApi* gtk2_load(JNIEnv *env, const char* lib_name);
GtkApi* gtk3_load(JNIEnv *env, const char* lib_name);
gboolean gtk2_check(const char* lib_name, gboolean load);
gboolean gtk3_check(const char* lib_name, gboolean load);
GtkApi *gtk;
@ -56,13 +54,6 @@ static GtkLib gtk_libs[] = {
&gtk3_load,
&gtk3_check
},
{
GTK_2,
JNI_LIB_NAME("gtk-x11-2.0"),
VERSIONED_JNI_LIB_NAME("gtk-x11-2.0", "0"),
&gtk2_load,
&gtk2_check
}
};
static GtkLib** get_libs_order(GtkVersion version) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -675,7 +675,6 @@ static gboolean isAllDataReady() {
static void *pipewire_libhandle = NULL;
//glib_version_2_68 false for gtk2, as it comes from gtk3_interface.c
extern gboolean glib_version_2_68;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -45,8 +45,9 @@ public class GtkVersionTest {
public static void main(String[] args) throws Exception {
test(null, "3");
test("2", "2");
test("2.2", "2");
// GTK 2 is removed, but the test can still be useful.
// test("2", "2");
// test("2.2", "2");
test("3", "3");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, JetBrains s.r.o.. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -41,10 +41,9 @@ import java.io.IOException;
* @test
* @key headful
* @bug 8280861
* @summary Verifies Robot screen capture capabilities with different
* @summary Verifies Robot screen capture capabilities with available
* Gtk backends and presence of UI scaling
* @requires os.family == "linux"
* @run main/othervm -Djdk.gtk.version=2 -Dsun.java2d.uiScale=1 ScreenCaptureGtkTest
* @run main/othervm -Djdk.gtk.version=3 -Dsun.java2d.uiScale=1 ScreenCaptureGtkTest
*/
@ -53,12 +52,6 @@ public class ScreenCaptureGtkTest {
Color.GREEN, Color.BLUE, Color.ORANGE, Color.RED};
public static void main(String[] args) throws Exception {
if ("2".equals(System.getProperty("jdk.gtk.version"))
&& System.getenv("WAYLAND_DISPLAY") != null) {
// screen capture is not supported with gtk2 on Wayland
return;
}
final int topOffset = 50;
final int leftOffset = 50;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -28,7 +28,6 @@
@bug 8156121
@key headful
@requires os.family == "linux"
@run main/othervm -Djdk.gtk.version=2 DemandGTK
@run main/othervm -Djdk.gtk.version=3 DemandGTK
*/

View File

@ -1,91 +0,0 @@
#!/bin/ksh -p
#
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @summary Try to force GTK2. We must bail out to GTK3 (if any) if no 2 available.
#
# @key headful
# @bug 8156128 8212903
# @compile ProvokeGTK.java
# @requires os.family == "linux"
# @run shell/timeout=400 DemandGTK2.sh
#
# Note that we depend on
# strace in the PATH
# /sbin/ldconfig (which may be not in PATH)
# It is true for OEL 7 and Ubuntu 14, 16
# but may fail in future. Save tomorrow for tomorrow.
#
# Read DemandGTK2.txt how to prepare GTK2-less machine.
#
which strace
if [ $? -ne 0 ]
then
echo "Please provide strace: \"which strace\" failed."
exit 1
fi
HAVE_2=`/sbin/ldconfig -v 2>/dev/null | grep libgtk-x11-2 | wc -l`
HAVE_3=`/sbin/ldconfig -v 2>/dev/null | grep libgtk-3.so | wc -l`
if [ "${HAVE_2}" = "0" ]
then
if [ "${HAVE_3}" = "0" ]
then
echo "Neither GTK2 nor GTK3 found: system misconfiguration. Exit."
exit 1
fi
echo "No GTK 2 library found: we should bail out to 3"
strace -o strace.log -fe open,openat ${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} -Djdk.gtk.version=2 ProvokeGTK
EXECRES=$?
grep 'libgtk-3.*=\ *[0-9]*$' strace.log > logg
else
echo "There is GTK 2 library: we should use it"
strace -o strace.log -fe open,openat ${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} -Djdk.gtk.version=2 ProvokeGTK
EXECRES=$?
grep 'libgtk-x11.*=\ *[0-9]*$' strace.log > logg
fi
if [ ${EXECRES} -ne 0 ]
then
echo "java execution failed for unknown reason, see logs"
exit 2
fi
cat logg
if [ -s logg ]
then
echo "Success."
exit 0
else
echo "Failed. Examine logs."
exit 3
fi

View File

@ -1,36 +0,0 @@
How to prepare an Ubuntu machine for GTK-2-less test run.
The test DemandGTK2.sh should work well without GTK-2 switching to version 3
if there's no GTK-2 library available.
At the moment, it's not easy to find a system with GTK-3 and without GTK-2:
many programs still depend on version 2.
We can, however, rename GTK-2 library for a single test run and then restore
it back.
(1) Find GTK2 library: run
/sbin/ldconfig -v 2>/dev/null | grep libgtk-x11-2
It will output one or two lines like
libgtk-x11-2.0.so.0 -> libgtk-x11-2.0.so.0.2400.23
Search for the target of that symlink for instance with locate:
locate libgtk-x11-2.0.so.0.2400.23
Finally, you'll find the libraries. On my current machine they are
/usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0.2400.23
/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23
I'm running 64-bit JDK and need to tamper with x86_64 copy only.
(2) Find running programs depending on this library. They probably would crash
if you rename it. Stop them for this test run.
That said, I'm afraid it would be impossible to do on a system older than Ubuntu 16.04.
On my Ubuntu 16.04 I have only hud-service using this library, and that's OK, it will restart
after a crash, if any.
To find these programs, run
lsof /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23
(3) Now,
sudo mv /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23 /usr/lib/x86_64-linux-gnu/bak.libgtk-x11-2.0.so.0.2400.23
jtreg DemandGTK2.sh
sudo mv /usr/lib/x86_64-linux-gnu/bak.libgtk-x11-2.0.so.0.2400.23 /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23
Needless to say, you should substitute your own library path and however you run jtreg.

View File

@ -1,7 +1,7 @@
#!/bin/ksh -p
#
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@ -25,7 +25,7 @@
# @test
# @summary Try to force GTK3. We must bail out to GTK2 if no 3 available.
# @summary Try to force GTK3.
#
# @key headful
# @bug 8156128 8212903
@ -53,11 +53,8 @@ HAVE_3=`/sbin/ldconfig -v 2>/dev/null | grep libgtk-3.so | wc -l`
if [ "${HAVE_3}" = "0" ]
then
echo "No GTK 3 library found: we should bail out to 2"
strace -o strace.log -fe open,openat ${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} -Djdk.gtk.version=3 ProvokeGTK
EXECRES=$?
grep 'libgtk-x11.*=\ *[0-9]*$' strace.log > logg
echo "No GTK 3 library found, do nothing"
exit 0
else
echo "There is GTK 3 library: we should use it"
strace -o strace.log -fe open,openat ${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} -Djdk.gtk.version=3 ProvokeGTK