1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-01-17 14:28:24 +01:00

Implement bringToFront properly for Qt5 on X11

This commit is contained in:
Dominik Schmidt 2015-02-04 17:59:02 +01:00
parent c7364b8f31
commit 9711421d8b
3 changed files with 21 additions and 4 deletions

View File

@ -159,6 +159,9 @@ if( NOT BUILD_WITH_QT4 )
find_package(Qt5WebKitWidgets REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Xml REQUIRED)
if(UNIX AND NOT APPLE)
find_package(Qt5X11Extras REQUIRED NO_MODULE)
endif()
message(STATUS "Found Qt5! Be aware that Qt5-support is still experimental and not officially supported!")
if( UNIX AND NOT APPLE )

View File

@ -411,6 +411,10 @@ IF(LIBATTICA_FOUND)
ENDIF( TOMAHAWK_QT5 )
ENDIF(LIBATTICA_FOUND)
if(UNIX AND NOT APPLE AND TOMAHAWK_QT5)
list(APPEND LINK_LIBRARIES Qt5::X11Extras)
endif()
IF( WIN32 )
SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES}

View File

@ -40,10 +40,17 @@
#include <QStyleOption>
#include <QDesktopServices>
#if QT_VERSION >= QT_VERSION_CHECK( 5, 0, 0 )
#ifdef Q_OS_LINUX
#include <QWindow>
#include <QX11Info>
#endif
#endif
//FIXME: Qt5: this doesnt fail because Q_WS_X11 is deprecated
//TODO: change to Q_OS_X11 and fix errors
#ifdef Q_WS_X11
#include <QtGui/QX11Info>
#include <libqnetwm/netwm.h>
#endif
@ -358,9 +365,12 @@ bringToFront()
if ( !widget )
return;
widget->show();
widget->activateWindow();
widget->raise();
// "Unminimize" first, otherwise the entry in the taskbar will only flash but the window won't come to front
widget->windowHandle()->showNormal();
if ( QX11Info::isPlatformX11() ) {
QX11Info::setAppTime( QX11Info::getTimestamp() );
}
}
#endif
}