Commit 9fa5378b authored by Geoffroy Couprie's avatar Geoffroy Couprie

Win32: fix Win7's taskbar buttons

parent 427d73cd
...@@ -168,7 +168,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -168,7 +168,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
MainInputManager::getInstance( p_intf ); MainInputManager::getInstance( p_intf );
#ifdef WIN32 #ifdef WIN32
createTaskBarButtons(); taskbar_wmsg = RegisterWindowMessage("TaskbarButtonCreated");
#endif #endif
/************************************************************ /************************************************************
...@@ -510,6 +510,7 @@ inline void MainInterface::createStatusBar() ...@@ -510,6 +510,7 @@ inline void MainInterface::createStatusBar()
#ifdef WIN32 #ifdef WIN32
void MainInterface::createTaskBarButtons() void MainInterface::createTaskBarButtons()
{ {
taskbar_wmsg = WM_NULL;
/*Here is the code for the taskbar thumb buttons /*Here is the code for the taskbar thumb buttons
FIXME:We need pretty buttons in 16x16 px that are handled correctly by masks in Qt FIXME:We need pretty buttons in 16x16 px that are handled correctly by masks in Qt
FIXME:the play button's picture doesn't changed to pause when clicked FIXME:the play button's picture doesn't changed to pause when clicked
...@@ -553,9 +554,6 @@ void MainInterface::createTaskBarButtons() ...@@ -553,9 +554,6 @@ void MainInterface::createTaskBarButtons()
{ {
p_taskbl->vt->HrInit(p_taskbl); p_taskbl->vt->HrInit(p_taskbl);
int msg_value = RegisterWindowMessage("TaskbarButtonCreated");
//msg_Info( p_intf, "msg value: %04x", msg_value );
// Define an array of two buttons. These buttons provide images through an // Define an array of two buttons. These buttons provide images through an
// image list and also provide tooltips. // image list and also provide tooltips.
DWORD dwMask = THB_BITMAP | THB_FLAGS; DWORD dwMask = THB_BITMAP | THB_FLAGS;
...@@ -576,13 +574,19 @@ void MainInterface::createTaskBarButtons() ...@@ -576,13 +574,19 @@ void MainInterface::createTaskBarButtons()
thbButtons[2].iBitmap = 3; thbButtons[2].iBitmap = 3;
thbButtons[2].dwFlags = THBF_HIDDEN; thbButtons[2].dwFlags = THBF_HIDDEN;
HRESULT hr = p_taskbl->vt->ThumbBarSetImageList(p_taskbl, GetForegroundWindow(), himl ); HRESULT hr = p_taskbl->vt->ThumbBarSetImageList(p_taskbl, winId(), himl );
if(S_OK != hr) if(S_OK != hr)
msg_Err( p_intf, "ThumbBarSetImageList failed with error %08x", hr ); msg_Err( p_intf, "ThumbBarSetImageList failed with error %08x", hr );
if(S_OK != p_taskbl->vt->ThumbBarAddButtons(p_taskbl, GetForegroundWindow(), 3, thbButtons)) else
msg_Err( p_intf, "ThumbBarAddButtons failed with error %08x", GetLastError() ); {
hr = p_taskbl->vt->ThumbBarAddButtons(p_taskbl, winId(), 3, thbButtons);
if(S_OK != hr)
msg_Err( p_intf, "ThumbBarAddButtons failed with error %08x", hr );
}
CONNECT( THEMIM->getIM(), statusChanged( int ), this, changeThumbbarButtons( int ) ); CONNECT( THEMIM->getIM(), statusChanged( int ), this, changeThumbbarButtons( int ) );
CONNECT( this, playPauseSignal(), THEMIM, togglePlayPause() );
CONNECT( this, prevSignal(), THEMIM, prev() );
CONNECT( this, nextSignal(), THEMIM, next() );
} }
} }
else else
...@@ -591,10 +595,37 @@ void MainInterface::createTaskBarButtons() ...@@ -591,10 +595,37 @@ void MainInterface::createTaskBarButtons()
p_taskbl = NULL; p_taskbl = NULL;
} }
} }
#endif
bool MainInterface::winEvent ( MSG * msg, long * result )
{
if (msg->message == taskbar_wmsg)
{
//We received the taskbarbuttoncreated, now we can really create th buttons
createTaskBarButtons();
}
switch( msg->message )
{
case WM_COMMAND:
if (HIWORD(msg->wParam) == THBN_CLICKED)
{
switch(LOWORD(msg->wParam))
{
case 0:
emit prevSignal();
break;
case 1:
emit playPauseSignal();
break;
case 2:
emit nextSignal();
break;
}
}
break;
}
return false;
}
#endif
/********************************************************************** /**********************************************************************
* Handling of sizing of the components * Handling of sizing of the components
...@@ -1420,7 +1451,7 @@ void MainInterface::toggleFullScreen( void ) ...@@ -1420,7 +1451,7 @@ void MainInterface::toggleFullScreen( void )
void MainInterface::changeThumbbarButtons( int i_status) void MainInterface::changeThumbbarButtons( int i_status)
{ {
#ifdef WIN32 #ifdef WIN32
// Define an array of two buttons. These buttons provide images through an // Define an array of three buttons. These buttons provide images through an
// image list and also provide tooltips. // image list and also provide tooltips.
DWORD dwMask = THB_BITMAP | THB_FLAGS; DWORD dwMask = THB_BITMAP | THB_FLAGS;
...@@ -1441,14 +1472,6 @@ void MainInterface::changeThumbbarButtons( int i_status) ...@@ -1441,14 +1472,6 @@ void MainInterface::changeThumbbarButtons( int i_status)
switch( i_status ) switch( i_status )
{ {
case 0:
case END_S:
{
thbButtons[0].dwFlags = THBF_HIDDEN;
thbButtons[1].dwFlags = THBF_HIDDEN;
thbButtons[2].dwFlags = THBF_HIDDEN;
break;
}
case PLAYING_S: case PLAYING_S:
{ {
thbButtons[0].dwFlags = THBF_ENABLED; thbButtons[0].dwFlags = THBF_ENABLED;
...@@ -1459,15 +1482,16 @@ void MainInterface::changeThumbbarButtons( int i_status) ...@@ -1459,15 +1482,16 @@ void MainInterface::changeThumbbarButtons( int i_status)
} }
case PAUSE_S: case PAUSE_S:
{ {
//thbButtons[0].dwFlags = THBF_ENABLED; thbButtons[0].dwFlags = THBF_ENABLED;
//thbButtons[1].dwFlags = THBF_ENABLED; thbButtons[1].dwFlags = THBF_ENABLED;
//thbButtons[2].dwFlags = THBF_ENABLED; thbButtons[2].dwFlags = THBF_ENABLED;
thbButtons[1].iBitmap = 2; thbButtons[1].iBitmap = 2;
break; break;
} }
default:
return;
} }
HRESULT hr = p_taskbl->vt->ThumbBarUpdateButtons(p_taskbl, this->winId(), 3, thbButtons);
HRESULT hr = p_taskbl->vt->ThumbBarUpdateButtons(p_taskbl, GetForegroundWindow(), 3, thbButtons);
if(S_OK != hr) if(S_OK != hr)
msg_Err( p_intf, "ThumbBarUpdateButtons failed with error %08x", hr ); msg_Err( p_intf, "ThumbBarUpdateButtons failed with error %08x", hr );
#else #else
......
...@@ -97,6 +97,9 @@ public: ...@@ -97,6 +97,9 @@ public:
protected: protected:
void dropEventPlay( QDropEvent *, bool); void dropEventPlay( QDropEvent *, bool);
#ifdef WIN32
bool winEvent( MSG *, long * );
#endif
virtual void dropEvent( QDropEvent *); virtual void dropEvent( QDropEvent *);
virtual void dragEnterEvent( QDragEnterEvent * ); virtual void dragEnterEvent( QDragEnterEvent * );
virtual void dragMoveEvent( QDragMoveEvent * ); virtual void dragMoveEvent( QDragMoveEvent * );
...@@ -171,6 +174,7 @@ private: ...@@ -171,6 +174,7 @@ private:
#ifdef WIN32 #ifdef WIN32
HIMAGELIST himl; HIMAGELIST himl;
LPTASKBARLIST3 p_taskbl; LPTASKBARLIST3 p_taskbl;
UINT taskbar_wmsg;
void createTaskBarButtons(); void createTaskBarButtons();
#endif #endif
void createPlaylist( bool ); void createPlaylist( bool );
...@@ -222,6 +226,9 @@ signals: ...@@ -222,6 +226,9 @@ signals:
void askUpdate(); void askUpdate();
void minimalViewToggled( bool ); void minimalViewToggled( bool );
void fullscreenInterfaceToggled( bool ); void fullscreenInterfaceToggled( bool );
void playPauseSignal();
void prevSignal();
void nextSignal();
}; };
#endif #endif
...@@ -364,11 +364,9 @@ static void *Thread( void *obj ) ...@@ -364,11 +364,9 @@ static void *Thread( void *obj )
argv[argc] = NULL; argv[argc] = NULL;
} }
#endif #endif
#ifdef WIN32
QVLCApp app( p_intf, argc, argv );
#else
QVLCApp app( argc, argv ); QVLCApp app( argc, argv );
#endif
p_intf->p_sys->p_app = &app; p_intf->p_sys->p_app = &app;
......
...@@ -41,20 +41,10 @@ class QVLCApp : public QApplication ...@@ -41,20 +41,10 @@ class QVLCApp : public QApplication
Q_OBJECT Q_OBJECT
public: public:
#ifdef WIN32
QVLCApp( intf_thread_t *p_intf, int & argc, char ** argv ) : QApplication( argc, argv, true )
{
connect( this, SIGNAL(quitSignal()), this, SLOT(quit()) );
CONNECT( this, playPauseSignal(), THEMIM, togglePlayPause() );
CONNECT( this, prevSignal(), THEMIM, prev() );
CONNECT( this, nextSignal(), THEMIM, next() );
}
#else
QVLCApp( int & argc, char ** argv ) : QApplication( argc, argv, true ) QVLCApp( int & argc, char ** argv ) : QApplication( argc, argv, true )
{ {
connect( this, SIGNAL(quitSignal()), this, SLOT(quit()) ); connect( this, SIGNAL(quitSignal()), this, SLOT(quit()) );
} }
#endif
static void triggerQuit() static void triggerQuit()
{ {
...@@ -82,25 +72,6 @@ protected: ...@@ -82,25 +72,6 @@ protected:
DefWindowProc( msg->hwnd, msg->message, DefWindowProc( msg->hwnd, msg->message,
msg->wParam, msg->lParam ); msg->wParam, msg->lParam );
break; break;
case 0xC0C2: /* TaskbarButtonCreated */
break;
case WM_COMMAND:
if (HIWORD(msg->wParam) == THBN_CLICKED)
{
switch(LOWORD(msg->wParam))
{
case 0:
emit prevSignal();
break;
case 1:
emit playPauseSignal();
break;
case 2:
emit nextSignal();
break;
}
}
break;
} }
return false; return false;
} }
...@@ -109,9 +80,6 @@ protected: ...@@ -109,9 +80,6 @@ protected:
signals: signals:
void quitSignal(); void quitSignal();
void playPauseSignal();
void prevSignal();
void nextSignal();
}; };
......
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