Raptor Widget
Files in mozilla/widget/src/os2/
(not yet checked in to mozilla.org cvs)
This is the cross-platform window library. Most of the files and classes (eg. nsEntryField) are small subclasses of the base OS/2 window class, nsWindow. Note that the widgets are grounded in an XP class, nsBaseWidget. The hierarchy looks like this:
nsISupports | +---nsIWidget | +---nsBaseWidget | +---nsWindow | +---nsEntryField (for example)
In order to do interesting things like create windows, a thread needs to have a HMQ. There are three places in the mozilla code where, independently, PM function is neeed: here, in libwidget; in nsTimerOS2, and in the plevent library. Here is the way in which message queues are to be managed:
- When a service needs a message queue, it should first test for there being one for the current thread, using WinQueryQueueInfo.
- If there is no queue, create one.
Otherwise the service should use HMQ_CURRENT. - The service should take no action to destroy any queue it creates.
- The exception to this rule is the nsAppShell class. It is the job of
nsAppShell to destroy the message queue and shut down PM.
This a valid thing to do because by the time the nsAppShell shuts down, it is no longer processing its message queue, and so the services which may be using will have stopped working anyhow.
Toolkits and thread management
That said, mozilla isn't too promiscuous in the thread-creation department. Plans for this version seem to be limited to one UI thread plus some more netlib threads (more info). But if things ever change, we will be ready.
The HWND to nsWindow mapping is implemented using a hashtable, found in nsWindow.cpp.
The resizing and moving code is a bit non-obvious and probably contains a few bugs: as in the graphics library, the coordinate system has the origin in the top-left. Because the height of the window is an oft-requested quanitity, the window rectangle (in XP space) is cached in the object. This is updated in the dispatch routines for the PM notification messages as opposed to the site of the Resize method. There's some interesting code (which is, as yet, uncalled) to batch window repositions.
There are some kludges in place to better mimic the behaviour of Win32, so that, for example, windows totally covered by other windows do not receive mouseclick events.
XP events are defined in nsGUIEvent.h. They're pretty straight-forward, though with a few notes:
- The keycodes (see nsKeyEvent) are occasionally ambiguous;
there's a global function in nsWindow.h to convert from a WM_CHAR to the
keycode.
Intl work needed for MBCS input modes. - No-one really knows when NS_SIZE and NS_MOVE events should be generated. OS/2's funky coordinate system doesn't help matters, and we could probably do better.
There are a bunch of methods in nsWindow.cpp which deal with setting up for and dispatching events to interested parties.
The nsILookAndFeel interface is meant to wrap up various platform-specific things, including various system colours.
There are some rather weird entries which have appeared relatively recently, which are used when laying out and aligning form elements.
These could do with verifying.
If components look `a bit wrong', adjusting a value in here is probably the way to go (but see above).
The per-window data-structure could do with optimising
(just use a hashtable)
This could well be subsumed into XP code.
Yes, event handling mechansims vary wildly. But that's what makes it so fun.
nsSwitchToPMThread rerouting isn't
hooked up yet.
The code for dispatching menu events is currently in
nsWindow.cpp. It should probably be moved to nsFrameWindow.cpp.
In practice, the white line doesn't look that bad, and it'll probably go away when the XPToolkit arrives.
Back to Raptor gfx | On to plugins |
---|