src/solaris/classes/sun/awt/X11/XWindowPeer.java

Print this page




 210 
 211     private static native String getLocalHostname();
 212     private static native int getJvmPID();
 213 
 214     void postInit(XCreateWindowParams params) {
 215         super.postInit(params);
 216 
 217         // Init WM_PROTOCOLS atom
 218         initWMProtocols();
 219 
 220         // Set _NET_WM_PID and WM_CLIENT_MACHINE using this JVM
 221         XAtom.get("WM_CLIENT_MACHINE").setProperty(getWindow(), getLocalHostname());
 222         XAtom.get("_NET_WM_PID").setCard32Property(getWindow(), getJvmPID());
 223 
 224         // Set WM_TRANSIENT_FOR and group_leader
 225         Window t_window = (Window)target;
 226         Window owner = t_window.getOwner();
 227         if (owner != null) {
 228             ownerPeer = (XWindowPeer)owner.getPeer();
 229             if (focusLog.isLoggable(PlatformLogger.FINER)) {
 230                 focusLog.fine("Owner is " + owner);
 231                 focusLog.fine("Owner peer is " + ownerPeer);
 232                 focusLog.fine("Owner X window " + Long.toHexString(ownerPeer.getWindow()));
 233                 focusLog.fine("Owner content X window " + Long.toHexString(ownerPeer.getContentWindow()));
 234             }
 235             // as owner window may be an embedded window, we must get a toplevel window
 236             // to set as TRANSIENT_FOR hint
 237             long ownerWindow = ownerPeer.getWindow();
 238             if (ownerWindow != 0) {
 239                 XToolkit.awtLock();
 240                 try {
 241                     // Set WM_TRANSIENT_FOR
 242                     if (focusLog.isLoggable(PlatformLogger.FINE)) focusLog.fine("Setting transient on " + Long.toHexString(getWindow())

 243                                                                        + " for " + Long.toHexString(ownerWindow));

 244                     setToplevelTransientFor(this, ownerPeer, false, true);
 245 
 246                     // Set group leader
 247                     XWMHints hints = getWMHints();
 248                     hints.set_flags(hints.get_flags() | (int)XUtilConstants.WindowGroupHint);
 249                     hints.set_window_group(ownerWindow);
 250                     XlibWrapper.XSetWMHints(XToolkit.getDisplay(), getWindow(), hints.pData);
 251                 }
 252                 finally {
 253                     XToolkit.awtUnlock();
 254                 }
 255             }
 256         }
 257 
 258         if (owner != null || isSimpleWindow()) {
 259             XNETProtocol protocol = XWM.getWM().getNETProtocol();
 260             if (protocol != null && protocol.active()) {
 261                 XToolkit.awtLock();
 262                 try {
 263                     XAtomList net_wm_state = getNETWMState();


 760         repositionSecurityWarning();
 761     }
 762 
 763     final void requestXFocus(long time) {
 764         requestXFocus(time, true);
 765     }
 766 
 767     final void requestXFocus() {
 768         requestXFocus(0, false);
 769     }
 770 
 771     /**
 772      * Requests focus to this top-level. Descendants should override to provide
 773      * implementations based on a class of top-level.
 774      */
 775     protected void requestXFocus(long time, boolean timeProvided) {
 776         // Since in XAWT focus is synthetic and all basic Windows are
 777         // override_redirect all we can do is check whether our parent
 778         // is active. If it is - we can freely synthesize focus transfer.
 779         // Luckily, this logic is already implemented in requestWindowFocus.
 780         if (focusLog.isLoggable(PlatformLogger.FINE)) focusLog.fine("Requesting window focus");


 781         requestWindowFocus(time, timeProvided);
 782     }
 783 
 784     public final boolean focusAllowedFor() {
 785         if (isNativelyNonFocusableWindow()) {
 786             return false;
 787         }
 788 /*
 789         Window target = (Window)this.target;
 790         if (!target.isVisible() ||
 791             !target.isEnabled() ||
 792             !target.isFocusable())
 793         {
 794             return false;
 795         }
 796 */
 797         if (isModalBlocked()) {
 798             return false;
 799         }
 800         return true;


1883                 typeAtom = protocol.XA_NET_WM_WINDOW_TYPE_UTILITY;
1884                 break;
1885             case POPUP:
1886                 typeAtom = protocol.XA_NET_WM_WINDOW_TYPE_POPUP_MENU;
1887                 break;
1888         }
1889 
1890         if (typeAtom != null) {
1891             XAtomList wtype = new XAtomList();
1892             wtype.add(typeAtom);
1893             protocol.XA_NET_WM_WINDOW_TYPE.
1894                 setAtomListProperty(getWindow(), wtype);
1895         } else {
1896             protocol.XA_NET_WM_WINDOW_TYPE.
1897                 DeleteProperty(getWindow());
1898         }
1899     }
1900 
1901     @Override
1902     public void xSetVisible(boolean visible) {
1903         if (log.isLoggable(PlatformLogger.FINE)) log.fine("Setting visible on " + this + " to " + visible);


1904         XToolkit.awtLock();
1905         try {
1906             this.visible = visible;
1907             if (visible) {
1908                 applyWindowType();
1909                 XlibWrapper.XMapRaised(XToolkit.getDisplay(), getWindow());
1910             } else {
1911                 XlibWrapper.XUnmapWindow(XToolkit.getDisplay(), getWindow());
1912             }
1913             XlibWrapper.XFlush(XToolkit.getDisplay());
1914         }
1915         finally {
1916             XToolkit.awtUnlock();
1917         }
1918     }
1919 
1920     // should be synchronized on awtLock
1921     private int dropTargetCount = 0;
1922 
1923     public void addDropTarget() {




 210 
 211     private static native String getLocalHostname();
 212     private static native int getJvmPID();
 213 
 214     void postInit(XCreateWindowParams params) {
 215         super.postInit(params);
 216 
 217         // Init WM_PROTOCOLS atom
 218         initWMProtocols();
 219 
 220         // Set _NET_WM_PID and WM_CLIENT_MACHINE using this JVM
 221         XAtom.get("WM_CLIENT_MACHINE").setProperty(getWindow(), getLocalHostname());
 222         XAtom.get("_NET_WM_PID").setCard32Property(getWindow(), getJvmPID());
 223 
 224         // Set WM_TRANSIENT_FOR and group_leader
 225         Window t_window = (Window)target;
 226         Window owner = t_window.getOwner();
 227         if (owner != null) {
 228             ownerPeer = (XWindowPeer)owner.getPeer();
 229             if (focusLog.isLoggable(PlatformLogger.FINER)) {
 230                 focusLog.finer("Owner is " + owner);
 231                 focusLog.finer("Owner peer is " + ownerPeer);
 232                 focusLog.finer("Owner X window " + Long.toHexString(ownerPeer.getWindow()));
 233                 focusLog.finer("Owner content X window " + Long.toHexString(ownerPeer.getContentWindow()));
 234             }
 235             // as owner window may be an embedded window, we must get a toplevel window
 236             // to set as TRANSIENT_FOR hint
 237             long ownerWindow = ownerPeer.getWindow();
 238             if (ownerWindow != 0) {
 239                 XToolkit.awtLock();
 240                 try {
 241                     // Set WM_TRANSIENT_FOR
 242                     if (focusLog.isLoggable(PlatformLogger.FINE)) {
 243                         focusLog.fine("Setting transient on " + Long.toHexString(getWindow())
 244                                       + " for " + Long.toHexString(ownerWindow));
 245                     }
 246                     setToplevelTransientFor(this, ownerPeer, false, true);
 247 
 248                     // Set group leader
 249                     XWMHints hints = getWMHints();
 250                     hints.set_flags(hints.get_flags() | (int)XUtilConstants.WindowGroupHint);
 251                     hints.set_window_group(ownerWindow);
 252                     XlibWrapper.XSetWMHints(XToolkit.getDisplay(), getWindow(), hints.pData);
 253                 }
 254                 finally {
 255                     XToolkit.awtUnlock();
 256                 }
 257             }
 258         }
 259 
 260         if (owner != null || isSimpleWindow()) {
 261             XNETProtocol protocol = XWM.getWM().getNETProtocol();
 262             if (protocol != null && protocol.active()) {
 263                 XToolkit.awtLock();
 264                 try {
 265                     XAtomList net_wm_state = getNETWMState();


 762         repositionSecurityWarning();
 763     }
 764 
 765     final void requestXFocus(long time) {
 766         requestXFocus(time, true);
 767     }
 768 
 769     final void requestXFocus() {
 770         requestXFocus(0, false);
 771     }
 772 
 773     /**
 774      * Requests focus to this top-level. Descendants should override to provide
 775      * implementations based on a class of top-level.
 776      */
 777     protected void requestXFocus(long time, boolean timeProvided) {
 778         // Since in XAWT focus is synthetic and all basic Windows are
 779         // override_redirect all we can do is check whether our parent
 780         // is active. If it is - we can freely synthesize focus transfer.
 781         // Luckily, this logic is already implemented in requestWindowFocus.
 782         if (focusLog.isLoggable(PlatformLogger.FINE)) {
 783             focusLog.fine("Requesting window focus");
 784         }
 785         requestWindowFocus(time, timeProvided);
 786     }
 787 
 788     public final boolean focusAllowedFor() {
 789         if (isNativelyNonFocusableWindow()) {
 790             return false;
 791         }
 792 /*
 793         Window target = (Window)this.target;
 794         if (!target.isVisible() ||
 795             !target.isEnabled() ||
 796             !target.isFocusable())
 797         {
 798             return false;
 799         }
 800 */
 801         if (isModalBlocked()) {
 802             return false;
 803         }
 804         return true;


1887                 typeAtom = protocol.XA_NET_WM_WINDOW_TYPE_UTILITY;
1888                 break;
1889             case POPUP:
1890                 typeAtom = protocol.XA_NET_WM_WINDOW_TYPE_POPUP_MENU;
1891                 break;
1892         }
1893 
1894         if (typeAtom != null) {
1895             XAtomList wtype = new XAtomList();
1896             wtype.add(typeAtom);
1897             protocol.XA_NET_WM_WINDOW_TYPE.
1898                 setAtomListProperty(getWindow(), wtype);
1899         } else {
1900             protocol.XA_NET_WM_WINDOW_TYPE.
1901                 DeleteProperty(getWindow());
1902         }
1903     }
1904 
1905     @Override
1906     public void xSetVisible(boolean visible) {
1907         if (log.isLoggable(PlatformLogger.FINE)) {
1908             log.fine("Setting visible on " + this + " to " + visible);
1909         }
1910         XToolkit.awtLock();
1911         try {
1912             this.visible = visible;
1913             if (visible) {
1914                 applyWindowType();
1915                 XlibWrapper.XMapRaised(XToolkit.getDisplay(), getWindow());
1916             } else {
1917                 XlibWrapper.XUnmapWindow(XToolkit.getDisplay(), getWindow());
1918             }
1919             XlibWrapper.XFlush(XToolkit.getDisplay());
1920         }
1921         finally {
1922             XToolkit.awtUnlock();
1923         }
1924     }
1925 
1926     // should be synchronized on awtLock
1927     private int dropTargetCount = 0;
1928 
1929     public void addDropTarget() {