>This sounds suspicious. Is this conjecture or based on analyzing the Swing
code?
>There's always an AWT window under a top-level Swing window, and I would
expect
>Swing to be using AWT events to be tracking input devices.
>
A little conjecture, a little analysis. Swing uses the AWT event queue,
true, but because all lightweight components must exist within an AWT
toplevel component, Swing has to take over from there and dispatch all
messages from thence forth. Whereas a native Win32 app (even if it's not
optimized and/or makes use of such whizzy-bang nifties like tooltips) can
"park" itself in the CPU when the application is disabled, a Java AWT/Swing
app can't necessarily do that. See below for what I mean.
>Not that there aren't a lot of CPU-sucking details buried in Swing (or
>lightweight components in general)... I just question whether this is one of
>them.
>
One of the details in Win32 AWT is that in the native Win32 event loop
(buried within the native implementation of the Win32 java.awt.Toolkit
implementation), the following calls are made:
/*
* Create the one-and-only toolkit window. This window isn't
* displayed, but is used to route messages to this thread.
*/
m_toolkitHWnd = CreateToolkitWnd("theAwtToolkitWindow");
ASSERT(m_toolkitHWnd != NULL);
/*
* Setup a GetMessage filter to watch all messages coming out of our
* queue from PreProcessMsg().
*/
m_hGetMessageHook = ::SetWindowsHookEx(WH_GETMESSAGE,
(HOOKPROC)GetMessageFilter,
0, GetCurrentThreadId());
Both of these are horribly inefficient; I'm not sure why Java/AWT needs to
route all messages through a single window (probably has to do with native
threads, come to think of it), nor why they need a message hook. One of the
properties, however, of hooks is that you will be called for each and every
message that comes through the system, whether you were intended for it or
not.
Anybody with more Swing/AWT internals knowledge than I care to comment?
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]