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

Print this page




 264     }
 265 
 266     public GraphicsConfiguration getGraphicsConfiguration() {
 267         if (graphicsConfig == null) {
 268             initGraphicsConfiguration();
 269         }
 270         return graphicsConfig;
 271     }
 272 
 273     public AwtGraphicsConfigData getGraphicsConfigurationData() {
 274         if (graphicsConfigData == null) {
 275             initGraphicsConfiguration();
 276         }
 277         return graphicsConfigData;
 278     }
 279 
 280     protected String[] getWMClass() {
 281         return new String[] {XToolkit.getCorrectXIDString(getClass().getName()), XToolkit.getAWTAppClassName()};
 282     }
 283 
 284     void setReparented(boolean newValue) {
 285         reparented = newValue;




















































 286     }
 287 
 288     boolean isReparented() {
 289         return reparented;




















 290     }
 291 
 292     static long getParentWindowID(Component target) {
 293 
 294         ComponentPeer peer = target.getParent().getPeer();
 295         Component temp = target.getParent();
 296         while (!(peer instanceof XWindow))
 297         {
 298             temp = temp.getParent();
 299             peer = temp.getPeer();
 300         }
 301 
 302         if (peer != null && peer instanceof XWindow)
 303             return ((XWindow)peer).getContentWindow();
 304         else return 0;
 305     }
 306 
 307 
 308     static XWindow getParentXWindowObject(Component target) {
 309         if (target == null) return null;


 977         if (compWithMouse != null) {
 978             MouseEvent me = new MouseEvent(compWithMouse,
 979                 MouseEvent.MOUSE_EXITED, jWhen, modifiers, xce.get_x(),
 980                 xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount, popupTrigger,
 981                 MouseEvent.NOBUTTON);
 982             postEventToEventQueue(me);
 983             eventLog.finest("Clearing last window ref");
 984             lastWindowRef = null;
 985         }
 986         if (xce.get_type() == XConstants.EnterNotify) {
 987             MouseEvent me = new MouseEvent(getEventSource(), MouseEvent.MOUSE_ENTERED,
 988                 jWhen, modifiers, xce.get_x(), xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount,
 989                 popupTrigger, MouseEvent.NOBUTTON);
 990             postEventToEventQueue(me);
 991         }
 992     }
 993 
 994     public void doLayout(int x, int y, int width, int height) {}
 995 
 996     public void handleConfigureNotifyEvent(XEvent xev) {
 997         Rectangle oldBounds = getBounds();
 998 





 999         super.handleConfigureNotifyEvent(xev);
1000         insLog.log(Level.FINER, "Configure, {0}, event disabled: {1}",
1001                    new Object[] {xev.get_xconfigure(), isEventDisabled(xev)});
1002         if (isEventDisabled(xev)) {
1003             return;
1004         }
1005 
1006 //  if ( Check if it's a resize, a move, or a stacking order change )
1007 //  {
1008         Rectangle bounds = getBounds();
1009         if (!bounds.getSize().equals(oldBounds.getSize())) {
1010             postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED));
1011         }
1012         if (!bounds.getLocation().equals(oldBounds.getLocation())) {
1013             postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_MOVED));
1014         }
1015 //  }
1016     }
1017 
1018     public void handleMapNotifyEvent(XEvent xev) {
1019         super.handleMapNotifyEvent(xev);
1020         log.log(Level.FINE, "Mapped {0}", new Object[] {this});
1021         if (isEventDisabled(xev)) {
1022             return;
1023         }





1024         ComponentEvent ce;
1025 
1026         ce = new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_SHOWN);
1027         postEventToEventQueue(ce);
1028     }
1029 
1030     public void handleUnmapNotifyEvent(XEvent xev) {
1031         super.handleUnmapNotifyEvent(xev);
1032         if (isEventDisabled(xev)) {
1033             return;
1034         }




1035         ComponentEvent ce;
1036 
1037         ce = new ComponentEvent(target, ComponentEvent.COMPONENT_HIDDEN);
1038         postEventToEventQueue(ce);
1039     }
1040 
1041     private void dumpKeysymArray(XKeyEvent ev) {
1042         keyEventLog.fine("  "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 0))+
1043                          "\n        "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 1))+
1044                          "\n        "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 2))+
1045                          "\n        "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 3)));
1046     }
1047     /**
1048        Return unicode character or 0 if no correspondent character found.
1049        Parameter is a keysym basically from keysymdef.h
1050        XXX: how about vendor keys? Is there some with Unicode value and not in the list?
1051     */
1052     int keysymToUnicode( long keysym, int state ) {
1053         return XKeysym.convertKeysym( keysym, state );
1054     }


