diff --git a/containmentactions/switchdesktop/CMakeLists.txt b/containmentactions/switchdesktop/CMakeLists.txt index 4af7dbf06..627981ec8 100644 --- a/containmentactions/switchdesktop/CMakeLists.txt +++ b/containmentactions/switchdesktop/CMakeLists.txt @@ -1,17 +1,18 @@ set(switchdesktop_SRCS desktop.cpp ) add_library(plasma_containmentactions_switchdesktop MODULE ${switchdesktop_SRCS}) kcoreaddons_desktop_to_json(plasma_containmentactions_switchdesktop plasma-containmentactions-switchdesktop.desktop) target_link_libraries(plasma_containmentactions_switchdesktop + Qt5::Widgets KF5::Plasma KF5::WindowSystem KF5::I18n - KF5::KIOCore + KF5::KIOCore ) install(TARGETS plasma_containmentactions_switchdesktop DESTINATION ${KDE_INSTALL_PLUGINDIR}) install(FILES plasma-containmentactions-switchdesktop.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) diff --git a/containmentactions/switchwindow/CMakeLists.txt b/containmentactions/switchwindow/CMakeLists.txt index 900f21538..74a62d876 100644 --- a/containmentactions/switchwindow/CMakeLists.txt +++ b/containmentactions/switchwindow/CMakeLists.txt @@ -1,20 +1,21 @@ add_definitions(-DTRANSLATION_DOMAIN=\"plasma_containmentactions_switchwindow\") set(switchwindow_SRCS switch.cpp ) ki18n_wrap_ui(switchwindow_SRCS config.ui) add_library(plasma_containmentactions_switchwindow MODULE ${switchwindow_SRCS}) kcoreaddons_desktop_to_json(plasma_containmentactions_switchwindow plasma-containmentactions-switchwindow.desktop) target_link_libraries(plasma_containmentactions_switchwindow + Qt5::Widgets KF5::Plasma KF5::KIOCore KF5::I18n KF5::WindowSystem taskmanager) install(TARGETS plasma_containmentactions_switchwindow DESTINATION ${KDE_INSTALL_PLUGINDIR}) install(FILES plasma-containmentactions-switchwindow.desktop DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) diff --git a/libkworkspace/kworkspace.cpp b/libkworkspace/kworkspace.cpp index 555119c3f..444270d82 100644 --- a/libkworkspace/kworkspace.cpp +++ b/libkworkspace/kworkspace.cpp @@ -1,266 +1,265 @@ /* This file is part of the KDE libraries Copyright (C) 1997 Matthias Kalle Dalheimer (kalle@kde.org) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "kworkspace.h" #include "config-libkworkspace.h" -#include #include #include #include #include #include #include #include // getenv() #include #include #if HAVE_X11 #include #include #include #include #include #endif #if HAVE_X11 #define DISPLAY "DISPLAY" #elif defined(Q_WS_QWS) #define DISPLAY "QWS_DISPLAY" #endif #include "config-workspace.h" #ifdef HAVE_UNISTD_H #include #endif // HAVE_UNISTD_H #include #include #include "kworkspace_p.h" namespace KWorkSpace { #if HAVE_X11 static void save_yourself_callback( SmcConn conn_P, SmPointer, int, Bool , int, Bool ) { SmcSaveYourselfDone( conn_P, True ); } static void dummy_callback( SmcConn, SmPointer ) { } #endif KRequestShutdownHelper::KRequestShutdownHelper() { #if HAVE_X11 SmcCallbacks calls; calls.save_yourself.callback = save_yourself_callback; calls.die.callback = dummy_callback; calls.save_complete.callback = dummy_callback; calls.shutdown_cancelled.callback = dummy_callback; char* id = NULL; char err[ 11 ]; conn = SmcOpenConnection( NULL, NULL, 1, 0, SmcSaveYourselfProcMask | SmcDieProcMask | SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask, &calls, NULL, &id, 10, err ); if( id != NULL ) free( id ); if( conn == NULL ) return; // no SM // set the required properties, mostly dummy values SmPropValue propvalue[ 5 ]; SmProp props[ 5 ]; propvalue[ 0 ].length = sizeof( unsigned char ); unsigned char value0 = SmRestartNever; // so that this extra SM connection doesn't interfere propvalue[ 0 ].value = &value0; props[ 0 ].name = const_cast< char* >( SmRestartStyleHint ); props[ 0 ].type = const_cast< char* >( SmCARD8 ); props[ 0 ].num_vals = 1; props[ 0 ].vals = &propvalue[ 0 ]; struct passwd* entry = getpwuid( geteuid() ); propvalue[ 1 ].length = entry != NULL ? strlen( entry->pw_name ) : 0; propvalue[ 1 ].value = (SmPointer)( entry != NULL ? entry->pw_name : "" ); props[ 1 ].name = const_cast< char* >( SmUserID ); props[ 1 ].type = const_cast< char* >( SmARRAY8 ); props[ 1 ].num_vals = 1; props[ 1 ].vals = &propvalue[ 1 ]; propvalue[ 2 ].length = 0; propvalue[ 2 ].value = (SmPointer)( "" ); props[ 2 ].name = const_cast< char* >( SmRestartCommand ); props[ 2 ].type = const_cast< char* >( SmLISTofARRAY8 ); props[ 2 ].num_vals = 1; props[ 2 ].vals = &propvalue[ 2 ]; propvalue[ 3 ].length = strlen( "requestshutdownhelper" ); propvalue[ 3 ].value = (SmPointer)"requestshutdownhelper"; props[ 3 ].name = const_cast< char* >( SmProgram ); props[ 3 ].type = const_cast< char* >( SmARRAY8 ); props[ 3 ].num_vals = 1; props[ 3 ].vals = &propvalue[ 3 ]; propvalue[ 4 ].length = 0; propvalue[ 4 ].value = (SmPointer)( "" ); props[ 4 ].name = const_cast< char* >( SmCloneCommand ); props[ 4 ].type = const_cast< char* >( SmLISTofARRAY8 ); props[ 4 ].num_vals = 1; props[ 4 ].vals = &propvalue[ 4 ]; SmProp* p[ 5 ] = { &props[ 0 ], &props[ 1 ], &props[ 2 ], &props[ 3 ], &props[ 4 ] }; SmcSetProperties( conn, 5, p ); notifier = new QSocketNotifier( IceConnectionNumber( SmcGetIceConnection( conn )), QSocketNotifier::Read, this ); connect( notifier, &QSocketNotifier::activated, this, &KRequestShutdownHelper::processData); #endif } KRequestShutdownHelper::~KRequestShutdownHelper() { #if HAVE_X11 if( conn != NULL ) { delete notifier; SmcCloseConnection( conn, 0, NULL ); } #endif } void KRequestShutdownHelper::processData() { #if HAVE_X11 if( conn != NULL ) IceProcessMessages( SmcGetIceConnection( conn ), 0, 0 ); #endif } bool KRequestShutdownHelper::requestShutdown( ShutdownConfirm confirm ) { #if HAVE_X11 if( conn == NULL ) return false; SmcRequestSaveYourself( conn, SmSaveBoth, True, SmInteractStyleAny, confirm == ShutdownConfirmNo, True ); // flush the request IceFlush(SmcGetIceConnection(conn)); #endif return true; } #if HAVE_X11 static KRequestShutdownHelper* helper = NULL; static void cleanup_sm() { delete helper; } #endif void requestShutDown(ShutdownConfirm confirm, ShutdownType sdtype, ShutdownMode sdmode) { #if HAVE_X11 /* use ksmserver's dcop interface if necessary */ if ( confirm == ShutdownConfirmYes || sdtype != ShutdownTypeDefault || sdmode != ShutdownModeDefault ) { org::kde::KSMServerInterface ksmserver(QStringLiteral("org.kde.ksmserver"), QStringLiteral("/KSMServer"), QDBusConnection::sessionBus()); ksmserver.logout((int)confirm, (int)sdtype, (int)sdmode); return; } if( helper == NULL ) { helper = new KRequestShutdownHelper(); qAddPostRoutine(cleanup_sm); } helper->requestShutdown( confirm ); #endif } bool canShutDown( ShutdownConfirm confirm, ShutdownType sdtype, ShutdownMode sdmode ) { #if HAVE_X11 if ( confirm == ShutdownConfirmYes || sdtype != ShutdownTypeDefault || sdmode != ShutdownModeDefault ) { org::kde::KSMServerInterface ksmserver(QStringLiteral("org.kde.ksmserver"), QStringLiteral("/KSMServer"), QDBusConnection::sessionBus()); QDBusReply reply = ksmserver.canShutdown(); if (!reply.isValid()) { return false; } return reply; } return true; #else return false; #endif } bool isShuttingDown() { org::kde::KSMServerInterface ksmserver(QStringLiteral("org.kde.ksmserver"), QStringLiteral("/KSMServer"), QDBusConnection::sessionBus()); QDBusReply reply = ksmserver.isShuttingDown(); if (!reply.isValid()) { return false; } return reply; } static QTime smModificationTime; void propagateSessionManager() { #if HAVE_X11 QByteArray fName = QFile::encodeName(QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation)+"/KSMserver"); QString display = QString::fromLocal8Bit( ::getenv(DISPLAY) ); // strip the screen number from the display display.remove(QRegExp(QStringLiteral("\\.[0-9]+$"))); int i; while( (i = display.indexOf(':')) >= 0) display[i] = '_'; while( (i = display.indexOf('/')) >= 0) display[i] = '_'; fName += '_'; fName += display.toLocal8Bit(); QByteArray smEnv = ::getenv("SESSION_MANAGER"); bool check = smEnv.isEmpty(); if ( !check && smModificationTime.isValid() ) { QFileInfo info( fName ); QTime current = info.lastModified().time(); check = current > smModificationTime; } if ( check ) { QFile f( fName ); if ( !f.open( QIODevice::ReadOnly ) ) return; QFileInfo info ( f ); smModificationTime = QTime( info.lastModified().time() ); QTextStream t(&f); t.setCodec( "ISO 8859-1" ); QString s = t.readLine(); f.close(); ::setenv( "SESSION_MANAGER", s.toLatin1(), true ); } #endif } } // end namespace diff --git a/libtaskmanager/xwindowtasksmodel.h b/libtaskmanager/xwindowtasksmodel.h index 51961c654..713d982e7 100644 --- a/libtaskmanager/xwindowtasksmodel.h +++ b/libtaskmanager/xwindowtasksmodel.h @@ -1,238 +1,239 @@ /******************************************************************** Copyright 2016 Eike Hein This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . *********************************************************************/ #ifndef XWINDOWTASKSMODEL_H #define XWINDOWTASKSMODEL_H #include "abstractwindowtasksmodel.h" #include "taskmanager_export.h" #include +#include #include namespace TaskManager { /** * @short A tasks model for X Windows windows. * * This model presents tasks sourced from window data on the X Windows * server the host process is connected to. * * For the purposes of presentation in a user interface and efficiency, * certain types of windows (e.g. utility windows, or windows that are * transients for an otherwise-included window) are omitted from the * model. * * @author Eike Hein */ class TASKMANAGER_EXPORT XWindowTasksModel : public AbstractWindowTasksModel { Q_OBJECT public: explicit XWindowTasksModel(QObject *parent = 0); virtual ~XWindowTasksModel(); virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; virtual int rowCount(const QModelIndex &parent = QModelIndex()) const override; /** * Request activation of the window at the given index. * * If the window has a transient demanding attention, it will be * activated instead. * * If the window has a transient in shaded state, it will be * activated instead. * * @param index An index in this window tasks model. **/ void requestActivate(const QModelIndex &index) override; /** * Request an additional instance of the application owning the window * at the given index. Success depends on whether a * AbstractTasksModel::LauncherUrl could be derived from window metadata. * * @param index An index in this window tasks model. **/ void requestNewInstance(const QModelIndex &index) override; /** * Runs the application backing the launcher at the given index with the given URLs. * Success depends on whether a AbstractTasksModel::LauncherUrl could be * derived from window metadata and a KService could be found from that. * * @param index An index in this launcher tasks model * @param urls The URLs to be passed to the application */ void requestOpenUrls(const QModelIndex &index, const QList &urls) override; /** * Request the window at the given index be closed. * * @param index An index in this window tasks model. **/ void requestClose(const QModelIndex &index) override; /** * Request starting an interactive move for the window at the given index. * * If the window is not currently the active window, it will be activated. * * If the window is not on the current desktop, the current desktop will * be set to the window's desktop. * FIXME: Desktop logic should maybe move into proxy. * * @param index An index in this window tasks model. **/ void requestMove(const QModelIndex &index) override; /** * Request starting an interactive resize for the window at the given index. * * If the window is not currently the active window, it will be activated. * * If the window is not on the current desktop, the current desktop will * be set to the window's desktop. * FIXME: Desktop logic should maybe move into proxy. * * @param index An index in this window tasks model. **/ void requestResize(const QModelIndex &index) override; /** * Request toggling the minimized state of the window at the given index. * * If the window is not on the current desktop, the current desktop will * be set to the window's desktop. * FIXME: Desktop logic should maybe move into proxy. * * @param index An index in this window tasks model. **/ void requestToggleMinimized(const QModelIndex &index) override; /** * Request toggling the maximized state of the task at the given index. * * If the window is not on the current desktop, the current desktop will * be set to the window's desktop. * FIXME: Desktop logic should maybe move into proxy. * * @param index An index in this window tasks model. **/ void requestToggleMaximized(const QModelIndex &index) override; /** * Request toggling the keep-above state of the task at the given index. * * @param index An index in this window tasks model. **/ void requestToggleKeepAbove(const QModelIndex &index) override; /** * Request toggling the keep-below state of the task at the given index. * * @param index An index in this window tasks model. **/ void requestToggleKeepBelow(const QModelIndex &index) override; /** * Request toggling the fullscreen state of the task at the given index. * * @param index An index in this window tasks model. **/ void requestToggleFullScreen(const QModelIndex &index) override; /** * Request toggling the shaded state of the task at the given index. * * @param index An index in this window tasks model. **/ void requestToggleShaded(const QModelIndex &index) override; /** * Request moving the window at the given index to the specified virtual * desktop. * * If the specified virtual desktop is 0, IsOnAllVirtualDesktops is * toggled instead. * * If the specified desktop number exceeds the number of virtual * desktops in the session, a new desktop is created before moving * the window. * * FIXME: Desktop logic should maybe move into proxy. * * @param index An index in this window tasks model. * @param desktop A virtual desktop number. **/ void requestVirtualDesktop(const QModelIndex &index, qint32 desktop) override; /** * Request moving the task at the given index to the specified activities. * * This is meant for tasks that have an associated window, and may be * a no-op when there is no window. * * * @param index An index in this tasks model. * @param activities The new list of activities. **/ void requestActivities(const QModelIndex &index, const QStringList &activities) override; /** * Request informing the window manager of new geometry for a visual * delegate for the window at the given index. * * @param index An index in this window tasks model. * @param geometry Visual delegate geometry in screen coordinates. * @param delegate The delegate. Unused in this implementation. **/ void requestPublishDelegateGeometry(const QModelIndex &index, const QRect &geometry, QObject *delegate = nullptr) override; /** * Tries to extract a X11 window id from supplied mime data. * * @param mimeData Some mime data. * @param @ok Set to true or false on success or failure. */ static WId winIdFromMimeData(const QMimeData *mimeData, bool *ok = 0); /** * Tries to extract X11 window ids from supplied mime data. * * @param mimeData Some mime data. * @param @ok Set to true or false on success or failure. */ static QList winIdsFromMimeData(const QMimeData *mimeData, bool *ok = 0); private: class Private; QScopedPointer d; }; } #endif