Hyprland/src/helpers/Monitor.hpp

108 lines
3.8 KiB
C++
Raw Normal View History

2022-03-17 16:56:33 +01:00
#pragma once
#include "../defines.hpp"
2022-03-17 18:25:16 +01:00
#include <deque>
#include "WLClasses.hpp"
2022-07-23 15:48:08 +02:00
#include <vector>
2022-03-19 13:54:24 +01:00
#include <array>
2022-07-23 15:48:08 +02:00
#include <memory>
#include <xf86drmMode.h>
#include "Timer.hpp"
2022-03-17 16:56:33 +01:00
2022-09-13 15:25:42 +02:00
struct SMonitorRule;
2022-07-27 12:32:00 +02:00
class CMonitor {
public:
2023-04-07 13:18:40 +02:00
CMonitor();
~CMonitor();
Vector2D vecPosition = Vector2D(-1, -1); // means unset
Vector2D vecSize = Vector2D(0, 0);
Vector2D vecPixelSize = Vector2D(0, 0);
Vector2D vecTransformedSize = Vector2D(0, 0);
2022-03-17 16:56:33 +01:00
bool primary = false;
2022-03-17 16:56:33 +01:00
uint64_t ID = -1;
int activeWorkspace = -1;
float scale = 1;
2022-03-17 16:56:33 +01:00
std::string szName = "";
2022-03-17 16:56:33 +01:00
Vector2D vecReservedTopLeft = Vector2D(0, 0);
Vector2D vecReservedBottomRight = Vector2D(0, 0);
drmModeModeInfo customDrmMode = {};
2022-03-17 18:25:16 +01:00
// WLR stuff
2023-04-07 13:18:40 +02:00
wlr_damage_ring damage;
wlr_output* output = nullptr;
float refreshRate = 60;
int framesToSkip = 0;
int forceFullFrames = 0;
bool noFrameSchedule = false;
bool scheduledRecalc = false;
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
bool gammaChanged = false;
bool dpmsStatus = true;
bool vrrActive = false; // this can be TRUE even if VRR is not active in the case that this display does not support it.
bool enabled10bit = false; // as above, this can be TRUE even if 10 bit failed.
bool createdByUser = false;
2022-10-05 19:14:11 +02:00
bool pendingFrame = false; // if we schedule a frame during rendering, reschedule it after
bool renderingActive = false;
wl_event_source* renderTimer = nullptr; // for RAT
bool RATScheduled = false;
CTimer lastPresentationTimer;
2022-09-13 15:25:42 +02:00
// mirroring
CMonitor* pMirrorOf = nullptr;
2022-09-13 15:25:42 +02:00
std::vector<CMonitor*> mirrors;
2022-11-27 23:42:22 +01:00
// for the special workspace. 0 means not open.
int specialWorkspaceID = 0;
2022-09-25 20:07:48 +02:00
std::array<std::vector<std::unique_ptr<SLayerSurface>>, 4> m_aLayerSurfaceLayers;
2022-03-17 18:25:16 +01:00
DYNLISTENER(monitorFrame);
DYNLISTENER(monitorDestroy);
2022-11-19 17:28:04 +01:00
DYNLISTENER(monitorStateRequest);
DYNLISTENER(monitorDamage);
2023-04-07 18:25:56 +02:00
DYNLISTENER(monitorNeedsFrame);
2023-04-12 22:40:51 +02:00
DYNLISTENER(monitorCommit);
DYNLISTENER(monitorBind);
2022-03-18 22:35:51 +01:00
// hack: a group = workspaces on a monitor.
// I don't really care lol :P
wlr_ext_workspace_group_handle_v1* pWLRWorkspaceGroupHandle = nullptr;
2022-07-27 12:32:00 +02:00
// methods
void onConnect(bool noRule);
void onDisconnect();
void addDamage(const pixman_region32_t* rg);
void addDamage(const wlr_box* box);
void setMirror(const std::string&);
bool isMirror();
float getDefaultScale();
void changeWorkspace(CWorkspace* const pWorkspace, bool internal = false);
void changeWorkspace(const int& id, bool internal = false);
void setSpecialWorkspace(CWorkspace* const pWorkspace);
void setSpecialWorkspace(const int& id);
std::shared_ptr<CMonitor>* m_pThisWrap = nullptr;
bool m_bEnabled = false;
bool m_bRenderingInitPassed = false;
2022-07-27 12:32:00 +02:00
2022-03-18 22:35:51 +01:00
// For the list lookup
2022-07-27 12:32:00 +02:00
bool operator==(const CMonitor& rhs) {
2022-03-18 22:35:51 +01:00
return vecPosition == rhs.vecPosition && vecSize == rhs.vecSize && szName == rhs.szName;
}
2022-09-13 15:25:42 +02:00
private:
void setupDefaultWS(const SMonitorRule&);
int findAvailableDefaultWS();
2022-09-25 20:07:48 +02:00
};