[vlc-commits] commit: skins2(Win32 and Linux): Don't refresh a window forcefully ( Erwan Tulou )
git at videolan.org
git at videolan.org
Mon Nov 22 16:36:16 CET 2010
vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Fri Nov 19 19:31:14 2010 +0100| [812106522ea2f4a3cb9534715de2f14b3e69ae1a] | committer: Erwan Tulou
skins2(Win32 and Linux): Don't refresh a window forcefully
A good practice is to invalidate the window and leave it to the OS to decide if a repaint is or not needed.
As a side effect, this fixes some alternative task switchers (alt-tab) on WinNT (like TaskSwitcher or ATTv) that displayed a black rectangle instead of the preview of the skin, because the skin engine was not doing things the usual way.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=812106522ea2f4a3cb9534715de2f14b3e69ae1a
---
modules/gui/skins2/src/generic_layout.cpp | 2 +-
modules/gui/skins2/src/generic_window.cpp | 15 +++++++++++++++
modules/gui/skins2/src/generic_window.hpp | 3 +++
modules/gui/skins2/src/os_window.hpp | 3 +++
modules/gui/skins2/win32/win32_window.cpp | 14 ++++++++++++--
modules/gui/skins2/win32/win32_window.hpp | 3 +++
modules/gui/skins2/x11/x11_window.cpp | 7 +++++++
modules/gui/skins2/x11/x11_window.hpp | 3 +++
8 files changed, 47 insertions(+), 3 deletions(-)
diff --git a/modules/gui/skins2/src/generic_layout.cpp b/modules/gui/skins2/src/generic_layout.cpp
index 9f4392b..54d1219 100644
--- a/modules/gui/skins2/src/generic_layout.cpp
+++ b/modules/gui/skins2/src/generic_layout.cpp
@@ -236,7 +236,7 @@ void GenericLayout::refreshRect( int x, int y, int width, int height )
// first apply new shape to the window
pWindow->updateShape();
- pWindow->refresh( x, y, width, height );
+ pWindow->invalidateRect( x, y, width, height );
}
}
diff --git a/modules/gui/skins2/src/generic_window.cpp b/modules/gui/skins2/src/generic_window.cpp
index 609f1e3..1df75d1 100644
--- a/modules/gui/skins2/src/generic_window.cpp
+++ b/modules/gui/skins2/src/generic_window.cpp
@@ -179,3 +179,18 @@ void GenericWindow::setParent( GenericWindow* pParent, int x, int y, int w, int
void* handle = pParent ? pParent->getOSHandle() : NULL;
m_pOsWindow->reparent( handle, m_left, m_top, m_width, m_height );
}
+
+
+void GenericWindow::invalidateRect( int left, int top, int width, int height )
+{
+ if( m_pOsWindow )
+ {
+ // tell the OS we invalidate a window client area
+ bool b_supported =
+ m_pOsWindow->invalidateRect( left, top, width, height );
+
+ // if not supported, directly refresh the area
+ if( !b_supported )
+ refresh( left, top, width, height );
+ }
+}
diff --git a/modules/gui/skins2/src/generic_window.hpp b/modules/gui/skins2/src/generic_window.hpp
index 4f65239..a094963 100644
--- a/modules/gui/skins2/src/generic_window.hpp
+++ b/modules/gui/skins2/src/generic_window.hpp
@@ -80,6 +80,9 @@ public:
/// Refresh an area of the window
virtual void refresh( int left, int top, int width, int height ) { }
+ /// Invalidate an area of the window
+ virtual void invalidateRect( int left, int top, int width, int height );
+
/// Get the coordinates of the window
int getLeft() const { return m_left; }
int getTop() const { return m_top; }
diff --git a/modules/gui/skins2/src/os_window.hpp b/modules/gui/skins2/src/os_window.hpp
index f8af4b1..d630f83 100644
--- a/modules/gui/skins2/src/os_window.hpp
+++ b/modules/gui/skins2/src/os_window.hpp
@@ -62,6 +62,9 @@ public:
/// reparent the window
virtual void reparent( void* OSHandle, int x, int y, int w, int h ) = 0;
+ /// updateWindow (tell the OS we need to update the window)
+ virtual bool invalidateRect( int x, int y, int w, int h ) const = 0;
+
protected:
OSWindow( intf_thread_t *pIntf ): SkinObject( pIntf ) { }
};
diff --git a/modules/gui/skins2/win32/win32_window.cpp b/modules/gui/skins2/win32/win32_window.cpp
index 07abb7f..0a2a6ea 100644
--- a/modules/gui/skins2/win32/win32_window.cpp
+++ b/modules/gui/skins2/win32/win32_window.cpp
@@ -135,7 +135,17 @@ void Win32Window::reparent( void* OSHandle, int x, int y, int w, int h )
}
SetParent( m_hWnd, (HWND)OSHandle );
- MoveWindow( m_hWnd, x, y, w, h, true );
+ MoveWindow( m_hWnd, x, y, w, h, TRUE );
+}
+
+
+bool Win32Window::invalidateRect( int x, int y, int w, int h) const
+{
+ RECT rect = { x, y, x + w , y + h };
+ InvalidateRect( m_hWnd, &rect, FALSE );
+ UpdateWindow( m_hWnd );
+
+ return true;
}
@@ -165,7 +175,7 @@ void Win32Window::hide() const
void Win32Window::moveResize( int left, int top, int width, int height ) const
{
- MoveWindow( m_hWnd, left, top, width, height, true );
+ MoveWindow( m_hWnd, left, top, width, height, TRUE );
}
diff --git a/modules/gui/skins2/win32/win32_window.hpp b/modules/gui/skins2/win32/win32_window.hpp
index 6717cd7..55de604 100644
--- a/modules/gui/skins2/win32/win32_window.hpp
+++ b/modules/gui/skins2/win32/win32_window.hpp
@@ -68,6 +68,9 @@ public:
/// reparent the window
void reparent( void* OSHandle, int x, int y, int w, int h );
+ /// invalidate a window surface
+ bool invalidateRect( int x, int y, int w, int h ) const;
+
private:
/// Window handle
HWND m_hWnd;
diff --git a/modules/gui/skins2/x11/x11_window.cpp b/modules/gui/skins2/x11/x11_window.cpp
index bc2c6eb..324886a 100644
--- a/modules/gui/skins2/x11/x11_window.cpp
+++ b/modules/gui/skins2/x11/x11_window.cpp
@@ -349,4 +349,11 @@ void X11Window::toggleOnTop( bool onTop ) const
}
}
+
+bool X11Window::invalidateRect( int x, int y, int w, int h ) const
+{
+ XClearArea( XDISPLAY, m_wnd, x, y, w, h, True );
+ return true;
+}
+
#endif
diff --git a/modules/gui/skins2/x11/x11_window.hpp b/modules/gui/skins2/x11/x11_window.hpp
index 58be247..dbd2440 100644
--- a/modules/gui/skins2/x11/x11_window.hpp
+++ b/modules/gui/skins2/x11/x11_window.hpp
@@ -76,6 +76,9 @@ public:
/// reparent the window
void reparent( void* OSHandle, int x, int y, int w, int h );
+ /// invalidate a window surface
+ bool invalidateRect( int x, int y, int w, int h ) const;
+
void setFullscreen() const;
private:
More information about the vlc-commits
mailing list