1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-24 17:33:50 +03:00

added methods to reserve screen space

This commit is contained in:
Johan Smith Agudelo Rodriguez 2016-12-29 00:37:53 -05:00 committed by Michail Vourlakos
parent 2c6ab968bd
commit 9debe8dbb3
3 changed files with 63 additions and 3 deletions

View File

@ -9,8 +9,11 @@
#include <list>
#include <QObject>
#include <QRect>
#include <QQuickWindow>
#include <Plasma>
namespace Latte {
class AbstractWindowInterface : public QObject {
@ -27,6 +30,9 @@ public:
virtual WindowInfoWrap requestInfoActive() = 0;
virtual const std::list<WId> &windows() = 0;
virtual void setDockStruts(const QRect &dockRect, Plasma::Types::Location location) = 0;
virtual void removeDockStruts() = 0;
signals:
void activeWindowChanged(WId wid);
void windowChanged(const WindowInfoWrap &winfo);

View File

@ -1,5 +1,7 @@
#include "xwindowinterface.h"
#include "../liblattedock/extras.h"
#include <QDebug>
#include <QtX11Extras/QX11Info>
#include <KWindowSystem>
@ -64,6 +66,54 @@ const std::list<WId> &XWindowInterface::windows()
return m_windows;
}
void XWindowInterface::setDockStruts(const QRect &dockRect, Plasma::Types::Location location)
{
NETExtendedStrut strut;
switch (location) {
case Plasma::Types::TopEdge:
strut.top_width = dockRect.height();
strut.top_start = dockRect.x();
strut.top_end = dockRect.x() + dockRect.width() - 1;
break;
case Plasma::Types::BottomEdge:
strut.bottom_width = dockRect.height();
strut.bottom_start = dockRect.x();
strut.bottom_end = dockRect.x() + dockRect.width() - 1;
break;
case Plasma::Types::LeftEdge:
strut.left_width = dockRect.width();
strut.left_start = dockRect.y();
strut.left_end = dockRect.y() + dockRect.height() - 1;
break;
case Plasma::Types::RightEdge:
strut.right_width = dockRect.width();
strut.right_start = dockRect.y();
strut.right_end = dockRect.y() + dockRect.height() - 1;
break;
default:
qWarning() << "wrong location:" << qEnumToStr(location);
return;
}
KWindowSystem::setExtendedStrut(m_view->winId(),
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,
strut.bottom_width, strut.bottom_start, strut.bottom_end
);
}
void XWindowInterface::removeDockStruts()
{
KWindowSystem::setStrut(m_view->winId(), 0, 0, 0, 0);
}
WindowInfoWrap XWindowInterface::requestInfoActive()
{
return requestInfo(KWindowSystem::activeWindow());

View File

@ -1,11 +1,12 @@
#ifndef XWINDOWINTERFACE_H
#define XWINDOWINTERFACE_H
#include "abstractwindowinterface.h"
#include <QObject>
#include <KWindowInfo>
#include "abstractwindowinterface.h"
#include <Plasma>
namespace Latte {
@ -14,7 +15,7 @@ class XWindowInterface : public AbstractWindowInterface {
public:
XWindowInterface(QQuickWindow *const view, QObject *parent);
virtual ~XWindowInterface();
~XWindowInterface() override;
void setDockDefaultFlags() override;
@ -23,6 +24,9 @@ public:
WindowInfoWrap requestInfoActive() override;
const std::list<WId> &windows() override;
void setDockStruts(const QRect &dockRect, Plasma::Types::Location location) override;
void removeDockStruts() override;
private:
bool isValidWindow(const KWindowInfo &winfo);
void windowChangedProxy(WId wid, NET::Properties prop1, NET::Properties2 prop2);