jdk/src/solaris/classes/sun/awt/X11/XWindow.java
changeset 22584 eed64ee05369
parent 21278 ef8a3a2a72f2
child 23276 add6f5c93bc6
equal deleted inserted replaced
22583:e7d5af0b11e9 22584:eed64ee05369
     1 /*
     1 /*
     2  * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   198         }
   198         }
   199         params.putIfNull(BORDER_PIXEL, Long.valueOf(0));
   199         params.putIfNull(BORDER_PIXEL, Long.valueOf(0));
   200         getColorModel(); // fix 4948833: this call forces the color map to be initialized
   200         getColorModel(); // fix 4948833: this call forces the color map to be initialized
   201         params.putIfNull(COLORMAP, gData.get_awt_cmap());
   201         params.putIfNull(COLORMAP, gData.get_awt_cmap());
   202         params.putIfNull(DEPTH, gData.get_awt_depth());
   202         params.putIfNull(DEPTH, gData.get_awt_depth());
   203         params.putIfNull(VISUAL_CLASS, Integer.valueOf((int)XConstants.InputOutput));
   203         params.putIfNull(VISUAL_CLASS, Integer.valueOf(XConstants.InputOutput));
   204         params.putIfNull(VISUAL, visInfo.get_visual());
   204         params.putIfNull(VISUAL, visInfo.get_visual());
   205         params.putIfNull(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWEventMask | XConstants.CWColormap);
   205         params.putIfNull(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWEventMask | XConstants.CWColormap);
   206         Long parentWindow = (Long)params.get(PARENT_WINDOW);
   206         Long parentWindow = (Long)params.get(PARENT_WINDOW);
   207         if (parentWindow == null || parentWindow.longValue() == 0) {
   207         if (parentWindow == null || parentWindow.longValue() == 0) {
   208             XToolkit.awtLock();
   208             XToolkit.awtLock();
   348     }
   348     }
   349 
   349 
   350     Graphics getGraphics(SurfaceData surfData, Color afore, Color aback, Font afont) {
   350     Graphics getGraphics(SurfaceData surfData, Color afore, Color aback, Font afont) {
   351         if (surfData == null) return null;
   351         if (surfData == null) return null;
   352 
   352 
   353         Component target = (Component) this.target;
   353         Component target = this.target;
   354 
   354 
   355         /* Fix for bug 4746122. Color and Font shouldn't be null */
   355         /* Fix for bug 4746122. Color and Font shouldn't be null */
   356         Color bgColor = aback;
   356         Color bgColor = aback;
   357         if (bgColor == null) {
   357         if (bgColor == null) {
   358             bgColor = SystemColor.window;
   358             bgColor = SystemColor.window;
   546         int x = xe.get_x();
   546         int x = xe.get_x();
   547         int y = xe.get_y();
   547         int y = xe.get_y();
   548         int w = xe.get_width();
   548         int w = xe.get_width();
   549         int h = xe.get_height();
   549         int h = xe.get_height();
   550 
   550 
   551         Component target = (Component)getEventSource();
   551         Component target = getEventSource();
   552         AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
   552         AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
   553 
   553 
   554         if (!compAccessor.getIgnoreRepaint(target)
   554         if (!compAccessor.getIgnoreRepaint(target)
   555             && compAccessor.getWidth(target) != 0
   555             && compAccessor.getWidth(target) != 0
   556             && compAccessor.getHeight(target) != 0)
   556             && compAccessor.getHeight(target) != 0)
   738             button -= 2;
   738             button -= 2;
   739         }
   739         }
   740         modifiers = getModifiers(xbe.get_state(),button,0, type, wheel_mouse);
   740         modifiers = getModifiers(xbe.get_state(),button,0, type, wheel_mouse);
   741 
   741 
   742         if (!wheel_mouse) {
   742         if (!wheel_mouse) {
   743             MouseEvent me = new MouseEvent((Component)getEventSource(),
   743             MouseEvent me = new MouseEvent(getEventSource(),
   744                                            type == XConstants.ButtonPress ? MouseEvent.MOUSE_PRESSED : MouseEvent.MOUSE_RELEASED,
   744                                            type == XConstants.ButtonPress ? MouseEvent.MOUSE_PRESSED : MouseEvent.MOUSE_RELEASED,
   745                                            jWhen,modifiers, x, y,
   745                                            jWhen,modifiers, x, y,
   746                                            xbe.get_x_root(),
   746                                            xbe.get_x_root(),
   747                                            xbe.get_y_root(),
   747                                            xbe.get_y_root(),
   748                                            clickCount,popupTrigger,button);
   748                                            clickCount,popupTrigger,button);
   750             postEventToEventQueue(me);
   750             postEventToEventQueue(me);
   751 
   751 
   752             if ((type == XConstants.ButtonRelease) &&
   752             if ((type == XConstants.ButtonRelease) &&
   753                 ((mouseButtonClickAllowed & XlibUtil.getButtonMask(lbutton)) != 0) ) // No up-button in the drag-state
   753                 ((mouseButtonClickAllowed & XlibUtil.getButtonMask(lbutton)) != 0) ) // No up-button in the drag-state
   754             {
   754             {
   755                 postEventToEventQueue(me = new MouseEvent((Component)getEventSource(),
   755                 postEventToEventQueue(me = new MouseEvent(getEventSource(),
   756                                                      MouseEvent.MOUSE_CLICKED,
   756                                                      MouseEvent.MOUSE_CLICKED,
   757                                                      jWhen,
   757                                                      jWhen,
   758                                                      modifiers,
   758                                                      modifiers,
   759                                                      x, y,
   759                                                      x, y,
   760                                                      xbe.get_x_root(),
   760                                                      xbe.get_x_root(),
   764             }
   764             }
   765 
   765 
   766         }
   766         }
   767         else {
   767         else {
   768             if (xev.get_type() == XConstants.ButtonPress) {
   768             if (xev.get_type() == XConstants.ButtonPress) {
   769                 MouseWheelEvent mwe = new MouseWheelEvent((Component)getEventSource(),MouseEvent.MOUSE_WHEEL, jWhen,
   769                 MouseWheelEvent mwe = new MouseWheelEvent(getEventSource(),MouseEvent.MOUSE_WHEEL, jWhen,
   770                                                           modifiers,
   770                                                           modifiers,
   771                                                           x, y,
   771                                                           x, y,
   772                                                           xbe.get_x_root(),
   772                                                           xbe.get_x_root(),
   773                                                           xbe.get_y_root(),
   773                                                           xbe.get_y_root(),
   774                                                           1,false,MouseWheelEvent.WHEEL_UNIT_SCROLL,
   774                                                           1,false,MouseWheelEvent.WHEEL_UNIT_SCROLL,
   835 
   835 
   836         long jWhen = XToolkit.nowMillisUTC_offset(xme.get_time());
   836         long jWhen = XToolkit.nowMillisUTC_offset(xme.get_time());
   837         int modifiers = getModifiers(xme.get_state(), 0, 0);
   837         int modifiers = getModifiers(xme.get_state(), 0, 0);
   838         boolean popupTrigger = false;
   838         boolean popupTrigger = false;
   839 
   839 
   840         Component source = (Component)getEventSource();
   840         Component source = getEventSource();
   841 
   841 
   842         if (xme.get_window() != window) {
   842         if (xme.get_window() != window) {
   843             Point localXY = toLocal(xme.get_x_root(), xme.get_y_root());
   843             Point localXY = toLocal(xme.get_x_root(), xme.get_y_root());
   844             x = localXY.x;
   844             x = localXY.x;
   845             y = localXY.y;
   845             y = localXY.y;
  1109                 return;
  1109                 return;
  1110             }else {
  1110             }else {
  1111                 unicodeKey = keysymToUnicode( keysym[0], ev.get_state() );
  1111                 unicodeKey = keysymToUnicode( keysym[0], ev.get_state() );
  1112                 if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
  1112                 if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
  1113                     keyEventLog.fine("--XWindow.java XIM did NOT process event, hex keysym:"+Long.toHexString(keysym[0])+"\n"+
  1113                     keyEventLog.fine("--XWindow.java XIM did NOT process event, hex keysym:"+Long.toHexString(keysym[0])+"\n"+
  1114                                      "                                         unicode key:"+Integer.toHexString((int)unicodeKey));
  1114                                      "                                         unicode key:"+Integer.toHexString(unicodeKey));
  1115                 }
  1115                 }
  1116             }
  1116             }
  1117         }else  {
  1117         }else  {
  1118             // No input method instance found. For example, there's a Java Input Method.
  1118             // No input method instance found. For example, there's a Java Input Method.
  1119             // Produce do-it-yourself keysym and perhaps unicode character.
  1119             // Produce do-it-yourself keysym and perhaps unicode character.
  1120             keysym[0] = xkeycodeToKeysym(ev);
  1120             keysym[0] = xkeycodeToKeysym(ev);
  1121             unicodeKey = keysymToUnicode( keysym[0], ev.get_state() );
  1121             unicodeKey = keysymToUnicode( keysym[0], ev.get_state() );
  1122             if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
  1122             if (keyEventLog.isLoggable(PlatformLogger.Level.FINE)) {
  1123                 keyEventLog.fine("--XWindow.java XIM is absent;             hex keysym:"+Long.toHexString(keysym[0])+"\n"+
  1123                 keyEventLog.fine("--XWindow.java XIM is absent;             hex keysym:"+Long.toHexString(keysym[0])+"\n"+
  1124                                  "                                         unicode key:"+Integer.toHexString((int)unicodeKey));
  1124                                  "                                         unicode key:"+Integer.toHexString(unicodeKey));
  1125             }
  1125             }
  1126         }
  1126         }
  1127         // Keysym should be converted to Unicode, if possible and necessary,
  1127         // Keysym should be converted to Unicode, if possible and necessary,
  1128         // and Java KeyEvent keycode should be calculated.
  1128         // and Java KeyEvent keycode should be calculated.
  1129         // For press we should post pressed & typed Java events.
  1129         // For press we should post pressed & typed Java events.
  1464 
  1464 
  1465     {
  1465     {
  1466         long jWhen = XToolkit.nowMillisUTC_offset(when);
  1466         long jWhen = XToolkit.nowMillisUTC_offset(when);
  1467         int modifiers = getModifiers(state, 0, keyCode);
  1467         int modifiers = getModifiers(state, 0, keyCode);
  1468 
  1468 
  1469         KeyEvent ke = new KeyEvent((Component)getEventSource(), id, jWhen,
  1469         KeyEvent ke = new KeyEvent(getEventSource(), id, jWhen,
  1470                                    modifiers, keyCode, (char)keyChar, keyLocation);
  1470                                    modifiers, keyCode, (char)keyChar, keyLocation);
  1471         if (event != 0) {
  1471         if (event != 0) {
  1472             byte[] data = Native.toBytes(event, eventSize);
  1472             byte[] data = Native.toBytes(event, eventSize);
  1473             setBData(ke, data);
  1473             setBData(ke, data);
  1474         }
  1474         }