Commit 64c2daf4 authored by Erwan Tulou's avatar Erwan Tulou

skins2: rework and simplify transparency

Several redraw were no longer needed
(tested successfully on Ubuntu/metacity and WinNT)

On Win32, switching back and forth between layered Window and not layered
 window (case where only one of the two alpha parameters is < 255) was removed
because display was not satisfactory. (transition a bit weird)
parent af5900ae
......@@ -33,13 +33,15 @@
WindowManager::WindowManager( intf_thread_t *pIntf ):
SkinObject( pIntf ), m_magnet( 0 ), m_direction( kNone ),
m_maximizeRect(0, 0, 50, 50),
m_pTooltip( NULL ), m_pPopup( NULL )
m_maximizeRect(0, 0, 50, 50), m_pTooltip( NULL ), m_pPopup( NULL ),
m_alpha( 255 ), m_moveAlpha( 255 ), m_OpacityEnabled( false )
{
// Create and register a variable for the "on top" status
VarManager *pVarManager = VarManager::instance( getIntf() );
m_cVarOnTop = VariablePtr( new VarBoolImpl( getIntf() ) );
pVarManager->registerVar( m_cVarOnTop, "vlc.isOnTop" );
m_OpacityEnabled = var_InheritBool( getIntf(), "skins2-transparency" );
}
......@@ -71,7 +73,7 @@ void WindowManager::startMove( TopWindow &rWindow )
m_movingWindows.clear();
buildDependSet( m_movingWindows, &rWindow );
if( var_InheritBool( getIntf(), "skins2-transparency" ) )
if( isOpacityNeeded() )
{
// Change the opacity of the moving windows
WinSet_t::const_iterator it;
......@@ -79,14 +81,6 @@ void WindowManager::startMove( TopWindow &rWindow )
{
(*it)->setOpacity( m_moveAlpha );
}
// FIXME: We need to refresh the windows, because if 2 windows overlap
// and one of them becomes transparent, the other one is not refreshed
// automatically. I don't know why... -- Ipkiss
for( it = m_allWindows.begin(); it != m_allWindows.end(); ++it )
{
(*it)->refresh( 0, 0, (*it)->getWidth(), (*it)->getHeight() );
}
}
}
......@@ -96,7 +90,7 @@ void WindowManager::stopMove()
WinSet_t::const_iterator itWin1, itWin2;
AncList_t::const_iterator itAnc1, itAnc2;
if( var_InheritBool( getIntf(), "skins2-transparency" ) )
if( isOpacityNeeded() )
{
// Restore the opacity of the moving windows
WinSet_t::const_iterator it;
......@@ -429,6 +423,15 @@ void WindowManager::showAll( bool firstTime ) const
}
void WindowManager::show( TopWindow &rWindow ) const
{
rWindow.show();
if( isOpacityNeeded() )
rWindow.setOpacity( m_alpha );
}
void WindowManager::hideAll() const
{
WinSet_t::const_iterator it;
......
......@@ -120,8 +120,7 @@ public:
void raise( TopWindow &rWindow ) const { rWindow.raise(); }
/// Show the given window
void show( TopWindow &rWindow ) const
{ rWindow.show(); rWindow.setOpacity( m_alpha); }
void show( TopWindow &rWindow ) const;
/// Hide the given window
void hide( TopWindow &rWindow ) const { rWindow.hide(); }
......@@ -163,6 +162,10 @@ public:
/// Return the active popup, or NULL if none is active
Popup * getActivePopup() const { return m_pPopup; }
/// getter to know whether opacity is needed
bool isOpacityNeeded() const
{ return (m_OpacityEnabled && (m_alpha != 255 || m_moveAlpha != 255 )); }
private:
/// Some useful typedefs for lazy people like me
typedef set<TopWindow*> WinSet_t;
......@@ -206,6 +209,8 @@ private:
int m_alpha;
/// Alpha value of the moving windows
int m_moveAlpha;
/// transparency set by user
bool m_OpacityEnabled;
/// Direction of the current resizing
Direction_t m_direction;
/// Rect of the last maximized window
......
......@@ -190,44 +190,17 @@ void Win32Window::setOpacity( uint8_t value ) const
{
Win32Factory *pFactory = (Win32Factory*)Win32Factory::instance( getIntf() );
if( value == 255 )
if( !m_isLayered )
{
// If the window is opaque, we remove the WS_EX_LAYERED attribute
// which slows down resizing for nothing
if( m_isLayered )
{
SetWindowLongPtr( m_hWnd, GWL_EXSTYLE,
GetWindowLongPtr( m_hWnd, GWL_EXSTYLE ) & ~WS_EX_LAYERED );
// Redraw the window, otherwise we may end up with a grey rectangle
// for some strange reason
RedrawWindow(m_hWnd, NULL, NULL,
RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
// add the WS_EX_LAYERED attribute.
SetWindowLongPtr( m_hWnd, GWL_EXSTYLE,
GetWindowLongPtr( m_hWnd, GWL_EXSTYLE ) | WS_EX_LAYERED );
m_isLayered = false;
}
m_isLayered = true;
}
else
{
if( ! m_isLayered )
{
// (Re)Add the WS_EX_LAYERED attribute.
// Resizing will be very slow, now :)
SetWindowLongPtr( m_hWnd, GWL_EXSTYLE,
GetWindowLongPtr( m_hWnd, GWL_EXSTYLE ) | WS_EX_LAYERED );
// Redraw the window, otherwise we may end up with a grey
// rectangle for some strange reason
RedrawWindow(m_hWnd, NULL, NULL,
RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
m_isLayered = true;
}
// Change the opacity
SetLayeredWindowAttributes(
m_hWnd, 0, value, LWA_ALPHA|LWA_COLORKEY );
}
// Change the opacity
SetLayeredWindowAttributes( m_hWnd, 0, value, LWA_ALPHA );
}
......
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