[webkit-help] npapi resize problems

Tim Prepscius timprepscius at gmail.com
Mon May 24 03:59:11 PDT 2010


So just a little bit more information..

The change in math is coming from:
    GetPortBounds( )

which after the resize is 50 pixels greater vertically. hhhmmmm...

GetPortBounds of
CGrafPtr pkPort = aglGetDrawable(m_pkAglContext);

which was:
m_pkAglContext = aglCreateContext(pkPixelFormat,0); and
    if (!aglSetDrawable(m_pkAglContext,m_pkAglDrawable)

    m_pkAglDrawable = (AGLDrawable)GetWindowPort(pkWindow);

and pkWindow refers back to that currentInstance->window.window

--

hmmmmmmmmmmmm

...

So it seems to me that.

The context is correctly associated with the drawable, which is the window
The NP_SetWindow is sending in the correct window.x window.y clip

But somewhere during the recomputation of layout during resize, the
window port is resized so as not to include the title bar.


Does this sound correct?

If it is correct, I see three possible solutions, both of which I am
not sure how I would implement.

Solution #1.  Find the correct variable to subtract out of this
GetPortBounds.  I have no idea..  Any thoughts?  This is obviously the
correct solution.

Solution #2:  Manufacture a resize event and send it to the window.
Always subtract some hacked constant from GetPortBounds.

Solution #3:  Catch the resize event for the window.  Thereafter,
subtract out some hacked value.


Any thoughts?  Hints.. Especially to solution #1?  Is there a better
way.  Is this possible in pure carbon?  I really really am not looking
forward to obj-c.

-tim

On 5/24/10, Tim Prepscius <timprepscius at gmail.com> wrote:
> 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