1 /*
2 * Copyright (c) 2003, 2010, 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
268 XBaseWindow(long parentWindow) {
269 this(new XCreateWindowParams(new Object[] {
270 PARENT_WINDOW, Long.valueOf(parentWindow),
271 EMBEDDED, Boolean.TRUE
272 }));
273 }
274
275 /**
276 * Verifies that all required parameters are set. If not, sets them to default values.
277 * Verifies values of critical parameters, adjust their values when needed.
278 * @throws IllegalArgumentException if params is null
279 */
280 protected void checkParams(XCreateWindowParams params) {
281 if (params == null) {
282 throw new IllegalArgumentException("Window creation parameters are null");
283 }
284 params.putIfNull(PARENT_WINDOW, Long.valueOf(XToolkit.getDefaultRootWindow()));
285 params.putIfNull(BOUNDS, new Rectangle(DEF_LOCATION, DEF_LOCATION, MIN_SIZE, MIN_SIZE));
286 params.putIfNull(DEPTH, Integer.valueOf((int)XConstants.CopyFromParent));
287 params.putIfNull(VISUAL, Long.valueOf(XConstants.CopyFromParent));
288 params.putIfNull(VISUAL_CLASS, Integer.valueOf((int)XConstants.InputOnly));
289 params.putIfNull(VALUE_MASK, Long.valueOf(XConstants.CWEventMask));
290 Rectangle bounds = (Rectangle)params.get(BOUNDS);
291 bounds.width = Math.max(MIN_SIZE, bounds.width);
292 bounds.height = Math.max(MIN_SIZE, bounds.height);
293
294 Long eventMaskObj = (Long)params.get(EVENT_MASK);
295 long eventMask = eventMaskObj != null ? eventMaskObj.longValue() : 0;
296 // We use our own synthetic grab see XAwtState.getGrabWindow()
297 // (see X vol. 1, 8.3.3.2)
298 eventMask |= XConstants.PropertyChangeMask | XConstants.OwnerGrabButtonMask;
299 params.put(EVENT_MASK, Long.valueOf(eventMask));
300 }
301
302 /**
303 * Creates window with parameters specified by <code>params</code>
304 * @see #init
305 */
306 private final void create(XCreateWindowParams params) {
307 XToolkit.awtLock();
308 try {
527 }
528 } else if ((hints.get_flags() & XUtilConstants.PMaxSize) != 0) {
529 flags |= XUtilConstants.PMaxSize;
530 if (maxBounds != null) {
531 if (maxBounds.width != Integer.MAX_VALUE) {
532 hints.set_max_width(maxBounds.width);
533 } else {
534 hints.set_max_width(XToolkit.getDefaultScreenWidth());
535 }
536 if (maxBounds.height != Integer.MAX_VALUE) {
537 hints.set_max_height(maxBounds.height);
538 } else {
539 hints.set_max_height(XToolkit.getDefaultScreenHeight());
540 }
541 } else {
542 // Leave intact
543 }
544 }
545 flags |= XUtilConstants.PWinGravity;
546 hints.set_flags(flags);
547 hints.set_win_gravity((int)XConstants.NorthWestGravity);
548 if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
549 insLog.finer("Setting hints, resulted flags " + XlibWrapper.hintsToString(flags) +
550 ", values " + hints);
551 }
552 XlibWrapper.XSetWMNormalHints(XToolkit.getDisplay(), getWindow(), hints.pData);
553 } finally {
554 XToolkit.awtUnlock();
555 }
556 }
557
558 public boolean isMinSizeSet() {
559 XSizeHints hints = getHints();
560 long flags = hints.get_flags();
561 return ((flags & XUtilConstants.PMinSize) == XUtilConstants.PMinSize);
562 }
563
564 /**
565 * This lock object can be used to protect instance data from concurrent access
566 * by two threads. If both state lock and AWT lock are taken, AWT Lock should be taken first.
567 */
|
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
268 XBaseWindow(long parentWindow) {
269 this(new XCreateWindowParams(new Object[] {
270 PARENT_WINDOW, Long.valueOf(parentWindow),
271 EMBEDDED, Boolean.TRUE
272 }));
273 }
274
275 /**
276 * Verifies that all required parameters are set. If not, sets them to default values.
277 * Verifies values of critical parameters, adjust their values when needed.
278 * @throws IllegalArgumentException if params is null
279 */
280 protected void checkParams(XCreateWindowParams params) {
281 if (params == null) {
282 throw new IllegalArgumentException("Window creation parameters are null");
283 }
284 params.putIfNull(PARENT_WINDOW, Long.valueOf(XToolkit.getDefaultRootWindow()));
285 params.putIfNull(BOUNDS, new Rectangle(DEF_LOCATION, DEF_LOCATION, MIN_SIZE, MIN_SIZE));
286 params.putIfNull(DEPTH, Integer.valueOf((int)XConstants.CopyFromParent));
287 params.putIfNull(VISUAL, Long.valueOf(XConstants.CopyFromParent));
288 params.putIfNull(VISUAL_CLASS, Integer.valueOf(XConstants.InputOnly));
289 params.putIfNull(VALUE_MASK, Long.valueOf(XConstants.CWEventMask));
290 Rectangle bounds = (Rectangle)params.get(BOUNDS);
291 bounds.width = Math.max(MIN_SIZE, bounds.width);
292 bounds.height = Math.max(MIN_SIZE, bounds.height);
293
294 Long eventMaskObj = (Long)params.get(EVENT_MASK);
295 long eventMask = eventMaskObj != null ? eventMaskObj.longValue() : 0;
296 // We use our own synthetic grab see XAwtState.getGrabWindow()
297 // (see X vol. 1, 8.3.3.2)
298 eventMask |= XConstants.PropertyChangeMask | XConstants.OwnerGrabButtonMask;
299 params.put(EVENT_MASK, Long.valueOf(eventMask));
300 }
301
302 /**
303 * Creates window with parameters specified by <code>params</code>
304 * @see #init
305 */
306 private final void create(XCreateWindowParams params) {
307 XToolkit.awtLock();
308 try {
527 }
528 } else if ((hints.get_flags() & XUtilConstants.PMaxSize) != 0) {
529 flags |= XUtilConstants.PMaxSize;
530 if (maxBounds != null) {
531 if (maxBounds.width != Integer.MAX_VALUE) {
532 hints.set_max_width(maxBounds.width);
533 } else {
534 hints.set_max_width(XToolkit.getDefaultScreenWidth());
535 }
536 if (maxBounds.height != Integer.MAX_VALUE) {
537 hints.set_max_height(maxBounds.height);
538 } else {
539 hints.set_max_height(XToolkit.getDefaultScreenHeight());
540 }
541 } else {
542 // Leave intact
543 }
544 }
545 flags |= XUtilConstants.PWinGravity;
546 hints.set_flags(flags);
547 hints.set_win_gravity(XConstants.NorthWestGravity);
548 if (insLog.isLoggable(PlatformLogger.Level.FINER)) {
549 insLog.finer("Setting hints, resulted flags " + XlibWrapper.hintsToString(flags) +
550 ", values " + hints);
551 }
552 XlibWrapper.XSetWMNormalHints(XToolkit.getDisplay(), getWindow(), hints.pData);
553 } finally {
554 XToolkit.awtUnlock();
555 }
556 }
557
558 public boolean isMinSizeSet() {
559 XSizeHints hints = getHints();
560 long flags = hints.get_flags();
561 return ((flags & XUtilConstants.PMinSize) == XUtilConstants.PMinSize);
562 }
563
564 /**
565 * This lock object can be used to protect instance data from concurrent access
566 * by two threads. If both state lock and AWT lock are taken, AWT Lock should be taken first.
567 */
|