fix #246, Incorrect/inconsistent behaviour when switching virtual desktops

pull/1/head
Johan Smith Agudelo Rodriguez 8 years ago
parent 59a797f87f
commit fb16fee66b

@ -285,25 +285,6 @@ void DockConfigView::setAutostart(bool state)
}
}
bool DockConfigView::raiseDocksTemporary() const
{
auto *dockCorona = qobject_cast<DockCorona *>(m_dockView->corona());
if (dockCorona) {
return dockCorona->raiseDocksTemporary();
}
return false;
}
void DockConfigView::setRaiseDocksTemporary(bool state)
{
auto *dockCorona = qobject_cast<DockCorona *>(m_dockView->corona());
if (dockCorona) {
dockCorona->setRaiseDocksTemporary(state);
}
}
Dock::SessionType DockConfigView::currentSession() const
{

@ -44,7 +44,6 @@ class DockView;
class DockConfigView : public PlasmaQuick::ConfigView {
Q_OBJECT
Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged)
Q_PROPERTY(bool raiseDocksTemporary READ raiseDocksTemporary WRITE setRaiseDocksTemporary NOTIFY raiseDocksTemporaryChanged)
Q_PROPERTY(Latte::Dock::SessionType currentSession READ currentSession WRITE setCurrentSession NOTIFY currentSessionChanged)
public:
@ -57,9 +56,6 @@ public:
bool autostart() const;
void setAutostart(bool state);
bool raiseDocksTemporary() const;
void setRaiseDocksTemporary(bool state);
Latte::Dock::SessionType currentSession() const;
void setCurrentSession(Latte::Dock::SessionType session);

@ -112,8 +112,6 @@ void DockCorona::load()
disconnect(m_activityConsumer, &KActivities::Consumer::serviceStatusChanged, this, &DockCorona::load);
m_activitiesStarting = false;
loadConfig();
m_tasksWillBeLoaded = heuresticForLoadingDockWithTasks();
qDebug() << "TASKS WILL BE PRESENT AFTER LOADING ::: " << m_tasksWillBeLoaded;
@ -158,19 +156,6 @@ void DockCorona::cleanConfig()
}
}
void DockCorona::loadConfig()
{
auto general = config()->group("General");
setRaiseDocksTemporary(general.readEntry("raiseDocksTemporary", false));
}
void DockCorona::saveConfig()
{
auto general = config()->group("General");
general.writeEntry("raiseDocksTemporary", m_raiseDocksTemporary);
general.sync();
}
bool DockCorona::containmentExists(uint id) const
{
foreach (auto containment, containments()) {
@ -628,22 +613,6 @@ bool DockCorona::autostart() const
return autostartFile.exists();
}
bool DockCorona::raiseDocksTemporary() const
{
return m_raiseDocksTemporary;
}
void DockCorona::setRaiseDocksTemporary(bool flag)
{
if (m_raiseDocksTemporary == flag) {
return;
}
m_raiseDocksTemporary = flag;
saveConfig();
emit raiseDocksTemporaryChanged();
}
Dock::SessionType DockCorona::currentSession()
{
@ -658,7 +627,6 @@ void DockCorona::setCurrentSession(Dock::SessionType session)
m_session = session;
}
void DockCorona::switchToSession(Dock::SessionType session)
{
if (currentSession() == session) {
@ -675,7 +643,6 @@ void DockCorona::switchToSession(Dock::SessionType session)
syncDockViews();
}
}
int DockCorona::noDocksForSession(Dock::SessionType session)
{
int count{0};

@ -70,9 +70,6 @@ public:
bool autostart() const;
void setAutostart(bool state);
bool raiseDocksTemporary() const;
void setRaiseDocksTemporary(bool flag);
Dock::SessionType currentSession();
void setCurrentSession(Dock::SessionType session);
void switchToSession(Dock::SessionType session);

@ -31,7 +31,7 @@ namespace Latte {
//! BEGIN: VisiblityManagerPrivate implementation
VisibilityManagerPrivate::VisibilityManagerPrivate(PlasmaQuick::ContainmentView *view, VisibilityManager *q)
: QObject(q), q(q), view(view), wm(&AbstractWindowInterface::self())
: QObject(q), q(q), view(view), wm(&WindowSystem::self())
{
DockView *dockView = qobject_cast<DockView *>(view);
@ -76,13 +76,25 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
Q_ASSERT_X(mode != Dock::None, q->staticMetaObject.className(), "set visibility to Dock::None");
// clear mode
if (this->mode == Dock::AlwaysVisible)
wm->removeDockStruts(view->winId());
for (auto &c : connections) {
disconnect(c);
}
if (this->mode == Dock::AlwaysVisible) {
wm->removeDockStruts(view->winId());
} else {
connections[3] = connect(wm, &WindowSystem::currentDesktopChanged
, this, [&]{
if (raiseOnDesktopChange)
raiseDockTemporarily();
});
connections[4] = connect(wm, &WindowSystem::currentActivityChanged
, this, [&]() {
if (raiseOnActivityChange)
raiseDockTemporarily();
});
}
timerShow.stop();
timerHide.stop();
timerCheckWindows.stop();
@ -108,36 +120,24 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
break;
case Dock::AutoHide: {
connections[0] = connect(wm, &AbstractWindowInterface::currentDesktopChanged
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
connections[1] = connect(wm, &AbstractWindowInterface::currentActivityChanged
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
raiseDock(containsMouse);
}
break;
case Dock::DodgeActive: {
connections[0] = connect(wm, &AbstractWindowInterface::activeWindowChanged
connections[0] = connect(wm, &WindowSystem::activeWindowChanged
, this, &VisibilityManagerPrivate::dodgeActive);
connections[1] = connect(wm, &AbstractWindowInterface::windowChanged
connections[1] = connect(wm, &WindowSystem::windowChanged
, this, &VisibilityManagerPrivate::dodgeActive);
connections[2] = connect(wm, &AbstractWindowInterface::currentDesktopChanged
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
connections[3] = connect(wm, &AbstractWindowInterface::currentActivityChanged
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
dodgeActive(wm->activeWindow());
}
break;
case Dock::DodgeMaximized: {
connections[0] = connect(wm, &AbstractWindowInterface::activeWindowChanged
, this, &VisibilityManagerPrivate::dodgeMaximized);
connections[1] = connect(wm, &AbstractWindowInterface::windowChanged
connections[0] = connect(wm, &WindowSystem::activeWindowChanged
, this, &VisibilityManagerPrivate::dodgeMaximized);
connections[2] = connect(wm, &AbstractWindowInterface::currentDesktopChanged
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
connections[3] = connect(wm, &AbstractWindowInterface::currentActivityChanged
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
connections[1] = connect(wm, &WindowSystem::windowChanged
, this, &VisibilityManagerPrivate::dodgeMaximized);
dodgeMaximized(wm->activeWindow());
}
break;
@ -147,30 +147,44 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
windows.insert({wid, wm->requestInfo(wid)});
}
connections[0] = connect(wm, &AbstractWindowInterface::windowChanged
connections[0] = connect(wm, &WindowSystem::windowChanged
, this, &VisibilityManagerPrivate::dodgeWindows);
connections[1] = connect(wm, &AbstractWindowInterface::windowRemoved
connections[1] = connect(wm, &WindowSystem::windowRemoved
, this, [&](WId wid) {
windows.erase(wid);
timerCheckWindows.start();
});
connections[2] = connect(wm, &AbstractWindowInterface::windowAdded
connections[2] = connect(wm, &WindowSystem::windowAdded
, this, [&](WId wid) {
windows.insert({wid, wm->requestInfo(wid)});
timerCheckWindows.start();
});
connections[3] = connect(wm, &AbstractWindowInterface::currentDesktopChanged
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
connections[4] = connect(wm, &AbstractWindowInterface::currentActivityChanged
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
timerCheckWindows.start();
}
break;
}
emit q->modeChanged();
saveConfig();
}
void VisibilityManagerPrivate::setRaiseOnDesktop(bool enable)
{
if (enable == raiseOnDesktopChange)
return;
raiseOnDesktopChange = enable;
emit q->raiseOnDesktopChanged();
}
void VisibilityManagerPrivate::setRaiseOnActivity(bool enable)
{
if (enable == raiseOnActivityChange)
return;
raiseOnActivityChange = enable;
emit q->raiseOnActivityChanged();
}
inline void VisibilityManagerPrivate::setIsHidden(bool isHidden)
@ -245,9 +259,7 @@ inline void VisibilityManagerPrivate::raiseDock(bool raise)
void VisibilityManagerPrivate::raiseDockTemporarily()
{
auto dockCorona = qobject_cast<DockCorona *>(view->corona());
if (raiseTemporarily || (dockCorona && !dockCorona->raiseDocksTemporary()))
if (raiseTemporarily)
return;
raiseTemporarily = true;
@ -314,10 +326,11 @@ void VisibilityManagerPrivate::dodgeActive(WId wid)
if (winfo.isPlasmaDesktop())
raiseDock(true);
return;
winfo = wm->requestInfo(wm->activeWindow());
}
raiseDock(wm->isOnCurrentDesktop(wid) && !intersects(winfo));
if (wm->isOnCurrentDesktop(wid))
raiseDock(!intersects(winfo));
}
void VisibilityManagerPrivate::dodgeMaximized(WId wid)
@ -334,10 +347,12 @@ void VisibilityManagerPrivate::dodgeMaximized(WId wid)
if (winfo.isPlasmaDesktop())
raiseDock(true);
return;
winfo = wm->requestInfo(wm->activeWindow());
}
raiseDock(wm->isOnCurrentDesktop(wid) && !winfo.isMaximized());
if (wm->isOnCurrentDesktop(wid) && !winfo.isMinimized())
raiseDock(!(view->formFactor() == Plasma::Types::Vertical
? winfo.isMaxHoriz() : winfo.isMaxVert()));
}
void VisibilityManagerPrivate::dodgeWindows(WId wid)
@ -398,6 +413,8 @@ inline void VisibilityManagerPrivate::saveConfig()
config.writeEntry("visibility", static_cast<int>(mode));
config.writeEntry("timerShow", timerShow.interval());
config.writeEntry("timerHide", timerHide.interval());
config.writeEntry("raiseOnDesktopChange", false);
config.writeEntry("raiseOnActivityChange", false);
view->containment()->configNeedsSaving();
}
@ -416,10 +433,21 @@ inline void VisibilityManagerPrivate::restoreConfig()
if (mode == Dock::AlwaysVisible) {
setMode(mode);
} else {
QTimer::singleShot(3000, this, [ &, mode]() {
QTimer::singleShot(3000, this, [&, mode]() {
setMode(mode);
});
setRaiseOnDesktop(config.readEntry("raiseOnDesktopChange", false));
setRaiseOnActivity(config.readEntry("raiseOnActivityChange", false));
}
qDebug() << config.entryMap();
connect(view->containment(), &Plasma::Containment::userConfiguringChanged
, this, [&](bool configuring) {
if (configuring)
return;
saveConfig();
});
}
bool VisibilityManagerPrivate::event(QEvent *ev)
@ -459,7 +487,6 @@ bool VisibilityManagerPrivate::event(QEvent *ev)
case QEvent::Show:
wm->setDockExtraFlags(*view);
restoreConfig();
break;
}
@ -487,6 +514,26 @@ void VisibilityManager::setMode(Dock::Visibility mode)
d->setMode(mode);
}
bool VisibilityManager::raiseOnDesktop() const
{
return d->raiseOnDesktopChange;
}
void VisibilityManager::setRaiseOnDesktop(bool enable)
{
d->setRaiseOnDesktop(enable);
}
bool VisibilityManager::raiseOnActivity() const
{
return d->raiseOnActivityChange;
}
void VisibilityManager::setRaiseOnActivity(bool enable)
{
d->setRaiseOnActivity(enable);
}
bool VisibilityManager::isHidden() const
{
return d->isHidden;

@ -37,6 +37,8 @@ class VisibilityManager : public QObject {
Q_OBJECT
Q_PROPERTY(Latte::Dock::Visibility mode READ mode WRITE setMode NOTIFY modeChanged)
Q_PROPERTY(bool raiseOnDesktop READ raiseOnDesktop WRITE setRaiseOnDesktop NOTIFY raiseOnDesktopChanged)
Q_PROPERTY(bool raiseOnActivity READ raiseOnActivity WRITE setRaiseOnActivity NOTIFY raiseOnActivityChanged)
Q_PROPERTY(bool isHidden READ isHidden WRITE setIsHidden NOTIFY isHiddenChanged)
Q_PROPERTY(bool blockHiding READ blockHiding WRITE setBlockHiding NOTIFY blockHidingChanged)
Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged)
@ -50,6 +52,12 @@ public:
Latte::Dock::Visibility mode() const;
void setMode(Latte::Dock::Visibility mode);
bool raiseOnDesktop() const;
void setRaiseOnDesktop(bool enable);
bool raiseOnActivity() const;
void setRaiseOnActivity(bool enable);
bool isHidden() const;
void setIsHidden(bool isHidden);
@ -69,6 +77,8 @@ signals:
void mustBeHide();
void modeChanged();
void raiseOnDesktopChanged();
void raiseOnActivityChanged();
void isHiddenChanged();
void blockHidingChanged();
void containsMouseChanged();

@ -29,6 +29,9 @@ public:
~VisibilityManagerPrivate();
void setMode(Dock::Visibility mode);
void setRaiseOnDesktop(bool enable);
void setRaiseOnActivity(bool enable);
void setIsHidden(bool isHidden);
void setBlockHiding(bool blockHiding);
void setTimerShow(int msec);
@ -68,6 +71,8 @@ public:
bool blockHiding{false};
bool containsMouse{false};
bool raiseTemporarily{false};
bool raiseOnDesktopChange{false};
bool raiseOnActivityChange{false};
bool hideNow{false};
};

@ -33,7 +33,8 @@ public:
: m_isValid(false)
, m_isActive(false)
, m_isMinimized(false)
, m_isMaximized(false)
, m_isMaxVert(false)
, m_isMaxHorz(false)
, m_isFullscreen(false)
, m_isPlasmaDesktop(false)
, m_wid(0)
@ -44,7 +45,8 @@ public:
: m_isValid(other.m_isValid)
, m_isActive(other.m_isActive)
, m_isMinimized(other.m_isMinimized)
, m_isMaximized(other.m_isMaximized)
, m_isMaxVert(other.m_isMaxVert)
, m_isMaxHorz(other.m_isMaxHorz)
, m_isFullscreen(other.m_isFullscreen)
, m_isPlasmaDesktop(other.m_isPlasmaDesktop)
, m_wid(other.m_wid)
@ -66,7 +68,12 @@ public:
inline void setIsMinimized(bool isMinimized);
constexpr bool isMaximized() const;
inline void setIsMaximized(bool isMaximized);
constexpr bool isMaxVert() const;
inline void setIsMaxVert(bool isMaxVert);
constexpr bool isMaxHoriz() const;
inline void setIsMaxHoriz(bool isMaxHoriz);
constexpr bool isFullscreen() const;
inline void setIsFullscreen(bool isFullscreen);
@ -84,7 +91,8 @@ private:
bool m_isValid : 1;
bool m_isActive : 1;
bool m_isMinimized : 1;
bool m_isMaximized : 1;
bool m_isMaxVert : 1;
bool m_isMaxHorz : 1;
bool m_isFullscreen : 1;
bool m_isPlasmaDesktop : 1;
WId m_wid;
@ -98,7 +106,8 @@ inline WindowInfoWrap &WindowInfoWrap::operator=(const WindowInfoWrap &rhs)
m_isValid = rhs.m_isValid;
m_isActive = rhs.m_isActive;
m_isMinimized = rhs.m_isMinimized;
m_isMaximized = rhs.m_isMaximized;
m_isMaxVert = rhs.m_isMaxVert;
m_isMaxHorz = rhs.m_isMaxHorz;
m_isFullscreen = rhs.m_isFullscreen;
m_isPlasmaDesktop = rhs.m_isPlasmaDesktop;
m_wid = rhs.m_wid;
@ -153,12 +162,27 @@ inline void WindowInfoWrap::setIsMinimized(bool isMinimized)
constexpr bool WindowInfoWrap::isMaximized() const
{
return m_isMaximized;
return m_isMaxVert || m_isMaxHorz;
}
constexpr bool WindowInfoWrap::isMaxVert() const
{
return m_isMaxVert;
}
inline void WindowInfoWrap::setIsMaxVert(bool isMaxVert)
{
m_isMaxVert = isMaxVert;
}
constexpr bool WindowInfoWrap::isMaxHoriz() const
{
return m_isMaxHorz;
}
inline void WindowInfoWrap::setIsMaximized(bool isMaximized)
inline void WindowInfoWrap::setIsMaxHoriz(bool isMaxHoriz)
{
m_isMaximized = isMaximized;
m_isMaxHorz = isMaxHoriz;
}
constexpr bool WindowInfoWrap::isFullscreen() const

@ -206,7 +206,8 @@ WindowInfoWrap XWindowInterface::requestInfo(WId wid) const
winfoWrap.setWid(wid);
winfoWrap.setIsActive(KWindowSystem::activeWindow() == wid);
winfoWrap.setIsMinimized(winfo.hasState(NET::Hidden));
winfoWrap.setIsMaximized(winfo.hasState(NET::Max));
winfoWrap.setIsMaxVert(winfo.hasState(NET::MaxVert));
winfoWrap.setIsMaxHoriz(winfo.hasState(NET::MaxHoriz));
winfoWrap.setIsFullscreen(winfo.hasState(NET::FullScreen));
winfoWrap.setGeometry(winfo.frameGeometry());
} else if (m_desktopId == wid) {

@ -114,5 +114,12 @@
<entry name="showOnlyCurrentActivity" type="Bool">
<default>true</default>
</entry>
<entry name="raiseOnDesktopChange" type="Bool">
<default>false</default>
</entry>
<entry name="raiseOnActivityChange" type="Bool">
<default>false</default>
</entry>
</group>
</kcfg>

@ -80,11 +80,21 @@ PlasmaComponents.Page {
PlasmaComponents.CheckBox {
Layout.leftMargin: units.smallSpacing * 2
text: i18n("Raise docks on desktop or actitivy change")
checked: dockConfig.raiseDocksTemporary
text: i18n("Raise dock on desktop change")
checked: dock.visibility.raiseOnDesktop
onClicked: {
dockConfig.raiseDocksTemporary = checked;
dock.visibility.raiseOnDesktop = checked
}
}
PlasmaComponents.CheckBox {
Layout.leftMargin: units.smallSpacing * 2
text: i18n("Raise dock on activity change")
checked: dock.visibility.raiseOnActivity
onClicked: {
dock.visibility.raiseOnActivity = checked
}
}
}

Loading…
Cancel
Save