150 }
151
152 protected boolean isInitialReshape() {
153 return true;
154 }
155
156 public void reparent(ContainerPeer newNativeParent) {
157 XComponentPeer newPeer = (XComponentPeer)newNativeParent;
158 XToolkit.awtLock();
159 try {
160 XlibWrapper.XReparentWindow(XToolkit.getDisplay(), getWindow(), newPeer.getContentWindow(), x, y);
161 parentWindow = newPeer;
162 } finally {
163 XToolkit.awtUnlock();
164 }
165 }
166 public boolean isReparentSupported() {
167 return System.getProperty("sun.awt.X11.XComponentPeer.reparentNotSupported", "false").equals("false");
168 }
169
170 public boolean isObscured() {
171 Container container = (target instanceof Container) ?
172 (Container)target : target.getParent();
173
174 if (container == null) {
175 return true;
176 }
177
178 Container parent;
179 while ((parent = container.getParent()) != null) {
180 container = parent;
181 }
182
183 if (container instanceof Window) {
184 XWindowPeer wpeer = (XWindowPeer)(container.getPeer());
185 if (wpeer != null) {
186 return (wpeer.winAttr.visibilityState !=
187 XWindowAttributesData.AWT_UNOBSCURED);
188 }
189 }
262 catch (ClassNotFoundException e) {
263 throw new NoClassDefFoundError("java.awt.SequencedEvent.");
264 }
265 catch (PrivilegedActionException ex) {
266 throw new NoClassDefFoundError("java.awt.SequencedEvent.");
267 }
268 catch (InstantiationException e) {
269 assert false;
270 }
271 catch (IllegalAccessException e) {
272 assert false;
273 }
274 catch (InvocationTargetException e) {
275 assert false;
276 }
277
278 return null;
279 }
280
281 // TODO: consider moving it to KeyboardFocusManagerPeerImpl
282 final public boolean requestFocus(Component lightweightChild, boolean temporary,
283 boolean focusedWindowChangeAllowed, long time,
284 CausedFocusEvent.Cause cause)
285 {
286 if (XKeyboardFocusManagerPeer.
287 processSynchronousLightweightTransfer(target, lightweightChild, temporary,
288 focusedWindowChangeAllowed, time))
289 {
290 return true;
291 }
292
293 int result = XKeyboardFocusManagerPeer.
294 shouldNativelyFocusHeavyweight(target, lightweightChild,
295 temporary, focusedWindowChangeAllowed,
296 time, cause);
297
298 switch (result) {
299 case XKeyboardFocusManagerPeer.SNFH_FAILURE:
300 return false;
301 case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
371 void handleJavaWindowFocusEvent(AWTEvent e) {
372 }
373
374 /*************************************************
375 * END OF FOCUS STUFF
376 *************************************************/
377
378
379
380 public void setVisible(boolean b) {
381 xSetVisible(b);
382 }
383
384 public void hide() {
385 setVisible(false);
386 }
387
388 /**
389 * @see java.awt.peer.ComponentPeer
390 */
391 public void setEnabled(final boolean value) {
392 if (enableLog.isLoggable(PlatformLogger.Level.FINE)) {
393 enableLog.fine("{0}ing {1}", (value ? "Enabl" : "Disabl"), this);
394 }
395 boolean status = value;
396 // If any of our heavyweight ancestors are disable, we should be too
397 // See 6176875 for more information
398 final Container cp = SunToolkit.getNativeContainer(target);
399 if (cp != null) {
400 status &= ((XComponentPeer) cp.getPeer()).isEnabled();
401 }
402 synchronized (getStateLock()) {
403 if (enabled == status) {
404 return;
405 }
406 enabled = status;
407 }
408
409 if (target instanceof Container) {
410 final Component[] list = ((Container) target).getComponents();
1307 case SET_BOUNDS:
1308 return "SET_BOUNDS";
1309 }
1310 }
1311
1312 /**
1313 * Lowers this component at the bottom of the above HW peer. If the above parameter
1314 * is null then the method places this component at the top of the Z-order.
1315 */
1316 public void setZOrder(ComponentPeer above) {
1317 long aboveWindow = (above != null) ? ((XComponentPeer)above).getWindow() : 0;
1318
1319 XToolkit.awtLock();
1320 try{
1321 XlibWrapper.SetZOrder(XToolkit.getDisplay(), getWindow(), aboveWindow);
1322 }finally{
1323 XToolkit.awtUnlock();
1324 }
1325 }
1326
1327 private void addTree(Collection<Long> order, Set<Long> set, Container cont) {
1328 for (int i = 0; i < cont.getComponentCount(); i++) {
1329 Component comp = cont.getComponent(i);
1330 ComponentPeer peer = comp.getPeer();
1331 if (peer instanceof XComponentPeer) {
1332 Long window = Long.valueOf(((XComponentPeer)peer).getWindow());
1333 if (!set.contains(window)) {
1334 set.add(window);
1335 order.add(window);
1336 }
1337 } else if (comp instanceof Container) {
1338 // It is lightweight container, it might contain heavyweight components attached to this
1339 // peer
1340 addTree(order, set, (Container)comp);
1341 }
1342 }
1343 }
1344
1345 /****** DropTargetPeer implementation ********************/
1346
1347 public void addDropTarget(DropTarget dt) {
1348 Component comp = target;
1349 while(!(comp == null || comp instanceof Window)) {
1350 comp = comp.getParent();
1351 }
1352
1353 if (comp instanceof Window) {
1354 XWindowPeer wpeer = (XWindowPeer)(comp.getPeer());
1355 if (wpeer != null) {
1356 wpeer.addDropTarget();
1357 }
1358 }
1359 }
1360
1361 public void removeDropTarget(DropTarget dt) {
1362 Component comp = target;
1363 while(!(comp == null || comp instanceof Window)) {
1364 comp = comp.getParent();
1365 }
1366
1367 if (comp instanceof Window) {
1368 XWindowPeer wpeer = (XWindowPeer)(comp.getPeer());
1369 if (wpeer != null) {
1370 wpeer.removeDropTarget();
1371 }
1372 }
1373 }
1374
1375 /**
1376 * Applies the shape to the X-window.
1377 * @since 1.7
1378 */
1379 public void applyShape(Region shape) {
1380 if (XlibUtil.isShapingSupported()) {
|
150 }
151
152 protected boolean isInitialReshape() {
153 return true;
154 }
155
156 public void reparent(ContainerPeer newNativeParent) {
157 XComponentPeer newPeer = (XComponentPeer)newNativeParent;
158 XToolkit.awtLock();
159 try {
160 XlibWrapper.XReparentWindow(XToolkit.getDisplay(), getWindow(), newPeer.getContentWindow(), x, y);
161 parentWindow = newPeer;
162 } finally {
163 XToolkit.awtUnlock();
164 }
165 }
166 public boolean isReparentSupported() {
167 return System.getProperty("sun.awt.X11.XComponentPeer.reparentNotSupported", "false").equals("false");
168 }
169
170 @SuppressWarnings("deprecation")
171 public boolean isObscured() {
172 Container container = (target instanceof Container) ?
173 (Container)target : target.getParent();
174
175 if (container == null) {
176 return true;
177 }
178
179 Container parent;
180 while ((parent = container.getParent()) != null) {
181 container = parent;
182 }
183
184 if (container instanceof Window) {
185 XWindowPeer wpeer = (XWindowPeer)(container.getPeer());
186 if (wpeer != null) {
187 return (wpeer.winAttr.visibilityState !=
188 XWindowAttributesData.AWT_UNOBSCURED);
189 }
190 }
263 catch (ClassNotFoundException e) {
264 throw new NoClassDefFoundError("java.awt.SequencedEvent.");
265 }
266 catch (PrivilegedActionException ex) {
267 throw new NoClassDefFoundError("java.awt.SequencedEvent.");
268 }
269 catch (InstantiationException e) {
270 assert false;
271 }
272 catch (IllegalAccessException e) {
273 assert false;
274 }
275 catch (InvocationTargetException e) {
276 assert false;
277 }
278
279 return null;
280 }
281
282 // TODO: consider moving it to KeyboardFocusManagerPeerImpl
283 @SuppressWarnings("deprecation")
284 final public boolean requestFocus(Component lightweightChild, boolean temporary,
285 boolean focusedWindowChangeAllowed, long time,
286 CausedFocusEvent.Cause cause)
287 {
288 if (XKeyboardFocusManagerPeer.
289 processSynchronousLightweightTransfer(target, lightweightChild, temporary,
290 focusedWindowChangeAllowed, time))
291 {
292 return true;
293 }
294
295 int result = XKeyboardFocusManagerPeer.
296 shouldNativelyFocusHeavyweight(target, lightweightChild,
297 temporary, focusedWindowChangeAllowed,
298 time, cause);
299
300 switch (result) {
301 case XKeyboardFocusManagerPeer.SNFH_FAILURE:
302 return false;
303 case XKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
373 void handleJavaWindowFocusEvent(AWTEvent e) {
374 }
375
376 /*************************************************
377 * END OF FOCUS STUFF
378 *************************************************/
379
380
381
382 public void setVisible(boolean b) {
383 xSetVisible(b);
384 }
385
386 public void hide() {
387 setVisible(false);
388 }
389
390 /**
391 * @see java.awt.peer.ComponentPeer
392 */
393 @SuppressWarnings("deprecation")
394 public void setEnabled(final boolean value) {
395 if (enableLog.isLoggable(PlatformLogger.Level.FINE)) {
396 enableLog.fine("{0}ing {1}", (value ? "Enabl" : "Disabl"), this);
397 }
398 boolean status = value;
399 // If any of our heavyweight ancestors are disable, we should be too
400 // See 6176875 for more information
401 final Container cp = SunToolkit.getNativeContainer(target);
402 if (cp != null) {
403 status &= ((XComponentPeer) cp.getPeer()).isEnabled();
404 }
405 synchronized (getStateLock()) {
406 if (enabled == status) {
407 return;
408 }
409 enabled = status;
410 }
411
412 if (target instanceof Container) {
413 final Component[] list = ((Container) target).getComponents();
1310 case SET_BOUNDS:
1311 return "SET_BOUNDS";
1312 }
1313 }
1314
1315 /**
1316 * Lowers this component at the bottom of the above HW peer. If the above parameter
1317 * is null then the method places this component at the top of the Z-order.
1318 */
1319 public void setZOrder(ComponentPeer above) {
1320 long aboveWindow = (above != null) ? ((XComponentPeer)above).getWindow() : 0;
1321
1322 XToolkit.awtLock();
1323 try{
1324 XlibWrapper.SetZOrder(XToolkit.getDisplay(), getWindow(), aboveWindow);
1325 }finally{
1326 XToolkit.awtUnlock();
1327 }
1328 }
1329
1330 @SuppressWarnings("deprecation")
1331 private void addTree(Collection<Long> order, Set<Long> set, Container cont) {
1332 for (int i = 0; i < cont.getComponentCount(); i++) {
1333 Component comp = cont.getComponent(i);
1334 ComponentPeer peer = comp.getPeer();
1335 if (peer instanceof XComponentPeer) {
1336 Long window = Long.valueOf(((XComponentPeer)peer).getWindow());
1337 if (!set.contains(window)) {
1338 set.add(window);
1339 order.add(window);
1340 }
1341 } else if (comp instanceof Container) {
1342 // It is lightweight container, it might contain heavyweight components attached to this
1343 // peer
1344 addTree(order, set, (Container)comp);
1345 }
1346 }
1347 }
1348
1349 /****** DropTargetPeer implementation ********************/
1350
1351 @SuppressWarnings("deprecation")
1352 public void addDropTarget(DropTarget dt) {
1353 Component comp = target;
1354 while(!(comp == null || comp instanceof Window)) {
1355 comp = comp.getParent();
1356 }
1357
1358 if (comp instanceof Window) {
1359 XWindowPeer wpeer = (XWindowPeer)(comp.getPeer());
1360 if (wpeer != null) {
1361 wpeer.addDropTarget();
1362 }
1363 }
1364 }
1365
1366 @SuppressWarnings("deprecation")
1367 public void removeDropTarget(DropTarget dt) {
1368 Component comp = target;
1369 while(!(comp == null || comp instanceof Window)) {
1370 comp = comp.getParent();
1371 }
1372
1373 if (comp instanceof Window) {
1374 XWindowPeer wpeer = (XWindowPeer)(comp.getPeer());
1375 if (wpeer != null) {
1376 wpeer.removeDropTarget();
1377 }
1378 }
1379 }
1380
1381 /**
1382 * Applies the shape to the X-window.
1383 * @since 1.7
1384 */
1385 public void applyShape(Region shape) {
1386 if (XlibUtil.isShapingSupported()) {
|