< prev index next >

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

Print this page




   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package sun.awt.X11;
  26 
  27 import java.awt.*;


  28 
  29 import java.awt.event.ComponentEvent;
  30 
  31 import sun.util.logging.PlatformLogger;
  32 
  33 import sun.awt.AWTAccessor;
  34 
  35 /**
  36  * This class implements window which serves as content window for decorated frames.
  37  * Its purpose to provide correct events dispatching for the complex
  38  * constructs such as decorated frames.
  39  *
  40  * It should always be located at (- left inset, - top inset) in the associated
  41  * decorated window.  So coordinates in it would be the same as java coordinates.
  42  */
  43 public final class XContentWindow extends XWindow {
  44     private static PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XContentWindow");
  45 
  46     static XContentWindow createContent(XDecoratedPeer parentFrame) {
  47         final WindowDimensions dims = parentFrame.getDimensions();


 141     public void handleExposeEvent(Component target, int x, int y, int w, int h) {
 142         // TODO: ?
 143         // get rid of 'istanceof' by subclassing:
 144         // XContentWindow -> XFrameContentWindow
 145 
 146         // Expose event(s) that result from deiconification
 147         // come before a deicinofication notification.
 148         // We reorder these events by saving all expose events
 149         // that come when the frame is iconified. Then we
 150         // actually handle saved expose events on deiconification.
 151 
 152         if (parentFrame instanceof XFramePeer &&
 153                 (((XFramePeer)parentFrame).getState() & java.awt.Frame.ICONIFIED) != 0) {
 154             // Save expose events if the frame is iconified
 155             // in order to handle them on deiconification.
 156             iconifiedExposeEvents.add(new SavedExposeEvent(target, x, y, w, h));
 157         } else {
 158             // Normal case: [it is not a frame or] the frame is not iconified.
 159             super.handleExposeEvent(target, x, y, w, h);
 160         }
 161     }
 162 
 163     public void handleButtonPressRelease(XEvent xev) {
 164         if (xev.get_type() == XConstants.ButtonPress) {
 165             Window parentWindow = (Window)parentFrame.getTarget();
 166             /*
 167              * In case the decorated frame is active but not focused
 168              * (that is an owned window is currently focused)
 169              * it should be made a focused window.
 170              * This is needed to focus the frame when it's clicked
 171              * in an empty spot of its content area. See 6886678.
 172              */
 173             if (parentWindow != null && parentWindow.isActive() && !parentWindow.isFocused()) {
 174                 parentFrame.requestWindowFocus();
 175             }
 176         }
 177         super.handleButtonPressRelease(xev);
 178     }
 179 
 180     void purgeIconifiedExposeEvents() {
 181         for (SavedExposeEvent evt : iconifiedExposeEvents) {
 182             super.handleExposeEvent(evt.target, evt.x, evt.y, evt.w, evt.h);
 183         }
 184         iconifiedExposeEvents.clear();
 185     }
 186 
 187     private static class SavedExposeEvent {
 188         Component target;
 189         int x, y, w, h;
 190         SavedExposeEvent(Component target, int x, int y, int w, int h) {
 191             this.target = target;
 192             this.x = x;
 193             this.y = y;
 194             this.w = w;
 195             this.h = h;
 196         }
 197     }


   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package sun.awt.X11;
  26 
  27 import java.awt.Component;
  28 import java.awt.Rectangle;
  29 import java.awt.Insets;
  30 
  31 import java.awt.event.ComponentEvent;
  32 
  33 import sun.util.logging.PlatformLogger;
  34 
  35 import sun.awt.AWTAccessor;
  36 
  37 /**
  38  * This class implements window which serves as content window for decorated frames.
  39  * Its purpose to provide correct events dispatching for the complex
  40  * constructs such as decorated frames.
  41  *
  42  * It should always be located at (- left inset, - top inset) in the associated
  43  * decorated window.  So coordinates in it would be the same as java coordinates.
  44  */
  45 public final class XContentWindow extends XWindow {
  46     private static PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XContentWindow");
  47 
  48     static XContentWindow createContent(XDecoratedPeer parentFrame) {
  49         final WindowDimensions dims = parentFrame.getDimensions();


 143     public void handleExposeEvent(Component target, int x, int y, int w, int h) {
 144         // TODO: ?
 145         // get rid of 'istanceof' by subclassing:
 146         // XContentWindow -> XFrameContentWindow
 147 
 148         // Expose event(s) that result from deiconification
 149         // come before a deicinofication notification.
 150         // We reorder these events by saving all expose events
 151         // that come when the frame is iconified. Then we
 152         // actually handle saved expose events on deiconification.
 153 
 154         if (parentFrame instanceof XFramePeer &&
 155                 (((XFramePeer)parentFrame).getState() & java.awt.Frame.ICONIFIED) != 0) {
 156             // Save expose events if the frame is iconified
 157             // in order to handle them on deiconification.
 158             iconifiedExposeEvents.add(new SavedExposeEvent(target, x, y, w, h));
 159         } else {
 160             // Normal case: [it is not a frame or] the frame is not iconified.
 161             super.handleExposeEvent(target, x, y, w, h);
 162         }

















 163     }
 164 
 165     void purgeIconifiedExposeEvents() {
 166         for (SavedExposeEvent evt : iconifiedExposeEvents) {
 167             super.handleExposeEvent(evt.target, evt.x, evt.y, evt.w, evt.h);
 168         }
 169         iconifiedExposeEvents.clear();
 170     }
 171 
 172     private static class SavedExposeEvent {
 173         Component target;
 174         int x, y, w, h;
 175         SavedExposeEvent(Component target, int x, int y, int w, int h) {
 176             this.target = target;
 177             this.x = x;
 178             this.y = y;
 179             this.w = w;
 180             this.h = h;
 181         }
 182     }
< prev index next >