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
96
97 void awtUnlock() {
98 XToolkit.awtUnlock();
99 }
100
101 void awtLockNotifyAll() {
102 XToolkit.awtLockNotifyAll();
103 }
104
105 void awtLockWait() throws InterruptedException {
106 XToolkit.awtLockWait();
107 }
108
109 // To prevent errors from overriding obsolete methods
110 protected final void init(long parentWindow, Rectangle bounds) {}
111 protected final void preInit() {}
112 protected final void postInit() {}
113
114 // internal lock for synchronizing state changes and paint calls, initialized in preInit.
115 // the order with other locks: AWTLock -> stateLock
116 static class StateLock extends Object { }
117 protected StateLock state_lock;
118
119 /**
120 * Called for delayed inits during construction
121 */
122 void instantPreInit(XCreateWindowParams params) {
123 state_lock = new StateLock();
124 }
125
126 /**
127 * Called before window creation, descendants should override to initialize the data,
128 * initialize params.
129 */
130 void preInit(XCreateWindowParams params) {
131 state_lock = new StateLock();
132 embedded = Boolean.TRUE.equals(params.get(EMBEDDED));
133 visible = Boolean.TRUE.equals(params.get(VISIBLE));
134
135 Object parent = params.get(PARENT);
136 if (parent instanceof XBaseWindow) {
298 /**
299 * Returns scale factor of the window. It is used to convert native
300 * coordinates to local and vice verse.
301 */
302 protected int getScale() {
303 return 1;
304 }
305
306 protected int scaleUp(int x) {
307 return x;
308 }
309
310 protected int scaleDown(int x) {
311 return x;
312 }
313
314 /**
315 * Creates window with parameters specified by {@code params}
316 * @see #init
317 */
318 private final void create(XCreateWindowParams params) {
319 XToolkit.awtLock();
320 try {
321 XSetWindowAttributes xattr = new XSetWindowAttributes();
322 try {
323 checkParams(params);
324
325 long value_mask = ((Long)params.get(VALUE_MASK)).longValue();
326
327 Long eventMask = (Long)params.get(EVENT_MASK);
328 xattr.set_event_mask(eventMask.longValue());
329 value_mask |= XConstants.CWEventMask;
330
331 Long border_pixel = (Long)params.get(BORDER_PIXEL);
332 if (border_pixel != null) {
333 xattr.set_border_pixel(border_pixel.longValue());
334 value_mask |= XConstants.CWBorderPixel;
335 }
336
337 Long colormap = (Long)params.get(COLORMAP);
338 if (colormap != null) {
|
1 /*
2 * Copyright (c) 2003, 2017, 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
96
97 void awtUnlock() {
98 XToolkit.awtUnlock();
99 }
100
101 void awtLockNotifyAll() {
102 XToolkit.awtLockNotifyAll();
103 }
104
105 void awtLockWait() throws InterruptedException {
106 XToolkit.awtLockWait();
107 }
108
109 // To prevent errors from overriding obsolete methods
110 protected final void init(long parentWindow, Rectangle bounds) {}
111 protected final void preInit() {}
112 protected final void postInit() {}
113
114 // internal lock for synchronizing state changes and paint calls, initialized in preInit.
115 // the order with other locks: AWTLock -> stateLock
116 static class StateLock { }
117 protected StateLock state_lock;
118
119 /**
120 * Called for delayed inits during construction
121 */
122 void instantPreInit(XCreateWindowParams params) {
123 state_lock = new StateLock();
124 }
125
126 /**
127 * Called before window creation, descendants should override to initialize the data,
128 * initialize params.
129 */
130 void preInit(XCreateWindowParams params) {
131 state_lock = new StateLock();
132 embedded = Boolean.TRUE.equals(params.get(EMBEDDED));
133 visible = Boolean.TRUE.equals(params.get(VISIBLE));
134
135 Object parent = params.get(PARENT);
136 if (parent instanceof XBaseWindow) {
298 /**
299 * Returns scale factor of the window. It is used to convert native
300 * coordinates to local and vice verse.
301 */
302 protected int getScale() {
303 return 1;
304 }
305
306 protected int scaleUp(int x) {
307 return x;
308 }
309
310 protected int scaleDown(int x) {
311 return x;
312 }
313
314 /**
315 * Creates window with parameters specified by {@code params}
316 * @see #init
317 */
318 private void create(XCreateWindowParams params) {
319 XToolkit.awtLock();
320 try {
321 XSetWindowAttributes xattr = new XSetWindowAttributes();
322 try {
323 checkParams(params);
324
325 long value_mask = ((Long)params.get(VALUE_MASK)).longValue();
326
327 Long eventMask = (Long)params.get(EVENT_MASK);
328 xattr.set_event_mask(eventMask.longValue());
329 value_mask |= XConstants.CWEventMask;
330
331 Long border_pixel = (Long)params.get(BORDER_PIXEL);
332 if (border_pixel != null) {
333 xattr.set_border_pixel(border_pixel.longValue());
334 value_mask |= XConstants.CWBorderPixel;
335 }
336
337 Long colormap = (Long)params.get(COLORMAP);
338 if (colormap != null) {
|