1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 22:26:32 +02: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 void
bringToFront() bringToFront()
{ {
#if QT_VERSION < QT_VERSION_CHECK( 5, 0, 0 ) qDebug() << Q_FUNC_INFO;
#if defined(Q_WS_X11)
{
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(); QWidget* widget = tomahawkWindow();
if ( !widget ) if ( !widget )
return; return;
@@ -330,34 +351,8 @@ bringToFront()
XSendEvent( QX11Info::display(), RootWindow( QX11Info::display(), DefaultScreen( QX11Info::display() ) ), False, SubstructureRedirectMask | SubstructureNotifyMask, &e ); 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 #else // Qt5
{ {
qDebug() << Q_FUNC_INFO;
QWidget* widget = tomahawkWindow(); QWidget* widget = tomahawkWindow();
if ( !widget ) if ( !widget )
return; return;
@@ -366,14 +361,15 @@ bringToFront()
widget->windowHandle()->showNormal(); widget->windowHandle()->showNormal();
widget->windowHandle()->requestActivate(); widget->windowHandle()->requestActivate();
#ifdef HAVE_X11 #ifdef HAVE_X11
if ( QX11Info::isPlatformX11() ) { if ( QX11Info::isPlatformX11() )
{
QX11Info::setAppTime( QX11Info::getTimestamp() ); QX11Info::setAppTime( QX11Info::getTimestamp() );
} }
#endif #endif
} }
#endif #endif
#endif
} }
#endif #endif