chore: cxx arrange draft

This commit is contained in:
Mikhail Zolotukhin 2022-03-27 16:04:08 +03:00 committed by Genda
parent 6a61242a5f
commit 2051051d20
6 changed files with 57 additions and 16 deletions

View File

@ -25,30 +25,33 @@ void Engine::removeWindow(PlasmaApi::Client 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);
}
// auto screenSurfaces = [this]() -> std::vector<Surface> {
// auto currentDesktop = m_plasmaApi.workspace().currentDesktop();
// auto currentActivity = m_plasmaApi.workspace().currentActivity();
// auto result = std::vector<Surface>(1, Surface(currentDesktop, 0, currentActivity));
//
// // Add from additional screens
// for (auto screen = 1; screen < m_plasmaApi.workspace().numScreens(); screen++) {
// result.push_back(Surface(currentDesktop, screen, currentActivity));
// }
//
// return result;
// };
//
// for (auto &surface : screenSurfaces()) {
// arrangeWindowsOnSurface(surface);
// }
}
void Engine::arrangeWindowsOnSurface(const Surface &surface)
{
auto layout = "Layout";
// auto &layout = m_activeLayouts.layoutOnSurface(surface);
auto workingArea = QRect();
auto tilingArea = QRect();
auto visibleWindows = std::vector<Window>();
auto visibleWindows = m_windows.visibleWindowsOn(surface);
auto windowsThatCanBeTiled = std::vector<Window>();
// auto windowsThatCanBeTiled = std::vector<Window>();
// Maximize sole tile if enabled or apply the current layout as expected
// ...

View File

@ -3,6 +3,7 @@
#pragma once
#include "engine/layout/layout_list.hpp"
#include "engine/surface.hpp"
#include "plasma-api/api.hpp"
#include "plasma-api/client.hpp"
@ -27,6 +28,7 @@ private:
void arrangeWindowsOnSurface(const Surface &);
WindowsList m_windows{};
LayoutList m_activeLayouts{};
PlasmaApi::Api &m_plasmaApi;
};
}

View File

@ -12,6 +12,24 @@ Surface::Surface(int desktop, int screen, const QString &activity)
{
}
bool Surface::operator<(const Surface &rhs) const
{
if (m_screen < rhs.m_screen) {
return true;
} else if (m_screen > rhs.m_screen) {
return false;
}
if (m_desktop < rhs.m_desktop) {
return true;
} else if (m_desktop > rhs.m_desktop) {
return false;
}
// Same screen, same desktop, different activities
return m_activity < rhs.m_activity;
}
int Surface::desktop() const
{
return m_desktop;

View File

@ -10,6 +10,8 @@ namespace Bismuth
struct Surface {
Surface(int desktop, int screen, const QString &activity);
bool operator<(const Surface &) const;
int desktop() const;
int screen() const;
QString activity() const;

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: MIT
#include "windows_list.hpp"
#include "engine/surface.hpp"
#include "logger.hpp"
namespace Bismuth
@ -16,4 +17,16 @@ void WindowsList::remove(PlasmaApi::Client client)
{
m_windowMap.erase(client);
}
std::vector<Window> WindowsList::visibleWindowsOn(const Surface &surface)
{
auto result = std::vector<Window>();
for (auto [_, window] : m_windowMap) {
if (window.visibleOn(surface)) {
result.push_back(window);
}
}
return result;
}
}

View File

@ -3,6 +3,7 @@
#pragma once
#include "engine/surface.hpp"
#include "plasma-api/client.hpp"
#include "window.hpp"
@ -14,6 +15,8 @@ public:
void add(PlasmaApi::Client);
void remove(PlasmaApi::Client);
std::vector<Window> visibleWindowsOn(const Surface &surface);
private:
std::map<PlasmaApi::Client, Window> m_windowMap{};
};