Commit 81210652 authored by Erwan Tulou's avatar 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.
parent a66bbe1e
......@@ -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 );
}
}
......
......@@ -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 );
}
}
......@@ -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; }
......
......@@ -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 ) { }
};
......
......@@ -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 );
}
......
......@@ -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;
......
......@@ -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
......@@ -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:
......
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