2022-03-17 20:22:29 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "defines.hpp"
|
|
|
|
#include "events/Events.hpp"
|
2022-03-27 21:46:27 +02:00
|
|
|
#include "helpers/SubsurfaceTree.hpp"
|
2022-04-23 14:16:02 +02:00
|
|
|
#include "helpers/AnimatedVariable.hpp"
|
2022-05-28 20:46:20 +02:00
|
|
|
#include "render/decorations/IHyprWindowDecoration.hpp"
|
|
|
|
#include <deque>
|
2022-11-26 18:56:43 +01:00
|
|
|
#include "config/ConfigDataValues.hpp"
|
2022-03-17 20:22:29 +01:00
|
|
|
|
2022-12-28 15:39:17 +01:00
|
|
|
enum eIdleInhibitMode {
|
2022-10-31 13:26:07 +01:00
|
|
|
IDLEINHIBIT_NONE = 0,
|
|
|
|
IDLEINHIBIT_ALWAYS,
|
|
|
|
IDLEINHIBIT_FULLSCREEN,
|
|
|
|
IDLEINHIBIT_FOCUS
|
|
|
|
};
|
|
|
|
|
2022-04-22 14:37:38 +02:00
|
|
|
struct SWindowSpecialRenderData {
|
2022-12-16 18:17:31 +01:00
|
|
|
bool alphaOverride = false;
|
|
|
|
float alpha = 1.f;
|
|
|
|
bool alphaInactiveOverride = false;
|
|
|
|
float alphaInactive = -1.f; // -1 means unset
|
2022-08-01 12:51:52 +02:00
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
int64_t activeBorderColor = -1; // -1 means unset
|
2022-11-13 20:33:13 +01:00
|
|
|
int64_t inactiveBorderColor = -1; // -1 means unset
|
|
|
|
|
2022-08-01 12:51:52 +02:00
|
|
|
// set by the layout
|
2022-12-20 03:18:47 +01:00
|
|
|
bool rounding = true;
|
|
|
|
bool border = true;
|
|
|
|
bool decorate = true;
|
2022-09-25 20:07:48 +02:00
|
|
|
};
|
2022-03-17 20:22:29 +01:00
|
|
|
|
2022-05-15 14:18:31 +02:00
|
|
|
struct SWindowAdditionalConfigData {
|
2022-12-16 18:17:31 +01:00
|
|
|
std::string animationStyle = "";
|
|
|
|
int rounding = -1; // -1 means no
|
|
|
|
bool forceNoBlur = false;
|
|
|
|
bool forceOpaque = false;
|
|
|
|
bool forceOpaqueOverriden = false; // if true, a rule will not change the forceOpaque state. This is for the force opaque dispatcher.
|
|
|
|
bool forceAllowsInput = false;
|
|
|
|
bool forceNoAnims = false;
|
|
|
|
bool forceNoBorder = false;
|
|
|
|
bool forceNoShadow = false;
|
|
|
|
bool windowDanceCompat = false;
|
|
|
|
bool noMaxSize = false;
|
2022-12-28 15:39:17 +01:00
|
|
|
bool dimAround = false;
|
2022-05-15 14:18:31 +02:00
|
|
|
};
|
|
|
|
|
2022-11-15 11:21:26 +01:00
|
|
|
struct SWindowRule {
|
|
|
|
std::string szRule;
|
|
|
|
std::string szValue;
|
|
|
|
|
2022-12-16 18:17:31 +01:00
|
|
|
bool v2 = false;
|
2022-11-15 11:21:26 +01:00
|
|
|
std::string szTitle;
|
|
|
|
std::string szClass;
|
2022-12-16 18:17:31 +01:00
|
|
|
int bX11 = -1; // -1 means "ANY"
|
|
|
|
int bFloating = -1;
|
|
|
|
int bFullscreen = -1;
|
|
|
|
int bPinned = -1;
|
2022-11-15 11:21:26 +01:00
|
|
|
};
|
|
|
|
|
2022-03-17 20:22:29 +01:00
|
|
|
class CWindow {
|
2022-12-16 18:17:31 +01:00
|
|
|
public:
|
2022-04-23 14:16:02 +02:00
|
|
|
CWindow();
|
2022-03-30 21:18:42 +02:00
|
|
|
~CWindow();
|
|
|
|
|
2022-03-17 20:22:29 +01:00
|
|
|
DYNLISTENER(commitWindow);
|
|
|
|
DYNLISTENER(mapWindow);
|
|
|
|
DYNLISTENER(unmapWindow);
|
|
|
|
DYNLISTENER(destroyWindow);
|
|
|
|
DYNLISTENER(setTitleWindow);
|
2022-07-08 11:24:07 +02:00
|
|
|
DYNLISTENER(setGeometryX11U);
|
2022-03-17 20:22:29 +01:00
|
|
|
DYNLISTENER(fullscreenWindow);
|
2022-03-20 14:00:46 +01:00
|
|
|
DYNLISTENER(newPopupXDG);
|
2022-07-16 00:11:21 +02:00
|
|
|
DYNLISTENER(requestMove);
|
|
|
|
DYNLISTENER(requestMinimize);
|
|
|
|
DYNLISTENER(requestMaximize);
|
|
|
|
DYNLISTENER(requestResize);
|
2022-08-06 20:57:38 +02:00
|
|
|
DYNLISTENER(activateX11);
|
|
|
|
DYNLISTENER(configureX11);
|
|
|
|
DYNLISTENER(toplevelClose);
|
|
|
|
DYNLISTENER(toplevelActivate);
|
|
|
|
DYNLISTENER(toplevelFullscreen);
|
2022-12-16 18:17:31 +01:00
|
|
|
// DYNLISTENER(newSubsurfaceWindow);
|
2022-03-17 20:22:29 +01:00
|
|
|
|
|
|
|
union {
|
2022-12-16 18:17:31 +01:00
|
|
|
wlr_xdg_surface* xdg;
|
2022-03-17 20:22:29 +01:00
|
|
|
wlr_xwayland_surface* xwayland;
|
|
|
|
} m_uSurface;
|
|
|
|
|
|
|
|
// this is the position and size of the "bounding box"
|
2022-12-20 03:18:47 +01:00
|
|
|
Vector2D m_vPosition = Vector2D(0, 0);
|
|
|
|
Vector2D m_vSize = Vector2D(0, 0);
|
2022-03-17 20:22:29 +01:00
|
|
|
|
|
|
|
// this is the real position and size used to draw the thing
|
2022-12-20 03:18:47 +01:00
|
|
|
CAnimatedVariable m_vRealPosition;
|
|
|
|
CAnimatedVariable m_vRealSize;
|
2022-03-17 20:22:29 +01:00
|
|
|
|
2022-07-28 23:55:00 +02:00
|
|
|
// for not spamming the protocols
|
2022-12-20 03:18:47 +01:00
|
|
|
Vector2D m_vReportedPosition;
|
|
|
|
Vector2D m_vReportedSize;
|
2022-07-28 23:55:00 +02:00
|
|
|
|
2022-08-05 17:52:14 +02:00
|
|
|
// for restoring floating statuses
|
2022-12-20 03:18:47 +01:00
|
|
|
Vector2D m_vLastFloatingSize;
|
|
|
|
Vector2D m_vLastFloatingPosition;
|
2022-08-05 17:52:14 +02:00
|
|
|
|
2022-04-02 20:04:32 +02:00
|
|
|
// this is used for pseudotiling
|
2022-12-20 03:18:47 +01:00
|
|
|
bool m_bIsPseudotiled = false;
|
|
|
|
Vector2D m_vPseudoSize = Vector2D(0, 0);
|
2022-04-02 20:04:32 +02:00
|
|
|
|
2022-12-20 03:18:47 +01:00
|
|
|
uint64_t m_iTags = 0;
|
|
|
|
bool m_bIsFloating = false;
|
|
|
|
bool m_bDraggingTiled = false; // for dragging around tiled windows
|
|
|
|
bool m_bIsFullscreen = false;
|
|
|
|
uint64_t m_iMonitorID = -1;
|
|
|
|
std::string m_szTitle = "";
|
|
|
|
int m_iWorkspaceID = -1;
|
2022-03-18 20:03:39 +01:00
|
|
|
|
2022-12-20 03:18:47 +01:00
|
|
|
bool m_bIsMapped = false;
|
2022-03-22 20:53:11 +01:00
|
|
|
|
2022-12-20 03:18:47 +01:00
|
|
|
bool m_bRequestsFloat = false;
|
2022-05-26 19:05:32 +02:00
|
|
|
|
2022-03-30 20:16:23 +02:00
|
|
|
// This is for fullscreen apps
|
2022-12-20 03:18:47 +01:00
|
|
|
bool m_bCreatedOverFullscreen = false;
|
2022-03-30 20:16:23 +02:00
|
|
|
|
2022-03-18 20:03:39 +01:00
|
|
|
// XWayland stuff
|
2022-12-20 03:18:47 +01:00
|
|
|
bool m_bIsX11 = false;
|
|
|
|
bool m_bMappedX11 = false;
|
|
|
|
CWindow* m_pX11Parent = nullptr;
|
|
|
|
uint64_t m_iX11Type = 0;
|
|
|
|
bool m_bIsModal = false;
|
|
|
|
bool m_bX11DoesntWantBorders = false;
|
|
|
|
bool m_bX11ShouldntFocus = false;
|
2022-03-18 20:03:39 +01:00
|
|
|
//
|
2022-03-18 22:35:51 +01:00
|
|
|
|
2022-05-14 14:37:57 +02:00
|
|
|
// For nofocus
|
2022-12-20 03:18:47 +01:00
|
|
|
bool m_bNoFocus = false;
|
|
|
|
bool m_bNoInitialFocus = false;
|
2022-05-14 14:37:57 +02:00
|
|
|
|
2022-11-26 21:44:40 +01:00
|
|
|
// initial fullscreen and fullscreen disabled
|
2022-12-20 03:18:47 +01:00
|
|
|
bool m_bWantsInitialFullscreen = false;
|
|
|
|
bool m_bNoFullscreenRequest = false;
|
2022-08-21 22:30:48 +02:00
|
|
|
|
2022-12-20 03:18:47 +01:00
|
|
|
SSurfaceTreeNode* m_pSurfaceTree = nullptr;
|
2022-03-27 21:46:27 +02:00
|
|
|
|
2022-03-31 17:50:00 +02:00
|
|
|
// Animated border
|
2022-12-20 03:18:47 +01:00
|
|
|
CGradientValueData m_cRealBorderColor = {0};
|
|
|
|
CGradientValueData m_cRealBorderColorPrevious = {0};
|
|
|
|
CAnimatedVariable m_fBorderAnimationProgress;
|
2022-03-31 17:50:00 +02:00
|
|
|
|
2022-04-05 19:28:10 +02:00
|
|
|
// Fade in-out
|
2022-12-20 03:18:47 +01:00
|
|
|
CAnimatedVariable m_fAlpha;
|
|
|
|
bool m_bFadingOut = false;
|
|
|
|
bool m_bReadyToDelete = false;
|
|
|
|
Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in
|
|
|
|
Vector2D m_vOriginalClosedSize; // drawing the closing animations
|
2022-04-05 19:28:10 +02:00
|
|
|
|
2022-09-10 13:11:02 +02:00
|
|
|
// For pinned (sticky) windows
|
2022-12-20 03:18:47 +01:00
|
|
|
bool m_bPinned = false;
|
2022-09-10 13:11:02 +02:00
|
|
|
|
2023-01-01 16:54:13 +01:00
|
|
|
// fakefullscreen
|
2023-01-06 13:29:43 +01:00
|
|
|
bool m_bFakeFullscreenState = false;
|
2023-01-01 16:54:13 +01:00
|
|
|
|
2022-08-24 22:01:25 +02:00
|
|
|
// for proper cycling. While cycling we can't just move the pointers, so we need to keep track of the last cycled window.
|
2022-12-20 03:18:47 +01:00
|
|
|
CWindow* m_pLastCycledWindow = nullptr;
|
2022-08-24 22:01:25 +02:00
|
|
|
|
2022-05-29 11:24:42 +02:00
|
|
|
// Foreign Toplevel proto
|
2022-12-20 03:18:47 +01:00
|
|
|
wlr_foreign_toplevel_handle_v1* m_phForeignToplevel = nullptr;
|
2022-05-29 11:24:42 +02:00
|
|
|
|
2022-05-28 20:46:20 +02:00
|
|
|
// Window decorations
|
2022-05-28 23:43:11 +02:00
|
|
|
std::deque<std::unique_ptr<IHyprWindowDecoration>> m_dWindowDecorations;
|
2022-12-16 18:17:31 +01:00
|
|
|
std::vector<IHyprWindowDecoration*> m_vDecosToRemove;
|
2022-05-28 20:46:20 +02:00
|
|
|
|
2022-04-22 14:37:38 +02:00
|
|
|
// Special render data, rules, etc
|
2022-12-20 03:18:47 +01:00
|
|
|
SWindowSpecialRenderData m_sSpecialRenderData;
|
|
|
|
SWindowAdditionalConfigData m_sAdditionalConfigData;
|
2022-03-18 22:35:51 +01:00
|
|
|
|
2022-07-12 13:40:55 +02:00
|
|
|
// for alpha
|
2022-12-20 03:18:47 +01:00
|
|
|
CAnimatedVariable m_fActiveInactiveAlpha;
|
2022-07-12 13:40:55 +02:00
|
|
|
|
2022-07-16 12:44:45 +02:00
|
|
|
// animated shadow color
|
2022-12-20 03:18:47 +01:00
|
|
|
CAnimatedVariable m_cRealShadowColor;
|
2022-07-16 12:44:45 +02:00
|
|
|
|
2022-08-30 12:46:17 +02:00
|
|
|
// animated tint
|
2022-12-20 03:18:47 +01:00
|
|
|
CAnimatedVariable m_fDimPercent;
|
2022-08-30 12:46:17 +02:00
|
|
|
|
2022-10-01 20:19:15 +02:00
|
|
|
// swallowing
|
2022-12-20 03:18:47 +01:00
|
|
|
CWindow* m_pSwallowed = nullptr;
|
2022-10-01 20:19:15 +02:00
|
|
|
|
2022-08-06 20:57:38 +02:00
|
|
|
// for toplevel monitor events
|
2022-12-20 03:18:47 +01:00
|
|
|
uint64_t m_iLastToplevelMonitorID = -1;
|
|
|
|
uint64_t m_iLastSurfaceMonitorID = -1;
|
2022-08-06 20:57:38 +02:00
|
|
|
|
2022-10-31 13:26:07 +01:00
|
|
|
// for idle inhibiting windows
|
2022-12-20 03:18:47 +01:00
|
|
|
eIdleInhibitMode m_eIdleInhibitMode = IDLEINHIBIT_NONE;
|
2022-10-31 13:26:07 +01:00
|
|
|
|
2022-03-18 22:35:51 +01:00
|
|
|
// For the list lookup
|
2022-12-20 03:18:47 +01:00
|
|
|
bool operator==(const CWindow& rhs) {
|
2022-12-16 18:17:31 +01:00
|
|
|
return m_uSurface.xdg == rhs.m_uSurface.xdg && m_uSurface.xwayland == rhs.m_uSurface.xwayland && m_vPosition == rhs.m_vPosition && m_vSize == rhs.m_vSize &&
|
|
|
|
m_bFadingOut == rhs.m_bFadingOut;
|
2022-03-18 22:35:51 +01:00
|
|
|
}
|
|
|
|
|
2022-05-30 14:55:42 +02:00
|
|
|
// methods
|
2022-12-16 18:17:31 +01:00
|
|
|
wlr_box getFullWindowBoundingBox();
|
|
|
|
wlr_box getWindowIdealBoundingBoxIgnoreReserved();
|
|
|
|
void updateWindowDecos();
|
|
|
|
pid_t getPID();
|
2022-07-16 12:44:45 +02:00
|
|
|
IHyprWindowDecoration* getDecorationByType(eDecorationType);
|
2022-12-16 18:17:31 +01:00
|
|
|
void removeDecorationByType(eDecorationType);
|
|
|
|
void createToplevelHandle();
|
|
|
|
void destroyToplevelHandle();
|
|
|
|
void updateToplevel();
|
|
|
|
void updateSurfaceOutputs();
|
|
|
|
void moveToWorkspace(int);
|
|
|
|
CWindow* X11TransientFor();
|
|
|
|
void onUnmap();
|
|
|
|
void onMap();
|
|
|
|
void setHidden(bool hidden);
|
|
|
|
bool isHidden();
|
|
|
|
void applyDynamicRule(const SWindowRule& r);
|
|
|
|
void updateDynamicRules();
|
2023-01-11 15:43:41 +01:00
|
|
|
bool isInCurvedCorner(double x, double y);
|
2022-12-16 18:17:31 +01:00
|
|
|
|
|
|
|
private:
|
2022-10-14 21:46:32 +02:00
|
|
|
// For hidden windows and stuff
|
2022-12-16 18:17:31 +01:00
|
|
|
bool m_bHidden = false;
|
2022-06-24 22:28:54 +02:00
|
|
|
};
|