Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul D'\''Pong2020-09-03 17:12:19 +0000
committerSoraphol (Paul) Damrongpiriyapong2020-09-10 18:51:05 +0000
commit0d4b170f3151e3366b377b52fc0b974a1b769538 (patch)
tree58bdabc1c056c375245fffa7379ef89287ca9073
parentd8738edda157a9479879c35b8783af214688b2c9 (diff)
downloadeclipse.platform.swt-0d4b170f3151e3366b377b52fc0b974a1b769538.tar.gz
eclipse.platform.swt-0d4b170f3151e3366b377b52fc0b974a1b769538.tar.xz
eclipse.platform.swt-0d4b170f3151e3366b377b52fc0b974a1b769538.zip
Bug 566654 - [GTK4] Removal of size-allocate signal
- Added "resize" signal to SWTFixed, which is emitted everytime gtk_widget_size_allocate is called. - Connect the shell's SWTFixed to the resize signal (alternative to size-allocate signal attached to GtkWindow) Change-Id: Id678bdec1ef683ce6e5173607a876ab9c361b46d Signed-off-by: Paul D'Pong <sdamrong@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.c65
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java5
4 files changed, 44 insertions, 44 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 a26be9698f..12ecf32d86 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
@@ -704,13 +704,20 @@ enum {
PROP_VSCROLL_POLICY,
};
+enum {
+ RESIZE,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
static void swt_fixed_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void swt_fixed_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
static void swt_fixed_finalize (GObject *object);
static void swt_fixed_map (GtkWidget *widget);
static void swt_fixed_measure (GtkWidget *widget, GtkOrientation orientation, int for_size, int *minimum,
int *natural, int *minimum_baseline, int *natural_baseline);
-static void swt_fixed_size_allocate (GtkWidget *widget, const GtkAllocation *allocation, int baseline);
+static void swt_fixed_size_allocate (GtkWidget *widget, int width, int height, int baseline);
G_DEFINE_TYPE_WITH_CODE (SwtFixed, swt_fixed, GTK_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (GTK_TYPE_SCROLLABLE, NULL)
@@ -725,7 +732,7 @@ static void swt_fixed_class_init (SwtFixedClass *class) {
gobject_class->get_property = swt_fixed_get_property;
gobject_class->finalize = swt_fixed_finalize;
- /* Scrollable implemetation */
+ /* Scrollable implementation */
g_object_class_override_property (gobject_class, PROP_HADJUSTMENT, "hadjustment");
g_object_class_override_property (gobject_class, PROP_VADJUSTMENT, "vadjustment");
g_object_class_override_property (gobject_class, PROP_HSCROLL_POLICY, "hscroll-policy");
@@ -735,6 +742,13 @@ static void swt_fixed_class_init (SwtFixedClass *class) {
widget_class->map = swt_fixed_map;
widget_class->measure = swt_fixed_measure;
widget_class->size_allocate = swt_fixed_size_allocate;
+
+ signals[RESIZE] = g_signal_new(
+ "resize",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
}
void swt_fixed_restack (SwtFixed *fixed, GtkWidget *widget, GtkWidget *sibling, gboolean above) {
@@ -771,17 +785,6 @@ void swt_fixed_restack (SwtFixed *fixed, GtkWidget *widget, GtkWidget *sibling,
list = above ? priv->children : NULL;
}
priv->children = g_list_insert_before (priv->children, list, child);
-
- /*
- {
- GdkWindow *sibling_window = NULL;
- if (list) {
- child = list->data;
- sibling_window = gtk_widget_get_window (child);
- }
- gdk_window_restack (gtk_widget_get_window (widget), sibling_window, above);
- }
- */
}
static void swt_fixed_init (SwtFixed *widget) {
@@ -908,51 +911,37 @@ static void swt_fixed_measure (GtkWidget *widget, GtkOrientation orientation, i
return;
}
-static void swt_fixed_size_allocate (GtkWidget *widget, const GtkAllocation *allocation, int baseline) {
+static void swt_fixed_size_allocate (GtkWidget *widget, int width, int height, int baseline) {
+ g_signal_emit (widget, signals[RESIZE], 0, width, height);
+
SwtFixed *fixed = SWT_FIXED (widget);
SwtFixedPrivate *priv = fixed->priv;
- GList *list;
- GtkAllocation child_allocation;
- GtkRequisition requisition;
- gint w, h;
-
- GtkNative* native = gtk_widget_get_native(widget);
- if (native != NULL) {
- if (gtk_widget_get_realized (widget)) {
- //TODO: GTK4 no surface_resize need to use respective present functions to position
- }
- }
-
- list = priv->children;
+ GList* list = priv->children;
while (list) {
SwtFixedChild *child_data = list->data;
GtkWidget *child = child_data->widget;
- list = list->next;
+ GtkAllocation child_allocation;
child_allocation.x = child_data->x;
child_allocation.y = child_data->y;
- if (native == NULL) {
- child_allocation.x += allocation->x;
- child_allocation.y += allocation->y;
- }
- w = child_data->width;
- h = child_data->height;
+ int w = child_data->width;
+ int h = child_data->height;
if (w == -1 || h == -1) {
+ GtkRequisition requisition;
gtk_widget_get_preferred_size (child, &requisition, NULL);
if (w == -1) w = requisition.width;
if (h == -1) h = requisition.height;
}
- // Feature in GTK: gtk_widget_preferred_size() has to be called before
- // gtk_widget_size_allocate otherwise a warning is thrown. See Bug 486068.
- gtk_widget_get_preferred_size (child, &requisition, NULL);
child_allocation.width = w;
child_allocation.height = h;
gtk_widget_size_allocate (child, &child_allocation, -1);
- }
+
+ list = list->next;
+ }
}
void swt_fixed_move (SwtFixed *fixed, GtkWidget *widget, gint x, gint y) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 3b218cc6ea..cb5a3907d2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -348,6 +348,7 @@ public class OS extends C {
public static final byte[] show = ascii("show");
public static final byte[] show_help = ascii("show-help");
public static final byte[] size_allocate = ascii("size-allocate");
+ public static final byte[] resize = ascii("resize");
public static final byte[] start_interactive_search = ascii("start-interactive-search");
public static final byte[] style_updated = ascii("style-updated");
public static final byte[] switch_page = ascii("switch-page");
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 8b93e7e5fd..307aa16fcc 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
@@ -129,12 +129,12 @@ public class Display extends Device {
Callback eventCallback;
long eventProc, windowProc2, windowProc3, windowProc4, windowProc5, windowProc6;
long snapshotDrawProc, changeValueProc;
- long keyPressReleaseProc, focusProc, enterMotionScrollProc, leaveProc;
+ long keyPressReleaseProc, focusProc, enterMotionScrollProc, leaveProc, resizeProc;
long gesturePressReleaseProc;
long notifyProc;
Callback windowCallback2, windowCallback3, windowCallback4, windowCallback5, windowCallback6;
Callback snapshotDraw, changeValue;
- Callback keyPressReleaseCallback, focusCallback, enterMotionScrollCallback, leaveCallback;
+ Callback keyPressReleaseCallback, focusCallback, enterMotionScrollCallback, leaveCallback, resizeCallback;
Callback gesturePressReleaseCallback;
Callback notifyCallback;
EventTable eventTable, filterTable;
@@ -3517,6 +3517,10 @@ void initializeCallbacks () {
long.class, long.class}); //$NON-NLS-1$
leaveProc = leaveCallback.getAddress ();
+ resizeCallback = new Callback (this, "resizeProc", void.class, new Type[] {
+ long.class, int.class, int.class}); //$NON-NLS-1$
+ resizeProc = resizeCallback.getAddress ();
+
closuresProc [Widget.LEAVE] = leaveProc;
}
@@ -4614,6 +4618,10 @@ void releaseDisplay () {
leaveCallback = null;
leaveProc = 0;
+ resizeCallback.dispose();
+ resizeCallback = null;
+ resizeProc = 0;
+
gesturePressReleaseCallback.dispose();
gesturePressReleaseCallback = null;
gesturePressReleaseProc = 0;
@@ -5961,6 +5969,11 @@ long leaveProc (long controller, long user_data) {
return widget.leaveProc(controller, handle, user_data);
}
+void resizeProc(long handle, int width, int height) {
+ Widget widget = getWidget(handle);
+ if (widget != null) widget.gtk_size_allocate(handle, 0);
+}
+
long notifyProc (long object, long param_spec, long user_data) {
Widget widget = getWidget (object);
if (widget == null) {
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 db4b2b3548..5ed7d69d13 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
@@ -937,10 +937,7 @@ void hookEvents () {
GTK.gtk_widget_realize(shellHandle);
long gdkSurface = gtk_widget_get_surface (shellHandle);
OS.g_signal_connect (gdkSurface, OS.notify_state, display.notifyProc, shellHandle);
- /* TODO: GTK4
- * The ::size-allocate signal has been removed, since it is easy to misuse.
- * If you need to learn about sizing changes of custom drawing widgets, use the “resize” or “resize” signals.
- * */
+ OS.g_signal_connect(handle, OS.resize, display.resizeProc, 0);
} else {
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [WINDOW_STATE_EVENT], 0, display.getClosure (WINDOW_STATE_EVENT), false);
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [CONFIGURE_EVENT], 0, display.getClosure (CONFIGURE_EVENT), false);

Back to the top