2022-03-16 21:37:21 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
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;
|
|
|
|
|
2024-12-07 18:51:18 +01:00
|
|
|
enum eManagersInitStage : uint8_t {
|
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";
|
|
|
|
|
2024-10-26 03:06:13 +02:00
|
|
|
std::vector<PHLMONITOR> m_vMonitors;
|
|
|
|
std::vector<PHLMONITOR> m_vRealMonitors; // for all monitors, even those turned off
|
2024-08-08 21:01:50 +02:00
|
|
|
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;
|
2024-10-26 03:06:13 +02:00
|
|
|
PHLMONITORREF m_pLastMonitor;
|
2024-08-08 21:01:50 +02:00
|
|
|
|
|
|
|
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;
|
2024-10-20 00:03:29 +02:00
|
|
|
PHLMONITORREF m_pUnsafeOutput; // fallback output for the unsafe state
|
2024-08-08 21:01:50 +02:00
|
|
|
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-10-20 00:03:29 +02:00
|
|
|
PHLMONITOR getMonitorFromID(const MONITORID&);
|
|
|
|
PHLMONITOR getMonitorFromName(const std::string&);
|
|
|
|
PHLMONITOR getMonitorFromDesc(const std::string&);
|
|
|
|
PHLMONITOR getMonitorFromCursor();
|
|
|
|
PHLMONITOR getMonitorFromVector(const Vector2D&);
|
2024-06-08 10:07:59 +02:00
|
|
|
void removeWindowFromVectorSafe(PHLWINDOW);
|
|
|
|
void focusWindow(PHLWINDOW, SP<CWLSurfaceResource> pSurface = nullptr);
|
|
|
|
void focusSurface(SP<CWLSurfaceResource>, PHLWINDOW pWindowOwner = nullptr);
|
2024-10-20 00:03:29 +02:00
|
|
|
bool monitorExists(PHLMONITOR);
|
2024-06-08 10:07:59 +02:00
|
|
|
PHLWINDOW vectorToWindowUnified(const Vector2D&, uint8_t properties, PHLWINDOW pIgnoreWindow = nullptr);
|
|
|
|
SP<CWLSurfaceResource> vectorToLayerSurface(const Vector2D&, std::vector<PHLLSREF>*, Vector2D*, PHLLS*);
|
2024-10-20 00:03:29 +02:00
|
|
|
SP<CWLSurfaceResource> vectorToLayerPopupSurface(const Vector2D&, PHLMONITOR monitor, Vector2D*, PHLLS*);
|
2024-06-08 10:07:59 +02:00
|
|
|
SP<CWLSurfaceResource> vectorWindowToSurface(const Vector2D&, PHLWINDOW, Vector2D& sl);
|
|
|
|
Vector2D vectorToSurfaceLocal(const Vector2D&, PHLWINDOW, SP<CWLSurfaceResource>);
|
2024-10-20 00:03:29 +02:00
|
|
|
PHLMONITOR getMonitorFromOutput(SP<Aquamarine::IOutput>);
|
|
|
|
PHLMONITOR getRealMonitorFromOutput(SP<Aquamarine::IOutput>);
|
2024-06-08 10:07:59 +02:00
|
|
|
PHLWINDOW getWindowFromSurface(SP<CWLSurfaceResource>);
|
|
|
|
PHLWINDOW getWindowFromHandle(uint32_t);
|
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();
|
|
|
|
PHLWINDOW getUrgentWindow();
|
|
|
|
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&);
|
2024-10-20 00:03:29 +02:00
|
|
|
bool isPointOnReservedArea(const Vector2D& point, const PHLMONITOR monitor = nullptr);
|
|
|
|
PHLMONITOR getMonitorInDirection(const char&);
|
|
|
|
PHLMONITOR getMonitorInDirection(PHLMONITOR, const char&);
|
2024-06-08 10:07:59 +02:00
|
|
|
void updateAllWindowsAnimatedDecorationValues();
|
|
|
|
void updateWindowAnimatedDecorationValues(PHLWINDOW);
|
2024-08-08 21:01:50 +02:00
|
|
|
MONITORID getNextAvailableMonitorID(std::string const& name);
|
2024-10-20 00:03:29 +02:00
|
|
|
void moveWorkspaceToMonitor(PHLWORKSPACE, PHLMONITOR, bool noWarpCursor = false);
|
|
|
|
void swapActiveWorkspaces(PHLMONITOR, PHLMONITOR);
|
|
|
|
PHLMONITOR 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);
|
2024-12-07 18:51:18 +01:00
|
|
|
void setWindowFullscreenState(const PHLWINDOW PWINDOW, const SFullscreenState state);
|
2024-07-31 19:55:52 +02:00
|
|
|
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-10-20 00:03:29 +02:00
|
|
|
void scheduleFrameForMonitor(PHLMONITOR, 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
|
|
|
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-10-20 00:03:29 +02:00
|
|
|
void setActiveMonitor(PHLMONITOR);
|
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();
|
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;
|