Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2019-01-23 13:53:43 -0500
committerEric Williams2019-01-23 14:52:10 -0500
commit4575657f00327b3a37f36198fdace58ed9f05424 (patch)
tree351c2f060d8e1ef09f205ef7bb57214342e0e879
parent51a0130d9b1343b377085816517ce34e9b2e2dca (diff)
downloadeclipse.platform.swt-4575657f00327b3a37f36198fdace58ed9f05424.tar.gz
eclipse.platform.swt-4575657f00327b3a37f36198fdace58ed9f05424.tar.xz
eclipse.platform.swt-4575657f00327b3a37f36198fdace58ed9f05424.zip
Bug 540841: [GTK4] Rename GdkWindow to GdkSurface
Don't use gdk_get_default_root_window() on GTK4. Change-Id: I45b7909c674df15cbb6d225264b0ee65b1893284 Signed-off-by: Eric Williams <ericwill@redhat.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java9
6 files changed, 26 insertions, 13 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java
index 8ec97e05a3..ab9bef8794 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/DropTarget.java
@@ -567,14 +567,14 @@ public DropTargetEffect getDropTargetEffect() {
int getOperationFromKeyState() {
int[] state = new int[1];
- long /*int*/ root = GDK.gdk_get_default_root_window ();
- long /*int*/ pointer = GDK.gdk_get_pointer (GDK.gdk_window_get_display (root));
+ long /*int*/ pointer = GDK.gdk_get_pointer (GDK.gdk_display_get_default());
if (GTK.GTK4) {
/*
* TODO: calling gdk_window_get_device_position() here
* uses gdk_get_default_root_window(), which doesn't exist on GTK4.
*/
} else {
+ long /*int*/ root = GDK.gdk_get_default_root_window ();
GDK.gdk_window_get_device_position(root, pointer, null, null, state);
}
boolean ctrl = (state[0] & GDK.GDK_CONTROL_MASK) != 0;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
index c15869c6b9..740cf4cc7b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Device.java
@@ -664,9 +664,7 @@ protected void init () {
long /*int*/ gdkResource;
long /*int*/ surface;
if (GTK.GTK4) {
- GTK.gtk_widget_realize(shellHandle);
- gdkResource = GTK.gtk_widget_get_surface(shellHandle);
- surface = GDK.gdk_surface_create_similar_surface(gdkResource, Cairo.CAIRO_CONTENT_COLOR, 10, 10);
+ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_CONTENT_COLOR, 10, 10);
} else {
gdkResource = GDK.gdk_get_default_root_window();
surface = GDK.gdk_window_create_similar_surface(gdkResource, Cairo.CAIRO_CONTENT_COLOR, 10, 10);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
index 76b912103d..01532de632 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/GC.java
@@ -2618,7 +2618,7 @@ void initCairo() {
if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
long /*int*/ surface;
if (GTK.GTK4) {
- surface = GDK.gdk_surface_create_similar_surface(data.drawable, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
+ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
} else {
surface = GDK.gdk_window_create_similar_surface(data.drawable, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
index ccaef78224..259d4a01e2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Image.java
@@ -1249,7 +1249,11 @@ void init(int width, int height) {
this.type = SWT.BITMAP;
/* Create the pixmap */
- surface = GDK.gdk_window_create_similar_surface(GDK.gdk_get_default_root_window(), Cairo.CAIRO_CONTENT_COLOR, width, height);
+ if (GTK.GTK4) {
+ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_CONTENT_COLOR, width, height);
+ } else {
+ surface = GDK.gdk_window_create_similar_surface(GDK.gdk_get_default_root_window(), Cairo.CAIRO_CONTENT_COLOR, width, height);
+ }
if (surface == 0) SWT.error(SWT.ERROR_NO_HANDLES);
// When we create a blank image we need to set it to 100 in GTK3 as we draw using 100% scale.
// Cairo will take care of scaling for us when image needs to be scaled.
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 39211debde..9c6e33db67 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
@@ -3959,13 +3959,19 @@ public void internal_dispose_GC (long /*int*/ hDC, GCData data) {
@Override
public long /*int*/ internal_new_GC (GCData data) {
if (isDisposed()) error(SWT.ERROR_DEVICE_DISPOSED);
- long /*int*/ root = GDK.gdk_get_default_root_window();
long /*int*/ gc = 0;
- if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
- long /*int*/ surface = GDK.gdk_window_create_similar_surface(root, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
+ long /*int*/ root = 0;
+ if (GTK.GTK4) {
+ long /*int*/ surface = Cairo.cairo_image_surface_create(Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
gc = Cairo.cairo_create(surface);
} else {
- gc = GDK.gdk_cairo_create(root);
+ root = GDK.gdk_get_default_root_window();
+ if (GTK.GTK_VERSION >= OS.VERSION(3, 22, 0)) {
+ long /*int*/ surface = GDK.gdk_window_create_similar_surface(root, Cairo.CAIRO_CONTENT_COLOR_ALPHA, data.width, data.height);
+ gc = Cairo.cairo_create(surface);
+ } else {
+ gc = GDK.gdk_cairo_create(root);
+ }
}
if (gc == 0) error (SWT.ERROR_NO_HANDLES);
//TODO how gdk_gc_set_subwindow is done in cairo?
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
index 7278e81f88..a2002de700 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
@@ -329,7 +329,12 @@ Rectangle [] computeProportions (Rectangle [] rects) {
* @param rects
*/
void drawRectangles (Rectangle [] rects) {
- long /*int*/ gdkResource = GDK.gdk_get_default_root_window();
+ long /*int*/ gdkResource = 0;
+ if (GTK.GTK4) {
+ if (parent != null) gdkResource = gtk_widget_get_surface(parent.handle);
+ } else {
+ gdkResource = GDK.gdk_get_default_root_window();
+ }
if (parent != null) {
long /*int*/ paintHandle = parent.paintHandle();
gdkResource = GTK.GTK4 ? gtk_widget_get_surface(paintHandle) : gtk_widget_get_window (paintHandle);
@@ -764,7 +769,7 @@ void moveRectangles (int xChange, int yChange) {
*/
public boolean open () {
checkWidget();
- window = GDK.gdk_get_default_root_window();
+ if (!GTK.GTK4) window = GDK.gdk_get_default_root_window();
if (parent != null) {
window = gtk_widget_get_window (parent.paintHandle());
}

Back to the top