mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-27 14:50:21 +03:00
#199, AbstractWindowInterface is now a shared resource
This commit is contained in:
parent
9fc10c84b1
commit
a12ce7d3ab
@ -1,6 +1,5 @@
|
||||
set(lattedock-app_SRCS
|
||||
../liblattedock/dock.cpp
|
||||
../liblattedock/windowsystem.cpp
|
||||
windowinfowrap.cpp
|
||||
abstractwindowinterface.cpp
|
||||
xwindowinterface.cpp
|
||||
|
@ -28,8 +28,8 @@
|
||||
|
||||
namespace Latte {
|
||||
|
||||
AbstractWindowInterface::AbstractWindowInterface(QQuickWindow *const view, QObject *parent)
|
||||
: QObject(parent), m_view(view)
|
||||
AbstractWindowInterface::AbstractWindowInterface(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
@ -37,15 +37,33 @@ AbstractWindowInterface::~AbstractWindowInterface()
|
||||
{
|
||||
}
|
||||
|
||||
AbstractWindowInterface *AbstractWindowInterface::getInstance(QQuickWindow *const view, QObject *parent)
|
||||
void AbstractWindowInterface::addDock(WId wid)
|
||||
{
|
||||
m_docks.push_back(wid);
|
||||
}
|
||||
|
||||
void AbstractWindowInterface::removeDock(WId wid)
|
||||
{
|
||||
auto it = std::find(m_docks.begin(), m_docks.end(), wid);
|
||||
|
||||
if (it != m_docks.end())
|
||||
m_docks.erase(it);
|
||||
}
|
||||
|
||||
AbstractWindowInterface &AbstractWindowInterface::self()
|
||||
{
|
||||
if (m_wm)
|
||||
return *m_wm;
|
||||
|
||||
if (KWindowSystem::isPlatformWayland()) {
|
||||
//! TODO: WaylandWindowInterface
|
||||
return nullptr;
|
||||
} else /* if(KWindowSystem::isPlatformX11) */ {
|
||||
m_wm = new XWindowInterface;
|
||||
}
|
||||
|
||||
/* if(KWindowSystem::isPlatformX11) */
|
||||
return new XWindowInterface(view, parent);
|
||||
return *m_wm;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QPointer<Latte::AbstractWindowInterface> Latte::AbstractWindowInterface::m_wm;
|
||||
|
@ -23,16 +23,19 @@
|
||||
|
||||
#include "windowinfowrap.h"
|
||||
#include "../liblattedock/dock.h"
|
||||
#include "../liblattedock/extras.h"
|
||||
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include <list>
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QRect>
|
||||
#include <QQuickWindow>
|
||||
#include <QQuickView>
|
||||
#include <QDialog>
|
||||
|
||||
#include <Plasma>
|
||||
#include <KActivities/Consumer>
|
||||
|
||||
namespace Latte {
|
||||
|
||||
@ -42,10 +45,20 @@ class AbstractWindowInterface : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AbstractWindowInterface(QQuickWindow *const view, QObject *parent = nullptr);
|
||||
enum class Slide {
|
||||
None,
|
||||
Top,
|
||||
Left,
|
||||
Bottom,
|
||||
Right,
|
||||
};
|
||||
|
||||
explicit AbstractWindowInterface(QObject *parent = nullptr);
|
||||
virtual ~AbstractWindowInterface();
|
||||
|
||||
virtual void setDockDefaultFlags() = 0;
|
||||
virtual void setDockExtraFlags(QQuickWindow &view) = 0;
|
||||
virtual void setDockStruts(WId dockId, const QRect &dockRect, Plasma::Types::Location location) const = 0;
|
||||
virtual void removeDockStruts(WId dockId) const = 0;
|
||||
|
||||
virtual WId activeWindow() const = 0;
|
||||
virtual WindowInfoWrap requestInfo(WId wid) const = 0;
|
||||
@ -53,10 +66,14 @@ public:
|
||||
virtual bool isOnCurrentDesktop(WId wid) const = 0;
|
||||
virtual const std::list<WId> &windows() const = 0;
|
||||
|
||||
virtual void setDockStruts(const QRect &dockRect, Plasma::Types::Location location) const = 0;
|
||||
virtual void removeDockStruts() const = 0;
|
||||
virtual void skipTaskBar(const QDialog &dialog) const = 0;
|
||||
virtual void slideWindow(QQuickWindow &view, Slide location) const = 0;
|
||||
virtual void enableBlurBehind(QQuickWindow &view) const = 0;
|
||||
|
||||
static AbstractWindowInterface *getInstance(QQuickWindow *const view, QObject *parent = nullptr);
|
||||
void addDock(WId wid);
|
||||
void removeDock(WId wid);
|
||||
|
||||
static AbstractWindowInterface &self();
|
||||
|
||||
signals:
|
||||
void activeWindowChanged(WId wid);
|
||||
@ -67,10 +84,15 @@ signals:
|
||||
void currentActivityChanged();
|
||||
|
||||
protected:
|
||||
QQuickWindow *const m_view;
|
||||
std::list<WId> m_windows;
|
||||
std::list<WId> m_docks;
|
||||
QPointer<KActivities::Consumer> m_activities;
|
||||
|
||||
static QPointer<AbstractWindowInterface> m_wm;
|
||||
};
|
||||
|
||||
}
|
||||
// namespace alias
|
||||
using WindowSystem = AbstractWindowInterface;
|
||||
|
||||
}
|
||||
#endif // ABSTRACTWINDOWINTERFACE_H
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "dockview.h"
|
||||
#include "dockcorona.h"
|
||||
#include "panelshadows_p.h"
|
||||
#include "abstractwindowinterface.h"
|
||||
|
||||
#include <QQuickItem>
|
||||
#include <QQmlContext>
|
||||
@ -30,8 +31,6 @@
|
||||
|
||||
#include <KLocalizedContext>
|
||||
#include <KDeclarative/KDeclarative>
|
||||
#include <KWindowSystem>
|
||||
#include <KWindowEffects>
|
||||
|
||||
#include <Plasma/Package>
|
||||
|
||||
@ -52,15 +51,11 @@ DockConfigView::DockConfigView(Plasma::Containment *containment, DockView *dockV
|
||||
connections << connect(dockView, SIGNAL(screenChanged(QScreen *)), &m_screenSyncTimer, SLOT(start()));
|
||||
connections << connect(&m_screenSyncTimer, &QTimer::timeout, this, [this]() {
|
||||
setScreen(m_dockView->screen());
|
||||
KWindowSystem::setType(winId(), NET::Dock);
|
||||
WindowSystem::self().setDockExtraFlags(*this);
|
||||
setFlags(wFlags());
|
||||
syncGeometry();
|
||||
syncSlideEffect();
|
||||
});
|
||||
KWindowSystem::setType(winId(), NET::Dock);
|
||||
KWindowSystem::setState(winId(), NET::KeepAbove);
|
||||
setFlags(wFlags());
|
||||
KWindowSystem::forceActiveWindow(winId());
|
||||
connections << connect(dockView->visibility(), &VisibilityManager::modeChanged, this, &DockConfigView::syncGeometry);
|
||||
connections << connect(containment, &Plasma::Containment::immutabilityChanged, this, &DockConfigView::immutabilityChanged);
|
||||
connections << connect(containment, &Plasma::Containment::locationChanged, [&]() {
|
||||
@ -154,23 +149,23 @@ void DockConfigView::syncSlideEffect()
|
||||
if (!m_dockView->containment())
|
||||
return;
|
||||
|
||||
KWindowEffects::SlideFromLocation slideLocation{KWindowEffects::NoEdge};
|
||||
auto slideLocation = WindowSystem::Slide::None;
|
||||
|
||||
switch (m_dockView->containment()->location()) {
|
||||
case Plasma::Types::TopEdge:
|
||||
slideLocation = KWindowEffects::TopEdge;
|
||||
slideLocation = WindowSystem::Slide::Top;
|
||||
break;
|
||||
|
||||
case Plasma::Types::RightEdge:
|
||||
slideLocation = KWindowEffects::RightEdge;
|
||||
slideLocation = WindowSystem::Slide::Right;
|
||||
break;
|
||||
|
||||
case Plasma::Types::BottomEdge:
|
||||
slideLocation = KWindowEffects::BottomEdge;
|
||||
slideLocation = WindowSystem::Slide::Bottom;
|
||||
break;
|
||||
|
||||
case Plasma::Types::LeftEdge:
|
||||
slideLocation = KWindowEffects::LeftEdge;
|
||||
slideLocation = WindowSystem::Slide::Left;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -178,17 +173,18 @@ void DockConfigView::syncSlideEffect()
|
||||
break;
|
||||
}
|
||||
|
||||
KWindowEffects::slideWindow(winId(), slideLocation, -1);
|
||||
WindowSystem::self().slideWindow(*this, slideLocation);
|
||||
}
|
||||
|
||||
void DockConfigView::showEvent(QShowEvent *ev)
|
||||
{
|
||||
QQuickWindow::showEvent(ev);
|
||||
KWindowSystem::setType(winId(), NET::Dock);
|
||||
|
||||
WindowSystem::self().setDockExtraFlags(*this);
|
||||
setFlags(wFlags());
|
||||
KWindowSystem::setState(winId(), NET::KeepAbove | NET::SkipPager | NET::SkipTaskbar);
|
||||
KWindowSystem::forceActiveWindow(winId());
|
||||
KWindowEffects::enableBlurBehind(winId(), true);
|
||||
|
||||
WindowSystem::self().enableBlurBehind(*this);
|
||||
|
||||
syncGeometry();
|
||||
syncSlideEffect();
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "dockcorona.h"
|
||||
#include "dockview.h"
|
||||
#include "packageplugins/shell/dockpackage.h"
|
||||
#include "../liblattedock/windowsystem.h"
|
||||
#include "abstractwindowinterface.h"
|
||||
#include "alternativeshelper.h"
|
||||
|
||||
#include <QAction>
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "visibilitymanager.h"
|
||||
#include "panelshadows_p.h"
|
||||
#include "../liblattedock/extras.h"
|
||||
#include "../liblattedock/windowsystem.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QQmlContext>
|
||||
@ -54,6 +53,10 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen)
|
||||
setIcon(QIcon::fromTheme(corona->kPackage().metadata().iconName()));
|
||||
setResizeMode(QuickViewSharedEngine::SizeRootObjectToView);
|
||||
setClearBeforeRendering(true);
|
||||
setFlags(Qt::FramelessWindowHint
|
||||
| Qt::WindowStaysOnTopHint
|
||||
| Qt::NoDropShadowWindowHint
|
||||
| Qt::WindowDoesNotAcceptFocus);
|
||||
|
||||
if (targetScreen)
|
||||
adaptToScreen(targetScreen);
|
||||
|
@ -30,7 +30,7 @@ namespace Latte {
|
||||
|
||||
//! BEGIN: VisiblityManagerPrivate implementation
|
||||
VisibilityManagerPrivate::VisibilityManagerPrivate(PlasmaQuick::ContainmentView *view, VisibilityManager *q)
|
||||
: QObject(q), q(q), view(view), wm(AbstractWindowInterface::getInstance(view, nullptr))
|
||||
: QObject(q), q(q), view(view), wm(&AbstractWindowInterface::self())
|
||||
{
|
||||
DockView *dockView = qobject_cast<DockView *>(view);
|
||||
|
||||
@ -56,13 +56,14 @@ VisibilityManagerPrivate::VisibilityManagerPrivate(PlasmaQuick::ContainmentView
|
||||
emit this->q->mustBeHide();
|
||||
}
|
||||
});
|
||||
wm->setDockDefaultFlags();
|
||||
wm->setDockExtraFlags(*view);
|
||||
wm->addDock(view->winId());
|
||||
}
|
||||
|
||||
VisibilityManagerPrivate::~VisibilityManagerPrivate()
|
||||
{
|
||||
wm->removeDockStruts();
|
||||
wm->deleteLater();
|
||||
wm->removeDockStruts(view->winId());
|
||||
wm->removeDock(view->winId());
|
||||
}
|
||||
|
||||
inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
|
||||
@ -72,7 +73,7 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
|
||||
|
||||
// clear mode
|
||||
if (this->mode == Dock::AlwaysVisible)
|
||||
wm->removeDockStruts();
|
||||
wm->removeDockStruts(view->winId());
|
||||
|
||||
for (auto &c : connections) {
|
||||
disconnect(c);
|
||||
@ -86,52 +87,52 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
|
||||
switch (this->mode) {
|
||||
case Dock::AlwaysVisible: {
|
||||
if (view->containment() && !view->containment()->isUserConfiguring())
|
||||
wm->setDockStruts(dockGeometry, view->location());
|
||||
wm->setDockStruts(view->winId(), dockGeometry, view->location());
|
||||
|
||||
connections[0] = connect(view->containment(), &Plasma::Containment::locationChanged
|
||||
, this, [&]() {
|
||||
if (view->containment()->isUserConfiguring())
|
||||
wm->removeDockStruts();
|
||||
wm->removeDockStruts(view->winId());
|
||||
});
|
||||
connections[1] = connect(view->containment(), &Plasma::Containment::userConfiguringChanged
|
||||
, this, [&](bool configuring) {
|
||||
if (!configuring)
|
||||
wm->setDockStruts(dockGeometry, view->containment()->location());
|
||||
wm->setDockStruts(view->winId(), dockGeometry, view->containment()->location());
|
||||
});
|
||||
raiseDock(true);
|
||||
}
|
||||
break;
|
||||
|
||||
case Dock::AutoHide: {
|
||||
connections[0] = connect(wm.get(), &AbstractWindowInterface::currentDesktopChanged
|
||||
connections[0] = connect(wm, &AbstractWindowInterface::currentDesktopChanged
|
||||
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
|
||||
connections[1] = connect(wm.get(), &AbstractWindowInterface::currentActivityChanged
|
||||
connections[1] = connect(wm, &AbstractWindowInterface::currentActivityChanged
|
||||
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
|
||||
raiseDock(containsMouse);
|
||||
}
|
||||
break;
|
||||
|
||||
case Dock::DodgeActive: {
|
||||
connections[0] = connect(wm.get(), &AbstractWindowInterface::activeWindowChanged
|
||||
connections[0] = connect(wm, &AbstractWindowInterface::activeWindowChanged
|
||||
, this, &VisibilityManagerPrivate::dodgeActive);
|
||||
connections[1] = connect(wm.get(), &AbstractWindowInterface::windowChanged
|
||||
connections[1] = connect(wm, &AbstractWindowInterface::windowChanged
|
||||
, this, &VisibilityManagerPrivate::dodgeActive);
|
||||
connections[2] = connect(wm.get(), &AbstractWindowInterface::currentDesktopChanged
|
||||
connections[2] = connect(wm, &AbstractWindowInterface::currentDesktopChanged
|
||||
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
|
||||
connections[3] = connect(wm.get(), &AbstractWindowInterface::currentActivityChanged
|
||||
connections[3] = connect(wm, &AbstractWindowInterface::currentActivityChanged
|
||||
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
|
||||
dodgeActive(wm->activeWindow());
|
||||
}
|
||||
break;
|
||||
|
||||
case Dock::DodgeMaximized: {
|
||||
connections[0] = connect(wm.get(), &AbstractWindowInterface::activeWindowChanged
|
||||
connections[0] = connect(wm, &AbstractWindowInterface::activeWindowChanged
|
||||
, this, &VisibilityManagerPrivate::dodgeMaximized);
|
||||
connections[1] = connect(wm.get(), &AbstractWindowInterface::windowChanged
|
||||
connections[1] = connect(wm, &AbstractWindowInterface::windowChanged
|
||||
, this, &VisibilityManagerPrivate::dodgeMaximized);
|
||||
connections[2] = connect(wm.get(), &AbstractWindowInterface::currentDesktopChanged
|
||||
connections[2] = connect(wm, &AbstractWindowInterface::currentDesktopChanged
|
||||
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
|
||||
connections[3] = connect(wm.get(), &AbstractWindowInterface::currentActivityChanged
|
||||
connections[3] = connect(wm, &AbstractWindowInterface::currentActivityChanged
|
||||
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
|
||||
dodgeMaximized(wm->activeWindow());
|
||||
}
|
||||
@ -142,21 +143,21 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
|
||||
windows.insert({wid, wm->requestInfo(wid)});
|
||||
}
|
||||
|
||||
connections[0] = connect(wm.get(), &AbstractWindowInterface::windowChanged
|
||||
connections[0] = connect(wm, &AbstractWindowInterface::windowChanged
|
||||
, this, &VisibilityManagerPrivate::dodgeWindows);
|
||||
connections[1] = connect(wm.get(), &AbstractWindowInterface::windowRemoved
|
||||
connections[1] = connect(wm, &AbstractWindowInterface::windowRemoved
|
||||
, this, [&](WId wid) {
|
||||
windows.erase(wid);
|
||||
timerCheckWindows.start();
|
||||
});
|
||||
connections[2] = connect(wm.get(), &AbstractWindowInterface::windowAdded
|
||||
connections[2] = connect(wm, &AbstractWindowInterface::windowAdded
|
||||
, this, [&](WId wid) {
|
||||
windows.insert({wid, wm->requestInfo(wid)});
|
||||
timerCheckWindows.start();
|
||||
});
|
||||
connections[3] = connect(wm.get(), &AbstractWindowInterface::currentDesktopChanged
|
||||
connections[3] = connect(wm, &AbstractWindowInterface::currentDesktopChanged
|
||||
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
|
||||
connections[4] = connect(wm.get(), &AbstractWindowInterface::currentActivityChanged
|
||||
connections[4] = connect(wm, &AbstractWindowInterface::currentActivityChanged
|
||||
, this, &VisibilityManagerPrivate::raiseDockTemporarily);
|
||||
|
||||
timerCheckWindows.start();
|
||||
@ -292,7 +293,7 @@ inline void VisibilityManagerPrivate::setDockGeometry(const QRect &geometry)
|
||||
this->dockGeometry = geometry;
|
||||
|
||||
if (mode == Dock::AlwaysVisible && !view->containment()->isUserConfiguring()) {
|
||||
wm->setDockStruts(this->dockGeometry, view->containment()->location());
|
||||
wm->setDockStruts(view->winId(), this->dockGeometry, view->containment()->location());
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,7 +455,7 @@ bool VisibilityManagerPrivate::event(QEvent *ev)
|
||||
break;
|
||||
|
||||
case QEvent::Show:
|
||||
wm->setDockDefaultFlags();
|
||||
wm->setDockExtraFlags(*view);
|
||||
restoreConfig();
|
||||
break;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
|
||||
VisibilityManager *q;
|
||||
PlasmaQuick::ContainmentView *view;
|
||||
std::unique_ptr<AbstractWindowInterface> wm;
|
||||
AbstractWindowInterface *wm;
|
||||
Dock::Visibility mode{Dock::None};
|
||||
std::array<QMetaObject::Connection, 5> connections;
|
||||
std::unordered_map<WId, WindowInfoWrap> windows;
|
||||
|
@ -19,131 +19,3 @@
|
||||
*/
|
||||
|
||||
#include "windowinfowrap.h"
|
||||
|
||||
namespace Latte {
|
||||
|
||||
WindowInfoWrap::WindowInfoWrap()
|
||||
: m_isValid(false)
|
||||
, m_isActive(false)
|
||||
, m_isMinimized(false)
|
||||
, m_isMaximized(false)
|
||||
, m_isFullscreen(false)
|
||||
, m_isPlasmaDesktop(false)
|
||||
, m_wid(0)
|
||||
{
|
||||
}
|
||||
|
||||
WindowInfoWrap::WindowInfoWrap(const WindowInfoWrap &other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
|
||||
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_isFullscreen = rhs.m_isFullscreen;
|
||||
m_isPlasmaDesktop = rhs.m_isPlasmaDesktop;
|
||||
m_geometry = rhs.m_geometry;
|
||||
m_wid = rhs.m_wid;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool WindowInfoWrap::operator==(const WindowInfoWrap &rhs) const
|
||||
{
|
||||
return m_wid == rhs.m_wid;
|
||||
}
|
||||
|
||||
bool WindowInfoWrap::operator<(const WindowInfoWrap &rhs) const
|
||||
{
|
||||
return m_wid < rhs.m_wid;
|
||||
}
|
||||
|
||||
bool WindowInfoWrap::operator>(const WindowInfoWrap &rhs) const
|
||||
{
|
||||
return m_wid > rhs.m_wid;
|
||||
}
|
||||
|
||||
bool WindowInfoWrap::isValid() const
|
||||
{
|
||||
return m_isValid;
|
||||
}
|
||||
|
||||
void WindowInfoWrap::setIsValid(bool isValid)
|
||||
{
|
||||
m_isValid = isValid;
|
||||
}
|
||||
|
||||
bool WindowInfoWrap::isActive() const
|
||||
{
|
||||
return m_isActive;
|
||||
}
|
||||
|
||||
void WindowInfoWrap::setIsActive(bool isActive)
|
||||
{
|
||||
m_isActive = isActive;
|
||||
}
|
||||
|
||||
bool WindowInfoWrap::isMinimized() const
|
||||
{
|
||||
return m_isMinimized;
|
||||
}
|
||||
|
||||
void WindowInfoWrap::setIsMinimized(bool isMinimized)
|
||||
{
|
||||
m_isMinimized = isMinimized;
|
||||
}
|
||||
|
||||
bool WindowInfoWrap::isMaximized() const
|
||||
{
|
||||
return m_isMaximized;
|
||||
}
|
||||
|
||||
void WindowInfoWrap::setIsMaximized(bool isMaximized)
|
||||
{
|
||||
m_isMaximized = isMaximized;
|
||||
}
|
||||
|
||||
bool WindowInfoWrap::isFullscreen() const
|
||||
{
|
||||
return m_isFullscreen;
|
||||
}
|
||||
|
||||
void WindowInfoWrap::setIsFullscreen(bool isFullscreen)
|
||||
{
|
||||
m_isFullscreen = isFullscreen;
|
||||
}
|
||||
|
||||
bool WindowInfoWrap::isPlasmaDesktop() const
|
||||
{
|
||||
return m_isPlasmaDesktop;
|
||||
}
|
||||
|
||||
void WindowInfoWrap::setIsPlasmaDesktop(bool isPlasmaDesktop)
|
||||
{
|
||||
m_isPlasmaDesktop = isPlasmaDesktop;
|
||||
}
|
||||
|
||||
QRect WindowInfoWrap::geometry() const
|
||||
{
|
||||
return m_geometry;
|
||||
}
|
||||
|
||||
void WindowInfoWrap::setGeometry(const QRect &geometry)
|
||||
{
|
||||
m_geometry = geometry;
|
||||
}
|
||||
|
||||
void WindowInfoWrap::setWid(WId wid)
|
||||
{
|
||||
m_wid = wid;
|
||||
}
|
||||
|
||||
WId WindowInfoWrap::wid() const
|
||||
{
|
||||
return m_wid;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,8 +21,7 @@
|
||||
#ifndef WINDOWINFOWRAP_H
|
||||
#define WINDOWINFOWRAP_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QWidget>
|
||||
#include <QWindow>
|
||||
#include <QRect>
|
||||
|
||||
namespace Latte {
|
||||
@ -30,38 +29,56 @@ namespace Latte {
|
||||
class WindowInfoWrap {
|
||||
|
||||
public:
|
||||
explicit WindowInfoWrap();
|
||||
WindowInfoWrap(const WindowInfoWrap &other);
|
||||
constexpr WindowInfoWrap()
|
||||
: m_isValid(false)
|
||||
, m_isActive(false)
|
||||
, m_isMinimized(false)
|
||||
, m_isMaximized(false)
|
||||
, m_isFullscreen(false)
|
||||
, m_isPlasmaDesktop(false)
|
||||
, m_wid(0)
|
||||
{
|
||||
}
|
||||
|
||||
WindowInfoWrap &operator=(const WindowInfoWrap &rhs);
|
||||
constexpr WindowInfoWrap(const WindowInfoWrap &other)
|
||||
: m_isValid(other.m_isValid)
|
||||
, m_isActive(other.m_isActive)
|
||||
, m_isMinimized(other.m_isMinimized)
|
||||
, m_isMaximized(other.m_isMaximized)
|
||||
, m_isFullscreen(other.m_isFullscreen)
|
||||
, m_isPlasmaDesktop(other.m_isPlasmaDesktop)
|
||||
, m_wid(other.m_wid)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const WindowInfoWrap &rhs) const;
|
||||
bool operator<(const WindowInfoWrap &rhs) const;
|
||||
bool operator>(const WindowInfoWrap &rhs) const;
|
||||
inline WindowInfoWrap &operator=(const WindowInfoWrap &rhs);
|
||||
constexpr bool operator==(const WindowInfoWrap &rhs) const;
|
||||
constexpr bool operator<(const WindowInfoWrap &rhs) const;
|
||||
constexpr bool operator>(const WindowInfoWrap &rhs) const;
|
||||
|
||||
bool isValid() const;
|
||||
void setIsValid(bool isValid);
|
||||
constexpr bool isValid() const;
|
||||
inline void setIsValid(bool isValid);
|
||||
|
||||
bool isActive() const;
|
||||
void setIsActive(bool isActive);
|
||||
constexpr bool isActive() const;
|
||||
inline void setIsActive(bool isActive);
|
||||
|
||||
bool isMinimized() const;
|
||||
void setIsMinimized(bool isMinimized);
|
||||
constexpr bool isMinimized() const;
|
||||
inline void setIsMinimized(bool isMinimized);
|
||||
|
||||
bool isMaximized() const;
|
||||
void setIsMaximized(bool isMaximized);
|
||||
constexpr bool isMaximized() const;
|
||||
inline void setIsMaximized(bool isMaximized);
|
||||
|
||||
bool isFullscreen() const;
|
||||
void setIsFullscreen(bool isFullscreen);
|
||||
constexpr bool isFullscreen() const;
|
||||
inline void setIsFullscreen(bool isFullscreen);
|
||||
|
||||
bool isPlasmaDesktop() const;
|
||||
void setIsPlasmaDesktop(bool isPlasmaDesktop);
|
||||
constexpr bool isPlasmaDesktop() const;
|
||||
inline void setIsPlasmaDesktop(bool isPlasmaDesktop);
|
||||
|
||||
QRect geometry() const;
|
||||
void setGeometry(const QRect &geometry);
|
||||
constexpr QRect geometry() const;
|
||||
inline void setGeometry(const QRect &geometry);
|
||||
|
||||
WId wid() const;
|
||||
void setWid(WId wid);
|
||||
constexpr WId wid() const;
|
||||
inline void setWid(WId wid);
|
||||
|
||||
private:
|
||||
bool m_isValid : 1;
|
||||
@ -70,10 +87,121 @@ private:
|
||||
bool m_isMaximized : 1;
|
||||
bool m_isFullscreen : 1;
|
||||
bool m_isPlasmaDesktop : 1;
|
||||
WId m_wid;
|
||||
QRect m_geometry;
|
||||
WId m_wid{0};
|
||||
};
|
||||
|
||||
// BEGIN: definitions
|
||||
|
||||
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_isFullscreen = rhs.m_isFullscreen;
|
||||
m_isPlasmaDesktop = rhs.m_isPlasmaDesktop;
|
||||
m_wid = rhs.m_wid;
|
||||
m_geometry = rhs.m_geometry;
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr bool WindowInfoWrap::operator==(const WindowInfoWrap &rhs) const
|
||||
{
|
||||
return m_wid == rhs.m_wid;
|
||||
}
|
||||
|
||||
constexpr bool WindowInfoWrap::operator<(const WindowInfoWrap &rhs) const
|
||||
{
|
||||
return m_wid < rhs.m_wid;
|
||||
}
|
||||
|
||||
constexpr bool WindowInfoWrap::operator>(const WindowInfoWrap &rhs) const
|
||||
{
|
||||
return m_wid > rhs.m_wid;
|
||||
}
|
||||
|
||||
constexpr bool WindowInfoWrap::isValid() const
|
||||
{
|
||||
return m_isValid;
|
||||
}
|
||||
|
||||
inline void WindowInfoWrap::setIsValid(bool isValid)
|
||||
{
|
||||
m_isValid = isValid;
|
||||
}
|
||||
|
||||
constexpr bool WindowInfoWrap::isActive() const
|
||||
{
|
||||
return m_isActive;
|
||||
}
|
||||
|
||||
inline void WindowInfoWrap::setIsActive(bool isActive)
|
||||
{
|
||||
m_isActive = isActive;
|
||||
}
|
||||
|
||||
constexpr bool WindowInfoWrap::isMinimized() const
|
||||
{
|
||||
return m_isMinimized;
|
||||
}
|
||||
|
||||
inline void WindowInfoWrap::setIsMinimized(bool isMinimized)
|
||||
{
|
||||
m_isMinimized = isMinimized;
|
||||
}
|
||||
|
||||
constexpr bool WindowInfoWrap::isMaximized() const
|
||||
{
|
||||
return m_isMaximized;
|
||||
}
|
||||
|
||||
inline void WindowInfoWrap::setIsMaximized(bool isMaximized)
|
||||
{
|
||||
m_isMaximized = isMaximized;
|
||||
}
|
||||
|
||||
constexpr bool WindowInfoWrap::isFullscreen() const
|
||||
{
|
||||
return m_isFullscreen;
|
||||
}
|
||||
|
||||
inline void WindowInfoWrap::setIsFullscreen(bool isFullscreen)
|
||||
{
|
||||
m_isFullscreen = isFullscreen;
|
||||
}
|
||||
|
||||
constexpr bool WindowInfoWrap::isPlasmaDesktop() const
|
||||
{
|
||||
return m_isPlasmaDesktop;
|
||||
}
|
||||
|
||||
inline void WindowInfoWrap::setIsPlasmaDesktop(bool isPlasmaDesktop)
|
||||
{
|
||||
m_isPlasmaDesktop = isPlasmaDesktop;
|
||||
}
|
||||
|
||||
constexpr QRect WindowInfoWrap::geometry() const
|
||||
{
|
||||
return m_geometry;
|
||||
}
|
||||
|
||||
inline void WindowInfoWrap::setGeometry(const QRect &geometry)
|
||||
{
|
||||
m_geometry = geometry;
|
||||
}
|
||||
|
||||
constexpr WId WindowInfoWrap::wid() const
|
||||
{
|
||||
return m_wid;
|
||||
}
|
||||
|
||||
inline void WindowInfoWrap::setWid(WId wid)
|
||||
{
|
||||
m_wid = wid;
|
||||
}
|
||||
|
||||
// END: definitions
|
||||
}
|
||||
|
||||
#endif // WINDOWINFOWRAP_H
|
||||
|
@ -31,17 +31,17 @@
|
||||
|
||||
namespace Latte {
|
||||
|
||||
XWindowInterface::XWindowInterface(QQuickWindow *const view, QObject *parent)
|
||||
: AbstractWindowInterface(view, parent), activities(new KActivities::Consumer(this))
|
||||
XWindowInterface::XWindowInterface(QObject *parent)
|
||||
: AbstractWindowInterface(parent)
|
||||
{
|
||||
Q_ASSERT(view != nullptr);
|
||||
|
||||
connections << connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged
|
||||
m_activities = new KActivities::Consumer(this);
|
||||
connect(KWindowSystem::self(), &KWindowSystem::activeWindowChanged
|
||||
, this, &AbstractWindowInterface::activeWindowChanged);
|
||||
connections << connect(KWindowSystem::self()
|
||||
connect(KWindowSystem::self()
|
||||
, static_cast<void (KWindowSystem::*)(WId, NET::Properties, NET::Properties2)>
|
||||
(&KWindowSystem::windowChanged)
|
||||
, this, &XWindowInterface::windowChangedProxy);
|
||||
|
||||
auto addWindow = [&](WId wid) {
|
||||
if (std::find(m_windows.cbegin(), m_windows.cend(), wid) == m_windows.cend()) {
|
||||
if (isValidWindow(KWindowInfo(wid, NET::WMWindowType))) {
|
||||
@ -50,16 +50,17 @@ XWindowInterface::XWindowInterface(QQuickWindow *const view, QObject *parent)
|
||||
}
|
||||
}
|
||||
};
|
||||
connections << connect(KWindowSystem::self(), &KWindowSystem::windowAdded, this, addWindow);
|
||||
connections << connect(KWindowSystem::self(), &KWindowSystem::windowRemoved, [this](WId wid) {
|
||||
|
||||
connect(KWindowSystem::self(), &KWindowSystem::windowAdded, this, addWindow);
|
||||
connect(KWindowSystem::self(), &KWindowSystem::windowRemoved, [this](WId wid) {
|
||||
if (std::find(m_windows.cbegin(), m_windows.cend(), wid) != m_windows.end()) {
|
||||
m_windows.remove(wid);
|
||||
emit windowRemoved(wid);
|
||||
}
|
||||
});
|
||||
connections << connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged
|
||||
connect(KWindowSystem::self(), &KWindowSystem::currentDesktopChanged
|
||||
, this, &XWindowInterface::currentDesktopChanged);
|
||||
connections << connect(activities.data(), &KActivities::Consumer::currentActivityChanged
|
||||
connect(m_activities.data(), &KActivities::Consumer::currentActivityChanged
|
||||
, this, &XWindowInterface::currentActivityChanged);
|
||||
|
||||
// fill windows list
|
||||
@ -71,42 +72,23 @@ XWindowInterface::XWindowInterface(QQuickWindow *const view, QObject *parent)
|
||||
XWindowInterface::~XWindowInterface()
|
||||
{
|
||||
qDebug() << "x window interface deleting...";
|
||||
|
||||
foreach (auto var, connections) {
|
||||
QObject::disconnect(var);
|
||||
}
|
||||
|
||||
qDebug() << "x window interface connections removed...";
|
||||
}
|
||||
|
||||
void XWindowInterface::setDockDefaultFlags()
|
||||
void XWindowInterface::setDockExtraFlags(QQuickWindow &view)
|
||||
{
|
||||
m_view->setFlags(Qt::FramelessWindowHint
|
||||
| Qt::WindowStaysOnTopHint
|
||||
| Qt::NoDropShadowWindowHint
|
||||
| Qt::WindowDoesNotAcceptFocus);
|
||||
NETWinInfo winfo(QX11Info::connection()
|
||||
, static_cast<xcb_window_t>(m_view->winId())
|
||||
, static_cast<xcb_window_t>(m_view->winId())
|
||||
, static_cast<xcb_window_t>(view.winId())
|
||||
, static_cast<xcb_window_t>(view.winId())
|
||||
, 0, 0);
|
||||
|
||||
winfo.setAllowedActions(NET::ActionChangeDesktop);
|
||||
KWindowSystem::setType(m_view->winId(), NET::Dock);
|
||||
KWindowSystem::setState(m_view->winId(), NET::SkipTaskbar | NET::SkipPager);
|
||||
KWindowSystem::setOnAllDesktops(m_view->winId(), true);
|
||||
KWindowSystem::setOnActivities(m_view->winId(), {"0"});
|
||||
KWindowSystem::setType(view.winId(), NET::Dock);
|
||||
KWindowSystem::setState(view.winId(), NET::SkipTaskbar | NET::SkipPager);
|
||||
KWindowSystem::setOnAllDesktops(view.winId(), true);
|
||||
KWindowSystem::setOnActivities(view.winId(), {"0"});
|
||||
}
|
||||
|
||||
WId XWindowInterface::activeWindow() const
|
||||
{
|
||||
return KWindowSystem::self()->activeWindow();
|
||||
}
|
||||
|
||||
const std::list<WId> &XWindowInterface::windows() const
|
||||
{
|
||||
return m_windows;
|
||||
}
|
||||
|
||||
void XWindowInterface::setDockStruts(const QRect &dockRect, Plasma::Types::Location location) const
|
||||
void XWindowInterface::setDockStruts(WId dockId, const QRect &dockRect, Plasma::Types::Location location) const
|
||||
{
|
||||
NETExtendedStrut strut;
|
||||
|
||||
@ -123,7 +105,7 @@ void XWindowInterface::setDockStruts(const QRect &dockRect, Plasma::Types::Locat
|
||||
strut.bottom_end = dockRect.x() + dockRect.width() - 1;
|
||||
break;
|
||||
|
||||
case Plasma::Types::LeftEdge:
|
||||
case Plasma::Types::Left:
|
||||
strut.left_width = dockRect.width();
|
||||
strut.left_start = dockRect.y();
|
||||
strut.left_end = dockRect.y() + dockRect.height() - 1;
|
||||
@ -140,7 +122,7 @@ void XWindowInterface::setDockStruts(const QRect &dockRect, Plasma::Types::Locat
|
||||
return;
|
||||
}
|
||||
|
||||
KWindowSystem::setExtendedStrut(m_view->winId(),
|
||||
KWindowSystem::setExtendedStrut(dockId,
|
||||
strut.left_width, strut.left_start, strut.left_end,
|
||||
strut.right_width, strut.right_start, strut.right_end,
|
||||
strut.top_width, strut.top_start, strut.top_end,
|
||||
@ -148,10 +130,59 @@ void XWindowInterface::setDockStruts(const QRect &dockRect, Plasma::Types::Locat
|
||||
);
|
||||
}
|
||||
|
||||
void XWindowInterface::removeDockStruts() const
|
||||
void XWindowInterface::removeDockStruts(WId dockId) const
|
||||
{
|
||||
KWindowSystem::setStrut(m_view->winId(), 0, 0, 0, 0);
|
||||
KWindowSystem::setStrut(dockId, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
WId XWindowInterface::activeWindow() const
|
||||
{
|
||||
return KWindowSystem::self()->activeWindow();
|
||||
}
|
||||
|
||||
const std::list<WId> &XWindowInterface::windows() const
|
||||
{
|
||||
return m_windows;
|
||||
}
|
||||
|
||||
void XWindowInterface::skipTaskBar(const QDialog &dialog) const
|
||||
{
|
||||
KWindowSystem::setState(dialog.winId(), NET::SkipTaskbar);
|
||||
}
|
||||
|
||||
void XWindowInterface::slideWindow(QQuickWindow &view, AbstractWindowInterface::Slide location) const
|
||||
{
|
||||
auto slideLocation = KWindowEffects::NoEdge;
|
||||
|
||||
switch (location) {
|
||||
case Slide::Top:
|
||||
slideLocation = KWindowEffects::TopEdge;
|
||||
break;
|
||||
|
||||
case Slide::Bottom:
|
||||
slideLocation = KWindowEffects::BottomEdge;
|
||||
break;
|
||||
|
||||
case Slide::Left:
|
||||
slideLocation = KWindowEffects::LeftEdge;
|
||||
break;
|
||||
|
||||
case Slide::Right:
|
||||
slideLocation = KWindowEffects::RightEdge;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
KWindowEffects::slideWindow(view.winId(), slideLocation, -1);
|
||||
}
|
||||
|
||||
void XWindowInterface::enableBlurBehind(QQuickWindow &view) const
|
||||
{
|
||||
KWindowEffects::enableBlurBehind(view.winId());
|
||||
}
|
||||
|
||||
WindowInfoWrap XWindowInterface::requestInfoActive() const
|
||||
{
|
||||
return requestInfo(KWindowSystem::activeWindow());
|
||||
@ -211,10 +242,9 @@ bool XWindowInterface::isValidWindow(const KWindowInfo &winfo) const
|
||||
void XWindowInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2)
|
||||
{
|
||||
//! if the dock changed is ignored
|
||||
if (wid == m_view->winId())
|
||||
if (std::find(m_docks.cbegin(), m_docks.cend(), wid) != m_docks.cend())
|
||||
return;
|
||||
|
||||
//! ignore when, eg: the user presses a key
|
||||
const auto winType = KWindowInfo(wid, NET::WMWindowType).windowType(NET::DesktopMask);
|
||||
|
||||
if (winType != -1 && (winType & NET::Desktop)) {
|
||||
@ -223,6 +253,7 @@ void XWindowInterface::windowChangedProxy(WId wid, NET::Properties prop1, NET::P
|
||||
return;
|
||||
}
|
||||
|
||||
//! ignore when, eg: the user presses a key
|
||||
if (prop1 == 0 && prop2 == NET::WM2UserTime) {
|
||||
return;
|
||||
}
|
||||
|
@ -22,13 +22,12 @@
|
||||
#define XWINDOWINTERFACE_H
|
||||
|
||||
#include "abstractwindowinterface.h"
|
||||
#include "windowinfowrap.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
|
||||
#include <KWindowInfo>
|
||||
#include <Plasma>
|
||||
#include <KActivities/Consumer>
|
||||
#include <KWindowEffects>
|
||||
|
||||
namespace Latte {
|
||||
|
||||
@ -36,10 +35,12 @@ class XWindowInterface : public AbstractWindowInterface {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
XWindowInterface(QQuickWindow *const view, QObject *parent);
|
||||
virtual ~XWindowInterface();
|
||||
explicit XWindowInterface(QObject *parent = nullptr);
|
||||
~XWindowInterface() override;
|
||||
|
||||
void setDockDefaultFlags() override;
|
||||
void setDockExtraFlags(QQuickWindow &view) override;
|
||||
void setDockStruts(WId dockId, const QRect &dockRect, Plasma::Types::Location location) const override;
|
||||
void removeDockStruts(WId dockId) const override;
|
||||
|
||||
WId activeWindow() const override;
|
||||
WindowInfoWrap requestInfo(WId wid) const override;
|
||||
@ -47,18 +48,15 @@ public:
|
||||
bool isOnCurrentDesktop(WId wid) const override;
|
||||
const std::list<WId> &windows() const override;
|
||||
|
||||
void setDockStruts(const QRect &dockRect, Plasma::Types::Location location) const override;
|
||||
void removeDockStruts() const override;
|
||||
|
||||
void skipTaskBar(const QDialog &dialog) const override;
|
||||
void slideWindow(QQuickWindow &view, Slide location) const override;
|
||||
void enableBlurBehind(QQuickWindow &view) const override;
|
||||
|
||||
private:
|
||||
bool isValidWindow(const KWindowInfo &winfo) const;
|
||||
void windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2);
|
||||
|
||||
WId m_desktopId;
|
||||
QPointer<KActivities::Consumer> activities;
|
||||
|
||||
QList<QMetaObject::Connection> connections;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user