Skip to content

Commit 90ff8bf

Browse files
committed
[GTK] Revert unification of blank Image initialization #1891
A previous change unified the Image surface initialization for blank Image instances just based on height and width. Because of the change, screen capturing using a GC on the display does only work properly when executed the first time in an application lifecycle and in specific situation, the initial properties of a GC changed (such as the text anti-aliasing behavior). Due to a lack of a better solution for now, this change reverts the unification of the Image surface initialization to the previous state. Fixes #1891 This partially reverts commit 5c2611d.
1 parent 74635dd commit 90ff8bf

File tree

1 file changed

+5
-1
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics

1 file changed

+5
-1
lines changed

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1260,7 +1260,11 @@ void init(int width, int height) {
12601260
this.type = SWT.BITMAP;
12611261

12621262
/* Create the pixmap */
1263-
surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_ARGB32, width, height);
1263+
if (GTK.GTK4) {
1264+
surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_FORMAT_RGB24, width, height);
1265+
} else {
1266+
surface = GDK.gdk_window_create_similar_surface(GDK.gdk_get_default_root_window(), Cairo.CAIRO_CONTENT_COLOR, width, height);
1267+
}
12641268
if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES);
12651269
// When we create a blank image we need to set it to 100 in GTK3 as we draw using 100% scale.
12661270
// Cairo will take care of scaling for us when image needs to be scaled.

0 commit comments

Comments
 (0)