diff --git a/CMakeLists.txt b/CMakeLists.txt index e25800421..94f9e89dc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,10 @@ ELSE() LIST(APPEND NEEDED_QT4_COMPONENTS "QtGui" "QtWebkit" ) ENDIF() +IF( BUILD_GUI AND UNIX AND NOT APPLE ) + FIND_PACKAGE( X11 ) +ENDIF() + macro_optional_find_package(Qt4 4.7.0 COMPONENTS ${NEEDED_QT4_COMPONENTS} ) macro_log_feature(QT4_FOUND "Qt" "A cross-platform application and UI framework" "http://qt.nokia.com" TRUE "" "If you see this, although libqt4-devel is installed, check whether \n the qtwebkit-devel package is installed as well") diff --git a/src/libtomahawk/CMakeLists.txt b/src/libtomahawk/CMakeLists.txt index a8f54f923..5b477f96d 100644 --- a/src/libtomahawk/CMakeLists.txt +++ b/src/libtomahawk/CMakeLists.txt @@ -426,6 +426,10 @@ IF( UNIX AND NOT APPLE ) infosystem/infoplugins/unix/mprispluginplayeradaptor.h infosystem/infoplugins/unix/mprisplugin.h infosystem/infoplugins/unix/fdonotifyplugin.h ) + + IF( BUILD_GUI AND X11_FOUND ) + SET( LINK_LIBRARIES ${LINK_LIBRARIES} ${X11_LIBRARIES} ) + ENDIF() ENDIF( UNIX AND NOT APPLE ) IF( WIN32 ) diff --git a/src/libtomahawk/utils/tomahawkutils.cpp b/src/libtomahawk/utils/tomahawkutils.cpp index d2a431803..eb5e0a40d 100644 --- a/src/libtomahawk/utils/tomahawkutils.cpp +++ b/src/libtomahawk/utils/tomahawkutils.cpp @@ -42,12 +42,12 @@ #ifndef TOMAHAWK_HEADLESS #include - #if defined(Q_WS_X11) - #include "tomahawkapp.h" - #include "tomahawkwindow.h" - #elif defined(Q_WS_WIN) - #include "tomahawkapp.h" - #include "tomahawkwindow.h" + #include + + #ifdef Q_WS_X11 + extern "C" { + #include + } #endif #endif @@ -519,12 +519,30 @@ setNam( QNetworkAccessManager* nam ) s_nam = QWeakPointer< QNetworkAccessManager >( nam ); } - #ifndef TOMAHAWK_HEADLESS #if defined(Q_WS_X11) void bringToFront() { + qDebug() << Q_FUNC_INFO; + QWidgetList widgetList = qApp->topLevelWidgets(); + int i = 0; + while( !widgetList.at( i )->isWindow() ) + i++; + QWidget *widget = widgetList.at( i ); + + WId winId = widget->winId(); + Display *display = XOpenDisplay( NULL ); + if ( !display ) + { + qDebug() << Q_FUNC_INFO << "Could not find display to raise"; + return; + } + + XRaiseWindow( display, winId ); + XSetInputFocus( display, winId, RevertToNone, CurrentTime ); + //widget->activateWindow(); + //widget->raise(); } #elif defined(Q_WS_WIN) void diff --git a/src/libtomahawk/utils/tomahawkutils.h b/src/libtomahawk/utils/tomahawkutils.h index aef43d509..1fe759bc5 100644 --- a/src/libtomahawk/utils/tomahawkutils.h +++ b/src/libtomahawk/utils/tomahawkutils.h @@ -21,11 +21,11 @@ #include "dllmacro.h" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define RESPATH ":/data/"