update libnowdockplugin to liblattedockplugin
parent
418f599004
commit
79bbf20a62
@ -0,0 +1,30 @@
|
|||||||
|
set (REQUIRED_QT_VERSION "5.6.0")
|
||||||
|
|
||||||
|
find_package(ECM 1.8.0 REQUIRED NO_MODULE)
|
||||||
|
find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE COMPONENTS Quick Qml)
|
||||||
|
|
||||||
|
find_package(KF5 REQUIRED COMPONENTS
|
||||||
|
WindowSystem
|
||||||
|
CoreAddons
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
|
||||||
|
set(lattedock_SRCS
|
||||||
|
lattedockplugin.cpp
|
||||||
|
windowsystem.cpp
|
||||||
|
types.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(lattedockplugin SHARED ${lattedock_SRCS})
|
||||||
|
|
||||||
|
target_link_libraries(lattedockplugin
|
||||||
|
Qt5::Quick
|
||||||
|
Qt5::Qml
|
||||||
|
KF5::WindowSystem
|
||||||
|
KF5::CoreAddons
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS lattedockplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/latte/dock)
|
||||||
|
|
||||||
|
install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/latte/dock)
|
@ -0,0 +1,14 @@
|
|||||||
|
#include "lattedockplugin.h"
|
||||||
|
#include "windowsystem.h"
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
#include <qqml.h>
|
||||||
|
|
||||||
|
void LatteDockPlugin::registerTypes(const char *uri)
|
||||||
|
{
|
||||||
|
Q_ASSERT(uri == QLatin1String("org.kde.latte.dock"));
|
||||||
|
|
||||||
|
qmlRegisterUncreatableType<LatteDock::Types>(uri, 0, 1, "Types", "LatteDock Types uncreatable");
|
||||||
|
|
||||||
|
qmlRegisterType<LatteDock::WindowSystem>(uri, 0, 1, "WindowSystem");
|
||||||
|
}
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef NOWDOCKPLUGIN_H
|
#ifndef LATTEDOCKPLUGIN_H
|
||||||
#define NOWDOCKPLUGIN_H
|
#define LATTEDOCKPLUGIN_H
|
||||||
|
|
||||||
#include <QQmlExtensionPlugin>
|
#include <QQmlExtensionPlugin>
|
||||||
|
|
||||||
class NowDockPlugin : public QQmlExtensionPlugin {
|
class LatteDockPlugin : public QQmlExtensionPlugin {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
|
||||||
|
|
@ -0,0 +1,2 @@
|
|||||||
|
module org.kde.latte.dock
|
||||||
|
plugin lattedockplugin
|
@ -1,39 +0,0 @@
|
|||||||
set (REQUIRED_QT_VERSION "5.6.0")
|
|
||||||
|
|
||||||
find_package(ECM 1.8.0 REQUIRED NO_MODULE)
|
|
||||||
find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE COMPONENTS Quick Qml)
|
|
||||||
|
|
||||||
find_package(KF5 REQUIRED COMPONENTS
|
|
||||||
Plasma
|
|
||||||
PlasmaQuick
|
|
||||||
WindowSystem
|
|
||||||
KDELibs4Support
|
|
||||||
CoreAddons
|
|
||||||
)
|
|
||||||
|
|
||||||
set(CMAKE_AUTOMOC ON)
|
|
||||||
|
|
||||||
set(nowdock_SRCS
|
|
||||||
nowdockplugin.cpp
|
|
||||||
panelwindow.cpp
|
|
||||||
windowsystem.cpp
|
|
||||||
xwindowinterface.cpp
|
|
||||||
abstractinterface.cpp
|
|
||||||
types.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(nowdockplugin SHARED ${nowdock_SRCS})
|
|
||||||
|
|
||||||
target_link_libraries(nowdockplugin
|
|
||||||
Qt5::Quick
|
|
||||||
Qt5::Qml
|
|
||||||
KF5::Plasma
|
|
||||||
KF5::PlasmaQuick
|
|
||||||
KF5::WindowSystem
|
|
||||||
KF5::KDELibs4Support
|
|
||||||
KF5::CoreAddons
|
|
||||||
)
|
|
||||||
|
|
||||||
install(TARGETS nowdockplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/nowdock)
|
|
||||||
|
|
||||||
install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/nowdock)
|
|
@ -1,42 +0,0 @@
|
|||||||
#include "abstractinterface.h"
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QQuickWindow>
|
|
||||||
|
|
||||||
namespace NowDock {
|
|
||||||
|
|
||||||
AbstractInterface::AbstractInterface(QQuickWindow *dock) :
|
|
||||||
QObject(dock),
|
|
||||||
m_isDockWindowType(false),
|
|
||||||
m_dockNumber(0)
|
|
||||||
{
|
|
||||||
m_dockWindow = dock;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AbstractInterface::setDockNumber(unsigned int no)
|
|
||||||
{
|
|
||||||
if (m_dockNumber == no) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_dockNumber = no;
|
|
||||||
|
|
||||||
emit dockNumberChanged(m_dockNumber);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int AbstractInterface::dockNumber() const
|
|
||||||
{
|
|
||||||
return m_dockNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void AbstractInterface::setMaskArea(QRect area)
|
|
||||||
{
|
|
||||||
if (m_maskArea == area) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_maskArea = area;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
#ifndef ABSTRACTINTERFACE_H
|
|
||||||
#define ABSTRACTINTERFACE_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QQuickWindow>
|
|
||||||
|
|
||||||
namespace NowDock {
|
|
||||||
|
|
||||||
class AbstractInterface : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit AbstractInterface(QQuickWindow *dock);
|
|
||||||
|
|
||||||
virtual bool activeIsDialog() const = 0;
|
|
||||||
virtual bool activeIsMaximized() const = 0;
|
|
||||||
virtual bool desktopIsActive() const = 0;
|
|
||||||
virtual bool dockIntersectsActiveWindow() const = 0;
|
|
||||||
virtual bool dockIsCovered(bool totally = false) const = 0;
|
|
||||||
virtual bool dockIsCovering() const = 0;
|
|
||||||
virtual bool dockIsOnTop() const = 0;
|
|
||||||
virtual bool dockInNormalState() const = 0;
|
|
||||||
virtual bool dockIsBelow() const = 0;
|
|
||||||
|
|
||||||
//FIXME: This may not be needed, it would be better to investigate in KWindowSystem
|
|
||||||
//its behavior when setting the window type to NET::Dock
|
|
||||||
virtual void setDockDefaultFlags(bool dock = false) = 0;
|
|
||||||
virtual void setDockToAllDesktops() = 0;
|
|
||||||
virtual void showDockAsNormal() = 0;
|
|
||||||
virtual void showDockOnBottom() = 0;
|
|
||||||
virtual void showDockOnTop() = 0;
|
|
||||||
|
|
||||||
void setDockNumber(unsigned int no);
|
|
||||||
unsigned int dockNumber() const;
|
|
||||||
|
|
||||||
void setMaskArea(QRect area);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void activeWindowChanged();
|
|
||||||
void dockNumberChanged(unsigned int no);
|
|
||||||
void windowInAttention(bool);
|
|
||||||
//FIXME: there is a chance that this signal is not needed at all
|
|
||||||
void windowChanged();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool m_isDockWindowType;
|
|
||||||
int m_dockNumber;
|
|
||||||
|
|
||||||
QRect m_maskArea;
|
|
||||||
|
|
||||||
QQuickWindow *m_dockWindow;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,17 +0,0 @@
|
|||||||
#include "nowdockplugin.h"
|
|
||||||
#include "panelwindow.h"
|
|
||||||
#include "windowsystem.h"
|
|
||||||
#include "types.h"
|
|
||||||
|
|
||||||
#include <qqml.h>
|
|
||||||
|
|
||||||
void NowDockPlugin::registerTypes(const char *uri)
|
|
||||||
{
|
|
||||||
Q_ASSERT(uri == QLatin1String("org.kde.nowdock"));
|
|
||||||
|
|
||||||
qmlRegisterUncreatableType<NowDock::Types>(uri, 0, 1, "Types", "NowDock Types uncreatable");
|
|
||||||
|
|
||||||
qmlRegisterType<NowDock::PanelWindow>(uri, 0, 1, "PanelWindow");
|
|
||||||
qmlRegisterType<NowDock::WindowSystem>(uri, 0, 1, "WindowSystem");
|
|
||||||
}
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1,203 +0,0 @@
|
|||||||
#ifndef PANELWINDOW_H
|
|
||||||
#define PANELWINDOW_H
|
|
||||||
|
|
||||||
#include <QMenu>
|
|
||||||
#include <QQuickWindow>
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
#include <plasma/plasma.h>
|
|
||||||
|
|
||||||
#include <Plasma/Applet>
|
|
||||||
#include <Plasma/Containment>
|
|
||||||
#include <PlasmaQuick/AppletQuickItem>
|
|
||||||
|
|
||||||
#include "abstractinterface.h"
|
|
||||||
#include "windowsystem.h"
|
|
||||||
|
|
||||||
namespace NowDock {
|
|
||||||
|
|
||||||
class PanelWindow : public QQuickWindow {
|
|
||||||
Q_OBJECT
|
|
||||||
Q_ENUMS(PanelVisibility)
|
|
||||||
Q_ENUMS(Alignment)
|
|
||||||
|
|
||||||
Q_PROPERTY(bool disableHiding READ disableHiding WRITE setDisableHiding NOTIFY disableHidingChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(bool immutable READ immutable WRITE setImmutable NOTIFY immutableChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(bool isAutoHidden READ isAutoHidden WRITE setIsAutoHidden NOTIFY isAutoHiddenChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(bool isDockWindowType READ isDockWindowType WRITE setIsDockWindowType NOTIFY isDockWindowTypeChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(bool isHovered READ isHovered NOTIFY isHoveredChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(bool windowInAttention READ windowInAttention WRITE setWindowInAttention NOTIFY windowInAttentionChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(int childrenLength READ childrenLength WRITE setChildrenLength NOTIFY childrenLengthChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(unsigned int maximumLength READ maximumLength NOTIFY maximumLengthChanged)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the window mask, can be used in real transparent panels that set only the visual area
|
|
||||||
* of the window
|
|
||||||
* @since 5.8
|
|
||||||
*/
|
|
||||||
Q_PROPERTY(QRect maskArea READ maskArea WRITE setMaskArea NOTIFY maskAreaChanged)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the dock's screen geometry, e.g. it is used to set correctly x, y values
|
|
||||||
*/
|
|
||||||
Q_PROPERTY(QRect screenGeometry READ screenGeometry NOTIFY screenGeometryChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(Plasma::Types::Location location READ location WRITE setLocation NOTIFY locationChanged)
|
|
||||||
|
|
||||||
Q_PROPERTY(PanelVisibility panelVisibility READ panelVisibility WRITE setPanelVisibility NOTIFY panelVisibilityChanged)
|
|
||||||
|
|
||||||
public:
|
|
||||||
enum PanelVisibility {
|
|
||||||
BelowActive = 0, /** always visible except if ovelaps with the active window, no area reserved */
|
|
||||||
BelowMaximized, /** always visible except if ovelaps with an active maximize window, no area reserved */
|
|
||||||
LetWindowsCover, /** always visible, windows will go over the panel, no area reserved */
|
|
||||||
WindowsGoBelow, /** default, always visible, windows will go under the panel, no area reserved */
|
|
||||||
AutoHide, /** the panel will be shownn only if the mouse cursor is on screen edges */
|
|
||||||
AlwaysVisible, /** always visible panel, "Normal" plasma panel, accompanies plasma's "Always Visible" */
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Alignment {
|
|
||||||
Center = 0,
|
|
||||||
Left,
|
|
||||||
Right,
|
|
||||||
Top,
|
|
||||||
Bottom,
|
|
||||||
Double = 10
|
|
||||||
};
|
|
||||||
|
|
||||||
explicit PanelWindow(QQuickWindow *parent = Q_NULLPTR);
|
|
||||||
~PanelWindow();
|
|
||||||
|
|
||||||
bool disableHiding() const;
|
|
||||||
void setDisableHiding(bool state);
|
|
||||||
|
|
||||||
bool immutable() const;
|
|
||||||
void setImmutable(bool state);
|
|
||||||
|
|
||||||
bool isAutoHidden() const;
|
|
||||||
void setIsAutoHidden(bool state);
|
|
||||||
|
|
||||||
bool isDockWindowType() const;
|
|
||||||
void setIsDockWindowType(bool state);
|
|
||||||
|
|
||||||
bool isHovered() const;
|
|
||||||
|
|
||||||
bool windowInAttention() const;
|
|
||||||
// void setWindowInAttention(bool state);
|
|
||||||
|
|
||||||
int childrenLength() const;
|
|
||||||
void setChildrenLength(int value);
|
|
||||||
|
|
||||||
unsigned int maximumLength() const;
|
|
||||||
|
|
||||||
QRect maskArea() const;
|
|
||||||
void setMaskArea(QRect area);
|
|
||||||
|
|
||||||
QRect screenGeometry() const;
|
|
||||||
|
|
||||||
Plasma::Types::Location location() const;
|
|
||||||
void setLocation(Plasma::Types::Location location);
|
|
||||||
|
|
||||||
PanelVisibility panelVisibility() const;
|
|
||||||
void setPanelVisibility(PanelVisibility state);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void childrenLengthChanged();
|
|
||||||
void disableHidingChanged();
|
|
||||||
void immutableChanged();
|
|
||||||
void isAutoHiddenChanged();
|
|
||||||
void isDockWindowTypeChanged();
|
|
||||||
void isHoveredChanged();
|
|
||||||
void locationChanged();
|
|
||||||
void maskAreaChanged();
|
|
||||||
void maximumLengthChanged();
|
|
||||||
void mustBeLowered();
|
|
||||||
void mustBeRaised(); //are used to triger the sliding animations from the qml part
|
|
||||||
void mustBeRaisedImmediately();
|
|
||||||
void panelVisibilityChanged();
|
|
||||||
void screenGeometryChanged();
|
|
||||||
void windowInAttentionChanged();
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
Q_INVOKABLE void addAppletItem(QObject *item);
|
|
||||||
Q_INVOKABLE void initialize();
|
|
||||||
Q_INVOKABLE void removeAppletItem(QObject *item);
|
|
||||||
Q_INVOKABLE void setTransientThickness(unsigned int thickness);
|
|
||||||
Q_INVOKABLE void showNormal();
|
|
||||||
Q_INVOKABLE void showOnTop();
|
|
||||||
Q_INVOKABLE void showOnTopCheck();
|
|
||||||
Q_INVOKABLE void showOnBottom();
|
|
||||||
void setWindowInAttention(bool state);
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool event(QEvent *event) override;
|
|
||||||
void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
|
||||||
void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void activeWindowChanged();
|
|
||||||
void compositingChanged();
|
|
||||||
void updateState();
|
|
||||||
void initWindow();
|
|
||||||
void menuAboutToHide();
|
|
||||||
void setIsHovered(bool state);
|
|
||||||
void screenChanged(QScreen *screen);
|
|
||||||
void setScreenGeometry(QRect geometry);
|
|
||||||
void shrinkTransient();
|
|
||||||
void transientPositionChanged();
|
|
||||||
void updateVisibilityFlags();
|
|
||||||
void updateWindowPosition();
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_disableHiding;
|
|
||||||
bool m_immutable;
|
|
||||||
bool m_isAutoHidden;
|
|
||||||
bool m_isDockWindowType;
|
|
||||||
bool m_isHovered;
|
|
||||||
//second pass of the initialization
|
|
||||||
bool m_secondInitPass;
|
|
||||||
bool m_windowIsInAttention;
|
|
||||||
|
|
||||||
int m_childrenLength;
|
|
||||||
int m_tempThickness;
|
|
||||||
unsigned int m_maximumLength;
|
|
||||||
|
|
||||||
QPointer<Plasma::Containment> m_containment;
|
|
||||||
QRect m_maskArea;
|
|
||||||
QRect m_screenGeometry;
|
|
||||||
QScreen *m_screen;
|
|
||||||
QList<PlasmaQuick::AppletQuickItem *> m_appletItems;
|
|
||||||
QTimer m_initTimer;
|
|
||||||
QTimer m_triggerShrinkTransient;
|
|
||||||
QTimer m_updateStateTimer;
|
|
||||||
QWeakPointer<QMenu> m_contextMenu;
|
|
||||||
QWindow *m_transient;
|
|
||||||
|
|
||||||
Qt::Orientations m_panelOrientation;
|
|
||||||
|
|
||||||
Plasma::Types::Location m_location;
|
|
||||||
|
|
||||||
PanelVisibility m_panelVisibility;
|
|
||||||
|
|
||||||
AbstractInterface *m_interface;
|
|
||||||
WindowSystem *m_windowSystem;
|
|
||||||
|
|
||||||
void addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEvent *event);
|
|
||||||
void addContainmentActions(QMenu *desktopMenu, QEvent *event);
|
|
||||||
void setPanelOrientation(Plasma::Types::Location location);
|
|
||||||
void setPanelScreen(QScreen *screen);
|
|
||||||
void updateMaximumLength();
|
|
||||||
void updateTransient();
|
|
||||||
};
|
|
||||||
|
|
||||||
} //NowDock namespace
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,2 +0,0 @@
|
|||||||
module org.kde.nowdock
|
|
||||||
plugin nowdockplugin
|
|
@ -1,361 +0,0 @@
|
|||||||
#include "xwindowinterface.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
#include <KWindowInfo>
|
|
||||||
#include <KWindowSystem>
|
|
||||||
|
|
||||||
namespace NowDock {
|
|
||||||
|
|
||||||
XWindowInterface::XWindowInterface(QQuickWindow *parent) :
|
|
||||||
AbstractInterface(parent),
|
|
||||||
m_demandsAttention(0)
|
|
||||||
{
|
|
||||||
m_activeWindow = KWindowSystem::activeWindow();
|
|
||||||
|
|
||||||
connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)), this, SLOT(activeWindowChanged(WId)));
|
|
||||||
connect(KWindowSystem::self(), SIGNAL(windowChanged(WId, NET::Properties, NET::Properties2)), this, SLOT(windowChanged(WId, NET::Properties, NET::Properties2)));
|
|
||||||
connect(KWindowSystem::self(), SIGNAL(windowRemoved(WId)), this, SLOT(windowRemoved(WId)));
|
|
||||||
|
|
||||||
connect(this, SIGNAL(dockNumberChanged(uint)), this, SLOT(dockNumberChanged(uint)));
|
|
||||||
}
|
|
||||||
|
|
||||||
XWindowInterface::~XWindowInterface()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void XWindowInterface::dockNumberChanged(unsigned int no)
|
|
||||||
{
|
|
||||||
if (no == 1) {
|
|
||||||
m_dockWindow->setFlags(Qt::Tool | Qt::WindowDoesNotAcceptFocus | Qt::FramelessWindowHint);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void XWindowInterface::setDockToAllDesktops()
|
|
||||||
{
|
|
||||||
KWindowSystem::setOnAllDesktops(m_dockWindow->winId(), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void XWindowInterface::setDockDefaultFlags(bool dock)
|
|
||||||
{
|
|
||||||
//Notice: the Qt::Tool flag even though it works perfectly for a single Now Dock
|
|
||||||
//it creates a strange situation when there are two and more Now Dock's
|
|
||||||
//in that case it is used only for the first created Now Dock
|
|
||||||
m_isDockWindowType = dock;
|
|
||||||
|
|
||||||
if ((m_dockNumber == 1) && (!m_isDockWindowType)) {
|
|
||||||
m_dockWindow->setFlags(Qt::Tool | Qt::WindowDoesNotAcceptFocus | Qt::FramelessWindowHint);
|
|
||||||
} else {
|
|
||||||
KWindowSystem::setType(m_dockWindow->winId(), NET::Dock);
|
|
||||||
KWindowSystem::setState(m_dockWindow->winId(), NET::SkipTaskbar | NET::SkipPager);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void XWindowInterface::showDockOnTop()
|
|
||||||
{
|
|
||||||
//this is the only way in order to not break the case of two and more NowDocks
|
|
||||||
//there is a small issue that the pop ups from locked plasmoids are opened
|
|
||||||
//on the maximum thickness
|
|
||||||
|
|
||||||
//qDebug() << "Docknumber:" << m_dockNumber;
|
|
||||||
if (m_isDockWindowType) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_dockNumber != 1) {
|
|
||||||
KWindowSystem::setType(m_dockWindow->winId(), NET::Dock);
|
|
||||||
}
|
|
||||||
|
|
||||||
KWindowSystem::clearState(m_dockWindow->winId(), NET::KeepBelow);
|
|
||||||
KWindowSystem::setState(m_dockWindow->winId(), NET::KeepAbove);
|
|
||||||
}
|
|
||||||
|
|
||||||
void XWindowInterface::showDockAsNormal()
|
|
||||||
{
|
|
||||||
// qDebug() << "reached make normal...";
|
|
||||||
if (m_isDockWindowType) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_dockNumber != 1) {
|
|
||||||
m_dockWindow->setFlags(Qt::Tool | Qt::WindowDoesNotAcceptFocus | Qt::FramelessWindowHint);
|
|
||||||
}
|
|
||||||
|
|
||||||
KWindowSystem::clearState(m_dockWindow->winId(), NET::KeepAbove);
|
|
||||||
KWindowSystem::clearState(m_dockWindow->winId(), NET::KeepBelow);
|
|
||||||
}
|
|
||||||
|
|
||||||
void XWindowInterface::showDockOnBottom()
|
|
||||||
{
|
|
||||||
// qDebug() << "reached make bottom...";
|
|
||||||
if (m_isDockWindowType) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_dockNumber != 1) {
|
|
||||||
m_dockWindow->setFlags(Qt::Tool | Qt::WindowDoesNotAcceptFocus | Qt::FramelessWindowHint);
|
|
||||||
}
|
|
||||||
|
|
||||||
KWindowSystem::clearState(m_dockWindow->winId(), NET::KeepAbove);
|
|
||||||
KWindowSystem::setState(m_dockWindow->winId(), NET::KeepBelow);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool XWindowInterface::isDesktop(WId id) const
|
|
||||||
{
|
|
||||||
KWindowInfo info(id, NET::WMWindowType);
|
|
||||||
|
|
||||||
if (!info.valid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
NET::WindowType type = info.windowType(NET::DesktopMask | NET::DockMask | NET::DialogMask);
|
|
||||||
|
|
||||||
return type == NET::Desktop;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XWindowInterface::isDialog(WId id) const
|
|
||||||
{
|
|
||||||
KWindowInfo info(id, NET::WMWindowType);
|
|
||||||
|
|
||||||
if (!info.valid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
NET::WindowType type = info.windowType(NET::DesktopMask | NET::DockMask | NET::DialogMask);
|
|
||||||
|
|
||||||
return type == NET::Dialog;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XWindowInterface::isMaximized(WId id) const
|
|
||||||
{
|
|
||||||
KWindowInfo info(id, NET::WMState);
|
|
||||||
|
|
||||||
if (!info.valid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (info.hasState(NET::Max));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XWindowInterface::isNormal(WId id) const
|
|
||||||
{
|
|
||||||
return (!isOnBottom(id) && !isOnTop(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XWindowInterface::isOnBottom(WId id) const
|
|
||||||
{
|
|
||||||
KWindowInfo info(id, NET::WMState);
|
|
||||||
|
|
||||||
if (!info.valid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (info.hasState(NET::KeepBelow));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XWindowInterface::isOnTop(WId id) const
|
|
||||||
{
|
|
||||||
KWindowInfo info(id, NET::WMState);
|
|
||||||
|
|
||||||
if (!info.valid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (info.hasState(NET::KeepAbove));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XWindowInterface::activeIsDialog() const
|
|
||||||
{
|
|
||||||
return isDialog(m_activeWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XWindowInterface::activeIsMaximized() const
|
|
||||||
{
|
|
||||||
return isMaximized(m_activeWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool XWindowInterface::desktopIsActive() const
|
|
||||||
{
|
|
||||||
return isDesktop(m_activeWindow);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XWindowInterface::dockIsOnTop() const
|
|
||||||
{
|
|
||||||
return isOnTop(m_dockWindow->winId());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XWindowInterface::dockInNormalState() const
|
|
||||||
{
|
|
||||||
return isNormal(m_dockWindow->winId());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XWindowInterface::dockIsBelow() const
|
|
||||||
{
|
|
||||||
return isOnBottom(m_dockWindow->winId());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XWindowInterface::dockIntersectsActiveWindow() const
|
|
||||||
{
|
|
||||||
KWindowInfo activeInfo(m_activeWindow, NET::WMGeometry);
|
|
||||||
|
|
||||||
if (activeInfo.valid()) {
|
|
||||||
QRect maskSize;
|
|
||||||
|
|
||||||
if (!m_maskArea.isNull()) {
|
|
||||||
maskSize = QRect(m_dockWindow->x() + m_maskArea.x(), m_dockWindow->y() + m_maskArea.y(), m_maskArea.width(), m_maskArea.height());
|
|
||||||
} else {
|
|
||||||
maskSize = QRect(m_dockWindow->x(), m_dockWindow->y(), m_dockWindow->width(), m_dockWindow->height());
|
|
||||||
}
|
|
||||||
|
|
||||||
return maskSize.intersects(activeInfo.geometry());
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool XWindowInterface::dockIsCovered(bool totally) const
|
|
||||||
{
|
|
||||||
int currentDockPos = -1;
|
|
||||||
|
|
||||||
QList<WId> windows = KWindowSystem::stackingOrder();
|
|
||||||
int size = windows.count();
|
|
||||||
|
|
||||||
for (int i = size - 1; i >= 0; --i) {
|
|
||||||
WId window = windows.at(i);
|
|
||||||
|
|
||||||
if (window == m_dockWindow->winId()) {
|
|
||||||
currentDockPos = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentDockPos >= 0) {
|
|
||||||
QRect maskSize;
|
|
||||||
|
|
||||||
if (!m_maskArea.isNull()) {
|
|
||||||
maskSize = QRect(m_dockWindow->x() + m_maskArea.x(), m_dockWindow->y() + m_maskArea.y(), m_maskArea.width(), m_maskArea.height());
|
|
||||||
} else {
|
|
||||||
maskSize = QRect(m_dockWindow->x(), m_dockWindow->y(), m_dockWindow->width(), m_dockWindow->height());
|
|
||||||
}
|
|
||||||
|
|
||||||
WId transient = 0;
|
|
||||||
|
|
||||||
if (m_dockWindow->transientParent()) {
|
|
||||||
transient = m_dockWindow->transientParent()->winId();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = size - 1; j > currentDockPos; --j) {
|
|
||||||
WId window = windows.at(j);
|
|
||||||
|
|
||||||
KWindowInfo info(window, NET::WMState | NET::XAWMState | NET::WMGeometry);
|
|
||||||
|
|
||||||
if (info.valid() && !isDesktop(window) && transient != window && !info.isMinimized()) {
|
|
||||||
if (totally) {
|
|
||||||
QRect winGeometry = info.geometry();
|
|
||||||
|
|
||||||
if ((maskSize.left() >= winGeometry.left()) && (maskSize.top() >= winGeometry.top())
|
|
||||||
&& (maskSize.right() <= winGeometry.right()) && (maskSize.bottom() <= winGeometry.bottom())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (maskSize.intersects(info.geometry())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool XWindowInterface::dockIsCovering() const
|
|
||||||
{
|
|
||||||
int currentDockPos = -1;
|
|
||||||
|
|
||||||
QList<WId> windows = KWindowSystem::stackingOrder();
|
|
||||||
int size = windows.count();
|
|
||||||
|
|
||||||
for (int i = size - 1; i >= 0; --i) {
|
|
||||||
WId window = windows.at(i);
|
|
||||||
|
|
||||||
if (window == m_dockWindow->winId()) {
|
|
||||||
currentDockPos = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentDockPos >= 0) {
|
|
||||||
QRect maskSize;
|
|
||||||
|
|
||||||
if (!m_maskArea.isNull()) {
|
|
||||||
maskSize = QRect(m_dockWindow->x() + m_maskArea.x(), m_dockWindow->y() + m_maskArea.y(), m_maskArea.width(), m_maskArea.height());
|
|
||||||
} else {
|
|
||||||
maskSize = QRect(m_dockWindow->x(), m_dockWindow->y(), m_dockWindow->width(), m_dockWindow->height());
|
|
||||||
}
|
|
||||||
|
|
||||||
WId transient = 0;
|
|
||||||
|
|
||||||
if (m_dockWindow->transientParent()) {
|
|
||||||
transient = m_dockWindow->transientParent()->winId();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int j = currentDockPos - 1; j >= 0; --j) {
|
|
||||||
WId window = windows.at(j);
|
|
||||||
|
|
||||||
KWindowInfo info(window, NET::WMState | NET::XAWMState | NET::WMGeometry);
|
|
||||||
|
|
||||||
if (info.valid() && !isDesktop(window) && transient != window && !info.isMinimized() && maskSize.intersects(info.geometry())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SLOTS
|
|
||||||
*/
|
|
||||||
|
|
||||||
void XWindowInterface::activeWindowChanged(WId win)
|
|
||||||
{
|
|
||||||
m_activeWindow = win;
|
|
||||||
|
|
||||||
emit AbstractInterface::activeWindowChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void XWindowInterface::windowChanged(WId id, NET::Properties properties, NET::Properties2 properties2)
|
|
||||||
{
|
|
||||||
KWindowInfo info(id, NET::WMState | NET::CloseWindow);
|
|
||||||
|
|
||||||
if (info.valid()) {
|
|
||||||
if ((m_demandsAttention == 0) && info.hasState(NET::DemandsAttention)) {
|
|
||||||
m_demandsAttention = id;
|
|
||||||
emit windowInAttention(true);
|
|
||||||
} else if ((m_demandsAttention == id) && !info.hasState(NET::DemandsAttention)) {
|
|
||||||
m_demandsAttention = 0;
|
|
||||||
emit windowInAttention(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// emit AbstractInterface::windowChanged();
|
|
||||||
|
|
||||||
if (id == m_activeWindow) {
|
|
||||||
emit AbstractInterface::activeWindowChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void XWindowInterface::windowRemoved(WId id)
|
|
||||||
{
|
|
||||||
if (id == m_demandsAttention) {
|
|
||||||
m_demandsAttention = 0;
|
|
||||||
emit AbstractInterface::windowInAttention(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,60 +0,0 @@
|
|||||||
#ifndef XWINDOWINTERFACE_H
|
|
||||||
#define XWINDOWINTERFACE_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
|
|
||||||
#include <KWindowInfo>
|
|
||||||
|
|
||||||
#include "abstractinterface.h"
|
|
||||||
|
|
||||||
namespace NowDock {
|
|
||||||
|
|
||||||
class XWindowInterface : public AbstractInterface {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit XWindowInterface(QQuickWindow *parent);
|
|
||||||
~XWindowInterface();
|
|
||||||
|
|
||||||
bool activeIsDialog() const;
|
|
||||||
bool activeIsMaximized() const;
|
|
||||||
bool dockIntersectsActiveWindow() const;
|
|
||||||
bool desktopIsActive() const;
|
|
||||||
bool dockIsCovered(bool totally = false) const;
|
|
||||||
bool dockIsCovering() const;
|
|
||||||
bool dockIsOnTop() const;
|
|
||||||
bool dockInNormalState() const;
|
|
||||||
bool dockIsBelow() const;
|
|
||||||
|
|
||||||
void setDockDefaultFlags(bool dock = false);
|
|
||||||
void setDockToAllDesktops();
|
|
||||||
void setDockToAlwaysVisible();
|
|
||||||
void showDockAsNormal();
|
|
||||||
void showDockOnBottom();
|
|
||||||
void showDockOnTop();
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
|
||||||
void activeWindowChanged(WId win);
|
|
||||||
void dockNumberChanged(unsigned int no);
|
|
||||||
void windowChanged(WId id, NET::Properties properties, NET::Properties2 properties2);
|
|
||||||
void windowRemoved(WId id);
|
|
||||||
|
|
||||||
private:
|
|
||||||
WId m_activeWindow;
|
|
||||||
WId m_demandsAttention;
|
|
||||||
|
|
||||||
bool isDesktop(WId id) const;
|
|
||||||
bool isDialog(WId id) const;
|
|
||||||
bool isMaximized(WId id) const;
|
|
||||||
bool isNormal(WId id) const;
|
|
||||||
bool isOnBottom(WId id) const;
|
|
||||||
bool isOnTop(WId id) const;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue