2022-03-16 21:37:21 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
2022-03-17 16:56:33 +01:00
|
|
|
#include <deque>
|
2022-03-18 22:35:51 +01:00
|
|
|
#include <list>
|
2024-06-19 18:36:40 +02:00
|
|
|
#include <sys/resource.h>
|
2022-03-16 21:37:21 +01:00
|
|
|
|
|
|
|
#include "defines.hpp"
|
|
|
|
#include "debug/Log.hpp"
|
|
|
|
#include "events/Events.hpp"
|
2022-03-17 15:53:45 +01:00
|
|
|
#include "config/ConfigManager.hpp"
|
2022-03-18 20:03:39 +01:00
|
|
|
#include "managers/ThreadManager.hpp"
|
|
|
|
#include "managers/XWaylandManager.hpp"
|
2022-06-09 12:46:55 +02:00
|
|
|
#include "managers/input/InputManager.hpp"
|
2022-03-19 15:59:53 +01:00
|
|
|
#include "managers/LayoutManager.hpp"
|
2022-03-19 17:48:18 +01:00
|
|
|
#include "managers/KeybindManager.hpp"
|
2022-03-23 22:01:59 +01:00
|
|
|
#include "managers/AnimationManager.hpp"
|
2022-05-24 19:42:43 +02:00
|
|
|
#include "managers/EventManager.hpp"
|
2022-12-05 18:05:15 +01:00
|
|
|
#include "managers/ProtocolManager.hpp"
|
2023-02-03 12:58:55 +01:00
|
|
|
#include "managers/SessionLockManager.hpp"
|
2023-02-19 21:54:53 +01:00
|
|
|
#include "managers/HookSystemManager.hpp"
|
2022-05-28 17:32:19 +02:00
|
|
|
#include "debug/HyprDebugOverlay.hpp"
|
2023-02-27 13:32:38 +01:00
|
|
|
#include "debug/HyprNotificationOverlay.hpp"
|
2022-03-17 16:56:33 +01:00
|
|
|
#include "helpers/Monitor.hpp"
|
2024-02-29 14:03:38 +01:00
|
|
|
#include "desktop/Workspace.hpp"
|
2024-03-20 02:44:51 +01:00
|
|
|
#include "desktop/Window.hpp"
|
2022-03-17 20:22:29 +01:00
|
|
|
#include "render/Renderer.hpp"
|
2022-04-04 19:44:25 +02:00
|
|
|
#include "render/OpenGL.hpp"
|
2022-04-08 21:40:41 +02:00
|
|
|
#include "hyprerror/HyprError.hpp"
|
2023-02-27 13:32:38 +01:00
|
|
|
#include "plugins/PluginSystem.hpp"
|
2023-09-29 17:38:13 +02:00
|
|
|
#include "helpers/Watchdog.hpp"
|
2022-03-20 15:55:47 +01:00
|
|
|
|
2024-07-21 13:09:54 +02:00
|
|
|
#include <aquamarine/backend/Backend.hpp>
|
|
|
|
#include <aquamarine/output/Output.hpp>
|
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
class CWLSurfaceResource;
|
|
|
|
|
2023-12-06 23:54:56 +01:00
|
|
|
enum eManagersInitStage {
|
2023-03-05 14:37:21 +01:00
|
|
|
STAGE_PRIORITY = 0,
|
2024-06-08 10:07:59 +02:00
|
|
|
STAGE_BASICINIT,
|
2023-03-05 14:37:21 +01:00
|
|
|
STAGE_LATE
|
|
|
|
};
|
|
|
|
|
2022-03-16 21:37:21 +01:00
|
|
|
class CCompositor {
|
2022-12-16 18:17:31 +01:00
|
|
|
public:
|
2022-03-16 21:37:21 +01:00
|
|
|
CCompositor();
|
|
|
|
~CCompositor();
|
|
|
|
|
2024-08-08 21:01:50 +02:00
|
|
|
wl_display* m_sWLDisplay;
|
|
|
|
wl_event_loop* m_sWLEventLoop;
|
|
|
|
int m_iDRMFD = -1;
|
|
|
|
bool m_bInitialized = false;
|
|
|
|
SP<Aquamarine::CBackend> m_pAqBackend;
|
|
|
|
|
|
|
|
std::string m_szHyprTempDataRoot = "";
|
|
|
|
|
|
|
|
std::string m_szWLDisplaySocket = "";
|
|
|
|
std::string m_szInstanceSignature = "";
|
|
|
|
std::string m_szInstancePath = "";
|
|
|
|
std::string m_szCurrentSplash = "error";
|
|
|
|
|
|
|
|
std::vector<SP<CMonitor>> m_vMonitors;
|
|
|
|
std::vector<SP<CMonitor>> m_vRealMonitors; // for all monitors, even those turned off
|
|
|
|
std::vector<PHLWINDOW> m_vWindows;
|
|
|
|
std::vector<PHLLS> m_vLayers;
|
|
|
|
std::vector<PHLWORKSPACE> m_vWorkspaces;
|
|
|
|
std::vector<PHLWINDOWREF> m_vWindowsFadingOut;
|
|
|
|
std::vector<PHLLSREF> m_vSurfacesFadingOut;
|
|
|
|
|
|
|
|
std::unordered_map<std::string, MONITORID> m_mMonitorIDMap;
|
|
|
|
|
|
|
|
void initServer(std::string socketName, int socketFd);
|
|
|
|
void startCompositor();
|
|
|
|
void stopCompositor();
|
|
|
|
void cleanup();
|
|
|
|
void createLockFile();
|
|
|
|
void removeLockFile();
|
|
|
|
void bumpNofile();
|
|
|
|
void restoreNofile();
|
|
|
|
|
|
|
|
WP<CWLSurfaceResource> m_pLastFocus;
|
|
|
|
PHLWINDOWREF m_pLastWindow;
|
|
|
|
WP<CMonitor> m_pLastMonitor;
|
|
|
|
|
|
|
|
std::vector<PHLWINDOWREF> m_vWindowFocusHistory; // first element is the most recently focused.
|
|
|
|
|
|
|
|
bool m_bReadyToProcess = false;
|
|
|
|
bool m_bSessionActive = true;
|
|
|
|
bool m_bDPMSStateON = true;
|
|
|
|
bool m_bUnsafeState = false; // unsafe state is when there is no monitors.
|
|
|
|
bool m_bNextIsUnsafe = false;
|
|
|
|
CMonitor* m_pUnsafeOutput = nullptr; // fallback output for the unsafe state
|
|
|
|
bool m_bIsShuttingDown = false;
|
2024-09-07 21:54:33 +02:00
|
|
|
bool m_bFinalRequests = false;
|
2024-08-15 18:14:48 +02:00
|
|
|
bool m_bDesktopEnvSet = false;
|
2024-09-05 18:26:46 +02:00
|
|
|
bool m_bEnableXwayland = true;
|
2022-04-28 17:57:24 +02:00
|
|
|
|
2022-03-17 20:22:29 +01:00
|
|
|
// ------------------------------------------------- //
|
|
|
|
|
2024-08-08 21:01:50 +02:00
|
|
|
CMonitor* getMonitorFromID(const MONITORID&);
|
2024-06-08 10:07:59 +02:00
|
|
|
CMonitor* getMonitorFromName(const std::string&);
|
|
|
|
CMonitor* getMonitorFromDesc(const std::string&);
|
|
|
|
CMonitor* getMonitorFromCursor();
|
|
|
|
CMonitor* getMonitorFromVector(const Vector2D&);
|
|
|
|
void removeWindowFromVectorSafe(PHLWINDOW);
|
|
|
|
void focusWindow(PHLWINDOW, SP<CWLSurfaceResource> pSurface = nullptr);
|
|
|
|
void focusSurface(SP<CWLSurfaceResource>, PHLWINDOW pWindowOwner = nullptr);
|
|
|
|
bool monitorExists(CMonitor*);
|
|
|
|
PHLWINDOW vectorToWindowUnified(const Vector2D&, uint8_t properties, PHLWINDOW pIgnoreWindow = nullptr);
|
|
|
|
SP<CWLSurfaceResource> vectorToLayerSurface(const Vector2D&, std::vector<PHLLSREF>*, Vector2D*, PHLLS*);
|
|
|
|
SP<CWLSurfaceResource> vectorToLayerPopupSurface(const Vector2D&, CMonitor* monitor, Vector2D*, PHLLS*);
|
|
|
|
SP<CWLSurfaceResource> vectorWindowToSurface(const Vector2D&, PHLWINDOW, Vector2D& sl);
|
|
|
|
Vector2D vectorToSurfaceLocal(const Vector2D&, PHLWINDOW, SP<CWLSurfaceResource>);
|
2024-07-21 13:09:54 +02:00
|
|
|
CMonitor* getMonitorFromOutput(SP<Aquamarine::IOutput>);
|
|
|
|
CMonitor* getRealMonitorFromOutput(SP<Aquamarine::IOutput>);
|
2024-06-08 10:07:59 +02:00
|
|
|
PHLWINDOW getWindowFromSurface(SP<CWLSurfaceResource>);
|
|
|
|
PHLWINDOW getWindowFromHandle(uint32_t);
|
|
|
|
bool isWorkspaceVisible(PHLWORKSPACE);
|
2024-06-11 22:56:35 +02:00
|
|
|
bool isWorkspaceVisibleNotCovered(PHLWORKSPACE);
|
2024-08-08 21:01:50 +02:00
|
|
|
PHLWORKSPACE getWorkspaceByID(const WORKSPACEID&);
|
2024-06-08 10:07:59 +02:00
|
|
|
PHLWORKSPACE getWorkspaceByName(const std::string&);
|
|
|
|
PHLWORKSPACE getWorkspaceByString(const std::string&);
|
|
|
|
void sanityCheckWorkspaces();
|
2024-08-08 21:01:50 +02:00
|
|
|
void updateWorkspaceWindowDecos(const WORKSPACEID&);
|
|
|
|
void updateWorkspaceWindowData(const WORKSPACEID&);
|
|
|
|
int getWindowsOnWorkspace(const WORKSPACEID& id, std::optional<bool> onlyTiled = {}, std::optional<bool> onlyVisible = {});
|
|
|
|
int getGroupsOnWorkspace(const WORKSPACEID& id, std::optional<bool> onlyTiled = {}, std::optional<bool> onlyVisible = {});
|
2024-06-08 10:07:59 +02:00
|
|
|
PHLWINDOW getUrgentWindow();
|
2024-08-08 21:01:50 +02:00
|
|
|
bool hasUrgentWindowOnWorkspace(const WORKSPACEID&);
|
|
|
|
PHLWINDOW getFirstWindowOnWorkspace(const WORKSPACEID&);
|
|
|
|
PHLWINDOW getTopLeftWindowOnWorkspace(const WORKSPACEID&);
|
|
|
|
PHLWINDOW getFullscreenWindowOnWorkspace(const WORKSPACEID&);
|
2024-06-08 10:07:59 +02:00
|
|
|
bool isWindowActive(PHLWINDOW);
|
|
|
|
void changeWindowZOrder(PHLWINDOW, bool);
|
2024-08-08 21:01:50 +02:00
|
|
|
void cleanupFadingOut(const MONITORID& monid);
|
2024-06-08 10:07:59 +02:00
|
|
|
PHLWINDOW getWindowInDirection(PHLWINDOW, char);
|
|
|
|
PHLWINDOW getNextWindowOnWorkspace(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {});
|
|
|
|
PHLWINDOW getPrevWindowOnWorkspace(PHLWINDOW, bool focusableOnly = false, std::optional<bool> floating = {});
|
2024-08-08 21:01:50 +02:00
|
|
|
WORKSPACEID getNextAvailableNamedWorkspace();
|
2024-06-08 10:07:59 +02:00
|
|
|
bool isPointOnAnyMonitor(const Vector2D&);
|
|
|
|
bool isPointOnReservedArea(const Vector2D& point, const CMonitor* monitor = nullptr);
|
|
|
|
CMonitor* getMonitorInDirection(const char&);
|
|
|
|
CMonitor* getMonitorInDirection(CMonitor*, const char&);
|
|
|
|
void updateAllWindowsAnimatedDecorationValues();
|
2024-08-08 21:01:50 +02:00
|
|
|
void updateWorkspaceWindows(const WORKSPACEID& id);
|
2024-06-08 10:07:59 +02:00
|
|
|
void updateWindowAnimatedDecorationValues(PHLWINDOW);
|
2024-08-08 21:01:50 +02:00
|
|
|
MONITORID getNextAvailableMonitorID(std::string const& name);
|
2024-06-08 10:07:59 +02:00
|
|
|
void moveWorkspaceToMonitor(PHLWORKSPACE, CMonitor*, bool noWarpCursor = false);
|
|
|
|
void swapActiveWorkspaces(CMonitor*, CMonitor*);
|
|
|
|
CMonitor* getMonitorFromString(const std::string&);
|
2024-08-08 21:01:50 +02:00
|
|
|
bool workspaceIDOutOfBounds(const WORKSPACEID&);
|
2024-07-31 19:55:52 +02:00
|
|
|
void setWindowFullscreenInternal(const PHLWINDOW PWINDOW, const eFullscreenMode MODE);
|
|
|
|
void setWindowFullscreenClient(const PHLWINDOW PWINDOW, const eFullscreenMode MODE);
|
|
|
|
void setWindowFullscreenState(const PHLWINDOW PWINDOW, const sFullscreenState state);
|
|
|
|
void changeWindowFullscreenModeInternal(const PHLWINDOW PWINDOW, const eFullscreenMode MODE, const bool ON);
|
|
|
|
void changeWindowFullscreenModeClient(const PHLWINDOW PWINDOW, const eFullscreenMode MODE, const bool ON);
|
2024-06-08 10:07:59 +02:00
|
|
|
void updateFullscreenFadeOnWorkspace(PHLWORKSPACE);
|
|
|
|
PHLWINDOW getX11Parent(PHLWINDOW);
|
2024-07-21 13:09:54 +02:00
|
|
|
void scheduleFrameForMonitor(CMonitor*, Aquamarine::IOutput::scheduleFrameReason reason = Aquamarine::IOutput::AQ_SCHEDULE_CLIENT_UNKNOWN);
|
2024-06-08 10:07:59 +02:00
|
|
|
void addToFadingOutSafe(PHLLS);
|
2024-06-12 22:57:06 +02:00
|
|
|
void removeFromFadingOutSafe(PHLLS);
|
2024-06-08 10:07:59 +02:00
|
|
|
void addToFadingOutSafe(PHLWINDOW);
|
|
|
|
PHLWINDOW getWindowByRegex(const std::string&);
|
|
|
|
void warpCursorTo(const Vector2D&, bool force = false);
|
|
|
|
PHLLS getLayerSurfaceFromSurface(SP<CWLSurfaceResource>);
|
|
|
|
void closeWindow(PHLWINDOW);
|
|
|
|
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
|
2024-08-08 21:01:50 +02:00
|
|
|
void forceReportSizesToWindowsOnWorkspace(const WORKSPACEID&);
|
|
|
|
PHLWORKSPACE createNewWorkspace(const WORKSPACEID&, const MONITORID&, const std::string& name = "",
|
2024-08-26 12:25:52 +02:00
|
|
|
bool isEmpty = true); // will be deleted next frame if left empty and unfocused!
|
2024-08-08 21:01:50 +02:00
|
|
|
void renameWorkspace(const WORKSPACEID&, const std::string& name = "");
|
2024-06-08 10:07:59 +02:00
|
|
|
void setActiveMonitor(CMonitor*);
|
2024-08-08 21:01:50 +02:00
|
|
|
bool isWorkspaceSpecial(const WORKSPACEID&);
|
|
|
|
WORKSPACEID getNewSpecialID();
|
2024-06-08 10:07:59 +02:00
|
|
|
void performUserChecks();
|
|
|
|
void moveWindowToWorkspaceSafe(PHLWINDOW pWindow, PHLWORKSPACE pWorkspace);
|
|
|
|
PHLWINDOW getForceFocus();
|
|
|
|
void arrangeMonitors();
|
|
|
|
void enterUnsafeState();
|
|
|
|
void leaveUnsafeState();
|
|
|
|
void setPreferredScaleForSurface(SP<CWLSurfaceResource> pSurface, double scale);
|
|
|
|
void setPreferredTransformForSurface(SP<CWLSurfaceResource> pSurface, wl_output_transform transform);
|
|
|
|
void updateSuspendedStates();
|
|
|
|
PHLWINDOW windowForCPointer(CWindow*);
|
2024-07-21 13:09:54 +02:00
|
|
|
void onNewMonitor(SP<Aquamarine::IOutput> output);
|
2024-06-08 10:07:59 +02:00
|
|
|
|
|
|
|
std::string explicitConfigPath;
|
2022-12-16 18:17:31 +01:00
|
|
|
|
|
|
|
private:
|
2024-06-06 20:27:09 +02:00
|
|
|
void initAllSignals();
|
|
|
|
void removeAllSignals();
|
|
|
|
void cleanEnvironment();
|
|
|
|
void setRandomSplash();
|
|
|
|
void initManagers(eManagersInitStage stage);
|
|
|
|
void prepareFallbackOutput();
|
|
|
|
|
2024-06-19 18:36:40 +02:00
|
|
|
uint64_t m_iHyprlandPID = 0;
|
|
|
|
wl_event_source* m_critSigSource = nullptr;
|
|
|
|
rlimit m_sOriginalNofile = {0};
|
2022-03-16 21:37:21 +01:00
|
|
|
};
|
|
|
|
|
2022-03-20 13:37:07 +01:00
|
|
|
inline std::unique_ptr<CCompositor> g_pCompositor;
|