Commit 0fb09cf4 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

Make session loading/saving helpers local to sm.cpp

Summary:
There is no point for keeping them in the Workspace class because they
are used only in sm.cpp.

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D20783
parent 48cacae8
......@@ -56,6 +56,32 @@ static KConfig *sessionConfig(QString id, QString key)
return config;
}
static const char* const window_type_names[] = {
"Unknown", "Normal" , "Desktop", "Dock", "Toolbar", "Menu", "Dialog",
"Override", "TopMenu", "Utility", "Splash"
};
// change also the two functions below when adding new entries
static const char* windowTypeToTxt(NET::WindowType type)
{
if (type >= NET::Unknown && type <= NET::Splash)
return window_type_names[ type + 1 ]; // +1 (unknown==-1)
if (type == -2) // undefined (not really part of NET::WindowType)
return "Undefined";
qFatal("Unknown Window Type");
return NULL;
}
static NET::WindowType txtToWindowType(const char* txt)
{
for (int i = NET::Unknown;
i <= NET::Splash;
++i)
if (qstrcmp(txt, window_type_names[ i + 1 ]) == 0) // +1
return static_cast< NET::WindowType >(i);
return static_cast< NET::WindowType >(-2); // undefined
}
void Workspace::saveState(QSessionManager &sm)
{
// If the session manager is ksmserver, save stacking
......@@ -273,6 +299,15 @@ void Workspace::loadSubSessionInfo(const QString &name)
addSessionInfo(cg);
}
static bool sessionInfoWindowTypeMatch(Client* c, SessionInfo* info)
{
if (info->windowType == -2) {
// undefined (not really part of NET::WindowType)
return !c->isSpecialWindow();
}
return info->windowType == c->windowType();
}
/**
* Returns a SessionInfo for client \a c. The returned session
* info is removed from the storage. It's up to the caller to delete it.
......@@ -340,44 +375,6 @@ SessionInfo* Workspace::takeSessionInfo(Client* c)
return realInfo;
}
bool Workspace::sessionInfoWindowTypeMatch(Client* c, SessionInfo* info)
{
if (info->windowType == -2) {
// undefined (not really part of NET::WindowType)
return !c->isSpecialWindow();
}
return info->windowType == c->windowType();
}
static const char* const window_type_names[] = {
"Unknown", "Normal" , "Desktop", "Dock", "Toolbar", "Menu", "Dialog",
"Override", "TopMenu", "Utility", "Splash"
};
// change also the two functions below when adding new entries
const char* Workspace::windowTypeToTxt(NET::WindowType type)
{
if (type >= NET::Unknown && type <= NET::Splash)
return window_type_names[ type + 1 ]; // +1 (unknown==-1)
if (type == -2) // undefined (not really part of NET::WindowType)
return "Undefined";
qFatal("Unknown Window Type");
return NULL;
}
NET::WindowType Workspace::txtToWindowType(const char* txt)
{
for (int i = NET::Unknown;
i <= NET::Splash;
++i)
if (qstrcmp(txt, window_type_names[ i + 1 ]) == 0) // +1
return static_cast< NET::WindowType >(i);
return static_cast< NET::WindowType >(-2); // undefined
}
// KWin's focus stealing prevention causes problems with user interaction
// during session save, as it prevents possible dialogs from getting focus.
// Therefore it's temporarily disabled during session saving. Start of
......
......@@ -552,9 +552,6 @@ private:
void addSessionInfo(KConfigGroup &cg);
QList<SessionInfo*> session;
static const char* windowTypeToTxt(NET::WindowType type);
static NET::WindowType txtToWindowType(const char* txt);
static bool sessionInfoWindowTypeMatch(Client* c, SessionInfo* info);
void updateXStackingOrder();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment