natXAnyEvent.cc (loadNext): Added timeout.
2005-04-07 Scott Gilbertson <scottg@mantatest.com> * gnu/gcj/xlib/natXAnyEvent.cc (loadNext): Added timeout. * gnu/awt/xlib/XCanvasPeer.java (setBackground): Removed throw UnsupportedOperationException, fixed comments. (setFont, setForeground): Fixed comments. * gnu/awt/xlib/XEventLoop.java (postNextEvent): Changed return type to boolean. (getNextEvent): Fixed javadocs. * gnu/awt/xlib/XToolkit.java (interrupted): Removed field. (nativeQueueEmpty): Removed unused code. (iterateNativeQueue): Removed outer loop. From-SVN: r96029
This commit is contained in:
parent
3eb54e5f63
commit
9ed9eda673
|
@ -1,3 +1,15 @@
|
|||
2005-04-07 Scott Gilbertson <scottg@mantatest.com>
|
||||
* gnu/gcj/xlib/natXAnyEvent.cc (loadNext): Added timeout.
|
||||
* gnu/awt/xlib/XCanvasPeer.java (setBackground): Removed
|
||||
throw UnsupportedOperationException, fixed comments.
|
||||
(setFont, setForeground): Fixed comments.
|
||||
* gnu/awt/xlib/XEventLoop.java (postNextEvent): Changed
|
||||
return type to boolean.
|
||||
(getNextEvent): Fixed javadocs.
|
||||
* gnu/awt/xlib/XToolkit.java (interrupted): Removed field.
|
||||
(nativeQueueEmpty): Removed unused code.
|
||||
(iterateNativeQueue): Removed outer loop.
|
||||
|
||||
2005-03-06 Roger Sayle <roger@eyesopen.com>
|
||||
|
||||
PR libgcj/20155
|
||||
|
|
|
@ -349,7 +349,8 @@ public class XCanvasPeer implements CanvasPeer
|
|||
|
||||
public void setBackground(Color color)
|
||||
{
|
||||
throw new UnsupportedOperationException("not implemented");
|
||||
/* default canvas peer does not keep track of background, since it won't
|
||||
* paint anything. */
|
||||
}
|
||||
|
||||
public void setBounds(int x, int y, int width, int height)
|
||||
|
@ -405,13 +406,13 @@ public class XCanvasPeer implements CanvasPeer
|
|||
|
||||
public void setFont(Font font)
|
||||
{
|
||||
/* default canvas peer does keep track of font, since it won't
|
||||
write anything. */
|
||||
/* default canvas peer does not keep track of font, since it won't
|
||||
paint anything. */
|
||||
}
|
||||
|
||||
public void setForeground(Color color)
|
||||
{
|
||||
/* default canvas peer does keep track of foreground, since it won't
|
||||
/* default canvas peer does not keep track of foreground, since it won't
|
||||
paint anything. */
|
||||
}
|
||||
|
||||
|
|
|
@ -42,15 +42,20 @@ public class XEventLoop
|
|||
anyEvent.interrupt();
|
||||
}
|
||||
|
||||
void postNextEvent(boolean block)
|
||||
/** If there's an event available, post it.
|
||||
* @return true if an event was posted
|
||||
*/
|
||||
boolean postNextEvent(boolean block)
|
||||
{
|
||||
AWTEvent evt = getNextEvent(block);
|
||||
if (evt != null)
|
||||
queue.postEvent(evt);
|
||||
return evt != null;
|
||||
}
|
||||
|
||||
/** get next event. Will block until events become available. */
|
||||
|
||||
/** Get the next event.
|
||||
* @param block If true, block until an event becomes available
|
||||
*/
|
||||
public AWTEvent getNextEvent(boolean block)
|
||||
{
|
||||
// ASSERT:
|
||||
|
@ -62,7 +67,7 @@ public class XEventLoop
|
|||
{
|
||||
event = createEvent();
|
||||
event = lightweightRedirector.redirect(event);
|
||||
}
|
||||
}
|
||||
return event;
|
||||
}
|
||||
|
||||
|
@ -169,7 +174,7 @@ public class XEventLoop
|
|||
return null;
|
||||
|
||||
default:
|
||||
String msg = "Do no know how to handle event (" + anyEvent + ")";
|
||||
String msg = "Do not know how to handle event (" + anyEvent + ")";
|
||||
throw new RuntimeException (msg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -444,8 +444,6 @@ public class XToolkit extends ClasspathToolkit
|
|||
throw new java.lang.UnsupportedOperationException ();
|
||||
}
|
||||
|
||||
boolean interrupted;
|
||||
|
||||
public boolean nativeQueueEmpty()
|
||||
{
|
||||
return eventLoop.isIdle();
|
||||
|
@ -453,14 +451,19 @@ public class XToolkit extends ClasspathToolkit
|
|||
|
||||
public void wakeNativeQueue()
|
||||
{
|
||||
interrupted = true;
|
||||
eventLoop.interrupt();
|
||||
}
|
||||
|
||||
/** Checks the native event queue for events. If blocking, waits until an
|
||||
* event is available before returning, unless interrupted by
|
||||
* wakeNativeQueue. If non-blocking, returns immediately even if no
|
||||
* event is available.
|
||||
*
|
||||
* @param locked The calling EventQueue
|
||||
* @param block If true, waits for a native event before returning
|
||||
*/
|
||||
public void iterateNativeQueue(java.awt.EventQueue locked, boolean block)
|
||||
{
|
||||
interrupted = false;
|
||||
while (!interrupted)
|
||||
eventLoop.postNextEvent(block);
|
||||
};
|
||||
eventLoop.postNextEvent(block);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,11 +69,14 @@ jboolean gnu::gcj::xlib::XAnyEvent::loadNext(jboolean block)
|
|||
int xfd = XConnectionNumber(dpy);
|
||||
int pipefd = pipe[0];
|
||||
int n = (xfd > pipefd ? xfd : pipefd) + 1;
|
||||
struct timeval timeout;
|
||||
timeout.tv_usec = 100000; // 100ms timeout
|
||||
timeout.tv_sec = 0;
|
||||
fd_set rfds;
|
||||
FD_ZERO(&rfds);
|
||||
FD_SET(xfd, &rfds);
|
||||
FD_SET(pipefd, &rfds);
|
||||
int sel = _Jv_select (n, &rfds, NULL, NULL, NULL);
|
||||
int sel = _Jv_select (n, &rfds, NULL, NULL, &timeout);
|
||||
if (sel > 0)
|
||||
{
|
||||
if (FD_ISSET(xfd, &rfds))
|
||||
|
|
Loading…
Reference in New Issue