refactor(plasma_api): resemble KWin 5.25 structure

See: https://blog.vladzahorodnii.com/2022/05/09/whats-cooking-in-kwin-plasma-5-25/
In particular, "Window management refactors" section.
This commit is contained in:
Mikhail Zolotukhin 2022-06-24 21:04:41 +03:00
parent e6cd2da97d
commit 29843405e4
26 changed files with 714 additions and 400 deletions

View File

@ -16,7 +16,7 @@
#include "config.hpp"
#include "engine/engine.hpp"
#include "logger.hpp"
#include "plasma-api/client.hpp"
#include "plasma-api/window.hpp"
#include "plasma-api/workspace.hpp"
#include "ts-proxy.hpp"
@ -44,7 +44,7 @@ void Controller::bindEvents()
connect(&workspace, &PlasmaApi::Workspace::currentActivityChanged, this, &Controller::onCurrentSurfaceChanged);
connect(&workspace, &PlasmaApi::Workspace::clientAdded, this, &Controller::onClientAdded);
connect(&workspace, &PlasmaApi::Workspace::clientRemoved, this, &Controller::onClientRemoved);
connect(&workspace, &PlasmaApi::Workspace::clientMaximizeSet, this, [this](PlasmaApi::Client client, bool h, bool v) {
connect(&workspace, &PlasmaApi::Workspace::clientMaximizeSet, this, [this](PlasmaApi::Window client, bool h, bool v) {
if (h == true && v == true) {
onClientMaximized(client);
} else if (h == false && v == false) {
@ -230,33 +230,33 @@ void Controller::onSurfaceUpdate()
}
}
void Controller::onClientAdded(PlasmaApi::Client client)
void Controller::onClientAdded(PlasmaApi::Window client)
{
if (m_config.experimentalBackend()) {
m_engine.addWindow(client);
}
}
void Controller::onClientRemoved(PlasmaApi::Client client)
void Controller::onClientRemoved(PlasmaApi::Window client)
{
if (m_config.experimentalBackend()) {
m_engine.removeWindow(client);
}
}
void Controller::onClientMaximized(PlasmaApi::Client)
void Controller::onClientMaximized(PlasmaApi::Window)
{
}
void Controller::onClientUnmaximized(PlasmaApi::Client)
void Controller::onClientUnmaximized(PlasmaApi::Window)
{
}
void Controller::onClientMinimized(PlasmaApi::Client)
void Controller::onClientMinimized(PlasmaApi::Window)
{
}
void Controller::onClientUnminimized(PlasmaApi::Client)
void Controller::onClientUnminimized(PlasmaApi::Window)
{
}

View File

@ -14,7 +14,7 @@
#include "config.hpp"
#include "engine/engine.hpp"
#include "plasma-api/api.hpp"
#include "plasma-api/client.hpp"
#include "plasma-api/window.hpp"
namespace Bismuth
{
@ -45,12 +45,12 @@ public:
public Q_SLOTS:
void onCurrentSurfaceChanged();
void onSurfaceUpdate();
void onClientAdded(PlasmaApi::Client);
void onClientRemoved(PlasmaApi::Client);
void onClientMaximized(PlasmaApi::Client);
void onClientUnmaximized(PlasmaApi::Client);
void onClientMinimized(PlasmaApi::Client);
void onClientUnminimized(PlasmaApi::Client);
void onClientAdded(PlasmaApi::Window);
void onClientRemoved(PlasmaApi::Window);
void onClientMaximized(PlasmaApi::Window);
void onClientUnmaximized(PlasmaApi::Window);
void onClientMinimized(PlasmaApi::Window);
void onClientUnminimized(PlasmaApi::Window);
private:
std::vector<QAction *> m_registeredShortcuts{};

View File

@ -21,7 +21,7 @@ Engine::Engine(PlasmaApi::Api &api, const Bismuth::Config &config)
{
}
void Engine::addWindow(PlasmaApi::Client client)
void Engine::addWindow(PlasmaApi::Window client)
{
// Don't manage special windows - docks, panels, etc.
if (client.specialWindow() || client.dialog()) {
@ -47,7 +47,7 @@ void Engine::addWindow(PlasmaApi::Client client)
// Bind events of this window
}
void Engine::removeWindow(PlasmaApi::Client client)
void Engine::removeWindow(PlasmaApi::Window client)
{
m_windows.remove(client);
}

View File

@ -6,7 +6,7 @@
#include "engine/layout/layout_list.hpp"
#include "engine/surface.hpp"
#include "plasma-api/api.hpp"
#include "plasma-api/client.hpp"
#include "plasma-api/window.hpp"
#include "windows_list.hpp"
namespace Bismuth
@ -17,8 +17,8 @@ struct Engine {
Engine(PlasmaApi::Api &, const Bismuth::Config &);
void addWindow(PlasmaApi::Client);
void removeWindow(PlasmaApi::Client);
void addWindow(PlasmaApi::Window);
void removeWindow(PlasmaApi::Window);
void focusWindowByOrder(FocusOrder);
void focusWindowByDirection(FocusDirection);

View File

@ -10,7 +10,7 @@
namespace Bismuth
{
Window::Window(PlasmaApi::Client client, PlasmaApi::Workspace &workspace)
Window::Window(PlasmaApi::Window client, PlasmaApi::Workspace &workspace)
: m_client(client)
, m_workspace(workspace)
{

View File

@ -7,7 +7,7 @@
#include <vector>
#include "engine/surface.hpp"
#include "plasma-api/client.hpp"
#include "plasma-api/window.hpp"
#include "plasma-api/workspace.hpp"
namespace Bismuth
@ -21,7 +21,7 @@ struct Window {
Tiled,
};
Window(PlasmaApi::Client, PlasmaApi::Workspace &);
Window(PlasmaApi::Window, PlasmaApi::Workspace &);
bool operator==(const Window &) const;
bool operator<(const Window &rhs) const;
@ -42,7 +42,7 @@ struct Window {
QString caption() const;
private:
PlasmaApi::Client m_client;
PlasmaApi::Window m_client;
std::reference_wrapper<PlasmaApi::Workspace> m_workspace;
Mode m_mode;

View File

@ -17,13 +17,13 @@ WindowsList::WindowsList(PlasmaApi::Workspace &workspace)
{
}
Window &WindowsList::add(PlasmaApi::Client client)
Window &WindowsList::add(PlasmaApi::Window client)
{
auto [it, _] = m_windowMap.insert_or_assign(client, Window(client, m_workspace));
return it->second;
}
void WindowsList::remove(PlasmaApi::Client client)
void WindowsList::remove(PlasmaApi::Window client)
{
m_windowMap.erase(client);
}

View File

@ -6,7 +6,7 @@
#include <optional>
#include "engine/surface.hpp"
#include "plasma-api/client.hpp"
#include "plasma-api/window.hpp"
#include "plasma-api/workspace.hpp"
#include "window.hpp"
@ -15,15 +15,15 @@ namespace Bismuth
struct WindowsList {
WindowsList(PlasmaApi::Workspace &);
Window &add(PlasmaApi::Client);
void remove(PlasmaApi::Client);
Window &add(PlasmaApi::Window);
void remove(PlasmaApi::Window);
std::optional<Window> activeWindow() const;
std::vector<Window> visibleWindowsOn(const Surface &surface) const;
private:
std::map<PlasmaApi::Client, Window> m_windowMap{};
std::map<PlasmaApi::Window, Window> m_windowMap{};
PlasmaApi::Workspace &m_workspace;
};

View File

@ -1,5 +1,4 @@
# SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
# SPDX-License-Identifier: MIT
target_sources(bismuth_core PRIVATE api.cpp client.cpp toplevel.cpp
workspace.cpp)
target_sources(bismuth_core PRIVATE api.cpp window.cpp workspace.cpp utils.hpp)

View File

@ -14,7 +14,7 @@ Api::Api(QQmlEngine *engine)
: m_engine(engine)
, m_workspace(engine->rootContext()->contextProperty(QStringLiteral("workspace")).value<QObject *>())
{
qRegisterMetaType<Client>();
qRegisterMetaType<Window>();
};
Workspace &Api::workspace()

View File

@ -1,26 +0,0 @@
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
// SPDX-License-Identifier: MIT
#include "client.hpp"
#include "toplevel.hpp"
namespace PlasmaApi
{
Client::Client(QObject *kwinImpl)
: TopLevel(kwinImpl){};
Client::Client(const Client &rhs)
: TopLevel(rhs){};
bool Client::operator==(const Client &rhs) const
{
return m_kwinImpl == rhs.m_kwinImpl;
}
bool Client::operator<(const Client &rhs) const
{
return m_kwinImpl < rhs.m_kwinImpl;
}
}

View File

@ -1,134 +0,0 @@
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
// SPDX-License-Identifier: MIT
#pragma once
#include <QList>
#include <QObject>
#include <QRect>
#include <QString>
#include "toplevel.hpp"
#include "utils.hpp"
namespace PlasmaApi
{
class Workspace;
class Client : public TopLevel
{
Q_OBJECT
public:
Client() = default;
Client(QObject *kwinImpl);
Client(const Client &);
virtual ~Client() = default;
bool operator==(const Client &rhs) const;
bool operator<(const Client &rhs) const;
/**
* The activities this client is on. If it's on all activities the property is empty.
*/
BI_READONLY_PROPERTY(QStringList, activities)
/**
* Window caption (The text in the titlebar).
*/
BI_READONLY_PROPERTY(QString, caption)
/**
* The geometry of this Client. Be aware that depending on resize mode the frameGeometryChanged
* signal might be emitted at each resize step or only at the end of the resize operation.
*/
BI_PROPERTY(QRect, frameGeometry, setFrameGeometry)
// /**
// * Whether the window is active.
// */
// Q_PROPERTY(bool active READ active)
// /**
// * Maximum allowed size for a window.
// */
// Q_PROPERTY(QSize maxSize READ maxSize)
// /**
// * Minimum allowed size for a window.
// */
// Q_PROPERTY(QSize minSize READ minSize)
// /**
// * Whether the window is modal or not.
// */
// Q_PROPERTY(bool modal READ modal)
// /**
// * Whether the window is currently being moved by the user.
// */
// Q_PROPERTY(bool move READ move)
// /**
// * Whether the window is currently being resized by the user.
// */
// Q_PROPERTY(bool resize READ resize)
// /**
// * Whether the window is resizable
// */
// Q_PROPERTY(bool resizable READ resizable)
/**
* Whether the window is any of special windows types (desktop, dock, splash, ...),
* i.e. window types that usually don't have a window frame and the user does not use window
* management (moving, raising,...) on them.
*/
BI_READONLY_PROPERTY(bool, specialWindow)
/**
* The desktop this window is on. If the window is on all desktops the property has value -1.
*/
BI_PROPERTY(int, desktop, setDesktop)
// /**
// * Whether the window is fullscreen
// */
// Q_PROPERTY(bool fullScreen READ fullScreen WRITE set_fullScreen)
/**
* Whether the window is set to be above all
*/
BI_PROPERTY(bool, keepAbove, setKeepAbove)
// /**
// * Whether the window is set to be below all
// */
// Q_PROPERTY(bool keepBelow READ keepBelow WRITE set_keepBelow)
/**
* Whether the window is minimized
*/
BI_PROPERTY(bool, minimized, setMinimized);
// /**
// * Whether the window has borders (window decorations)
// */
// Q_PROPERTY(bool noBorder READ noBorder WRITE set_noBorder)
/**
* Whether the window is set to be on all desktops
*/
BI_PROPERTY(bool, onAllDesktops, setOnAllDesktops)
// /**
// * Whether the Client is shaded.
// */
// Q_PROPERTY(bool shade READ shade WRITE set_shade)
friend class PlasmaApi::Workspace;
};
}
Q_DECLARE_METATYPE(PlasmaApi::Client);

View File

@ -1,35 +0,0 @@
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
// SPDX-License-Identifier: MIT
#include "toplevel.hpp"
namespace PlasmaApi
{
TopLevel::TopLevel(QObject *kwinImpl)
: m_kwinImpl(kwinImpl){};
TopLevel::TopLevel(const TopLevel &rhs)
: m_kwinImpl(rhs.m_kwinImpl){};
TopLevel::TopLevel(TopLevel &&rhs)
: m_kwinImpl(rhs.m_kwinImpl){};
TopLevel &TopLevel::operator=(const TopLevel &rhs)
{
if (&rhs != this) {
m_kwinImpl = rhs.m_kwinImpl;
}
return *this;
}
TopLevel &TopLevel::operator=(TopLevel &&rhs)
{
if (&rhs != this) {
m_kwinImpl = std::move(rhs.m_kwinImpl);
}
return *this;
}
}

View File

@ -1,94 +0,0 @@
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
// SPDX-License-Identifier: MIT
#pragma once
#include <QObject>
#include "utils.hpp"
namespace PlasmaApi
{
class TopLevel : public QObject
{
Q_OBJECT
public:
TopLevel() = default;
virtual ~TopLevel() = default;
explicit TopLevel(QObject *kwinImplPtr);
TopLevel(const TopLevel &);
TopLevel(TopLevel &&);
TopLevel &operator=(const TopLevel &);
TopLevel &operator=(TopLevel &&);
/**
* Whether the window is a dialog window.
*/
BI_READONLY_PROPERTY(bool, dialog)
// /**
// * Frame geometry
// */
// // Q_PROPERTY(QRect frameGeometry READ frameGeometry WRITE set_frameGeometry)
// // QRECT_
/**
* Window class name
*/
BI_READONLY_PROPERTY(QByteArray, resourceClass)
// /**
// * Window title
// */
// Q_PROPERTY(QByteArray resourceName READ resourceName)
// QBYTEARRAY_PRIMITIVE_GET(resourceName)
/**
* On which screen toplevel is
*/
BI_READONLY_PROPERTY(int, screen)
// /**
// * Whether the window is a splashscreen.
// */
// Q_PROPERTY(bool splash READ splash)
// BOOL_PRIMITIVE_GET(splash)
//
// /**
// * Whether the window is a utility window, such as a tool window.
// */
// Q_PROPERTY(bool utility READ utility)
// BOOL_PRIMITIVE_GET(utility)
//
// /**
// * Window id in KWin
// */
// Q_PROPERTY(int windowId READ windowId)
// INT_PRIMITIVE_GET(windowId)
//
// /**
// * Window role property
// */
// Q_PROPERTY(QByteArray windowRole READ windowRole)
// QBYTEARRAY_PRIMITIVE_GET(windowRole)
//
// /**
// * Client position
// */
// Q_PROPERTY(QPoint clientPos READ clientPos)
// QPOINT_PRIMITIVE_GET(clientPos)
//
// /**
// * Client size
// */
// Q_PROPERTY(QSize clientSize READ clientSize)
// QSIZE_PRIMITIVE_GET(clientSize)
protected:
QObject *m_kwinImpl;
};
}
Q_DECLARE_METATYPE(PlasmaApi::TopLevel);

View File

@ -0,0 +1,46 @@
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
// SPDX-License-Identifier: MIT
#include "window.hpp"
namespace PlasmaApi
{
Window::Window(QObject *kwinImpl)
: m_kwinImpl(kwinImpl){};
Window::Window(const Window &rhs)
: m_kwinImpl(rhs.m_kwinImpl){};
Window::Window(Window &&rhs)
: m_kwinImpl(std::move(rhs.m_kwinImpl)){};
Window &Window::operator=(const Window &rhs)
{
if (&rhs != this) {
m_kwinImpl = rhs.m_kwinImpl;
}
return *this;
}
Window &Window::operator=(Window &&rhs)
{
if (&rhs != this) {
m_kwinImpl = std::move(rhs.m_kwinImpl);
}
return *this;
}
bool Window::operator==(const Window &rhs) const
{
return m_kwinImpl == rhs.m_kwinImpl;
}
bool Window::operator<(const Window &rhs) const
{
return m_kwinImpl < rhs.m_kwinImpl;
}
}

View File

@ -0,0 +1,558 @@
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
// SPDX-License-Identifier: MIT
#pragma once
#include <QList>
#include <QObject>
#include <QRect>
#include <QString>
#include "utils.hpp"
namespace PlasmaApi
{
class Workspace;
class Window : public QObject
{
Q_OBJECT
public:
Window() = default;
Window(QObject *kwinImpl);
Window(const Window &);
Window(Window &&);
virtual ~Window() = default;
Window &operator=(const Window &rhs);
Window &operator=(Window &&rhs);
bool operator==(const Window &rhs) const;
bool operator<(const Window &rhs) const;
// Q_PROPERTY(bool alpha READ hasAlpha NOTIFY hasAlphaChanged)
// Q_PROPERTY(qulonglong frameId READ frameId)
/**
* This property holds rectangle that the pixmap or buffer of this Window
* occupies on the screen. This rectangle includes invisible portions of the
* window, e.g. client-side drop shadows, etc.
*/
// Q_PROPERTY(QRect bufferGeometry READ bufferGeometry)
/**
* This property holds the position of the Window's frame geometry.
*/
// Q_PROPERTY(QPoint pos READ pos)
/**
* This property holds the size of the Window's frame geometry.
*/
// Q_PROPERTY(QSize size READ size)
/**
* This property holds the x position of the Window's frame geometry.
*/
// Q_PROPERTY(int x READ x NOTIFY frameGeometryChanged)
/**
* This property holds the y position of the Window's frame geometry.
*/
// Q_PROPERTY(int y READ y NOTIFY frameGeometryChanged)
/**
* This property holds the width of the Window's frame geometry.
*/
// Q_PROPERTY(int width READ width NOTIFY frameGeometryChanged)
/**
* This property holds the height of the Window's frame geometry.
*/
// Q_PROPERTY(int height READ height NOTIFY frameGeometryChanged)
// Q_PROPERTY(QRect visibleRect READ visibleGeometry)
// Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
BI_READONLY_PROPERTY(int, screen)
// Q_PROPERTY(int screen READ screen NOTIFY screenChanged)
// Q_PROPERTY(qulonglong windowId READ window CONSTANT)
// Q_PROPERTY(QRect rect READ rect)
// Q_PROPERTY(QPoint clientPos READ clientPos)
// Q_PROPERTY(QSize clientSize READ clientSize)
// Q_PROPERTY(QByteArray resourceName READ resourceName NOTIFY windowClassChanged)
BI_READONLY_PROPERTY(QByteArray, resourceClass)
// Q_PROPERTY(QByteArray resourceClass READ resourceClass NOTIFY windowClassChanged)
// Q_PROPERTY(QByteArray windowRole READ windowRole NOTIFY windowRoleChanged)
/**
* Returns whether the window is a desktop background window (the one with wallpaper).
* See _NET_WM_WINDOW_TYPE_DESKTOP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
// Q_PROPERTY(bool desktopWindow READ isDesktop)
/**
* Returns whether the window is a dock (i.e. a panel).
* See _NET_WM_WINDOW_TYPE_DOCK at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
// Q_PROPERTY(bool dock READ isDock)
/**
* Returns whether the window is a standalone (detached) toolbar window.
* See _NET_WM_WINDOW_TYPE_TOOLBAR at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
// Q_PROPERTY(bool toolbar READ isToolbar)
/**
* Returns whether the window is a torn-off menu.
* See _NET_WM_WINDOW_TYPE_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
// Q_PROPERTY(bool menu READ isMenu)
/**
* Returns whether the window is a "normal" window, i.e. an application or any other window
* for which none of the specialized window types fit.
* See _NET_WM_WINDOW_TYPE_NORMAL at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
// Q_PROPERTY(bool normalWindow READ isNormalWindow)
/**
* Returns whether the window is a dialog window.
* See _NET_WM_WINDOW_TYPE_DIALOG at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
BI_READONLY_PROPERTY(bool, dialog)
// Q_PROPERTY(bool dialog READ isDialog)
/**
* Returns whether the window is a splashscreen. Note that many (especially older) applications
* do not support marking their splash windows with this type.
* See _NET_WM_WINDOW_TYPE_SPLASH at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
// Q_PROPERTY(bool splash READ isSplash)
/**
* Returns whether the window is a utility window, such as a tool window.
* See _NET_WM_WINDOW_TYPE_UTILITY at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
// Q_PROPERTY(bool utility READ isUtility)
/**
* Returns whether the window is a dropdown menu (i.e. a popup directly or indirectly open
* from the applications menubar).
* See _NET_WM_WINDOW_TYPE_DROPDOWN_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
// Q_PROPERTY(bool dropdownMenu READ isDropdownMenu)
/**
* Returns whether the window is a popup menu (that is not a torn-off or dropdown menu).
* See _NET_WM_WINDOW_TYPE_POPUP_MENU at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
// Q_PROPERTY(bool popupMenu READ isPopupMenu)
/**
* Returns whether the window is a tooltip.
* See _NET_WM_WINDOW_TYPE_TOOLTIP at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
// Q_PROPERTY(bool tooltip READ isTooltip)
/**
* Returns whether the window is a window with a notification.
* See _NET_WM_WINDOW_TYPE_NOTIFICATION at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
// Q_PROPERTY(bool notification READ isNotification)
/**
* Returns whether the window is a window with a critical notification.
*/
// Q_PROPERTY(bool criticalNotification READ isCriticalNotification)
/**
* Returns whether the window is an applet popup.
*/
// Q_PROPERTY(bool appletPopup READ isAppletPopup)
/**
* Returns whether the window is an On Screen Display.
*/
// Q_PROPERTY(bool onScreenDisplay READ isOnScreenDisplay)
/**
* Returns whether the window is a combobox popup.
* See _NET_WM_WINDOW_TYPE_COMBO at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
// Q_PROPERTY(bool comboBox READ isComboBox)
/**
* Returns whether the window is a Drag&Drop icon.
* See _NET_WM_WINDOW_TYPE_DND at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
// Q_PROPERTY(bool dndIcon READ isDNDIcon)
/**
* Returns the NETWM window type
* See https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
*/
// Q_PROPERTY(int windowType READ windowType)
/**
* Whether this Window is managed by KWin (it has control over its placement and other
* aspects, as opposed to override-redirect windows that are entirely handled by the application).
*/
// Q_PROPERTY(bool managed READ isClient CONSTANT)
/**
* Whether this Window represents an already deleted window and only kept for the compositor for animations.
*/
// Q_PROPERTY(bool deleted READ isDeleted CONSTANT)
/**
* Whether the window has an own shape
*/
// Q_PROPERTY(bool shaped READ shape NOTIFY shapedChanged)
/**
* Whether the window does not want to be animated on window close.
* There are legit reasons for this like a screenshot application which does not want it's
* window being captured.
*/
// Q_PROPERTY(bool skipsCloseAnimation READ skipsCloseAnimation WRITE setSkipCloseAnimation NOTIFY skipCloseAnimationChanged)
/**
* Interface to the Wayland Surface.
* Relevant only in Wayland, in X11 it will be nullptr
*/
// Q_PROPERTY(KWaylandServer::SurfaceInterface *surface READ surface)
/**
* Whether the window is a popup.
*/
// Q_PROPERTY(bool popupWindow READ isPopupWindow)
/**
* Whether this Window represents the outline.
*
* @note It's always @c false if compositing is turned off.
*/
// Q_PROPERTY(bool outline READ isOutline)
/**
* This property holds a UUID to uniquely identify this Window.
*/
// Q_PROPERTY(QUuid internalId READ internalId CONSTANT)
/**
* The pid of the process owning this window.
*
* @since 5.20
*/
// Q_PROPERTY(int pid READ pid CONSTANT)
/**
* The position of this window within Workspace's window stack.
*/
// Q_PROPERTY(int stackingOrder READ stackingOrder NOTIFY stackingOrderChanged)
/**
* Whether this Window is fullScreen. A Window might either be fullScreen due to the _NET_WM property
* or through a legacy support hack. The fullScreen state can only be changed if the Window does not
* use the legacy hack. To be sure whether the state changed, connect to the notify signal.
*/
// Q_PROPERTY(bool fullScreen READ isFullScreen WRITE setFullScreen NOTIFY fullScreenChanged)
/**
* Whether the Window can be set to fullScreen. The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
*/
// Q_PROPERTY(bool fullScreenable READ isFullScreenable)
/**
* Whether this Window is active or not. Use Workspace::activateWindow() to activate a Window.
* @see Workspace::activateWindow
*/
// Q_PROPERTY(bool active READ isActive NOTIFY activeChanged)
/**
* The desktop this Window is on. If the Window is on all desktops the property has value -1.
* This is a legacy property, use x11DesktopIds instead
*
* @deprecated Use the desktops property instead.
*/
BI_PROPERTY(int, desktop, setDesktop)
// Q_PROPERTY(int desktop READ desktop WRITE setDesktop NOTIFY desktopChanged)
/**
* The virtual desktops this client is on. If it's on all desktops, the list is empty.
*/
// Q_PROPERTY(QVector<KWin::VirtualDesktop *> desktops READ desktops WRITE setDesktops NOTIFY desktopChanged)
/**
* Whether the Window is on all desktops. That is desktop is -1.
*/
BI_PROPERTY(bool, onAllDesktops, setOnAllDesktops)
// Q_PROPERTY(bool onAllDesktops READ isOnAllDesktops WRITE setOnAllDesktops NOTIFY desktopChanged)
/**
* The activities this client is on. If it's on all activities the property is empty.
*/
BI_READONLY_PROPERTY(QStringList, activities)
// Q_PROPERTY(QStringList activities READ activities WRITE setOnActivities NOTIFY activitiesChanged)
/**
* The x11 ids for all desktops this client is in. On X11 this list will always have a length of 1
*
* @deprecated prefer using apis that use VirtualDesktop objects
*/
// Q_PROPERTY(QVector<uint> x11DesktopIds READ x11DesktopIds NOTIFY x11DesktopIdsChanged)
/**
* Indicates that the window should not be included on a taskbar.
*/
// Q_PROPERTY(bool skipTaskbar READ skipTaskbar WRITE setSkipTaskbar NOTIFY skipTaskbarChanged)
/**
* Indicates that the window should not be included on a Pager.
*/
// Q_PROPERTY(bool skipPager READ skipPager WRITE setSkipPager NOTIFY skipPagerChanged)
/**
* Whether the Window should be excluded from window switching effects.
*/
// Q_PROPERTY(bool skipSwitcher READ skipSwitcher WRITE setSkipSwitcher NOTIFY skipSwitcherChanged)
/**
* Whether the window can be closed by the user.
*/
// Q_PROPERTY(bool closeable READ isCloseable NOTIFY closeableChanged)
// Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged)
/**
* Whether the Window is set to be kept above other windows.
*/
BI_PROPERTY(bool, keepAbove, setKeepAbove)
// Q_PROPERTY(bool keepAbove READ keepAbove WRITE setKeepAbove NOTIFY keepAboveChanged)
/**
* Whether the Window is set to be kept below other windows.
*/
// Q_PROPERTY(bool keepBelow READ keepBelow WRITE setKeepBelow NOTIFY keepBelowChanged)
/**
* Whether the Window can be shaded. The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
*/
// Q_PROPERTY(bool shadeable READ isShadeable)
/**
* Whether the Window is shaded.
*/
// Q_PROPERTY(bool shade READ isShade WRITE setShade NOTIFY shadeChanged)
/**
* Whether the Window can be minimized. The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
*/
// Q_PROPERTY(bool minimizable READ isMinimizable)
/**
* Whether the Window is minimized.
*/
BI_PROPERTY(bool, minimized, setMinimized);
// Q_PROPERTY(bool minimized READ isMinimized WRITE setMinimized NOTIFY minimizedChanged)
/**
* The optional geometry representing the minimized Window in e.g a taskbar.
* See _NET_WM_ICON_GEOMETRY at https://standards.freedesktop.org/wm-spec/wm-spec-latest.html .
* The value is evaluated each time the getter is called.
* Because of that no changed signal is provided.
*/
// Q_PROPERTY(QRect iconGeometry READ iconGeometry)
/**
* Returns whether the window is any of special windows types (desktop, dock, splash, ...),
* i.e. window types that usually don't have a window frame and the user does not use window
* management (moving, raising,...) on them.
* The value is evaluated each time the getter is called.
* Because of that no changed signal is provided.
*/
BI_READONLY_PROPERTY(bool, specialWindow)
// Q_PROPERTY(bool specialWindow READ isSpecialWindow)
/**
* Whether window state _NET_WM_STATE_DEMANDS_ATTENTION is set. This state indicates that some
* action in or with the window happened. For example, it may be set by the Window Manager if
* the window requested activation but the Window Manager refused it, or the application may set
* it if it finished some work. This state may be set by both the Window and the Window Manager.
* It should be unset by the Window Manager when it decides the window got the required attention
* (usually, that it got activated).
*/
// Q_PROPERTY(bool demandsAttention READ isDemandingAttention WRITE demandAttention NOTIFY demandsAttentionChanged)
/**
* The Caption of the Window. Read from WM_NAME property together with a suffix for hostname and shortcut.
* To read only the caption as provided by WM_NAME, use the getter with an additional @c false value.
*/
BI_READONLY_PROPERTY(QString, caption)
// Q_PROPERTY(QString caption READ caption NOTIFY captionChanged)
/**
* Minimum size as specified in WM_NORMAL_HINTS
*/
// Q_PROPERTY(QSize minSize READ minSize)
/**
* Maximum size as specified in WM_NORMAL_HINTS
*/
// Q_PROPERTY(QSize maxSize READ maxSize)
/**
* Whether the Window can accept keyboard focus.
* The value is evaluated each time the getter is called.
* Because of that no changed signal is provided.
*/
// Q_PROPERTY(bool wantsInput READ wantsInput)
/**
* Whether the Window is a transient Window to another Window.
* @see transientFor
*/
// Q_PROPERTY(bool transient READ isTransient NOTIFY transientChanged)
/**
* The Window to which this Window is a transient if any.
*/
// Q_PROPERTY(KWin::Window *transientFor READ transientFor NOTIFY transientChanged)
/**
* Whether the Window represents a modal window.
*/
// Q_PROPERTY(bool modal READ isModal NOTIFY modalChanged)
/**
* The geometry of this Window. Be aware that depending on resize mode the frameGeometryChanged
* signal might be emitted at each resize step or only at the end of the resize operation.
*
* @deprecated Use frameGeometry
*/
// Q_PROPERTY(QRect geometry READ frameGeometry WRITE moveResize NOTIFY frameGeometryChanged)
/**
* The geometry of this Window. Be aware that depending on resize mode the frameGeometryChanged
* signal might be emitted at each resize step or only at the end of the resize operation.
*/
BI_PROPERTY(QRect, frameGeometry, setFrameGeometry)
// Q_PROPERTY(QRect frameGeometry READ frameGeometry WRITE moveResize NOTIFY frameGeometryChanged)
/**
* Whether the Window is currently being moved by the user.
* Notify signal is emitted when the Window starts or ends move/resize mode.
*/
// Q_PROPERTY(bool move READ isInteractiveMove NOTIFY moveResizedChanged)
/**
* Whether the Window is currently being resized by the user.
* Notify signal is emitted when the Window starts or ends move/resize mode.
*/
// Q_PROPERTY(bool resize READ isInteractiveResize NOTIFY moveResizedChanged)
/**
* Whether the decoration is currently using an alpha channel.
*/
// Q_PROPERTY(bool decorationHasAlpha READ decorationHasAlpha)
/**
* Whether the window has a decoration or not.
* This property is not allowed to be set by applications themselves.
* The decision whether a window has a border or not belongs to the window manager.
* If this property gets abused by application developers, it will be removed again.
*/
// Q_PROPERTY(bool noBorder READ noBorder WRITE setNoBorder)
/**
* Whether the Window provides context help. Mostly needed by decorations to decide whether to
* show the help button or not.
*/
// Q_PROPERTY(bool providesContextHelp READ providesContextHelp CONSTANT)
/**
* Whether the Window can be maximized both horizontally and vertically.
* The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
*/
// Q_PROPERTY(bool maximizable READ isMaximizable)
/**
* Whether the Window is moveable. Even if it is not moveable, it might be possible to move
* it to another screen. The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
* @see moveableAcrossScreens
*/
// Q_PROPERTY(bool moveable READ isMovable)
/**
* Whether the Window can be moved to another screen. The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
* @see moveable
*/
// Q_PROPERTY(bool moveableAcrossScreens READ isMovableAcrossScreens)
/**
* Whether the Window can be resized. The property is evaluated each time it is invoked.
* Because of that there is no notify signal.
*/
// Q_PROPERTY(bool resizeable READ isResizable)
/**
* The desktop file name of the application this Window belongs to.
*
* This is either the base name without full path and without file extension of the
* desktop file for the window's application (e.g. "org.kde.foo").
*
* The application's desktop file name can also be the full path to the desktop file
* (e.g. "/opt/kde/share/org.kde.foo.desktop") in case it's not in a standard location.
*/
// Q_PROPERTY(QByteArray desktopFileName READ desktopFileName NOTIFY desktopFileNameChanged)
/**
* Whether an application menu is available for this Window
*/
// Q_PROPERTY(bool hasApplicationMenu READ hasApplicationMenu NOTIFY hasApplicationMenuChanged)
/**
* Whether the application menu for this Window is currently opened
*/
// Q_PROPERTY(bool applicationMenuActive READ applicationMenuActive NOTIFY applicationMenuActiveChanged)
/**
* Whether this window is unresponsive.
*
* When an application failed to react on a ping request in time, it is
* considered unresponsive. This usually indicates that the application froze or crashed.
*/
// Q_PROPERTY(bool unresponsive READ unresponsive NOTIFY unresponsiveChanged)
/**
* The color scheme set on this window
* Absolute file path, or name of palette in the user's config directory following KColorSchemes format.
* An empty string indicates the default palette from kdeglobals is used.
* @note this indicates the colour scheme requested, which might differ from the theme applied if the colorScheme cannot be found
*/
// Q_PROPERTY(QString colorScheme READ colorScheme NOTIFY colorSchemeChanged)
// Q_PROPERTY(KWin::Layer layer READ layer)
/**
* Whether this window is hidden. It's usually the case with auto-hide panels.
*/
// Q_PROPERTY(bool hidden READ isHiddenInternal NOTIFY hiddenChanged)
private:
QObject *m_kwinImpl;
friend class PlasmaApi::Workspace;
};
}
Q_DECLARE_METATYPE(PlasmaApi::Window);

View File

@ -7,7 +7,7 @@
#include "logger.hpp"
#include "plasma-api/api.hpp"
#include "plasma-api/client.hpp"
#include "plasma-api/window.hpp"
namespace PlasmaApi
{
@ -26,13 +26,13 @@ Workspace::Workspace(const Workspace &rhs)
wrapSignals();
};
std::optional<PlasmaApi::Client> Workspace::activeClient() const
std::optional<PlasmaApi::Window> Workspace::activeClient() const
{
auto kwinClient = m_kwinImpl->property("activeClient").value<QObject *>();
return kwinClient ? PlasmaApi::Client(kwinClient) : std::optional<PlasmaApi::Client>();
return kwinClient ? PlasmaApi::Window(kwinClient) : std::optional<PlasmaApi::Window>();
}
void Workspace::setActiveClient(std::optional<PlasmaApi::Client> client)
void Workspace::setActiveClient(std::optional<PlasmaApi::Window> client)
{
auto valueToSet = client.has_value() ? client->m_kwinImpl : nullptr;
m_kwinImpl->setProperty("activeClient", QVariant::fromValue(valueToSet));
@ -55,12 +55,12 @@ void Workspace::wrapSignals()
wrapSimpleSignal(SIGNAL(screenResized(int)));
wrapSimpleSignal(SIGNAL(currentActivityChanged(const QString &)));
wrapComplexSignal(SIGNAL(currentDesktopChanged(int, KWin::AbstractClient *)), SLOT(currentDesktopChangedTransformer(int, KWin::AbstractClient *)));
wrapComplexSignal(SIGNAL(clientAdded(KWin::AbstractClient *)), SLOT(clientAddedTransformer(KWin::AbstractClient *)));
wrapComplexSignal(SIGNAL(clientRemoved(KWin::AbstractClient *)), SLOT(clientRemovedTransformer(KWin::AbstractClient *)));
wrapComplexSignal(SIGNAL(clientMinimized(KWin::AbstractClient *)), SLOT(clientMinimizedTransformer(KWin::AbstractClient *)));
wrapComplexSignal(SIGNAL(clientUnminimized(KWin::AbstractClient *)), SLOT(clientUnminimizedTransformer(KWin::AbstractClient *)));
wrapComplexSignal(SIGNAL(clientMaximizeSet(KWin::AbstractClient *, bool, bool)), SLOT(clientMaximizeSetTransformer(KWin::AbstractClient *, bool, bool)));
wrapComplexSignal(SIGNAL(currentDesktopChanged(int, KWin::Window *)), SLOT(currentDesktopChangedTransformer(int, KWin::Window *)));
wrapComplexSignal(SIGNAL(clientAdded(KWin::Window *)), SLOT(clientAddedTransformer(KWin::Window *)));
wrapComplexSignal(SIGNAL(clientRemoved(KWin::Window *)), SLOT(clientRemovedTransformer(KWin::Window *)));
wrapComplexSignal(SIGNAL(clientMinimized(KWin::Window *)), SLOT(clientMinimizedTransformer(KWin::Window *)));
wrapComplexSignal(SIGNAL(clientUnminimized(KWin::Window *)), SLOT(clientUnminimizedTransformer(KWin::Window *)));
wrapComplexSignal(SIGNAL(clientMaximizeSet(KWin::Window *, bool, bool)), SLOT(clientMaximizeSetTransformer(KWin::Window *, bool, bool)));
};
QRect Workspace::clientArea(ClientAreaOption option, int screen, int desktop)
@ -68,59 +68,59 @@ QRect Workspace::clientArea(ClientAreaOption option, int screen, int desktop)
BI_METHOD_IMPL_WRAP(QRect, "clientArea(ClientAreaOption, int, int)", Q_ARG(ClientAreaOption, option), Q_ARG(int, screen), Q_ARG(int, desktop));
};
std::vector<PlasmaApi::Client> Workspace::clientList() const
std::vector<PlasmaApi::Window> Workspace::clientList() const
{
auto apiCall = [&]() -> QList<KWin::AbstractClient *> {
BI_METHOD_IMPL_WRAP(QList<KWin::AbstractClient *>, "clientList()", QGenericArgument(nullptr));
auto apiCall = [&]() -> QList<KWin::Window *> {
BI_METHOD_IMPL_WRAP(QList<KWin::Window *>, "clientList()", QGenericArgument(nullptr));
};
auto apiCallRes = apiCall();
auto result = std::vector<PlasmaApi::Client>();
auto result = std::vector<PlasmaApi::Window>();
result.reserve(apiCallRes.size());
for (auto clientPtr : apiCallRes) {
if (clientPtr) {
result.push_back(Client(reinterpret_cast<QObject *>(clientPtr)));
result.push_back(Window(reinterpret_cast<QObject *>(clientPtr)));
}
}
return result;
}
void Workspace::currentDesktopChangedTransformer(int desktop, KWin::AbstractClient *kwinClient)
void Workspace::currentDesktopChangedTransformer(int desktop, KWin::Window *kwinClient)
{
// Since we don't know the KWin internal implementation we have to use reinterpret_cast
auto clientWrapper = Client(reinterpret_cast<QObject *>(kwinClient));
auto clientWrapper = Window(reinterpret_cast<QObject *>(kwinClient));
Q_EMIT currentDesktopChanged(desktop, clientWrapper);
};
void Workspace::clientAddedTransformer(KWin::AbstractClient *kwinClient)
void Workspace::clientAddedTransformer(KWin::Window *kwinClient)
{
auto clientWrapper = Client(reinterpret_cast<QObject *>(kwinClient));
auto clientWrapper = Window(reinterpret_cast<QObject *>(kwinClient));
Q_EMIT clientAdded(clientWrapper);
}
void Workspace::clientRemovedTransformer(KWin::AbstractClient *kwinClient)
void Workspace::clientRemovedTransformer(KWin::Window *kwinClient)
{
auto clientWrapper = Client(reinterpret_cast<QObject *>(kwinClient));
auto clientWrapper = Window(reinterpret_cast<QObject *>(kwinClient));
Q_EMIT clientRemoved(clientWrapper);
}
void Workspace::clientMinimizedTransformer(KWin::AbstractClient *kwinClient)
void Workspace::clientMinimizedTransformer(KWin::Window *kwinClient)
{
auto clientWrapper = Client(reinterpret_cast<QObject *>(kwinClient));
auto clientWrapper = Window(reinterpret_cast<QObject *>(kwinClient));
Q_EMIT clientMinimized(clientWrapper);
}
void Workspace::clientUnminimizedTransformer(KWin::AbstractClient *kwinClient)
void Workspace::clientUnminimizedTransformer(KWin::Window *kwinClient)
{
auto clientWrapper = Client(reinterpret_cast<QObject *>(kwinClient));
auto clientWrapper = Window(reinterpret_cast<QObject *>(kwinClient));
Q_EMIT clientUnminimized(clientWrapper);
}
void Workspace::clientMaximizeSetTransformer(KWin::AbstractClient *kwinClient, bool h, bool v)
void Workspace::clientMaximizeSetTransformer(KWin::Window *kwinClient, bool h, bool v)
{
auto clientWrapper = Client(reinterpret_cast<QObject *>(kwinClient));
auto clientWrapper = Window(reinterpret_cast<QObject *>(kwinClient));
Q_EMIT clientMaximizeSet(clientWrapper, h, v);
}

View File

@ -8,14 +8,14 @@
#include <optional>
#include "plasma-api/client.hpp"
#include "plasma-api/window.hpp"
#include "utils.hpp"
// Forward declare KWin Classes
namespace KWin
{
class AbstractClient;
class Window;
}
namespace PlasmaApi
@ -47,10 +47,10 @@ public:
BI_PROPERTY(QString, currentActivity, setCurrentActivity);
BI_PROPERTY(int, desktops, setDesktops);
Q_PROPERTY(std::optional<PlasmaApi::Client> activeClient READ activeClient WRITE setActiveClient);
Q_PROPERTY(std::optional<PlasmaApi::Window> activeClient READ activeClient WRITE setActiveClient);
std::optional<PlasmaApi::Client> activeClient() const;
void setActiveClient(std::optional<PlasmaApi::Client> client);
std::optional<PlasmaApi::Window> activeClient() const;
void setActiveClient(std::optional<PlasmaApi::Window> client);
/**
* Returns the geometry a Client can use with the specified option.
@ -64,18 +64,18 @@ public:
*/
Q_INVOKABLE QRect clientArea(ClientAreaOption, int screen, int desktop);
Q_INVOKABLE std::vector<PlasmaApi::Client> clientList() const;
Q_INVOKABLE std::vector<PlasmaApi::Window> clientList() const;
private Q_SLOTS:
void currentDesktopChangedTransformer(int desktop, KWin::AbstractClient *kwinClient);
void clientAddedTransformer(KWin::AbstractClient *);
void clientRemovedTransformer(KWin::AbstractClient *);
void clientMinimizedTransformer(KWin::AbstractClient *);
void clientUnminimizedTransformer(KWin::AbstractClient *);
void clientMaximizeSetTransformer(KWin::AbstractClient *, bool h, bool v);
void currentDesktopChangedTransformer(int desktop, KWin::Window *kwinClient);
void clientAddedTransformer(KWin::Window *);
void clientRemovedTransformer(KWin::Window *);
void clientMinimizedTransformer(KWin::Window *);
void clientUnminimizedTransformer(KWin::Window *);
void clientMaximizeSetTransformer(KWin::Window *, bool h, bool v);
Q_SIGNALS:
void currentDesktopChanged(int desktop, PlasmaApi::Client kwinClient);
void currentDesktopChanged(int desktop, PlasmaApi::Window kwinClient);
/**
* Signal emitted when the number of screens changes.
@ -97,15 +97,15 @@ Q_SIGNALS:
*/
void currentActivityChanged(const QString &id);
void clientAdded(PlasmaApi::Client client);
void clientAdded(PlasmaApi::Window client);
void clientRemoved(PlasmaApi::Client client);
void clientRemoved(PlasmaApi::Window client);
void clientMinimized(PlasmaApi::Client client);
void clientMinimized(PlasmaApi::Window client);
void clientUnminimized(PlasmaApi::Client client);
void clientUnminimized(PlasmaApi::Window client);
void clientMaximizeSet(PlasmaApi::Client client, bool h, bool v);
void clientMaximizeSet(PlasmaApi::Window client, bool h, bool v);
private:
void wrapSignals();

View File

@ -139,7 +139,7 @@ declare namespace KWin {
/**
* TODO: I could not find anything about signal in the KWin source.
* Probably it does not exist here. It exists in KWin::AbstractClient though.
* Probably it does not exist here. It exists in KWin::Window though.
*/
activitiesChanged: QSignal;
@ -161,7 +161,7 @@ declare namespace KWin {
}
/**
* Client, also known as window. Represents KWin::AbstractClient.
* Client, also known as window. Represents KWin::Window.
*/
interface Client extends Toplevel {
/**

View File

@ -7,8 +7,8 @@
#include "engine/layout/monocle.hpp"
#include "engine/window.hpp"
#include "plasma-api/client.hpp"
#include "plasma-api/client.mock.hpp"
#include "plasma-api/window.hpp"
#include "plasma-api/window.mock.hpp"
#include "plasma-api/workspace.hpp"
#include "plasma-api/workspace.mock.hpp"
@ -28,8 +28,8 @@ TEST_CASE("Monocle Tiling Logic")
auto tilingArea = QRect(0, 0, 1000, 1000);
auto windowsToTile = std::vector<Bismuth::Window>({
Bismuth::Window(PlasmaApi::Client(&fakeClient1), workspace),
Bismuth::Window(PlasmaApi::Client(&fakeClient2), workspace),
Bismuth::Window(PlasmaApi::Window(&fakeClient1), workspace),
Bismuth::Window(PlasmaApi::Window(&fakeClient2), workspace),
});
monocleLayout.apply(tilingArea, windowsToTile);

View File

@ -8,9 +8,9 @@
#include "engine/surface.hpp"
#include "engine/window.hpp"
#include "plasma-api/client.hpp"
#include "plasma-api/window.hpp"
#include "plasma-api/client.mock.hpp"
#include "plasma-api/window.mock.hpp"
#include "plasma-api/workspace.hpp"
#include "plasma-api/workspace.mock.hpp"
@ -18,7 +18,7 @@ TEST_CASE("Window Visibility")
{
auto fakeKWinClient = FakeKWinClient();
auto fakeKwinWorkspace = FakeKWinWorkspace();
auto client = PlasmaApi::Client(&fakeKWinClient);
auto client = PlasmaApi::Window(&fakeKWinClient);
auto workspace = PlasmaApi::Workspace(&fakeKwinWorkspace);
auto window = Bismuth::Window(client, workspace);
@ -117,7 +117,7 @@ TEST_CASE("Desktops List")
{
auto fakeKWinClient = FakeKWinClient();
auto fakeKWinWorkspace = FakeKWinWorkspace();
auto client = PlasmaApi::Client(&fakeKWinClient);
auto client = PlasmaApi::Window(&fakeKWinClient);
auto workspace = PlasmaApi::Workspace(&fakeKWinWorkspace);
auto window = Bismuth::Window(client, workspace);
@ -153,7 +153,7 @@ TEST_CASE("Activities List")
{
auto fakeKWinClient = FakeKWinClient();
auto fakeKWinWorkspace = FakeKWinWorkspace();
auto client = PlasmaApi::Client(&fakeKWinClient);
auto client = PlasmaApi::Window(&fakeKWinClient);
auto workspace = PlasmaApi::Workspace(&fakeKWinWorkspace);
auto window = Bismuth::Window(client, workspace);

View File

@ -1,5 +1,5 @@
# SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
# SPDX-License-Identifier: MIT
target_sources(test_runner PRIVATE workspace.test.cpp client.mock.cpp
target_sources(test_runner PRIVATE workspace.test.cpp window.mock.cpp
workspace.mock.cpp)

View File

@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
// SPDX-License-Identifier: MIT
#include "client.mock.hpp"
#include "window.mock.hpp"
FakeKWinClient &FakeKWinClient::operator=(const FakeKWinClient &rhs)
{

View File

@ -7,7 +7,7 @@
namespace KWin
{
class AbstractClient;
class Window;
}
class FakeKWinWorkspace : public QObject
@ -27,10 +27,10 @@ Q_SIGNALS:
void numberScreensChanged(int count);
void screenResized(int screen);
void currentActivityChanged(const QString &id);
void clientAdded(KWin::AbstractClient *);
void clientMaximizeSet(KWin::AbstractClient *, bool h, bool v);
void clientMinimized(KWin::AbstractClient *);
void clientRemoved(KWin::AbstractClient *);
void clientUnminimized(KWin::AbstractClient *);
void currentDesktopChanged(int desktop, KWin::AbstractClient *kwinClient);
void clientAdded(KWin::Window *);
void clientMaximizeSet(KWin::Window *, bool h, bool v);
void clientMinimized(KWin::Window *);
void clientRemoved(KWin::Window *);
void clientUnminimized(KWin::Window *);
void currentDesktopChanged(int desktop, KWin::Window *kwinClient);
};

View File

@ -9,18 +9,18 @@
#include <QSignalSpy>
#include "plasma-api/api.hpp"
#include "plasma-api/client.hpp"
#include "plasma-api/window.hpp"
#include "plasma-api/workspace.hpp"
// Mock KWin Objects. This is for tests only.
namespace KWin
{
class AbstractClient
class Window
{
};
}
Q_DECLARE_METATYPE(KWin::AbstractClient *)
Q_DECLARE_METATYPE(KWin::Window *)
class MockWorkspaceJS : public QObject
{
@ -38,16 +38,16 @@ public:
}
Q_SIGNALS:
void currentDesktopChanged(int desktop, KWin::AbstractClient *client);
void currentDesktopChanged(int desktop, KWin::Window *client);
// Not all signals are used, some of them declared to avoid warnings
void numberScreensChanged(int);
void screenResized(int);
void currentActivityChanged(const QString &);
void clientAdded(KWin::AbstractClient *);
void clientRemoved(KWin::AbstractClient *);
void clientMinimized(KWin::AbstractClient *);
void clientUnminimized(KWin::AbstractClient *);
void clientMaximizeSet(KWin::AbstractClient *, bool, bool);
void clientAdded(KWin::Window *);
void clientRemoved(KWin::Window *);
void clientMinimized(KWin::Window *);
void clientUnminimized(KWin::Window *);
void clientMaximizeSet(KWin::Window *, bool, bool);
private:
int m_currentDesktop{};
@ -102,9 +102,9 @@ TEST_CASE("Workspace Properties Signals")
SUBCASE("currentDesktop")
{
qRegisterMetaType<KWin::AbstractClient *>();
auto signalSpy = QSignalSpy(&workspace, SIGNAL(currentDesktopChanged(int, PlasmaApi::Client)));
auto mockKWinClient = KWin::AbstractClient();
qRegisterMetaType<KWin::Window *>();
auto signalSpy = QSignalSpy(&workspace, SIGNAL(currentDesktopChanged(int, PlasmaApi::Window)));
auto mockKWinClient = KWin::Window();
// Act
Q_EMIT mockWorkspace.currentDesktopChanged(69, &mockKWinClient);
@ -117,7 +117,7 @@ TEST_CASE("Workspace Properties Signals")
auto clientVariant = signal.at(1);
CHECK(desktopNum == 69);
CHECK(clientVariant.canConvert<PlasmaApi::Client>());
CHECK(clientVariant.canConvert<PlasmaApi::Window>());
}
}