- Make popup appear on the right screen coordinates (this was broken after the flipy switch)

- Make sure the popup stays until it is dismissed (no need to hold the mouse button to scroll through eg a listbox) [This needs a CEF change.)
master
Nicky 2016-05-27 00:27:10 +02:00
parent 8c85ec13d5
commit ccfb18948d
1 changed files with 48 additions and 10 deletions

View File

@ -100,6 +100,12 @@ private:
LLCEFLib* mLLCEFLib;
VolumeCatcher mVolumeCatcher;
U8 *mPopupBuffer;
U32 mPopupW;
U32 mPopupH;
U32 mPopupX;
U32 mPopupY;
};
////////////////////////////////////////////////////////////////////////////////
@ -127,12 +133,19 @@ MediaPluginBase(host_send_func, host_user_data)
mCookiePath = "";
mPickedFile = "";
mLLCEFLib = new LLCEFLib();
mPopupBuffer = NULL;
mPopupW = 0;
mPopupH = 0;
mPopupX = 0;
mPopupY = 0;
}
////////////////////////////////////////////////////////////////////////////////
//
MediaPluginCEF::~MediaPluginCEF()
{
delete[] mPopupBuffer;
}
////////////////////////////////////////////////////////////////////////////////
@ -155,20 +168,28 @@ void MediaPluginCEF::postDebugMessage(const std::string& msg)
//
void MediaPluginCEF::onPageChangedCallback(unsigned char* pixels, int x, int y, int width, int height, bool is_popup)
{
if (mPixels && pixels)
if( is_popup )
{
delete mPopupBuffer;
mPopupBuffer = NULL;
mPopupH = 0;
mPopupW = 0;
mPopupX = 0;
mPopupY = 0;
}
if( mPixels && pixels )
{
if (is_popup)
{
for (int line = 0; line < height; ++line)
if( width > 0 && height> 0 )
{
int inverted_y = mHeight - y - height;
int src = line * width * mDepth;
int dst = (inverted_y + line) * mWidth * mDepth + x * mDepth;
if (dst + width * mDepth < mWidth * mHeight * mDepth)
{
memcpy(mPixels + dst, pixels + src, width * mDepth);
}
mPopupBuffer = new U8[ width * height * mDepth ];
memcpy( mPopupBuffer, pixels, width * height * mDepth );
mPopupH = height;
mPopupW = width;
mPopupX = x;
mPopupY = y;
}
}
else
@ -177,6 +198,23 @@ void MediaPluginCEF::onPageChangedCallback(unsigned char* pixels, int x, int y,
{
memcpy(mPixels, pixels, mWidth * mHeight * mDepth);
}
if( mPopupBuffer && mPopupH && mPopupW )
{
U32 bufferSize = mWidth * mHeight * mDepth;
U32 popupStride = mPopupW * mDepth;
U32 bufferStride = mWidth * mDepth;
int dstY = mPopupY;
int src = 0;
int dst = dstY * mWidth * mDepth + mPopupX * mDepth;
for( int line = 0; dst + popupStride < bufferSize && line < mPopupH; ++line )
{
memcpy( mPixels + dst, mPopupBuffer + src, popupStride );
src += popupStride;
dst += bufferStride;
}
}
}
setDirty(0, 0, mWidth, mHeight);