Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEric Williams2018-04-03 17:50:54 +0000
committerEric Williams2018-04-03 18:01:37 +0000
commit6186fb3eb3c00dde36a5ef7b90a15abcb46b5dcf (patch)
tree873f7d5f8fc87cb8e79c15ce019bf8c503b3baf5 /tests
parent32a4ec463315fd2e2cc607aeeefcd084d8768804 (diff)
downloadeclipse.platform.swt-6186fb3eb3c00dde36a5ef7b90a15abcb46b5dcf.tar.gz
eclipse.platform.swt-6186fb3eb3c00dde36a5ef7b90a15abcb46b5dcf.tar.xz
eclipse.platform.swt-6186fb3eb3c00dde36a5ef7b90a15abcb46b5dcf.zip
Bug 529431: [GTK3.10+] Snippet294 fails to draw Region
Allow GtkWindow (usually Shells) to be shaped using gdk_window_shape_combine_region() instead of cairo_clip. GtkWindow is unaffected by the changes in GTK3.10 so this is fine. A snippet has been added to test this functionality, and to test for the case mentioned in comment 8 of bug 529431. Change-Id: I40c80599e015553576fc8979181577c1170146d2 Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug529431_ShellSetRegion.java67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug529431_ShellSetRegion.java b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug529431_ShellSetRegion.java
new file mode 100644
index 0000000000..65b0f428eb
--- /dev/null
+++ b/tests/org.eclipse.swt.tests.gtk/ManualTests/org/eclipse/swt/tests/gtk/snippets/Bug529431_ShellSetRegion.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2018 Red Hat and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tests.gtk.snippets;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Region;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/*
+ * Title: Bug 529431: [GTK3.10+] Snippet294 fails to draw Region
+ * How to run: launch snippet and look for the resulting Shell
+ * Bug description: the Shell is a 200 x 200 square with no region set
+ * Expected results: the Shell is circle with inner circular regions
+ * GTK Version(s): GTK3.10+
+ */
+public class Bug529431_ShellSetRegion {
+
+ static int[] circle(int r, int offsetX, int offsetY) {
+ int[] polygon = new int[8 * r + 4];
+ // x^2 + y^2 = r^2
+ for (int i = 0; i < 2 * r + 1; i++) {
+ int x = i - r;
+ int y = (int)Math.sqrt(r*r - x*x);
+ polygon[2*i] = offsetX + x;
+ polygon[2*i+1] = offsetY + y;
+ polygon[8*r - 2*i - 2] = offsetX + x;
+ polygon[8*r - 2*i - 1] = offsetY - y;
+ }
+ return polygon;
+ }
+
+ public static void main(String[] args) {
+ final Display display = new Display();
+
+ final Shell shell = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP
+ | SWT.NO_FOCUS | SWT.TOOL);
+
+ shell.setSize(200,200);
+
+ // define a region that looks like a circle with two holes in it
+ Region region = new Region();
+ region.add(circle(67, 87, 77));
+ region.subtract(circle(20, 87, 47));
+ region.subtract(circle(20, 87, 113));
+
+ // define the shape of the shell using setRegion
+ shell.setRegion(region);
+ shell.open();
+
+ while (!shell.isDisposed()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ region.dispose();
+ display.dispose();
+ }
+
+}

Back to the top