1 /*
2 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
38 */
39 public class XEmbedServerTester implements XEventDispatcher {
40 private static final PlatformLogger xembedLog = PlatformLogger.getLogger("sun.awt.X11.xembed.XEmbedServerTester");
41 private final Object EVENT_LOCK = new Object();
42 static final int SYSTEM_EVENT_MASK = 0x8000;
43 int my_version, server_version;
44 XEmbedHelper xembed = new XEmbedHelper();
45 boolean focused;
46 int focusedKind;
47 int focusedServerComponent;
48 boolean reparent;
49 long parent;
50 boolean windowActive;
51 boolean xembedActive;
52 XBaseWindow window;
53 volatile int eventWaited = -1, eventReceived = -1;
54 int mapped;
55 int accel_key, accel_keysym, accel_mods;
56 static Rectangle initialBounds = new Rectangle(0, 0, 100, 100);
57 Robot robot;
58 Rectangle serverBounds[]; // first rectangle is for the server frame, second is for dummy frame, others are for its children
59 private static final int SERVER_BOUNDS = 0, OTHER_FRAME = 1, SERVER_FOCUS = 2, SERVER_MODAL = 3, MODAL_CLOSE = 4;
60
61 LinkedList<Integer> events = new LinkedList<Integer>();
62
63 private XEmbedServerTester(Rectangle serverBounds[], long parent) {
64 this.parent = parent;
65 focusedKind = -1;
66 focusedServerComponent = -1;
67 reparent = false;
68 windowActive = false;
69 xembedActive = false;
70 my_version = XEmbedHelper.XEMBED_VERSION;
71 mapped = XEmbedHelper.XEMBED_MAPPED;
72 this.serverBounds = serverBounds;
73 if (serverBounds.length < 5) {
74 throw new IllegalArgumentException("There must be at least five areas: server-activation, server-deactivation, server-focus, " +
75 "server-modal show, modal-close");
76 }
77 try {
78 robot = new Robot();
79 robot.setAutoDelay(100);
80 } catch (Exception e) {
81 throw new RuntimeException("Can't create robot");
82 }
83 initAccel();
84 if (xembedLog.isLoggable(PlatformLogger.Level.FINER)) {
85 xembedLog.finer("XEmbed client(tester), embedder window: " + Long.toHexString(parent));
86 }
87 }
88
89 public static XEmbedServerTester getTester(Rectangle serverBounds[], long parent) {
90 return new XEmbedServerTester(serverBounds, parent);
91 }
92
93 private void dumpReceivedEvents() {
94 if (xembedLog.isLoggable(PlatformLogger.Level.FINER)) {
95 xembedLog.finer("Events received so far:");
96 int pos = 0;
97 for (Integer event : events) {
98 xembedLog.finer((pos++) + ":" + XEmbedHelper.msgidToString(event));
99 }
100 xembedLog.finer("End of event dump");
101 }
102 }
103
104 public void test1_1() {
105 int res = embedCompletely();
106 waitWindowActivated(res);
107 requestFocus();
108 deactivateServer();
109 res = activateServer(getEventPos());
|
1 /*
2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
38 */
39 public class XEmbedServerTester implements XEventDispatcher {
40 private static final PlatformLogger xembedLog = PlatformLogger.getLogger("sun.awt.X11.xembed.XEmbedServerTester");
41 private final Object EVENT_LOCK = new Object();
42 static final int SYSTEM_EVENT_MASK = 0x8000;
43 int my_version, server_version;
44 XEmbedHelper xembed = new XEmbedHelper();
45 boolean focused;
46 int focusedKind;
47 int focusedServerComponent;
48 boolean reparent;
49 long parent;
50 boolean windowActive;
51 boolean xembedActive;
52 XBaseWindow window;
53 volatile int eventWaited = -1, eventReceived = -1;
54 int mapped;
55 int accel_key, accel_keysym, accel_mods;
56 static Rectangle initialBounds = new Rectangle(0, 0, 100, 100);
57 Robot robot;
58 Rectangle[] serverBounds; // first rectangle is for the server frame, second is for dummy frame, others are for its children
59 private static final int SERVER_BOUNDS = 0, OTHER_FRAME = 1, SERVER_FOCUS = 2, SERVER_MODAL = 3, MODAL_CLOSE = 4;
60
61 LinkedList<Integer> events = new LinkedList<Integer>();
62
63 private XEmbedServerTester(Rectangle[] serverBounds, long parent) {
64 this.parent = parent;
65 focusedKind = -1;
66 focusedServerComponent = -1;
67 reparent = false;
68 windowActive = false;
69 xembedActive = false;
70 my_version = XEmbedHelper.XEMBED_VERSION;
71 mapped = XEmbedHelper.XEMBED_MAPPED;
72 this.serverBounds = serverBounds;
73 if (serverBounds.length < 5) {
74 throw new IllegalArgumentException("There must be at least five areas: server-activation, server-deactivation, server-focus, " +
75 "server-modal show, modal-close");
76 }
77 try {
78 robot = new Robot();
79 robot.setAutoDelay(100);
80 } catch (Exception e) {
81 throw new RuntimeException("Can't create robot");
82 }
83 initAccel();
84 if (xembedLog.isLoggable(PlatformLogger.Level.FINER)) {
85 xembedLog.finer("XEmbed client(tester), embedder window: " + Long.toHexString(parent));
86 }
87 }
88
89 public static XEmbedServerTester getTester(Rectangle[] serverBounds, long parent) {
90 return new XEmbedServerTester(serverBounds, parent);
91 }
92
93 private void dumpReceivedEvents() {
94 if (xembedLog.isLoggable(PlatformLogger.Level.FINER)) {
95 xembedLog.finer("Events received so far:");
96 int pos = 0;
97 for (Integer event : events) {
98 xembedLog.finer((pos++) + ":" + XEmbedHelper.msgidToString(event));
99 }
100 xembedLog.finer("End of event dump");
101 }
102 }
103
104 public void test1_1() {
105 int res = embedCompletely();
106 waitWindowActivated(res);
107 requestFocus();
108 deactivateServer();
109 res = activateServer(getEventPos());
|