/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XWindow");
/* If a motion comes in while a multi-click is pending,
* allow a smudge factor so that moving the mouse by a small
* amount does not wipe out the multi-click state variables.
*/
// ButtonXXX events stuff
// used to check if we need to re-create surfaceData.
private boolean reparented;
// fallback default font object
if (null == defaultFont) {
}
return defaultFont;
}
/* A bitmask keeps the button's numbers as Button1Mask, Button2Mask, Button3Mask
* which are allowed to
* generate the CLICK event after the RELEASE has happened.
* There are conditions that must be true for that sending CLICK event:
* 1) button was initially PRESSED
* 2) no movement or drag has happened until RELEASE
*/
private native static void initIDs();
static {
initIDs();
}
super(params);
}
XWindow() {
}
super(new XCreateWindowParams(new Object[] {
}
super(new XCreateWindowParams(new Object[] {
}
}
this(target, (target.getParent() == null) ? 0 : getParentWindowID(target), new Rectangle(target.getBounds()));
}
}
/* This create is used by the XEmbeddedFramePeer since it has to create the window
as a child of the netscape window. This netscape window is passed in as wid */
super(new XCreateWindowParams(new Object[] {
}
protected void initGraphicsConfiguration() {
}
} else {
}
getColorModel(); // fix 4948833: this call forces the color map to be initialized
params.putIfNull(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWEventMask | XConstants.CWColormap);
try {
if (screen != -1) {
} else {
}
} finally {
}
}
paintArea = new XRepaintArea();
}
try {
if (wm_protocols == null) {
}
}
finally {
}
winAttr = new XWindowAttributesData();
}
setWMClass(getWMClass());
Color c;
// We need a version of setBackground that does not call repaint !!
// and one that does not get overridden. The problem is that in postInit
// we call setBackground and we dont have all the stuff initialized to
// do a full paint for most peers. So we cannot call setBackground in postInit.
// instead we need to call xSetBackground.
xSetBackground(c);
}
}
if (graphicsConfig == null) {
}
return graphicsConfig;
}
if (graphicsConfigData == null) {
}
return graphicsConfigData;
}
return new String[] {XToolkit.getCorrectXIDString(getClass().getName()), XToolkit.getAWTAppClassName()};
}
}
boolean isReparented() {
return reparented;
}
{
}
else return 0;
}
{
}
else return null;
}
return false;
}
}
}
return target;
}
return target;
}
}
if (graphicsConfig != null) {
return graphicsConfig.getColorModel ();
}
else {
return XToolkit.getStaticColorModel();
}
}
/* Fix for bug 4746122. Color and Font shouldn't be null */
}
}
}
}
return getGraphics(surfaceData,
}
}
}
/**
* Returns true if the event has been handled and should not be
* posted to Java.
*/
return false;
}
// The uses of this method imply that the incoming event is system-generated
public void run() {
}
if (focusLog.isLoggable(PlatformLogger.FINER) && (e instanceof FocusEvent)) focusLog.finer("Sending " + e);
}
/*
* Post an event to the event queue.
*/
// NOTE: This method may be called by privileged threads.
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
}
}
//fix for 6239938 : Choice drop-down does not disappear when it loses focus, on XToolkit
if (!prePostEvent(event)) {
//event hasn't been handled and must be posted to EventQueue
}
}
// overriden in XCanvasPeer
protected boolean doEraseBackground() {
return true;
}
// We need a version of setBackground that does not call repaint !!
// and one that does not get overridden. The problem is that in postInit
// we call setBackground and we dont have all the stuff initialized to
// do a full paint for most peers. So we cannot call setBackground in postInit.
try {
winBackground(c);
// fix for 6558510: handle sun.awt.noerasebackground flag,
// see doEraseBackground() and preInit() methods in XCanvasPeer
if (!doEraseBackground()) {
return;
}
// 6304250: XAWT: Items in choice show a blue border on OpenGL + Solaris10 when background color is set
// Note: When OGL is enabled, surfaceData.pixelFor() will not
// return a pixel value appropriate for passing to
// XSetWindowBackground(). Therefore, we will use the ColorModel
// for this component in order to calculate a pixel value from
// the given RGB value.
}
finally {
}
}
xSetBackground(c);
}
backgroundColor = c;
}
if (backgroundColor != null) {
c = backgroundColor;
c = parent.getWinBackground();
}
if (c instanceof SystemColor) {
}
return c;
}
public boolean isEmbedded() {
return embedded;
}
if (!isVisible()) {
return;
}
Graphics g = getGraphics();
if (g != null) {
try {
paint(g);
} finally {
g.dispose();
}
}
}
public void repaint() {
if (!isVisible()) {
return;
}
Graphics g = getGraphics();
if (g != null) {
try {
paint(g);
} finally {
g.dispose();
}
}
}
}
//used by Peers to avoid flickering withing paint()
protected void flush(){
try {
} finally {
}
}
// TBD: grab the pointer
}
super.handleExposeEvent(xev);
if (isEventDisabled(xev)) {
return;
}
int h = xe.get_height();
{
handleExposeEvent(target, x, y, w, h);
}
}
createPaintEvent(target, x, y, w, h);
}
}
}
int modifiers = 0;
}
}
}
}
}
//InputEvent.BUTTON_DOWN_MASK array is starting from BUTTON1_DOWN_MASK on index == 0.
// button currently reflects a real button number and starts from 1. (except NOBUTTON which is zero )
/* this is an attempt to refactor button IDs in : MouseEvent, InputEvent, XlibWrapper and XWindow.*/
//reflects a button number similar to MouseEvent.BUTTON1, 2, 3 etc.
//modifier should be added if :
// 1) current button is now still in PRESSED state (means that user just pressed mouse but not released yet) or
// 2) if Xsystem reports that "state" represents that button was just released. This only happens on RELEASE with 1,2,3 buttons.
// ONLY one of these conditions should be TRUE to add that modifier.
//exclude wheel buttons from adding their numbers as modifiers
if (!wheel_mouse) {
}
}
}
return modifiers;
}
int res = 0;
}
}
}
}
}
return res;
}
/**
* Returns true if this event is disabled and shouldn't be passed to Java.
* Default implementation returns false for all events.
*/
static int getRightButtonNumber() {
try {
}
finally {
}
}
return rbutton;
}
static int getMouseMovementSmudge() {
//TODO: It's possible to read corresponding settings
return AWT_MULTICLICK_SMUDGE;
}
super.handleButtonPressRelease(xev);
if (isEventDisabled(xev)) {
return;
}
long when;
int modifiers;
boolean popupTrigger = false;
int button=0;
boolean wheel_mouse = false;
/*
* Ignore the buttons above 20 due to the bit limit for
* InputEvent.BUTTON_DOWN_MASK.
* One more bit is reserved for FIRST_HIGH_BIT.
*/
return;
}
x = localXY.x;
y = localXY.y;
}
//Allow this mouse button to generate CLICK event on next ButtonRelease
/*
multiclick checking
*/
if (eventLog.isLoggable(PlatformLogger.FINEST)) eventLog.finest("lastWindow = " + lastWindow + ", lastButton "
+ XToolkit.getMultiClickTime());
if (lastWindow == this && lastButton == lbutton && (when - lastTime) < XToolkit.getMultiClickTime()) {
clickCount++;
} else {
clickCount = 1;
lastWindowRef = new WeakReference(this);
lastX = x;
lastY = y;
}
/*
Check for popup trigger !!
*/
popupTrigger = true;
} else {
popupTrigger = false;
}
}
// 4 and 5 buttons are usually considered assigned to a first wheel
wheel_mouse = true;
}
// mapping extra buttons to numbers starting from 4.
if ((button > XConstants.buttons[4]) && (!Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled())){
return;
}
button -= 2;
}
if (!wheel_mouse) {
xbe.get_x_root(),
xbe.get_y_root(),
((mouseButtonClickAllowed & XConstants.buttonsMask[lbutton]) != 0) ) // No up-button in the drag-state
{
x, y,
xbe.get_x_root(),
xbe.get_y_root(),
false, button));
}
}
else {
MouseWheelEvent mwe = new MouseWheelEvent((Component)getEventSource(),MouseEvent.MOUSE_WHEEL, jWhen,
x, y,
xbe.get_x_root(),
xbe.get_y_root(),
}
}
/* Update the state variable AFTER the CLICKED event post. */
/* Exclude this mouse button from allowed list.*/
}
}
super.handleMotionNotify(xev);
if (isEventDisabled(xev)) {
return;
}
int mouseKeyState = 0; //(xme.get_state() & (XConstants.buttonsMask[0] | XConstants.buttonsMask[1] | XConstants.buttonsMask[2]));
//this doesn't work for extra buttons because Xsystem is sending state==0 for every extra button event.
// we can't correct it in MouseEvent class as we done it with modifiers, because exact type (DRAG|MOVE)
// should be passed from XWindow.
for (int i = 0; i < buttonsNumber; i++){
// TODO : here is the bug in WM: extra buttons doesn't have state!=0 as they should.
if ((i != 4) && (i != 5)) {
}
}
int mouseEventType = 0;
if (isDragging) {
} else {
}
/*
Fix for 6176814 . Add multiclick checking.
*/
if (!(lastWindow == this &&
clickCount = 0;
lastTime = 0;
lastX = 0;
lastY = 0;
}
boolean popupTrigger = false;
x = localXY.x;
y = localXY.y;
}
/* Fix for 5039416.
* According to canvas.c we shouldn't post any MouseEvent if mouse is dragging and clickCount!=0.
*/
}
}
// REMIND: need to implement looking for disabled events
native boolean haveCurrentX11InputMethodInstance();
private boolean mouseAboveMe;
public boolean isMouseAbove() {
synchronized (getStateLock()) {
return mouseAboveMe;
}
}
synchronized (getStateLock()) {
}
}
setMouseAbove(true);
}
}
setMouseAbove(false);
}
}
super.handleXCrossingEvent(xev);
} else { // LeaveNotify:
}
// Skip event If it was caused by a grab
// This is needed because on displays with focus-follows-mouse on MousePress X system generates
// two XCrossing events with mode != NormalNotify. First of them notifies that the mouse has left
// current component. Second one notifies that it has entered into the same component.
// This looks like the window under the mouse has actually changed and Java handle these events
// accordingly. This leads to impossibility to make a double click on Component (6404708)
// 6404708 : need update cursor in accordance with skipping Leave/EnterNotify event
// whereas it doesn't need to handled further.
} else { // LeaveNotify:
}
return;
}
}
// X sends XCrossing to all hierarchy so if the edge of child equals to
// ancestor and mouse enters child, the ancestor will get an event too.
// From java point the event is bogus as ancestor is obscured, so if
// the child can get java event itself, we skip it on ancestor.
{
return;
}
}
// Remember old component with mouse to have the opportunity to send it MOUSE_EXITED.
if(!toplevel.isModalBlocked()){
// Change XAwtState's component mouse entered to the up-to-date one before requesting
// to update the cursor since XAwtState.getComponentMouseEntered() is used when the
// cursor is updated (in XGlobalCursorManager.findHeavyweightUnderCursor()).
} else { // LeaveNotify:
}
} else {
}
}
if (isEventDisabled(xev)) {
return;
}
int clickCount = 0;
boolean popupTrigger = false;
x = localXY.x;
y = localXY.y;
}
// This code tracks boundary crossing and ensures MOUSE_ENTER/EXIT
// are posted in alternate pairs
if (compWithMouse != null) {
}
}
}
super.handleConfigureNotifyEvent(xev);
if (isEventDisabled(xev)) {
return;
}
// if ( Check if it's a resize, a move, or a stacking order change )
// {
}
}
// }
}
super.handleMapNotifyEvent(xev);
if (isEventDisabled(xev)) {
return;
}
}
super.handleUnmapNotifyEvent(xev);
if (isEventDisabled(xev)) {
return;
}
}
keyEventLog.fine(" "+Long.toHexString(XlibWrapper.XKeycodeToKeysym(XToolkit.getDisplay(), ev.get_keycode(), 0))+
}
/**
Return unicode character or 0 if no correspondent character found.
Parameter is a keysym basically from keysymdef.h
XXX: how about vendor keys? Is there some with Unicode value and not in the list?
*/
}
}
}
}
//return (uni > 0? uni + 0x01000000 : 0);
}
keyEventLog.fine("XXXXXXXXXXXXXX javakeycode will be most probably:0x"+ Integer.toHexString(XKeysym.getJavaKeycodeOnly(ev)));
}
super.handleKeyPress(xev);
if (isEventDisabled(xev)) {
return;
}
}
// called directly from this package, unlike handleKeyRelease.
// un-final it if you need to override it in a subclass.
long keysym[] = new long[2];
int unicodeKey = 0;
}
if ( //TODO check if there's an active input method instance
// without calling a native method. Is it necessary though?
);
}
return;
}else {
keyEventLog.fine("--XWindow.java XIM did NOT process event, hex keysym:"+Long.toHexString(keysym[0])+"\n"+
}
}
}else {
// No input method instance found. For example, there's a Java Input Method.
// Produce do-it-yourself keysym and perhaps unicode character.
}
}
// Keysym should be converted to Unicode, if possible and necessary,
// and Java KeyEvent keycode should be calculated.
// For press we should post pressed & typed Java events.
//
// Press event might be not processed to this time because
// (1) either XIM could not handle it or
// (2) it was Latin 1:1 mapping.
//
jkc = new XKeysym.Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_UNDEFINED, java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN);
}
// Take the first keysym from a keysym array associated with the XKeyevent
// and convert it to Unicode. Then, even if a Java keycode for the keystroke
// is undefined, we still have a guess of what has been engraved on a keytop.
);
}
if( unicodeKey > 0 ) {
}
}
super.handleKeyRelease(xev);
if (isEventDisabled(xev)) {
return;
}
}
// un-private it if you need to call it from elsewhere
long keysym[] = new long[2];
int unicodeKey = 0;
}
// Keysym should be converted to Unicode, if possible and necessary,
// and Java KeyEvent keycode should be calculated.
// For release we should post released event.
//
jkc = new XKeysym.Keysym2JavaKeycode(java.awt.event.KeyEvent.VK_UNDEFINED, java.awt.event.KeyEvent.KEY_LOCATION_UNKNOWN);
}
);
}
// We obtain keysym from IM and derive unicodeKey from it for KeyPress only.
// We used to cache that value and retrieve it on KeyRelease,
// but in case for example of a dead key+vowel pair, a vowel after a deadkey
// might never be cached before.
// Also, switching between keyboard layouts, we might cache a wrong letter.
// That's why we use the same procedure as if there was no IM instance: do-it-yourself unicode.
// Take a first keysym from a keysym array associated with the XKeyevent
// and convert it to Unicode. Then, even if Java keycode for the keystroke
// is undefined, we still will have a guess of what was engraved on a keytop.
}
/*
* XmNiconic and Map/UnmapNotify (that XmNiconic relies on) are
* unreliable, since mapping changes can happen for a virtual desktop
* switch or MacOS style shading that became quite popular under X as
* well. Yes, it probably should not be this way, as it violates
* ICCCM, but reality is that quite a lot of window managers abuse
* mapping state.
*/
int getWMState() {
if (stateChanged) {
stateChanged = false;
try {
}
}
} finally {
}
}
return savedState;
}
/**
* Override this methods to get notifications when top-level window state changes. The state is
* meant in terms of ICCCM: WithdrawnState, IconicState, NormalState
*/
}
super.handlePropertyNotify(xev);
// State has changed, invalidate saved value
stateChanged = true;
}
}
}
if (width <= 0) {
width = 1;
}
if (height <= 0) {
height = 1;
}
this.x = x;
this.y = y;
// Fixed 6322593, 6304251, 6315137:
// XWindow's SurfaceData should be invalidated and recreated as part
// of the process of resizing the window
// see the evaluation of the bug 6304251 for more information
layout();
}
public void layout() {}
boolean isShowing() {
return visible;
}
boolean isResizable() {
return true;
}
boolean isLocationByPlatform() {
return false;
}
void updateSizeHints() {
}
long flags = XUtilConstants.PSize | (isLocationByPlatform() ? 0 : (XUtilConstants.PPosition | XUtilConstants.USPosition));
if (!isResizable()) {
} else {
}
}
void updateSizeHints(int x, int y) {
if (!isResizable()) {
} else {
}
}
void validateSurface() {
}
}
final void doValidateSurface() {
}
}
return surfaceData;
}
public void dispose() {
surfaceData = null;
}
destroy();
}
synchronized (target.getTreeLock()) {
}
// applets, embedded, etc - translate directly
// XXX: override in subclass?
}
try {
|| !(wpeer instanceof XDecoratedPeer)
{
}
// wpeer is an XDecoratedPeer not yet fully adopted by WM
0, 0);
}
return pt;
} finally {
}
}
}
}
int unicodeFromPrimaryKeysym, int extendedKeyCode)
{
if (event != 0) {
}
}
/* These two methods are actually applicable to toplevel windows only.
* However, the functionality is required by both the XWindowPeer and
* XWarningWindow, both of which have the XWindow as a common ancestor.
* See XWM.setMotifDecor() for details.
*/
mwm_hints = new PropMwmHints();
if (!XWM.XA_MWM_HINTS.getAtomData(getWindow(), mwm_hints.pData, MWMConstants.PROP_MWM_HINTS_ELEMENTS)) {
}
}
return mwm_hints;
}
}
}
protected final void initWMProtocols() {
}
/**
* Returns list of protocols which should be installed on this window.
* Descendants can override this method to add class-specific protocols
*/
// No protocols on simple window
return new XAtomList();
}
/**
* Indicates if the window is currently in the FSEM.
* Synchronization: state lock.
*/
private boolean fullScreenExclusiveModeState = false;
// Implementation of the X11ComponentPeer
synchronized (getStateLock()) {
}
}
public final boolean isFullScreenExclusiveMode() {
synchronized (getStateLock()) {
return fullScreenExclusiveModeState;
}
}
}