]> git.sesse.net Git - vlc/commitdiff
skins(Win32): replace GetWindowDC with GetDC
authorErwan Tulou <erwan10@videolan.org>
Mon, 1 Mar 2010 17:16:47 +0000 (18:16 +0100)
committerErwan Tulou <erwan10@videolan.org>
Mon, 1 Mar 2010 20:58:29 +0000 (21:58 +0100)
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)

modules/gui/skins2/src/generic_layout.cpp
modules/gui/skins2/src/generic_layout.hpp
modules/gui/skins2/src/top_window.cpp
modules/gui/skins2/src/top_window.hpp
modules/gui/skins2/win32/win32_graphics.cpp
modules/gui/skins2/win32/win32_tooltip.cpp

index 217d3b0ba8df2abeed116ec47f41a0c1d4a87bee..731d8dd75c1fe87147fb2f7c0e2348ea4d599914 100644 (file)
@@ -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
-
 }
 
 
index 5b6f46d7ea82c3af24bbe36c9a7ed3248289e2cd..a730d19961662f8baa4ece7571251ea9b5d30dbf 100644 (file)
@@ -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 );
 
index 1b355ebf0fa891d6fbd7815578b3e4ea2f9f6c21..c6c71423ab3dd251548e2b638552f2c4b221afa8 100644 (file)
@@ -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());
index 653e41525715994a8c9af613c1d017a908da3a2e..254bdc7cb009bfcec8962f82b2d8682502564806 100644 (file)
@@ -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 );
index bee4a09030db0b16dfc2d5ab71d4e596661af64e..8a6536c8224330a4dbdf9b18ba2142a619ee7bb9 100644 (file)
@@ -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
index 34d4487852fe9dbb582f8e722596f51f5839baeb..09585848611b945928e5ec2b598961d7145c5fb2 100644 (file)
@@ -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 );
 }