[webkit-help] npapi resize problems

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


Greetings,

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?

-tim


:::::::::::::::::::::::::::::::::

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

  if(instance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  if(window == NULL)
    return NPERR_GENERIC_ERROR;

  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,
	currentInstance->window.clipRect.left,
currentInstance->window.clipRect.top,
currentInstance->window.clipRect.right,
currentInstance->window.clipRect.bottom
	);
	
  CGContextRef cgContext =
((NP_CGContext*)(currentInstance->window.window))->context;
    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;
     StartInstance(context->window,currentInstance->argc,currentInstance->argn,currentInstance->argv);
     UpdatePositionWidthHeight (context->window,
currentInstance->window.x, currentInstance->window.y,
currentInstance->window.width, currentInstance->window.height);
  }
  else
  {
     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