2053 // since it generates MOUSE_ENTERED/MOUSE_EXITED for frame and dialog. 2054 // (fix for 6390326) 2055 XBaseWindow target = XToolkit.windowToXWindow(xce.get_window()); 2056 grabLog.finer(" - Grab event target {0}", target); 2057 if (target != null && target != this) { 2058 target.dispatchEvent(xev); 2059 return; 2060 } 2061 } 2062 super.handleXCrossingEvent(xev); 2063 } 2064 2065 public void handleMotionNotify(XEvent xev) { 2066 XMotionEvent xme = xev.get_xmotion(); 2067 if (grabLog.isLoggable(PlatformLogger.FINE)) { 2068 grabLog.finer("{0}, when grabbed {1}, contains {2}", 2069 xme, isGrabbed(), containsGlobal(xme.get_x_root(), xme.get_y_root())); 2070 } 2071 if (isGrabbed()) { 2072 boolean dragging = false; 2073 final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons(); 2074 2075 for (int i = 0; i < buttonsNumber; i++){ 2076 // here is the bug in WM: extra buttons doesn't have state!=0 as they should. 2077 if ((i != 4) && (i != 5)){ 2078 dragging = dragging || ((xme.get_state() & XConstants.buttonsMask[i]) != 0); 2079 } 2080 } 2081 // When window is grabbed, all events are dispatched to 2082 // it. Retarget them to the corresponding windows (notice 2083 // that XBaseWindow.dispatchEvent does the opposite 2084 // translation) 2085 XBaseWindow target = XToolkit.windowToXWindow(xme.get_window()); 2086 if (dragging && pressTarget != target) { 2087 // for some reasons if we grab input MotionNotify for drag is reported with target 2088 // to underlying window, not to window on which we have initiated drag 2089 // so we need to retarget them. Here I use simplified logic which retarget all 2090 // such events to source of mouse press (or the grabber). It helps with fix for 6390326. 2091 // So, I do not want to implement complicated logic for better retargeting. 2092 target = pressTarget.isVisible() ? pressTarget : this; 2093 xme.set_window(target.getWindow()); 2094 Point localCoord = target.toLocal(xme.get_x_root(), xme.get_y_root()); 2095 xme.set_x(localCoord.x); 2096 xme.set_y(localCoord.y); 2097 } 2098 grabLog.finer(" - Grab event target {0}", target); | 2053 // since it generates MOUSE_ENTERED/MOUSE_EXITED for frame and dialog. 2054 // (fix for 6390326) 2055 XBaseWindow target = XToolkit.windowToXWindow(xce.get_window()); 2056 grabLog.finer(" - Grab event target {0}", target); 2057 if (target != null && target != this) { 2058 target.dispatchEvent(xev); 2059 return; 2060 } 2061 } 2062 super.handleXCrossingEvent(xev); 2063 } 2064 2065 public void handleMotionNotify(XEvent xev) { 2066 XMotionEvent xme = xev.get_xmotion(); 2067 if (grabLog.isLoggable(PlatformLogger.FINE)) { 2068 grabLog.finer("{0}, when grabbed {1}, contains {2}", 2069 xme, isGrabbed(), containsGlobal(xme.get_x_root(), xme.get_y_root())); 2070 } 2071 if (isGrabbed()) { 2072 boolean dragging = false; 2073 final int buttonsNumber = XToolkit.getNumberOfButtonsForMask(); 2074 2075 for (int i = 0; i < buttonsNumber; i++){ 2076 // here is the bug in WM: extra buttons doesn't have state!=0 as they should. 2077 if ((i != 4) && (i != 5)){ 2078 dragging = dragging || ((xme.get_state() & XlibUtil.getButtonMask(i + 1)) != 0); 2079 } 2080 } 2081 // When window is grabbed, all events are dispatched to 2082 // it. Retarget them to the corresponding windows (notice 2083 // that XBaseWindow.dispatchEvent does the opposite 2084 // translation) 2085 XBaseWindow target = XToolkit.windowToXWindow(xme.get_window()); 2086 if (dragging && pressTarget != target) { 2087 // for some reasons if we grab input MotionNotify for drag is reported with target 2088 // to underlying window, not to window on which we have initiated drag 2089 // so we need to retarget them. Here I use simplified logic which retarget all 2090 // such events to source of mouse press (or the grabber). It helps with fix for 6390326. 2091 // So, I do not want to implement complicated logic for better retargeting. 2092 target = pressTarget.isVisible() ? pressTarget : this; 2093 xme.set_window(target.getWindow()); 2094 Point localCoord = target.toLocal(xme.get_x_root(), xme.get_y_root()); 2095 xme.set_x(localCoord.x); 2096 xme.set_y(localCoord.y); 2097 } 2098 grabLog.finer(" - Grab event target {0}", target); |