Commit 4ad06d10 authored by Erwan Tulou's avatar Erwan Tulou

skins(Win32): replace GetWindowDC with GetDC

GetWindowDC paints in nonclient area (not recommended on msdn)
and not needed for skins. Also, it doesn't take WS_CLIPCHILDREN
into account and forced to add a lengthy hack which can now be removed.

This patch hopefully could also fix a refresh issue found only on
Vista/Win7 (to be tested) (http://forum.videolan.org/viewtopic.php?f=15&t=68891)
parent 88d39cee
......@@ -247,134 +247,8 @@ void GenericLayout::refreshRect( int x, int y, int width, int height )
if( y + height > m_rect.getHeight() )
height = m_rect.getHeight() - y;
computeRefresh( x, y, width, height );
}
}
class rect
{
public:
rect( int v_x = 0, int v_y = 0, int v_width = 0, int v_height = 0 )
: x( v_x ), y( v_y ), width( v_width ), height( v_height ) { }
~rect() { }
int x;
int y;
int width;
int height;
static bool isIncluded( rect& rect2, rect& rect1 )
{
int x1 = rect1.x;
int y1 = rect1.y;
int w1 = rect1.width;
int h1 = rect1.height;
int x2 = rect2.x;
int y2 = rect2.y;
int w2 = rect2.width;
int h2 = rect2.height;
return x2 >= x1 && x2 < x1 + w1
&& y2 >= y1 && y2 < y1 + h1
&& w2 <= w1
&& h2 <= h1;
}
};
void GenericLayout::computeRefresh( int x, int y, int width, int height )
{
TopWindow *pWindow = getWindow();
#ifndef WIN32
pWindow->refresh( x, y, width, height );
#else
if( !m_pVideoCtrlSet.size() )
{
// No video control, we can safely repaint the rectangle
pWindow->refresh( x, y, width, height );
return;
}
int w = width;
int h = height;
set<int> x_set;
set<int> y_set;
vector<rect> rect_set;
x_set.insert( x + w );
y_set.insert( y + h );
// retrieve video controls being used
// and remember their rectangles
set<CtrlVideo*>::const_iterator it;
for( it = m_pVideoCtrlSet.begin(); it != m_pVideoCtrlSet.end(); it++ )
{
if( (*it)->isUsed() )
{
int xx = (*it)->getPosition()->getLeft();
int yy = (*it)->getPosition()->getTop();
int ww = (*it)->getPosition()->getWidth();
int hh = (*it)->getPosition()->getHeight();
rect r(xx, yy, ww, hh );
rect_set.push_back( r );
if( xx > x && xx < x + w )
x_set.insert( xx );
if( xx + ww > x && xx + ww < x + w )
x_set.insert( xx + ww );
if( yy > y && yy < y + h )
y_set.insert( yy );
if( yy + hh > y && yy + hh < y + h )
y_set.insert( yy + hh );
}
}
// for each subregion, test whether they are part
// of the video control(s) or not
set<int>::const_iterator it_x;
set<int>::const_iterator it_y;
int x_prev, y_prev;
for( x_prev = x, it_x = x_set.begin();
it_x != x_set.end(); x_prev = *it_x, it_x++ )
{
int x0 = x_prev;
int w0 = *it_x - x_prev;
for( y_prev = y, it_y = y_set.begin();
it_y != y_set.end(); y_prev = *it_y, it_y++ )
{
int y0 = y_prev;
int h0 = *it_y - y_prev;
rect r( x0, y0, w0, h0 );
bool b_refresh = true;
vector<rect>::iterator it;
for( it = rect_set.begin(); it != rect_set.end(); it++ )
{
rect r_ctrl = *it;
if( rect::isIncluded( r, r_ctrl ) )
{
b_refresh = false;
break;
}
}
// subregion is not part of a video control
// needs to be refreshed
if( b_refresh )
pWindow->refresh( x0, y0, w0 ,h0 );
}
}
#endif
}
......
......@@ -104,9 +104,6 @@ public:
virtual int getMinHeight() const { return m_minHeight; }
virtual int getMaxHeight() const { return m_maxHeight; }
/// specific refresh window (if video controls)
virtual void computeRefresh( int x, int y, int width, int height );
/// Resize the layout
virtual void resize( int width, int height );
......
......@@ -72,24 +72,6 @@ TopWindow::~TopWindow()
}
void TopWindow::processEvent( EvtRefresh &rEvtRefresh )
{
// We override the behaviour defined in GenericWindow, because we don't
// want to draw on a video control!
if( m_pActiveLayout == NULL )
{
GenericWindow::processEvent( rEvtRefresh );
}
else
{
m_pActiveLayout->computeRefresh( rEvtRefresh.getXStart(),
rEvtRefresh.getYStart(),
rEvtRefresh.getWidth(),
rEvtRefresh.getHeight() );
}
}
void TopWindow::processEvent( EvtFocus &rEvtFocus )
{
// fprintf(stderr, rEvtFocus.getAsString().c_str());
......
......@@ -48,7 +48,6 @@ public:
virtual ~TopWindow();
/// Methods to process OS events.
virtual void processEvent( EvtRefresh &rEvtRefresh );
virtual void processEvent( EvtFocus &rEvtFocus );
virtual void processEvent( EvtMenu &rEvtMenu );
virtual void processEvent( EvtMotion &rEvtMotion );
......
......@@ -328,7 +328,7 @@ void Win32Graphics::copyToWindow( OSWindow &rWindow, int xSrc, int ySrc,
{
// Initialize painting
HWND hWnd = ((Win32Window&)rWindow).getHandle();
HDC wndDC = GetWindowDC( hWnd );
HDC wndDC = GetDC( hWnd );
HDC srcDC = m_hDC;
// Draw image on window
......
......@@ -64,7 +64,7 @@ void Win32Tooltip::show( int left, int top, OSGraphics &rText )
SetWindowPos( m_hWnd, HWND_TOPMOST, left, top, width, height, 0 );
ShowWindow( m_hWnd, SW_SHOW );
HDC wndDC = GetWindowDC( m_hWnd );
HDC wndDC = GetDC( m_hWnd );
BitBlt( wndDC, 0, 0, width, height, srcDC, 0, 0, SRCCOPY );
ReleaseDC( m_hWnd, wndDC );
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment