« Gecko Plugin API Reference « Plug-in Side Plug-in API


Contains information about the target into which the plug-in instance can draw.


typedef struct _NPWindow
  void*        window;   /* Platform specific handle */
  uint32_t     x;        /* Coordinates of top left corner */
  uint32_t     y;        /*   relative to a Netscape page */
  uint32_t     width;    /* Maximum window size */
  uint32_t     height;
  NPRect       clipRect; /* Clipping rectangle coordinates */
#ifdef XP_UNIX
  void *       ws_info;  /* Platform-dependent additional data */
#endif /* XP_UNIX */
  NPWindowType type;   /* Window or drawable target */
} NPWindow;


The data structure has the following fields:

Platform-specific handle to a native window element in the Netscape window hierarchy on Windows (HWND) and Unix (X Window ID). Mac OS: window is a pointer to an NP_Port.
x, y
The x and y coordinates for the top left corner of the plug-in relative to the page (and thus relative to the origin of the drawable). Should not be modified by the plug-in.
height, width
The height and width of the plug-in area. Should not be modified by the plug-in.
Clipping rectangle of the plug-in; the origin is the top left corner of the drawable or window. Clipping to the clipRect prevents the plug-in from overwriting the status bar, scroll bars, and other page elements when partially scrolled off the screen. Mac OS: clipRect is the rectangle in port coordinates to which the plug-in should clip its drawing.
Unix: Contains information about the plug-in's Unix window environment; points to an NPSetWindowCallbackStruct.
NPWindowType value that specifies whether the NPWindow instance represents a window or a drawable. Values:
  • NPWindowTypeWindow: Indicates that the window field holds a platform-specific handle to a window (as in Navigator 2.0 and Navigator 3.0). The plug-in is considered windowed.
  • NPWindowTypeDrawable: Indicates that the plugin is windowless. The window field holds a platform-specific handle to a drawable or an off-screen pixmap, as follows:
    • Windows: HDC
    • Mac OS: pointer to NP_Port structure
    • Unix/X11: not used. (The drawable is provided in a GraphicsExpose event, when the paint is requested.)


The NPWindow structure represents the native window or a drawable, and contains information about coordinate position, size, whether the plug-in is windowed or windowless, and some platform-specific information. The plug-in area is a native window element on Windows and Unix, or a rectangle within a native window on Mac OS. The x, y, height, and width coordinates of NPWindow specify the position and size of this area.

The browser calls NPP_SetValue whenever the drawable changes.

A windowed plug-in is drawn into a native window (or portion of a native window) on a web page. For windowed plug-ins, the browser calls the NPP_SetWindow method with an NPWindow structure that represents a drawable (a pointer to an NPWindow allocated by the browser). This window is valid until NPP_SetWindow is called again with a different window or the instance is destroyed.

A windowless plug-in is drawn into a target called a drawable, which can be defined in several ways depending on the platform. For windowless plug-ins, the browser calls the NPP_SetWindow method with an NPWindow structure that represents a drawable.

The plug-in should not modify the field values in this structure.

See Also

NPP_SetWindow, NP_Port, NPSetWindowCallbackStruct, NPRect