Hyprland/src/Compositor.hpp

111 lines
4.4 KiB
C++
Raw Normal View History

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"
#include "managers/InputManager.hpp"
#include "managers/LayoutManager.hpp"
2022-03-19 17:48:18 +01:00
#include "managers/KeybindManager.hpp"
2022-03-17 16:56:33 +01:00
#include "helpers/Monitor.hpp"
2022-03-20 15:55:47 +01:00
#include "helpers/Workspace.hpp"
2022-03-17 20:22:29 +01:00
#include "Window.hpp"
#include "render/Renderer.hpp"
2022-03-20 15:55:47 +01:00
2022-03-16 21:37:21 +01:00
class CCompositor {
public:
CCompositor();
~CCompositor();
// ------------------ WLR BASICS ------------------ //
wl_display* m_sWLDisplay;
wlr_backend* m_sWLRBackend;
wlr_renderer* m_sWLRRenderer;
wlr_allocator* m_sWLRAllocator;
wlr_compositor* m_sWLRCompositor;
2022-03-17 19:03:15 +01:00
wlr_subcompositor* m_sWLRSubCompositor;
wlr_data_device_manager* m_sWLRDataDevMgr;
2022-03-16 21:37:21 +01:00
wlr_xdg_activation_v1* m_sWLRXDGActivation;
wlr_output_layout* m_sWLROutputLayout;
wlr_idle* m_sWLRIdle;
wlr_layer_shell_v1* m_sWLRLayerShell;
wlr_xdg_shell* m_sWLRXDGShell;
wlr_cursor* m_sWLRCursor;
wlr_xcursor_manager* m_sWLRXCursorMgr;
wlr_virtual_keyboard_manager_v1* m_sWLRVKeyboardMgr;
wlr_seat* m_sWLRSeat;
wlr_output_manager_v1* m_sWLROutputMgr;
wlr_presentation* m_sWLRPresentation;
2022-03-17 19:03:15 +01:00
wlr_scene* m_sWLRScene;
2022-03-16 21:37:21 +01:00
// ------------------------------------------------- //
const char* m_szWLDisplaySocket;
2022-03-18 22:35:51 +01:00
std::list<SMonitor> m_lMonitors;
std::list<CWindow> m_lWindows;
2022-03-20 12:11:57 +01:00
std::list<SLayerPopup> m_lLayerPopups;
2022-03-20 14:00:46 +01:00
std::list<SXDGPopup> m_lXDGPopups;
2022-03-20 15:55:47 +01:00
std::list<SWorkspace> m_lWorkspaces;
2022-03-21 16:13:43 +01:00
std::list<SSubsurface> m_lSubsurfaces;
2022-03-17 16:56:33 +01:00
void startCompositor();
2022-03-17 20:22:29 +01:00
2022-03-20 14:36:55 +01:00
wlr_surface* m_pLastFocus = nullptr;
2022-03-19 20:30:21 +01:00
SMonitor* m_pLastMonitor = nullptr;
2022-03-18 22:53:27 +01:00
2022-03-17 20:22:29 +01:00
// ------------------------------------------------- //
SMonitor* getMonitorFromID(const int&);
SMonitor* getMonitorFromCursor();
SMonitor* getMonitorFromVector(const Vector2D&);
2022-03-18 22:35:51 +01:00
void removeWindowFromVectorSafe(CWindow*);
2022-03-18 22:53:27 +01:00
void focusWindow(CWindow*);
2022-03-20 14:36:55 +01:00
void focusSurface(wlr_surface*);
2022-03-18 22:53:27 +01:00
bool windowExists(CWindow*);
2022-03-18 23:16:15 +01:00
bool windowValidMapped(CWindow*);
2022-03-18 22:53:27 +01:00
CWindow* vectorToWindow(const Vector2D&);
2022-03-19 17:48:18 +01:00
CWindow* vectorToWindowIdeal(const Vector2D&);
2022-03-20 18:31:58 +01:00
CWindow* vectorToWindowTiled(const Vector2D&);
2022-03-20 14:36:55 +01:00
wlr_surface* vectorToLayerSurface(const Vector2D&, std::list<SLayerSurface*>*, Vector2D*);
2022-03-19 20:30:21 +01:00
CWindow* windowFromCursor();
2022-03-20 11:14:24 +01:00
CWindow* windowFloatingFromCursor();
2022-03-19 20:56:19 +01:00
SMonitor* getMonitorFromOutput(wlr_output*);
2022-03-20 12:11:57 +01:00
SLayerSurface* getLayerForPopup(SLayerPopup*);
2022-03-20 14:00:46 +01:00
CWindow* getWindowForPopup(wlr_xdg_popup*);
2022-03-20 14:36:55 +01:00
CWindow* getWindowFromSurface(wlr_surface*);
2022-03-20 15:55:47 +01:00
bool isWorkspaceVisible(const int&);
SWorkspace* getWorkspaceByID(const int&);
void sanityCheckWorkspaces();
int getWindowsOnWorkspace(const int&);
CWindow* getFirstWindowOnWorkspace(const int&);
void fixXWaylandWindowsOnWorkspace(const int&);
2022-03-21 19:18:33 +01:00
CWindow* getFullscreenWindowOnWorkspace(const int&);
2022-03-18 23:52:36 +01:00
private:
void initAllSignals();
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
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"),
HYPRATOM("_NET_WM_WINDOW_TYPE_NOTIFICATION")};