mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-11 00:15:37 +03:00
chore: arrange cxx skeleton
This commit is contained in:
parent
805229a182
commit
1dd1e82cf0
@ -1,4 +1,5 @@
|
||||
# SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
target_sources(bismuth_core PRIVATE engine.cpp windows_list.cpp window.cpp)
|
||||
target_sources(bismuth_core PRIVATE engine.cpp windows_list.cpp window.cpp
|
||||
surface.cpp)
|
||||
|
@ -2,10 +2,13 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "engine.hpp"
|
||||
#include "engine/surface.hpp"
|
||||
#include "plasma-api/api.hpp"
|
||||
|
||||
namespace Bismuth
|
||||
{
|
||||
Engine::Engine()
|
||||
Engine::Engine(PlasmaApi::Api &api)
|
||||
: m_plasmaApi(api)
|
||||
{
|
||||
}
|
||||
|
||||
@ -17,9 +20,45 @@ void Engine::addWindow(PlasmaApi::Client client)
|
||||
|
||||
void Engine::removeWindow(PlasmaApi::Client client)
|
||||
{
|
||||
m_windows.remove(client);
|
||||
}
|
||||
|
||||
void Engine::arrange()
|
||||
{
|
||||
auto screenSurfaces = [this]() -> std::vector<Surface> {
|
||||
auto result = std::vector<Surface>(1);
|
||||
|
||||
for (auto screen = 0; screen < m_plasmaApi.workspace().numScreens(); screen++) {
|
||||
result.push_back(Surface());
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
for (auto &surface : screenSurfaces()) {
|
||||
arrangeWindowsOnSurface(surface);
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::arrangeWindowsOnSurface(const Surface &surface)
|
||||
{
|
||||
auto layout = "Layout";
|
||||
auto workingArea = QRect();
|
||||
auto tilingArea = QRect();
|
||||
|
||||
auto visibleWindows = std::vector<Window>();
|
||||
|
||||
auto windowsThatCanBeTiled = std::vector<Window>();
|
||||
|
||||
// Maximize sole tile if enabled or apply the current layout as expected
|
||||
// ...
|
||||
// Or
|
||||
// Apply layout to windows
|
||||
|
||||
// If enabled, limit the windows' width
|
||||
|
||||
// Commit window assigned properties
|
||||
// visibleWindows.forEach((win : EngineWindow) = > win.commit());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "engine/surface.hpp"
|
||||
#include "plasma-api/api.hpp"
|
||||
#include "plasma-api/client.hpp"
|
||||
#include "windows_list.hpp"
|
||||
|
||||
@ -11,7 +13,7 @@ namespace Bismuth
|
||||
class Engine
|
||||
{
|
||||
public:
|
||||
Engine();
|
||||
Engine(PlasmaApi::Api &);
|
||||
|
||||
void addWindow(PlasmaApi::Client);
|
||||
void removeWindow(PlasmaApi::Client);
|
||||
@ -22,6 +24,9 @@ public:
|
||||
void arrange();
|
||||
|
||||
private:
|
||||
void arrangeWindowsOnSurface(const Surface &);
|
||||
|
||||
WindowsList m_windows{};
|
||||
PlasmaApi::Api &m_plasmaApi;
|
||||
};
|
||||
}
|
||||
|
9
src/core/engine/surface.cpp
Normal file
9
src/core/engine/surface.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include "surface.hpp"
|
||||
|
||||
namespace Bismuth
|
||||
{
|
||||
|
||||
}
|
11
src/core/engine/surface.hpp
Normal file
11
src/core/engine/surface.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
// SPDX-FileCopyrightText: 2022 Mikhail Zolotukhin <mail@gikari.com>
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Bismuth
|
||||
{
|
||||
class Surface
|
||||
{
|
||||
};
|
||||
}
|
@ -6,4 +6,24 @@
|
||||
namespace Bismuth
|
||||
{
|
||||
|
||||
Window::Window(PlasmaApi::Client client)
|
||||
: m_client(client)
|
||||
{
|
||||
}
|
||||
|
||||
bool Window::operator<(const Window &rhs) const
|
||||
{
|
||||
return m_client < m_client;
|
||||
}
|
||||
|
||||
void Window::setMode(Mode value)
|
||||
{
|
||||
m_mode = value;
|
||||
}
|
||||
|
||||
Window::Mode Window::mode() const
|
||||
{
|
||||
return m_mode;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,9 +3,31 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "plasma-api/client.hpp"
|
||||
|
||||
namespace Bismuth
|
||||
{
|
||||
class Window
|
||||
{
|
||||
public:
|
||||
enum class Mode {
|
||||
Ignored,
|
||||
Floating,
|
||||
Fullscreen,
|
||||
Maximized,
|
||||
Tiled,
|
||||
};
|
||||
|
||||
Window(PlasmaApi::Client client);
|
||||
|
||||
bool operator<(const Window &rhs) const;
|
||||
|
||||
void setMode(Mode);
|
||||
Mode mode() const;
|
||||
|
||||
private:
|
||||
PlasmaApi::Client m_client;
|
||||
|
||||
Mode m_mode;
|
||||
};
|
||||
}
|
||||
|
@ -7,8 +7,13 @@
|
||||
namespace Bismuth
|
||||
{
|
||||
|
||||
void WindowsList::add(PlasmaApi::Client)
|
||||
void WindowsList::add(PlasmaApi::Client client)
|
||||
{
|
||||
qDebug(Bi) << "Adding window... (CXX)";
|
||||
m_windowMap.insert_or_assign(client, Window(client));
|
||||
}
|
||||
|
||||
void WindowsList::remove(PlasmaApi::Client client)
|
||||
{
|
||||
m_windowMap.erase(client);
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ class WindowsList
|
||||
{
|
||||
public:
|
||||
void add(PlasmaApi::Client);
|
||||
void remove(PlasmaApi::Client);
|
||||
|
||||
private:
|
||||
std::map<PlasmaApi::Client, Window> m_windowMap{};
|
||||
|
@ -12,4 +12,10 @@ Client::Client(QObject *kwinImpl)
|
||||
|
||||
Client::Client(const Client &rhs)
|
||||
: TopLevel(rhs){};
|
||||
|
||||
bool Client::operator<(const Client &rhs) const
|
||||
{
|
||||
return m_kwinImpl < rhs.m_kwinImpl;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ public:
|
||||
Client(const Client &);
|
||||
virtual ~Client() = default;
|
||||
|
||||
bool operator<(const Client &rhs) const;
|
||||
|
||||
/**
|
||||
* The activities this client is on. If it's on all activities the property is empty.
|
||||
*/
|
||||
|
@ -11,4 +11,25 @@ TopLevel::TopLevel(QObject *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;
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,12 @@ class TopLevel : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
TopLevel() = default;
|
||||
virtual ~TopLevel() = default;
|
||||
explicit TopLevel(QObject *kwinImplPtr);
|
||||
TopLevel(const TopLevel &);
|
||||
virtual ~TopLevel() = default;
|
||||
TopLevel(TopLevel &&);
|
||||
TopLevel &operator=(const TopLevel &);
|
||||
TopLevel &operator=(TopLevel &&);
|
||||
|
||||
/**
|
||||
* Whether the window is a dialog window.
|
||||
|
@ -44,7 +44,7 @@ void Core::init()
|
||||
m_config = std::make_unique<Bismuth::Config>();
|
||||
m_qmlEngine = qmlEngine(this);
|
||||
m_plasmaApi = std::make_unique<PlasmaApi::Api>(m_qmlEngine);
|
||||
m_engine = std::make_unique<Bismuth::Engine>();
|
||||
m_engine = std::make_unique<Bismuth::Engine>(*m_plasmaApi);
|
||||
m_controller = std::make_unique<Bismuth::Controller>(*m_plasmaApi, *m_engine);
|
||||
m_tsProxy = std::make_unique<TSProxy>(m_qmlEngine, *m_controller, *m_plasmaApi, *m_config);
|
||||
m_controller->setProxy(m_tsProxy.get());
|
||||
|
@ -333,14 +333,6 @@ export class EngineImpl implements Engine {
|
||||
const tilingArea = this.getTilingArea(workingArea, layout);
|
||||
|
||||
const visibleWindows = this.windows.visibleWindowsOn(screenSurface);
|
||||
this.log.log([
|
||||
"arrangeScreen",
|
||||
{
|
||||
layout,
|
||||
screenSurface,
|
||||
visibles: visibleWindows.length,
|
||||
},
|
||||
]);
|
||||
|
||||
// Set correct window state for new windows
|
||||
visibleWindows.forEach((win: EngineWindow) => {
|
||||
|
Loading…
Reference in New Issue
Block a user