[webkit-help] npapi resize problems

Tim Prepscius timprepscius at gmail.com
Mon May 24 00:14:30 PDT 2010


I'm not really sure if this is the appropriate place to pose this question.
Anyway, here goes:

I've developed an opengl plugin for firefox/safari/chrome under win32/osx.

Within OSX, using Safari my plugin exhibits incorrect vertical
placement behavior after the browser window is resized.

In detail:
1. I start the browser and go to the plugin test page.
2. Plugin starts fine, is correctly placed.. (I made a surrounding div
so I can see placement problems)

[ NPP_SetWindow is called, I look at the window.x window.y
window.width window.height
I also look at the clipping rectange ]

3.  I scroll the window.  the plugin maintains its appropriate
relative position.

[NPP_SetWindow is called, I can see the window.y changing correctly ]

4.  I resize the window by only one pixel horizontally (it doesn't
matter how much or in what direction)

The window.x window.y window.width window.height change appropriately.
 In this case the X variable might change by 1 pixel width by 1 or
something like that.

*** however *** the plugin now draws at the wrong vertical position.
The number of pixels off the plugin draws is equal to the number of
pixels of the top "url + buttons" area.


So, I'm searching for the correct vertical placement variable to
add/subtract from window.y but have not found it.

I've tried also looking at that CGContext, and working backwards from
there, but it doesn't give me any different information.

I think I need to somehow get some attribute of that window, to see if
there is an additional offset, but I'm not sure which one.


Any hints?



// Called to update a plugin instances's NPWindow
NPError NPP_SetWindow(NPP instance, NPWindow* window)
  fprintf (stderr, "NP_SetWindow called!!!\n");

  if(instance == NULL)

  if(window == NULL)

  PluginInstance* currentInstance = (PluginInstance*)(instance->pdata);

  currentInstance->window = *window;

  NP_CGContext *context = ((NP_CGContext*)(currentInstance->window.window));

  fprintf (stderr, "%d %d %d %d - %d %d %d %d",
	currentInstance->window.x, currentInstance->window.y,
currentInstance->window.width, currentInstance->window.height,
  CGContextRef cgContext =
    CGRect rect = CGRectMake(0,0,1,1);	
	CGRect userRect = CGContextConvertRectToUserSpace (cgContext, rect);
    fprintf(stderr, "userspace %f %f %f %f", userRect.origin.x,
userRect.origin.y, userRect.size.width, userRect.size.height);

	CGRect deviceRect = CGContextConvertRectToDeviceSpace (cgContext, rect);
    fprintf(stderr, "devicespace %f %f %f %f", deviceRect.origin.x,
deviceRect.origin.y, deviceRect.size.width, deviceRect.size.height);

  if (!currentInstance->initialized && context)
     currentInstance->initialized = true;
     UpdatePositionWidthHeight (context->window,
currentInstance->window.x, currentInstance->window.y,
currentInstance->window.width, currentInstance->window.height);
     UpdatePositionWidthHeight (context->window,
currentInstance->window.x, currentInstance->window.y,
currentInstance->window.width, currentInstance->window.height);

  return NPERR_NO_ERROR;

More information about the webkit-help mailing list