44 |
44 |
45 /** |
45 /** |
46 * Class incapsulating knowledge about window managers in general |
46 * Class incapsulating knowledge about window managers in general |
47 * Descendants should provide some information about specific window manager. |
47 * Descendants should provide some information about specific window manager. |
48 */ |
48 */ |
49 final class XWM implements MWMConstants, XUtilConstants |
49 final class XWM |
50 { |
50 { |
51 |
51 |
52 private final static Logger log = Logger.getLogger("sun.awt.X11.XWM"); |
52 private final static Logger log = Logger.getLogger("sun.awt.X11.XWM"); |
53 private final static Logger insLog = Logger.getLogger("sun.awt.X11.insets.XWM"); |
53 private final static Logger insLog = Logger.getLogger("sun.awt.X11.insets.XWM"); |
54 private final static Logger stateLog = Logger.getLogger("sun.awt.X11.states.XWM"); |
54 private final static Logger stateLog = Logger.getLogger("sun.awt.X11.states.XWM"); |
272 if (selection_owner != XConstants.None) { |
272 if (selection_owner != XConstants.None) { |
273 return false; |
273 return false; |
274 } |
274 } |
275 |
275 |
276 winmgr_running = false; |
276 winmgr_running = false; |
277 substruct.set_event_mask(XlibWrapper.SubstructureRedirectMask); |
277 substruct.set_event_mask(XConstants.SubstructureRedirectMask); |
278 |
278 |
279 XToolkit.WITH_XERROR_HANDLER(DetectWMHandler); |
279 XToolkit.WITH_XERROR_HANDLER(DetectWMHandler); |
280 XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(), |
280 XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(), |
281 XToolkit.getDefaultRootWindow(), |
281 XToolkit.getDefaultRootWindow(), |
282 XlibWrapper.CWEventMask, |
282 XConstants.CWEventMask, |
283 substruct.pData); |
283 substruct.pData); |
284 XToolkit.RESTORE_XERROR_HANDLER(); |
284 XToolkit.RESTORE_XERROR_HANDLER(); |
285 |
285 |
286 /* |
286 /* |
287 * If no WM is running then our selection for SubstructureRedirect |
287 * If no WM is running then our selection for SubstructureRedirect |
289 */ |
289 */ |
290 if (!winmgr_running) { |
290 if (!winmgr_running) { |
291 substruct.set_event_mask(0); |
291 substruct.set_event_mask(0); |
292 XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(), |
292 XlibWrapper.XChangeWindowAttributes(XToolkit.getDisplay(), |
293 XToolkit.getDefaultRootWindow(), |
293 XToolkit.getDefaultRootWindow(), |
294 XlibWrapper.CWEventMask, |
294 XConstants.CWEventMask, |
295 substruct.pData); |
295 substruct.pData); |
296 if (insLog.isLoggable(Level.FINE)) { |
296 if (insLog.isLoggable(Level.FINE)) { |
297 insLog.finer("It looks like there is no WM thus NO_WM"); |
297 insLog.finer("It looks like there is no WM thus NO_WM"); |
298 } |
298 } |
299 } |
299 } |
320 WindowPropertyGetter getter = |
320 WindowPropertyGetter getter = |
321 new WindowPropertyGetter(window, XA_ENLIGHTENMENT_COMMS, 0, 14, false, |
321 new WindowPropertyGetter(window, XA_ENLIGHTENMENT_COMMS, 0, 14, false, |
322 XAtom.XA_STRING); |
322 XAtom.XA_STRING); |
323 try { |
323 try { |
324 int status = getter.execute(XToolkit.IgnoreBadWindowHandler); |
324 int status = getter.execute(XToolkit.IgnoreBadWindowHandler); |
325 if (status != XlibWrapper.Success || getter.getData() == 0) { |
325 if (status != XConstants.Success || getter.getData() == 0) { |
326 return 0; |
326 return 0; |
327 } |
327 } |
328 |
328 |
329 if (getter.getActualType() != XAtom.XA_STRING |
329 if (getter.getActualType() != XAtom.XA_STRING |
330 || getter.getActualFormat() != 8 |
330 || getter.getActualFormat() != 8 |
409 new WindowPropertyGetter(XToolkit.getDefaultRootWindow(), |
409 new WindowPropertyGetter(XToolkit.getDefaultRootWindow(), |
410 XA_DT_SM_WINDOW_INFO, 0, 2, |
410 XA_DT_SM_WINDOW_INFO, 0, 2, |
411 false, XA_DT_SM_WINDOW_INFO); |
411 false, XA_DT_SM_WINDOW_INFO); |
412 try { |
412 try { |
413 int status = getter.execute(); |
413 int status = getter.execute(); |
414 if (status != XlibWrapper.Success || getter.getData() == 0) { |
414 if (status != XConstants.Success || getter.getData() == 0) { |
415 log.finer("Getting of _DT_SM_WINDOW_INFO is not successfull"); |
415 log.finer("Getting of _DT_SM_WINDOW_INFO is not successfull"); |
416 return false; |
416 return false; |
417 } |
417 } |
418 if (getter.getActualType() != XA_DT_SM_WINDOW_INFO.getAtom() |
418 if (getter.getActualType() != XA_DT_SM_WINDOW_INFO.getAtom() |
419 || getter.getActualFormat() != 32 |
419 || getter.getActualFormat() != 32 |
440 false, XA_DT_SM_STATE_INFO); |
440 false, XA_DT_SM_STATE_INFO); |
441 try { |
441 try { |
442 status = getter2.execute(XToolkit.IgnoreBadWindowHandler); |
442 status = getter2.execute(XToolkit.IgnoreBadWindowHandler); |
443 |
443 |
444 |
444 |
445 if (status != XlibWrapper.Success || getter2.getData() == 0) { |
445 if (status != XConstants.Success || getter2.getData() == 0) { |
446 log.finer("Getting of _DT_SM_STATE_INFO is not successfull"); |
446 log.finer("Getting of _DT_SM_STATE_INFO is not successfull"); |
447 return false; |
447 return false; |
448 } |
448 } |
449 if (getter2.getActualType() != XA_DT_SM_STATE_INFO.getAtom() |
449 if (getter2.getActualType() != XA_DT_SM_STATE_INFO.getAtom() |
450 || getter2.getActualFormat() != 32) |
450 || getter2.getActualFormat() != 32) |
478 } |
478 } |
479 |
479 |
480 WindowPropertyGetter getter = |
480 WindowPropertyGetter getter = |
481 new WindowPropertyGetter(XToolkit.getDefaultRootWindow(), |
481 new WindowPropertyGetter(XToolkit.getDefaultRootWindow(), |
482 XA_MOTIF_WM_INFO, 0, |
482 XA_MOTIF_WM_INFO, 0, |
483 PROP_MOTIF_WM_INFO_ELEMENTS, |
483 MWMConstants.PROP_MOTIF_WM_INFO_ELEMENTS, |
484 false, XA_MOTIF_WM_INFO); |
484 false, XA_MOTIF_WM_INFO); |
485 try { |
485 try { |
486 int status = getter.execute(); |
486 int status = getter.execute(); |
487 |
487 |
488 if (status != XlibWrapper.Success || getter.getData() == 0) { |
488 if (status != XConstants.Success || getter.getData() == 0) { |
489 return false; |
489 return false; |
490 } |
490 } |
491 |
491 |
492 if (getter.getActualType() != XA_MOTIF_WM_INFO.getAtom() |
492 if (getter.getActualType() != XA_MOTIF_WM_INFO.getAtom() |
493 || getter.getActualFormat() != 32 |
493 || getter.getActualFormat() != 32 |
494 || getter.getNumberOfItems() != PROP_MOTIF_WM_INFO_ELEMENTS |
494 || getter.getNumberOfItems() != MWMConstants.PROP_MOTIF_WM_INFO_ELEMENTS |
495 || getter.getBytesAfter() != 0) |
495 || getter.getBytesAfter() != 0) |
496 { |
496 { |
497 return false; |
497 return false; |
498 } |
498 } |
499 |
499 |
575 * XChangeProperty succeeded or not. |
575 * XChangeProperty succeeded or not. |
576 */ |
576 */ |
577 static XToolkit.XErrorHandler VerifyChangePropertyHandler = new XToolkit.XErrorHandler() { |
577 static XToolkit.XErrorHandler VerifyChangePropertyHandler = new XToolkit.XErrorHandler() { |
578 public int handleError(long display, XErrorEvent err) { |
578 public int handleError(long display, XErrorEvent err) { |
579 XToolkit.XERROR_SAVE(err); |
579 XToolkit.XERROR_SAVE(err); |
580 if (err.get_request_code() == XlibWrapper.X_ChangeProperty) { |
580 if (err.get_request_code() == XProtocolConstants.X_ChangeProperty) { |
581 return 0; |
581 return 0; |
582 } else { |
582 } else { |
583 return XToolkit.SAVED_ERROR_HANDLER(display, err); |
583 return XToolkit.SAVED_ERROR_HANDLER(display, err); |
584 } |
584 } |
585 } |
585 } |
619 try { |
619 try { |
620 XToolkit.WITH_XERROR_HANDLER(VerifyChangePropertyHandler); |
620 XToolkit.WITH_XERROR_HANDLER(VerifyChangePropertyHandler); |
621 XlibWrapper.XChangePropertyS(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), |
621 XlibWrapper.XChangePropertyS(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), |
622 XA_ICEWM_WINOPTHINT.getAtom(), |
622 XA_ICEWM_WINOPTHINT.getAtom(), |
623 XA_ICEWM_WINOPTHINT.getAtom(), |
623 XA_ICEWM_WINOPTHINT.getAtom(), |
624 8, XlibWrapper.PropModeReplace, |
624 8, XConstants.PropModeReplace, |
625 new String(opt)); |
625 new String(opt)); |
626 XToolkit.RESTORE_XERROR_HANDLER(); |
626 XToolkit.RESTORE_XERROR_HANDLER(); |
627 |
627 |
628 if (XToolkit.saved_error != null && XToolkit.saved_error.get_error_code() != XlibWrapper.Success) { |
628 if (XToolkit.saved_error != null && XToolkit.saved_error.get_error_code() != XConstants.Success) { |
629 log.finer("Erorr getting XA_ICEWM_WINOPTHINT property"); |
629 log.finer("Erorr getting XA_ICEWM_WINOPTHINT property"); |
630 return false; |
630 return false; |
631 } |
631 } |
632 log.finer("Prepared for IceWM detection"); |
632 log.finer("Prepared for IceWM detection"); |
633 return true; |
633 return true; |
652 new WindowPropertyGetter(XToolkit.getDefaultRootWindow(), |
652 new WindowPropertyGetter(XToolkit.getDefaultRootWindow(), |
653 XA_ICEWM_WINOPTHINT, 0, 0xFFFF, |
653 XA_ICEWM_WINOPTHINT, 0, 0xFFFF, |
654 true, XA_ICEWM_WINOPTHINT); |
654 true, XA_ICEWM_WINOPTHINT); |
655 try { |
655 try { |
656 int status = getter.execute(); |
656 int status = getter.execute(); |
657 boolean res = (status == XlibWrapper.Success && getter.getActualType() != 0); |
657 boolean res = (status == XConstants.Success && getter.getActualType() != 0); |
658 log.finer("Status getting XA_ICEWM_WINOPTHINT: " + !res); |
658 log.finer("Status getting XA_ICEWM_WINOPTHINT: " + !res); |
659 return !res || isNetWMName("IceWM"); |
659 return !res || isNetWMName("IceWM"); |
660 } finally { |
660 } finally { |
661 getter.dispose(); |
661 getter.dispose(); |
662 } |
662 } |
684 */ |
684 */ |
685 static boolean winmgr_running = false; |
685 static boolean winmgr_running = false; |
686 static XToolkit.XErrorHandler DetectWMHandler = new XToolkit.XErrorHandler() { |
686 static XToolkit.XErrorHandler DetectWMHandler = new XToolkit.XErrorHandler() { |
687 public int handleError(long display, XErrorEvent err) { |
687 public int handleError(long display, XErrorEvent err) { |
688 XToolkit.XERROR_SAVE(err); |
688 XToolkit.XERROR_SAVE(err); |
689 if (err.get_request_code() == XlibWrapper.X_ChangeWindowAttributes |
689 if (err.get_request_code() == XProtocolConstants.X_ChangeWindowAttributes |
690 && err.get_error_code() == XlibWrapper.BadAccess) |
690 && err.get_error_code() == XConstants.BadAccess) |
691 { |
691 { |
692 winmgr_running = true; |
692 winmgr_running = true; |
693 return 0; |
693 return 0; |
694 } else { |
694 } else { |
695 return XToolkit.SAVED_ERROR_HANDLER(display, err); |
695 return XToolkit.SAVED_ERROR_HANDLER(display, err); |
802 /* |
802 /* |
803 * Remove size hints specified by the mask. |
803 * Remove size hints specified by the mask. |
804 * XXX: Why do we need this in the first place??? |
804 * XXX: Why do we need this in the first place??? |
805 */ |
805 */ |
806 static void removeSizeHints(XDecoratedPeer window, long mask) { |
806 static void removeSizeHints(XDecoratedPeer window, long mask) { |
807 mask &= PMaxSize | PMinSize; |
807 mask &= XUtilConstants.PMaxSize | XUtilConstants.PMinSize; |
808 |
808 |
809 XToolkit.awtLock(); |
809 XToolkit.awtLock(); |
810 try { |
810 try { |
811 XSizeHints hints = window.getHints(); |
811 XSizeHints hints = window.getHints(); |
812 if ((hints.get_flags() & mask) == 0) { |
812 if ((hints.get_flags() & mask) == 0) { |
828 * to be subtracted from the decorations. Normalize decoration spec |
828 * to be subtracted from the decorations. Normalize decoration spec |
829 * so that we can map motif decor to something else bit-by-bit in the |
829 * so that we can map motif decor to something else bit-by-bit in the |
830 * rest of the code. |
830 * rest of the code. |
831 */ |
831 */ |
832 static int normalizeMotifDecor(int decorations) { |
832 static int normalizeMotifDecor(int decorations) { |
833 if ((decorations & MWM_DECOR_ALL) == 0) { |
833 if ((decorations & MWMConstants.MWM_DECOR_ALL) == 0) { |
834 return decorations; |
834 return decorations; |
835 } |
835 } |
836 int d = MWM_DECOR_BORDER | MWM_DECOR_RESIZEH |
836 int d = MWMConstants.MWM_DECOR_BORDER | MWMConstants.MWM_DECOR_RESIZEH |
837 | MWM_DECOR_TITLE |
837 | MWMConstants.MWM_DECOR_TITLE |
838 | MWM_DECOR_MENU | MWM_DECOR_MINIMIZE |
838 | MWMConstants.MWM_DECOR_MENU | MWMConstants.MWM_DECOR_MINIMIZE |
839 | MWM_DECOR_MAXIMIZE; |
839 | MWMConstants.MWM_DECOR_MAXIMIZE; |
840 d &= ~decorations; |
840 d &= ~decorations; |
841 return d; |
841 return d; |
842 } |
842 } |
843 |
843 |
844 /* |
844 /* |
846 * to be subtracted from the functions. Normalize function spec |
846 * to be subtracted from the functions. Normalize function spec |
847 * so that we can map motif func to something else bit-by-bit in the |
847 * so that we can map motif func to something else bit-by-bit in the |
848 * rest of the code. |
848 * rest of the code. |
849 */ |
849 */ |
850 static int normalizeMotifFunc(int functions) { |
850 static int normalizeMotifFunc(int functions) { |
851 if ((functions & MWM_FUNC_ALL) == 0) { |
851 if ((functions & MWMConstants.MWM_FUNC_ALL) == 0) { |
852 return functions; |
852 return functions; |
853 } |
853 } |
854 int f = MWM_FUNC_RESIZE | |
854 int f = MWMConstants.MWM_FUNC_RESIZE | |
855 MWM_FUNC_MOVE | |
855 MWMConstants.MWM_FUNC_MOVE | |
856 MWM_FUNC_MAXIMIZE | |
856 MWMConstants.MWM_FUNC_MAXIMIZE | |
857 MWM_FUNC_MINIMIZE | |
857 MWMConstants.MWM_FUNC_MINIMIZE | |
858 MWM_FUNC_CLOSE; |
858 MWMConstants.MWM_FUNC_CLOSE; |
859 f &= ~functions; |
859 f &= ~functions; |
860 return f; |
860 return f; |
861 } |
861 } |
862 |
862 |
863 /* |
863 /* |
870 } |
870 } |
871 |
871 |
872 XAtomList decorDel = new XAtomList(); |
872 XAtomList decorDel = new XAtomList(); |
873 decorations = normalizeMotifDecor(decorations); |
873 decorations = normalizeMotifDecor(decorations); |
874 if (insLog.isLoggable(Level.FINER)) insLog.finer("Setting OL_DECOR to " + Integer.toBinaryString(decorations)); |
874 if (insLog.isLoggable(Level.FINER)) insLog.finer("Setting OL_DECOR to " + Integer.toBinaryString(decorations)); |
875 if ((decorations & MWM_DECOR_TITLE) == 0) { |
875 if ((decorations & MWMConstants.MWM_DECOR_TITLE) == 0) { |
876 decorDel.add(XA_OL_DECOR_HEADER); |
876 decorDel.add(XA_OL_DECOR_HEADER); |
877 } |
877 } |
878 if ((decorations & (MWM_DECOR_RESIZEH | MWM_DECOR_MAXIMIZE)) == 0) { |
878 if ((decorations & (MWMConstants.MWM_DECOR_RESIZEH | MWMConstants.MWM_DECOR_MAXIMIZE)) == 0) { |
879 decorDel.add(XA_OL_DECOR_RESIZE); |
879 decorDel.add(XA_OL_DECOR_RESIZE); |
880 } |
880 } |
881 if ((decorations & (MWM_DECOR_MENU | |
881 if ((decorations & (MWMConstants.MWM_DECOR_MENU | |
882 MWM_DECOR_MAXIMIZE | |
882 MWMConstants.MWM_DECOR_MAXIMIZE | |
883 MWM_DECOR_MINIMIZE)) == 0) |
883 MWMConstants.MWM_DECOR_MINIMIZE)) == 0) |
884 { |
884 { |
885 decorDel.add(XA_OL_DECOR_CLOSE); |
885 decorDel.add(XA_OL_DECOR_CLOSE); |
886 } |
886 } |
887 if (decorDel.size() == 0) { |
887 if (decorDel.size() == 0) { |
888 insLog.finer("Deleting OL_DECOR"); |
888 insLog.finer("Deleting OL_DECOR"); |
896 /* |
896 /* |
897 * Set MWM decorations. Set MWM functions depending on resizability. |
897 * Set MWM decorations. Set MWM functions depending on resizability. |
898 */ |
898 */ |
899 static void setMotifDecor(XWindowPeer window, boolean resizable, int decorations, int functions) { |
899 static void setMotifDecor(XWindowPeer window, boolean resizable, int decorations, int functions) { |
900 /* Apparently some WMs don't implement MWM_*_ALL semantic correctly */ |
900 /* Apparently some WMs don't implement MWM_*_ALL semantic correctly */ |
901 if ((decorations & MWM_DECOR_ALL) != 0 |
901 if ((decorations & MWMConstants.MWM_DECOR_ALL) != 0 |
902 && (decorations != MWM_DECOR_ALL)) |
902 && (decorations != MWMConstants.MWM_DECOR_ALL)) |
903 { |
903 { |
904 decorations = normalizeMotifDecor(decorations); |
904 decorations = normalizeMotifDecor(decorations); |
905 } |
905 } |
906 if ((functions & MWM_FUNC_ALL) != 0 |
906 if ((functions & MWMConstants.MWM_FUNC_ALL) != 0 |
907 && (functions != MWM_FUNC_ALL)) |
907 && (functions != MWMConstants.MWM_FUNC_ALL)) |
908 { |
908 { |
909 functions = normalizeMotifFunc(functions); |
909 functions = normalizeMotifFunc(functions); |
910 } |
910 } |
911 |
911 |
912 PropMwmHints hints = window.getMWMHints(); |
912 PropMwmHints hints = window.getMWMHints(); |
913 hints.set_flags(hints.get_flags() | MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS); |
913 hints.set_flags(hints.get_flags() | |
|
914 MWMConstants.MWM_HINTS_FUNCTIONS | |
|
915 MWMConstants.MWM_HINTS_DECORATIONS); |
914 hints.set_functions(functions); |
916 hints.set_functions(functions); |
915 hints.set_decorations(decorations); |
917 hints.set_decorations(decorations); |
916 |
918 |
917 if (stateLog.isLoggable(Level.FINER)) stateLog.finer("Setting MWM_HINTS to " + hints); |
919 if (stateLog.isLoggable(Level.FINER)) stateLog.finer("Setting MWM_HINTS to " + hints); |
918 window.setMWMHints(hints); |
920 window.setMWMHints(hints); |
948 int decorations = window.getDecorations(); |
950 int decorations = window.getDecorations(); |
949 int functions = window.getFunctions(); |
951 int functions = window.getFunctions(); |
950 boolean resizable = window.isResizable(); |
952 boolean resizable = window.isResizable(); |
951 |
953 |
952 if (!resizable) { |
954 if (!resizable) { |
953 if ((decorations & MWM_DECOR_ALL) != 0) { |
955 if ((decorations & MWMConstants.MWM_DECOR_ALL) != 0) { |
954 decorations |= MWM_DECOR_RESIZEH | MWM_DECOR_MAXIMIZE; |
956 decorations |= MWMConstants.MWM_DECOR_RESIZEH | MWMConstants.MWM_DECOR_MAXIMIZE; |
955 } else { |
957 } else { |
956 decorations &= ~(MWM_DECOR_RESIZEH | MWM_DECOR_MAXIMIZE); |
958 decorations &= ~(MWMConstants.MWM_DECOR_RESIZEH | MWMConstants.MWM_DECOR_MAXIMIZE); |
957 } |
959 } |
958 } |
960 } |
959 setMotifDecor(window, resizable, decorations, functions); |
961 setMotifDecor(window, resizable, decorations, functions); |
960 setOLDecor(window, resizable, decorations); |
962 setOLDecor(window, resizable, decorations); |
961 |
963 |
986 XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), window.getShell(), |
988 XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(), window.getShell(), |
987 shellBounds.x, shellBounds.y, shellBounds.width, shellBounds.height); |
989 shellBounds.x, shellBounds.y, shellBounds.width, shellBounds.height); |
988 /* REMINDER: will need to revisit when setExtendedStateBounds is added */ |
990 /* REMINDER: will need to revisit when setExtendedStateBounds is added */ |
989 //Fix for 4320050: Minimum size for java.awt.Frame is not being enforced. |
991 //Fix for 4320050: Minimum size for java.awt.Frame is not being enforced. |
990 //We need to update frame's minimum size, not to reset it |
992 //We need to update frame's minimum size, not to reset it |
991 removeSizeHints(window, PMaxSize); |
993 removeSizeHints(window, XUtilConstants.PMaxSize); |
992 window.updateMinimumSize(); |
994 window.updateMinimumSize(); |
993 |
995 |
994 /* Restore decorations */ |
996 /* Restore decorations */ |
995 setShellDecor(window); |
997 setShellDecor(window); |
996 } finally { |
998 } finally { |
1132 stateLog.finer("Window is not showing"); |
1134 stateLog.finer("Window is not showing"); |
1133 return false; |
1135 return false; |
1134 } |
1136 } |
1135 |
1137 |
1136 int wm_state = window.getWMState(); |
1138 int wm_state = window.getWMState(); |
1137 if (wm_state == XlibWrapper.WithdrawnState) { |
1139 if (wm_state == XUtilConstants.WithdrawnState) { |
1138 stateLog.finer("WithdrawnState"); |
1140 stateLog.finer("WithdrawnState"); |
1139 return false; |
1141 return false; |
1140 } else { |
1142 } else { |
1141 stateLog.finer("Window WM_STATE is " + wm_state); |
1143 stateLog.finer("Window WM_STATE is " + wm_state); |
1142 } |
1144 } |
1156 * Returns current state (including extended) of a given window. |
1158 * Returns current state (including extended) of a given window. |
1157 */ |
1159 */ |
1158 int getState(XDecoratedPeer window) { |
1160 int getState(XDecoratedPeer window) { |
1159 int res = 0; |
1161 int res = 0; |
1160 final int wm_state = window.getWMState(); |
1162 final int wm_state = window.getWMState(); |
1161 if (wm_state == XlibWrapper.IconicState) { |
1163 if (wm_state == XUtilConstants.IconicState) { |
1162 res = Frame.ICONIFIED; |
1164 res = Frame.ICONIFIED; |
1163 } else { |
1165 } else { |
1164 res = Frame.NORMAL; |
1166 res = Frame.NORMAL; |
1165 } |
1167 } |
1166 res |= getExtendedState(window); |
1168 res |= getExtendedState(window); |
1395 |
1397 |
1396 WindowPropertyGetter getter = |
1398 WindowPropertyGetter getter = |
1397 new WindowPropertyGetter(window, atom, |
1399 new WindowPropertyGetter(window, atom, |
1398 0, 4, false, XAtom.XA_CARDINAL); |
1400 0, 4, false, XAtom.XA_CARDINAL); |
1399 try { |
1401 try { |
1400 if (getter.execute() != XlibWrapper.Success |
1402 if (getter.execute() != XConstants.Success |
1401 || getter.getData() == 0 |
1403 || getter.getData() == 0 |
1402 || getter.getActualType() != XAtom.XA_CARDINAL |
1404 || getter.getActualType() != XAtom.XA_CARDINAL |
1403 || getter.getActualFormat() != 32) |
1405 || getter.getActualFormat() != 32) |
1404 { |
1406 { |
1405 return null; |
1407 return null; |
1424 |
1426 |
1425 log.fine("Requesting FRAME_EXTENTS"); |
1427 log.fine("Requesting FRAME_EXTENTS"); |
1426 |
1428 |
1427 XClientMessageEvent msg = new XClientMessageEvent(); |
1429 XClientMessageEvent msg = new XClientMessageEvent(); |
1428 msg.zero(); |
1430 msg.zero(); |
1429 msg.set_type(XlibWrapper.ClientMessage); |
1431 msg.set_type(XConstants.ClientMessage); |
1430 msg.set_display(XToolkit.getDisplay()); |
1432 msg.set_display(XToolkit.getDisplay()); |
1431 msg.set_window(window); |
1433 msg.set_window(window); |
1432 msg.set_format(32); |
1434 msg.set_format(32); |
1433 XToolkit.awtLock(); |
1435 XToolkit.awtLock(); |
1434 try { |
1436 try { |
1435 XNETProtocol net_protocol = getWM().getNETProtocol(); |
1437 XNETProtocol net_protocol = getWM().getNETProtocol(); |
1436 if (net_protocol != null && net_protocol.active()) { |
1438 if (net_protocol != null && net_protocol.active()) { |
1437 msg.set_message_type(XA_NET_REQUEST_FRAME_EXTENTS.getAtom()); |
1439 msg.set_message_type(XA_NET_REQUEST_FRAME_EXTENTS.getAtom()); |
1438 XlibWrapper.XSendEvent(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), |
1440 XlibWrapper.XSendEvent(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), |
1439 false, XlibWrapper.SubstructureRedirectMask | XlibWrapper.SubstructureNotifyMask, |
1441 false, |
|
1442 XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask, |
1440 msg.getPData()); |
1443 msg.getPData()); |
1441 } |
1444 } |
1442 if (getWMID() == XWM.KDE2_WM) { |
1445 if (getWMID() == XWM.KDE2_WM) { |
1443 msg.set_message_type(XA_KDE_NET_WM_FRAME_STRUT.getAtom()); |
1446 msg.set_message_type(XA_KDE_NET_WM_FRAME_STRUT.getAtom()); |
1444 XlibWrapper.XSendEvent(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), |
1447 XlibWrapper.XSendEvent(XToolkit.getDisplay(), XToolkit.getDefaultRootWindow(), |
1445 false, XlibWrapper.SubstructureRedirectMask | XlibWrapper.SubstructureNotifyMask, |
1448 false, |
|
1449 XConstants.SubstructureRedirectMask | XConstants.SubstructureNotifyMask, |
1446 msg.getPData()); |
1450 msg.getPData()); |
1447 } |
1451 } |
1448 // XXX: should we wait for response? XIfEvent() would be useful here :) |
1452 // XXX: should we wait for response? XIfEvent() would be useful here :) |
1449 } finally { |
1453 } finally { |
1450 XToolkit.awtUnlock(); |
1454 XToolkit.awtUnlock(); |