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
26 package sun.awt.X11;
27
28 import java.awt.*;
29 import java.awt.event.*;
30 import java.awt.peer.ComponentPeer;
31 import java.awt.image.ColorModel;
32
33 import java.lang.ref.WeakReference;
34
35 import java.lang.reflect.Field;
36 import java.lang.reflect.Method;
37
38 import sun.util.logging.PlatformLogger;
39
40 import sun.awt.*;
41
42 import sun.awt.image.PixelConverter;
43
44 import sun.java2d.SunGraphics2D;
45 import sun.java2d.SurfaceData;
46
47 public class XWindow extends XBaseWindow implements X11ComponentPeer {
48 private static PlatformLogger log = PlatformLogger.getLogger("sun.awt.X11.XWindow");
49 private static PlatformLogger insLog = PlatformLogger.getLogger("sun.awt.X11.insets.XWindow");
50 private static PlatformLogger eventLog = PlatformLogger.getLogger("sun.awt.X11.event.XWindow");
51 private static final PlatformLogger focusLog = PlatformLogger.getLogger("sun.awt.X11.focus.XWindow");
52 private static PlatformLogger keyEventLog = PlatformLogger.getLogger("sun.awt.X11.kye.XWindow");
53 /* If a motion comes in while a multi-click is pending,
54 * allow a smudge factor so that moving the mouse by a small
55 * amount does not wipe out the multi-click state variables.
474
475 public Color getWinBackground() {
476 Color c = null;
477
478 if (backgroundColor != null) {
479 c = backgroundColor;
480 } else if (parent != null) {
481 c = parent.getWinBackground();
482 }
483
484 if (c instanceof SystemColor) {
485 c = new Color(c.getRGB());
486 }
487
488 return c;
489 }
490
491 public boolean isEmbedded() {
492 return embedded;
493 }
494 public void repaint(int x,int y, int width, int height) {
495 if (!isVisible() || getWidth() == 0 || getHeight() == 0) {
496 return;
497 }
498 Graphics g = getGraphics();
499 if (g != null) {
500 try {
501 g.setClip(x,y,width,height);
502 paint(g);
503 } finally {
504 g.dispose();
505 }
506 }
507 }
508 void repaint() {
509 if (!isVisible() || getWidth() == 0 || getHeight() == 0) {
510 return;
511 }
512 final Graphics g = getGraphics();
513 if (g != null) {
514 try {
515 paint(g);
516 } finally {
517 g.dispose();
518 }
519 }
520 }
521 public void paint(final Graphics g) {
522 // paint peer
523 paintPeer(g);
524 }
525
526 void paintPeer(final Graphics g) {
527 }
528 //used by Peers to avoid flickering withing paint()
529 protected void flush(){
530 XToolkit.awtLock();
531 try {
532 XlibWrapper.XFlush(XToolkit.getDisplay());
533 } finally {
534 XToolkit.awtUnlock();
535 }
536 }
537
538 public void popup(int x, int y, int width, int height) {
539 // TBD: grab the pointer
540 xSetBounds(x, y, width, height);
541 }
542
543 public void handleExposeEvent(XEvent xev) {
544 super.handleExposeEvent(xev);
545 XExposeEvent xe = xev.get_xexpose();
546 if (isEventDisabled(xev)) {
547 return;
548 }
549 int x = xe.get_x();
550 int y = xe.get_y();
551 int w = xe.get_width();
552 int h = xe.get_height();
553
554 Component target = (Component)getEventSource();
555 AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
556
557 if (!compAccessor.getIgnoreRepaint(target)
558 && compAccessor.getWidth(target) != 0
559 && compAccessor.getHeight(target) != 0)
560 {
561 handleExposeEvent(target, x, y, w, h);
562 }
563 }
564
565 public void handleExposeEvent(Component target, int x, int y, int w, int h) {
566 PaintEvent event = PaintEventDispatcher.getPaintEventDispatcher().
567 createPaintEvent(target, x, y, w, h);
568 if (event != null) {
569 postEventToEventQueue(event);
570 }
571 }
572
573 static int getModifiers(int state, int button, int keyCode) {
574 return getModifiers(state, button, keyCode, 0, false);
575 }
576
577 static int getModifiers(int state, int button, int keyCode, int type, boolean wheel_mouse) {
578 int modifiers = 0;
579
580 if (((state & XConstants.ShiftMask) != 0) ^ (keyCode == KeyEvent.VK_SHIFT)) {
581 modifiers |= InputEvent.SHIFT_DOWN_MASK;
582 }
583 if (((state & XConstants.ControlMask) != 0) ^ (keyCode == KeyEvent.VK_CONTROL)) {
584 modifiers |= InputEvent.CTRL_DOWN_MASK;
585 }
|
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
26 package sun.awt.X11;
27
28 import java.awt.*;
29 import java.awt.event.*;
30 import java.awt.peer.ComponentPeer;
31 import java.awt.image.ColorModel;
32
33 import java.lang.ref.WeakReference;
34
35 import java.lang.reflect.Method;
36
37 import sun.util.logging.PlatformLogger;
38
39 import sun.awt.*;
40
41 import sun.awt.image.PixelConverter;
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.
473
474 public Color getWinBackground() {
475 Color c = null;
476
477 if (backgroundColor != null) {
478 c = backgroundColor;
479 } else if (parent != null) {
480 c = parent.getWinBackground();
481 }
482
483 if (c instanceof SystemColor) {
484 c = new Color(c.getRGB());
485 }
486
487 return c;
488 }
489
490 public boolean isEmbedded() {
491 return embedded;
492 }
493
494 public final void repaint(int x, int y, int width, int height) {
495 if (!isVisible() || getWidth() == 0 || getHeight() == 0) {
496 return;
497 }
498 Graphics g = getGraphics();
499 if (g != null) {
500 try {
501 g.setClip(x, y, width, height);
502 if (SunToolkit.isDispatchThreadForAppContext(getTarget())) {
503 paint(g);
504 } else {
505 paintPeer(g);
506 postPaintEvent(target, x, y, width, height);
507 }
508 } finally {
509 g.dispose();
510 }
511 }
512 }
513
514 void repaint() {
515 repaint(0, 0, getWidth(), getHeight());
516 }
517
518 public void paint(final Graphics g) {
519 // paint peer
520 paintPeer(g);
521 }
522
523 void paintPeer(final Graphics g) {
524 }
525 //used by Peers to avoid flickering withing paint()
526 protected void flush(){
527 XToolkit.awtLock();
528 try {
529 XlibWrapper.XFlush(XToolkit.getDisplay());
530 } finally {
531 XToolkit.awtUnlock();
532 }
533 }
534
535 public void popup(int x, int y, int width, int height) {
536 // TBD: grab the pointer
537 xSetBounds(x, y, width, height);
538 }
539
540 public void handleExposeEvent(XEvent xev) {
541 super.handleExposeEvent(xev);
542 XExposeEvent xe = xev.get_xexpose();
543 if (isEventDisabled(xev)) {
544 return;
545 }
546 int x = xe.get_x();
547 int y = xe.get_y();
548 int w = xe.get_width();
549 int h = xe.get_height();
550
551 Component target = (Component)getEventSource();
552 AWTAccessor.ComponentAccessor compAccessor = AWTAccessor.getComponentAccessor();
553
554 if (!compAccessor.getIgnoreRepaint(target)
555 && compAccessor.getWidth(target) != 0
556 && compAccessor.getHeight(target) != 0)
557 {
558 postPaintEvent(target, x, y, w, h);
559 }
560 }
561
562 public void postPaintEvent(Component target, int x, int y, int w, int h) {
563 PaintEvent event = PaintEventDispatcher.getPaintEventDispatcher().
564 createPaintEvent(target, x, y, w, h);
565 if (event != null) {
566 postEventToEventQueue(event);
567 }
568 }
569
570 static int getModifiers(int state, int button, int keyCode) {
571 return getModifiers(state, button, keyCode, 0, false);
572 }
573
574 static int getModifiers(int state, int button, int keyCode, int type, boolean wheel_mouse) {
575 int modifiers = 0;
576
577 if (((state & XConstants.ShiftMask) != 0) ^ (keyCode == KeyEvent.VK_SHIFT)) {
578 modifiers |= InputEvent.SHIFT_DOWN_MASK;
579 }
580 if (((state & XConstants.ControlMask) != 0) ^ (keyCode == KeyEvent.VK_CONTROL)) {
581 modifiers |= InputEvent.CTRL_DOWN_MASK;
582 }
|