176 initGraphicsConfiguration(); |
176 initGraphicsConfiguration(); |
177 |
177 |
178 AwtGraphicsConfigData gData = getGraphicsConfigurationData(); |
178 AwtGraphicsConfigData gData = getGraphicsConfigurationData(); |
179 X11GraphicsConfig config = (X11GraphicsConfig) getGraphicsConfiguration(); |
179 X11GraphicsConfig config = (X11GraphicsConfig) getGraphicsConfiguration(); |
180 XVisualInfo visInfo = gData.get_awt_visInfo(); |
180 XVisualInfo visInfo = gData.get_awt_visInfo(); |
181 params.putIfNull(EVENT_MASK, KeyPressMask | KeyReleaseMask |
181 params.putIfNull(EVENT_MASK, XConstants.KeyPressMask | XConstants.KeyReleaseMask |
182 | FocusChangeMask | ButtonPressMask | ButtonReleaseMask |
182 | XConstants.FocusChangeMask | XConstants.ButtonPressMask | XConstants.ButtonReleaseMask |
183 | EnterWindowMask | LeaveWindowMask | PointerMotionMask |
183 | XConstants.EnterWindowMask | XConstants.LeaveWindowMask | XConstants.PointerMotionMask |
184 | ButtonMotionMask | ExposureMask | StructureNotifyMask); |
184 | XConstants.ButtonMotionMask | XConstants.ExposureMask | XConstants.StructureNotifyMask); |
185 |
185 |
186 if (target != null) { |
186 if (target != null) { |
187 params.putIfNull(BOUNDS, target.getBounds()); |
187 params.putIfNull(BOUNDS, target.getBounds()); |
188 } else { |
188 } else { |
189 params.putIfNull(BOUNDS, new Rectangle(0, 0, MIN_SIZE, MIN_SIZE)); |
189 params.putIfNull(BOUNDS, new Rectangle(0, 0, MIN_SIZE, MIN_SIZE)); |
190 } |
190 } |
191 params.putIfNull(BORDER_PIXEL, Long.valueOf(0)); |
191 params.putIfNull(BORDER_PIXEL, Long.valueOf(0)); |
192 getColorModel(); // fix 4948833: this call forces the color map to be initialized |
192 getColorModel(); // fix 4948833: this call forces the color map to be initialized |
193 params.putIfNull(COLORMAP, gData.get_awt_cmap()); |
193 params.putIfNull(COLORMAP, gData.get_awt_cmap()); |
194 params.putIfNull(DEPTH, gData.get_awt_depth()); |
194 params.putIfNull(DEPTH, gData.get_awt_depth()); |
195 params.putIfNull(VISUAL_CLASS, Integer.valueOf((int)XlibWrapper.InputOutput)); |
195 params.putIfNull(VISUAL_CLASS, Integer.valueOf((int)XConstants.InputOutput)); |
196 params.putIfNull(VISUAL, visInfo.get_visual()); |
196 params.putIfNull(VISUAL, visInfo.get_visual()); |
197 params.putIfNull(VALUE_MASK, XlibWrapper.CWBorderPixel | XlibWrapper.CWEventMask | XlibWrapper.CWColormap); |
197 params.putIfNull(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWEventMask | XConstants.CWColormap); |
198 Long parentWindow = (Long)params.get(PARENT_WINDOW); |
198 Long parentWindow = (Long)params.get(PARENT_WINDOW); |
199 if (parentWindow == null || parentWindow.longValue() == 0) { |
199 if (parentWindow == null || parentWindow.longValue() == 0) { |
200 XToolkit.awtLock(); |
200 XToolkit.awtLock(); |
201 try { |
201 try { |
202 int screen = visInfo.get_screen(); |
202 int screen = visInfo.get_screen(); |
551 } |
551 } |
552 |
552 |
553 static int getModifiers(int state, int button, int keyCode) { |
553 static int getModifiers(int state, int button, int keyCode) { |
554 int modifiers = 0; |
554 int modifiers = 0; |
555 |
555 |
556 if (((state & XlibWrapper.ShiftMask) != 0) ^ (keyCode == KeyEvent.VK_SHIFT)) { |
556 if (((state & XConstants.ShiftMask) != 0) ^ (keyCode == KeyEvent.VK_SHIFT)) { |
557 modifiers |= InputEvent.SHIFT_DOWN_MASK; |
557 modifiers |= InputEvent.SHIFT_DOWN_MASK; |
558 } |
558 } |
559 if (((state & XlibWrapper.ControlMask) != 0) ^ (keyCode == KeyEvent.VK_CONTROL)) { |
559 if (((state & XConstants.ControlMask) != 0) ^ (keyCode == KeyEvent.VK_CONTROL)) { |
560 modifiers |= InputEvent.CTRL_DOWN_MASK; |
560 modifiers |= InputEvent.CTRL_DOWN_MASK; |
561 } |
561 } |
562 if (((state & XToolkit.metaMask) != 0) ^ (keyCode == KeyEvent.VK_META)) { |
562 if (((state & XToolkit.metaMask) != 0) ^ (keyCode == KeyEvent.VK_META)) { |
563 modifiers |= InputEvent.META_DOWN_MASK; |
563 modifiers |= InputEvent.META_DOWN_MASK; |
564 } |
564 } |
566 modifiers |= InputEvent.ALT_DOWN_MASK; |
566 modifiers |= InputEvent.ALT_DOWN_MASK; |
567 } |
567 } |
568 if (((state & XToolkit.modeSwitchMask) != 0) ^ (keyCode == KeyEvent.VK_ALT_GRAPH)) { |
568 if (((state & XToolkit.modeSwitchMask) != 0) ^ (keyCode == KeyEvent.VK_ALT_GRAPH)) { |
569 modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK; |
569 modifiers |= InputEvent.ALT_GRAPH_DOWN_MASK; |
570 } |
570 } |
571 if (((state & XlibWrapper.Button1Mask) != 0) ^ (button == MouseEvent.BUTTON1)) { |
571 if (((state & XConstants.Button1Mask) != 0) ^ (button == MouseEvent.BUTTON1)) { |
572 modifiers |= InputEvent.BUTTON1_DOWN_MASK; |
572 modifiers |= InputEvent.BUTTON1_DOWN_MASK; |
573 } |
573 } |
574 if (((state & XlibWrapper.Button2Mask) != 0) ^ (button == MouseEvent.BUTTON2)) { |
574 if (((state & XConstants.Button2Mask) != 0) ^ (button == MouseEvent.BUTTON2)) { |
575 modifiers |= InputEvent.BUTTON2_DOWN_MASK; |
575 modifiers |= InputEvent.BUTTON2_DOWN_MASK; |
576 } |
576 } |
577 if (((state & XlibWrapper.Button3Mask) != 0) ^ (button == MouseEvent.BUTTON3)) { |
577 if (((state & XConstants.Button3Mask) != 0) ^ (button == MouseEvent.BUTTON3)) { |
578 modifiers |= InputEvent.BUTTON3_DOWN_MASK; |
578 modifiers |= InputEvent.BUTTON3_DOWN_MASK; |
579 } |
579 } |
580 return modifiers; |
580 return modifiers; |
581 } |
581 } |
582 |
582 |
583 static int getXModifiers(AWTKeyStroke stroke) { |
583 static int getXModifiers(AWTKeyStroke stroke) { |
584 int mods = stroke.getModifiers(); |
584 int mods = stroke.getModifiers(); |
585 int res = 0; |
585 int res = 0; |
586 if ((mods & (InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK)) != 0) { |
586 if ((mods & (InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK)) != 0) { |
587 res |= XToolkit.ShiftMask; |
587 res |= XConstants.ShiftMask; |
588 } |
588 } |
589 if ((mods & (InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK)) != 0) { |
589 if ((mods & (InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK)) != 0) { |
590 res |= XToolkit.ControlMask; |
590 res |= XConstants.ControlMask; |
591 } |
591 } |
592 if ((mods & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK)) != 0) { |
592 if ((mods & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK)) != 0) { |
593 res |= XToolkit.altMask; |
593 res |= XToolkit.altMask; |
594 } |
594 } |
595 if ((mods & (InputEvent.META_DOWN_MASK | InputEvent.META_MASK)) != 0) { |
595 if ((mods & (InputEvent.META_DOWN_MASK | InputEvent.META_MASK)) != 0) { |
600 } |
600 } |
601 return res; |
601 return res; |
602 } |
602 } |
603 |
603 |
604 private static int getButtonMask(long mouseButton) { |
604 private static int getButtonMask(long mouseButton) { |
605 if (mouseButton == XlibWrapper.Button1) { |
605 if (mouseButton == XConstants.Button1) { |
606 return XlibWrapper.Button1Mask; |
606 return XConstants.Button1Mask; |
607 } else if (mouseButton == XlibWrapper.Button2) { |
607 } else if (mouseButton == XConstants.Button2) { |
608 return XlibWrapper.Button2Mask; |
608 return XConstants.Button2Mask; |
609 } else if (mouseButton == XlibWrapper.Button3) { |
609 } else if (mouseButton == XConstants.Button3) { |
610 return XlibWrapper.Button3Mask; |
610 return XConstants.Button3Mask; |
611 } |
611 } |
612 return 0; |
612 return 0; |
613 } |
613 } |
614 |
614 |
615 /** |
615 /** |
687 } else { |
687 } else { |
688 popupTrigger = false; |
688 popupTrigger = false; |
689 } |
689 } |
690 } |
690 } |
691 |
691 |
692 if (lbutton == XlibWrapper.Button1) |
692 if (lbutton == XConstants.Button1) |
693 button = MouseEvent.BUTTON1; |
693 button = MouseEvent.BUTTON1; |
694 else if (lbutton == XlibWrapper.Button2 ) |
694 else if (lbutton == XConstants.Button2 ) |
695 button = MouseEvent.BUTTON2; |
695 button = MouseEvent.BUTTON2; |
696 else if (lbutton == XlibWrapper.Button3) |
696 else if (lbutton == XConstants.Button3) |
697 button = MouseEvent.BUTTON3; |
697 button = MouseEvent.BUTTON3; |
698 else if (lbutton == XlibWrapper.Button4) { |
698 else if (lbutton == XConstants.Button4) { |
699 button = 4; |
699 button = 4; |
700 wheel_mouse = true; |
700 wheel_mouse = true; |
701 } else if (lbutton == XlibWrapper.Button5) { |
701 } else if (lbutton == XConstants.Button5) { |
702 button = 5; |
702 button = 5; |
703 wheel_mouse = true; |
703 wheel_mouse = true; |
704 } |
704 } |
705 |
705 |
706 modifiers = getModifiers(xbe.get_state(),button,0); |
706 modifiers = getModifiers(xbe.get_state(),button,0); |
707 |
707 |
708 if (!wheel_mouse) { |
708 if (!wheel_mouse) { |
709 MouseEvent me = new MouseEvent((Component)getEventSource(), |
709 MouseEvent me = new MouseEvent((Component)getEventSource(), |
710 type == XlibWrapper.ButtonPress ? MouseEvent.MOUSE_PRESSED : MouseEvent.MOUSE_RELEASED, |
710 type == XConstants.ButtonPress ? MouseEvent.MOUSE_PRESSED : MouseEvent.MOUSE_RELEASED, |
711 jWhen,modifiers, x, y, |
711 jWhen,modifiers, x, y, |
712 xbe.get_x_root(), |
712 xbe.get_x_root(), |
713 xbe.get_y_root(), |
713 xbe.get_y_root(), |
714 clickCount,popupTrigger,button); |
714 clickCount,popupTrigger,button); |
715 |
715 |
716 postEventToEventQueue(me); |
716 postEventToEventQueue(me); |
717 |
717 |
718 if (((mouseDragState & getButtonMask(lbutton)) == 0) && // No up-button in the drag-state |
718 if (((mouseDragState & getButtonMask(lbutton)) == 0) && // No up-button in the drag-state |
719 (type == XlibWrapper.ButtonRelease)) |
719 (type == XConstants.ButtonRelease)) |
720 { |
720 { |
721 postEventToEventQueue(me = new MouseEvent((Component)getEventSource(), |
721 postEventToEventQueue(me = new MouseEvent((Component)getEventSource(), |
722 MouseEvent.MOUSE_CLICKED, |
722 MouseEvent.MOUSE_CLICKED, |
723 jWhen, |
723 jWhen, |
724 modifiers, |
724 modifiers, |
751 XMotionEvent xme = xev.get_xmotion(); |
751 XMotionEvent xme = xev.get_xmotion(); |
752 if (isEventDisabled(xev)) { |
752 if (isEventDisabled(xev)) { |
753 return; |
753 return; |
754 } |
754 } |
755 |
755 |
756 int mouseKeyState = (xme.get_state() & (Button1Mask | Button2Mask | Button3Mask)); |
756 int mouseKeyState = (xme.get_state() & (XConstants.Button1Mask | XConstants.Button2Mask | XConstants.Button3Mask)); |
757 boolean isDragging = (mouseKeyState != 0); |
757 boolean isDragging = (mouseKeyState != 0); |
758 int mouseEventType = 0; |
758 int mouseEventType = 0; |
759 |
759 |
760 if (isDragging) { |
760 if (isDragging) { |
761 mouseEventType = MouseEvent.MOUSE_DRAGGED; |
761 mouseEventType = MouseEvent.MOUSE_DRAGGED; |
821 // current component. Second one notifies that it has entered into the same component. |
821 // current component. Second one notifies that it has entered into the same component. |
822 // This looks like the window under the mouse has actually changed and Java handle these events |
822 // This looks like the window under the mouse has actually changed and Java handle these events |
823 // accordingly. This leads to impossibility to make a double click on Component (6404708) |
823 // accordingly. This leads to impossibility to make a double click on Component (6404708) |
824 XWindowPeer toplevel = getToplevelXWindow(); |
824 XWindowPeer toplevel = getToplevelXWindow(); |
825 if (toplevel != null && !toplevel.isModalBlocked()){ |
825 if (toplevel != null && !toplevel.isModalBlocked()){ |
826 if (xce.get_mode() != NotifyNormal) { |
826 if (xce.get_mode() != XConstants.NotifyNormal) { |
827 // 6404708 : need update cursor in accordance with skipping Leave/EnterNotify event |
827 // 6404708 : need update cursor in accordance with skipping Leave/EnterNotify event |
828 // whereas it doesn't need to handled further. |
828 // whereas it doesn't need to handled further. |
829 if (xce.get_type() == EnterNotify) { |
829 if (xce.get_type() == XConstants.EnterNotify) { |
830 XAwtState.setComponentMouseEntered(getEventSource()); |
830 XAwtState.setComponentMouseEntered(getEventSource()); |
831 XGlobalCursorManager.nativeUpdateCursor(getEventSource()); |
831 XGlobalCursorManager.nativeUpdateCursor(getEventSource()); |
832 } else { // LeaveNotify: |
832 } else { // LeaveNotify: |
833 XAwtState.setComponentMouseEntered(null); |
833 XAwtState.setComponentMouseEntered(null); |
834 } |
834 } |
838 // X sends XCrossing to all hierarchy so if the edge of child equals to |
838 // X sends XCrossing to all hierarchy so if the edge of child equals to |
839 // ancestor and mouse enters child, the ancestor will get an event too. |
839 // ancestor and mouse enters child, the ancestor will get an event too. |
840 // From java point the event is bogus as ancestor is obscured, so if |
840 // From java point the event is bogus as ancestor is obscured, so if |
841 // the child can get java event itself, we skip it on ancestor. |
841 // the child can get java event itself, we skip it on ancestor. |
842 long childWnd = xce.get_subwindow(); |
842 long childWnd = xce.get_subwindow(); |
843 if (childWnd != None) { |
843 if (childWnd != XConstants.None) { |
844 XBaseWindow child = XToolkit.windowToXWindow(childWnd); |
844 XBaseWindow child = XToolkit.windowToXWindow(childWnd); |
845 if (child != null && child instanceof XWindow && |
845 if (child != null && child instanceof XWindow && |
846 !child.isEventDisabled(xev)) |
846 !child.isEventDisabled(xev)) |
847 { |
847 { |
848 return; |
848 return; |
851 |
851 |
852 // Remember old component with mouse to have the opportunity to send it MOUSE_EXITED. |
852 // Remember old component with mouse to have the opportunity to send it MOUSE_EXITED. |
853 final Component compWithMouse = XAwtState.getComponentMouseEntered(); |
853 final Component compWithMouse = XAwtState.getComponentMouseEntered(); |
854 if (toplevel != null) { |
854 if (toplevel != null) { |
855 if(!toplevel.isModalBlocked()){ |
855 if(!toplevel.isModalBlocked()){ |
856 if (xce.get_type() == EnterNotify) { |
856 if (xce.get_type() == XConstants.EnterNotify) { |
857 // Change XAwtState's component mouse entered to the up-to-date one before requesting |
857 // Change XAwtState's component mouse entered to the up-to-date one before requesting |
858 // to update the cursor since XAwtState.getComponentMouseEntered() is used when the |
858 // to update the cursor since XAwtState.getComponentMouseEntered() is used when the |
859 // cursor is updated (in XGlobalCursorManager.findHeavyweightUnderCursor()). |
859 // cursor is updated (in XGlobalCursorManager.findHeavyweightUnderCursor()). |
860 XAwtState.setComponentMouseEntered(getEventSource()); |
860 XAwtState.setComponentMouseEntered(getEventSource()); |
861 XGlobalCursorManager.nativeUpdateCursor(getEventSource()); |
861 XGlobalCursorManager.nativeUpdateCursor(getEventSource()); |
893 MouseEvent.NOBUTTON); |
893 MouseEvent.NOBUTTON); |
894 postEventToEventQueue(me); |
894 postEventToEventQueue(me); |
895 eventLog.finest("Clearing last window ref"); |
895 eventLog.finest("Clearing last window ref"); |
896 lastWindowRef = null; |
896 lastWindowRef = null; |
897 } |
897 } |
898 if (xce.get_type() == EnterNotify) { |
898 if (xce.get_type() == XConstants.EnterNotify) { |
899 MouseEvent me = new MouseEvent(getEventSource(), MouseEvent.MOUSE_ENTERED, |
899 MouseEvent me = new MouseEvent(getEventSource(), MouseEvent.MOUSE_ENTERED, |
900 jWhen, modifiers, xce.get_x(), xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount, |
900 jWhen, modifiers, xce.get_x(), xce.get_y(), xce.get_x_root(), xce.get_y_root(), clickCount, |
901 popupTrigger, MouseEvent.NOBUTTON); |
901 popupTrigger, MouseEvent.NOBUTTON); |
902 postEventToEventQueue(me); |
902 postEventToEventQueue(me); |
903 } |
903 } |
988 // called directly from this package, unlike handleKeyRelease. |
988 // called directly from this package, unlike handleKeyRelease. |
989 // un-final it if you need to override it in a subclass. |
989 // un-final it if you need to override it in a subclass. |
990 final void handleKeyPress(XKeyEvent ev) { |
990 final void handleKeyPress(XKeyEvent ev) { |
991 long keysym[] = new long[2]; |
991 long keysym[] = new long[2]; |
992 char unicodeKey = 0; |
992 char unicodeKey = 0; |
993 keysym[0] = NoSymbol; |
993 keysym[0] = XConstants.NoSymbol; |
994 |
994 |
995 if (keyEventLog.isLoggable(Level.FINE)) { |
995 if (keyEventLog.isLoggable(Level.FINE)) { |
996 logIncomingKeyEvent( ev ); |
996 logIncomingKeyEvent( ev ); |
997 } |
997 } |
998 if ( //TODO check if there's an active input method instance |
998 if ( //TODO check if there's an active input method instance |
1071 } |
1071 } |
1072 // un-private it if you need to call it from elsewhere |
1072 // un-private it if you need to call it from elsewhere |
1073 private void handleKeyRelease(XKeyEvent ev) { |
1073 private void handleKeyRelease(XKeyEvent ev) { |
1074 long keysym[] = new long[2]; |
1074 long keysym[] = new long[2]; |
1075 char unicodeKey = 0; |
1075 char unicodeKey = 0; |
1076 keysym[0] = NoSymbol; |
1076 keysym[0] = XConstants.NoSymbol; |
1077 |
1077 |
1078 if (keyEventLog.isLoggable(Level.FINE)) { |
1078 if (keyEventLog.isLoggable(Level.FINE)) { |
1079 logIncomingKeyEvent( ev ); |
1079 logIncomingKeyEvent( ev ); |
1080 } |
1080 } |
1081 // Keysym should be converted to Unicode, if possible and necessary, |
1081 // Keysym should be converted to Unicode, if possible and necessary, |
1151 void updateSizeHints() { |
1151 void updateSizeHints() { |
1152 updateSizeHints(x, y, width, height); |
1152 updateSizeHints(x, y, width, height); |
1153 } |
1153 } |
1154 |
1154 |
1155 void updateSizeHints(int x, int y, int width, int height) { |
1155 void updateSizeHints(int x, int y, int width, int height) { |
1156 long flags = XlibWrapper.PSize | (isLocationByPlatform() ? 0 : (XlibWrapper.PPosition | XlibWrapper.USPosition)); |
1156 long flags = XUtilConstants.PSize | (isLocationByPlatform() ? 0 : (XUtilConstants.PPosition | XUtilConstants.USPosition)); |
1157 if (!isResizable()) { |
1157 if (!isResizable()) { |
1158 log.log(Level.FINER, "Window {0} is not resizable", new Object[] {this}); |
1158 log.log(Level.FINER, "Window {0} is not resizable", new Object[] {this}); |
1159 flags |= XlibWrapper.PMinSize | XlibWrapper.PMaxSize; |
1159 flags |= XUtilConstants.PMinSize | XUtilConstants.PMaxSize; |
1160 } else { |
1160 } else { |
1161 log.log(Level.FINER, "Window {0} is resizable", new Object[] {this}); |
1161 log.log(Level.FINER, "Window {0} is resizable", new Object[] {this}); |
1162 } |
1162 } |
1163 setSizeHints(flags, x, y, width, height); |
1163 setSizeHints(flags, x, y, width, height); |
1164 } |
1164 } |
1165 |
1165 |
1166 void updateSizeHints(int x, int y) { |
1166 void updateSizeHints(int x, int y) { |
1167 long flags = isLocationByPlatform() ? 0 : (XlibWrapper.PPosition | XlibWrapper.USPosition); |
1167 long flags = isLocationByPlatform() ? 0 : (XUtilConstants.PPosition | XUtilConstants.USPosition); |
1168 if (!isResizable()) { |
1168 if (!isResizable()) { |
1169 log.log(Level.FINER, "Window {0} is not resizable", new Object[] {this}); |
1169 log.log(Level.FINER, "Window {0} is not resizable", new Object[] {this}); |
1170 flags |= XlibWrapper.PMinSize | XlibWrapper.PMaxSize | XlibWrapper.PSize; |
1170 flags |= XUtilConstants.PMinSize | XUtilConstants.PMaxSize | XUtilConstants.PSize; |
1171 } else { |
1171 } else { |
1172 log.log(Level.FINER, "Window {0} is resizable", new Object[] {this}); |
1172 log.log(Level.FINER, "Window {0} is resizable", new Object[] {this}); |
1173 } |
1173 } |
1174 setSizeHints(flags, x, y, width, height); |
1174 setSizeHints(flags, x, y, width, height); |
1175 } |
1175 } |