1385 
1386     public Point getLocationOnScreen() {
1387         synchronized (target.getTreeLock()) {
1388             Component comp = target;
1389 
1390             while (comp != null && !(comp instanceof Window)) {
1391                 comp = ComponentAccessor.getParent_NoClientCode(comp);
1392             }
1393 
1394             // applets, embedded, etc - translate directly
1395             // XXX: override in subclass?
1396             if (comp == null || comp instanceof sun.awt.EmbeddedFrame) {
1397                 return toGlobal(0, 0);
1398             }
1399 
1400             XToolkit.awtLock();
1401             try {
1402                 Object wpeer = XToolkit.targetToPeer(comp);
1403                 if (wpeer == null
1404                     || !(wpeer instanceof XDecoratedPeer)
1405                     || ((XDecoratedPeer)wpeer).configure_seen)
1406                 {
1407                     return toGlobal(0, 0);
1408                 }
1409 
1410                 // wpeer is an XDecoratedPeer not yet fully adopted by WM
1411                 Point pt = toOtherWindow(getContentWindow(),
1412                                          ((XDecoratedPeer)wpeer).getContentWindow(),
1413                                          0, 0);
1414 
1415                 if (pt == null) {
1416                     pt = new Point(((XBaseWindow)wpeer).getAbsoluteX(), ((XBaseWindow)wpeer).getAbsoluteY());
1417                 }
1418                 pt.x += comp.getX();
1419                 pt.y += comp.getY();
1420                 return pt;
1421             } finally {
1422                 XToolkit.awtUnlock();
1423             }
1424         }
1425     }




 264     }
 265 
 266     public GraphicsConfiguration getGraphicsConfiguration() {
 267         if (graphicsConfig == null) {
 268             initGraphicsConfiguration();
 269         }
 270         return graphicsConfig;
 271     }
 272 
 273     public AwtGraphicsConfigData getGraphicsConfigurationData() {
 274         if (graphicsConfigData == null) {
 275             initGraphicsConfiguration();
 276         }
 277         return graphicsConfigData;
 278     }
 279 
 280     protected String[] getWMClass() {
 281         return new String[] {XToolkit.getCorrectXIDString(getClass().getName()), XToolkit.getAWTAppClassName()};
 282     }
 283 
 284     /**
 285      * Current native parent of this window.
 286      *
 287      * Synchronization: state lock.
 288      */
 289     private long nativeParent = XConstants.None;
 290 
 291     /**
 292      * Get the current native parent window of this window as reported via
 293      * the ReparentNotify.
 294      */
 295     public final long getNativeParent() {
 296         synchronized (getStateLock()) {
 297             return nativeParent;
 298         }
 299     }
 300 
 301     /**
 302      * Sets the current native parent of the window.
 303      * Primarily intended to be called from the handleReparentNotifyEvent().
 304      */
 305     public void setNativeParent(long parent) {
 306         synchronized (getStateLock()) {
 307             nativeParent = parent;
 308         }
 309     }
 310 
 311     @Override
 312     public void handleReparentNotifyEvent(XEvent xev) {
 313         super.handleReparentNotifyEvent(xev);
 314 
 315         XReparentEvent  xe = xev.get_xreparent();
 316 
 317         if (xe.get_window() != getWindow()) {
 318             return;
 319         }
 320 
 321         setNativeParent(xe.get_parent());
 322     }
 323 
 324     /**
 325      * Returns the root window of the current window.
 326      */
 327     public final long getRootWindow() {
 328         if (getWindow() == XConstants.None) {
 329             return XConstants.None;
 330         }
 331         XToolkit.awtLock();
 332         try {
 333             XlibUtil.getWindowGeometry(getWindow(), XlibWrapper.larg1);
 334             return Native.getWindow(XlibWrapper.larg1);
 335         } finally {
 336             XToolkit.awtUnlock();
 337         }
 338     }
 339 
 340     /**
 341      * Indicates whether the window is currently parented or not.
 342      */
 343     public final boolean isParented() {
 344         long nativeParent = getNativeParent();
 345         return nativeParent != XConstants.None &&
 346             nativeParent != getRootWindow();
 347     }
 348 
 349     /**
 350      * Indicates if this window has not yet been parented by the window
 351      * manager.
 352      *
 353      * If the window is not expected to be parented at all (like if the WM is
 354      * non-reparenting, or this is an OverrideRedirect window), this method
 355      * returns false.
 356      */
 357     public boolean mayBeReparented() {
 358         return 
 359             XWM.isRunning() &&
 360             !XWM.isNonReparentingWM() &&
 361             !isParented();
 362     }
 363 
 364     static long getParentWindowID(Component target) {
 365 
 366         ComponentPeer peer = target.getParent().getPeer();
 367         Component temp = target.getParent();
 368         while (!(peer instanceof XWindow))
 369         {
 370             temp = temp.getParent();
 371             peer = temp.getPeer();
 372         }
 373 
 374         if (peer != null && peer instanceof XWindow)
 375             return ((XWindow)peer).getContentWindow();
 376         else return 0;
 377     }
 378 
 379 
 380     static XWindow getParentXWindowObject(Component target) {
 381         if (target == null) return null;


1049         if (compWithMouse != null) {
1050             MouseEvent me = new MouseEvent(compWithMouse,
1051                 MouseEvent.MOUSE_EXITED, jWhen, modifiers, xce.get_x(),
1052                 xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount, popupTrigger,
1053                 MouseEvent.NOBUTTON);
1054             postEventToEventQueue(me);
1055             eventLog.finest("Clearing last window ref");
1056             lastWindowRef = null;
1057         }
1058         if (xce.get_type() == XConstants.EnterNotify) {
1059             MouseEvent me = new MouseEvent(getEventSource(), MouseEvent.MOUSE_ENTERED,
1060                 jWhen, modifiers, xce.get_x(), xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount,
1061                 popupTrigger, MouseEvent.NOBUTTON);
1062             postEventToEventQueue(me);
1063         }
1064     }
1065 
1066     public void doLayout(int x, int y, int width, int height) {}
1067 
1068     public void handleConfigureNotifyEvent(XEvent xev) {
1069         XConfigureEvent xe = xev.get_xconfigure();
1070 
1071         if (xe.get_window() != getWindow()) {
1072             return;
1073         }
1074 
1075         Rectangle oldBounds = getBounds();
1076         super.handleConfigureNotifyEvent(xev);
1077         insLog.log(Level.FINER, "Configure, {0}, event disabled: {1}",
1078                    new Object[] {xe, isEventDisabled(xev)});
1079         if (isEventDisabled(xev)) {
1080             return;
1081         }
1082 
1083 

1084         Rectangle bounds = getBounds();
1085         if (!bounds.getSize().equals(oldBounds.getSize())) {
1086             postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_RESIZED));
1087         }
1088         if (!bounds.getLocation().equals(oldBounds.getLocation())) {
1089             postEventToEventQueue(new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_MOVED));
1090         }

