corona/ has been renamed to app/
parent
615c038b8d
commit
a29378943b
@ -1,48 +0,0 @@
|
||||
|
||||
include(KDEInstallDirs)
|
||||
include(KDECMakeSettings)
|
||||
#include(KDECompilerSettings NO_POLICY_SCOPE)
|
||||
#include(ECMPackageConfigHelpers)
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(WriteBasicConfigVersionFile)
|
||||
include(CheckIncludeFiles)
|
||||
include(ECMOptionalAddSubdirectory)
|
||||
include(ECMQtDeclareLoggingCategory)
|
||||
include(KDEPackageAppTemplates)
|
||||
|
||||
|
||||
set(lattedock-app_SRCS
|
||||
../liblattedock/dock.cpp
|
||||
abstractwindowinterface.cpp
|
||||
xwindowinterface.cpp
|
||||
windowinfowrap.cpp
|
||||
visibilitymanager.cpp
|
||||
nowdockconfigview.cpp
|
||||
nowdockview.cpp
|
||||
packageplugins/shell/nowdockpackage.cpp
|
||||
nowdockcorona.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
#add_subdirectory(packageplugins)
|
||||
|
||||
add_executable(latte-dock ${lattedock-app_SRCS})
|
||||
|
||||
target_link_libraries(
|
||||
latte-dock
|
||||
Qt5::Widgets
|
||||
Qt5::Quick
|
||||
Qt5::Qml
|
||||
KF5::I18n
|
||||
KF5::CoreAddons
|
||||
KF5::XmlGui
|
||||
KF5::PlasmaQuick
|
||||
KF5::Plasma
|
||||
KF5::QuickAddons
|
||||
KF5::DBusAddons
|
||||
KF5::Notifications
|
||||
)
|
||||
|
||||
install(TARGETS latte-dock ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
#even if hidden, the desktop file is needed anyways for kdbusservice::unique
|
||||
install(FILES latte-dock.desktop DESTINATION ${KDE_INSTALL_APPDIR})
|
@ -1,225 +0,0 @@
|
||||
/*
|
||||
* Copyright 2014 Bhushan Shah <bhush94@gmail.com>
|
||||
* Copyright 2014 Marco Martin <notmart@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 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 14 of version 3 of the license.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
#include "nowdockcorona.h"
|
||||
#include "nowdockview.h"
|
||||
//#include "visibilitymanager.h"
|
||||
#include "packageplugins/shell/nowdockpackage.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QScreen>
|
||||
#include <QDebug>
|
||||
|
||||
#include <KActionCollection>
|
||||
#include <KPluginMetaData>
|
||||
|
||||
#include <Plasma>
|
||||
#include <Plasma/Corona>
|
||||
#include <Plasma/Containment>
|
||||
#include <KLocalizedString>
|
||||
#include <KPackage/Package>
|
||||
#include <KPackage/PackageLoader>
|
||||
|
||||
NowDockCorona::NowDockCorona(QObject *parent)
|
||||
: Plasma::Corona(parent)
|
||||
{
|
||||
KPackage::Package package(new NowDockPackage(this));
|
||||
|
||||
if (!package.isValid()) {
|
||||
qWarning() << staticMetaObject.className()
|
||||
<< "the package" << package.metadata().rawData() << "is invalid!";
|
||||
return;
|
||||
} else {
|
||||
qDebug() << staticMetaObject.className()
|
||||
<< "the package" << package.metadata().rawData() << "is valid!";
|
||||
}
|
||||
|
||||
setKPackage(package);
|
||||
qmlRegisterTypes();
|
||||
connect(this, &Corona::containmentAdded, this, &NowDockCorona::addDock);
|
||||
|
||||
loadLayout();
|
||||
|
||||
/*QAction *addDock = actions()->add<QAction>(QStringLiteral("add dock"));
|
||||
connect(addDock, &QAction::triggered, this, &NowDockCorona::loadDefaultLayout);
|
||||
addDock->setText(i18n("Add New Dock"));
|
||||
addDock->setAutoRepeat(true);
|
||||
addDock->setStatusTip(tr("Adds a new dock in the environment"));
|
||||
addDock->setVisible(true);
|
||||
addDock->setEnabled(true);
|
||||
|
||||
addDock->setIcon(QIcon::fromTheme(QStringLiteral("object-locked")));
|
||||
addDock->setData(Plasma::Types::ControlAction);
|
||||
addDock->setShortcut(QKeySequence(QStringLiteral("alt+d, l")));
|
||||
addDock->setShortcutContext(Qt::ApplicationShortcut);*/
|
||||
}
|
||||
|
||||
NowDockCorona::~NowDockCorona()
|
||||
{
|
||||
for (auto c : m_containments)
|
||||
c->deleteLater();
|
||||
|
||||
qDebug() << "deleted" << this;
|
||||
}
|
||||
|
||||
int NowDockCorona::numScreens() const
|
||||
{
|
||||
return qGuiApp->screens().count();
|
||||
}
|
||||
|
||||
QRect NowDockCorona::screenGeometry(int id) const
|
||||
{
|
||||
const auto screens = qGuiApp->screens();
|
||||
|
||||
if (id >= 0 && id < screens.count()) {
|
||||
return screens[id]->geometry();
|
||||
}
|
||||
|
||||
return qGuiApp->primaryScreen()->geometry();
|
||||
}
|
||||
|
||||
QRegion NowDockCorona::availableScreenRegion(int id) const
|
||||
{
|
||||
const auto screens = qGuiApp->screens();
|
||||
|
||||
if (id >= 0 && id < screens.count()) {
|
||||
return screens[id]->geometry();
|
||||
}
|
||||
|
||||
return qGuiApp->primaryScreen()->availableGeometry();
|
||||
}
|
||||
|
||||
QRect NowDockCorona::availableScreenRect(int id) const
|
||||
{
|
||||
const auto screens = qGuiApp->screens();
|
||||
|
||||
if (id >= 0 && id < screens.count()) {
|
||||
return screens[id]->availableGeometry();
|
||||
}
|
||||
|
||||
return qGuiApp->primaryScreen()->availableGeometry();
|
||||
}
|
||||
|
||||
QList<Plasma::Types::Location> NowDockCorona::freeEdges(int screen) const
|
||||
{
|
||||
using Plasma::Types;
|
||||
QList<Types::Location> edges{Types::TopEdge, Types::BottomEdge
|
||||
, Types::LeftEdge, Types::RightEdge};
|
||||
|
||||
for (const NowDockView *cont : m_containments) {
|
||||
if (cont && cont->containment()->screen() == screen)
|
||||
edges.removeOne(cont->location());
|
||||
}
|
||||
|
||||
return edges;
|
||||
}
|
||||
|
||||
int NowDockCorona::screenForContainment(const Plasma::Containment *containment) const
|
||||
{
|
||||
for (auto *view : m_containments) {
|
||||
if (view && view->containment() && view->containment()->id() == containment->id())
|
||||
if (view->screen())
|
||||
return qGuiApp->screens().indexOf(view->screen());
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void NowDockCorona::addDock(Plasma::Containment *containment)
|
||||
{
|
||||
if (!containment || !containment->kPackage().isValid()) {
|
||||
qWarning() << "the requested containment plugin can not be located or loaded";
|
||||
return;
|
||||
}
|
||||
|
||||
qWarning() << "Adding dock for container...";
|
||||
|
||||
auto dockView = new NowDockView(this);
|
||||
dockView->init();
|
||||
dockView->setContainment(containment);
|
||||
dockView->show();
|
||||
//dockView->showNormal();
|
||||
|
||||
m_containments.push_back(dockView);
|
||||
}
|
||||
|
||||
void NowDockCorona::loadDefaultLayout()
|
||||
{
|
||||
|
||||
qDebug() << "loading default layout";
|
||||
//! Settting mutable for create a containment
|
||||
setImmutability(Plasma::Types::Mutable);
|
||||
|
||||
QVariantList args;
|
||||
auto defaultContainment = createContainmentDelayed("org.kde.latte.containment", args);
|
||||
//auto defaultContainment = createContainmentDelayed("org.kde.panel", args);
|
||||
defaultContainment->setContainmentType(Plasma::Types::PanelContainment);
|
||||
defaultContainment->init();
|
||||
|
||||
if (!defaultContainment || !defaultContainment->kPackage().isValid()) {
|
||||
qWarning() << "the requested containment plugin can not be located or loaded";
|
||||
return;
|
||||
}
|
||||
|
||||
auto config = defaultContainment->config();
|
||||
|
||||
config.writeEntry("dock", "initial");
|
||||
// config.writeEntry("alignment", (int)Dock::Center);
|
||||
// config.deleteEntry("wallpaperplugin");
|
||||
|
||||
switch (containments().size()) {
|
||||
case 1:
|
||||
defaultContainment->setLocation(Plasma::Types::LeftEdge);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
defaultContainment->setLocation(Plasma::Types::RightEdge);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
defaultContainment->setLocation(Plasma::Types::TopEdge);
|
||||
break;
|
||||
|
||||
default:
|
||||
defaultContainment->setLocation(Plasma::Types::BottomEdge);
|
||||
break;
|
||||
}
|
||||
|
||||
auto cfg = defaultContainment->config();
|
||||
defaultContainment->save(cfg);
|
||||
|
||||
addDock(defaultContainment);
|
||||
|
||||
defaultContainment->createApplet(QStringLiteral("org.kde.store.nowdock.plasmoid"));
|
||||
defaultContainment->createApplet(QStringLiteral("org.kde.plasma.analogclock"));
|
||||
}
|
||||
|
||||
inline void NowDockCorona::qmlRegisterTypes() const
|
||||
{
|
||||
constexpr auto uri = "org.kde.nowdock.shell";
|
||||
constexpr auto vMajor = 0;
|
||||
constexpr auto vMinor = 2;
|
||||
|
||||
// qmlRegisterUncreatableType<Candil::Dock>(uri, vMajor, vMinor, "Dock", "class Dock uncreatable");
|
||||
// qmlRegisterUncreatableType<Candil::VisibilityManager>(uri, vMajor, vMinor, "VisibilityManager", "class VisibilityManager uncreatable");
|
||||
// qmlRegisterUncreatableType<NowDockView>(uri, vMajor, vMinor, "DockView", "class DockView uncreatable");
|
||||
qmlRegisterType<QScreen>();
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
#ifndef VISIBILITYMANAGER_H
|
||||
#define VISIBILITYMANAGER_H
|
||||
|
||||
#include "plasmaquick/containmentview.h"
|
||||
#include "../liblattedock/dock.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
|
||||
#include <Plasma/Containment>
|
||||
|
||||
class VisibilityManager : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(Latte::Dock::Visibility mode READ mode WRITE setMode NOTIFY modeChanged)
|
||||
Q_PROPERTY(bool isHidden READ isHidden WRITE isHidden NOTIFY isHiddenChanged)
|
||||
Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged)
|
||||
Q_PROPERTY(int timerShow READ timerShow WRITE setTimerShow NOTIFY timerShowChanged)
|
||||
Q_PROPERTY(int timerHide READ timerHide WRITE setTimerHide NOTIFY timerHideChanged)
|
||||
|
||||
public:
|
||||
explicit VisibilityManager(PlasmaQuick::ContainmentView *view);
|
||||
virtual ~VisibilityManager();
|
||||
|
||||
Latte::Dock::Visibility mode() const;
|
||||
void setMode(Latte::Dock::Visibility mode);
|
||||
|
||||
bool isHidden() const;
|
||||
void setHidden(bool isHidden);
|
||||
|
||||
bool containsMouse() const;
|
||||
|
||||
int timerShow() const;
|
||||
void setTimerShow(int msec);
|
||||
|
||||
int timerHide() const;
|
||||
void setTimerHide(int msec);
|
||||
|
||||
/**
|
||||
* @brief updateDockGeometry, the window geometry in absolute coordinates.
|
||||
*/
|
||||
void updateDockGeometry(QRect &geometry);
|
||||
|
||||
signals:
|
||||
void mustBeShown();
|
||||
void mustBeHide();
|
||||
|
||||
void modeChanged();
|
||||
void isHiddenChanged();
|
||||
void containsMouseChanged();
|
||||
void timerShowChanged();
|
||||
void timerHideChanged();
|
||||
|
||||
private:
|
||||
VisibilityManagerPrivate *const d;
|
||||
};
|
||||
#endif // VISIBILITYMANAGER_H
|
@ -1,124 +0,0 @@
|
||||
#include "xwindowinterface.h"
|
||||
|
||||
#include <QtX11Extras/QX11Info>
|
||||
|
||||
#include <KWindowSystem>
|
||||
#include <NETWM>
|
||||
|
||||
namespace Latte {
|
||||
|
||||
XWindowInterface::XWindowInterface(QQuickWindow *const view, QObject *parent)
|
||||
: AbstractWindowInterface(view, parent)
|
||||
{
|
||||
Q_ASSERT(view != nullptr);
|
||||
|
||||
connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged
|
||||
, this, &AbstractWindowInterface::activeWindowChanged);
|
||||
|
||||
connect(KWindowSystem::self()
|
||||
, static_cast<void (KWindowSystem::*)(WId, NET::Properties, NET::Properties2)>
|
||||
(&KWindowSystem::windowChanged)
|
||||
, this, &XWindowInterface::windowChangedProxy);
|
||||
|
||||
connect(KWindowSystem::self(), &KWindowSystem::windowAdded, [this](WId wid) {
|
||||
if (std::find(m_windows.cbegin(), m_windows.cend(), wid) != m_windows.cend()) {
|
||||
m_windows.push_back(wid);
|
||||
}
|
||||
|
||||
emit windowAdded(wid);
|
||||
});
|
||||
|
||||
connect(KWindowSystem::self(), &KWindowSystem::windowAdded, [this](WId wid) {
|
||||
m_windows.remove(wid);
|
||||
emit windowRemoved(wid);
|
||||
});
|
||||
|
||||
connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged
|
||||
, this, &AbstractWindowInterface::currentDesktopChanged);
|
||||
}
|
||||
|
||||
XWindowInterface::~XWindowInterface()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void XWindowInterface::setDockDefaultFlags()
|
||||
{
|
||||
NETWinInfo winfo(QX11Info::connection()
|
||||
, static_cast<xcb_window_t>(m_view->winId())
|
||||
, static_cast<xcb_window_t>(m_view->winId())
|
||||
, 0, 0);
|
||||
|
||||
winfo.setAllowedActions(NET::ActionChangeDesktop);
|
||||
KWindowSystem::setType(m_view->winId(), NET::Dock);
|
||||
KWindowSystem::setOnAllDesktops(m_view->winId(), true);
|
||||
}
|
||||
|
||||
WId XWindowInterface::activeWindow() const
|
||||
{
|
||||
return KWindowSystem::self()->activeWindow();
|
||||
}
|
||||
|
||||
const std::list<WId> &XWindowInterface::windows()
|
||||
{
|
||||
return m_windows;
|
||||
}
|
||||
|
||||
WindowInfoWrap XWindowInterface::requestInfoActive()
|
||||
{
|
||||
return requestInfo(KWindowSystem::activeWindow());
|
||||
}
|
||||
|
||||
WindowInfoWrap XWindowInterface::requestInfo(WId wid)
|
||||
{
|
||||
const KWindowInfo winfo{wid, NET::WMDesktop | NET::WMFrameExtents | NET::WMWindowType | NET::WMState};
|
||||
|
||||
WindowInfoWrap winfoWrap;
|
||||
|
||||
if (!winfo.valid() || !isValidWindow(winfo))
|
||||
return winfoWrap;
|
||||
|
||||
winfoWrap.setIsValid(true);
|
||||
winfoWrap.setWid(wid);
|
||||
winfoWrap.setIsActive(KWindowSystem::activeWindow() == wid);
|
||||
winfoWrap.setIsMinimized(winfo.hasState(NET::Hidden));
|
||||
winfoWrap.setIsMaximized(winfo.hasState(NET::Max));
|
||||
winfoWrap.setIsFullscreen(winfo.hasState(NET::FullScreen));
|
||||
winfoWrap.setIsOnCurrentDesktop(winfo.isOnCurrentDesktop());
|
||||
winfoWrap.setGeometry(winfo.geometry());
|
||||
|
||||
return winfoWrap;
|
||||
}
|
||||
|
||||
bool XWindowInterface::isValidWindow(const KWindowInfo &winfo)
|
||||
{
|
||||
const auto winType = winfo.windowType(NET::DesktopMask | NET::DockMask
|
||||
| NET::MenuMask | NET::SplashMask
|
||||
| NET::NormalMask);
|
||||
|
||||
if (winType == -1 || (winType & NET::Desktop) || (winType & NET::Menu)
|
||||
|| (winType & NET::Dock) || (winType & NET::Splash)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void XWindowInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2)
|
||||
{
|
||||
//! if the dock changed is ignored
|
||||
if (wid == m_view->winId())
|
||||
return;
|
||||
|
||||
//! ignore when, eg: the user presses a key
|
||||
if (prop1 == 0 && prop2 == NET::WM2UserTime)
|
||||
return;
|
||||
|
||||
if (prop1 && !(prop1 & NET::WMState || prop1 & NET::WMGeometry || prop1 & NET::ActiveWindow))
|
||||
return;
|
||||
|
||||
emit windowChanged(requestInfo(wid));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue