28 |
28 |
29 import java.awt.event.ComponentEvent; |
29 import java.awt.event.ComponentEvent; |
30 import java.awt.event.InvocationEvent; |
30 import java.awt.event.InvocationEvent; |
31 import java.awt.event.WindowEvent; |
31 import java.awt.event.WindowEvent; |
32 |
32 |
33 import java.util.logging.Level; |
33 import sun.util.logging.PlatformLogger; |
34 import java.util.logging.Logger; |
|
35 |
34 |
36 import sun.awt.ComponentAccessor; |
35 import sun.awt.ComponentAccessor; |
37 import sun.awt.SunToolkit; |
36 import sun.awt.SunToolkit; |
38 |
37 |
39 abstract class XDecoratedPeer extends XWindowPeer { |
38 abstract class XDecoratedPeer extends XWindowPeer { |
40 private static final Logger log = Logger.getLogger("sun.awt.X11.XDecoratedPeer"); |
39 private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XDecoratedPeer"); |
41 private static final Logger insLog = Logger.getLogger("sun.awt.X11.insets.XDecoratedPeer"); |
40 private static final PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XDecoratedPeer"); |
42 private static final Logger focusLog = Logger.getLogger("sun.awt.X11.focus.XDecoratedPeer"); |
41 private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XDecoratedPeer"); |
43 private static final Logger iconLog = Logger.getLogger("sun.awt.X11.icon.XDecoratedPeer"); |
42 private static final PlatformLogger iconLog = PlatformLogger.getLogger("sun.awt.X11.icon.XDecoratedPeer"); |
44 |
43 |
45 // Set to true when we get the first ConfigureNotify after being |
44 // Set to true when we get the first ConfigureNotify after being |
46 // reparented - indicates that WM has adopted the top-level. |
45 // reparented - indicates that WM has adopted the top-level. |
47 boolean configure_seen; |
46 boolean configure_seen; |
48 boolean insets_corrected; |
47 boolean insets_corrected; |
77 applyGuessedInsets(); |
76 applyGuessedInsets(); |
78 |
77 |
79 Rectangle bounds = (Rectangle)params.get(BOUNDS); |
78 Rectangle bounds = (Rectangle)params.get(BOUNDS); |
80 dimensions = new WindowDimensions(bounds, getRealInsets(), false); |
79 dimensions = new WindowDimensions(bounds, getRealInsets(), false); |
81 params.put(BOUNDS, dimensions.getClientRect()); |
80 params.put(BOUNDS, dimensions.getClientRect()); |
82 if (insLog.isLoggable(Level.FINE)) { |
81 insLog.fine("Initial dimensions {0}", dimensions); |
83 insLog.log(Level.FINE, "Initial dimensions {0}",new Object[] { String.valueOf(dimensions) }); |
|
84 } |
|
85 |
82 |
86 // Deny default processing of these events on the shell - proxy will take care of |
83 // Deny default processing of these events on the shell - proxy will take care of |
87 // them instead |
84 // them instead |
88 Long eventMask = (Long)params.get(EVENT_MASK); |
85 Long eventMask = (Long)params.get(EVENT_MASK); |
89 params.add(EVENT_MASK, Long.valueOf(eventMask.longValue() & ~(XConstants.FocusChangeMask | XConstants.KeyPressMask | XConstants.KeyReleaseMask))); |
86 params.add(EVENT_MASK, Long.valueOf(eventMask.longValue() & ~(XConstants.FocusChangeMask | XConstants.KeyPressMask | XConstants.KeyReleaseMask))); |
175 ComponentAccessor.getBackground(target), |
172 ComponentAccessor.getBackground(target), |
176 ComponentAccessor.getFont_NoClientCode(target)); |
173 ComponentAccessor.getFont_NoClientCode(target)); |
177 } |
174 } |
178 |
175 |
179 public void setTitle(String title) { |
176 public void setTitle(String title) { |
180 if (log.isLoggable(Level.FINE)) log.fine("Title is " + title); |
177 if (log.isLoggable(PlatformLogger.FINE)) log.fine("Title is " + title); |
181 winAttr.title = title; |
178 winAttr.title = title; |
182 updateWMName(); |
179 updateWMName(); |
183 } |
180 } |
184 |
181 |
185 protected String getWMName() { |
182 protected String getWMName() { |
265 wm_set_insets = XWM.getInsetsFromExtents(getWindow()); |
262 wm_set_insets = XWM.getInsetsFromExtents(getWindow()); |
266 } else { |
263 } else { |
267 wm_set_insets = XWM.getInsetsFromProp(getWindow(), changedAtom); |
264 wm_set_insets = XWM.getInsetsFromProp(getWindow(), changedAtom); |
268 } |
265 } |
269 |
266 |
270 if (insLog.isLoggable(Level.FINER)) { |
267 insLog.finer("FRAME_EXTENTS: {0}", wm_set_insets); |
271 insLog.log(Level.FINER, "FRAME_EXTENTS: {0}", |
|
272 new Object[]{String.valueOf(wm_set_insets)}); |
|
273 } |
|
274 |
268 |
275 if (wm_set_insets != null) { |
269 if (wm_set_insets != null) { |
276 wm_set_insets = copy(wm_set_insets); |
270 wm_set_insets = copy(wm_set_insets); |
277 } |
271 } |
278 return wm_set_insets; |
272 return wm_set_insets; |
295 |
289 |
296 long reparent_serial = 0; |
290 long reparent_serial = 0; |
297 |
291 |
298 public void handleReparentNotifyEvent(XEvent xev) { |
292 public void handleReparentNotifyEvent(XEvent xev) { |
299 XReparentEvent xe = xev.get_xreparent(); |
293 XReparentEvent xe = xev.get_xreparent(); |
300 if (insLog.isLoggable(Level.FINE)) insLog.fine(xe.toString()); |
294 if (insLog.isLoggable(PlatformLogger.FINE)) insLog.fine(xe.toString()); |
301 reparent_serial = xe.get_serial(); |
295 reparent_serial = xe.get_serial(); |
302 XToolkit.awtLock(); |
296 XToolkit.awtLock(); |
303 try { |
297 try { |
304 long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()); |
298 long root = XlibWrapper.RootWindow(XToolkit.getDisplay(), getScreenNumber()); |
305 |
299 |
334 insets_corrected = false; |
328 insets_corrected = false; |
335 |
329 |
336 // Check if we have insets provided by the WM |
330 // Check if we have insets provided by the WM |
337 Insets correctWM = getWMSetInsets(null); |
331 Insets correctWM = getWMSetInsets(null); |
338 if (correctWM != null) { |
332 if (correctWM != null) { |
339 if (insLog.isLoggable(Level.FINER)) { |
333 insLog.finer("wm-provided insets {0}", correctWM); |
340 insLog.log(Level.FINER, "wm-provided insets {0}", |
|
341 new Object[]{String.valueOf(correctWM)}); |
|
342 } |
|
343 // If these insets are equal to our current insets - no actions are necessary |
334 // If these insets are equal to our current insets - no actions are necessary |
344 Insets dimInsets = dimensions.getInsets(); |
335 Insets dimInsets = dimensions.getInsets(); |
345 if (correctWM.equals(dimInsets)) { |
336 if (correctWM.equals(dimInsets)) { |
346 insLog.finer("Insets are the same as estimated - no additional reshapes necessary"); |
337 insLog.finer("Insets are the same as estimated - no additional reshapes necessary"); |
347 no_reparent_artifacts = true; |
338 no_reparent_artifacts = true; |
351 } |
342 } |
352 } else { |
343 } else { |
353 correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent()); |
344 correctWM = XWM.getWM().getInsets(this, xe.get_window(), xe.get_parent()); |
354 |
345 |
355 if (correctWM != null) { |
346 if (correctWM != null) { |
356 if (insLog.isLoggable(Level.FINE)) { |
347 insLog.finer("correctWM {0}", correctWM); |
357 insLog.log(Level.FINER, "correctWM {0}", new Object[] {String.valueOf(correctWM)}); |
|
358 } |
|
359 } else { |
348 } else { |
360 insLog.log(Level.FINER, "correctWM insets are not available, waiting for configureNotify"); |
349 insLog.finer("correctWM insets are not available, waiting for configureNotify"); |
361 } |
350 } |
362 } |
351 } |
363 |
352 |
364 if (correctWM != null) { |
353 if (correctWM != null) { |
365 handleCorrectInsets(correctWM); |
354 handleCorrectInsets(correctWM); |
376 /* |
365 /* |
377 * Ok, now see if we need adjust window size because |
366 * Ok, now see if we need adjust window size because |
378 * initial insets were wrong (most likely they were). |
367 * initial insets were wrong (most likely they were). |
379 */ |
368 */ |
380 Insets correction = difference(correctWM, currentInsets); |
369 Insets correction = difference(correctWM, currentInsets); |
381 if (insLog.isLoggable(Level.FINEST)) { |
370 insLog.finest("Corrention {0}", correction); |
382 insLog.log(Level.FINEST, "Corrention {0}", |
|
383 new Object[] {String.valueOf(correction)}); |
|
384 } |
|
385 if (!isNull(correction)) { |
371 if (!isNull(correction)) { |
386 currentInsets = copy(correctWM); |
372 currentInsets = copy(correctWM); |
387 applyGuessedInsets(); |
373 applyGuessedInsets(); |
388 |
374 |
389 //Fix for 6318109: PIT: Min Size is not honored properly when a |
375 //Fix for 6318109: PIT: Min Size is not honored properly when a |
390 //smaller size is specified in setSize(), XToolkit |
376 //smaller size is specified in setSize(), XToolkit |
391 //update minimum size hints |
377 //update minimum size hints |
392 updateMinSizeHints(); |
378 updateMinSizeHints(); |
393 } |
379 } |
394 if (insLog.isLoggable(Level.FINER)) insLog.finer("Dimensions before reparent: " + dimensions); |
380 if (insLog.isLoggable(PlatformLogger.FINER)) insLog.finer("Dimensions before reparent: " + dimensions); |
395 |
381 |
396 dimensions.setInsets(getRealInsets()); |
382 dimensions.setInsets(getRealInsets()); |
397 insets_corrected = true; |
383 insets_corrected = true; |
398 |
384 |
399 if (isMaximized()) { |
385 if (isMaximized()) { |
463 } |
449 } |
464 |
450 |
465 public Insets getInsets() { |
451 public Insets getInsets() { |
466 Insets in = copy(getRealInsets()); |
452 Insets in = copy(getRealInsets()); |
467 in.top += getMenuBarHeight(); |
453 in.top += getMenuBarHeight(); |
468 if (insLog.isLoggable(Level.FINEST)) { |
454 if (insLog.isLoggable(PlatformLogger.FINEST)) { |
469 insLog.log(Level.FINEST, "Get insets returns {0}", new Object[] {String.valueOf(in)}); |
455 insLog.finest("Get insets returns {0}", in); |
470 } |
456 } |
471 return in; |
457 return in; |
472 } |
458 } |
473 |
459 |
474 boolean gravityBug() { |
460 boolean gravityBug() { |
493 // Coordinates are that of the target |
479 // Coordinates are that of the target |
494 // Called only on Toolkit thread |
480 // Called only on Toolkit thread |
495 public void reshape(WindowDimensions newDimensions, int op, |
481 public void reshape(WindowDimensions newDimensions, int op, |
496 boolean userReshape) |
482 boolean userReshape) |
497 { |
483 { |
498 if (insLog.isLoggable(Level.FINE)) { |
484 if (insLog.isLoggable(PlatformLogger.FINE)) { |
499 insLog.fine("Reshaping " + this + " to " + newDimensions + " op " + op + " user reshape " + userReshape); |
485 insLog.fine("Reshaping " + this + " to " + newDimensions + " op " + op + " user reshape " + userReshape); |
500 } |
486 } |
501 if (userReshape) { |
487 if (userReshape) { |
502 // We handle only userReshape == true cases. It means that |
488 // We handle only userReshape == true cases. It means that |
503 // if the window manager or any other part of the windowing |
489 // if the window manager or any other part of the windowing |
514 newDimensions = new WindowDimensions(newBounds, insets, newDimensions.isClientSizeSet()); |
500 newDimensions = new WindowDimensions(newBounds, insets, newDimensions.isClientSizeSet()); |
515 } |
501 } |
516 XToolkit.awtLock(); |
502 XToolkit.awtLock(); |
517 try { |
503 try { |
518 if (!isReparented() || !isVisible()) { |
504 if (!isReparented() || !isVisible()) { |
519 insLog.log(Level.FINE, "- not reparented({0}) or not visible({1}), default reshape", |
505 insLog.fine("- not reparented({0}) or not visible({1}), default reshape", |
520 new Object[] {Boolean.valueOf(isReparented()), Boolean.valueOf(visible)}); |
506 Boolean.valueOf(isReparented()), Boolean.valueOf(visible)); |
521 |
507 |
522 // Fix for 6323293. |
508 // Fix for 6323293. |
523 // This actually is needed to preserve compatibility with previous releases - |
509 // This actually is needed to preserve compatibility with previous releases - |
524 // some of licensees are expecting componentMoved event on invisible one while |
510 // some of licensees are expecting componentMoved event on invisible one while |
525 // its location changes. |
511 // its location changes. |
620 default: |
606 default: |
621 dims.setLocation(x, y); |
607 dims.setLocation(x, y); |
622 dims.setSize(width, height); |
608 dims.setSize(width, height); |
623 break; |
609 break; |
624 } |
610 } |
625 if (insLog.isLoggable(Level.FINE)) insLog.log(Level.FINE, "For the operation {0} new dimensions are {1}", |
611 if (insLog.isLoggable(PlatformLogger.FINE)) |
626 new Object[] {operationToString(operation), String.valueOf(dims)}); |
612 insLog.fine("For the operation {0} new dimensions are {1}", |
|
613 operationToString(operation), dims); |
627 |
614 |
628 reshape(dims, operation, userReshape); |
615 reshape(dims, operation, userReshape); |
629 } |
616 } |
630 |
617 |
631 // This method gets overriden in XFramePeer & XDialogPeer. |
618 // This method gets overriden in XFramePeer & XDialogPeer. |
651 |
638 |
652 boolean no_reparent_artifacts = false; |
639 boolean no_reparent_artifacts = false; |
653 public void handleConfigureNotifyEvent(XEvent xev) { |
640 public void handleConfigureNotifyEvent(XEvent xev) { |
654 assert (SunToolkit.isAWTLockHeldByCurrentThread()); |
641 assert (SunToolkit.isAWTLockHeldByCurrentThread()); |
655 XConfigureEvent xe = xev.get_xconfigure(); |
642 XConfigureEvent xe = xev.get_xconfigure(); |
656 if (insLog.isLoggable(Level.FINE)) { |
643 insLog.fine("Configure notify {0}", xe); |
657 insLog.log(Level.FINE, "Configure notify {0}", new Object[] {String.valueOf(xe)}); |
|
658 } |
|
659 |
644 |
660 // XXX: should really only consider synthetic events, but |
645 // XXX: should really only consider synthetic events, but |
661 if (isReparented()) { |
646 if (isReparented()) { |
662 configure_seen = true; |
647 configure_seen = true; |
663 } |
648 } |
690 * possibly MWM as well). If we haven't been reparented yet |
675 * possibly MWM as well). If we haven't been reparented yet |
691 * this is just the WM shuffling us into position. Ignore |
676 * this is just the WM shuffling us into position. Ignore |
692 * it!!!! or we wind up in a bogus location. |
677 * it!!!! or we wind up in a bogus location. |
693 */ |
678 */ |
694 int runningWM = XWM.getWMID(); |
679 int runningWM = XWM.getWMID(); |
695 if (insLog.isLoggable(Level.FINE)) { |
680 if (insLog.isLoggable(PlatformLogger.FINE)) { |
696 insLog.log(Level.FINE, "reparented={0}, visible={1}, WM={2}, decorations={3}", |
681 insLog.fine("reparented={0}, visible={1}, WM={2}, decorations={3}", |
697 new Object[] {isReparented(), isVisible(), runningWM, getDecorations()}); |
682 isReparented(), isVisible(), runningWM, getDecorations()); |
698 } |
683 } |
699 if (!isReparented() && isVisible() && runningWM != XWM.NO_WM |
684 if (!isReparented() && isVisible() && runningWM != XWM.NO_WM |
700 && !XWM.isNonReparentingWM() |
685 && !XWM.isNonReparentingWM() |
701 && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) { |
686 && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) { |
702 insLog.fine("- visible but not reparented, skipping"); |
687 insLog.fine("- visible but not reparented, skipping"); |
704 } |
689 } |
705 //Last chance to correct insets |
690 //Last chance to correct insets |
706 if (!insets_corrected && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) { |
691 if (!insets_corrected && getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) { |
707 long parent = XlibUtil.getParentWindow(window); |
692 long parent = XlibUtil.getParentWindow(window); |
708 Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null; |
693 Insets correctWM = (parent != -1) ? XWM.getWM().getInsets(this, window, parent) : null; |
709 if (insLog.isLoggable(Level.FINER)) { |
694 if (insLog.isLoggable(PlatformLogger.FINER)) { |
710 if (correctWM != null) { |
695 if (correctWM != null) { |
711 insLog.finer("Configure notify - insets : " + correctWM); |
696 insLog.finer("Configure notify - insets : " + correctWM); |
712 } else { |
697 } else { |
713 insLog.finer("Configure notify - insets are still not available"); |
698 insLog.finer("Configure notify - insets are still not available"); |
714 } |
699 } |
745 case XWM.MOTIF_WM: |
730 case XWM.MOTIF_WM: |
746 case XWM.METACITY_WM: |
731 case XWM.METACITY_WM: |
747 case XWM.SAWFISH_WM: |
732 case XWM.SAWFISH_WM: |
748 { |
733 { |
749 Point xlocation = queryXLocation(); |
734 Point xlocation = queryXLocation(); |
750 if (log.isLoggable(Level.FINE)) { |
735 if (log.isLoggable(PlatformLogger.FINE)) log.fine("New X location: {0}", xlocation); |
751 log.log(Level.FINE, "New X location: {0}", |
|
752 new Object[]{String.valueOf(xlocation)}); |
|
753 } |
|
754 if (xlocation != null) { |
736 if (xlocation != null) { |
755 newLocation = xlocation; |
737 newLocation = xlocation; |
756 } |
738 } |
757 break; |
739 break; |
758 } |
740 } |
765 new WindowDimensions(newLocation, |
747 new WindowDimensions(newLocation, |
766 new Dimension(xe.get_width(), xe.get_height()), |
748 new Dimension(xe.get_width(), xe.get_height()), |
767 copy(currentInsets), |
749 copy(currentInsets), |
768 true); |
750 true); |
769 |
751 |
770 if (insLog.isLoggable(Level.FINER)) { |
752 insLog.finer("Insets are {0}, new dimensions {1}", |
771 insLog.log(Level.FINER, "Insets are {0}, new dimensions {1}", |
753 currentInsets, newDimensions); |
772 new Object[] {String.valueOf(currentInsets), String.valueOf(newDimensions)}); |
|
773 } |
|
774 |
754 |
775 checkIfOnNewScreen(newDimensions.getBounds()); |
755 checkIfOnNewScreen(newDimensions.getBounds()); |
776 |
756 |
777 Point oldLocation = getLocation(); |
757 Point oldLocation = getLocation(); |
778 dimensions = newDimensions; |
758 dimensions = newDimensions; |
807 checkShellRectSize(shellRect); |
787 checkShellRectSize(shellRect); |
808 checkShellRectPos(shellRect); |
788 checkShellRectPos(shellRect); |
809 } |
789 } |
810 |
790 |
811 public void setShellBounds(Rectangle rec) { |
791 public void setShellBounds(Rectangle rec) { |
812 if (insLog.isLoggable(Level.FINE)) insLog.fine("Setting shell bounds on " + |
792 if (insLog.isLoggable(PlatformLogger.FINE)) insLog.fine("Setting shell bounds on " + |
813 this + " to " + rec); |
793 this + " to " + rec); |
814 XToolkit.awtLock(); |
794 XToolkit.awtLock(); |
815 try { |
795 try { |
816 updateSizeHints(rec.x, rec.y, rec.width, rec.height); |
796 updateSizeHints(rec.x, rec.y, rec.width, rec.height); |
817 XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), rec.width, rec.height); |
797 XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), rec.width, rec.height); |
818 XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), rec.x, rec.y); |
798 XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), rec.x, rec.y); |
820 finally { |
800 finally { |
821 XToolkit.awtUnlock(); |
801 XToolkit.awtUnlock(); |
822 } |
802 } |
823 } |
803 } |
824 public void setShellSize(Rectangle rec) { |
804 public void setShellSize(Rectangle rec) { |
825 if (insLog.isLoggable(Level.FINE)) insLog.fine("Setting shell size on " + |
805 if (insLog.isLoggable(PlatformLogger.FINE)) insLog.fine("Setting shell size on " + |
826 this + " to " + rec); |
806 this + " to " + rec); |
827 XToolkit.awtLock(); |
807 XToolkit.awtLock(); |
828 try { |
808 try { |
829 updateSizeHints(rec.x, rec.y, rec.width, rec.height); |
809 updateSizeHints(rec.x, rec.y, rec.width, rec.height); |
830 XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), rec.width, rec.height); |
810 XlibWrapper.XResizeWindow(XToolkit.getDisplay(), getShell(), rec.width, rec.height); |
831 } |
811 } |
832 finally { |
812 finally { |
833 XToolkit.awtUnlock(); |
813 XToolkit.awtUnlock(); |
834 } |
814 } |
835 } |
815 } |
836 public void setShellPosition(Rectangle rec) { |
816 public void setShellPosition(Rectangle rec) { |
837 if (insLog.isLoggable(Level.FINE)) insLog.fine("Setting shell position on " + |
817 if (insLog.isLoggable(PlatformLogger.FINE)) insLog.fine("Setting shell position on " + |
838 this + " to " + rec); |
818 this + " to " + rec); |
839 XToolkit.awtLock(); |
819 XToolkit.awtLock(); |
840 try { |
820 try { |
841 updateSizeHints(rec.x, rec.y, rec.width, rec.height); |
821 updateSizeHints(rec.x, rec.y, rec.width, rec.height); |
842 XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), rec.x, rec.y); |
822 XlibWrapper.XMoveWindow(XToolkit.getDisplay(), getShell(), rec.x, rec.y); |
843 } |
823 } |
933 try { |
913 try { |
934 if (configure_seen) { |
914 if (configure_seen) { |
935 return toGlobal(0,0); |
915 return toGlobal(0,0); |
936 } else { |
916 } else { |
937 Point location = target.getLocation(); |
917 Point location = target.getLocation(); |
938 if (insLog.isLoggable(Level.FINE)) |
918 if (insLog.isLoggable(PlatformLogger.FINE)) |
939 insLog.log(Level.FINE, "getLocationOnScreen {0} not reparented: {1} ", |
919 insLog.fine("getLocationOnScreen {0} not reparented: {1} ", |
940 new Object[] {String.valueOf(this), String.valueOf(location)}); |
920 this, location); |
941 return location; |
921 return location; |
942 } |
922 } |
943 } finally { |
923 } finally { |
944 XToolkit.awtUnlock(); |
924 XToolkit.awtUnlock(); |
945 } |
925 } |
972 int getFunctions() { |
952 int getFunctions() { |
973 return winAttr.functions; |
953 return winAttr.functions; |
974 } |
954 } |
975 |
955 |
976 public void setVisible(boolean vis) { |
956 public void setVisible(boolean vis) { |
977 if (log.isLoggable(Level.FINE)) { |
957 log.finer("Setting {0} to visible {1}", this, Boolean.valueOf(vis)); |
978 log.log(Level.FINER, "Setting {0} to visible {1}", |
|
979 new Object[] {String.valueOf(this), Boolean.valueOf(vis)}); |
|
980 } |
|
981 if (vis && !isVisible()) { |
958 if (vis && !isVisible()) { |
982 XWM.setShellDecor(this); |
959 XWM.setShellDecor(this); |
983 super.setVisible(vis); |
960 super.setVisible(vis); |
984 if (winAttr.isResizable) { |
961 if (winAttr.isResizable) { |
985 //Fix for 4320050: Minimum size for java.awt.Frame is not being enforced. |
962 //Fix for 4320050: Minimum size for java.awt.Frame is not being enforced. |
1026 } |
1003 } |
1027 } |
1004 } |
1028 } |
1005 } |
1029 |
1006 |
1030 private void handleWmTakeFocus(XClientMessageEvent cl) { |
1007 private void handleWmTakeFocus(XClientMessageEvent cl) { |
1031 if (focusLog.isLoggable(Level.FINE)) { |
1008 focusLog.fine("WM_TAKE_FOCUS on {0}", this); |
1032 focusLog.log(Level.FINE, "WM_TAKE_FOCUS on {0}", new Object[]{String.valueOf(this)}); |
|
1033 } |
|
1034 requestWindowFocus(cl.get_data(1), true); |
1009 requestWindowFocus(cl.get_data(1), true); |
1035 } |
1010 } |
1036 |
1011 |
1037 /** |
1012 /** |
1038 * Requests focus to this decorated top-level by requesting X input focus |
1013 * Requests focus to this decorated top-level by requesting X input focus |
1041 protected void requestXFocus(long time, boolean timeProvided) { |
1016 protected void requestXFocus(long time, boolean timeProvided) { |
1042 // We have proxied focus mechanism - instead of shell the focus is held |
1017 // We have proxied focus mechanism - instead of shell the focus is held |
1043 // by "proxy" - invisible mapped window. When we want to set X input focus to |
1018 // by "proxy" - invisible mapped window. When we want to set X input focus to |
1044 // toplevel set it on proxy instead. |
1019 // toplevel set it on proxy instead. |
1045 if (focusProxy == null) { |
1020 if (focusProxy == null) { |
1046 if (focusLog.isLoggable(Level.FINE)) focusLog.warning("Focus proxy is null for " + this); |
1021 if (focusLog.isLoggable(PlatformLogger.FINE)) focusLog.warning("Focus proxy is null for " + this); |
1047 } else { |
1022 } else { |
1048 if (focusLog.isLoggable(Level.FINE)) focusLog.fine("Requesting focus to proxy: " + focusProxy); |
1023 if (focusLog.isLoggable(PlatformLogger.FINE)) focusLog.fine("Requesting focus to proxy: " + focusProxy); |
1049 if (timeProvided) { |
1024 if (timeProvided) { |
1050 focusProxy.xRequestFocus(time); |
1025 focusProxy.xRequestFocus(time); |
1051 } else { |
1026 } else { |
1052 focusProxy.xRequestFocus(); |
1027 focusProxy.xRequestFocus(); |
1053 } |
1028 } |
1134 // If this is Frame or Dialog we can't assure focus request success - but we still can try |
1109 // If this is Frame or Dialog we can't assure focus request success - but we still can try |
1135 // If this is Window and its owner Frame is active we can be sure request succedded. |
1110 // If this is Window and its owner Frame is active we can be sure request succedded. |
1136 Window focusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow(); |
1111 Window focusedWindow = XKeyboardFocusManagerPeer.getCurrentNativeFocusedWindow(); |
1137 Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow); |
1112 Window activeWindow = XWindowPeer.getDecoratedOwner(focusedWindow); |
1138 |
1113 |
1139 focusLog.log(Level.FINER, "Current window is: active={0}, focused={1}", |
1114 focusLog.finer("Current window is: active={0}, focused={1}", |
1140 new Object[]{ Boolean.valueOf(target == activeWindow), |
1115 Boolean.valueOf(target == activeWindow), |
1141 Boolean.valueOf(target == focusedWindow)}); |
1116 Boolean.valueOf(target == focusedWindow)); |
1142 |
1117 |
1143 XWindowPeer toFocus = this; |
1118 XWindowPeer toFocus = this; |
1144 while (toFocus.nextTransientFor != null) { |
1119 while (toFocus.nextTransientFor != null) { |
1145 toFocus = toFocus.nextTransientFor; |
1120 toFocus = toFocus.nextTransientFor; |
1146 } |
1121 } |