42
43 import sun.java2d.SunGraphics2D;
44 import sun.java2d.SurfaceData;
45
46 public class XWindow extends XBaseWindow implements X11ComponentPeer {
47 private static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XWindow");
48 private static PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XWindow");
49 private static PlatformLogger eventLog = PlatformLogger.getLogger("sun.awt.X11.event.XWindow");
50 private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XWindow");
51 private static PlatformLogger keyEventLog = PlatformLogger.getLogger("sun.awt.X11.kye.XWindow");
52 /* If a motion comes in while a multi-click is pending,
53 * allow a smudge factor so that moving the mouse by a small
54 * amount does not wipe out the multi-click state variables.
55 */
56 private final static int AWT_MULTICLICK_SMUDGE = 4;
57 // ButtonXXX events stuff
58 static int rbutton = 0;
59 static int lastX = 0, lastY = 0;
60 static long lastTime = 0;
61 static long lastButton = 0;
62 static WeakReference lastWindowRef = null;
63 static int clickCount = 0;
64
65 // used to check if we need to re-create surfaceData.
66 int oldWidth = -1;
67 int oldHeight = -1;
68
69 protected PropMwmHints mwm_hints;
70 protected static XAtom wm_protocols;
71 protected static XAtom wm_delete_window;
72 protected static XAtom wm_take_focus;
73
74 private boolean stateChanged; // Indicates whether the value on savedState is valid
75 private int savedState; // Holds last known state of the top-level window
76
77 XWindowAttributesData winAttr;
78
79 protected X11GraphicsConfig graphicsConfig;
80 protected AwtGraphicsConfigData graphicsConfigData;
81
82 private boolean reparented;
675 * One more bit is reserved for FIRST_HIGH_BIT.
676 */
677 if (lbutton > SunToolkit.MAX_BUTTONS_SUPPORTED) {
678 return;
679 }
680 int type = xev.get_type();
681 when = xbe.get_time();
682 long jWhen = XToolkit.nowMillisUTC_offset(when);
683
684 int x = xbe.get_x();
685 int y = xbe.get_y();
686 if (xev.get_xany().get_window() != window) {
687 Point localXY = toLocal(xbe.get_x_root(), xbe.get_y_root());
688 x = localXY.x;
689 y = localXY.y;
690 }
691
692 if (type == XConstants.ButtonPress) {
693 //Allow this mouse button to generate CLICK event on next ButtonRelease
694 mouseButtonClickAllowed |= XlibUtil.getButtonMask(lbutton);
695 XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null);
696 /*
697 multiclick checking
698 */
699 if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
700 eventLog.finest("lastWindow = " + lastWindow + ", lastButton "
701 + lastButton + ", lastTime " + lastTime + ", multiClickTime "
702 + XToolkit.getMultiClickTime());
703 }
704 if (lastWindow == this && lastButton == lbutton && (when - lastTime) < XToolkit.getMultiClickTime()) {
705 clickCount++;
706 } else {
707 clickCount = 1;
708 lastWindowRef = new WeakReference(this);
709 lastButton = lbutton;
710 lastX = x;
711 lastY = y;
712 }
713 lastTime = when;
714
715
716 /*
717 Check for popup trigger !!
718 */
719 if (lbutton == getRightButtonNumber() || lbutton > 2) {
720 popupTrigger = true;
721 } else {
722 popupTrigger = false;
723 }
724 }
725
726 button = XConstants.buttons[lbutton - 1];
727 // 4 and 5 buttons are usually considered assigned to a first wheel
728 if (lbutton == XConstants.buttons[3] ||
803 // TODO : here is the bug in WM: extra buttons doesn't have state!=0 as they should.
804 if ((i != 4) && (i != 5)) {
805 mouseKeyState = mouseKeyState | (xme.get_state() & XlibUtil.getButtonMask(i + 1));
806 }
807 }
808
809 boolean isDragging = (mouseKeyState != 0);
810 int mouseEventType = 0;
811
812 if (isDragging) {
813 mouseEventType = MouseEvent.MOUSE_DRAGGED;
814 } else {
815 mouseEventType = MouseEvent.MOUSE_MOVED;
816 }
817
818 /*
819 Fix for 6176814 . Add multiclick checking.
820 */
821 int x = xme.get_x();
822 int y = xme.get_y();
823 XWindow lastWindow = (lastWindowRef != null) ? ((XWindow)lastWindowRef.get()):(null);
824
825 if (!(lastWindow == this &&
826 (xme.get_time() - lastTime) < XToolkit.getMultiClickTime() &&
827 (Math.abs(lastX - x) < AWT_MULTICLICK_SMUDGE &&
828 Math.abs(lastY - y) < AWT_MULTICLICK_SMUDGE))) {
829 clickCount = 0;
830 lastWindowRef = null;
831 mouseButtonClickAllowed = 0;
832 lastTime = 0;
833 lastX = 0;
834 lastY = 0;
835 }
836
837 long jWhen = XToolkit.nowMillisUTC_offset(xme.get_time());
838 int modifiers = getModifiers(xme.get_state(), 0, 0);
839 boolean popupTrigger = false;
840
841 Component source = getEventSource();
842
843 if (xme.get_window() != window) {
|
42
43 import sun.java2d.SunGraphics2D;
44 import sun.java2d.SurfaceData;
45
46 public class XWindow extends XBaseWindow implements X11ComponentPeer {
47 private static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XWindow");
48 private static PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XWindow");
49 private static PlatformLogger eventLog = PlatformLogger.getLogger("sun.awt.X11.event.XWindow");
50 private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XWindow");
51 private static PlatformLogger keyEventLog = PlatformLogger.getLogger("sun.awt.X11.kye.XWindow");
52 /* If a motion comes in while a multi-click is pending,
53 * allow a smudge factor so that moving the mouse by a small
54 * amount does not wipe out the multi-click state variables.
55 */
56 private final static int AWT_MULTICLICK_SMUDGE = 4;
57 // ButtonXXX events stuff
58 static int rbutton = 0;
59 static int lastX = 0, lastY = 0;
60 static long lastTime = 0;
61 static long lastButton = 0;
62 static WeakReference<XWindow> lastWindowRef = null;
63 static int clickCount = 0;
64
65 // used to check if we need to re-create surfaceData.
66 int oldWidth = -1;
67 int oldHeight = -1;
68
69 protected PropMwmHints mwm_hints;
70 protected static XAtom wm_protocols;
71 protected static XAtom wm_delete_window;
72 protected static XAtom wm_take_focus;
73
74 private boolean stateChanged; // Indicates whether the value on savedState is valid
75 private int savedState; // Holds last known state of the top-level window
76
77 XWindowAttributesData winAttr;
78
79 protected X11GraphicsConfig graphicsConfig;
80 protected AwtGraphicsConfigData graphicsConfigData;
81
82 private boolean reparented;
675 * One more bit is reserved for FIRST_HIGH_BIT.
676 */
677 if (lbutton > SunToolkit.MAX_BUTTONS_SUPPORTED) {
678 return;
679 }
680 int type = xev.get_type();
681 when = xbe.get_time();
682 long jWhen = XToolkit.nowMillisUTC_offset(when);
683
684 int x = xbe.get_x();
685 int y = xbe.get_y();
686 if (xev.get_xany().get_window() != window) {
687 Point localXY = toLocal(xbe.get_x_root(), xbe.get_y_root());
688 x = localXY.x;
689 y = localXY.y;
690 }
691
692 if (type == XConstants.ButtonPress) {
693 //Allow this mouse button to generate CLICK event on next ButtonRelease
694 mouseButtonClickAllowed |= XlibUtil.getButtonMask(lbutton);
695 XWindow lastWindow = (lastWindowRef != null) ? (lastWindowRef.get()):(null);
696 /*
697 multiclick checking
698 */
699 if (eventLog.isLoggable(PlatformLogger.Level.FINEST)) {
700 eventLog.finest("lastWindow = " + lastWindow + ", lastButton "
701 + lastButton + ", lastTime " + lastTime + ", multiClickTime "
702 + XToolkit.getMultiClickTime());
703 }
704 if (lastWindow == this && lastButton == lbutton && (when - lastTime) < XToolkit.getMultiClickTime()) {
705 clickCount++;
706 } else {
707 clickCount = 1;
708 lastWindowRef = new WeakReference<>(this);
709 lastButton = lbutton;
710 lastX = x;
711 lastY = y;
712 }
713 lastTime = when;
714
715
716 /*
717 Check for popup trigger !!
718 */
719 if (lbutton == getRightButtonNumber() || lbutton > 2) {
720 popupTrigger = true;
721 } else {
722 popupTrigger = false;
723 }
724 }
725
726 button = XConstants.buttons[lbutton - 1];
727 // 4 and 5 buttons are usually considered assigned to a first wheel
728 if (lbutton == XConstants.buttons[3] ||
803 // TODO : here is the bug in WM: extra buttons doesn't have state!=0 as they should.
804 if ((i != 4) && (i != 5)) {
805 mouseKeyState = mouseKeyState | (xme.get_state() & XlibUtil.getButtonMask(i + 1));
806 }
807 }
808
809 boolean isDragging = (mouseKeyState != 0);
810 int mouseEventType = 0;
811
812 if (isDragging) {
813 mouseEventType = MouseEvent.MOUSE_DRAGGED;
814 } else {
815 mouseEventType = MouseEvent.MOUSE_MOVED;
816 }
817
818 /*
819 Fix for 6176814 . Add multiclick checking.
820 */
821 int x = xme.get_x();
822 int y = xme.get_y();
823 XWindow lastWindow = (lastWindowRef != null) ? (lastWindowRef.get()):(null);
824
825 if (!(lastWindow == this &&
826 (xme.get_time() - lastTime) < XToolkit.getMultiClickTime() &&
827 (Math.abs(lastX - x) < AWT_MULTICLICK_SMUDGE &&
828 Math.abs(lastY - y) < AWT_MULTICLICK_SMUDGE))) {
829 clickCount = 0;
830 lastWindowRef = null;
831 mouseButtonClickAllowed = 0;
832 lastTime = 0;
833 lastX = 0;
834 lastY = 0;
835 }
836
837 long jWhen = XToolkit.nowMillisUTC_offset(xme.get_time());
838 int modifiers = getModifiers(xme.get_state(), 0, 0);
839 boolean popupTrigger = false;
840
841 Component source = getEventSource();
842
843 if (xme.get_window() != window) {
|