1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-18 23:17:59 +01:00

Fixed bringToFront for Windows with Qt5.

This commit is contained in:
Christian Muehlhaeuser 2015-02-10 21:22:32 +01:00
parent 7218d112bc
commit f71fb9997b

View File

@ -300,11 +300,32 @@ tomahawkWindow()
void
bringToFront()
{
#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 )
#if defined(Q_WS_X11)
{
qDebug() << Q_FUNC_INFO;
qDebug() << Q_FUNC_INFO;
#if defined(Q_OS_WIN)
{
QWidget* widget = tomahawkWindow();
if ( !widget )
return;
widget->show();
widget->activateWindow();
widget->raise();
WId wid = widget->winId();
HWND hwndActiveWin = GetForegroundWindow();
int idActive = GetWindowThreadProcessId( hwndActiveWin, NULL );
if ( AttachThreadInput(GetCurrentThreadId(), idActive, TRUE) )
{
SetForegroundWindow( (HWND)wid );
SetFocus( (HWND)wid );
AttachThreadInput( GetCurrentThreadId(), idActive, FALSE );
}
}
#else
#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 )
{
QWidget* widget = tomahawkWindow();
if ( !widget )
return;
@ -330,34 +351,8 @@ bringToFront()
XSendEvent( QX11Info::display(), RootWindow( QX11Info::display(), DefaultScreen( QX11Info::display() ) ), False, SubstructureRedirectMask | SubstructureNotifyMask, &e );
}
#elif defined(Q_OS_WIN)
{
qDebug() << Q_FUNC_INFO;
QWidget* widget = tomahawkWindow();
if ( !widget )
return;
widget->show();
widget->activateWindow();
widget->raise();
WId wid = widget->winId();
HWND hwndActiveWin = GetForegroundWindow();
int idActive = GetWindowThreadProcessId(hwndActiveWin, NULL);
if ( AttachThreadInput(GetCurrentThreadId(), idActive, TRUE) )
{
SetForegroundWindow( (HWND)wid );
SetFocus( (HWND)wid );
AttachThreadInput(GetCurrentThreadId(), idActive, FALSE);
}
}
#endif
#else // Qt5
{
qDebug() << Q_FUNC_INFO;
QWidget* widget = tomahawkWindow();
if ( !widget )
return;
@ -366,14 +361,15 @@ bringToFront()
widget->windowHandle()->showNormal();
widget->windowHandle()->requestActivate();
#ifdef HAVE_X11
if ( QX11Info::isPlatformX11() ) {
if ( QX11Info::isPlatformX11() )
{
QX11Info::setAppTime( QX11Info::getTimestamp() );
}
#endif
}
#endif
#endif
}
#endif