/*****************************************************************************
* Called when initializing or resizing the window.
*****************************************************************************/
NPError NPP_SetWindow(NPP instance, NPWindow* aWindow)
{
D("SetWindow\n");
if(aWindow == NULL)
return FALSE;
mX = aWindow->x;
mY = aWindow->y;
mWidth = aWindow->width;
mHeight = aWindow->height;
if (mWindow == (Window) aWindow->window) {
// The page with the plugin is being resized.
// Save any UI information because the next time
// around expect a SetWindow with a new window id.
} else {
D("new window\n");
mWindow = (Window) aWindow->window;
NPSetWindowCallbackStruct *ws_info = (NPSetWindowCallbackStruct *)aWindow->ws_info;
mDisplay = ws_info->display;
mVisual = ws_info->visual;
mDepth = ws_info->depth;
mColormap = ws_info->colormap;
if (!mFontInfo) {
if (!(mFontInfo = XLoadQueryFont(mDisplay, "-bitstream-bitstream charter-*-*-*--33-*-*-*-*-*-iso8859-1")))
D("Cannot open font\n");
}
// add xt event handler
Widget xtwidget = XtWindowToWidget(mDisplay, mWindow);
if (xtwidget && mXtwidget != xtwidget) {
mXtwidget = xtwidget;
long event_mask = ExposureMask|
KeyPressMask |
ButtonPressMask |
StructureNotifyMask;
XSelectInput(mDisplay, mWindow, event_mask);
XtAddEventHandler(xtwidget, event_mask, False, (XtEventHandler)xt_event_handler, NULL);
}
}
draw();
return NPERR_NO_ERROR;
}