1091     }
1092 
1093     public void handleMapNotifyEvent(XEvent xev) {
1094         super.handleMapNotifyEvent(xev);
1095         log.log(Level.FINE, "Mapped {0}", new Object[] {this});
1096         if (isEventDisabled(xev)) {
1097             return;
1098         }
1099 
1100         if (xev.get_xany().get_window() != getWindow()) {
1101             return;
1102         }
1103 
1104         ComponentEvent ce;
1105 
1106         ce = new ComponentEvent(getEventSource(), ComponentEvent.COMPONENT_SHOWN);
1107         postEventToEventQueue(ce);
1108     }
1109 
1110     public void handleUnmapNotifyEvent(XEvent xev) {
1111         super.handleUnmapNotifyEvent(xev);
1112         if (isEventDisabled(xev)) {
1113             return;
1114         }
1115         if (xev.get_xany().get_window() != getWindow()) {
1116             return;
1117         }
1118 
1119         ComponentEvent ce;
1120 
1121         ce = new ComponentEvent(target, ComponentEvent.COMPONENT_HIDDEN);
1122         postEventToEventQueue(ce);
1123     }
1124 
1125     private void dumpKeysymArray(XKeyEvent ev) {
1126         keyEventLog.fine("  "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 0))+
1127                          "\n        "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 1))+
1128                          "\n        "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 2))+
1129                          "\n        "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 3)));
1130     }
1131     /**
1132        Return unicode character or 0 if no correspondent character found.
1133        Parameter is a keysym basically from keysymdef.h
1134        XXX: how about vendor keys? Is there some with Unicode value and not in the list?
1135     */
1136     int keysymToUnicode( long keysym, int state ) {
1137         return XKeysym.convertKeysym( keysym, state );
1138     }


1469 
1470     public Point getLocationOnScreen() {
1471         synchronized (target.getTreeLock()) {
1472             Component comp = target;
1473 
1474             while (comp != null && !(comp instanceof Window)) {
1475                 comp = ComponentAccessor.getParent_NoClientCode(comp);
1476             }
1477 
1478             // applets, embedded, etc - translate directly
1479             // XXX: override in subclass?
1480             if (comp == null || comp instanceof sun.awt.EmbeddedFrame) {
1481                 return toGlobal(0, 0);
1482             }
1483 
1484             XToolkit.awtLock();
1485             try {
1486                 Object wpeer = XToolkit.targetToPeer(comp);
1487                 if (wpeer == null
1488                     || !(wpeer instanceof XDecoratedPeer)
1489                     || !((XDecoratedPeer)wpeer).areBoundsAdjusting())
1490                 {
1491                     return toGlobal(0, 0);
1492                 }
1493 
1494                 // wpeer is an XDecoratedPeer not yet fully adopted by WM
1495                 Point pt = toOtherWindow(getContentWindow(),
1496                                          ((XDecoratedPeer)wpeer).getContentWindow(),
1497                                          0, 0);
1498 
1499                 if (pt == null) {
1500                     pt = new Point(((XBaseWindow)wpeer).getAbsoluteX(), ((XBaseWindow)wpeer).getAbsoluteY());
1501                 }
1502                 pt.x += comp.getX();
1503                 pt.y += comp.getY();
1504                 return pt;
1505             } finally {
1506                 XToolkit.awtUnlock();
1507             }
1508         }
1509     }