< prev index next >

src/java.desktop/unix/classes/sun/awt/X11/XWindow.java

Print this page
rev 58017 : 8239124: Minimize the usage of AwtGraphicsConfigDataPtr in native
Reviewed-by: XXX
   1 /*
   2  * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   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 
  26 package sun.awt.X11;
  27 
  28 import java.awt.*;
  29 import java.awt.event.*;
  30 import java.awt.peer.ComponentPeer;



















  31 import java.awt.image.ColorModel;
  32 
  33 import java.lang.ref.WeakReference;
  34 

  35 import sun.awt.AWTAccessor.ComponentAccessor;
  36 import sun.util.logging.PlatformLogger;
  37 
  38 import sun.awt.*;
  39 
  40 import sun.awt.image.PixelConverter;
  41 
  42 import sun.java2d.SunGraphics2D;
  43 import sun.java2d.SurfaceData;

  44 
  45 class XWindow extends XBaseWindow implements X11ComponentPeer {
  46     private static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XWindow");
  47     private static PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XWindow");
  48     private static PlatformLogger eventLog = PlatformLogger.getLogger("sun.awt.X11.event.XWindow");
  49     private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XWindow");
  50     private static PlatformLogger keyEventLog = PlatformLogger.getLogger("sun.awt.X11.kye.XWindow");
  51   /* If a motion comes in while a multi-click is pending,
  52    * allow a smudge factor so that moving the mouse by a small
  53    * amount does not wipe out the multi-click state variables.
  54    */
  55     private static final int AWT_MULTICLICK_SMUDGE = 4;
  56     // ButtonXXX events stuff
  57     static int lastX = 0, lastY = 0;
  58     static long lastTime = 0;
  59     static long lastButton = 0;
  60     static WeakReference<XWindow> lastWindowRef = null;
  61     static int clickCount = 0;
  62 
  63     // used to check if we need to re-create surfaceData.


 100 
 101     // fallback default font object
 102     private static Font defaultFont;
 103 
 104     static synchronized Font getDefaultFont() {
 105         if (null == defaultFont) {
 106             defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
 107         }
 108         return defaultFont;
 109     }
 110 
 111     /* A bitmask keeps the button's numbers as Button1Mask, Button2Mask, Button3Mask
 112      * which are allowed to
 113      * generate the CLICK event after the RELEASE has happened.
 114      * There are conditions that must be true for that sending CLICK event:
 115      * 1) button was initially PRESSED
 116      * 2) no movement or drag has happened until RELEASE
 117     */
 118     private int mouseButtonClickAllowed = 0;
 119 
 120     native int getNativeColor(Color clr, GraphicsConfiguration gc);
 121     native void getWMInsets(long window, long left, long top, long right, long bottom, long border);
 122     native long getTopWindow(long window, long rootWin);
 123     native void getWindowBounds(long window, long x, long y, long width, long height);
 124     private static native void initIDs();
 125 
 126     static {
 127         initIDs();
 128     }
 129 
 130     XWindow(XCreateWindowParams params) {
 131         super(params);
 132     }
 133 
 134     XWindow() {
 135     }
 136 
 137     XWindow(long parentWindow, Rectangle bounds) {
 138         super(new XCreateWindowParams(new Object[] {
 139             BOUNDS, bounds,
 140             PARENT_WINDOW, Long.valueOf(parentWindow)}));
 141     }
 142 
 143     XWindow(Component target, long parentWindow, Rectangle bounds) {


   1 /*
   2  * Copyright (c) 2002, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   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 
  26 package sun.awt.X11;
  27 
  28 import java.awt.AWTEvent;
  29 import java.awt.AWTKeyStroke;
  30 import java.awt.Color;
  31 import java.awt.Component;
  32 import java.awt.Container;
  33 import java.awt.Cursor;
  34 import java.awt.Font;
  35 import java.awt.FontMetrics;
  36 import java.awt.Graphics;
  37 import java.awt.GraphicsConfiguration;
  38 import java.awt.Point;
  39 import java.awt.Rectangle;
  40 import java.awt.SystemColor;
  41 import java.awt.Toolkit;
  42 import java.awt.Window;
  43 import java.awt.event.ComponentEvent;
  44 import java.awt.event.FocusEvent;
  45 import java.awt.event.InputEvent;
  46 import java.awt.event.KeyEvent;
  47 import java.awt.event.MouseEvent;
  48 import java.awt.event.MouseWheelEvent;
  49 import java.awt.event.PaintEvent;
  50 import java.awt.image.ColorModel;
  51 import java.awt.peer.ComponentPeer;
  52 import java.lang.ref.WeakReference;
  53 
  54 import sun.awt.AWTAccessor;
  55 import sun.awt.AWTAccessor.ComponentAccessor;
  56 import sun.awt.PaintEventDispatcher;
  57 import sun.awt.PeerEvent;
  58 import sun.awt.SunToolkit;
  59 import sun.awt.X11ComponentPeer;
  60 import sun.awt.X11GraphicsConfig;

  61 import sun.java2d.SunGraphics2D;
  62 import sun.java2d.SurfaceData;
  63 import sun.util.logging.PlatformLogger;
  64 
  65 class XWindow extends XBaseWindow implements X11ComponentPeer {
  66     private static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XWindow");
  67     private static PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XWindow");
  68     private static PlatformLogger eventLog = PlatformLogger.getLogger("sun.awt.X11.event.XWindow");
  69     private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XWindow");
  70     private static PlatformLogger keyEventLog = PlatformLogger.getLogger("sun.awt.X11.kye.XWindow");
  71   /* If a motion comes in while a multi-click is pending,
  72    * allow a smudge factor so that moving the mouse by a small
  73    * amount does not wipe out the multi-click state variables.
  74    */
  75     private static final int AWT_MULTICLICK_SMUDGE = 4;
  76     // ButtonXXX events stuff
  77     static int lastX = 0, lastY = 0;
  78     static long lastTime = 0;
  79     static long lastButton = 0;
  80     static WeakReference<XWindow> lastWindowRef = null;
  81     static int clickCount = 0;
  82 
  83     // used to check if we need to re-create surfaceData.


 120 
 121     // fallback default font object
 122     private static Font defaultFont;
 123 
 124     static synchronized Font getDefaultFont() {
 125         if (null == defaultFont) {
 126             defaultFont = new Font(Font.DIALOG, Font.PLAIN, 12);
 127         }
 128         return defaultFont;
 129     }
 130 
 131     /* A bitmask keeps the button's numbers as Button1Mask, Button2Mask, Button3Mask
 132      * which are allowed to
 133      * generate the CLICK event after the RELEASE has happened.
 134      * There are conditions that must be true for that sending CLICK event:
 135      * 1) button was initially PRESSED
 136      * 2) no movement or drag has happened until RELEASE
 137     */
 138     private int mouseButtonClickAllowed = 0;
 139 




 140     private static native void initIDs();
 141 
 142     static {
 143         initIDs();
 144     }
 145 
 146     XWindow(XCreateWindowParams params) {
 147         super(params);
 148     }
 149 
 150     XWindow() {
 151     }
 152 
 153     XWindow(long parentWindow, Rectangle bounds) {
 154         super(new XCreateWindowParams(new Object[] {
 155             BOUNDS, bounds,
 156             PARENT_WINDOW, Long.valueOf(parentWindow)}));
 157     }
 158 
 159     XWindow(Component target, long parentWindow, Rectangle bounds) {


< prev index next >