diff --git a/CMakeLists.txt b/CMakeLists.txt index b78aaf4e0..d9f4f2fa4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -413,10 +413,6 @@ if(NOT X11_Xext_FOUND) katie_config(QT_NO_XSYNC) katie_config(QT_NO_XSHAPE) endif() -if(NOT X11_SM_FOUND OR NOT X11_ICE_FOUND) - message(WARNING "The X11 SM/ICE was not found thus disabling session manager support") - katie_config(QT_NO_SESSIONMANAGER) -endif() configure_file( ${CMAKE_SOURCE_DIR}/src/core/global/qconfig.h.cmake diff --git a/package/freebsd/pkg-plist b/package/freebsd/pkg-plist index 36122c1fa..41f3561c1 100644 --- a/package/freebsd/pkg-plist +++ b/package/freebsd/pkg-plist @@ -486,7 +486,6 @@ include/katie/QtGui/QRubberBand include/katie/QtGui/QScrollArea include/katie/QtGui/QScrollBar include/katie/QtGui/QSequentialAnimationGroup -include/katie/QtGui/QSessionManager include/katie/QtGui/QShortcut include/katie/QtGui/QShortcutEvent include/katie/QtGui/QShowEvent @@ -743,7 +742,6 @@ include/katie/QtGui/qrubberband.h include/katie/QtGui/qscrollarea.h include/katie/QtGui/qscrollbar.h include/katie/QtGui/qsequentialanimationgroup.h -include/katie/QtGui/qsessionmanager.h include/katie/QtGui/qshortcut.h include/katie/QtGui/qsizegrip.h include/katie/QtGui/qsizepolicy.h diff --git a/scripts/namefsck.py b/scripts/namefsck.py index 082352189..2979ec172 100755 --- a/scripts/namefsck.py +++ b/scripts/namefsck.py @@ -357,7 +357,6 @@ classlist = [ "QScrollBar", "QSemaphore", "QSequentialAnimationGroup", - "QSessionManager", "QSet", "QSetIterator", "QSettings", diff --git a/src/core/global/qconfig.h.cmake b/src/core/global/qconfig.h.cmake index b67b1e88a..b3f355f2d 100644 --- a/src/core/global/qconfig.h.cmake +++ b/src/core/global/qconfig.h.cmake @@ -72,7 +72,6 @@ #cmakedefine QT_NO_CUPS #cmakedefine QT_NO_EXECINFO #cmakedefine QT_NO_FONTCONFIG -#cmakedefine QT_NO_SESSIONMANAGER #cmakedefine QT_NO_TRANSLATION #cmakedefine QT_NO_XCURSOR #cmakedefine QT_NO_XFIXES diff --git a/src/core/io/qfilesystemengine_unix.cpp b/src/core/io/qfilesystemengine_unix.cpp index 2d57e536b..152d0205e 100644 --- a/src/core/io/qfilesystemengine_unix.cpp +++ b/src/core/io/qfilesystemengine_unix.cpp @@ -130,7 +130,8 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) return QFileSystemEntry(stringVersion); } -Q_CORE_EXPORT QString qt_resolveUserName(uint userId) +//static +QString QFileSystemEngine::resolveUserName(uint userId) { #if !defined(QT_NO_THREAD) static long size_max = sysconf(_SC_GETPW_R_SIZE_MAX); @@ -148,12 +149,6 @@ Q_CORE_EXPORT QString qt_resolveUserName(uint userId) return QString(); } -//static -QString QFileSystemEngine::resolveUserName(uint userId) -{ - return qt_resolveUserName(userId); -} - //static QString QFileSystemEngine::resolveGroupName(uint groupId) { diff --git a/src/core/io/qsettings.cpp b/src/core/io/qsettings.cpp index 57f38b549..fae41c5d7 100644 --- a/src/core/io/qsettings.cpp +++ b/src/core/io/qsettings.cpp @@ -350,8 +350,6 @@ QString QSettingsPrivate::toGroupKey(const QString &key) const If you want to read an INI file directly, you can use the QSettings constructor that takes a file name as first argument. You can then use the QSettings object to read and write settingsin the file. - - \sa QSessionManager */ /*! \enum QSettings::SettingsStatus diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 95e1c09d3..7c4c24f89 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -132,7 +132,6 @@ set(GUI_PUBLIC_HEADERS QRubberBand QScrollArea QScrollBar - QSessionManager QShortcut QSizeGrip QSizePolicy @@ -353,7 +352,6 @@ set(GUI_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qlayout_p.h ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qlayoutengine_p.h ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qlayoutitem.h - ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qsessionmanager.h ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qshortcut.h ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qshortcutmap_p.h ${CMAKE_CURRENT_SOURCE_DIR}/kernel/qsizepolicy.h @@ -828,7 +826,7 @@ set(GUI_SOURCES ) # keep in sync with the top-level CMake file, only libraries setup is needed here -foreach(x11ext Xshape Xinerama Xrandr Xrender Xfixes Xcursor Xext SM ICE) +foreach(x11ext Xshape Xinerama Xrandr Xrender Xfixes Xcursor Xext) if(X11_${x11ext}_FOUND AND X11_${x11ext}_LIB) set(EXTRA_GUI_LIBS ${EXTRA_GUI_LIBS} diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 00ae584c2..544cc6f83 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -32,7 +32,6 @@ #include "qhash.h" #include "qset.h" #include "qlayout.h" -#include "qsessionmanager.h" #include "qstyle.h" #include "qstylefactory.h" #include "qtextcodec.h" @@ -77,11 +76,6 @@ bool QApplicationPrivate::autoSipEnabled = true; QApplicationPrivate::QApplicationPrivate(int &argc, char **argv) : QCoreApplicationPrivate(argc, argv) -#ifndef QT_NO_SESSIONMANAGER - , session_manager(nullptr) - , is_session_restored(false) -#endif - { QCoreApplicationPrivate::app_type = QCoreApplication::Gui; @@ -104,9 +98,8 @@ QApplicationPrivate::~QApplicationPrivate() QApplication contains the main event loop, where all events from the window system and other sources are processed and dispatched. It also handles the - application's initialization, finalization, and provides session - management. In addition, QApplication handles most of the system-wide and - application-wide settings. + application's initialization and finalization. In addition, QApplication + handles most of the system-wide and application-wide settings. For any GUI application using Qt, there is precisely \bold one QApplication object, no matter whether the application has 0, 1, 2 or more windows at @@ -151,14 +144,6 @@ QApplicationPrivate::~QApplicationPrivate() \o On the X window system, it provides functions to flush and sync the communication stream, see flushX() and syncX(). - - \o It provides support for sophisticated \l{Session Management} - {session management}. This makes it possible for applications - to terminate gracefully when the user logs out, to cancel a - shutdown process if termination isn't possible and even to - preserve the entire application's state for a future session. - See isSessionRestored(), sessionId() and commitData() and - saveState() for details. \endlist Since the QApplication object does so much initialization, it \e{must} be @@ -235,13 +220,6 @@ QApplicationPrivate::~QApplicationPrivate() \o flushX(), syncX(). - \row - \o Session management - \o isSessionRestored(), - sessionId(), - commitData(), - saveState(). - \row \o Miscellaneous \o closeAllWindows(), @@ -354,19 +332,6 @@ void QApplicationPrivate::process_cmdline() s = QString::fromLocal8Bit(argv[i] + 7).toLower(); } else if (qstrcmp(argv[i], "-style") == 0 && i < argc - 1) { s = QString::fromLocal8Bit(argv[++i]).toLower(); -#ifndef QT_NO_SESSIONMANAGER - } else if (qstrcmp(argv[i], "-session") == 0 && i < argc - 1) { - ++i; - if (argv[i] && *argv[i]) { - session_id = QString::fromLatin1(argv[i]); - int p = session_id.indexOf(QLatin1Char('_')); - if (p >= 0) { - session_key = session_id.mid(p +1); - session_id = session_id.left(p); - } - is_session_restored = true; - } -#endif } else if (qstrcmp(argv[i], "-reverse") == 0) { force_reverse = true; QApplication::setLayoutDirection(Qt::RightToLeft); @@ -419,9 +384,6 @@ void QApplicationPrivate::process_cmdline() additional styles or have additional styles as plugins these will be available to the \c -style command line option. \o -style \e style, is the same as listed above. - \o -session= \e session, restores the application from an earlier - \l{Session Management}{session}. - \o -session \e session, is the same as listed above. \o -reverse, sets the application's layout direction to Qt::RightToLeft \endlist @@ -479,11 +441,6 @@ void QApplicationPrivate::construct(Display *dpy, Qt::HANDLE visual, Qt::HANDLE is_app_running = true; // no longer starting up Q_Q(QApplication); -#ifndef QT_NO_SESSIONMANAGER - // connect to the session manager - session_manager = new QSessionManager(q, session_id, session_key); -#endif - if (qgetenv("QT_USE_NATIVE_WINDOWS").toInt() > 0) q->setAttribute(Qt::AA_NativeWindows); } @@ -664,11 +621,6 @@ QApplication::~QApplication() qt_cleanup(); -#ifndef QT_NO_SESSIONMANAGER - delete d->session_manager; - d->session_manager = nullptr; -#endif //QT_NO_SESSIONMANAGER - QApplicationPrivate::cursor_flash_time = 1000; QApplicationPrivate::mouse_double_click_time = 400; QApplicationPrivate::keyboard_input_time = 400; @@ -2276,222 +2228,6 @@ Qt::MouseButtons QApplication::mouseButtons() return QApplicationPrivate::mouse_buttons; } -/*! - \fn bool QApplication::isSessionRestored() const - - Returns true if the application has been restored from an earlier - \l{Session Management}{session}; otherwise returns false. - - \sa sessionId(), commitData(), saveState() -*/ - - -/*! - \fn QString QApplication::sessionId() const - - Returns the current \l{Session Management}{session's} identifier. - - If the application has been restored from an earlier session, this - identifier is the same as it was in that previous session. The session - identifier is guaranteed to be unique both for different applications - and for different instances of the same application. - - \sa isSessionRestored(), sessionKey(), commitData(), saveState() -*/ - -/*! - \fn QString QApplication::sessionKey() const - - Returns the session key in the current \l{Session Management}{session}. - - If the application has been restored from an earlier session, this key is - the same as it was when the previous session ended. - - The session key changes with every call of commitData() or saveState(). - - \sa isSessionRestored(), sessionId(), commitData(), saveState() -*/ -#ifndef QT_NO_SESSIONMANAGER -bool QApplication::isSessionRestored() const -{ - Q_D(const QApplication); - return d->is_session_restored; -} - -QString QApplication::sessionId() const -{ - Q_D(const QApplication); - return d->session_id; -} - -QString QApplication::sessionKey() const -{ - Q_D(const QApplication); - return d->session_key; -} -#endif - -/*! - \since 4.7.4 - \fn void QApplication::aboutToReleaseGpuResources() - - This signal is emitted when application is about to release all - GPU resources associated to contexts owned by application. - - The signal is particularly useful if your application has allocated - GPU resources directly apart from Qt and needs to do some last-second - cleanup. - - \warning This signal is only emitted on Symbian. - - \sa aboutToUseGpuResources() -*/ - -/*! - \since 4.7.4 - \fn void QApplication::aboutToUseGpuResources() - - This signal is emitted when application is about to use GPU resources. - - The signal is particularly useful if your application needs to know - when GPU resources are be available. - - \warning This signal is only emitted on Symbian. - - \sa aboutToReleaseGpuResources() -*/ - -/*! - \since 4.2 - \fn void QApplication::commitDataRequest(QSessionManager &manager) - - This signal deals with \l{Session Management}{session management}. It is - emitted when the QSessionManager wants the application to commit all its - data. - - Usually this means saving all open files, after getting permission from - the user. Furthermore you may want to provide a means by which the user - can cancel the shutdown. - - You should not exit the application within this signal. Instead, - the session manager may or may not do this afterwards, depending on the - context. - - \warning Within this signal, no user interaction is possible, \e - unless you ask the \a manager for explicit permission. See - QSessionManager::allowsInteraction() and - QSessionManager::allowsErrorInteraction() for details and example - usage. - - \note You should use Qt::DirectConnection when connecting to this signal. - - \sa isSessionRestored(), sessionId(), saveState(), {Session Management} -*/ - -/*! - This function deals with \l{Session Management}{session management}. It is - invoked when the QSessionManager wants the application to commit all its - data. - - Usually this means saving all open files, after getting permission from the - user. Furthermore you may want to provide a means by which the user can - cancel the shutdown. - - You should not exit the application within this function. Instead, the - session manager may or may not do this afterwards, depending on the - context. - - \warning Within this function, no user interaction is possible, \e - unless you ask the \a manager for explicit permission. See - QSessionManager::allowsInteraction() and - QSessionManager::allowsErrorInteraction() for details and example - usage. - - The default implementation requests interaction and sends a close event to - all visible top-level widgets. If any event was rejected, the shutdown is - canceled. - - \sa isSessionRestored(), sessionId(), saveState(), {Session Management} -*/ -#ifndef QT_NO_SESSIONMANAGER -void QApplication::commitData(QSessionManager& manager ) -{ - emit commitDataRequest(manager); - if (manager.allowsInteraction()) { - QWidgetList done; - QWidgetList list = QApplication::topLevelWidgets(); - bool cancelled = false; - for (int i = 0; !cancelled && i < list.size(); ++i) { - QWidget* w = list.at(i); - if (w->isVisible() && !done.contains(w)) { - cancelled = !w->close(); - if (!cancelled) - done.append(w); - list = QApplication::topLevelWidgets(); - i = -1; - } - } - if (cancelled) - manager.cancel(); - } -} - -/*! - \since 4.2 - \fn void QApplication::saveStateRequest(QSessionManager &manager) - - This signal deals with \l{Session Management}{session management}. It is - invoked when the \l{QSessionManager}{session manager} wants the application - to preserve its state for a future session. - - For example, a text editor would create a temporary file that includes the - current contents of its edit buffers, the location of the cursor and other - aspects of the current editing session. - - You should never exit the application within this signal. Instead, the - session manager may or may not do this afterwards, depending on the - context. Futhermore, most session managers will very likely request a saved - state immediately after the application has been started. This permits the - session manager to learn about the application's restart policy. - - \warning Within this function, no user interaction is possible, \e - unless you ask the \a manager for explicit permission. See - QSessionManager::allowsInteraction() and - QSessionManager::allowsErrorInteraction() for details. - - \note You should use Qt::DirectConnection when connecting to this signal. - - \sa isSessionRestored(), sessionId(), commitData(), {Session Management} -*/ - -/*! - This function deals with \l{Session Management}{session management}. It is - invoked when the \l{QSessionManager}{session manager} wants the application - to preserve its state for a future session. - - For example, a text editor would create a temporary file that includes the - current contents of its edit buffers, the location of the cursor and other - aspects of the current editing session. - - You should never exit the application within this function. Instead, the - session manager may or may not do this afterwards, depending on the - context. Futhermore, most session managers will very likely request a saved - state immediately after the application has been started. This permits the - session manager to learn about the application's restart policy. - - \warning Within this function, no user interaction is possible, \e - unless you ask the \a manager for explicit permission. See - QSessionManager::allowsInteraction() and - QSessionManager::allowsErrorInteraction() for details. - - \sa isSessionRestored(), sessionId(), commitData(), {Session Management} -*/ - -void QApplication::saveState(QSessionManager &manager) -{ - emit saveStateRequest(manager); -} -#endif //QT_NO_SESSIONMANAGER /* Sets the time after which a drag should start to \a ms ms. @@ -3105,297 +2841,6 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) } -/*! - \class QSessionManager - \brief The QSessionManager class provides access to the session manager. - - A session manager in a desktop environment (in which Qt GUI applications - live) keeps track of a session, which is a group of running applications, - each of which has a particular state. The state of an application contains - (most notably) the documents the application has open and the position and - size of its windows. - - The session manager is used to save the session, e.g., when the machine is - shut down, and to restore a session, e.g., when the machine is started up. - We recommend that you use QSettings to save an application's settings, - for example, window positions, recently used files, etc. When the - application is restarted by the session manager, you can restore the - settings. - - QSessionManager provides an interface between the application and the - session manager so that the program can work well with the session manager. - In Qt, session management requests for action are handled by the two - virtual functions QApplication::commitData() and QApplication::saveState(). - Both provide a reference to a session manager object as argument, to allow - the application to communicate with the session manager. The session - manager can only be accessed through these functions. - - No user interaction is possible \e unless the application gets explicit - permission from the session manager. You ask for permission by calling - allowsInteraction() or, if it is really urgent, allowsErrorInteraction(). - Qt does not enforce this, but the session manager may. - - You can try to abort the shutdown process by calling cancel(). The default - commitData() function does this if some top-level window rejected its - closeEvent(). - - For sophisticated session managers provided on Unix/X11, QSessionManager - offers further possibilities to fine-tune an application's session - management behavior: setRestartCommand(), setDiscardCommand(), - setRestartHint(), setProperty(), requestPhase2(). See the respective - function descriptions for further details. - - \sa QApplication, {Session Management} -*/ - -/*! \enum QSessionManager::RestartHint - - This enum type defines the circumstances under which this application wants - to be restarted by the session manager. The current values are: - - \value RestartIfRunning If the application is still running when the - session is shut down, it wants to be restarted - at the start of the next session. - - \value RestartAnyway The application wants to be started at the - start of the next session, no matter what. - (This is useful for utilities that run just - after startup and then quit.) - - \value RestartImmediately The application wants to be started immediately - whenever it is not running. - - \value RestartNever The application does not want to be restarted - automatically. - - The default hint is \c RestartIfRunning. -*/ - - -/*! - \fn QString QSessionManager::sessionId() const - - Returns the identifier of the current session. - - If the application has been restored from an earlier session, this - identifier is the same as it was in the earlier session. - - \sa sessionKey(), QApplication::sessionId() -*/ - -/*! - \fn QString QSessionManager::sessionKey() const - - Returns the session key in the current session. - - If the application has been restored from an earlier session, this key is - the same as it was when the previous session ended. - - The session key changes with every call of commitData() or saveState(). - - \sa sessionId(), QApplication::sessionKey() -*/ - -/*! - \fn void* QSessionManager::handle() const - - \internal -*/ - -/*! - \fn bool QSessionManager::allowsInteraction() - - Asks the session manager for permission to interact with the user. Returns - true if interaction is permitted; otherwise returns false. - - The rationale behind this mechanism is to make it possible to synchronize - user interaction during a shutdown. Advanced session managers may ask all - applications simultaneously to commit their data, resulting in a much - faster shutdown. - - When the interaction is completed we strongly recommend releasing the user - interaction semaphore with a call to release(). This way, other - applications may get the chance to interact with the user while your - application is still busy saving data. (The semaphore is implicitly - released when the application exits.) - - If the user decides to cancel the shutdown process during the interaction - phase, you must tell the session manager that this has happened by calling - cancel(). - - Here's an example of how an application's QApplication::commitData() might - be implemented: - - \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 8 - - If an error occurred within the application while saving its data, you may - want to try allowsErrorInteraction() instead. - - \sa QApplication::commitData(), release(), cancel() -*/ - - -/*! - \fn bool QSessionManager::allowsErrorInteraction() - - Returns true if error interaction is permitted; otherwise returns false. - - This is similar to allowsInteraction(), but also enables the application to - tell the user about any errors that occur. Session managers may give error - interaction requests higher priority, which means that it is more likely - that an error interaction is permitted. However, you are still not - guaranteed that the session manager will allow interaction. - - \sa allowsInteraction(), release(), cancel() -*/ - -/*! - \fn void QSessionManager::release() - - Releases the session manager's interaction semaphore after an interaction - phase. - - \sa allowsInteraction(), allowsErrorInteraction() -*/ - -/*! - \fn void QSessionManager::cancel() - - Tells the session manager to cancel the shutdown process. Applications - should not call this function without asking the user first. - - \sa allowsInteraction(), allowsErrorInteraction() -*/ - -/*! - \fn void QSessionManager::setRestartHint(RestartHint hint) - - Sets the application's restart hint to \a hint. On application startup, the - hint is set to \c RestartIfRunning. - - \note These flags are only hints, a session manager may or may not respect - them. - - We recommend setting the restart hint in QApplication::saveState() because - most session managers perform a checkpoint shortly after an application's - startup. - - \sa restartHint() -*/ - -/*! - \fn QSessionManager::RestartHint QSessionManager::restartHint() const - - Returns the application's current restart hint. The default is - \c RestartIfRunning. - - \sa setRestartHint() -*/ - -/*! - \fn void QSessionManager::setRestartCommand(const QStringList& command) - - If the session manager is capable of restoring sessions it will execute - \a command in order to restore the application. The command defaults to - - \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 9 - - The \c -session option is mandatory; otherwise QApplication cannot tell - whether it has been restored or what the current session identifier is. - See QApplication::isSessionRestored() and QApplication::sessionId() for - details. - - If your application is very simple, it may be possible to store the entire - application state in additional command line options. This is usually a - very bad idea because command lines are often limited to a few hundred - bytes. Instead, use QSettings, temporary files, or a database for this - purpose. By marking the data with the unique sessionId(), you will be able - to restore the application in a future session. - - \sa restartCommand(), setDiscardCommand(), setRestartHint() -*/ - -/*! - \fn QStringList QSessionManager::restartCommand() const - - Returns the currently set restart command. - - To iterate over the list, you can use the \l foreach pseudo-keyword: - - \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 10 - - \sa setRestartCommand(), restartHint() -*/ - -/*! - \fn void QSessionManager::setDiscardCommand(const QStringList& list) - - Sets the discard command to the given \a list. - - \sa discardCommand(), setRestartCommand() -*/ - - -/*! - \fn QStringList QSessionManager::discardCommand() const - - Returns the currently set discard command. - - To iterate over the list, you can use the \l foreach pseudo-keyword: - - \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 11 - - \sa setDiscardCommand(), restartCommand(), setRestartCommand() -*/ - -/*! - \fn void QSessionManager::setManagerProperty(const QString &name, const QString &value) - \overload - - Low-level write access to the application's identification and state - records are kept in the session manager. - - The property called \a name has its value set to the string \a value. -*/ - -/*! - \fn void QSessionManager::setManagerProperty(const QString& name, - const QStringList& value) - - Low-level write access to the application's identification and state record - are kept in the session manager. - - The property called \a name has its value set to the string list \a value. -*/ - -/*! - \fn bool QSessionManager::isPhase2() const - - Returns true if the session manager is currently performing a second - session management phase; otherwise returns false. - - \sa requestPhase2() -*/ - -/*! - \fn void QSessionManager::requestPhase2() - - Requests a second session management phase for the application. The - application may then return immediately from the QApplication::commitData() - or QApplication::saveState() function, and they will be called again once - most or all other applications have finished their session management. - - The two phases are useful for applications such as the X11 window manager - that need to store information about another application's windows and - therefore have to wait until these applications have completed their - respective session management tasks. - - \note If another application has requested a second phase it may get called - before, simultaneously with, or after your application's second phase. - - \sa isPhase2() -*/ - /*! \fn bool QApplication::hasGlobalMouseTracking() diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h index 01c09f45c..6f15f7a3f 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -35,7 +35,6 @@ class QFont; class QPalette; class QFontMetrics; class QClipboard; -class QSessionManager; class QDesktopWidget; class QStyle; class QIcon; @@ -154,15 +153,6 @@ public: int x11ProcessEvent(XEvent*); #endif -#ifndef QT_NO_SESSIONMANAGER - // session management - bool isSessionRestored() const; - QString sessionId() const; - QString sessionKey() const; - virtual void commitData(QSessionManager& sm); - virtual void saveState(QSessionManager& sm); -#endif - static QLocale keyboardInputLocale(); static Qt::LayoutDirection keyboardInputDirection(); @@ -175,10 +165,6 @@ public: Q_SIGNALS: void lastWindowClosed(); void focusChanged(QWidget *old, QWidget *now); -#ifndef QT_NO_SESSIONMANAGER - void commitDataRequest(QSessionManager &sessionManager); - void saveStateRequest(QSessionManager &sessionManager); -#endif public Q_SLOTS: void setAutoSipEnabled(const bool enabled); diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 1030a1d24..4ece8147c 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -102,13 +102,6 @@ public: static void setFocusWidget(QWidget *focus, Qt::FocusReason reason); static QWidget *focusNextPrevChild_helper(QWidget *toplevel, bool next); -#ifndef QT_NO_SESSIONMANAGER - QSessionManager *session_manager; - QString session_id; - QString session_key; - bool is_session_restored; -#endif - #ifndef QT_NO_CURSOR QList cursor_list; #endif diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 5b479a146..7ac428153 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -33,7 +33,6 @@ #include "qtextcodec.h" #include "qdatastream.h" #include "qsocketnotifier.h" -#include "qsessionmanager.h" #include "qclipboard.h" #include "qwhatsthis.h" #include "qstylefactory.h" @@ -94,7 +93,6 @@ static const char* X11AtomsTbl[QX11Data::NPredefinedAtoms] = { // Session management "WM_CLIENT_LEADER\0", "WM_WINDOW_ROLE\0", - "SM_CLIENT_ID\0", // Clipboard "CLIPBOARD\0", @@ -226,8 +224,6 @@ static Window pressed_window = XNone; static bool replayPopupMouseEvent = false; static bool popupGrabOk = false; -bool qt_sm_blockUserInput = false; // session management - static bool qt_x11EventFilter(XEvent* ev) { long unused; @@ -2388,9 +2384,6 @@ bool QETWidget::translateMouseEvent(const XEvent *event) Qt::KeyboardModifiers modifiers; XEvent nextEvent; - if (qt_sm_blockUserInput) // block user interaction during session management - return true; - if (event->type == MotionNotify) { // mouse move if (event->xmotion.root != RootWindow(qt_x11Data->display, x11Info().screen()) && ! qt_xdnd_dragging) @@ -3239,488 +3232,4 @@ bool QApplication::isEffectEnabled(Qt::UIEffect effect) } } -/***************************************************************************** - Session management support - *****************************************************************************/ - -#ifndef QT_NO_SESSIONMANAGER -class QSessionManagerPrivate : public QObjectPrivate -{ -public: - QSessionManagerPrivate(QSessionManager* mgr, QString& id, QString& key) - : QObjectPrivate(), sm(mgr), sessionId(id), sessionKey(key), - restartHint(QSessionManager::RestartIfRunning), eventLoop(0) {} - QSessionManager* sm; - QStringList restartCommand; - QStringList discardCommand; - QString& sessionId; - QString& sessionKey; - QSessionManager::RestartHint restartHint; - QEventLoop *eventLoop; -}; - -class QSmSocketReceiver : public QObject -{ - Q_OBJECT -public: - QSmSocketReceiver(int socket) - { - QSocketNotifier* sn = new QSocketNotifier(socket, QSocketNotifier::Read, this); - connect(sn, SIGNAL(activated(int)), this, SLOT(socketActivated(int))); - } - -public slots: - void socketActivated(int); -}; - -static SmcConn smcConnection = 0; -static bool sm_interactionActive = false; -static bool sm_smActive = false; -static int sm_interactStyle = SmInteractStyleNone; -static int sm_saveType = SmSaveLocal; -static bool sm_cancel = false; -static bool sm_waitingForInteraction = false; -static bool sm_isshutdown = false; -static bool sm_phase2 = false; -static bool sm_in_phase2 = false; - -static QSmSocketReceiver* sm_receiver = 0; - -static void resetSmState(); -static void sm_setProperty(const char* name, const char* type, SmPropValue* vals); -static void sm_saveYourselfCallback(SmcConn smcConn, SmPointer clientData, - int saveType, Bool shutdown , int interactStyle, Bool fast); -static void sm_saveYourselfPhase2Callback(SmcConn smcConn, SmPointer clientData) ; -static void sm_dieCallback(SmcConn smcConn, SmPointer clientData) ; -static void sm_shutdownCancelledCallback(SmcConn smcConn, SmPointer clientData); -static void sm_saveCompleteCallback(SmcConn smcConn, SmPointer clientData); -static void sm_interactCallback(SmcConn smcConn, SmPointer clientData); -static void sm_performSaveYourself(QSessionManagerPrivate*); - -static void resetSmState() -{ - sm_waitingForInteraction = false; - sm_interactionActive = false; - sm_interactStyle = SmInteractStyleNone; - sm_smActive = false; - qt_sm_blockUserInput = false; - sm_isshutdown = false; - sm_phase2 = false; - sm_in_phase2 = false; -} - - -// theoretically it's possible to set several properties at once. For -// simplicity, however, we do just one property at a time -static void sm_setProperty(const char* name, const char* type, SmPropValue* vals) -{ - SmProp prop; - prop.name = (char*)name; - prop.type = (char*)type; - prop.num_vals = 1; - prop.vals = vals; - - SmProp* props[1]; - props[0] = ∝ - SmcSetProperties(smcConnection, 1, props); -} - -static void sm_setProperty(const QString& name, const QString& value) -{ - QByteArray v = value.toUtf8(); - SmPropValue prop; - prop.length = v.length(); - prop.value = (SmPointer) v.constData(); - sm_setProperty(name.toLatin1().data(), SmARRAY8, &prop); -} - -static void sm_setProperty(const QString& name, const QStringList& value) -{ - QByteArray ln = name.toLatin1(); - - if (value.isEmpty()) { - char* names[1]; - names[0] = (char*) ln.data(); - SmcDeleteProperties(smcConnection, 1, names); - return; - } - - SmPropValue *prop = new SmPropValue[value.count()]; - int count = 0; - QList vl; - for (QStringList::ConstIterator it = value.begin(); it != value.end(); ++it) { - prop[count].length = (*it).length(); - vl.append((*it).toUtf8()); - prop[count].value = (char*)vl.last().data(); - ++count; - } - - SmProp prop2; - prop2.name = (char*)ln.data(); - prop2.type = (char*)SmLISTofARRAY8; - prop2.num_vals = count; - prop2.vals = prop; - - SmProp* props[1]; - props[0] = &prop2; - SmcSetProperties(smcConnection, 1, props); - - delete [] prop; -} - -static void sm_saveYourselfCallback(SmcConn smcConn, SmPointer clientData, - int saveType, Bool shutdown , int interactStyle, Bool /*fast*/) -{ - if (smcConn != smcConnection) - return; - sm_cancel = false; - sm_smActive = true; - sm_isshutdown = shutdown; - sm_saveType = saveType; - sm_interactStyle = interactStyle; - - sm_performSaveYourself((QSessionManagerPrivate*) clientData); - if (!sm_isshutdown) // we cannot expect a confirmation message in that case - resetSmState(); -} - -Q_CORE_EXPORT QString qt_resolveUserName(uint userId); - -static void sm_performSaveYourself(QSessionManagerPrivate* smd) -{ - if (sm_isshutdown) - qt_sm_blockUserInput = true; - - QSessionManager* sm = smd->sm; - - // generate a new session key - struct timeval tv; - ::gettimeofday(&tv, nullptr); - smd->sessionKey = QString::number(qulonglong(tv.tv_sec)) + QLatin1Char('_') + QString::number(qulonglong(tv.tv_usec)); - - QStringList arguments = qApp->arguments(); - QString argument0 = arguments.isEmpty() ? qApp->applicationFilePath() : arguments.at(0); - - // tell the session manager about our program in best POSIX style - sm_setProperty(QString::fromLatin1(SmProgram), argument0); - // tell the session manager about our user as well. - QString username = qt_resolveUserName(::geteuid()); - if (!username.isEmpty()) - sm_setProperty(QString::fromLatin1(SmUserID), username); - - // generate a restart and discard command that makes sense - QStringList restart; - restart << argument0 << QLatin1String("-session") - << smd->sessionId + QLatin1Char('_') + smd->sessionKey; - sm->setRestartCommand(restart); - QStringList discard; - sm->setDiscardCommand(discard); - - switch (sm_saveType) { - case SmSaveBoth: - qApp->commitData(*sm); - if (sm_isshutdown && sm_cancel) - break; // we cancelled the shutdown, no need to save state - // fall through - case SmSaveLocal: - qApp->saveState(*sm); - break; - case SmSaveGlobal: - qApp->commitData(*sm); - break; - default: - break; - } - - if (sm_phase2 && !sm_in_phase2) { - SmcRequestSaveYourselfPhase2(smcConnection, sm_saveYourselfPhase2Callback, (SmPointer*) smd); - qt_sm_blockUserInput = false; - } - else { - // close eventual interaction monitors and cancel the - // shutdown, if required. Note that we can only cancel when - // performing a shutdown, it does not work for checkpoints - if (sm_interactionActive) { - SmcInteractDone(smcConnection, sm_isshutdown && sm_cancel); - sm_interactionActive = false; - } - else if (sm_cancel && sm_isshutdown) { - if (sm->allowsErrorInteraction()) { - SmcInteractDone(smcConnection, True); - sm_interactionActive = false; - } - } - - // set restart and discard command in session manager - sm_setProperty(QString::fromLatin1(SmRestartCommand), sm->restartCommand()); - sm_setProperty(QString::fromLatin1(SmDiscardCommand), sm->discardCommand()); - - // set the restart hint - SmPropValue prop; - prop.length = sizeof(int); - int value = sm->restartHint(); - prop.value = (SmPointer) &value; - sm_setProperty(SmRestartStyleHint, SmCARD8, &prop); - - // we are done - SmcSaveYourselfDone(smcConnection, !sm_cancel); - } -} - -static void sm_dieCallback(SmcConn smcConn, SmPointer /* clientData */) -{ - if (smcConn != smcConnection) - return; - resetSmState(); - QEvent quitEvent(QEvent::Quit); - QApplication::sendEvent(qApp, &quitEvent); -} - -static void sm_shutdownCancelledCallback(SmcConn smcConn, SmPointer clientData) -{ - if (smcConn != smcConnection) - return; - if (sm_waitingForInteraction) - ((QSessionManagerPrivate *) clientData)->eventLoop->exit(); - resetSmState(); -} - -static void sm_saveCompleteCallback(SmcConn smcConn, SmPointer /*clientData */) -{ - if (smcConn != smcConnection) - return; - resetSmState(); -} - -static void sm_interactCallback(SmcConn smcConn, SmPointer clientData) -{ - if (smcConn != smcConnection) - return; - if (sm_waitingForInteraction) - ((QSessionManagerPrivate *) clientData)->eventLoop->exit(); -} - -static void sm_saveYourselfPhase2Callback(SmcConn smcConn, SmPointer clientData) -{ - if (smcConn != smcConnection) - return; - sm_in_phase2 = true; - sm_performSaveYourself((QSessionManagerPrivate*) clientData); -} - - -void QSmSocketReceiver::socketActivated(int) -{ - IceProcessMessages(SmcGetIceConnection(smcConnection), 0, 0); -} - -QSessionManager::QSessionManager(QApplication * app, QString &id, QString& key) - : QObject(*new QSessionManagerPrivate(this, id, key), app) -{ - Q_D(QSessionManager); - d->restartHint = RestartIfRunning; - - resetSmState(); - - // avoid showing a warning message below - if (qgetenv("SESSION_MANAGER").isEmpty()) { - return; - } - - QSTACKARRAY(char, cerror, 256); - char* myId = 0; - const QByteArray b_id = id.toLatin1(); - - SmcCallbacks cb; - cb.save_yourself.callback = sm_saveYourselfCallback; - cb.save_yourself.client_data = (SmPointer) d; - cb.die.callback = sm_dieCallback; - cb.die.client_data = (SmPointer) d; - cb.save_complete.callback = sm_saveCompleteCallback; - cb.save_complete.client_data = (SmPointer) d; - cb.shutdown_cancelled.callback = sm_shutdownCancelledCallback; - cb.shutdown_cancelled.client_data = (SmPointer) d; - - smcConnection = SmcOpenConnection(0, 0, 1, 0, - SmcSaveYourselfProcMask | - SmcDieProcMask | - SmcSaveCompleteProcMask | - SmcShutdownCancelledProcMask, - &cb, - b_id.constData(), - &myId, - 256, cerror); - - id = QString::fromLatin1(myId); - ::free(myId); // it was allocated by C - - if (Q_UNLIKELY(!smcConnection)) { - const QString error = QString::fromLocal8Bit(cerror); - qWarning("Qt: Session management error: %s", qPrintable(error)); - } else { - sm_receiver = new QSmSocketReceiver(IceConnectionNumber(SmcGetIceConnection(smcConnection))); - } -} - -QSessionManager::~QSessionManager() -{ - if (smcConnection) - SmcCloseConnection(smcConnection, 0, 0); - smcConnection = 0; - delete sm_receiver; -} - -QString QSessionManager::sessionId() const -{ - Q_D(const QSessionManager); - return d->sessionId; -} - -QString QSessionManager::sessionKey() const -{ - Q_D(const QSessionManager); - return d->sessionKey; -} - - -void* QSessionManager::handle() const -{ - return (void*) smcConnection; -} - - -bool QSessionManager::allowsInteraction() -{ - Q_D(QSessionManager); - if (sm_interactionActive) - return true; - - if (sm_waitingForInteraction) - return false; - - if (sm_interactStyle == SmInteractStyleAny) { - sm_waitingForInteraction = SmcInteractRequest(smcConnection, SmDialogNormal, - sm_interactCallback, (SmPointer*) d); - } - if (sm_waitingForInteraction) { - QEventLoop eventLoop; - d->eventLoop = &eventLoop; - (void) eventLoop.exec(); - d->eventLoop = 0; - - sm_waitingForInteraction = false; - if (sm_smActive) { // not cancelled - sm_interactionActive = true; - qt_sm_blockUserInput = false; - return true; - } - } - return false; -} - -bool QSessionManager::allowsErrorInteraction() -{ - Q_D(QSessionManager); - if (sm_interactionActive) - return true; - - if (sm_waitingForInteraction) - return false; - - if (sm_interactStyle == SmInteractStyleAny || sm_interactStyle == SmInteractStyleErrors) { - sm_waitingForInteraction = SmcInteractRequest(smcConnection, SmDialogError, - sm_interactCallback, (SmPointer*) d); - } - if (sm_waitingForInteraction) { - QEventLoop eventLoop; - d->eventLoop = &eventLoop; - (void) eventLoop.exec(); - d->eventLoop = 0; - - sm_waitingForInteraction = false; - if (sm_smActive) { // not cancelled - sm_interactionActive = true; - qt_sm_blockUserInput = false; - return true; - } - } - return false; -} - -void QSessionManager::release() -{ - if (sm_interactionActive) { - SmcInteractDone(smcConnection, False); - sm_interactionActive = false; - if (sm_smActive && sm_isshutdown) - qt_sm_blockUserInput = true; - } -} - -void QSessionManager::cancel() -{ - sm_cancel = true; -} - -void QSessionManager::setRestartHint(QSessionManager::RestartHint hint) -{ - Q_D(QSessionManager); - d->restartHint = hint; -} - -QSessionManager::RestartHint QSessionManager::restartHint() const -{ - Q_D(const QSessionManager); - return d->restartHint; -} - -void QSessionManager::setRestartCommand(const QStringList& command) -{ - Q_D(QSessionManager); - d->restartCommand = command; -} - -QStringList QSessionManager::restartCommand() const -{ - Q_D(const QSessionManager); - return d->restartCommand; -} - -void QSessionManager::setDiscardCommand(const QStringList& command) -{ - Q_D(QSessionManager); - d->discardCommand = command; -} - -QStringList QSessionManager::discardCommand() const -{ - Q_D(const QSessionManager); - return d->discardCommand; -} - -void QSessionManager::setManagerProperty(const QString& name, const QString& value) -{ - sm_setProperty(name, value); -} - -void QSessionManager::setManagerProperty(const QString& name, const QStringList& value) -{ - sm_setProperty(name, value); -} - -bool QSessionManager::isPhase2() const -{ - return sm_in_phase2; -} - -void QSessionManager::requestPhase2() -{ - sm_phase2 = true; -} - -#endif // QT_NO_SESSIONMANAGER - QT_END_NAMESPACE - -#include "moc_qapplication_x11.cpp" -#include "moc_qsessionmanager.h" diff --git a/src/gui/kernel/qkeymapper_x11.cpp b/src/gui/kernel/qkeymapper_x11.cpp index a449a6013..35c209f4e 100644 --- a/src/gui/kernel/qkeymapper_x11.cpp +++ b/src/gui/kernel/qkeymapper_x11.cpp @@ -58,8 +58,6 @@ void QKeyMapper::clearMappings() keyboardInputDirection = keyboardInputLocale.textDirection(); } -extern bool qt_sm_blockUserInput; - // keyboard mapping table static const struct KeyTblData { const uint x11key; @@ -204,9 +202,6 @@ struct qt_auto_repeat_data bool QKeyMapper::translateKeyEvent(QWidget *keyWidget, const XEvent *event) { - if (qt_sm_blockUserInput) // block user interaction during session management - return true; - Q_ASSERT(keyWidget->isEnabled()); QEvent::Type type = (event->type == XKeyPress) ? QEvent::KeyPress : QEvent::KeyRelease; diff --git a/src/gui/kernel/qsessionmanager.h b/src/gui/kernel/qsessionmanager.h deleted file mode 100644 index 8ba1f5731..000000000 --- a/src/gui/kernel/qsessionmanager.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Copyright (C) 2016 Ivailo Monev -** -** This file is part of the QtGui module of the Katie Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSESSIONMANAGER_H -#define QSESSIONMANAGER_H - -#include -#include -#include -#include - -#ifndef QT_NO_SESSIONMANAGER - - -QT_BEGIN_NAMESPACE - -class QApplication; -class QSessionManagerPrivate; - -class Q_GUI_EXPORT QSessionManager : public QObject -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QSessionManager) - QSessionManager(QApplication *app, QString &id, QString &key); - ~QSessionManager(); -public: - QString sessionId() const; - QString sessionKey() const; -#if defined(Q_WS_X11) - void *handle() const; -#endif - - bool allowsInteraction(); - bool allowsErrorInteraction(); - void release(); - - void cancel(); - - enum RestartHint { - RestartIfRunning, - RestartAnyway, - RestartImmediately, - RestartNever - }; - void setRestartHint(RestartHint); - RestartHint restartHint() const; - - void setRestartCommand(const QStringList&); - QStringList restartCommand() const; - void setDiscardCommand(const QStringList&); - QStringList discardCommand() const; - - void setManagerProperty(const QString& name, const QString& value); - void setManagerProperty(const QString& name, const QStringList& value); - - bool isPhase2() const; - void requestPhase2(); - -private: - friend class QApplication; - friend class QApplicationPrivate; -}; - -QT_END_NAMESPACE - - -#endif // QT_NO_SESSIONMANAGER - -#endif // QSESSIONMANAGER_H diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h index ddf005084..da1454bbe 100644 --- a/src/gui/kernel/qt_x11_p.h +++ b/src/gui/kernel/qt_x11_p.h @@ -92,10 +92,6 @@ # include #endif // QT_NO_XFIXES -#ifndef QT_NO_SESSIONMANAGER -# include -#endif // QT_NO_SESSIONMANAGER - QT_BEGIN_NAMESPACE class QWidget; @@ -262,7 +258,6 @@ public: // Session management WM_CLIENT_LEADER, WM_WINDOW_ROLE, - SM_CLIENT_ID, // Clipboard CLIPBOARD, diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index ef02265fb..dc40d7319 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -219,17 +219,6 @@ static void create_wm_client_leader() qt_x11Data->wm_client_leader, ATOM(WM_CLIENT_LEADER), XA_WINDOW, 32, PropModeReplace, (unsigned char *)&qt_x11Data->wm_client_leader, 1); - -#ifndef QT_NO_SESSIONMANAGER - // If we are session managed, inform the window manager about it - QByteArray session = qApp->sessionId().toLatin1(); - if (!session.isEmpty()) { - XChangeProperty(qt_x11Data->display, - qt_x11Data->wm_client_leader, ATOM(SM_CLIENT_ID), - XA_STRING, 8, PropModeReplace, - (unsigned char *)session.data(), session.size()); - } -#endif } /*!