2022-03-20 15:55:47 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
2024-02-29 13:03:38 +00:00
|
|
|
#include "../helpers/AnimatedVariable.hpp"
|
2023-08-07 13:35:19 +02:00
|
|
|
#include <string>
|
2024-04-02 20:32:39 +01:00
|
|
|
#include "DesktopTypes.hpp"
|
2024-06-23 16:43:53 +03:00
|
|
|
#include "../helpers/MiscFunctions.hpp"
|
2025-06-26 09:32:44 -07:00
|
|
|
#include "../helpers/signal/Signal.hpp"
|
2022-03-20 15:55:47 +01:00
|
|
|
|
2023-10-22 19:11:03 -03:00
|
|
|
enum eFullscreenMode : int8_t {
|
2024-07-31 17:55:52 +00:00
|
|
|
FSMODE_NONE = 0,
|
|
|
|
|
FSMODE_MAXIMIZED = 1 << 0,
|
|
|
|
|
FSMODE_FULLSCREEN = 1 << 1,
|
|
|
|
|
FSMODE_MAX = (1 << 2) - 1
|
2022-05-29 15:44:30 +02:00
|
|
|
};
|
|
|
|
|
|
2022-08-31 17:02:44 +02:00
|
|
|
class CWindow;
|
|
|
|
|
|
2022-04-11 19:51:37 +02:00
|
|
|
class CWorkspace {
|
2022-12-16 17:17:31 +00:00
|
|
|
public:
|
2024-10-27 18:45:38 +00:00
|
|
|
static PHLWORKSPACE create(WORKSPACEID id, PHLMONITOR monitor, std::string name, bool special = false, bool isEmpty = true);
|
2024-04-02 20:32:39 +01:00
|
|
|
// use create() don't use this
|
2024-10-27 18:45:38 +00:00
|
|
|
CWorkspace(WORKSPACEID id, PHLMONITOR monitor, std::string name, bool special = false, bool isEmpty = true);
|
2022-04-11 19:51:37 +02:00
|
|
|
~CWorkspace();
|
|
|
|
|
|
2025-06-26 09:32:44 -07:00
|
|
|
WP<CWorkspace> m_self;
|
|
|
|
|
|
2022-04-21 16:38:48 +02:00
|
|
|
// Workspaces ID-based have IDs > 0
|
|
|
|
|
// and workspaces name-based have IDs starting with -1337
|
2025-04-25 02:37:12 +02:00
|
|
|
WORKSPACEID m_id = WORKSPACE_INVALID;
|
|
|
|
|
std::string m_name = "";
|
|
|
|
|
PHLMONITORREF m_monitor;
|
2023-03-13 15:19:25 +00:00
|
|
|
|
2025-04-25 02:37:12 +02:00
|
|
|
bool m_hasFullscreenWindow = false;
|
|
|
|
|
eFullscreenMode m_fullscreenMode = FSMODE_NONE;
|
2022-04-11 19:51:37 +02:00
|
|
|
|
2025-01-11 19:05:53 +03:00
|
|
|
wl_array m_wlrCoordinateArr;
|
2022-05-12 11:27:31 +02:00
|
|
|
|
|
|
|
|
// for animations
|
2025-04-25 02:37:12 +02:00
|
|
|
PHLANIMVAR<Vector2D> m_renderOffset;
|
|
|
|
|
PHLANIMVAR<float> m_alpha;
|
|
|
|
|
bool m_forceRendering = false;
|
2022-05-16 23:13:32 +02:00
|
|
|
|
2024-04-03 10:09:42 +01:00
|
|
|
// allows damage to propagate.
|
2025-04-25 02:37:12 +02:00
|
|
|
bool m_visible = false;
|
2024-04-03 10:09:42 +01:00
|
|
|
|
2022-05-31 14:01:00 +02:00
|
|
|
// "scratchpad"
|
2025-04-25 02:37:12 +02:00
|
|
|
bool m_isSpecialWorkspace = false;
|
2022-05-31 14:01:00 +02:00
|
|
|
|
2022-08-31 17:02:44 +02:00
|
|
|
// last window
|
2025-04-25 02:37:12 +02:00
|
|
|
PHLWINDOWREF m_lastFocusedWindow;
|
2022-08-31 17:02:44 +02:00
|
|
|
|
2022-05-26 19:05:32 +02:00
|
|
|
// user-set
|
2025-04-25 02:37:12 +02:00
|
|
|
bool m_defaultFloating = false;
|
|
|
|
|
bool m_defaultPseudo = false;
|
2023-04-13 21:09:50 +01:00
|
|
|
|
2023-05-03 15:15:56 +01:00
|
|
|
// last monitor (used on reconnect)
|
2025-04-25 02:37:12 +02:00
|
|
|
std::string m_lastMonitor = "";
|
2022-05-26 19:05:32 +02:00
|
|
|
|
2025-04-25 02:37:12 +02:00
|
|
|
bool m_wasCreatedEmpty = true;
|
2024-05-11 20:03:32 -03:00
|
|
|
|
2024-04-02 20:32:39 +01:00
|
|
|
// Inert: destroyed and invalid. If this is true, release the ptr you have.
|
2024-06-23 00:52:42 +03:00
|
|
|
bool inert();
|
2024-10-27 18:45:38 +00:00
|
|
|
MONITORID monitorID();
|
2024-06-23 00:52:42 +03:00
|
|
|
PHLWINDOW getLastFocusedWindow();
|
|
|
|
|
void rememberPrevWorkspace(const PHLWORKSPACE& prevWorkspace);
|
|
|
|
|
std::string getConfigName();
|
|
|
|
|
bool matchesStaticSelector(const std::string& selector);
|
|
|
|
|
void markInert();
|
2025-01-11 19:05:53 +03:00
|
|
|
SWorkspaceIDName getPrevWorkspaceIDName() const;
|
2024-11-22 16:01:02 +00:00
|
|
|
void updateWindowDecos();
|
|
|
|
|
void updateWindowData();
|
2025-02-08 01:45:13 +01:00
|
|
|
int getWindows(std::optional<bool> onlyTiled = {}, std::optional<bool> onlyPinned = {}, std::optional<bool> onlyVisible = {});
|
|
|
|
|
int getGroups(std::optional<bool> onlyTiled = {}, std::optional<bool> onlyPinned = {}, std::optional<bool> onlyVisible = {});
|
2024-11-22 16:01:02 +00:00
|
|
|
bool hasUrgentWindow();
|
|
|
|
|
PHLWINDOW getFirstWindow();
|
|
|
|
|
PHLWINDOW getTopLeftWindow();
|
|
|
|
|
PHLWINDOW getFullscreenWindow();
|
|
|
|
|
bool isVisible();
|
|
|
|
|
bool isVisibleNotCovered();
|
|
|
|
|
void rename(const std::string& name = "");
|
|
|
|
|
void forceReportSizesToWindows();
|
|
|
|
|
void updateWindows();
|
2025-07-27 18:46:23 +02:00
|
|
|
void setPersistent(bool persistent);
|
|
|
|
|
bool isPersistent();
|
2024-04-02 20:32:39 +01:00
|
|
|
|
2025-06-26 09:32:44 -07:00
|
|
|
struct {
|
2025-07-08 09:56:40 -07:00
|
|
|
CSignalT<> destroy;
|
|
|
|
|
CSignalT<> renamed;
|
|
|
|
|
CSignalT<> monitorChanged;
|
|
|
|
|
CSignalT<> activeChanged;
|
2025-06-26 09:32:44 -07:00
|
|
|
} m_events;
|
|
|
|
|
|
2024-04-02 12:10:03 +01:00
|
|
|
private:
|
2025-01-11 19:05:53 +03:00
|
|
|
void init(PHLWORKSPACE self);
|
|
|
|
|
// Previous workspace ID and name is stored during a workspace change, allowing travel
|
|
|
|
|
// to the previous workspace.
|
2025-04-25 02:37:12 +02:00
|
|
|
SWorkspaceIDName m_prevWorkspace;
|
2024-04-02 20:32:39 +01:00
|
|
|
|
2025-04-25 02:37:12 +02:00
|
|
|
SP<HOOK_CALLBACK_FN> m_focusedWindowHook;
|
|
|
|
|
bool m_inert = true;
|
2025-07-27 18:46:23 +02:00
|
|
|
|
|
|
|
|
SP<CWorkspace> m_selfPersistent; // for persistent workspaces.
|
|
|
|
|
bool m_persistent = false;
|
2022-12-10 22:59:16 +01:00
|
|
|
};
|
2024-04-02 20:32:39 +01:00
|
|
|
|
|
|
|
|
inline bool valid(const PHLWORKSPACE& ref) {
|
|
|
|
|
if (!ref)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
return !ref->inert();
|
|
|
|
|
}
|