Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2019-04-17 20:34:02 +0000
committerEric Williams2019-05-03 16:23:33 +0000
commit40d3246c17d9458f2ea44ca058ff534cf8c4fcf5 (patch)
treed423e37d649e7c8db420f1219a613055a20c8f91
parent95a91a1f5a85a0bdc7d04a87bb9f94a30d9c9ecf (diff)
downloadeclipse.platform.swt-40d3246c17d9458f2ea44ca058ff534cf8c4fcf5.tar.gz
eclipse.platform.swt-40d3246c17d9458f2ea44ca058ff534cf8c4fcf5.tar.xz
eclipse.platform.swt-40d3246c17d9458f2ea44ca058ff534cf8c4fcf5.zip
Bug 546525: [GTK4] Handle layout problems
Connect the proper "size-allocate" signal for GTK4, which solves the layout issues. At the time of this patch, there were some overdrawing issues -- the buttons in Snippet5 are drawn outside their Shell. This will be handled separately. Tested on GTK 3.94 on Fedora 29 and Fedora 30. Change-Id: I055efc036b3c0580247bdb0d07af271d0b3abba1 Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java13
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java4
3 files changed, 17 insertions, 7 deletions
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 d7d8a36c3d..103bde2ebc 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
@@ -3634,7 +3634,11 @@ void initializeCallbacks () {
signalIds [Widget.SCROLL_EVENT] = OS.g_signal_lookup (OS.scroll_event, GTK.GTK_TYPE_WIDGET ());
signalIds [Widget.SHOW] = OS.g_signal_lookup (OS.show, GTK.GTK_TYPE_WIDGET ());
signalIds [Widget.SHOW_HELP] = OS.g_signal_lookup (OS.show_help, GTK.GTK_TYPE_WIDGET ());
- signalIds [Widget.SIZE_ALLOCATE] = OS.g_signal_lookup (OS.size_allocate, GTK.GTK_TYPE_WIDGET ());
+ if (GTK.GTK4) {
+ signalIds [Widget.SIZE_ALLOCATE_GTK4] = OS.g_signal_lookup (OS.size_allocate, GTK.GTK_TYPE_WIDGET ());
+ } else {
+ signalIds [Widget.SIZE_ALLOCATE] = OS.g_signal_lookup (OS.size_allocate, GTK.GTK_TYPE_WIDGET ());
+ }
signalIds [Widget.STYLE_UPDATED] = OS.g_signal_lookup (OS.style_updated, GTK.GTK_TYPE_WIDGET ());
signalIds [Widget.UNMAP] = OS.g_signal_lookup (OS.unmap, GTK.GTK_TYPE_WIDGET ());
signalIds [Widget.UNMAP_EVENT] = OS.g_signal_lookup (OS.unmap_event, GTK.GTK_TYPE_WIDGET ());
@@ -3793,6 +3797,7 @@ void initializeCallbacks () {
closuresProc [Widget.ROW_HAS_CHILD_TOGGLED] = windowProc4;
closuresProc [Widget.DELETE_FROM_CURSOR] = windowProc4;
closuresProc [Widget.DELETE_FROM_CURSOR_INVERSE] = windowProc4;
+ closuresProc [Widget.SIZE_ALLOCATE_GTK4] = windowProc4;
windowCallback5 = new Callback (this, "windowProc", 5); //$NON-NLS-1$
windowProc5 = windowCallback5.getAddress ();
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 3d19416e8a..caa4466520 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
@@ -927,12 +927,13 @@ void hookEvents () {
GTK.gtk_widget_realize(shellHandle);
long gdkSurface = gtk_widget_get_surface (shellHandle);
OS.g_signal_connect (gdkSurface, OS.notify_state, notifyStateAddress, shellHandle);
+ OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [SIZE_ALLOCATE_GTK4], 0, display.getClosure (SIZE_ALLOCATE_GTK4), false);
} 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);
OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [MAP_EVENT], 0, display.shellMapProcClosure, false);
+ OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [SIZE_ALLOCATE], 0, display.getClosure (SIZE_ALLOCATE), false);
}
- OS.g_signal_connect_closure_by_id (shellHandle, display.signalIds [SIZE_ALLOCATE], 0, display.getClosure (SIZE_ALLOCATE), false);
if (GTK.GTK4) {
OS.g_signal_connect_closure (shellHandle, OS.close_request, display.getClosure (CLOSE_REQUEST), false);
long keyController = GTK.gtk_event_controller_key_new();
@@ -2144,10 +2145,12 @@ void resizeBounds (int width, int height, boolean notify) {
if (redrawSurface != 0) {
GDK.gdk_surface_resize (redrawSurface, width, height);
}
- GtkAllocation allocation = new GtkAllocation();
- allocation.width = width;
- allocation.height = height;
- GTK.gtk_widget_size_allocate(shellHandle, allocation, -1);
+ if (parent != null) {
+ GtkAllocation allocation = new GtkAllocation();
+ allocation.width = width;
+ allocation.height = height;
+ GTK.gtk_widget_size_allocate(shellHandle, allocation, -1);
+ }
} else {
if (redrawWindow != 0) {
GDK.gdk_window_resize (redrawWindow, width, height);
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 5ac365a557..a0e68d8da7 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
@@ -235,7 +235,8 @@ public abstract class Widget {
static final int GESTURE_PRESSED = 100;
static final int GESTURE_RELEASED = 101;
static final int NOTIFY_STATE = 102;
- static final int LAST_SIGNAL = 103;
+ static final int SIZE_ALLOCATE_GTK4 = 103;
+ static final int LAST_SIGNAL = 104;
static final String IS_ACTIVE = "org.eclipse.swt.internal.control.isactive"; //$NON-NLS-1$
static final String KEY_CHECK_SUBWINDOW = "org.eclipse.swt.internal.control.checksubwindow"; //$NON-NLS-1$
@@ -2267,6 +2268,7 @@ long windowProc (long handle, long arg0, long arg1, long user_data) {
case TEST_EXPAND_ROW: return gtk_test_expand_row(handle, arg0, arg1);
case ROW_INSERTED: return gtk_row_inserted (handle, arg0, arg1);
case ROW_HAS_CHILD_TOGGLED: return gtk_row_has_child_toggled(handle, arg0, arg1);
+ case SIZE_ALLOCATE_GTK4: return gtk_size_allocate(handle, arg0);
default: return 0;
}
}

Back to the top