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>
|
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
|
|
|
|
2023-12-06 23:54:56 +01:00
|
|
|
enum eManagersInitStage {
|
2023-03-05 14:37:21 +01:00
|
|
|
STAGE_PRIORITY = 0,
|
|
|
|
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();
|
|
|
|
|
|
|
|
// ------------------ WLR BASICS ------------------ //
|
2024-04-25 15:32:35 +02:00
|
|
|
wl_display* m_sWLDisplay;
|
|
|
|
wl_event_loop* m_sWLEventLoop;
|
|
|
|
wlr_backend* m_sWLRBackend;
|
|
|
|
wlr_session* m_sWLRSession;
|
|
|
|
wlr_renderer* m_sWLRRenderer;
|
|
|
|
wlr_allocator* m_sWLRAllocator;
|
|
|
|
wlr_compositor* m_sWLRCompositor;
|
|
|
|
wlr_subcompositor* m_sWLRSubCompositor;
|
|
|
|
wlr_data_device_manager* m_sWLRDataDevMgr;
|
|
|
|
wlr_drm* m_sWRLDRM;
|
|
|
|
wlr_drm_lease_v1_manager* m_sWRLDRMLeaseMgr;
|
|
|
|
wlr_xdg_activation_v1* m_sWLRXDGActivation;
|
|
|
|
wlr_output_layout* m_sWLROutputLayout;
|
|
|
|
wlr_idle_notifier_v1* m_sWLRIdleNotifier;
|
|
|
|
wlr_layer_shell_v1* m_sWLRLayerShell;
|
|
|
|
wlr_xdg_shell* m_sWLRXDGShell;
|
|
|
|
wlr_cursor* m_sWLRCursor;
|
|
|
|
wlr_virtual_keyboard_manager_v1* m_sWLRVKeyboardMgr;
|
|
|
|
wlr_output_manager_v1* m_sWLROutputMgr;
|
|
|
|
wlr_presentation* m_sWLRPresentation;
|
|
|
|
wlr_egl* m_sWLREGL;
|
|
|
|
int m_iDRMFD;
|
|
|
|
wlr_server_decoration_manager* m_sWLRServerDecoMgr;
|
|
|
|
wlr_virtual_pointer_manager_v1* m_sWLRVirtPtrMgr;
|
|
|
|
wlr_tablet_manager_v2* m_sWLRTabletManager;
|
|
|
|
wlr_xdg_foreign_registry* m_sWLRForeignRegistry;
|
|
|
|
wlr_input_method_manager_v2* m_sWLRIMEMgr;
|
|
|
|
wlr_xdg_activation_v1* m_sWLRActivation;
|
|
|
|
wlr_linux_dmabuf_v1* m_sWLRLinuxDMABuf;
|
|
|
|
wlr_backend* m_sWLRHeadlessBackend;
|
|
|
|
wlr_session_lock_manager_v1* m_sWLRSessionLockMgr;
|
2022-03-16 21:37:21 +01:00
|
|
|
// ------------------------------------------------- //
|
|
|
|
|
2024-04-28 23:25:24 +02:00
|
|
|
std::string m_szHyprTempDataRoot = "";
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
std::string m_szWLDisplaySocket = "";
|
|
|
|
std::string m_szInstanceSignature = "";
|
2024-04-28 23:25:24 +02:00
|
|
|
std::string m_szInstancePath = "";
|
2022-12-16 18:17:31 +01:00
|
|
|
std::string m_szCurrentSplash = "error";
|
2022-03-16 21:37:21 +01:00
|
|
|
|
2024-04-27 13:43:12 +02:00
|
|
|
std::vector<SP<CMonitor>> m_vMonitors;
|
|
|
|
std::vector<SP<CMonitor>> m_vRealMonitors; // for all monitors, even those turned off
|
|
|
|
std::vector<PHLWINDOW> m_vWindows;
|
2024-04-02 21:32:39 +02:00
|
|
|
std::vector<PHLWORKSPACE> m_vWorkspaces;
|
2024-04-27 13:43:12 +02:00
|
|
|
std::vector<PHLWINDOWREF> m_vWindowsFadingOut;
|
2022-12-16 18:17:31 +01:00
|
|
|
std::vector<SLayerSurface*> m_vSurfacesFadingOut;
|
2022-03-16 21:37:21 +01:00
|
|
|
|
2023-07-24 18:50:17 +02:00
|
|
|
std::unordered_map<std::string, uint64_t> m_mMonitorIDMap;
|
2023-07-09 23:08:40 +02:00
|
|
|
|
2023-03-05 14:37:21 +01:00
|
|
|
void initServer();
|
2022-12-16 18:17:31 +01:00
|
|
|
void startCompositor();
|
|
|
|
void cleanup();
|
2023-08-08 16:16:34 +02:00
|
|
|
void createLockFile();
|
|
|
|
void removeLockFile();
|
2022-03-17 16:56:33 +01:00
|
|
|
|
2024-04-27 13:43:12 +02:00
|
|
|
wlr_surface* m_pLastFocus = nullptr;
|
|
|
|
PHLWINDOWREF m_pLastWindow;
|
2022-12-16 18:17:31 +01:00
|
|
|
CMonitor* m_pLastMonitor = nullptr;
|
2022-03-17 20:22:29 +01:00
|
|
|
|
2024-04-27 13:43:12 +02:00
|
|
|
std::vector<PHLWINDOWREF> m_vWindowFocusHistory; // first element is the most recently focused.
|
2023-01-20 19:15:15 +01:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
SSeat m_sSeat;
|
2022-09-25 20:07:48 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
bool m_bReadyToProcess = false;
|
|
|
|
bool m_bSessionActive = true;
|
|
|
|
bool m_bDPMSStateON = true;
|
2023-09-24 19:04:38 +02:00
|
|
|
bool m_bUnsafeState = false; // unsafe state is when there is no monitors.
|
2023-11-01 19:53:36 +01:00
|
|
|
bool m_bNextIsUnsafe = false; // because wlroots
|
|
|
|
CMonitor* m_pUnsafeOutput = nullptr; // fallback output for the unsafe state
|
2024-03-25 17:20:30 +01:00
|
|
|
bool m_bExitTriggered = false; // For exit dispatcher
|
2022-12-16 18:17:31 +01:00
|
|
|
bool m_bIsShuttingDown = false;
|
2022-04-28 17:57:24 +02:00
|
|
|
|
2022-03-17 20:22:29 +01:00
|
|
|
// ------------------------------------------------- //
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
CMonitor* getMonitorFromID(const int&);
|
|
|
|
CMonitor* getMonitorFromName(const std::string&);
|
2023-07-09 23:10:35 +02:00
|
|
|
CMonitor* getMonitorFromDesc(const std::string&);
|
2022-12-16 18:17:31 +01:00
|
|
|
CMonitor* getMonitorFromCursor();
|
|
|
|
CMonitor* getMonitorFromVector(const Vector2D&);
|
2024-04-27 13:43:12 +02:00
|
|
|
void removeWindowFromVectorSafe(PHLWINDOW);
|
|
|
|
void focusWindow(PHLWINDOW, wlr_surface* pSurface = nullptr);
|
|
|
|
void focusSurface(wlr_surface*, PHLWINDOW pWindowOwner = nullptr);
|
2024-02-07 01:18:47 +01:00
|
|
|
bool monitorExists(CMonitor*);
|
2024-04-27 13:43:12 +02:00
|
|
|
PHLWINDOW vectorToWindowUnified(const Vector2D&, uint8_t properties, PHLWINDOW pIgnoreWindow = nullptr);
|
2022-12-16 18:17:31 +01:00
|
|
|
wlr_surface* vectorToLayerSurface(const Vector2D&, std::vector<std::unique_ptr<SLayerSurface>>*, Vector2D*, SLayerSurface**);
|
2024-03-25 17:20:30 +01:00
|
|
|
wlr_surface* vectorToLayerPopupSurface(const Vector2D&, CMonitor* monitor, Vector2D*, SLayerSurface**);
|
2024-04-27 13:43:12 +02:00
|
|
|
wlr_surface* vectorWindowToSurface(const Vector2D&, PHLWINDOW, Vector2D& sl);
|
|
|
|
Vector2D vectorToSurfaceLocal(const Vector2D&, PHLWINDOW, wlr_surface*);
|
2022-12-16 18:17:31 +01:00
|
|
|
CMonitor* getMonitorFromOutput(wlr_output*);
|
2024-02-18 03:24:01 +01:00
|
|
|
CMonitor* getRealMonitorFromOutput(wlr_output*);
|
2024-04-27 13:43:12 +02:00
|
|
|
PHLWINDOW getWindowFromSurface(wlr_surface*);
|
|
|
|
PHLWINDOW getWindowFromHandle(uint32_t);
|
2024-04-03 11:09:42 +02:00
|
|
|
bool isWorkspaceVisible(PHLWORKSPACE);
|
2024-04-02 21:32:39 +02:00
|
|
|
PHLWORKSPACE getWorkspaceByID(const int&);
|
|
|
|
PHLWORKSPACE getWorkspaceByName(const std::string&);
|
|
|
|
PHLWORKSPACE getWorkspaceByString(const std::string&);
|
2022-12-16 18:17:31 +01:00
|
|
|
void sanityCheckWorkspaces();
|
|
|
|
void updateWorkspaceWindowDecos(const int&);
|
2024-04-10 18:26:11 +02:00
|
|
|
void updateWorkspaceSpecialRenderData(const int&);
|
2024-04-19 03:44:51 +02:00
|
|
|
int getWindowsOnWorkspace(const int& id, std::optional<bool> onlyTiled = {}, std::optional<bool> onlyVisible = {});
|
|
|
|
int getGroupsOnWorkspace(const int& id, std::optional<bool> onlyTiled = {}, std::optional<bool> onlyVisible = {});
|
2024-04-27 13:43:12 +02:00
|
|
|
PHLWINDOW getUrgentWindow();
|
2023-01-14 20:31:11 +01:00
|
|
|
bool hasUrgentWindowOnWorkspace(const int&);
|
2024-04-27 13:43:12 +02:00
|
|
|
PHLWINDOW getFirstWindowOnWorkspace(const int&);
|
|
|
|
PHLWINDOW getTopLeftWindowOnWorkspace(const int&);
|
|
|
|
PHLWINDOW getFullscreenWindowOnWorkspace(const int&);
|
2022-12-16 18:17:31 +01:00
|
|
|
bool doesSeatAcceptInput(wlr_surface*);
|
2024-04-27 13:43:12 +02:00
|
|
|
bool isWindowActive(PHLWINDOW);
|
|
|
|
void changeWindowZOrder(PHLWINDOW, bool);
|
2022-12-16 18:17:31 +01:00
|
|
|
void cleanupFadingOut(const int& monid);
|
2024-04-27 13:43:12 +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 = {});
|
2022-12-16 18:17:31 +01:00
|
|
|
int getNextAvailableNamedWorkspace();
|
|
|
|
bool isPointOnAnyMonitor(const Vector2D&);
|
2023-12-26 17:24:31 +01:00
|
|
|
bool isPointOnReservedArea(const Vector2D& point, const CMonitor* monitor = nullptr);
|
2022-12-16 18:17:31 +01:00
|
|
|
CMonitor* getMonitorInDirection(const char&);
|
2024-02-25 15:03:00 +01:00
|
|
|
CMonitor* getMonitorInDirection(CMonitor*, const char&);
|
2022-12-16 18:17:31 +01:00
|
|
|
void updateAllWindowsAnimatedDecorationValues();
|
2023-12-20 23:52:18 +01:00
|
|
|
void updateWorkspaceWindows(const int64_t& id);
|
2024-04-27 13:43:12 +02:00
|
|
|
void updateWindowAnimatedDecorationValues(PHLWINDOW);
|
2023-07-13 18:05:34 +02:00
|
|
|
int getNextAvailableMonitorID(std::string const& name);
|
2024-04-02 21:32:39 +02:00
|
|
|
void moveWorkspaceToMonitor(PHLWORKSPACE, CMonitor*, bool noWarpCursor = false);
|
2022-12-16 18:17:31 +01:00
|
|
|
void swapActiveWorkspaces(CMonitor*, CMonitor*);
|
|
|
|
CMonitor* getMonitorFromString(const std::string&);
|
2023-05-09 15:07:58 +02:00
|
|
|
bool workspaceIDOutOfBounds(const int64_t&);
|
2024-04-27 13:43:12 +02:00
|
|
|
void setWindowFullscreen(PHLWINDOW, bool, eFullscreenMode mode = FULLSCREEN_INVALID);
|
2024-04-02 21:32:39 +02:00
|
|
|
void updateFullscreenFadeOnWorkspace(PHLWORKSPACE);
|
2024-04-27 13:43:12 +02:00
|
|
|
PHLWINDOW getX11Parent(PHLWINDOW);
|
2022-12-16 18:17:31 +01:00
|
|
|
void scheduleFrameForMonitor(CMonitor*);
|
|
|
|
void addToFadingOutSafe(SLayerSurface*);
|
2024-04-27 13:43:12 +02:00
|
|
|
void addToFadingOutSafe(PHLWINDOW);
|
|
|
|
PHLWINDOW getWindowByRegex(const std::string&);
|
2023-01-28 13:26:33 +01:00
|
|
|
void warpCursorTo(const Vector2D&, bool force = false);
|
2022-12-16 18:17:31 +01:00
|
|
|
SLayerSurface* getLayerSurfaceFromWlr(wlr_layer_surface_v1*);
|
|
|
|
SLayerSurface* getLayerSurfaceFromSurface(wlr_surface*);
|
2024-04-27 13:43:12 +02:00
|
|
|
void closeWindow(PHLWINDOW);
|
2022-12-16 18:17:31 +01:00
|
|
|
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
|
|
|
|
void forceReportSizesToWindowsOnWorkspace(const int&);
|
2024-04-02 21:32:39 +02:00
|
|
|
PHLWORKSPACE createNewWorkspace(const int&, const int&, const std::string& name = ""); // will be deleted next frame if left empty and unfocused!
|
2023-01-08 14:19:18 +01:00
|
|
|
void renameWorkspace(const int&, const std::string& name = "");
|
2022-12-16 18:17:31 +01:00
|
|
|
void setActiveMonitor(CMonitor*);
|
|
|
|
bool isWorkspaceSpecial(const int&);
|
|
|
|
int getNewSpecialID();
|
2023-03-20 16:02:47 +01:00
|
|
|
void performUserChecks();
|
2024-04-27 13:43:12 +02:00
|
|
|
void moveWindowToWorkspaceSafe(PHLWINDOW pWindow, PHLWORKSPACE pWorkspace);
|
|
|
|
PHLWINDOW getForceFocus();
|
2023-07-13 18:05:34 +02:00
|
|
|
void notifyIdleActivity();
|
|
|
|
void setIdleActivityInhibit(bool inhibit);
|
2023-08-14 14:22:06 +02:00
|
|
|
void arrangeMonitors();
|
2023-09-24 19:04:38 +02:00
|
|
|
void enterUnsafeState();
|
|
|
|
void leaveUnsafeState();
|
2023-10-22 17:58:06 +02:00
|
|
|
void setPreferredScaleForSurface(wlr_surface* pSurface, double scale);
|
|
|
|
void setPreferredTransformForSurface(wlr_surface* pSurface, wl_output_transform transform);
|
2023-12-23 22:30:49 +01:00
|
|
|
void updateSuspendedStates();
|
2024-04-27 13:43:12 +02:00
|
|
|
PHLWINDOW windowForCPointer(CWindow*);
|
2022-12-16 18:17:31 +01:00
|
|
|
|
|
|
|
std::string explicitConfigPath;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void initAllSignals();
|
2024-01-19 16:20:22 +01:00
|
|
|
void removeAllSignals();
|
2022-12-16 18:17:31 +01:00
|
|
|
void setRandomSplash();
|
2023-03-05 14:37:21 +01:00
|
|
|
void initManagers(eManagersInitStage stage);
|
2023-11-01 19:53:36 +01:00
|
|
|
void prepareFallbackOutput();
|
2022-12-16 18:17:31 +01:00
|
|
|
|
|
|
|
uint64_t m_iHyprlandPID = 0;
|
2022-03-16 21:37:21 +01:00
|
|
|
};
|
|
|
|
|
2022-03-20 13:37:07 +01:00
|
|
|
inline std::unique_ptr<CCompositor> g_pCompositor;
|
|
|
|
|
|
|
|
// For XWayland
|
2022-12-16 18:17:31 +01:00
|
|
|
inline std::map<std::string, xcb_atom_t> HYPRATOMS = {HYPRATOM("_NET_WM_WINDOW_TYPE"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_NORMAL"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_DOCK"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_DIALOG"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_UTILITY"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_TOOLBAR"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_SPLASH"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_MENU"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_POPUP_MENU"),
|
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_TOOLTIP"),
|
2023-04-22 23:20:48 +02:00
|
|
|
HYPRATOM("_NET_WM_WINDOW_TYPE_NOTIFICATION"),
|
2024-03-09 17:47:57 +01:00
|
|
|
HYPRATOM("_KDE_NET_WM_WINDOW_TYPE_OVERRIDE"),
|
|
|
|
HYPRATOM("_NET_SUPPORTING_WM_CHECK"),
|
|
|
|
HYPRATOM("_NET_WM_NAME"),
|
|
|
|
HYPRATOM("UTF8_STRING")};
|