|
|
|
@ -4,12 +4,20 @@
|
|
|
|
|
|
|
|
|
|
#include "../liblattedock/extras.h"
|
|
|
|
|
|
|
|
|
|
#include "nowdockview.h"
|
|
|
|
|
|
|
|
|
|
namespace Latte {
|
|
|
|
|
|
|
|
|
|
//! BEGIN: VisiblityManagerPrivate implementation
|
|
|
|
|
VisibilityManagerPrivate::VisibilityManagerPrivate(PlasmaQuick::ContainmentView *view, VisibilityManager *q)
|
|
|
|
|
: QObject(view), q(q), view(view), wm(AbstractWindowInterface::getInstance(view, nullptr))
|
|
|
|
|
{
|
|
|
|
|
NowDockView *dockView = dynamic_cast<NowDockView *>(view);
|
|
|
|
|
|
|
|
|
|
if (dockView) {
|
|
|
|
|
connect(dockView, &NowDockView::eventTriggered, q, &VisibilityManager::eventReceived);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
timerCheckWindows.setInterval(350);
|
|
|
|
|
timerCheckWindows.setSingleShot(true);
|
|
|
|
|
|
|
|
|
@ -34,11 +42,11 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
|
|
|
|
|
{
|
|
|
|
|
if (this->mode == mode)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// clear mode
|
|
|
|
|
if (this->mode == Dock::AlwaysVisible)
|
|
|
|
|
wm->removeDockStruts();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (auto &c : connections) {
|
|
|
|
|
disconnect(c);
|
|
|
|
|
}
|
|
|
|
@ -60,31 +68,31 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
|
|
|
|
|
raiseDock(true);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case Dock::DodgeActive: {
|
|
|
|
|
connections[0] = connect(wm.get(), &AbstractWindowInterface::activeWindowChanged
|
|
|
|
|
, this, &VisibilityManagerPrivate::dodgeActive);
|
|
|
|
|
connections[1] = connect(wm.get(), &AbstractWindowInterface::windowChanged
|
|
|
|
|
, this, &VisibilityManagerPrivate::dodgeActive);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dodgeActive(wm->activeWindow());
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case Dock::DodgeMaximized: {
|
|
|
|
|
connections[0] = connect(wm.get(), &AbstractWindowInterface::windowChanged
|
|
|
|
|
, this, &VisibilityManagerPrivate::dodgeMaximized);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case Dock::DodgeAllWindows: {
|
|
|
|
|
for (const auto &wid : wm->windows()) {
|
|
|
|
|
windows.insert({wid, wm->requestInfo(wid)});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connections[0] = connect(wm.get(), &AbstractWindowInterface::windowChanged
|
|
|
|
|
, this, &VisibilityManagerPrivate::dodgeWindows);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
connections[1] = connect(wm.get(), &AbstractWindowInterface::windowRemoved
|
|
|
|
|
, this, [&](WId wid) {
|
|
|
|
|
windows.erase(wid);
|
|
|
|
@ -99,13 +107,15 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
saveConfig();
|
|
|
|
|
|
|
|
|
|
emit q->modeChanged();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline void VisibilityManagerPrivate::setIsHidden(bool isHidden)
|
|
|
|
|
{
|
|
|
|
|
if (this->isHidden == isHidden)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this->isHidden = isHidden;
|
|
|
|
|
emit q->isHiddenChanged();
|
|
|
|
|
}
|
|
|
|
@ -130,15 +140,18 @@ inline void VisibilityManagerPrivate::raiseDock(bool raise)
|
|
|
|
|
/* if (!isHidden == raise) {
|
|
|
|
|
return;
|
|
|
|
|
} */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (raise) {
|
|
|
|
|
timerHide.stop();
|
|
|
|
|
|
|
|
|
|
if (!timerShow.isActive())
|
|
|
|
|
if (!timerShow.isActive() && mode != Dock::AutoHide) {
|
|
|
|
|
timerShow.start();
|
|
|
|
|
} else {
|
|
|
|
|
emit q->mustBeShown();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
timerShow.stop();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!timerHide.isActive())
|
|
|
|
|
timerHide.start();
|
|
|
|
|
}
|
|
|
|
@ -148,7 +161,7 @@ inline void VisibilityManagerPrivate::setDockRect(const QRect &dockRect)
|
|
|
|
|
{
|
|
|
|
|
if (!view->containment() || this->dockRect == dockRect)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this->dockRect = dockRect;
|
|
|
|
|
|
|
|
|
|
if (mode == Dock::AlwaysVisible) {
|
|
|
|
@ -160,12 +173,12 @@ void VisibilityManagerPrivate::dodgeActive(WId wid)
|
|
|
|
|
{
|
|
|
|
|
if (wid != wm->activeWindow())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto winfo = wm->requestInfo(wid);
|
|
|
|
|
|
|
|
|
|
if (!winfo.isValid() || !winfo.isOnCurrentDesktop() || winfo.isMinimized())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
raiseDock(intersects(winfo));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -173,12 +186,12 @@ void VisibilityManagerPrivate::dodgeMaximized(WId wid)
|
|
|
|
|
{
|
|
|
|
|
if (wid != wm->activeWindow())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto winfo = wm->requestInfo(wid);
|
|
|
|
|
|
|
|
|
|
if (!winfo.isValid() || !winfo.isOnCurrentDesktop() || winfo.isMinimized())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
raiseDock(winfo.isMaximized());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -188,7 +201,7 @@ void VisibilityManagerPrivate::dodgeWindows(WId wid)
|
|
|
|
|
|
|
|
|
|
if (!winfo.isValid() || !winfo.isOnCurrentDesktop() || winfo.isMinimized())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (intersects(winfo))
|
|
|
|
|
raiseDock(false);
|
|
|
|
|
else
|
|
|
|
@ -203,7 +216,7 @@ void VisibilityManagerPrivate::checkAllWindows()
|
|
|
|
|
//! std::pair<WId, WindowInfoWrap>
|
|
|
|
|
if (!std::get<1>(winfo).isValid() || !std::get<1>(winfo).isOnCurrentDesktop())
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (std::get<1>(winfo).isFullscreen()) {
|
|
|
|
|
raise = false;
|
|
|
|
|
break;
|
|
|
|
@ -229,7 +242,7 @@ inline void VisibilityManagerPrivate::saveConfig()
|
|
|
|
|
{
|
|
|
|
|
if (!view->containment())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto config = view->containment()->config();
|
|
|
|
|
|
|
|
|
|
config.writeEntry("visibility", static_cast<int>(mode));
|
|
|
|
@ -243,7 +256,7 @@ inline void VisibilityManagerPrivate::restoreConfig()
|
|
|
|
|
{
|
|
|
|
|
if (!view->containment())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto config = view->containment()->config();
|
|
|
|
|
|
|
|
|
|
mode = static_cast<Dock::Visibility>(config.readEntry("visibility", static_cast<int>(Dock::DodgeActive)));
|
|
|
|
@ -259,14 +272,14 @@ bool VisibilityManagerPrivate::event(QEvent *ev)
|
|
|
|
|
|
|
|
|
|
if (mode == Dock::AutoHide)
|
|
|
|
|
raiseDock(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (ev->type() == QEvent::Leave && containsMouse) {
|
|
|
|
|
containsMouse = false;
|
|
|
|
|
emit q->containsMouseChanged();
|
|
|
|
|
|
|
|
|
|
if (mode == Dock::AutoHide)
|
|
|
|
|
raiseDock(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (ev->type() == QEvent::Show) {
|
|
|
|
|
wm->setDockDefaultFlags();
|
|
|
|
|
}
|
|
|
|
@ -338,13 +351,13 @@ void VisibilityManager::updateDockGeometry(const QRect &geometry)
|
|
|
|
|
d->setDockRect(geometry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void VisibilityManager::eventReceived(QEvent *ev)
|
|
|
|
|
{
|
|
|
|
|
d->event(ev);
|
|
|
|
|
}
|
|
|
|
|
//! END: VisibilityManager implementation
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include "abstractwindowinterface.h"
|
|
|
|
|
#include "xwindowinterface.h"
|
|
|
|
|
#include "plasmaquick/containmentview.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|