OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-dev/] [fsf-gcc-snapshot-1-mar-12/] [or1k-gcc/] [libjava/] [gnu/] [awt/] [xlib/] [XEventQueue.java] - Diff between revs 756 and 783

Only display areas with differences | Details | Blame | View Log

Rev 756 Rev 783
/* Copyright (C) 2000  Free Software Foundation
/* Copyright (C) 2000  Free Software Foundation
 
 
   This file is part of libgcj.
   This file is part of libgcj.
 
 
This software is copyrighted work licensed under the terms of the
This software is copyrighted work licensed under the terms of the
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
details.  */
details.  */
 
 
package gnu.awt.xlib;
package gnu.awt.xlib;
 
 
import gnu.gcj.xlib.Display;
import gnu.gcj.xlib.Display;
import java.awt.AWTEvent;
import java.awt.AWTEvent;
import java.awt.Component;
import java.awt.Component;
import java.awt.Container;
import java.awt.Container;
import java.awt.EventQueue;
import java.awt.EventQueue;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentEvent;
import java.awt.event.ContainerEvent;
import java.awt.event.ContainerEvent;
 
 
/**
/**
 * The main difference here from a standard EventQueue is that the X
 * The main difference here from a standard EventQueue is that the X
 * display connection is flushed before waiting for more events.
 * display connection is flushed before waiting for more events.
 */
 */
public class XEventQueue extends EventQueue
public class XEventQueue extends EventQueue
{
{
  Display display;
  Display display;
 
 
  public XEventQueue(Display display)
  public XEventQueue(Display display)
  {
  {
    this.display = display;
    this.display = display;
  }
  }
 
 
  public AWTEvent getNextEvent() throws InterruptedException
  public AWTEvent getNextEvent() throws InterruptedException
  {
  {
    if ((peekEvent() == null) && (display != null))
    if ((peekEvent() == null) && (display != null))
      display.flush();
      display.flush();
    AWTEvent event = super.getNextEvent();
    AWTEvent event = super.getNextEvent();
    if (event != null)
    if (event != null)
    {
    {
      switch (event.getID ())
      switch (event.getID ())
      {
      {
        case ContainerEvent.COMPONENT_ADDED:
        case ContainerEvent.COMPONENT_ADDED:
        {
        {
          /* If a component has been added to a container, it needs to be
          /* If a component has been added to a container, it needs to be
           * invalidated, to ensure that it ultimately gets an addNotify.
           * invalidated, to ensure that it ultimately gets an addNotify.
           * If it's not invalidated, the component will never display in
           * If it's not invalidated, the component will never display in
           * an already-showing container (probably applies only to CardLayout).
           * an already-showing container (probably applies only to CardLayout).
           * Perhaps this code should be in java.awt, but the problem only seems
           * Perhaps this code should be in java.awt, but the problem only seems
           * to happen with xlib peers (not with gtk peers) so it's here instead.
           * to happen with xlib peers (not with gtk peers) so it's here instead.
           */
           */
          ContainerEvent ce = (ContainerEvent)event;
          ContainerEvent ce = (ContainerEvent)event;
          ce.getChild ().invalidate ();
          ce.getChild ().invalidate ();
          ce.getContainer ().validate ();
          ce.getContainer ().validate ();
        }
        }
        break;
        break;
 
 
        case ComponentEvent.COMPONENT_RESIZED:
        case ComponentEvent.COMPONENT_RESIZED:
        {
        {
          ComponentEvent ce = (ComponentEvent)event;
          ComponentEvent ce = (ComponentEvent)event;
          // FIXME: there may be opportunities to coalesce resize events
          // FIXME: there may be opportunities to coalesce resize events
          ce.getComponent ().validate ();
          ce.getComponent ().validate ();
        }
        }
        break;
        break;
 
 
        case ComponentEvent.COMPONENT_SHOWN:
        case ComponentEvent.COMPONENT_SHOWN:
        {
        {
          ComponentEvent ce = (ComponentEvent)event;
          ComponentEvent ce = (ComponentEvent)event;
          Component comp = ce.getComponent ();
          Component comp = ce.getComponent ();
          if (!comp.isValid ())
          if (!comp.isValid ())
          {
          {
            /* Try to validate, going up the tree to the highest-level invalid
            /* Try to validate, going up the tree to the highest-level invalid
             * Container.  The idea is to ensure that addNotify gets called for
             * Container.  The idea is to ensure that addNotify gets called for
             * any non-top-level component being shown, to make it create a peer.
             * any non-top-level component being shown, to make it create a peer.
             */
             */
            Container parent = comp.getParent ();
            Container parent = comp.getParent ();
            while (parent != null)
            while (parent != null)
            {
            {
              Container next = parent.getParent ();
              Container next = parent.getParent ();
              if (next == null || next.isValid ())
              if (next == null || next.isValid ())
              {
              {
                parent.validate ();
                parent.validate ();
                break;
                break;
              }
              }
              else
              else
                parent = next;
                parent = next;
            }
            }
            if (comp instanceof Container)
            if (comp instanceof Container)
              comp.validate ();
              comp.validate ();
          }
          }
          comp.repaint ();
          comp.repaint ();
        }
        }
        break;
        break;
 
 
        default:
        default:
          break;
          break;
      }
      }
    }
    }
    return event;
    return event;
  }
  }
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.