1 /*
2 * Copyright (c) 2003, 2008, 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
164 /* The caller must hold AWT_LOCK. */
165 public abstract void sendEnterMessage(long[] formats, int sourceAction,
166 int sourceActions, long time);
167 /* The caller must hold AWT_LOCK. */
168 public abstract void sendMoveMessage(int xRoot, int yRoot,
169 int sourceAction, int sourceActions,
170 long time);
171 /* The caller must hold AWT_LOCK. */
172 public abstract void sendLeaveMessage(long time);
173
174 /* The caller must hold AWT_LOCK. */
175 protected abstract void sendDropMessage(int xRoot, int yRoot,
176 int sourceAction, int sourceActions,
177 long time);
178
179 public final void initiateDrop(int xRoot, int yRoot,
180 int sourceAction, int sourceActions,
181 long time) {
182 XWindowAttributes wattr = new XWindowAttributes();
183 try {
184 XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
185 int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
186 targetWindow, wattr.pData);
187
188 XToolkit.RESTORE_XERROR_HANDLER();
189
190 if (status == 0 ||
191 (XToolkit.saved_error != null &&
192 XToolkit.saved_error.get_error_code() != XConstants.Success)) {
193 throw new XException("XGetWindowAttributes failed");
194 }
195
196 targetWindowMask = wattr.get_your_event_mask();
197 } finally {
198 wattr.dispose();
199 }
200
201 XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
202 XlibWrapper.XSelectInput(XToolkit.getDisplay(), targetWindow,
203 targetWindowMask |
204 XConstants.StructureNotifyMask);
205
206 XToolkit.RESTORE_XERROR_HANDLER();
207
208 if (XToolkit.saved_error != null &&
209 XToolkit.saved_error.get_error_code() != XConstants.Success) {
210 throw new XException("XSelectInput failed");
211 }
212
213 sendDropMessage(xRoot, yRoot, sourceAction, sourceActions, time);
214 }
215
216 protected final void finalizeDrop() {
217 XToolkit.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
218 XlibWrapper.XSelectInput(XToolkit.getDisplay(), targetWindow,
219 targetWindowMask);
220 XToolkit.RESTORE_XERROR_HANDLER();
221 }
222
223 public abstract boolean processProxyModeEvent(XClientMessageEvent xclient,
224 long sourceWindow);
225
226 protected final long getTargetWindow() {
227 return targetWindow;
228 }
229
230 protected final long getTargetProxyWindow() {
231 if (targetProxyWindow != 0) {
232 return targetProxyWindow;
233 } else {
234 return targetWindow;
235 }
236 }
237
238 protected final int getTargetProtocolVersion() {
239 return targetProtocolVersion;
240 }
|
1 /*
2 * Copyright (c) 2003, 2013, 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
164 /* The caller must hold AWT_LOCK. */
165 public abstract void sendEnterMessage(long[] formats, int sourceAction,
166 int sourceActions, long time);
167 /* The caller must hold AWT_LOCK. */
168 public abstract void sendMoveMessage(int xRoot, int yRoot,
169 int sourceAction, int sourceActions,
170 long time);
171 /* The caller must hold AWT_LOCK. */
172 public abstract void sendLeaveMessage(long time);
173
174 /* The caller must hold AWT_LOCK. */
175 protected abstract void sendDropMessage(int xRoot, int yRoot,
176 int sourceAction, int sourceActions,
177 long time);
178
179 public final void initiateDrop(int xRoot, int yRoot,
180 int sourceAction, int sourceActions,
181 long time) {
182 XWindowAttributes wattr = new XWindowAttributes();
183 try {
184 XErrorHandlerUtil.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
185 int status = XlibWrapper.XGetWindowAttributes(XToolkit.getDisplay(),
186 targetWindow, wattr.pData);
187
188 XErrorHandlerUtil.RESTORE_XERROR_HANDLER();
189
190 if ((status == 0) ||
191 ((XErrorHandlerUtil.saved_error != null) &&
192 (XErrorHandlerUtil.saved_error.get_error_code() != XConstants.Success))) {
193 throw new XException("XGetWindowAttributes failed");
194 }
195
196 targetWindowMask = wattr.get_your_event_mask();
197 } finally {
198 wattr.dispose();
199 }
200
201 XErrorHandlerUtil.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
202 XlibWrapper.XSelectInput(XToolkit.getDisplay(), targetWindow,
203 targetWindowMask |
204 XConstants.StructureNotifyMask);
205
206 XErrorHandlerUtil.RESTORE_XERROR_HANDLER();
207
208 if ((XErrorHandlerUtil.saved_error != null) &&
209 (XErrorHandlerUtil.saved_error.get_error_code() != XConstants.Success)) {
210 throw new XException("XSelectInput failed");
211 }
212
213 sendDropMessage(xRoot, yRoot, sourceAction, sourceActions, time);
214 }
215
216 protected final void finalizeDrop() {
217 XErrorHandlerUtil.WITH_XERROR_HANDLER(XErrorHandler.IgnoreBadWindowHandler.getInstance());
218 XlibWrapper.XSelectInput(XToolkit.getDisplay(), targetWindow,
219 targetWindowMask);
220 XErrorHandlerUtil.RESTORE_XERROR_HANDLER();
221 }
222
223 public abstract boolean processProxyModeEvent(XClientMessageEvent xclient,
224 long sourceWindow);
225
226 protected final long getTargetWindow() {
227 return targetWindow;
228 }
229
230 protected final long getTargetProxyWindow() {
231 if (targetProxyWindow != 0) {
232 return targetProxyWindow;
233 } else {
234 return targetWindow;
235 }
236 }
237
238 protected final int getTargetProtocolVersion() {
239 return targetProtocolVersion;
240 }
|