diff options
author | Eric Williams | 2019-05-21 16:30:27 +0000 |
---|---|---|
committer | Eric Williams | 2019-05-21 16:45:31 +0000 |
commit | d420adf2c536a3df6b496354233f299b73bdc5d3 (patch) | |
tree | f3415e6586ce2268c9f767b62850fdbc60601ee1 | |
parent | e5a15ba55972b191ed4270c58ce4c2b1af683cc5 (diff) | |
download | eclipse.platform.swt-d420adf2c536a3df6b496354233f299b73bdc5d3.tar.gz eclipse.platform.swt-d420adf2c536a3df6b496354233f299b73bdc5d3.tar.xz eclipse.platform.swt-d420adf2c536a3df6b496354233f299b73bdc5d3.zip |
Bug 547466: [GTK3] Form title text is partially not shown
Use the old-style GdkWindow drawing on GTK3 to prevent any breakages
and use the Cairo-only approach on GTK4. Removed the region parameter as
it's always 0.
Tested on GTK3.24 (Fedora 30) using the commit viewer and plugin.xml
editor.
Change-Id: I4b4f4bb193fa0768545d139a88ac41438c72300f
Signed-off-by: Eric Williams <ericwill@redhat.com>
3 files changed, 56 insertions, 23 deletions
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 03da5c05ef..cd3b5b32a6 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 @@ -191,22 +191,39 @@ void deregister () { if (imHandle != 0) display.removeWidget (imHandle); } -void drawBackground (Control control, long gdkResource, long cr, long region, int x, int y, int width, int height) { - long cairo = cr; - if (region == 0 && gdkResource != 0) { - cairo_rectangle_int_t regionRect = new cairo_rectangle_int_t (); - int [] fetchedHeight = new int [1]; - int [] fetchedWidth = new int [1]; - if (GTK.GTK4) { - gdk_surface_get_size(gdkResource, fetchedWidth, fetchedHeight); +void drawBackground (Control control, long gdkResource, long cr, int x, int y, int width, int height) { + long cairo, context = 0; + long region = 0; + if (GTK.GTK4) { + // TODO: once Eclipse runs on GTK4, check for bug 547466. + cairo = cr; + if (gdkResource != 0) { + cairo_rectangle_int_t regionRect = new cairo_rectangle_int_t (); + int [] fetchedHeight = new int [1]; + int [] fetchedWidth = new int [1]; + if (GTK.GTK4) { + gdk_surface_get_size(gdkResource, fetchedWidth, fetchedHeight); + } else { + gdk_window_get_size(gdkResource, fetchedWidth, fetchedHeight); + } + regionRect.x = 0; + regionRect.y = 0; + regionRect.width = fetchedWidth[0]; + regionRect.height = fetchedHeight[0]; + region = Cairo.cairo_region_create_rectangle(regionRect); + } + } else { + if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) { + if (cr == 0) { + long cairo_region = GDK.gdk_window_get_visible_region(gdkResource); + context = GDK.gdk_window_begin_draw_frame(gdkResource, cairo_region); + cairo = GDK.gdk_drawing_context_get_cairo_context(context); + } else { + cairo = cr; + } } else { - gdk_window_get_size(gdkResource, fetchedWidth, fetchedHeight); + cairo = cr != 0 ? cr : GDK.gdk_cairo_create(gdkResource); } - regionRect.x = 0; - regionRect.y = 0; - regionRect.width = fetchedWidth[0]; - regionRect.height = fetchedHeight[0]; - region = Cairo.cairo_region_create_rectangle(regionRect); } /* * It's possible that a client is using an SWT.NO_BACKGROUND Composite with custom painting @@ -244,6 +261,13 @@ void drawBackground (Control control, long gdkResource, long cr, long region, in } Cairo.cairo_rectangle (cairo, x, y, width, height); Cairo.cairo_fill (cairo); + if (!GTK.GTK4 ) { + if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) { + if (cairo != cr && context != 0) GDK.gdk_window_end_draw_frame(gdkResource, context); + } else { + if (cairo != cr) Cairo.cairo_destroy(cairo); + } + } } boolean drawGripper (GC gc, int x, int y, int width, int height, boolean vertical) { @@ -6766,9 +6790,18 @@ long windowProc (long handle, long arg0, long user_data) { GdkRectangle rect = new GdkRectangle (); GDK.gdk_cairo_get_clip_rectangle (cairo, rect); if (control == null) control = this; - long gdkResource = GTK.GTK4 ? GTK.gtk_widget_get_surface(handle) : - GTK.gtk_widget_get_window(handle); - drawBackground (control, gdkResource, cairo, 0, rect.x, rect.y, rect.width, rect.height); + long gdkResource; + if (GTK.GTK4) { + gdkResource = GTK.gtk_widget_get_surface(handle); + drawBackground (control, gdkResource, cairo, rect.x, rect.y, rect.width, rect.height); + } else { + gdkResource = GTK.gtk_widget_get_window(handle); + if (gdkResource != 0) { + drawBackground (control, gdkResource, 0, rect.x, rect.y, rect.width, rect.height); + } else { + drawBackground (control, 0, cairo, rect.x, rect.y, rect.width, rect.height); + } + } } break; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java index 778f9eb401..2bb970c8b4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java @@ -2272,7 +2272,7 @@ void drawInheritedBackground (long cairo) { OS.g_free (iter); } if (height [0] > bottom) { - drawBackground (control, gdkResource, cairo, 0, 0, bottom, width [0], height [0] - bottom); + drawBackground (control, gdkResource, cairo, 0, bottom, width [0], height [0] - bottom); } } } @@ -3000,7 +3000,7 @@ void rendererRender (long cell, long cr, long snapshot, long widget, long backgr if (cr != 0) { Cairo.cairo_save (cr); } - drawBackground (control, 0, cr, 0, rect.x, rect.y, rect.width, rect.height); + drawBackground (control, 0, cr, rect.x, rect.y, rect.width, rect.height); if (cr != 0) { Cairo.cairo_restore (cr); } @@ -4203,7 +4203,7 @@ long windowProc (long handle, long arg0, long user_data) { if (window == GTK.gtk_widget_get_window(handle)) { GdkRectangle rect = new GdkRectangle (); GDK.gdk_cairo_get_clip_rectangle (arg0, rect); - drawBackground (control, window, arg0, 0, rect.x, rect.y, rect.width, rect.height); + drawBackground (control, window, arg0, rect.x, rect.y, rect.width, rect.height); } } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java index 080570b8a4..374bc60e39 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java @@ -2364,7 +2364,7 @@ void drawInheritedBackground (long cairo) { } if (parent != 0) OS.g_free (parent); if (height [0] > (rect.y + rect.height)) { - drawBackground (control, gdkResource, cairo, 0, 0, rect.y + rect.height, width [0], height [0] - (rect.y + rect.height)); + drawBackground (control, gdkResource, cairo, 0, rect.y + rect.height, width [0], height [0] - (rect.y + rect.height)); } } } @@ -3106,7 +3106,7 @@ void rendererRender (long cell, long cr, long snapshot, long widget, long backgr if (cr != 0) { Cairo.cairo_save (cr); } - drawBackground (control, 0, cr, 0, rect.x, rect.y, rect.width, rect.height); + drawBackground (control, 0, cr, rect.x, rect.y, rect.width, rect.height); if (cr != 0) { Cairo.cairo_restore (cr); } @@ -4178,7 +4178,7 @@ long windowProc (long handle, long arg0, long user_data) { if (window == GTK.gtk_widget_get_window(handle)) { GdkRectangle rect = new GdkRectangle (); GDK.gdk_cairo_get_clip_rectangle (arg0, rect); - drawBackground (control, window, arg0, 0, rect.x, rect.y, rect.width, rect.height); + drawBackground (control, window, arg0, rect.x, rect.y, rect.width, rect.height); } } } |