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

Print this page




  42         BOUNDS = "bounds", // bounds of the window, Rectangle
  43         OVERRIDE_REDIRECT = "overrideRedirect", // override_redirect setting, Boolean
  44         EVENT_MASK = "event mask", // event mask, Integer
  45         VALUE_MASK = "value mask", // value mask, Long
  46         BORDER_PIXEL = "border pixel", // border pixel value, Integer
  47         COLORMAP = "color map", // color map, Long
  48         DEPTH = "visual depth", // depth, Integer
  49         VISUAL_CLASS = "visual class", // visual class, Integer
  50         VISUAL = "visual", // visual, Long
  51         EMBEDDED = "embedded", // is embedded?, Boolean
  52         DELAYED = "delayed", // is creation delayed?, Boolean
  53         PARENT = "parent", // parent peer
  54         BACKGROUND_PIXMAP = "pixmap", // background pixmap
  55         VISIBLE = "visible", // whether it is visible by default
  56         SAVE_UNDER = "save under", // save content under this window
  57         BACKING_STORE = "backing store", // enables double buffering
  58         BIT_GRAVITY = "bit gravity"; // copy old content on geometry change
  59     private XCreateWindowParams delayedParams;
  60 
  61     Set<Long> children = new HashSet<Long>();
  62     long window;
  63     boolean visible;
  64     boolean mapped;
  65     boolean embedded;
  66     Rectangle maxBounds;
  67     volatile XBaseWindow parentWindow;
  68 
  69     private boolean disposed;
  70 
  71     private long screen;
  72     private XSizeHints hints;
  73     private XWMHints wmHints;
  74 
  75     final static int MIN_SIZE = 1;
  76     final static int DEF_LOCATION = 1;
  77 
  78     private static XAtom wm_client_leader;
  79 
  80     static enum InitialiseState {
  81         INITIALISING,
  82         NOT_INITIALISED,


 315                 value_mask |= XConstants.CWEventMask;
 316 
 317                 Long border_pixel = (Long)params.get(BORDER_PIXEL);
 318                 if (border_pixel != null) {
 319                     xattr.set_border_pixel(border_pixel.longValue());
 320                     value_mask |= XConstants.CWBorderPixel;
 321                 }
 322 
 323                 Long colormap = (Long)params.get(COLORMAP);
 324                 if (colormap != null) {
 325                     xattr.set_colormap(colormap.longValue());
 326                     value_mask |= XConstants.CWColormap;
 327                 }
 328                 Long background_pixmap = (Long)params.get(BACKGROUND_PIXMAP);
 329                 if (background_pixmap != null) {
 330                     xattr.set_background_pixmap(background_pixmap.longValue());
 331                     value_mask |= XConstants.CWBackPixmap;
 332                 }
 333 
 334                 Long parentWindow = (Long)params.get(PARENT_WINDOW);

 335                 Rectangle bounds = (Rectangle)params.get(BOUNDS);





 336                 Integer depth = (Integer)params.get(DEPTH);
 337                 Integer visual_class = (Integer)params.get(VISUAL_CLASS);
 338                 Long visual = (Long)params.get(VISUAL);
 339                 Boolean overrideRedirect = (Boolean)params.get(OVERRIDE_REDIRECT);
 340                 if (overrideRedirect != null) {
 341                     xattr.set_override_redirect(overrideRedirect.booleanValue());
 342                     value_mask |= XConstants.CWOverrideRedirect;
 343                 }
 344 
 345                 Boolean saveUnder = (Boolean)params.get(SAVE_UNDER);
 346                 if (saveUnder != null) {
 347                     xattr.set_save_under(saveUnder.booleanValue());
 348                     value_mask |= XConstants.CWSaveUnder;
 349                 }
 350 
 351                 Integer backingStore = (Integer)params.get(BACKING_STORE);
 352                 if (backingStore != null) {
 353                     xattr.set_backing_store(backingStore.intValue());
 354                     value_mask |= XConstants.CWBackingStore;
 355                 }


 906 
 907     // called from ungrabInput, used in popup windows to hide theirselfs in ungrabbing
 908     void ungrabInputImpl() {
 909     }
 910 
 911     static void checkSecurity() {
 912         if (XToolkit.isSecurityWarningEnabled() && XToolkit.isToolkitThread()) {
 913             StackTraceElement stack[] = (new Throwable()).getStackTrace();
 914             log.warning(stack[1] + ": Security violation: calling user code on toolkit thread");
 915         }
 916     }
 917 
 918     public Set<Long> getChildren() {
 919         synchronized (getStateLock()) {
 920             return new HashSet<Long>(children);
 921         }
 922     }
 923 
 924     // -------------- Event handling ----------------
 925     public void handleMapNotifyEvent(XEvent xev) {

 926         mapped = true;
 927     }

 928     public void handleUnmapNotifyEvent(XEvent xev) {

 929         mapped = false;
 930     }

 931     public void handleReparentNotifyEvent(XEvent xev) {
 932         if (eventLog.isLoggable(Level.FINER)) {
 933             XReparentEvent msg = xev.get_xreparent();
 934             eventLog.finer(msg.toString());
 935         }
 936     }
 937     public void handlePropertyNotify(XEvent xev) {
 938         XPropertyEvent msg = xev.get_xproperty();
 939         if (XPropertyCache.isCachingSupported()) {
 940             XPropertyCache.clearCache(window, XAtom.get(msg.get_atom()));
 941         }
 942         if (eventLog.isLoggable(Level.FINER)) {
 943             eventLog.log(Level.FINER, "{0}", new Object[] {msg});
 944         }
 945     }
 946 
 947     public void handleDestroyNotify(XEvent xev) {
 948         XAnyEvent xany = xev.get_xany();
 949         if (xany.get_window() == getWindow()) {
 950             XToolkit.removeFromWinMap(getWindow(), this);


1009         case XConstants.ButtonPress:
1010             if (buttonState == 0) {
1011                 XAwtState.setAutoGrabWindow(this);
1012             }
1013             break;
1014         case XConstants.ButtonRelease:
1015             if (isFullRelease(buttonState, xbe.get_button())) {
1016                 XAwtState.setAutoGrabWindow(null);
1017             }
1018             break;
1019         }
1020     }
1021     public void handleMotionNotify(XEvent xev) {
1022     }
1023     public void handleXCrossingEvent(XEvent xev) {
1024     }
1025     public void handleConfigureNotifyEvent(XEvent xev) {
1026         XConfigureEvent xe = xev.get_xconfigure();
1027         insLog.log(Level.FINER, "Configure, {0}",
1028                    new Object[] {xe});





1029         x = xe.get_x();
1030         y = xe.get_y();
1031         width = xe.get_width();
1032         height = xe.get_height();
1033     }
1034     /**
1035      * Checks ButtonRelease released all Mouse buttons
1036      */
1037     static boolean isFullRelease(int buttonState, int button) {
1038         final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
1039 
1040         if (button < 0 || button > buttonsNumber) {
1041             return buttonState == 0;
1042         } else {
1043             return buttonState == XConstants.buttonsMask[button - 1];
1044         }
1045     }
1046 
1047     static boolean isGrabbedEvent(XEvent ev, XBaseWindow target) {
1048         switch (ev.get_type()) {




  42         BOUNDS = "bounds", // bounds of the window, Rectangle
  43         OVERRIDE_REDIRECT = "overrideRedirect", // override_redirect setting, Boolean
  44         EVENT_MASK = "event mask", // event mask, Integer
  45         VALUE_MASK = "value mask", // value mask, Long
  46         BORDER_PIXEL = "border pixel", // border pixel value, Integer
  47         COLORMAP = "color map", // color map, Long
  48         DEPTH = "visual depth", // depth, Integer
  49         VISUAL_CLASS = "visual class", // visual class, Integer
  50         VISUAL = "visual", // visual, Long
  51         EMBEDDED = "embedded", // is embedded?, Boolean
  52         DELAYED = "delayed", // is creation delayed?, Boolean
  53         PARENT = "parent", // parent peer
  54         BACKGROUND_PIXMAP = "pixmap", // background pixmap
  55         VISIBLE = "visible", // whether it is visible by default
  56         SAVE_UNDER = "save under", // save content under this window
  57         BACKING_STORE = "backing store", // enables double buffering
  58         BIT_GRAVITY = "bit gravity"; // copy old content on geometry change
  59     private XCreateWindowParams delayedParams;
  60 
  61     Set<Long> children = new HashSet<Long>();
  62     long window = XConstants.None;
  63     boolean visible;
  64     boolean mapped;
  65     boolean embedded;
  66     Rectangle maxBounds;
  67     volatile XBaseWindow parentWindow;
  68 
  69     private boolean disposed;
  70 
  71     private long screen;
  72     private XSizeHints hints;
  73     private XWMHints wmHints;
  74 
  75     final static int MIN_SIZE = 1;
  76     final static int DEF_LOCATION = 1;
  77 
  78     private static XAtom wm_client_leader;
  79 
  80     static enum InitialiseState {
  81         INITIALISING,
  82         NOT_INITIALISED,


 315                 value_mask |= XConstants.CWEventMask;
 316 
 317                 Long border_pixel = (Long)params.get(BORDER_PIXEL);
 318                 if (border_pixel != null) {
 319                     xattr.set_border_pixel(border_pixel.longValue());
 320                     value_mask |= XConstants.CWBorderPixel;
 321                 }
 322 
 323                 Long colormap = (Long)params.get(COLORMAP);
 324                 if (colormap != null) {
 325                     xattr.set_colormap(colormap.longValue());
 326                     value_mask |= XConstants.CWColormap;
 327                 }
 328                 Long background_pixmap = (Long)params.get(BACKGROUND_PIXMAP);
 329                 if (background_pixmap != null) {
 330                     xattr.set_background_pixmap(background_pixmap.longValue());
 331                     value_mask |= XConstants.CWBackPixmap;
 332                 }
 333 
 334                 Long parentWindow = (Long)params.get(PARENT_WINDOW);
 335                 
 336                 Rectangle bounds = (Rectangle)params.get(BOUNDS);
 337                 this.x = bounds.x;
 338                 this.y = bounds.y;
 339                 this.width = bounds.width;
 340                 this.height = bounds.height;
 341 
 342                 Integer depth = (Integer)params.get(DEPTH);
 343                 Integer visual_class = (Integer)params.get(VISUAL_CLASS);
 344                 Long visual = (Long)params.get(VISUAL);
 345                 Boolean overrideRedirect = (Boolean)params.get(OVERRIDE_REDIRECT);
 346                 if (overrideRedirect != null) {
 347                     xattr.set_override_redirect(overrideRedirect.booleanValue());
 348                     value_mask |= XConstants.CWOverrideRedirect;
 349                 }
 350 
 351                 Boolean saveUnder = (Boolean)params.get(SAVE_UNDER);
 352                 if (saveUnder != null) {
 353                     xattr.set_save_under(saveUnder.booleanValue());
 354                     value_mask |= XConstants.CWSaveUnder;
 355                 }
 356 
 357                 Integer backingStore = (Integer)params.get(BACKING_STORE);
 358                 if (backingStore != null) {
 359                     xattr.set_backing_store(backingStore.intValue());
 360                     value_mask |= XConstants.CWBackingStore;
 361                 }


 912 
 913     // called from ungrabInput, used in popup windows to hide theirselfs in ungrabbing
 914     void ungrabInputImpl() {
 915     }
 916 
 917     static void checkSecurity() {
 918         if (XToolkit.isSecurityWarningEnabled() && XToolkit.isToolkitThread()) {
 919             StackTraceElement stack[] = (new Throwable()).getStackTrace();
 920             log.warning(stack[1] + ": Security violation: calling user code on toolkit thread");
 921         }
 922     }
 923 
 924     public Set<Long> getChildren() {
 925         synchronized (getStateLock()) {
 926             return new HashSet<Long>(children);
 927         }
 928     }
 929 
 930     // -------------- Event handling ----------------
 931     public void handleMapNotifyEvent(XEvent xev) {
 932         if (xev.get_xany().get_window() == getWindow()) {
 933             mapped = true;
 934         }
 935     }
 936     public void handleUnmapNotifyEvent(XEvent xev) {
 937         if (xev.get_xany().get_window() == getWindow()) {
 938             mapped = false;
 939         }
 940     }
 941     public void handleReparentNotifyEvent(XEvent xev) {
 942         if (eventLog.isLoggable(Level.FINER)) {
 943             XReparentEvent msg = xev.get_xreparent();
 944             eventLog.finer(msg.toString());
 945         }
 946     }
 947     public void handlePropertyNotify(XEvent xev) {
 948         XPropertyEvent msg = xev.get_xproperty();
 949         if (XPropertyCache.isCachingSupported()) {
 950             XPropertyCache.clearCache(window, XAtom.get(msg.get_atom()));
 951         }
 952         if (eventLog.isLoggable(Level.FINER)) {
 953             eventLog.log(Level.FINER, "{0}", new Object[] {msg});
 954         }
 955     }
 956 
 957     public void handleDestroyNotify(XEvent xev) {
 958         XAnyEvent xany = xev.get_xany();
 959         if (xany.get_window() == getWindow()) {
 960             XToolkit.removeFromWinMap(getWindow(), this);


1019         case XConstants.ButtonPress:
1020             if (buttonState == 0) {
1021                 XAwtState.setAutoGrabWindow(this);
1022             }
1023             break;
1024         case XConstants.ButtonRelease:
1025             if (isFullRelease(buttonState, xbe.get_button())) {
1026                 XAwtState.setAutoGrabWindow(null);
1027             }
1028             break;
1029         }
1030     }
1031     public void handleMotionNotify(XEvent xev) {
1032     }
1033     public void handleXCrossingEvent(XEvent xev) {
1034     }
1035     public void handleConfigureNotifyEvent(XEvent xev) {
1036         XConfigureEvent xe = xev.get_xconfigure();
1037         insLog.log(Level.FINER, "Configure, {0}",
1038                    new Object[] {xe});
1039 
1040         if (xe.get_window() != getWindow()) {
1041             return;
1042         }
1043 
1044         x = xe.get_x();
1045         y = xe.get_y();
1046         width = xe.get_width();
1047         height = xe.get_height();
1048     }
1049     /**
1050      * Checks ButtonRelease released all Mouse buttons
1051      */
1052     static boolean isFullRelease(int buttonState, int button) {
1053         final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
1054 
1055         if (button < 0 || button > buttonsNumber) {
1056             return buttonState == 0;
1057         } else {
1058             return buttonState == XConstants.buttonsMask[button - 1];
1059         }
1060     }
1061 
1062     static boolean isGrabbedEvent(XEvent ev, XBaseWindow target) {
1063         switch (ev.get_type()) {