# Windows and Events

All imaging and user interface events for a plug-in instance are handled according to its native platform. The plug-in API provides a native window handle within which an instance does its drawing, via the API call NPP_SetWindow, which passes the instance an NPWindow object containing the native window handle. On Window and UNIX, each instance receives its own child window within the Navigator window hierarchy, and all imaging and event processing is relative to this window.

On the Macintosh, the native window is shared between the instance and Navigator, so the instance must restrict its drawing to to a specified area of the shared window, and must take care to always save, set up, and restore the shared drawing environment around any drawing operations. On the Macintosh, events are explicitly provided to the instance via the API NPP_HandleEvent.

It is important that plug-ins do not block any API call from the Netscape client. There is no yield function from the plug-in to Netscape since many plug-ins may be active at once. If a plug-in involves substantial asynchronous work, it should use a separate thread or a timer as appropriate. In some cases a plug-in may achieve this goal by communicating with an entirely separate application. If a plug-in makes API calls into Navigator, it should be prepared to handle re-entrant API calls back into the plug-in.