11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package sun.awt.windows;
26
27 import java.awt.*;
28 import java.awt.peer.*;
29 import java.awt.image.VolatileImage;
30 import sun.awt.RepaintArea;
31 import sun.awt.CausedFocusEvent;
32 import sun.awt.image.SunVolatileImage;
33 import sun.awt.image.ToolkitImage;
34 import java.awt.image.BufferedImage;
35 import java.awt.image.ImageProducer;
36 import java.awt.image.ImageObserver;
37 import java.awt.image.ColorModel;
38 import java.awt.event.PaintEvent;
39 import java.awt.event.InvocationEvent;
40 import java.awt.event.KeyEvent;
41 import java.awt.event.FocusEvent;
42 import java.awt.event.MouseEvent;
43 import java.awt.event.MouseWheelEvent;
44 import java.awt.event.InputEvent;
45 import sun.awt.Win32GraphicsConfig;
46 import sun.awt.Win32GraphicsEnvironment;
47 import sun.java2d.InvalidPipeException;
48 import sun.java2d.SurfaceData;
49 import sun.java2d.ScreenUpdateManager;
50 import sun.java2d.d3d.D3DSurfaceData;
51 import sun.java2d.opengl.OGLSurfaceData;
304 }
305 }
306 }
307
308 public synchronized native void reshape(int x, int y, int width, int height);
309
310 // returns true if the event has been handled and shouldn't be propagated
311 // though handleEvent method chain - e.g. WTextFieldPeer returns true
312 // on handling '\n' to prevent it from being passed to native code
313 public boolean handleJavaKeyEvent(KeyEvent e) { return false; }
314
315 public void handleJavaMouseEvent(MouseEvent e) {
316 switch (e.getID()) {
317 case MouseEvent.MOUSE_PRESSED:
318 // Note that Swing requests focus in its own mouse event handler.
319 if (target == e.getSource() &&
320 !((Component)target).isFocusOwner() &&
321 WKeyboardFocusManagerPeer.shouldFocusOnClick((Component)target))
322 {
323 WKeyboardFocusManagerPeer.requestFocusFor((Component)target,
324 CausedFocusEvent.Cause.MOUSE_EVENT);
325 }
326 break;
327 }
328 }
329
330 native void nativeHandleEvent(AWTEvent e);
331
332 @Override
333 @SuppressWarnings("fallthrough")
334 public void handleEvent(AWTEvent e) {
335 int id = e.getID();
336
337 if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() &&
338 ((Component)target).isEnabled())
339 {
340 if (e instanceof MouseEvent && !(e instanceof MouseWheelEvent)) {
341 handleJavaMouseEvent((MouseEvent) e);
342 } else if (e instanceof KeyEvent) {
343 if (handleJavaKeyEvent((KeyEvent)e)) {
344 return;
670 }
671
672 private native void _setForeground(int rgb);
673 private native void _setBackground(int rgb);
674
675 @Override
676 public synchronized void setFont(Font f) {
677 font = f;
678 _setFont(f);
679 }
680 synchronized native void _setFont(Font f);
681 @Override
682 public void updateCursorImmediately() {
683 WGlobalCursorManager.getCursorManager().updateCursorImmediately();
684 }
685
686 // TODO: consider moving it to KeyboardFocusManagerPeerImpl
687 @Override
688 public boolean requestFocus(Component lightweightChild, boolean temporary,
689 boolean focusedWindowChangeAllowed, long time,
690 CausedFocusEvent.Cause cause)
691 {
692 if (WKeyboardFocusManagerPeer.
693 processSynchronousLightweightTransfer((Component)target, lightweightChild, temporary,
694 focusedWindowChangeAllowed, time))
695 {
696 return true;
697 }
698
699 int result = WKeyboardFocusManagerPeer
700 .shouldNativelyFocusHeavyweight((Component)target, lightweightChild,
701 temporary, focusedWindowChangeAllowed,
702 time, cause);
703
704 switch (result) {
705 case WKeyboardFocusManagerPeer.SNFH_FAILURE:
706 return false;
707 case WKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
708 if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
709 focusLog.finer("Proceeding with request to " + lightweightChild + " in " + target);
710 }
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25 package sun.awt.windows;
26
27 import java.awt.*;
28 import java.awt.peer.*;
29 import java.awt.image.VolatileImage;
30 import sun.awt.RepaintArea;
31 import sun.awt.image.SunVolatileImage;
32 import sun.awt.image.ToolkitImage;
33 import java.awt.image.BufferedImage;
34 import java.awt.image.ImageProducer;
35 import java.awt.image.ImageObserver;
36 import java.awt.image.ColorModel;
37 import java.awt.event.PaintEvent;
38 import java.awt.event.InvocationEvent;
39 import java.awt.event.KeyEvent;
40 import java.awt.event.FocusEvent;
41 import java.awt.event.MouseEvent;
42 import java.awt.event.MouseWheelEvent;
43 import java.awt.event.InputEvent;
44 import sun.awt.Win32GraphicsConfig;
45 import sun.awt.Win32GraphicsEnvironment;
46 import sun.java2d.InvalidPipeException;
47 import sun.java2d.SurfaceData;
48 import sun.java2d.ScreenUpdateManager;
49 import sun.java2d.d3d.D3DSurfaceData;
50 import sun.java2d.opengl.OGLSurfaceData;
303 }
304 }
305 }
306
307 public synchronized native void reshape(int x, int y, int width, int height);
308
309 // returns true if the event has been handled and shouldn't be propagated
310 // though handleEvent method chain - e.g. WTextFieldPeer returns true
311 // on handling '\n' to prevent it from being passed to native code
312 public boolean handleJavaKeyEvent(KeyEvent e) { return false; }
313
314 public void handleJavaMouseEvent(MouseEvent e) {
315 switch (e.getID()) {
316 case MouseEvent.MOUSE_PRESSED:
317 // Note that Swing requests focus in its own mouse event handler.
318 if (target == e.getSource() &&
319 !((Component)target).isFocusOwner() &&
320 WKeyboardFocusManagerPeer.shouldFocusOnClick((Component)target))
321 {
322 WKeyboardFocusManagerPeer.requestFocusFor((Component)target,
323 FocusEvent.Cause.MOUSE_EVENT);
324 }
325 break;
326 }
327 }
328
329 native void nativeHandleEvent(AWTEvent e);
330
331 @Override
332 @SuppressWarnings("fallthrough")
333 public void handleEvent(AWTEvent e) {
334 int id = e.getID();
335
336 if ((e instanceof InputEvent) && !((InputEvent)e).isConsumed() &&
337 ((Component)target).isEnabled())
338 {
339 if (e instanceof MouseEvent && !(e instanceof MouseWheelEvent)) {
340 handleJavaMouseEvent((MouseEvent) e);
341 } else if (e instanceof KeyEvent) {
342 if (handleJavaKeyEvent((KeyEvent)e)) {
343 return;
669 }
670
671 private native void _setForeground(int rgb);
672 private native void _setBackground(int rgb);
673
674 @Override
675 public synchronized void setFont(Font f) {
676 font = f;
677 _setFont(f);
678 }
679 synchronized native void _setFont(Font f);
680 @Override
681 public void updateCursorImmediately() {
682 WGlobalCursorManager.getCursorManager().updateCursorImmediately();
683 }
684
685 // TODO: consider moving it to KeyboardFocusManagerPeerImpl
686 @Override
687 public boolean requestFocus(Component lightweightChild, boolean temporary,
688 boolean focusedWindowChangeAllowed, long time,
689 FocusEvent.Cause cause)
690 {
691 if (WKeyboardFocusManagerPeer.
692 processSynchronousLightweightTransfer((Component)target, lightweightChild, temporary,
693 focusedWindowChangeAllowed, time))
694 {
695 return true;
696 }
697
698 int result = WKeyboardFocusManagerPeer
699 .shouldNativelyFocusHeavyweight((Component)target, lightweightChild,
700 temporary, focusedWindowChangeAllowed,
701 time, cause);
702
703 switch (result) {
704 case WKeyboardFocusManagerPeer.SNFH_FAILURE:
705 return false;
706 case WKeyboardFocusManagerPeer.SNFH_SUCCESS_PROCEED:
707 if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
708 focusLog.finer("Proceeding with request to " + lightweightChild + " in " + target);
709 }
|