mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 09:45:58 +01:00
parent
7c33c7fc64
commit
98a4fa2b0d
90 changed files with 4118 additions and 3993 deletions
65
.clang-format
Normal file
65
.clang-format
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
|
||||||
|
AccessModifierOffset: -2
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveMacros: true
|
||||||
|
AlignConsecutiveAssignments: true
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: false
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllConstructorInitializersOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: true
|
||||||
|
AllowShortCaseLabelsOnASingleLine: true
|
||||||
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeTernaryOperators: false
|
||||||
|
BreakConstructorInitializers: AfterColon
|
||||||
|
ColumnLimit: 180
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: false
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IndentCaseLabels: true
|
||||||
|
IndentWidth: 4
|
||||||
|
PointerAlignment: Left
|
||||||
|
ReflowComments: false
|
||||||
|
SortIncludes: false
|
||||||
|
SortUsingDeclarations: false
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInContainerLiterals: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
Standard: Auto
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
|
||||||
|
AllowShortEnumsOnASingleLine: false
|
||||||
|
|
||||||
|
BraceWrapping:
|
||||||
|
AfterEnum: false
|
||||||
|
|
||||||
|
AlignConsecutiveDeclarations: AcrossEmptyLinesAndComments
|
||||||
|
|
||||||
|
NamespaceIndentation: All
|
|
@ -96,9 +96,9 @@ CCompositor::CCompositor() {
|
||||||
throw std::runtime_error("wlr_gles2_renderer_get_egl() failed!");
|
throw std::runtime_error("wlr_gles2_renderer_get_egl() failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sWLRCompositor = wlr_compositor_create(m_sWLDisplay, m_sWLRRenderer);
|
m_sWLRCompositor = wlr_compositor_create(m_sWLDisplay, m_sWLRRenderer);
|
||||||
m_sWLRSubCompositor = wlr_subcompositor_create(m_sWLDisplay);
|
m_sWLRSubCompositor = wlr_subcompositor_create(m_sWLDisplay);
|
||||||
m_sWLRDataDevMgr = wlr_data_device_manager_create(m_sWLDisplay);
|
m_sWLRDataDevMgr = wlr_data_device_manager_create(m_sWLDisplay);
|
||||||
|
|
||||||
wlr_export_dmabuf_manager_v1_create(m_sWLDisplay);
|
wlr_export_dmabuf_manager_v1_create(m_sWLDisplay);
|
||||||
wlr_screencopy_manager_v1_create(m_sWLDisplay);
|
wlr_screencopy_manager_v1_create(m_sWLDisplay);
|
||||||
|
@ -134,13 +134,13 @@ CCompositor::CCompositor() {
|
||||||
m_sWLRLayerShell = wlr_layer_shell_v1_create(m_sWLDisplay, 4);
|
m_sWLRLayerShell = wlr_layer_shell_v1_create(m_sWLDisplay, 4);
|
||||||
|
|
||||||
m_sWLRServerDecoMgr = wlr_server_decoration_manager_create(m_sWLDisplay);
|
m_sWLRServerDecoMgr = wlr_server_decoration_manager_create(m_sWLDisplay);
|
||||||
m_sWLRXDGDecoMgr = wlr_xdg_decoration_manager_v1_create(m_sWLDisplay);
|
m_sWLRXDGDecoMgr = wlr_xdg_decoration_manager_v1_create(m_sWLDisplay);
|
||||||
wlr_server_decoration_manager_set_default_mode(m_sWLRServerDecoMgr, WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);
|
wlr_server_decoration_manager_set_default_mode(m_sWLRServerDecoMgr, WLR_SERVER_DECORATION_MANAGER_MODE_SERVER);
|
||||||
|
|
||||||
wlr_xdg_output_manager_v1_create(m_sWLDisplay, m_sWLROutputLayout);
|
wlr_xdg_output_manager_v1_create(m_sWLDisplay, m_sWLROutputLayout);
|
||||||
m_sWLROutputMgr = wlr_output_manager_v1_create(m_sWLDisplay);
|
m_sWLROutputMgr = wlr_output_manager_v1_create(m_sWLDisplay);
|
||||||
|
|
||||||
m_sWLRInhibitMgr = wlr_input_inhibit_manager_create(m_sWLDisplay);
|
m_sWLRInhibitMgr = wlr_input_inhibit_manager_create(m_sWLDisplay);
|
||||||
m_sWLRKbShInhibitMgr = wlr_keyboard_shortcuts_inhibit_v1_create(m_sWLDisplay);
|
m_sWLRKbShInhibitMgr = wlr_keyboard_shortcuts_inhibit_v1_create(m_sWLDisplay);
|
||||||
|
|
||||||
m_sWLREXTWorkspaceMgr = wlr_ext_workspace_manager_v1_create(m_sWLDisplay);
|
m_sWLREXTWorkspaceMgr = wlr_ext_workspace_manager_v1_create(m_sWLDisplay);
|
||||||
|
@ -193,8 +193,8 @@ CCompositor::~CCompositor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCompositor::setRandomSplash() {
|
void CCompositor::setRandomSplash() {
|
||||||
std::random_device dev;
|
std::random_device dev;
|
||||||
std::mt19937 engine(dev());
|
std::mt19937 engine(dev());
|
||||||
std::uniform_int_distribution<> distribution(0, SPLASHES.size() - 1);
|
std::uniform_int_distribution<> distribution(0, SPLASHES.size() - 1);
|
||||||
|
|
||||||
m_szCurrentSplash = SPLASHES[distribution(engine)];
|
m_szCurrentSplash = SPLASHES[distribution(engine)];
|
||||||
|
@ -244,7 +244,7 @@ void CCompositor::initAllSignals() {
|
||||||
addWLSignal(&m_sWLRTextInputMgr->events.text_input, &Events::listen_newTextInput, m_sWLRTextInputMgr, "TextInputMgr");
|
addWLSignal(&m_sWLRTextInputMgr->events.text_input, &Events::listen_newTextInput, m_sWLRTextInputMgr, "TextInputMgr");
|
||||||
addWLSignal(&m_sWLRActivation->events.request_activate, &Events::listen_activateXDG, m_sWLRActivation, "ActivationV1");
|
addWLSignal(&m_sWLRActivation->events.request_activate, &Events::listen_activateXDG, m_sWLRActivation, "ActivationV1");
|
||||||
|
|
||||||
if(m_sWRLDRMLeaseMgr)
|
if (m_sWRLDRMLeaseMgr)
|
||||||
addWLSignal(&m_sWRLDRMLeaseMgr->events.request, &Events::listen_leaseRequest, &m_sWRLDRMLeaseMgr, "DRM");
|
addWLSignal(&m_sWRLDRMLeaseMgr->events.request, &Events::listen_leaseRequest, &m_sWRLDRMLeaseMgr, "DRM");
|
||||||
|
|
||||||
if (m_sWLRSession)
|
if (m_sWLRSession)
|
||||||
|
@ -257,7 +257,7 @@ void CCompositor::cleanup() {
|
||||||
|
|
||||||
m_bIsShuttingDown = true;
|
m_bIsShuttingDown = true;
|
||||||
|
|
||||||
m_pLastFocus = nullptr;
|
m_pLastFocus = nullptr;
|
||||||
m_pLastWindow = nullptr;
|
m_pLastWindow = nullptr;
|
||||||
|
|
||||||
// accumulate all PIDs for killing, also request closing.
|
// accumulate all PIDs for killing, also request closing.
|
||||||
|
@ -288,8 +288,8 @@ void CCompositor::cleanup() {
|
||||||
|
|
||||||
wl_display_terminate(m_sWLDisplay);
|
wl_display_terminate(m_sWLDisplay);
|
||||||
|
|
||||||
g_pKeybindManager->spawn("sleep 5 && kill -9 " + std::to_string(m_iHyprlandPID)); // this is to prevent that random "freezing"
|
g_pKeybindManager->spawn("sleep 5 && kill -9 " + std::to_string(m_iHyprlandPID)); // this is to prevent that random "freezing"
|
||||||
// the PID should not be reused.
|
// the PID should not be reused.
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCompositor::startCompositor() {
|
void CCompositor::startCompositor() {
|
||||||
|
@ -412,15 +412,15 @@ CMonitor* CCompositor::getMonitorFromVector(const Vector2D& point) {
|
||||||
const auto OUTPUT = wlr_output_layout_output_at(m_sWLROutputLayout, point.x, point.y);
|
const auto OUTPUT = wlr_output_layout_output_at(m_sWLROutputLayout, point.x, point.y);
|
||||||
|
|
||||||
if (!OUTPUT) {
|
if (!OUTPUT) {
|
||||||
float bestDistance = 0.f;
|
float bestDistance = 0.f;
|
||||||
CMonitor* pBestMon = nullptr;
|
CMonitor* pBestMon = nullptr;
|
||||||
|
|
||||||
for (auto& m : m_vMonitors) {
|
for (auto& m : m_vMonitors) {
|
||||||
float dist = vecToRectDistanceSquared(point, m->vecPosition, m->vecPosition + m->vecSize);
|
float dist = vecToRectDistanceSquared(point, m->vecPosition, m->vecPosition + m->vecSize);
|
||||||
|
|
||||||
if (dist < bestDistance || !pBestMon) {
|
if (dist < bestDistance || !pBestMon) {
|
||||||
bestDistance = dist;
|
bestDistance = dist;
|
||||||
pBestMon = m.get();
|
pBestMon = m.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ CMonitor* CCompositor::getMonitorFromVector(const Vector2D& point) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCompositor::removeWindowFromVectorSafe(CWindow* pWindow) {
|
void CCompositor::removeWindowFromVectorSafe(CWindow* pWindow) {
|
||||||
if (windowExists(pWindow) && !pWindow->m_bFadingOut){
|
if (windowExists(pWindow) && !pWindow->m_bFadingOut) {
|
||||||
if (pWindow->m_bIsX11 && pWindow->m_iX11Type == 2) {
|
if (pWindow->m_bIsX11 && pWindow->m_iX11Type == 2) {
|
||||||
std::erase_if(m_dUnmanagedX11Windows, [&](std::unique_ptr<CWindow>& el) { return el.get() == pWindow; });
|
std::erase_if(m_dUnmanagedX11Windows, [&](std::unique_ptr<CWindow>& el) { return el.get() == pWindow; });
|
||||||
}
|
}
|
||||||
|
@ -498,7 +498,8 @@ CWindow* CCompositor::vectorToWindow(const Vector2D& pos) {
|
||||||
// first loop over floating cuz they're above, m_vWindows should be sorted bottom->top, for tiled it doesn't matter.
|
// first loop over floating cuz they're above, m_vWindows should be sorted bottom->top, for tiled it doesn't matter.
|
||||||
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) {
|
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) {
|
||||||
wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
|
wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
|
||||||
if (wlr_box_contains_point(&box, pos.x, pos.y) && (*w)->m_bIsMapped && (*w)->m_bIsFloating && isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->isHidden() && !(*w)->m_bPinned)
|
if (wlr_box_contains_point(&box, pos.x, pos.y) && (*w)->m_bIsMapped && (*w)->m_bIsFloating && isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->isHidden() &&
|
||||||
|
!(*w)->m_bPinned)
|
||||||
return w->get();
|
return w->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,7 +535,7 @@ CWindow* CCompositor::vectorToWindowTiled(const Vector2D& pos) {
|
||||||
void findExtensionForVector2D(wlr_surface* surface, int x, int y, void* data) {
|
void findExtensionForVector2D(wlr_surface* surface, int x, int y, void* data) {
|
||||||
const auto DATA = (SExtensionFindingData*)data;
|
const auto DATA = (SExtensionFindingData*)data;
|
||||||
|
|
||||||
wlr_box box = {DATA->origin.x + x, DATA->origin.y + y, surface->current.width, surface->current.height};
|
wlr_box box = {DATA->origin.x + x, DATA->origin.y + y, surface->current.width, surface->current.height};
|
||||||
|
|
||||||
if (wlr_box_contains_point(&box, DATA->vec.x, DATA->vec.y))
|
if (wlr_box_contains_point(&box, DATA->vec.x, DATA->vec.y))
|
||||||
*DATA->found = surface;
|
*DATA->found = surface;
|
||||||
|
@ -547,13 +548,15 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
||||||
if (PMONITOR->specialWorkspaceID) {
|
if (PMONITOR->specialWorkspaceID) {
|
||||||
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) {
|
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) {
|
||||||
wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
|
wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
|
||||||
if ((*w)->m_bIsFloating && (*w)->m_iWorkspaceID == PMONITOR->specialWorkspaceID && (*w)->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && !(*w)->isHidden() && !(*w)->m_bX11ShouldntFocus)
|
if ((*w)->m_bIsFloating && (*w)->m_iWorkspaceID == PMONITOR->specialWorkspaceID && (*w)->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) &&
|
||||||
|
!(*w)->isHidden() && !(*w)->m_bX11ShouldntFocus)
|
||||||
return (*w).get();
|
return (*w).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& w : m_vWindows) {
|
for (auto& w : m_vWindows) {
|
||||||
wlr_box box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y};
|
wlr_box box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y};
|
||||||
if (!w->m_bIsFloating && w->m_iWorkspaceID == PMONITOR->specialWorkspaceID && w->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && !w->isHidden() && !w->m_bX11ShouldntFocus)
|
if (!w->m_bIsFloating && w->m_iWorkspaceID == PMONITOR->specialWorkspaceID && w->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && !w->isHidden() &&
|
||||||
|
!w->m_bX11ShouldntFocus)
|
||||||
return w.get();
|
return w.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -566,9 +569,9 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
||||||
return w->get();
|
return w->get();
|
||||||
|
|
||||||
if (!(*w)->m_bIsX11) {
|
if (!(*w)->m_bIsX11) {
|
||||||
wlr_surface* resultSurf = nullptr;
|
wlr_surface* resultSurf = nullptr;
|
||||||
Vector2D origin = (*w)->m_vRealPosition.vec();
|
Vector2D origin = (*w)->m_vRealPosition.vec();
|
||||||
SExtensionFindingData data = {origin, pos, &resultSurf};
|
SExtensionFindingData data = {origin, pos, &resultSurf};
|
||||||
wlr_xdg_surface_for_each_popup_surface((*w)->m_uSurface.xdg, findExtensionForVector2D, &data);
|
wlr_xdg_surface_for_each_popup_surface((*w)->m_uSurface.xdg, findExtensionForVector2D, &data);
|
||||||
|
|
||||||
if (resultSurf)
|
if (resultSurf)
|
||||||
|
@ -589,7 +592,7 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
||||||
|
|
||||||
if ((*w)->m_iX11Type == 2) {
|
if ((*w)->m_iX11Type == 2) {
|
||||||
// Override Redirect
|
// Override Redirect
|
||||||
return g_pCompositor->m_pLastWindow; // we kinda trick everything here.
|
return g_pCompositor->m_pLastWindow; // we kinda trick everything here.
|
||||||
// TODO: this is wrong, we should focus the parent, but idk how to get it considering it's nullptr in most cases.
|
// TODO: this is wrong, we should focus the parent, but idk how to get it considering it's nullptr in most cases.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,9 +600,9 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(*w)->m_bIsX11) {
|
if (!(*w)->m_bIsX11) {
|
||||||
wlr_surface* resultSurf = nullptr;
|
wlr_surface* resultSurf = nullptr;
|
||||||
Vector2D origin =(*w)->m_vRealPosition.vec();
|
Vector2D origin = (*w)->m_vRealPosition.vec();
|
||||||
SExtensionFindingData data = {origin, pos, &resultSurf};
|
SExtensionFindingData data = {origin, pos, &resultSurf};
|
||||||
wlr_xdg_surface_for_each_popup_surface((*w)->m_uSurface.xdg, findExtensionForVector2D, &data);
|
wlr_xdg_surface_for_each_popup_surface((*w)->m_uSurface.xdg, findExtensionForVector2D, &data);
|
||||||
|
|
||||||
if (resultSurf)
|
if (resultSurf)
|
||||||
|
@ -611,9 +614,9 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
||||||
// for windows, we need to check their extensions too, first.
|
// for windows, we need to check their extensions too, first.
|
||||||
for (auto& w : m_vWindows) {
|
for (auto& w : m_vWindows) {
|
||||||
if (!w->m_bIsX11 && !w->m_bIsFloating && w->m_bIsMapped && w->m_iWorkspaceID == PMONITOR->activeWorkspace && !w->isHidden() && !w->m_bX11ShouldntFocus) {
|
if (!w->m_bIsX11 && !w->m_bIsFloating && w->m_bIsMapped && w->m_iWorkspaceID == PMONITOR->activeWorkspace && !w->isHidden() && !w->m_bX11ShouldntFocus) {
|
||||||
wlr_surface* resultSurf = nullptr;
|
wlr_surface* resultSurf = nullptr;
|
||||||
Vector2D origin = w->m_vRealPosition.vec();
|
Vector2D origin = w->m_vRealPosition.vec();
|
||||||
SExtensionFindingData data = {origin, pos, &resultSurf};
|
SExtensionFindingData data = {origin, pos, &resultSurf};
|
||||||
wlr_xdg_surface_for_each_popup_surface(w->m_uSurface.xdg, findExtensionForVector2D, &data);
|
wlr_xdg_surface_for_each_popup_surface(w->m_uSurface.xdg, findExtensionForVector2D, &data);
|
||||||
|
|
||||||
if (resultSurf)
|
if (resultSurf)
|
||||||
|
@ -622,7 +625,8 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
||||||
}
|
}
|
||||||
for (auto& w : m_vWindows) {
|
for (auto& w : m_vWindows) {
|
||||||
wlr_box box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y};
|
wlr_box box = {w->m_vPosition.x, w->m_vPosition.y, w->m_vSize.x, w->m_vSize.y};
|
||||||
if (!w->m_bIsFloating && w->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && w->m_iWorkspaceID == PMONITOR->activeWorkspace && !w->isHidden() && !w->m_bX11ShouldntFocus)
|
if (!w->m_bIsFloating && w->m_bIsMapped && wlr_box_contains_point(&box, pos.x, pos.y) && w->m_iWorkspaceID == PMONITOR->activeWorkspace && !w->isHidden() &&
|
||||||
|
!w->m_bX11ShouldntFocus)
|
||||||
return w.get();
|
return w.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,7 +639,8 @@ CWindow* CCompositor::windowFromCursor() {
|
||||||
if (PMONITOR->specialWorkspaceID) {
|
if (PMONITOR->specialWorkspaceID) {
|
||||||
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) {
|
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) {
|
||||||
wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
|
wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
|
||||||
if ((*w)->m_bIsFloating && (*w)->m_iWorkspaceID == PMONITOR->specialWorkspaceID && (*w)->m_bIsMapped && wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && !(*w)->isHidden())
|
if ((*w)->m_bIsFloating && (*w)->m_iWorkspaceID == PMONITOR->specialWorkspaceID && (*w)->m_bIsMapped &&
|
||||||
|
wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && !(*w)->isHidden())
|
||||||
return (*w).get();
|
return (*w).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,7 +661,8 @@ CWindow* CCompositor::windowFromCursor() {
|
||||||
// first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter.
|
// first loop over floating cuz they're above, m_lWindows should be sorted bottom->top, for tiled it doesn't matter.
|
||||||
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) {
|
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) {
|
||||||
wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
|
wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
|
||||||
if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && (*w)->m_bIsMapped && (*w)->m_bIsFloating && isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->m_bPinned)
|
if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && (*w)->m_bIsMapped && (*w)->m_bIsFloating && isWorkspaceVisible((*w)->m_iWorkspaceID) &&
|
||||||
|
!(*w)->m_bPinned)
|
||||||
return w->get();
|
return w->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,7 +684,8 @@ CWindow* CCompositor::windowFloatingFromCursor() {
|
||||||
|
|
||||||
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) {
|
for (auto w = m_vWindows.rbegin(); w != m_vWindows.rend(); w++) {
|
||||||
wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
|
wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
|
||||||
if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && (*w)->m_bIsMapped && (*w)->m_bIsFloating && isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->isHidden() && !(*w)->m_bPinned)
|
if (wlr_box_contains_point(&box, m_sWLRCursor->x, m_sWLRCursor->y) && (*w)->m_bIsMapped && (*w)->m_bIsFloating && isWorkspaceVisible((*w)->m_iWorkspaceID) &&
|
||||||
|
!(*w)->isHidden() && !(*w)->m_bPinned)
|
||||||
return w->get();
|
return w->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,7 +701,7 @@ wlr_surface* CCompositor::vectorWindowToSurface(const Vector2D& pos, CWindow* pW
|
||||||
|
|
||||||
const auto PSURFACE = pWindow->m_uSurface.xdg;
|
const auto PSURFACE = pWindow->m_uSurface.xdg;
|
||||||
|
|
||||||
double subx, suby;
|
double subx, suby;
|
||||||
|
|
||||||
// calc for oversized windows... fucking bullshit, again.
|
// calc for oversized windows... fucking bullshit, again.
|
||||||
wlr_box geom;
|
wlr_box geom;
|
||||||
|
@ -736,7 +743,7 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
|
||||||
|
|
||||||
if (!pWindow || !windowValidMapped(pWindow)) {
|
if (!pWindow || !windowValidMapped(pWindow)) {
|
||||||
const auto PLASTWINDOW = m_pLastWindow;
|
const auto PLASTWINDOW = m_pLastWindow;
|
||||||
m_pLastWindow = nullptr;
|
m_pLastWindow = nullptr;
|
||||||
|
|
||||||
if (windowValidMapped(PLASTWINDOW)) {
|
if (windowValidMapped(PLASTWINDOW)) {
|
||||||
updateWindowAnimatedDecorationValues(PLASTWINDOW);
|
updateWindowAnimatedDecorationValues(PLASTWINDOW);
|
||||||
|
@ -774,7 +781,7 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
|
||||||
g_pKeybindManager->changeworkspace("[internal]" + std::to_string(pWindow->m_iWorkspaceID));
|
g_pKeybindManager->changeworkspace("[internal]" + std::to_string(pWindow->m_iWorkspaceID));
|
||||||
|
|
||||||
const auto PLASTWINDOW = m_pLastWindow;
|
const auto PLASTWINDOW = m_pLastWindow;
|
||||||
m_pLastWindow = pWindow;
|
m_pLastWindow = pWindow;
|
||||||
|
|
||||||
// we need to make the PLASTWINDOW not equal to m_pLastWindow so that RENDERDATA is correct for an unfocused window
|
// we need to make the PLASTWINDOW not equal to m_pLastWindow so that RENDERDATA is correct for an unfocused window
|
||||||
if (windowValidMapped(PLASTWINDOW)) {
|
if (windowValidMapped(PLASTWINDOW)) {
|
||||||
|
@ -821,8 +828,9 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
|
||||||
|
|
||||||
void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) {
|
void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) {
|
||||||
|
|
||||||
if (m_sSeat.seat->keyboard_state.focused_surface == pSurface || (pWindowOwner && m_sSeat.seat->keyboard_state.focused_surface == g_pXWaylandManager->getWindowSurface(pWindowOwner)))
|
if (m_sSeat.seat->keyboard_state.focused_surface == pSurface ||
|
||||||
return; // Don't focus when already focused on this.
|
(pWindowOwner && m_sSeat.seat->keyboard_state.focused_surface == g_pXWaylandManager->getWindowSurface(pWindowOwner)))
|
||||||
|
return; // Don't focus when already focused on this.
|
||||||
|
|
||||||
// Unfocus last surface if should
|
// Unfocus last surface if should
|
||||||
if (m_pLastFocus && !pWindowOwner)
|
if (m_pLastFocus && !pWindowOwner)
|
||||||
|
@ -835,7 +843,6 @@ void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const auto KEYBOARD = wlr_seat_get_keyboard(m_sSeat.seat);
|
const auto KEYBOARD = wlr_seat_get_keyboard(m_sSeat.seat);
|
||||||
|
|
||||||
if (!KEYBOARD)
|
if (!KEYBOARD)
|
||||||
|
@ -846,7 +853,7 @@ void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) {
|
||||||
g_pInputManager->m_sIMERelay.onKeyboardFocus(pSurface);
|
g_pInputManager->m_sIMERelay.onKeyboardFocus(pSurface);
|
||||||
|
|
||||||
wlr_seat_keyboard_focus_change_event event = {
|
wlr_seat_keyboard_focus_change_event event = {
|
||||||
.seat = m_sSeat.seat,
|
.seat = m_sSeat.seat,
|
||||||
.old_surface = m_pLastFocus,
|
.old_surface = m_pLastFocus,
|
||||||
.new_surface = pSurface,
|
.new_surface = pSurface,
|
||||||
};
|
};
|
||||||
|
@ -889,7 +896,8 @@ CWindow* CCompositor::getWindowForPopup(wlr_xdg_popup* popup) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_surface* CCompositor::vectorToLayerSurface(const Vector2D& pos, std::vector<std::unique_ptr<SLayerSurface>>* layerSurfaces, Vector2D* sCoords, SLayerSurface** ppLayerSurfaceFound) {
|
wlr_surface* CCompositor::vectorToLayerSurface(const Vector2D& pos, std::vector<std::unique_ptr<SLayerSurface>>* layerSurfaces, Vector2D* sCoords,
|
||||||
|
SLayerSurface** ppLayerSurfaceFound) {
|
||||||
for (auto it = layerSurfaces->rbegin(); it != layerSurfaces->rend(); it++) {
|
for (auto it = layerSurfaces->rbegin(); it != layerSurfaces->rend(); it++) {
|
||||||
if ((*it)->fadingOut || !(*it)->layerSurface || ((*it)->layerSurface && !(*it)->layerSurface->mapped) || (*it)->alpha.fl() == 0.f)
|
if ((*it)->fadingOut || !(*it)->layerSurface || ((*it)->layerSurface && !(*it)->layerSurface->mapped) || (*it)->alpha.fl() == 0.f)
|
||||||
continue;
|
continue;
|
||||||
|
@ -1096,7 +1104,7 @@ void CCompositor::cleanupFadingOut(const int& monid) {
|
||||||
|
|
||||||
Debug::log(LOG, "Cleanup: destroyed a window");
|
Debug::log(LOG, "Cleanup: destroyed a window");
|
||||||
|
|
||||||
glFlush(); // to free mem NOW.
|
glFlush(); // to free mem NOW.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1123,7 +1131,7 @@ void CCompositor::cleanupFadingOut(const int& monid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
m_vSurfacesFadingOut.erase(std::remove(m_vSurfacesFadingOut.begin(), m_vSurfacesFadingOut.end(), ls));
|
std::erase(m_vSurfacesFadingOut, ls);
|
||||||
|
|
||||||
Debug::log(LOG, "Fading out a non-existent LS??");
|
Debug::log(LOG, "Fading out a non-existent LS??");
|
||||||
|
|
||||||
|
@ -1144,16 +1152,16 @@ void CCompositor::cleanupFadingOut(const int& monid) {
|
||||||
for (auto& m : m_vMonitors) {
|
for (auto& m : m_vMonitors) {
|
||||||
for (auto& lsl : m->m_aLayerSurfaceLists) {
|
for (auto& lsl : m->m_aLayerSurfaceLists) {
|
||||||
if (!lsl.empty() && std::find_if(lsl.begin(), lsl.end(), [&](std::unique_ptr<SLayerSurface>& other) { return other.get() == ls; }) != lsl.end()) {
|
if (!lsl.empty() && std::find_if(lsl.begin(), lsl.end(), [&](std::unique_ptr<SLayerSurface>& other) { return other.get() == ls; }) != lsl.end()) {
|
||||||
lsl.erase(std::remove_if(lsl.begin(), lsl.end(), [&](std::unique_ptr<SLayerSurface>& other) { return other.get() == ls; }));
|
std::erase_if(lsl, [&](std::unique_ptr<SLayerSurface>& other) { return other.get() == ls; });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vSurfacesFadingOut.erase(std::remove(m_vSurfacesFadingOut.begin(), m_vSurfacesFadingOut.end(), ls));
|
std::erase(m_vSurfacesFadingOut, ls);
|
||||||
|
|
||||||
Debug::log(LOG, "Cleanup: destroyed a layersurface");
|
Debug::log(LOG, "Cleanup: destroyed a layersurface");
|
||||||
|
|
||||||
glFlush(); // to free mem NOW.
|
glFlush(); // to free mem NOW.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1163,7 +1171,7 @@ void CCompositor::addToFadingOutSafe(SLayerSurface* pLS) {
|
||||||
const auto FOUND = std::find_if(m_vSurfacesFadingOut.begin(), m_vSurfacesFadingOut.end(), [&](SLayerSurface* other) { return other == pLS; });
|
const auto FOUND = std::find_if(m_vSurfacesFadingOut.begin(), m_vSurfacesFadingOut.end(), [&](SLayerSurface* other) { return other == pLS; });
|
||||||
|
|
||||||
if (FOUND != m_vSurfacesFadingOut.end())
|
if (FOUND != m_vSurfacesFadingOut.end())
|
||||||
return; // if it's already added, don't add it.
|
return; // if it's already added, don't add it.
|
||||||
|
|
||||||
m_vSurfacesFadingOut.emplace_back(pLS);
|
m_vSurfacesFadingOut.emplace_back(pLS);
|
||||||
}
|
}
|
||||||
|
@ -1172,7 +1180,7 @@ void CCompositor::addToFadingOutSafe(CWindow* pWindow) {
|
||||||
const auto FOUND = std::find_if(m_vWindowsFadingOut.begin(), m_vWindowsFadingOut.end(), [&](CWindow* other) { return other == pWindow; });
|
const auto FOUND = std::find_if(m_vWindowsFadingOut.begin(), m_vWindowsFadingOut.end(), [&](CWindow* other) { return other == pWindow; });
|
||||||
|
|
||||||
if (FOUND != m_vWindowsFadingOut.end())
|
if (FOUND != m_vWindowsFadingOut.end())
|
||||||
return; // if it's already added, don't add it.
|
return; // if it's already added, don't add it.
|
||||||
|
|
||||||
m_vWindowsFadingOut.emplace_back(pWindow);
|
m_vWindowsFadingOut.emplace_back(pWindow);
|
||||||
}
|
}
|
||||||
|
@ -1181,11 +1189,11 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
||||||
|
|
||||||
const auto WINDOWIDEALBB = pWindow->getWindowIdealBoundingBoxIgnoreReserved();
|
const auto WINDOWIDEALBB = pWindow->getWindowIdealBoundingBoxIgnoreReserved();
|
||||||
|
|
||||||
const auto POSA = Vector2D(WINDOWIDEALBB.x, WINDOWIDEALBB.y);
|
const auto POSA = Vector2D(WINDOWIDEALBB.x, WINDOWIDEALBB.y);
|
||||||
const auto SIZEA = Vector2D(WINDOWIDEALBB.width, WINDOWIDEALBB.height);
|
const auto SIZEA = Vector2D(WINDOWIDEALBB.width, WINDOWIDEALBB.height);
|
||||||
|
|
||||||
auto longestIntersect = -1;
|
auto longestIntersect = -1;
|
||||||
CWindow* longestIntersectWindow = nullptr;
|
CWindow* longestIntersectWindow = nullptr;
|
||||||
|
|
||||||
for (auto& w : m_vWindows) {
|
for (auto& w : m_vWindows) {
|
||||||
if (w.get() == pWindow || !w->m_bIsMapped || w->isHidden() || w->m_bIsFloating || !isWorkspaceVisible(w->m_iWorkspaceID))
|
if (w.get() == pWindow || !w->m_bIsMapped || w->isHidden() || w->m_bIsFloating || !isWorkspaceVisible(w->m_iWorkspaceID))
|
||||||
|
@ -1197,7 +1205,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
||||||
|
|
||||||
const auto BWINDOWIDEALBB = w->getWindowIdealBoundingBoxIgnoreReserved();
|
const auto BWINDOWIDEALBB = w->getWindowIdealBoundingBoxIgnoreReserved();
|
||||||
|
|
||||||
const auto POSB = Vector2D(BWINDOWIDEALBB.x, BWINDOWIDEALBB.y);
|
const auto POSB = Vector2D(BWINDOWIDEALBB.x, BWINDOWIDEALBB.y);
|
||||||
const auto SIZEB = Vector2D(BWINDOWIDEALBB.width, BWINDOWIDEALBB.height);
|
const auto SIZEB = Vector2D(BWINDOWIDEALBB.width, BWINDOWIDEALBB.height);
|
||||||
|
|
||||||
switch (dir) {
|
switch (dir) {
|
||||||
|
@ -1205,7 +1213,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
||||||
if (STICKS(POSA.x, POSB.x + SIZEB.x)) {
|
if (STICKS(POSA.x, POSB.x + SIZEB.x)) {
|
||||||
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y));
|
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y));
|
||||||
if (INTERSECTLEN > longestIntersect) {
|
if (INTERSECTLEN > longestIntersect) {
|
||||||
longestIntersect = INTERSECTLEN;
|
longestIntersect = INTERSECTLEN;
|
||||||
longestIntersectWindow = w.get();
|
longestIntersectWindow = w.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1214,7 +1222,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
||||||
if (STICKS(POSA.x + SIZEA.x, POSB.x)) {
|
if (STICKS(POSA.x + SIZEA.x, POSB.x)) {
|
||||||
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y));
|
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y));
|
||||||
if (INTERSECTLEN > longestIntersect) {
|
if (INTERSECTLEN > longestIntersect) {
|
||||||
longestIntersect = INTERSECTLEN;
|
longestIntersect = INTERSECTLEN;
|
||||||
longestIntersectWindow = w.get();
|
longestIntersectWindow = w.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1224,7 +1232,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
||||||
if (STICKS(POSA.y, POSB.y + SIZEB.y)) {
|
if (STICKS(POSA.y, POSB.y + SIZEB.y)) {
|
||||||
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x));
|
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x));
|
||||||
if (INTERSECTLEN > longestIntersect) {
|
if (INTERSECTLEN > longestIntersect) {
|
||||||
longestIntersect = INTERSECTLEN;
|
longestIntersect = INTERSECTLEN;
|
||||||
longestIntersectWindow = w.get();
|
longestIntersectWindow = w.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1234,7 +1242,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
||||||
if (STICKS(POSA.y + SIZEA.y, POSB.y)) {
|
if (STICKS(POSA.y + SIZEA.y, POSB.y)) {
|
||||||
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x));
|
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x));
|
||||||
if (INTERSECTLEN > longestIntersect) {
|
if (INTERSECTLEN > longestIntersect) {
|
||||||
longestIntersect = INTERSECTLEN;
|
longestIntersect = INTERSECTLEN;
|
||||||
longestIntersectWindow = w.get();
|
longestIntersectWindow = w.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1328,9 +1336,7 @@ CWorkspace* CCompositor::getWorkspaceByString(const std::string& str) {
|
||||||
try {
|
try {
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
return getWorkspaceByID(getWorkspaceIDFromString(str, name));
|
return getWorkspaceByID(getWorkspaceIDFromString(str, name));
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) { Debug::log(ERR, "Error in getWorkspaceByString, invalid id"); }
|
||||||
Debug::log(ERR, "Error in getWorkspaceByString, invalid id");
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -1345,7 +1351,7 @@ bool CCompositor::isPointOnAnyMonitor(const Vector2D& point) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkFocusSurfaceIter(wlr_surface* pSurface, int x, int y, void* data) {
|
void checkFocusSurfaceIter(wlr_surface* pSurface, int x, int y, void* data) {
|
||||||
auto pair = (std::pair<wlr_surface*, bool>*)data;
|
auto pair = (std::pair<wlr_surface*, bool>*)data;
|
||||||
pair->second = pair->second || pSurface == pair->first;
|
pair->second = pair->second || pSurface == pair->first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1375,24 +1381,24 @@ CWindow* CCompositor::getConstraintWindow(SMouse* pMouse) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CMonitor* CCompositor::getMonitorInDirection(const char& dir) {
|
CMonitor* CCompositor::getMonitorInDirection(const char& dir) {
|
||||||
const auto POSA = m_pLastMonitor->vecPosition;
|
const auto POSA = m_pLastMonitor->vecPosition;
|
||||||
const auto SIZEA = m_pLastMonitor->vecSize;
|
const auto SIZEA = m_pLastMonitor->vecSize;
|
||||||
|
|
||||||
auto longestIntersect = -1;
|
auto longestIntersect = -1;
|
||||||
CMonitor* longestIntersectMonitor = nullptr;
|
CMonitor* longestIntersectMonitor = nullptr;
|
||||||
|
|
||||||
for (auto& m : m_vMonitors) {
|
for (auto& m : m_vMonitors) {
|
||||||
if (m.get() == m_pLastMonitor)
|
if (m.get() == m_pLastMonitor)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const auto POSB = m->vecPosition;
|
const auto POSB = m->vecPosition;
|
||||||
const auto SIZEB = m->vecSize;
|
const auto SIZEB = m->vecSize;
|
||||||
switch (dir) {
|
switch (dir) {
|
||||||
case 'l':
|
case 'l':
|
||||||
if (STICKS(POSA.x, POSB.x + SIZEB.x)) {
|
if (STICKS(POSA.x, POSB.x + SIZEB.x)) {
|
||||||
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y));
|
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y));
|
||||||
if (INTERSECTLEN > longestIntersect) {
|
if (INTERSECTLEN > longestIntersect) {
|
||||||
longestIntersect = INTERSECTLEN;
|
longestIntersect = INTERSECTLEN;
|
||||||
longestIntersectMonitor = m.get();
|
longestIntersectMonitor = m.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1401,7 +1407,7 @@ CMonitor* CCompositor::getMonitorInDirection(const char& dir) {
|
||||||
if (STICKS(POSA.x + SIZEA.x, POSB.x)) {
|
if (STICKS(POSA.x + SIZEA.x, POSB.x)) {
|
||||||
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y));
|
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.y + SIZEA.y, POSB.y + SIZEB.y) - std::max(POSA.y, POSB.y));
|
||||||
if (INTERSECTLEN > longestIntersect) {
|
if (INTERSECTLEN > longestIntersect) {
|
||||||
longestIntersect = INTERSECTLEN;
|
longestIntersect = INTERSECTLEN;
|
||||||
longestIntersectMonitor = m.get();
|
longestIntersectMonitor = m.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1411,7 +1417,7 @@ CMonitor* CCompositor::getMonitorInDirection(const char& dir) {
|
||||||
if (STICKS(POSA.y, POSB.y + SIZEB.y)) {
|
if (STICKS(POSA.y, POSB.y + SIZEB.y)) {
|
||||||
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x));
|
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x));
|
||||||
if (INTERSECTLEN > longestIntersect) {
|
if (INTERSECTLEN > longestIntersect) {
|
||||||
longestIntersect = INTERSECTLEN;
|
longestIntersect = INTERSECTLEN;
|
||||||
longestIntersectMonitor = m.get();
|
longestIntersectMonitor = m.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1421,7 +1427,7 @@ CMonitor* CCompositor::getMonitorInDirection(const char& dir) {
|
||||||
if (STICKS(POSA.y + SIZEA.y, POSB.y)) {
|
if (STICKS(POSA.y + SIZEA.y, POSB.y)) {
|
||||||
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x));
|
const auto INTERSECTLEN = std::max(0.0, std::min(POSA.x + SIZEA.x, POSB.x + SIZEB.x) - std::max(POSA.x, POSB.x));
|
||||||
if (INTERSECTLEN > longestIntersect) {
|
if (INTERSECTLEN > longestIntersect) {
|
||||||
longestIntersect = INTERSECTLEN;
|
longestIntersect = INTERSECTLEN;
|
||||||
longestIntersectMonitor = m.get();
|
longestIntersectMonitor = m.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1446,22 +1452,21 @@ void CCompositor::updateAllWindowsAnimatedDecorationValues() {
|
||||||
|
|
||||||
void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
|
void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
|
||||||
// optimization
|
// optimization
|
||||||
static auto *const ACTIVECOL = (CGradientValueData*)g_pConfigManager->getConfigValuePtr("general:col.active_border")->data.get();
|
static auto* const ACTIVECOL = (CGradientValueData*)g_pConfigManager->getConfigValuePtr("general:col.active_border")->data.get();
|
||||||
static auto *const INACTIVECOL = (CGradientValueData*)g_pConfigManager->getConfigValuePtr("general:col.inactive_border")->data.get();
|
static auto* const INACTIVECOL = (CGradientValueData*)g_pConfigManager->getConfigValuePtr("general:col.inactive_border")->data.get();
|
||||||
static auto *const PINACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:inactive_opacity")->floatValue;
|
static auto* const PINACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:inactive_opacity")->floatValue;
|
||||||
static auto *const PACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:active_opacity")->floatValue;
|
static auto* const PACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:active_opacity")->floatValue;
|
||||||
static auto *const PFULLSCREENALPHA = &g_pConfigManager->getConfigValuePtr("decoration:fullscreen_opacity")->floatValue;
|
static auto* const PFULLSCREENALPHA = &g_pConfigManager->getConfigValuePtr("decoration:fullscreen_opacity")->floatValue;
|
||||||
static auto *const PSHADOWCOL = &g_pConfigManager->getConfigValuePtr("decoration:col.shadow")->intValue;
|
static auto* const PSHADOWCOL = &g_pConfigManager->getConfigValuePtr("decoration:col.shadow")->intValue;
|
||||||
static auto *const PSHADOWCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("decoration:col.shadow_inactive")->intValue;
|
static auto* const PSHADOWCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("decoration:col.shadow_inactive")->intValue;
|
||||||
static auto *const PDIMSTRENGTH = &g_pConfigManager->getConfigValuePtr("decoration:dim_strength")->floatValue;
|
static auto* const PDIMSTRENGTH = &g_pConfigManager->getConfigValuePtr("decoration:dim_strength")->floatValue;
|
||||||
|
|
||||||
auto setBorderColor = [&] (CGradientValueData grad) -> void {
|
|
||||||
|
|
||||||
|
auto setBorderColor = [&](CGradientValueData grad) -> void {
|
||||||
if (grad == pWindow->m_cRealBorderColor)
|
if (grad == pWindow->m_cRealBorderColor)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pWindow->m_cRealBorderColorPrevious = pWindow->m_cRealBorderColor;
|
pWindow->m_cRealBorderColorPrevious = pWindow->m_cRealBorderColor;
|
||||||
pWindow->m_cRealBorderColor = grad;
|
pWindow->m_cRealBorderColor = grad;
|
||||||
pWindow->m_fBorderAnimationProgress.setValueAndWarp(0.f);
|
pWindow->m_fBorderAnimationProgress.setValueAndWarp(0.f);
|
||||||
pWindow->m_fBorderAnimationProgress = 1.f;
|
pWindow->m_fBorderAnimationProgress = 1.f;
|
||||||
};
|
};
|
||||||
|
@ -1471,10 +1476,11 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
|
||||||
if (RENDERDATA.isBorderColor)
|
if (RENDERDATA.isBorderColor)
|
||||||
setBorderColor(RENDERDATA.borderColor * (1.f / 255.f));
|
setBorderColor(RENDERDATA.borderColor * (1.f / 255.f));
|
||||||
else
|
else
|
||||||
setBorderColor(pWindow == m_pLastWindow ?
|
setBorderColor(
|
||||||
(pWindow->m_sSpecialRenderData.activeBorderColor >= 0 ? CGradientValueData(CColor(pWindow->m_sSpecialRenderData.activeBorderColor) * (1.f / 255.f)) : *ACTIVECOL) :
|
pWindow == m_pLastWindow ?
|
||||||
(pWindow->m_sSpecialRenderData.inactiveBorderColor >= 0 ? CGradientValueData(CColor(pWindow->m_sSpecialRenderData.inactiveBorderColor) * (1.f / 255.f)) : *INACTIVECOL));
|
(pWindow->m_sSpecialRenderData.activeBorderColor >= 0 ? CGradientValueData(CColor(pWindow->m_sSpecialRenderData.activeBorderColor) * (1.f / 255.f)) : *ACTIVECOL) :
|
||||||
|
(pWindow->m_sSpecialRenderData.inactiveBorderColor >= 0 ? CGradientValueData(CColor(pWindow->m_sSpecialRenderData.inactiveBorderColor) * (1.f / 255.f)) :
|
||||||
|
*INACTIVECOL));
|
||||||
|
|
||||||
// opacity
|
// opacity
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
||||||
|
@ -1482,9 +1488,13 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
|
||||||
pWindow->m_fActiveInactiveAlpha = *PFULLSCREENALPHA;
|
pWindow->m_fActiveInactiveAlpha = *PFULLSCREENALPHA;
|
||||||
} else {
|
} else {
|
||||||
if (pWindow == m_pLastWindow)
|
if (pWindow == m_pLastWindow)
|
||||||
pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alphaOverride ? pWindow->m_sSpecialRenderData.alpha : pWindow->m_sSpecialRenderData.alpha * *PACTIVEALPHA;
|
pWindow->m_fActiveInactiveAlpha =
|
||||||
|
pWindow->m_sSpecialRenderData.alphaOverride ? pWindow->m_sSpecialRenderData.alpha : pWindow->m_sSpecialRenderData.alpha * *PACTIVEALPHA;
|
||||||
else
|
else
|
||||||
pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alphaInactive != -1 ? (pWindow->m_sSpecialRenderData.alphaInactiveOverride ? pWindow->m_sSpecialRenderData.alphaInactive : pWindow->m_sSpecialRenderData.alphaInactive * *PINACTIVEALPHA) : *PINACTIVEALPHA;
|
pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alphaInactive != -1 ?
|
||||||
|
(pWindow->m_sSpecialRenderData.alphaInactiveOverride ? pWindow->m_sSpecialRenderData.alphaInactive :
|
||||||
|
pWindow->m_sSpecialRenderData.alphaInactive * *PINACTIVEALPHA) :
|
||||||
|
*PINACTIVEALPHA;
|
||||||
}
|
}
|
||||||
|
|
||||||
// dim
|
// dim
|
||||||
|
@ -1534,7 +1544,7 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
|
||||||
|
|
||||||
if (w->m_bIsFullscreen) {
|
if (w->m_bIsFullscreen) {
|
||||||
w->m_vRealPosition = pMonitorB->vecPosition;
|
w->m_vRealPosition = pMonitorB->vecPosition;
|
||||||
w->m_vRealSize = pMonitorB->vecSize;
|
w->m_vRealSize = pMonitorB->vecSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
w->updateToplevel();
|
w->updateToplevel();
|
||||||
|
@ -1554,7 +1564,7 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
|
||||||
|
|
||||||
if (w->m_bIsFullscreen) {
|
if (w->m_bIsFullscreen) {
|
||||||
w->m_vRealPosition = pMonitorA->vecPosition;
|
w->m_vRealPosition = pMonitorA->vecPosition;
|
||||||
w->m_vRealSize = pMonitorA->vecSize;
|
w->m_vRealSize = pMonitorA->vecSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
w->updateToplevel();
|
w->updateToplevel();
|
||||||
|
@ -1596,7 +1606,7 @@ CMonitor* CCompositor::getMonitorFromString(const std::string& name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int offsetLeft = std::stoi(OFFSET);
|
int offsetLeft = std::stoi(OFFSET);
|
||||||
offsetLeft = offsetLeft < 0 ? -((-offsetLeft) % m_vMonitors.size()) : offsetLeft % m_vMonitors.size();
|
offsetLeft = offsetLeft < 0 ? -((-offsetLeft) % m_vMonitors.size()) : offsetLeft % m_vMonitors.size();
|
||||||
|
|
||||||
int currentPlace = 0;
|
int currentPlace = 0;
|
||||||
for (int i = 0; i < (int)m_vMonitors.size(); i++) {
|
for (int i = 0; i < (int)m_vMonitors.size(); i++) {
|
||||||
|
@ -1683,7 +1693,10 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
|
||||||
if (nextWorkspaceOnMonitorID == -1) {
|
if (nextWorkspaceOnMonitorID == -1) {
|
||||||
nextWorkspaceOnMonitorID = 1;
|
nextWorkspaceOnMonitorID = 1;
|
||||||
|
|
||||||
while (getWorkspaceByID(nextWorkspaceOnMonitorID) || [&]() -> bool { const auto B = g_pConfigManager->getBoundMonitorForWS(std::to_string(nextWorkspaceOnMonitorID)); return B && B != POLDMON; }())
|
while (getWorkspaceByID(nextWorkspaceOnMonitorID) || [&]() -> bool {
|
||||||
|
const auto B = g_pConfigManager->getBoundMonitorForWS(std::to_string(nextWorkspaceOnMonitorID));
|
||||||
|
return B && B != POLDMON;
|
||||||
|
}())
|
||||||
nextWorkspaceOnMonitorID++;
|
nextWorkspaceOnMonitorID++;
|
||||||
|
|
||||||
Debug::log(LOG, "moveWorkspaceToMonitor: Plugging gap with new %d", nextWorkspaceOnMonitorID);
|
Debug::log(LOG, "moveWorkspaceToMonitor: Plugging gap with new %d", nextWorkspaceOnMonitorID);
|
||||||
|
@ -1710,7 +1723,7 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
|
||||||
|
|
||||||
if (w->m_bIsFullscreen) {
|
if (w->m_bIsFullscreen) {
|
||||||
w->m_vRealPosition = pMonitor->vecPosition;
|
w->m_vRealPosition = pMonitor->vecPosition;
|
||||||
w->m_vRealSize = pMonitor->vecSize;
|
w->m_vRealSize = pMonitor->vecSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1729,7 +1742,8 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
|
||||||
|
|
||||||
pWorkspace->startAnim(true, true, true);
|
pWorkspace->startAnim(true, true, true);
|
||||||
|
|
||||||
wlr_cursor_warp(m_sWLRCursor, m_sSeat.mouse->mouse, pMonitor->vecPosition.x + pMonitor->vecTransformedSize.x / 2, pMonitor->vecPosition.y + pMonitor->vecTransformedSize.y / 2);
|
wlr_cursor_warp(m_sWLRCursor, m_sSeat.mouse->mouse, pMonitor->vecPosition.x + pMonitor->vecTransformedSize.x / 2,
|
||||||
|
pMonitor->vecPosition.y + pMonitor->vecTransformedSize.y / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finalize
|
// finalize
|
||||||
|
@ -1742,7 +1756,7 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCompositor::workspaceIDOutOfBounds(const int& id) {
|
bool CCompositor::workspaceIDOutOfBounds(const int& id) {
|
||||||
int lowestID = 99999;
|
int lowestID = 99999;
|
||||||
int highestID = -99999;
|
int highestID = -99999;
|
||||||
|
|
||||||
for (auto& w : m_vWorkspaces) {
|
for (auto& w : m_vWorkspaces) {
|
||||||
|
@ -1855,16 +1869,16 @@ void CCompositor::scheduleFrameForMonitor(CMonitor* pMonitor) {
|
||||||
CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
|
CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
|
||||||
eFocusWindowMode mode = MODE_CLASS_REGEX;
|
eFocusWindowMode mode = MODE_CLASS_REGEX;
|
||||||
|
|
||||||
std::regex regexCheck(regexp);
|
std::regex regexCheck(regexp);
|
||||||
std::string matchCheck;
|
std::string matchCheck;
|
||||||
if (regexp.find("title:") == 0) {
|
if (regexp.find("title:") == 0) {
|
||||||
mode = MODE_TITLE_REGEX;
|
mode = MODE_TITLE_REGEX;
|
||||||
regexCheck = std::regex(regexp.substr(6));
|
regexCheck = std::regex(regexp.substr(6));
|
||||||
} else if (regexp.find("address:") == 0) {
|
} else if (regexp.find("address:") == 0) {
|
||||||
mode = MODE_ADDRESS;
|
mode = MODE_ADDRESS;
|
||||||
matchCheck = regexp.substr(8);
|
matchCheck = regexp.substr(8);
|
||||||
} else if (regexp.find("pid:") == 0) {
|
} else if (regexp.find("pid:") == 0) {
|
||||||
mode = MODE_PID;
|
mode = MODE_PID;
|
||||||
matchCheck = regexp.substr(4);
|
matchCheck = regexp.substr(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1897,8 +1911,7 @@ CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
|
||||||
continue;
|
continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return w.get();
|
return w.get();
|
||||||
|
@ -1912,7 +1925,7 @@ void CCompositor::warpCursorTo(const Vector2D& pos) {
|
||||||
// warpCursorTo should only be used for warps that
|
// warpCursorTo should only be used for warps that
|
||||||
// should be disabled with no_cursor_warps
|
// should be disabled with no_cursor_warps
|
||||||
|
|
||||||
static auto *const PNOWARPS = &g_pConfigManager->getConfigValuePtr("general:no_cursor_warps")->intValue;
|
static auto* const PNOWARPS = &g_pConfigManager->getConfigValuePtr("general:no_cursor_warps")->intValue;
|
||||||
|
|
||||||
if (*PNOWARPS)
|
if (*PNOWARPS)
|
||||||
return;
|
return;
|
||||||
|
@ -2015,8 +2028,8 @@ bool CCompositor::cursorOnReservedArea() {
|
||||||
}
|
}
|
||||||
|
|
||||||
CWorkspace* CCompositor::createNewWorkspace(const int& id, const int& monid, const std::string& name) {
|
CWorkspace* CCompositor::createNewWorkspace(const int& id, const int& monid, const std::string& name) {
|
||||||
const auto NAME = name == "" ? std::to_string(id) : name;
|
const auto NAME = name == "" ? std::to_string(id) : name;
|
||||||
auto monID = monid;
|
auto monID = monid;
|
||||||
|
|
||||||
// check if bound
|
// check if bound
|
||||||
if (const auto PMONITOR = g_pConfigManager->getBoundMonitorForWS(NAME); PMONITOR) {
|
if (const auto PMONITOR = g_pConfigManager->getBoundMonitorForWS(NAME); PMONITOR) {
|
||||||
|
@ -2031,7 +2044,7 @@ CWorkspace* CCompositor::createNewWorkspace(const int& id, const int& monid, con
|
||||||
if (!SPECIAL)
|
if (!SPECIAL)
|
||||||
wlr_ext_workspace_handle_v1_set_name(PWORKSPACE->m_pWlrHandle, NAME.c_str());
|
wlr_ext_workspace_handle_v1_set_name(PWORKSPACE->m_pWlrHandle, NAME.c_str());
|
||||||
|
|
||||||
PWORKSPACE->m_iID = id;
|
PWORKSPACE->m_iID = id;
|
||||||
PWORKSPACE->m_iMonitorID = monID;
|
PWORKSPACE->m_iMonitorID = monID;
|
||||||
|
|
||||||
return PWORKSPACE;
|
return PWORKSPACE;
|
||||||
|
|
|
@ -25,180 +25,177 @@
|
||||||
#include "hyprerror/HyprError.hpp"
|
#include "hyprerror/HyprError.hpp"
|
||||||
|
|
||||||
class CCompositor {
|
class CCompositor {
|
||||||
public:
|
public:
|
||||||
CCompositor();
|
CCompositor();
|
||||||
~CCompositor();
|
~CCompositor();
|
||||||
|
|
||||||
// ------------------ WLR BASICS ------------------ //
|
// ------------------ WLR BASICS ------------------ //
|
||||||
wl_display* m_sWLDisplay;
|
wl_display* m_sWLDisplay;
|
||||||
wl_event_loop* m_sWLEventLoop;
|
wl_event_loop* m_sWLEventLoop;
|
||||||
wlr_backend* m_sWLRBackend;
|
wlr_backend* m_sWLRBackend;
|
||||||
wlr_session* m_sWLRSession;
|
wlr_session* m_sWLRSession;
|
||||||
wlr_renderer* m_sWLRRenderer;
|
wlr_renderer* m_sWLRRenderer;
|
||||||
wlr_allocator* m_sWLRAllocator;
|
wlr_allocator* m_sWLRAllocator;
|
||||||
wlr_compositor* m_sWLRCompositor;
|
wlr_compositor* m_sWLRCompositor;
|
||||||
wlr_subcompositor* m_sWLRSubCompositor;
|
wlr_subcompositor* m_sWLRSubCompositor;
|
||||||
wlr_data_device_manager* m_sWLRDataDevMgr;
|
wlr_data_device_manager* m_sWLRDataDevMgr;
|
||||||
wlr_drm* m_sWRLDRM;
|
wlr_drm* m_sWRLDRM;
|
||||||
wlr_drm_lease_v1_manager* m_sWRLDRMLeaseMgr;
|
wlr_drm_lease_v1_manager* m_sWRLDRMLeaseMgr;
|
||||||
wlr_xdg_activation_v1* m_sWLRXDGActivation;
|
wlr_xdg_activation_v1* m_sWLRXDGActivation;
|
||||||
wlr_output_layout* m_sWLROutputLayout;
|
wlr_output_layout* m_sWLROutputLayout;
|
||||||
wlr_idle* m_sWLRIdle;
|
wlr_idle* m_sWLRIdle;
|
||||||
wlr_layer_shell_v1* m_sWLRLayerShell;
|
wlr_layer_shell_v1* m_sWLRLayerShell;
|
||||||
wlr_xdg_shell* m_sWLRXDGShell;
|
wlr_xdg_shell* m_sWLRXDGShell;
|
||||||
wlr_cursor* m_sWLRCursor;
|
wlr_cursor* m_sWLRCursor;
|
||||||
wlr_xcursor_manager* m_sWLRXCursorMgr;
|
wlr_xcursor_manager* m_sWLRXCursorMgr;
|
||||||
wlr_virtual_keyboard_manager_v1* m_sWLRVKeyboardMgr;
|
wlr_virtual_keyboard_manager_v1* m_sWLRVKeyboardMgr;
|
||||||
wlr_output_manager_v1* m_sWLROutputMgr;
|
wlr_output_manager_v1* m_sWLROutputMgr;
|
||||||
wlr_presentation* m_sWLRPresentation;
|
wlr_presentation* m_sWLRPresentation;
|
||||||
wlr_scene* m_sWLRScene;
|
wlr_scene* m_sWLRScene;
|
||||||
wlr_input_inhibit_manager* m_sWLRInhibitMgr;
|
wlr_input_inhibit_manager* m_sWLRInhibitMgr;
|
||||||
wlr_keyboard_shortcuts_inhibit_manager_v1* m_sWLRKbShInhibitMgr;
|
wlr_keyboard_shortcuts_inhibit_manager_v1* m_sWLRKbShInhibitMgr;
|
||||||
wlr_egl* m_sWLREGL;
|
wlr_egl* m_sWLREGL;
|
||||||
int m_iDRMFD;
|
int m_iDRMFD;
|
||||||
wlr_ext_workspace_manager_v1* m_sWLREXTWorkspaceMgr;
|
wlr_ext_workspace_manager_v1* m_sWLREXTWorkspaceMgr;
|
||||||
wlr_pointer_constraints_v1* m_sWLRPointerConstraints;
|
wlr_pointer_constraints_v1* m_sWLRPointerConstraints;
|
||||||
wlr_relative_pointer_manager_v1* m_sWLRRelPointerMgr;
|
wlr_relative_pointer_manager_v1* m_sWLRRelPointerMgr;
|
||||||
wlr_server_decoration_manager* m_sWLRServerDecoMgr;
|
wlr_server_decoration_manager* m_sWLRServerDecoMgr;
|
||||||
wlr_xdg_decoration_manager_v1* m_sWLRXDGDecoMgr;
|
wlr_xdg_decoration_manager_v1* m_sWLRXDGDecoMgr;
|
||||||
wlr_virtual_pointer_manager_v1* m_sWLRVirtPtrMgr;
|
wlr_virtual_pointer_manager_v1* m_sWLRVirtPtrMgr;
|
||||||
wlr_foreign_toplevel_manager_v1* m_sWLRToplevelMgr;
|
wlr_foreign_toplevel_manager_v1* m_sWLRToplevelMgr;
|
||||||
wlr_tablet_manager_v2* m_sWLRTabletManager;
|
wlr_tablet_manager_v2* m_sWLRTabletManager;
|
||||||
wlr_xdg_foreign_registry* m_sWLRForeignRegistry;
|
wlr_xdg_foreign_registry* m_sWLRForeignRegistry;
|
||||||
wlr_idle_inhibit_manager_v1* m_sWLRIdleInhibitMgr;
|
wlr_idle_inhibit_manager_v1* m_sWLRIdleInhibitMgr;
|
||||||
wlr_pointer_gestures_v1* m_sWLRPointerGestures;
|
wlr_pointer_gestures_v1* m_sWLRPointerGestures;
|
||||||
wlr_output_power_manager_v1* m_sWLROutputPowerMgr;
|
wlr_output_power_manager_v1* m_sWLROutputPowerMgr;
|
||||||
wlr_input_method_manager_v2* m_sWLRIMEMgr;
|
wlr_input_method_manager_v2* m_sWLRIMEMgr;
|
||||||
wlr_text_input_manager_v3* m_sWLRTextInputMgr;
|
wlr_text_input_manager_v3* m_sWLRTextInputMgr;
|
||||||
wlr_xdg_activation_v1* m_sWLRActivation;
|
wlr_xdg_activation_v1* m_sWLRActivation;
|
||||||
wlr_linux_dmabuf_v1* m_sWLRLinuxDMABuf;
|
wlr_linux_dmabuf_v1* m_sWLRLinuxDMABuf;
|
||||||
wlr_backend* m_sWLRHeadlessBackend;
|
wlr_backend* m_sWLRHeadlessBackend;
|
||||||
// ------------------------------------------------- //
|
// ------------------------------------------------- //
|
||||||
|
|
||||||
|
std::string m_szWLDisplaySocket = "";
|
||||||
|
std::string m_szInstanceSignature = "";
|
||||||
|
std::string m_szCurrentSplash = "error";
|
||||||
|
|
||||||
std::string m_szWLDisplaySocket = "";
|
std::vector<std::shared_ptr<CMonitor>> m_vMonitors;
|
||||||
std::string m_szInstanceSignature = "";
|
std::vector<std::shared_ptr<CMonitor>> m_vRealMonitors; // for all monitors, even those turned off
|
||||||
std::string m_szCurrentSplash = "error";
|
std::vector<std::unique_ptr<CWindow>> m_vWindows;
|
||||||
|
std::deque<std::unique_ptr<CWindow>> m_dUnmanagedX11Windows;
|
||||||
|
std::vector<std::unique_ptr<SXDGPopup>> m_vXDGPopups;
|
||||||
|
std::vector<std::unique_ptr<CWorkspace>> m_vWorkspaces;
|
||||||
|
std::vector<std::unique_ptr<SSubsurface>> m_vSubsurfaces;
|
||||||
|
std::vector<CWindow*> m_vWindowsFadingOut;
|
||||||
|
std::vector<SLayerSurface*> m_vSurfacesFadingOut;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<CMonitor>> m_vMonitors;
|
void startCompositor();
|
||||||
std::vector<std::shared_ptr<CMonitor>> m_vRealMonitors; // for all monitors, even those turned off
|
void cleanup();
|
||||||
std::vector<std::unique_ptr<CWindow>> m_vWindows;
|
|
||||||
std::deque<std::unique_ptr<CWindow>> m_dUnmanagedX11Windows;
|
|
||||||
std::vector<std::unique_ptr<SXDGPopup>> m_vXDGPopups;
|
|
||||||
std::vector<std::unique_ptr<CWorkspace>> m_vWorkspaces;
|
|
||||||
std::vector<std::unique_ptr<SSubsurface>> m_vSubsurfaces;
|
|
||||||
std::vector<CWindow*> m_vWindowsFadingOut;
|
|
||||||
std::vector<SLayerSurface*> m_vSurfacesFadingOut;
|
|
||||||
|
|
||||||
void startCompositor();
|
wlr_surface* m_pLastFocus = nullptr;
|
||||||
void cleanup();
|
CWindow* m_pLastWindow = nullptr;
|
||||||
|
CMonitor* m_pLastMonitor = nullptr;
|
||||||
|
|
||||||
wlr_surface* m_pLastFocus = nullptr;
|
SSeat m_sSeat;
|
||||||
CWindow* m_pLastWindow = nullptr;
|
|
||||||
CMonitor* m_pLastMonitor = nullptr;
|
|
||||||
|
|
||||||
SSeat m_sSeat;
|
bool m_bReadyToProcess = false;
|
||||||
|
bool m_bSessionActive = true;
|
||||||
bool m_bReadyToProcess = false;
|
bool m_bDPMSStateON = true;
|
||||||
bool m_bSessionActive = true;
|
bool m_bUnsafeState = false; // unsafe state is when there is no monitors.
|
||||||
bool m_bDPMSStateON = true;
|
bool m_bIsShuttingDown = false;
|
||||||
bool m_bUnsafeState = false; // unsafe state is when there is no monitors.
|
std::deque<uint64_t> m_dProcessPIDsOnShutdown; // stores PIDs of apps to kill later when shutting down
|
||||||
bool m_bIsShuttingDown = false;
|
|
||||||
std::deque<uint64_t> m_dProcessPIDsOnShutdown; // stores PIDs of apps to kill later when shutting down
|
|
||||||
|
|
||||||
// ------------------------------------------------- //
|
// ------------------------------------------------- //
|
||||||
|
|
||||||
CMonitor* getMonitorFromID(const int&);
|
CMonitor* getMonitorFromID(const int&);
|
||||||
CMonitor* getMonitorFromName(const std::string&);
|
CMonitor* getMonitorFromName(const std::string&);
|
||||||
CMonitor* getMonitorFromCursor();
|
CMonitor* getMonitorFromCursor();
|
||||||
CMonitor* getMonitorFromVector(const Vector2D&);
|
CMonitor* getMonitorFromVector(const Vector2D&);
|
||||||
void removeWindowFromVectorSafe(CWindow*);
|
void removeWindowFromVectorSafe(CWindow*);
|
||||||
void focusWindow(CWindow*, wlr_surface* pSurface = nullptr);
|
void focusWindow(CWindow*, wlr_surface* pSurface = nullptr);
|
||||||
void focusSurface(wlr_surface*, CWindow* pWindowOwner = nullptr);
|
void focusSurface(wlr_surface*, CWindow* pWindowOwner = nullptr);
|
||||||
bool windowExists(CWindow*);
|
bool windowExists(CWindow*);
|
||||||
bool windowValidMapped(CWindow*);
|
bool windowValidMapped(CWindow*);
|
||||||
CWindow* vectorToWindow(const Vector2D&);
|
CWindow* vectorToWindow(const Vector2D&);
|
||||||
CWindow* vectorToWindowIdeal(const Vector2D&); // used only for finding a window to focus on, basically a "findFocusableWindow"
|
CWindow* vectorToWindowIdeal(const Vector2D&); // used only for finding a window to focus on, basically a "findFocusableWindow"
|
||||||
CWindow* vectorToWindowTiled(const Vector2D&);
|
CWindow* vectorToWindowTiled(const Vector2D&);
|
||||||
wlr_surface* vectorToLayerSurface(const Vector2D&, std::vector<std::unique_ptr<SLayerSurface>>*, Vector2D*, SLayerSurface**);
|
wlr_surface* vectorToLayerSurface(const Vector2D&, std::vector<std::unique_ptr<SLayerSurface>>*, Vector2D*, SLayerSurface**);
|
||||||
wlr_surface* vectorWindowToSurface(const Vector2D&, CWindow*, Vector2D& sl);
|
wlr_surface* vectorWindowToSurface(const Vector2D&, CWindow*, Vector2D& sl);
|
||||||
CWindow* windowFromCursor();
|
CWindow* windowFromCursor();
|
||||||
CWindow* windowFloatingFromCursor();
|
CWindow* windowFloatingFromCursor();
|
||||||
CMonitor* getMonitorFromOutput(wlr_output*);
|
CMonitor* getMonitorFromOutput(wlr_output*);
|
||||||
CWindow* getWindowForPopup(wlr_xdg_popup*);
|
CWindow* getWindowForPopup(wlr_xdg_popup*);
|
||||||
CWindow* getWindowFromSurface(wlr_surface*);
|
CWindow* getWindowFromSurface(wlr_surface*);
|
||||||
CWindow* getWindowFromHandle(uint32_t);
|
CWindow* getWindowFromHandle(uint32_t);
|
||||||
CWindow* getWindowFromZWLRHandle(wl_resource*);
|
CWindow* getWindowFromZWLRHandle(wl_resource*);
|
||||||
bool isWorkspaceVisible(const int&);
|
bool isWorkspaceVisible(const int&);
|
||||||
CWorkspace* getWorkspaceByID(const int&);
|
CWorkspace* getWorkspaceByID(const int&);
|
||||||
CWorkspace* getWorkspaceByName(const std::string&);
|
CWorkspace* getWorkspaceByName(const std::string&);
|
||||||
CWorkspace* getWorkspaceByString(const std::string&);
|
CWorkspace* getWorkspaceByString(const std::string&);
|
||||||
void sanityCheckWorkspaces();
|
void sanityCheckWorkspaces();
|
||||||
void updateWorkspaceWindowDecos(const int&);
|
void updateWorkspaceWindowDecos(const int&);
|
||||||
int getWindowsOnWorkspace(const int&);
|
int getWindowsOnWorkspace(const int&);
|
||||||
CWindow* getFirstWindowOnWorkspace(const int&);
|
CWindow* getFirstWindowOnWorkspace(const int&);
|
||||||
CWindow* getFullscreenWindowOnWorkspace(const int&);
|
CWindow* getFullscreenWindowOnWorkspace(const int&);
|
||||||
bool doesSeatAcceptInput(wlr_surface*);
|
bool doesSeatAcceptInput(wlr_surface*);
|
||||||
bool isWindowActive(CWindow*);
|
bool isWindowActive(CWindow*);
|
||||||
void moveWindowToTop(CWindow*);
|
void moveWindowToTop(CWindow*);
|
||||||
void cleanupFadingOut(const int& monid);
|
void cleanupFadingOut(const int& monid);
|
||||||
CWindow* getWindowInDirection(CWindow*, char);
|
CWindow* getWindowInDirection(CWindow*, char);
|
||||||
void deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude = nullptr);
|
void deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude = nullptr);
|
||||||
CWindow* getNextWindowOnWorkspace(CWindow*, bool focusableOnly = false);
|
CWindow* getNextWindowOnWorkspace(CWindow*, bool focusableOnly = false);
|
||||||
CWindow* getPrevWindowOnWorkspace(CWindow*, bool focusableOnly = false);
|
CWindow* getPrevWindowOnWorkspace(CWindow*, bool focusableOnly = false);
|
||||||
int getNextAvailableNamedWorkspace();
|
int getNextAvailableNamedWorkspace();
|
||||||
bool isPointOnAnyMonitor(const Vector2D&);
|
bool isPointOnAnyMonitor(const Vector2D&);
|
||||||
CWindow* getConstraintWindow(SMouse*);
|
CWindow* getConstraintWindow(SMouse*);
|
||||||
CMonitor* getMonitorInDirection(const char&);
|
CMonitor* getMonitorInDirection(const char&);
|
||||||
void updateAllWindowsAnimatedDecorationValues();
|
void updateAllWindowsAnimatedDecorationValues();
|
||||||
void updateWindowAnimatedDecorationValues(CWindow*);
|
void updateWindowAnimatedDecorationValues(CWindow*);
|
||||||
int getNextAvailableMonitorID();
|
int getNextAvailableMonitorID();
|
||||||
void moveWorkspaceToMonitor(CWorkspace*, CMonitor*);
|
void moveWorkspaceToMonitor(CWorkspace*, CMonitor*);
|
||||||
void swapActiveWorkspaces(CMonitor*, CMonitor*);
|
void swapActiveWorkspaces(CMonitor*, CMonitor*);
|
||||||
CMonitor* getMonitorFromString(const std::string&);
|
CMonitor* getMonitorFromString(const std::string&);
|
||||||
bool workspaceIDOutOfBounds(const int&);
|
bool workspaceIDOutOfBounds(const int&);
|
||||||
void setWindowFullscreen(CWindow*, bool, eFullscreenMode);
|
void setWindowFullscreen(CWindow*, bool, eFullscreenMode);
|
||||||
void moveUnmanagedX11ToWindows(CWindow*);
|
void moveUnmanagedX11ToWindows(CWindow*);
|
||||||
CWindow* getX11Parent(CWindow*);
|
CWindow* getX11Parent(CWindow*);
|
||||||
void scheduleFrameForMonitor(CMonitor*);
|
void scheduleFrameForMonitor(CMonitor*);
|
||||||
void addToFadingOutSafe(SLayerSurface*);
|
void addToFadingOutSafe(SLayerSurface*);
|
||||||
void addToFadingOutSafe(CWindow*);
|
void addToFadingOutSafe(CWindow*);
|
||||||
CWindow* getWindowByRegex(const std::string&);
|
CWindow* getWindowByRegex(const std::string&);
|
||||||
void warpCursorTo(const Vector2D&);
|
void warpCursorTo(const Vector2D&);
|
||||||
SLayerSurface* getLayerSurfaceFromWlr(wlr_layer_surface_v1*);
|
SLayerSurface* getLayerSurfaceFromWlr(wlr_layer_surface_v1*);
|
||||||
SLayerSurface* getLayerSurfaceFromSurface(wlr_surface*);
|
SLayerSurface* getLayerSurfaceFromSurface(wlr_surface*);
|
||||||
void closeWindow(CWindow*);
|
void closeWindow(CWindow*);
|
||||||
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
|
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
|
||||||
void forceReportSizesToWindowsOnWorkspace(const int&);
|
void forceReportSizesToWindowsOnWorkspace(const int&);
|
||||||
bool cursorOnReservedArea();
|
bool cursorOnReservedArea();
|
||||||
CWorkspace* createNewWorkspace(const int&, const int&, const std::string& name = ""); // will be deleted next frame if left empty and unfocused!
|
CWorkspace* createNewWorkspace(const int&, const int&, const std::string& name = ""); // will be deleted next frame if left empty and unfocused!
|
||||||
void setActiveMonitor(CMonitor*);
|
void setActiveMonitor(CMonitor*);
|
||||||
bool isWorkspaceSpecial(const int&);
|
bool isWorkspaceSpecial(const int&);
|
||||||
int getNewSpecialID();
|
int getNewSpecialID();
|
||||||
|
|
||||||
std::string explicitConfigPath;
|
std::string explicitConfigPath;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initAllSignals();
|
void initAllSignals();
|
||||||
void setRandomSplash();
|
void setRandomSplash();
|
||||||
|
|
||||||
uint64_t m_iHyprlandPID = 0;
|
uint64_t m_iHyprlandPID = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline std::unique_ptr<CCompositor> g_pCompositor;
|
inline std::unique_ptr<CCompositor> g_pCompositor;
|
||||||
|
|
||||||
// For XWayland
|
// For XWayland
|
||||||
inline std::map<std::string, xcb_atom_t> HYPRATOMS = {
|
inline std::map<std::string, xcb_atom_t> HYPRATOMS = {HYPRATOM("_NET_WM_WINDOW_TYPE"),
|
||||||
HYPRATOM("_NET_WM_WINDOW_TYPE"),
|
HYPRATOM("_NET_WM_WINDOW_TYPE_NORMAL"),
|
||||||
HYPRATOM("_NET_WM_WINDOW_TYPE_NORMAL"),
|
HYPRATOM("_NET_WM_WINDOW_TYPE_DOCK"),
|
||||||
HYPRATOM("_NET_WM_WINDOW_TYPE_DOCK"),
|
HYPRATOM("_NET_WM_WINDOW_TYPE_DIALOG"),
|
||||||
HYPRATOM("_NET_WM_WINDOW_TYPE_DIALOG"),
|
HYPRATOM("_NET_WM_WINDOW_TYPE_UTILITY"),
|
||||||
HYPRATOM("_NET_WM_WINDOW_TYPE_UTILITY"),
|
HYPRATOM("_NET_WM_WINDOW_TYPE_TOOLBAR"),
|
||||||
HYPRATOM("_NET_WM_WINDOW_TYPE_TOOLBAR"),
|
HYPRATOM("_NET_WM_WINDOW_TYPE_SPLASH"),
|
||||||
HYPRATOM("_NET_WM_WINDOW_TYPE_SPLASH"),
|
HYPRATOM("_NET_WM_WINDOW_TYPE_MENU"),
|
||||||
HYPRATOM("_NET_WM_WINDOW_TYPE_MENU"),
|
HYPRATOM("_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"),
|
||||||
HYPRATOM("_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"),
|
HYPRATOM("_NET_WM_WINDOW_TYPE_POPUP_MENU"),
|
||||||
HYPRATOM("_NET_WM_WINDOW_TYPE_POPUP_MENU"),
|
HYPRATOM("_NET_WM_WINDOW_TYPE_TOOLTIP"),
|
||||||
HYPRATOM("_NET_WM_WINDOW_TYPE_TOOLTIP"),
|
HYPRATOM("_NET_WM_WINDOW_TYPE_NOTIFICATION")};
|
||||||
HYPRATOM("_NET_WM_WINDOW_TYPE_NOTIFICATION")};
|
|
||||||
|
|
101
src/Window.cpp
101
src/Window.cpp
|
@ -16,13 +16,13 @@ CWindow::CWindow() {
|
||||||
|
|
||||||
CWindow::~CWindow() {
|
CWindow::~CWindow() {
|
||||||
if (g_pCompositor->isWindowActive(this)) {
|
if (g_pCompositor->isWindowActive(this)) {
|
||||||
g_pCompositor->m_pLastFocus = nullptr;
|
g_pCompositor->m_pLastFocus = nullptr;
|
||||||
g_pCompositor->m_pLastWindow = nullptr;
|
g_pCompositor->m_pLastWindow = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_box CWindow::getFullWindowBoundingBox() {
|
wlr_box CWindow::getFullWindowBoundingBox() {
|
||||||
static auto *const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||||
|
|
||||||
SWindowDecorationExtents maxExtents = {{*PBORDERSIZE + 2, *PBORDERSIZE + 2}, {*PBORDERSIZE + 2, *PBORDERSIZE + 2}};
|
SWindowDecorationExtents maxExtents = {{*PBORDERSIZE + 2, *PBORDERSIZE + 2}, {*PBORDERSIZE + 2, *PBORDERSIZE + 2}};
|
||||||
|
|
||||||
|
@ -44,10 +44,8 @@ wlr_box CWindow::getFullWindowBoundingBox() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add extents to the real base BB and return
|
// Add extents to the real base BB and return
|
||||||
wlr_box finalBox = {m_vRealPosition.vec().x - maxExtents.topLeft.x,
|
wlr_box finalBox = {m_vRealPosition.vec().x - maxExtents.topLeft.x, m_vRealPosition.vec().y - maxExtents.topLeft.y,
|
||||||
m_vRealPosition.vec().y - maxExtents.topLeft.y,
|
m_vRealSize.vec().x + maxExtents.topLeft.x + maxExtents.bottomRight.x, m_vRealSize.vec().y + maxExtents.topLeft.y + maxExtents.bottomRight.y};
|
||||||
m_vRealSize.vec().x + maxExtents.topLeft.x + maxExtents.bottomRight.x,
|
|
||||||
m_vRealSize.vec().y + maxExtents.topLeft.y + maxExtents.bottomRight.y};
|
|
||||||
|
|
||||||
return finalBox;
|
return finalBox;
|
||||||
}
|
}
|
||||||
|
@ -56,11 +54,11 @@ wlr_box CWindow::getWindowIdealBoundingBoxIgnoreReserved() {
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
|
||||||
|
|
||||||
auto POS = m_vPosition;
|
auto POS = m_vPosition;
|
||||||
auto SIZE = m_vSize;
|
auto SIZE = m_vSize;
|
||||||
|
|
||||||
if (m_bIsFullscreen) {
|
if (m_bIsFullscreen) {
|
||||||
POS = PMONITOR->vecPosition;
|
POS = PMONITOR->vecPosition;
|
||||||
SIZE = PMONITOR->vecSize;
|
SIZE = PMONITOR->vecSize;
|
||||||
|
|
||||||
return wlr_box{(int)POS.x, (int)POS.y, (int)SIZE.x, (int)SIZE.y};
|
return wlr_box{(int)POS.x, (int)POS.y, (int)SIZE.x, (int)SIZE.y};
|
||||||
|
@ -135,25 +133,28 @@ void CWindow::createToplevelHandle() {
|
||||||
wlr_foreign_toplevel_handle_v1_set_fullscreen(m_phForeignToplevel, false);
|
wlr_foreign_toplevel_handle_v1_set_fullscreen(m_phForeignToplevel, false);
|
||||||
|
|
||||||
// handle events
|
// handle events
|
||||||
hyprListener_toplevelActivate.initCallback(&m_phForeignToplevel->events.request_activate, [&](void* owner, void* data) {
|
hyprListener_toplevelActivate.initCallback(
|
||||||
|
&m_phForeignToplevel->events.request_activate,
|
||||||
|
[&](void* owner, void* data) {
|
||||||
|
g_pCompositor->focusWindow(this);
|
||||||
|
},
|
||||||
|
this, "Toplevel");
|
||||||
|
|
||||||
g_pCompositor->focusWindow(this);
|
hyprListener_toplevelFullscreen.initCallback(
|
||||||
|
&m_phForeignToplevel->events.request_fullscreen,
|
||||||
|
[&](void* owner, void* data) {
|
||||||
|
const auto EV = (wlr_foreign_toplevel_handle_v1_fullscreen_event*)data;
|
||||||
|
|
||||||
}, this, "Toplevel");
|
g_pCompositor->setWindowFullscreen(this, EV->fullscreen, FULLSCREEN_FULL);
|
||||||
|
},
|
||||||
|
this, "Toplevel");
|
||||||
|
|
||||||
hyprListener_toplevelFullscreen.initCallback(&m_phForeignToplevel->events.request_fullscreen, [&](void* owner, void* data) {
|
hyprListener_toplevelClose.initCallback(
|
||||||
|
&m_phForeignToplevel->events.request_close,
|
||||||
const auto EV = (wlr_foreign_toplevel_handle_v1_fullscreen_event*)data;
|
[&](void* owner, void* data) {
|
||||||
|
g_pCompositor->closeWindow(this);
|
||||||
g_pCompositor->setWindowFullscreen(this, EV->fullscreen, FULLSCREEN_FULL);
|
},
|
||||||
|
this, "Toplevel");
|
||||||
}, this, "Toplevel");
|
|
||||||
|
|
||||||
hyprListener_toplevelClose.initCallback(&m_phForeignToplevel->events.request_close, [&](void* owner, void* data) {
|
|
||||||
|
|
||||||
g_pCompositor->closeWindow(this);
|
|
||||||
|
|
||||||
}, this, "Toplevel");
|
|
||||||
|
|
||||||
m_iLastToplevelMonitorID = m_iMonitorID;
|
m_iLastToplevelMonitorID = m_iMonitorID;
|
||||||
}
|
}
|
||||||
|
@ -290,12 +291,8 @@ void CWindow::onMap() {
|
||||||
m_cRealShadowColor.registerVar();
|
m_cRealShadowColor.registerVar();
|
||||||
m_fDimPercent.registerVar();
|
m_fDimPercent.registerVar();
|
||||||
|
|
||||||
m_vRealSize.setCallbackOnEnd([&] (void* ptr) {
|
m_vRealSize.setCallbackOnEnd([&](void* ptr) { g_pHyprOpenGL->onWindowResizeEnd(this); }, false);
|
||||||
g_pHyprOpenGL->onWindowResizeEnd(this);
|
m_vRealSize.setCallbackOnBegin([&](void* ptr) { g_pHyprOpenGL->onWindowResizeStart(this); }, false);
|
||||||
}, false);
|
|
||||||
m_vRealSize.setCallbackOnBegin([&] (void* ptr) {
|
|
||||||
g_pHyprOpenGL->onWindowResizeStart(this);
|
|
||||||
}, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWindow::setHidden(bool hidden) {
|
void CWindow::setHidden(bool hidden) {
|
||||||
|
@ -323,9 +320,7 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
|
||||||
} else if (r.szRule.find("rounding") == 0) {
|
} else if (r.szRule.find("rounding") == 0) {
|
||||||
try {
|
try {
|
||||||
m_sAdditionalConfigData.rounding = std::stoi(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
|
m_sAdditionalConfigData.rounding = std::stoi(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) { Debug::log(ERR, "Rounding rule \"%s\" failed with: %s", r.szRule.c_str(), e.what()); }
|
||||||
Debug::log(ERR, "Rounding rule \"%s\" failed with: %s", r.szRule.c_str(), e.what());
|
|
||||||
}
|
|
||||||
} else if (r.szRule.find("opacity") == 0) {
|
} else if (r.szRule.find("opacity") == 0) {
|
||||||
try {
|
try {
|
||||||
CVarList vars(r.szRule, 0, ' ');
|
CVarList vars(r.szRule, 0, ' ');
|
||||||
|
@ -346,44 +341,40 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(std::exception& e) {
|
} catch (std::exception& e) { Debug::log(ERR, "Opacity rule \"%s\" failed with: %s", r.szRule.c_str(), e.what()); }
|
||||||
Debug::log(ERR, "Opacity rule \"%s\" failed with: %s", r.szRule.c_str(), e.what());
|
} else if (r.szRule == "noanim") {
|
||||||
}
|
m_sAdditionalConfigData.forceNoAnims = true;
|
||||||
} else if (r.szRule == "noanim") {
|
} else if (r.szRule.find("animation") == 0) {
|
||||||
m_sAdditionalConfigData.forceNoAnims = true;
|
auto STYLE = r.szRule.substr(r.szRule.find_first_of(' ') + 1);
|
||||||
} else if (r.szRule.find("animation") == 0) {
|
m_sAdditionalConfigData.animationStyle = STYLE;
|
||||||
auto STYLE = r.szRule.substr(r.szRule.find_first_of(' ') + 1);
|
} else if (r.szRule.find("bordercolor") == 0) {
|
||||||
m_sAdditionalConfigData.animationStyle = STYLE;
|
|
||||||
} else if (r.szRule.find("bordercolor") == 0) {
|
|
||||||
try {
|
try {
|
||||||
std::string colorPart = removeBeginEndSpacesTabs(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
|
std::string colorPart = removeBeginEndSpacesTabs(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
|
||||||
|
|
||||||
if (colorPart.contains(' ')) {
|
if (colorPart.contains(' ')) {
|
||||||
// we have a space, 2 values
|
// we have a space, 2 values
|
||||||
m_sSpecialRenderData.activeBorderColor = configStringToInt(colorPart.substr(0, colorPart.find_first_of(' ')));
|
m_sSpecialRenderData.activeBorderColor = configStringToInt(colorPart.substr(0, colorPart.find_first_of(' ')));
|
||||||
m_sSpecialRenderData.inactiveBorderColor = configStringToInt(colorPart.substr(colorPart.find_first_of(' ') + 1));
|
m_sSpecialRenderData.inactiveBorderColor = configStringToInt(colorPart.substr(colorPart.find_first_of(' ') + 1));
|
||||||
} else {
|
} else {
|
||||||
m_sSpecialRenderData.activeBorderColor = configStringToInt(colorPart);
|
m_sSpecialRenderData.activeBorderColor = configStringToInt(colorPart);
|
||||||
}
|
}
|
||||||
} catch(std::exception& e) {
|
} catch (std::exception& e) { Debug::log(ERR, "BorderColor rule \"%s\" failed with: %s", r.szRule.c_str(), e.what()); }
|
||||||
Debug::log(ERR, "BorderColor rule \"%s\" failed with: %s", r.szRule.c_str(), e.what());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWindow::updateDynamicRules() {
|
void CWindow::updateDynamicRules() {
|
||||||
m_sSpecialRenderData.activeBorderColor = -1;
|
m_sSpecialRenderData.activeBorderColor = -1;
|
||||||
m_sSpecialRenderData.inactiveBorderColor = -1;
|
m_sSpecialRenderData.inactiveBorderColor = -1;
|
||||||
m_sSpecialRenderData.alpha = 1.f;
|
m_sSpecialRenderData.alpha = 1.f;
|
||||||
m_sSpecialRenderData.alphaInactive = -1.f;
|
m_sSpecialRenderData.alphaInactive = -1.f;
|
||||||
m_sAdditionalConfigData.forceNoBlur = false;
|
m_sAdditionalConfigData.forceNoBlur = false;
|
||||||
m_sAdditionalConfigData.forceNoBorder = false;
|
m_sAdditionalConfigData.forceNoBorder = false;
|
||||||
m_sAdditionalConfigData.forceNoShadow = false;
|
m_sAdditionalConfigData.forceNoShadow = false;
|
||||||
if (!m_sAdditionalConfigData.forceOpaqueOverriden)
|
if (!m_sAdditionalConfigData.forceOpaqueOverriden)
|
||||||
m_sAdditionalConfigData.forceOpaque = false;
|
m_sAdditionalConfigData.forceOpaque = false;
|
||||||
m_sAdditionalConfigData.forceNoAnims = false;
|
m_sAdditionalConfigData.forceNoAnims = false;
|
||||||
m_sAdditionalConfigData.animationStyle = "";
|
m_sAdditionalConfigData.animationStyle = "";
|
||||||
m_sAdditionalConfigData.rounding = -1;
|
m_sAdditionalConfigData.rounding = -1;
|
||||||
|
|
||||||
const auto WINDOWRULES = g_pConfigManager->getMatchingRules(this);
|
const auto WINDOWRULES = g_pConfigManager->getMatchingRules(this);
|
||||||
for (auto& r : WINDOWRULES) {
|
for (auto& r : WINDOWRULES) {
|
||||||
|
|
205
src/Window.hpp
205
src/Window.hpp
|
@ -8,7 +8,8 @@
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include "config/ConfigDataValues.hpp"
|
#include "config/ConfigDataValues.hpp"
|
||||||
|
|
||||||
enum eIdleInhibitMode {
|
enum eIdleInhibitMode
|
||||||
|
{
|
||||||
IDLEINHIBIT_NONE = 0,
|
IDLEINHIBIT_NONE = 0,
|
||||||
IDLEINHIBIT_ALWAYS,
|
IDLEINHIBIT_ALWAYS,
|
||||||
IDLEINHIBIT_FULLSCREEN,
|
IDLEINHIBIT_FULLSCREEN,
|
||||||
|
@ -16,49 +17,49 @@ enum eIdleInhibitMode {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SWindowSpecialRenderData {
|
struct SWindowSpecialRenderData {
|
||||||
bool alphaOverride = false;
|
bool alphaOverride = false;
|
||||||
float alpha = 1.f;
|
float alpha = 1.f;
|
||||||
bool alphaInactiveOverride = false;
|
bool alphaInactiveOverride = false;
|
||||||
float alphaInactive = -1.f; // -1 means unset
|
float alphaInactive = -1.f; // -1 means unset
|
||||||
|
|
||||||
int64_t activeBorderColor = -1; // -1 means unset
|
int64_t activeBorderColor = -1; // -1 means unset
|
||||||
int64_t inactiveBorderColor = -1; // -1 means unset
|
int64_t inactiveBorderColor = -1; // -1 means unset
|
||||||
|
|
||||||
// set by the layout
|
// set by the layout
|
||||||
bool rounding = true;
|
bool rounding = true;
|
||||||
bool border = true;
|
bool border = true;
|
||||||
bool decorate = true;
|
bool decorate = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SWindowAdditionalConfigData {
|
struct SWindowAdditionalConfigData {
|
||||||
std::string animationStyle = "";
|
std::string animationStyle = "";
|
||||||
int rounding = -1; // -1 means no
|
int rounding = -1; // -1 means no
|
||||||
bool forceNoBlur = false;
|
bool forceNoBlur = false;
|
||||||
bool forceOpaque = 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 forceOpaqueOverriden = false; // if true, a rule will not change the forceOpaque state. This is for the force opaque dispatcher.
|
||||||
bool forceAllowsInput = false;
|
bool forceAllowsInput = false;
|
||||||
bool forceNoAnims = false;
|
bool forceNoAnims = false;
|
||||||
bool forceNoBorder = false;
|
bool forceNoBorder = false;
|
||||||
bool forceNoShadow = false;
|
bool forceNoShadow = false;
|
||||||
bool windowDanceCompat = false;
|
bool windowDanceCompat = false;
|
||||||
bool noMaxSize = false;
|
bool noMaxSize = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SWindowRule {
|
struct SWindowRule {
|
||||||
std::string szRule;
|
std::string szRule;
|
||||||
std::string szValue;
|
std::string szValue;
|
||||||
|
|
||||||
bool v2 = false;
|
bool v2 = false;
|
||||||
std::string szTitle;
|
std::string szTitle;
|
||||||
std::string szClass;
|
std::string szClass;
|
||||||
int bX11 = -1; // -1 means "ANY"
|
int bX11 = -1; // -1 means "ANY"
|
||||||
int bFloating = -1;
|
int bFloating = -1;
|
||||||
int bFullscreen = -1;
|
int bFullscreen = -1;
|
||||||
int bPinned = -1;
|
int bPinned = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CWindow {
|
class CWindow {
|
||||||
public:
|
public:
|
||||||
CWindow();
|
CWindow();
|
||||||
~CWindow();
|
~CWindow();
|
||||||
|
|
||||||
|
@ -79,142 +80,142 @@ public:
|
||||||
DYNLISTENER(toplevelClose);
|
DYNLISTENER(toplevelClose);
|
||||||
DYNLISTENER(toplevelActivate);
|
DYNLISTENER(toplevelActivate);
|
||||||
DYNLISTENER(toplevelFullscreen);
|
DYNLISTENER(toplevelFullscreen);
|
||||||
// DYNLISTENER(newSubsurfaceWindow);
|
// DYNLISTENER(newSubsurfaceWindow);
|
||||||
|
|
||||||
union {
|
union {
|
||||||
wlr_xdg_surface* xdg;
|
wlr_xdg_surface* xdg;
|
||||||
wlr_xwayland_surface* xwayland;
|
wlr_xwayland_surface* xwayland;
|
||||||
} m_uSurface;
|
} m_uSurface;
|
||||||
|
|
||||||
// this is the position and size of the "bounding box"
|
// this is the position and size of the "bounding box"
|
||||||
Vector2D m_vPosition = Vector2D(0,0);
|
Vector2D m_vPosition = Vector2D(0, 0);
|
||||||
Vector2D m_vSize = Vector2D(0,0);
|
Vector2D m_vSize = Vector2D(0, 0);
|
||||||
|
|
||||||
// this is the real position and size used to draw the thing
|
// this is the real position and size used to draw the thing
|
||||||
CAnimatedVariable m_vRealPosition;
|
CAnimatedVariable m_vRealPosition;
|
||||||
CAnimatedVariable m_vRealSize;
|
CAnimatedVariable m_vRealSize;
|
||||||
|
|
||||||
// for not spamming the protocols
|
// for not spamming the protocols
|
||||||
Vector2D m_vReportedPosition;
|
Vector2D m_vReportedPosition;
|
||||||
Vector2D m_vReportedSize;
|
Vector2D m_vReportedSize;
|
||||||
|
|
||||||
// for restoring floating statuses
|
// for restoring floating statuses
|
||||||
Vector2D m_vLastFloatingSize;
|
Vector2D m_vLastFloatingSize;
|
||||||
|
|
||||||
// this is used for pseudotiling
|
// this is used for pseudotiling
|
||||||
bool m_bIsPseudotiled = false;
|
bool m_bIsPseudotiled = false;
|
||||||
Vector2D m_vPseudoSize = Vector2D(0,0);
|
Vector2D m_vPseudoSize = Vector2D(0, 0);
|
||||||
|
|
||||||
uint64_t m_iTags = 0;
|
uint64_t m_iTags = 0;
|
||||||
bool m_bIsFloating = false;
|
bool m_bIsFloating = false;
|
||||||
bool m_bDraggingTiled = false; // for dragging around tiled windows
|
bool m_bDraggingTiled = false; // for dragging around tiled windows
|
||||||
bool m_bIsFullscreen = false;
|
bool m_bIsFullscreen = false;
|
||||||
uint64_t m_iMonitorID = -1;
|
uint64_t m_iMonitorID = -1;
|
||||||
std::string m_szTitle = "";
|
std::string m_szTitle = "";
|
||||||
int m_iWorkspaceID = -1;
|
int m_iWorkspaceID = -1;
|
||||||
|
|
||||||
bool m_bIsMapped = false;
|
bool m_bIsMapped = false;
|
||||||
|
|
||||||
bool m_bRequestsFloat = false;
|
bool m_bRequestsFloat = false;
|
||||||
|
|
||||||
// This is for fullscreen apps
|
// This is for fullscreen apps
|
||||||
bool m_bCreatedOverFullscreen = false;
|
bool m_bCreatedOverFullscreen = false;
|
||||||
|
|
||||||
// XWayland stuff
|
// XWayland stuff
|
||||||
bool m_bIsX11 = false;
|
bool m_bIsX11 = false;
|
||||||
bool m_bMappedX11 = false;
|
bool m_bMappedX11 = false;
|
||||||
CWindow* m_pX11Parent = nullptr;
|
CWindow* m_pX11Parent = nullptr;
|
||||||
uint64_t m_iX11Type = 0;
|
uint64_t m_iX11Type = 0;
|
||||||
bool m_bIsModal = false;
|
bool m_bIsModal = false;
|
||||||
bool m_bX11DoesntWantBorders = false;
|
bool m_bX11DoesntWantBorders = false;
|
||||||
bool m_bX11ShouldntFocus = false;
|
bool m_bX11ShouldntFocus = false;
|
||||||
//
|
//
|
||||||
|
|
||||||
// For nofocus
|
// For nofocus
|
||||||
bool m_bNoFocus = false;
|
bool m_bNoFocus = false;
|
||||||
bool m_bNoInitialFocus = false;
|
bool m_bNoInitialFocus = false;
|
||||||
|
|
||||||
// initial fullscreen and fullscreen disabled
|
// initial fullscreen and fullscreen disabled
|
||||||
bool m_bWantsInitialFullscreen = false;
|
bool m_bWantsInitialFullscreen = false;
|
||||||
bool m_bNoFullscreenRequest = false;
|
bool m_bNoFullscreenRequest = false;
|
||||||
|
|
||||||
SSurfaceTreeNode* m_pSurfaceTree = nullptr;
|
SSurfaceTreeNode* m_pSurfaceTree = nullptr;
|
||||||
|
|
||||||
// Animated border
|
// Animated border
|
||||||
CGradientValueData m_cRealBorderColor = {0};
|
CGradientValueData m_cRealBorderColor = {0};
|
||||||
CGradientValueData m_cRealBorderColorPrevious = {0};
|
CGradientValueData m_cRealBorderColorPrevious = {0};
|
||||||
CAnimatedVariable m_fBorderAnimationProgress;
|
CAnimatedVariable m_fBorderAnimationProgress;
|
||||||
|
|
||||||
// Fade in-out
|
// Fade in-out
|
||||||
CAnimatedVariable m_fAlpha;
|
CAnimatedVariable m_fAlpha;
|
||||||
bool m_bFadingOut = false;
|
bool m_bFadingOut = false;
|
||||||
bool m_bReadyToDelete = false;
|
bool m_bReadyToDelete = false;
|
||||||
Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in
|
Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in
|
||||||
Vector2D m_vOriginalClosedSize; // drawing the closing animations
|
Vector2D m_vOriginalClosedSize; // drawing the closing animations
|
||||||
|
|
||||||
// For pinned (sticky) windows
|
// For pinned (sticky) windows
|
||||||
bool m_bPinned = false;
|
bool m_bPinned = false;
|
||||||
|
|
||||||
// for proper cycling. While cycling we can't just move the pointers, so we need to keep track of the last cycled window.
|
// for proper cycling. While cycling we can't just move the pointers, so we need to keep track of the last cycled window.
|
||||||
CWindow* m_pLastCycledWindow = nullptr;
|
CWindow* m_pLastCycledWindow = nullptr;
|
||||||
|
|
||||||
// Foreign Toplevel proto
|
// Foreign Toplevel proto
|
||||||
wlr_foreign_toplevel_handle_v1* m_phForeignToplevel = nullptr;
|
wlr_foreign_toplevel_handle_v1* m_phForeignToplevel = nullptr;
|
||||||
|
|
||||||
// Window decorations
|
// Window decorations
|
||||||
std::deque<std::unique_ptr<IHyprWindowDecoration>> m_dWindowDecorations;
|
std::deque<std::unique_ptr<IHyprWindowDecoration>> m_dWindowDecorations;
|
||||||
std::vector<IHyprWindowDecoration*> m_vDecosToRemove;
|
std::vector<IHyprWindowDecoration*> m_vDecosToRemove;
|
||||||
|
|
||||||
// Special render data, rules, etc
|
// Special render data, rules, etc
|
||||||
SWindowSpecialRenderData m_sSpecialRenderData;
|
SWindowSpecialRenderData m_sSpecialRenderData;
|
||||||
SWindowAdditionalConfigData m_sAdditionalConfigData;
|
SWindowAdditionalConfigData m_sAdditionalConfigData;
|
||||||
|
|
||||||
// for alpha
|
// for alpha
|
||||||
CAnimatedVariable m_fActiveInactiveAlpha;
|
CAnimatedVariable m_fActiveInactiveAlpha;
|
||||||
|
|
||||||
// animated shadow color
|
// animated shadow color
|
||||||
CAnimatedVariable m_cRealShadowColor;
|
CAnimatedVariable m_cRealShadowColor;
|
||||||
|
|
||||||
// animated tint
|
// animated tint
|
||||||
CAnimatedVariable m_fDimPercent;
|
CAnimatedVariable m_fDimPercent;
|
||||||
|
|
||||||
// swallowing
|
// swallowing
|
||||||
CWindow* m_pSwallowed = nullptr;
|
CWindow* m_pSwallowed = nullptr;
|
||||||
|
|
||||||
// for toplevel monitor events
|
// for toplevel monitor events
|
||||||
uint64_t m_iLastToplevelMonitorID = -1;
|
uint64_t m_iLastToplevelMonitorID = -1;
|
||||||
uint64_t m_iLastSurfaceMonitorID = -1;
|
uint64_t m_iLastSurfaceMonitorID = -1;
|
||||||
|
|
||||||
// for idle inhibiting windows
|
// for idle inhibiting windows
|
||||||
eIdleInhibitMode m_eIdleInhibitMode = IDLEINHIBIT_NONE;
|
eIdleInhibitMode m_eIdleInhibitMode = IDLEINHIBIT_NONE;
|
||||||
|
|
||||||
// For the list lookup
|
// For the list lookup
|
||||||
bool operator==(const CWindow& rhs) {
|
bool operator==(const CWindow& rhs) {
|
||||||
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;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
wlr_box getFullWindowBoundingBox();
|
wlr_box getFullWindowBoundingBox();
|
||||||
wlr_box getWindowIdealBoundingBoxIgnoreReserved();
|
wlr_box getWindowIdealBoundingBoxIgnoreReserved();
|
||||||
void updateWindowDecos();
|
void updateWindowDecos();
|
||||||
pid_t getPID();
|
pid_t getPID();
|
||||||
IHyprWindowDecoration* getDecorationByType(eDecorationType);
|
IHyprWindowDecoration* getDecorationByType(eDecorationType);
|
||||||
void removeDecorationByType(eDecorationType);
|
void removeDecorationByType(eDecorationType);
|
||||||
void createToplevelHandle();
|
void createToplevelHandle();
|
||||||
void destroyToplevelHandle();
|
void destroyToplevelHandle();
|
||||||
void updateToplevel();
|
void updateToplevel();
|
||||||
void updateSurfaceOutputs();
|
void updateSurfaceOutputs();
|
||||||
void moveToWorkspace(int);
|
void moveToWorkspace(int);
|
||||||
CWindow* X11TransientFor();
|
CWindow* X11TransientFor();
|
||||||
void onUnmap();
|
void onUnmap();
|
||||||
void onMap();
|
void onMap();
|
||||||
void setHidden(bool hidden);
|
void setHidden(bool hidden);
|
||||||
bool isHidden();
|
bool isHidden();
|
||||||
void applyDynamicRule(const SWindowRule& r);
|
void applyDynamicRule(const SWindowRule& r);
|
||||||
void updateDynamicRules();
|
void updateDynamicRules();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// For hidden windows and stuff
|
// For hidden windows and stuff
|
||||||
bool m_bHidden = false;
|
bool m_bHidden = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,24 +1,26 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
enum eConfigValueDataTypes {
|
enum eConfigValueDataTypes
|
||||||
CVD_TYPE_INVALID = -1,
|
{
|
||||||
|
CVD_TYPE_INVALID = -1,
|
||||||
CVD_TYPE_GRADIENT = 0
|
CVD_TYPE_GRADIENT = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
interface ICustomConfigValueData {
|
interface ICustomConfigValueData {
|
||||||
public:
|
public:
|
||||||
virtual ~ICustomConfigValueData() = 0;
|
virtual ~ICustomConfigValueData() = 0;
|
||||||
|
|
||||||
virtual eConfigValueDataTypes getDataType() = 0;
|
virtual eConfigValueDataTypes getDataType() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CGradientValueData : public ICustomConfigValueData {
|
class CGradientValueData : public ICustomConfigValueData {
|
||||||
public:
|
public:
|
||||||
CGradientValueData(CColor col) {
|
CGradientValueData(CColor col) {
|
||||||
m_vColors.push_back(col);
|
m_vColors.push_back(col);
|
||||||
};
|
};
|
||||||
virtual ~CGradientValueData() { };
|
virtual ~CGradientValueData(){};
|
||||||
|
|
||||||
virtual eConfigValueDataTypes getDataType() {
|
virtual eConfigValueDataTypes getDataType() {
|
||||||
return CVD_TYPE_GRADIENT;
|
return CVD_TYPE_GRADIENT;
|
||||||
|
@ -34,14 +36,15 @@ public:
|
||||||
std::vector<CColor> m_vColors;
|
std::vector<CColor> m_vColors;
|
||||||
|
|
||||||
/* Float corresponding to the angle (rad) */
|
/* Float corresponding to the angle (rad) */
|
||||||
float m_fAngle = 0;
|
float m_fAngle = 0;
|
||||||
|
|
||||||
bool operator==(const CGradientValueData& other) {
|
bool operator==(const CGradientValueData& other) {
|
||||||
if (other.m_vColors.size() != m_vColors.size() || m_fAngle != other.m_fAngle)
|
if (other.m_vColors.size() != m_vColors.size() || m_fAngle != other.m_fAngle)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (size_t i = 0; i < m_vColors.size(); ++i)
|
for (size_t i = 0; i < m_vColors.size(); ++i)
|
||||||
if (m_vColors[i] != other.m_vColors[i]) return false;
|
if (m_vColors[i] != other.m_vColors[i])
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
CConfigManager::CConfigManager() {
|
CConfigManager::CConfigManager() {
|
||||||
configValues["general:col.active_border"].data = std::make_shared<CGradientValueData>(0xffffffff);
|
configValues["general:col.active_border"].data = std::make_shared<CGradientValueData>(0xffffffff);
|
||||||
configValues["general:col.inactive_border"].data = std::make_shared<CGradientValueData>(0xff444444);
|
configValues["general:col.inactive_border"].data = std::make_shared<CGradientValueData>(0xff444444);
|
||||||
|
|
||||||
setDefaultVars();
|
setDefaultVars();
|
||||||
|
@ -20,7 +20,7 @@ CConfigManager::CConfigManager() {
|
||||||
std::string CONFIGPATH;
|
std::string CONFIGPATH;
|
||||||
if (g_pCompositor->explicitConfigPath == "") {
|
if (g_pCompositor->explicitConfigPath == "") {
|
||||||
static const char* const ENVHOME = getenv("HOME");
|
static const char* const ENVHOME = getenv("HOME");
|
||||||
CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
|
CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
|
||||||
} else {
|
} else {
|
||||||
CONFIGPATH = g_pCompositor->explicitConfigPath;
|
CONFIGPATH = g_pCompositor->explicitConfigPath;
|
||||||
}
|
}
|
||||||
|
@ -32,146 +32,146 @@ CConfigManager::CConfigManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::setDefaultVars() {
|
void CConfigManager::setDefaultVars() {
|
||||||
configValues["general:max_fps"].intValue = 60;
|
configValues["general:max_fps"].intValue = 60;
|
||||||
configValues["general:sensitivity"].floatValue = 1.0f;
|
configValues["general:sensitivity"].floatValue = 1.0f;
|
||||||
configValues["general:apply_sens_to_raw"].intValue = 0;
|
configValues["general:apply_sens_to_raw"].intValue = 0;
|
||||||
configValues["general:main_mod"].strValue = "SUPER"; // exposed to the user for easier configuring
|
configValues["general:main_mod"].strValue = "SUPER"; // exposed to the user for easier configuring
|
||||||
configValues["general:main_mod_internal"].intValue = g_pKeybindManager->stringToModMask("SUPER"); // actually used and automatically calculated
|
configValues["general:main_mod_internal"].intValue = g_pKeybindManager->stringToModMask("SUPER"); // actually used and automatically calculated
|
||||||
|
|
||||||
configValues["general:border_size"].intValue = 1;
|
configValues["general:border_size"].intValue = 1;
|
||||||
configValues["general:no_border_on_floating"].intValue = 0;
|
configValues["general:no_border_on_floating"].intValue = 0;
|
||||||
configValues["general:gaps_in"].intValue = 5;
|
configValues["general:gaps_in"].intValue = 5;
|
||||||
configValues["general:gaps_out"].intValue = 20;
|
configValues["general:gaps_out"].intValue = 20;
|
||||||
((CGradientValueData*)configValues["general:col.active_border"].data.get())->reset(0xffffffff);
|
((CGradientValueData*)configValues["general:col.active_border"].data.get())->reset(0xffffffff);
|
||||||
((CGradientValueData*)configValues["general:col.inactive_border"].data.get())->reset(0xff444444);
|
((CGradientValueData*)configValues["general:col.inactive_border"].data.get())->reset(0xff444444);
|
||||||
configValues["general:cursor_inactive_timeout"].intValue = 0;
|
configValues["general:cursor_inactive_timeout"].intValue = 0;
|
||||||
configValues["general:no_cursor_warps"].intValue = 0;
|
configValues["general:no_cursor_warps"].intValue = 0;
|
||||||
|
|
||||||
configValues["general:layout"].strValue = "dwindle";
|
configValues["general:layout"].strValue = "dwindle";
|
||||||
|
|
||||||
configValues["misc:disable_hyprland_logo"].intValue = 0;
|
configValues["misc:disable_hyprland_logo"].intValue = 0;
|
||||||
configValues["misc:disable_splash_rendering"].intValue = 0;
|
configValues["misc:disable_splash_rendering"].intValue = 0;
|
||||||
configValues["misc:no_vfr"].intValue = 1;
|
configValues["misc:no_vfr"].intValue = 1;
|
||||||
configValues["misc:damage_entire_on_snapshot"].intValue = 0;
|
configValues["misc:damage_entire_on_snapshot"].intValue = 0;
|
||||||
configValues["misc:mouse_move_enables_dpms"].intValue = 0;
|
configValues["misc:mouse_move_enables_dpms"].intValue = 0;
|
||||||
configValues["misc:always_follow_on_dnd"].intValue = 1;
|
configValues["misc:always_follow_on_dnd"].intValue = 1;
|
||||||
configValues["misc:layers_hog_keyboard_focus"].intValue = 1;
|
configValues["misc:layers_hog_keyboard_focus"].intValue = 1;
|
||||||
configValues["misc:animate_manual_resizes"].intValue = 0;
|
configValues["misc:animate_manual_resizes"].intValue = 0;
|
||||||
configValues["misc:disable_autoreload"].intValue = 0;
|
configValues["misc:disable_autoreload"].intValue = 0;
|
||||||
configValues["misc:enable_swallow"].intValue = 0;
|
configValues["misc:enable_swallow"].intValue = 0;
|
||||||
configValues["misc:swallow_regex"].strValue = STRVAL_EMPTY;
|
configValues["misc:swallow_regex"].strValue = STRVAL_EMPTY;
|
||||||
configValues["misc:focus_on_activate"].intValue = 0;
|
configValues["misc:focus_on_activate"].intValue = 0;
|
||||||
configValues["misc:no_direct_scanout"].intValue = 0;
|
configValues["misc:no_direct_scanout"].intValue = 0;
|
||||||
|
|
||||||
configValues["debug:int"].intValue = 0;
|
configValues["debug:int"].intValue = 0;
|
||||||
configValues["debug:log_damage"].intValue = 0;
|
configValues["debug:log_damage"].intValue = 0;
|
||||||
configValues["debug:overlay"].intValue = 0;
|
configValues["debug:overlay"].intValue = 0;
|
||||||
configValues["debug:damage_blink"].intValue = 0;
|
configValues["debug:damage_blink"].intValue = 0;
|
||||||
configValues["debug:disable_logs"].intValue = 0;
|
configValues["debug:disable_logs"].intValue = 0;
|
||||||
configValues["debug:disable_time"].intValue = 1;
|
configValues["debug:disable_time"].intValue = 1;
|
||||||
configValues["debug:damage_tracking"].intValue = DAMAGE_TRACKING_FULL;
|
configValues["debug:damage_tracking"].intValue = DAMAGE_TRACKING_FULL;
|
||||||
|
|
||||||
configValues["decoration:rounding"].intValue = 0;
|
configValues["decoration:rounding"].intValue = 0;
|
||||||
configValues["decoration:blur"].intValue = 1;
|
configValues["decoration:blur"].intValue = 1;
|
||||||
configValues["decoration:blur_size"].intValue = 8;
|
configValues["decoration:blur_size"].intValue = 8;
|
||||||
configValues["decoration:blur_passes"].intValue = 1;
|
configValues["decoration:blur_passes"].intValue = 1;
|
||||||
configValues["decoration:blur_ignore_opacity"].intValue = 0;
|
configValues["decoration:blur_ignore_opacity"].intValue = 0;
|
||||||
configValues["decoration:blur_new_optimizations"].intValue = 1;
|
configValues["decoration:blur_new_optimizations"].intValue = 1;
|
||||||
configValues["decoration:blur_xray"].intValue = 0;
|
configValues["decoration:blur_xray"].intValue = 0;
|
||||||
configValues["decoration:active_opacity"].floatValue = 1;
|
configValues["decoration:active_opacity"].floatValue = 1;
|
||||||
configValues["decoration:inactive_opacity"].floatValue = 1;
|
configValues["decoration:inactive_opacity"].floatValue = 1;
|
||||||
configValues["decoration:fullscreen_opacity"].floatValue = 1;
|
configValues["decoration:fullscreen_opacity"].floatValue = 1;
|
||||||
configValues["decoration:multisample_edges"].intValue = 1;
|
configValues["decoration:multisample_edges"].intValue = 1;
|
||||||
configValues["decoration:no_blur_on_oversized"].intValue = 0;
|
configValues["decoration:no_blur_on_oversized"].intValue = 0;
|
||||||
configValues["decoration:drop_shadow"].intValue = 1;
|
configValues["decoration:drop_shadow"].intValue = 1;
|
||||||
configValues["decoration:shadow_range"].intValue = 4;
|
configValues["decoration:shadow_range"].intValue = 4;
|
||||||
configValues["decoration:shadow_render_power"].intValue = 3;
|
configValues["decoration:shadow_render_power"].intValue = 3;
|
||||||
configValues["decoration:shadow_ignore_window"].intValue = 1;
|
configValues["decoration:shadow_ignore_window"].intValue = 1;
|
||||||
configValues["decoration:shadow_offset"].vecValue = Vector2D();
|
configValues["decoration:shadow_offset"].vecValue = Vector2D();
|
||||||
configValues["decoration:shadow_scale"].floatValue = 1.f;
|
configValues["decoration:shadow_scale"].floatValue = 1.f;
|
||||||
configValues["decoration:col.shadow"].intValue = 0xee1a1a1a;
|
configValues["decoration:col.shadow"].intValue = 0xee1a1a1a;
|
||||||
configValues["decoration:col.shadow_inactive"].intValue = INT_MAX;
|
configValues["decoration:col.shadow_inactive"].intValue = INT_MAX;
|
||||||
configValues["decoration:dim_inactive"].intValue = 0;
|
configValues["decoration:dim_inactive"].intValue = 0;
|
||||||
configValues["decoration:dim_strength"].floatValue = 0.5f;
|
configValues["decoration:dim_strength"].floatValue = 0.5f;
|
||||||
configValues["decoration:screen_shader"].strValue = STRVAL_EMPTY;
|
configValues["decoration:screen_shader"].strValue = STRVAL_EMPTY;
|
||||||
|
|
||||||
configValues["dwindle:pseudotile"].intValue = 0;
|
configValues["dwindle:pseudotile"].intValue = 0;
|
||||||
configValues["dwindle:col.group_border"].intValue = 0x66777700;
|
configValues["dwindle:col.group_border"].intValue = 0x66777700;
|
||||||
configValues["dwindle:col.group_border_active"].intValue = 0x66ffff00;
|
configValues["dwindle:col.group_border_active"].intValue = 0x66ffff00;
|
||||||
configValues["dwindle:force_split"].intValue = 0;
|
configValues["dwindle:force_split"].intValue = 0;
|
||||||
configValues["dwindle:preserve_split"].intValue = 0;
|
configValues["dwindle:preserve_split"].intValue = 0;
|
||||||
configValues["dwindle:special_scale_factor"].floatValue = 0.8f;
|
configValues["dwindle:special_scale_factor"].floatValue = 0.8f;
|
||||||
configValues["dwindle:split_width_multiplier"].floatValue = 1.0f;
|
configValues["dwindle:split_width_multiplier"].floatValue = 1.0f;
|
||||||
configValues["dwindle:no_gaps_when_only"].intValue = 0;
|
configValues["dwindle:no_gaps_when_only"].intValue = 0;
|
||||||
configValues["dwindle:use_active_for_splits"].intValue = 1;
|
configValues["dwindle:use_active_for_splits"].intValue = 1;
|
||||||
|
|
||||||
configValues["master:special_scale_factor"].floatValue = 0.8f;
|
configValues["master:special_scale_factor"].floatValue = 0.8f;
|
||||||
configValues["master:new_is_master"].intValue = 1;
|
configValues["master:new_is_master"].intValue = 1;
|
||||||
configValues["master:new_on_top"].intValue = 0;
|
configValues["master:new_on_top"].intValue = 0;
|
||||||
configValues["master:no_gaps_when_only"].intValue = 0;
|
configValues["master:no_gaps_when_only"].intValue = 0;
|
||||||
configValues["master:orientation"].strValue = "left";
|
configValues["master:orientation"].strValue = "left";
|
||||||
configValues["master:inherit_fullscreen"].intValue = 1;
|
configValues["master:inherit_fullscreen"].intValue = 1;
|
||||||
|
|
||||||
configValues["animations:enabled"].intValue = 1;
|
configValues["animations:enabled"].intValue = 1;
|
||||||
configValues["animations:speed"].floatValue = 7.f;
|
configValues["animations:speed"].floatValue = 7.f;
|
||||||
configValues["animations:curve"].strValue = "default";
|
configValues["animations:curve"].strValue = "default";
|
||||||
configValues["animations:windows_style"].strValue = STRVAL_EMPTY;
|
configValues["animations:windows_style"].strValue = STRVAL_EMPTY;
|
||||||
configValues["animations:windows_curve"].strValue = "[[f]]";
|
configValues["animations:windows_curve"].strValue = "[[f]]";
|
||||||
configValues["animations:windows_speed"].floatValue = 0.f;
|
configValues["animations:windows_speed"].floatValue = 0.f;
|
||||||
configValues["animations:windows"].intValue = 1;
|
configValues["animations:windows"].intValue = 1;
|
||||||
configValues["animations:borders_style"].strValue = STRVAL_EMPTY;
|
configValues["animations:borders_style"].strValue = STRVAL_EMPTY;
|
||||||
configValues["animations:borders_curve"].strValue = "[[f]]";
|
configValues["animations:borders_curve"].strValue = "[[f]]";
|
||||||
configValues["animations:borders_speed"].floatValue = 0.f;
|
configValues["animations:borders_speed"].floatValue = 0.f;
|
||||||
configValues["animations:borders"].intValue = 1;
|
configValues["animations:borders"].intValue = 1;
|
||||||
configValues["animations:fadein_style"].strValue = STRVAL_EMPTY;
|
configValues["animations:fadein_style"].strValue = STRVAL_EMPTY;
|
||||||
configValues["animations:fadein_curve"].strValue = "[[f]]";
|
configValues["animations:fadein_curve"].strValue = "[[f]]";
|
||||||
configValues["animations:fadein_speed"].floatValue = 0.f;
|
configValues["animations:fadein_speed"].floatValue = 0.f;
|
||||||
configValues["animations:fadein"].intValue = 1;
|
configValues["animations:fadein"].intValue = 1;
|
||||||
configValues["animations:workspaces_style"].strValue = STRVAL_EMPTY;
|
configValues["animations:workspaces_style"].strValue = STRVAL_EMPTY;
|
||||||
configValues["animations:workspaces_curve"].strValue = "[[f]]";
|
configValues["animations:workspaces_curve"].strValue = "[[f]]";
|
||||||
configValues["animations:workspaces_speed"].floatValue = 0.f;
|
configValues["animations:workspaces_speed"].floatValue = 0.f;
|
||||||
configValues["animations:workspaces"].intValue = 1;
|
configValues["animations:workspaces"].intValue = 1;
|
||||||
|
|
||||||
configValues["input:sensitivity"].floatValue = 0.f;
|
configValues["input:sensitivity"].floatValue = 0.f;
|
||||||
configValues["input:accel_profile"].strValue = STRVAL_EMPTY;
|
configValues["input:accel_profile"].strValue = STRVAL_EMPTY;
|
||||||
configValues["input:kb_file"].strValue = STRVAL_EMPTY;
|
configValues["input:kb_file"].strValue = STRVAL_EMPTY;
|
||||||
configValues["input:kb_layout"].strValue = "us";
|
configValues["input:kb_layout"].strValue = "us";
|
||||||
configValues["input:kb_variant"].strValue = STRVAL_EMPTY;
|
configValues["input:kb_variant"].strValue = STRVAL_EMPTY;
|
||||||
configValues["input:kb_options"].strValue = STRVAL_EMPTY;
|
configValues["input:kb_options"].strValue = STRVAL_EMPTY;
|
||||||
configValues["input:kb_rules"].strValue = STRVAL_EMPTY;
|
configValues["input:kb_rules"].strValue = STRVAL_EMPTY;
|
||||||
configValues["input:kb_model"].strValue = STRVAL_EMPTY;
|
configValues["input:kb_model"].strValue = STRVAL_EMPTY;
|
||||||
configValues["input:repeat_rate"].intValue = 25;
|
configValues["input:repeat_rate"].intValue = 25;
|
||||||
configValues["input:repeat_delay"].intValue = 600;
|
configValues["input:repeat_delay"].intValue = 600;
|
||||||
configValues["input:natural_scroll"].intValue = 0;
|
configValues["input:natural_scroll"].intValue = 0;
|
||||||
configValues["input:numlock_by_default"].intValue = 0;
|
configValues["input:numlock_by_default"].intValue = 0;
|
||||||
configValues["input:force_no_accel"].intValue = 0;
|
configValues["input:force_no_accel"].intValue = 0;
|
||||||
configValues["input:float_switch_override_focus"].intValue = 1;
|
configValues["input:float_switch_override_focus"].intValue = 1;
|
||||||
configValues["input:left_handed"].intValue = 0;
|
configValues["input:left_handed"].intValue = 0;
|
||||||
configValues["input:scroll_method"].strValue = STRVAL_EMPTY;
|
configValues["input:scroll_method"].strValue = STRVAL_EMPTY;
|
||||||
configValues["input:scroll_button"].intValue = 0;
|
configValues["input:scroll_button"].intValue = 0;
|
||||||
configValues["input:touchpad:natural_scroll"].intValue = 0;
|
configValues["input:touchpad:natural_scroll"].intValue = 0;
|
||||||
configValues["input:touchpad:disable_while_typing"].intValue = 1;
|
configValues["input:touchpad:disable_while_typing"].intValue = 1;
|
||||||
configValues["input:touchpad:clickfinger_behavior"].intValue = 0;
|
configValues["input:touchpad:clickfinger_behavior"].intValue = 0;
|
||||||
configValues["input:touchpad:middle_button_emulation"].intValue = 0;
|
configValues["input:touchpad:middle_button_emulation"].intValue = 0;
|
||||||
configValues["input:touchpad:tap-to-click"].intValue = 1;
|
configValues["input:touchpad:tap-to-click"].intValue = 1;
|
||||||
configValues["input:touchpad:drag_lock"].intValue = 0;
|
configValues["input:touchpad:drag_lock"].intValue = 0;
|
||||||
configValues["input:touchpad:scroll_factor"].floatValue = 1.f;
|
configValues["input:touchpad:scroll_factor"].floatValue = 1.f;
|
||||||
configValues["input:touchdevice:transform"].intValue = 0;
|
configValues["input:touchdevice:transform"].intValue = 0;
|
||||||
configValues["input:touchdevice:output"].strValue = STRVAL_EMPTY;
|
configValues["input:touchdevice:output"].strValue = STRVAL_EMPTY;
|
||||||
|
|
||||||
configValues["binds:pass_mouse_when_bound"].intValue = 0;
|
configValues["binds:pass_mouse_when_bound"].intValue = 0;
|
||||||
configValues["binds:scroll_event_delay"].intValue = 300;
|
configValues["binds:scroll_event_delay"].intValue = 300;
|
||||||
configValues["binds:workspace_back_and_forth"].intValue = 0;
|
configValues["binds:workspace_back_and_forth"].intValue = 0;
|
||||||
configValues["binds:allow_workspace_cycles"].intValue = 0;
|
configValues["binds:allow_workspace_cycles"].intValue = 0;
|
||||||
|
|
||||||
configValues["gestures:workspace_swipe"].intValue = 0;
|
configValues["gestures:workspace_swipe"].intValue = 0;
|
||||||
configValues["gestures:workspace_swipe_fingers"].intValue = 3;
|
configValues["gestures:workspace_swipe_fingers"].intValue = 3;
|
||||||
configValues["gestures:workspace_swipe_distance"].intValue = 300;
|
configValues["gestures:workspace_swipe_distance"].intValue = 300;
|
||||||
configValues["gestures:workspace_swipe_invert"].intValue = 1;
|
configValues["gestures:workspace_swipe_invert"].intValue = 1;
|
||||||
configValues["gestures:workspace_swipe_min_speed_to_force"].intValue = 30;
|
configValues["gestures:workspace_swipe_min_speed_to_force"].intValue = 30;
|
||||||
configValues["gestures:workspace_swipe_cancel_ratio"].floatValue = 0.5f;
|
configValues["gestures:workspace_swipe_cancel_ratio"].floatValue = 0.5f;
|
||||||
configValues["gestures:workspace_swipe_create_new"].intValue = 1;
|
configValues["gestures:workspace_swipe_create_new"].intValue = 1;
|
||||||
configValues["gestures:workspace_swipe_forever"].intValue = 0;
|
configValues["gestures:workspace_swipe_forever"].intValue = 0;
|
||||||
|
|
||||||
configValues["input:follow_mouse"].intValue = 1;
|
configValues["input:follow_mouse"].intValue = 1;
|
||||||
|
|
||||||
|
@ -181,29 +181,29 @@ void CConfigManager::setDefaultVars() {
|
||||||
void CConfigManager::setDeviceDefaultVars(const std::string& dev) {
|
void CConfigManager::setDeviceDefaultVars(const std::string& dev) {
|
||||||
auto& cfgValues = deviceConfigs[dev];
|
auto& cfgValues = deviceConfigs[dev];
|
||||||
|
|
||||||
cfgValues["sensitivity"].floatValue = 0.f;
|
cfgValues["sensitivity"].floatValue = 0.f;
|
||||||
cfgValues["accel_profile"].strValue = STRVAL_EMPTY;
|
cfgValues["accel_profile"].strValue = STRVAL_EMPTY;
|
||||||
cfgValues["kb_file"].strValue = STRVAL_EMPTY;
|
cfgValues["kb_file"].strValue = STRVAL_EMPTY;
|
||||||
cfgValues["kb_layout"].strValue = "us";
|
cfgValues["kb_layout"].strValue = "us";
|
||||||
cfgValues["kb_variant"].strValue = STRVAL_EMPTY;
|
cfgValues["kb_variant"].strValue = STRVAL_EMPTY;
|
||||||
cfgValues["kb_options"].strValue = STRVAL_EMPTY;
|
cfgValues["kb_options"].strValue = STRVAL_EMPTY;
|
||||||
cfgValues["kb_rules"].strValue = STRVAL_EMPTY;
|
cfgValues["kb_rules"].strValue = STRVAL_EMPTY;
|
||||||
cfgValues["kb_model"].strValue = STRVAL_EMPTY;
|
cfgValues["kb_model"].strValue = STRVAL_EMPTY;
|
||||||
cfgValues["repeat_rate"].intValue = 25;
|
cfgValues["repeat_rate"].intValue = 25;
|
||||||
cfgValues["repeat_delay"].intValue = 600;
|
cfgValues["repeat_delay"].intValue = 600;
|
||||||
cfgValues["natural_scroll"].intValue = 0;
|
cfgValues["natural_scroll"].intValue = 0;
|
||||||
cfgValues["numlock_by_default"].intValue = 0;
|
cfgValues["numlock_by_default"].intValue = 0;
|
||||||
cfgValues["disable_while_typing"].intValue = 1;
|
cfgValues["disable_while_typing"].intValue = 1;
|
||||||
cfgValues["clickfinger_behavior"].intValue = 0;
|
cfgValues["clickfinger_behavior"].intValue = 0;
|
||||||
cfgValues["middle_button_emulation"].intValue = 0;
|
cfgValues["middle_button_emulation"].intValue = 0;
|
||||||
cfgValues["tap-to-click"].intValue = 1;
|
cfgValues["tap-to-click"].intValue = 1;
|
||||||
cfgValues["drag_lock"].intValue = 0;
|
cfgValues["drag_lock"].intValue = 0;
|
||||||
cfgValues["left_handed"].intValue = 0;
|
cfgValues["left_handed"].intValue = 0;
|
||||||
cfgValues["scroll_method"].strValue = STRVAL_EMPTY;
|
cfgValues["scroll_method"].strValue = STRVAL_EMPTY;
|
||||||
cfgValues["scroll_button"].intValue = 0;
|
cfgValues["scroll_button"].intValue = 0;
|
||||||
cfgValues["touch_transform"].intValue = 0;
|
cfgValues["touch_transform"].intValue = 0;
|
||||||
cfgValues["touch_output"].strValue = STRVAL_EMPTY;
|
cfgValues["touch_output"].strValue = STRVAL_EMPTY;
|
||||||
cfgValues["enabled"].intValue = 1; // only for mice / touchpads
|
cfgValues["enabled"].intValue = 1; // only for mice / touchpads
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::setDefaultAnimationVars() {
|
void CConfigManager::setDefaultAnimationVars() {
|
||||||
|
@ -233,15 +233,7 @@ void CConfigManager::setDefaultAnimationVars() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// init the values
|
// init the values
|
||||||
animationConfig["global"] = {
|
animationConfig["global"] = {false, "default", "", 8.f, 1, &animationConfig["general"], nullptr};
|
||||||
false,
|
|
||||||
"default",
|
|
||||||
"",
|
|
||||||
8.f,
|
|
||||||
1,
|
|
||||||
&animationConfig["general"],
|
|
||||||
nullptr
|
|
||||||
};
|
|
||||||
|
|
||||||
CREATEANIMCFG("windows", "global");
|
CREATEANIMCFG("windows", "global");
|
||||||
CREATEANIMCFG("fade", "global");
|
CREATEANIMCFG("fade", "global");
|
||||||
|
@ -270,7 +262,7 @@ void CConfigManager::init() {
|
||||||
const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
|
const std::string CONFIGPATH = ENVHOME + (ISDEBUG ? (std::string) "/.config/hypr/hyprlandd.conf" : (std::string) "/.config/hypr/hyprland.conf");
|
||||||
|
|
||||||
struct stat fileStat;
|
struct stat fileStat;
|
||||||
int err = stat(CONFIGPATH.c_str(), &fileStat);
|
int err = stat(CONFIGPATH.c_str(), &fileStat);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
Debug::log(WARN, "Error at statting config, error %i", errno);
|
Debug::log(WARN, "Error at statting config, error %i", errno);
|
||||||
}
|
}
|
||||||
|
@ -298,7 +290,7 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s
|
||||||
SConfigValue* CONFIGENTRY = nullptr;
|
SConfigValue* CONFIGENTRY = nullptr;
|
||||||
|
|
||||||
if (COMMAND.find("device:") == 0) {
|
if (COMMAND.find("device:") == 0) {
|
||||||
const auto DEVICE = COMMAND.substr(7).substr(0, COMMAND.find_last_of(':') - 7);
|
const auto DEVICE = COMMAND.substr(7).substr(0, COMMAND.find_last_of(':') - 7);
|
||||||
const auto CONFIGVAR = COMMAND.substr(COMMAND.find_last_of(':') + 1);
|
const auto CONFIGVAR = COMMAND.substr(COMMAND.find_last_of(':') + 1);
|
||||||
|
|
||||||
if (!deviceConfigExists(DEVICE))
|
if (!deviceConfigExists(DEVICE))
|
||||||
|
@ -360,7 +352,7 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s
|
||||||
|
|
||||||
switch (CONFIGENTRY->data->getDataType()) {
|
switch (CONFIGENTRY->data->getDataType()) {
|
||||||
case CVD_TYPE_GRADIENT: {
|
case CVD_TYPE_GRADIENT: {
|
||||||
|
|
||||||
CVarList varlist(VALUE, 0, ' ');
|
CVarList varlist(VALUE, 0, ' ');
|
||||||
|
|
||||||
CGradientValueData* data = (CGradientValueData*)CONFIGENTRY->data.get();
|
CGradientValueData* data = (CGradientValueData*)CONFIGENTRY->data.get();
|
||||||
|
@ -414,7 +406,7 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s
|
||||||
configPaths.push_back(PATH);
|
configPaths.push_back(PATH);
|
||||||
|
|
||||||
struct stat fileStat;
|
struct stat fileStat;
|
||||||
int err = stat(PATH.c_str(), &fileStat);
|
int err = stat(PATH.c_str(), &fileStat);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
Debug::log(WARN, "Error at ticking config at %s, error %i: %s", PATH.c_str(), err, strerror(err));
|
Debug::log(WARN, "Error at ticking config at %s, error %i: %s", PATH.c_str(), err, strerror(err));
|
||||||
return;
|
return;
|
||||||
|
@ -470,8 +462,7 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::find_if(m_dMonitorRules.begin(), m_dMonitorRules.end(), [&](const auto& other) { return other.name == newrule.name; }) != m_dMonitorRules.end())
|
std::erase_if(m_dMonitorRules, [&](const auto& other) { return other.name == newrule.name; });
|
||||||
m_dMonitorRules.erase(std::remove_if(m_dMonitorRules.begin(), m_dMonitorRules.end(), [&](const auto& other) { return other.name == newrule.name; }));
|
|
||||||
|
|
||||||
m_dMonitorRules.push_back(newrule);
|
m_dMonitorRules.push_back(newrule);
|
||||||
|
|
||||||
|
@ -481,9 +472,9 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
|
||||||
if (ARGS[1].find("pref") == 0) {
|
if (ARGS[1].find("pref") == 0) {
|
||||||
newrule.resolution = Vector2D();
|
newrule.resolution = Vector2D();
|
||||||
} else if (ARGS[1].find("highrr") == 0) {
|
} else if (ARGS[1].find("highrr") == 0) {
|
||||||
newrule.resolution = Vector2D(-1,-1);
|
newrule.resolution = Vector2D(-1, -1);
|
||||||
} else if (ARGS[1].find("highres") == 0) {
|
} else if (ARGS[1].find("highres") == 0) {
|
||||||
newrule.resolution = Vector2D(-1,-2);
|
newrule.resolution = Vector2D(-1, -2);
|
||||||
} else {
|
} else {
|
||||||
newrule.resolution.x = stoi(ARGS[1].substr(0, ARGS[1].find_first_of('x')));
|
newrule.resolution.x = stoi(ARGS[1].substr(0, ARGS[1].find_first_of('x')));
|
||||||
newrule.resolution.y = stoi(ARGS[1].substr(ARGS[1].find_first_of('x') + 1, ARGS[1].find_first_of('@')));
|
newrule.resolution.y = stoi(ARGS[1].substr(ARGS[1].find_first_of('x') + 1, ARGS[1].find_first_of('@')));
|
||||||
|
@ -499,7 +490,7 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
|
||||||
newrule.offset.y = stoi(ARGS[2].substr(ARGS[2].find_first_of('x') + 1));
|
newrule.offset.y = stoi(ARGS[2].substr(ARGS[2].find_first_of('x') + 1));
|
||||||
|
|
||||||
if (newrule.offset.x < 0 || newrule.offset.y < 0) {
|
if (newrule.offset.x < 0 || newrule.offset.y < 0) {
|
||||||
parseError = "invalid offset. Offset cannot be negative.";
|
parseError = "invalid offset. Offset cannot be negative.";
|
||||||
newrule.offset = Vector2D();
|
newrule.offset = Vector2D();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -510,7 +501,7 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
|
||||||
newrule.scale = stof(ARGS[3]);
|
newrule.scale = stof(ARGS[3]);
|
||||||
|
|
||||||
if (newrule.scale < 0.25f) {
|
if (newrule.scale < 0.25f) {
|
||||||
parseError = "not a valid scale.";
|
parseError = "not a valid scale.";
|
||||||
newrule.scale = 1;
|
newrule.scale = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -533,8 +524,7 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
|
||||||
argno++;
|
argno++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::find_if(m_dMonitorRules.begin(), m_dMonitorRules.end(), [&](const auto& other) { return other.name == newrule.name; }) != m_dMonitorRules.end())
|
std::erase_if(m_dMonitorRules, [&](const auto& other) { return other.name == newrule.name; });
|
||||||
m_dMonitorRules.erase(std::remove_if(m_dMonitorRules.begin(), m_dMonitorRules.end(), [&](const auto& other) { return other.name == newrule.name; }));
|
|
||||||
|
|
||||||
m_dMonitorRules.push_back(newrule);
|
m_dMonitorRules.push_back(newrule);
|
||||||
}
|
}
|
||||||
|
@ -566,7 +556,7 @@ void CConfigManager::handleBezier(const std::string& command, const std::string&
|
||||||
g_pAnimationManager->addBezierWithName(bezierName, Vector2D(p1x, p1y), Vector2D(p2x, p2y));
|
g_pAnimationManager->addBezierWithName(bezierName, Vector2D(p1x, p1y), Vector2D(p2x, p2y));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::setAnimForChildren(SAnimationPropertyConfig *const ANIM) {
|
void CConfigManager::setAnimForChildren(SAnimationPropertyConfig* const ANIM) {
|
||||||
for (auto& [name, anim] : animationConfig) {
|
for (auto& [name, anim] : animationConfig) {
|
||||||
if (anim.pParentAnimation == ANIM && !anim.overriden) {
|
if (anim.pParentAnimation == ANIM && !anim.overriden) {
|
||||||
// if a child isnt overriden, set the values of the parent
|
// if a child isnt overriden, set the values of the parent
|
||||||
|
@ -593,7 +583,7 @@ void CConfigManager::handleAnimation(const std::string& command, const std::stri
|
||||||
}
|
}
|
||||||
|
|
||||||
PANIM->second.overriden = true;
|
PANIM->second.overriden = true;
|
||||||
PANIM->second.pValues = &PANIM->second;
|
PANIM->second.pValues = &PANIM->second;
|
||||||
|
|
||||||
// on/off
|
// on/off
|
||||||
PANIM->second.internalEnabled = ARGS[1] == "1";
|
PANIM->second.internalEnabled = ARGS[1] == "1";
|
||||||
|
@ -607,19 +597,19 @@ void CConfigManager::handleAnimation(const std::string& command, const std::stri
|
||||||
PANIM->second.internalSpeed = std::stof(ARGS[2]);
|
PANIM->second.internalSpeed = std::stof(ARGS[2]);
|
||||||
|
|
||||||
if (PANIM->second.internalSpeed <= 0) {
|
if (PANIM->second.internalSpeed <= 0) {
|
||||||
parseError = "invalid speed";
|
parseError = "invalid speed";
|
||||||
PANIM->second.internalSpeed = 1.f;
|
PANIM->second.internalSpeed = 1.f;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PANIM->second.internalSpeed = 10.f;
|
PANIM->second.internalSpeed = 10.f;
|
||||||
parseError = "invalid speed";
|
parseError = "invalid speed";
|
||||||
}
|
}
|
||||||
|
|
||||||
// curve
|
// curve
|
||||||
PANIM->second.internalBezier = ARGS[3];
|
PANIM->second.internalBezier = ARGS[3];
|
||||||
|
|
||||||
if (!g_pAnimationManager->bezierExists(ARGS[3])) {
|
if (!g_pAnimationManager->bezierExists(ARGS[3])) {
|
||||||
parseError = "no such bezier";
|
parseError = "no such bezier";
|
||||||
PANIM->second.internalBezier = "default";
|
PANIM->second.internalBezier = "default";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -642,10 +632,10 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v
|
||||||
// bind[fl]=SUPER,G,exec,dmenu_run <args>
|
// bind[fl]=SUPER,G,exec,dmenu_run <args>
|
||||||
|
|
||||||
// flags
|
// flags
|
||||||
bool locked = false;
|
bool locked = false;
|
||||||
bool release = false;
|
bool release = false;
|
||||||
bool repeat = false;
|
bool repeat = false;
|
||||||
bool mouse = false;
|
bool mouse = false;
|
||||||
const auto BINDARGS = command.substr(4);
|
const auto BINDARGS = command.substr(4);
|
||||||
|
|
||||||
for (auto& arg : BINDARGS) {
|
for (auto& arg : BINDARGS) {
|
||||||
|
@ -683,7 +673,7 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto MOD = g_pKeybindManager->stringToModMask(ARGS[0]);
|
const auto MOD = g_pKeybindManager->stringToModMask(ARGS[0]);
|
||||||
const auto MODSTR = ARGS[0];
|
const auto MODSTR = ARGS[0];
|
||||||
|
|
||||||
const auto KEY = ARGS[1];
|
const auto KEY = ARGS[1];
|
||||||
|
@ -736,38 +726,16 @@ void CConfigManager::handleUnbind(const std::string& command, const std::string&
|
||||||
}
|
}
|
||||||
|
|
||||||
bool windowRuleValid(const std::string& RULE) {
|
bool windowRuleValid(const std::string& RULE) {
|
||||||
return !(RULE != "float"
|
return !(RULE != "float" && RULE != "tile" && RULE.find("opacity") != 0 && RULE.find("move") != 0 && RULE.find("size") != 0 && RULE.find("minsize") != 0 &&
|
||||||
&& RULE != "tile"
|
RULE.find("maxsize") != 0 && RULE.find("pseudo") != 0 && RULE.find("monitor") != 0 && RULE.find("idleinhibit") != 0 && RULE != "nofocus" && RULE != "noblur" &&
|
||||||
&& RULE.find("opacity") != 0
|
RULE != "noshadow" && RULE != "noborder" && RULE != "center" && RULE != "opaque" && RULE != "forceinput" && RULE != "fullscreen" && RULE != "nofullscreenrequest" &&
|
||||||
&& RULE.find("move") != 0
|
RULE != "nomaxsize" && RULE != "pin" && RULE != "noanim" && RULE != "windowdance" && RULE.find("animation") != 0 && RULE.find("rounding") != 0 &&
|
||||||
&& RULE.find("size") != 0
|
RULE.find("workspace") != 0 && RULE.find("bordercolor") != 0);
|
||||||
&& RULE.find("minsize") != 0
|
|
||||||
&& RULE.find("maxsize") != 0
|
|
||||||
&& RULE.find("pseudo") != 0
|
|
||||||
&& RULE.find("monitor") != 0
|
|
||||||
&& RULE.find("idleinhibit") != 0
|
|
||||||
&& RULE != "nofocus"
|
|
||||||
&& RULE != "noblur"
|
|
||||||
&& RULE != "noshadow"
|
|
||||||
&& RULE != "noborder"
|
|
||||||
&& RULE != "center"
|
|
||||||
&& RULE != "opaque"
|
|
||||||
&& RULE != "forceinput"
|
|
||||||
&& RULE != "fullscreen"
|
|
||||||
&& RULE != "nofullscreenrequest"
|
|
||||||
&& RULE != "nomaxsize"
|
|
||||||
&& RULE != "pin"
|
|
||||||
&& RULE != "noanim"
|
|
||||||
&& RULE != "windowdance"
|
|
||||||
&& RULE.find("animation") != 0
|
|
||||||
&& RULE.find("rounding") != 0
|
|
||||||
&& RULE.find("workspace") != 0
|
|
||||||
&& RULE.find("bordercolor") != 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {
|
void CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {
|
||||||
const auto RULE = removeBeginEndSpacesTabs(value.substr(0, value.find_first_of(",")));
|
const auto RULE = removeBeginEndSpacesTabs(value.substr(0, value.find_first_of(',')));
|
||||||
const auto VALUE = removeBeginEndSpacesTabs(value.substr(value.find_first_of(",") + 1));
|
const auto VALUE = removeBeginEndSpacesTabs(value.substr(value.find_first_of(',') + 1));
|
||||||
|
|
||||||
// check rule and value
|
// check rule and value
|
||||||
if (RULE == "" || VALUE == "") {
|
if (RULE == "" || VALUE == "") {
|
||||||
|
@ -775,9 +743,7 @@ void CConfigManager::handleWindowRule(const std::string& command, const std::str
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RULE == "unset") {
|
if (RULE == "unset") {
|
||||||
std::erase_if(m_dWindowRules, [&] (const SWindowRule& other) {
|
std::erase_if(m_dWindowRules, [&](const SWindowRule& other) { return other.szValue == VALUE; });
|
||||||
return other.szValue == VALUE;
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -792,8 +758,8 @@ void CConfigManager::handleWindowRule(const std::string& command, const std::str
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::handleWindowRuleV2(const std::string& command, const std::string& value) {
|
void CConfigManager::handleWindowRuleV2(const std::string& command, const std::string& value) {
|
||||||
const auto RULE = value.substr(0, value.find_first_of(","));
|
const auto RULE = value.substr(0, value.find_first_of(','));
|
||||||
const auto VALUE = value.substr(value.find_first_of(",") + 1);
|
const auto VALUE = value.substr(value.find_first_of(',') + 1);
|
||||||
|
|
||||||
if (!windowRuleValid(RULE) && RULE != "unset") {
|
if (!windowRuleValid(RULE) && RULE != "unset") {
|
||||||
Debug::log(ERR, "Invalid rulev2 found: %s", RULE.c_str());
|
Debug::log(ERR, "Invalid rulev2 found: %s", RULE.c_str());
|
||||||
|
@ -803,20 +769,19 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
|
||||||
|
|
||||||
// now we estract shit from the value
|
// now we estract shit from the value
|
||||||
SWindowRule rule;
|
SWindowRule rule;
|
||||||
rule.v2 = true;
|
rule.v2 = true;
|
||||||
rule.szRule = RULE;
|
rule.szRule = RULE;
|
||||||
rule.szValue = VALUE;
|
rule.szValue = VALUE;
|
||||||
|
|
||||||
const auto TITLEPOS = VALUE.find("title:");
|
const auto TITLEPOS = VALUE.find("title:");
|
||||||
const auto CLASSPOS = VALUE.find("class:");
|
const auto CLASSPOS = VALUE.find("class:");
|
||||||
const auto X11POS = VALUE.find("xwayland:");
|
const auto X11POS = VALUE.find("xwayland:");
|
||||||
const auto FLOATPOS = VALUE.find("floating:");
|
const auto FLOATPOS = VALUE.find("floating:");
|
||||||
const auto FULLSCREENPOS = VALUE.find("fullscreen:");
|
const auto FULLSCREENPOS = VALUE.find("fullscreen:");
|
||||||
const auto PINNEDPOS = VALUE.find("pinned:");
|
const auto PINNEDPOS = VALUE.find("pinned:");
|
||||||
|
|
||||||
if (TITLEPOS == std::string::npos && CLASSPOS == std::string::npos &&
|
if (TITLEPOS == std::string::npos && CLASSPOS == std::string::npos && X11POS == std::string::npos && FLOATPOS == std::string::npos && FULLSCREENPOS == std::string::npos &&
|
||||||
X11POS == std::string::npos && FLOATPOS == std::string::npos &&
|
PINNEDPOS == std::string::npos) {
|
||||||
FULLSCREENPOS == std::string::npos && PINNEDPOS == std::string::npos) {
|
|
||||||
Debug::log(ERR, "Invalid rulev2 syntax: %s", VALUE.c_str());
|
Debug::log(ERR, "Invalid rulev2 syntax: %s", VALUE.c_str());
|
||||||
parseError = "Invalid rulev2 syntax: " + VALUE;
|
parseError = "Invalid rulev2 syntax: " + VALUE;
|
||||||
return;
|
return;
|
||||||
|
@ -827,12 +792,18 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
|
||||||
result = VALUE.substr(pos);
|
result = VALUE.substr(pos);
|
||||||
|
|
||||||
size_t min = 999999;
|
size_t min = 999999;
|
||||||
if (TITLEPOS > pos && TITLEPOS < min) min = TITLEPOS;
|
if (TITLEPOS > pos && TITLEPOS < min)
|
||||||
if (CLASSPOS > pos && CLASSPOS < min) min = CLASSPOS;
|
min = TITLEPOS;
|
||||||
if (X11POS > pos && X11POS < min) min = X11POS;
|
if (CLASSPOS > pos && CLASSPOS < min)
|
||||||
if (FLOATPOS > pos && FLOATPOS < min) min = FLOATPOS;
|
min = CLASSPOS;
|
||||||
if (FULLSCREENPOS > pos && FULLSCREENPOS < min) min = FULLSCREENPOS;
|
if (X11POS > pos && X11POS < min)
|
||||||
if (PINNEDPOS > pos && PINNEDPOS < min) min = PINNEDPOS;
|
min = X11POS;
|
||||||
|
if (FLOATPOS > pos && FLOATPOS < min)
|
||||||
|
min = FLOATPOS;
|
||||||
|
if (FULLSCREENPOS > pos && FULLSCREENPOS < min)
|
||||||
|
min = FULLSCREENPOS;
|
||||||
|
if (PINNEDPOS > pos && PINNEDPOS < min)
|
||||||
|
min = PINNEDPOS;
|
||||||
|
|
||||||
result = result.substr(0, min - pos);
|
result = result.substr(0, min - pos);
|
||||||
|
|
||||||
|
@ -909,7 +880,7 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
|
||||||
void CConfigManager::handleBlurLS(const std::string& command, const std::string& value) {
|
void CConfigManager::handleBlurLS(const std::string& command, const std::string& value) {
|
||||||
if (value.find("remove,") == 0) {
|
if (value.find("remove,") == 0) {
|
||||||
const auto TOREMOVE = removeBeginEndSpacesTabs(value.substr(7));
|
const auto TOREMOVE = removeBeginEndSpacesTabs(value.substr(7));
|
||||||
std::erase_if(m_dBlurLSNamespaces, [&] (const auto& other) { return other == TOREMOVE; });
|
std::erase_if(m_dBlurLSNamespaces, [&](const auto& other) { return other == TOREMOVE; });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,7 +923,7 @@ void CConfigManager::handleSource(const std::string& command, const std::string&
|
||||||
configPaths.push_back(value);
|
configPaths.push_back(value);
|
||||||
|
|
||||||
struct stat fileStat;
|
struct stat fileStat;
|
||||||
int err = stat(value.c_str(), &fileStat);
|
int err = stat(value.c_str(), &fileStat);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
Debug::log(WARN, "Error at ticking config at %s, error %i: %s", value.c_str(), err, strerror(err));
|
Debug::log(WARN, "Error at ticking config at %s, error %i: %s", value.c_str(), err, strerror(err));
|
||||||
return;
|
return;
|
||||||
|
@ -962,8 +933,8 @@ void CConfigManager::handleSource(const std::string& command, const std::string&
|
||||||
|
|
||||||
std::ifstream ifs;
|
std::ifstream ifs;
|
||||||
ifs.open(value);
|
ifs.open(value);
|
||||||
std::string line = "";
|
std::string line = "";
|
||||||
int linenum = 1;
|
int linenum = 1;
|
||||||
if (ifs.is_open()) {
|
if (ifs.is_open()) {
|
||||||
while (std::getline(ifs, line)) {
|
while (std::getline(ifs, line)) {
|
||||||
// Read line by line.
|
// Read line by line.
|
||||||
|
@ -1003,7 +974,7 @@ void CConfigManager::handleBindWS(const std::string& command, const std::string&
|
||||||
|
|
||||||
std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::string& VALUE, bool dynamic) {
|
std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::string& VALUE, bool dynamic) {
|
||||||
if (dynamic) {
|
if (dynamic) {
|
||||||
parseError = "";
|
parseError = "";
|
||||||
currentCategory = "";
|
currentCategory = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1019,19 +990,30 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
|
||||||
if (isFirstLaunch) {
|
if (isFirstLaunch) {
|
||||||
firstExecRequests.push_back(VALUE);
|
firstExecRequests.push_back(VALUE);
|
||||||
}
|
}
|
||||||
}
|
} else if (COMMAND == "monitor")
|
||||||
else if (COMMAND == "monitor") handleMonitor(COMMAND, VALUE);
|
handleMonitor(COMMAND, VALUE);
|
||||||
else if (COMMAND.find("bind") == 0) handleBind(COMMAND, VALUE);
|
else if (COMMAND.find("bind") == 0)
|
||||||
else if (COMMAND == "unbind") handleUnbind(COMMAND, VALUE);
|
handleBind(COMMAND, VALUE);
|
||||||
else if (COMMAND == "workspace") handleDefaultWorkspace(COMMAND, VALUE);
|
else if (COMMAND == "unbind")
|
||||||
else if (COMMAND == "windowrule") handleWindowRule(COMMAND, VALUE);
|
handleUnbind(COMMAND, VALUE);
|
||||||
else if (COMMAND == "windowrulev2") handleWindowRuleV2(COMMAND, VALUE);
|
else if (COMMAND == "workspace")
|
||||||
else if (COMMAND == "bezier") handleBezier(COMMAND, VALUE);
|
handleDefaultWorkspace(COMMAND, VALUE);
|
||||||
else if (COMMAND == "animation") handleAnimation(COMMAND, VALUE);
|
else if (COMMAND == "windowrule")
|
||||||
else if (COMMAND == "source") handleSource(COMMAND, VALUE);
|
handleWindowRule(COMMAND, VALUE);
|
||||||
else if (COMMAND == "submap") handleSubmap(COMMAND, VALUE);
|
else if (COMMAND == "windowrulev2")
|
||||||
else if (COMMAND == "blurls") handleBlurLS(COMMAND, VALUE);
|
handleWindowRuleV2(COMMAND, VALUE);
|
||||||
else if (COMMAND == "wsbind") handleBindWS(COMMAND, VALUE);
|
else if (COMMAND == "bezier")
|
||||||
|
handleBezier(COMMAND, VALUE);
|
||||||
|
else if (COMMAND == "animation")
|
||||||
|
handleAnimation(COMMAND, VALUE);
|
||||||
|
else if (COMMAND == "source")
|
||||||
|
handleSource(COMMAND, VALUE);
|
||||||
|
else if (COMMAND == "submap")
|
||||||
|
handleSubmap(COMMAND, VALUE);
|
||||||
|
else if (COMMAND == "blurls")
|
||||||
|
handleBlurLS(COMMAND, VALUE);
|
||||||
|
else if (COMMAND == "wsbind")
|
||||||
|
handleBindWS(COMMAND, VALUE);
|
||||||
else {
|
else {
|
||||||
configSetValueSafe(currentCategory + (currentCategory == "" ? "" : ":") + COMMAND, VALUE);
|
configSetValueSafe(currentCategory + (currentCategory == "" ? "" : ":") + COMMAND, VALUE);
|
||||||
needsLayoutRecalc = 2;
|
needsLayoutRecalc = 2;
|
||||||
|
@ -1039,7 +1021,7 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
|
||||||
|
|
||||||
if (dynamic) {
|
if (dynamic) {
|
||||||
std::string retval = parseError;
|
std::string retval = parseError;
|
||||||
parseError = "";
|
parseError = "";
|
||||||
|
|
||||||
// invalidate layouts if they changed
|
// invalidate layouts if they changed
|
||||||
if (needsLayoutRecalc) {
|
if (needsLayoutRecalc) {
|
||||||
|
@ -1064,7 +1046,7 @@ void CConfigManager::applyUserDefinedVars(std::string& line, const size_t equals
|
||||||
while (dollarPlace != std::string::npos) {
|
while (dollarPlace != std::string::npos) {
|
||||||
|
|
||||||
const auto STRAFTERDOLLAR = line.substr(dollarPlace + 1);
|
const auto STRAFTERDOLLAR = line.substr(dollarPlace + 1);
|
||||||
for (auto&[var, value] : configDynamicVars) {
|
for (auto& [var, value] : configDynamicVars) {
|
||||||
if (STRAFTERDOLLAR.find(var) == 0) {
|
if (STRAFTERDOLLAR.find(var) == 0) {
|
||||||
line.replace(dollarPlace, var.length() + 1, value);
|
line.replace(dollarPlace, var.length() + 1, value);
|
||||||
break;
|
break;
|
||||||
|
@ -1110,8 +1092,7 @@ void CConfigManager::parseLine(std::string& line) {
|
||||||
if (currentCategory.length() != 0) {
|
if (currentCategory.length() != 0) {
|
||||||
currentCategory.push_back(':');
|
currentCategory.push_back(':');
|
||||||
currentCategory.append(cat);
|
currentCategory.append(cat);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
currentCategory = cat;
|
currentCategory = cat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1141,7 +1122,7 @@ void CConfigManager::parseLine(std::string& line) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto COMMAND = removeBeginEndSpacesTabs(line.substr(0, EQUALSPLACE));
|
const auto COMMAND = removeBeginEndSpacesTabs(line.substr(0, EQUALSPLACE));
|
||||||
const auto VALUE = removeBeginEndSpacesTabs(line.substr(EQUALSPLACE + 1));
|
const auto VALUE = removeBeginEndSpacesTabs(line.substr(EQUALSPLACE + 1));
|
||||||
//
|
//
|
||||||
|
|
||||||
parseKeyword(COMMAND, VALUE);
|
parseKeyword(COMMAND, VALUE);
|
||||||
|
@ -1149,8 +1130,8 @@ void CConfigManager::parseLine(std::string& line) {
|
||||||
|
|
||||||
void CConfigManager::loadConfigLoadVars() {
|
void CConfigManager::loadConfigLoadVars() {
|
||||||
Debug::log(LOG, "Reloading the config!");
|
Debug::log(LOG, "Reloading the config!");
|
||||||
parseError = ""; // reset the error
|
parseError = ""; // reset the error
|
||||||
currentCategory = ""; // reset the category
|
currentCategory = ""; // reset the category
|
||||||
|
|
||||||
// reset all vars before loading
|
// reset all vars before loading
|
||||||
setDefaultVars();
|
setDefaultVars();
|
||||||
|
@ -1170,8 +1151,8 @@ void CConfigManager::loadConfigLoadVars() {
|
||||||
|
|
||||||
std::string CONFIGPATH;
|
std::string CONFIGPATH;
|
||||||
|
|
||||||
static const char* const ENVHOME = getenv("HOME");
|
static const char* const ENVHOME = getenv("HOME");
|
||||||
const std::string CONFIGPARENTPATH = ENVHOME + (std::string) "/.config/hypr/";
|
const std::string CONFIGPARENTPATH = ENVHOME + (std::string) "/.config/hypr/";
|
||||||
|
|
||||||
if (g_pCompositor->explicitConfigPath == "") {
|
if (g_pCompositor->explicitConfigPath == "") {
|
||||||
CONFIGPATH = CONFIGPARENTPATH + (ISDEBUG ? "hyprlandd.conf" : "hyprland.conf");
|
CONFIGPATH = CONFIGPARENTPATH + (ISDEBUG ? "hyprlandd.conf" : "hyprland.conf");
|
||||||
|
@ -1185,17 +1166,17 @@ void CConfigManager::loadConfigLoadVars() {
|
||||||
ifs.open(CONFIGPATH);
|
ifs.open(CONFIGPATH);
|
||||||
|
|
||||||
if (!ifs.good()) {
|
if (!ifs.good()) {
|
||||||
if(g_pCompositor->explicitConfigPath == "") {
|
if (g_pCompositor->explicitConfigPath == "") {
|
||||||
Debug::log(WARN, "Config reading error. (No file? Attempting to generate, backing up old one if exists)");
|
Debug::log(WARN, "Config reading error. (No file? Attempting to generate, backing up old one if exists)");
|
||||||
try {
|
try {
|
||||||
std::filesystem::rename(CONFIGPATH, CONFIGPATH + ".backup");
|
std::filesystem::rename(CONFIGPATH, CONFIGPATH + ".backup");
|
||||||
} catch(...) { /* Probably doesn't exist */}
|
} catch (...) { /* Probably doesn't exist */
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!std::filesystem::is_directory(CONFIGPARENTPATH))
|
if (!std::filesystem::is_directory(CONFIGPARENTPATH))
|
||||||
std::filesystem::create_directories(CONFIGPARENTPATH);
|
std::filesystem::create_directories(CONFIGPARENTPATH);
|
||||||
}
|
} catch (...) {
|
||||||
catch (...) {
|
|
||||||
parseError = "Broken config file! (Could not create directory)";
|
parseError = "Broken config file! (Could not create directory)";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1216,8 +1197,8 @@ void CConfigManager::loadConfigLoadVars() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string line = "";
|
std::string line = "";
|
||||||
int linenum = 1;
|
int linenum = 1;
|
||||||
if (ifs.is_open()) {
|
if (ifs.is_open()) {
|
||||||
while (std::getline(ifs, line)) {
|
while (std::getline(ifs, line)) {
|
||||||
// Read line by line.
|
// Read line by line.
|
||||||
|
@ -1261,7 +1242,8 @@ void CConfigManager::loadConfigLoadVars() {
|
||||||
if (parseError != "")
|
if (parseError != "")
|
||||||
g_pHyprError->queueCreate(parseError + "\nHyprland may not work correctly.", CColor(255, 50, 50, 255));
|
g_pHyprError->queueCreate(parseError + "\nHyprland may not work correctly.", CColor(255, 50, 50, 255));
|
||||||
else if (configValues["autogenerated"].intValue == 1)
|
else if (configValues["autogenerated"].intValue == 1)
|
||||||
g_pHyprError->queueCreate("Warning: You're using an autogenerated config! (config file: " + CONFIGPATH + " )\nSUPER+Q -> kitty\nSUPER+M -> exit Hyprland", CColor(255, 255, 70, 255));
|
g_pHyprError->queueCreate("Warning: You're using an autogenerated config! (config file: " + CONFIGPATH + " )\nSUPER+Q -> kitty\nSUPER+M -> exit Hyprland",
|
||||||
|
CColor(255, 255, 70, 255));
|
||||||
else
|
else
|
||||||
g_pHyprError->destroy();
|
g_pHyprError->destroy();
|
||||||
|
|
||||||
|
@ -1308,7 +1290,7 @@ void CConfigManager::tick() {
|
||||||
|
|
||||||
for (auto& cf : configPaths) {
|
for (auto& cf : configPaths) {
|
||||||
struct stat fileStat;
|
struct stat fileStat;
|
||||||
int err = stat(cf.c_str(), &fileStat);
|
int err = stat(cf.c_str(), &fileStat);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
Debug::log(WARN, "Error at ticking config at %s, error %i: %s", cf.c_str(), err, strerror(err));
|
Debug::log(WARN, "Error at ticking config at %s, error %i: %s", cf.c_str(), err, strerror(err));
|
||||||
return;
|
return;
|
||||||
|
@ -1316,7 +1298,7 @@ void CConfigManager::tick() {
|
||||||
|
|
||||||
// check if we need to reload cfg
|
// check if we need to reload cfg
|
||||||
if (fileStat.st_mtime != configModifyTimes[cf] || m_bForceReload) {
|
if (fileStat.st_mtime != configModifyTimes[cf] || m_bForceReload) {
|
||||||
parse = true;
|
parse = true;
|
||||||
configModifyTimes[cf] = fileStat.st_mtime;
|
configModifyTimes[cf] = fileStat.st_mtime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1328,7 +1310,7 @@ void CConfigManager::tick() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::mutex configmtx;
|
std::mutex configmtx;
|
||||||
SConfigValue CConfigManager::getConfigValueSafe(const std::string& val) {
|
SConfigValue CConfigManager::getConfigValueSafe(const std::string& val) {
|
||||||
std::lock_guard<std::mutex> lg(configmtx);
|
std::lock_guard<std::mutex> lg(configmtx);
|
||||||
|
|
||||||
|
@ -1374,7 +1356,7 @@ float CConfigManager::getFloat(const std::string& v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CConfigManager::getString(const std::string& v) {
|
std::string CConfigManager::getString(const std::string& v) {
|
||||||
const auto VAL = getConfigValueSafe(v).strValue;
|
auto VAL = getConfigValueSafe(v).strValue;
|
||||||
|
|
||||||
if (VAL == STRVAL_EMPTY)
|
if (VAL == STRVAL_EMPTY)
|
||||||
return "";
|
return "";
|
||||||
|
@ -1391,7 +1373,7 @@ float CConfigManager::getDeviceFloat(const std::string& dev, const std::string&
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CConfigManager::getDeviceString(const std::string& dev, const std::string& v) {
|
std::string CConfigManager::getDeviceString(const std::string& dev, const std::string& v) {
|
||||||
const auto VAL = getConfigValueSafeDevice(dev, v).strValue;
|
auto VAL = getConfigValueSafeDevice(dev, v).strValue;
|
||||||
|
|
||||||
if (VAL == STRVAL_EMPTY)
|
if (VAL == STRVAL_EMPTY)
|
||||||
return "";
|
return "";
|
||||||
|
@ -1399,23 +1381,25 @@ std::string CConfigManager::getDeviceString(const std::string& dev, const std::s
|
||||||
return VAL;
|
return VAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::setInt(std::string v, int val) {
|
void CConfigManager::setInt(const std::string& v, int val) {
|
||||||
configValues[v].intValue = val;
|
configValues[v].intValue = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::setFloat(std::string v, float val) {
|
void CConfigManager::setFloat(const std::string& v, float val) {
|
||||||
configValues[v].floatValue = val;
|
configValues[v].floatValue = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::setString(std::string v, std::string val) {
|
void CConfigManager::setString(const std::string& v, const std::string& val) {
|
||||||
configValues[v].strValue = val;
|
configValues[v].strValue = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
SMonitorRule CConfigManager::getMonitorRuleFor(std::string name, std::string displayName) {
|
SMonitorRule CConfigManager::getMonitorRuleFor(const std::string& name, const std::string& displayName) {
|
||||||
SMonitorRule* found = nullptr;
|
SMonitorRule* found = nullptr;
|
||||||
|
|
||||||
for (auto& r : m_dMonitorRules) {
|
for (auto& r : m_dMonitorRules) {
|
||||||
if (r.name == name || (r.name.find("desc:") == 0 && (r.name.substr(5) == displayName || r.name.substr(5) == removeBeginEndSpacesTabs(displayName.substr(0, displayName.find_first_of('(')))))) {
|
if (r.name == name ||
|
||||||
|
(r.name.find("desc:") == 0 &&
|
||||||
|
(r.name.substr(5) == displayName || r.name.substr(5) == removeBeginEndSpacesTabs(displayName.substr(0, displayName.find_first_of('(')))))) {
|
||||||
found = &r;
|
found = &r;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1447,7 +1431,7 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
|
||||||
|
|
||||||
std::vector<SWindowRule> returns;
|
std::vector<SWindowRule> returns;
|
||||||
|
|
||||||
std::string title = g_pXWaylandManager->getTitle(pWindow);
|
std::string title = g_pXWaylandManager->getTitle(pWindow);
|
||||||
std::string appidclass = g_pXWaylandManager->getAppIDClass(pWindow);
|
std::string appidclass = g_pXWaylandManager->getAppIDClass(pWindow);
|
||||||
|
|
||||||
Debug::log(LOG, "Searching for matching rules for %s (title: %s)", appidclass.c_str(), title.c_str());
|
Debug::log(LOG, "Searching for matching rules for %s (title: %s)", appidclass.c_str(), title.c_str());
|
||||||
|
@ -1519,8 +1503,8 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
|
||||||
returns.push_back(rule);
|
returns.push_back(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint64_t PID = pWindow->getPID();
|
const uint64_t PID = pWindow->getPID();
|
||||||
bool anyExecFound = false;
|
bool anyExecFound = false;
|
||||||
|
|
||||||
for (auto& er : execRequestedRules) {
|
for (auto& er : execRequestedRules) {
|
||||||
if (er.iPid == PID) {
|
if (er.iPid == PID) {
|
||||||
|
@ -1585,11 +1569,11 @@ void CConfigManager::performMonitorReload() {
|
||||||
m_bWantsMonitorReload = false;
|
m_bWantsMonitorReload = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SConfigValue* CConfigManager::getConfigValuePtr(std::string val) {
|
SConfigValue* CConfigManager::getConfigValuePtr(const std::string& val) {
|
||||||
return &configValues[val];
|
return &configValues[val];
|
||||||
}
|
}
|
||||||
|
|
||||||
SConfigValue* CConfigManager::getConfigValuePtrSafe(std::string val) {
|
SConfigValue* CConfigManager::getConfigValuePtrSafe(const std::string& val) {
|
||||||
const auto IT = configValues.find(val);
|
const auto IT = configValues.find(val);
|
||||||
|
|
||||||
if (IT == configValues.end())
|
if (IT == configValues.end())
|
||||||
|
@ -1622,14 +1606,14 @@ void CConfigManager::ensureDPMS() {
|
||||||
auto rule = getMonitorRuleFor(rm->szName, rm->output->description ? rm->output->description : "");
|
auto rule = getMonitorRuleFor(rm->szName, rm->output->description ? rm->output->description : "");
|
||||||
|
|
||||||
if (rule.disabled == rm->m_bEnabled) {
|
if (rule.disabled == rm->m_bEnabled) {
|
||||||
rm->m_pThisWrap = &rm;
|
rm->m_pThisWrap = &rm;
|
||||||
g_pHyprRenderer->applyMonitorRule(rm.get(), &rule);
|
g_pHyprRenderer->applyMonitorRule(rm.get(), &rule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::ensureVRR(CMonitor* pMonitor) {
|
void CConfigManager::ensureVRR(CMonitor* pMonitor) {
|
||||||
static auto *const PNOVRR = &getConfigValuePtr("misc:no_vfr")->intValue;
|
static auto* const PNOVRR = &getConfigValuePtr("misc:no_vfr")->intValue;
|
||||||
|
|
||||||
auto ensureVRRForDisplay = [&](CMonitor* m) -> void {
|
auto ensureVRRForDisplay = [&](CMonitor* m) -> void {
|
||||||
if (!*PNOVRR && !m->vrrActive) {
|
if (!*PNOVRR && !m->vrrActive) {
|
||||||
|
@ -1682,8 +1666,8 @@ void CConfigManager::addParseError(const std::string& err) {
|
||||||
g_pHyprError->queueCreate(parseError + "\nHyprland may not work correctly.", CColor(255, 50, 50, 255));
|
g_pHyprError->queueCreate(parseError + "\nHyprland may not work correctly.", CColor(255, 50, 50, 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
CMonitor* CConfigManager::getBoundMonitorForWS(std::string wsname) {
|
CMonitor* CConfigManager::getBoundMonitorForWS(const std::string& wsname) {
|
||||||
for (auto&[ws, mon] : boundWorkspaces) {
|
for (auto& [ws, mon] : boundWorkspaces) {
|
||||||
const auto WSNAME = ws.find("name:") == 0 ? ws.substr(5) : ws;
|
const auto WSNAME = ws.find("name:") == 0 ? ws.substr(5) : ws;
|
||||||
|
|
||||||
if (WSNAME == wsname) {
|
if (WSNAME == wsname) {
|
||||||
|
@ -1694,7 +1678,7 @@ CMonitor* CConfigManager::getBoundMonitorForWS(std::string wsname) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CConfigManager::getBoundMonitorStringForWS(std::string wsname) {
|
std::string CConfigManager::getBoundMonitorStringForWS(const std::string& wsname) {
|
||||||
for (auto& [ws, mon] : boundWorkspaces) {
|
for (auto& [ws, mon] : boundWorkspaces) {
|
||||||
const auto WSNAME = ws.find("name:") == 0 ? ws.substr(5) : ws;
|
const auto WSNAME = ws.find("name:") == 0 ? ws.substr(5) : ws;
|
||||||
|
|
||||||
|
@ -1706,7 +1690,7 @@ std::string CConfigManager::getBoundMonitorStringForWS(std::string wsname) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConfigManager::addExecRule(SExecRequestedRule rule) {
|
void CConfigManager::addExecRule(const SExecRequestedRule& rule) {
|
||||||
execRequestedRules.push_back(rule);
|
execRequestedRules.push_back(rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,71 +17,71 @@
|
||||||
|
|
||||||
#define STRVAL_EMPTY "[[EMPTY]]"
|
#define STRVAL_EMPTY "[[EMPTY]]"
|
||||||
|
|
||||||
#define INITANIMCFG(name) animationConfig[name] = {}
|
#define INITANIMCFG(name) animationConfig[name] = {}
|
||||||
#define CREATEANIMCFG(name, parent) animationConfig[name] = {false, "", "", 0.f, -1, &animationConfig["global"], &animationConfig[parent]}
|
#define CREATEANIMCFG(name, parent) animationConfig[name] = {false, "", "", 0.f, -1, &animationConfig["global"], &animationConfig[parent]}
|
||||||
|
|
||||||
struct SConfigValue {
|
struct SConfigValue {
|
||||||
int64_t intValue = -INT64_MAX;
|
int64_t intValue = -INT64_MAX;
|
||||||
float floatValue = -__FLT_MAX__;
|
float floatValue = -__FLT_MAX__;
|
||||||
std::string strValue = "";
|
std::string strValue = "";
|
||||||
Vector2D vecValue = Vector2D(-__FLT_MAX__, -__FLT_MAX__);
|
Vector2D vecValue = Vector2D(-__FLT_MAX__, -__FLT_MAX__);
|
||||||
std::shared_ptr<ICustomConfigValueData> data;
|
std::shared_ptr<ICustomConfigValueData> data;
|
||||||
|
|
||||||
bool set = false; // used for device configs
|
bool set = false; // used for device configs
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMonitorRule {
|
struct SMonitorRule {
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
Vector2D resolution = Vector2D(1280,720);
|
Vector2D resolution = Vector2D(1280, 720);
|
||||||
Vector2D offset = Vector2D(0,0);
|
Vector2D offset = Vector2D(0, 0);
|
||||||
float scale = 1;
|
float scale = 1;
|
||||||
float refreshRate = 60;
|
float refreshRate = 60;
|
||||||
std::string defaultWorkspace = "";
|
std::string defaultWorkspace = "";
|
||||||
bool disabled = false;
|
bool disabled = false;
|
||||||
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
std::string mirrorOf = "";
|
std::string mirrorOf = "";
|
||||||
bool enable10bit = false;
|
bool enable10bit = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMonitorAdditionalReservedArea {
|
struct SMonitorAdditionalReservedArea {
|
||||||
int top = 0;
|
int top = 0;
|
||||||
int bottom = 0;
|
int bottom = 0;
|
||||||
int left = 0;
|
int left = 0;
|
||||||
int right = 0;
|
int right = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SAnimationPropertyConfig {
|
struct SAnimationPropertyConfig {
|
||||||
bool overriden = true;
|
bool overriden = true;
|
||||||
|
|
||||||
std::string internalBezier = "";
|
std::string internalBezier = "";
|
||||||
std::string internalStyle = "";
|
std::string internalStyle = "";
|
||||||
float internalSpeed = 0.f;
|
float internalSpeed = 0.f;
|
||||||
int internalEnabled = -1;
|
int internalEnabled = -1;
|
||||||
|
|
||||||
SAnimationPropertyConfig* pValues = nullptr;
|
SAnimationPropertyConfig* pValues = nullptr;
|
||||||
SAnimationPropertyConfig* pParentAnimation = nullptr;
|
SAnimationPropertyConfig* pParentAnimation = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SExecRequestedRule {
|
struct SExecRequestedRule {
|
||||||
std::string szRule = "";
|
std::string szRule = "";
|
||||||
uint64_t iPid = 0;
|
uint64_t iPid = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CVarList {
|
class CVarList {
|
||||||
public:
|
public:
|
||||||
CVarList(const std::string& in, long unsigned int lastArgNo = 0, const char separator = ',') {
|
CVarList(const std::string& in, long unsigned int lastArgNo = 0, const char separator = ',') {
|
||||||
std::string curitem = "";
|
std::string curitem = "";
|
||||||
std::string argZ = in;
|
std::string argZ = in;
|
||||||
|
|
||||||
auto nextItem = [&]() {
|
auto nextItem = [&]() {
|
||||||
auto idx = lastArgNo != 0 && m_vArgs.size() >= lastArgNo - 1 ? std::string::npos : argZ.find_first_of(separator);
|
auto idx = lastArgNo != 0 && m_vArgs.size() >= lastArgNo - 1 ? std::string::npos : argZ.find_first_of(separator);
|
||||||
|
|
||||||
if (idx != std::string::npos) {
|
if (idx != std::string::npos) {
|
||||||
curitem = argZ.substr(0, idx);
|
curitem = argZ.substr(0, idx);
|
||||||
argZ = argZ.substr(idx + 1);
|
argZ = argZ.substr(idx + 1);
|
||||||
} else {
|
} else {
|
||||||
curitem = argZ;
|
curitem = argZ;
|
||||||
argZ = STRVAL_EMPTY;
|
argZ = STRVAL_EMPTY;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -106,122 +106,130 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// for range-based loops
|
// for range-based loops
|
||||||
std::vector<std::string>::iterator begin() { return m_vArgs.begin(); }
|
std::vector<std::string>::iterator begin() {
|
||||||
std::vector<std::string>::const_iterator begin() const { return m_vArgs.begin(); }
|
return m_vArgs.begin();
|
||||||
std::vector<std::string>::iterator end() { return m_vArgs.end(); }
|
}
|
||||||
std::vector<std::string>::const_iterator end() const { return m_vArgs.end(); }
|
std::vector<std::string>::const_iterator begin() const {
|
||||||
|
return m_vArgs.begin();
|
||||||
|
}
|
||||||
|
std::vector<std::string>::iterator end() {
|
||||||
|
return m_vArgs.end();
|
||||||
|
}
|
||||||
|
std::vector<std::string>::const_iterator end() const {
|
||||||
|
return m_vArgs.end();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::string> m_vArgs;
|
std::vector<std::string> m_vArgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CConfigManager {
|
class CConfigManager {
|
||||||
public:
|
public:
|
||||||
CConfigManager();
|
CConfigManager();
|
||||||
|
|
||||||
void tick();
|
void tick();
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
int getInt(const std::string&);
|
int getInt(const std::string&);
|
||||||
float getFloat(const std::string&);
|
float getFloat(const std::string&);
|
||||||
std::string getString(const std::string&);
|
std::string getString(const std::string&);
|
||||||
void setFloat(std::string, float);
|
void setFloat(const std::string&, float);
|
||||||
void setInt(std::string, int);
|
void setInt(const std::string&, int);
|
||||||
void setString(std::string, std::string);
|
void setString(const std::string&, const std::string&);
|
||||||
|
|
||||||
int getDeviceInt(const std::string&, const std::string&);
|
int getDeviceInt(const std::string&, const std::string&);
|
||||||
float getDeviceFloat(const std::string&, const std::string&);
|
float getDeviceFloat(const std::string&, const std::string&);
|
||||||
std::string getDeviceString(const std::string&, const std::string&);
|
std::string getDeviceString(const std::string&, const std::string&);
|
||||||
bool deviceConfigExists(const std::string&);
|
bool deviceConfigExists(const std::string&);
|
||||||
bool shouldBlurLS(const std::string&);
|
bool shouldBlurLS(const std::string&);
|
||||||
|
|
||||||
SConfigValue* getConfigValuePtr(std::string);
|
SConfigValue* getConfigValuePtr(const std::string&);
|
||||||
SConfigValue* getConfigValuePtrSafe(std::string);
|
SConfigValue* getConfigValuePtrSafe(const std::string&);
|
||||||
|
|
||||||
SMonitorRule getMonitorRuleFor(std::string, std::string displayName = "");
|
SMonitorRule getMonitorRuleFor(const std::string&, const std::string& displayName = "");
|
||||||
|
|
||||||
CMonitor* getBoundMonitorForWS(std::string);
|
CMonitor* getBoundMonitorForWS(const std::string&);
|
||||||
std::string getBoundMonitorStringForWS(std::string);
|
std::string getBoundMonitorStringForWS(const std::string&);
|
||||||
|
|
||||||
std::vector<SWindowRule> getMatchingRules(CWindow*);
|
std::vector<SWindowRule> getMatchingRules(CWindow*);
|
||||||
|
|
||||||
std::unordered_map<std::string, SMonitorAdditionalReservedArea> m_mAdditionalReservedAreas;
|
std::unordered_map<std::string, SMonitorAdditionalReservedArea> m_mAdditionalReservedAreas;
|
||||||
|
|
||||||
// no-op when done.
|
// no-op when done.
|
||||||
void dispatchExecOnce();
|
void dispatchExecOnce();
|
||||||
|
|
||||||
void performMonitorReload();
|
void performMonitorReload();
|
||||||
bool m_bWantsMonitorReload = false;
|
bool m_bWantsMonitorReload = false;
|
||||||
bool m_bForceReload = false;
|
bool m_bForceReload = false;
|
||||||
bool m_bNoMonitorReload = false;
|
bool m_bNoMonitorReload = false;
|
||||||
void ensureDPMS();
|
void ensureDPMS();
|
||||||
void ensureVRR(CMonitor* pMonitor = nullptr);
|
void ensureVRR(CMonitor* pMonitor = nullptr);
|
||||||
|
|
||||||
std::string parseKeyword(const std::string&, const std::string&, bool dynamic = false);
|
std::string parseKeyword(const std::string&, const std::string&, bool dynamic = false);
|
||||||
|
|
||||||
void addParseError(const std::string&);
|
void addParseError(const std::string&);
|
||||||
|
|
||||||
SAnimationPropertyConfig* getAnimationPropertyConfig(const std::string&);
|
SAnimationPropertyConfig* getAnimationPropertyConfig(const std::string&);
|
||||||
|
|
||||||
void addExecRule(SExecRequestedRule);
|
void addExecRule(const SExecRequestedRule&);
|
||||||
|
|
||||||
std::string configCurrentPath;
|
std::string configCurrentPath;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::deque<std::string> configPaths; // stores all the config paths
|
std::deque<std::string> configPaths; // stores all the config paths
|
||||||
std::unordered_map<std::string, time_t> configModifyTimes; // stores modify times
|
std::unordered_map<std::string, time_t> configModifyTimes; // stores modify times
|
||||||
std::unordered_map<std::string, std::string> configDynamicVars; // stores dynamic vars declared by the user
|
std::unordered_map<std::string, std::string> configDynamicVars; // stores dynamic vars declared by the user
|
||||||
std::unordered_map<std::string, SConfigValue> configValues;
|
std::unordered_map<std::string, SConfigValue> configValues;
|
||||||
std::unordered_map<std::string, std::unordered_map<std::string, SConfigValue>> deviceConfigs; // stores device configs
|
std::unordered_map<std::string, std::unordered_map<std::string, SConfigValue>> deviceConfigs; // stores device configs
|
||||||
|
|
||||||
std::unordered_map<std::string, SAnimationPropertyConfig> animationConfig; // stores all the animations with their set values
|
std::unordered_map<std::string, SAnimationPropertyConfig> animationConfig; // stores all the animations with their set values
|
||||||
|
|
||||||
std::string currentCategory = ""; // For storing the category of the current item
|
std::string currentCategory = ""; // For storing the category of the current item
|
||||||
|
|
||||||
std::string parseError = ""; // For storing a parse error to display later
|
std::string parseError = ""; // For storing a parse error to display later
|
||||||
|
|
||||||
std::string m_szCurrentSubmap = ""; // For storing the current keybind submap
|
std::string m_szCurrentSubmap = ""; // For storing the current keybind submap
|
||||||
|
|
||||||
std::vector<std::pair<std::string, std::string>> boundWorkspaces;
|
std::vector<std::pair<std::string, std::string>> boundWorkspaces;
|
||||||
|
|
||||||
std::vector<SExecRequestedRule> execRequestedRules; // rules requested with exec, e.g. [workspace 2] kitty
|
std::vector<SExecRequestedRule> execRequestedRules; // rules requested with exec, e.g. [workspace 2] kitty
|
||||||
|
|
||||||
bool isFirstLaunch = true; // For exec-once
|
bool isFirstLaunch = true; // For exec-once
|
||||||
|
|
||||||
std::deque<SMonitorRule> m_dMonitorRules;
|
std::deque<SMonitorRule> m_dMonitorRules;
|
||||||
std::deque<SWindowRule> m_dWindowRules;
|
std::deque<SWindowRule> m_dWindowRules;
|
||||||
std::deque<std::string> m_dBlurLSNamespaces;
|
std::deque<std::string> m_dBlurLSNamespaces;
|
||||||
|
|
||||||
bool firstExecDispatched = false;
|
bool firstExecDispatched = false;
|
||||||
std::deque<std::string> firstExecRequests;
|
std::deque<std::string> firstExecRequests;
|
||||||
|
|
||||||
// internal methods
|
// internal methods
|
||||||
void setDefaultVars();
|
void setDefaultVars();
|
||||||
void setDefaultAnimationVars();
|
void setDefaultAnimationVars();
|
||||||
void setDeviceDefaultVars(const std::string&);
|
void setDeviceDefaultVars(const std::string&);
|
||||||
|
|
||||||
void setAnimForChildren(SAnimationPropertyConfig *const);
|
void setAnimForChildren(SAnimationPropertyConfig* const);
|
||||||
|
|
||||||
void applyUserDefinedVars(std::string&, const size_t);
|
void applyUserDefinedVars(std::string&, const size_t);
|
||||||
void loadConfigLoadVars();
|
void loadConfigLoadVars();
|
||||||
SConfigValue getConfigValueSafe(const std::string&);
|
SConfigValue getConfigValueSafe(const std::string&);
|
||||||
SConfigValue getConfigValueSafeDevice(const std::string&, const std::string&);
|
SConfigValue getConfigValueSafeDevice(const std::string&, const std::string&);
|
||||||
void parseLine(std::string&);
|
void parseLine(std::string&);
|
||||||
void configSetValueSafe(const std::string&, const std::string&);
|
void configSetValueSafe(const std::string&, const std::string&);
|
||||||
void handleDeviceConfig(const std::string&, const std::string&);
|
void handleDeviceConfig(const std::string&, const std::string&);
|
||||||
void handleRawExec(const std::string&, const std::string&);
|
void handleRawExec(const std::string&, const std::string&);
|
||||||
void handleMonitor(const std::string&, const std::string&);
|
void handleMonitor(const std::string&, const std::string&);
|
||||||
void handleBind(const std::string&, const std::string&);
|
void handleBind(const std::string&, const std::string&);
|
||||||
void handleUnbind(const std::string&, const std::string&);
|
void handleUnbind(const std::string&, const std::string&);
|
||||||
void handleWindowRule(const std::string&, const std::string&);
|
void handleWindowRule(const std::string&, const std::string&);
|
||||||
void handleWindowRuleV2(const std::string&, const std::string&);
|
void handleWindowRuleV2(const std::string&, const std::string&);
|
||||||
void handleDefaultWorkspace(const std::string&, const std::string&);
|
void handleDefaultWorkspace(const std::string&, const std::string&);
|
||||||
void handleBezier(const std::string&, const std::string&);
|
void handleBezier(const std::string&, const std::string&);
|
||||||
void handleAnimation(const std::string&, const std::string&);
|
void handleAnimation(const std::string&, const std::string&);
|
||||||
void handleSource(const std::string&, const std::string&);
|
void handleSource(const std::string&, const std::string&);
|
||||||
void handleSubmap(const std::string&, const std::string&);
|
void handleSubmap(const std::string&, const std::string&);
|
||||||
void handleBlurLS(const std::string&, const std::string&);
|
void handleBlurLS(const std::string&, const std::string&);
|
||||||
void handleBindWS(const std::string&, const std::string&);
|
void handleBindWS(const std::string&, const std::string&);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CConfigManager> g_pConfigManager;
|
inline std::unique_ptr<CConfigManager> g_pConfigManager;
|
||||||
|
|
|
@ -20,7 +20,7 @@ std::string monitorsRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
|
|
||||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||||
result += getFormat(
|
result += getFormat(
|
||||||
R"#({
|
R"#({
|
||||||
"id": %i,
|
"id": %i,
|
||||||
"name": "%s",
|
"name": "%s",
|
||||||
"description": "%s",
|
"description": "%s",
|
||||||
|
@ -39,19 +39,11 @@ R"#({
|
||||||
"focused": %s,
|
"focused": %s,
|
||||||
"dpmsStatus": %s
|
"dpmsStatus": %s
|
||||||
},)#",
|
},)#",
|
||||||
m->ID,
|
m->ID, escapeJSONStrings(m->szName).c_str(), escapeJSONStrings(m->output->description ? m->output->description : "").c_str(), (int)m->vecPixelSize.x,
|
||||||
escapeJSONStrings(m->szName).c_str(),
|
(int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y, m->activeWorkspace,
|
||||||
escapeJSONStrings(m->output->description ? m->output->description : "").c_str(),
|
escapeJSONStrings(g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName).c_str(), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y,
|
||||||
(int)m->vecPixelSize.x, (int)m->vecPixelSize.y,
|
(int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (m.get() == g_pCompositor->m_pLastMonitor ? "true" : "false"),
|
||||||
m->refreshRate,
|
(m->dpmsStatus ? "true" : "false"));
|
||||||
(int)m->vecPosition.x, (int)m->vecPosition.y,
|
|
||||||
m->activeWorkspace, escapeJSONStrings(g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName).c_str(),
|
|
||||||
(int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y,
|
|
||||||
m->scale,
|
|
||||||
(int)m->transform,
|
|
||||||
(m.get() == g_pCompositor->m_pLastMonitor ? "true" : "false"),
|
|
||||||
(m->dpmsStatus ? "true" : "false")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove trailing comma
|
// remove trailing comma
|
||||||
|
@ -60,8 +52,12 @@ R"#({
|
||||||
result += "]";
|
result += "]";
|
||||||
} else {
|
} else {
|
||||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||||
result += getFormat("Monitor %s (ID %i):\n\t%ix%i@%f at %ix%i\n\tdescription: %s\n\tactive workspace: %i (%s)\n\treserved: %i %i %i %i\n\tscale: %.2f\n\ttransform: %i\n\tfocused: %s\n\tdpmsStatus: %i\n\n",
|
result += getFormat("Monitor %s (ID %i):\n\t%ix%i@%f at %ix%i\n\tdescription: %s\n\tactive workspace: %i (%s)\n\treserved: %i %i %i %i\n\tscale: %.2f\n\ttransform: "
|
||||||
m->szName.c_str(), m->ID, (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y, (m->output->description ? m->output->description : ""), m->activeWorkspace, g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName.c_str(), (int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale, (int)m->transform, (m.get() == g_pCompositor->m_pLastMonitor ? "yes" : "no"), (int)m->dpmsStatus);
|
"%i\n\tfocused: %s\n\tdpmsStatus: %i\n\n",
|
||||||
|
m->szName.c_str(), m->ID, (int)m->vecPixelSize.x, (int)m->vecPixelSize.y, m->refreshRate, (int)m->vecPosition.x, (int)m->vecPosition.y,
|
||||||
|
(m->output->description ? m->output->description : ""), m->activeWorkspace, g_pCompositor->getWorkspaceByID(m->activeWorkspace)->m_szName.c_str(),
|
||||||
|
(int)m->vecReservedTopLeft.x, (int)m->vecReservedTopLeft.y, (int)m->vecReservedBottomRight.x, (int)m->vecReservedBottomRight.y, m->scale,
|
||||||
|
(int)m->transform, (m.get() == g_pCompositor->m_pLastMonitor ? "yes" : "no"), (int)m->dpmsStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,16 +70,16 @@ static std::string getGroupedData(CWindow* w, HyprCtl::eHyprCtlOutputFormat form
|
||||||
return isJson ? "" : "0";
|
return isJson ? "" : "0";
|
||||||
|
|
||||||
SLayoutMessageHeader header;
|
SLayoutMessageHeader header;
|
||||||
header.pWindow = w;
|
header.pWindow = w;
|
||||||
const auto groupMembers = std::any_cast<std::deque<CWindow*>>(g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "groupinfo"));
|
const auto groupMembers = std::any_cast<std::deque<CWindow*>>(g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "groupinfo"));
|
||||||
if (groupMembers.empty())
|
if (groupMembers.empty())
|
||||||
return isJson ? "" : "0";
|
return isJson ? "" : "0";
|
||||||
|
|
||||||
const auto comma = isJson ? ", " : ",";
|
const auto comma = isJson ? ", " : ",";
|
||||||
const auto fmt = isJson ? "\"0x%x\"" : "%x";
|
const auto fmt = isJson ? "\"0x%x\"" : "%x";
|
||||||
std::ostringstream result;
|
std::ostringstream result;
|
||||||
|
|
||||||
bool first = true;
|
bool first = true;
|
||||||
for (auto& gw : groupMembers) {
|
for (auto& gw : groupMembers) {
|
||||||
if (first)
|
if (first)
|
||||||
first = false;
|
first = false;
|
||||||
|
@ -99,7 +95,7 @@ static std::string getGroupedData(CWindow* w, HyprCtl::eHyprCtlOutputFormat form
|
||||||
static std::string getWindowData(CWindow* w, HyprCtl::eHyprCtlOutputFormat format) {
|
static std::string getWindowData(CWindow* w, HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
if (format == HyprCtl::FORMAT_JSON) {
|
if (format == HyprCtl::FORMAT_JSON) {
|
||||||
return getFormat(
|
return getFormat(
|
||||||
R"#({
|
R"#({
|
||||||
"address": "0x%x",
|
"address": "0x%x",
|
||||||
"at": [%i, %i],
|
"at": [%i, %i],
|
||||||
"size": [%i, %i],
|
"size": [%i, %i],
|
||||||
|
@ -119,25 +115,29 @@ R"#({
|
||||||
"grouped": [%s],
|
"grouped": [%s],
|
||||||
"swallowing": %s
|
"swallowing": %s
|
||||||
},)#",
|
},)#",
|
||||||
w,
|
w, (int)w->m_vRealPosition.goalv().x, (int)w->m_vRealPosition.goalv().y, (int)w->m_vRealSize.goalv().x, (int)w->m_vRealSize.goalv().y, w->m_iWorkspaceID,
|
||||||
(int)w->m_vRealPosition.goalv().x, (int)w->m_vRealPosition.goalv().y,
|
escapeJSONStrings(w->m_iWorkspaceID == -1 ? "" :
|
||||||
(int)w->m_vRealSize.goalv().x, (int)w->m_vRealSize.goalv().y,
|
g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName :
|
||||||
w->m_iWorkspaceID, escapeJSONStrings(w->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName : std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID))).c_str(),
|
std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID)))
|
||||||
((int)w->m_bIsFloating == 1 ? "true" : "false"),
|
.c_str(),
|
||||||
w->m_iMonitorID,
|
((int)w->m_bIsFloating == 1 ? "true" : "false"), w->m_iMonitorID, escapeJSONStrings(g_pXWaylandManager->getAppIDClass(w)).c_str(),
|
||||||
escapeJSONStrings(g_pXWaylandManager->getAppIDClass(w)).c_str(),
|
escapeJSONStrings(g_pXWaylandManager->getTitle(w)).c_str(), w->getPID(), ((int)w->m_bIsX11 == 1 ? "true" : "false"), (w->m_bPinned ? "true" : "false"),
|
||||||
escapeJSONStrings(g_pXWaylandManager->getTitle(w)).c_str(),
|
(w->m_bIsFullscreen ? "true" : "false"),
|
||||||
w->getPID(),
|
(w->m_bIsFullscreen ? (g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_efFullscreenMode : 0) : 0),
|
||||||
((int)w->m_bIsX11 == 1 ? "true" : "false"),
|
getGroupedData(w, format).c_str(), (w->m_pSwallowed ? getFormat("\"0x%x\"", w->m_pSwallowed).c_str() : "null"));
|
||||||
(w->m_bPinned ? "true" : "false"),
|
|
||||||
(w->m_bIsFullscreen ? "true" : "false"),
|
|
||||||
(w->m_bIsFullscreen ? (g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_efFullscreenMode : 0) : 0),
|
|
||||||
getGroupedData(w, format).c_str(),
|
|
||||||
(w->m_pSwallowed ? getFormat("\"0x%x\"", w->m_pSwallowed).c_str() : "null")
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
return getFormat("Window %x -> %s:\n\tat: %i,%i\n\tsize: %i,%i\n\tworkspace: %i (%s)\n\tfloating: %i\n\tmonitor: %i\n\tclass: %s\n\ttitle: %s\n\tpid: %i\n\txwayland: %i\n\tpinned: %i\n\tfullscreen: %i\n\tfullscreenmode: %i\n\tgrouped: %s\n\tswallowing: %x\n\n",
|
return getFormat(
|
||||||
w, w->m_szTitle.c_str(), (int)w->m_vRealPosition.goalv().x, (int)w->m_vRealPosition.goalv().y, (int)w->m_vRealSize.goalv().x, (int)w->m_vRealSize.goalv().y, w->m_iWorkspaceID, (w->m_iWorkspaceID == -1 ? "" : g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName.c_str() : std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID)).c_str()), (int)w->m_bIsFloating, w->m_iMonitorID, g_pXWaylandManager->getAppIDClass(w).c_str(), g_pXWaylandManager->getTitle(w).c_str(), w->getPID(), (int)w->m_bIsX11, (int)w->m_bPinned, (int)w->m_bIsFullscreen, (w->m_bIsFullscreen ? (g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_efFullscreenMode : 0) : 0), getGroupedData(w, format).c_str(), w->m_pSwallowed);
|
"Window %x -> %s:\n\tat: %i,%i\n\tsize: %i,%i\n\tworkspace: %i (%s)\n\tfloating: %i\n\tmonitor: %i\n\tclass: %s\n\ttitle: %s\n\tpid: %i\n\txwayland: %i\n\tpinned: "
|
||||||
|
"%i\n\tfullscreen: %i\n\tfullscreenmode: %i\n\tgrouped: %s\n\tswallowing: %x\n\n",
|
||||||
|
w, w->m_szTitle.c_str(), (int)w->m_vRealPosition.goalv().x, (int)w->m_vRealPosition.goalv().y, (int)w->m_vRealSize.goalv().x, (int)w->m_vRealSize.goalv().y,
|
||||||
|
w->m_iWorkspaceID,
|
||||||
|
(w->m_iWorkspaceID == -1 ? "" :
|
||||||
|
g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_szName.c_str() :
|
||||||
|
std::string("Invalid workspace " + std::to_string(w->m_iWorkspaceID)).c_str()),
|
||||||
|
(int)w->m_bIsFloating, w->m_iMonitorID, g_pXWaylandManager->getAppIDClass(w).c_str(), g_pXWaylandManager->getTitle(w).c_str(), w->getPID(), (int)w->m_bIsX11,
|
||||||
|
(int)w->m_bPinned, (int)w->m_bIsFullscreen,
|
||||||
|
(w->m_bIsFullscreen ? (g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID) ? g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID)->m_efFullscreenMode : 0) : 0),
|
||||||
|
getGroupedData(w, format).c_str(), w->m_pSwallowed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ std::string clientsRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
|
|
||||||
// remove trailing comma
|
// remove trailing comma
|
||||||
if (result != "[")
|
if (result != "[")
|
||||||
result.pop_back();
|
result.pop_back();
|
||||||
|
|
||||||
result += "]";
|
result += "]";
|
||||||
} else {
|
} else {
|
||||||
|
@ -176,7 +176,7 @@ std::string workspacesRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
const auto PLASTW = w->getLastFocusedWindow();
|
const auto PLASTW = w->getLastFocusedWindow();
|
||||||
|
|
||||||
result += getFormat(
|
result += getFormat(
|
||||||
R"#({
|
R"#({
|
||||||
"id": %i,
|
"id": %i,
|
||||||
"name": "%s",
|
"name": "%s",
|
||||||
"monitor": "%s",
|
"monitor": "%s",
|
||||||
|
@ -185,14 +185,9 @@ R"#({
|
||||||
"lastwindow": "0x%x",
|
"lastwindow": "0x%x",
|
||||||
"lastwindowtitle": "%s"
|
"lastwindowtitle": "%s"
|
||||||
},)#",
|
},)#",
|
||||||
w->m_iID,
|
w->m_iID, escapeJSONStrings(w->m_szName).c_str(), escapeJSONStrings(g_pCompositor->getMonitorFromID(w->m_iMonitorID)->szName).c_str(),
|
||||||
escapeJSONStrings(w->m_szName).c_str(),
|
g_pCompositor->getWindowsOnWorkspace(w->m_iID), ((int)w->m_bHasFullscreenWindow == 1 ? "true" : "false"), PLASTW,
|
||||||
escapeJSONStrings(g_pCompositor->getMonitorFromID(w->m_iMonitorID)->szName).c_str(),
|
PLASTW ? escapeJSONStrings(PLASTW->m_szTitle).c_str() : "");
|
||||||
g_pCompositor->getWindowsOnWorkspace(w->m_iID),
|
|
||||||
((int)w->m_bHasFullscreenWindow == 1 ? "true" : "false"),
|
|
||||||
PLASTW,
|
|
||||||
PLASTW ? escapeJSONStrings(PLASTW->m_szTitle).c_str() : ""
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove trailing comma
|
// remove trailing comma
|
||||||
|
@ -202,8 +197,9 @@ R"#({
|
||||||
} else {
|
} else {
|
||||||
for (auto& w : g_pCompositor->m_vWorkspaces) {
|
for (auto& w : g_pCompositor->m_vWorkspaces) {
|
||||||
const auto PLASTW = w->getLastFocusedWindow();
|
const auto PLASTW = w->getLastFocusedWindow();
|
||||||
result += getFormat("workspace ID %i (%s) on monitor %s:\n\twindows: %i\n\thasfullscreen: %i\n\tlastwindow: 0x%x\n\tlastwindowtitle: %s\n\n",
|
result += getFormat("workspace ID %i (%s) on monitor %s:\n\twindows: %i\n\thasfullscreen: %i\n\tlastwindow: 0x%x\n\tlastwindowtitle: %s\n\n", w->m_iID,
|
||||||
w->m_iID, w->m_szName.c_str(), g_pCompositor->getMonitorFromID(w->m_iMonitorID)->szName.c_str(), g_pCompositor->getWindowsOnWorkspace(w->m_iID), (int)w->m_bHasFullscreenWindow, PLASTW, PLASTW ? PLASTW->m_szTitle.c_str() : "");
|
w->m_szName.c_str(), g_pCompositor->getMonitorFromID(w->m_iMonitorID)->szName.c_str(), g_pCompositor->getWindowsOnWorkspace(w->m_iID),
|
||||||
|
(int)w->m_bHasFullscreenWindow, PLASTW, PLASTW ? PLASTW->m_szTitle.c_str() : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -216,7 +212,7 @@ std::string activeWindowRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
return format == HyprCtl::FORMAT_JSON ? "{}" : "Invalid";
|
return format == HyprCtl::FORMAT_JSON ? "{}" : "Invalid";
|
||||||
|
|
||||||
auto result = getWindowData(PWINDOW, format);
|
auto result = getWindowData(PWINDOW, format);
|
||||||
|
|
||||||
if (format == HyprCtl::FORMAT_JSON)
|
if (format == HyprCtl::FORMAT_JSON)
|
||||||
result.pop_back();
|
result.pop_back();
|
||||||
|
|
||||||
|
@ -231,23 +227,21 @@ std::string layersRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
|
|
||||||
for (auto& mon : g_pCompositor->m_vMonitors) {
|
for (auto& mon : g_pCompositor->m_vMonitors) {
|
||||||
result += getFormat(
|
result += getFormat(
|
||||||
R"#("%s": {
|
R"#("%s": {
|
||||||
"levels": {
|
"levels": {
|
||||||
)#",
|
)#",
|
||||||
escapeJSONStrings(mon->szName).c_str()
|
escapeJSONStrings(mon->szName).c_str());
|
||||||
);
|
|
||||||
|
|
||||||
int layerLevel = 0;
|
int layerLevel = 0;
|
||||||
for (auto& level : mon->m_aLayerSurfaceLists) {
|
for (auto& level : mon->m_aLayerSurfaceLists) {
|
||||||
result += getFormat(
|
result += getFormat(
|
||||||
R"#(
|
R"#(
|
||||||
"%i": [
|
"%i": [
|
||||||
)#",
|
)#",
|
||||||
layerLevel
|
layerLevel);
|
||||||
);
|
|
||||||
for (auto& layer : level) {
|
for (auto& layer : level) {
|
||||||
result += getFormat(
|
result += getFormat(
|
||||||
R"#( {
|
R"#( {
|
||||||
"address": "0x%x",
|
"address": "0x%x",
|
||||||
"x": %i,
|
"x": %i,
|
||||||
"y": %i,
|
"y": %i,
|
||||||
|
@ -255,13 +249,7 @@ R"#( {
|
||||||
"h": %i,
|
"h": %i,
|
||||||
"namespace": "%s"
|
"namespace": "%s"
|
||||||
},)#",
|
},)#",
|
||||||
layer.get(),
|
layer.get(), layer->geometry.x, layer->geometry.y, layer->geometry.width, layer->geometry.height, escapeJSONStrings(layer->szNamespace).c_str());
|
||||||
layer->geometry.x,
|
|
||||||
layer->geometry.y,
|
|
||||||
layer->geometry.width,
|
|
||||||
layer->geometry.height,
|
|
||||||
escapeJSONStrings(layer->szNamespace).c_str()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove trailing comma
|
// remove trailing comma
|
||||||
|
@ -294,7 +282,8 @@ R"#( {
|
||||||
result += getFormat("\tLayer level %i:\n", layerLevel);
|
result += getFormat("\tLayer level %i:\n", layerLevel);
|
||||||
|
|
||||||
for (auto& layer : level) {
|
for (auto& layer : level) {
|
||||||
result += getFormat("\t\tLayer %x: xywh: %i %i %i %i, namespace: %s\n", layer.get(), layer->geometry.x, layer->geometry.y, layer->geometry.width, layer->geometry.height, layer->szNamespace.c_str());
|
result += getFormat("\t\tLayer %x: xywh: %i %i %i %i, namespace: %s\n", layer.get(), layer->geometry.x, layer->geometry.y, layer->geometry.width,
|
||||||
|
layer->geometry.height, layer->szNamespace.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
layerLevel++;
|
layerLevel++;
|
||||||
|
@ -315,15 +304,13 @@ std::string devicesRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
|
|
||||||
for (auto& m : g_pInputManager->m_lMice) {
|
for (auto& m : g_pInputManager->m_lMice) {
|
||||||
result += getFormat(
|
result += getFormat(
|
||||||
R"#( {
|
R"#( {
|
||||||
"address": "0x%x",
|
"address": "0x%x",
|
||||||
"name": "%s",
|
"name": "%s",
|
||||||
"defaultSpeed": %f
|
"defaultSpeed": %f
|
||||||
},)#",
|
},)#",
|
||||||
&m,
|
&m, escapeJSONStrings(m.name).c_str(),
|
||||||
escapeJSONStrings(m.name).c_str(),
|
wlr_input_device_is_libinput(m.mouse) ? libinput_device_config_accel_get_default_speed((libinput_device*)wlr_libinput_get_device_handle(m.mouse)) : 0.f);
|
||||||
wlr_input_device_is_libinput(m.mouse) ? libinput_device_config_accel_get_default_speed((libinput_device*)wlr_libinput_get_device_handle(m.mouse)) : 0.f
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove trailing comma
|
// remove trailing comma
|
||||||
|
@ -334,7 +321,7 @@ R"#( {
|
||||||
for (auto& k : g_pInputManager->m_lKeyboards) {
|
for (auto& k : g_pInputManager->m_lKeyboards) {
|
||||||
const auto KM = g_pInputManager->getActiveLayoutForKeyboard(&k);
|
const auto KM = g_pInputManager->getActiveLayoutForKeyboard(&k);
|
||||||
result += getFormat(
|
result += getFormat(
|
||||||
R"#( {
|
R"#( {
|
||||||
"address": "0x%x",
|
"address": "0x%x",
|
||||||
"name": "%s",
|
"name": "%s",
|
||||||
"rules": "%s",
|
"rules": "%s",
|
||||||
|
@ -345,16 +332,9 @@ R"#( {
|
||||||
"active_keymap": "%s",
|
"active_keymap": "%s",
|
||||||
"main": %s
|
"main": %s
|
||||||
},)#",
|
},)#",
|
||||||
&k,
|
&k, escapeJSONStrings(k.name).c_str(), escapeJSONStrings(k.currentRules.rules).c_str(), escapeJSONStrings(k.currentRules.model).c_str(),
|
||||||
escapeJSONStrings(k.name).c_str(),
|
escapeJSONStrings(k.currentRules.layout).c_str(), escapeJSONStrings(k.currentRules.variant).c_str(), escapeJSONStrings(k.currentRules.options).c_str(),
|
||||||
escapeJSONStrings(k.currentRules.rules).c_str(),
|
escapeJSONStrings(KM).c_str(), (k.active ? "true" : "false"));
|
||||||
escapeJSONStrings(k.currentRules.model).c_str(),
|
|
||||||
escapeJSONStrings(k.currentRules.layout).c_str(),
|
|
||||||
escapeJSONStrings(k.currentRules.variant).c_str(),
|
|
||||||
escapeJSONStrings(k.currentRules.options).c_str(),
|
|
||||||
escapeJSONStrings(KM).c_str(),
|
|
||||||
(k.active ? "true" : "false")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove trailing comma
|
// remove trailing comma
|
||||||
|
@ -365,7 +345,7 @@ R"#( {
|
||||||
|
|
||||||
for (auto& d : g_pInputManager->m_lTabletPads) {
|
for (auto& d : g_pInputManager->m_lTabletPads) {
|
||||||
result += getFormat(
|
result += getFormat(
|
||||||
R"#( {
|
R"#( {
|
||||||
"address": "0x%x",
|
"address": "0x%x",
|
||||||
"type": "tabletPad",
|
"type": "tabletPad",
|
||||||
"belongsTo": {
|
"belongsTo": {
|
||||||
|
@ -373,33 +353,26 @@ R"#( {
|
||||||
"name": "%s"
|
"name": "%s"
|
||||||
}
|
}
|
||||||
},)#",
|
},)#",
|
||||||
&d,
|
&d, d.pTabletParent, escapeJSONStrings(d.pTabletParent ? d.pTabletParent->name : "").c_str());
|
||||||
d.pTabletParent,
|
|
||||||
escapeJSONStrings(d.pTabletParent ? d.pTabletParent->name : "").c_str()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& d : g_pInputManager->m_lTablets) {
|
for (auto& d : g_pInputManager->m_lTablets) {
|
||||||
result += getFormat(
|
result += getFormat(
|
||||||
R"#( {
|
R"#( {
|
||||||
"address": "0x%x",
|
"address": "0x%x",
|
||||||
"name": "%s"
|
"name": "%s"
|
||||||
},)#",
|
},)#",
|
||||||
&d,
|
&d, escapeJSONStrings(d.name).c_str());
|
||||||
escapeJSONStrings(d.name).c_str()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& d : g_pInputManager->m_lTabletTools) {
|
for (auto& d : g_pInputManager->m_lTabletTools) {
|
||||||
result += getFormat(
|
result += getFormat(
|
||||||
R"#( {
|
R"#( {
|
||||||
"address": "0x%x",
|
"address": "0x%x",
|
||||||
"type": "tabletTool",
|
"type": "tabletTool",
|
||||||
"belongsTo": "0x%x"
|
"belongsTo": "0x%x"
|
||||||
},)#",
|
},)#",
|
||||||
&d,
|
&d, d.wlrTabletTool ? d.wlrTabletTool->data : 0);
|
||||||
d.wlrTabletTool ? d.wlrTabletTool->data : 0
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove trailing comma
|
// remove trailing comma
|
||||||
|
@ -410,13 +383,11 @@ R"#( {
|
||||||
|
|
||||||
for (auto& d : g_pInputManager->m_lTouchDevices) {
|
for (auto& d : g_pInputManager->m_lTouchDevices) {
|
||||||
result += getFormat(
|
result += getFormat(
|
||||||
R"#( {
|
R"#( {
|
||||||
"address": "0x%x",
|
"address": "0x%x",
|
||||||
"name": "%s"
|
"name": "%s"
|
||||||
},)#",
|
},)#",
|
||||||
&d,
|
&d, d.name.c_str());
|
||||||
d.name.c_str()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove trailing comma
|
// remove trailing comma
|
||||||
|
@ -428,13 +399,11 @@ R"#( {
|
||||||
|
|
||||||
for (auto& d : g_pInputManager->m_lSwitches) {
|
for (auto& d : g_pInputManager->m_lSwitches) {
|
||||||
result += getFormat(
|
result += getFormat(
|
||||||
R"#( {
|
R"#( {
|
||||||
"address": "0x%x",
|
"address": "0x%x",
|
||||||
"name": "%s"
|
"name": "%s"
|
||||||
},)#",
|
},)#",
|
||||||
&d,
|
&d, d.pWlrDevice ? d.pWlrDevice->name : "");
|
||||||
d.pWlrDevice ? d.pWlrDevice->name : ""
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove trailing comma
|
// remove trailing comma
|
||||||
|
@ -448,14 +417,18 @@ R"#( {
|
||||||
result += "mice:\n";
|
result += "mice:\n";
|
||||||
|
|
||||||
for (auto& m : g_pInputManager->m_lMice) {
|
for (auto& m : g_pInputManager->m_lMice) {
|
||||||
result += getFormat("\tMouse at %x:\n\t\t%s\n\t\t\tdefault speed: %f\n", &m, m.name.c_str(), (wlr_input_device_is_libinput(m.mouse) ? libinput_device_config_accel_get_default_speed((libinput_device*)wlr_libinput_get_device_handle(m.mouse)) : 0.f));
|
result += getFormat(
|
||||||
|
"\tMouse at %x:\n\t\t%s\n\t\t\tdefault speed: %f\n", &m, m.name.c_str(),
|
||||||
|
(wlr_input_device_is_libinput(m.mouse) ? libinput_device_config_accel_get_default_speed((libinput_device*)wlr_libinput_get_device_handle(m.mouse)) : 0.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
result += "\n\nKeyboards:\n";
|
result += "\n\nKeyboards:\n";
|
||||||
|
|
||||||
for (auto& k : g_pInputManager->m_lKeyboards) {
|
for (auto& k : g_pInputManager->m_lKeyboards) {
|
||||||
const auto KM = g_pInputManager->getActiveLayoutForKeyboard(&k);
|
const auto KM = g_pInputManager->getActiveLayoutForKeyboard(&k);
|
||||||
result += getFormat("\tKeyboard at %x:\n\t\t%s\n\t\t\trules: r \"%s\", m \"%s\", l \"%s\", v \"%s\", o \"%s\"\n\t\t\tactive keymap: %s\n\t\t\tmain: %s\n", &k, k.name.c_str(), k.currentRules.rules.c_str(), k.currentRules.model.c_str(), k.currentRules.layout.c_str(), k.currentRules.variant.c_str(), k.currentRules.options.c_str(), KM.c_str(), (k.active ? "yes" : "no"));
|
result += getFormat("\tKeyboard at %x:\n\t\t%s\n\t\t\trules: r \"%s\", m \"%s\", l \"%s\", v \"%s\", o \"%s\"\n\t\t\tactive keymap: %s\n\t\t\tmain: %s\n", &k,
|
||||||
|
k.name.c_str(), k.currentRules.rules.c_str(), k.currentRules.model.c_str(), k.currentRules.layout.c_str(), k.currentRules.variant.c_str(),
|
||||||
|
k.currentRules.options.c_str(), KM.c_str(), (k.active ? "yes" : "no"));
|
||||||
}
|
}
|
||||||
|
|
||||||
result += "\n\nTablets:\n";
|
result += "\n\nTablets:\n";
|
||||||
|
@ -491,7 +464,8 @@ R"#( {
|
||||||
std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
|
|
||||||
if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) {
|
if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL) {
|
||||||
std::string result = "Hyprland, built from branch " + std::string(GIT_BRANCH) + " at commit " + GIT_COMMIT_HASH + GIT_DIRTY + " (" + removeBeginEndSpacesTabs(GIT_COMMIT_MESSAGE).c_str() + ").\nflags: (if any)\n";
|
std::string result = "Hyprland, built from branch " + std::string(GIT_BRANCH) + " at commit " + GIT_COMMIT_HASH + GIT_DIRTY + " (" +
|
||||||
|
removeBeginEndSpacesTabs(GIT_COMMIT_MESSAGE).c_str() + ").\nflags: (if any)\n";
|
||||||
|
|
||||||
#ifdef LEGACY_RENDERER
|
#ifdef LEGACY_RENDERER
|
||||||
result += "legacyrenderer\n";
|
result += "legacyrenderer\n";
|
||||||
|
@ -500,7 +474,7 @@ std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
result += "debug\n";
|
result += "debug\n";
|
||||||
#endif
|
#endif
|
||||||
#ifdef HYPRLAND_DEBUG
|
#ifdef HYPRLAND_DEBUG
|
||||||
result += "debug\n";
|
result += "debug\n";
|
||||||
#endif
|
#endif
|
||||||
#ifdef NO_XWAYLAND
|
#ifdef NO_XWAYLAND
|
||||||
result += "no xwayland\n";
|
result += "no xwayland\n";
|
||||||
|
@ -509,12 +483,13 @@ std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
std::string result = getFormat(
|
std::string result = getFormat(
|
||||||
R"#({
|
R"#({
|
||||||
"branch": "%s",
|
"branch": "%s",
|
||||||
"commit": "%s",
|
"commit": "%s",
|
||||||
"dirty": %s,
|
"dirty": %s,
|
||||||
"commit_message": "%s",
|
"commit_message": "%s",
|
||||||
"flags": [)#", GIT_BRANCH, GIT_COMMIT_HASH, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), removeBeginEndSpacesTabs(GIT_COMMIT_MESSAGE).c_str());
|
"flags": [)#",
|
||||||
|
GIT_BRANCH, GIT_COMMIT_HASH, (strcmp(GIT_DIRTY, "dirty") == 0 ? "true" : "false"), removeBeginEndSpacesTabs(GIT_COMMIT_MESSAGE).c_str());
|
||||||
|
|
||||||
#ifdef LEGACY_RENDERER
|
#ifdef LEGACY_RENDERER
|
||||||
result += "\"legacyrenderer\",";
|
result += "\"legacyrenderer\",";
|
||||||
|
@ -523,7 +498,7 @@ R"#({
|
||||||
result += "\"debug\",";
|
result += "\"debug\",";
|
||||||
#endif
|
#endif
|
||||||
#ifdef HYPRLAND_DEBUG
|
#ifdef HYPRLAND_DEBUG
|
||||||
result += "\"debug\",";
|
result += "\"debug\",";
|
||||||
#endif
|
#endif
|
||||||
#ifdef NO_XWAYLAND
|
#ifdef NO_XWAYLAND
|
||||||
result += "\"no xwayland\",";
|
result += "\"no xwayland\",";
|
||||||
|
@ -563,9 +538,9 @@ std::string dispatchKeyword(std::string in) {
|
||||||
// get rid of the keyword keyword
|
// get rid of the keyword keyword
|
||||||
in = in.substr(in.find_first_of(' ') + 1);
|
in = in.substr(in.find_first_of(' ') + 1);
|
||||||
|
|
||||||
const auto COMMAND = in.substr(0, in.find_first_of(' '));
|
const auto COMMAND = in.substr(0, in.find_first_of(' '));
|
||||||
|
|
||||||
const auto VALUE = in.substr(in.find_first_of(' ') + 1);
|
const auto VALUE = in.substr(in.find_first_of(' ') + 1);
|
||||||
|
|
||||||
std::string retval = g_pConfigManager->parseKeyword(COMMAND, VALUE, true);
|
std::string retval = g_pConfigManager->parseKeyword(COMMAND, VALUE, true);
|
||||||
|
|
||||||
|
@ -573,14 +548,14 @@ std::string dispatchKeyword(std::string in) {
|
||||||
g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords
|
g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords
|
||||||
|
|
||||||
if (COMMAND.contains("input") || COMMAND.contains("device:")) {
|
if (COMMAND.contains("input") || COMMAND.contains("device:")) {
|
||||||
g_pInputManager->setKeyboardLayout(); // update kb layout
|
g_pInputManager->setKeyboardLayout(); // update kb layout
|
||||||
g_pInputManager->setPointerConfigs(); // update mouse cfgs
|
g_pInputManager->setPointerConfigs(); // update mouse cfgs
|
||||||
g_pInputManager->setTouchDeviceConfigs(); // update touch device cfgs
|
g_pInputManager->setTouchDeviceConfigs(); // update touch device cfgs
|
||||||
}
|
}
|
||||||
|
|
||||||
if (COMMAND.contains("general:layout"))
|
if (COMMAND.contains("general:layout"))
|
||||||
g_pLayoutManager->switchToLayout(g_pConfigManager->getString("general:layout")); // update layout
|
g_pLayoutManager->switchToLayout(g_pConfigManager->getString("general:layout")); // update layout
|
||||||
|
|
||||||
if (COMMAND.contains("decoration:screen_shader"))
|
if (COMMAND.contains("decoration:screen_shader"))
|
||||||
g_pHyprOpenGL->m_bReloadScreenShader = true;
|
g_pHyprOpenGL->m_bReloadScreenShader = true;
|
||||||
|
|
||||||
|
@ -592,7 +567,7 @@ std::string dispatchKeyword(std::string in) {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string reloadRequest(std::string request) {
|
std::string reloadRequest(const std::string& request) {
|
||||||
|
|
||||||
const auto REQMODE = request.substr(request.find_last_of(' ') + 1);
|
const auto REQMODE = request.substr(request.find_last_of(' ') + 1);
|
||||||
|
|
||||||
|
@ -628,7 +603,8 @@ std::string cursorPosRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
"x": %i,
|
"x": %i,
|
||||||
"y": %i
|
"y": %i
|
||||||
}
|
}
|
||||||
)#", (int)CURSORPOS.x, (int)CURSORPOS.y);
|
)#",
|
||||||
|
(int)CURSORPOS.x, (int)CURSORPOS.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "error";
|
return "error";
|
||||||
|
@ -639,11 +615,11 @@ std::string getReply(std::string);
|
||||||
std::string dispatchBatch(std::string request) {
|
std::string dispatchBatch(std::string request) {
|
||||||
// split by ;
|
// split by ;
|
||||||
|
|
||||||
request = request.substr(9);
|
request = request.substr(9);
|
||||||
std::string curitem = "";
|
std::string curitem = "";
|
||||||
std::string reply = "";
|
std::string reply = "";
|
||||||
|
|
||||||
auto nextItem = [&]() {
|
auto nextItem = [&]() {
|
||||||
auto idx = request.find_first_of(';');
|
auto idx = request.find_first_of(';');
|
||||||
|
|
||||||
if (idx != std::string::npos) {
|
if (idx != std::string::npos) {
|
||||||
|
@ -671,7 +647,7 @@ std::string dispatchBatch(std::string request) {
|
||||||
std::string dispatchSetCursor(std::string request) {
|
std::string dispatchSetCursor(std::string request) {
|
||||||
std::string curitem = "";
|
std::string curitem = "";
|
||||||
|
|
||||||
auto nextItem = [&]() {
|
auto nextItem = [&]() {
|
||||||
auto idx = request.find_first_of(' ');
|
auto idx = request.find_first_of(' ');
|
||||||
|
|
||||||
if (idx != std::string::npos) {
|
if (idx != std::string::npos) {
|
||||||
|
@ -718,20 +694,21 @@ std::string dispatchSetCursor(std::string request) {
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string switchXKBLayoutRequest(std::string request) {
|
std::string switchXKBLayoutRequest(const std::string& request) {
|
||||||
CVarList vars(request, 0, ' ');
|
CVarList vars(request, 0, ' ');
|
||||||
|
|
||||||
const auto KB = vars[1];
|
const auto KB = vars[1];
|
||||||
const auto CMD = vars[2];
|
const auto CMD = vars[2];
|
||||||
|
|
||||||
// get kb
|
// get kb
|
||||||
const auto PKEYBOARD = std::find_if(g_pInputManager->m_lKeyboards.begin(), g_pInputManager->m_lKeyboards.end(), [&] (const SKeyboard& other) { return other.name == g_pInputManager->deviceNameToInternalString(KB); });
|
const auto PKEYBOARD = std::find_if(g_pInputManager->m_lKeyboards.begin(), g_pInputManager->m_lKeyboards.end(),
|
||||||
|
[&](const SKeyboard& other) { return other.name == g_pInputManager->deviceNameToInternalString(KB); });
|
||||||
|
|
||||||
if (PKEYBOARD == g_pInputManager->m_lKeyboards.end())
|
if (PKEYBOARD == g_pInputManager->m_lKeyboards.end())
|
||||||
return "device not found";
|
return "device not found";
|
||||||
|
|
||||||
const auto PWLRKEYBOARD = wlr_keyboard_from_input_device(PKEYBOARD->keyboard);
|
const auto PWLRKEYBOARD = wlr_keyboard_from_input_device(PKEYBOARD->keyboard);
|
||||||
const auto LAYOUTS = xkb_keymap_num_layouts(PWLRKEYBOARD->keymap);
|
const auto LAYOUTS = xkb_keymap_num_layouts(PWLRKEYBOARD->keymap);
|
||||||
xkb_layout_index_t activeLayout = 0;
|
xkb_layout_index_t activeLayout = 0;
|
||||||
while (activeLayout < LAYOUTS) {
|
while (activeLayout < LAYOUTS) {
|
||||||
if (xkb_state_layout_index_is_active(PWLRKEYBOARD->xkb_state, activeLayout, XKB_STATE_LAYOUT_EFFECTIVE))
|
if (xkb_state_layout_index_is_active(PWLRKEYBOARD->xkb_state, activeLayout, XKB_STATE_LAYOUT_EFFECTIVE))
|
||||||
|
@ -741,23 +718,23 @@ std::string switchXKBLayoutRequest(std::string request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CMD == "next") {
|
if (CMD == "next") {
|
||||||
wlr_keyboard_notify_modifiers(PWLRKEYBOARD, PWLRKEYBOARD->modifiers.depressed, PWLRKEYBOARD->modifiers.latched, PWLRKEYBOARD->modifiers.locked, activeLayout > LAYOUTS ? 0 : activeLayout + 1);
|
wlr_keyboard_notify_modifiers(PWLRKEYBOARD, PWLRKEYBOARD->modifiers.depressed, PWLRKEYBOARD->modifiers.latched, PWLRKEYBOARD->modifiers.locked,
|
||||||
|
activeLayout > LAYOUTS ? 0 : activeLayout + 1);
|
||||||
} else if (CMD == "prev") {
|
} else if (CMD == "prev") {
|
||||||
wlr_keyboard_notify_modifiers(PWLRKEYBOARD, PWLRKEYBOARD->modifiers.depressed, PWLRKEYBOARD->modifiers.latched, PWLRKEYBOARD->modifiers.locked, activeLayout == 0 ? LAYOUTS - 1 : activeLayout - 1);
|
wlr_keyboard_notify_modifiers(PWLRKEYBOARD, PWLRKEYBOARD->modifiers.depressed, PWLRKEYBOARD->modifiers.latched, PWLRKEYBOARD->modifiers.locked,
|
||||||
|
activeLayout == 0 ? LAYOUTS - 1 : activeLayout - 1);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
int requestedLayout = 0;
|
int requestedLayout = 0;
|
||||||
try {
|
try {
|
||||||
requestedLayout = std::stoi(CMD);
|
requestedLayout = std::stoi(CMD);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) { return "invalid arg 2"; }
|
||||||
return "invalid arg 2";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (requestedLayout < 0 || (uint64_t)requestedLayout > LAYOUTS - 1) {
|
if (requestedLayout < 0 || (uint64_t)requestedLayout > LAYOUTS - 1) {
|
||||||
return "layout idx out of range of " + std::to_string(LAYOUTS);
|
return "layout idx out of range of " + std::to_string(LAYOUTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_keyboard_notify_modifiers(PWLRKEYBOARD, PWLRKEYBOARD->modifiers.depressed, PWLRKEYBOARD->modifiers.latched, PWLRKEYBOARD->modifiers.locked, requestedLayout);
|
wlr_keyboard_notify_modifiers(PWLRKEYBOARD, PWLRKEYBOARD->modifiers.depressed, PWLRKEYBOARD->modifiers.latched, PWLRKEYBOARD->modifiers.locked, requestedLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "ok";
|
return "ok";
|
||||||
|
@ -766,7 +743,7 @@ std::string switchXKBLayoutRequest(std::string request) {
|
||||||
std::string dispatchGetOption(std::string request, HyprCtl::eHyprCtlOutputFormat format) {
|
std::string dispatchGetOption(std::string request, HyprCtl::eHyprCtlOutputFormat format) {
|
||||||
std::string curitem = "";
|
std::string curitem = "";
|
||||||
|
|
||||||
auto nextItem = [&]() {
|
auto nextItem = [&]() {
|
||||||
auto idx = request.find_first_of(' ');
|
auto idx = request.find_first_of(' ');
|
||||||
|
|
||||||
if (idx != std::string::npos) {
|
if (idx != std::string::npos) {
|
||||||
|
@ -789,10 +766,11 @@ std::string dispatchGetOption(std::string request, HyprCtl::eHyprCtlOutputFormat
|
||||||
return "no such option";
|
return "no such option";
|
||||||
|
|
||||||
if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL)
|
if (format == HyprCtl::eHyprCtlOutputFormat::FORMAT_NORMAL)
|
||||||
return getFormat("option %s\n\tint: %lld\n\tfloat: %f\n\tstr: \"%s\"\n\tdata: %x", curitem.c_str(), PCFGOPT->intValue, PCFGOPT->floatValue, PCFGOPT->strValue.c_str(), PCFGOPT->data.get());
|
return getFormat("option %s\n\tint: %lld\n\tfloat: %f\n\tstr: \"%s\"\n\tdata: %x", curitem.c_str(), PCFGOPT->intValue, PCFGOPT->floatValue, PCFGOPT->strValue.c_str(),
|
||||||
|
PCFGOPT->data.get());
|
||||||
else {
|
else {
|
||||||
return getFormat(
|
return getFormat(
|
||||||
R"#(
|
R"#(
|
||||||
{
|
{
|
||||||
"option": "%s",
|
"option": "%s",
|
||||||
"int": %lld,
|
"int": %lld,
|
||||||
|
@ -800,8 +778,8 @@ R"#(
|
||||||
"str": "%s",
|
"str": "%s",
|
||||||
"data": "0x%x"
|
"data": "0x%x"
|
||||||
}
|
}
|
||||||
)#", curitem.c_str(), PCFGOPT->intValue, PCFGOPT->floatValue, PCFGOPT->strValue.c_str(), PCFGOPT->data.get()
|
)#",
|
||||||
);
|
curitem.c_str(), PCFGOPT->intValue, PCFGOPT->floatValue, PCFGOPT->strValue.c_str(), PCFGOPT->data.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -839,7 +817,7 @@ void createOutputIter(wlr_backend* backend, void* data) {
|
||||||
std::string dispatchOutput(std::string request) {
|
std::string dispatchOutput(std::string request) {
|
||||||
std::string curitem = "";
|
std::string curitem = "";
|
||||||
|
|
||||||
auto nextItem = [&]() {
|
auto nextItem = [&]() {
|
||||||
auto idx = request.find_first_of(' ');
|
auto idx = request.find_first_of(' ');
|
||||||
|
|
||||||
if (idx != std::string::npos) {
|
if (idx != std::string::npos) {
|
||||||
|
@ -863,7 +841,7 @@ std::string dispatchOutput(std::string request) {
|
||||||
const auto NAME = curitem;
|
const auto NAME = curitem;
|
||||||
|
|
||||||
if (MODE == "create" || MODE == "add") {
|
if (MODE == "create" || MODE == "add") {
|
||||||
std::pair<std::string, bool> result = { NAME, false };
|
std::pair<std::string, bool> result = {NAME, false};
|
||||||
|
|
||||||
wlr_multi_for_each_backend(g_pCompositor->m_sWLRBackend, createOutputIter, &result);
|
wlr_multi_for_each_backend(g_pCompositor->m_sWLRBackend, createOutputIter, &result);
|
||||||
|
|
||||||
|
@ -951,13 +929,13 @@ int hyprCtlFDTick(int fd, uint32_t mask, void* data) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
sockaddr_in clientAddress;
|
sockaddr_in clientAddress;
|
||||||
socklen_t clientSize = sizeof(clientAddress);
|
socklen_t clientSize = sizeof(clientAddress);
|
||||||
|
|
||||||
const auto ACCEPTEDCONNECTION = accept(HyprCtl::iSocketFD, (sockaddr*)&clientAddress, &clientSize);
|
const auto ACCEPTEDCONNECTION = accept(HyprCtl::iSocketFD, (sockaddr*)&clientAddress, &clientSize);
|
||||||
|
|
||||||
char readBuffer[1024];
|
char readBuffer[1024];
|
||||||
|
|
||||||
auto messageSize = read(ACCEPTEDCONNECTION, readBuffer, 1024);
|
auto messageSize = read(ACCEPTEDCONNECTION, readBuffer, 1024);
|
||||||
readBuffer[messageSize == 1024 ? 1023 : messageSize] = '\0';
|
readBuffer[messageSize == 1024 ? 1023 : messageSize] = '\0';
|
||||||
|
|
||||||
std::string request(readBuffer);
|
std::string request(readBuffer);
|
||||||
|
@ -997,7 +975,10 @@ void HyprCtl::startHyprCtlSocket() {
|
||||||
|
|
||||||
strcpy(SERVERADDRESS.sun_path, socketPath.c_str());
|
strcpy(SERVERADDRESS.sun_path, socketPath.c_str());
|
||||||
|
|
||||||
bind(iSocketFD, (sockaddr*)&SERVERADDRESS, SUN_LEN(&SERVERADDRESS));
|
if (bind(iSocketFD, (sockaddr*)&SERVERADDRESS, SUN_LEN(&SERVERADDRESS)) < 0) {
|
||||||
|
Debug::log(ERR, "Couldn't start the Hyprland Socket. (2) IPC will not work.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 10 max queued.
|
// 10 max queued.
|
||||||
listen(iSocketFD, 10);
|
listen(iSocketFD, 10);
|
||||||
|
|
|
@ -5,20 +5,21 @@
|
||||||
#include "../helpers/MiscFunctions.hpp"
|
#include "../helpers/MiscFunctions.hpp"
|
||||||
|
|
||||||
namespace HyprCtl {
|
namespace HyprCtl {
|
||||||
void startHyprCtlSocket();
|
void startHyprCtlSocket();
|
||||||
|
|
||||||
// very simple thread-safe request method
|
// very simple thread-safe request method
|
||||||
inline bool requestMade = false;
|
inline bool requestMade = false;
|
||||||
inline bool requestReady = false;
|
inline bool requestReady = false;
|
||||||
inline std::string request = "";
|
inline std::string request = "";
|
||||||
|
|
||||||
inline std::ifstream requestStream;
|
inline std::ifstream requestStream;
|
||||||
|
|
||||||
inline wl_event_source* hyprCtlTickSource = nullptr;
|
inline wl_event_source* hyprCtlTickSource = nullptr;
|
||||||
|
|
||||||
inline int iSocketFD = -1;
|
inline int iSocketFD = -1;
|
||||||
|
|
||||||
enum eHyprCtlOutputFormat {
|
enum eHyprCtlOutputFormat
|
||||||
|
{
|
||||||
FORMAT_NORMAL = 0,
|
FORMAT_NORMAL = 0,
|
||||||
FORMAT_JSON
|
FORMAT_JSON
|
||||||
};
|
};
|
||||||
|
|
|
@ -38,10 +38,10 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
||||||
if (!m_pMonitor)
|
if (!m_pMonitor)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int yOffset = offset;
|
int yOffset = offset;
|
||||||
cairo_text_extents_t cairoExtents;
|
cairo_text_extents_t cairoExtents;
|
||||||
float maxX = 0;
|
float maxX = 0;
|
||||||
std::string text = "";
|
std::string text = "";
|
||||||
|
|
||||||
// get avg fps
|
// get avg fps
|
||||||
float avgFrametime = 0;
|
float avgFrametime = 0;
|
||||||
|
@ -62,7 +62,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
||||||
}
|
}
|
||||||
avgRenderTimeNoOverlay /= m_dLastRenderTimes.size() == 0 ? 1 : m_dLastRenderTimes.size();
|
avgRenderTimeNoOverlay /= m_dLastRenderTimes.size() == 0 ? 1 : m_dLastRenderTimes.size();
|
||||||
|
|
||||||
const float FPS = 1.f / (avgFrametime / 1000.f); // frametimes are in ms
|
const float FPS = 1.f / (avgFrametime / 1000.f); // frametimes are in ms
|
||||||
const float idealFPS = m_dLastFrametimes.size();
|
const float idealFPS = m_dLastFrametimes.size();
|
||||||
|
|
||||||
cairo_select_font_face(g_pDebugOverlay->m_pCairo, "Noto Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
cairo_select_font_face(g_pDebugOverlay->m_pCairo, "Noto Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||||
|
@ -75,7 +75,8 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
||||||
text = m_pMonitor->szName;
|
text = m_pMonitor->szName;
|
||||||
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
||||||
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
||||||
if (cairoExtents.width > maxX) maxX = cairoExtents.width;
|
if (cairoExtents.width > maxX)
|
||||||
|
maxX = cairoExtents.width;
|
||||||
|
|
||||||
cairo_set_font_size(g_pDebugOverlay->m_pCairo, 16);
|
cairo_set_font_size(g_pDebugOverlay->m_pCairo, 16);
|
||||||
|
|
||||||
|
@ -91,7 +92,8 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
||||||
text = std::string(std::to_string((int)FPS) + " FPS");
|
text = std::string(std::to_string((int)FPS) + " FPS");
|
||||||
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
||||||
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
||||||
if (cairoExtents.width > maxX) maxX = cairoExtents.width;
|
if (cairoExtents.width > maxX)
|
||||||
|
maxX = cairoExtents.width;
|
||||||
|
|
||||||
cairo_set_font_size(g_pDebugOverlay->m_pCairo, 10);
|
cairo_set_font_size(g_pDebugOverlay->m_pCairo, 10);
|
||||||
cairo_set_source_rgba(g_pDebugOverlay->m_pCairo, 1.f, 1.f, 1.f, 1.f);
|
cairo_set_source_rgba(g_pDebugOverlay->m_pCairo, 1.f, 1.f, 1.f, 1.f);
|
||||||
|
@ -101,26 +103,30 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
||||||
text = std::string("Avg Frametime: " + std::to_string((int)avgFrametime) + "." + std::to_string((int)(avgFrametime * 10.f) % 10) + "ms");
|
text = std::string("Avg Frametime: " + std::to_string((int)avgFrametime) + "." + std::to_string((int)(avgFrametime * 10.f) % 10) + "ms");
|
||||||
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
||||||
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
||||||
if (cairoExtents.width > maxX) maxX = cairoExtents.width;
|
if (cairoExtents.width > maxX)
|
||||||
|
maxX = cairoExtents.width;
|
||||||
|
|
||||||
yOffset += 11;
|
yOffset += 11;
|
||||||
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
|
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
|
||||||
text = std::string("Avg Rendertime: " + std::to_string((int)avgRenderTime) + "." + std::to_string((int)(avgRenderTime * 10.f) % 10) + "ms");
|
text = std::string("Avg Rendertime: " + std::to_string((int)avgRenderTime) + "." + std::to_string((int)(avgRenderTime * 10.f) % 10) + "ms");
|
||||||
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
||||||
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
||||||
if (cairoExtents.width > maxX) maxX = cairoExtents.width;
|
if (cairoExtents.width > maxX)
|
||||||
|
maxX = cairoExtents.width;
|
||||||
|
|
||||||
yOffset += 11;
|
yOffset += 11;
|
||||||
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
|
cairo_move_to(g_pDebugOverlay->m_pCairo, 0, yOffset);
|
||||||
text = std::string("Avg Rendertime (no overlay): " + std::to_string((int)avgRenderTimeNoOverlay) + "." + std::to_string((int)(avgRenderTimeNoOverlay * 10.f) % 10) + "ms");
|
text = std::string("Avg Rendertime (no overlay): " + std::to_string((int)avgRenderTimeNoOverlay) + "." + std::to_string((int)(avgRenderTimeNoOverlay * 10.f) % 10) + "ms");
|
||||||
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
||||||
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
cairo_text_extents(g_pDebugOverlay->m_pCairo, text.c_str(), &cairoExtents);
|
||||||
if (cairoExtents.width > maxX) maxX = cairoExtents.width;
|
if (cairoExtents.width > maxX)
|
||||||
|
maxX = cairoExtents.width;
|
||||||
|
|
||||||
yOffset += 11;
|
yOffset += 11;
|
||||||
|
|
||||||
g_pHyprRenderer->damageBox(&m_wbLastDrawnBox);
|
g_pHyprRenderer->damageBox(&m_wbLastDrawnBox);
|
||||||
m_wbLastDrawnBox = {(int)g_pCompositor->m_vMonitors.front()->vecPosition.x, (int)g_pCompositor->m_vMonitors.front()->vecPosition.y + offset - 1, (int)maxX + 2, yOffset - offset + 2};
|
m_wbLastDrawnBox = {(int)g_pCompositor->m_vMonitors.front()->vecPosition.x, (int)g_pCompositor->m_vMonitors.front()->vecPosition.y + offset - 1, (int)maxX + 2,
|
||||||
|
yOffset - offset + 2};
|
||||||
g_pHyprRenderer->damageBox(&m_wbLastDrawnBox);
|
g_pHyprRenderer->damageBox(&m_wbLastDrawnBox);
|
||||||
|
|
||||||
return yOffset - offset;
|
return yOffset - offset;
|
||||||
|
@ -144,7 +150,7 @@ void CHyprDebugOverlay::draw() {
|
||||||
|
|
||||||
if (!m_pCairoSurface || !m_pCairo) {
|
if (!m_pCairoSurface || !m_pCairo) {
|
||||||
m_pCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PMONITOR->vecSize.x, PMONITOR->vecSize.y);
|
m_pCairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, PMONITOR->vecSize.x, PMONITOR->vecSize.y);
|
||||||
m_pCairo = cairo_create(m_pCairoSurface);
|
m_pCairo = cairo_create(m_pCairoSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear the pixmap
|
// clear the pixmap
|
||||||
|
@ -176,6 +182,6 @@ void CHyprDebugOverlay::draw() {
|
||||||
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, PMONITOR->vecSize.x, PMONITOR->vecSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, PMONITOR->vecSize.x, PMONITOR->vecSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA);
|
||||||
|
|
||||||
wlr_box pMonBox = {0,0,PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y};
|
wlr_box pMonBox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y};
|
||||||
g_pHyprOpenGL->renderTexture(m_tTexture, &pMonBox, 255.f);
|
g_pHyprOpenGL->renderTexture(m_tTexture, &pMonBox, 255.f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,38 +8,36 @@
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
class CHyprMonitorDebugOverlay {
|
class CHyprMonitorDebugOverlay {
|
||||||
public:
|
public:
|
||||||
int draw(int offset);
|
int draw(int offset);
|
||||||
|
|
||||||
void renderData(CMonitor* pMonitor, float µs);
|
void renderData(CMonitor* pMonitor, float µs);
|
||||||
void renderDataNoOverlay(CMonitor* pMonitor, float µs);
|
void renderDataNoOverlay(CMonitor* pMonitor, float µs);
|
||||||
void frameData(CMonitor* pMonitor);
|
void frameData(CMonitor* pMonitor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::deque<float> m_dLastFrametimes;
|
std::deque<float> m_dLastFrametimes;
|
||||||
std::deque<float> m_dLastRenderTimes;
|
std::deque<float> m_dLastRenderTimes;
|
||||||
std::deque<float> m_dLastRenderTimesNoOverlay;
|
std::deque<float> m_dLastRenderTimesNoOverlay;
|
||||||
std::chrono::high_resolution_clock::time_point m_tpLastFrame;
|
std::chrono::high_resolution_clock::time_point m_tpLastFrame;
|
||||||
CMonitor* m_pMonitor = nullptr;
|
CMonitor* m_pMonitor = nullptr;
|
||||||
wlr_box m_wbLastDrawnBox;
|
wlr_box m_wbLastDrawnBox;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CHyprDebugOverlay {
|
class CHyprDebugOverlay {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
void renderData(CMonitor*, float µs);
|
void renderData(CMonitor*, float µs);
|
||||||
void renderDataNoOverlay(CMonitor*, float µs);
|
void renderDataNoOverlay(CMonitor*, float µs);
|
||||||
void frameData(CMonitor*);
|
void frameData(CMonitor*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::unordered_map<CMonitor*, CHyprMonitorDebugOverlay> m_mMonitorOverlays;
|
std::unordered_map<CMonitor*, CHyprMonitorDebugOverlay> m_mMonitorOverlays;
|
||||||
|
|
||||||
cairo_surface_t* m_pCairoSurface = nullptr;
|
cairo_surface_t* m_pCairoSurface = nullptr;
|
||||||
cairo_t* m_pCairo = nullptr;
|
cairo_t* m_pCairo = nullptr;
|
||||||
|
|
||||||
CTexture m_tTexture;
|
CTexture m_tTexture;
|
||||||
|
|
||||||
friend class CHyprMonitorDebugOverlay;
|
friend class CHyprMonitorDebugOverlay;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
void Debug::init(std::string IS) {
|
void Debug::init(const std::string& IS) {
|
||||||
logFile = "/tmp/hypr/" + IS + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log");
|
logFile = "/tmp/hypr/" + IS + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Debug::wlrLog(wlr_log_importance level, const char* fmt, va_list args) {
|
void Debug::wlrLog(wlr_log_importance level, const char* fmt, va_list args) {
|
||||||
char* outputStr = nullptr;
|
char* outputStr = nullptr;
|
||||||
|
|
||||||
std::ofstream ofs;
|
std::ofstream ofs;
|
||||||
ofs.open(logFile, std::ios::out | std::ios::app);
|
ofs.open(logFile, std::ios::out | std::ios::app);
|
||||||
|
@ -35,28 +35,17 @@ void Debug::log(LogLevel level, const char* fmt, ...) {
|
||||||
ofs.open(logFile, std::ios::out | std::ios::app);
|
ofs.open(logFile, std::ios::out | std::ios::app);
|
||||||
|
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case LOG:
|
case LOG: ofs << "[LOG] "; break;
|
||||||
ofs << "[LOG] ";
|
case WARN: ofs << "[WARN] "; break;
|
||||||
break;
|
case ERR: ofs << "[ERR] "; break;
|
||||||
case WARN:
|
case CRIT: ofs << "[CRITICAL] "; break;
|
||||||
ofs << "[WARN] ";
|
case INFO: ofs << "[INFO] "; break;
|
||||||
break;
|
default: break;
|
||||||
case ERR:
|
|
||||||
ofs << "[ERR] ";
|
|
||||||
break;
|
|
||||||
case CRIT:
|
|
||||||
ofs << "[CRITICAL] ";
|
|
||||||
break;
|
|
||||||
case INFO:
|
|
||||||
ofs << "[INFO] ";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// print date and time to the ofs
|
// print date and time to the ofs
|
||||||
if (disableTime && !*disableTime) {
|
if (disableTime && !*disableTime) {
|
||||||
auto timet = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
auto timet = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
|
||||||
const auto MILLIS = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() % 1000;
|
const auto MILLIS = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count() % 1000;
|
||||||
|
|
||||||
ofs << std::put_time(std::localtime(&timet), "[%H:%M:%S:");
|
ofs << std::put_time(std::localtime(&timet), "[%H:%M:%S:");
|
||||||
|
@ -71,7 +60,7 @@ void Debug::log(LogLevel level, const char* fmt, ...) {
|
||||||
ofs << "] ";
|
ofs << "] ";
|
||||||
}
|
}
|
||||||
|
|
||||||
char* outputStr = nullptr;
|
char* outputStr = nullptr;
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
|
|
|
@ -4,9 +4,10 @@
|
||||||
|
|
||||||
#define LOGMESSAGESIZE 1024
|
#define LOGMESSAGESIZE 1024
|
||||||
|
|
||||||
enum LogLevel {
|
enum LogLevel
|
||||||
|
{
|
||||||
NONE = -1,
|
NONE = -1,
|
||||||
LOG = 0,
|
LOG = 0,
|
||||||
WARN,
|
WARN,
|
||||||
ERR,
|
ERR,
|
||||||
CRIT,
|
CRIT,
|
||||||
|
@ -14,11 +15,11 @@ enum LogLevel {
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace Debug {
|
namespace Debug {
|
||||||
void init(std::string IS);
|
void init(const std::string& IS);
|
||||||
void log(LogLevel level, const char* fmt, ...);
|
void log(LogLevel level, const char* fmt, ...);
|
||||||
void wlrLog(wlr_log_importance level, const char* fmt, va_list args);
|
void wlrLog(wlr_log_importance level, const char* fmt, va_list args);
|
||||||
|
|
||||||
inline std::string logFile;
|
inline std::string logFile;
|
||||||
inline int64_t* disableLogs = nullptr;
|
inline int64_t* disableLogs = nullptr;
|
||||||
inline int64_t* disableTime = nullptr;
|
inline int64_t* disableTime = nullptr;
|
||||||
};
|
};
|
|
@ -18,39 +18,44 @@
|
||||||
#define ISDEBUG false
|
#define ISDEBUG false
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LISTENER(name) void listener_##name(wl_listener*, void*); inline wl_listener listen_##name = { .notify = listener_##name }
|
#define LISTENER(name) \
|
||||||
#define DYNLISTENFUNC(name) void listener_##name(void*, void*)
|
void listener_##name(wl_listener*, void*); \
|
||||||
#define DYNLISTENER(name) CHyprWLListener hyprListener_##name
|
inline wl_listener listen_##name = {.notify = listener_##name}
|
||||||
|
#define DYNLISTENFUNC(name) void listener_##name(void*, void*)
|
||||||
|
#define DYNLISTENER(name) CHyprWLListener hyprListener_##name
|
||||||
#define DYNMULTILISTENER(name) wl_listener listen_##name
|
#define DYNMULTILISTENER(name) wl_listener listen_##name
|
||||||
|
|
||||||
#define VECINRECT(vec, x1, y1, x2, y2) (vec.x >= (x1) && vec.x <= (x2) && vec.y >= (y1) && vec.y <= (y2))
|
#define VECINRECT(vec, x1, y1, x2, y2) ((vec).x >= (x1) && (vec).x <= (x2) && (vec).y >= (y1) && (vec).y <= (y2))
|
||||||
|
|
||||||
#define DELTALESSTHAN(a, b, delta) (abs((a) - (b)) < delta)
|
#define DELTALESSTHAN(a, b, delta) (abs((a) - (b)) < (delta))
|
||||||
|
|
||||||
#define PIXMAN_DAMAGE_FOREACH(region) int rectsNum = 0; \
|
#define PIXMAN_DAMAGE_FOREACH(region) \
|
||||||
const auto RECTSARR = pixman_region32_rectangles(region, &rectsNum); \
|
int rectsNum = 0; \
|
||||||
|
const auto RECTSARR = pixman_region32_rectangles(region, &rectsNum); \
|
||||||
for (int i = 0; i < rectsNum; ++i)
|
for (int i = 0; i < rectsNum; ++i)
|
||||||
|
|
||||||
#define PIXMAN_REGION_FOREACH(region) PIXMAN_DAMAGE_FOREACH(region)
|
#define PIXMAN_REGION_FOREACH(region) PIXMAN_DAMAGE_FOREACH(region)
|
||||||
|
|
||||||
|
|
||||||
#define interface class
|
#define interface class
|
||||||
|
|
||||||
#define STICKS(a, b) abs((a) - (b)) < 2
|
#define STICKS(a, b) abs((a) - (b)) < 2
|
||||||
|
|
||||||
#define ALPHA(c) ((double)(((c) >> 24) & 0xff) / 255.0)
|
#define ALPHA(c) ((double)(((c) >> 24) & 0xff) / 255.0)
|
||||||
#define RED(c) ((double)(((c) >> 16) & 0xff) / 255.0)
|
#define RED(c) ((double)(((c) >> 16) & 0xff) / 255.0)
|
||||||
#define GREEN(c) ((double)(((c) >> 8) & 0xff) / 255.0)
|
#define GREEN(c) ((double)(((c) >> 8) & 0xff) / 255.0)
|
||||||
#define BLUE(c) ((double)(((c)) & 0xff) / 255.0)
|
#define BLUE(c) ((double)(((c)) & 0xff) / 255.0)
|
||||||
|
|
||||||
#define HYPRATOM(name) {name, 0}
|
#define HYPRATOM(name) \
|
||||||
|
{ name, 0 }
|
||||||
|
|
||||||
#ifndef __INTELLISENSE__
|
#ifndef __INTELLISENSE__
|
||||||
#define RASSERT(expr, reason, ...) \
|
#define RASSERT(expr, reason, ...) \
|
||||||
if (!(expr)) { \
|
if (!(expr)) { \
|
||||||
Debug::log(CRIT, "\n==========================================================================================\nASSERTION FAILED! \n\n%s\n\nat: line %d in %s", getFormat(reason, ##__VA_ARGS__).c_str(), __LINE__, ([]() constexpr->std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })().c_str()); \
|
Debug::log(CRIT, "\n==========================================================================================\nASSERTION FAILED! \n\n%s\n\nat: line %d in %s", \
|
||||||
printf("Assertion failed! See the log in /tmp/hypr/hyprland.log for more info."); \
|
getFormat(reason, ##__VA_ARGS__).c_str(), __LINE__, \
|
||||||
*((int*)nullptr) = 1; /* so that we crash and get a coredump */ \
|
([]() constexpr->std::string { return std::string(__FILE__).substr(std::string(__FILE__).find_last_of('/') + 1); })().c_str()); \
|
||||||
|
printf("Assertion failed! See the log in /tmp/hypr/hyprland.log for more info."); \
|
||||||
|
*((int*)nullptr) = 1; /* so that we crash and get a coredump */ \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define RASSERT(expr, reason, ...)
|
#define RASSERT(expr, reason, ...)
|
||||||
|
@ -59,7 +64,11 @@
|
||||||
#define ASSERT(expr) RASSERT(expr, "?")
|
#define ASSERT(expr) RASSERT(expr, "?")
|
||||||
|
|
||||||
#if ISDEBUG
|
#if ISDEBUG
|
||||||
#define UNREACHABLE() { Debug::log(CRIT, "\n\nMEMORY CORRUPTED: Unreachable failed! (Reached an unreachable position, memory corruption!!!)"); *((int*)nullptr) = 1; }
|
#define UNREACHABLE() \
|
||||||
|
{ \
|
||||||
|
Debug::log(CRIT, "\n\nMEMORY CORRUPTED: Unreachable failed! (Reached an unreachable position, memory corruption!!!)"); \
|
||||||
|
*((int*)nullptr) = 1; \
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
#define UNREACHABLE() std::unreachable();
|
#define UNREACHABLE() std::unreachable();
|
||||||
#endif
|
#endif
|
||||||
|
@ -78,6 +87,6 @@
|
||||||
#define GIT_DIRTY "?"
|
#define GIT_DIRTY "?"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SPECIAL_WORKSPACE_START -99
|
#define SPECIAL_WORKSPACE_START (-99)
|
||||||
|
|
||||||
#define PI 3.14159265358979
|
#define PI 3.14159265358979
|
||||||
|
|
|
@ -61,7 +61,7 @@ void Events::listener_requestMouse(wl_listener* listener, void* data) {
|
||||||
void Events::listener_newInput(wl_listener* listener, void* data) {
|
void Events::listener_newInput(wl_listener* listener, void* data) {
|
||||||
const auto DEVICE = (wlr_input_device*)data;
|
const auto DEVICE = (wlr_input_device*)data;
|
||||||
|
|
||||||
switch(DEVICE->type) {
|
switch (DEVICE->type) {
|
||||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||||
Debug::log(LOG, "Attached a keyboard with name %s", DEVICE->name);
|
Debug::log(LOG, "Attached a keyboard with name %s", DEVICE->name);
|
||||||
g_pInputManager->newKeyboard(DEVICE);
|
g_pInputManager->newKeyboard(DEVICE);
|
||||||
|
@ -86,9 +86,7 @@ void Events::listener_newInput(wl_listener* listener, void* data) {
|
||||||
Debug::log(LOG, "Attached a switch device with name %s", DEVICE->name);
|
Debug::log(LOG, "Attached a switch device with name %s", DEVICE->name);
|
||||||
g_pInputManager->newSwitch(DEVICE);
|
g_pInputManager->newSwitch(DEVICE);
|
||||||
break;
|
break;
|
||||||
default:
|
default: Debug::log(WARN, "Unrecognized input device plugged in: %s", DEVICE->name); break;
|
||||||
Debug::log(WARN, "Unrecognized input device plugged in: %s", DEVICE->name);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pInputManager->updateCapabilities();
|
g_pInputManager->updateCapabilities();
|
||||||
|
@ -102,7 +100,7 @@ void Events::listener_newConstraint(wl_listener* listener, void* data) {
|
||||||
g_pInputManager->m_lConstraints.emplace_back();
|
g_pInputManager->m_lConstraints.emplace_back();
|
||||||
const auto CONSTRAINT = &g_pInputManager->m_lConstraints.back();
|
const auto CONSTRAINT = &g_pInputManager->m_lConstraints.back();
|
||||||
|
|
||||||
CONSTRAINT->pMouse = g_pCompositor->m_sSeat.mouse;
|
CONSTRAINT->pMouse = g_pCompositor->m_sSeat.mouse;
|
||||||
CONSTRAINT->constraint = PCONSTRAINT;
|
CONSTRAINT->constraint = PCONSTRAINT;
|
||||||
|
|
||||||
CONSTRAINT->hyprListener_destroyConstraint.initCallback(&PCONSTRAINT->events.destroy, &Events::listener_destroyConstraint, CONSTRAINT, "Constraint");
|
CONSTRAINT->hyprListener_destroyConstraint.initCallback(&PCONSTRAINT->events.destroy, &Events::listener_destroyConstraint, CONSTRAINT, "Constraint");
|
||||||
|
@ -112,7 +110,7 @@ void Events::listener_newConstraint(wl_listener* listener, void* data) {
|
||||||
g_pInputManager->constrainMouse(CONSTRAINT->pMouse, PCONSTRAINT);
|
g_pInputManager->constrainMouse(CONSTRAINT->pMouse, PCONSTRAINT);
|
||||||
|
|
||||||
if (!CONSTRAINT->hintSet) {
|
if (!CONSTRAINT->hintSet) {
|
||||||
const auto PWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
|
const auto PWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
|
||||||
CONSTRAINT->positionHint = g_pInputManager->getMouseCoordsInternal() - PWINDOW->m_vRealPosition.goalv();
|
CONSTRAINT->positionHint = g_pInputManager->getMouseCoordsInternal() - PWINDOW->m_vRealPosition.goalv();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,13 +126,13 @@ void Events::listener_destroyConstraint(void* owner, void* data) {
|
||||||
|
|
||||||
if (PWINDOW) {
|
if (PWINDOW) {
|
||||||
if (PWINDOW->m_bIsX11) {
|
if (PWINDOW->m_bIsX11) {
|
||||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr,
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, PCONSTRAINT->positionHint.x + PWINDOW->m_uSurface.xwayland->x,
|
||||||
PCONSTRAINT->positionHint.x + PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y + PCONSTRAINT->positionHint.y);
|
PWINDOW->m_uSurface.xwayland->y + PCONSTRAINT->positionHint.y);
|
||||||
|
|
||||||
wlr_seat_pointer_warp(PCONSTRAINT->constraint->seat, PCONSTRAINT->positionHint.x, PCONSTRAINT->positionHint.y);
|
wlr_seat_pointer_warp(PCONSTRAINT->constraint->seat, PCONSTRAINT->positionHint.x, PCONSTRAINT->positionHint.y);
|
||||||
} else {
|
} else {
|
||||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr,
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, PCONSTRAINT->positionHint.x + PWINDOW->m_vRealPosition.vec().x,
|
||||||
PCONSTRAINT->positionHint.x + PWINDOW->m_vRealPosition.vec().x, PCONSTRAINT->positionHint.y + PWINDOW->m_vRealPosition.vec().y);
|
PCONSTRAINT->positionHint.y + PWINDOW->m_vRealPosition.vec().y);
|
||||||
|
|
||||||
wlr_seat_pointer_warp(PCONSTRAINT->constraint->seat, PCONSTRAINT->positionHint.x, PCONSTRAINT->positionHint.y);
|
wlr_seat_pointer_warp(PCONSTRAINT->constraint->seat, PCONSTRAINT->positionHint.x, PCONSTRAINT->positionHint.y);
|
||||||
}
|
}
|
||||||
|
@ -153,9 +151,9 @@ void Events::listener_setConstraintRegion(void* owner, void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_newVirtPtr(wl_listener* listener, void* data) {
|
void Events::listener_newVirtPtr(wl_listener* listener, void* data) {
|
||||||
const auto EV = (wlr_virtual_pointer_v1_new_pointer_event*)data;
|
const auto EV = (wlr_virtual_pointer_v1_new_pointer_event*)data;
|
||||||
const auto POINTER = EV->new_pointer;
|
const auto POINTER = EV->new_pointer;
|
||||||
const auto DEVICE = &POINTER->pointer.base;
|
const auto DEVICE = &POINTER->pointer.base;
|
||||||
|
|
||||||
g_pInputManager->newMouse(DEVICE, true);
|
g_pInputManager->newMouse(DEVICE, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace Events {
|
||||||
DYNLISTENFUNC(commitSubsurface);
|
DYNLISTENFUNC(commitSubsurface);
|
||||||
|
|
||||||
// Popups
|
// Popups
|
||||||
DYNLISTENFUNC(newPopup); // LayerSurface
|
DYNLISTENFUNC(newPopup); // LayerSurface
|
||||||
|
|
||||||
DYNLISTENFUNC(newPopupXDG);
|
DYNLISTENFUNC(newPopupXDG);
|
||||||
DYNLISTENFUNC(mapPopupXDG);
|
DYNLISTENFUNC(mapPopupXDG);
|
||||||
|
@ -60,7 +60,7 @@ namespace Events {
|
||||||
DYNLISTENFUNC(requestMaximize);
|
DYNLISTENFUNC(requestMaximize);
|
||||||
|
|
||||||
// Window subsurfaces
|
// Window subsurfaces
|
||||||
// LISTENER(newSubsurfaceWindow);
|
// LISTENER(newSubsurfaceWindow);
|
||||||
|
|
||||||
// Input events
|
// Input events
|
||||||
LISTENER(mouseMove);
|
LISTENER(mouseMove);
|
||||||
|
|
|
@ -34,7 +34,7 @@ void Events::listener_newLayerSurface(wl_listener* listener, void* data) {
|
||||||
auto PMONITOR = (CMonitor*)g_pCompositor->getMonitorFromOutput(WLRLAYERSURFACE->output);
|
auto PMONITOR = (CMonitor*)g_pCompositor->getMonitorFromOutput(WLRLAYERSURFACE->output);
|
||||||
|
|
||||||
if (!WLRLAYERSURFACE->output || !PMONITOR || PMONITOR->pMirrorOf) {
|
if (!WLRLAYERSURFACE->output || !PMONITOR || PMONITOR->pMirrorOf) {
|
||||||
PMONITOR = g_pCompositor->m_vMonitors.front().get();
|
PMONITOR = g_pCompositor->m_vMonitors.front().get();
|
||||||
WLRLAYERSURFACE->output = PMONITOR->output; // TODO: current mon
|
WLRLAYERSURFACE->output = PMONITOR->output; // TODO: current mon
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,13 +49,14 @@ void Events::listener_newLayerSurface(wl_listener* listener, void* data) {
|
||||||
layerSurface->hyprListener_newPopup.initCallback(&WLRLAYERSURFACE->events.new_popup, &Events::listener_newPopup, layerSurface, "layerSurface");
|
layerSurface->hyprListener_newPopup.initCallback(&WLRLAYERSURFACE->events.new_popup, &Events::listener_newPopup, layerSurface, "layerSurface");
|
||||||
|
|
||||||
layerSurface->layerSurface = WLRLAYERSURFACE;
|
layerSurface->layerSurface = WLRLAYERSURFACE;
|
||||||
layerSurface->layer = WLRLAYERSURFACE->current.layer;
|
layerSurface->layer = WLRLAYERSURFACE->current.layer;
|
||||||
WLRLAYERSURFACE->data = layerSurface;
|
WLRLAYERSURFACE->data = layerSurface;
|
||||||
layerSurface->monitorID = PMONITOR->ID;
|
layerSurface->monitorID = PMONITOR->ID;
|
||||||
|
|
||||||
layerSurface->forceBlur = g_pConfigManager->shouldBlurLS(layerSurface->szNamespace);
|
layerSurface->forceBlur = g_pConfigManager->shouldBlurLS(layerSurface->szNamespace);
|
||||||
|
|
||||||
Debug::log(LOG, "LayerSurface %x (namespace %s layer %d) created on monitor %s", layerSurface->layerSurface, layerSurface->layerSurface->_namespace, layerSurface->layer, PMONITOR->szName.c_str());
|
Debug::log(LOG, "LayerSurface %x (namespace %s layer %d) created on monitor %s", layerSurface->layerSurface, layerSurface->layerSurface->_namespace, layerSurface->layer,
|
||||||
|
PMONITOR->szName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_destroyLayerSurface(void* owner, void* data) {
|
void Events::listener_destroyLayerSurface(void* owner, void* data) {
|
||||||
|
@ -94,12 +95,13 @@ void Events::listener_destroyLayerSurface(void* owner, void* data) {
|
||||||
PMONITOR->scheduledRecalc = true;
|
PMONITOR->scheduledRecalc = true;
|
||||||
|
|
||||||
// and damage
|
// and damage
|
||||||
wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width, layersurface->geometry.height};
|
wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width,
|
||||||
|
layersurface->geometry.height};
|
||||||
g_pHyprRenderer->damageBox(&geomFixed);
|
g_pHyprRenderer->damageBox(&geomFixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
layersurface->readyToDelete = true;
|
layersurface->readyToDelete = true;
|
||||||
layersurface->layerSurface = nullptr;
|
layersurface->layerSurface = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_mapLayerSurface(void* owner, void* data) {
|
void Events::listener_mapLayerSurface(void* owner, void* data) {
|
||||||
|
@ -108,7 +110,7 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
|
||||||
Debug::log(LOG, "LayerSurface %x mapped", layersurface->layerSurface);
|
Debug::log(LOG, "LayerSurface %x mapped", layersurface->layerSurface);
|
||||||
|
|
||||||
layersurface->layerSurface->mapped = true;
|
layersurface->layerSurface->mapped = true;
|
||||||
layersurface->mapped = true;
|
layersurface->mapped = true;
|
||||||
|
|
||||||
// anim
|
// anim
|
||||||
layersurface->alpha.setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeIn"));
|
layersurface->alpha.setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeIn"));
|
||||||
|
@ -128,7 +130,7 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
layersurface->monitorID = PMONITOR->ID;
|
layersurface->monitorID = PMONITOR->ID;
|
||||||
PMONITOR->scheduledRecalc = true;
|
PMONITOR->scheduledRecalc = true;
|
||||||
g_pHyprRenderer->arrangeLayersForMonitor(POLDMON->ID);
|
g_pHyprRenderer->arrangeLayersForMonitor(POLDMON->ID);
|
||||||
}
|
}
|
||||||
|
@ -137,23 +139,26 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
|
||||||
|
|
||||||
wlr_surface_send_enter(layersurface->layerSurface->surface, layersurface->layerSurface->output);
|
wlr_surface_send_enter(layersurface->layerSurface->surface, layersurface->layerSurface->output);
|
||||||
|
|
||||||
if (layersurface->layerSurface->current.keyboard_interactive && (!g_pCompositor->m_sSeat.mouse || !g_pCompositor->m_sSeat.mouse->currentConstraint)) { // don't focus if constrained
|
if (layersurface->layerSurface->current.keyboard_interactive &&
|
||||||
|
(!g_pCompositor->m_sSeat.mouse || !g_pCompositor->m_sSeat.mouse->currentConstraint)) { // don't focus if constrained
|
||||||
g_pCompositor->focusSurface(layersurface->layerSurface->surface);
|
g_pCompositor->focusSurface(layersurface->layerSurface->surface);
|
||||||
|
|
||||||
const auto LOCAL = g_pInputManager->getMouseCoordsInternal() - Vector2D(layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y);
|
const auto LOCAL =
|
||||||
|
g_pInputManager->getMouseCoordsInternal() - Vector2D(layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y);
|
||||||
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, layersurface->layerSurface->surface, LOCAL.x, LOCAL.y);
|
wlr_seat_pointer_notify_enter(g_pCompositor->m_sSeat.seat, layersurface->layerSurface->surface, LOCAL.x, LOCAL.y);
|
||||||
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, 0, LOCAL.x, LOCAL.y);
|
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, 0, LOCAL.x, LOCAL.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y);
|
layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y);
|
||||||
|
|
||||||
wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width, layersurface->geometry.height};
|
wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width,
|
||||||
|
layersurface->geometry.height};
|
||||||
g_pHyprRenderer->damageBox(&geomFixed);
|
g_pHyprRenderer->damageBox(&geomFixed);
|
||||||
|
|
||||||
layersurface->alpha.setValue(0);
|
layersurface->alpha.setValue(0);
|
||||||
layersurface->alpha = 255.f;
|
layersurface->alpha = 255.f;
|
||||||
layersurface->readyToDelete = false;
|
layersurface->readyToDelete = false;
|
||||||
layersurface->fadingOut = false;
|
layersurface->fadingOut = false;
|
||||||
|
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent{"openlayer", std::string(layersurface->layerSurface->_namespace ? layersurface->layerSurface->_namespace : "")});
|
g_pEventManager->postEvent(SHyprIPCEvent{"openlayer", std::string(layersurface->layerSurface->_namespace ? layersurface->layerSurface->_namespace : "")});
|
||||||
}
|
}
|
||||||
|
@ -201,19 +206,20 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
|
||||||
|
|
||||||
// refocus if needed
|
// refocus if needed
|
||||||
if (layersurface->layerSurface->surface == g_pCompositor->m_pLastFocus) {
|
if (layersurface->layerSurface->surface == g_pCompositor->m_pLastFocus) {
|
||||||
|
|
||||||
Vector2D surfaceCoords;
|
Vector2D surfaceCoords;
|
||||||
SLayerSurface* pFoundLayerSurface = nullptr;
|
SLayerSurface* pFoundLayerSurface = nullptr;
|
||||||
wlr_surface* foundSurface = nullptr;
|
wlr_surface* foundSurface = nullptr;
|
||||||
|
|
||||||
g_pCompositor->m_pLastFocus = nullptr;
|
g_pCompositor->m_pLastFocus = nullptr;
|
||||||
|
|
||||||
// find LS-es to focus
|
// find LS-es to focus
|
||||||
foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], &surfaceCoords, &pFoundLayerSurface);
|
foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY],
|
||||||
|
&surfaceCoords, &pFoundLayerSurface);
|
||||||
|
|
||||||
if (!foundSurface)
|
if (!foundSurface)
|
||||||
foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP], &surfaceCoords, &pFoundLayerSurface);
|
foundSurface = g_pCompositor->vectorToLayerSurface(g_pInputManager->getMouseCoordsInternal(), &PMONITOR->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP],
|
||||||
|
&surfaceCoords, &pFoundLayerSurface);
|
||||||
|
|
||||||
if (!foundSurface) {
|
if (!foundSurface) {
|
||||||
// if there isn't any, focus the last window
|
// if there isn't any, focus the last window
|
||||||
|
@ -226,13 +232,16 @@ void Events::listener_unmapLayerSurface(void* owner, void* data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width, layersurface->geometry.height};
|
wlr_box geomFixed = {layersurface->geometry.x + PMONITOR->vecPosition.x, layersurface->geometry.y + PMONITOR->vecPosition.y, layersurface->geometry.width,
|
||||||
|
layersurface->geometry.height};
|
||||||
g_pHyprRenderer->damageBox(&geomFixed);
|
g_pHyprRenderer->damageBox(&geomFixed);
|
||||||
|
|
||||||
geomFixed = {layersurface->geometry.x + (int)PMONITOR->vecPosition.x, layersurface->geometry.y + (int)PMONITOR->vecPosition.y, (int)layersurface->layerSurface->surface->current.width, (int)layersurface->layerSurface->surface->current.height};
|
geomFixed = {layersurface->geometry.x + (int)PMONITOR->vecPosition.x, layersurface->geometry.y + (int)PMONITOR->vecPosition.y,
|
||||||
|
(int)layersurface->layerSurface->surface->current.width, (int)layersurface->layerSurface->surface->current.height};
|
||||||
g_pHyprRenderer->damageBox(&geomFixed);
|
g_pHyprRenderer->damageBox(&geomFixed);
|
||||||
|
|
||||||
geomFixed = {layersurface->geometry.x, layersurface->geometry.y, (int)layersurface->layerSurface->surface->current.width, (int)layersurface->layerSurface->surface->current.height};
|
geomFixed = {layersurface->geometry.x, layersurface->geometry.y, (int)layersurface->layerSurface->surface->current.width,
|
||||||
|
(int)layersurface->layerSurface->surface->current.height};
|
||||||
layersurface->geometry = geomFixed; // because the surface can overflow... for some reason?
|
layersurface->geometry = geomFixed; // because the surface can overflow... for some reason?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +257,7 @@ void Events::listener_commitLayerSurface(void* owner, void* data) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)
|
if (layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)
|
||||||
g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR); // so that blur is recalc'd
|
g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR); // so that blur is recalc'd
|
||||||
|
|
||||||
wlr_box geomFixed = {layersurface->geometry.x, layersurface->geometry.y, layersurface->geometry.width, layersurface->geometry.height};
|
wlr_box geomFixed = {layersurface->geometry.x, layersurface->geometry.y, layersurface->geometry.width, layersurface->geometry.height};
|
||||||
g_pHyprRenderer->damageBox(&geomFixed);
|
g_pHyprRenderer->damageBox(&geomFixed);
|
||||||
|
@ -265,7 +274,7 @@ void Events::listener_commitLayerSurface(void* owner, void* data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layersurface->monitorID = PMONITOR->ID;
|
layersurface->monitorID = PMONITOR->ID;
|
||||||
PMONITOR->scheduledRecalc = true;
|
PMONITOR->scheduledRecalc = true;
|
||||||
g_pHyprRenderer->arrangeLayersForMonitor(POLDMON->ID);
|
g_pHyprRenderer->arrangeLayersForMonitor(POLDMON->ID);
|
||||||
}
|
}
|
||||||
|
@ -284,7 +293,7 @@ void Events::listener_commitLayerSurface(void* owner, void* data) {
|
||||||
layersurface->layer = layersurface->layerSurface->current.layer;
|
layersurface->layer = layersurface->layerSurface->current.layer;
|
||||||
|
|
||||||
if (layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)
|
if (layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND || layersurface->layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM)
|
||||||
g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR); // so that blur is recalc'd
|
g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR); // so that blur is recalc'd
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID);
|
g_pHyprRenderer->arrangeLayersForMonitor(PMONITOR->ID);
|
||||||
|
@ -295,7 +304,8 @@ void Events::listener_commitLayerSurface(void* owner, void* data) {
|
||||||
layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y);
|
layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y);
|
||||||
|
|
||||||
// update geom if it changed
|
// update geom if it changed
|
||||||
layersurface->geometry = {layersurface->geometry.x, layersurface->geometry.y, layersurface->layerSurface->surface->current.width, layersurface->layerSurface->surface->current.height};
|
layersurface->geometry = {layersurface->geometry.x, layersurface->geometry.y, layersurface->layerSurface->surface->current.width,
|
||||||
|
layersurface->layerSurface->surface->current.height};
|
||||||
|
|
||||||
g_pHyprRenderer->damageSurface(layersurface->layerSurface->surface, layersurface->position.x, layersurface->position.y);
|
g_pHyprRenderer->damageSurface(layersurface->layerSurface->surface, layersurface->position.x, layersurface->position.y);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ void Events::listener_outputMgrTest(wl_listener* listener, void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_leaseRequest(wl_listener* listener, void* data) {
|
void Events::listener_leaseRequest(wl_listener* listener, void* data) {
|
||||||
const auto REQUEST = (wlr_drm_lease_request_v1*)data;
|
const auto REQUEST = (wlr_drm_lease_request_v1*)data;
|
||||||
struct wlr_drm_lease_v1* lease = wlr_drm_lease_request_v1_grant(REQUEST);
|
struct wlr_drm_lease_v1* lease = wlr_drm_lease_request_v1_grant(REQUEST);
|
||||||
if (!lease) {
|
if (!lease) {
|
||||||
Debug::log(ERR, "Failed to grant lease request!");
|
Debug::log(ERR, "Failed to grant lease request!");
|
||||||
wlr_drm_lease_request_v1_reject(REQUEST);
|
wlr_drm_lease_request_v1_reject(REQUEST);
|
||||||
|
@ -47,7 +47,7 @@ void Events::listener_requestSetSel(wl_listener* listener, void* data) {
|
||||||
void Events::listener_readyXWayland(wl_listener* listener, void* data) {
|
void Events::listener_readyXWayland(wl_listener* listener, void* data) {
|
||||||
#ifndef NO_XWAYLAND
|
#ifndef NO_XWAYLAND
|
||||||
const auto XCBCONNECTION = xcb_connect(g_pXWaylandManager->m_sWLRXWayland->display_name, NULL);
|
const auto XCBCONNECTION = xcb_connect(g_pXWaylandManager->m_sWLRXWayland->display_name, NULL);
|
||||||
const auto ERR = xcb_connection_has_error(XCBCONNECTION);
|
const auto ERR = xcb_connection_has_error(XCBCONNECTION);
|
||||||
if (ERR) {
|
if (ERR) {
|
||||||
Debug::log(LogLevel::ERR, "XWayland -> xcb_connection_has_error failed with %i", ERR);
|
Debug::log(LogLevel::ERR, "XWayland -> xcb_connection_has_error failed with %i", ERR);
|
||||||
return;
|
return;
|
||||||
|
@ -55,7 +55,7 @@ void Events::listener_readyXWayland(wl_listener* listener, void* data) {
|
||||||
|
|
||||||
for (auto& ATOM : HYPRATOMS) {
|
for (auto& ATOM : HYPRATOMS) {
|
||||||
xcb_intern_atom_cookie_t cookie = xcb_intern_atom(XCBCONNECTION, 0, ATOM.first.length(), ATOM.first.c_str());
|
xcb_intern_atom_cookie_t cookie = xcb_intern_atom(XCBCONNECTION, 0, ATOM.first.length(), ATOM.first.c_str());
|
||||||
xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(XCBCONNECTION, cookie, NULL);
|
xcb_intern_atom_reply_t* reply = xcb_intern_atom_reply(XCBCONNECTION, cookie, NULL);
|
||||||
|
|
||||||
if (!reply) {
|
if (!reply) {
|
||||||
Debug::log(LogLevel::ERR, "XWayland -> Atom failed: %s", ATOM.first.c_str());
|
Debug::log(LogLevel::ERR, "XWayland -> Atom failed: %s", ATOM.first.c_str());
|
||||||
|
@ -69,7 +69,8 @@ void Events::listener_readyXWayland(wl_listener* listener, void* data) {
|
||||||
|
|
||||||
const auto XCURSOR = wlr_xcursor_manager_get_xcursor(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", 1);
|
const auto XCURSOR = wlr_xcursor_manager_get_xcursor(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", 1);
|
||||||
if (XCURSOR) {
|
if (XCURSOR) {
|
||||||
wlr_xwayland_set_cursor(g_pXWaylandManager->m_sWLRXWayland, XCURSOR->images[0]->buffer, XCURSOR->images[0]->width * 4, XCURSOR->images[0]->width, XCURSOR->images[0]->height, XCURSOR->images[0]->hotspot_x, XCURSOR->images[0]->hotspot_y);
|
wlr_xwayland_set_cursor(g_pXWaylandManager->m_sWLRXWayland, XCURSOR->images[0]->buffer, XCURSOR->images[0]->width * 4, XCURSOR->images[0]->width,
|
||||||
|
XCURSOR->images[0]->height, XCURSOR->images[0]->hotspot_x, XCURSOR->images[0]->hotspot_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
xcb_disconnect(XCBCONNECTION);
|
xcb_disconnect(XCBCONNECTION);
|
||||||
|
@ -107,15 +108,16 @@ void Events::listener_startDrag(wl_listener* listener, void* data) {
|
||||||
Debug::log(LOG, "Drag started with an icon %x", wlrDrag->icon);
|
Debug::log(LOG, "Drag started with an icon %x", wlrDrag->icon);
|
||||||
|
|
||||||
g_pInputManager->m_sDrag.dragIcon = wlrDrag->icon;
|
g_pInputManager->m_sDrag.dragIcon = wlrDrag->icon;
|
||||||
wlrDrag->icon->data = g_pInputManager->m_sDrag.dragIcon;
|
wlrDrag->icon->data = g_pInputManager->m_sDrag.dragIcon;
|
||||||
|
|
||||||
g_pInputManager->m_sDrag.hyprListener_mapIcon.initCallback(&wlrDrag->icon->events.map, &Events::listener_mapDragIcon, &g_pInputManager->m_sDrag, "DragIcon");
|
g_pInputManager->m_sDrag.hyprListener_mapIcon.initCallback(&wlrDrag->icon->events.map, &Events::listener_mapDragIcon, &g_pInputManager->m_sDrag, "DragIcon");
|
||||||
g_pInputManager->m_sDrag.hyprListener_unmapIcon.initCallback(&wlrDrag->icon->events.unmap, &Events::listener_unmapDragIcon, &g_pInputManager->m_sDrag, "DragIcon");
|
g_pInputManager->m_sDrag.hyprListener_unmapIcon.initCallback(&wlrDrag->icon->events.unmap, &Events::listener_unmapDragIcon, &g_pInputManager->m_sDrag, "DragIcon");
|
||||||
g_pInputManager->m_sDrag.hyprListener_destroyIcon.initCallback(&wlrDrag->icon->events.destroy, &Events::listener_destroyDragIcon, &g_pInputManager->m_sDrag, "DragIcon");
|
g_pInputManager->m_sDrag.hyprListener_destroyIcon.initCallback(&wlrDrag->icon->events.destroy, &Events::listener_destroyDragIcon, &g_pInputManager->m_sDrag, "DragIcon");
|
||||||
g_pInputManager->m_sDrag.hyprListener_commitIcon.initCallback(&wlrDrag->icon->surface->events.commit, &Events::listener_commitDragIcon, &g_pInputManager->m_sDrag, "DragIcon");
|
g_pInputManager->m_sDrag.hyprListener_commitIcon.initCallback(&wlrDrag->icon->surface->events.commit, &Events::listener_commitDragIcon, &g_pInputManager->m_sDrag,
|
||||||
|
"DragIcon");
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto *const PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue;
|
static auto* const PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue;
|
||||||
|
|
||||||
if (*PFOLLOWONDND)
|
if (*PFOLLOWONDND)
|
||||||
g_pInputManager->m_pFollowOnDnDBegin = g_pCompositor->m_pLastWindow;
|
g_pInputManager->m_pFollowOnDnDBegin = g_pCompositor->m_pLastWindow;
|
||||||
|
@ -126,12 +128,13 @@ void Events::listener_startDrag(wl_listener* listener, void* data) {
|
||||||
void Events::listener_destroyDrag(void* owner, void* data) {
|
void Events::listener_destroyDrag(void* owner, void* data) {
|
||||||
Debug::log(LOG, "Drag destroyed.");
|
Debug::log(LOG, "Drag destroyed.");
|
||||||
|
|
||||||
static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
||||||
|
|
||||||
if (g_pInputManager->m_sDrag.drag && g_pInputManager->m_sDrag.dragIcon && g_pInputManager->m_sDrag.dragIcon->surface)
|
if (g_pInputManager->m_sDrag.drag && g_pInputManager->m_sDrag.dragIcon && g_pInputManager->m_sDrag.dragIcon->surface)
|
||||||
g_pHyprRenderer->damageBox(g_pInputManager->m_sDrag.pos.x - 2, g_pInputManager->m_sDrag.pos.y - 2, g_pInputManager->m_sDrag.dragIcon->surface->current.width + 4, g_pInputManager->m_sDrag.dragIcon->surface->current.height + 4);
|
g_pHyprRenderer->damageBox(g_pInputManager->m_sDrag.pos.x - 2, g_pInputManager->m_sDrag.pos.y - 2, g_pInputManager->m_sDrag.dragIcon->surface->current.width + 4,
|
||||||
|
g_pInputManager->m_sDrag.dragIcon->surface->current.height + 4);
|
||||||
|
|
||||||
g_pInputManager->m_sDrag.drag = nullptr;
|
g_pInputManager->m_sDrag.drag = nullptr;
|
||||||
g_pInputManager->m_sDrag.dragIcon = nullptr;
|
g_pInputManager->m_sDrag.dragIcon = nullptr;
|
||||||
g_pInputManager->m_sDrag.hyprListener_destroy.removeCallback();
|
g_pInputManager->m_sDrag.hyprListener_destroy.removeCallback();
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
CMonitor* pMostHzMonitor = nullptr;
|
CMonitor* pMostHzMonitor = nullptr;
|
||||||
|
|
||||||
void Events::listener_change(wl_listener* listener, void* data) {
|
void Events::listener_change(wl_listener* listener, void* data) {
|
||||||
// layout got changed, let's update monitors.
|
// layout got changed, let's update monitors.
|
||||||
const auto CONFIG = wlr_output_configuration_v1_create();
|
const auto CONFIG = wlr_output_configuration_v1_create();
|
||||||
|
|
||||||
|
@ -29,14 +29,14 @@ void Events::listener_change(wl_listener* listener, void* data) {
|
||||||
wlr_output_layout_get_box(g_pCompositor->m_sWLROutputLayout, m->output, &BOX);
|
wlr_output_layout_get_box(g_pCompositor->m_sWLROutputLayout, m->output, &BOX);
|
||||||
|
|
||||||
//m->vecSize.x = BOX.width;
|
//m->vecSize.x = BOX.width;
|
||||||
// m->vecSize.y = BOX.height;
|
// m->vecSize.y = BOX.height;
|
||||||
m->vecPosition.x = BOX.x;
|
m->vecPosition.x = BOX.x;
|
||||||
m->vecPosition.y = BOX.y;
|
m->vecPosition.y = BOX.y;
|
||||||
|
|
||||||
CONFIGHEAD->state.enabled = m->output->enabled;
|
CONFIGHEAD->state.enabled = m->output->enabled;
|
||||||
CONFIGHEAD->state.mode = m->output->current_mode;
|
CONFIGHEAD->state.mode = m->output->current_mode;
|
||||||
CONFIGHEAD->state.x = m->vecPosition.x;
|
CONFIGHEAD->state.x = m->vecPosition.x;
|
||||||
CONFIGHEAD->state.y = m->vecPosition.y;
|
CONFIGHEAD->state.y = m->vecPosition.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_output_manager_v1_set_configuration(g_pCompositor->m_sWLROutputMgr, CONFIG);
|
wlr_output_manager_v1_set_configuration(g_pCompositor->m_sWLROutputMgr, CONFIG);
|
||||||
|
@ -75,7 +75,7 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
|
||||||
|
|
||||||
const auto PNEWMONITOR = PNEWMONITORWRAP->get();
|
const auto PNEWMONITOR = PNEWMONITORWRAP->get();
|
||||||
|
|
||||||
PNEWMONITOR->output = OUTPUT;
|
PNEWMONITOR->output = OUTPUT;
|
||||||
PNEWMONITOR->m_pThisWrap = PNEWMONITORWRAP;
|
PNEWMONITOR->m_pThisWrap = PNEWMONITORWRAP;
|
||||||
|
|
||||||
PNEWMONITOR->onConnect(false);
|
PNEWMONITOR->onConnect(false);
|
||||||
|
@ -86,7 +86,7 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
|
||||||
// ready to process cuz we have a monitor
|
// ready to process cuz we have a monitor
|
||||||
if (PNEWMONITOR->m_bEnabled) {
|
if (PNEWMONITOR->m_bEnabled) {
|
||||||
g_pCompositor->m_bReadyToProcess = true;
|
g_pCompositor->m_bReadyToProcess = true;
|
||||||
g_pCompositor->m_bUnsafeState = false;
|
g_pCompositor->m_bUnsafeState = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pConfigManager->m_bWantsMonitorReload = true;
|
g_pConfigManager->m_bWantsMonitorReload = true;
|
||||||
|
@ -104,17 +104,17 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
||||||
if (!PMONITOR->m_bEnabled)
|
if (!PMONITOR->m_bEnabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static std::chrono::high_resolution_clock::time_point startRender = std::chrono::high_resolution_clock::now();
|
static std::chrono::high_resolution_clock::time_point startRender = std::chrono::high_resolution_clock::now();
|
||||||
static std::chrono::high_resolution_clock::time_point startRenderOverlay = std::chrono::high_resolution_clock::now();
|
static std::chrono::high_resolution_clock::time_point startRenderOverlay = std::chrono::high_resolution_clock::now();
|
||||||
static std::chrono::high_resolution_clock::time_point endRenderOverlay = std::chrono::high_resolution_clock::now();
|
static std::chrono::high_resolution_clock::time_point endRenderOverlay = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
static auto *const PDEBUGOVERLAY = &g_pConfigManager->getConfigValuePtr("debug:overlay")->intValue;
|
static auto* const PDEBUGOVERLAY = &g_pConfigManager->getConfigValuePtr("debug:overlay")->intValue;
|
||||||
static auto *const PDAMAGETRACKINGMODE = &g_pConfigManager->getConfigValuePtr("debug:damage_tracking")->intValue;
|
static auto* const PDAMAGETRACKINGMODE = &g_pConfigManager->getConfigValuePtr("debug:damage_tracking")->intValue;
|
||||||
static auto *const PDAMAGEBLINK = &g_pConfigManager->getConfigValuePtr("debug:damage_blink")->intValue;
|
static auto* const PDAMAGEBLINK = &g_pConfigManager->getConfigValuePtr("debug:damage_blink")->intValue;
|
||||||
static auto *const PNOVFR = &g_pConfigManager->getConfigValuePtr("misc:no_vfr")->intValue;
|
static auto* const PNOVFR = &g_pConfigManager->getConfigValuePtr("misc:no_vfr")->intValue;
|
||||||
static auto *const PNODIRECTSCANOUT = &g_pConfigManager->getConfigValuePtr("misc:no_direct_scanout")->intValue;
|
static auto* const PNODIRECTSCANOUT = &g_pConfigManager->getConfigValuePtr("misc:no_direct_scanout")->intValue;
|
||||||
|
|
||||||
static int damageBlinkCleanup = 0; // because double-buffered
|
static int damageBlinkCleanup = 0; // because double-buffered
|
||||||
|
|
||||||
if (!*PDAMAGEBLINK)
|
if (!*PDAMAGEBLINK)
|
||||||
damageBlinkCleanup = 0;
|
damageBlinkCleanup = 0;
|
||||||
|
@ -140,16 +140,17 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// checks //
|
// checks //
|
||||||
if (PMONITOR->ID == pMostHzMonitor->ID || !*PNOVFR) { // unfortunately with VFR we don't have the guarantee mostHz is going to be updated all the time, so we have to ignore that
|
if (PMONITOR->ID == pMostHzMonitor->ID ||
|
||||||
|
!*PNOVFR) { // unfortunately with VFR we don't have the guarantee mostHz is going to be updated all the time, so we have to ignore that
|
||||||
g_pCompositor->sanityCheckWorkspaces();
|
g_pCompositor->sanityCheckWorkspaces();
|
||||||
g_pAnimationManager->tick();
|
g_pAnimationManager->tick();
|
||||||
|
|
||||||
g_pConfigManager->dispatchExecOnce(); // We exec-once when at least one monitor starts refreshing, meaning stuff has init'd
|
g_pConfigManager->dispatchExecOnce(); // We exec-once when at least one monitor starts refreshing, meaning stuff has init'd
|
||||||
|
|
||||||
if (g_pConfigManager->m_bWantsMonitorReload)
|
if (g_pConfigManager->m_bWantsMonitorReload)
|
||||||
g_pConfigManager->performMonitorReload();
|
g_pConfigManager->performMonitorReload();
|
||||||
|
|
||||||
g_pHyprRenderer->ensureCursorRenderingMode(); // so that the cursor gets hidden/shown if the user requested timeouts
|
g_pHyprRenderer->ensureCursorRenderingMode(); // so that the cursor gets hidden/shown if the user requested timeouts
|
||||||
}
|
}
|
||||||
// //
|
// //
|
||||||
|
|
||||||
|
@ -173,7 +174,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
||||||
|
|
||||||
// check the damage
|
// check the damage
|
||||||
pixman_region32_t damage;
|
pixman_region32_t damage;
|
||||||
bool hasChanged;
|
bool hasChanged;
|
||||||
pixman_region32_init(&damage);
|
pixman_region32_init(&damage);
|
||||||
|
|
||||||
if (*PDAMAGETRACKINGMODE == -1) {
|
if (*PDAMAGETRACKINGMODE == -1) {
|
||||||
|
@ -183,7 +184,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
||||||
|
|
||||||
g_pHyprOpenGL->preRender(PMONITOR);
|
g_pHyprOpenGL->preRender(PMONITOR);
|
||||||
|
|
||||||
if (!wlr_output_damage_attach_render(PMONITOR->damage, &hasChanged, &damage)){
|
if (!wlr_output_damage_attach_render(PMONITOR->damage, &hasChanged, &damage)) {
|
||||||
Debug::log(ERR, "Couldn't attach render to display %s ???", PMONITOR->szName.c_str());
|
Debug::log(ERR, "Couldn't attach render to display %s ???", PMONITOR->szName.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -202,24 +203,25 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we have no tracking or full tracking, invalidate the entire monitor
|
// if we have no tracking or full tracking, invalidate the entire monitor
|
||||||
if (*PDAMAGETRACKINGMODE == DAMAGE_TRACKING_NONE || *PDAMAGETRACKINGMODE == DAMAGE_TRACKING_MONITOR || PMONITOR->forceFullFrames > 0 || damageBlinkCleanup > 0 || PMONITOR->isMirror() /* why??? */) {
|
if (*PDAMAGETRACKINGMODE == DAMAGE_TRACKING_NONE || *PDAMAGETRACKINGMODE == DAMAGE_TRACKING_MONITOR || PMONITOR->forceFullFrames > 0 || damageBlinkCleanup > 0 ||
|
||||||
|
PMONITOR->isMirror() /* why??? */) {
|
||||||
pixman_region32_union_rect(&damage, &damage, 0, 0, (int)PMONITOR->vecTransformedSize.x * 10, (int)PMONITOR->vecTransformedSize.y * 10); // wot?
|
pixman_region32_union_rect(&damage, &damage, 0, 0, (int)PMONITOR->vecTransformedSize.x * 10, (int)PMONITOR->vecTransformedSize.y * 10); // wot?
|
||||||
|
|
||||||
pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage);
|
pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage);
|
||||||
} else {
|
} else {
|
||||||
static auto *const PBLURENABLED = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue;
|
static auto* const PBLURENABLED = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue;
|
||||||
|
|
||||||
// if we use blur we need to expand the damage for proper blurring
|
// if we use blur we need to expand the damage for proper blurring
|
||||||
if (*PBLURENABLED == 1) {
|
if (*PBLURENABLED == 1) {
|
||||||
// TODO: can this be optimized?
|
// TODO: can this be optimized?
|
||||||
static auto *const PBLURSIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_size")->intValue;
|
static auto* const PBLURSIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_size")->intValue;
|
||||||
static auto *const PBLURPASSES = &g_pConfigManager->getConfigValuePtr("decoration:blur_passes")->intValue;
|
static auto* const PBLURPASSES = &g_pConfigManager->getConfigValuePtr("decoration:blur_passes")->intValue;
|
||||||
const auto BLURRADIUS = *PBLURSIZE * pow(2, *PBLURPASSES); // is this 2^pass? I don't know but it works... I think.
|
const auto BLURRADIUS = *PBLURSIZE * pow(2, *PBLURPASSES); // is this 2^pass? I don't know but it works... I think.
|
||||||
|
|
||||||
pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage);
|
pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage);
|
||||||
|
|
||||||
// now, prep the damage, get the extended damage region
|
// now, prep the damage, get the extended damage region
|
||||||
wlr_region_expand(&damage, &damage, BLURRADIUS); // expand for proper blurring
|
wlr_region_expand(&damage, &damage, BLURRADIUS); // expand for proper blurring
|
||||||
} else {
|
} else {
|
||||||
pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage);
|
pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage);
|
||||||
}
|
}
|
||||||
|
@ -231,7 +233,6 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
||||||
PMONITOR->forceFullFrames = 0;
|
PMONITOR->forceFullFrames = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: this is getting called with extents being 0,0,0,0 should it be?
|
// TODO: this is getting called with extents being 0,0,0,0 should it be?
|
||||||
// potentially can save on resources.
|
// potentially can save on resources.
|
||||||
|
|
||||||
|
@ -241,7 +242,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
||||||
g_pHyprOpenGL->renderMirrored();
|
g_pHyprOpenGL->renderMirrored();
|
||||||
} else {
|
} else {
|
||||||
g_pHyprOpenGL->clear(CColor(17, 17, 17, 255));
|
g_pHyprOpenGL->clear(CColor(17, 17, 17, 255));
|
||||||
g_pHyprOpenGL->clearWithTex(); // will apply the hypr "wallpaper"
|
g_pHyprOpenGL->clearWithTex(); // will apply the hypr "wallpaper"
|
||||||
|
|
||||||
g_pHyprRenderer->renderAllClientsForMonitor(PMONITOR->ID, &now);
|
g_pHyprRenderer->renderAllClientsForMonitor(PMONITOR->ID, &now);
|
||||||
|
|
||||||
|
@ -318,7 +319,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
||||||
void Events::listener_monitorDestroy(void* owner, void* data) {
|
void Events::listener_monitorDestroy(void* owner, void* data) {
|
||||||
const auto OUTPUT = (wlr_output*)data;
|
const auto OUTPUT = (wlr_output*)data;
|
||||||
|
|
||||||
CMonitor* pMonitor = nullptr;
|
CMonitor* pMonitor = nullptr;
|
||||||
|
|
||||||
for (auto& m : g_pCompositor->m_vRealMonitors) {
|
for (auto& m : g_pCompositor->m_vRealMonitors) {
|
||||||
if (m->output == OUTPUT) {
|
if (m->output == OUTPUT) {
|
||||||
|
@ -338,16 +339,16 @@ void Events::listener_monitorDestroy(void* owner, void* data) {
|
||||||
if (!g_pCompositor->m_bUnsafeState) {
|
if (!g_pCompositor->m_bUnsafeState) {
|
||||||
Debug::log(LOG, "Removing monitor %s from realMonitors", pMonitor->output->name);
|
Debug::log(LOG, "Removing monitor %s from realMonitors", pMonitor->output->name);
|
||||||
|
|
||||||
g_pCompositor->m_vRealMonitors.erase(std::remove_if(g_pCompositor->m_vRealMonitors.begin(), g_pCompositor->m_vRealMonitors.end(), [&](std::shared_ptr<CMonitor>& el) { return el.get() == pMonitor; }));
|
std::erase_if(g_pCompositor->m_vRealMonitors, [&](std::shared_ptr<CMonitor>& el) { return el.get() == pMonitor; });
|
||||||
|
|
||||||
if (pMostHzMonitor == pMonitor) {
|
if (pMostHzMonitor == pMonitor) {
|
||||||
int mostHz = 0;
|
int mostHz = 0;
|
||||||
CMonitor* pMonitorMostHz = nullptr;
|
CMonitor* pMonitorMostHz = nullptr;
|
||||||
|
|
||||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||||
if (m->refreshRate > mostHz) {
|
if (m->refreshRate > mostHz) {
|
||||||
pMonitorMostHz = m.get();
|
pMonitorMostHz = m.get();
|
||||||
mostHz = m->refreshRate;
|
mostHz = m->refreshRate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,7 +359,7 @@ void Events::listener_monitorDestroy(void* owner, void* data) {
|
||||||
|
|
||||||
void Events::listener_monitorStateRequest(void* owner, void* data) {
|
void Events::listener_monitorStateRequest(void* owner, void* data) {
|
||||||
const auto PMONITOR = (CMonitor*)owner;
|
const auto PMONITOR = (CMonitor*)owner;
|
||||||
const auto E = (wlr_output_event_request_state*)data;
|
const auto E = (wlr_output_event_request_state*)data;
|
||||||
|
|
||||||
wlr_output_commit_state(PMONITOR->output, E->state);
|
wlr_output_commit_state(PMONITOR->output, E->state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
// --------------------------------------------- //
|
// --------------------------------------------- //
|
||||||
|
|
||||||
void addPopupGlobalCoords(void* pPopup, int* x, int* y) {
|
void addPopupGlobalCoords(void* pPopup, int* x, int* y) {
|
||||||
SXDGPopup *const PPOPUP = (SXDGPopup*)pPopup;
|
SXDGPopup* const PPOPUP = (SXDGPopup*)pPopup;
|
||||||
|
|
||||||
auto curPopup = PPOPUP;
|
auto curPopup = PPOPUP;
|
||||||
|
|
||||||
int px = 0;
|
int px = 0;
|
||||||
int py = 0;
|
int py = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
px += curPopup->popup->current.geometry.x;
|
px += curPopup->popup->current.geometry.x;
|
||||||
|
@ -63,13 +63,14 @@ void createNewPopup(wlr_xdg_popup* popup, SXDGPopup* pHyprPopup) {
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->m_pLastMonitor;
|
const auto PMONITOR = g_pCompositor->m_pLastMonitor;
|
||||||
|
|
||||||
wlr_box box = {.x = PMONITOR->vecPosition.x - pHyprPopup->lx, .y = PMONITOR->vecPosition.y - pHyprPopup->ly, .width = PMONITOR->vecSize.x, .height = PMONITOR->vecSize.y};
|
wlr_box box = {.x = PMONITOR->vecPosition.x - pHyprPopup->lx, .y = PMONITOR->vecPosition.y - pHyprPopup->ly, .width = PMONITOR->vecSize.x, .height = PMONITOR->vecSize.y};
|
||||||
|
|
||||||
wlr_xdg_popup_unconstrain_from_box(popup, &box);
|
wlr_xdg_popup_unconstrain_from_box(popup, &box);
|
||||||
|
|
||||||
pHyprPopup->monitor = PMONITOR;
|
pHyprPopup->monitor = PMONITOR;
|
||||||
|
|
||||||
Debug::log(LOG, "Popup: Unconstrained from lx ly: %f %f, pHyprPopup lx ly: %f %f", (float)PMONITOR->vecPosition.x, (float)PMONITOR->vecPosition.y, (float)pHyprPopup->lx, (float)pHyprPopup->ly);
|
Debug::log(LOG, "Popup: Unconstrained from lx ly: %f %f, pHyprPopup lx ly: %f %f", (float)PMONITOR->vecPosition.x, (float)PMONITOR->vecPosition.y, (float)pHyprPopup->lx,
|
||||||
|
(float)pHyprPopup->ly);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_newPopup(void* owner, void* data) {
|
void Events::listener_newPopup(void* owner, void* data) {
|
||||||
|
@ -85,9 +86,9 @@ void Events::listener_newPopup(void* owner, void* data) {
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(layersurface->monitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(layersurface->monitorID);
|
||||||
|
|
||||||
PNEWPOPUP->popup = WLRPOPUP;
|
PNEWPOPUP->popup = WLRPOPUP;
|
||||||
PNEWPOPUP->lx = layersurface->position.x;
|
PNEWPOPUP->lx = layersurface->position.x;
|
||||||
PNEWPOPUP->ly = layersurface->position.y;
|
PNEWPOPUP->ly = layersurface->position.y;
|
||||||
PNEWPOPUP->monitor = PMONITOR;
|
PNEWPOPUP->monitor = PMONITOR;
|
||||||
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
||||||
}
|
}
|
||||||
|
@ -108,11 +109,11 @@ void Events::listener_newPopupXDG(void* owner, void* data) {
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||||
|
|
||||||
PNEWPOPUP->popup = WLRPOPUP;
|
PNEWPOPUP->popup = WLRPOPUP;
|
||||||
PNEWPOPUP->lx = PWINDOW->m_vRealPosition.goalv().x;
|
PNEWPOPUP->lx = PWINDOW->m_vRealPosition.goalv().x;
|
||||||
PNEWPOPUP->ly = PWINDOW->m_vRealPosition.goalv().y;
|
PNEWPOPUP->ly = PWINDOW->m_vRealPosition.goalv().y;
|
||||||
PNEWPOPUP->parentWindow = PWINDOW;
|
PNEWPOPUP->parentWindow = PWINDOW;
|
||||||
PNEWPOPUP->monitor = PMONITOR;
|
PNEWPOPUP->monitor = PMONITOR;
|
||||||
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,12 +131,12 @@ void Events::listener_newPopupFromPopupXDG(void* owner, void* data) {
|
||||||
|
|
||||||
const auto PNEWPOPUP = g_pCompositor->m_vXDGPopups.emplace_back(std::make_unique<SXDGPopup>()).get();
|
const auto PNEWPOPUP = g_pCompositor->m_vXDGPopups.emplace_back(std::make_unique<SXDGPopup>()).get();
|
||||||
|
|
||||||
PNEWPOPUP->popup = WLRPOPUP;
|
PNEWPOPUP->popup = WLRPOPUP;
|
||||||
PNEWPOPUP->parentPopup = PPOPUP;
|
PNEWPOPUP->parentPopup = PPOPUP;
|
||||||
PNEWPOPUP->lx = PPOPUP->lx;
|
PNEWPOPUP->lx = PPOPUP->lx;
|
||||||
PNEWPOPUP->ly = PPOPUP->ly;
|
PNEWPOPUP->ly = PPOPUP->ly;
|
||||||
PNEWPOPUP->parentWindow = PPOPUP->parentWindow;
|
PNEWPOPUP->parentWindow = PPOPUP->parentWindow;
|
||||||
PNEWPOPUP->monitor = PPOPUP->monitor;
|
PNEWPOPUP->monitor = PPOPUP->monitor;
|
||||||
|
|
||||||
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +183,7 @@ void Events::listener_unmapPopupXDG(void* owner, void* data) {
|
||||||
void Events::listener_commitPopupXDG(void* owner, void* data) {
|
void Events::listener_commitPopupXDG(void* owner, void* data) {
|
||||||
SXDGPopup* PPOPUP = (SXDGPopup*)owner;
|
SXDGPopup* PPOPUP = (SXDGPopup*)owner;
|
||||||
|
|
||||||
int lx = 0, ly = 0;
|
int lx = 0, ly = 0;
|
||||||
addPopupGlobalCoords(PPOPUP, &lx, &ly);
|
addPopupGlobalCoords(PPOPUP, &lx, &ly);
|
||||||
|
|
||||||
g_pHyprRenderer->damageSurface(PPOPUP->popup->base->surface, lx, ly);
|
g_pHyprRenderer->damageSurface(PPOPUP->popup->base->surface, lx, ly);
|
||||||
|
@ -200,5 +201,5 @@ void Events::listener_destroyPopupXDG(void* owner, void* data) {
|
||||||
PPOPUP->pSurfaceTree = nullptr;
|
PPOPUP->pSurfaceTree = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pCompositor->m_vXDGPopups.erase(std::remove_if(g_pCompositor->m_vXDGPopups.begin(), g_pCompositor->m_vXDGPopups.end(), [&](std::unique_ptr<SXDGPopup>& el) { return el.get() == PPOPUP; }));
|
std::erase_if(g_pCompositor->m_vXDGPopups, [&](std::unique_ptr<SXDGPopup>& el) { return el.get() == PPOPUP; });
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ void addViewCoords(void* pWindow, int* x, int* y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAnimToMove(void* data) {
|
void setAnimToMove(void* data) {
|
||||||
auto *const PANIMCFG = g_pConfigManager->getAnimationPropertyConfig("windowsMove");
|
auto* const PANIMCFG = g_pConfigManager->getAnimationPropertyConfig("windowsMove");
|
||||||
|
|
||||||
CAnimatedVariable* animvar = (CAnimatedVariable*)data;
|
CAnimatedVariable* animvar = (CAnimatedVariable*)data;
|
||||||
|
|
||||||
|
@ -38,23 +38,24 @@ void setAnimToMove(void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_mapWindow(void* owner, void* data) {
|
void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
CWindow* PWINDOW = (CWindow*)owner;
|
CWindow* PWINDOW = (CWindow*)owner;
|
||||||
|
|
||||||
static auto *const PINACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:inactive_opacity")->floatValue;
|
static auto* const PINACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:inactive_opacity")->floatValue;
|
||||||
static auto *const PACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:active_opacity")->floatValue;
|
static auto* const PACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:active_opacity")->floatValue;
|
||||||
static auto *const PDIMSTRENGTH = &g_pConfigManager->getConfigValuePtr("decoration:dim_strength")->floatValue;
|
static auto* const PDIMSTRENGTH = &g_pConfigManager->getConfigValuePtr("decoration:dim_strength")->floatValue;
|
||||||
static auto *const PSWALLOW = &g_pConfigManager->getConfigValuePtr("misc:enable_swallow")->intValue;
|
static auto* const PSWALLOW = &g_pConfigManager->getConfigValuePtr("misc:enable_swallow")->intValue;
|
||||||
static auto *const PSWALLOWREGEX = &g_pConfigManager->getConfigValuePtr("misc:swallow_regex")->strValue;
|
static auto* const PSWALLOWREGEX = &g_pConfigManager->getConfigValuePtr("misc:swallow_regex")->strValue;
|
||||||
|
|
||||||
auto PMONITOR = g_pCompositor->m_pLastMonitor;
|
auto PMONITOR = g_pCompositor->m_pLastMonitor;
|
||||||
const auto PWORKSPACE = PMONITOR->specialWorkspaceID ? g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID) : g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
const auto PWORKSPACE =
|
||||||
PWINDOW->m_iMonitorID = PMONITOR->ID;
|
PMONITOR->specialWorkspaceID ? g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID) : g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
||||||
PWINDOW->m_bMappedX11 = true;
|
PWINDOW->m_iMonitorID = PMONITOR->ID;
|
||||||
PWINDOW->m_iWorkspaceID = PMONITOR->specialWorkspaceID ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace;
|
PWINDOW->m_bMappedX11 = true;
|
||||||
PWINDOW->m_bIsMapped = true;
|
PWINDOW->m_iWorkspaceID = PMONITOR->specialWorkspaceID ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace;
|
||||||
|
PWINDOW->m_bIsMapped = true;
|
||||||
PWINDOW->m_bReadyToDelete = false;
|
PWINDOW->m_bReadyToDelete = false;
|
||||||
PWINDOW->m_bFadingOut = false;
|
PWINDOW->m_bFadingOut = false;
|
||||||
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
|
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
|
||||||
|
|
||||||
if (PWINDOW->m_iX11Type == 2)
|
if (PWINDOW->m_iX11Type == 2)
|
||||||
g_pCompositor->moveUnmanagedX11ToWindows(PWINDOW);
|
g_pCompositor->moveUnmanagedX11ToWindows(PWINDOW);
|
||||||
|
@ -79,7 +80,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_pXWaylandManager->shouldBeFloated(PWINDOW)) {
|
if (g_pXWaylandManager->shouldBeFloated(PWINDOW)) {
|
||||||
PWINDOW->m_bIsFloating = true;
|
PWINDOW->m_bIsFloating = true;
|
||||||
PWINDOW->m_bRequestsFloat = true;
|
PWINDOW->m_bRequestsFloat = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
|
|
||||||
if (PWORKSPACE->m_bDefaultPseudo) {
|
if (PWORKSPACE->m_bDefaultPseudo) {
|
||||||
PWINDOW->m_bIsPseudotiled = true;
|
PWINDOW->m_bIsPseudotiled = true;
|
||||||
wlr_box desiredGeometry = {0};
|
wlr_box desiredGeometry = {0};
|
||||||
g_pXWaylandManager->getGeometryForWindow(PWINDOW, &desiredGeometry);
|
g_pXWaylandManager->getGeometryForWindow(PWINDOW, &desiredGeometry);
|
||||||
PWINDOW->m_vPseudoSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
|
PWINDOW->m_vPseudoSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
|
||||||
}
|
}
|
||||||
|
@ -99,22 +100,24 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
|
|
||||||
if (PWORKSPACE->m_bHasFullscreenWindow && !PWINDOW->m_bIsFloating) {
|
if (PWORKSPACE->m_bHasFullscreenWindow && !PWINDOW->m_bIsFloating) {
|
||||||
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
|
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
|
||||||
pFullscreenWindow = PFULLWINDOW;
|
pFullscreenWindow = PFULLWINDOW;
|
||||||
g_pCompositor->setWindowFullscreen(PFULLWINDOW, false, PWORKSPACE->m_efFullscreenMode);
|
g_pCompositor->setWindowFullscreen(PFULLWINDOW, false, PWORKSPACE->m_efFullscreenMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// window rules
|
// window rules
|
||||||
const auto WINDOWRULES = g_pConfigManager->getMatchingRules(PWINDOW);
|
const auto WINDOWRULES = g_pConfigManager->getMatchingRules(PWINDOW);
|
||||||
std::string requestedWorkspace = "";
|
std::string requestedWorkspace = "";
|
||||||
bool workspaceSilent = false;
|
bool workspaceSilent = false;
|
||||||
bool requestsFullscreen = PWINDOW->m_bWantsInitialFullscreen || (!PWINDOW->m_bIsX11 && PWINDOW->m_uSurface.xdg->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL && PWINDOW->m_uSurface.xdg->toplevel->requested.fullscreen) || (PWINDOW->m_bIsX11 && PWINDOW->m_uSurface.xwayland->fullscreen);
|
bool requestsFullscreen = PWINDOW->m_bWantsInitialFullscreen ||
|
||||||
bool shouldFocus = true;
|
(!PWINDOW->m_bIsX11 && PWINDOW->m_uSurface.xdg->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL && PWINDOW->m_uSurface.xdg->toplevel->requested.fullscreen) ||
|
||||||
|
(PWINDOW->m_bIsX11 && PWINDOW->m_uSurface.xwayland->fullscreen);
|
||||||
|
bool shouldFocus = true;
|
||||||
bool workspaceSpecial = false;
|
bool workspaceSpecial = false;
|
||||||
|
|
||||||
for (auto& r : WINDOWRULES) {
|
for (auto& r : WINDOWRULES) {
|
||||||
if (r.szRule.find("monitor") == 0) {
|
if (r.szRule.find("monitor") == 0) {
|
||||||
try {
|
try {
|
||||||
const auto MONITORSTR = r.szRule.substr(r.szRule.find(" "));
|
const auto MONITORSTR = r.szRule.substr(r.szRule.find(' '));
|
||||||
|
|
||||||
if (MONITORSTR == "unset") {
|
if (MONITORSTR == "unset") {
|
||||||
PWINDOW->m_iMonitorID = PMONITOR->ID;
|
PWINDOW->m_iMonitorID = PMONITOR->ID;
|
||||||
|
@ -133,9 +136,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug::log(ERR, "Rule monitor, applying to window %x -> mon: %i, workspace: %i", PWINDOW, PWINDOW->m_iMonitorID, PWINDOW->m_iWorkspaceID);
|
Debug::log(ERR, "Rule monitor, applying to window %x -> mon: %i, workspace: %i", PWINDOW, PWINDOW->m_iMonitorID, PWINDOW->m_iWorkspaceID);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) { Debug::log(ERR, "Rule monitor failed, rule: %s -> %s | err: %s", r.szRule.c_str(), r.szValue.c_str(), e.what()); }
|
||||||
Debug::log(ERR, "Rule monitor failed, rule: %s -> %s | err: %s", r.szRule.c_str(), r.szValue.c_str(), e.what());
|
|
||||||
}
|
|
||||||
} else if (r.szRule.find("workspace") == 0) {
|
} else if (r.szRule.find("workspace") == 0) {
|
||||||
// check if it isnt unset
|
// check if it isnt unset
|
||||||
const auto WORKSPACERQ = r.szRule.substr(r.szRule.find_first_of(' ') + 1);
|
const auto WORKSPACERQ = r.szRule.substr(r.szRule.find_first_of(' ') + 1);
|
||||||
|
@ -200,7 +201,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
// check for silent
|
// check for silent
|
||||||
if (requestedWorkspace.contains("silent")) {
|
if (requestedWorkspace.contains("silent")) {
|
||||||
workspaceSilent = true;
|
workspaceSilent = true;
|
||||||
shouldFocus = false;
|
shouldFocus = false;
|
||||||
|
|
||||||
requestedWorkspace = requestedWorkspace.substr(0, requestedWorkspace.find_first_of(' '));
|
requestedWorkspace = requestedWorkspace.substr(0, requestedWorkspace.find_first_of(' '));
|
||||||
}
|
}
|
||||||
|
@ -211,13 +212,13 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
|
|
||||||
if (requestedWorkspace.find("special") == 0) {
|
if (requestedWorkspace.find("special") == 0) {
|
||||||
workspaceSpecial = true;
|
workspaceSpecial = true;
|
||||||
workspaceSilent = true;
|
workspaceSilent = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!workspaceSilent) {
|
if (!workspaceSilent) {
|
||||||
g_pKeybindManager->m_mDispatchers["workspace"](requestedWorkspace);
|
g_pKeybindManager->m_mDispatchers["workspace"](requestedWorkspace);
|
||||||
|
|
||||||
PWINDOW->m_iMonitorID = g_pCompositor->m_pLastMonitor->ID;
|
PWINDOW->m_iMonitorID = g_pCompositor->m_pLastMonitor->ID;
|
||||||
PWINDOW->m_iWorkspaceID = g_pCompositor->m_pLastMonitor->activeWorkspace;
|
PWINDOW->m_iWorkspaceID = g_pCompositor->m_pLastMonitor->activeWorkspace;
|
||||||
|
|
||||||
PMONITOR = g_pCompositor->m_pLastMonitor;
|
PMONITOR = g_pCompositor->m_pLastMonitor;
|
||||||
|
@ -231,14 +232,14 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
|
|
||||||
if (!PWORKSPACE) {
|
if (!PWORKSPACE) {
|
||||||
std::string workspaceName = "";
|
std::string workspaceName = "";
|
||||||
int workspaceID = 0;
|
int workspaceID = 0;
|
||||||
|
|
||||||
if (requestedWorkspace.find("name:") == 0) {
|
if (requestedWorkspace.find("name:") == 0) {
|
||||||
workspaceName = requestedWorkspace.substr(5);
|
workspaceName = requestedWorkspace.substr(5);
|
||||||
workspaceID = g_pCompositor->getNextAvailableNamedWorkspace();
|
workspaceID = g_pCompositor->getNextAvailableNamedWorkspace();
|
||||||
} else if (workspaceSpecial) {
|
} else if (workspaceSpecial) {
|
||||||
workspaceName = "";
|
workspaceName = "";
|
||||||
workspaceID = getWorkspaceIDFromString(requestedWorkspace, workspaceName);
|
workspaceID = getWorkspaceIDFromString(requestedWorkspace, workspaceName);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
workspaceID = std::stoi(requestedWorkspace);
|
workspaceID = std::stoi(requestedWorkspace);
|
||||||
|
@ -258,7 +259,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
|
|
||||||
if (PWORKSPACE) {
|
if (PWORKSPACE) {
|
||||||
PWINDOW->m_iWorkspaceID = PWORKSPACE->m_iID;
|
PWINDOW->m_iWorkspaceID = PWORKSPACE->m_iID;
|
||||||
PWINDOW->m_iMonitorID = PWORKSPACE->m_iMonitorID;
|
PWINDOW->m_iMonitorID = PWORKSPACE->m_iMonitorID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,14 +271,18 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
for (auto& r : WINDOWRULES) {
|
for (auto& r : WINDOWRULES) {
|
||||||
if (r.szRule.find("size") == 0) {
|
if (r.szRule.find("size") == 0) {
|
||||||
try {
|
try {
|
||||||
const auto VALUE = r.szRule.substr(r.szRule.find(" ") + 1);
|
const auto VALUE = r.szRule.substr(r.szRule.find(' ') + 1);
|
||||||
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(" "));
|
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(' '));
|
||||||
const auto SIZEYSTR = VALUE.substr(VALUE.find(" ") + 1);
|
const auto SIZEYSTR = VALUE.substr(VALUE.find(' ') + 1);
|
||||||
|
|
||||||
const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(PWINDOW);
|
const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(PWINDOW);
|
||||||
|
|
||||||
const auto SIZEX = SIZEXSTR == "max" ? std::clamp(MAXSIZE.x, 20.0, PMONITOR->vecSize.x) : (!SIZEXSTR.contains('%') ? std::stoi(SIZEXSTR) : std::stoi(SIZEXSTR.substr(0, SIZEXSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.x);
|
const auto SIZEX = SIZEXSTR == "max" ?
|
||||||
const auto SIZEY = SIZEYSTR == "max" ? std::clamp(MAXSIZE.y, 20.0, PMONITOR->vecSize.y) : (!SIZEYSTR.contains('%') ? std::stoi(SIZEYSTR) : std::stoi(SIZEYSTR.substr(0, SIZEYSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.y);
|
std::clamp(MAXSIZE.x, 20.0, PMONITOR->vecSize.x) :
|
||||||
|
(!SIZEXSTR.contains('%') ? std::stoi(SIZEXSTR) : std::stoi(SIZEXSTR.substr(0, SIZEXSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.x);
|
||||||
|
const auto SIZEY = SIZEYSTR == "max" ?
|
||||||
|
std::clamp(MAXSIZE.y, 20.0, PMONITOR->vecSize.y) :
|
||||||
|
(!SIZEYSTR.contains('%') ? std::stoi(SIZEYSTR) : std::stoi(SIZEYSTR.substr(0, SIZEYSTR.length() - 1)) * 0.01 * PMONITOR->vecSize.y);
|
||||||
|
|
||||||
Debug::log(LOG, "Rule size, applying to window %x", PWINDOW);
|
Debug::log(LOG, "Rule size, applying to window %x", PWINDOW);
|
||||||
|
|
||||||
|
@ -285,58 +290,55 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
|
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
|
||||||
|
|
||||||
PWINDOW->setHidden(false);
|
PWINDOW->setHidden(false);
|
||||||
} catch (...) {
|
} catch (...) { Debug::log(LOG, "Rule size failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); }
|
||||||
Debug::log(LOG, "Rule size failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
|
|
||||||
}
|
|
||||||
} else if (r.szRule.find("minsize") == 0) {
|
} else if (r.szRule.find("minsize") == 0) {
|
||||||
try {
|
try {
|
||||||
const auto VALUE = r.szRule.substr(r.szRule.find(" ") + 1);
|
const auto VALUE = r.szRule.substr(r.szRule.find(' ') + 1);
|
||||||
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(" "));
|
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(' '));
|
||||||
const auto SIZEYSTR = VALUE.substr(VALUE.find(" ") + 1);
|
const auto SIZEYSTR = VALUE.substr(VALUE.find(' ') + 1);
|
||||||
|
|
||||||
const auto SIZE = Vector2D(std::max((double)std::stoll(SIZEXSTR), PWINDOW->m_vRealSize.goalv().x), std::max((double)std::stoll(SIZEYSTR), PWINDOW->m_vRealSize.goalv().y));
|
const auto SIZE =
|
||||||
|
Vector2D(std::max((double)std::stoll(SIZEXSTR), PWINDOW->m_vRealSize.goalv().x), std::max((double)std::stoll(SIZEYSTR), PWINDOW->m_vRealSize.goalv().y));
|
||||||
|
|
||||||
PWINDOW->m_vRealSize = SIZE;
|
PWINDOW->m_vRealSize = SIZE;
|
||||||
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
|
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
|
||||||
|
|
||||||
PWINDOW->setHidden(false);
|
PWINDOW->setHidden(false);
|
||||||
} catch (...) {
|
} catch (...) { Debug::log(LOG, "Rule minsize failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); }
|
||||||
Debug::log(LOG, "Rule minsize failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
|
|
||||||
}
|
|
||||||
} else if (r.szRule.find("maxsize") == 0) {
|
} else if (r.szRule.find("maxsize") == 0) {
|
||||||
try {
|
try {
|
||||||
const auto VALUE = r.szRule.substr(r.szRule.find(" ") + 1);
|
const auto VALUE = r.szRule.substr(r.szRule.find(' ') + 1);
|
||||||
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(" "));
|
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(' '));
|
||||||
const auto SIZEYSTR = VALUE.substr(VALUE.find(" ") + 1);
|
const auto SIZEYSTR = VALUE.substr(VALUE.find(' ') + 1);
|
||||||
|
|
||||||
const auto SIZE = Vector2D(std::min((double)std::stoll(SIZEXSTR), PWINDOW->m_vRealSize.goalv().x), std::min((double)std::stoll(SIZEYSTR), PWINDOW->m_vRealSize.goalv().y));
|
const auto SIZE =
|
||||||
|
Vector2D(std::min((double)std::stoll(SIZEXSTR), PWINDOW->m_vRealSize.goalv().x), std::min((double)std::stoll(SIZEYSTR), PWINDOW->m_vRealSize.goalv().y));
|
||||||
|
|
||||||
PWINDOW->m_vRealSize = SIZE;
|
PWINDOW->m_vRealSize = SIZE;
|
||||||
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
|
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
|
||||||
|
|
||||||
PWINDOW->setHidden(false);
|
PWINDOW->setHidden(false);
|
||||||
} catch (...) {
|
} catch (...) { Debug::log(LOG, "Rule maxsize failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); }
|
||||||
Debug::log(LOG, "Rule maxsize failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
|
|
||||||
}
|
|
||||||
} else if (r.szRule.find("move") == 0) {
|
} else if (r.szRule.find("move") == 0) {
|
||||||
try {
|
try {
|
||||||
auto value = r.szRule.substr(r.szRule.find(" ") + 1);
|
auto value = r.szRule.substr(r.szRule.find(' ') + 1);
|
||||||
|
|
||||||
const bool CURSOR = value.find("cursor") == 0;
|
const bool CURSOR = value.find("cursor") == 0;
|
||||||
|
|
||||||
if (CURSOR)
|
if (CURSOR)
|
||||||
value = value.substr(value.find_first_of(' ') + 1);
|
value = value.substr(value.find_first_of(' ') + 1);
|
||||||
|
|
||||||
const auto POSXSTR = value.substr(0, value.find(" "));
|
const auto POSXSTR = value.substr(0, value.find(' '));
|
||||||
const auto POSYSTR = value.substr(value.find(" ") + 1);
|
const auto POSYSTR = value.substr(value.find(' ') + 1);
|
||||||
|
|
||||||
int posX = 0;
|
int posX = 0;
|
||||||
int posY = 0;
|
int posY = 0;
|
||||||
|
|
||||||
if (POSXSTR.find("100%-") == 0) {
|
if (POSXSTR.find("100%-") == 0) {
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||||
const auto POSXRAW = POSXSTR.substr(5);
|
const auto POSXRAW = POSXSTR.substr(5);
|
||||||
posX = PMONITOR->vecSize.x - (!POSXRAW.contains('%') ? std::stoi(POSXRAW) : std::stoi(POSXRAW.substr(0, POSXRAW.length() - 1)) * 0.01 * PMONITOR->vecSize.x);
|
posX =
|
||||||
|
PMONITOR->vecSize.x - (!POSXRAW.contains('%') ? std::stoi(POSXRAW) : std::stoi(POSXRAW.substr(0, POSXRAW.length() - 1)) * 0.01 * PMONITOR->vecSize.x);
|
||||||
|
|
||||||
if (CURSOR)
|
if (CURSOR)
|
||||||
Debug::log(ERR, "Cursor is not compatible with 100%-, ignoring cursor!");
|
Debug::log(ERR, "Cursor is not compatible with 100%-, ignoring cursor!");
|
||||||
|
@ -347,14 +349,16 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
if (POSXSTR == "cursor") {
|
if (POSXSTR == "cursor") {
|
||||||
posX = g_pInputManager->getMouseCoordsInternal().x - PMONITOR->vecPosition.x;
|
posX = g_pInputManager->getMouseCoordsInternal().x - PMONITOR->vecPosition.x;
|
||||||
} else {
|
} else {
|
||||||
posX = g_pInputManager->getMouseCoordsInternal().x - PMONITOR->vecPosition.x + (!POSXSTR.contains('%') ? std::stoi(POSXSTR) : std::stoi(POSXSTR.substr(0, POSXSTR.length() - 1)) * 0.01 * PWINDOW->m_vRealSize.goalv().x);
|
posX = g_pInputManager->getMouseCoordsInternal().x - PMONITOR->vecPosition.x +
|
||||||
|
(!POSXSTR.contains('%') ? std::stoi(POSXSTR) : std::stoi(POSXSTR.substr(0, POSXSTR.length() - 1)) * 0.01 * PWINDOW->m_vRealSize.goalv().x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (POSYSTR.find("100%-") == 0) {
|
if (POSYSTR.find("100%-") == 0) {
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||||
const auto POSYRAW = POSYSTR.substr(5);
|
const auto POSYRAW = POSYSTR.substr(5);
|
||||||
posY = PMONITOR->vecSize.y - (!POSYRAW.contains('%') ? std::stoi(POSYRAW) : std::stoi(POSYRAW.substr(0, POSYRAW.length() - 1)) * 0.01 * PMONITOR->vecSize.y);
|
posY =
|
||||||
|
PMONITOR->vecSize.y - (!POSYRAW.contains('%') ? std::stoi(POSYRAW) : std::stoi(POSYRAW.substr(0, POSYRAW.length() - 1)) * 0.01 * PMONITOR->vecSize.y);
|
||||||
|
|
||||||
if (CURSOR)
|
if (CURSOR)
|
||||||
Debug::log(ERR, "Cursor is not compatible with 100%-, ignoring cursor!");
|
Debug::log(ERR, "Cursor is not compatible with 100%-, ignoring cursor!");
|
||||||
|
@ -365,7 +369,8 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
if (POSYSTR == "cursor") {
|
if (POSYSTR == "cursor") {
|
||||||
posY = g_pInputManager->getMouseCoordsInternal().y - PMONITOR->vecPosition.y;
|
posY = g_pInputManager->getMouseCoordsInternal().y - PMONITOR->vecPosition.y;
|
||||||
} else {
|
} else {
|
||||||
posY = g_pInputManager->getMouseCoordsInternal().y - PMONITOR->vecPosition.y + (!POSYSTR.contains('%') ? std::stoi(POSYSTR) : std::stoi(POSYSTR.substr(0, POSYSTR.length() - 1)) * 0.01 * PWINDOW->m_vRealSize.goalv().y);
|
posY = g_pInputManager->getMouseCoordsInternal().y - PMONITOR->vecPosition.y +
|
||||||
|
(!POSYSTR.contains('%') ? std::stoi(POSYSTR) : std::stoi(POSYSTR.substr(0, POSYSTR.length() - 1)) * 0.01 * PWINDOW->m_vRealSize.goalv().y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,9 +379,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
PWINDOW->m_vRealPosition = Vector2D(posX, posY) + PMONITOR->vecPosition;
|
PWINDOW->m_vRealPosition = Vector2D(posX, posY) + PMONITOR->vecPosition;
|
||||||
|
|
||||||
PWINDOW->setHidden(false);
|
PWINDOW->setHidden(false);
|
||||||
} catch (...) {
|
} catch (...) { Debug::log(LOG, "Rule move failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); }
|
||||||
Debug::log(LOG, "Rule move failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
|
|
||||||
}
|
|
||||||
} else if (r.szRule == "center") {
|
} else if (r.szRule == "center") {
|
||||||
PWINDOW->m_vRealPosition = PMONITOR->vecPosition + PMONITOR->vecSize / 2.f - PWINDOW->m_vRealSize.goalv() / 2.f;
|
PWINDOW->m_vRealPosition = PMONITOR->vecPosition + PMONITOR->vecSize / 2.f - PWINDOW->m_vRealSize.goalv() / 2.f;
|
||||||
}
|
}
|
||||||
|
@ -391,14 +394,14 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW);
|
g_pLayoutManager->getCurrentLayout()->onWindowCreated(PWINDOW);
|
||||||
|
|
||||||
// Set the pseudo size here too so that it doesnt end up being 0x0
|
// Set the pseudo size here too so that it doesnt end up being 0x0
|
||||||
PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goalv() - Vector2D(10,10);
|
PWINDOW->m_vPseudoSize = PWINDOW->m_vRealSize.goalv() - Vector2D(10, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto PFOCUSEDWINDOWPREV = g_pCompositor->m_pLastWindow;
|
const auto PFOCUSEDWINDOWPREV = g_pCompositor->m_pLastWindow;
|
||||||
|
|
||||||
if (PWINDOW->m_sAdditionalConfigData.forceAllowsInput) {
|
if (PWINDOW->m_sAdditionalConfigData.forceAllowsInput) {
|
||||||
PWINDOW->m_bNoFocus = false;
|
PWINDOW->m_bNoFocus = false;
|
||||||
PWINDOW->m_bNoInitialFocus = false;
|
PWINDOW->m_bNoInitialFocus = false;
|
||||||
PWINDOW->m_bX11ShouldntFocus = false;
|
PWINDOW->m_bX11ShouldntFocus = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,21 +425,28 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
PWINDOW->hyprListener_commitWindow.initCallback(&PWINDOW->m_uSurface.xdg->surface->events.commit, &Events::listener_commitWindow, PWINDOW, "XDG Window Late");
|
PWINDOW->hyprListener_commitWindow.initCallback(&PWINDOW->m_uSurface.xdg->surface->events.commit, &Events::listener_commitWindow, PWINDOW, "XDG Window Late");
|
||||||
PWINDOW->hyprListener_setTitleWindow.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.set_title, &Events::listener_setTitleWindow, PWINDOW, "XDG Window Late");
|
PWINDOW->hyprListener_setTitleWindow.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.set_title, &Events::listener_setTitleWindow, PWINDOW, "XDG Window Late");
|
||||||
PWINDOW->hyprListener_newPopupXDG.initCallback(&PWINDOW->m_uSurface.xdg->events.new_popup, &Events::listener_newPopupXDG, PWINDOW, "XDG Window Late");
|
PWINDOW->hyprListener_newPopupXDG.initCallback(&PWINDOW->m_uSurface.xdg->events.new_popup, &Events::listener_newPopupXDG, PWINDOW, "XDG Window Late");
|
||||||
PWINDOW->hyprListener_requestMaximize.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_maximize, &Events::listener_requestMaximize, PWINDOW, "XDG Window Late");
|
PWINDOW->hyprListener_requestMaximize.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_maximize, &Events::listener_requestMaximize, PWINDOW,
|
||||||
PWINDOW->hyprListener_requestMinimize.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_minimize, &Events::listener_requestMinimize, PWINDOW, "XDG Window Late");
|
"XDG Window Late");
|
||||||
|
PWINDOW->hyprListener_requestMinimize.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_minimize, &Events::listener_requestMinimize, PWINDOW,
|
||||||
|
"XDG Window Late");
|
||||||
PWINDOW->hyprListener_requestMove.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_move, &Events::listener_requestMove, PWINDOW, "XDG Window Late");
|
PWINDOW->hyprListener_requestMove.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_move, &Events::listener_requestMove, PWINDOW, "XDG Window Late");
|
||||||
PWINDOW->hyprListener_requestResize.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_resize, &Events::listener_requestResize, PWINDOW, "XDG Window Late");
|
PWINDOW->hyprListener_requestResize.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_resize, &Events::listener_requestResize, PWINDOW, "XDG Window Late");
|
||||||
PWINDOW->hyprListener_fullscreenWindow.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_fullscreen, &Events::listener_fullscreenWindow, PWINDOW, "XDG Window Late");
|
PWINDOW->hyprListener_fullscreenWindow.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_fullscreen, &Events::listener_fullscreenWindow, PWINDOW,
|
||||||
|
"XDG Window Late");
|
||||||
} else {
|
} else {
|
||||||
PWINDOW->hyprListener_fullscreenWindow.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_fullscreen, &Events::listener_fullscreenWindow, PWINDOW, "XWayland Window Late");
|
PWINDOW->hyprListener_fullscreenWindow.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_fullscreen, &Events::listener_fullscreenWindow, PWINDOW,
|
||||||
|
"XWayland Window Late");
|
||||||
PWINDOW->hyprListener_activateX11.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_activate, &Events::listener_activateX11, PWINDOW, "XWayland Window Late");
|
PWINDOW->hyprListener_activateX11.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_activate, &Events::listener_activateX11, PWINDOW, "XWayland Window Late");
|
||||||
PWINDOW->hyprListener_configureX11.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_configure, &Events::listener_configureX11, PWINDOW, "XWayland Window Late");
|
PWINDOW->hyprListener_configureX11.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_configure, &Events::listener_configureX11, PWINDOW, "XWayland Window Late");
|
||||||
PWINDOW->hyprListener_setTitleWindow.initCallback(&PWINDOW->m_uSurface.xwayland->events.set_title, &Events::listener_setTitleWindow, PWINDOW, "XWayland Window Late");
|
PWINDOW->hyprListener_setTitleWindow.initCallback(&PWINDOW->m_uSurface.xwayland->events.set_title, &Events::listener_setTitleWindow, PWINDOW, "XWayland Window Late");
|
||||||
PWINDOW->hyprListener_requestMinimize.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_minimize, &Events::listener_requestMinimize, PWINDOW, "Xwayland Window Late");
|
PWINDOW->hyprListener_requestMinimize.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_minimize, &Events::listener_requestMinimize, PWINDOW,
|
||||||
PWINDOW->hyprListener_requestMinimize.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_maximize, &Events::listener_requestMaximize, PWINDOW, "Xwayland Window Late");
|
"Xwayland Window Late");
|
||||||
|
PWINDOW->hyprListener_requestMinimize.initCallback(&PWINDOW->m_uSurface.xwayland->events.request_maximize, &Events::listener_requestMaximize, PWINDOW,
|
||||||
|
"Xwayland Window Late");
|
||||||
|
|
||||||
if (PWINDOW->m_iX11Type == 2)
|
if (PWINDOW->m_iX11Type == 2)
|
||||||
PWINDOW->hyprListener_setGeometryX11U.initCallback(&PWINDOW->m_uSurface.xwayland->events.set_geometry, &Events::listener_unmanagedSetGeometry, PWINDOW, "XWayland Window Late");
|
PWINDOW->hyprListener_setGeometryX11U.initCallback(&PWINDOW->m_uSurface.xwayland->events.set_geometry, &Events::listener_unmanagedSetGeometry, PWINDOW,
|
||||||
|
"XWayland Window Late");
|
||||||
}
|
}
|
||||||
|
|
||||||
// do the animation thing
|
// do the animation thing
|
||||||
|
@ -502,7 +512,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
if (ppid) {
|
if (ppid) {
|
||||||
// get window by pid
|
// get window by pid
|
||||||
std::vector<CWindow*> found;
|
std::vector<CWindow*> found;
|
||||||
CWindow* finalFound = nullptr;
|
CWindow* finalFound = nullptr;
|
||||||
for (auto& w : g_pCompositor->m_vWindows) {
|
for (auto& w : g_pCompositor->m_vWindows) {
|
||||||
if (!w->m_bIsMapped || w->isHidden())
|
if (!w->m_bIsMapped || w->isHidden())
|
||||||
continue;
|
continue;
|
||||||
|
@ -539,10 +549,12 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y, PWINDOW->m_vRealSize.goalv().x, PWINDOW->m_vRealSize.goalv().y);
|
Debug::log(LOG, "Map request dispatched, monitor %s, xywh: %f %f %f %f", PMONITOR->szName.c_str(), PWINDOW->m_vRealPosition.goalv().x, PWINDOW->m_vRealPosition.goalv().y,
|
||||||
|
PWINDOW->m_vRealSize.goalv().x, PWINDOW->m_vRealSize.goalv().y);
|
||||||
|
|
||||||
auto workspaceID = requestedWorkspace != "" ? requestedWorkspace : PWORKSPACE->m_szName;
|
auto workspaceID = requestedWorkspace != "" ? requestedWorkspace : PWORKSPACE->m_szName;
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent{"openwindow", getFormat("%x,%s,%s,%s", PWINDOW, workspaceID.c_str(), g_pXWaylandManager->getAppIDClass(PWINDOW).c_str(), PWINDOW->m_szTitle.c_str())});
|
g_pEventManager->postEvent(
|
||||||
|
SHyprIPCEvent{"openwindow", getFormat("%x,%s,%s,%s", PWINDOW, workspaceID.c_str(), g_pXWaylandManager->getAppIDClass(PWINDOW).c_str(), PWINDOW->m_szTitle.c_str())});
|
||||||
|
|
||||||
// recalc the values for this window
|
// recalc the values for this window
|
||||||
g_pCompositor->updateWindowAnimatedDecorationValues(PWINDOW);
|
g_pCompositor->updateWindowAnimatedDecorationValues(PWINDOW);
|
||||||
|
@ -595,9 +607,9 @@ void Events::listener_unmapWindow(void* owner, void* data) {
|
||||||
bool wasLastWindow = false;
|
bool wasLastWindow = false;
|
||||||
|
|
||||||
if (PWINDOW == g_pCompositor->m_pLastWindow) {
|
if (PWINDOW == g_pCompositor->m_pLastWindow) {
|
||||||
wasLastWindow = true;
|
wasLastWindow = true;
|
||||||
g_pCompositor->m_pLastWindow = nullptr;
|
g_pCompositor->m_pLastWindow = nullptr;
|
||||||
g_pCompositor->m_pLastFocus = nullptr;
|
g_pCompositor->m_pLastFocus = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
PWINDOW->m_bMappedX11 = false;
|
PWINDOW->m_bMappedX11 = false;
|
||||||
|
@ -645,11 +657,11 @@ void Events::listener_unmapWindow(void* owner, void* data) {
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||||
|
|
||||||
// do the animation thing
|
// do the animation thing
|
||||||
PWINDOW->m_vOriginalClosedPos = PWINDOW->m_vRealPosition.vec() - PMONITOR->vecPosition;
|
PWINDOW->m_vOriginalClosedPos = PWINDOW->m_vRealPosition.vec() - PMONITOR->vecPosition;
|
||||||
PWINDOW->m_vOriginalClosedSize = PWINDOW->m_vRealSize.vec();
|
PWINDOW->m_vOriginalClosedSize = PWINDOW->m_vRealSize.vec();
|
||||||
|
|
||||||
if (!PWINDOW->m_bX11DoesntWantBorders) // don't animate out if they weren't animated in.
|
if (!PWINDOW->m_bX11DoesntWantBorders) // don't animate out if they weren't animated in.
|
||||||
PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition.vec() + Vector2D(0.01f, 0.01f); // it has to be animated, otherwise onWindowPostCreateClose will ignore it
|
PWINDOW->m_vRealPosition = PWINDOW->m_vRealPosition.vec() + Vector2D(0.01f, 0.01f); // it has to be animated, otherwise onWindowPostCreateClose will ignore it
|
||||||
|
|
||||||
// anims
|
// anims
|
||||||
g_pAnimationManager->onWindowPostCreateClose(PWINDOW, true);
|
g_pAnimationManager->onWindowPostCreateClose(PWINDOW, true);
|
||||||
|
@ -689,7 +701,7 @@ void Events::listener_destroyWindow(void* owner, void* data) {
|
||||||
|
|
||||||
if (PWINDOW == g_pCompositor->m_pLastWindow) {
|
if (PWINDOW == g_pCompositor->m_pLastWindow) {
|
||||||
g_pCompositor->m_pLastWindow = nullptr;
|
g_pCompositor->m_pLastWindow = nullptr;
|
||||||
g_pCompositor->m_pLastFocus = nullptr;
|
g_pCompositor->m_pLastFocus = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
PWINDOW->hyprListener_mapWindow.removeCallback();
|
PWINDOW->hyprListener_mapWindow.removeCallback();
|
||||||
|
@ -705,7 +717,7 @@ void Events::listener_destroyWindow(void* owner, void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PWINDOW->m_bReadyToDelete = true;
|
PWINDOW->m_bReadyToDelete = true;
|
||||||
|
|
||||||
if (!PWINDOW->m_bFadingOut) {
|
if (!PWINDOW->m_bFadingOut) {
|
||||||
g_pCompositor->removeWindowFromVectorSafe(PWINDOW); // most likely X11 unmanaged or sumn
|
g_pCompositor->removeWindowFromVectorSafe(PWINDOW); // most likely X11 unmanaged or sumn
|
||||||
Debug::log(LOG, "Unmapped window %x removed instantly", PWINDOW);
|
Debug::log(LOG, "Unmapped window %x removed instantly", PWINDOW);
|
||||||
|
@ -716,7 +728,7 @@ void Events::listener_setTitleWindow(void* owner, void* data) {
|
||||||
CWindow* PWINDOW = (CWindow*)owner;
|
CWindow* PWINDOW = (CWindow*)owner;
|
||||||
|
|
||||||
if (!g_pCompositor->windowValidMapped(PWINDOW))
|
if (!g_pCompositor->windowValidMapped(PWINDOW))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
|
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
|
||||||
|
|
||||||
|
@ -761,9 +773,9 @@ void Events::listener_fullscreenWindow(void* owner, void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_activateXDG(wl_listener* listener, void* data) {
|
void Events::listener_activateXDG(wl_listener* listener, void* data) {
|
||||||
const auto E = (wlr_xdg_activation_v1_request_activate_event*)data;
|
const auto E = (wlr_xdg_activation_v1_request_activate_event*)data;
|
||||||
|
|
||||||
static auto *const PFOCUSONACTIVATE = &g_pConfigManager->getConfigValuePtr("misc:focus_on_activate")->intValue;
|
static auto* const PFOCUSONACTIVATE = &g_pConfigManager->getConfigValuePtr("misc:focus_on_activate")->intValue;
|
||||||
|
|
||||||
Debug::log(LOG, "Activate request for surface at %x", E->surface);
|
Debug::log(LOG, "Activate request for surface at %x", E->surface);
|
||||||
|
|
||||||
|
@ -781,9 +793,9 @@ void Events::listener_activateXDG(wl_listener* listener, void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Events::listener_activateX11(void* owner, void* data) {
|
void Events::listener_activateX11(void* owner, void* data) {
|
||||||
const auto PWINDOW = (CWindow*)owner;
|
const auto PWINDOW = (CWindow*)owner;
|
||||||
|
|
||||||
static auto *const PFOCUSONACTIVATE = &g_pConfigManager->getConfigValuePtr("misc:focus_on_activate")->intValue;
|
static auto* const PFOCUSONACTIVATE = &g_pConfigManager->getConfigValuePtr("misc:focus_on_activate")->intValue;
|
||||||
|
|
||||||
Debug::log(LOG, "X11 Activate request for window %x", PWINDOW);
|
Debug::log(LOG, "X11 Activate request for window %x", PWINDOW);
|
||||||
|
|
||||||
|
@ -824,7 +836,7 @@ void Events::listener_configureX11(void* owner, void* data) {
|
||||||
PWINDOW->m_vRealPosition.setValueAndWarp(Vector2D(E->x, E->y));
|
PWINDOW->m_vRealPosition.setValueAndWarp(Vector2D(E->x, E->y));
|
||||||
PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(E->width, E->height));
|
PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(E->width, E->height));
|
||||||
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.vec();
|
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.vec();
|
||||||
PWINDOW->m_vSize = PWINDOW->m_vRealSize.vec();
|
PWINDOW->m_vSize = PWINDOW->m_vRealSize.vec();
|
||||||
|
|
||||||
wlr_xwayland_surface_configure(PWINDOW->m_uSurface.xwayland, E->x, E->y, E->width, E->height);
|
wlr_xwayland_surface_configure(PWINDOW->m_uSurface.xwayland, E->x, E->y, E->width, E->height);
|
||||||
|
|
||||||
|
@ -862,8 +874,10 @@ void Events::listener_unmanagedSetGeometry(void* owner, void* data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (abs(std::floor(POS.x) - PWINDOW->m_uSurface.xwayland->x) > 2 || abs(std::floor(POS.y) - PWINDOW->m_uSurface.xwayland->y) > 2 || abs(std::floor(SIZ.x) - PWINDOW->m_uSurface.xwayland->width) > 2 || abs(std::floor(SIZ.y) - PWINDOW->m_uSurface.xwayland->height) > 2) {
|
if (abs(std::floor(POS.x) - PWINDOW->m_uSurface.xwayland->x) > 2 || abs(std::floor(POS.y) - PWINDOW->m_uSurface.xwayland->y) > 2 ||
|
||||||
Debug::log(LOG, "Unmanaged window %x requests geometry update to %i %i %i %i", PWINDOW, (int)PWINDOW->m_uSurface.xwayland->x, (int)PWINDOW->m_uSurface.xwayland->y, (int)PWINDOW->m_uSurface.xwayland->width, (int)PWINDOW->m_uSurface.xwayland->height);
|
abs(std::floor(SIZ.x) - PWINDOW->m_uSurface.xwayland->width) > 2 || abs(std::floor(SIZ.y) - PWINDOW->m_uSurface.xwayland->height) > 2) {
|
||||||
|
Debug::log(LOG, "Unmanaged window %x requests geometry update to %i %i %i %i", PWINDOW, (int)PWINDOW->m_uSurface.xwayland->x, (int)PWINDOW->m_uSurface.xwayland->y,
|
||||||
|
(int)PWINDOW->m_uSurface.xwayland->width, (int)PWINDOW->m_uSurface.xwayland->height);
|
||||||
|
|
||||||
g_pHyprRenderer->damageWindow(PWINDOW);
|
g_pHyprRenderer->damageWindow(PWINDOW);
|
||||||
PWINDOW->m_vRealPosition.setValueAndWarp(Vector2D(PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y));
|
PWINDOW->m_vRealPosition.setValueAndWarp(Vector2D(PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y));
|
||||||
|
@ -886,11 +900,12 @@ void Events::listener_surfaceXWayland(wl_listener* listener, void* data) {
|
||||||
if (XWSURFACE->parent)
|
if (XWSURFACE->parent)
|
||||||
Debug::log(LOG, "Window parent data: %s at %x", XWSURFACE->parent->_class, XWSURFACE->parent);
|
Debug::log(LOG, "Window parent data: %s at %x", XWSURFACE->parent->_class, XWSURFACE->parent);
|
||||||
|
|
||||||
const auto PNEWWINDOW = XWSURFACE->override_redirect ? g_pCompositor->m_dUnmanagedX11Windows.emplace_back(std::make_unique<CWindow>()).get() : g_pCompositor->m_vWindows.emplace_back(std::make_unique<CWindow>()).get();
|
const auto PNEWWINDOW = XWSURFACE->override_redirect ? g_pCompositor->m_dUnmanagedX11Windows.emplace_back(std::make_unique<CWindow>()).get() :
|
||||||
|
g_pCompositor->m_vWindows.emplace_back(std::make_unique<CWindow>()).get();
|
||||||
|
|
||||||
PNEWWINDOW->m_uSurface.xwayland = XWSURFACE;
|
PNEWWINDOW->m_uSurface.xwayland = XWSURFACE;
|
||||||
PNEWWINDOW->m_iX11Type = XWSURFACE->override_redirect ? 2 : 1;
|
PNEWWINDOW->m_iX11Type = XWSURFACE->override_redirect ? 2 : 1;
|
||||||
PNEWWINDOW->m_bIsX11 = true;
|
PNEWWINDOW->m_bIsX11 = true;
|
||||||
|
|
||||||
PNEWWINDOW->m_pX11Parent = g_pCompositor->getX11Parent(PNEWWINDOW);
|
PNEWWINDOW->m_pX11Parent = g_pCompositor->getX11Parent(PNEWWINDOW);
|
||||||
|
|
||||||
|
@ -908,7 +923,7 @@ void Events::listener_newXDGSurface(wl_listener* listener, void* data) {
|
||||||
|
|
||||||
Debug::log(LOG, "New XDG Surface created. (class: %s)", XDGSURFACE->toplevel->app_id);
|
Debug::log(LOG, "New XDG Surface created. (class: %s)", XDGSURFACE->toplevel->app_id);
|
||||||
|
|
||||||
const auto PNEWWINDOW = g_pCompositor->m_vWindows.emplace_back(std::make_unique<CWindow>()).get();
|
const auto PNEWWINDOW = g_pCompositor->m_vWindows.emplace_back(std::make_unique<CWindow>()).get();
|
||||||
PNEWWINDOW->m_uSurface.xdg = XDGSURFACE;
|
PNEWWINDOW->m_uSurface.xdg = XDGSURFACE;
|
||||||
|
|
||||||
PNEWWINDOW->hyprListener_mapWindow.initCallback(&XDGSURFACE->events.map, &Events::listener_mapWindow, PNEWWINDOW, "XDG Window");
|
PNEWWINDOW->hyprListener_mapWindow.initCallback(&XDGSURFACE->events.map, &Events::listener_mapWindow, PNEWWINDOW, "XDG Window");
|
||||||
|
@ -931,7 +946,8 @@ void Events::listener_requestMaximize(void* owner, void* data) {
|
||||||
if (!PWINDOW->m_bIsX11) {
|
if (!PWINDOW->m_bIsX11) {
|
||||||
const auto EV = (wlr_foreign_toplevel_handle_v1_maximized_event*)data;
|
const auto EV = (wlr_foreign_toplevel_handle_v1_maximized_event*)data;
|
||||||
|
|
||||||
g_pCompositor->setWindowFullscreen(PWINDOW, EV ? EV->maximized : !PWINDOW->m_bIsFullscreen, FULLSCREEN_MAXIMIZED); // this will be rejected if there already is a fullscreen window
|
g_pCompositor->setWindowFullscreen(PWINDOW, EV ? EV->maximized : !PWINDOW->m_bIsFullscreen,
|
||||||
|
FULLSCREEN_MAXIMIZED); // this will be rejected if there already is a fullscreen window
|
||||||
|
|
||||||
wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg);
|
wlr_xdg_surface_schedule_configure(PWINDOW->m_uSurface.xdg);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,10 +7,10 @@ CAnimatedVariable::CAnimatedVariable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimatedVariable::create(ANIMATEDVARTYPE type, SAnimationPropertyConfig* pAnimConfig, void* pWindow, AVARDAMAGEPOLICY policy) {
|
void CAnimatedVariable::create(ANIMATEDVARTYPE type, SAnimationPropertyConfig* pAnimConfig, void* pWindow, AVARDAMAGEPOLICY policy) {
|
||||||
m_eVarType = type;
|
m_eVarType = type;
|
||||||
m_eDamagePolicy = policy;
|
m_eDamagePolicy = policy;
|
||||||
m_pConfig = pAnimConfig;
|
m_pConfig = pAnimConfig;
|
||||||
m_pWindow = pWindow;
|
m_pWindow = pWindow;
|
||||||
|
|
||||||
m_bDummy = false;
|
m_bDummy = false;
|
||||||
}
|
}
|
||||||
|
@ -22,25 +22,23 @@ void CAnimatedVariable::create(ANIMATEDVARTYPE type, std::any val, SAnimationPro
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AVARTYPE_FLOAT: {
|
case AVARTYPE_FLOAT: {
|
||||||
const auto V = std::any_cast<float>(val);
|
const auto V = std::any_cast<float>(val);
|
||||||
m_fValue = V;
|
m_fValue = V;
|
||||||
m_fGoal = V;
|
m_fGoal = V;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AVARTYPE_VECTOR: {
|
case AVARTYPE_VECTOR: {
|
||||||
const auto V = std::any_cast<Vector2D>(val);
|
const auto V = std::any_cast<Vector2D>(val);
|
||||||
m_vValue = V;
|
m_vValue = V;
|
||||||
m_vGoal = V;
|
m_vGoal = V;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AVARTYPE_COLOR: {
|
case AVARTYPE_COLOR: {
|
||||||
const auto V = std::any_cast<CColor>(val);
|
const auto V = std::any_cast<CColor>(val);
|
||||||
m_cValue = V;
|
m_cValue = V;
|
||||||
m_cGoal = V;
|
m_cGoal = V;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: ASSERT(false); break;
|
||||||
ASSERT(false);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
Debug::log(ERR, "CAnimatedVariable create error: %s", e.what());
|
Debug::log(ERR, "CAnimatedVariable create error: %s", e.what());
|
||||||
|
@ -64,7 +62,8 @@ void CAnimatedVariable::registerVar() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int CAnimatedVariable::getDurationLeftMs() {
|
int CAnimatedVariable::getDurationLeftMs() {
|
||||||
return std::max((int)(m_pConfig->pValues->internalSpeed * 100) - (int)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - animationBegin).count(), 0);
|
return std::max(
|
||||||
|
(int)(m_pConfig->pValues->internalSpeed * 100) - (int)std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - animationBegin).count(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
float CAnimatedVariable::getPercent() {
|
float CAnimatedVariable::getPercent() {
|
||||||
|
|
|
@ -3,16 +3,18 @@
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
#include <any>
|
#include <any>
|
||||||
|
|
||||||
enum ANIMATEDVARTYPE {
|
enum ANIMATEDVARTYPE
|
||||||
|
{
|
||||||
AVARTYPE_INVALID = -1,
|
AVARTYPE_INVALID = -1,
|
||||||
AVARTYPE_FLOAT,
|
AVARTYPE_FLOAT,
|
||||||
AVARTYPE_VECTOR,
|
AVARTYPE_VECTOR,
|
||||||
AVARTYPE_COLOR
|
AVARTYPE_COLOR
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AVARDAMAGEPOLICY {
|
enum AVARDAMAGEPOLICY
|
||||||
|
{
|
||||||
AVARDAMAGE_INVALID = -1,
|
AVARDAMAGE_INVALID = -1,
|
||||||
AVARDAMAGE_ENTIRE = 0,
|
AVARDAMAGE_ENTIRE = 0,
|
||||||
AVARDAMAGE_BORDER,
|
AVARDAMAGE_BORDER,
|
||||||
AVARDAMAGE_SHADOW
|
AVARDAMAGE_SHADOW
|
||||||
};
|
};
|
||||||
|
@ -24,7 +26,7 @@ struct SAnimationPropertyConfig;
|
||||||
class CHyprRenderer;
|
class CHyprRenderer;
|
||||||
|
|
||||||
class CAnimatedVariable {
|
class CAnimatedVariable {
|
||||||
public:
|
public:
|
||||||
CAnimatedVariable(); // dummy var
|
CAnimatedVariable(); // dummy var
|
||||||
|
|
||||||
void create(ANIMATEDVARTYPE, SAnimationPropertyConfig*, void* pWindow, AVARDAMAGEPOLICY);
|
void create(ANIMATEDVARTYPE, SAnimationPropertyConfig*, void* pWindow, AVARDAMAGEPOLICY);
|
||||||
|
@ -65,53 +67,59 @@ public:
|
||||||
return m_cGoal;
|
return m_cGoal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator=(const Vector2D& v) {
|
CAnimatedVariable& operator=(const Vector2D& v) {
|
||||||
m_vGoal = v;
|
m_vGoal = v;
|
||||||
animationBegin = std::chrono::system_clock::now();
|
animationBegin = std::chrono::system_clock::now();
|
||||||
m_vBegun = m_vValue;
|
m_vBegun = m_vValue;
|
||||||
|
|
||||||
onAnimationBegin();
|
onAnimationBegin();
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator=(const float& v) {
|
CAnimatedVariable& operator=(const float& v) {
|
||||||
m_fGoal = v;
|
m_fGoal = v;
|
||||||
animationBegin = std::chrono::system_clock::now();
|
animationBegin = std::chrono::system_clock::now();
|
||||||
m_fBegun = m_fValue;
|
m_fBegun = m_fValue;
|
||||||
|
|
||||||
onAnimationBegin();
|
onAnimationBegin();
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator=(const CColor& v) {
|
CAnimatedVariable& operator=(const CColor& v) {
|
||||||
m_cGoal = v;
|
m_cGoal = v;
|
||||||
animationBegin = std::chrono::system_clock::now();
|
animationBegin = std::chrono::system_clock::now();
|
||||||
m_cBegun = m_cValue;
|
m_cBegun = m_cValue;
|
||||||
|
|
||||||
onAnimationBegin();
|
onAnimationBegin();
|
||||||
|
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the actual stored value, without affecting the goal, but resets the timer
|
// Sets the actual stored value, without affecting the goal, but resets the timer
|
||||||
void setValue(const Vector2D& v) {
|
void setValue(const Vector2D& v) {
|
||||||
m_vValue = v;
|
m_vValue = v;
|
||||||
animationBegin = std::chrono::system_clock::now();
|
animationBegin = std::chrono::system_clock::now();
|
||||||
m_vBegun = m_vValue;
|
m_vBegun = m_vValue;
|
||||||
|
|
||||||
onAnimationBegin();
|
onAnimationBegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the actual stored value, without affecting the goal, but resets the timer
|
// Sets the actual stored value, without affecting the goal, but resets the timer
|
||||||
void setValue(const float& v) {
|
void setValue(const float& v) {
|
||||||
m_fValue = v;
|
m_fValue = v;
|
||||||
animationBegin = std::chrono::system_clock::now();
|
animationBegin = std::chrono::system_clock::now();
|
||||||
m_vBegun = m_vValue;
|
m_vBegun = m_vValue;
|
||||||
|
|
||||||
onAnimationBegin();
|
onAnimationBegin();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the actual stored value, without affecting the goal, but resets the timer
|
// Sets the actual stored value, without affecting the goal, but resets the timer
|
||||||
void setValue(const CColor& v) {
|
void setValue(const CColor& v) {
|
||||||
m_cValue = v;
|
m_cValue = v;
|
||||||
animationBegin = std::chrono::system_clock::now();
|
animationBegin = std::chrono::system_clock::now();
|
||||||
m_vBegun = m_vValue;
|
m_vBegun = m_vValue;
|
||||||
|
|
||||||
onAnimationBegin();
|
onAnimationBegin();
|
||||||
}
|
}
|
||||||
|
@ -137,14 +145,10 @@ public:
|
||||||
// checks if an animation is in progress
|
// checks if an animation is in progress
|
||||||
bool isBeingAnimated() {
|
bool isBeingAnimated() {
|
||||||
switch (m_eVarType) {
|
switch (m_eVarType) {
|
||||||
case AVARTYPE_FLOAT:
|
case AVARTYPE_FLOAT: return m_fValue != m_fGoal;
|
||||||
return m_fValue != m_fGoal;
|
case AVARTYPE_VECTOR: return m_vValue != m_vGoal;
|
||||||
case AVARTYPE_VECTOR:
|
case AVARTYPE_COLOR: return m_cValue != m_cGoal;
|
||||||
return m_vValue != m_vGoal;
|
default: UNREACHABLE();
|
||||||
case AVARTYPE_COLOR:
|
|
||||||
return m_cValue != m_cGoal;
|
|
||||||
default:
|
|
||||||
UNREACHABLE();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
|
@ -166,8 +170,7 @@ public:
|
||||||
m_cValue = m_cGoal;
|
m_cValue = m_cGoal;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: UNREACHABLE();
|
||||||
UNREACHABLE();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endCallback)
|
if (endCallback)
|
||||||
|
@ -191,7 +194,7 @@ public:
|
||||||
if an animation is not running, runs instantly.
|
if an animation is not running, runs instantly.
|
||||||
if "remove" is set to true, will remove the callback when ran. */
|
if "remove" is set to true, will remove the callback when ran. */
|
||||||
void setCallbackOnEnd(std::function<void(void* thisptr)> func, bool remove = true) {
|
void setCallbackOnEnd(std::function<void(void* thisptr)> func, bool remove = true) {
|
||||||
m_fEndCallback = func;
|
m_fEndCallback = func;
|
||||||
m_bRemoveEndAfterRan = remove;
|
m_bRemoveEndAfterRan = remove;
|
||||||
|
|
||||||
if (!isBeingAnimated())
|
if (!isBeingAnimated())
|
||||||
|
@ -201,58 +204,57 @@ public:
|
||||||
/* sets a function to be ran when an animation is started.
|
/* sets a function to be ran when an animation is started.
|
||||||
if "remove" is set to true, will remove the callback when ran. */
|
if "remove" is set to true, will remove the callback when ran. */
|
||||||
void setCallbackOnBegin(std::function<void(void* thisptr)> func, bool remove = true) {
|
void setCallbackOnBegin(std::function<void(void* thisptr)> func, bool remove = true) {
|
||||||
m_fBeginCallback = func;
|
m_fBeginCallback = func;
|
||||||
m_bRemoveBeginAfterRan = remove;
|
m_bRemoveBeginAfterRan = remove;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* resets all callbacks. Does not call any. */
|
/* resets all callbacks. Does not call any. */
|
||||||
void resetAllCallbacks() {
|
void resetAllCallbacks() {
|
||||||
m_fBeginCallback = nullptr;
|
m_fBeginCallback = nullptr;
|
||||||
m_fEndCallback = nullptr;
|
m_fEndCallback = nullptr;
|
||||||
m_bRemoveBeginAfterRan = false;
|
m_bRemoveBeginAfterRan = false;
|
||||||
m_bRemoveEndAfterRan = false;
|
m_bRemoveEndAfterRan = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Vector2D m_vValue = Vector2D(0, 0);
|
||||||
|
float m_fValue = 0;
|
||||||
|
CColor m_cValue;
|
||||||
|
|
||||||
Vector2D m_vValue = Vector2D(0,0);
|
Vector2D m_vGoal = Vector2D(0, 0);
|
||||||
float m_fValue = 0;
|
float m_fGoal = 0;
|
||||||
CColor m_cValue;
|
CColor m_cGoal;
|
||||||
|
|
||||||
Vector2D m_vGoal = Vector2D(0,0);
|
Vector2D m_vBegun = Vector2D(0, 0);
|
||||||
float m_fGoal = 0;
|
float m_fBegun = 0;
|
||||||
CColor m_cGoal;
|
CColor m_cBegun;
|
||||||
|
|
||||||
Vector2D m_vBegun = Vector2D(0,0);
|
|
||||||
float m_fBegun = 0;
|
|
||||||
CColor m_cBegun;
|
|
||||||
|
|
||||||
// owners
|
// owners
|
||||||
void* m_pWindow = nullptr;
|
void* m_pWindow = nullptr;
|
||||||
void* m_pWorkspace = nullptr;
|
void* m_pWorkspace = nullptr;
|
||||||
void* m_pLayer = nullptr;
|
void* m_pLayer = nullptr;
|
||||||
|
|
||||||
SAnimationPropertyConfig* m_pConfig = nullptr;
|
SAnimationPropertyConfig* m_pConfig = nullptr;
|
||||||
|
|
||||||
bool m_bDummy = true;
|
bool m_bDummy = true;
|
||||||
bool m_bIsRegistered = false;
|
bool m_bIsRegistered = false;
|
||||||
|
|
||||||
std::chrono::system_clock::time_point animationBegin;
|
std::chrono::system_clock::time_point animationBegin;
|
||||||
|
|
||||||
ANIMATEDVARTYPE m_eVarType = AVARTYPE_INVALID;
|
ANIMATEDVARTYPE m_eVarType = AVARTYPE_INVALID;
|
||||||
AVARDAMAGEPOLICY m_eDamagePolicy = AVARDAMAGE_INVALID;
|
AVARDAMAGEPOLICY m_eDamagePolicy = AVARDAMAGE_INVALID;
|
||||||
|
|
||||||
bool m_bRemoveEndAfterRan = true;
|
bool m_bRemoveEndAfterRan = true;
|
||||||
bool m_bRemoveBeginAfterRan = true;
|
bool m_bRemoveBeginAfterRan = true;
|
||||||
std::function<void(void* thisptr)> m_fEndCallback;
|
std::function<void(void* thisptr)> m_fEndCallback;
|
||||||
std::function<void(void* thisptr)> m_fBeginCallback;
|
std::function<void(void* thisptr)> m_fBeginCallback;
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
void onAnimationEnd() {
|
void onAnimationEnd() {
|
||||||
if (m_fEndCallback) {
|
if (m_fEndCallback) {
|
||||||
m_fEndCallback(this);
|
m_fEndCallback(this);
|
||||||
if (m_bRemoveEndAfterRan)
|
if (m_bRemoveEndAfterRan)
|
||||||
m_fEndCallback = nullptr; // reset
|
m_fEndCallback = nullptr; // reset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +262,7 @@ private:
|
||||||
if (m_fBeginCallback) {
|
if (m_fBeginCallback) {
|
||||||
m_fBeginCallback(this);
|
m_fBeginCallback(this);
|
||||||
if (m_bRemoveBeginAfterRan)
|
if (m_bRemoveBeginAfterRan)
|
||||||
m_fBeginCallback = nullptr; // reset
|
m_fBeginCallback = nullptr; // reset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,13 @@ void CBezierCurve::setup(std::vector<Vector2D>* pVec) {
|
||||||
|
|
||||||
const auto BEGIN = std::chrono::high_resolution_clock::now();
|
const auto BEGIN = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
m_dPoints.emplace_back(Vector2D(0,0));
|
m_dPoints.emplace_back(Vector2D(0, 0));
|
||||||
|
|
||||||
for (auto& p : *pVec) {
|
for (auto& p : *pVec) {
|
||||||
m_dPoints.push_back(p);
|
m_dPoints.push_back(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dPoints.emplace_back(Vector2D(1,1));
|
m_dPoints.emplace_back(Vector2D(1, 1));
|
||||||
|
|
||||||
RASSERT(m_dPoints.size() == 4, "CBezierCurve only supports cubic beziers! (points num: %i)", m_dPoints.size());
|
RASSERT(m_dPoints.size() == 4, "CBezierCurve only supports cubic beziers! (points num: %i)", m_dPoints.size());
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ void CBezierCurve::setup(std::vector<Vector2D>* pVec) {
|
||||||
m_aPointsBaked[i] = Vector2D(getXForT((i + 1) / (float)BAKEDPOINTS), getYForT((i + 1) / (float)BAKEDPOINTS));
|
m_aPointsBaked[i] = Vector2D(getXForT((i + 1) / (float)BAKEDPOINTS), getYForT((i + 1) / (float)BAKEDPOINTS));
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto ELAPSEDUS = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - BEGIN).count() / 1000.f;
|
const auto ELAPSEDUS = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - BEGIN).count() / 1000.f;
|
||||||
const auto POINTSSIZE = m_aPointsBaked.size() * sizeof(m_aPointsBaked[0]) / 1000.f;
|
const auto POINTSSIZE = m_aPointsBaked.size() * sizeof(m_aPointsBaked[0]) / 1000.f;
|
||||||
|
|
||||||
const auto BEGINCALC = std::chrono::high_resolution_clock::now();
|
const auto BEGINCALC = std::chrono::high_resolution_clock::now();
|
||||||
|
@ -29,9 +29,8 @@ void CBezierCurve::setup(std::vector<Vector2D>* pVec) {
|
||||||
getYForPoint(i);
|
getYForPoint(i);
|
||||||
const auto ELAPSEDCALCAVG = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - BEGINCALC).count() / 1000.f / 10.f;
|
const auto ELAPSEDCALCAVG = std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now() - BEGINCALC).count() / 1000.f / 10.f;
|
||||||
|
|
||||||
Debug::log(LOG, "Created a bezier curve, baked %i points, mem usage: %.2fkB, time to bake: %.2fµs. Estimated average calc time: %.2fµs.",
|
Debug::log(LOG, "Created a bezier curve, baked %i points, mem usage: %.2fkB, time to bake: %.2fµs. Estimated average calc time: %.2fµs.", BAKEDPOINTS, POINTSSIZE, ELAPSEDUS,
|
||||||
BAKEDPOINTS, POINTSSIZE, ELAPSEDUS, ELAPSEDCALCAVG);
|
ELAPSEDCALCAVG);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float CBezierCurve::getYForT(float t) {
|
float CBezierCurve::getYForT(float t) {
|
||||||
|
@ -47,9 +46,9 @@ float CBezierCurve::getYForPoint(float x) {
|
||||||
// binary search for the range UPDOWN X
|
// binary search for the range UPDOWN X
|
||||||
float upperT = 1;
|
float upperT = 1;
|
||||||
float lowerT = 0;
|
float lowerT = 0;
|
||||||
float mid = 0.5;
|
float mid = 0.5;
|
||||||
|
|
||||||
while(std::abs(upperT - lowerT) > INVBAKEDPOINTS) {
|
while (std::abs(upperT - lowerT) > INVBAKEDPOINTS) {
|
||||||
if (m_aPointsBaked[((int)(mid * (float)BAKEDPOINTS))].x > x) {
|
if (m_aPointsBaked[((int)(mid * (float)BAKEDPOINTS))].x > x) {
|
||||||
upperT = mid;
|
upperT = mid;
|
||||||
} else {
|
} else {
|
||||||
|
@ -65,7 +64,7 @@ float CBezierCurve::getYForPoint(float x) {
|
||||||
|
|
||||||
const auto PERCINDELTA = (x - LOWERPOINT->x) / (UPPERPOINT->x - LOWERPOINT->x);
|
const auto PERCINDELTA = (x - LOWERPOINT->x) / (UPPERPOINT->x - LOWERPOINT->x);
|
||||||
|
|
||||||
if (std::isnan(PERCINDELTA) || std::isinf(PERCINDELTA)) // can sometimes happen for VERY small x
|
if (std::isnan(PERCINDELTA) || std::isinf(PERCINDELTA)) // can sometimes happen for VERY small x
|
||||||
return 0.f;
|
return 0.f;
|
||||||
|
|
||||||
return LOWERPOINT->y + (UPPERPOINT->y - UPPERPOINT->y) * PERCINDELTA;
|
return LOWERPOINT->y + (UPPERPOINT->y - UPPERPOINT->y) * PERCINDELTA;
|
||||||
|
|
|
@ -3,25 +3,25 @@
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
constexpr int BAKEDPOINTS = 200;
|
constexpr int BAKEDPOINTS = 200;
|
||||||
constexpr float INVBAKEDPOINTS = 1.f / BAKEDPOINTS;
|
constexpr float INVBAKEDPOINTS = 1.f / BAKEDPOINTS;
|
||||||
|
|
||||||
// an implementation of a cubic bezier curve
|
// an implementation of a cubic bezier curve
|
||||||
// might do better later
|
// might do better later
|
||||||
// TODO: n-point curves
|
// TODO: n-point curves
|
||||||
class CBezierCurve {
|
class CBezierCurve {
|
||||||
public:
|
public:
|
||||||
// sets up the bezier curve.
|
// sets up the bezier curve.
|
||||||
// this EXCLUDES the 0,0 and 1,1 points,
|
// this EXCLUDES the 0,0 and 1,1 points,
|
||||||
void setup(std::vector<Vector2D>* points);
|
void setup(std::vector<Vector2D>* points);
|
||||||
|
|
||||||
float getYForT(float t);
|
float getYForT(float t);
|
||||||
float getXForT(float t);
|
float getXForT(float t);
|
||||||
float getYForPoint(float x);
|
float getYForPoint(float x);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// this INCLUDES the 0,0 and 1,1 points.
|
// this INCLUDES the 0,0 and 1,1 points.
|
||||||
std::deque<Vector2D> m_dPoints;
|
std::deque<Vector2D> m_dPoints;
|
||||||
|
|
||||||
std::array<Vector2D, BAKEDPOINTS> m_aPointsBaked;
|
std::array<Vector2D, BAKEDPOINTS> m_aPointsBaked;
|
||||||
};
|
};
|
|
@ -1,7 +1,7 @@
|
||||||
#include "Color.hpp"
|
#include "Color.hpp"
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
|
|
||||||
CColor::CColor() { }
|
CColor::CColor() {}
|
||||||
|
|
||||||
CColor::CColor(float r, float g, float b, float a) {
|
CColor::CColor(float r, float g, float b, float a) {
|
||||||
this->r = r;
|
this->r = r;
|
||||||
|
|
|
@ -3,24 +3,24 @@
|
||||||
#include "../includes.hpp"
|
#include "../includes.hpp"
|
||||||
|
|
||||||
class CColor {
|
class CColor {
|
||||||
public:
|
public:
|
||||||
CColor();
|
CColor();
|
||||||
CColor(float, float, float, float);
|
CColor(float, float, float, float);
|
||||||
CColor(uint64_t);
|
CColor(uint64_t);
|
||||||
|
|
||||||
float r = 0, g = 0, b = 0, a = 255;
|
float r = 0, g = 0, b = 0, a = 255;
|
||||||
|
|
||||||
uint64_t getAsHex();
|
uint64_t getAsHex();
|
||||||
|
|
||||||
CColor operator- (const CColor& c2) const {
|
CColor operator-(const CColor& c2) const {
|
||||||
return CColor(r - c2.r, g - c2.g, b - c2.b, a - c2.a);
|
return CColor(r - c2.r, g - c2.g, b - c2.b, a - c2.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
CColor operator+ (const CColor& c2) const {
|
CColor operator+(const CColor& c2) const {
|
||||||
return CColor(r + c2.r, g + c2.g, b + c2.b, a + c2.a);
|
return CColor(r + c2.r, g + c2.g, b + c2.b, a + c2.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
CColor operator* (const float& v) const {
|
CColor operator*(const float& v) const {
|
||||||
return CColor(r * v, g * v, b * v, a * v);
|
return CColor(r * v, g * v, b * v, a * v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,29 +5,28 @@
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
#if defined(__DragonFly__) || defined(__FreeBSD__) || \
|
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
#include <sys/sysctl.h>
|
||||||
# include <sys/sysctl.h>
|
#if defined(__DragonFly__)
|
||||||
# if defined(__DragonFly__)
|
#include <sys/kinfo.h> // struct kinfo_proc
|
||||||
# include <sys/kinfo.h> // struct kinfo_proc
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
#include <sys/user.h> // struct kinfo_proc
|
||||||
# include <sys/user.h> // struct kinfo_proc
|
#endif
|
||||||
# endif
|
|
||||||
|
|
||||||
# if defined(__NetBSD__)
|
#if defined(__NetBSD__)
|
||||||
# undef KERN_PROC
|
#undef KERN_PROC
|
||||||
# define KERN_PROC KERN_PROC2
|
#define KERN_PROC KERN_PROC2
|
||||||
# define KINFO_PROC struct kinfo_proc2
|
#define KINFO_PROC struct kinfo_proc2
|
||||||
# else
|
#else
|
||||||
# define KINFO_PROC struct kinfo_proc
|
#define KINFO_PROC struct kinfo_proc
|
||||||
# endif
|
#endif
|
||||||
# if defined(__DragonFly__)
|
#if defined(__DragonFly__)
|
||||||
# define KP_PPID(kp) kp.kp_ppid
|
#define KP_PPID(kp) kp.kp_ppid
|
||||||
# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||||
# define KP_PPID(kp) kp.ki_ppid
|
#define KP_PPID(kp) kp.ki_ppid
|
||||||
# else
|
#else
|
||||||
# define KP_PPID(kp) kp.p_ppid
|
#define KP_PPID(kp) kp.p_ppid
|
||||||
# endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const float transforms[][9] = {{
|
static const float transforms[][9] = {{
|
||||||
|
@ -87,7 +86,7 @@ std::string absolutePath(const std::string& rawpath, const std::string& currentP
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addWLSignal(wl_signal* pSignal, wl_listener* pListener, void* pOwner, std::string ownerString) {
|
void addWLSignal(wl_signal* pSignal, wl_listener* pListener, void* pOwner, const std::string& ownerString) {
|
||||||
ASSERT(pSignal);
|
ASSERT(pSignal);
|
||||||
ASSERT(pListener);
|
ASSERT(pListener);
|
||||||
|
|
||||||
|
@ -96,12 +95,12 @@ void addWLSignal(wl_signal* pSignal, wl_listener* pListener, void* pOwner, std::
|
||||||
Debug::log(LOG, "Registered signal for owner %x: %x -> %x (owner: %s)", pOwner, pSignal, pListener, ownerString.c_str());
|
Debug::log(LOG, "Registered signal for owner %x: %x -> %x (owner: %s)", pOwner, pSignal, pListener, ownerString.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleNoop(struct wl_listener *listener, void *data) {
|
void handleNoop(struct wl_listener* listener, void* data) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getFormat(const char *fmt, ...) {
|
std::string getFormat(const char* fmt, ...) {
|
||||||
char* outputStr = nullptr;
|
char* outputStr = nullptr;
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
|
@ -116,32 +115,31 @@ std::string getFormat(const char *fmt, ...) {
|
||||||
|
|
||||||
std::string escapeJSONStrings(const std::string& str) {
|
std::string escapeJSONStrings(const std::string& str) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
for (auto &c : str) {
|
for (auto& c : str) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '"': oss << "\\\""; break;
|
case '"': oss << "\\\""; break;
|
||||||
case '\\': oss << "\\\\"; break;
|
case '\\': oss << "\\\\"; break;
|
||||||
case '\b': oss << "\\b"; break;
|
case '\b': oss << "\\b"; break;
|
||||||
case '\f': oss << "\\f"; break;
|
case '\f': oss << "\\f"; break;
|
||||||
case '\n': oss << "\\n"; break;
|
case '\n': oss << "\\n"; break;
|
||||||
case '\r': oss << "\\r"; break;
|
case '\r': oss << "\\r"; break;
|
||||||
case '\t': oss << "\\t"; break;
|
case '\t': oss << "\\t"; break;
|
||||||
default:
|
default:
|
||||||
if ('\x00' <= c && c <= '\x1f') {
|
if ('\x00' <= c && c <= '\x1f') {
|
||||||
oss << "\\u"
|
oss << "\\u" << std::hex << std::setw(4) << std::setfill('0') << static_cast<int>(c);
|
||||||
<< std::hex << std::setw(4) << std::setfill('0') << static_cast<int>(c);
|
} else {
|
||||||
} else {
|
oss << c;
|
||||||
oss << c;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void scaleBox(wlr_box* box, float scale) {
|
void scaleBox(wlr_box* box, float scale) {
|
||||||
box->width = std::round(box->width * scale);
|
box->width = std::round(box->width * scale);
|
||||||
box->height = std::round(box->height * scale);
|
box->height = std::round(box->height * scale);
|
||||||
box->x = std::round(box->x * scale);
|
box->x = std::round(box->x * scale);
|
||||||
box->y = std::round(box->y * scale);
|
box->y = std::round(box->y * scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string removeBeginEndSpacesTabs(std::string str) {
|
std::string removeBeginEndSpacesTabs(std::string str) {
|
||||||
|
@ -166,9 +164,9 @@ std::string removeBeginEndSpacesTabs(std::string str) {
|
||||||
float getPlusMinusKeywordResult(std::string source, float relative) {
|
float getPlusMinusKeywordResult(std::string source, float relative) {
|
||||||
float result = INT_MAX;
|
float result = INT_MAX;
|
||||||
|
|
||||||
if (source.find_first_of("+") == 0) {
|
if (source[0] == '+') {
|
||||||
try {
|
try {
|
||||||
if (source.contains("."))
|
if (source.contains('.'))
|
||||||
result = relative + std::stof(source.substr(1));
|
result = relative + std::stof(source.substr(1));
|
||||||
else
|
else
|
||||||
result = relative + std::stoi(source.substr(1));
|
result = relative + std::stoi(source.substr(1));
|
||||||
|
@ -176,9 +174,9 @@ float getPlusMinusKeywordResult(std::string source, float relative) {
|
||||||
Debug::log(ERR, "Invalid arg \"%s\" in getPlusMinusKeywordResult!", source.c_str());
|
Debug::log(ERR, "Invalid arg \"%s\" in getPlusMinusKeywordResult!", source.c_str());
|
||||||
return INT_MAX;
|
return INT_MAX;
|
||||||
}
|
}
|
||||||
} else if (source.find_first_of("-") == 0) {
|
} else if (source[0] == '-') {
|
||||||
try {
|
try {
|
||||||
if (source.contains("."))
|
if (source.contains('.'))
|
||||||
result = relative - std::stof(source.substr(1));
|
result = relative - std::stof(source.substr(1));
|
||||||
else
|
else
|
||||||
result = relative - std::stoi(source.substr(1));
|
result = relative - std::stoi(source.substr(1));
|
||||||
|
@ -188,7 +186,7 @@ float getPlusMinusKeywordResult(std::string source, float relative) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
if (source.contains("."))
|
if (source.contains('.'))
|
||||||
result = stof(source);
|
result = stof(source);
|
||||||
else
|
else
|
||||||
result = stoi(source);
|
result = stoi(source);
|
||||||
|
@ -239,7 +237,7 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
||||||
const auto NAME = in.substr(8);
|
const auto NAME = in.substr(8);
|
||||||
|
|
||||||
const auto WS = g_pCompositor->getWorkspaceByName("special:" + NAME);
|
const auto WS = g_pCompositor->getWorkspaceByName("special:" + NAME);
|
||||||
|
|
||||||
outName = "special:" + NAME;
|
outName = "special:" + NAME;
|
||||||
|
|
||||||
return WS ? WS->m_iID : g_pCompositor->getNewSpecialID();
|
return WS ? WS->m_iID : g_pCompositor->getNewSpecialID();
|
||||||
|
@ -248,7 +246,7 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
||||||
return SPECIAL_WORKSPACE_START;
|
return SPECIAL_WORKSPACE_START;
|
||||||
} else if (in.find("name:") == 0) {
|
} else if (in.find("name:") == 0) {
|
||||||
const auto WORKSPACENAME = in.substr(in.find_first_of(':') + 1);
|
const auto WORKSPACENAME = in.substr(in.find_first_of(':') + 1);
|
||||||
const auto WORKSPACE = g_pCompositor->getWorkspaceByName(WORKSPACENAME);
|
const auto WORKSPACE = g_pCompositor->getWorkspaceByName(WORKSPACENAME);
|
||||||
if (!WORKSPACE) {
|
if (!WORKSPACE) {
|
||||||
result = g_pCompositor->getNextAvailableNamedWorkspace();
|
result = g_pCompositor->getNextAvailableNamedWorkspace();
|
||||||
} else {
|
} else {
|
||||||
|
@ -276,8 +274,8 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
||||||
result = (int)getPlusMinusKeywordResult(in.substr(1), 0);
|
result = (int)getPlusMinusKeywordResult(in.substr(1), 0);
|
||||||
|
|
||||||
// result now has +/- what we should move on mon
|
// result now has +/- what we should move on mon
|
||||||
int remains = (int)result;
|
int remains = (int)result;
|
||||||
|
|
||||||
std::vector<int> validWSes;
|
std::vector<int> validWSes;
|
||||||
for (auto& ws : g_pCompositor->m_vWorkspaces) {
|
for (auto& ws : g_pCompositor->m_vWorkspaces) {
|
||||||
if (ws->m_bIsSpecialWorkspace || (ws->m_iMonitorID != g_pCompositor->m_pLastMonitor->ID && !onAllMonitors))
|
if (ws->m_bIsSpecialWorkspace || (ws->m_iMonitorID != g_pCompositor->m_pLastMonitor->ID && !onAllMonitors))
|
||||||
|
@ -310,7 +308,7 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
||||||
currentItem = validWSes.size() + currentItem;
|
currentItem = validWSes.size() + currentItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = validWSes[currentItem];
|
result = validWSes[currentItem];
|
||||||
outName = g_pCompositor->getWorkspaceByID(validWSes[currentItem])->m_szName;
|
outName = g_pCompositor->getWorkspaceByID(validWSes[currentItem])->m_szName;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -345,8 +343,8 @@ float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Ve
|
||||||
|
|
||||||
// Execute a shell command and get the output
|
// Execute a shell command and get the output
|
||||||
std::string execAndGet(const char* cmd) {
|
std::string execAndGet(const char* cmd) {
|
||||||
std::array<char, 128> buffer;
|
std::array<char, 128> buffer;
|
||||||
std::string result;
|
std::string result;
|
||||||
const std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
const std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
||||||
if (!pipe) {
|
if (!pipe) {
|
||||||
Debug::log(ERR, "execAndGet: failed in pipe");
|
Debug::log(ERR, "execAndGet: failed in pipe");
|
||||||
|
@ -387,8 +385,8 @@ void matrixProjection(float mat[9], int w, int h, wl_output_transform tr) {
|
||||||
memset(mat, 0, sizeof(*mat) * 9);
|
memset(mat, 0, sizeof(*mat) * 9);
|
||||||
|
|
||||||
const float* t = transforms[tr];
|
const float* t = transforms[tr];
|
||||||
float x = 2.0f / w;
|
float x = 2.0f / w;
|
||||||
float y = 2.0f / h;
|
float y = 2.0f / h;
|
||||||
|
|
||||||
// Rotation + reflection
|
// Rotation + reflection
|
||||||
mat[0] = x * t[0];
|
mat[0] = x * t[0];
|
||||||
|
@ -411,35 +409,35 @@ int64_t getPPIDof(int64_t pid) {
|
||||||
KERN_PROC,
|
KERN_PROC,
|
||||||
KERN_PROC_PID,
|
KERN_PROC_PID,
|
||||||
(int)pid,
|
(int)pid,
|
||||||
# if defined(__NetBSD__) || defined(__OpenBSD__)
|
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||||
sizeof(KINFO_PROC),
|
sizeof(KINFO_PROC),
|
||||||
1,
|
1,
|
||||||
# endif
|
#endif
|
||||||
};
|
};
|
||||||
u_int miblen = sizeof(mib) / sizeof(mib[0]);
|
u_int miblen = sizeof(mib) / sizeof(mib[0]);
|
||||||
KINFO_PROC kp;
|
KINFO_PROC kp;
|
||||||
size_t sz = sizeof(KINFO_PROC);
|
size_t sz = sizeof(KINFO_PROC);
|
||||||
if (sysctl(mib, miblen, &kp, &sz, NULL, 0) != -1)
|
if (sysctl(mib, miblen, &kp, &sz, NULL, 0) != -1)
|
||||||
return KP_PPID(kp);
|
return KP_PPID(kp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
std::string dir = "/proc/" + std::to_string(pid) + "/status";
|
std::string dir = "/proc/" + std::to_string(pid) + "/status";
|
||||||
FILE* infile;
|
FILE* infile;
|
||||||
|
|
||||||
infile = fopen(dir.c_str(), "r");
|
infile = fopen(dir.c_str(), "r");
|
||||||
if (!infile)
|
if (!infile)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
char* line = nullptr;
|
char* line = nullptr;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
ssize_t len2 = 0;
|
ssize_t len2 = 0;
|
||||||
|
|
||||||
std::string pidstr;
|
std::string pidstr;
|
||||||
|
|
||||||
while ((len2 = getline(&line, &len, infile)) != -1) {
|
while ((len2 = getline(&line, &len, infile)) != -1) {
|
||||||
if (strstr(line, "PPid:")) {
|
if (strstr(line, "PPid:")) {
|
||||||
pidstr = std::string(line, len2);
|
pidstr = std::string(line, len2);
|
||||||
const auto tabpos = pidstr.find_last_of('\t');
|
const auto tabpos = pidstr.find_last_of('\t');
|
||||||
if (tabpos != std::string::npos)
|
if (tabpos != std::string::npos)
|
||||||
pidstr = pidstr.substr(tabpos);
|
pidstr = pidstr.substr(tabpos);
|
||||||
|
@ -453,9 +451,7 @@ int64_t getPPIDof(int64_t pid) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return std::stoll(pidstr);
|
return std::stoll(pidstr);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +460,7 @@ int64_t configStringToInt(const std::string& VALUE) {
|
||||||
// Values with 0x are hex
|
// Values with 0x are hex
|
||||||
const auto VALUEWITHOUTHEX = VALUE.substr(2);
|
const auto VALUEWITHOUTHEX = VALUE.substr(2);
|
||||||
return stol(VALUEWITHOUTHEX, nullptr, 16);
|
return stol(VALUEWITHOUTHEX, nullptr, 16);
|
||||||
} else if (VALUE.find("rgba(") == 0 && VALUE.find(")") == VALUE.length() - 1) {
|
} else if (VALUE.find("rgba(") == 0 && VALUE.find(')') == VALUE.length() - 1) {
|
||||||
const auto VALUEWITHOUTFUNC = VALUE.substr(5, VALUE.length() - 6);
|
const auto VALUEWITHOUTFUNC = VALUE.substr(5, VALUE.length() - 6);
|
||||||
|
|
||||||
if (removeBeginEndSpacesTabs(VALUEWITHOUTFUNC).length() != 8) {
|
if (removeBeginEndSpacesTabs(VALUEWITHOUTFUNC).length() != 8) {
|
||||||
|
@ -476,7 +472,7 @@ int64_t configStringToInt(const std::string& VALUE) {
|
||||||
|
|
||||||
// now we need to RGBA -> ARGB. The config holds ARGB only.
|
// now we need to RGBA -> ARGB. The config holds ARGB only.
|
||||||
return (RGBA >> 8) + 0x1000000 * (RGBA & 0xFF);
|
return (RGBA >> 8) + 0x1000000 * (RGBA & 0xFF);
|
||||||
} else if (VALUE.find("rgb(") == 0 && VALUE.find(")") == VALUE.length() - 1) {
|
} else if (VALUE.find("rgb(") == 0 && VALUE.find(')') == VALUE.length() - 1) {
|
||||||
const auto VALUEWITHOUTFUNC = VALUE.substr(4, VALUE.length() - 5);
|
const auto VALUEWITHOUTFUNC = VALUE.substr(4, VALUE.length() - 5);
|
||||||
|
|
||||||
if (removeBeginEndSpacesTabs(VALUEWITHOUTFUNC).length() != 6) {
|
if (removeBeginEndSpacesTabs(VALUEWITHOUTFUNC).length() != 6) {
|
||||||
|
|
|
@ -3,20 +3,20 @@
|
||||||
#include "../includes.hpp"
|
#include "../includes.hpp"
|
||||||
|
|
||||||
std::string absolutePath(const std::string&, const std::string&);
|
std::string absolutePath(const std::string&, const std::string&);
|
||||||
void addWLSignal(wl_signal*, wl_listener*, void* pOwner, std::string ownerString);
|
void addWLSignal(wl_signal*, wl_listener*, void* pOwner, const std::string& ownerString);
|
||||||
std::string getFormat(const char *fmt, ...); // Basically Debug::log to a string
|
std::string getFormat(const char* fmt, ...); // Basically Debug::log to a string
|
||||||
std::string escapeJSONStrings(const std::string& str);
|
std::string escapeJSONStrings(const std::string& str);
|
||||||
void scaleBox(wlr_box*, float);
|
void scaleBox(wlr_box*, float);
|
||||||
std::string removeBeginEndSpacesTabs(std::string);
|
std::string removeBeginEndSpacesTabs(std::string);
|
||||||
bool isNumber(const std::string&, bool allowfloat = false);
|
bool isNumber(const std::string&, bool allowfloat = false);
|
||||||
bool isDirection(const std::string&);
|
bool isDirection(const std::string&);
|
||||||
int getWorkspaceIDFromString(const std::string&, std::string&);
|
int getWorkspaceIDFromString(const std::string&, std::string&);
|
||||||
float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2);
|
float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2);
|
||||||
void logSystemInfo();
|
void logSystemInfo();
|
||||||
std::string execAndGet(const char*);
|
std::string execAndGet(const char*);
|
||||||
int64_t getPPIDof(int64_t pid);
|
int64_t getPPIDof(int64_t pid);
|
||||||
int64_t configStringToInt(const std::string&);
|
int64_t configStringToInt(const std::string&);
|
||||||
|
|
||||||
float getPlusMinusKeywordResult(std::string in, float relative);
|
float getPlusMinusKeywordResult(std::string in, float relative);
|
||||||
|
|
||||||
void matrixProjection(float mat[9], int w, int h, wl_output_transform tr);
|
void matrixProjection(float mat[9], int w, int h, wl_output_transform tr);
|
||||||
|
|
|
@ -67,15 +67,15 @@ void CMonitor::onConnect(bool noRule) {
|
||||||
|
|
||||||
if (output->non_desktop) {
|
if (output->non_desktop) {
|
||||||
Debug::log(LOG, "Not configuring non-desktop output");
|
Debug::log(LOG, "Not configuring non-desktop output");
|
||||||
if (g_pCompositor->m_sWRLDRMLeaseMgr) {
|
if (g_pCompositor->m_sWRLDRMLeaseMgr) {
|
||||||
wlr_drm_lease_v1_manager_offer_output(g_pCompositor->m_sWRLDRMLeaseMgr, output);
|
wlr_drm_lease_v1_manager_offer_output(g_pCompositor->m_sWRLDRMLeaseMgr, output);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_bRenderingInitPassed) {
|
if (!m_bRenderingInitPassed) {
|
||||||
output->allocator = nullptr;
|
output->allocator = nullptr;
|
||||||
output->renderer = nullptr;
|
output->renderer = nullptr;
|
||||||
wlr_output_init_render(output, g_pCompositor->m_sWLRAllocator, g_pCompositor->m_sWLRRenderer);
|
wlr_output_init_render(output, g_pCompositor->m_sWLRAllocator, g_pCompositor->m_sWLRRenderer);
|
||||||
m_bRenderingInitPassed = true;
|
m_bRenderingInitPassed = true;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ void CMonitor::onConnect(bool noRule) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::find_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](auto& other) { return other.get() == this; }) == g_pCompositor->m_vMonitors.end()){
|
if (std::find_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](auto& other) { return other.get() == this; }) == g_pCompositor->m_vMonitors.end()) {
|
||||||
g_pCompositor->m_vMonitors.push_back(*m_pThisWrap);
|
g_pCompositor->m_vMonitors.push_back(*m_pThisWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ void CMonitor::onConnect(bool noRule) {
|
||||||
|
|
||||||
// create it in the arr
|
// create it in the arr
|
||||||
vecPosition = monitorRule.offset;
|
vecPosition = monitorRule.offset;
|
||||||
vecSize = monitorRule.resolution;
|
vecSize = monitorRule.resolution;
|
||||||
refreshRate = monitorRule.refreshRate;
|
refreshRate = monitorRule.refreshRate;
|
||||||
|
|
||||||
wlr_output_enable(output, 1);
|
wlr_output_enable(output, 1);
|
||||||
|
@ -110,7 +110,8 @@ void CMonitor::onConnect(bool noRule) {
|
||||||
|
|
||||||
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, scale);
|
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, scale);
|
||||||
|
|
||||||
Debug::log(LOG, "Added new monitor with name %s at %i,%i with size %ix%i, pointer %x", output->name, (int)vecPosition.x, (int)vecPosition.y, (int)vecPixelSize.x, (int)vecPixelSize.y, output);
|
Debug::log(LOG, "Added new monitor with name %s at %i,%i with size %ix%i, pointer %x", output->name, (int)vecPosition.x, (int)vecPosition.y, (int)vecPixelSize.x,
|
||||||
|
(int)vecPixelSize.y, output);
|
||||||
|
|
||||||
damage = wlr_output_damage_create(output);
|
damage = wlr_output_damage_create(output);
|
||||||
|
|
||||||
|
@ -127,12 +128,12 @@ void CMonitor::onConnect(bool noRule) {
|
||||||
|
|
||||||
m_pThisWrap = nullptr;
|
m_pThisWrap = nullptr;
|
||||||
|
|
||||||
forceFullFrames = 3; // force 3 full frames to make sure there is no blinking due to double-buffering.
|
forceFullFrames = 3; // force 3 full frames to make sure there is no blinking due to double-buffering.
|
||||||
//
|
//
|
||||||
|
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", szName});
|
g_pEventManager->postEvent(SHyprIPCEvent{"monitoradded", szName});
|
||||||
|
|
||||||
if (!g_pCompositor->m_pLastMonitor) // set the last monitor if it isnt set yet
|
if (!g_pCompositor->m_pLastMonitor) // set the last monitor if it isnt set yet
|
||||||
g_pCompositor->setActiveMonitor(this);
|
g_pCompositor->setActiveMonitor(this);
|
||||||
|
|
||||||
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, scale);
|
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, scale);
|
||||||
|
@ -189,7 +190,7 @@ void CMonitor::onDisconnect() {
|
||||||
g_pConfigManager->m_bWantsMonitorReload = true;
|
g_pConfigManager->m_bWantsMonitorReload = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_bEnabled = false;
|
m_bEnabled = false;
|
||||||
m_bRenderingInitPassed = false;
|
m_bRenderingInitPassed = false;
|
||||||
|
|
||||||
hyprListener_monitorFrame.removeCallback();
|
hyprListener_monitorFrame.removeCallback();
|
||||||
|
@ -206,7 +207,8 @@ void CMonitor::onDisconnect() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// snap cursor
|
// snap cursor
|
||||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, BACKUPMON->vecPosition.x + BACKUPMON->vecTransformedSize.x / 2.f, BACKUPMON->vecPosition.y + BACKUPMON->vecTransformedSize.y / 2.f);
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, BACKUPMON->vecPosition.x + BACKUPMON->vecTransformedSize.x / 2.f,
|
||||||
|
BACKUPMON->vecPosition.y + BACKUPMON->vecTransformedSize.y / 2.f);
|
||||||
|
|
||||||
// move workspaces
|
// move workspaces
|
||||||
std::deque<CWorkspace*> wspToMove;
|
std::deque<CWorkspace*> wspToMove;
|
||||||
|
@ -259,7 +261,7 @@ int CMonitor::findAvailableDefaultWS() {
|
||||||
|
|
||||||
if (const auto BOUND = g_pConfigManager->getBoundMonitorStringForWS(std::to_string(i)); !BOUND.empty() && BOUND != szName)
|
if (const auto BOUND = g_pConfigManager->getBoundMonitorStringForWS(std::to_string(i)); !BOUND.empty() && BOUND != szName)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,10 +271,10 @@ int CMonitor::findAvailableDefaultWS() {
|
||||||
void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {
|
void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {
|
||||||
// Workspace
|
// Workspace
|
||||||
std::string newDefaultWorkspaceName = "";
|
std::string newDefaultWorkspaceName = "";
|
||||||
int64_t WORKSPACEID = monitorRule.defaultWorkspace == "" ? findAvailableDefaultWS() : getWorkspaceIDFromString(monitorRule.defaultWorkspace, newDefaultWorkspaceName);
|
int64_t WORKSPACEID = monitorRule.defaultWorkspace == "" ? findAvailableDefaultWS() : getWorkspaceIDFromString(monitorRule.defaultWorkspace, newDefaultWorkspaceName);
|
||||||
|
|
||||||
if (WORKSPACEID == INT_MAX || (WORKSPACEID >= SPECIAL_WORKSPACE_START && WORKSPACEID <= -2)) {
|
if (WORKSPACEID == INT_MAX || (WORKSPACEID >= SPECIAL_WORKSPACE_START && WORKSPACEID <= -2)) {
|
||||||
WORKSPACEID = g_pCompositor->m_vWorkspaces.size() + 1;
|
WORKSPACEID = g_pCompositor->m_vWorkspaces.size() + 1;
|
||||||
newDefaultWorkspaceName = std::to_string(WORKSPACEID);
|
newDefaultWorkspaceName = std::to_string(WORKSPACEID);
|
||||||
|
|
||||||
Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"%s\" is invalid.", monitorRule.defaultWorkspace.c_str());
|
Debug::log(LOG, "Invalid workspace= directive name in monitor parsing, workspace name \"%s\" is invalid.", monitorRule.defaultWorkspace.c_str());
|
||||||
|
@ -347,7 +349,8 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::find_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](auto& other) { return other.get() == this; }) == g_pCompositor->m_vMonitors.end()) {
|
if (std::find_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](auto& other) { return other.get() == this; }) ==
|
||||||
|
g_pCompositor->m_vMonitors.end()) {
|
||||||
g_pCompositor->m_vMonitors.push_back(*m_pThisWrap);
|
g_pCompositor->m_vMonitors.push_back(*m_pThisWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,9 +390,7 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
|
||||||
pMirrorOf->mirrors.push_back(this);
|
pMirrorOf->mirrors.push_back(this);
|
||||||
|
|
||||||
// remove from mvmonitors
|
// remove from mvmonitors
|
||||||
if (std::find_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](auto& other) { return other.get() == this; }) != g_pCompositor->m_vMonitors.end()) {
|
std::erase_if(g_pCompositor->m_vMonitors, [&](const auto& other) { return other.get() == this; });
|
||||||
g_pCompositor->m_vMonitors.erase(std::remove_if(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), [&](const auto& other) { return other.get() == this; }));
|
|
||||||
}
|
|
||||||
|
|
||||||
g_pCompositor->setActiveMonitor(g_pCompositor->m_vMonitors.front().get());
|
g_pCompositor->setActiveMonitor(g_pCompositor->m_vMonitors.front().get());
|
||||||
}
|
}
|
||||||
|
@ -401,10 +402,10 @@ float CMonitor::getDefaultScale() {
|
||||||
|
|
||||||
static constexpr double MMPERINCH = 25.4;
|
static constexpr double MMPERINCH = 25.4;
|
||||||
|
|
||||||
const auto DIAGONALPX = sqrt(pow(vecPixelSize.x, 2) + pow(vecPixelSize.y, 2));
|
const auto DIAGONALPX = sqrt(pow(vecPixelSize.x, 2) + pow(vecPixelSize.y, 2));
|
||||||
const auto DIAGONALIN = sqrt(pow(output->phys_width / MMPERINCH, 2) + pow(output->phys_height / MMPERINCH, 2));
|
const auto DIAGONALIN = sqrt(pow(output->phys_width / MMPERINCH, 2) + pow(output->phys_height / MMPERINCH, 2));
|
||||||
|
|
||||||
const auto PPI = DIAGONALPX / DIAGONALIN;
|
const auto PPI = DIAGONALPX / DIAGONALIN;
|
||||||
|
|
||||||
if (PPI > 200 /* High PPI, 2x*/)
|
if (PPI > 200 /* High PPI, 2x*/)
|
||||||
return 2;
|
return 2;
|
||||||
|
|
|
@ -10,49 +10,49 @@
|
||||||
struct SMonitorRule;
|
struct SMonitorRule;
|
||||||
|
|
||||||
class CMonitor {
|
class CMonitor {
|
||||||
public:
|
public:
|
||||||
Vector2D vecPosition = Vector2D(-1,-1); // means unset
|
Vector2D vecPosition = Vector2D(-1, -1); // means unset
|
||||||
Vector2D vecSize = Vector2D(0,0);
|
Vector2D vecSize = Vector2D(0, 0);
|
||||||
Vector2D vecPixelSize = Vector2D(0,0);
|
Vector2D vecPixelSize = Vector2D(0, 0);
|
||||||
Vector2D vecTransformedSize = Vector2D(0,0);
|
Vector2D vecTransformedSize = Vector2D(0, 0);
|
||||||
|
|
||||||
bool primary = false;
|
bool primary = false;
|
||||||
|
|
||||||
uint64_t ID = -1;
|
uint64_t ID = -1;
|
||||||
int activeWorkspace = -1;
|
int activeWorkspace = -1;
|
||||||
float scale = 1;
|
float scale = 1;
|
||||||
|
|
||||||
std::string szName = "";
|
std::string szName = "";
|
||||||
|
|
||||||
Vector2D vecReservedTopLeft = Vector2D(0,0);
|
Vector2D vecReservedTopLeft = Vector2D(0, 0);
|
||||||
Vector2D vecReservedBottomRight = Vector2D(0,0);
|
Vector2D vecReservedBottomRight = Vector2D(0, 0);
|
||||||
|
|
||||||
// WLR stuff
|
// WLR stuff
|
||||||
wlr_output* output = nullptr;
|
wlr_output* output = nullptr;
|
||||||
float refreshRate = 60;
|
float refreshRate = 60;
|
||||||
wlr_output_damage* damage = nullptr;
|
wlr_output_damage* damage = nullptr;
|
||||||
int framesToSkip = 0;
|
int framesToSkip = 0;
|
||||||
int forceFullFrames = 0;
|
int forceFullFrames = 0;
|
||||||
bool noFrameSchedule = false;
|
bool noFrameSchedule = false;
|
||||||
bool scheduledRecalc = false;
|
bool scheduledRecalc = false;
|
||||||
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||||
|
|
||||||
bool dpmsStatus = true;
|
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 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 enabled10bit = false; // as above, this can be TRUE even if 10 bit failed.
|
||||||
bool createdByUser = false;
|
bool createdByUser = false;
|
||||||
|
|
||||||
// mirroring
|
// mirroring
|
||||||
CMonitor* pMirrorOf = nullptr;
|
CMonitor* pMirrorOf = nullptr;
|
||||||
std::vector<CMonitor*> mirrors;
|
std::vector<CMonitor*> mirrors;
|
||||||
|
|
||||||
// for the special workspace. 0 means not open.
|
// for the special workspace. 0 means not open.
|
||||||
int specialWorkspaceID = 0;
|
int specialWorkspaceID = 0;
|
||||||
|
|
||||||
// Double-linked list because we need to have constant mem addresses for signals
|
// Double-linked list because we need to have constant mem addresses for signals
|
||||||
// We have to store pointers and use raw new/delete because they might be moved between them
|
// We have to store pointers and use raw new/delete because they might be moved between them
|
||||||
// and I am lazy
|
// and I am lazy
|
||||||
std::array<std::vector<std::unique_ptr<SLayerSurface>>, 4> m_aLayerSurfaceLists;
|
std::array<std::vector<std::unique_ptr<SLayerSurface>>, 4> m_aLayerSurfaceLists;
|
||||||
|
|
||||||
DYNLISTENER(monitorFrame);
|
DYNLISTENER(monitorFrame);
|
||||||
DYNLISTENER(monitorDestroy);
|
DYNLISTENER(monitorDestroy);
|
||||||
|
@ -62,19 +62,18 @@ public:
|
||||||
// I don't really care lol :P
|
// I don't really care lol :P
|
||||||
wlr_ext_workspace_group_handle_v1* pWLRWorkspaceGroupHandle = nullptr;
|
wlr_ext_workspace_group_handle_v1* pWLRWorkspaceGroupHandle = nullptr;
|
||||||
|
|
||||||
|
|
||||||
// methods
|
// methods
|
||||||
void onConnect(bool noRule);
|
void onConnect(bool noRule);
|
||||||
void onDisconnect();
|
void onDisconnect();
|
||||||
void addDamage(pixman_region32_t* rg);
|
void addDamage(pixman_region32_t* rg);
|
||||||
void addDamage(wlr_box* box);
|
void addDamage(wlr_box* box);
|
||||||
void setMirror(const std::string&);
|
void setMirror(const std::string&);
|
||||||
bool isMirror();
|
bool isMirror();
|
||||||
float getDefaultScale();
|
float getDefaultScale();
|
||||||
|
|
||||||
std::shared_ptr<CMonitor>* m_pThisWrap = nullptr;
|
std::shared_ptr<CMonitor>* m_pThisWrap = nullptr;
|
||||||
bool m_bEnabled = false;
|
bool m_bEnabled = false;
|
||||||
bool m_bRenderingInitPassed = false;
|
bool m_bRenderingInitPassed = false;
|
||||||
|
|
||||||
// For the list lookup
|
// For the list lookup
|
||||||
|
|
||||||
|
@ -82,7 +81,7 @@ public:
|
||||||
return vecPosition == rhs.vecPosition && vecSize == rhs.vecSize && szName == rhs.szName;
|
return vecPosition == rhs.vecPosition && vecSize == rhs.vecSize && szName == rhs.szName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupDefaultWS(const SMonitorRule&);
|
void setupDefaultWS(const SMonitorRule&);
|
||||||
int findAvailableDefaultWS();
|
int findAvailableDefaultWS();
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,7 @@ void addSurfaceGlobalOffset(SSurfaceTreeNode* node, int* lx, int* ly) {
|
||||||
SSurfaceTreeNode* createTree(wlr_surface* pSurface, CWindow* pWindow) {
|
SSurfaceTreeNode* createTree(wlr_surface* pSurface, CWindow* pWindow) {
|
||||||
const auto PNODE = &SubsurfaceTree::surfaceTreeNodes.emplace_back();
|
const auto PNODE = &SubsurfaceTree::surfaceTreeNodes.emplace_back();
|
||||||
|
|
||||||
PNODE->pSurface = pSurface;
|
PNODE->pSurface = pSurface;
|
||||||
PNODE->pWindowOwner = pWindow;
|
PNODE->pWindowOwner = pWindow;
|
||||||
|
|
||||||
PNODE->hyprListener_newSubsurface.initCallback(&pSurface->events.new_subsurface, &Events::listener_newSubsurfaceNode, PNODE, "SurfaceTreeNode");
|
PNODE->hyprListener_newSubsurface.initCallback(&pSurface->events.new_subsurface, &Events::listener_newSubsurfaceNode, PNODE, "SurfaceTreeNode");
|
||||||
|
@ -42,8 +42,8 @@ SSurfaceTreeNode* createTree(wlr_surface* pSurface, CWindow* pWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SSurfaceTreeNode* createSubsurfaceNode(SSurfaceTreeNode* pParent, SSubsurface* pSubsurface, wlr_surface* surface, CWindow* pWindow) {
|
SSurfaceTreeNode* createSubsurfaceNode(SSurfaceTreeNode* pParent, SSubsurface* pSubsurface, wlr_surface* surface, CWindow* pWindow) {
|
||||||
const auto PNODE = createTree(surface, pWindow);
|
const auto PNODE = createTree(surface, pWindow);
|
||||||
PNODE->pParent = pParent;
|
PNODE->pParent = pParent;
|
||||||
PNODE->pSubsurface = pSubsurface;
|
PNODE->pSubsurface = pSubsurface;
|
||||||
|
|
||||||
Debug::log(LOG, "Creating a subsurface Node! (pWindow: %x)", pWindow);
|
Debug::log(LOG, "Creating a subsurface Node! (pWindow: %x)", pWindow);
|
||||||
|
@ -56,7 +56,7 @@ SSurfaceTreeNode* SubsurfaceTree::createTreeRoot(wlr_surface* pSurface, applyGlo
|
||||||
|
|
||||||
Debug::log(LOG, "Creating a surfaceTree Root! (pWindow: %x)", pWindow);
|
Debug::log(LOG, "Creating a surfaceTree Root! (pWindow: %x)", pWindow);
|
||||||
|
|
||||||
PNODE->offsetfn = fn;
|
PNODE->offsetfn = fn;
|
||||||
PNODE->globalOffsetData = data;
|
PNODE->globalOffsetData = data;
|
||||||
|
|
||||||
return PNODE;
|
return PNODE;
|
||||||
|
@ -74,8 +74,8 @@ void SubsurfaceTree::destroySurfaceTree(SSurfaceTreeNode* pNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
Debug::log(ERR, "Tried to remove a SurfaceTreeNode that doesn't exist?? (Node %x)", pNode);
|
Debug::log(ERR, "Tried to remove a SurfaceTreeNode that doesn't exist?? (Node %x)", pNode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& c : pNode->childSubsurfaces)
|
for (auto& c : pNode->childSubsurfaces)
|
||||||
|
@ -132,14 +132,14 @@ void destroySubsurface(SSubsurface* pSubsurface) {
|
||||||
void Events::listener_newSubsurfaceNode(void* owner, void* data) {
|
void Events::listener_newSubsurfaceNode(void* owner, void* data) {
|
||||||
SSurfaceTreeNode* pNode = (SSurfaceTreeNode*)owner;
|
SSurfaceTreeNode* pNode = (SSurfaceTreeNode*)owner;
|
||||||
|
|
||||||
const auto PSUBSURFACE = (wlr_subsurface*)data;
|
const auto PSUBSURFACE = (wlr_subsurface*)data;
|
||||||
|
|
||||||
const auto PNEWSUBSURFACE = &pNode->childSubsurfaces.emplace_back();
|
const auto PNEWSUBSURFACE = &pNode->childSubsurfaces.emplace_back();
|
||||||
|
|
||||||
Debug::log(LOG, "Added a new subsurface %x", PSUBSURFACE);
|
Debug::log(LOG, "Added a new subsurface %x", PSUBSURFACE);
|
||||||
|
|
||||||
PNEWSUBSURFACE->pSubsurface = PSUBSURFACE;
|
PNEWSUBSURFACE->pSubsurface = PSUBSURFACE;
|
||||||
PNEWSUBSURFACE->pParent = pNode;
|
PNEWSUBSURFACE->pParent = pNode;
|
||||||
|
|
||||||
PNEWSUBSURFACE->hyprListener_map.initCallback(&PSUBSURFACE->events.map, &Events::listener_mapSubsurface, PNEWSUBSURFACE, "Subsurface");
|
PNEWSUBSURFACE->hyprListener_map.initCallback(&PSUBSURFACE->events.map, &Events::listener_mapSubsurface, PNEWSUBSURFACE, "Subsurface");
|
||||||
PNEWSUBSURFACE->hyprListener_unmap.initCallback(&PSUBSURFACE->events.unmap, &Events::listener_unmapSubsurface, PNEWSUBSURFACE, "Subsurface");
|
PNEWSUBSURFACE->hyprListener_unmap.initCallback(&PSUBSURFACE->events.unmap, &Events::listener_unmapSubsurface, PNEWSUBSURFACE, "Subsurface");
|
||||||
|
@ -178,7 +178,8 @@ void Events::listener_unmapSubsurface(void* owner, void* data) {
|
||||||
if (subsurface->pChild) {
|
if (subsurface->pChild) {
|
||||||
const auto PNODE = subsurface->pChild;
|
const auto PNODE = subsurface->pChild;
|
||||||
|
|
||||||
const auto IT = std::find_if(SubsurfaceTree::surfaceTreeNodes.begin(), SubsurfaceTree::surfaceTreeNodes.end(), [&](const SSurfaceTreeNode& other) { return &other == PNODE; });
|
const auto IT =
|
||||||
|
std::find_if(SubsurfaceTree::surfaceTreeNodes.begin(), SubsurfaceTree::surfaceTreeNodes.end(), [&](const SSurfaceTreeNode& other) { return &other == PNODE; });
|
||||||
|
|
||||||
if (IT != SubsurfaceTree::surfaceTreeNodes.end()) {
|
if (IT != SubsurfaceTree::surfaceTreeNodes.end()) {
|
||||||
int lx = 0, ly = 0;
|
int lx = 0, ly = 0;
|
||||||
|
@ -186,7 +187,7 @@ void Events::listener_unmapSubsurface(void* owner, void* data) {
|
||||||
|
|
||||||
wlr_box extents = {lx, ly, 0, 0};
|
wlr_box extents = {lx, ly, 0, 0};
|
||||||
if (PNODE->pSurface) {
|
if (PNODE->pSurface) {
|
||||||
extents.width = PNODE->pSurface->current.width;
|
extents.width = PNODE->pSurface->current.width;
|
||||||
extents.height = PNODE->pSurface->current.height;
|
extents.height = PNODE->pSurface->current.height;
|
||||||
|
|
||||||
g_pHyprRenderer->damageBox(&extents);
|
g_pHyprRenderer->damageBox(&extents);
|
||||||
|
@ -203,7 +204,7 @@ void Events::listener_commitSubsurface(void* owner, void* data) {
|
||||||
|
|
||||||
// no damaging if it's not visible
|
// no damaging if it's not visible
|
||||||
if (!g_pHyprRenderer->shouldRenderWindow(pNode->pWindowOwner)) {
|
if (!g_pHyprRenderer->shouldRenderWindow(pNode->pWindowOwner)) {
|
||||||
static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
|
static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
|
||||||
if (*PLOGDAMAGE)
|
if (*PLOGDAMAGE)
|
||||||
Debug::log(LOG, "Refusing to commit damage from %x because it's invisible.", pNode->pWindowOwner);
|
Debug::log(LOG, "Refusing to commit damage from %x because it's invisible.", pNode->pWindowOwner);
|
||||||
return;
|
return;
|
||||||
|
@ -216,13 +217,14 @@ void Events::listener_commitSubsurface(void* owner, void* data) {
|
||||||
// I do not think this is correct, but it solves a lot of issues with some apps (e.g. firefox)
|
// I do not think this is correct, but it solves a lot of issues with some apps (e.g. firefox)
|
||||||
// What this does is that basically, if the pNode is a child of some other node, on commit,
|
// What this does is that basically, if the pNode is a child of some other node, on commit,
|
||||||
// it will also damage (check & damage if needed) all its siblings.
|
// it will also damage (check & damage if needed) all its siblings.
|
||||||
if (pNode->pParent) for (auto& cs : pNode->pParent->childSubsurfaces) {
|
if (pNode->pParent)
|
||||||
const auto NODECOORDS = pNode->pSubsurface ? Vector2D(pNode->pSubsurface->pSubsurface->current.x, pNode->pSubsurface->pSubsurface->current.y) : Vector2D();
|
for (auto& cs : pNode->pParent->childSubsurfaces) {
|
||||||
|
const auto NODECOORDS = pNode->pSubsurface ? Vector2D(pNode->pSubsurface->pSubsurface->current.x, pNode->pSubsurface->pSubsurface->current.y) : Vector2D();
|
||||||
|
|
||||||
if (&cs != pNode->pSubsurface && cs.pSubsurface) {
|
if (&cs != pNode->pSubsurface && cs.pSubsurface) {
|
||||||
g_pHyprRenderer->damageSurface(cs.pSubsurface->surface, lx - NODECOORDS.x + cs.pSubsurface->current.x, ly - NODECOORDS.y + cs.pSubsurface->current.y);
|
g_pHyprRenderer->damageSurface(cs.pSubsurface->surface, lx - NODECOORDS.x + cs.pSubsurface->current.x, ly - NODECOORDS.y + cs.pSubsurface->current.y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
g_pHyprRenderer->damageSurface(pNode->pSurface, lx, ly);
|
g_pHyprRenderer->damageSurface(pNode->pSurface, lx, ly);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,49 +6,49 @@
|
||||||
struct SSubsurface;
|
struct SSubsurface;
|
||||||
class CWindow;
|
class CWindow;
|
||||||
|
|
||||||
typedef void (*applyGlobalOffsetFn)(void *, int *, int *);
|
typedef void (*applyGlobalOffsetFn)(void*, int*, int*);
|
||||||
|
|
||||||
struct SSurfaceTreeNode {
|
struct SSurfaceTreeNode {
|
||||||
wlr_surface* pSurface = nullptr;
|
wlr_surface* pSurface = nullptr;
|
||||||
|
|
||||||
DYNLISTENER(newSubsurface);
|
DYNLISTENER(newSubsurface);
|
||||||
DYNLISTENER(commit);
|
DYNLISTENER(commit);
|
||||||
DYNLISTENER(destroy);
|
DYNLISTENER(destroy);
|
||||||
|
|
||||||
SSurfaceTreeNode* pParent = nullptr;
|
SSurfaceTreeNode* pParent = nullptr;
|
||||||
SSubsurface* pSubsurface = nullptr;
|
SSubsurface* pSubsurface = nullptr;
|
||||||
|
|
||||||
std::list<SSubsurface> childSubsurfaces;
|
std::list<SSubsurface> childSubsurfaces;
|
||||||
|
|
||||||
applyGlobalOffsetFn offsetfn;
|
applyGlobalOffsetFn offsetfn;
|
||||||
void *globalOffsetData;
|
void* globalOffsetData;
|
||||||
CWindow* pWindowOwner = nullptr;
|
CWindow* pWindowOwner = nullptr;
|
||||||
|
|
||||||
bool operator==(const SSurfaceTreeNode& rhs) {
|
bool operator==(const SSurfaceTreeNode& rhs) {
|
||||||
return pSurface == rhs.pSurface;
|
return pSurface == rhs.pSurface;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SSubsurface {
|
struct SSubsurface {
|
||||||
wlr_subsurface* pSubsurface = nullptr;
|
wlr_subsurface* pSubsurface = nullptr;
|
||||||
|
|
||||||
SSurfaceTreeNode* pParent = nullptr;
|
SSurfaceTreeNode* pParent = nullptr;
|
||||||
SSurfaceTreeNode* pChild = nullptr;
|
SSurfaceTreeNode* pChild = nullptr;
|
||||||
|
|
||||||
DYNLISTENER(map);
|
DYNLISTENER(map);
|
||||||
DYNLISTENER(unmap);
|
DYNLISTENER(unmap);
|
||||||
DYNLISTENER(destroy);
|
DYNLISTENER(destroy);
|
||||||
|
|
||||||
CWindow* pWindowOwner = nullptr;
|
CWindow* pWindowOwner = nullptr;
|
||||||
|
|
||||||
bool operator==(const SSubsurface& rhs) {
|
bool operator==(const SSubsurface& rhs) {
|
||||||
return pSubsurface == rhs.pSubsurface;
|
return pSubsurface == rhs.pSubsurface;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace SubsurfaceTree {
|
namespace SubsurfaceTree {
|
||||||
SSurfaceTreeNode* createTreeRoot(wlr_surface*, applyGlobalOffsetFn, void*, CWindow* pWindow = nullptr);
|
SSurfaceTreeNode* createTreeRoot(wlr_surface*, applyGlobalOffsetFn, void*, CWindow* pWindow = nullptr);
|
||||||
void destroySurfaceTree(SSurfaceTreeNode*);
|
void destroySurfaceTree(SSurfaceTreeNode*);
|
||||||
|
|
||||||
inline std::list<SSurfaceTreeNode> surfaceTreeNodes;
|
inline std::list<SSurfaceTreeNode> surfaceTreeNodes;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
|
|
||||||
class CTimer {
|
class CTimer {
|
||||||
public:
|
public:
|
||||||
void reset();
|
void reset();
|
||||||
float getSeconds();
|
float getSeconds();
|
||||||
int getMillis();
|
int getMillis();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::chrono::system_clock::time_point m_tpLastReset;
|
std::chrono::system_clock::time_point m_tpLastReset;
|
||||||
|
|
||||||
std::chrono::system_clock::duration getDuration();
|
std::chrono::system_clock::duration getDuration();
|
||||||
};
|
};
|
|
@ -6,7 +6,11 @@ Vector2D::Vector2D(double xx, double yy) {
|
||||||
y = yy;
|
y = yy;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2D::Vector2D() { x = 0; y = 0; }
|
Vector2D::Vector2D() {
|
||||||
|
x = 0;
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
Vector2D::~Vector2D() {}
|
Vector2D::~Vector2D() {}
|
||||||
|
|
||||||
double Vector2D::normalize() {
|
double Vector2D::normalize() {
|
||||||
|
@ -24,8 +28,5 @@ Vector2D Vector2D::floor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2D Vector2D::clamp(const Vector2D& min, const Vector2D& max) {
|
Vector2D Vector2D::clamp(const Vector2D& min, const Vector2D& max) {
|
||||||
return Vector2D(
|
return Vector2D(std::clamp(this->x, min.x, max.x == 0 ? INFINITY : max.x), std::clamp(this->y, min.y, max.y == 0 ? INFINITY : max.y));
|
||||||
std::clamp(this->x, min.x, max.x == 0 ? INFINITY : max.x),
|
|
||||||
std::clamp(this->y, min.y, max.y == 0 ? INFINITY : max.y)
|
|
||||||
);
|
|
||||||
}
|
}
|
|
@ -3,7 +3,7 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
class Vector2D {
|
class Vector2D {
|
||||||
public:
|
public:
|
||||||
Vector2D(double, double);
|
Vector2D(double, double);
|
||||||
Vector2D();
|
Vector2D();
|
||||||
~Vector2D();
|
~Vector2D();
|
||||||
|
@ -12,18 +12,18 @@ class Vector2D {
|
||||||
double y = 0;
|
double y = 0;
|
||||||
|
|
||||||
// returns the scale
|
// returns the scale
|
||||||
double normalize();
|
double normalize();
|
||||||
|
|
||||||
Vector2D operator+(const Vector2D a) const {
|
Vector2D operator+(const Vector2D& a) const {
|
||||||
return Vector2D(this->x + a.x, this->y + a.y);
|
return Vector2D(this->x + a.x, this->y + a.y);
|
||||||
}
|
}
|
||||||
Vector2D operator-(const Vector2D a) const {
|
Vector2D operator-(const Vector2D& a) const {
|
||||||
return Vector2D(this->x - a.x, this->y - a.y);
|
return Vector2D(this->x - a.x, this->y - a.y);
|
||||||
}
|
}
|
||||||
Vector2D operator*(const float a) const {
|
Vector2D operator*(const float& a) const {
|
||||||
return Vector2D(this->x * a, this->y * a);
|
return Vector2D(this->x * a, this->y * a);
|
||||||
}
|
}
|
||||||
Vector2D operator/(const float a) const {
|
Vector2D operator/(const float& a) const {
|
||||||
return Vector2D(this->x / a, this->y / a);
|
return Vector2D(this->x / a, this->y / a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
struct SLayerSurface {
|
struct SLayerSurface {
|
||||||
SLayerSurface();
|
SLayerSurface();
|
||||||
|
|
||||||
wlr_layer_surface_v1* layerSurface;
|
wlr_layer_surface_v1* layerSurface;
|
||||||
wl_list link;
|
wl_list link;
|
||||||
|
|
||||||
DYNLISTENER(destroyLayerSurface);
|
DYNLISTENER(destroyLayerSurface);
|
||||||
DYNLISTENER(mapLayerSurface);
|
DYNLISTENER(mapLayerSurface);
|
||||||
|
@ -19,22 +19,22 @@ struct SLayerSurface {
|
||||||
DYNLISTENER(commitLayerSurface);
|
DYNLISTENER(commitLayerSurface);
|
||||||
DYNLISTENER(newPopup);
|
DYNLISTENER(newPopup);
|
||||||
|
|
||||||
wlr_box geometry = {0,0,0,0};
|
wlr_box geometry = {0, 0, 0, 0};
|
||||||
Vector2D position;
|
Vector2D position;
|
||||||
zwlr_layer_shell_v1_layer layer;
|
zwlr_layer_shell_v1_layer layer;
|
||||||
|
|
||||||
bool mapped = false;
|
bool mapped = false;
|
||||||
|
|
||||||
int monitorID = -1;
|
int monitorID = -1;
|
||||||
|
|
||||||
std::string szNamespace = "";
|
std::string szNamespace = "";
|
||||||
|
|
||||||
CAnimatedVariable alpha;
|
CAnimatedVariable alpha;
|
||||||
bool fadingOut = false;
|
bool fadingOut = false;
|
||||||
bool readyToDelete = false;
|
bool readyToDelete = false;
|
||||||
bool noProcess = false;
|
bool noProcess = false;
|
||||||
|
|
||||||
bool forceBlur = false;
|
bool forceBlur = false;
|
||||||
|
|
||||||
// For the list lookup
|
// For the list lookup
|
||||||
bool operator==(const SLayerSurface& rhs) {
|
bool operator==(const SLayerSurface& rhs) {
|
||||||
|
@ -44,14 +44,14 @@ struct SLayerSurface {
|
||||||
|
|
||||||
struct SRenderData {
|
struct SRenderData {
|
||||||
wlr_output* output;
|
wlr_output* output;
|
||||||
timespec* when;
|
timespec* when;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
// for iters
|
// for iters
|
||||||
void* data = nullptr;
|
void* data = nullptr;
|
||||||
wlr_surface* surface = nullptr;
|
wlr_surface* surface = nullptr;
|
||||||
int w, h;
|
int w, h;
|
||||||
void* pMonitor = nullptr;
|
void* pMonitor = nullptr;
|
||||||
|
|
||||||
// for rounding
|
// for rounding
|
||||||
bool dontRound = true;
|
bool dontRound = true;
|
||||||
|
@ -69,7 +69,7 @@ struct SRenderData {
|
||||||
int rounding = -1; // -1 means not set
|
int rounding = -1; // -1 means not set
|
||||||
|
|
||||||
// for blurring
|
// for blurring
|
||||||
bool blur = false;
|
bool blur = false;
|
||||||
bool blockBlurOptimization = false;
|
bool blockBlurOptimization = false;
|
||||||
|
|
||||||
// only for windows, not popups
|
// only for windows, not popups
|
||||||
|
@ -80,17 +80,17 @@ struct SRenderData {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SExtensionFindingData {
|
struct SExtensionFindingData {
|
||||||
Vector2D origin;
|
Vector2D origin;
|
||||||
Vector2D vec;
|
Vector2D vec;
|
||||||
wlr_surface** found;
|
wlr_surface** found;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SStringRuleNames {
|
struct SStringRuleNames {
|
||||||
std::string layout = "";
|
std::string layout = "";
|
||||||
std::string model = "";
|
std::string model = "";
|
||||||
std::string variant = "";
|
std::string variant = "";
|
||||||
std::string options = "";
|
std::string options = "";
|
||||||
std::string rules = "";
|
std::string rules = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SKeyboard {
|
struct SKeyboard {
|
||||||
|
@ -101,18 +101,18 @@ struct SKeyboard {
|
||||||
DYNLISTENER(keyboardKeymap);
|
DYNLISTENER(keyboardKeymap);
|
||||||
DYNLISTENER(keyboardDestroy);
|
DYNLISTENER(keyboardDestroy);
|
||||||
|
|
||||||
bool isVirtual = false;
|
bool isVirtual = false;
|
||||||
bool active = false;
|
bool active = false;
|
||||||
|
|
||||||
xkb_layout_index_t activeLayout = 0;
|
xkb_layout_index_t activeLayout = 0;
|
||||||
|
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
std::string xkbFilePath = "";
|
std::string xkbFilePath = "";
|
||||||
|
|
||||||
SStringRuleNames currentRules;
|
SStringRuleNames currentRules;
|
||||||
int repeatRate = 0;
|
int repeatRate = 0;
|
||||||
int repeatDelay = 0;
|
int repeatDelay = 0;
|
||||||
int numlockOn = -1;
|
int numlockOn = -1;
|
||||||
|
|
||||||
// For the list lookup
|
// For the list lookup
|
||||||
bool operator==(const SKeyboard& rhs) {
|
bool operator==(const SKeyboard& rhs) {
|
||||||
|
@ -121,18 +121,18 @@ struct SKeyboard {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMouse {
|
struct SMouse {
|
||||||
wlr_input_device* mouse = nullptr;
|
wlr_input_device* mouse = nullptr;
|
||||||
|
|
||||||
wlr_pointer_constraint_v1* currentConstraint = nullptr;
|
wlr_pointer_constraint_v1* currentConstraint = nullptr;
|
||||||
bool constraintActive = false;
|
bool constraintActive = false;
|
||||||
|
|
||||||
pixman_region32_t confinedTo;
|
pixman_region32_t confinedTo;
|
||||||
|
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
|
|
||||||
bool virt = false;
|
bool virt = false;
|
||||||
|
|
||||||
bool connected = false; // means connected to the cursor
|
bool connected = false; // means connected to the cursor
|
||||||
|
|
||||||
DYNLISTENER(commitConstraint);
|
DYNLISTENER(commitConstraint);
|
||||||
DYNLISTENER(destroyMouse);
|
DYNLISTENER(destroyMouse);
|
||||||
|
@ -143,11 +143,11 @@ struct SMouse {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SConstraint {
|
struct SConstraint {
|
||||||
SMouse* pMouse = nullptr;
|
SMouse* pMouse = nullptr;
|
||||||
wlr_pointer_constraint_v1* constraint = nullptr;
|
wlr_pointer_constraint_v1* constraint = nullptr;
|
||||||
|
|
||||||
bool hintSet = false;
|
bool hintSet = false;
|
||||||
Vector2D positionHint; // the position hint, but will be set to the current cursor pos if not set.
|
Vector2D positionHint; // the position hint, but will be set to the current cursor pos if not set.
|
||||||
|
|
||||||
DYNLISTENER(setConstraintRegion);
|
DYNLISTENER(setConstraintRegion);
|
||||||
DYNLISTENER(destroyConstraint);
|
DYNLISTENER(destroyConstraint);
|
||||||
|
@ -160,10 +160,10 @@ struct SConstraint {
|
||||||
class CMonitor;
|
class CMonitor;
|
||||||
|
|
||||||
struct SXDGPopup {
|
struct SXDGPopup {
|
||||||
CWindow* parentWindow = nullptr;
|
CWindow* parentWindow = nullptr;
|
||||||
SXDGPopup* parentPopup = nullptr;
|
SXDGPopup* parentPopup = nullptr;
|
||||||
wlr_xdg_popup* popup = nullptr;
|
wlr_xdg_popup* popup = nullptr;
|
||||||
CMonitor* monitor = nullptr;
|
CMonitor* monitor = nullptr;
|
||||||
|
|
||||||
DYNLISTENER(newPopupFromPopupXDG);
|
DYNLISTENER(newPopupFromPopupXDG);
|
||||||
DYNLISTENER(destroyPopupXDG);
|
DYNLISTENER(destroyPopupXDG);
|
||||||
|
@ -171,8 +171,8 @@ struct SXDGPopup {
|
||||||
DYNLISTENER(unmapPopupXDG);
|
DYNLISTENER(unmapPopupXDG);
|
||||||
DYNLISTENER(commitPopupXDG);
|
DYNLISTENER(commitPopupXDG);
|
||||||
|
|
||||||
double lx;
|
double lx;
|
||||||
double ly;
|
double ly;
|
||||||
|
|
||||||
SSurfaceTreeNode* pSurfaceTree = nullptr;
|
SSurfaceTreeNode* pSurfaceTree = nullptr;
|
||||||
|
|
||||||
|
@ -183,24 +183,24 @@ struct SXDGPopup {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SSeat {
|
struct SSeat {
|
||||||
wlr_seat* seat = nullptr;
|
wlr_seat* seat = nullptr;
|
||||||
wl_client* exclusiveClient = nullptr;
|
wl_client* exclusiveClient = nullptr;
|
||||||
|
|
||||||
SMouse* mouse = nullptr;
|
SMouse* mouse = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SDrag {
|
struct SDrag {
|
||||||
wlr_drag* drag = nullptr;
|
wlr_drag* drag = nullptr;
|
||||||
|
|
||||||
DYNLISTENER(destroy);
|
DYNLISTENER(destroy);
|
||||||
|
|
||||||
// Icon
|
// Icon
|
||||||
|
|
||||||
bool iconMapped = false;
|
bool iconMapped = false;
|
||||||
|
|
||||||
wlr_drag_icon* dragIcon = nullptr;
|
wlr_drag_icon* dragIcon = nullptr;
|
||||||
|
|
||||||
Vector2D pos;
|
Vector2D pos;
|
||||||
|
|
||||||
DYNLISTENER(destroyIcon);
|
DYNLISTENER(destroyIcon);
|
||||||
DYNLISTENER(mapIcon);
|
DYNLISTENER(mapIcon);
|
||||||
|
@ -215,31 +215,31 @@ struct STablet {
|
||||||
DYNLISTENER(Proximity);
|
DYNLISTENER(Proximity);
|
||||||
DYNLISTENER(Destroy);
|
DYNLISTENER(Destroy);
|
||||||
|
|
||||||
wlr_tablet* wlrTablet = nullptr;
|
wlr_tablet* wlrTablet = nullptr;
|
||||||
wlr_tablet_v2_tablet* wlrTabletV2 = nullptr;
|
wlr_tablet_v2_tablet* wlrTabletV2 = nullptr;
|
||||||
wlr_input_device* wlrDevice = nullptr;
|
wlr_input_device* wlrDevice = nullptr;
|
||||||
|
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
|
|
||||||
bool operator==(const STablet& b) {
|
bool operator==(const STablet& b) {
|
||||||
return wlrDevice == b.wlrDevice;
|
return wlrDevice == b.wlrDevice;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct STabletTool {
|
struct STabletTool {
|
||||||
wlr_tablet_tool* wlrTabletTool = nullptr;
|
wlr_tablet_tool* wlrTabletTool = nullptr;
|
||||||
wlr_tablet_v2_tablet_tool* wlrTabletToolV2 = nullptr;
|
wlr_tablet_v2_tablet_tool* wlrTabletToolV2 = nullptr;
|
||||||
|
|
||||||
wlr_tablet_v2_tablet* wlrTabletOwnerV2 = nullptr;
|
wlr_tablet_v2_tablet* wlrTabletOwnerV2 = nullptr;
|
||||||
|
|
||||||
wlr_surface* pSurface = nullptr;
|
wlr_surface* pSurface = nullptr;
|
||||||
|
|
||||||
double tiltX = 0;
|
double tiltX = 0;
|
||||||
double tiltY = 0;
|
double tiltY = 0;
|
||||||
|
|
||||||
bool active = true;
|
bool active = true;
|
||||||
|
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
|
|
||||||
DYNLISTENER(TabletToolDestroy);
|
DYNLISTENER(TabletToolDestroy);
|
||||||
DYNLISTENER(TabletToolSetCursor);
|
DYNLISTENER(TabletToolSetCursor);
|
||||||
|
@ -251,9 +251,9 @@ struct STabletTool {
|
||||||
|
|
||||||
struct STabletPad {
|
struct STabletPad {
|
||||||
wlr_tablet_v2_tablet_pad* wlrTabletPadV2 = nullptr;
|
wlr_tablet_v2_tablet_pad* wlrTabletPadV2 = nullptr;
|
||||||
STablet* pTabletParent = nullptr;
|
STablet* pTabletParent = nullptr;
|
||||||
|
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
|
|
||||||
DYNLISTENER(Attach);
|
DYNLISTENER(Attach);
|
||||||
DYNLISTENER(Button);
|
DYNLISTENER(Button);
|
||||||
|
@ -268,7 +268,7 @@ struct STabletPad {
|
||||||
|
|
||||||
struct SIdleInhibitor {
|
struct SIdleInhibitor {
|
||||||
wlr_idle_inhibitor_v1* pWlrInhibitor = nullptr;
|
wlr_idle_inhibitor_v1* pWlrInhibitor = nullptr;
|
||||||
CWindow* pWindow = nullptr;
|
CWindow* pWindow = nullptr;
|
||||||
|
|
||||||
DYNLISTENER(Destroy);
|
DYNLISTENER(Destroy);
|
||||||
|
|
||||||
|
@ -278,20 +278,20 @@ struct SIdleInhibitor {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SSwipeGesture {
|
struct SSwipeGesture {
|
||||||
CWorkspace* pWorkspaceBegin = nullptr;
|
CWorkspace* pWorkspaceBegin = nullptr;
|
||||||
|
|
||||||
double delta = 0;
|
double delta = 0;
|
||||||
|
|
||||||
float avgSpeed = 0;
|
float avgSpeed = 0;
|
||||||
int speedPoints = 0;
|
int speedPoints = 0;
|
||||||
|
|
||||||
CMonitor* pMonitor = nullptr;
|
CMonitor* pMonitor = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct STextInput {
|
struct STextInput {
|
||||||
wlr_text_input_v3* pWlrInput = nullptr;
|
wlr_text_input_v3* pWlrInput = nullptr;
|
||||||
|
|
||||||
wlr_surface* pPendingSurface = nullptr;
|
wlr_surface* pPendingSurface = nullptr;
|
||||||
|
|
||||||
DYNLISTENER(textInputEnable);
|
DYNLISTENER(textInputEnable);
|
||||||
DYNLISTENER(textInputDisable);
|
DYNLISTENER(textInputDisable);
|
||||||
|
@ -304,7 +304,7 @@ struct STextInput {
|
||||||
struct SIMEKbGrab {
|
struct SIMEKbGrab {
|
||||||
wlr_input_method_keyboard_grab_v2* pWlrKbGrab = nullptr;
|
wlr_input_method_keyboard_grab_v2* pWlrKbGrab = nullptr;
|
||||||
|
|
||||||
wlr_keyboard* pKeyboard = nullptr;
|
wlr_keyboard* pKeyboard = nullptr;
|
||||||
|
|
||||||
DYNLISTENER(grabDestroy);
|
DYNLISTENER(grabDestroy);
|
||||||
};
|
};
|
||||||
|
@ -312,10 +312,10 @@ struct SIMEKbGrab {
|
||||||
struct SIMEPopup {
|
struct SIMEPopup {
|
||||||
wlr_input_popup_surface_v2* pSurface = nullptr;
|
wlr_input_popup_surface_v2* pSurface = nullptr;
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
int realX, realY;
|
int realX, realY;
|
||||||
bool visible;
|
bool visible;
|
||||||
Vector2D lastSize;
|
Vector2D lastSize;
|
||||||
|
|
||||||
DYNLISTENER(mapPopup);
|
DYNLISTENER(mapPopup);
|
||||||
DYNLISTENER(unmapPopup);
|
DYNLISTENER(unmapPopup);
|
||||||
|
@ -332,9 +332,9 @@ struct SIMEPopup {
|
||||||
struct STouchDevice {
|
struct STouchDevice {
|
||||||
wlr_input_device* pWlrDevice = nullptr;
|
wlr_input_device* pWlrDevice = nullptr;
|
||||||
|
|
||||||
std::string name = "";
|
std::string name = "";
|
||||||
|
|
||||||
std::string boundOutput = "";
|
std::string boundOutput = "";
|
||||||
|
|
||||||
DYNLISTENER(destroy);
|
DYNLISTENER(destroy);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ CHyprWLListener::CHyprWLListener(wl_signal* pSignal, std::function<void(void*, v
|
||||||
}
|
}
|
||||||
|
|
||||||
CHyprWLListener::CHyprWLListener() {
|
CHyprWLListener::CHyprWLListener() {
|
||||||
m_swWrapper.m_pSelf = this;
|
m_swWrapper.m_pSelf = this;
|
||||||
m_swWrapper.m_sListener.notify = &handleWrapped;
|
m_swWrapper.m_sListener.notify = &handleWrapped;
|
||||||
wl_list_init(&m_swWrapper.m_sListener.link);
|
wl_list_init(&m_swWrapper.m_sListener.link);
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,9 @@ void CHyprWLListener::initCallback(wl_signal* pSignal, std::function<void(void*,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pOwner = pOwner;
|
m_pOwner = pOwner;
|
||||||
m_pCallback = callback;
|
m_pCallback = callback;
|
||||||
m_szAuthor = author;
|
m_szAuthor = author;
|
||||||
|
|
||||||
addWLSignal(pSignal, &m_swWrapper.m_sListener, pOwner, m_szAuthor);
|
addWLSignal(pSignal, &m_swWrapper.m_sListener, pOwner, m_szAuthor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,35 +4,35 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
class CHyprWLListener {
|
class CHyprWLListener {
|
||||||
public:
|
public:
|
||||||
CHyprWLListener(wl_signal*, std::function<void(void*, void*)>, void* owner);
|
CHyprWLListener(wl_signal*, std::function<void(void*, void*)>, void* owner);
|
||||||
CHyprWLListener();
|
CHyprWLListener();
|
||||||
~CHyprWLListener();
|
~CHyprWLListener();
|
||||||
|
|
||||||
CHyprWLListener(const CHyprWLListener&) = delete;
|
CHyprWLListener(const CHyprWLListener&) = delete;
|
||||||
CHyprWLListener(CHyprWLListener&&) = delete;
|
CHyprWLListener(CHyprWLListener&&) = delete;
|
||||||
CHyprWLListener& operator=(const CHyprWLListener&) = delete;
|
CHyprWLListener& operator=(const CHyprWLListener&) = delete;
|
||||||
CHyprWLListener& operator=(CHyprWLListener&&) = delete;
|
CHyprWLListener& operator=(CHyprWLListener&&) = delete;
|
||||||
|
|
||||||
void initCallback(wl_signal*, std::function<void(void*, void*)>, void* owner, std::string author = "");
|
void initCallback(wl_signal*, std::function<void(void*, void*)>, void* owner, std::string author = "");
|
||||||
|
|
||||||
void removeCallback();
|
void removeCallback();
|
||||||
|
|
||||||
bool isConnected();
|
bool isConnected();
|
||||||
|
|
||||||
struct SWrapper {
|
struct SWrapper {
|
||||||
wl_listener m_sListener;
|
wl_listener m_sListener;
|
||||||
CHyprWLListener* m_pSelf;
|
CHyprWLListener* m_pSelf;
|
||||||
};
|
};
|
||||||
|
|
||||||
void emit(void*);
|
void emit(void*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SWrapper m_swWrapper;
|
SWrapper m_swWrapper;
|
||||||
|
|
||||||
void* m_pOwner = nullptr;
|
void* m_pOwner = nullptr;
|
||||||
|
|
||||||
std::function<void(void*, void*)> m_pCallback = nullptr;
|
std::function<void(void*, void*)> m_pCallback = nullptr;
|
||||||
|
|
||||||
std::string m_szAuthor = "";
|
std::string m_szAuthor = "";
|
||||||
};
|
};
|
|
@ -9,8 +9,8 @@ CWorkspace::CWorkspace(int monitorID, std::string name, bool special) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_iMonitorID = monitorID;
|
m_iMonitorID = monitorID;
|
||||||
m_szName = name;
|
m_szName = name;
|
||||||
m_bIsSpecialWorkspace = special;
|
m_bIsSpecialWorkspace = special;
|
||||||
|
|
||||||
if (!special) {
|
if (!special) {
|
||||||
|
@ -26,9 +26,11 @@ CWorkspace::CWorkspace(int monitorID, std::string name, bool special) {
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vRenderOffset.m_pWorkspace = this;
|
m_vRenderOffset.m_pWorkspace = this;
|
||||||
m_vRenderOffset.create(AVARTYPE_VECTOR, special ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"), nullptr, AVARDAMAGE_ENTIRE);
|
m_vRenderOffset.create(AVARTYPE_VECTOR, special ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"),
|
||||||
|
nullptr, AVARDAMAGE_ENTIRE);
|
||||||
m_fAlpha.m_pWorkspace = this;
|
m_fAlpha.m_pWorkspace = this;
|
||||||
m_fAlpha.create(AVARTYPE_FLOAT, special ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"), nullptr, AVARDAMAGE_ENTIRE);
|
m_fAlpha.create(AVARTYPE_FLOAT, special ? g_pConfigManager->getAnimationPropertyConfig("specialWorkspace") : g_pConfigManager->getAnimationPropertyConfig("workspaces"),
|
||||||
|
nullptr, AVARDAMAGE_ENTIRE);
|
||||||
m_fAlpha.setValueAndWarp(255.f);
|
m_fAlpha.setValueAndWarp(255.f);
|
||||||
|
|
||||||
m_vRenderOffset.registerVar();
|
m_vRenderOffset.registerVar();
|
||||||
|
@ -68,7 +70,7 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
|
||||||
// fallback is slide
|
// fallback is slide
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
|
||||||
|
|
||||||
m_fAlpha.setValueAndWarp(255.f); // fix a bug, if switching from fade -> slide.
|
m_fAlpha.setValueAndWarp(255.f); // fix a bug, if switching from fade -> slide.
|
||||||
|
|
||||||
if (in) {
|
if (in) {
|
||||||
m_vRenderOffset.setValueAndWarp(Vector2D(0, left ? PMONITOR->vecSize.y : -PMONITOR->vecSize.y));
|
m_vRenderOffset.setValueAndWarp(Vector2D(0, left ? PMONITOR->vecSize.y : -PMONITOR->vecSize.y));
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
#include "AnimatedVariable.hpp"
|
#include "AnimatedVariable.hpp"
|
||||||
|
|
||||||
enum eFullscreenMode : uint8_t {
|
enum eFullscreenMode : uint8_t
|
||||||
|
{
|
||||||
FULLSCREEN_FULL = 0,
|
FULLSCREEN_FULL = 0,
|
||||||
FULLSCREEN_MAXIMIZED
|
FULLSCREEN_MAXIMIZED
|
||||||
};
|
};
|
||||||
|
@ -11,24 +12,24 @@ enum eFullscreenMode : uint8_t {
|
||||||
class CWindow;
|
class CWindow;
|
||||||
|
|
||||||
class CWorkspace {
|
class CWorkspace {
|
||||||
public:
|
public:
|
||||||
CWorkspace(int monitorID, std::string name, bool special = false);
|
CWorkspace(int monitorID, std::string name, bool special = false);
|
||||||
~CWorkspace();
|
~CWorkspace();
|
||||||
|
|
||||||
// Workspaces ID-based have IDs > 0
|
// Workspaces ID-based have IDs > 0
|
||||||
// and workspaces name-based have IDs starting with -1337
|
// and workspaces name-based have IDs starting with -1337
|
||||||
int m_iID = -1;
|
int m_iID = -1;
|
||||||
std::string m_szName = "";
|
std::string m_szName = "";
|
||||||
uint64_t m_iMonitorID = -1;
|
uint64_t m_iMonitorID = -1;
|
||||||
// Previous workspace ID is stored during a workspace change, allowing travel
|
// Previous workspace ID is stored during a workspace change, allowing travel
|
||||||
// to the previous workspace.
|
// to the previous workspace.
|
||||||
int m_iPrevWorkspaceID = -1;
|
int m_iPrevWorkspaceID = -1;
|
||||||
bool m_bHasFullscreenWindow = false;
|
bool m_bHasFullscreenWindow = false;
|
||||||
eFullscreenMode m_efFullscreenMode = FULLSCREEN_FULL;
|
eFullscreenMode m_efFullscreenMode = FULLSCREEN_FULL;
|
||||||
|
|
||||||
wlr_ext_workspace_handle_v1* m_pWlrHandle = nullptr;
|
wlr_ext_workspace_handle_v1* m_pWlrHandle = nullptr;
|
||||||
|
|
||||||
wl_array m_wlrCoordinateArr;
|
wl_array m_wlrCoordinateArr;
|
||||||
|
|
||||||
// for animations
|
// for animations
|
||||||
CAnimatedVariable m_vRenderOffset;
|
CAnimatedVariable m_vRenderOffset;
|
||||||
|
@ -36,19 +37,19 @@ public:
|
||||||
bool m_bForceRendering = false;
|
bool m_bForceRendering = false;
|
||||||
|
|
||||||
// "scratchpad"
|
// "scratchpad"
|
||||||
bool m_bIsSpecialWorkspace = false;
|
bool m_bIsSpecialWorkspace = false;
|
||||||
|
|
||||||
// last window
|
// last window
|
||||||
CWindow* m_pLastFocusedWindow = nullptr;
|
CWindow* m_pLastFocusedWindow = nullptr;
|
||||||
|
|
||||||
// user-set
|
// user-set
|
||||||
bool m_bDefaultFloating = false;
|
bool m_bDefaultFloating = false;
|
||||||
bool m_bDefaultPseudo = false;
|
bool m_bDefaultPseudo = false;
|
||||||
|
|
||||||
void startAnim(bool in, bool left, bool instant = false);
|
void startAnim(bool in, bool left, bool instant = false);
|
||||||
void setActive(bool on);
|
void setActive(bool on);
|
||||||
|
|
||||||
void moveToMonitor(const int&);
|
void moveToMonitor(const int&);
|
||||||
|
|
||||||
CWindow* getLastFocusedWindow();
|
CWindow* getLastFocusedWindow();
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,68 +28,69 @@ typedef struct {
|
||||||
} xcb_size_hints_t;
|
} xcb_size_hints_t;
|
||||||
typedef unsigned int xcb_window_t;
|
typedef unsigned int xcb_window_t;
|
||||||
|
|
||||||
typedef enum xcb_stack_mode_t {
|
typedef enum xcb_stack_mode_t
|
||||||
XCB_STACK_MODE_ABOVE = 0,
|
{
|
||||||
XCB_STACK_MODE_BELOW = 1,
|
XCB_STACK_MODE_ABOVE = 0,
|
||||||
XCB_STACK_MODE_TOP_IF = 2,
|
XCB_STACK_MODE_BELOW = 1,
|
||||||
|
XCB_STACK_MODE_TOP_IF = 2,
|
||||||
XCB_STACK_MODE_BOTTOM_IF = 3,
|
XCB_STACK_MODE_BOTTOM_IF = 3,
|
||||||
XCB_STACK_MODE_OPPOSITE = 4
|
XCB_STACK_MODE_OPPOSITE = 4
|
||||||
} xcb_stack_mode_t;
|
} xcb_stack_mode_t;
|
||||||
|
|
||||||
struct wlr_xwayland {
|
struct wlr_xwayland {
|
||||||
struct wlr_xwayland_server *server;
|
struct wlr_xwayland_server* server;
|
||||||
struct wlr_xwm *xwm;
|
struct wlr_xwm* xwm;
|
||||||
struct wlr_xwayland_cursor *cursor;
|
struct wlr_xwayland_cursor* cursor;
|
||||||
|
|
||||||
const char *display_name;
|
const char* display_name;
|
||||||
|
|
||||||
struct wl_display *wl_display;
|
struct wl_display* wl_display;
|
||||||
struct wlr_compositor *compositor;
|
struct wlr_compositor* compositor;
|
||||||
struct wlr_seat *seat;
|
struct wlr_seat* seat;
|
||||||
|
|
||||||
void *data;
|
void* data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_xwayland_surface {
|
struct wlr_xwayland_surface {
|
||||||
xcb_window_t window_id;
|
xcb_window_t window_id;
|
||||||
struct wlr_xwm *xwm;
|
struct wlr_xwm* xwm;
|
||||||
uint32_t surface_id;
|
uint32_t surface_id;
|
||||||
|
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct wl_list stack_link;
|
struct wl_list stack_link;
|
||||||
struct wl_list unpaired_link;
|
struct wl_list unpaired_link;
|
||||||
|
|
||||||
struct wlr_surface *surface;
|
struct wlr_surface* surface;
|
||||||
int16_t x, y;
|
int16_t x, y;
|
||||||
uint16_t width, height;
|
uint16_t width, height;
|
||||||
uint16_t saved_width, saved_height;
|
uint16_t saved_width, saved_height;
|
||||||
bool override_redirect;
|
bool override_redirect;
|
||||||
bool mapped;
|
bool mapped;
|
||||||
|
|
||||||
char *title;
|
char* title;
|
||||||
char *_class;
|
char* _class;
|
||||||
char *instance;
|
char* instance;
|
||||||
char *role;
|
char* role;
|
||||||
char *startup_id;
|
char* startup_id;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
bool has_utf8_title;
|
bool has_utf8_title;
|
||||||
|
|
||||||
struct wl_list children; // wlr_xwayland_surface::parent_link
|
struct wl_list children; // wlr_xwayland_surface::parent_link
|
||||||
struct wlr_xwayland_surface *parent;
|
struct wlr_xwayland_surface* parent;
|
||||||
struct wl_list parent_link; // wlr_xwayland_surface::children
|
struct wl_list parent_link; // wlr_xwayland_surface::children
|
||||||
|
|
||||||
xcb_atom_t *window_type;
|
xcb_atom_t* window_type;
|
||||||
size_t window_type_len;
|
size_t window_type_len;
|
||||||
|
|
||||||
xcb_atom_t *protocols;
|
xcb_atom_t* protocols;
|
||||||
size_t protocols_len;
|
size_t protocols_len;
|
||||||
|
|
||||||
uint32_t decorations;
|
uint32_t decorations;
|
||||||
xcb_icccm_wm_hints_t *hints;
|
xcb_icccm_wm_hints_t* hints;
|
||||||
xcb_size_hints_t *size_hints;
|
xcb_size_hints_t* size_hints;
|
||||||
|
|
||||||
bool pinging;
|
bool pinging;
|
||||||
struct wl_event_source *ping_timer;
|
struct wl_event_source* ping_timer;
|
||||||
|
|
||||||
// _NET_WM_STATE
|
// _NET_WM_STATE
|
||||||
bool modal;
|
bool modal;
|
||||||
|
@ -127,35 +128,41 @@ struct wlr_xwayland_surface {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_xwayland_surface_configure_event {
|
struct wlr_xwayland_surface_configure_event {
|
||||||
struct wlr_xwayland_surface *surface;
|
struct wlr_xwayland_surface* surface;
|
||||||
int16_t x, y;
|
int16_t x, y;
|
||||||
uint16_t width, height;
|
uint16_t width, height;
|
||||||
uint16_t mask; // xcb_config_window_t
|
uint16_t mask; // xcb_config_window_t
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_xwayland_minimize_event {
|
struct wlr_xwayland_minimize_event {
|
||||||
struct wlr_xwayland_surface *surface;
|
struct wlr_xwayland_surface* surface;
|
||||||
bool minimize;
|
bool minimize;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void wlr_xwayland_destroy(wlr_xwayland*) { }
|
inline void wlr_xwayland_destroy(wlr_xwayland*) {}
|
||||||
|
|
||||||
inline void wlr_xwayland_surface_configure(wlr_xwayland_surface*, int, int, int, int) { }
|
inline void wlr_xwayland_surface_configure(wlr_xwayland_surface*, int, int, int, int) {}
|
||||||
|
|
||||||
inline bool wlr_surface_is_xwayland_surface(void*) { return false; }
|
inline bool wlr_surface_is_xwayland_surface(void*) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
inline void wlr_xwayland_surface_activate(wlr_xwayland_surface*, bool) { }
|
inline void wlr_xwayland_surface_activate(wlr_xwayland_surface*, bool) {}
|
||||||
|
|
||||||
inline void wlr_xwayland_surface_restack(wlr_xwayland_surface*, int, xcb_stack_mode_t) { }
|
inline void wlr_xwayland_surface_restack(wlr_xwayland_surface*, int, xcb_stack_mode_t) {}
|
||||||
|
|
||||||
inline wlr_xwayland_surface* wlr_xwayland_surface_from_wlr_surface(void*) { return nullptr; }
|
inline wlr_xwayland_surface* wlr_xwayland_surface_from_wlr_surface(void*) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
inline void wlr_xwayland_surface_close(wlr_xwayland_surface*) { }
|
inline void wlr_xwayland_surface_close(wlr_xwayland_surface*) {}
|
||||||
|
|
||||||
inline void wlr_xwayland_surface_set_fullscreen(wlr_xwayland_surface*, bool) { }
|
inline void wlr_xwayland_surface_set_fullscreen(wlr_xwayland_surface*, bool) {}
|
||||||
|
|
||||||
inline void wlr_xwayland_surface_set_minimized(wlr_xwayland_surface *, bool) { }
|
inline void wlr_xwayland_surface_set_minimized(wlr_xwayland_surface*, bool) {}
|
||||||
|
|
||||||
inline bool wlr_backend_is_x11(void*) { return false; }
|
inline bool wlr_backend_is_x11(void*) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
inline void wlr_x11_output_create(void*) { }
|
inline void wlr_x11_output_create(void*) {}
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
void CHyprError::queueCreate(std::string message, const CColor& color) {
|
void CHyprError::queueCreate(std::string message, const CColor& color) {
|
||||||
m_szQueued = message;
|
m_szQueued = message;
|
||||||
m_cQueued = color;
|
m_cQueued = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprError::createQueued() {
|
void CHyprError::createQueued() {
|
||||||
|
@ -32,9 +32,9 @@ void CHyprError::createQueued() {
|
||||||
cairo_rectangle(CAIRO, 0, 0, PMONITOR->vecPixelSize.x, (FONTSIZE + 2 * (FONTSIZE / 10.f)) * LINECOUNT);
|
cairo_rectangle(CAIRO, 0, 0, PMONITOR->vecPixelSize.x, (FONTSIZE + 2 * (FONTSIZE / 10.f)) * LINECOUNT);
|
||||||
|
|
||||||
// outline
|
// outline
|
||||||
cairo_rectangle(CAIRO, 0, 0, 1, PMONITOR->vecPixelSize.y); // left
|
cairo_rectangle(CAIRO, 0, 0, 1, PMONITOR->vecPixelSize.y); // left
|
||||||
cairo_rectangle(CAIRO, PMONITOR->vecPixelSize.x - 1, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y); // right
|
cairo_rectangle(CAIRO, PMONITOR->vecPixelSize.x - 1, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y); // right
|
||||||
cairo_rectangle(CAIRO, 0, PMONITOR->vecPixelSize.y - 1, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y); // bottom
|
cairo_rectangle(CAIRO, 0, PMONITOR->vecPixelSize.y - 1, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y); // bottom
|
||||||
|
|
||||||
cairo_fill(CAIRO);
|
cairo_fill(CAIRO);
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ void CHyprError::createQueued() {
|
||||||
cairo_set_source_rgba(CAIRO, textColor.r / 255.f, textColor.g / 255.f, textColor.b / 255.f, textColor.a / 255.f);
|
cairo_set_source_rgba(CAIRO, textColor.r / 255.f, textColor.g / 255.f, textColor.b / 255.f, textColor.a / 255.f);
|
||||||
|
|
||||||
float yoffset = FONTSIZE;
|
float yoffset = FONTSIZE;
|
||||||
while(m_szQueued != "") {
|
while (m_szQueued != "") {
|
||||||
std::string current = m_szQueued.substr(0, m_szQueued.find('\n'));
|
std::string current = m_szQueued.substr(0, m_szQueued.find('\n'));
|
||||||
if (const auto NEWLPOS = m_szQueued.find('\n'); NEWLPOS != std::string::npos)
|
if (const auto NEWLPOS = m_szQueued.find('\n'); NEWLPOS != std::string::npos)
|
||||||
m_szQueued = m_szQueued.substr(NEWLPOS + 1);
|
m_szQueued = m_szQueued.substr(NEWLPOS + 1);
|
||||||
|
@ -57,7 +57,6 @@ void CHyprError::createQueued() {
|
||||||
yoffset += FONTSIZE + (FONTSIZE / 10.f);
|
yoffset += FONTSIZE + (FONTSIZE / 10.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cairo_surface_flush(CAIROSURFACE);
|
cairo_surface_flush(CAIROSURFACE);
|
||||||
|
|
||||||
// copy the data to an OpenGL texture we have
|
// copy the data to an OpenGL texture we have
|
||||||
|
@ -79,8 +78,8 @@ void CHyprError::createQueued() {
|
||||||
cairo_surface_destroy(CAIROSURFACE);
|
cairo_surface_destroy(CAIROSURFACE);
|
||||||
|
|
||||||
m_bIsCreated = true;
|
m_bIsCreated = true;
|
||||||
m_szQueued = "";
|
m_szQueued = "";
|
||||||
m_cQueued = CColor();
|
m_cQueued = CColor();
|
||||||
|
|
||||||
g_pHyprRenderer->damageMonitor(PMONITOR);
|
g_pHyprRenderer->damageMonitor(PMONITOR);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +95,7 @@ void CHyprError::draw() {
|
||||||
m_bQueuedDestroy = false;
|
m_bQueuedDestroy = false;
|
||||||
m_tTexture.destroyTexture();
|
m_tTexture.destroyTexture();
|
||||||
m_bIsCreated = false;
|
m_bIsCreated = false;
|
||||||
m_szQueued = "";
|
m_szQueued = "";
|
||||||
g_pHyprRenderer->damageMonitor(g_pCompositor->m_vMonitors.front().get());
|
g_pHyprRenderer->damageMonitor(g_pCompositor->m_vMonitors.front().get());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,18 @@
|
||||||
#include <cairo/cairo.h>
|
#include <cairo/cairo.h>
|
||||||
|
|
||||||
class CHyprError {
|
class CHyprError {
|
||||||
public:
|
public:
|
||||||
void queueCreate(std::string message, const CColor& color);
|
void queueCreate(std::string message, const CColor& color);
|
||||||
void draw();
|
void draw();
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void createQueued();
|
void createQueued();
|
||||||
std::string m_szQueued = "";
|
std::string m_szQueued = "";
|
||||||
CColor m_cQueued;
|
CColor m_cQueued;
|
||||||
bool m_bQueuedDestroy = false;
|
bool m_bQueuedDestroy = false;
|
||||||
bool m_bIsCreated = false;
|
bool m_bIsCreated = false;
|
||||||
CTexture m_tTexture;
|
CTexture m_tTexture;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CHyprError> g_pHyprError; // This is a full-screen error. Treat it with respect, and there can only be one at a time.
|
inline std::unique_ptr<CHyprError> g_pHyprError; // This is a full-screen error. Treat it with respect, and there can only be one at a time.
|
|
@ -4,10 +4,10 @@
|
||||||
void SDwindleNodeData::recalcSizePosRecursive(bool force) {
|
void SDwindleNodeData::recalcSizePosRecursive(bool force) {
|
||||||
if (children[0]) {
|
if (children[0]) {
|
||||||
|
|
||||||
const auto REVERSESPLITRATIO = 2.f - splitRatio;
|
const auto REVERSESPLITRATIO = 2.f - splitRatio;
|
||||||
|
|
||||||
static auto *const PPRESERVESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:preserve_split")->intValue;
|
static auto* const PPRESERVESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:preserve_split")->intValue;
|
||||||
static auto *const PFLMULT = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
|
static auto* const PFLMULT = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
|
||||||
|
|
||||||
if (*PPRESERVESPLIT == 0) {
|
if (*PPRESERVESPLIT == 0) {
|
||||||
splitTop = size.y * *PFLMULT > size.x;
|
splitTop = size.y * *PFLMULT > size.x;
|
||||||
|
@ -18,15 +18,15 @@ void SDwindleNodeData::recalcSizePosRecursive(bool force) {
|
||||||
if (SPLITSIDE) {
|
if (SPLITSIDE) {
|
||||||
// split left/right
|
// split left/right
|
||||||
children[0]->position = position;
|
children[0]->position = position;
|
||||||
children[0]->size = Vector2D(size.x / 2.f * splitRatio, size.y);
|
children[0]->size = Vector2D(size.x / 2.f * splitRatio, size.y);
|
||||||
children[1]->position = Vector2D(position.x + size.x / 2.f * splitRatio, position.y);
|
children[1]->position = Vector2D(position.x + size.x / 2.f * splitRatio, position.y);
|
||||||
children[1]->size = Vector2D(size.x / 2.f * REVERSESPLITRATIO, size.y);
|
children[1]->size = Vector2D(size.x / 2.f * REVERSESPLITRATIO, size.y);
|
||||||
} else {
|
} else {
|
||||||
// split top/bottom
|
// split top/bottom
|
||||||
children[0]->position = position;
|
children[0]->position = position;
|
||||||
children[0]->size = Vector2D(size.x, size.y / 2.f * splitRatio);
|
children[0]->size = Vector2D(size.x, size.y / 2.f * splitRatio);
|
||||||
children[1]->position = Vector2D(position.x, position.y + size.y / 2.f * splitRatio);
|
children[1]->position = Vector2D(position.x, position.y + size.y / 2.f * splitRatio);
|
||||||
children[1]->size = Vector2D(size.x, size.y / 2.f * REVERSESPLITRATIO);
|
children[1]->size = Vector2D(size.x, size.y / 2.f * REVERSESPLITRATIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
children[0]->recalcSizePosRecursive(force);
|
children[0]->recalcSizePosRecursive(force);
|
||||||
|
@ -93,7 +93,7 @@ void SDwindleNodeData::setGroupFocusedNode(SDwindleNodeData* pMember) {
|
||||||
int SDwindleNodeData::getGroupMemberCount() {
|
int SDwindleNodeData::getGroupMemberCount() {
|
||||||
SDwindleNodeData* current = this->pNextGroupMember;
|
SDwindleNodeData* current = this->pNextGroupMember;
|
||||||
|
|
||||||
int no = 1;
|
int no = 1;
|
||||||
|
|
||||||
while (current != this) {
|
while (current != this) {
|
||||||
current = current->pNextGroupMember;
|
current = current->pNextGroupMember;
|
||||||
|
@ -161,14 +161,14 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
||||||
}
|
}
|
||||||
|
|
||||||
// for gaps outer
|
// for gaps outer
|
||||||
const bool DISPLAYLEFT = STICKS(pNode->position.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
const bool DISPLAYLEFT = STICKS(pNode->position.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
||||||
const bool DISPLAYRIGHT = STICKS(pNode->position.x + pNode->size.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
|
const bool DISPLAYRIGHT = STICKS(pNode->position.x + pNode->size.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
|
||||||
const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
||||||
const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
|
const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
|
||||||
|
|
||||||
const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||||
const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
||||||
const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
||||||
|
|
||||||
const auto PWINDOW = pNode->pWindow;
|
const auto PWINDOW = pNode->pWindow;
|
||||||
|
|
||||||
|
@ -178,40 +178,40 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PWINDOW->m_vSize = pNode->size;
|
PWINDOW->m_vSize = pNode->size;
|
||||||
PWINDOW->m_vPosition = pNode->position;
|
PWINDOW->m_vPosition = pNode->position;
|
||||||
|
|
||||||
static auto *const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("dwindle:no_gaps_when_only")->intValue;
|
static auto* const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("dwindle:no_gaps_when_only")->intValue;
|
||||||
|
|
||||||
auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE);
|
auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE);
|
||||||
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
||||||
|
|
||||||
const auto NODESONWORKSPACE = getNodesOnWorkspace(PWINDOW->m_iWorkspaceID);
|
const auto NODESONWORKSPACE = getNodesOnWorkspace(PWINDOW->m_iWorkspaceID);
|
||||||
|
|
||||||
if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) && (NODESONWORKSPACE == 1 || (pNode->isGroupMember() && pNode->getGroupMemberCount() == NODESONWORKSPACE) || (PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
|
if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) &&
|
||||||
|
(NODESONWORKSPACE == 1 || (pNode->isGroupMember() && pNode->getGroupMemberCount() == NODESONWORKSPACE) ||
|
||||||
|
(PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
|
||||||
PWINDOW->m_vRealPosition = calcPos - Vector2D(*PBORDERSIZE, *PBORDERSIZE);
|
PWINDOW->m_vRealPosition = calcPos - Vector2D(*PBORDERSIZE, *PBORDERSIZE);
|
||||||
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
||||||
|
|
||||||
PWINDOW->updateWindowDecos();
|
PWINDOW->updateWindowDecos();
|
||||||
|
|
||||||
PWINDOW->m_sSpecialRenderData.rounding = false;
|
PWINDOW->m_sSpecialRenderData.rounding = false;
|
||||||
PWINDOW->m_sSpecialRenderData.border = false;
|
PWINDOW->m_sSpecialRenderData.border = false;
|
||||||
PWINDOW->m_sSpecialRenderData.decorate = false;
|
PWINDOW->m_sSpecialRenderData.decorate = false;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PWINDOW->m_sSpecialRenderData.rounding = true;
|
PWINDOW->m_sSpecialRenderData.rounding = true;
|
||||||
PWINDOW->m_sSpecialRenderData.border = true;
|
PWINDOW->m_sSpecialRenderData.border = true;
|
||||||
PWINDOW->m_sSpecialRenderData.decorate = true;
|
PWINDOW->m_sSpecialRenderData.decorate = true;
|
||||||
|
|
||||||
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN,
|
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN, DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
|
||||||
DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
|
|
||||||
|
|
||||||
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN,
|
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN, DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
|
||||||
DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
|
|
||||||
|
|
||||||
calcPos = calcPos + OFFSETTOPLEFT;
|
calcPos = calcPos + OFFSETTOPLEFT;
|
||||||
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
|
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
|
||||||
|
|
||||||
if (PWINDOW->m_bIsPseudotiled) {
|
if (PWINDOW->m_bIsPseudotiled) {
|
||||||
|
@ -229,25 +229,25 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
||||||
}
|
}
|
||||||
|
|
||||||
auto DELTA = calcSize - PWINDOW->m_vPseudoSize * scale;
|
auto DELTA = calcSize - PWINDOW->m_vPseudoSize * scale;
|
||||||
calcSize = PWINDOW->m_vPseudoSize * scale;
|
calcSize = PWINDOW->m_vPseudoSize * scale;
|
||||||
calcPos = calcPos + DELTA / 2.f; // center
|
calcPos = calcPos + DELTA / 2.f; // center
|
||||||
} else {
|
} else {
|
||||||
auto DELTA = calcSize - PWINDOW->m_vPseudoSize;
|
auto DELTA = calcSize - PWINDOW->m_vPseudoSize;
|
||||||
calcPos = calcPos + DELTA / 2.f; // center
|
calcPos = calcPos + DELTA / 2.f; // center
|
||||||
calcSize = PWINDOW->m_vPseudoSize;
|
calcSize = PWINDOW->m_vPseudoSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID)) {
|
if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID)) {
|
||||||
// if special, we adjust the coords a bit
|
// if special, we adjust the coords a bit
|
||||||
static auto *const PSCALEFACTOR = &g_pConfigManager->getConfigValuePtr("dwindle:special_scale_factor")->floatValue;
|
static auto* const PSCALEFACTOR = &g_pConfigManager->getConfigValuePtr("dwindle:special_scale_factor")->floatValue;
|
||||||
|
|
||||||
PWINDOW->m_vRealPosition = calcPos + (calcSize - calcSize * *PSCALEFACTOR) / 2.f;
|
PWINDOW->m_vRealPosition = calcPos + (calcSize - calcSize * *PSCALEFACTOR) / 2.f;
|
||||||
PWINDOW->m_vRealSize = calcSize * *PSCALEFACTOR;
|
PWINDOW->m_vRealSize = calcSize * *PSCALEFACTOR;
|
||||||
|
|
||||||
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize * *PSCALEFACTOR);
|
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize * *PSCALEFACTOR);
|
||||||
} else {
|
} else {
|
||||||
PWINDOW->m_vRealSize = calcSize;
|
PWINDOW->m_vRealSize = calcSize;
|
||||||
PWINDOW->m_vRealPosition = calcPos;
|
PWINDOW->m_vRealPosition = calcPos;
|
||||||
|
|
||||||
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize);
|
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize);
|
||||||
|
@ -266,7 +266,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
||||||
// update visible node
|
// update visible node
|
||||||
const auto PVISNODE = pNode->getGroupVisible();
|
const auto PVISNODE = pNode->getGroupVisible();
|
||||||
|
|
||||||
PVISNODE->pWindow->m_vRealSize = PWINDOW->m_vRealSize.goalv();
|
PVISNODE->pWindow->m_vRealSize = PWINDOW->m_vRealSize.goalv();
|
||||||
PVISNODE->pWindow->m_vRealPosition = PWINDOW->m_vRealPosition.goalv();
|
PVISNODE->pWindow->m_vRealPosition = PWINDOW->m_vRealPosition.goalv();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,22 +278,23 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_lDwindleNodesData.push_back(SDwindleNodeData());
|
m_lDwindleNodesData.push_back(SDwindleNodeData());
|
||||||
const auto PNODE = &m_lDwindleNodesData.back();
|
const auto PNODE = &m_lDwindleNodesData.back();
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
||||||
|
|
||||||
static auto *const PUSEACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:use_active_for_splits")->intValue;
|
static auto* const PUSEACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:use_active_for_splits")->intValue;
|
||||||
|
|
||||||
// Populate the node with our window's data
|
// Populate the node with our window's data
|
||||||
PNODE->workspaceID = pWindow->m_iWorkspaceID;
|
PNODE->workspaceID = pWindow->m_iWorkspaceID;
|
||||||
PNODE->pWindow = pWindow;
|
PNODE->pWindow = pWindow;
|
||||||
PNODE->isNode = false;
|
PNODE->isNode = false;
|
||||||
PNODE->layout = this;
|
PNODE->layout = this;
|
||||||
|
|
||||||
SDwindleNodeData* OPENINGON;
|
SDwindleNodeData* OPENINGON;
|
||||||
const auto MONFROMCURSOR = g_pCompositor->getMonitorFromCursor();
|
const auto MONFROMCURSOR = g_pCompositor->getMonitorFromCursor();
|
||||||
|
|
||||||
if (PMONITOR->ID == MONFROMCURSOR->ID && (PNODE->workspaceID == PMONITOR->activeWorkspace || (g_pCompositor->isWorkspaceSpecial(PNODE->workspaceID) && PMONITOR->specialWorkspaceID)) && !*PUSEACTIVE) {
|
if (PMONITOR->ID == MONFROMCURSOR->ID &&
|
||||||
|
(PNODE->workspaceID == PMONITOR->activeWorkspace || (g_pCompositor->isWorkspaceSpecial(PNODE->workspaceID) && PMONITOR->specialWorkspaceID)) && !*PUSEACTIVE) {
|
||||||
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()));
|
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()));
|
||||||
|
|
||||||
// happens on reserved area
|
// happens on reserved area
|
||||||
|
@ -301,7 +302,8 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
||||||
OPENINGON = getFirstNodeOnWorkspace(PMONITOR->activeWorkspace);
|
OPENINGON = getFirstNodeOnWorkspace(PMONITOR->activeWorkspace);
|
||||||
|
|
||||||
} else if (*PUSEACTIVE) {
|
} else if (*PUSEACTIVE) {
|
||||||
if (g_pCompositor->m_pLastWindow && !g_pCompositor->m_pLastWindow->m_bIsFloating && g_pCompositor->m_pLastWindow != pWindow && g_pCompositor->m_pLastWindow->m_iWorkspaceID == pWindow->m_iWorkspaceID && g_pCompositor->m_pLastWindow->m_bIsMapped) {
|
if (g_pCompositor->m_pLastWindow && !g_pCompositor->m_pLastWindow->m_bIsFloating && g_pCompositor->m_pLastWindow != pWindow &&
|
||||||
|
g_pCompositor->m_pLastWindow->m_iWorkspaceID == pWindow->m_iWorkspaceID && g_pCompositor->m_pLastWindow->m_bIsMapped) {
|
||||||
OPENINGON = getNodeFromWindow(g_pCompositor->m_pLastWindow);
|
OPENINGON = getNodeFromWindow(g_pCompositor->m_pLastWindow);
|
||||||
} else {
|
} else {
|
||||||
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()));
|
OPENINGON = getNodeFromWindow(g_pCompositor->vectorToWindowTiled(g_pInputManager->getMouseCoordsInternal()));
|
||||||
|
@ -349,7 +351,7 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
||||||
// if it's the first, it's easy. Make it fullscreen.
|
// if it's the first, it's easy. Make it fullscreen.
|
||||||
if (!OPENINGON || OPENINGON->pWindow == pWindow) {
|
if (!OPENINGON || OPENINGON->pWindow == pWindow) {
|
||||||
PNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
PNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||||
PNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
PNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||||
|
|
||||||
applyNodeDataToWindow(PNODE);
|
applyNodeDataToWindow(PNODE);
|
||||||
|
|
||||||
|
@ -363,15 +365,15 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
||||||
const auto PTAIL = PHEAD->pPreviousGroupMember;
|
const auto PTAIL = PHEAD->pPreviousGroupMember;
|
||||||
|
|
||||||
PHEAD->pPreviousGroupMember = PNODE;
|
PHEAD->pPreviousGroupMember = PNODE;
|
||||||
PTAIL->pNextGroupMember = PNODE;
|
PTAIL->pNextGroupMember = PNODE;
|
||||||
|
|
||||||
PNODE->pNextGroupMember = PHEAD;
|
PNODE->pNextGroupMember = PHEAD;
|
||||||
PNODE->pPreviousGroupMember = PTAIL;
|
PNODE->pPreviousGroupMember = PTAIL;
|
||||||
|
|
||||||
PHEAD->setGroupFocusedNode(PNODE);
|
PHEAD->setGroupFocusedNode(PNODE);
|
||||||
|
|
||||||
PNODE->position = PHEAD->position;
|
PNODE->position = PHEAD->position;
|
||||||
PNODE->size = PHEAD->size;
|
PNODE->size = PHEAD->size;
|
||||||
|
|
||||||
applyNodeDataToWindow(PNODE);
|
applyNodeDataToWindow(PNODE);
|
||||||
|
|
||||||
|
@ -386,25 +388,29 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
||||||
const auto NEWPARENT = &m_lDwindleNodesData.back();
|
const auto NEWPARENT = &m_lDwindleNodesData.back();
|
||||||
|
|
||||||
// make the parent have the OPENINGON's stats
|
// make the parent have the OPENINGON's stats
|
||||||
NEWPARENT->position = OPENINGON->position;
|
NEWPARENT->position = OPENINGON->position;
|
||||||
NEWPARENT->size = OPENINGON->size;
|
NEWPARENT->size = OPENINGON->size;
|
||||||
NEWPARENT->workspaceID = OPENINGON->workspaceID;
|
NEWPARENT->workspaceID = OPENINGON->workspaceID;
|
||||||
NEWPARENT->pParent = OPENINGON->pParent;
|
NEWPARENT->pParent = OPENINGON->pParent;
|
||||||
NEWPARENT->isNode = true; // it is a node
|
NEWPARENT->isNode = true; // it is a node
|
||||||
|
|
||||||
const auto PWIDTHMULTIPLIER = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
|
const auto PWIDTHMULTIPLIER = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
|
||||||
|
|
||||||
// if cursor over first child, make it first, etc
|
// if cursor over first child, make it first, etc
|
||||||
const auto SIDEBYSIDE = NEWPARENT->size.x > NEWPARENT->size.y * *PWIDTHMULTIPLIER;
|
const auto SIDEBYSIDE = NEWPARENT->size.x > NEWPARENT->size.y * *PWIDTHMULTIPLIER;
|
||||||
NEWPARENT->splitTop = !SIDEBYSIDE;
|
NEWPARENT->splitTop = !SIDEBYSIDE;
|
||||||
|
|
||||||
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
|
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
|
||||||
|
|
||||||
const auto PFORCESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:force_split")->intValue;
|
const auto PFORCESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:force_split")->intValue;
|
||||||
|
|
||||||
if (*PFORCESPLIT == 0) {
|
if (*PFORCESPLIT == 0) {
|
||||||
if ((SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / *PWIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y + NEWPARENT->size.y))
|
if ((SIDEBYSIDE &&
|
||||||
|| (!SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / *PWIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) {
|
VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / *PWIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x / 2.f,
|
||||||
|
NEWPARENT->position.y + NEWPARENT->size.y)) ||
|
||||||
|
(!SIDEBYSIDE &&
|
||||||
|
VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / *PWIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x,
|
||||||
|
NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) {
|
||||||
// we are hovering over the first node, make PNODE first.
|
// we are hovering over the first node, make PNODE first.
|
||||||
NEWPARENT->children[1] = OPENINGON;
|
NEWPARENT->children[1] = OPENINGON;
|
||||||
NEWPARENT->children[0] = PNODE;
|
NEWPARENT->children[0] = PNODE;
|
||||||
|
@ -434,23 +440,22 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
||||||
|
|
||||||
// Update the children
|
// Update the children
|
||||||
|
|
||||||
|
|
||||||
if (NEWPARENT->size.x * *PWIDTHMULTIPLIER > NEWPARENT->size.y) {
|
if (NEWPARENT->size.x * *PWIDTHMULTIPLIER > NEWPARENT->size.y) {
|
||||||
// split left/right
|
// split left/right
|
||||||
OPENINGON->position = NEWPARENT->position;
|
OPENINGON->position = NEWPARENT->position;
|
||||||
OPENINGON->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
|
OPENINGON->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
|
||||||
PNODE->position = Vector2D(NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y);
|
PNODE->position = Vector2D(NEWPARENT->position.x + NEWPARENT->size.x / 2.f, NEWPARENT->position.y);
|
||||||
PNODE->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
|
PNODE->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
|
||||||
} else {
|
} else {
|
||||||
// split top/bottom
|
// split top/bottom
|
||||||
OPENINGON->position = NEWPARENT->position;
|
OPENINGON->position = NEWPARENT->position;
|
||||||
OPENINGON->size = Vector2D(NEWPARENT->size.x, NEWPARENT->size.y / 2.f);
|
OPENINGON->size = Vector2D(NEWPARENT->size.x, NEWPARENT->size.y / 2.f);
|
||||||
PNODE->position = Vector2D(NEWPARENT->position.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f);
|
PNODE->position = Vector2D(NEWPARENT->position.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f);
|
||||||
PNODE->size = Vector2D(NEWPARENT->size.x, NEWPARENT->size.y / 2.f);
|
PNODE->size = Vector2D(NEWPARENT->size.x, NEWPARENT->size.y / 2.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
OPENINGON->pParent = NEWPARENT;
|
OPENINGON->pParent = NEWPARENT;
|
||||||
PNODE->pParent = NEWPARENT;
|
PNODE->pParent = NEWPARENT;
|
||||||
|
|
||||||
NEWPARENT->recalcSizePosRecursive();
|
NEWPARENT->recalcSizePosRecursive();
|
||||||
|
|
||||||
|
@ -468,7 +473,7 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pWindow->m_sSpecialRenderData.rounding = true;
|
pWindow->m_sSpecialRenderData.rounding = true;
|
||||||
pWindow->m_sSpecialRenderData.border = true;
|
pWindow->m_sSpecialRenderData.border = true;
|
||||||
pWindow->m_sSpecialRenderData.decorate = true;
|
pWindow->m_sSpecialRenderData.decorate = true;
|
||||||
|
|
||||||
if (pWindow->m_bIsFullscreen)
|
if (pWindow->m_bIsFullscreen)
|
||||||
|
@ -480,12 +485,12 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
||||||
const auto PPREV = PNODE->pPreviousGroupMember;
|
const auto PPREV = PNODE->pPreviousGroupMember;
|
||||||
const auto PNEXT = PNODE->pNextGroupMember;
|
const auto PNEXT = PNODE->pNextGroupMember;
|
||||||
|
|
||||||
PPREV->pNextGroupMember = PNEXT;
|
PPREV->pNextGroupMember = PNEXT;
|
||||||
PNEXT->pPreviousGroupMember = PPREV;
|
PNEXT->pPreviousGroupMember = PPREV;
|
||||||
|
|
||||||
if (PNODE->groupHead) {
|
if (PNODE->groupHead) {
|
||||||
PNEXT->groupHead = true;
|
PNEXT->groupHead = true;
|
||||||
PNEXT->pParent = PNODE->pParent;
|
PNEXT->pParent = PNODE->pParent;
|
||||||
|
|
||||||
if (PNODE->pParent) {
|
if (PNODE->pParent) {
|
||||||
if (PNODE->pParent->children[0] == PNODE) {
|
if (PNODE->pParent->children[0] == PNODE) {
|
||||||
|
@ -496,12 +501,12 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PNEXT->position = PNODE->position;
|
PNEXT->position = PNODE->position;
|
||||||
PNEXT->size = PNODE->size;
|
PNEXT->size = PNODE->size;
|
||||||
} else {
|
} else {
|
||||||
const auto PHEAD = PNODE->getGroupHead();
|
const auto PHEAD = PNODE->getGroupHead();
|
||||||
|
|
||||||
PNEXT->position = PHEAD->position;
|
PNEXT->position = PHEAD->position;
|
||||||
PNEXT->size = PHEAD->size;
|
PNEXT->size = PHEAD->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
PNEXT->setGroupFocusedNode(PNEXT);
|
PNEXT->setGroupFocusedNode(PNEXT);
|
||||||
|
@ -530,8 +535,8 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
||||||
const auto PSIBLING = PPARENT->children[0] == PNODE ? PPARENT->children[1] : PPARENT->children[0];
|
const auto PSIBLING = PPARENT->children[0] == PNODE ? PPARENT->children[1] : PPARENT->children[0];
|
||||||
|
|
||||||
PSIBLING->position = PPARENT->position;
|
PSIBLING->position = PPARENT->position;
|
||||||
PSIBLING->size = PPARENT->size;
|
PSIBLING->size = PPARENT->size;
|
||||||
PSIBLING->pParent = PPARENT->pParent;
|
PSIBLING->pParent = PPARENT->pParent;
|
||||||
|
|
||||||
if (PSIBLING->isGroupMember()) {
|
if (PSIBLING->isGroupMember()) {
|
||||||
// apply to all group members
|
// apply to all group members
|
||||||
|
@ -539,8 +544,8 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
||||||
|
|
||||||
while (current != PSIBLING) {
|
while (current != PSIBLING) {
|
||||||
current->position = PPARENT->position;
|
current->position = PPARENT->position;
|
||||||
current->size = PPARENT->size;
|
current->size = PPARENT->size;
|
||||||
current = current->pNextGroupMember;
|
current = current->pNextGroupMember;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,7 +558,7 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PPARENT->valid = false;
|
PPARENT->valid = false;
|
||||||
PNODE->valid = false;
|
PNODE->valid = false;
|
||||||
|
|
||||||
if (PSIBLING->pParent)
|
if (PSIBLING->pParent)
|
||||||
PSIBLING->pParent->recalcSizePosRecursive();
|
PSIBLING->pParent->recalcSizePosRecursive();
|
||||||
|
@ -582,7 +587,7 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
|
||||||
|
|
||||||
if (TOPNODE && PMONITOR) {
|
if (TOPNODE && PMONITOR) {
|
||||||
TOPNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
TOPNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||||
TOPNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
TOPNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||||
TOPNODE->recalcSizePosRecursive();
|
TOPNODE->recalcSizePosRecursive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -599,12 +604,12 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
|
||||||
PWORKSPACE->m_bHasFullscreenWindow = false;
|
PWORKSPACE->m_bHasFullscreenWindow = false;
|
||||||
} else {
|
} else {
|
||||||
SDwindleNodeData fakeNode;
|
SDwindleNodeData fakeNode;
|
||||||
fakeNode.pWindow = PFULLWINDOW;
|
fakeNode.pWindow = PFULLWINDOW;
|
||||||
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||||
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||||
fakeNode.workspaceID = PWORKSPACE->m_iID;
|
fakeNode.workspaceID = PWORKSPACE->m_iID;
|
||||||
PFULLWINDOW->m_vPosition = fakeNode.position;
|
PFULLWINDOW->m_vPosition = fakeNode.position;
|
||||||
PFULLWINDOW->m_vSize = fakeNode.size;
|
PFULLWINDOW->m_vSize = fakeNode.size;
|
||||||
|
|
||||||
applyNodeDataToWindow(&fakeNode);
|
applyNodeDataToWindow(&fakeNode);
|
||||||
|
|
||||||
|
@ -616,7 +621,7 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
|
||||||
|
|
||||||
if (TOPNODE && PMONITOR) {
|
if (TOPNODE && PMONITOR) {
|
||||||
TOPNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
TOPNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||||
TOPNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
TOPNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||||
TOPNODE->recalcSizePosRecursive();
|
TOPNODE->recalcSizePosRecursive();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -643,10 +648,10 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
|
||||||
const auto PANIMATE = &g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue;
|
const auto PANIMATE = &g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue;
|
||||||
|
|
||||||
// get some data about our window
|
// get some data about our window
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||||
const bool DISPLAYLEFT = STICKS(PWINDOW->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
const bool DISPLAYLEFT = STICKS(PWINDOW->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
||||||
const bool DISPLAYRIGHT = STICKS(PWINDOW->m_vPosition.x + PWINDOW->m_vSize.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
|
const bool DISPLAYRIGHT = STICKS(PWINDOW->m_vPosition.x + PWINDOW->m_vSize.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
|
||||||
const bool DISPLAYTOP = STICKS(PWINDOW->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
const bool DISPLAYTOP = STICKS(PWINDOW->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
||||||
const bool DISPLAYBOTTOM = STICKS(PWINDOW->m_vPosition.y + PWINDOW->m_vSize.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
|
const bool DISPLAYBOTTOM = STICKS(PWINDOW->m_vPosition.y + PWINDOW->m_vSize.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
|
||||||
|
|
||||||
// construct allowed movement
|
// construct allowed movement
|
||||||
|
@ -661,7 +666,7 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
|
||||||
const auto PPARENT = PNODE->pParent;
|
const auto PPARENT = PNODE->pParent;
|
||||||
|
|
||||||
if (!PPARENT)
|
if (!PPARENT)
|
||||||
return; // the only window on a workspace, ignore
|
return; // the only window on a workspace, ignore
|
||||||
|
|
||||||
const bool PARENTSIDEBYSIDE = !PPARENT->splitTop;
|
const bool PARENTSIDEBYSIDE = !PPARENT->splitTop;
|
||||||
|
|
||||||
|
@ -704,13 +709,13 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
|
||||||
|
|
||||||
// 2 axes of freedom
|
// 2 axes of freedom
|
||||||
const auto SIDECONTAINER = PARENTSIDEBYSIDE ? PPARENT : PPARENT2;
|
const auto SIDECONTAINER = PARENTSIDEBYSIDE ? PPARENT : PPARENT2;
|
||||||
const auto TOPCONTAINER = PARENTSIDEBYSIDE ? PPARENT2 : PPARENT;
|
const auto TOPCONTAINER = PARENTSIDEBYSIDE ? PPARENT2 : PPARENT;
|
||||||
|
|
||||||
allowedMovement.x *= 2.f / SIDECONTAINER->size.x;
|
allowedMovement.x *= 2.f / SIDECONTAINER->size.x;
|
||||||
allowedMovement.y *= 2.f / TOPCONTAINER->size.y;
|
allowedMovement.y *= 2.f / TOPCONTAINER->size.y;
|
||||||
|
|
||||||
SIDECONTAINER->splitRatio = std::clamp(SIDECONTAINER->splitRatio + allowedMovement.x, 0.1, 1.9);
|
SIDECONTAINER->splitRatio = std::clamp(SIDECONTAINER->splitRatio + allowedMovement.x, 0.1, 1.9);
|
||||||
TOPCONTAINER->splitRatio = std::clamp(TOPCONTAINER->splitRatio + allowedMovement.y, 0.1, 1.9);
|
TOPCONTAINER->splitRatio = std::clamp(TOPCONTAINER->splitRatio + allowedMovement.y, 0.1, 1.9);
|
||||||
SIDECONTAINER->recalcSizePosRecursive(*PANIMATE == 0);
|
SIDECONTAINER->recalcSizePosRecursive(*PANIMATE == 0);
|
||||||
TOPCONTAINER->recalcSizePosRecursive(*PANIMATE == 0);
|
TOPCONTAINER->recalcSizePosRecursive(*PANIMATE == 0);
|
||||||
}
|
}
|
||||||
|
@ -722,7 +727,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
|
||||||
if (on == pWindow->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(pWindow->m_iWorkspaceID))
|
if (on == pWindow->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(pWindow->m_iWorkspaceID))
|
||||||
return; // ignore
|
return; // ignore
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
||||||
|
|
||||||
if (PWORKSPACE->m_bHasFullscreenWindow && on) {
|
if (PWORKSPACE->m_bHasFullscreenWindow && on) {
|
||||||
|
@ -732,7 +737,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise, accept it.
|
// otherwise, accept it.
|
||||||
pWindow->m_bIsFullscreen = on;
|
pWindow->m_bIsFullscreen = on;
|
||||||
PWORKSPACE->m_bHasFullscreenWindow = !PWORKSPACE->m_bHasFullscreenWindow;
|
PWORKSPACE->m_bHasFullscreenWindow = !PWORKSPACE->m_bHasFullscreenWindow;
|
||||||
|
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent{"fullscreen", std::to_string((int)on)});
|
g_pEventManager->postEvent(SHyprIPCEvent{"fullscreen", std::to_string((int)on)});
|
||||||
|
@ -745,7 +750,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
|
||||||
else {
|
else {
|
||||||
// get back its' dimensions from position and size
|
// get back its' dimensions from position and size
|
||||||
pWindow->m_vRealPosition = pWindow->m_vPosition;
|
pWindow->m_vRealPosition = pWindow->m_vPosition;
|
||||||
pWindow->m_vRealSize = pWindow->m_vSize;
|
pWindow->m_vRealSize = pWindow->m_vSize;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if it now got fullscreen, make it fullscreen
|
// if it now got fullscreen, make it fullscreen
|
||||||
|
@ -755,25 +760,25 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
|
||||||
// save position and size if floating
|
// save position and size if floating
|
||||||
if (pWindow->m_bIsFloating) {
|
if (pWindow->m_bIsFloating) {
|
||||||
pWindow->m_vPosition = pWindow->m_vRealPosition.vec();
|
pWindow->m_vPosition = pWindow->m_vRealPosition.vec();
|
||||||
pWindow->m_vSize = pWindow->m_vRealSize.vec();
|
pWindow->m_vSize = pWindow->m_vRealSize.vec();
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply new pos and size being monitors' box
|
// apply new pos and size being monitors' box
|
||||||
if (fullscreenMode == FULLSCREEN_FULL) {
|
if (fullscreenMode == FULLSCREEN_FULL) {
|
||||||
pWindow->m_vRealPosition = PMONITOR->vecPosition;
|
pWindow->m_vRealPosition = PMONITOR->vecPosition;
|
||||||
pWindow->m_vRealSize = PMONITOR->vecSize;
|
pWindow->m_vRealSize = PMONITOR->vecSize;
|
||||||
} else {
|
} else {
|
||||||
// This is a massive hack.
|
// This is a massive hack.
|
||||||
// We make a fake "only" node and apply
|
// We make a fake "only" node and apply
|
||||||
// To keep consistent with the settings without C+P code
|
// To keep consistent with the settings without C+P code
|
||||||
|
|
||||||
SDwindleNodeData fakeNode;
|
SDwindleNodeData fakeNode;
|
||||||
fakeNode.pWindow = pWindow;
|
fakeNode.pWindow = pWindow;
|
||||||
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||||
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||||
fakeNode.workspaceID = pWindow->m_iWorkspaceID;
|
fakeNode.workspaceID = pWindow->m_iWorkspaceID;
|
||||||
pWindow->m_vPosition = fakeNode.position;
|
pWindow->m_vPosition = fakeNode.position;
|
||||||
pWindow->m_vSize = fakeNode.size;
|
pWindow->m_vSize = fakeNode.size;
|
||||||
|
|
||||||
applyNodeDataToWindow(&fakeNode);
|
applyNodeDataToWindow(&fakeNode);
|
||||||
}
|
}
|
||||||
|
@ -828,7 +833,7 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
|
||||||
|
|
||||||
if (PNODE->isGroupMember()) {
|
if (PNODE->isGroupMember()) {
|
||||||
// dissolve group
|
// dissolve group
|
||||||
const auto PHEAD = PNODE->getGroupHead();
|
const auto PHEAD = PNODE->getGroupHead();
|
||||||
|
|
||||||
SDwindleNodeData* current = PNODE->pNextGroupMember;
|
SDwindleNodeData* current = PNODE->pNextGroupMember;
|
||||||
|
|
||||||
|
@ -836,26 +841,26 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
|
||||||
|
|
||||||
std::deque<CWindow*> toAddWindows;
|
std::deque<CWindow*> toAddWindows;
|
||||||
|
|
||||||
const auto PWINDOWNODE = PNODE->pWindow;
|
const auto PWINDOWNODE = PNODE->pWindow;
|
||||||
toAddWindows.push_back(PWINDOWNODE);
|
toAddWindows.push_back(PWINDOWNODE);
|
||||||
|
|
||||||
while (current != PNODE) {
|
while (current != PNODE) {
|
||||||
const auto PWINDOW = current->pWindow;
|
const auto PWINDOW = current->pWindow;
|
||||||
current = current->pNextGroupMember;
|
current = current->pNextGroupMember;
|
||||||
|
|
||||||
toAddWindows.push_back(PWINDOW);
|
toAddWindows.push_back(PWINDOW);
|
||||||
|
|
||||||
PWINDOW->setHidden(false);
|
PWINDOW->setHidden(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PHEAD->pPreviousGroupMember)
|
if (PHEAD->pPreviousGroupMember)
|
||||||
PHEAD->pPreviousGroupMember->pNextGroupMember = PHEAD->pNextGroupMember;
|
PHEAD->pPreviousGroupMember->pNextGroupMember = PHEAD->pNextGroupMember;
|
||||||
|
|
||||||
if (PHEAD->pNextGroupMember)
|
if (PHEAD->pNextGroupMember)
|
||||||
PHEAD->pNextGroupMember->pPreviousGroupMember = PHEAD->pPreviousGroupMember;
|
PHEAD->pNextGroupMember->pPreviousGroupMember = PHEAD->pPreviousGroupMember;
|
||||||
|
|
||||||
PHEAD->pPreviousGroupMember = nullptr;
|
PHEAD->pPreviousGroupMember = nullptr;
|
||||||
PHEAD->pNextGroupMember = nullptr;
|
PHEAD->pNextGroupMember = nullptr;
|
||||||
|
|
||||||
onWindowRemoved(PHEAD->pWindow);
|
onWindowRemoved(PHEAD->pWindow);
|
||||||
|
|
||||||
|
@ -902,7 +907,7 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
PNODE->position = PNODE->pParent->position;
|
PNODE->position = PNODE->pParent->position;
|
||||||
PNODE->size = PNODE->pParent->size;
|
PNODE->size = PNODE->pParent->size;
|
||||||
|
|
||||||
applyNodeDataToWindow(PNODE);
|
applyNodeDataToWindow(PNODE);
|
||||||
|
|
||||||
|
@ -925,14 +930,14 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
|
||||||
for (int i = 0; i < (int)newGroupMembers.size(); ++i) {
|
for (int i = 0; i < (int)newGroupMembers.size(); ++i) {
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
newGroupMembers[i]->groupHead = false;
|
newGroupMembers[i]->groupHead = false;
|
||||||
newGroupMembers[i]->pParent = PNODE->pParent;
|
newGroupMembers[i]->pParent = PNODE->pParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto PREVMEMBER = i == 0 ? newGroupMembers[newGroupMembers.size() - 1] : newGroupMembers[i - 1];
|
const auto PREVMEMBER = i == 0 ? newGroupMembers[newGroupMembers.size() - 1] : newGroupMembers[i - 1];
|
||||||
const auto NEXTMEMBER = i == (int)newGroupMembers.size() - 1 ? newGroupMembers[0] : newGroupMembers[i + 1];
|
const auto NEXTMEMBER = i == (int)newGroupMembers.size() - 1 ? newGroupMembers[0] : newGroupMembers[i + 1];
|
||||||
|
|
||||||
newGroupMembers[i]->pPreviousGroupMember = PREVMEMBER;
|
newGroupMembers[i]->pPreviousGroupMember = PREVMEMBER;
|
||||||
newGroupMembers[i]->pNextGroupMember = NEXTMEMBER;
|
newGroupMembers[i]->pNextGroupMember = NEXTMEMBER;
|
||||||
|
|
||||||
// add the deco
|
// add the deco
|
||||||
newGroupMembers[i]->pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(newGroupMembers[i]->pWindow));
|
newGroupMembers[i]->pWindow->m_dWindowDecorations.emplace_back(std::make_unique<CHyprGroupBarDecoration>(newGroupMembers[i]->pWindow));
|
||||||
|
@ -961,9 +966,9 @@ std::deque<CWindow*> CHyprDwindleLayout::getGroupMembers(CWindow* pWindow) {
|
||||||
const auto PNODE = getNodeFromWindow(pWindow);
|
const auto PNODE = getNodeFromWindow(pWindow);
|
||||||
|
|
||||||
if (!PNODE || !PNODE->isGroupMember())
|
if (!PNODE || !PNODE->isGroupMember())
|
||||||
return result; // reject with empty
|
return result; // reject with empty
|
||||||
|
|
||||||
const auto HEAD = PNODE->getGroupHead();
|
const auto HEAD = PNODE->getGroupHead();
|
||||||
SDwindleNodeData* current = HEAD->pNextGroupMember;
|
SDwindleNodeData* current = HEAD->pNextGroupMember;
|
||||||
|
|
||||||
result.push_back(HEAD->pWindow);
|
result.push_back(HEAD->pWindow);
|
||||||
|
@ -985,7 +990,7 @@ void CHyprDwindleLayout::switchGroupWindow(CWindow* pWindow, bool forward, CWind
|
||||||
if (!PNODE || !PNODE->isGroupMember())
|
if (!PNODE || !PNODE->isGroupMember())
|
||||||
return; // reject
|
return; // reject
|
||||||
|
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PNODE->workspaceID);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PNODE->workspaceID);
|
||||||
|
|
||||||
SDwindleNodeData* pNewNode;
|
SDwindleNodeData* pNewNode;
|
||||||
|
|
||||||
|
@ -1003,8 +1008,8 @@ void CHyprDwindleLayout::switchGroupWindow(CWindow* pWindow, bool forward, CWind
|
||||||
|
|
||||||
PNODE->setGroupFocusedNode(pNewNode);
|
PNODE->setGroupFocusedNode(pNewNode);
|
||||||
|
|
||||||
pNewNode->position = PNODE->position;
|
pNewNode->position = PNODE->position;
|
||||||
pNewNode->size = PNODE->size;
|
pNewNode->size = PNODE->size;
|
||||||
pNewNode->workspaceID = PNODE->workspaceID;
|
pNewNode->workspaceID = PNODE->workspaceID;
|
||||||
|
|
||||||
applyNodeDataToWindow(pNewNode);
|
applyNodeDataToWindow(pNewNode);
|
||||||
|
@ -1037,10 +1042,10 @@ SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow
|
||||||
|
|
||||||
SWindowRenderLayoutHints hints;
|
SWindowRenderLayoutHints hints;
|
||||||
|
|
||||||
static auto *const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->intValue;
|
static auto* const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->intValue;
|
||||||
static auto *const PGROUPCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border")->intValue;
|
static auto* const PGROUPCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border")->intValue;
|
||||||
|
|
||||||
const auto PNODE = getNodeFromWindow(pWindow);
|
const auto PNODE = getNodeFromWindow(pWindow);
|
||||||
if (!PNODE)
|
if (!PNODE)
|
||||||
return hints; // left for the future, maybe floating funkiness
|
return hints; // left for the future, maybe floating funkiness
|
||||||
|
|
||||||
|
@ -1059,17 +1064,17 @@ SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow
|
||||||
void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
||||||
// windows should be valid, insallah
|
// windows should be valid, insallah
|
||||||
|
|
||||||
auto PNODE = getNodeFromWindow(pWindow);
|
auto PNODE = getNodeFromWindow(pWindow);
|
||||||
auto PNODE2 = getNodeFromWindow(pWindow2);
|
auto PNODE2 = getNodeFromWindow(pWindow2);
|
||||||
|
|
||||||
if (!PNODE2 || !PNODE) {
|
if (!PNODE2 || !PNODE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDwindleNodeData* ACTIVE1 = nullptr;
|
SDwindleNodeData* ACTIVE1 = nullptr;
|
||||||
SDwindleNodeData* ACTIVE2 = nullptr;
|
SDwindleNodeData* ACTIVE2 = nullptr;
|
||||||
|
|
||||||
if (PNODE2->isGroupMember() || PNODE->isGroupMember()) {
|
if (PNODE2->isGroupMember() || PNODE->isGroupMember()) {
|
||||||
|
|
||||||
if (PNODE->workspaceID != PNODE2->workspaceID) {
|
if (PNODE->workspaceID != PNODE2->workspaceID) {
|
||||||
Debug::log(ERR, "Groups are confined to a monitor");
|
Debug::log(ERR, "Groups are confined to a monitor");
|
||||||
|
@ -1078,82 +1083,82 @@ void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
||||||
|
|
||||||
if (PNODE->isGroupMember()) {
|
if (PNODE->isGroupMember()) {
|
||||||
ACTIVE1 = PNODE;
|
ACTIVE1 = PNODE;
|
||||||
PNODE = PNODE->getGroupHead();
|
PNODE = PNODE->getGroupHead();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PNODE2->isGroupMember()) {
|
if (PNODE2->isGroupMember()) {
|
||||||
ACTIVE2 = PNODE2;
|
ACTIVE2 = PNODE2;
|
||||||
PNODE2 = PNODE2->getGroupHead();
|
PNODE2 = PNODE2->getGroupHead();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PNODE2->pParent == PNODE->pParent) {
|
if (PNODE2->pParent == PNODE->pParent) {
|
||||||
const auto PPARENT = PNODE->pParent;
|
const auto PPARENT = PNODE->pParent;
|
||||||
|
|
||||||
if (PPARENT->children[0] == PNODE) {
|
if (PPARENT->children[0] == PNODE) {
|
||||||
PPARENT->children[0] = PNODE2;
|
PPARENT->children[0] = PNODE2;
|
||||||
PPARENT->children[1] = PNODE;
|
PPARENT->children[1] = PNODE;
|
||||||
} else {
|
} else {
|
||||||
PPARENT->children[0] = PNODE;
|
PPARENT->children[0] = PNODE;
|
||||||
PPARENT->children[1] = PNODE2;
|
PPARENT->children[1] = PNODE2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (PNODE->pParent) {
|
if (PNODE->pParent) {
|
||||||
const auto PPARENT = PNODE->pParent;
|
const auto PPARENT = PNODE->pParent;
|
||||||
|
|
||||||
if (PPARENT->children[0] == PNODE) {
|
if (PPARENT->children[0] == PNODE) {
|
||||||
PPARENT->children[0] = PNODE2;
|
PPARENT->children[0] = PNODE2;
|
||||||
} else {
|
} else {
|
||||||
PPARENT->children[1] = PNODE2;
|
PPARENT->children[1] = PNODE2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PNODE2->pParent) {
|
if (PNODE2->pParent) {
|
||||||
const auto PPARENT = PNODE2->pParent;
|
const auto PPARENT = PNODE2->pParent;
|
||||||
|
|
||||||
if (PPARENT->children[0] == PNODE2) {
|
if (PPARENT->children[0] == PNODE2) {
|
||||||
PPARENT->children[0] = PNODE;
|
PPARENT->children[0] = PNODE;
|
||||||
} else {
|
} else {
|
||||||
PPARENT->children[1] = PNODE;
|
PPARENT->children[1] = PNODE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto PPARENTNODE2 = PNODE2->pParent;
|
const auto PPARENTNODE2 = PNODE2->pParent;
|
||||||
PNODE2->pParent = PNODE->pParent;
|
PNODE2->pParent = PNODE->pParent;
|
||||||
PNODE->pParent = PPARENTNODE2;
|
PNODE->pParent = PPARENTNODE2;
|
||||||
|
|
||||||
std::swap(PNODE2->workspaceID, PNODE->workspaceID);
|
std::swap(PNODE2->workspaceID, PNODE->workspaceID);
|
||||||
} else {
|
} else {
|
||||||
// swap the windows and recalc
|
// swap the windows and recalc
|
||||||
PNODE2->pWindow = pWindow;
|
PNODE2->pWindow = pWindow;
|
||||||
PNODE->pWindow = pWindow2;
|
PNODE->pWindow = pWindow2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PNODE->workspaceID != PNODE2->workspaceID) {
|
if (PNODE->workspaceID != PNODE2->workspaceID) {
|
||||||
std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID);
|
std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID);
|
||||||
std::swap(pWindow2->m_iWorkspaceID, pWindow->m_iWorkspaceID);
|
std::swap(pWindow2->m_iWorkspaceID, pWindow->m_iWorkspaceID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// recalc the workspace
|
// recalc the workspace
|
||||||
getMasterNodeOnWorkspace(PNODE->workspaceID)->recalcSizePosRecursive();
|
getMasterNodeOnWorkspace(PNODE->workspaceID)->recalcSizePosRecursive();
|
||||||
|
|
||||||
if (PNODE2->workspaceID != PNODE->workspaceID) {
|
if (PNODE2->workspaceID != PNODE->workspaceID) {
|
||||||
getMasterNodeOnWorkspace(PNODE2->workspaceID)->recalcSizePosRecursive();
|
getMasterNodeOnWorkspace(PNODE2->workspaceID)->recalcSizePosRecursive();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ACTIVE1) {
|
if (ACTIVE1) {
|
||||||
ACTIVE1->position = PNODE->position;
|
ACTIVE1->position = PNODE->position;
|
||||||
ACTIVE1->size = PNODE->size;
|
ACTIVE1->size = PNODE->size;
|
||||||
ACTIVE1->pWindow->m_vPosition = ACTIVE1->position;
|
ACTIVE1->pWindow->m_vPosition = ACTIVE1->position;
|
||||||
ACTIVE1->pWindow->m_vSize = ACTIVE1->size;
|
ACTIVE1->pWindow->m_vSize = ACTIVE1->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ACTIVE2) {
|
if (ACTIVE2) {
|
||||||
ACTIVE2->position = PNODE2->position;
|
ACTIVE2->position = PNODE2->position;
|
||||||
ACTIVE2->size = PNODE2->size;
|
ACTIVE2->size = PNODE2->size;
|
||||||
ACTIVE2->pWindow->m_vPosition = ACTIVE2->position;
|
ACTIVE2->pWindow->m_vPosition = ACTIVE2->position;
|
||||||
ACTIVE2->pWindow->m_vSize = ACTIVE2->size;
|
ACTIVE2->pWindow->m_vSize = ACTIVE2->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pHyprRenderer->damageWindow(pWindow);
|
g_pHyprRenderer->damageWindow(pWindow);
|
||||||
g_pHyprRenderer->damageWindow(pWindow2);
|
g_pHyprRenderer->damageWindow(pWindow2);
|
||||||
|
|
|
@ -4,80 +4,81 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include "../render/decorations/CHyprGroupBarDecoration.hpp"
|
#include "../render/decorations/CHyprGroupBarDecoration.hpp"
|
||||||
|
#include <array>
|
||||||
|
|
||||||
class CHyprDwindleLayout;
|
class CHyprDwindleLayout;
|
||||||
enum eFullscreenMode : uint8_t;
|
enum eFullscreenMode : uint8_t;
|
||||||
|
|
||||||
struct SDwindleNodeData {
|
struct SDwindleNodeData {
|
||||||
SDwindleNodeData* pParent = nullptr;
|
SDwindleNodeData* pParent = nullptr;
|
||||||
bool isNode = false;
|
bool isNode = false;
|
||||||
|
|
||||||
CWindow* pWindow = nullptr;
|
CWindow* pWindow = nullptr;
|
||||||
|
|
||||||
std::array<SDwindleNodeData*, 2> children = { nullptr, nullptr };
|
std::array<SDwindleNodeData*, 2> children = {nullptr, nullptr};
|
||||||
|
|
||||||
bool splitTop = false; // for preserve_split
|
bool splitTop = false; // for preserve_split
|
||||||
|
|
||||||
bool groupHead = false;
|
bool groupHead = false;
|
||||||
SDwindleNodeData* pNextGroupMember = nullptr;
|
SDwindleNodeData* pNextGroupMember = nullptr;
|
||||||
SDwindleNodeData* pPreviousGroupMember = nullptr;
|
SDwindleNodeData* pPreviousGroupMember = nullptr;
|
||||||
|
|
||||||
Vector2D position;
|
Vector2D position;
|
||||||
Vector2D size;
|
Vector2D size;
|
||||||
|
|
||||||
int workspaceID = -1;
|
int workspaceID = -1;
|
||||||
|
|
||||||
float splitRatio = 1.f;
|
float splitRatio = 1.f;
|
||||||
|
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
|
|
||||||
// For list lookup
|
// For list lookup
|
||||||
bool operator==(const SDwindleNodeData& rhs) {
|
bool operator==(const SDwindleNodeData& rhs) {
|
||||||
return pWindow == rhs.pWindow && workspaceID == rhs.workspaceID && position == rhs.position && size == rhs.size && pParent == rhs.pParent && children[0] == rhs.children[0] && children[1] == rhs.children[1];
|
return pWindow == rhs.pWindow && workspaceID == rhs.workspaceID && position == rhs.position && size == rhs.size && pParent == rhs.pParent &&
|
||||||
|
children[0] == rhs.children[0] && children[1] == rhs.children[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void recalcSizePosRecursive(bool force = false);
|
void recalcSizePosRecursive(bool force = false);
|
||||||
void getAllChildrenRecursive(std::deque<SDwindleNodeData*>*);
|
void getAllChildrenRecursive(std::deque<SDwindleNodeData*>*);
|
||||||
bool isGroupMember();
|
bool isGroupMember();
|
||||||
SDwindleNodeData* getGroupHead();
|
SDwindleNodeData* getGroupHead();
|
||||||
SDwindleNodeData* getGroupVisible();
|
SDwindleNodeData* getGroupVisible();
|
||||||
int getGroupMemberCount();
|
int getGroupMemberCount();
|
||||||
void setGroupFocusedNode(SDwindleNodeData*);
|
void setGroupFocusedNode(SDwindleNodeData*);
|
||||||
CHyprDwindleLayout* layout = nullptr;
|
CHyprDwindleLayout* layout = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CHyprDwindleLayout : public IHyprLayout {
|
class CHyprDwindleLayout : public IHyprLayout {
|
||||||
public:
|
public:
|
||||||
virtual void onWindowCreatedTiling(CWindow*);
|
virtual void onWindowCreatedTiling(CWindow*);
|
||||||
virtual void onWindowRemovedTiling(CWindow*);
|
virtual void onWindowRemovedTiling(CWindow*);
|
||||||
virtual bool isWindowTiled(CWindow*);
|
virtual bool isWindowTiled(CWindow*);
|
||||||
virtual void recalculateMonitor(const int&);
|
virtual void recalculateMonitor(const int&);
|
||||||
virtual void recalculateWindow(CWindow*);
|
virtual void recalculateWindow(CWindow*);
|
||||||
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
|
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
|
||||||
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
|
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
|
||||||
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
||||||
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
||||||
virtual void switchWindows(CWindow*, CWindow*);
|
virtual void switchWindows(CWindow*, CWindow*);
|
||||||
virtual void alterSplitRatioBy(CWindow*, float);
|
virtual void alterSplitRatioBy(CWindow*, float);
|
||||||
virtual std::string getLayoutName();
|
virtual std::string getLayoutName();
|
||||||
|
|
||||||
virtual void onEnable();
|
virtual void onEnable();
|
||||||
virtual void onDisable();
|
virtual void onDisable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::list<SDwindleNodeData> m_lDwindleNodesData;
|
||||||
|
|
||||||
std::list<SDwindleNodeData> m_lDwindleNodesData;
|
int getNodesOnWorkspace(const int&);
|
||||||
|
void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
|
||||||
|
SDwindleNodeData* getNodeFromWindow(CWindow*);
|
||||||
|
SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
|
||||||
|
SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
|
||||||
|
|
||||||
int getNodesOnWorkspace(const int&);
|
void toggleWindowGroup(CWindow*);
|
||||||
void applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
|
void switchGroupWindow(CWindow*, bool forward, CWindow* to = nullptr);
|
||||||
SDwindleNodeData* getNodeFromWindow(CWindow*);
|
void toggleSplit(CWindow*);
|
||||||
SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
|
std::deque<CWindow*> getGroupMembers(CWindow*);
|
||||||
SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
|
|
||||||
|
|
||||||
void toggleWindowGroup(CWindow*);
|
|
||||||
void switchGroupWindow(CWindow*, bool forward, CWindow* to = nullptr);
|
|
||||||
void toggleSplit(CWindow*);
|
|
||||||
std::deque<CWindow*> getGroupMembers(CWindow*);
|
|
||||||
|
|
||||||
friend struct SDwindleNodeData;
|
friend struct SDwindleNodeData;
|
||||||
};
|
};
|
|
@ -10,7 +10,7 @@ void IHyprLayout::onWindowCreated(CWindow* pWindow) {
|
||||||
g_pXWaylandManager->getGeometryForWindow(pWindow, &desiredGeometry);
|
g_pXWaylandManager->getGeometryForWindow(pWindow, &desiredGeometry);
|
||||||
|
|
||||||
if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) {
|
if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) {
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
||||||
pWindow->m_vLastFloatingSize = PMONITOR->vecSize / 2.f;
|
pWindow->m_vLastFloatingSize = PMONITOR->vecSize / 2.f;
|
||||||
} else {
|
} else {
|
||||||
pWindow->m_vLastFloatingSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
|
pWindow->m_vLastFloatingSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
|
||||||
|
@ -50,9 +50,10 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
|
||||||
|
|
||||||
if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) {
|
if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) {
|
||||||
const auto PWINDOWSURFACE = g_pXWaylandManager->getWindowSurface(pWindow);
|
const auto PWINDOWSURFACE = g_pXWaylandManager->getWindowSurface(pWindow);
|
||||||
pWindow->m_vRealSize = Vector2D(PWINDOWSURFACE->current.width, PWINDOWSURFACE->current.height);
|
pWindow->m_vRealSize = Vector2D(PWINDOWSURFACE->current.width, PWINDOWSURFACE->current.height);
|
||||||
|
|
||||||
if ((desiredGeometry.width <= 1 || desiredGeometry.height <= 1) && pWindow->m_bIsX11 && pWindow->m_iX11Type == 2) { // XDG windows should be fine. TODO: check for weird atoms?
|
if ((desiredGeometry.width <= 1 || desiredGeometry.height <= 1) && pWindow->m_bIsX11 &&
|
||||||
|
pWindow->m_iX11Type == 2) { // XDG windows should be fine. TODO: check for weird atoms?
|
||||||
pWindow->setHidden(true);
|
pWindow->setHidden(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +63,8 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
|
||||||
pWindow->m_vRealSize = PMONITOR->vecSize / 2.f;
|
pWindow->m_vRealSize = PMONITOR->vecSize / 2.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
pWindow->m_vRealPosition = Vector2D(PMONITOR->vecPosition.x + (PMONITOR->vecSize.x - pWindow->m_vRealSize.goalv().x) / 2.f, PMONITOR->vecPosition.y + (PMONITOR->vecSize.y - pWindow->m_vRealSize.goalv().y) / 2.f);
|
pWindow->m_vRealPosition = Vector2D(PMONITOR->vecPosition.x + (PMONITOR->vecSize.x - pWindow->m_vRealSize.goalv().x) / 2.f,
|
||||||
|
PMONITOR->vecPosition.y + (PMONITOR->vecSize.y - pWindow->m_vRealSize.goalv().y) / 2.f);
|
||||||
} else {
|
} else {
|
||||||
// we respect the size.
|
// we respect the size.
|
||||||
pWindow->m_vRealSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
|
pWindow->m_vRealSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
|
||||||
|
@ -75,10 +77,14 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
|
||||||
|
|
||||||
if (!pWindow->m_bIsX11) {
|
if (!pWindow->m_bIsX11) {
|
||||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||||
if (VECINRECT(Vector2D(desiredGeometry.x, desiredGeometry.y), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x, m->vecPosition.y + m->vecPosition.y)
|
if (VECINRECT(Vector2D(desiredGeometry.x, desiredGeometry.y), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x,
|
||||||
|| VECINRECT(Vector2D(desiredGeometry.x + desiredGeometry.width, desiredGeometry.y), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x, m->vecPosition.y + m->vecPosition.y)
|
m->vecPosition.y + m->vecPosition.y) ||
|
||||||
|| VECINRECT(Vector2D(desiredGeometry.x, desiredGeometry.y + desiredGeometry.height), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x, m->vecPosition.y + m->vecPosition.y)
|
VECINRECT(Vector2D(desiredGeometry.x + desiredGeometry.width, desiredGeometry.y), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x,
|
||||||
|| VECINRECT(Vector2D(desiredGeometry.x + desiredGeometry.width, desiredGeometry.y + desiredGeometry.height), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x, m->vecPosition.y + m->vecPosition.y)) {
|
m->vecPosition.y + m->vecPosition.y) ||
|
||||||
|
VECINRECT(Vector2D(desiredGeometry.x, desiredGeometry.y + desiredGeometry.height), m->vecPosition.x, m->vecPosition.y, m->vecPosition.x + m->vecSize.x,
|
||||||
|
m->vecPosition.y + m->vecPosition.y) ||
|
||||||
|
VECINRECT(Vector2D(desiredGeometry.x + desiredGeometry.width, desiredGeometry.y + desiredGeometry.height), m->vecPosition.x, m->vecPosition.y,
|
||||||
|
m->vecPosition.x + m->vecSize.x, m->vecPosition.y + m->vecPosition.y)) {
|
||||||
|
|
||||||
visible = true;
|
visible = true;
|
||||||
break;
|
break;
|
||||||
|
@ -144,17 +150,17 @@ void IHyprLayout::onBeginDragWindow() {
|
||||||
if (!DRAGGINGWINDOW->m_bIsFloating) {
|
if (!DRAGGINGWINDOW->m_bIsFloating) {
|
||||||
if (g_pInputManager->dragMode == MBIND_MOVE) {
|
if (g_pInputManager->dragMode == MBIND_MOVE) {
|
||||||
changeWindowFloatingMode(DRAGGINGWINDOW);
|
changeWindowFloatingMode(DRAGGINGWINDOW);
|
||||||
DRAGGINGWINDOW->m_bIsFloating = true;
|
DRAGGINGWINDOW->m_bIsFloating = true;
|
||||||
DRAGGINGWINDOW->m_bDraggingTiled = true;
|
DRAGGINGWINDOW->m_bDraggingTiled = true;
|
||||||
|
|
||||||
DRAGGINGWINDOW->m_vRealPosition = g_pInputManager->getMouseCoordsInternal() - DRAGGINGWINDOW->m_vRealSize.goalv() / 2.f;
|
DRAGGINGWINDOW->m_vRealPosition = g_pInputManager->getMouseCoordsInternal() - DRAGGINGWINDOW->m_vRealSize.goalv() / 2.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_vBeginDragXY = g_pInputManager->getMouseCoordsInternal();
|
m_vBeginDragXY = g_pInputManager->getMouseCoordsInternal();
|
||||||
m_vBeginDragPositionXY = DRAGGINGWINDOW->m_vRealPosition.goalv();
|
m_vBeginDragPositionXY = DRAGGINGWINDOW->m_vRealPosition.goalv();
|
||||||
m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize.goalv();
|
m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize.goalv();
|
||||||
m_vLastDragXY = m_vBeginDragXY;
|
m_vLastDragXY = m_vBeginDragXY;
|
||||||
|
|
||||||
// get the grab corner
|
// get the grab corner
|
||||||
if (m_vBeginDragXY.x < m_vBeginDragPositionXY.x + m_vBeginDragSizeXY.x / 2.0) {
|
if (m_vBeginDragXY.x < m_vBeginDragPositionXY.x + m_vBeginDragSizeXY.x / 2.0) {
|
||||||
|
@ -208,7 +214,7 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
|
||||||
|
|
||||||
const auto SPECIAL = g_pCompositor->isWorkspaceSpecial(DRAGGINGWINDOW->m_iWorkspaceID);
|
const auto SPECIAL = g_pCompositor->isWorkspaceSpecial(DRAGGINGWINDOW->m_iWorkspaceID);
|
||||||
|
|
||||||
const auto DELTA = Vector2D(mousePos.x - m_vBeginDragXY.x, mousePos.y - m_vBeginDragXY.y);
|
const auto DELTA = Vector2D(mousePos.x - m_vBeginDragXY.x, mousePos.y - m_vBeginDragXY.y);
|
||||||
const auto TICKDELTA = Vector2D(mousePos.x - m_vLastDragXY.x, mousePos.y - m_vLastDragXY.y);
|
const auto TICKDELTA = Vector2D(mousePos.x - m_vLastDragXY.x, mousePos.y - m_vLastDragXY.y);
|
||||||
|
|
||||||
const auto PANIMATE = &g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue;
|
const auto PANIMATE = &g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue;
|
||||||
|
@ -237,25 +243,25 @@ void IHyprLayout::onMouseMove(const Vector2D& mousePos) {
|
||||||
// calc the new size and pos
|
// calc the new size and pos
|
||||||
|
|
||||||
Vector2D newSize = m_vBeginDragSizeXY;
|
Vector2D newSize = m_vBeginDragSizeXY;
|
||||||
Vector2D newPos = m_vBeginDragPositionXY;
|
Vector2D newPos = m_vBeginDragPositionXY;
|
||||||
|
|
||||||
if (m_iGrabbedCorner == 3) {
|
if (m_iGrabbedCorner == 3) {
|
||||||
newSize = newSize + DELTA;
|
newSize = newSize + DELTA;
|
||||||
} else if (m_iGrabbedCorner == 0) {
|
} else if (m_iGrabbedCorner == 0) {
|
||||||
newSize = newSize - DELTA;
|
newSize = newSize - DELTA;
|
||||||
newPos = newPos + DELTA;
|
newPos = newPos + DELTA;
|
||||||
} else if (m_iGrabbedCorner == 1) {
|
} else if (m_iGrabbedCorner == 1) {
|
||||||
newSize = newSize + Vector2D(DELTA.x, -DELTA.y);
|
newSize = newSize + Vector2D(DELTA.x, -DELTA.y);
|
||||||
newPos = newPos + Vector2D(0, DELTA.y);
|
newPos = newPos + Vector2D(0, DELTA.y);
|
||||||
} else if (m_iGrabbedCorner == 4) {
|
} else if (m_iGrabbedCorner == 4) {
|
||||||
newSize = newSize + Vector2D(-DELTA.x, DELTA.y);
|
newSize = newSize + Vector2D(-DELTA.x, DELTA.y);
|
||||||
newPos = newPos + Vector2D(DELTA.x, 0);
|
newPos = newPos + Vector2D(DELTA.x, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
newSize = newSize.clamp(Vector2D(20,20), MAXSIZE);
|
newSize = newSize.clamp(Vector2D(20, 20), MAXSIZE);
|
||||||
|
|
||||||
if (*PANIMATE) {
|
if (*PANIMATE) {
|
||||||
DRAGGINGWINDOW->m_vRealSize = newSize;
|
DRAGGINGWINDOW->m_vRealSize = newSize;
|
||||||
DRAGGINGWINDOW->m_vRealPosition = newPos;
|
DRAGGINGWINDOW->m_vRealPosition = newPos;
|
||||||
} else {
|
} else {
|
||||||
DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(newSize);
|
DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(newSize);
|
||||||
|
@ -301,15 +307,15 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
|
||||||
const auto TILED = isWindowTiled(pWindow);
|
const auto TILED = isWindowTiled(pWindow);
|
||||||
|
|
||||||
// event
|
// event
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent{ "changefloatingmode", getFormat("%x,%d", pWindow, (int)TILED) });
|
g_pEventManager->postEvent(SHyprIPCEvent{"changefloatingmode", getFormat("%x,%d", pWindow, (int)TILED)});
|
||||||
|
|
||||||
if (!TILED) {
|
if (!TILED) {
|
||||||
const auto PNEWMON = g_pCompositor->getMonitorFromVector(pWindow->m_vRealPosition.vec() + pWindow->m_vRealSize.vec() / 2.f);
|
const auto PNEWMON = g_pCompositor->getMonitorFromVector(pWindow->m_vRealPosition.vec() + pWindow->m_vRealSize.vec() / 2.f);
|
||||||
pWindow->m_iMonitorID = PNEWMON->ID;
|
pWindow->m_iMonitorID = PNEWMON->ID;
|
||||||
pWindow->moveToWorkspace(PNEWMON->activeWorkspace);
|
pWindow->moveToWorkspace(PNEWMON->activeWorkspace);
|
||||||
|
|
||||||
// save real pos cuz the func applies the default 5,5 mid
|
// save real pos cuz the func applies the default 5,5 mid
|
||||||
const auto PSAVEDPOS = pWindow->m_vRealPosition.goalv();
|
const auto PSAVEDPOS = pWindow->m_vRealPosition.goalv();
|
||||||
const auto PSAVEDSIZE = pWindow->m_vRealSize.goalv();
|
const auto PSAVEDSIZE = pWindow->m_vRealSize.goalv();
|
||||||
|
|
||||||
// if the window is pseudo, update its size
|
// if the window is pseudo, update its size
|
||||||
|
@ -336,9 +342,9 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
|
||||||
g_pCompositor->moveWindowToTop(pWindow);
|
g_pCompositor->moveWindowToTop(pWindow);
|
||||||
|
|
||||||
pWindow->m_vRealPosition = pWindow->m_vRealPosition.goalv() + (pWindow->m_vRealSize.goalv() - pWindow->m_vLastFloatingSize) / 2.f;
|
pWindow->m_vRealPosition = pWindow->m_vRealPosition.goalv() + (pWindow->m_vRealSize.goalv() - pWindow->m_vLastFloatingSize) / 2.f;
|
||||||
pWindow->m_vRealSize = pWindow->m_vLastFloatingSize;
|
pWindow->m_vRealSize = pWindow->m_vLastFloatingSize;
|
||||||
|
|
||||||
pWindow->m_vSize = pWindow->m_vRealSize.goalv();
|
pWindow->m_vSize = pWindow->m_vRealSize.goalv();
|
||||||
pWindow->m_vPosition = pWindow->m_vRealPosition.goalv();
|
pWindow->m_vPosition = pWindow->m_vRealPosition.goalv();
|
||||||
|
|
||||||
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID));
|
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID));
|
||||||
|
@ -389,8 +395,10 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
|
||||||
|
|
||||||
// find whether there is a floating window below this one
|
// find whether there is a floating window below this one
|
||||||
for (auto& w : g_pCompositor->m_vWindows) {
|
for (auto& w : g_pCompositor->m_vWindows) {
|
||||||
if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && !w->m_bX11ShouldntFocus && !w->m_bNoFocus) {
|
if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && !w->m_bX11ShouldntFocus &&
|
||||||
if (VECINRECT((pWindow->m_vSize / 2.f + pWindow->m_vPosition), w->m_vPosition.x, w->m_vPosition.y, w->m_vPosition.x + w->m_vSize.x, w->m_vPosition.y + w->m_vSize.y)) {
|
!w->m_bNoFocus) {
|
||||||
|
if (VECINRECT((pWindow->m_vSize / 2.f + pWindow->m_vPosition), w->m_vPosition.x, w->m_vPosition.y, w->m_vPosition.x + w->m_vSize.x,
|
||||||
|
w->m_vPosition.y + w->m_vSize.y)) {
|
||||||
return w.get();
|
return w.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,7 +414,8 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
|
||||||
|
|
||||||
// if not, floating window
|
// if not, floating window
|
||||||
for (auto& w : g_pCompositor->m_vWindows) {
|
for (auto& w : g_pCompositor->m_vWindows) {
|
||||||
if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && !w->m_bX11ShouldntFocus && !w->m_bNoFocus)
|
if (w->m_bIsMapped && !w->isHidden() && w->m_bIsFloating && w->m_iX11Type != 2 && w->m_iWorkspaceID == pWindow->m_iWorkspaceID && !w->m_bX11ShouldntFocus &&
|
||||||
|
!w->m_bNoFocus)
|
||||||
return w.get();
|
return w.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,11 +426,11 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
|
||||||
// if it was a tiled window, we first try to find the window that will replace it.
|
// if it was a tiled window, we first try to find the window that will replace it.
|
||||||
const auto PWINDOWCANDIDATE = g_pCompositor->vectorToWindowIdeal(pWindow->m_vRealPosition.goalv() + pWindow->m_vRealSize.goalv() / 2.f);
|
const auto PWINDOWCANDIDATE = g_pCompositor->vectorToWindowIdeal(pWindow->m_vRealPosition.goalv() + pWindow->m_vRealSize.goalv() / 2.f);
|
||||||
|
|
||||||
if (!PWINDOWCANDIDATE || pWindow == PWINDOWCANDIDATE || !PWINDOWCANDIDATE->m_bIsMapped || PWINDOWCANDIDATE->isHidden() || PWINDOWCANDIDATE->m_bX11ShouldntFocus || PWINDOWCANDIDATE->m_iX11Type == 2 || PWINDOWCANDIDATE->m_iMonitorID != g_pCompositor->m_pLastMonitor->ID)
|
if (!PWINDOWCANDIDATE || pWindow == PWINDOWCANDIDATE || !PWINDOWCANDIDATE->m_bIsMapped || PWINDOWCANDIDATE->isHidden() || PWINDOWCANDIDATE->m_bX11ShouldntFocus ||
|
||||||
|
PWINDOWCANDIDATE->m_iX11Type == 2 || PWINDOWCANDIDATE->m_iMonitorID != g_pCompositor->m_pLastMonitor->ID)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return PWINDOWCANDIDATE;
|
return PWINDOWCANDIDATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
IHyprLayout::~IHyprLayout() {
|
IHyprLayout::~IHyprLayout() {}
|
||||||
}
|
|
||||||
|
|
|
@ -2,103 +2,104 @@
|
||||||
|
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
#include "../Window.hpp"
|
#include "../Window.hpp"
|
||||||
|
#include <any>
|
||||||
|
|
||||||
struct SWindowRenderLayoutHints {
|
struct SWindowRenderLayoutHints {
|
||||||
bool isBorderColor = false;
|
bool isBorderColor = false;
|
||||||
CColor borderColor;
|
CColor borderColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SLayoutMessageHeader {
|
struct SLayoutMessageHeader {
|
||||||
CWindow* pWindow = nullptr;
|
CWindow* pWindow = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eFullscreenMode : uint8_t;
|
enum eFullscreenMode : uint8_t;
|
||||||
|
|
||||||
interface IHyprLayout {
|
interface IHyprLayout {
|
||||||
public:
|
public:
|
||||||
virtual ~IHyprLayout() = 0;
|
virtual ~IHyprLayout() = 0;
|
||||||
virtual void onEnable() = 0;
|
virtual void onEnable() = 0;
|
||||||
virtual void onDisable() = 0;
|
virtual void onDisable() = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Called when a window is created (mapped)
|
Called when a window is created (mapped)
|
||||||
The layout HAS TO set the goal pos and size (anim mgr will use it)
|
The layout HAS TO set the goal pos and size (anim mgr will use it)
|
||||||
If !animationinprogress, then the anim mgr will not apply an anim.
|
If !animationinprogress, then the anim mgr will not apply an anim.
|
||||||
*/
|
*/
|
||||||
virtual void onWindowCreated(CWindow*);
|
virtual void onWindowCreated(CWindow*);
|
||||||
virtual void onWindowCreatedTiling(CWindow*) = 0;
|
virtual void onWindowCreatedTiling(CWindow*) = 0;
|
||||||
virtual void onWindowCreatedFloating(CWindow*);
|
virtual void onWindowCreatedFloating(CWindow*);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Return tiled status
|
Return tiled status
|
||||||
*/
|
*/
|
||||||
virtual bool isWindowTiled(CWindow*) = 0;
|
virtual bool isWindowTiled(CWindow*) = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Called when a window is removed (unmapped)
|
Called when a window is removed (unmapped)
|
||||||
*/
|
*/
|
||||||
virtual void onWindowRemoved(CWindow*);
|
virtual void onWindowRemoved(CWindow*);
|
||||||
virtual void onWindowRemovedTiling(CWindow*) = 0;
|
virtual void onWindowRemovedTiling(CWindow*) = 0;
|
||||||
virtual void onWindowRemovedFloating(CWindow*);
|
virtual void onWindowRemovedFloating(CWindow*);
|
||||||
/*
|
/*
|
||||||
Called when the monitor requires a layout recalculation
|
Called when the monitor requires a layout recalculation
|
||||||
this usually means reserved area changes
|
this usually means reserved area changes
|
||||||
*/
|
*/
|
||||||
virtual void recalculateMonitor(const int&) = 0;
|
virtual void recalculateMonitor(const int&) = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Called when the compositor requests a window
|
Called when the compositor requests a window
|
||||||
to be recalculated, e.g. when pseudo is toggled.
|
to be recalculated, e.g. when pseudo is toggled.
|
||||||
*/
|
*/
|
||||||
virtual void recalculateWindow(CWindow*) = 0;
|
virtual void recalculateWindow(CWindow*) = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Called when a window is requested to be floated
|
Called when a window is requested to be floated
|
||||||
*/
|
*/
|
||||||
virtual void changeWindowFloatingMode(CWindow*);
|
virtual void changeWindowFloatingMode(CWindow*);
|
||||||
/*
|
/*
|
||||||
Called when a window is clicked on, beginning a drag
|
Called when a window is clicked on, beginning a drag
|
||||||
this might be a resize, move, whatever the layout defines it
|
this might be a resize, move, whatever the layout defines it
|
||||||
as.
|
as.
|
||||||
*/
|
*/
|
||||||
virtual void onBeginDragWindow();
|
virtual void onBeginDragWindow();
|
||||||
/*
|
/*
|
||||||
Called when a user requests a resize of the current window by a vec
|
Called when a user requests a resize of the current window by a vec
|
||||||
Vector2D holds pixel values
|
Vector2D holds pixel values
|
||||||
Optional pWindow for a specific window
|
Optional pWindow for a specific window
|
||||||
*/
|
*/
|
||||||
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr) = 0;
|
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr) = 0;
|
||||||
/*
|
/*
|
||||||
Called when a user requests a move of the current window by a vec
|
Called when a user requests a move of the current window by a vec
|
||||||
Vector2D holds pixel values
|
Vector2D holds pixel values
|
||||||
Optional pWindow for a specific window
|
Optional pWindow for a specific window
|
||||||
*/
|
*/
|
||||||
virtual void moveActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
|
virtual void moveActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
|
||||||
/*
|
/*
|
||||||
Called when a window is ended being dragged
|
Called when a window is ended being dragged
|
||||||
(mouse up)
|
(mouse up)
|
||||||
*/
|
*/
|
||||||
virtual void onEndDragWindow();
|
virtual void onEndDragWindow();
|
||||||
/*
|
/*
|
||||||
Called whenever the mouse moves, should the layout want to
|
Called whenever the mouse moves, should the layout want to
|
||||||
do anything with it.
|
do anything with it.
|
||||||
Useful for dragging.
|
Useful for dragging.
|
||||||
*/
|
*/
|
||||||
virtual void onMouseMove(const Vector2D&);
|
virtual void onMouseMove(const Vector2D&);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Called when a window / the user requests to toggle the fullscreen state of a window
|
Called when a window / the user requests to toggle the fullscreen state of a window
|
||||||
The layout sets all the fullscreen flags.
|
The layout sets all the fullscreen flags.
|
||||||
It can either accept or ignore.
|
It can either accept or ignore.
|
||||||
*/
|
*/
|
||||||
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool) = 0;
|
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool) = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Called when a dispatcher requests a custom message
|
Called when a dispatcher requests a custom message
|
||||||
The layout is free to ignore.
|
The layout is free to ignore.
|
||||||
std::any is the reply. Can be empty.
|
std::any is the reply. Can be empty.
|
||||||
*/
|
*/
|
||||||
virtual std::any layoutMessage(SLayoutMessageHeader, std::string) = 0;
|
virtual std::any layoutMessage(SLayoutMessageHeader, std::string) = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Required to be handled, but may return just SWindowRenderLayoutHints()
|
Required to be handled, but may return just SWindowRenderLayoutHints()
|
||||||
|
@ -111,35 +112,35 @@ public:
|
||||||
Called when the user requests two windows to be swapped places.
|
Called when the user requests two windows to be swapped places.
|
||||||
The layout is free to ignore.
|
The layout is free to ignore.
|
||||||
*/
|
*/
|
||||||
virtual void switchWindows(CWindow*, CWindow*) = 0;
|
virtual void switchWindows(CWindow*, CWindow*) = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Called when the user requests to change the splitratio by X
|
Called when the user requests to change the splitratio by X
|
||||||
on a window
|
on a window
|
||||||
*/
|
*/
|
||||||
virtual void alterSplitRatioBy(CWindow*, float) = 0;
|
virtual void alterSplitRatioBy(CWindow*, float) = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Called when something wants the current layout's name
|
Called when something wants the current layout's name
|
||||||
*/
|
*/
|
||||||
virtual std::string getLayoutName() = 0;
|
virtual std::string getLayoutName() = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Called for getting the next candidate for a focus
|
Called for getting the next candidate for a focus
|
||||||
*/
|
*/
|
||||||
virtual CWindow* getNextWindowCandidate(CWindow*);
|
virtual CWindow* getNextWindowCandidate(CWindow*);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Internal: called when window focus changes
|
Internal: called when window focus changes
|
||||||
*/
|
*/
|
||||||
virtual void onWindowFocusChange(CWindow*);
|
virtual void onWindowFocusChange(CWindow*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector2D m_vBeginDragXY;
|
Vector2D m_vBeginDragXY;
|
||||||
Vector2D m_vLastDragXY;
|
Vector2D m_vLastDragXY;
|
||||||
Vector2D m_vBeginDragPositionXY;
|
Vector2D m_vBeginDragPositionXY;
|
||||||
Vector2D m_vBeginDragSizeXY;
|
Vector2D m_vBeginDragSizeXY;
|
||||||
int m_iGrabbedCorner = 0;
|
int m_iGrabbedCorner = 0;
|
||||||
|
|
||||||
CWindow* m_pLastTiledWindow = nullptr;
|
CWindow* m_pLastTiledWindow = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,9 +37,9 @@ SMasterWorkspaceData* CHyprMasterLayout::getMasterWorkspaceData(const int& ws) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//create on the fly if it doesn't exist yet
|
//create on the fly if it doesn't exist yet
|
||||||
const auto PWORKSPACEDATA = &m_lMasterWorkspacesData.emplace_back();
|
const auto PWORKSPACEDATA = &m_lMasterWorkspacesData.emplace_back();
|
||||||
PWORKSPACEDATA->workspaceID = ws;
|
PWORKSPACEDATA->workspaceID = ws;
|
||||||
const auto orientation = &g_pConfigManager->getConfigValuePtr("master:orientation")->strValue;
|
const auto orientation = &g_pConfigManager->getConfigValuePtr("master:orientation")->strValue;
|
||||||
if (*orientation == "top") {
|
if (*orientation == "top") {
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
|
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
|
||||||
} else if (*orientation == "right") {
|
} else if (*orientation == "right") {
|
||||||
|
@ -69,30 +69,30 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
||||||
if (pWindow->m_bIsFloating)
|
if (pWindow->m_bIsFloating)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static auto *const PNEWTOP = &g_pConfigManager->getConfigValuePtr("master:new_on_top")->intValue;
|
static auto* const PNEWTOP = &g_pConfigManager->getConfigValuePtr("master:new_on_top")->intValue;
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
||||||
|
|
||||||
const auto PNODE = *PNEWTOP ? &m_lMasterNodesData.emplace_front() : &m_lMasterNodesData.emplace_back();
|
const auto PNODE = *PNEWTOP ? &m_lMasterNodesData.emplace_front() : &m_lMasterNodesData.emplace_back();
|
||||||
|
|
||||||
PNODE->workspaceID = pWindow->m_iWorkspaceID;
|
PNODE->workspaceID = pWindow->m_iWorkspaceID;
|
||||||
PNODE->pWindow = pWindow;
|
PNODE->pWindow = pWindow;
|
||||||
|
|
||||||
static auto *const PNEWISMASTER = &g_pConfigManager->getConfigValuePtr("master:new_is_master")->intValue;
|
static auto* const PNEWISMASTER = &g_pConfigManager->getConfigValuePtr("master:new_is_master")->intValue;
|
||||||
|
|
||||||
const auto WINDOWSONWORKSPACE = getNodesOnWorkspace(PNODE->workspaceID);
|
const auto WINDOWSONWORKSPACE = getNodesOnWorkspace(PNODE->workspaceID);
|
||||||
float lastSplitPercent = 0.5f;
|
float lastSplitPercent = 0.5f;
|
||||||
|
|
||||||
if (*PNEWISMASTER || WINDOWSONWORKSPACE == 1) {
|
if (*PNEWISMASTER || WINDOWSONWORKSPACE == 1) {
|
||||||
for (auto& nd : m_lMasterNodesData) {
|
for (auto& nd : m_lMasterNodesData) {
|
||||||
if (nd.isMaster && nd.workspaceID == PNODE->workspaceID) {
|
if (nd.isMaster && nd.workspaceID == PNODE->workspaceID) {
|
||||||
nd.isMaster = false;
|
nd.isMaster = false;
|
||||||
lastSplitPercent = nd.percMaster;
|
lastSplitPercent = nd.percMaster;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PNODE->isMaster = true;
|
PNODE->isMaster = true;
|
||||||
PNODE->percMaster = lastSplitPercent;
|
PNODE->percMaster = lastSplitPercent;
|
||||||
|
|
||||||
// first, check if it isn't too big.
|
// first, check if it isn't too big.
|
||||||
|
@ -107,7 +107,8 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
||||||
PNODE->isMaster = false;
|
PNODE->isMaster = false;
|
||||||
|
|
||||||
// first, check if it isn't too big.
|
// first, check if it isn't too big.
|
||||||
if (const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(pWindow); MAXSIZE.x < PMONITOR->vecSize.x * (1 - lastSplitPercent) || MAXSIZE.y < PMONITOR->vecSize.y * (1.f / (WINDOWSONWORKSPACE - 1))) {
|
if (const auto MAXSIZE = g_pXWaylandManager->getMaxSizeForWindow(pWindow);
|
||||||
|
MAXSIZE.x < PMONITOR->vecSize.x * (1 - lastSplitPercent) || MAXSIZE.y < PMONITOR->vecSize.y * (1.f / (WINDOWSONWORKSPACE - 1))) {
|
||||||
// we can't continue. make it floating.
|
// we can't continue. make it floating.
|
||||||
pWindow->m_bIsFloating = true;
|
pWindow->m_bIsFloating = true;
|
||||||
m_lMasterNodesData.remove(*PNODE);
|
m_lMasterNodesData.remove(*PNODE);
|
||||||
|
@ -134,7 +135,7 @@ void CHyprMasterLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pWindow->m_sSpecialRenderData.rounding = true;
|
pWindow->m_sSpecialRenderData.rounding = true;
|
||||||
pWindow->m_sSpecialRenderData.border = true;
|
pWindow->m_sSpecialRenderData.border = true;
|
||||||
pWindow->m_sSpecialRenderData.decorate = true;
|
pWindow->m_sSpecialRenderData.decorate = true;
|
||||||
|
|
||||||
if (pWindow->m_bIsFullscreen)
|
if (pWindow->m_bIsFullscreen)
|
||||||
|
@ -169,7 +170,7 @@ void CHyprMasterLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprMasterLayout::recalculateMonitor(const int& monid) {
|
void CHyprMasterLayout::recalculateMonitor(const int& monid) {
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(monid);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(monid);
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
||||||
|
|
||||||
if (!PWORKSPACE)
|
if (!PWORKSPACE)
|
||||||
|
@ -186,15 +187,15 @@ void CHyprMasterLayout::recalculateMonitor(const int& monid) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// massive hack from the fullscreen func
|
// massive hack from the fullscreen func
|
||||||
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
|
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
|
||||||
|
|
||||||
SMasterNodeData fakeNode;
|
SMasterNodeData fakeNode;
|
||||||
fakeNode.pWindow = PFULLWINDOW;
|
fakeNode.pWindow = PFULLWINDOW;
|
||||||
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||||
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||||
fakeNode.workspaceID = PWORKSPACE->m_iID;
|
fakeNode.workspaceID = PWORKSPACE->m_iID;
|
||||||
PFULLWINDOW->m_vPosition = fakeNode.position;
|
PFULLWINDOW->m_vPosition = fakeNode.position;
|
||||||
PFULLWINDOW->m_vSize = fakeNode.size;
|
PFULLWINDOW->m_vSize = fakeNode.size;
|
||||||
|
|
||||||
applyNodeDataToWindow(&fakeNode);
|
applyNodeDataToWindow(&fakeNode);
|
||||||
|
|
||||||
|
@ -225,14 +226,15 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
|
||||||
//compute placement of master window(s)
|
//compute placement of master window(s)
|
||||||
if (getNodesOnWorkspace(PWORKSPACE->m_iID) < 2) {
|
if (getNodesOnWorkspace(PWORKSPACE->m_iID) < 2) {
|
||||||
PMASTERNODE->position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition;
|
PMASTERNODE->position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition;
|
||||||
PMASTERNODE->size = Vector2D(PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x, PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y);
|
PMASTERNODE->size = Vector2D(PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x,
|
||||||
|
PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y);
|
||||||
applyNodeDataToWindow(PMASTERNODE);
|
applyNodeDataToWindow(PMASTERNODE);
|
||||||
return;
|
return;
|
||||||
} else if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT || PWORKSPACEDATA->orientation == ORIENTATION_RIGHT) {
|
} else if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT || PWORKSPACEDATA->orientation == ORIENTATION_RIGHT) {
|
||||||
float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
|
float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
|
||||||
int nodesLeft = MASTERS;
|
int nodesLeft = MASTERS;
|
||||||
float nextY = 0;
|
float nextY = 0;
|
||||||
const float WIDTH = (PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x) * PMASTERNODE->percMaster;
|
const float WIDTH = (PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x) * PMASTERNODE->percMaster;
|
||||||
|
|
||||||
for (auto& n : m_lMasterNodesData) {
|
for (auto& n : m_lMasterNodesData) {
|
||||||
if (n.workspaceID == PWORKSPACE->m_iID && n.isMaster) {
|
if (n.workspaceID == PWORKSPACE->m_iID && n.isMaster) {
|
||||||
|
@ -254,15 +256,15 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (PWORKSPACEDATA->orientation == ORIENTATION_TOP || PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
|
} else if (PWORKSPACEDATA->orientation == ORIENTATION_TOP || PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
|
||||||
float widthLeft = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x;
|
float widthLeft = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x;
|
||||||
int nodesLeft = MASTERS;
|
int nodesLeft = MASTERS;
|
||||||
float nextX = 0;
|
float nextX = 0;
|
||||||
const float HEIGHT = (PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y) * PMASTERNODE->percMaster;
|
const float HEIGHT = (PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y) * PMASTERNODE->percMaster;
|
||||||
|
|
||||||
for (auto& n : m_lMasterNodesData) {
|
for (auto& n : m_lMasterNodesData) {
|
||||||
if (n.workspaceID == PWORKSPACE->m_iID && n.isMaster) {
|
if (n.workspaceID == PWORKSPACE->m_iID && n.isMaster) {
|
||||||
if (PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
|
if (PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
|
||||||
n.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX,PMONITOR->vecSize.y - HEIGHT - PMONITOR->vecReservedBottomRight.y);
|
n.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX, PMONITOR->vecSize.y - HEIGHT - PMONITOR->vecReservedBottomRight.y);
|
||||||
} else {
|
} else {
|
||||||
n.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX, 0);
|
n.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX, 0);
|
||||||
}
|
}
|
||||||
|
@ -280,20 +282,20 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//compute placement of slave window(s)
|
//compute placement of slave window(s)
|
||||||
int slavesLeft = getNodesOnWorkspace(PWORKSPACE->m_iID) - MASTERS;
|
int slavesLeft = getNodesOnWorkspace(PWORKSPACE->m_iID) - MASTERS;
|
||||||
if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT || PWORKSPACEDATA->orientation == ORIENTATION_RIGHT) {
|
if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT || PWORKSPACEDATA->orientation == ORIENTATION_RIGHT) {
|
||||||
float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
|
float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
|
||||||
float nextY = 0;
|
float nextY = 0;
|
||||||
const float WIDTH = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x - PMASTERNODE->size.x;
|
const float WIDTH = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x - PMASTERNODE->size.x;
|
||||||
|
|
||||||
for (auto& nd : m_lMasterNodesData) {
|
for (auto& nd : m_lMasterNodesData) {
|
||||||
if (nd.workspaceID != PWORKSPACE->m_iID || nd.isMaster)
|
if (nd.workspaceID != PWORKSPACE->m_iID || nd.isMaster)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT) {
|
if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT) {
|
||||||
nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(PMASTERNODE->percMaster * (PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x), nextY);
|
nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition +
|
||||||
|
Vector2D(PMASTERNODE->percMaster * (PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x), nextY);
|
||||||
} else {
|
} else {
|
||||||
nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(0, nextY);
|
nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(0, nextY);
|
||||||
}
|
}
|
||||||
|
@ -309,15 +311,16 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
|
||||||
applyNodeDataToWindow(&nd);
|
applyNodeDataToWindow(&nd);
|
||||||
}
|
}
|
||||||
} else if (PWORKSPACEDATA->orientation == ORIENTATION_TOP || PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
|
} else if (PWORKSPACEDATA->orientation == ORIENTATION_TOP || PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
|
||||||
float widthLeft = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x;
|
float widthLeft = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x;
|
||||||
float nextX = 0;
|
float nextX = 0;
|
||||||
const float HEIGHT = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y - PMASTERNODE->size.y;
|
const float HEIGHT = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y - PMASTERNODE->size.y;
|
||||||
|
|
||||||
for (auto& nd : m_lMasterNodesData) {
|
for (auto& nd : m_lMasterNodesData) {
|
||||||
if (nd.workspaceID != PWORKSPACE->m_iID || nd.isMaster)
|
if (nd.workspaceID != PWORKSPACE->m_iID || nd.isMaster)
|
||||||
continue;
|
continue;
|
||||||
if (PWORKSPACEDATA->orientation == ORIENTATION_TOP) {
|
if (PWORKSPACEDATA->orientation == ORIENTATION_TOP) {
|
||||||
nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX, PMASTERNODE->percMaster * (PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y));
|
nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition +
|
||||||
|
Vector2D(nextX, PMASTERNODE->percMaster * (PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y));
|
||||||
} else {
|
} else {
|
||||||
nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX, 0);
|
nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX, 0);
|
||||||
}
|
}
|
||||||
|
@ -333,8 +336,6 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
|
||||||
applyNodeDataToWindow(&nd);
|
applyNodeDataToWindow(&nd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
||||||
|
@ -357,14 +358,14 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// for gaps outer
|
// for gaps outer
|
||||||
const bool DISPLAYLEFT = STICKS(pNode->position.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
const bool DISPLAYLEFT = STICKS(pNode->position.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
||||||
const bool DISPLAYRIGHT = STICKS(pNode->position.x + pNode->size.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
|
const bool DISPLAYRIGHT = STICKS(pNode->position.x + pNode->size.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
|
||||||
const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
const bool DISPLAYTOP = STICKS(pNode->position.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
||||||
const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
|
const bool DISPLAYBOTTOM = STICKS(pNode->position.y + pNode->size.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
|
||||||
|
|
||||||
const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||||
const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
||||||
const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
||||||
|
|
||||||
const auto PWINDOW = pNode->pWindow;
|
const auto PWINDOW = pNode->pWindow;
|
||||||
|
|
||||||
|
@ -373,49 +374,49 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto *const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("master:no_gaps_when_only")->intValue;
|
static auto* const PNOGAPSWHENONLY = &g_pConfigManager->getConfigValuePtr("master:no_gaps_when_only")->intValue;
|
||||||
|
|
||||||
PWINDOW->m_vSize = pNode->size;
|
PWINDOW->m_vSize = pNode->size;
|
||||||
PWINDOW->m_vPosition = pNode->position;
|
PWINDOW->m_vPosition = pNode->position;
|
||||||
|
|
||||||
auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE);
|
auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *PBORDERSIZE);
|
||||||
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
auto calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
||||||
|
|
||||||
if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) && (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1 || (PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
|
if (*PNOGAPSWHENONLY && !g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID) &&
|
||||||
|
(getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) == 1 ||
|
||||||
|
(PWINDOW->m_bIsFullscreen && g_pCompositor->getWorkspaceByID(PWINDOW->m_iWorkspaceID)->m_efFullscreenMode == FULLSCREEN_MAXIMIZED))) {
|
||||||
PWINDOW->m_vRealPosition = calcPos - Vector2D(*PBORDERSIZE, *PBORDERSIZE);
|
PWINDOW->m_vRealPosition = calcPos - Vector2D(*PBORDERSIZE, *PBORDERSIZE);
|
||||||
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
||||||
|
|
||||||
PWINDOW->updateWindowDecos();
|
PWINDOW->updateWindowDecos();
|
||||||
|
|
||||||
PWINDOW->m_sSpecialRenderData.rounding = false;
|
PWINDOW->m_sSpecialRenderData.rounding = false;
|
||||||
PWINDOW->m_sSpecialRenderData.border = false;
|
PWINDOW->m_sSpecialRenderData.border = false;
|
||||||
PWINDOW->m_sSpecialRenderData.decorate = false;
|
PWINDOW->m_sSpecialRenderData.decorate = false;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PWINDOW->m_sSpecialRenderData.rounding = true;
|
PWINDOW->m_sSpecialRenderData.rounding = true;
|
||||||
PWINDOW->m_sSpecialRenderData.border = true;
|
PWINDOW->m_sSpecialRenderData.border = true;
|
||||||
PWINDOW->m_sSpecialRenderData.decorate = true;
|
PWINDOW->m_sSpecialRenderData.decorate = true;
|
||||||
|
|
||||||
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN,
|
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN, DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
|
||||||
DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
|
|
||||||
|
|
||||||
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN,
|
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN, DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
|
||||||
DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
|
|
||||||
|
|
||||||
calcPos = calcPos + OFFSETTOPLEFT;
|
calcPos = calcPos + OFFSETTOPLEFT;
|
||||||
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
|
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
|
||||||
|
|
||||||
if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID)) {
|
if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID)) {
|
||||||
static auto *const PSCALEFACTOR = &g_pConfigManager->getConfigValuePtr("master:special_scale_factor")->floatValue;
|
static auto* const PSCALEFACTOR = &g_pConfigManager->getConfigValuePtr("master:special_scale_factor")->floatValue;
|
||||||
|
|
||||||
PWINDOW->m_vRealPosition = calcPos + (calcSize - calcSize * *PSCALEFACTOR) / 2.f;
|
PWINDOW->m_vRealPosition = calcPos + (calcSize - calcSize * *PSCALEFACTOR) / 2.f;
|
||||||
PWINDOW->m_vRealSize = calcSize * *PSCALEFACTOR;
|
PWINDOW->m_vRealSize = calcSize * *PSCALEFACTOR;
|
||||||
|
|
||||||
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize * *PSCALEFACTOR);
|
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize * *PSCALEFACTOR);
|
||||||
} else {
|
} else {
|
||||||
PWINDOW->m_vRealSize = calcSize;
|
PWINDOW->m_vRealSize = calcSize;
|
||||||
PWINDOW->m_vRealPosition = calcPos;
|
PWINDOW->m_vRealPosition = calcPos;
|
||||||
|
|
||||||
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize);
|
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize);
|
||||||
|
@ -471,10 +472,10 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow* p
|
||||||
if (PNODE->isMaster && getMastersOnWorkspace(PNODE->workspaceID) > 1) {
|
if (PNODE->isMaster && getMastersOnWorkspace(PNODE->workspaceID) > 1) {
|
||||||
// check master size
|
// check master size
|
||||||
const auto SIZEY = (PMONITOR->vecSize.y - PMONITOR->vecReservedTopLeft.y - PMONITOR->vecReservedBottomRight.y) / getMastersOnWorkspace(PNODE->workspaceID);
|
const auto SIZEY = (PMONITOR->vecSize.y - PMONITOR->vecReservedTopLeft.y - PMONITOR->vecReservedBottomRight.y) / getMastersOnWorkspace(PNODE->workspaceID);
|
||||||
PNODE->percSize = std::clamp(PNODE->percSize + pixResize.y / SIZEY, 0.05, 1.95);
|
PNODE->percSize = std::clamp(PNODE->percSize + pixResize.y / SIZEY, 0.05, 1.95);
|
||||||
} else if (!PNODE->isMaster && (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) - getMastersOnWorkspace(PNODE->workspaceID)) > 1) {
|
} else if (!PNODE->isMaster && (getNodesOnWorkspace(PWINDOW->m_iWorkspaceID) - getMastersOnWorkspace(PNODE->workspaceID)) > 1) {
|
||||||
const auto SIZEY = (PMONITOR->vecSize.y - PMONITOR->vecReservedTopLeft.y - PMONITOR->vecReservedBottomRight.y) / getNodesOnWorkspace(PNODE->workspaceID);
|
const auto SIZEY = (PMONITOR->vecSize.y - PMONITOR->vecReservedTopLeft.y - PMONITOR->vecReservedBottomRight.y) / getNodesOnWorkspace(PNODE->workspaceID);
|
||||||
PNODE->percSize = std::clamp(PNODE->percSize + pixResize.y / SIZEY, 0.05, 1.95);
|
PNODE->percSize = std::clamp(PNODE->percSize + pixResize.y / SIZEY, 0.05, 1.95);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,9 +489,9 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (on == pWindow->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(pWindow->m_iWorkspaceID))
|
if (on == pWindow->m_bIsFullscreen || g_pCompositor->isWorkspaceSpecial(pWindow->m_iWorkspaceID))
|
||||||
return; // ignore
|
return; // ignore
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
||||||
|
|
||||||
if (PWORKSPACE->m_bHasFullscreenWindow && on) {
|
if (PWORKSPACE->m_bHasFullscreenWindow && on) {
|
||||||
|
@ -500,7 +501,7 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
|
||||||
}
|
}
|
||||||
|
|
||||||
// otherwise, accept it.
|
// otherwise, accept it.
|
||||||
pWindow->m_bIsFullscreen = on;
|
pWindow->m_bIsFullscreen = on;
|
||||||
PWORKSPACE->m_bHasFullscreenWindow = !PWORKSPACE->m_bHasFullscreenWindow;
|
PWORKSPACE->m_bHasFullscreenWindow = !PWORKSPACE->m_bHasFullscreenWindow;
|
||||||
|
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent{"fullscreen", std::to_string((int)on)});
|
g_pEventManager->postEvent(SHyprIPCEvent{"fullscreen", std::to_string((int)on)});
|
||||||
|
@ -513,7 +514,7 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
|
||||||
else {
|
else {
|
||||||
// get back its' dimensions from position and size
|
// get back its' dimensions from position and size
|
||||||
pWindow->m_vRealPosition = pWindow->m_vPosition;
|
pWindow->m_vRealPosition = pWindow->m_vPosition;
|
||||||
pWindow->m_vRealSize = pWindow->m_vSize;
|
pWindow->m_vRealSize = pWindow->m_vSize;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// if it now got fullscreen, make it fullscreen
|
// if it now got fullscreen, make it fullscreen
|
||||||
|
@ -523,25 +524,25 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
|
||||||
// save position and size if floating
|
// save position and size if floating
|
||||||
if (pWindow->m_bIsFloating) {
|
if (pWindow->m_bIsFloating) {
|
||||||
pWindow->m_vPosition = pWindow->m_vRealPosition.vec();
|
pWindow->m_vPosition = pWindow->m_vRealPosition.vec();
|
||||||
pWindow->m_vSize = pWindow->m_vRealSize.vec();
|
pWindow->m_vSize = pWindow->m_vRealSize.vec();
|
||||||
}
|
}
|
||||||
|
|
||||||
// apply new pos and size being monitors' box
|
// apply new pos and size being monitors' box
|
||||||
if (fullscreenMode == FULLSCREEN_FULL) {
|
if (fullscreenMode == FULLSCREEN_FULL) {
|
||||||
pWindow->m_vRealPosition = PMONITOR->vecPosition;
|
pWindow->m_vRealPosition = PMONITOR->vecPosition;
|
||||||
pWindow->m_vRealSize = PMONITOR->vecSize;
|
pWindow->m_vRealSize = PMONITOR->vecSize;
|
||||||
} else {
|
} else {
|
||||||
// This is a massive hack.
|
// This is a massive hack.
|
||||||
// We make a fake "only" node and apply
|
// We make a fake "only" node and apply
|
||||||
// To keep consistent with the settings without C+P code
|
// To keep consistent with the settings without C+P code
|
||||||
|
|
||||||
SMasterNodeData fakeNode;
|
SMasterNodeData fakeNode;
|
||||||
fakeNode.pWindow = pWindow;
|
fakeNode.pWindow = pWindow;
|
||||||
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||||
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||||
fakeNode.workspaceID = pWindow->m_iWorkspaceID;
|
fakeNode.workspaceID = pWindow->m_iWorkspaceID;
|
||||||
pWindow->m_vPosition = fakeNode.position;
|
pWindow->m_vPosition = fakeNode.position;
|
||||||
pWindow->m_vSize = fakeNode.size;
|
pWindow->m_vSize = fakeNode.size;
|
||||||
|
|
||||||
applyNodeDataToWindow(&fakeNode);
|
applyNodeDataToWindow(&fakeNode);
|
||||||
}
|
}
|
||||||
|
@ -576,7 +577,7 @@ SWindowRenderLayoutHints CHyprMasterLayout::requestRenderHints(CWindow* pWindow)
|
||||||
void CHyprMasterLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
void CHyprMasterLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
||||||
// windows should be valid, insallah
|
// windows should be valid, insallah
|
||||||
|
|
||||||
const auto PNODE = getNodeFromWindow(pWindow);
|
const auto PNODE = getNodeFromWindow(pWindow);
|
||||||
const auto PNODE2 = getNodeFromWindow(pWindow2);
|
const auto PNODE2 = getNodeFromWindow(pWindow2);
|
||||||
|
|
||||||
if (!PNODE2 || !PNODE)
|
if (!PNODE2 || !PNODE)
|
||||||
|
@ -590,7 +591,7 @@ void CHyprMasterLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// massive hack: just swap window pointers, lol
|
// massive hack: just swap window pointers, lol
|
||||||
PNODE->pWindow = pWindow2;
|
PNODE->pWindow = pWindow2;
|
||||||
PNODE2->pWindow = pWindow;
|
PNODE2->pWindow = pWindow;
|
||||||
|
|
||||||
recalculateMonitor(pWindow->m_iMonitorID);
|
recalculateMonitor(pWindow->m_iMonitorID);
|
||||||
|
@ -635,7 +636,7 @@ CWindow* CHyprMasterLayout::getNextWindow(CWindow* pWindow, bool next) {
|
||||||
} else {
|
} else {
|
||||||
// focus next
|
// focus next
|
||||||
bool reached = false;
|
bool reached = false;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (auto n : m_lMasterNodesData) {
|
for (auto n : m_lMasterNodesData) {
|
||||||
if (n.pWindow == pWindow) {
|
if (n.pWindow == pWindow) {
|
||||||
reached = true;
|
reached = true;
|
||||||
|
@ -664,7 +665,7 @@ CWindow* CHyprMasterLayout::getNextWindow(CWindow* pWindow, bool next) {
|
||||||
} else {
|
} else {
|
||||||
// focus previous
|
// focus previous
|
||||||
bool reached = false;
|
bool reached = false;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) {
|
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) {
|
||||||
if (it->pWindow == pWindow) {
|
if (it->pWindow == pWindow) {
|
||||||
reached = true;
|
reached = true;
|
||||||
|
@ -694,7 +695,7 @@ bool CHyprMasterLayout::prepareLoseFocus(CWindow* pWindow) {
|
||||||
//if the current window is fullscreen, make it normal again if we are about to lose focus
|
//if the current window is fullscreen, make it normal again if we are about to lose focus
|
||||||
if (pWindow->m_bIsFullscreen) {
|
if (pWindow->m_bIsFullscreen) {
|
||||||
g_pCompositor->setWindowFullscreen(pWindow, false, FULLSCREEN_FULL);
|
g_pCompositor->setWindowFullscreen(pWindow, false, FULLSCREEN_FULL);
|
||||||
static auto *const INHERIT = &g_pConfigManager->getConfigValuePtr("master:inherit_fullscreen")->intValue;
|
static auto* const INHERIT = &g_pConfigManager->getConfigValuePtr("master:inherit_fullscreen")->intValue;
|
||||||
return *INHERIT == 1;
|
return *INHERIT == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -732,7 +733,6 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
||||||
if (!PMASTER)
|
if (!PMASTER)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
if (PMASTER->pWindow != PWINDOW) {
|
if (PMASTER->pWindow != PWINDOW) {
|
||||||
switchWindows(PWINDOW, PMASTER->pWindow);
|
switchWindows(PWINDOW, PMASTER->pWindow);
|
||||||
switchToWindow(PWINDOW);
|
switchToWindow(PWINDOW);
|
||||||
|
@ -835,7 +835,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
||||||
if (header.pWindow->m_bIsFloating)
|
if (header.pWindow->m_bIsFloating)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const auto PNODE = getNodeFromWindow(header.pWindow);
|
const auto PNODE = getNodeFromWindow(header.pWindow);
|
||||||
|
|
||||||
const auto WINDOWS = getNodesOnWorkspace(header.pWindow->m_iWorkspaceID);
|
const auto WINDOWS = getNodesOnWorkspace(header.pWindow->m_iWorkspaceID);
|
||||||
const auto MASTERS = getMastersOnWorkspace(header.pWindow->m_iWorkspaceID);
|
const auto MASTERS = getMastersOnWorkspace(header.pWindow->m_iWorkspaceID);
|
||||||
|
@ -900,13 +900,13 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
||||||
|
|
||||||
const auto PWORKSPACEDATA = getMasterWorkspaceData(PWINDOW->m_iWorkspaceID);
|
const auto PWORKSPACEDATA = getMasterWorkspaceData(PWINDOW->m_iWorkspaceID);
|
||||||
|
|
||||||
if (message == "orientationleft")
|
if (message == "orientationleft")
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
|
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
|
||||||
else if (message == "orientationright")
|
else if (message == "orientationright")
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_RIGHT;
|
PWORKSPACEDATA->orientation = ORIENTATION_RIGHT;
|
||||||
else if (message == "orientationtop")
|
else if (message == "orientationtop")
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
|
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
|
||||||
else if (message == "orientationbottom")
|
else if (message == "orientationbottom")
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
|
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
|
||||||
|
|
||||||
recalculateMonitor(header.pWindow->m_iMonitorID);
|
recalculateMonitor(header.pWindow->m_iMonitorID);
|
||||||
|
@ -924,7 +924,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
||||||
if (PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
|
if (PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
|
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
|
||||||
} else {
|
} else {
|
||||||
PWORKSPACEDATA->orientation = (eOrientation) (PWORKSPACEDATA->orientation + 1);
|
PWORKSPACEDATA->orientation = (eOrientation)(PWORKSPACEDATA->orientation + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
recalculateMonitor(header.pWindow->m_iMonitorID);
|
recalculateMonitor(header.pWindow->m_iMonitorID);
|
||||||
|
@ -941,7 +941,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
||||||
if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT) {
|
if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT) {
|
||||||
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
|
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
|
||||||
} else {
|
} else {
|
||||||
PWORKSPACEDATA->orientation = (eOrientation) (PWORKSPACEDATA->orientation - 1);
|
PWORKSPACEDATA->orientation = (eOrientation)(PWORKSPACEDATA->orientation - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
recalculateMonitor(header.pWindow->m_iMonitorID);
|
recalculateMonitor(header.pWindow->m_iMonitorID);
|
||||||
|
|
|
@ -4,11 +4,13 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#include <any>
|
||||||
|
|
||||||
enum eFullscreenMode : uint8_t;
|
enum eFullscreenMode : uint8_t;
|
||||||
|
|
||||||
//orientation determines which side of the screen the master area resides
|
//orientation determines which side of the screen the master area resides
|
||||||
enum eOrientation : uint8_t {
|
enum eOrientation : uint8_t
|
||||||
|
{
|
||||||
ORIENTATION_LEFT = 0,
|
ORIENTATION_LEFT = 0,
|
||||||
ORIENTATION_TOP,
|
ORIENTATION_TOP,
|
||||||
ORIENTATION_RIGHT,
|
ORIENTATION_RIGHT,
|
||||||
|
@ -16,67 +18,66 @@ enum eOrientation : uint8_t {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMasterNodeData {
|
struct SMasterNodeData {
|
||||||
bool isMaster = false;
|
bool isMaster = false;
|
||||||
float percMaster = 0.5f;
|
float percMaster = 0.5f;
|
||||||
|
|
||||||
CWindow* pWindow = nullptr;
|
CWindow* pWindow = nullptr;
|
||||||
|
|
||||||
Vector2D position;
|
Vector2D position;
|
||||||
Vector2D size;
|
Vector2D size;
|
||||||
|
|
||||||
float percSize = 1.f; // size multiplier for resizing children
|
float percSize = 1.f; // size multiplier for resizing children
|
||||||
|
|
||||||
int workspaceID = -1;
|
int workspaceID = -1;
|
||||||
|
|
||||||
bool operator==(const SMasterNodeData& rhs) {
|
bool operator==(const SMasterNodeData& rhs) {
|
||||||
return pWindow == rhs.pWindow;
|
return pWindow == rhs.pWindow;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SMasterWorkspaceData {
|
struct SMasterWorkspaceData {
|
||||||
int workspaceID = -1;
|
int workspaceID = -1;
|
||||||
eOrientation orientation = ORIENTATION_LEFT;
|
eOrientation orientation = ORIENTATION_LEFT;
|
||||||
|
|
||||||
bool operator==(const SMasterWorkspaceData& rhs) {
|
bool operator==(const SMasterWorkspaceData& rhs) {
|
||||||
return workspaceID == rhs.workspaceID;
|
return workspaceID == rhs.workspaceID;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CHyprMasterLayout : public IHyprLayout {
|
class CHyprMasterLayout : public IHyprLayout {
|
||||||
public:
|
public:
|
||||||
virtual void onWindowCreatedTiling(CWindow*);
|
virtual void onWindowCreatedTiling(CWindow*);
|
||||||
virtual void onWindowRemovedTiling(CWindow*);
|
virtual void onWindowRemovedTiling(CWindow*);
|
||||||
virtual bool isWindowTiled(CWindow*);
|
virtual bool isWindowTiled(CWindow*);
|
||||||
virtual void recalculateMonitor(const int&);
|
virtual void recalculateMonitor(const int&);
|
||||||
virtual void recalculateWindow(CWindow*);
|
virtual void recalculateWindow(CWindow*);
|
||||||
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
|
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
|
||||||
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
|
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
|
||||||
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
||||||
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
||||||
virtual void switchWindows(CWindow*, CWindow*);
|
virtual void switchWindows(CWindow*, CWindow*);
|
||||||
virtual void alterSplitRatioBy(CWindow*, float);
|
virtual void alterSplitRatioBy(CWindow*, float);
|
||||||
virtual std::string getLayoutName();
|
virtual std::string getLayoutName();
|
||||||
|
|
||||||
virtual void onEnable();
|
virtual void onEnable();
|
||||||
virtual void onDisable();
|
virtual void onDisable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::list<SMasterNodeData> m_lMasterNodesData;
|
||||||
std::list<SMasterNodeData> m_lMasterNodesData;
|
|
||||||
std::vector<SMasterWorkspaceData> m_lMasterWorkspacesData;
|
std::vector<SMasterWorkspaceData> m_lMasterWorkspacesData;
|
||||||
|
|
||||||
bool m_bForceWarps = false;
|
bool m_bForceWarps = false;
|
||||||
|
|
||||||
int getNodesOnWorkspace(const int&);
|
int getNodesOnWorkspace(const int&);
|
||||||
void applyNodeDataToWindow(SMasterNodeData*);
|
void applyNodeDataToWindow(SMasterNodeData*);
|
||||||
SMasterNodeData* getNodeFromWindow(CWindow*);
|
SMasterNodeData* getNodeFromWindow(CWindow*);
|
||||||
SMasterNodeData* getMasterNodeOnWorkspace(const int&);
|
SMasterNodeData* getMasterNodeOnWorkspace(const int&);
|
||||||
SMasterWorkspaceData* getMasterWorkspaceData(const int&);
|
SMasterWorkspaceData* getMasterWorkspaceData(const int&);
|
||||||
void calculateWorkspace(const int&);
|
void calculateWorkspace(const int&);
|
||||||
CWindow* getNextWindow(CWindow*, bool);
|
CWindow* getNextWindow(CWindow*, bool);
|
||||||
int getMastersOnWorkspace(const int&);
|
int getMastersOnWorkspace(const int&);
|
||||||
bool prepareLoseFocus(CWindow*);
|
bool prepareLoseFocus(CWindow*);
|
||||||
void prepareNewFocus(CWindow*, bool inherit_fullscreen);
|
void prepareNewFocus(CWindow*, bool inherit_fullscreen);
|
||||||
|
|
||||||
friend struct SMasterNodeData;
|
friend struct SMasterNodeData;
|
||||||
friend struct SMasterWorkspaceData;
|
friend struct SMasterWorkspaceData;
|
||||||
|
|
12
src/main.cpp
12
src/main.cpp
|
@ -20,7 +20,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
// parse some args
|
// parse some args
|
||||||
std::string configPath;
|
std::string configPath;
|
||||||
bool ignoreSudo = false;
|
bool ignoreSudo = false;
|
||||||
for (int i = 1; i < argc; ++i) {
|
for (int i = 1; i < argc; ++i) {
|
||||||
if (!strcmp(argv[i], "--i-am-really-stupid"))
|
if (!strcmp(argv[i], "--i-am-really-stupid"))
|
||||||
ignoreSudo = true;
|
ignoreSudo = true;
|
||||||
|
@ -28,9 +28,9 @@ int main(int argc, char** argv) {
|
||||||
configPath = std::string(argv[++i]);
|
configPath = std::string(argv[++i]);
|
||||||
Debug::log(LOG, "Using config location %s.", configPath.c_str());
|
Debug::log(LOG, "Using config location %s.", configPath.c_str());
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Hyprland usage: Hyprland [arg [...]].\n\nArguments:\n" <<
|
std::cout << "Hyprland usage: Hyprland [arg [...]].\n\nArguments:\n"
|
||||||
"--help -h | Show this help message\n" <<
|
<< "--help -h | Show this help message\n"
|
||||||
"--config -c | Specify config file to use\n";
|
<< "--config -c | Specify config file to use\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ int main(int argc, char** argv) {
|
||||||
if (Init::isSudo()) {
|
if (Init::isSudo()) {
|
||||||
std::cout << "Hyprland shall not be run as the root user. If you really want to, use the --i-am-really-stupid flag.\n";
|
std::cout << "Hyprland shall not be run as the root user. If you really want to, use the --i-am-really-stupid flag.\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Running with ignored root checks, I surely hope you know what you're doing.\n";
|
std::cout << "Running with ignored root checks, I surely hope you know what you're doing.\n";
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
@ -55,7 +55,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
// let's init the compositor.
|
// let's init the compositor.
|
||||||
// it initializes basic Wayland stuff in the constructor.
|
// it initializes basic Wayland stuff in the constructor.
|
||||||
g_pCompositor = std::make_unique<CCompositor>();
|
g_pCompositor = std::make_unique<CCompositor>();
|
||||||
g_pCompositor->explicitConfigPath = configPath;
|
g_pCompositor->explicitConfigPath = configPath;
|
||||||
|
|
||||||
Debug::log(LOG, "Hyprland init finished.");
|
Debug::log(LOG, "Hyprland init finished.");
|
||||||
|
|
|
@ -21,17 +21,17 @@ void CAnimationManager::addBezierWithName(std::string name, const Vector2D& p1,
|
||||||
|
|
||||||
void CAnimationManager::tick() {
|
void CAnimationManager::tick() {
|
||||||
|
|
||||||
bool animGlobalDisabled = false;
|
bool animGlobalDisabled = false;
|
||||||
|
|
||||||
static auto *const PANIMENABLED = &g_pConfigManager->getConfigValuePtr("animations:enabled")->intValue;
|
static auto* const PANIMENABLED = &g_pConfigManager->getConfigValuePtr("animations:enabled")->intValue;
|
||||||
|
|
||||||
if (!*PANIMENABLED)
|
if (!*PANIMENABLED)
|
||||||
animGlobalDisabled = true;
|
animGlobalDisabled = true;
|
||||||
|
|
||||||
static auto *const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||||
static auto *const PSHADOWSENABLED = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
|
static auto* const PSHADOWSENABLED = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
|
||||||
|
|
||||||
const auto DEFAULTBEZIER = m_mBezierCurves.find("default");
|
const auto DEFAULTBEZIER = m_mBezierCurves.find("default");
|
||||||
|
|
||||||
std::vector<CAnimatedVariable*> animationEndedVars;
|
std::vector<CAnimatedVariable*> animationEndedVars;
|
||||||
|
|
||||||
|
@ -50,23 +50,23 @@ void CAnimationManager::tick() {
|
||||||
const float SPENT = av->getPercent();
|
const float SPENT = av->getPercent();
|
||||||
|
|
||||||
// window stuff
|
// window stuff
|
||||||
const auto PWINDOW = (CWindow*)av->m_pWindow;
|
const auto PWINDOW = (CWindow*)av->m_pWindow;
|
||||||
const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace;
|
const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace;
|
||||||
const auto PLAYER = (SLayerSurface*)av->m_pLayer;
|
const auto PLAYER = (SLayerSurface*)av->m_pLayer;
|
||||||
CMonitor* PMONITOR = nullptr;
|
CMonitor* PMONITOR = nullptr;
|
||||||
bool animationsDisabled = animGlobalDisabled;
|
bool animationsDisabled = animGlobalDisabled;
|
||||||
|
|
||||||
wlr_box WLRBOXPREV = {0,0,0,0};
|
wlr_box WLRBOXPREV = {0, 0, 0, 0};
|
||||||
if (PWINDOW) {
|
if (PWINDOW) {
|
||||||
WLRBOXPREV = PWINDOW->getFullWindowBoundingBox();
|
WLRBOXPREV = PWINDOW->getFullWindowBoundingBox();
|
||||||
PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||||
animationsDisabled = animationsDisabled || PWINDOW->m_sAdditionalConfigData.forceNoAnims;
|
animationsDisabled = animationsDisabled || PWINDOW->m_sAdditionalConfigData.forceNoAnims;
|
||||||
} else if (PWORKSPACE) {
|
} else if (PWORKSPACE) {
|
||||||
PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
|
PMONITOR = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
|
||||||
WLRBOXPREV = {(int)PMONITOR->vecPosition.x, (int)PMONITOR->vecPosition.y, (int)PMONITOR->vecSize.x, (int)PMONITOR->vecSize.y};
|
WLRBOXPREV = {(int)PMONITOR->vecPosition.x, (int)PMONITOR->vecPosition.y, (int)PMONITOR->vecSize.x, (int)PMONITOR->vecSize.y};
|
||||||
} else if (PLAYER) {
|
} else if (PLAYER) {
|
||||||
WLRBOXPREV = PLAYER->geometry;
|
WLRBOXPREV = PLAYER->geometry;
|
||||||
PMONITOR = g_pCompositor->getMonitorFromVector(Vector2D(PLAYER->geometry.x, PLAYER->geometry.y) + Vector2D(PLAYER->geometry.width, PLAYER->geometry.height) / 2.f);
|
PMONITOR = g_pCompositor->getMonitorFromVector(Vector2D(PLAYER->geometry.x, PLAYER->geometry.y) + Vector2D(PLAYER->geometry.width, PLAYER->geometry.height) / 2.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// beziers are with a switch unforto
|
// beziers are with a switch unforto
|
||||||
|
@ -85,7 +85,7 @@ void CAnimationManager::tick() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto DELTA = av->m_fGoal - av->m_fBegun;
|
const auto DELTA = av->m_fGoal - av->m_fBegun;
|
||||||
const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
|
const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
|
||||||
|
|
||||||
if (BEZIER != m_mBezierCurves.end())
|
if (BEZIER != m_mBezierCurves.end())
|
||||||
|
@ -106,7 +106,7 @@ void CAnimationManager::tick() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto DELTA = av->m_vGoal - av->m_vBegun;
|
const auto DELTA = av->m_vGoal - av->m_vBegun;
|
||||||
const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
|
const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
|
||||||
|
|
||||||
if (BEZIER != m_mBezierCurves.end())
|
if (BEZIER != m_mBezierCurves.end())
|
||||||
|
@ -127,7 +127,7 @@ void CAnimationManager::tick() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto DELTA = av->m_cGoal - av->m_cBegun;
|
const auto DELTA = av->m_cGoal - av->m_cBegun;
|
||||||
const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
|
const auto BEZIER = m_mBezierCurves.find(av->m_pConfig->pValues->internalBezier);
|
||||||
|
|
||||||
if (BEZIER != m_mBezierCurves.end())
|
if (BEZIER != m_mBezierCurves.end())
|
||||||
|
@ -164,40 +164,45 @@ void CAnimationManager::tick() {
|
||||||
g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR);
|
g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} case AVARDAMAGE_BORDER: {
|
}
|
||||||
|
case AVARDAMAGE_BORDER: {
|
||||||
RASSERT(PWINDOW, "Tried to AVARDAMAGE_BORDER a non-window AVAR!");
|
RASSERT(PWINDOW, "Tried to AVARDAMAGE_BORDER a non-window AVAR!");
|
||||||
|
|
||||||
// damage only the border.
|
// damage only the border.
|
||||||
static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
|
static auto* const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
|
||||||
const auto ROUNDINGSIZE = *PROUNDING + 1;
|
const auto ROUNDINGSIZE = *PROUNDING + 1;
|
||||||
const auto BORDERSIZE = *PBORDERSIZE;
|
const auto BORDERSIZE = *PBORDERSIZE;
|
||||||
|
|
||||||
// damage for old box
|
// damage for old box
|
||||||
g_pHyprRenderer->damageBox(WLRBOXPREV.x - BORDERSIZE, WLRBOXPREV.y - BORDERSIZE, WLRBOXPREV.width + 2 * BORDERSIZE, BORDERSIZE + ROUNDINGSIZE); // top
|
g_pHyprRenderer->damageBox(WLRBOXPREV.x - BORDERSIZE, WLRBOXPREV.y - BORDERSIZE, WLRBOXPREV.width + 2 * BORDERSIZE, BORDERSIZE + ROUNDINGSIZE); // top
|
||||||
g_pHyprRenderer->damageBox(WLRBOXPREV.x - BORDERSIZE, WLRBOXPREV.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE, WLRBOXPREV.height + 2 * BORDERSIZE); // left
|
g_pHyprRenderer->damageBox(WLRBOXPREV.x - BORDERSIZE, WLRBOXPREV.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE, WLRBOXPREV.height + 2 * BORDERSIZE); // left
|
||||||
g_pHyprRenderer->damageBox(WLRBOXPREV.x + WLRBOXPREV.width - ROUNDINGSIZE, WLRBOXPREV.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE, WLRBOXPREV.height + 2 * BORDERSIZE); // right
|
g_pHyprRenderer->damageBox(WLRBOXPREV.x + WLRBOXPREV.width - ROUNDINGSIZE, WLRBOXPREV.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE,
|
||||||
g_pHyprRenderer->damageBox(WLRBOXPREV.x, WLRBOXPREV.y + WLRBOXPREV.height - ROUNDINGSIZE, WLRBOXPREV.width + 2 * BORDERSIZE, BORDERSIZE + ROUNDINGSIZE); // bottom
|
WLRBOXPREV.height + 2 * BORDERSIZE); // right
|
||||||
|
g_pHyprRenderer->damageBox(WLRBOXPREV.x, WLRBOXPREV.y + WLRBOXPREV.height - ROUNDINGSIZE, WLRBOXPREV.width + 2 * BORDERSIZE, BORDERSIZE + ROUNDINGSIZE); // bottom
|
||||||
|
|
||||||
// damage for new box
|
// damage for new box
|
||||||
const wlr_box WLRBOXNEW = {PWINDOW->m_vRealPosition.vec().x, PWINDOW->m_vRealPosition.vec().y, PWINDOW->m_vRealSize.vec().x, PWINDOW->m_vRealSize.vec().y};
|
const wlr_box WLRBOXNEW = {PWINDOW->m_vRealPosition.vec().x, PWINDOW->m_vRealPosition.vec().y, PWINDOW->m_vRealSize.vec().x, PWINDOW->m_vRealSize.vec().y};
|
||||||
g_pHyprRenderer->damageBox(WLRBOXNEW.x - BORDERSIZE, WLRBOXNEW.y - BORDERSIZE, WLRBOXNEW.width + 2 * BORDERSIZE, BORDERSIZE + ROUNDINGSIZE); // top
|
g_pHyprRenderer->damageBox(WLRBOXNEW.x - BORDERSIZE, WLRBOXNEW.y - BORDERSIZE, WLRBOXNEW.width + 2 * BORDERSIZE, BORDERSIZE + ROUNDINGSIZE); // top
|
||||||
g_pHyprRenderer->damageBox(WLRBOXNEW.x - BORDERSIZE, WLRBOXNEW.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE, WLRBOXNEW.height + 2 * BORDERSIZE); // left
|
g_pHyprRenderer->damageBox(WLRBOXNEW.x - BORDERSIZE, WLRBOXNEW.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE, WLRBOXNEW.height + 2 * BORDERSIZE); // left
|
||||||
g_pHyprRenderer->damageBox(WLRBOXNEW.x + WLRBOXNEW.width - ROUNDINGSIZE, WLRBOXNEW.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE, WLRBOXNEW.height + 2 * BORDERSIZE); // right
|
g_pHyprRenderer->damageBox(WLRBOXNEW.x + WLRBOXNEW.width - ROUNDINGSIZE, WLRBOXNEW.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE,
|
||||||
g_pHyprRenderer->damageBox(WLRBOXNEW.x, WLRBOXNEW.y + WLRBOXNEW.height - ROUNDINGSIZE, WLRBOXNEW.width + 2 * BORDERSIZE, BORDERSIZE + ROUNDINGSIZE); // bottom
|
WLRBOXNEW.height + 2 * BORDERSIZE); // right
|
||||||
|
g_pHyprRenderer->damageBox(WLRBOXNEW.x, WLRBOXNEW.y + WLRBOXNEW.height - ROUNDINGSIZE, WLRBOXNEW.width + 2 * BORDERSIZE, BORDERSIZE + ROUNDINGSIZE); // bottom
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} case AVARDAMAGE_SHADOW: {
|
}
|
||||||
|
case AVARDAMAGE_SHADOW: {
|
||||||
RASSERT(PWINDOW, "Tried to AVARDAMAGE_SHADOW a non-window AVAR!");
|
RASSERT(PWINDOW, "Tried to AVARDAMAGE_SHADOW a non-window AVAR!");
|
||||||
|
|
||||||
static auto *const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue;
|
static auto* const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue;
|
||||||
|
|
||||||
const auto PDECO = PWINDOW->getDecorationByType(DECORATION_SHADOW);
|
const auto PDECO = PWINDOW->getDecorationByType(DECORATION_SHADOW);
|
||||||
|
|
||||||
if (PDECO) {
|
if (PDECO) {
|
||||||
const auto EXTENTS = PDECO->getWindowDecorationExtents();
|
const auto EXTENTS = PDECO->getWindowDecorationExtents();
|
||||||
|
|
||||||
wlr_box dmg = {PWINDOW->m_vRealPosition.vec().x - EXTENTS.topLeft.x, PWINDOW->m_vRealPosition.vec().y - EXTENTS.topLeft.y,
|
wlr_box dmg = {PWINDOW->m_vRealPosition.vec().x - EXTENTS.topLeft.x, PWINDOW->m_vRealPosition.vec().y - EXTENTS.topLeft.y,
|
||||||
PWINDOW->m_vRealSize.vec().x + EXTENTS.topLeft.x + EXTENTS.bottomRight.x, PWINDOW->m_vRealSize.vec().y + EXTENTS.topLeft.y + EXTENTS.bottomRight.y};
|
PWINDOW->m_vRealSize.vec().x + EXTENTS.topLeft.x + EXTENTS.bottomRight.x,
|
||||||
|
PWINDOW->m_vRealSize.vec().y + EXTENTS.topLeft.y + EXTENTS.bottomRight.y};
|
||||||
|
|
||||||
if (!*PSHADOWIGNOREWINDOW) {
|
if (!*PSHADOWIGNOREWINDOW) {
|
||||||
// easy, damage the entire box
|
// easy, damage the entire box
|
||||||
|
@ -206,7 +211,8 @@ void CAnimationManager::tick() {
|
||||||
pixman_region32_t rg;
|
pixman_region32_t rg;
|
||||||
pixman_region32_init_rect(&rg, dmg.x, dmg.y, dmg.width, dmg.height);
|
pixman_region32_init_rect(&rg, dmg.x, dmg.y, dmg.width, dmg.height);
|
||||||
pixman_region32_t wb;
|
pixman_region32_t wb;
|
||||||
pixman_region32_init_rect(&wb, PWINDOW->m_vRealPosition.vec().x, PWINDOW->m_vRealPosition.vec().y, PWINDOW->m_vRealSize.vec().x, PWINDOW->m_vRealSize.vec().y);
|
pixman_region32_init_rect(&wb, PWINDOW->m_vRealPosition.vec().x, PWINDOW->m_vRealPosition.vec().y, PWINDOW->m_vRealSize.vec().x,
|
||||||
|
PWINDOW->m_vRealSize.vec().y);
|
||||||
pixman_region32_subtract(&rg, &rg, &wb);
|
pixman_region32_subtract(&rg, &rg, &wb);
|
||||||
g_pHyprRenderer->damageRegion(&rg);
|
g_pHyprRenderer->damageRegion(&rg);
|
||||||
pixman_region32_fini(&rg);
|
pixman_region32_fini(&rg);
|
||||||
|
@ -265,7 +271,7 @@ bool CAnimationManager::deltazero(const CColor& a, const CColor& b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAnimationManager::bezierExists(const std::string& bezier) {
|
bool CAnimationManager::bezierExists(const std::string& bezier) {
|
||||||
for (auto&[bc, bz] : m_mBezierCurves) {
|
for (auto& [bc, bz] : m_mBezierCurves) {
|
||||||
if (bc == bezier)
|
if (bc == bezier)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -279,33 +285,37 @@ bool CAnimationManager::bezierExists(const std::string& bezier) {
|
||||||
//
|
//
|
||||||
|
|
||||||
void CAnimationManager::animationPopin(CWindow* pWindow, bool close, float minPerc) {
|
void CAnimationManager::animationPopin(CWindow* pWindow, bool close, float minPerc) {
|
||||||
const auto GOALPOS = pWindow->m_vRealPosition.goalv();
|
const auto GOALPOS = pWindow->m_vRealPosition.goalv();
|
||||||
const auto GOALSIZE = pWindow->m_vRealSize.goalv();
|
const auto GOALSIZE = pWindow->m_vRealSize.goalv();
|
||||||
|
|
||||||
if (!close) {
|
if (!close) {
|
||||||
pWindow->m_vRealSize.setValue((GOALSIZE * minPerc).clamp({5, 5}, {GOALSIZE.x, GOALSIZE.y}));
|
pWindow->m_vRealSize.setValue((GOALSIZE * minPerc).clamp({5, 5}, {GOALSIZE.x, GOALSIZE.y}));
|
||||||
pWindow->m_vRealPosition.setValue(GOALPOS + GOALSIZE / 2.f - pWindow->m_vRealSize.m_vValue / 2.f);
|
pWindow->m_vRealPosition.setValue(GOALPOS + GOALSIZE / 2.f - pWindow->m_vRealSize.m_vValue / 2.f);
|
||||||
} else {
|
} else {
|
||||||
pWindow->m_vRealSize = (GOALSIZE * minPerc).clamp({5, 5}, {GOALSIZE.x, GOALSIZE.y});
|
pWindow->m_vRealSize = (GOALSIZE * minPerc).clamp({5, 5}, {GOALSIZE.x, GOALSIZE.y});
|
||||||
pWindow->m_vRealPosition = GOALPOS + GOALSIZE / 2.f - pWindow->m_vRealSize.m_vGoal / 2.f;
|
pWindow->m_vRealPosition = GOALPOS + GOALSIZE / 2.f - pWindow->m_vRealSize.m_vGoal / 2.f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimationManager::animationSlide(CWindow* pWindow, std::string force, bool close) {
|
void CAnimationManager::animationSlide(CWindow* pWindow, std::string force, bool close) {
|
||||||
pWindow->m_vRealSize.warp(false); // size we preserve in slide
|
pWindow->m_vRealSize.warp(false); // size we preserve in slide
|
||||||
|
|
||||||
const auto GOALPOS = pWindow->m_vRealPosition.goalv();
|
const auto GOALPOS = pWindow->m_vRealPosition.goalv();
|
||||||
const auto GOALSIZE = pWindow->m_vRealSize.goalv();
|
const auto GOALSIZE = pWindow->m_vRealSize.goalv();
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
||||||
|
|
||||||
Vector2D posOffset;
|
Vector2D posOffset;
|
||||||
|
|
||||||
if (force != "") {
|
if (force != "") {
|
||||||
if (force == "bottom") posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y);
|
if (force == "bottom")
|
||||||
else if (force == "left") posOffset = GOALPOS - Vector2D(GOALSIZE.x, 0);
|
posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y);
|
||||||
else if (force == "right") posOffset = GOALPOS + Vector2D(GOALSIZE.x, 0);
|
else if (force == "left")
|
||||||
else posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y - GOALSIZE.y);
|
posOffset = GOALPOS - Vector2D(GOALSIZE.x, 0);
|
||||||
|
else if (force == "right")
|
||||||
|
posOffset = GOALPOS + Vector2D(GOALSIZE.x, 0);
|
||||||
|
else
|
||||||
|
posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y - GOALSIZE.y);
|
||||||
|
|
||||||
if (!close)
|
if (!close)
|
||||||
pWindow->m_vRealPosition.setValue(posOffset);
|
pWindow->m_vRealPosition.setValue(posOffset);
|
||||||
|
@ -318,9 +328,9 @@ void CAnimationManager::animationSlide(CWindow* pWindow, std::string force, bool
|
||||||
const auto MIDPOINT = GOALPOS + GOALSIZE / 2.f;
|
const auto MIDPOINT = GOALPOS + GOALSIZE / 2.f;
|
||||||
|
|
||||||
// check sides it touches
|
// check sides it touches
|
||||||
const bool DISPLAYLEFT = STICKS(pWindow->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
const bool DISPLAYLEFT = STICKS(pWindow->m_vPosition.x, PMONITOR->vecPosition.x + PMONITOR->vecReservedTopLeft.x);
|
||||||
const bool DISPLAYRIGHT = STICKS(pWindow->m_vPosition.x + pWindow->m_vSize.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
|
const bool DISPLAYRIGHT = STICKS(pWindow->m_vPosition.x + pWindow->m_vSize.x, PMONITOR->vecPosition.x + PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x);
|
||||||
const bool DISPLAYTOP = STICKS(pWindow->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
const bool DISPLAYTOP = STICKS(pWindow->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
||||||
const bool DISPLAYBOTTOM = STICKS(pWindow->m_vPosition.y + pWindow->m_vSize.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
|
const bool DISPLAYBOTTOM = STICKS(pWindow->m_vPosition.y + pWindow->m_vSize.y, PMONITOR->vecPosition.y + PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y);
|
||||||
|
|
||||||
if (DISPLAYBOTTOM && DISPLAYTOP) {
|
if (DISPLAYBOTTOM && DISPLAYTOP) {
|
||||||
|
@ -351,12 +361,12 @@ void CAnimationManager::animationSlide(CWindow* pWindow, std::string force, bool
|
||||||
void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
|
void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
|
||||||
if (!close) {
|
if (!close) {
|
||||||
pWindow->m_vRealPosition.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsIn");
|
pWindow->m_vRealPosition.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsIn");
|
||||||
pWindow->m_vRealSize.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsIn");
|
pWindow->m_vRealSize.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsIn");
|
||||||
pWindow->m_fAlpha.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("fadeIn");
|
pWindow->m_fAlpha.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("fadeIn");
|
||||||
} else {
|
} else {
|
||||||
pWindow->m_vRealPosition.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsOut");
|
pWindow->m_vRealPosition.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsOut");
|
||||||
pWindow->m_vRealSize.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsOut");
|
pWindow->m_vRealSize.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsOut");
|
||||||
pWindow->m_fAlpha.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("fadeOut");
|
pWindow->m_fAlpha.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("fadeOut");
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ANIMSTYLE = pWindow->m_vRealPosition.m_pConfig->pValues->internalStyle;
|
auto ANIMSTYLE = pWindow->m_vRealPosition.m_pConfig->pValues->internalStyle;
|
||||||
|
@ -386,7 +396,7 @@ void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
|
||||||
if (pWindow->m_sAdditionalConfigData.animationStyle.find("%") != std::string::npos) {
|
if (pWindow->m_sAdditionalConfigData.animationStyle.find("%") != std::string::npos) {
|
||||||
try {
|
try {
|
||||||
auto percstr = pWindow->m_sAdditionalConfigData.animationStyle.substr(pWindow->m_sAdditionalConfigData.animationStyle.find_last_of(' '));
|
auto percstr = pWindow->m_sAdditionalConfigData.animationStyle.substr(pWindow->m_sAdditionalConfigData.animationStyle.find_last_of(' '));
|
||||||
minPerc = std::stoi(percstr.substr(0, percstr.length() - 1));
|
minPerc = std::stoi(percstr.substr(0, percstr.length() - 1));
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
; // oops
|
; // oops
|
||||||
}
|
}
|
||||||
|
@ -404,7 +414,7 @@ void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
|
||||||
if (ANIMSTYLE.find("%") != 0) {
|
if (ANIMSTYLE.find("%") != 0) {
|
||||||
try {
|
try {
|
||||||
auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' '));
|
auto percstr = ANIMSTYLE.substr(ANIMSTYLE.find_last_of(' '));
|
||||||
minPerc = std::stoi(percstr.substr(0, percstr.length() - 1));
|
minPerc = std::stoi(percstr.substr(0, percstr.length() - 1));
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
; // oops
|
; // oops
|
||||||
}
|
}
|
||||||
|
@ -425,10 +435,8 @@ std::string CAnimationManager::styleValidInConfigVar(const std::string& config,
|
||||||
if (style.find("%") != std::string::npos) {
|
if (style.find("%") != std::string::npos) {
|
||||||
try {
|
try {
|
||||||
auto percstr = style.substr(style.find_last_of(' '));
|
auto percstr = style.substr(style.find_last_of(' '));
|
||||||
minPerc = std::stoi(percstr.substr(0, percstr.length() - 1));
|
minPerc = std::stoi(percstr.substr(0, percstr.length() - 1));
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) { return "invalid minperc"; }
|
||||||
return "invalid minperc";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,35 +8,34 @@
|
||||||
#include "../Window.hpp"
|
#include "../Window.hpp"
|
||||||
|
|
||||||
class CAnimationManager {
|
class CAnimationManager {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CAnimationManager();
|
CAnimationManager();
|
||||||
|
|
||||||
void tick();
|
void tick();
|
||||||
void addBezierWithName(std::string, const Vector2D&, const Vector2D&);
|
void addBezierWithName(std::string, const Vector2D&, const Vector2D&);
|
||||||
void removeAllBeziers();
|
void removeAllBeziers();
|
||||||
|
|
||||||
void onWindowPostCreateClose(CWindow*, bool close = false);
|
void onWindowPostCreateClose(CWindow*, bool close = false);
|
||||||
|
|
||||||
bool bezierExists(const std::string&);
|
bool bezierExists(const std::string&);
|
||||||
|
|
||||||
std::string styleValidInConfigVar(const std::string&, const std::string&);
|
std::string styleValidInConfigVar(const std::string&, const std::string&);
|
||||||
|
|
||||||
std::list<CAnimatedVariable*> m_lAnimatedVariables;
|
std::list<CAnimatedVariable*> m_lAnimatedVariables;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool deltaSmallToFlip(const Vector2D& a, const Vector2D& b);
|
bool deltaSmallToFlip(const Vector2D& a, const Vector2D& b);
|
||||||
bool deltaSmallToFlip(const CColor& a, const CColor& b);
|
bool deltaSmallToFlip(const CColor& a, const CColor& b);
|
||||||
bool deltaSmallToFlip(const float& a, const float& b);
|
bool deltaSmallToFlip(const float& a, const float& b);
|
||||||
bool deltazero(const Vector2D& a, const Vector2D& b);
|
bool deltazero(const Vector2D& a, const Vector2D& b);
|
||||||
bool deltazero(const CColor& a, const CColor& b);
|
bool deltazero(const CColor& a, const CColor& b);
|
||||||
bool deltazero(const float& a, const float& b);
|
bool deltazero(const float& a, const float& b);
|
||||||
|
|
||||||
std::unordered_map<std::string, CBezierCurve> m_mBezierCurves;
|
std::unordered_map<std::string, CBezierCurve> m_mBezierCurves;
|
||||||
|
|
||||||
// Anim stuff
|
// Anim stuff
|
||||||
void animationPopin(CWindow*, bool close = false, float minPerc = 0.f);
|
void animationPopin(CWindow*, bool close = false, float minPerc = 0.f);
|
||||||
void animationSlide(CWindow*, std::string force = "", bool close = false);
|
void animationSlide(CWindow*, std::string force = "", bool close = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CAnimationManager> g_pAnimationManager;
|
inline std::unique_ptr<CAnimationManager> g_pAnimationManager;
|
|
@ -15,14 +15,13 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
CEventManager::CEventManager() {
|
CEventManager::CEventManager() {}
|
||||||
}
|
|
||||||
|
|
||||||
int fdHandleWrite(int fd, uint32_t mask, void* data) {
|
int fdHandleWrite(int fd, uint32_t mask, void* data) {
|
||||||
if (mask & WL_EVENT_ERROR || mask & WL_EVENT_HANGUP) {
|
if (mask & WL_EVENT_ERROR || mask & WL_EVENT_HANGUP) {
|
||||||
// remove, hanged up
|
// remove, hanged up
|
||||||
const auto ACCEPTEDFDS = (std::deque<std::pair<int, wl_event_source*>>*)data;
|
const auto ACCEPTEDFDS = (std::deque<std::pair<int, wl_event_source*>>*)data;
|
||||||
for (auto it = ACCEPTEDFDS->begin(); it != ACCEPTEDFDS->end(); ) {
|
for (auto it = ACCEPTEDFDS->begin(); it != ACCEPTEDFDS->end();) {
|
||||||
if (it->first == fd) {
|
if (it->first == fd) {
|
||||||
wl_event_source_remove(it->second); // remove this fd listener
|
wl_event_source_remove(it->second); // remove this fd listener
|
||||||
it = ACCEPTEDFDS->erase(it);
|
it = ACCEPTEDFDS->erase(it);
|
||||||
|
@ -45,7 +44,7 @@ void CEventManager::startThread() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sockaddr_un SERVERADDRESS = {.sun_family = AF_UNIX};
|
sockaddr_un SERVERADDRESS = {.sun_family = AF_UNIX};
|
||||||
std::string socketPath = "/tmp/hypr/" + g_pCompositor->m_szInstanceSignature + "/.socket2.sock";
|
std::string socketPath = "/tmp/hypr/" + g_pCompositor->m_szInstanceSignature + "/.socket2.sock";
|
||||||
strcpy(SERVERADDRESS.sun_path, socketPath.c_str());
|
strcpy(SERVERADDRESS.sun_path, socketPath.c_str());
|
||||||
|
|
||||||
bind(SOCKET, (sockaddr*)&SERVERADDRESS, SUN_LEN(&SERVERADDRESS));
|
bind(SOCKET, (sockaddr*)&SERVERADDRESS, SUN_LEN(&SERVERADDRESS));
|
||||||
|
@ -54,7 +53,7 @@ void CEventManager::startThread() {
|
||||||
listen(SOCKET, 10);
|
listen(SOCKET, 10);
|
||||||
|
|
||||||
sockaddr_in clientAddress;
|
sockaddr_in clientAddress;
|
||||||
socklen_t clientSize = sizeof(clientAddress);
|
socklen_t clientSize = sizeof(clientAddress);
|
||||||
|
|
||||||
Debug::log(LOG, "Hypr socket 2 started at %s", socketPath.c_str());
|
Debug::log(LOG, "Hypr socket 2 started at %s", socketPath.c_str());
|
||||||
|
|
||||||
|
@ -70,7 +69,8 @@ void CEventManager::startThread() {
|
||||||
Debug::log(LOG, "Socket 2 accepted a new client at FD %d", ACCEPTEDCONNECTION);
|
Debug::log(LOG, "Socket 2 accepted a new client at FD %d", ACCEPTEDCONNECTION);
|
||||||
|
|
||||||
// add to event loop so we can close it when we need to
|
// add to event loop so we can close it when we need to
|
||||||
m_dAcceptedSocketFDs.push_back({ACCEPTEDCONNECTION, wl_event_loop_add_fd(g_pCompositor->m_sWLEventLoop, ACCEPTEDCONNECTION, WL_EVENT_READABLE, fdHandleWrite, &m_dAcceptedSocketFDs)});
|
m_dAcceptedSocketFDs.push_back(
|
||||||
|
{ACCEPTEDCONNECTION, wl_event_loop_add_fd(g_pCompositor->m_sWLEventLoop, ACCEPTEDCONNECTION, WL_EVENT_READABLE, fdHandleWrite, &m_dAcceptedSocketFDs)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,15 +98,18 @@ void CEventManager::flushEvents() {
|
||||||
void CEventManager::postEvent(const SHyprIPCEvent event, bool force) {
|
void CEventManager::postEvent(const SHyprIPCEvent event, bool force) {
|
||||||
|
|
||||||
if ((m_bIgnoreEvents && !force) || g_pCompositor->m_bIsShuttingDown) {
|
if ((m_bIgnoreEvents && !force) || g_pCompositor->m_bIsShuttingDown) {
|
||||||
Debug::log(WARN, "Suppressed (ignoreevents true / shutting down) event of type %s, content: %s",event.event.c_str(), event.data.c_str());
|
Debug::log(WARN, "Suppressed (ignoreevents true / shutting down) event of type %s, content: %s", event.event.c_str(), event.data.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::thread([&](const SHyprIPCEvent ev) {
|
std::thread(
|
||||||
eventQueueMutex.lock();
|
[&](const SHyprIPCEvent ev) {
|
||||||
m_dQueuedEvents.push_back(ev);
|
eventQueueMutex.lock();
|
||||||
eventQueueMutex.unlock();
|
m_dQueuedEvents.push_back(ev);
|
||||||
|
eventQueueMutex.unlock();
|
||||||
|
|
||||||
flushEvents();
|
flushEvents();
|
||||||
}, event).detach();
|
},
|
||||||
|
event)
|
||||||
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,23 +12,22 @@ struct SHyprIPCEvent {
|
||||||
};
|
};
|
||||||
|
|
||||||
class CEventManager {
|
class CEventManager {
|
||||||
public:
|
public:
|
||||||
CEventManager();
|
CEventManager();
|
||||||
|
|
||||||
void postEvent(const SHyprIPCEvent event, bool force = false);
|
void postEvent(const SHyprIPCEvent event, bool force = false);
|
||||||
|
|
||||||
void startThread();
|
void startThread();
|
||||||
|
|
||||||
bool m_bIgnoreEvents = false;
|
bool m_bIgnoreEvents = false;
|
||||||
|
|
||||||
std::thread m_tThread;
|
std::thread m_tThread;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void flushEvents();
|
||||||
|
|
||||||
void flushEvents();
|
std::mutex eventQueueMutex;
|
||||||
|
std::deque<SHyprIPCEvent> m_dQueuedEvents;
|
||||||
std::mutex eventQueueMutex;
|
|
||||||
std::deque<SHyprIPCEvent> m_dQueuedEvents;
|
|
||||||
|
|
||||||
std::deque<std::pair<int, wl_event_source*>> m_dAcceptedSocketFDs;
|
std::deque<std::pair<int, wl_event_source*>> m_dAcceptedSocketFDs;
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,47 +5,47 @@
|
||||||
CKeybindManager::CKeybindManager() {
|
CKeybindManager::CKeybindManager() {
|
||||||
// initialize all dispatchers
|
// initialize all dispatchers
|
||||||
|
|
||||||
m_mDispatchers["exec"] = spawn;
|
m_mDispatchers["exec"] = spawn;
|
||||||
m_mDispatchers["killactive"] = killActive;
|
m_mDispatchers["killactive"] = killActive;
|
||||||
m_mDispatchers["closewindow"] = kill;
|
m_mDispatchers["closewindow"] = kill;
|
||||||
m_mDispatchers["togglefloating"] = toggleActiveFloating;
|
m_mDispatchers["togglefloating"] = toggleActiveFloating;
|
||||||
m_mDispatchers["workspace"] = changeworkspace;
|
m_mDispatchers["workspace"] = changeworkspace;
|
||||||
m_mDispatchers["fullscreen"] = fullscreenActive;
|
m_mDispatchers["fullscreen"] = fullscreenActive;
|
||||||
m_mDispatchers["movetoworkspace"] = moveActiveToWorkspace;
|
m_mDispatchers["movetoworkspace"] = moveActiveToWorkspace;
|
||||||
m_mDispatchers["movetoworkspacesilent"] = moveActiveToWorkspaceSilent;
|
m_mDispatchers["movetoworkspacesilent"] = moveActiveToWorkspaceSilent;
|
||||||
m_mDispatchers["pseudo"] = toggleActivePseudo;
|
m_mDispatchers["pseudo"] = toggleActivePseudo;
|
||||||
m_mDispatchers["movefocus"] = moveFocusTo;
|
m_mDispatchers["movefocus"] = moveFocusTo;
|
||||||
m_mDispatchers["movewindow"] = moveActiveTo;
|
m_mDispatchers["movewindow"] = moveActiveTo;
|
||||||
m_mDispatchers["centerwindow"] = centerWindow;
|
m_mDispatchers["centerwindow"] = centerWindow;
|
||||||
m_mDispatchers["togglegroup"] = toggleGroup;
|
m_mDispatchers["togglegroup"] = toggleGroup;
|
||||||
m_mDispatchers["changegroupactive"] = changeGroupActive;
|
m_mDispatchers["changegroupactive"] = changeGroupActive;
|
||||||
m_mDispatchers["togglesplit"] = toggleSplit;
|
m_mDispatchers["togglesplit"] = toggleSplit;
|
||||||
m_mDispatchers["splitratio"] = alterSplitRatio;
|
m_mDispatchers["splitratio"] = alterSplitRatio;
|
||||||
m_mDispatchers["focusmonitor"] = focusMonitor;
|
m_mDispatchers["focusmonitor"] = focusMonitor;
|
||||||
m_mDispatchers["movecursortocorner"] = moveCursorToCorner;
|
m_mDispatchers["movecursortocorner"] = moveCursorToCorner;
|
||||||
m_mDispatchers["workspaceopt"] = workspaceOpt;
|
m_mDispatchers["workspaceopt"] = workspaceOpt;
|
||||||
m_mDispatchers["exit"] = exitHyprland;
|
m_mDispatchers["exit"] = exitHyprland;
|
||||||
m_mDispatchers["movecurrentworkspacetomonitor"] = moveCurrentWorkspaceToMonitor;
|
m_mDispatchers["movecurrentworkspacetomonitor"] = moveCurrentWorkspaceToMonitor;
|
||||||
m_mDispatchers["moveworkspacetomonitor"] = moveWorkspaceToMonitor;
|
m_mDispatchers["moveworkspacetomonitor"] = moveWorkspaceToMonitor;
|
||||||
m_mDispatchers["togglespecialworkspace"] = toggleSpecialWorkspace;
|
m_mDispatchers["togglespecialworkspace"] = toggleSpecialWorkspace;
|
||||||
m_mDispatchers["forcerendererreload"] = forceRendererReload;
|
m_mDispatchers["forcerendererreload"] = forceRendererReload;
|
||||||
m_mDispatchers["resizeactive"] = resizeActive;
|
m_mDispatchers["resizeactive"] = resizeActive;
|
||||||
m_mDispatchers["moveactive"] = moveActive;
|
m_mDispatchers["moveactive"] = moveActive;
|
||||||
m_mDispatchers["cyclenext"] = circleNext;
|
m_mDispatchers["cyclenext"] = circleNext;
|
||||||
m_mDispatchers["focuswindowbyclass"] = focusWindow;
|
m_mDispatchers["focuswindowbyclass"] = focusWindow;
|
||||||
m_mDispatchers["focuswindow"] = focusWindow;
|
m_mDispatchers["focuswindow"] = focusWindow;
|
||||||
m_mDispatchers["submap"] = setSubmap;
|
m_mDispatchers["submap"] = setSubmap;
|
||||||
m_mDispatchers["pass"] = pass;
|
m_mDispatchers["pass"] = pass;
|
||||||
m_mDispatchers["layoutmsg"] = layoutmsg;
|
m_mDispatchers["layoutmsg"] = layoutmsg;
|
||||||
m_mDispatchers["toggleopaque"] = toggleOpaque;
|
m_mDispatchers["toggleopaque"] = toggleOpaque;
|
||||||
m_mDispatchers["dpms"] = dpms;
|
m_mDispatchers["dpms"] = dpms;
|
||||||
m_mDispatchers["movewindowpixel"] = moveWindow;
|
m_mDispatchers["movewindowpixel"] = moveWindow;
|
||||||
m_mDispatchers["resizewindowpixel"] = resizeWindow;
|
m_mDispatchers["resizewindowpixel"] = resizeWindow;
|
||||||
m_mDispatchers["swapnext"] = swapnext;
|
m_mDispatchers["swapnext"] = swapnext;
|
||||||
m_mDispatchers["swapactiveworkspaces"] = swapActiveWorkspaces;
|
m_mDispatchers["swapactiveworkspaces"] = swapActiveWorkspaces;
|
||||||
m_mDispatchers["pin"] = pinActive;
|
m_mDispatchers["pin"] = pinActive;
|
||||||
m_mDispatchers["mouse"] = mouse;
|
m_mDispatchers["mouse"] = mouse;
|
||||||
m_mDispatchers["bringactivetotop"] = bringActiveToTop;
|
m_mDispatchers["bringactivetotop"] = bringActiveToTop;
|
||||||
|
|
||||||
m_tScrollTimer.reset();
|
m_tScrollTimer.reset();
|
||||||
}
|
}
|
||||||
|
@ -67,8 +67,7 @@ void CKeybindManager::removeKeybind(uint32_t mod, const std::string& key) {
|
||||||
if (it == m_lKeybinds.end())
|
if (it == m_lKeybinds.end())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else if (it->modmask == mod && it->key == key) {
|
||||||
else if (it->modmask == mod && it->key == key) {
|
|
||||||
it = m_lKeybinds.erase(it);
|
it = m_lKeybinds.erase(it);
|
||||||
|
|
||||||
if (it == m_lKeybinds.end())
|
if (it == m_lKeybinds.end())
|
||||||
|
@ -109,28 +108,27 @@ void CKeybindManager::updateXKBTranslationState() {
|
||||||
m_pXKBTranslationState = nullptr;
|
m_pXKBTranslationState = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto FILEPATH = g_pConfigManager->getString("input:kb_file");
|
const auto FILEPATH = g_pConfigManager->getString("input:kb_file");
|
||||||
const auto RULES = g_pConfigManager->getString("input:kb_rules");
|
const auto RULES = g_pConfigManager->getString("input:kb_rules");
|
||||||
const auto MODEL = g_pConfigManager->getString("input:kb_model");
|
const auto MODEL = g_pConfigManager->getString("input:kb_model");
|
||||||
const auto LAYOUT = g_pConfigManager->getString("input:kb_layout");
|
const auto LAYOUT = g_pConfigManager->getString("input:kb_layout");
|
||||||
const auto VARIANT = g_pConfigManager->getString("input:kb_variant");
|
const auto VARIANT = g_pConfigManager->getString("input:kb_variant");
|
||||||
const auto OPTIONS = g_pConfigManager->getString("input:kb_options");
|
const auto OPTIONS = g_pConfigManager->getString("input:kb_options");
|
||||||
|
|
||||||
xkb_rule_names rules = {
|
xkb_rule_names rules = {.rules = RULES.c_str(), .model = MODEL.c_str(), .layout = LAYOUT.c_str(), .variant = VARIANT.c_str(), .options = OPTIONS.c_str()};
|
||||||
.rules = RULES.c_str(),
|
|
||||||
.model = MODEL.c_str(),
|
|
||||||
.layout = LAYOUT.c_str(),
|
|
||||||
.variant = VARIANT.c_str(),
|
|
||||||
.options = OPTIONS.c_str()};
|
|
||||||
|
|
||||||
const auto PCONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
const auto PCONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||||
|
|
||||||
auto PKEYMAP = FILEPATH == "" ? xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS) : xkb_keymap_new_from_file(PCONTEXT, fopen(FILEPATH.c_str(), "r"), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
auto PKEYMAP = FILEPATH == "" ? xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS) :
|
||||||
|
xkb_keymap_new_from_file(PCONTEXT, fopen(FILEPATH.c_str(), "r"), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
|
||||||
if (!PKEYMAP) {
|
if (!PKEYMAP) {
|
||||||
g_pHyprError->queueCreate("[Runtime Error] Invalid keyboard layout passed. ( rules: " + RULES + ", model: " + MODEL + ", variant: " + VARIANT + ", options: " + OPTIONS + ", layout: " + LAYOUT + " )", CColor(255, 50, 50, 255));
|
g_pHyprError->queueCreate("[Runtime Error] Invalid keyboard layout passed. ( rules: " + RULES + ", model: " + MODEL + ", variant: " + VARIANT + ", options: " + OPTIONS +
|
||||||
|
", layout: " + LAYOUT + " )",
|
||||||
|
CColor(255, 50, 50, 255));
|
||||||
|
|
||||||
Debug::log(ERR, "[XKBTranslationState] Keyboard layout %s with variant %s (rules: %s, model: %s, options: %s) couldn't have been loaded.", rules.layout, rules.variant, rules.rules, rules.model, rules.options);
|
Debug::log(ERR, "[XKBTranslationState] Keyboard layout %s with variant %s (rules: %s, model: %s, options: %s) couldn't have been loaded.", rules.layout, rules.variant,
|
||||||
|
rules.rules, rules.model, rules.options);
|
||||||
memset(&rules, 0, sizeof(rules));
|
memset(&rules, 0, sizeof(rules));
|
||||||
|
|
||||||
PKEYMAP = xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
PKEYMAP = xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
|
@ -148,7 +146,7 @@ bool CKeybindManager::ensureMouseBindState() {
|
||||||
m_bIsMouseBindActive = false;
|
m_bIsMouseBindActive = false;
|
||||||
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
||||||
g_pInputManager->currentlyDraggedWindow = nullptr;
|
g_pInputManager->currentlyDraggedWindow = nullptr;
|
||||||
g_pInputManager->dragMode = MBIND_INVALID;
|
g_pInputManager->dragMode = MBIND_INVALID;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -176,9 +174,9 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto KEYCODE = e->keycode + 8; // Because to xkbcommon it's +8 from libinput
|
const auto KEYCODE = e->keycode + 8; // Because to xkbcommon it's +8 from libinput
|
||||||
|
|
||||||
const xkb_keysym_t keysym = xkb_state_key_get_one_sym(m_pXKBTranslationState, KEYCODE);
|
const xkb_keysym_t keysym = xkb_state_key_get_one_sym(m_pXKBTranslationState, KEYCODE);
|
||||||
const xkb_keysym_t internalKeysym = xkb_state_key_get_one_sym(wlr_keyboard_from_input_device(pKeyboard->keyboard)->xkb_state, KEYCODE);
|
const xkb_keysym_t internalKeysym = xkb_state_key_get_one_sym(wlr_keyboard_from_input_device(pKeyboard->keyboard)->xkb_state, KEYCODE);
|
||||||
|
|
||||||
if (handleInternalKeybinds(internalKeysym))
|
if (handleInternalKeybinds(internalKeysym))
|
||||||
|
@ -186,8 +184,8 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard
|
||||||
|
|
||||||
const auto MODS = g_pInputManager->accumulateModsFromAllKBs();
|
const auto MODS = g_pInputManager->accumulateModsFromAllKBs();
|
||||||
|
|
||||||
m_uTimeLastMs = e->time_msec;
|
m_uTimeLastMs = e->time_msec;
|
||||||
m_uLastCode = KEYCODE;
|
m_uLastCode = KEYCODE;
|
||||||
m_uLastMouseCode = 0;
|
m_uLastMouseCode = 0;
|
||||||
|
|
||||||
bool mouseBindWasActive = ensureMouseBindState();
|
bool mouseBindWasActive = ensureMouseBindState();
|
||||||
|
@ -198,7 +196,7 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard
|
||||||
if (m_pActiveKeybindEventSource) {
|
if (m_pActiveKeybindEventSource) {
|
||||||
wl_event_source_remove(m_pActiveKeybindEventSource);
|
wl_event_source_remove(m_pActiveKeybindEventSource);
|
||||||
m_pActiveKeybindEventSource = nullptr;
|
m_pActiveKeybindEventSource = nullptr;
|
||||||
m_pActiveKeybind = nullptr;
|
m_pActiveKeybind = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dPressedKeycodes.push_back(KEYCODE);
|
m_dPressedKeycodes.push_back(KEYCODE);
|
||||||
|
@ -215,7 +213,7 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard
|
||||||
if (m_pActiveKeybindEventSource) {
|
if (m_pActiveKeybindEventSource) {
|
||||||
wl_event_source_remove(m_pActiveKeybindEventSource);
|
wl_event_source_remove(m_pActiveKeybindEventSource);
|
||||||
m_pActiveKeybindEventSource = nullptr;
|
m_pActiveKeybindEventSource = nullptr;
|
||||||
m_pActiveKeybind = nullptr;
|
m_pActiveKeybind = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dPressedKeycodes.erase(std::remove(m_dPressedKeycodes.begin(), m_dPressedKeycodes.end(), KEYCODE), m_dPressedKeycodes.end());
|
m_dPressedKeycodes.erase(std::remove(m_dPressedKeycodes.begin(), m_dPressedKeycodes.end(), KEYCODE), m_dPressedKeycodes.end());
|
||||||
|
@ -232,9 +230,9 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CKeybindManager::onAxisEvent(wlr_pointer_axis_event* e) {
|
bool CKeybindManager::onAxisEvent(wlr_pointer_axis_event* e) {
|
||||||
const auto MODS = g_pInputManager->accumulateModsFromAllKBs();
|
const auto MODS = g_pInputManager->accumulateModsFromAllKBs();
|
||||||
|
|
||||||
static auto *const PDELAY = &g_pConfigManager->getConfigValuePtr("binds:scroll_event_delay")->intValue;
|
static auto* const PDELAY = &g_pConfigManager->getConfigValuePtr("binds:scroll_event_delay")->intValue;
|
||||||
|
|
||||||
if (m_tScrollTimer.getMillis() < *PDELAY) {
|
if (m_tScrollTimer.getMillis() < *PDELAY) {
|
||||||
m_tScrollTimer.reset();
|
m_tScrollTimer.reset();
|
||||||
|
@ -261,11 +259,11 @@ bool CKeybindManager::onAxisEvent(wlr_pointer_axis_event* e) {
|
||||||
bool CKeybindManager::onMouseEvent(wlr_pointer_button_event* e) {
|
bool CKeybindManager::onMouseEvent(wlr_pointer_button_event* e) {
|
||||||
const auto MODS = g_pInputManager->accumulateModsFromAllKBs();
|
const auto MODS = g_pInputManager->accumulateModsFromAllKBs();
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
m_uLastMouseCode = e->button;
|
m_uLastMouseCode = e->button;
|
||||||
m_uLastCode = 0;
|
m_uLastCode = 0;
|
||||||
m_uTimeLastMs = e->time_msec;
|
m_uTimeLastMs = e->time_msec;
|
||||||
|
|
||||||
bool mouseBindWasActive = ensureMouseBindState();
|
bool mouseBindWasActive = ensureMouseBindState();
|
||||||
|
|
||||||
|
@ -316,7 +314,8 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string&
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& k : m_lKeybinds) {
|
for (auto& k : m_lKeybinds) {
|
||||||
if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap || (!pressed && !k.release && k.handler != "pass" && k.handler != "mouse") || k.shadowed)
|
if (modmask != k.modmask || (g_pCompositor->m_sSeat.exclusiveClient && !k.locked) || k.submap != m_szCurrentSelectedSubmap ||
|
||||||
|
(!pressed && !k.release && k.handler != "pass" && k.handler != "mouse") || k.shadowed)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!key.empty()) {
|
if (!key.empty()) {
|
||||||
|
@ -327,11 +326,11 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string&
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if (keysym == 0)
|
if (keysym == 0)
|
||||||
continue; // this is a keycode check run
|
continue; // this is a keycode check run
|
||||||
|
|
||||||
// oMg such performance hit!!11!
|
// oMg such performance hit!!11!
|
||||||
// this little maneouver is gonna cost us 4µs
|
// this little maneouver is gonna cost us 4µs
|
||||||
const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE);
|
const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE);
|
||||||
const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY);
|
const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY);
|
||||||
// small TODO: fix 0-9 keys and other modified ones with shift
|
// small TODO: fix 0-9 keys and other modified ones with shift
|
||||||
|
|
||||||
|
@ -370,7 +369,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string&
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k.repeat) {
|
if (k.repeat) {
|
||||||
m_pActiveKeybind = &k;
|
m_pActiveKeybind = &k;
|
||||||
m_pActiveKeybindEventSource = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, repeatKeyHandler, &m_pActiveKeybind);
|
m_pActiveKeybindEventSource = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, repeatKeyHandler, &m_pActiveKeybind);
|
||||||
|
|
||||||
const auto PACTIVEKEEB = g_pInputManager->m_pActiveKeyboard;
|
const auto PACTIVEKEEB = g_pInputManager->m_pActiveKeyboard;
|
||||||
|
@ -389,9 +388,9 @@ void CKeybindManager::shadowKeybinds(const xkb_keysym_t& doesntHave, const int&
|
||||||
|
|
||||||
for (auto& k : m_lKeybinds) {
|
for (auto& k : m_lKeybinds) {
|
||||||
|
|
||||||
bool shadow = false;
|
bool shadow = false;
|
||||||
|
|
||||||
const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE);
|
const auto KBKEY = xkb_keysym_from_name(k.key.c_str(), XKB_KEYSYM_CASE_INSENSITIVE);
|
||||||
const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY);
|
const auto KBKEYUPPER = xkb_keysym_to_upper(KBKEY);
|
||||||
|
|
||||||
for (auto& pk : m_dPressedKeysyms) {
|
for (auto& pk : m_dPressedKeysyms) {
|
||||||
|
@ -433,10 +432,10 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) {
|
||||||
|
|
||||||
// vtnr is bugged for some reason.
|
// vtnr is bugged for some reason.
|
||||||
const std::string TTYSTR = execAndGet("head -n 1 /sys/devices/virtual/tty/tty0/active").substr(3);
|
const std::string TTYSTR = execAndGet("head -n 1 /sys/devices/virtual/tty/tty0/active").substr(3);
|
||||||
unsigned int ttynum = 0;
|
unsigned int ttynum = 0;
|
||||||
try {
|
try {
|
||||||
ttynum = std::stoll(TTYSTR);
|
ttynum = std::stoll(TTYSTR);
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception& e) {
|
||||||
; // oops?
|
; // oops?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,7 +451,7 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) {
|
||||||
|
|
||||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||||
m->noFrameSchedule = true;
|
m->noFrameSchedule = true;
|
||||||
m->framesToSkip = 1;
|
m->framesToSkip = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug::log(LOG, "Switched to VT %i, destroyed all render data, frames to skip for each: 2", TTY);
|
Debug::log(LOG, "Switched to VT %i, destroyed all render data, frames to skip for each: 2", TTY);
|
||||||
|
@ -491,7 +490,7 @@ void CKeybindManager::spawn(std::string args) {
|
||||||
if (args[0] == '[') {
|
if (args[0] == '[') {
|
||||||
// we have exec rules
|
// we have exec rules
|
||||||
RULES = args.substr(1, args.substr(1).find_first_of(']'));
|
RULES = args.substr(1, args.substr(1).find_first_of(']'));
|
||||||
args = args.substr(args.find_first_of(']') + 1);
|
args = args.substr(args.find_first_of(']') + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_pXWaylandManager->m_sWLRXWayland)
|
if (g_pXWaylandManager->m_sWLRXWayland)
|
||||||
|
@ -613,7 +612,7 @@ void CKeybindManager::centerWindow(std::string args) {
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||||
|
|
||||||
PWINDOW->m_vRealPosition = PMONITOR->vecPosition + PMONITOR->vecSize / 2.f - PWINDOW->m_vRealSize.goalv() / 2.f;
|
PWINDOW->m_vRealPosition = PMONITOR->vecPosition + PMONITOR->vecSize / 2.f - PWINDOW->m_vRealSize.goalv() / 2.f;
|
||||||
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.goalv();
|
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.goalv();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::toggleActivePseudo(std::string args) {
|
void CKeybindManager::toggleActivePseudo(std::string args) {
|
||||||
|
@ -629,8 +628,8 @@ void CKeybindManager::toggleActivePseudo(std::string args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::changeworkspace(std::string args) {
|
void CKeybindManager::changeworkspace(std::string args) {
|
||||||
int workspaceToChangeTo = 0;
|
int workspaceToChangeTo = 0;
|
||||||
std::string workspaceName = "";
|
std::string workspaceName = "";
|
||||||
|
|
||||||
// Flag needed so that the previous workspace is not recorded when switching
|
// Flag needed so that the previous workspace is not recorded when switching
|
||||||
// to a previous workspace.
|
// to a previous workspace.
|
||||||
|
@ -639,7 +638,7 @@ void CKeybindManager::changeworkspace(std::string args) {
|
||||||
bool internal = false;
|
bool internal = false;
|
||||||
|
|
||||||
if (args.find("[internal]") == 0) {
|
if (args.find("[internal]") == 0) {
|
||||||
workspaceToChangeTo = std::stoi(args.substr(10));
|
workspaceToChangeTo = std::stoi(args.substr(10));
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceToChangeTo);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceToChangeTo);
|
||||||
if (PWORKSPACE)
|
if (PWORKSPACE)
|
||||||
workspaceName = PWORKSPACE->m_szName;
|
workspaceName = PWORKSPACE->m_szName;
|
||||||
|
@ -664,7 +663,7 @@ void CKeybindManager::changeworkspace(std::string args) {
|
||||||
|
|
||||||
// If the previous workspace ID isn't reset, cycles can form when continually going
|
// If the previous workspace ID isn't reset, cycles can form when continually going
|
||||||
// to the previous workspace again and again.
|
// to the previous workspace again and again.
|
||||||
static auto *const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue;
|
static auto* const PALLOWWORKSPACECYCLES = &g_pConfigManager->getConfigValuePtr("binds:allow_workspace_cycles")->intValue;
|
||||||
if (!*PALLOWWORKSPACECYCLES)
|
if (!*PALLOWWORKSPACECYCLES)
|
||||||
PCURRENTWORKSPACE->m_iPrevWorkspaceID = -1;
|
PCURRENTWORKSPACE->m_iPrevWorkspaceID = -1;
|
||||||
}
|
}
|
||||||
|
@ -679,8 +678,8 @@ void CKeybindManager::changeworkspace(std::string args) {
|
||||||
|
|
||||||
// Workspace_back_and_forth being enabled means that an attempt to switch to
|
// Workspace_back_and_forth being enabled means that an attempt to switch to
|
||||||
// the current workspace will instead switch to the previous.
|
// the current workspace will instead switch to the previous.
|
||||||
const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
|
const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
|
||||||
static auto *const PBACKANDFORTH = &g_pConfigManager->getConfigValuePtr("binds:workspace_back_and_forth")->intValue;
|
static auto* const PBACKANDFORTH = &g_pConfigManager->getConfigValuePtr("binds:workspace_back_and_forth")->intValue;
|
||||||
|
|
||||||
if (*PBACKANDFORTH && PCURRENTWORKSPACE && PCURRENTWORKSPACE->m_iID == workspaceToChangeTo && PCURRENTWORKSPACE->m_iPrevWorkspaceID != -1 && !internal) {
|
if (*PBACKANDFORTH && PCURRENTWORKSPACE && PCURRENTWORKSPACE->m_iID == workspaceToChangeTo && PCURRENTWORKSPACE->m_iPrevWorkspaceID != -1 && !internal) {
|
||||||
|
|
||||||
|
@ -874,7 +873,7 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
|
||||||
|
|
||||||
if (args.contains(',')) {
|
if (args.contains(',')) {
|
||||||
PWINDOW = g_pCompositor->getWindowByRegex(args.substr(args.find_last_of(',') + 1));
|
PWINDOW = g_pCompositor->getWindowByRegex(args.substr(args.find_last_of(',') + 1));
|
||||||
args = args.substr(0, args.find_last_of(','));
|
args = args.substr(0, args.find_last_of(','));
|
||||||
} else {
|
} else {
|
||||||
PWINDOW = g_pCompositor->m_pLastWindow;
|
PWINDOW = g_pCompositor->m_pLastWindow;
|
||||||
}
|
}
|
||||||
|
@ -886,7 +885,7 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
|
||||||
|
|
||||||
// hack
|
// hack
|
||||||
std::string workspaceName;
|
std::string workspaceName;
|
||||||
const auto WORKSPACEID = getWorkspaceIDFromString(args, workspaceName);
|
const auto WORKSPACEID = getWorkspaceIDFromString(args, workspaceName);
|
||||||
|
|
||||||
if (WORKSPACEID == INT_MAX) {
|
if (WORKSPACEID == INT_MAX) {
|
||||||
Debug::log(LOG, "Invalid workspace in moveActiveToWorkspace");
|
Debug::log(LOG, "Invalid workspace in moveActiveToWorkspace");
|
||||||
|
@ -898,8 +897,8 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto PSAVEDSIZE = PWINDOW->m_vRealSize.goalv();
|
auto PSAVEDSIZE = PWINDOW->m_vRealSize.goalv();
|
||||||
auto PSAVEDPOS = PWINDOW->m_vRealPosition.goalv();
|
auto PSAVEDPOS = PWINDOW->m_vRealPosition.goalv();
|
||||||
const bool WASFULLSCREEN = PWINDOW->m_bIsFullscreen;
|
const bool WASFULLSCREEN = PWINDOW->m_bIsFullscreen;
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(PWINDOW);
|
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(PWINDOW);
|
||||||
|
@ -931,7 +930,8 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
|
||||||
// and restore it
|
// and restore it
|
||||||
if (PWINDOW->m_bIsFloating) {
|
if (PWINDOW->m_bIsFloating) {
|
||||||
PWINDOW->m_vRealSize.setValueAndWarp(PSAVEDSIZE);
|
PWINDOW->m_vRealSize.setValueAndWarp(PSAVEDSIZE);
|
||||||
PWINDOW->m_vRealPosition.setValueAndWarp(PSAVEDPOS - g_pCompositor->getMonitorFromID(OLDWORKSPACE->m_iMonitorID)->vecPosition + g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID)->vecPosition);
|
PWINDOW->m_vRealPosition.setValueAndWarp(PSAVEDPOS - g_pCompositor->getMonitorFromID(OLDWORKSPACE->m_iMonitorID)->vecPosition +
|
||||||
|
g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID)->vecPosition);
|
||||||
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.vec();
|
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.vec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,13 +952,13 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
||||||
// hacky, but works lol
|
// hacky, but works lol
|
||||||
// TODO: this sucks
|
// TODO: this sucks
|
||||||
|
|
||||||
CWindow* PWINDOW = nullptr;
|
CWindow* PWINDOW = nullptr;
|
||||||
|
|
||||||
const auto ORIGINALARGS = args;
|
const auto ORIGINALARGS = args;
|
||||||
|
|
||||||
if (args.contains(',')) {
|
if (args.contains(',')) {
|
||||||
PWINDOW = g_pCompositor->getWindowByRegex(args.substr(args.find_last_of(',') + 1));
|
PWINDOW = g_pCompositor->getWindowByRegex(args.substr(args.find_last_of(',') + 1));
|
||||||
args = args.substr(0, args.find_last_of(','));
|
args = args.substr(0, args.find_last_of(','));
|
||||||
} else {
|
} else {
|
||||||
PWINDOW = g_pCompositor->m_pLastWindow;
|
PWINDOW = g_pCompositor->m_pLastWindow;
|
||||||
}
|
}
|
||||||
|
@ -966,8 +966,8 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
||||||
if (!PWINDOW)
|
if (!PWINDOW)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int workspaceToMoveTo = 0;
|
int workspaceToMoveTo = 0;
|
||||||
std::string workspaceName = "";
|
std::string workspaceName = "";
|
||||||
|
|
||||||
workspaceToMoveTo = getWorkspaceIDFromString(args, workspaceName);
|
workspaceToMoveTo = getWorkspaceIDFromString(args, workspaceName);
|
||||||
|
|
||||||
|
@ -992,9 +992,9 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto OLDWORKSPACEIDONMONITOR = PMONITORNEW->activeWorkspace;
|
const auto OLDWORKSPACEIDONMONITOR = PMONITORNEW->activeWorkspace;
|
||||||
const auto OLDWORKSPACEIDRETURN = PMONITOR->activeWorkspace;
|
const auto OLDWORKSPACEIDRETURN = PMONITOR->activeWorkspace;
|
||||||
|
|
||||||
const auto POLDWORKSPACEONMON = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDONMONITOR);
|
const auto POLDWORKSPACEONMON = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDONMONITOR);
|
||||||
const auto POLDWORKSPACEIDRETURN = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDRETURN);
|
const auto POLDWORKSPACEIDRETURN = g_pCompositor->getWorkspaceByID(OLDWORKSPACEIDRETURN);
|
||||||
|
|
||||||
g_pEventManager->m_bIgnoreEvents = true;
|
g_pEventManager->m_bIgnoreEvents = true;
|
||||||
|
@ -1007,7 +1007,7 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
||||||
changeworkspace("[internal]" + std::to_string(OLDWORKSPACEIDRETURN));
|
changeworkspace("[internal]" + std::to_string(OLDWORKSPACEIDRETURN));
|
||||||
|
|
||||||
// revert animations
|
// revert animations
|
||||||
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
|
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
||||||
PWORKSPACE->m_fAlpha.setValueAndWarp(0.f);
|
PWORKSPACE->m_fAlpha.setValueAndWarp(0.f);
|
||||||
|
|
||||||
POLDWORKSPACEIDRETURN->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
POLDWORKSPACEIDRETURN->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
||||||
|
@ -1021,9 +1021,9 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
||||||
// manually post event cuz it got ignored above
|
// manually post event cuz it got ignored above
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", getFormat("%x,%s", PWINDOW, PWORKSPACE->m_szName.c_str())});
|
g_pEventManager->postEvent(SHyprIPCEvent{"movewindow", getFormat("%x,%s", PWINDOW, PWORKSPACE->m_szName.c_str())});
|
||||||
|
|
||||||
PWINDOW->m_iWorkspaceID = OLDWORKSPACEIDRETURN;
|
PWINDOW->m_iWorkspaceID = OLDWORKSPACEIDRETURN;
|
||||||
const auto PNEXTCANDIDATE = g_pLayoutManager->getCurrentLayout()->getNextWindowCandidate(PWINDOW);
|
const auto PNEXTCANDIDATE = g_pLayoutManager->getCurrentLayout()->getNextWindowCandidate(PWINDOW);
|
||||||
PWINDOW->m_iWorkspaceID = workspaceToMoveTo;
|
PWINDOW->m_iWorkspaceID = workspaceToMoveTo;
|
||||||
|
|
||||||
g_pCompositor->focusWindow(PNEXTCANDIDATE);
|
g_pCompositor->focusWindow(PNEXTCANDIDATE);
|
||||||
}
|
}
|
||||||
|
@ -1045,10 +1045,9 @@ void CKeybindManager::moveFocusTo(std::string args) {
|
||||||
g_pInputManager->unconstrainMouse();
|
g_pInputManager->unconstrainMouse();
|
||||||
|
|
||||||
auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) {
|
auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) {
|
||||||
|
|
||||||
if (PLASTWINDOW->m_iWorkspaceID == PWINDOWTOCHANGETO->m_iWorkspaceID && PLASTWINDOW->m_bIsFullscreen) {
|
if (PLASTWINDOW->m_iWorkspaceID == PWINDOWTOCHANGETO->m_iWorkspaceID && PLASTWINDOW->m_bIsFullscreen) {
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PLASTWINDOW->m_iWorkspaceID);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PLASTWINDOW->m_iWorkspaceID);
|
||||||
const auto FSMODE = PWORKSPACE->m_efFullscreenMode;
|
const auto FSMODE = PWORKSPACE->m_efFullscreenMode;
|
||||||
|
|
||||||
if (!PWINDOWTOCHANGETO->m_bPinned)
|
if (!PWINDOWTOCHANGETO->m_bPinned)
|
||||||
g_pCompositor->setWindowFullscreen(PLASTWINDOW, false, FULLSCREEN_FULL);
|
g_pCompositor->setWindowFullscreen(PLASTWINDOW, false, FULLSCREEN_FULL);
|
||||||
|
@ -1084,7 +1083,7 @@ void CKeybindManager::moveFocusTo(std::string args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::moveActiveTo(std::string args) {
|
void CKeybindManager::moveActiveTo(std::string args) {
|
||||||
char arg = args[0];
|
char arg = args[0];
|
||||||
|
|
||||||
const auto LASTMONITOR = g_pCompositor->m_pLastMonitor;
|
const auto LASTMONITOR = g_pCompositor->m_pLastMonitor;
|
||||||
|
|
||||||
|
@ -1202,15 +1201,18 @@ void CKeybindManager::moveCursorToCorner(std::string arg) {
|
||||||
switch (CORNER) {
|
switch (CORNER) {
|
||||||
case 0:
|
case 0:
|
||||||
// bottom left
|
// bottom left
|
||||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x, PWINDOW->m_vRealPosition.vec().y + PWINDOW->m_vRealSize.vec().y);
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x,
|
||||||
|
PWINDOW->m_vRealPosition.vec().y + PWINDOW->m_vRealSize.vec().y);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// bottom right
|
// bottom right
|
||||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x + PWINDOW->m_vRealSize.vec().x, PWINDOW->m_vRealPosition.vec().y + PWINDOW->m_vRealSize.vec().y);
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x + PWINDOW->m_vRealSize.vec().x,
|
||||||
|
PWINDOW->m_vRealPosition.vec().y + PWINDOW->m_vRealSize.vec().y);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
// top right
|
// top right
|
||||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x + PWINDOW->m_vRealSize.vec().x, PWINDOW->m_vRealPosition.vec().y);
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PWINDOW->m_vRealPosition.vec().x + PWINDOW->m_vRealSize.vec().x,
|
||||||
|
PWINDOW->m_vRealPosition.vec().y);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
// top left
|
// top left
|
||||||
|
@ -1251,7 +1253,7 @@ void CKeybindManager::workspaceOpt(std::string args) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!w->m_bRequestsFloat && w->m_bIsFloating != PWORKSPACE->m_bDefaultFloating) {
|
if (!w->m_bRequestsFloat && w->m_bIsFloating != PWORKSPACE->m_bDefaultFloating) {
|
||||||
const auto SAVEDPOS = w->m_vRealPosition.vec();
|
const auto SAVEDPOS = w->m_vRealPosition.vec();
|
||||||
const auto SAVEDSIZE = w->m_vRealSize.vec();
|
const auto SAVEDSIZE = w->m_vRealSize.vec();
|
||||||
|
|
||||||
w->m_bIsFloating = PWORKSPACE->m_bDefaultFloating;
|
w->m_bIsFloating = PWORKSPACE->m_bDefaultFloating;
|
||||||
|
@ -1261,8 +1263,8 @@ void CKeybindManager::workspaceOpt(std::string args) {
|
||||||
w->m_vRealPosition.setValueAndWarp(SAVEDPOS);
|
w->m_vRealPosition.setValueAndWarp(SAVEDPOS);
|
||||||
w->m_vRealSize.setValueAndWarp(SAVEDSIZE);
|
w->m_vRealSize.setValueAndWarp(SAVEDSIZE);
|
||||||
g_pXWaylandManager->setWindowSize(w, SAVEDSIZE);
|
g_pXWaylandManager->setWindowSize(w, SAVEDSIZE);
|
||||||
w->m_vRealSize = w->m_vRealSize.vec() + Vector2D(4,4);
|
w->m_vRealSize = w->m_vRealSize.vec() + Vector2D(4, 4);
|
||||||
w->m_vRealPosition = w->m_vRealPosition.vec() - Vector2D(2,2);
|
w->m_vRealPosition = w->m_vRealPosition.vec() - Vector2D(2, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1299,17 +1301,17 @@ void CKeybindManager::moveWorkspaceToMonitor(std::string args) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string workspace = args.substr(0, args.find_first_of(' '));
|
std::string workspace = args.substr(0, args.find_first_of(' '));
|
||||||
std::string monitor = args.substr(args.find_first_of(' ') + 1);
|
std::string monitor = args.substr(args.find_first_of(' ') + 1);
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromString(monitor);
|
const auto PMONITOR = g_pCompositor->getMonitorFromString(monitor);
|
||||||
|
|
||||||
if (!PMONITOR){
|
if (!PMONITOR) {
|
||||||
Debug::log(ERR, "Ignoring moveWorkspaceToMonitor: monitor doesnt exist");
|
Debug::log(ERR, "Ignoring moveWorkspaceToMonitor: monitor doesnt exist");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string workspaceName;
|
std::string workspaceName;
|
||||||
const int WORKSPACEID = getWorkspaceIDFromString(workspace, workspaceName);
|
const int WORKSPACEID = getWorkspaceIDFromString(workspace, workspaceName);
|
||||||
|
|
||||||
if (WORKSPACEID == INT_MAX) {
|
if (WORKSPACEID == INT_MAX) {
|
||||||
Debug::log(ERR, "moveWorkspaceToMonitor invalid workspace!");
|
Debug::log(ERR, "moveWorkspaceToMonitor invalid workspace!");
|
||||||
|
@ -1328,10 +1330,10 @@ void CKeybindManager::moveWorkspaceToMonitor(std::string args) {
|
||||||
|
|
||||||
void CKeybindManager::toggleSpecialWorkspace(std::string args) {
|
void CKeybindManager::toggleSpecialWorkspace(std::string args) {
|
||||||
|
|
||||||
static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
||||||
|
|
||||||
std::string workspaceName = "";
|
std::string workspaceName = "";
|
||||||
int workspaceID = getWorkspaceIDFromString("special:" + args, workspaceName);
|
int workspaceID = getWorkspaceIDFromString("special:" + args, workspaceName);
|
||||||
|
|
||||||
if (workspaceID == INT_MAX || !g_pCompositor->isWorkspaceSpecial(workspaceID)) {
|
if (workspaceID == INT_MAX || !g_pCompositor->isWorkspaceSpecial(workspaceID)) {
|
||||||
Debug::log(ERR, "Invalid workspace passed to special");
|
Debug::log(ERR, "Invalid workspace passed to special");
|
||||||
|
@ -1343,9 +1345,9 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool requestedWorkspaceIsAlreadyOpen = false;
|
bool requestedWorkspaceIsAlreadyOpen = false;
|
||||||
const auto PMONITOR = *PFOLLOWMOUSE == 1 ? g_pCompositor->getMonitorFromCursor() : g_pCompositor->m_pLastMonitor;
|
const auto PMONITOR = *PFOLLOWMOUSE == 1 ? g_pCompositor->getMonitorFromCursor() : g_pCompositor->m_pLastMonitor;
|
||||||
int specialOpenOnMonitor = PMONITOR->specialWorkspaceID;
|
int specialOpenOnMonitor = PMONITOR->specialWorkspaceID;
|
||||||
|
|
||||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||||
if (m->specialWorkspaceID == workspaceID) {
|
if (m->specialWorkspaceID == workspaceID) {
|
||||||
|
@ -1382,7 +1384,7 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) {
|
||||||
|
|
||||||
// move to current
|
// move to current
|
||||||
const auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceID);
|
const auto PSPECIALWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceID);
|
||||||
const auto POLDMON = g_pCompositor->getMonitorFromID(PSPECIALWORKSPACE->m_iMonitorID);
|
const auto POLDMON = g_pCompositor->getMonitorFromID(PSPECIALWORKSPACE->m_iMonitorID);
|
||||||
|
|
||||||
POLDMON->specialWorkspaceID = 0;
|
POLDMON->specialWorkspaceID = 0;
|
||||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID);
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID);
|
||||||
|
@ -1451,8 +1453,8 @@ void CKeybindManager::resizeActive(std::string args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::moveActive(std::string args) {
|
void CKeybindManager::moveActive(std::string args) {
|
||||||
if (!g_pCompositor->m_pLastWindow || g_pCompositor->m_pLastWindow->m_bIsFullscreen)
|
if (!g_pCompositor->m_pLastWindow || g_pCompositor->m_pLastWindow->m_bIsFullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto POS = g_pCompositor->parseWindowVectorArgsRelative(args, g_pCompositor->m_pLastWindow->m_vRealPosition.goalv());
|
const auto POS = g_pCompositor->parseWindowVectorArgsRelative(args, g_pCompositor->m_pLastWindow->m_vRealPosition.goalv());
|
||||||
|
|
||||||
|
@ -1462,7 +1464,7 @@ void CKeybindManager::moveActive(std::string args) {
|
||||||
void CKeybindManager::moveWindow(std::string args) {
|
void CKeybindManager::moveWindow(std::string args) {
|
||||||
|
|
||||||
const auto WINDOWREGEX = args.substr(args.find_first_of(',') + 1);
|
const auto WINDOWREGEX = args.substr(args.find_first_of(',') + 1);
|
||||||
const auto MOVECMD = args.substr(0, args.find_first_of(','));
|
const auto MOVECMD = args.substr(0, args.find_first_of(','));
|
||||||
|
|
||||||
const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX);
|
const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX);
|
||||||
|
|
||||||
|
@ -1482,7 +1484,7 @@ void CKeybindManager::moveWindow(std::string args) {
|
||||||
void CKeybindManager::resizeWindow(std::string args) {
|
void CKeybindManager::resizeWindow(std::string args) {
|
||||||
|
|
||||||
const auto WINDOWREGEX = args.substr(args.find_first_of(',') + 1);
|
const auto WINDOWREGEX = args.substr(args.find_first_of(',') + 1);
|
||||||
const auto MOVECMD = args.substr(0, args.find_first_of(','));
|
const auto MOVECMD = args.substr(0, args.find_first_of(','));
|
||||||
|
|
||||||
const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX);
|
const auto PWINDOW = g_pCompositor->getWindowByRegex(WINDOWREGEX);
|
||||||
|
|
||||||
|
@ -1491,10 +1493,10 @@ void CKeybindManager::resizeWindow(std::string args) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PWINDOW->m_bIsFullscreen)
|
if (PWINDOW->m_bIsFullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto SIZ = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->m_vRealSize.goalv());
|
const auto SIZ = g_pCompositor->parseWindowVectorArgsRelative(MOVECMD, PWINDOW->m_vRealSize.goalv());
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(SIZ - PWINDOW->m_vRealSize.goalv(), PWINDOW);
|
g_pLayoutManager->getCurrentLayout()->resizeActiveWindow(SIZ - PWINDOW->m_vRealSize.goalv(), PWINDOW);
|
||||||
|
|
||||||
|
@ -1509,7 +1511,7 @@ void CKeybindManager::circleNext(std::string arg) {
|
||||||
|
|
||||||
if (g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_iWorkspaceID == PWINDOWTOCHANGETO->m_iWorkspaceID && g_pCompositor->m_pLastWindow->m_bIsFullscreen) {
|
if (g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_iWorkspaceID == PWINDOWTOCHANGETO->m_iWorkspaceID && g_pCompositor->m_pLastWindow->m_bIsFullscreen) {
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastWindow->m_iWorkspaceID);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastWindow->m_iWorkspaceID);
|
||||||
const auto FSMODE = PWORKSPACE->m_efFullscreenMode;
|
const auto FSMODE = PWORKSPACE->m_efFullscreenMode;
|
||||||
|
|
||||||
if (!PWINDOWTOCHANGETO->m_bPinned)
|
if (!PWINDOWTOCHANGETO->m_bPinned)
|
||||||
g_pCompositor->setWindowFullscreen(g_pCompositor->m_pLastWindow, false, FULLSCREEN_FULL);
|
g_pCompositor->setWindowFullscreen(g_pCompositor->m_pLastWindow, false, FULLSCREEN_FULL);
|
||||||
|
@ -1591,13 +1593,13 @@ void CKeybindManager::pass(std::string regexp) {
|
||||||
|
|
||||||
const auto KEYBOARD = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
|
const auto KEYBOARD = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
|
||||||
|
|
||||||
if (!KEYBOARD){
|
if (!KEYBOARD) {
|
||||||
Debug::log(ERR, "No kb in pass?");
|
Debug::log(ERR, "No kb in pass?");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto XWTOXW = PWINDOW->m_bIsX11 && g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_bIsX11;
|
const auto XWTOXW = PWINDOW->m_bIsX11 && g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow->m_bIsX11;
|
||||||
const auto SL = Vector2D(g_pCompositor->m_sSeat.seat->pointer_state.sx, g_pCompositor->m_sSeat.seat->pointer_state.sy);
|
const auto SL = Vector2D(g_pCompositor->m_sSeat.seat->pointer_state.sx, g_pCompositor->m_sSeat.seat->pointer_state.sy);
|
||||||
|
|
||||||
// pass all mf shit
|
// pass all mf shit
|
||||||
if (!XWTOXW) {
|
if (!XWTOXW) {
|
||||||
|
@ -1607,7 +1609,6 @@ void CKeybindManager::pass(std::string regexp) {
|
||||||
wlr_seat_pointer_enter(g_pCompositor->m_sSeat.seat, g_pXWaylandManager->getWindowSurface(PWINDOW), 1, 1);
|
wlr_seat_pointer_enter(g_pCompositor->m_sSeat.seat, g_pXWaylandManager->getWindowSurface(PWINDOW), 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wlr_keyboard_modifiers kbmods = {g_pInputManager->accumulateModsFromAllKBs(), 0, 0, 0};
|
wlr_keyboard_modifiers kbmods = {g_pInputManager->accumulateModsFromAllKBs(), 0, 0, 0};
|
||||||
wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &kbmods);
|
wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &kbmods);
|
||||||
|
|
||||||
|
@ -1640,10 +1641,10 @@ void CKeybindManager::pass(std::string regexp) {
|
||||||
// please kill me
|
// please kill me
|
||||||
if (PWINDOW->m_bIsX11) {
|
if (PWINDOW->m_bIsX11) {
|
||||||
if (g_pKeybindManager->m_uLastCode != 0) {
|
if (g_pKeybindManager->m_uLastCode != 0) {
|
||||||
g_pCompositor->m_sSeat.seat->keyboard_state.focused_client = nullptr;
|
g_pCompositor->m_sSeat.seat->keyboard_state.focused_client = nullptr;
|
||||||
g_pCompositor->m_sSeat.seat->keyboard_state.focused_surface = nullptr;
|
g_pCompositor->m_sSeat.seat->keyboard_state.focused_surface = nullptr;
|
||||||
} else {
|
} else {
|
||||||
g_pCompositor->m_sSeat.seat->pointer_state.focused_client = nullptr;
|
g_pCompositor->m_sSeat.seat->pointer_state.focused_client = nullptr;
|
||||||
g_pCompositor->m_sSeat.seat->pointer_state.focused_surface = nullptr;
|
g_pCompositor->m_sSeat.seat->pointer_state.focused_surface = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1665,15 +1666,15 @@ void CKeybindManager::toggleOpaque(std::string unused) {
|
||||||
if (!PWINDOW)
|
if (!PWINDOW)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PWINDOW->m_sAdditionalConfigData.forceOpaque = !PWINDOW->m_sAdditionalConfigData.forceOpaque;
|
PWINDOW->m_sAdditionalConfigData.forceOpaque = !PWINDOW->m_sAdditionalConfigData.forceOpaque;
|
||||||
PWINDOW->m_sAdditionalConfigData.forceOpaqueOverriden = true;
|
PWINDOW->m_sAdditionalConfigData.forceOpaqueOverriden = true;
|
||||||
|
|
||||||
g_pHyprRenderer->damageWindow(PWINDOW);
|
g_pHyprRenderer->damageWindow(PWINDOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CKeybindManager::dpms(std::string arg) {
|
void CKeybindManager::dpms(std::string arg) {
|
||||||
bool enable = arg.find("on") == 0;
|
bool enable = arg.find("on") == 0;
|
||||||
std::string port = "";
|
std::string port = "";
|
||||||
|
|
||||||
if (arg.find_first_of(' ') != std::string::npos) {
|
if (arg.find_first_of(' ') != std::string::npos) {
|
||||||
port = arg.substr(arg.find_first_of(' ') + 1);
|
port = arg.substr(arg.find_first_of(' ') + 1);
|
||||||
|
@ -1708,7 +1709,10 @@ void CKeybindManager::swapnext(std::string arg) {
|
||||||
|
|
||||||
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow;
|
const auto PLASTWINDOW = g_pCompositor->m_pLastWindow;
|
||||||
|
|
||||||
const auto PLASTCYCLED = g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow->m_pLastCycledWindow) && g_pCompositor->m_pLastWindow->m_pLastCycledWindow->m_iWorkspaceID == PLASTWINDOW->m_iWorkspaceID ? g_pCompositor->m_pLastWindow->m_pLastCycledWindow : nullptr;
|
const auto PLASTCYCLED = g_pCompositor->windowValidMapped(g_pCompositor->m_pLastWindow->m_pLastCycledWindow) &&
|
||||||
|
g_pCompositor->m_pLastWindow->m_pLastCycledWindow->m_iWorkspaceID == PLASTWINDOW->m_iWorkspaceID ?
|
||||||
|
g_pCompositor->m_pLastWindow->m_pLastCycledWindow :
|
||||||
|
nullptr;
|
||||||
|
|
||||||
if (arg == "last" || arg == "l" || arg == "prev" || arg == "p")
|
if (arg == "last" || arg == "l" || arg == "prev" || arg == "p")
|
||||||
toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW, true);
|
toSwap = g_pCompositor->getPrevWindowOnWorkspace(PLASTCYCLED ? PLASTCYCLED : PLASTWINDOW, true);
|
||||||
|
@ -1747,7 +1751,7 @@ void CKeybindManager::pinActive(std::string args) {
|
||||||
if (!g_pCompositor->m_pLastWindow || !g_pCompositor->m_pLastWindow->m_bIsFloating || g_pCompositor->m_pLastWindow->m_bIsFullscreen)
|
if (!g_pCompositor->m_pLastWindow || !g_pCompositor->m_pLastWindow->m_bIsFloating || g_pCompositor->m_pLastWindow->m_bIsFullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
g_pCompositor->m_pLastWindow->m_bPinned = !g_pCompositor->m_pLastWindow->m_bPinned;
|
g_pCompositor->m_pLastWindow->m_bPinned = !g_pCompositor->m_pLastWindow->m_bPinned;
|
||||||
g_pCompositor->m_pLastWindow->m_iWorkspaceID = g_pCompositor->getMonitorFromID(g_pCompositor->m_pLastWindow->m_iMonitorID)->activeWorkspace;
|
g_pCompositor->m_pLastWindow->m_iWorkspaceID = g_pCompositor->getMonitorFromID(g_pCompositor->m_pLastWindow->m_iMonitorID)->activeWorkspace;
|
||||||
|
|
||||||
g_pCompositor->m_pLastWindow->updateDynamicRules();
|
g_pCompositor->m_pLastWindow->updateDynamicRules();
|
||||||
|
@ -1767,7 +1771,7 @@ void CKeybindManager::mouse(std::string args) {
|
||||||
g_pKeybindManager->m_bIsMouseBindActive = true;
|
g_pKeybindManager->m_bIsMouseBindActive = true;
|
||||||
|
|
||||||
g_pInputManager->currentlyDraggedWindow = g_pCompositor->vectorToWindowIdeal(g_pInputManager->getMouseCoordsInternal());
|
g_pInputManager->currentlyDraggedWindow = g_pCompositor->vectorToWindowIdeal(g_pInputManager->getMouseCoordsInternal());
|
||||||
g_pInputManager->dragMode = MBIND_MOVE;
|
g_pInputManager->dragMode = MBIND_MOVE;
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
|
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1776,7 +1780,7 @@ void CKeybindManager::mouse(std::string args) {
|
||||||
if (g_pInputManager->currentlyDraggedWindow) {
|
if (g_pInputManager->currentlyDraggedWindow) {
|
||||||
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
||||||
g_pInputManager->currentlyDraggedWindow = nullptr;
|
g_pInputManager->currentlyDraggedWindow = nullptr;
|
||||||
g_pInputManager->dragMode = MBIND_INVALID;
|
g_pInputManager->dragMode = MBIND_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (TRUEARG == "resizewindow") {
|
} else if (TRUEARG == "resizewindow") {
|
||||||
|
@ -1784,7 +1788,7 @@ void CKeybindManager::mouse(std::string args) {
|
||||||
g_pKeybindManager->m_bIsMouseBindActive = true;
|
g_pKeybindManager->m_bIsMouseBindActive = true;
|
||||||
|
|
||||||
g_pInputManager->currentlyDraggedWindow = g_pCompositor->vectorToWindowIdeal(g_pInputManager->getMouseCoordsInternal());
|
g_pInputManager->currentlyDraggedWindow = g_pCompositor->vectorToWindowIdeal(g_pInputManager->getMouseCoordsInternal());
|
||||||
g_pInputManager->dragMode = MBIND_RESIZE;
|
g_pInputManager->dragMode = MBIND_RESIZE;
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
|
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1793,7 +1797,7 @@ void CKeybindManager::mouse(std::string args) {
|
||||||
if (g_pInputManager->currentlyDraggedWindow) {
|
if (g_pInputManager->currentlyDraggedWindow) {
|
||||||
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
||||||
g_pInputManager->currentlyDraggedWindow = nullptr;
|
g_pInputManager->currentlyDraggedWindow = nullptr;
|
||||||
g_pInputManager->dragMode = MBIND_INVALID;
|
g_pInputManager->dragMode = MBIND_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,22 +10,23 @@ class CInputManager;
|
||||||
class CConfigManager;
|
class CConfigManager;
|
||||||
|
|
||||||
struct SKeybind {
|
struct SKeybind {
|
||||||
std::string key = "";
|
std::string key = "";
|
||||||
int keycode = -1;
|
int keycode = -1;
|
||||||
uint32_t modmask = 0;
|
uint32_t modmask = 0;
|
||||||
std::string handler = "";
|
std::string handler = "";
|
||||||
std::string arg = "";
|
std::string arg = "";
|
||||||
bool locked = false;
|
bool locked = false;
|
||||||
std::string submap = "";
|
std::string submap = "";
|
||||||
bool release = false;
|
bool release = false;
|
||||||
bool repeat = false;
|
bool repeat = false;
|
||||||
bool mouse = false;
|
bool mouse = false;
|
||||||
|
|
||||||
// DO NOT INITIALIZE
|
// DO NOT INITIALIZE
|
||||||
bool shadowed = false;
|
bool shadowed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eFocusWindowMode {
|
enum eFocusWindowMode
|
||||||
|
{
|
||||||
MODE_CLASS_REGEX = 0,
|
MODE_CLASS_REGEX = 0,
|
||||||
MODE_TITLE_REGEX,
|
MODE_TITLE_REGEX,
|
||||||
MODE_ADDRESS,
|
MODE_ADDRESS,
|
||||||
|
@ -33,96 +34,96 @@ enum eFocusWindowMode {
|
||||||
};
|
};
|
||||||
|
|
||||||
class CKeybindManager {
|
class CKeybindManager {
|
||||||
public:
|
public:
|
||||||
CKeybindManager();
|
CKeybindManager();
|
||||||
|
|
||||||
bool onKeyEvent(wlr_keyboard_key_event*, SKeyboard*);
|
bool onKeyEvent(wlr_keyboard_key_event*, SKeyboard*);
|
||||||
bool onAxisEvent(wlr_pointer_axis_event*);
|
bool onAxisEvent(wlr_pointer_axis_event*);
|
||||||
bool onMouseEvent(wlr_pointer_button_event*);
|
bool onMouseEvent(wlr_pointer_button_event*);
|
||||||
void onSwitchEvent(const std::string&);
|
void onSwitchEvent(const std::string&);
|
||||||
|
|
||||||
void addKeybind(SKeybind);
|
void addKeybind(SKeybind);
|
||||||
void removeKeybind(uint32_t, const std::string&);
|
void removeKeybind(uint32_t, const std::string&);
|
||||||
uint32_t stringToModMask(std::string);
|
uint32_t stringToModMask(std::string);
|
||||||
void clearKeybinds();
|
void clearKeybinds();
|
||||||
void shadowKeybinds(const xkb_keysym_t& doesntHave = 0, const int& doesntHaveCode = 0);
|
void shadowKeybinds(const xkb_keysym_t& doesntHave = 0, const int& doesntHaveCode = 0);
|
||||||
|
|
||||||
std::unordered_map<std::string, std::function<void(std::string)>> m_mDispatchers;
|
std::unordered_map<std::string, std::function<void(std::string)>> m_mDispatchers;
|
||||||
|
|
||||||
wl_event_source* m_pActiveKeybindEventSource = nullptr;
|
wl_event_source* m_pActiveKeybindEventSource = nullptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::list<SKeybind> m_lKeybinds;
|
std::list<SKeybind> m_lKeybinds;
|
||||||
std::deque<xkb_keysym_t> m_dPressedKeysyms;
|
std::deque<xkb_keysym_t> m_dPressedKeysyms;
|
||||||
std::deque<int> m_dPressedKeycodes;
|
std::deque<int> m_dPressedKeycodes;
|
||||||
|
|
||||||
inline static std::string m_szCurrentSelectedSubmap = "";
|
inline static std::string m_szCurrentSelectedSubmap = "";
|
||||||
|
|
||||||
xkb_keysym_t m_kHeldBack = 0;
|
xkb_keysym_t m_kHeldBack = 0;
|
||||||
|
|
||||||
SKeybind* m_pActiveKeybind = nullptr;
|
SKeybind* m_pActiveKeybind = nullptr;
|
||||||
|
|
||||||
uint32_t m_uTimeLastMs = 0;
|
uint32_t m_uTimeLastMs = 0;
|
||||||
uint32_t m_uLastCode = 0;
|
uint32_t m_uLastCode = 0;
|
||||||
uint32_t m_uLastMouseCode = 0;
|
uint32_t m_uLastMouseCode = 0;
|
||||||
|
|
||||||
bool m_bIsMouseBindActive = false;
|
bool m_bIsMouseBindActive = false;
|
||||||
|
|
||||||
int m_iPassPressed = -1; // used for pass
|
int m_iPassPressed = -1; // used for pass
|
||||||
|
|
||||||
CTimer m_tScrollTimer;
|
CTimer m_tScrollTimer;
|
||||||
|
|
||||||
bool handleKeybinds(const uint32_t&, const std::string&, const xkb_keysym_t&, const int&, bool, uint32_t);
|
bool handleKeybinds(const uint32_t&, const std::string&, const xkb_keysym_t&, const int&, bool, uint32_t);
|
||||||
|
|
||||||
bool handleInternalKeybinds(xkb_keysym_t);
|
bool handleInternalKeybinds(xkb_keysym_t);
|
||||||
bool handleVT(xkb_keysym_t);
|
bool handleVT(xkb_keysym_t);
|
||||||
|
|
||||||
xkb_state* m_pXKBTranslationState = nullptr;
|
xkb_state* m_pXKBTranslationState = nullptr;
|
||||||
|
|
||||||
void updateXKBTranslationState();
|
void updateXKBTranslationState();
|
||||||
bool ensureMouseBindState();
|
bool ensureMouseBindState();
|
||||||
|
|
||||||
// -------------- Dispatchers -------------- //
|
// -------------- Dispatchers -------------- //
|
||||||
static void killActive(std::string);
|
static void killActive(std::string);
|
||||||
static void kill(std::string);
|
static void kill(std::string);
|
||||||
static void spawn(std::string);
|
static void spawn(std::string);
|
||||||
static void toggleActiveFloating(std::string);
|
static void toggleActiveFloating(std::string);
|
||||||
static void toggleActivePseudo(std::string);
|
static void toggleActivePseudo(std::string);
|
||||||
static void changeworkspace(std::string);
|
static void changeworkspace(std::string);
|
||||||
static void fullscreenActive(std::string);
|
static void fullscreenActive(std::string);
|
||||||
static void moveActiveToWorkspace(std::string);
|
static void moveActiveToWorkspace(std::string);
|
||||||
static void moveActiveToWorkspaceSilent(std::string);
|
static void moveActiveToWorkspaceSilent(std::string);
|
||||||
static void moveFocusTo(std::string);
|
static void moveFocusTo(std::string);
|
||||||
static void centerWindow(std::string);
|
static void centerWindow(std::string);
|
||||||
static void moveActiveTo(std::string);
|
static void moveActiveTo(std::string);
|
||||||
static void toggleGroup(std::string);
|
static void toggleGroup(std::string);
|
||||||
static void changeGroupActive(std::string);
|
static void changeGroupActive(std::string);
|
||||||
static void alterSplitRatio(std::string);
|
static void alterSplitRatio(std::string);
|
||||||
static void focusMonitor(std::string);
|
static void focusMonitor(std::string);
|
||||||
static void toggleSplit(std::string);
|
static void toggleSplit(std::string);
|
||||||
static void moveCursorToCorner(std::string);
|
static void moveCursorToCorner(std::string);
|
||||||
static void workspaceOpt(std::string);
|
static void workspaceOpt(std::string);
|
||||||
static void exitHyprland(std::string);
|
static void exitHyprland(std::string);
|
||||||
static void moveCurrentWorkspaceToMonitor(std::string);
|
static void moveCurrentWorkspaceToMonitor(std::string);
|
||||||
static void moveWorkspaceToMonitor(std::string);
|
static void moveWorkspaceToMonitor(std::string);
|
||||||
static void toggleSpecialWorkspace(std::string);
|
static void toggleSpecialWorkspace(std::string);
|
||||||
static void forceRendererReload(std::string);
|
static void forceRendererReload(std::string);
|
||||||
static void resizeActive(std::string);
|
static void resizeActive(std::string);
|
||||||
static void moveActive(std::string);
|
static void moveActive(std::string);
|
||||||
static void moveWindow(std::string);
|
static void moveWindow(std::string);
|
||||||
static void resizeWindow(std::string);
|
static void resizeWindow(std::string);
|
||||||
static void circleNext(std::string);
|
static void circleNext(std::string);
|
||||||
static void focusWindow(std::string);
|
static void focusWindow(std::string);
|
||||||
static void setSubmap(std::string);
|
static void setSubmap(std::string);
|
||||||
static void pass(std::string);
|
static void pass(std::string);
|
||||||
static void layoutmsg(std::string);
|
static void layoutmsg(std::string);
|
||||||
static void toggleOpaque(std::string);
|
static void toggleOpaque(std::string);
|
||||||
static void dpms(std::string);
|
static void dpms(std::string);
|
||||||
static void swapnext(std::string);
|
static void swapnext(std::string);
|
||||||
static void swapActiveWorkspaces(std::string);
|
static void swapActiveWorkspaces(std::string);
|
||||||
static void pinActive(std::string);
|
static void pinActive(std::string);
|
||||||
static void mouse(std::string);
|
static void mouse(std::string);
|
||||||
static void bringActiveToTop(std::string);
|
static void bringActiveToTop(std::string);
|
||||||
|
|
||||||
friend class CCompositor;
|
friend class CCompositor;
|
||||||
friend class CInputManager;
|
friend class CInputManager;
|
||||||
|
|
|
@ -2,10 +2,8 @@
|
||||||
|
|
||||||
IHyprLayout* CLayoutManager::getCurrentLayout() {
|
IHyprLayout* CLayoutManager::getCurrentLayout() {
|
||||||
switch (m_iCurrentLayoutID) {
|
switch (m_iCurrentLayoutID) {
|
||||||
case DWINDLE:
|
case DWINDLE: return &m_cDwindleLayout;
|
||||||
return &m_cDwindleLayout;
|
case MASTER: return &m_cMasterLayout;
|
||||||
case MASTER:
|
|
||||||
return &m_cMasterLayout;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// fallback
|
// fallback
|
||||||
|
|
|
@ -4,19 +4,19 @@
|
||||||
#include "../layout/MasterLayout.hpp"
|
#include "../layout/MasterLayout.hpp"
|
||||||
|
|
||||||
class CLayoutManager {
|
class CLayoutManager {
|
||||||
public:
|
public:
|
||||||
|
IHyprLayout* getCurrentLayout();
|
||||||
|
|
||||||
IHyprLayout* getCurrentLayout();
|
void switchToLayout(std::string);
|
||||||
|
|
||||||
void switchToLayout(std::string);
|
private:
|
||||||
|
enum HYPRLAYOUTS
|
||||||
private:
|
{
|
||||||
enum HYPRLAYOUTS {
|
|
||||||
DWINDLE = 0,
|
DWINDLE = 0,
|
||||||
MASTER
|
MASTER
|
||||||
};
|
};
|
||||||
|
|
||||||
HYPRLAYOUTS m_iCurrentLayoutID = DWINDLE;
|
HYPRLAYOUTS m_iCurrentLayoutID = DWINDLE;
|
||||||
|
|
||||||
CHyprDwindleLayout m_cDwindleLayout;
|
CHyprDwindleLayout m_cDwindleLayout;
|
||||||
CHyprMasterLayout m_cMasterLayout;
|
CHyprMasterLayout m_cMasterLayout;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "../protocols/ToplevelExport.hpp"
|
#include "../protocols/ToplevelExport.hpp"
|
||||||
|
|
||||||
class CProtocolManager {
|
class CProtocolManager {
|
||||||
public:
|
public:
|
||||||
CProtocolManager();
|
CProtocolManager();
|
||||||
|
|
||||||
std::unique_ptr<CToplevelExportProtocolManager> m_pToplevelExportProtocolManager;
|
std::unique_ptr<CToplevelExportProtocolManager> m_pToplevelExportProtocolManager;
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
int slowUpdate = 0;
|
int slowUpdate = 0;
|
||||||
|
|
||||||
int handleTimer(void* data) {
|
int handleTimer(void* data) {
|
||||||
const auto PTM = (CThreadManager*)data;
|
const auto PTM = (CThreadManager*)data;
|
||||||
|
|
||||||
static auto *const PDISABLECFGRELOAD = &g_pConfigManager->getConfigValuePtr("misc:disable_autoreload")->intValue;
|
static auto* const PDISABLECFGRELOAD = &g_pConfigManager->getConfigValuePtr("misc:disable_autoreload")->intValue;
|
||||||
|
|
||||||
if (*PDISABLECFGRELOAD != 1)
|
if (*PDISABLECFGRELOAD != 1)
|
||||||
g_pConfigManager->tick();
|
g_pConfigManager->tick();
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
#include "../Compositor.hpp"
|
#include "../Compositor.hpp"
|
||||||
|
|
||||||
class CThreadManager {
|
class CThreadManager {
|
||||||
public:
|
public:
|
||||||
CThreadManager();
|
CThreadManager();
|
||||||
~CThreadManager();
|
~CThreadManager();
|
||||||
|
|
||||||
wl_event_source* m_esConfigTimer;
|
wl_event_source* m_esConfigTimer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CThreadManager> g_pThreadManager;
|
inline std::unique_ptr<CThreadManager> g_pThreadManager;
|
|
@ -18,13 +18,11 @@ CHyprXWaylandManager::CHyprXWaylandManager() {
|
||||||
|
|
||||||
Debug::log(LOG, "CHyprXWaylandManager started on display %s", m_sWLRXWayland->display_name);
|
Debug::log(LOG, "CHyprXWaylandManager started on display %s", m_sWLRXWayland->display_name);
|
||||||
#else
|
#else
|
||||||
unsetenv("DISPLAY"); // unset DISPLAY so that X11 apps do not try to start on a different/invalid DISPLAY
|
unsetenv("DISPLAY"); // unset DISPLAY so that X11 apps do not try to start on a different/invalid DISPLAY
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
CHyprXWaylandManager::~CHyprXWaylandManager() {
|
CHyprXWaylandManager::~CHyprXWaylandManager() {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_surface* CHyprXWaylandManager::getWindowSurface(CWindow* pWindow) {
|
wlr_surface* CHyprXWaylandManager::getWindowSurface(CWindow* pWindow) {
|
||||||
if (pWindow->m_bIsX11)
|
if (pWindow->m_bIsX11)
|
||||||
|
@ -48,7 +46,6 @@ void CHyprXWaylandManager::activateSurface(wlr_surface* pSurface, bool activate)
|
||||||
if (activate)
|
if (activate)
|
||||||
wlr_xwayland_surface_restack(wlr_xwayland_surface_from_wlr_surface(pSurface), NULL, XCB_STACK_MODE_ABOVE);
|
wlr_xwayland_surface_restack(wlr_xwayland_surface_from_wlr_surface(pSurface), NULL, XCB_STACK_MODE_ABOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprXWaylandManager::activateWindow(CWindow* pWindow, bool activate) {
|
void CHyprXWaylandManager::activateWindow(CWindow* pWindow, bool activate) {
|
||||||
|
@ -58,14 +55,13 @@ void CHyprXWaylandManager::activateWindow(CWindow* pWindow, bool activate) {
|
||||||
wlr_xwayland_surface_set_minimized(pWindow->m_uSurface.xwayland, false);
|
wlr_xwayland_surface_set_minimized(pWindow->m_uSurface.xwayland, false);
|
||||||
wlr_xwayland_surface_restack(pWindow->m_uSurface.xwayland, NULL, XCB_STACK_MODE_ABOVE);
|
wlr_xwayland_surface_restack(pWindow->m_uSurface.xwayland, NULL, XCB_STACK_MODE_ABOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_xwayland_surface_activate(pWindow->m_uSurface.xwayland, activate);
|
wlr_xwayland_surface_activate(pWindow->m_uSurface.xwayland, activate);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
wlr_xdg_toplevel_set_activated(pWindow->m_uSurface.xdg->toplevel, activate);
|
wlr_xdg_toplevel_set_activated(pWindow->m_uSurface.xdg->toplevel, activate);
|
||||||
|
|
||||||
if (activate) {
|
if (activate) {
|
||||||
g_pCompositor->m_pLastFocus = getWindowSurface(pWindow);
|
g_pCompositor->m_pLastFocus = getWindowSurface(pWindow);
|
||||||
g_pCompositor->m_pLastWindow = pWindow;
|
g_pCompositor->m_pLastWindow = pWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,14 +74,14 @@ void CHyprXWaylandManager::getGeometryForWindow(CWindow* pWindow, wlr_box* pbox)
|
||||||
const auto SIZEHINTS = pWindow->m_uSurface.xwayland->size_hints;
|
const auto SIZEHINTS = pWindow->m_uSurface.xwayland->size_hints;
|
||||||
|
|
||||||
if (SIZEHINTS && pWindow->m_iX11Type != 2) {
|
if (SIZEHINTS && pWindow->m_iX11Type != 2) {
|
||||||
pbox->x = SIZEHINTS->x;
|
pbox->x = SIZEHINTS->x;
|
||||||
pbox->y = SIZEHINTS->y;
|
pbox->y = SIZEHINTS->y;
|
||||||
pbox->width = SIZEHINTS->width;
|
pbox->width = SIZEHINTS->width;
|
||||||
pbox->height = SIZEHINTS->height;
|
pbox->height = SIZEHINTS->height;
|
||||||
} else {
|
} else {
|
||||||
pbox->x = pWindow->m_uSurface.xwayland->x;
|
pbox->x = pWindow->m_uSurface.xwayland->x;
|
||||||
pbox->y = pWindow->m_uSurface.xwayland->y;
|
pbox->y = pWindow->m_uSurface.xwayland->y;
|
||||||
pbox->width = pWindow->m_uSurface.xwayland->width;
|
pbox->width = pWindow->m_uSurface.xwayland->width;
|
||||||
pbox->height = pWindow->m_uSurface.xwayland->height;
|
pbox->height = pWindow->m_uSurface.xwayland->height;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -106,9 +102,7 @@ std::string CHyprXWaylandManager::getTitle(CWindow* pWindow) {
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
} catch (...) {
|
} catch (...) { Debug::log(ERR, "Error in getTitle (probably null title)"); }
|
||||||
Debug::log(ERR, "Error in getTitle (probably null title)");
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -129,9 +123,7 @@ std::string CHyprXWaylandManager::getAppIDClass(CWindow* pWindow) {
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
} catch (std::logic_error& e) {
|
} catch (std::logic_error& e) { Debug::log(ERR, "Error in getAppIDClass: %s", e.what()); }
|
||||||
Debug::log(ERR, "Error in getAppIDClass: %s", e.what());
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -146,11 +138,12 @@ void CHyprXWaylandManager::sendCloseWindow(CWindow* pWindow) {
|
||||||
|
|
||||||
void CHyprXWaylandManager::setWindowSize(CWindow* pWindow, const Vector2D& size, bool force) {
|
void CHyprXWaylandManager::setWindowSize(CWindow* pWindow, const Vector2D& size, bool force) {
|
||||||
|
|
||||||
if (!force && ((pWindow->m_vReportedSize == size && pWindow->m_vRealPosition.vec() == pWindow->m_vReportedPosition) || (pWindow->m_vReportedSize == size && !pWindow->m_bIsX11)))
|
if (!force &&
|
||||||
|
((pWindow->m_vReportedSize == size && pWindow->m_vRealPosition.vec() == pWindow->m_vReportedPosition) || (pWindow->m_vReportedSize == size && !pWindow->m_bIsX11)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pWindow->m_vReportedPosition = pWindow->m_vRealPosition.vec();
|
pWindow->m_vReportedPosition = pWindow->m_vRealPosition.vec();
|
||||||
pWindow->m_vReportedSize = size;
|
pWindow->m_vReportedSize = size;
|
||||||
|
|
||||||
if (pWindow->m_bIsX11)
|
if (pWindow->m_bIsX11)
|
||||||
wlr_xwayland_surface_configure(pWindow->m_uSurface.xwayland, pWindow->m_vRealPosition.vec().x, pWindow->m_vRealPosition.vec().y, size.x, size.y);
|
wlr_xwayland_surface_configure(pWindow->m_uSurface.xwayland, pWindow->m_vRealPosition.vec().x, pWindow->m_vRealPosition.vec().y, size.x, size.y);
|
||||||
|
@ -173,18 +166,23 @@ wlr_surface* CHyprXWaylandManager::surfaceAt(CWindow* pWindow, const Vector2D& c
|
||||||
bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) {
|
bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) {
|
||||||
if (pWindow->m_bIsX11) {
|
if (pWindow->m_bIsX11) {
|
||||||
for (size_t i = 0; i < pWindow->m_uSurface.xwayland->window_type_len; i++)
|
for (size_t i = 0; i < pWindow->m_uSurface.xwayland->window_type_len; i++)
|
||||||
if (pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DIALOG"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_SPLASH"] ||
|
if (pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DIALOG"] ||
|
||||||
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLBAR"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_UTILITY"] ||
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_SPLASH"] ||
|
||||||
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLTIP"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_POPUP_MENU"] ||
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLBAR"] ||
|
||||||
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DOCK"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"] ||
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_UTILITY"] ||
|
||||||
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_MENU"])
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLTIP"] ||
|
||||||
{
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_POPUP_MENU"] ||
|
||||||
if (pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_MENU"])
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DOCK"] ||
|
||||||
pWindow->m_bX11ShouldntFocus = true;
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"] ||
|
||||||
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_MENU"]) {
|
||||||
|
|
||||||
|
if (pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"] ||
|
||||||
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_MENU"])
|
||||||
|
pWindow->m_bX11ShouldntFocus = true;
|
||||||
|
|
||||||
pWindow->m_bNoInitialFocus = true;
|
pWindow->m_bNoInitialFocus = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pWindow->m_uSurface.xwayland->role) {
|
if (pWindow->m_uSurface.xwayland->role) {
|
||||||
try {
|
try {
|
||||||
|
@ -192,9 +190,7 @@ bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) {
|
||||||
if (winrole.contains("pop-up") || winrole.contains("task_dialog")) {
|
if (winrole.contains("pop-up") || winrole.contains("task_dialog")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) { Debug::log(ERR, "Error in shouldBeFloated, winrole threw %s", e.what()); }
|
||||||
Debug::log(ERR, "Error in shouldBeFloated, winrole threw %s", e.what());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pWindow->m_uSurface.xwayland->modal) {
|
if (pWindow->m_uSurface.xwayland->modal) {
|
||||||
|
@ -212,7 +208,8 @@ bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) {
|
||||||
} else {
|
} else {
|
||||||
const auto PSTATE = &pWindow->m_uSurface.xdg->toplevel->current;
|
const auto PSTATE = &pWindow->m_uSurface.xdg->toplevel->current;
|
||||||
|
|
||||||
if ((PSTATE->min_width != 0 && PSTATE->min_height != 0 && (PSTATE->min_width == PSTATE->max_width || PSTATE->min_height == PSTATE->max_height)) || pWindow->m_uSurface.xdg->toplevel->parent)
|
if ((PSTATE->min_width != 0 && PSTATE->min_height != 0 && (PSTATE->min_width == PSTATE->max_width || PSTATE->min_height == PSTATE->max_height)) ||
|
||||||
|
pWindow->m_uSurface.xdg->toplevel->parent)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,9 +230,12 @@ void CHyprXWaylandManager::checkBorders(CWindow* pWindow) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (size_t i = 0; i < pWindow->m_uSurface.xwayland->window_type_len; i++) {
|
for (size_t i = 0; i < pWindow->m_uSurface.xwayland->window_type_len; i++) {
|
||||||
if (pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_POPUP_MENU"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_NOTIFICATION"] ||
|
if (pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_POPUP_MENU"] ||
|
||||||
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_COMBO"] ||
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_NOTIFICATION"] ||
|
||||||
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_MENU"] || pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_SPLASH"] ||
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"] ||
|
||||||
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_COMBO"] ||
|
||||||
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_MENU"] ||
|
||||||
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_SPLASH"] ||
|
||||||
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLTIP"]) {
|
pWindow->m_uSurface.xwayland->window_type[i] == HYPRATOMS["_NET_WM_WINDOW_TYPE_TOOLTIP"]) {
|
||||||
|
|
||||||
pWindow->m_bX11DoesntWantBorders = true;
|
pWindow->m_bX11DoesntWantBorders = true;
|
||||||
|
@ -263,11 +263,12 @@ Vector2D CHyprXWaylandManager::getMaxSizeForWindow(CWindow* pWindow) {
|
||||||
if (!g_pCompositor->windowValidMapped(pWindow))
|
if (!g_pCompositor->windowValidMapped(pWindow))
|
||||||
return Vector2D(99999, 99999);
|
return Vector2D(99999, 99999);
|
||||||
|
|
||||||
if ((pWindow->m_bIsX11 && !pWindow->m_uSurface.xwayland->size_hints) || (!pWindow->m_bIsX11 && !pWindow->m_uSurface.xdg->toplevel) || pWindow->m_sAdditionalConfigData.noMaxSize)
|
if ((pWindow->m_bIsX11 && !pWindow->m_uSurface.xwayland->size_hints) || (!pWindow->m_bIsX11 && !pWindow->m_uSurface.xdg->toplevel) ||
|
||||||
|
pWindow->m_sAdditionalConfigData.noMaxSize)
|
||||||
return Vector2D(99999, 99999);
|
return Vector2D(99999, 99999);
|
||||||
|
|
||||||
auto MAXSIZE = pWindow->m_bIsX11 ? Vector2D(pWindow->m_uSurface.xwayland->size_hints->max_width, pWindow->m_uSurface.xwayland->size_hints->max_height)
|
auto MAXSIZE = pWindow->m_bIsX11 ? Vector2D(pWindow->m_uSurface.xwayland->size_hints->max_width, pWindow->m_uSurface.xwayland->size_hints->max_height) :
|
||||||
: Vector2D(pWindow->m_uSurface.xdg->toplevel->current.max_width, pWindow->m_uSurface.xdg->toplevel->current.max_height);
|
Vector2D(pWindow->m_uSurface.xdg->toplevel->current.max_width, pWindow->m_uSurface.xdg->toplevel->current.max_height);
|
||||||
|
|
||||||
if (MAXSIZE.x < 5)
|
if (MAXSIZE.x < 5)
|
||||||
MAXSIZE.x = 99999;
|
MAXSIZE.x = 99999;
|
||||||
|
|
|
@ -4,27 +4,27 @@
|
||||||
#include "../Window.hpp"
|
#include "../Window.hpp"
|
||||||
|
|
||||||
class CHyprXWaylandManager {
|
class CHyprXWaylandManager {
|
||||||
public:
|
public:
|
||||||
CHyprXWaylandManager();
|
CHyprXWaylandManager();
|
||||||
~CHyprXWaylandManager();
|
~CHyprXWaylandManager();
|
||||||
|
|
||||||
wlr_xwayland* m_sWLRXWayland = nullptr;
|
wlr_xwayland* m_sWLRXWayland = nullptr;
|
||||||
|
|
||||||
wlr_surface* getWindowSurface(CWindow*);
|
wlr_surface* getWindowSurface(CWindow*);
|
||||||
void activateSurface(wlr_surface*, bool);
|
void activateSurface(wlr_surface*, bool);
|
||||||
void activateWindow(CWindow*, bool);
|
void activateWindow(CWindow*, bool);
|
||||||
void getGeometryForWindow(CWindow*, wlr_box*);
|
void getGeometryForWindow(CWindow*, wlr_box*);
|
||||||
std::string getTitle(CWindow*);
|
std::string getTitle(CWindow*);
|
||||||
std::string getAppIDClass(CWindow*);
|
std::string getAppIDClass(CWindow*);
|
||||||
void sendCloseWindow(CWindow*);
|
void sendCloseWindow(CWindow*);
|
||||||
void setWindowSize(CWindow*, const Vector2D&, bool force = false);
|
void setWindowSize(CWindow*, const Vector2D&, bool force = false);
|
||||||
void setWindowStyleTiled(CWindow*, uint32_t);
|
void setWindowStyleTiled(CWindow*, uint32_t);
|
||||||
void setWindowFullscreen(CWindow*, bool);
|
void setWindowFullscreen(CWindow*, bool);
|
||||||
wlr_surface* surfaceAt(CWindow*, const Vector2D&, Vector2D&);
|
wlr_surface* surfaceAt(CWindow*, const Vector2D&, Vector2D&);
|
||||||
bool shouldBeFloated(CWindow*);
|
bool shouldBeFloated(CWindow*);
|
||||||
void moveXWaylandWindow(CWindow*, const Vector2D&);
|
void moveXWaylandWindow(CWindow*, const Vector2D&);
|
||||||
void checkBorders(CWindow*);
|
void checkBorders(CWindow*);
|
||||||
Vector2D getMaxSizeForWindow(CWindow*);
|
Vector2D getMaxSizeForWindow(CWindow*);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline std::unique_ptr<CHyprXWaylandManager> g_pXWaylandManager;
|
inline std::unique_ptr<CHyprXWaylandManager> g_pXWaylandManager;
|
|
@ -17,17 +17,18 @@ void CInputManager::newIdleInhibitor(wlr_idle_inhibitor_v1* pInhibitor) {
|
||||||
|
|
||||||
PINHIBIT->pWlrInhibitor = pInhibitor;
|
PINHIBIT->pWlrInhibitor = pInhibitor;
|
||||||
|
|
||||||
PINHIBIT->hyprListener_Destroy.initCallback(&pInhibitor->events.destroy, [](void* owner, void* data){
|
PINHIBIT->hyprListener_Destroy.initCallback(
|
||||||
|
&pInhibitor->events.destroy,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto PINH = (SIdleInhibitor*)owner;
|
||||||
|
|
||||||
const auto PINH = (SIdleInhibitor*)owner;
|
g_pInputManager->m_lIdleInhibitors.remove(*PINH);
|
||||||
|
|
||||||
g_pInputManager->m_lIdleInhibitors.remove(*PINH);
|
Debug::log(LOG, "Destroyed an idleinhibitor");
|
||||||
|
|
||||||
Debug::log(LOG, "Destroyed an idleinhibitor");
|
g_pInputManager->recheckIdleInhibitorStatus();
|
||||||
|
},
|
||||||
g_pInputManager->recheckIdleInhibitorStatus();
|
PINHIBIT, "IdleInhibitor");
|
||||||
|
|
||||||
}, PINHIBIT, "IdleInhibitor");
|
|
||||||
|
|
||||||
PINHIBIT->pWindow = g_pCompositor->getWindowFromSurface(pInhibitor->surface);
|
PINHIBIT->pWindow = g_pCompositor->getWindowFromSurface(pInhibitor->surface);
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,18 @@
|
||||||
#include "../../Compositor.hpp"
|
#include "../../Compositor.hpp"
|
||||||
|
|
||||||
void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) {
|
void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) {
|
||||||
static auto *const PSENS = &g_pConfigManager->getConfigValuePtr("general:sensitivity")->floatValue;
|
static auto* const PSENS = &g_pConfigManager->getConfigValuePtr("general:sensitivity")->floatValue;
|
||||||
static auto *const PNOACCEL = &g_pConfigManager->getConfigValuePtr("input:force_no_accel")->intValue;
|
static auto* const PNOACCEL = &g_pConfigManager->getConfigValuePtr("input:force_no_accel")->intValue;
|
||||||
static auto* const PSENSTORAW = &g_pConfigManager->getConfigValuePtr("general:apply_sens_to_raw")->intValue;
|
static auto* const PSENSTORAW = &g_pConfigManager->getConfigValuePtr("general:apply_sens_to_raw")->intValue;
|
||||||
|
|
||||||
const auto DELTA = *PNOACCEL == 1 ? Vector2D(e->unaccel_dx, e->unaccel_dy) : Vector2D(e->delta_x, e->delta_y);
|
const auto DELTA = *PNOACCEL == 1 ? Vector2D(e->unaccel_dx, e->unaccel_dy) : Vector2D(e->delta_x, e->delta_y);
|
||||||
|
|
||||||
if (*PSENSTORAW == 1)
|
if (*PSENSTORAW == 1)
|
||||||
wlr_relative_pointer_manager_v1_send_relative_motion(g_pCompositor->m_sWLRRelPointerMgr, g_pCompositor->m_sSeat.seat, (uint64_t)e->time_msec * 1000, DELTA.x * *PSENS, DELTA.y * *PSENS, e->unaccel_dx * *PSENS, e->unaccel_dy * *PSENS);
|
wlr_relative_pointer_manager_v1_send_relative_motion(g_pCompositor->m_sWLRRelPointerMgr, g_pCompositor->m_sSeat.seat, (uint64_t)e->time_msec * 1000, DELTA.x * *PSENS,
|
||||||
|
DELTA.y * *PSENS, e->unaccel_dx * *PSENS, e->unaccel_dy * *PSENS);
|
||||||
else
|
else
|
||||||
wlr_relative_pointer_manager_v1_send_relative_motion(g_pCompositor->m_sWLRRelPointerMgr, g_pCompositor->m_sSeat.seat, (uint64_t)e->time_msec * 1000, DELTA.x, DELTA.y, e->unaccel_dx, e->unaccel_dy);
|
wlr_relative_pointer_manager_v1_send_relative_motion(g_pCompositor->m_sWLRRelPointerMgr, g_pCompositor->m_sSeat.seat, (uint64_t)e->time_msec * 1000, DELTA.x, DELTA.y,
|
||||||
|
e->unaccel_dx, e->unaccel_dy);
|
||||||
|
|
||||||
wlr_cursor_move(g_pCompositor->m_sWLRCursor, &e->pointer->base, DELTA.x * *PSENS, DELTA.y * *PSENS);
|
wlr_cursor_move(g_pCompositor->m_sWLRCursor, &e->pointer->base, DELTA.x * *PSENS, DELTA.y * *PSENS);
|
||||||
|
|
||||||
|
@ -29,19 +31,19 @@ void CInputManager::onMouseWarp(wlr_pointer_motion_absolute_event* e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
||||||
static auto *const PMOUSEDPMS = &g_pConfigManager->getConfigValuePtr("misc:mouse_move_enables_dpms")->intValue;
|
static auto* const PMOUSEDPMS = &g_pConfigManager->getConfigValuePtr("misc:mouse_move_enables_dpms")->intValue;
|
||||||
static auto *const PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue;
|
static auto* const PFOLLOWONDND = &g_pConfigManager->getConfigValuePtr("misc:always_follow_on_dnd")->intValue;
|
||||||
static auto *const PHOGFOCUS = &g_pConfigManager->getConfigValuePtr("misc:layers_hog_keyboard_focus")->intValue;
|
static auto* const PHOGFOCUS = &g_pConfigManager->getConfigValuePtr("misc:layers_hog_keyboard_focus")->intValue;
|
||||||
static auto *const PFLOATBEHAVIOR = &g_pConfigManager->getConfigValuePtr("input:float_switch_override_focus")->intValue;
|
static auto* const PFLOATBEHAVIOR = &g_pConfigManager->getConfigValuePtr("input:float_switch_override_focus")->intValue;
|
||||||
|
|
||||||
m_pFoundSurfaceToFocus = nullptr;
|
m_pFoundSurfaceToFocus = nullptr;
|
||||||
m_pFoundLSToFocus = nullptr;
|
m_pFoundLSToFocus = nullptr;
|
||||||
m_pFoundWindowToFocus = nullptr;
|
m_pFoundWindowToFocus = nullptr;
|
||||||
wlr_surface* foundSurface = nullptr;
|
wlr_surface* foundSurface = nullptr;
|
||||||
Vector2D surfaceCoords;
|
Vector2D surfaceCoords;
|
||||||
Vector2D surfacePos = Vector2D(-1337, -1337);
|
Vector2D surfacePos = Vector2D(-1337, -1337);
|
||||||
CWindow* pFoundWindow = nullptr;
|
CWindow* pFoundWindow = nullptr;
|
||||||
SLayerSurface* pFoundLayerSurface = nullptr;
|
SLayerSurface* pFoundLayerSurface = nullptr;
|
||||||
|
|
||||||
if (!g_pCompositor->m_bReadyToProcess || g_pCompositor->m_bIsShuttingDown)
|
if (!g_pCompositor->m_bReadyToProcess || g_pCompositor->m_bIsShuttingDown)
|
||||||
|
@ -57,7 +59,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
g_pKeybindManager->dpms("on");
|
g_pKeybindManager->dpms("on");
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2D mouseCoords = getMouseCoordsInternal();
|
Vector2D mouseCoords = getMouseCoordsInternal();
|
||||||
const auto MOUSECOORDSFLOORED = mouseCoords.floor();
|
const auto MOUSECOORDSFLOORED = mouseCoords.floor();
|
||||||
|
|
||||||
if (MOUSECOORDSFLOORED == m_vLastCursorPosFloored && !refocus)
|
if (MOUSECOORDSFLOORED == m_vLastCursorPosFloored && !refocus)
|
||||||
|
@ -73,20 +75,22 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
// XWayland windows sometimes issue constraints weirdly.
|
// XWayland windows sometimes issue constraints weirdly.
|
||||||
// TODO: We probably should search their parent. wlr_xwayland_surface->parent
|
// TODO: We probably should search their parent. wlr_xwayland_surface->parent
|
||||||
const auto CONSTRAINTWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
|
const auto CONSTRAINTWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
|
||||||
const auto PCONSTRAINT = constraintFromWlr(g_pCompositor->m_sSeat.mouse->currentConstraint);
|
const auto PCONSTRAINT = constraintFromWlr(g_pCompositor->m_sSeat.mouse->currentConstraint);
|
||||||
|
|
||||||
if (!CONSTRAINTWINDOW || !PCONSTRAINT) {
|
if (!CONSTRAINTWINDOW || !PCONSTRAINT) {
|
||||||
unconstrainMouse();
|
unconstrainMouse();
|
||||||
} else {
|
} else {
|
||||||
// Native Wayland apps know how 2 constrain themselves.
|
// Native Wayland apps know how 2 constrain themselves.
|
||||||
// XWayland, we just have to accept them. Might cause issues, but thats XWayland for ya.
|
// XWayland, we just have to accept them. Might cause issues, but thats XWayland for ya.
|
||||||
const auto CONSTRAINTPOS = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->x, CONSTRAINTWINDOW->m_uSurface.xwayland->y) : CONSTRAINTWINDOW->m_vRealPosition.vec();
|
const auto CONSTRAINTPOS =
|
||||||
const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec();
|
CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->x, CONSTRAINTWINDOW->m_uSurface.xwayland->y) : CONSTRAINTWINDOW->m_vRealPosition.vec();
|
||||||
|
const auto CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) :
|
||||||
|
CONSTRAINTWINDOW->m_vRealSize.vec();
|
||||||
|
|
||||||
if (g_pCompositor->m_sSeat.mouse->currentConstraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED) {
|
if (g_pCompositor->m_sSeat.mouse->currentConstraint->type == WLR_POINTER_CONSTRAINT_V1_LOCKED) {
|
||||||
// we just snap the cursor to where it should be.
|
// we just snap the cursor to where it should be.
|
||||||
|
|
||||||
Vector2D hint = { PCONSTRAINT->positionHint.x, PCONSTRAINT->positionHint.y };
|
Vector2D hint = {PCONSTRAINT->positionHint.x, PCONSTRAINT->positionHint.y};
|
||||||
|
|
||||||
wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, CONSTRAINTPOS.x + hint.x, CONSTRAINTPOS.y + hint.y);
|
wlr_cursor_warp_closest(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, CONSTRAINTPOS.x + hint.x, CONSTRAINTPOS.y + hint.y);
|
||||||
|
|
||||||
|
@ -108,7 +112,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
|
|
||||||
if (CONSTRAINTWINDOW->m_bIsX11) {
|
if (CONSTRAINTWINDOW->m_bIsX11) {
|
||||||
foundSurface = g_pXWaylandManager->getWindowSurface(CONSTRAINTWINDOW);
|
foundSurface = g_pXWaylandManager->getWindowSurface(CONSTRAINTWINDOW);
|
||||||
surfacePos = CONSTRAINTWINDOW->m_vRealPosition.vec();
|
surfacePos = CONSTRAINTWINDOW->m_vRealPosition.vec();
|
||||||
} else {
|
} else {
|
||||||
g_pCompositor->vectorWindowToSurface(mouseCoords, CONSTRAINTWINDOW, surfaceCoords);
|
g_pCompositor->vectorWindowToSurface(mouseCoords, CONSTRAINTWINDOW, surfaceCoords);
|
||||||
}
|
}
|
||||||
|
@ -152,7 +156,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
// only check floating because tiled cant be over fullscreen
|
// only check floating because tiled cant be over fullscreen
|
||||||
for (auto w = g_pCompositor->m_vWindows.rbegin(); w != g_pCompositor->m_vWindows.rend(); w++) {
|
for (auto w = g_pCompositor->m_vWindows.rbegin(); w != g_pCompositor->m_vWindows.rend(); w++) {
|
||||||
wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
|
wlr_box box = {(*w)->m_vRealPosition.vec().x, (*w)->m_vRealPosition.vec().y, (*w)->m_vRealSize.vec().x, (*w)->m_vRealSize.vec().y};
|
||||||
if ((((*w)->m_bIsFloating && (*w)->m_bIsMapped && ((*w)->m_bCreatedOverFullscreen || (*w)->m_bPinned)) || (g_pCompositor->isWorkspaceSpecial((*w)->m_iWorkspaceID) && PMONITOR->specialWorkspaceID)) && wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->isHidden()) {
|
if ((((*w)->m_bIsFloating && (*w)->m_bIsMapped && ((*w)->m_bCreatedOverFullscreen || (*w)->m_bPinned)) ||
|
||||||
|
(g_pCompositor->isWorkspaceSpecial((*w)->m_iWorkspaceID) && PMONITOR->specialWorkspaceID)) &&
|
||||||
|
wlr_box_contains_point(&box, mouseCoords.x, mouseCoords.y) && g_pCompositor->isWorkspaceVisible((*w)->m_iWorkspaceID) && !(*w)->isHidden()) {
|
||||||
pFoundWindow = (*w).get();
|
pFoundWindow = (*w).get();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -160,10 +166,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
|
|
||||||
if (!pFoundWindow->m_bIsX11) {
|
if (!pFoundWindow->m_bIsX11) {
|
||||||
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
|
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
|
||||||
surfacePos = Vector2D(-1337, -1337);
|
surfacePos = Vector2D(-1337, -1337);
|
||||||
} else {
|
} else {
|
||||||
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
|
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
|
||||||
surfacePos = pFoundWindow->m_vRealPosition.vec();
|
surfacePos = pFoundWindow->m_vRealPosition.vec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,9 +193,9 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords);
|
pFoundWindow = g_pCompositor->vectorToWindowIdeal(mouseCoords);
|
||||||
|
|
||||||
// TODO: this causes crashes, sometimes. ???
|
// TODO: this causes crashes, sometimes. ???
|
||||||
// if (refocus && !pFoundWindow) {
|
// if (refocus && !pFoundWindow) {
|
||||||
// pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace);
|
// pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pFoundWindow) {
|
if (pFoundWindow) {
|
||||||
|
@ -197,7 +203,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
|
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
|
||||||
} else {
|
} else {
|
||||||
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
|
foundSurface = g_pXWaylandManager->getWindowSurface(pFoundWindow);
|
||||||
surfacePos = pFoundWindow->m_vRealPosition.vec();
|
surfacePos = pFoundWindow->m_vRealPosition.vec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,7 +224,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor);
|
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor);
|
||||||
else
|
else
|
||||||
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor);
|
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor);
|
||||||
|
|
||||||
m_bEmptyFocusCursorSet = true;
|
m_bEmptyFocusCursorSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,14 +264,15 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
|
|
||||||
// set the values for use
|
// set the values for use
|
||||||
if (refocus) {
|
if (refocus) {
|
||||||
m_pFoundLSToFocus = pFoundLayerSurface;
|
m_pFoundLSToFocus = pFoundLayerSurface;
|
||||||
m_pFoundWindowToFocus = pFoundWindow;
|
m_pFoundWindowToFocus = pFoundWindow;
|
||||||
m_pFoundSurfaceToFocus = foundSurface;
|
m_pFoundSurfaceToFocus = foundSurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pFoundWindow) {
|
if (pFoundWindow) {
|
||||||
if (*PFOLLOWMOUSE != 1 && !refocus) {
|
if (*PFOLLOWMOUSE != 1 && !refocus) {
|
||||||
if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow && ((pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR == 2) || (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR != 0))) {
|
if (pFoundWindow != g_pCompositor->m_pLastWindow && g_pCompositor->m_pLastWindow &&
|
||||||
|
((pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR == 2) || (g_pCompositor->m_pLastWindow->m_bIsFloating != pFoundWindow->m_bIsFloating && *PFLOATBEHAVIOR != 0))) {
|
||||||
// enter if change floating style
|
// enter if change floating style
|
||||||
if (*PFOLLOWMOUSE != 3 && allowKeyboardRefocus)
|
if (*PFOLLOWMOUSE != 3 && allowKeyboardRefocus)
|
||||||
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
||||||
|
@ -289,7 +296,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||||
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y);
|
wlr_seat_pointer_notify_motion(g_pCompositor->m_sSeat.seat, time, surfaceLocal.x, surfaceLocal.y);
|
||||||
|
|
||||||
m_bLastFocusOnLS = false;
|
m_bLastFocusOnLS = false;
|
||||||
return; // don't enter any new surfaces
|
return; // don't enter any new surfaces
|
||||||
} else {
|
} else {
|
||||||
if ((*PFOLLOWMOUSE != 3 && allowKeyboardRefocus) || refocus)
|
if ((*PFOLLOWMOUSE != 3 && allowKeyboardRefocus) || refocus)
|
||||||
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
||||||
|
@ -315,14 +322,9 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
|
||||||
m_tmrLastCursorMovement.reset();
|
m_tmrLastCursorMovement.reset();
|
||||||
|
|
||||||
switch (m_ecbClickBehavior) {
|
switch (m_ecbClickBehavior) {
|
||||||
case CLICKMODE_DEFAULT:
|
case CLICKMODE_DEFAULT: processMouseDownNormal(e); break;
|
||||||
processMouseDownNormal(e);
|
case CLICKMODE_KILL: processMouseDownKill(e); break;
|
||||||
break;
|
default: break;
|
||||||
case CLICKMODE_KILL:
|
|
||||||
processMouseDownKill(e);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,17 +374,16 @@ void CInputManager::setClickMode(eClickBehaviorMode mode) {
|
||||||
// set cursor
|
// set cursor
|
||||||
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor);
|
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor);
|
||||||
break;
|
break;
|
||||||
default:
|
default: break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
|
void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
|
||||||
|
|
||||||
// notify the keybind manager
|
// notify the keybind manager
|
||||||
static auto *const PPASSMOUSE = &g_pConfigManager->getConfigValuePtr("binds:pass_mouse_when_bound")->intValue;
|
static auto* const PPASSMOUSE = &g_pConfigManager->getConfigValuePtr("binds:pass_mouse_when_bound")->intValue;
|
||||||
const auto PASS = g_pKeybindManager->onMouseEvent(e);
|
const auto PASS = g_pKeybindManager->onMouseEvent(e);
|
||||||
static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
||||||
|
|
||||||
if (!PASS && !*PPASSMOUSE)
|
if (!PASS && !*PPASSMOUSE)
|
||||||
return;
|
return;
|
||||||
|
@ -400,8 +401,7 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
|
||||||
g_pCompositor->moveWindowToTop(g_pCompositor->m_pLastWindow);
|
g_pCompositor->moveWindowToTop(g_pCompositor->m_pLastWindow);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case WLR_BUTTON_RELEASED:
|
case WLR_BUTTON_RELEASED: break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// notify app if we didnt handle it
|
// notify app if we didnt handle it
|
||||||
|
@ -424,10 +424,8 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) {
|
||||||
kill(PWINDOW->getPID(), SIGKILL);
|
kill(PWINDOW->getPID(), SIGKILL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WLR_BUTTON_RELEASED:
|
case WLR_BUTTON_RELEASED: break;
|
||||||
break;
|
default: break;
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset click behavior mode
|
// reset click behavior mode
|
||||||
|
@ -435,17 +433,16 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
|
void CInputManager::onMouseWheel(wlr_pointer_axis_event* e) {
|
||||||
static auto *const PSCROLLFACTOR = &g_pConfigManager->getConfigValuePtr("input:touchpad:scroll_factor")->floatValue;
|
static auto* const PSCROLLFACTOR = &g_pConfigManager->getConfigValuePtr("input:touchpad:scroll_factor")->floatValue;
|
||||||
|
|
||||||
auto factor = (*PSCROLLFACTOR <= 0.f || e->source != WLR_AXIS_SOURCE_FINGER ? 1.f : *PSCROLLFACTOR);
|
auto factor = (*PSCROLLFACTOR <= 0.f || e->source != WLR_AXIS_SOURCE_FINGER ? 1.f : *PSCROLLFACTOR);
|
||||||
|
|
||||||
bool passEvent = g_pKeybindManager->onAxisEvent(e);
|
bool passEvent = g_pKeybindManager->onAxisEvent(e);
|
||||||
|
|
||||||
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
|
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
|
||||||
|
|
||||||
if (passEvent) {
|
if (passEvent) {
|
||||||
wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, factor * e->delta,
|
wlr_seat_pointer_notify_axis(g_pCompositor->m_sSeat.seat, e->time_msec, e->orientation, factor * e->delta, std::round(factor * e->delta_discrete), e->source);
|
||||||
std::round(factor * e->delta_discrete), e->source);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,19 +458,21 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
|
||||||
try {
|
try {
|
||||||
PNEWKEYBOARD->name = getNameForNewDevice(keyboard->name);
|
PNEWKEYBOARD->name = getNameForNewDevice(keyboard->name);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
Debug::log(ERR, "Keyboard had no name???"); // logic error
|
Debug::log(ERR, "Keyboard had no name???"); // logic error
|
||||||
}
|
}
|
||||||
|
|
||||||
PNEWKEYBOARD->hyprListener_keyboardMod.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.modifiers, &Events::listener_keyboardMod, PNEWKEYBOARD, "Keyboard");
|
PNEWKEYBOARD->hyprListener_keyboardMod.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.modifiers, &Events::listener_keyboardMod, PNEWKEYBOARD, "Keyboard");
|
||||||
PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard");
|
PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard");
|
||||||
PNEWKEYBOARD->hyprListener_keyboardDestroy.initCallback(&keyboard->events.destroy, &Events::listener_keyboardDestroy, PNEWKEYBOARD, "Keyboard");
|
PNEWKEYBOARD->hyprListener_keyboardDestroy.initCallback(&keyboard->events.destroy, &Events::listener_keyboardDestroy, PNEWKEYBOARD, "Keyboard");
|
||||||
|
|
||||||
PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.keymap, [&](void* owner, void* data) {
|
PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(
|
||||||
const auto PKEYBOARD = (SKeyboard*)owner;
|
&wlr_keyboard_from_input_device(keyboard)->events.keymap,
|
||||||
|
[&](void* owner, void* data) {
|
||||||
|
const auto PKEYBOARD = (SKeyboard*)owner;
|
||||||
|
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," +getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
|
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," + getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
|
||||||
|
},
|
||||||
}, PNEWKEYBOARD, "Keyboard");
|
PNEWKEYBOARD, "Keyboard");
|
||||||
|
|
||||||
disableAllKeyboards(false);
|
disableAllKeyboards(false);
|
||||||
|
|
||||||
|
@ -491,24 +490,26 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
|
||||||
void CInputManager::newVirtualKeyboard(wlr_input_device* keyboard) {
|
void CInputManager::newVirtualKeyboard(wlr_input_device* keyboard) {
|
||||||
const auto PNEWKEYBOARD = &m_lKeyboards.emplace_back();
|
const auto PNEWKEYBOARD = &m_lKeyboards.emplace_back();
|
||||||
|
|
||||||
PNEWKEYBOARD->keyboard = keyboard;
|
PNEWKEYBOARD->keyboard = keyboard;
|
||||||
PNEWKEYBOARD->isVirtual = true;
|
PNEWKEYBOARD->isVirtual = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PNEWKEYBOARD->name = getNameForNewDevice(keyboard->name);
|
PNEWKEYBOARD->name = getNameForNewDevice(keyboard->name);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
Debug::log(ERR, "Keyboard had no name???"); // logic error
|
Debug::log(ERR, "Keyboard had no name???"); // logic error
|
||||||
}
|
}
|
||||||
|
|
||||||
PNEWKEYBOARD->hyprListener_keyboardMod.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.modifiers, &Events::listener_keyboardMod, PNEWKEYBOARD, "Keyboard");
|
PNEWKEYBOARD->hyprListener_keyboardMod.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.modifiers, &Events::listener_keyboardMod, PNEWKEYBOARD, "Keyboard");
|
||||||
PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard");
|
PNEWKEYBOARD->hyprListener_keyboardKey.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.key, &Events::listener_keyboardKey, PNEWKEYBOARD, "Keyboard");
|
||||||
PNEWKEYBOARD->hyprListener_keyboardDestroy.initCallback(&keyboard->events.destroy, &Events::listener_keyboardDestroy, PNEWKEYBOARD, "Keyboard");
|
PNEWKEYBOARD->hyprListener_keyboardDestroy.initCallback(&keyboard->events.destroy, &Events::listener_keyboardDestroy, PNEWKEYBOARD, "Keyboard");
|
||||||
PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.keymap, [&](void* owner, void* data) {
|
PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(
|
||||||
const auto PKEYBOARD = (SKeyboard*)owner;
|
&wlr_keyboard_from_input_device(keyboard)->events.keymap,
|
||||||
|
[&](void* owner, void* data) {
|
||||||
|
const auto PKEYBOARD = (SKeyboard*)owner;
|
||||||
|
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," +getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
|
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," + getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
|
||||||
|
},
|
||||||
}, PNEWKEYBOARD, "Keyboard");
|
PNEWKEYBOARD, "Keyboard");
|
||||||
|
|
||||||
disableAllKeyboards(true);
|
disableAllKeyboards(true);
|
||||||
|
|
||||||
|
@ -531,7 +532,7 @@ void CInputManager::setKeyboardLayout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
|
void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
|
||||||
auto devname = pKeyboard->name;
|
auto devname = pKeyboard->name;
|
||||||
|
|
||||||
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
|
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
|
||||||
|
|
||||||
|
@ -542,20 +543,22 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
|
||||||
if (!wlr_keyboard_from_input_device(pKeyboard->keyboard))
|
if (!wlr_keyboard_from_input_device(pKeyboard->keyboard))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto REPEATRATE = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "repeat_rate") : g_pConfigManager->getInt("input:repeat_rate");
|
const auto REPEATRATE = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "repeat_rate") : g_pConfigManager->getInt("input:repeat_rate");
|
||||||
const auto REPEATDELAY = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "repeat_delay") : g_pConfigManager->getInt("input:repeat_delay");
|
const auto REPEATDELAY = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "repeat_delay") : g_pConfigManager->getInt("input:repeat_delay");
|
||||||
|
|
||||||
const auto NUMLOCKON = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "numlock_by_default") : g_pConfigManager->getInt("input:numlock_by_default");
|
const auto NUMLOCKON = HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "numlock_by_default") : g_pConfigManager->getInt("input:numlock_by_default");
|
||||||
|
|
||||||
const auto FILEPATH = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_file") : g_pConfigManager->getString("input:kb_file");
|
const auto FILEPATH = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_file") : g_pConfigManager->getString("input:kb_file");
|
||||||
const auto RULES = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_rules") : g_pConfigManager->getString("input:kb_rules");
|
const auto RULES = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_rules") : g_pConfigManager->getString("input:kb_rules");
|
||||||
const auto MODEL = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_model") : g_pConfigManager->getString("input:kb_model");
|
const auto MODEL = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_model") : g_pConfigManager->getString("input:kb_model");
|
||||||
const auto LAYOUT = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_layout") : g_pConfigManager->getString("input:kb_layout");
|
const auto LAYOUT = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_layout") : g_pConfigManager->getString("input:kb_layout");
|
||||||
const auto VARIANT = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_variant") : g_pConfigManager->getString("input:kb_variant");
|
const auto VARIANT = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_variant") : g_pConfigManager->getString("input:kb_variant");
|
||||||
const auto OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_options") : g_pConfigManager->getString("input:kb_options");
|
const auto OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_options") : g_pConfigManager->getString("input:kb_options");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" && RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout && VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options && FILEPATH == pKeyboard->xkbFilePath) {
|
if (NUMLOCKON == pKeyboard->numlockOn && REPEATDELAY == pKeyboard->repeatDelay && REPEATRATE == pKeyboard->repeatRate && RULES != "" &&
|
||||||
|
RULES == pKeyboard->currentRules.rules && MODEL == pKeyboard->currentRules.model && LAYOUT == pKeyboard->currentRules.layout &&
|
||||||
|
VARIANT == pKeyboard->currentRules.variant && OPTIONS == pKeyboard->currentRules.options && FILEPATH == pKeyboard->xkbFilePath) {
|
||||||
Debug::log(LOG, "Not applying config to keyboard, it did not change.");
|
Debug::log(LOG, "Not applying config to keyboard, it did not change.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -567,22 +570,17 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
|
||||||
wlr_keyboard_set_repeat_info(wlr_keyboard_from_input_device(pKeyboard->keyboard), std::max(0, REPEATRATE), std::max(0, REPEATDELAY));
|
wlr_keyboard_set_repeat_info(wlr_keyboard_from_input_device(pKeyboard->keyboard), std::max(0, REPEATRATE), std::max(0, REPEATDELAY));
|
||||||
|
|
||||||
pKeyboard->repeatDelay = REPEATDELAY;
|
pKeyboard->repeatDelay = REPEATDELAY;
|
||||||
pKeyboard->repeatRate = REPEATRATE;
|
pKeyboard->repeatRate = REPEATRATE;
|
||||||
pKeyboard->numlockOn = NUMLOCKON;
|
pKeyboard->numlockOn = NUMLOCKON;
|
||||||
pKeyboard->xkbFilePath = FILEPATH.c_str();
|
pKeyboard->xkbFilePath = FILEPATH.c_str();
|
||||||
|
|
||||||
xkb_rule_names rules = {
|
xkb_rule_names rules = {.rules = RULES.c_str(), .model = MODEL.c_str(), .layout = LAYOUT.c_str(), .variant = VARIANT.c_str(), .options = OPTIONS.c_str()};
|
||||||
.rules = RULES.c_str(),
|
|
||||||
.model = MODEL.c_str(),
|
|
||||||
.layout = LAYOUT.c_str(),
|
|
||||||
.variant = VARIANT.c_str(),
|
|
||||||
.options = OPTIONS.c_str()};
|
|
||||||
|
|
||||||
pKeyboard->currentRules.rules = RULES;
|
pKeyboard->currentRules.rules = RULES;
|
||||||
pKeyboard->currentRules.model = MODEL;
|
pKeyboard->currentRules.model = MODEL;
|
||||||
pKeyboard->currentRules.variant = VARIANT;
|
pKeyboard->currentRules.variant = VARIANT;
|
||||||
pKeyboard->currentRules.options = OPTIONS;
|
pKeyboard->currentRules.options = OPTIONS;
|
||||||
pKeyboard->currentRules.layout = LAYOUT;
|
pKeyboard->currentRules.layout = LAYOUT;
|
||||||
|
|
||||||
const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||||
|
|
||||||
|
@ -591,35 +589,38 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug::log(LOG, "Attempting to create a keymap for layout %s with variant %s (rules: %s, model: %s, options: %s)", rules.layout, rules.variant, rules.rules, rules.model, rules.options);
|
Debug::log(LOG, "Attempting to create a keymap for layout %s with variant %s (rules: %s, model: %s, options: %s)", rules.layout, rules.variant, rules.rules, rules.model,
|
||||||
|
rules.options);
|
||||||
|
|
||||||
xkb_keymap * KEYMAP = NULL;
|
xkb_keymap* KEYMAP = NULL;
|
||||||
|
|
||||||
if (!FILEPATH.empty()) {
|
if (!FILEPATH.empty()) {
|
||||||
auto path = absolutePath(FILEPATH, g_pConfigManager->configCurrentPath);
|
auto path = absolutePath(FILEPATH, g_pConfigManager->configCurrentPath);
|
||||||
|
|
||||||
if (!std::filesystem::exists(path)) {
|
if (!std::filesystem::exists(path)) {
|
||||||
Debug::log(ERR, "input:kb_file= file doesnt exist");
|
Debug::log(ERR, "input:kb_file= file doesnt exist");
|
||||||
} else {
|
} else {
|
||||||
KEYMAP = xkb_keymap_new_from_file(CONTEXT, fopen(path.c_str(), "r"), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
KEYMAP = xkb_keymap_new_from_file(CONTEXT, fopen(path.c_str(), "r"), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!KEYMAP) {
|
if (!KEYMAP) {
|
||||||
KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!KEYMAP) {
|
if (!KEYMAP) {
|
||||||
g_pConfigManager->addParseError("Invalid keyboard layout passed. ( rules: " + RULES + ", model: " + MODEL + ", variant: " + VARIANT + ", options: " + OPTIONS + ", layout: " + LAYOUT + " )");
|
g_pConfigManager->addParseError("Invalid keyboard layout passed. ( rules: " + RULES + ", model: " + MODEL + ", variant: " + VARIANT + ", options: " + OPTIONS +
|
||||||
|
", layout: " + LAYOUT + " )");
|
||||||
|
|
||||||
Debug::log(ERR, "Keyboard layout %s with variant %s (rules: %s, model: %s, options: %s) couldn't have been loaded.", rules.layout, rules.variant, rules.rules, rules.model, rules.options);
|
Debug::log(ERR, "Keyboard layout %s with variant %s (rules: %s, model: %s, options: %s) couldn't have been loaded.", rules.layout, rules.variant, rules.rules, rules.model,
|
||||||
|
rules.options);
|
||||||
memset(&rules, 0, sizeof(rules));
|
memset(&rules, 0, sizeof(rules));
|
||||||
|
|
||||||
pKeyboard->currentRules.rules = "";
|
pKeyboard->currentRules.rules = "";
|
||||||
pKeyboard->currentRules.model = "";
|
pKeyboard->currentRules.model = "";
|
||||||
pKeyboard->currentRules.variant = "";
|
pKeyboard->currentRules.variant = "";
|
||||||
pKeyboard->currentRules.options = "";
|
pKeyboard->currentRules.options = "";
|
||||||
pKeyboard->currentRules.layout = "";
|
pKeyboard->currentRules.layout = "";
|
||||||
|
|
||||||
KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
KEYMAP = xkb_keymap_new_from_names(CONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||||
}
|
}
|
||||||
|
@ -643,7 +644,7 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
|
||||||
xkb_keymap_unref(KEYMAP);
|
xkb_keymap_unref(KEYMAP);
|
||||||
xkb_context_unref(CONTEXT);
|
xkb_context_unref(CONTEXT);
|
||||||
|
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->name + "," +getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
|
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->name + "," + getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
|
||||||
|
|
||||||
Debug::log(LOG, "Set the keyboard layout to %s and variant to %s for keyboard \"%s\"", rules.layout, rules.variant, pKeyboard->keyboard->name);
|
Debug::log(LOG, "Set the keyboard layout to %s and variant to %s for keyboard \"%s\"", rules.layout, rules.variant, pKeyboard->keyboard->name);
|
||||||
}
|
}
|
||||||
|
@ -653,17 +654,19 @@ void CInputManager::newMouse(wlr_input_device* mouse, bool virt) {
|
||||||
const auto PMOUSE = &m_lMice.back();
|
const auto PMOUSE = &m_lMice.back();
|
||||||
|
|
||||||
PMOUSE->mouse = mouse;
|
PMOUSE->mouse = mouse;
|
||||||
PMOUSE->virt = virt;
|
PMOUSE->virt = virt;
|
||||||
try {
|
try {
|
||||||
PMOUSE->name = getNameForNewDevice(mouse->name);
|
PMOUSE->name = getNameForNewDevice(mouse->name);
|
||||||
} catch(std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
Debug::log(ERR, "Mouse had no name???"); // logic error
|
Debug::log(ERR, "Mouse had no name???"); // logic error
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wlr_input_device_is_libinput(mouse)) {
|
if (wlr_input_device_is_libinput(mouse)) {
|
||||||
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(mouse);
|
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(mouse);
|
||||||
|
|
||||||
Debug::log(LOG, "New mouse has libinput sens %.2f (%.2f) with accel profile %i (%i)", libinput_device_config_accel_get_speed(LIBINPUTDEV), libinput_device_config_accel_get_default_speed(LIBINPUTDEV), libinput_device_config_accel_get_profile(LIBINPUTDEV), libinput_device_config_accel_get_default_profile(LIBINPUTDEV));
|
Debug::log(LOG, "New mouse has libinput sens %.2f (%.2f) with accel profile %i (%i)", libinput_device_config_accel_get_speed(LIBINPUTDEV),
|
||||||
|
libinput_device_config_accel_get_default_speed(LIBINPUTDEV), libinput_device_config_accel_get_profile(LIBINPUTDEV),
|
||||||
|
libinput_device_config_accel_get_default_profile(LIBINPUTDEV));
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, mouse);
|
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, mouse);
|
||||||
|
@ -685,7 +688,7 @@ void CInputManager::setPointerConfigs() {
|
||||||
for (auto& m : m_lMice) {
|
for (auto& m : m_lMice) {
|
||||||
const auto PPOINTER = &m;
|
const auto PPOINTER = &m;
|
||||||
|
|
||||||
auto devname = PPOINTER->name;
|
auto devname = PPOINTER->name;
|
||||||
|
|
||||||
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
|
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
|
||||||
|
|
||||||
|
@ -703,7 +706,8 @@ void CInputManager::setPointerConfigs() {
|
||||||
if (wlr_input_device_is_libinput(m.mouse)) {
|
if (wlr_input_device_is_libinput(m.mouse)) {
|
||||||
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.mouse);
|
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.mouse);
|
||||||
|
|
||||||
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "clickfinger_behavior") : g_pConfigManager->getInt("input:touchpad:clickfinger_behavior")) == 0) // toggle software buttons or clickfinger
|
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "clickfinger_behavior") : g_pConfigManager->getInt("input:touchpad:clickfinger_behavior")) ==
|
||||||
|
0) // toggle software buttons or clickfinger
|
||||||
libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
|
libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS);
|
||||||
else
|
else
|
||||||
libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
|
libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
|
||||||
|
@ -713,7 +717,7 @@ void CInputManager::setPointerConfigs() {
|
||||||
else
|
else
|
||||||
libinput_device_config_left_handed_set(LIBINPUTDEV, 1);
|
libinput_device_config_left_handed_set(LIBINPUTDEV, 1);
|
||||||
|
|
||||||
if (libinput_device_config_middle_emulation_is_available(LIBINPUTDEV)) { // middleclick on r+l mouse button pressed
|
if (libinput_device_config_middle_emulation_is_available(LIBINPUTDEV)) { // middleclick on r+l mouse button pressed
|
||||||
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "middle_button_emulation") : g_pConfigManager->getInt("input:touchpad:middle_button_emulation")) == 1)
|
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "middle_button_emulation") : g_pConfigManager->getInt("input:touchpad:middle_button_emulation")) == 1)
|
||||||
libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
||||||
else
|
else
|
||||||
|
@ -740,25 +744,30 @@ void CInputManager::setPointerConfigs() {
|
||||||
else
|
else
|
||||||
libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_ENABLED);
|
libinput_device_config_tap_set_drag_lock_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_DRAG_LOCK_ENABLED);
|
||||||
|
|
||||||
if (libinput_device_config_tap_get_finger_count(LIBINPUTDEV)) // this is for tapping (like on a laptop)
|
if (libinput_device_config_tap_get_finger_count(LIBINPUTDEV)) // this is for tapping (like on a laptop)
|
||||||
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "tap-to-click") : g_pConfigManager->getInt("input:touchpad:tap-to-click")) == 1)
|
if ((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "tap-to-click") : g_pConfigManager->getInt("input:touchpad:tap-to-click")) == 1)
|
||||||
libinput_device_config_tap_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_ENABLED);
|
libinput_device_config_tap_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_ENABLED);
|
||||||
|
|
||||||
if (libinput_device_config_scroll_has_natural_scroll(LIBINPUTDEV)) {
|
if (libinput_device_config_scroll_has_natural_scroll(LIBINPUTDEV)) {
|
||||||
double w = 0, h = 0;
|
double w = 0, h = 0;
|
||||||
|
|
||||||
if (libinput_device_has_capability(LIBINPUTDEV, LIBINPUT_DEVICE_CAP_POINTER) && libinput_device_get_size(LIBINPUTDEV, &w, &h) == 0) // pointer with size is a touchpad
|
if (libinput_device_has_capability(LIBINPUTDEV, LIBINPUT_DEVICE_CAP_POINTER) &&
|
||||||
libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "natural_scroll") : g_pConfigManager->getInt("input:touchpad:natural_scroll")));
|
libinput_device_get_size(LIBINPUTDEV, &w, &h) == 0) // pointer with size is a touchpad
|
||||||
|
libinput_device_config_scroll_set_natural_scroll_enabled(
|
||||||
|
LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "natural_scroll") : g_pConfigManager->getInt("input:touchpad:natural_scroll")));
|
||||||
else
|
else
|
||||||
libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "natural_scroll") : g_pConfigManager->getInt("input:natural_scroll")));
|
libinput_device_config_scroll_set_natural_scroll_enabled(
|
||||||
|
LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "natural_scroll") : g_pConfigManager->getInt("input:natural_scroll")));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (libinput_device_config_dwt_is_available(LIBINPUTDEV)) {
|
if (libinput_device_config_dwt_is_available(LIBINPUTDEV)) {
|
||||||
const auto DWT = static_cast<enum libinput_config_dwt_state>((HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "disable_while_typing") : g_pConfigManager->getInt("input:touchpad:disable_while_typing")) != 0);
|
const auto DWT = static_cast<enum libinput_config_dwt_state>(
|
||||||
|
(HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "disable_while_typing") : g_pConfigManager->getInt("input:touchpad:disable_while_typing")) != 0);
|
||||||
libinput_device_config_dwt_set_enabled(LIBINPUTDEV, DWT);
|
libinput_device_config_dwt_set_enabled(LIBINPUTDEV, DWT);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto LIBINPUTSENS = std::clamp((HASCONFIG ? g_pConfigManager->getDeviceFloat(devname, "sensitivity") : g_pConfigManager->getFloat("input:sensitivity")), -1.f, 1.f);
|
const auto LIBINPUTSENS =
|
||||||
|
std::clamp((HASCONFIG ? g_pConfigManager->getDeviceFloat(devname, "sensitivity") : g_pConfigManager->getFloat("input:sensitivity")), -1.f, 1.f);
|
||||||
libinput_device_config_accel_set_speed(LIBINPUTDEV, LIBINPUTSENS);
|
libinput_device_config_accel_set_speed(LIBINPUTDEV, LIBINPUTSENS);
|
||||||
|
|
||||||
const auto ACCELPROFILE = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "accel_profile") : g_pConfigManager->getString("input:accel_profile");
|
const auto ACCELPROFILE = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "accel_profile") : g_pConfigManager->getString("input:accel_profile");
|
||||||
|
@ -791,7 +800,7 @@ void CInputManager::destroyKeyboard(SKeyboard* pKeyboard) {
|
||||||
m_lKeyboards.remove(*pKeyboard);
|
m_lKeyboards.remove(*pKeyboard);
|
||||||
|
|
||||||
if (m_lKeyboards.size() > 0) {
|
if (m_lKeyboards.size() > 0) {
|
||||||
m_pActiveKeyboard = &m_lKeyboards.back();
|
m_pActiveKeyboard = &m_lKeyboards.back();
|
||||||
m_pActiveKeyboard->active = true;
|
m_pActiveKeyboard->active = true;
|
||||||
} else {
|
} else {
|
||||||
m_pActiveKeyboard = nullptr;
|
m_pActiveKeyboard = nullptr;
|
||||||
|
@ -815,22 +824,20 @@ void CInputManager::destroyMouse(wlr_input_device* mouse) {
|
||||||
unconstrainMouse();
|
unconstrainMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CInputManager::updateKeyboardsLeds(wlr_input_device* pKeyboard) {
|
||||||
void CInputManager::updateKeyboardsLeds(wlr_input_device* pKeyboard) {
|
|
||||||
auto keyboard = wlr_keyboard_from_input_device(pKeyboard);
|
auto keyboard = wlr_keyboard_from_input_device(pKeyboard);
|
||||||
|
|
||||||
if (keyboard->xkb_state == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t leds = 0;
|
if (keyboard->xkb_state == NULL) {
|
||||||
for (uint32_t i = 0; i < WLR_LED_COUNT; ++i) {
|
return;
|
||||||
if (xkb_state_led_index_is_active(keyboard->xkb_state,
|
}
|
||||||
keyboard->led_indexes[i])) {
|
|
||||||
leds |= (1 << i);
|
uint32_t leds = 0;
|
||||||
}
|
for (uint32_t i = 0; i < WLR_LED_COUNT; ++i) {
|
||||||
}
|
if (xkb_state_led_index_is_active(keyboard->xkb_state, keyboard->led_indexes[i])) {
|
||||||
|
leds |= (1 << i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (auto& kb : m_lKeyboards) {
|
for (auto& kb : m_lKeyboards) {
|
||||||
if ((kb.isVirtual && shouldIgnoreVirtualKeyboard(&kb)) || kb.keyboard == pKeyboard)
|
if ((kb.isVirtual && shouldIgnoreVirtualKeyboard(&kb)) || kb.keyboard == pKeyboard)
|
||||||
continue;
|
continue;
|
||||||
|
@ -839,7 +846,6 @@ void CInputManager::updateKeyboardsLeds(wlr_input_device* pKeyboard) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) {
|
void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) {
|
||||||
bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard);
|
bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard);
|
||||||
|
|
||||||
|
@ -866,8 +872,8 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
|
||||||
|
|
||||||
const auto ALLMODS = accumulateModsFromAllKBs();
|
const auto ALLMODS = accumulateModsFromAllKBs();
|
||||||
|
|
||||||
auto MODS = wlr_keyboard_from_input_device(pKeyboard->keyboard)->modifiers;
|
auto MODS = wlr_keyboard_from_input_device(pKeyboard->keyboard)->modifiers;
|
||||||
MODS.depressed = ALLMODS;
|
MODS.depressed = ALLMODS;
|
||||||
|
|
||||||
if (PIMEGRAB && PIMEGRAB->pWlrKbGrab && PIMEGRAB->pWlrKbGrab->input_method) {
|
if (PIMEGRAB && PIMEGRAB->pWlrKbGrab && PIMEGRAB->pWlrKbGrab->input_method) {
|
||||||
wlr_input_method_keyboard_grab_v2_set_keyboard(PIMEGRAB->pWlrKbGrab, wlr_keyboard_from_input_device(pKeyboard->keyboard));
|
wlr_input_method_keyboard_grab_v2_set_keyboard(PIMEGRAB->pWlrKbGrab, wlr_keyboard_from_input_device(pKeyboard->keyboard));
|
||||||
|
@ -882,14 +888,16 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
|
||||||
const auto PWLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
|
const auto PWLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
|
||||||
|
|
||||||
if (PWLRKB->modifiers.group != pKeyboard->activeLayout) {
|
if (PWLRKB->modifiers.group != pKeyboard->activeLayout) {
|
||||||
pKeyboard->activeLayout = PWLRKB->modifiers.group;
|
pKeyboard->activeLayout = PWLRKB->modifiers.group;
|
||||||
|
|
||||||
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->name + "," + getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
|
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", pKeyboard->name + "," + getActiveLayoutForKeyboard(pKeyboard)}, true); // force as this should ALWAYS be sent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CInputManager::shouldIgnoreVirtualKeyboard(SKeyboard* pKeyboard) {
|
bool CInputManager::shouldIgnoreVirtualKeyboard(SKeyboard* pKeyboard) {
|
||||||
return !pKeyboard || (m_sIMERelay.m_pKeyboardGrab && wl_resource_get_client(m_sIMERelay.m_pKeyboardGrab->pWlrKbGrab->resource) == wl_resource_get_client(wlr_input_device_get_virtual_keyboard(pKeyboard->keyboard)->resource));
|
return !pKeyboard ||
|
||||||
|
(m_sIMERelay.m_pKeyboardGrab &&
|
||||||
|
wl_resource_get_client(m_sIMERelay.m_pKeyboardGrab->pWlrKbGrab->resource) == wl_resource_get_client(wlr_input_device_get_virtual_keyboard(pKeyboard->keyboard)->resource));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::refocus() {
|
void CInputManager::refocus() {
|
||||||
|
@ -901,16 +909,14 @@ void CInputManager::updateDragIcon() {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (m_sDrag.dragIcon->drag->grab_type) {
|
switch (m_sDrag.dragIcon->drag->grab_type) {
|
||||||
case WLR_DRAG_GRAB_KEYBOARD:
|
case WLR_DRAG_GRAB_KEYBOARD: break;
|
||||||
break;
|
|
||||||
case WLR_DRAG_GRAB_KEYBOARD_POINTER: {
|
case WLR_DRAG_GRAB_KEYBOARD_POINTER: {
|
||||||
wlr_box box = {m_sDrag.pos.x - 2, m_sDrag.pos.y - 2, m_sDrag.dragIcon->surface->current.width + 4, m_sDrag.dragIcon->surface->current.height + 4};
|
wlr_box box = {m_sDrag.pos.x - 2, m_sDrag.pos.y - 2, m_sDrag.dragIcon->surface->current.width + 4, m_sDrag.dragIcon->surface->current.height + 4};
|
||||||
g_pHyprRenderer->damageBox(&box);
|
g_pHyprRenderer->damageBox(&box);
|
||||||
m_sDrag.pos = getMouseCoordsInternal();
|
m_sDrag.pos = getMouseCoordsInternal();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -926,10 +932,11 @@ void CInputManager::recheckConstraint(SMouse* pMouse) {
|
||||||
pixman_region32_clear(&pMouse->confinedTo);
|
pixman_region32_clear(&pMouse->confinedTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto PWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
|
const auto PWINDOW = g_pCompositor->getConstraintWindow(g_pCompositor->m_sSeat.mouse);
|
||||||
const auto PWINDOWNAME = PWINDOW ? PWINDOW->m_szTitle : "";
|
const auto PWINDOWNAME = PWINDOW ? PWINDOW->m_szTitle : "";
|
||||||
|
|
||||||
Debug::log(LOG, "Constraint rechecked: %i, %i to %i, %i for %x (window name: %s)", PREGION->extents.x1, PREGION->extents.y1, PREGION->extents.x2, PREGION->extents.y2, pMouse->currentConstraint->surface, PWINDOWNAME.c_str());
|
Debug::log(LOG, "Constraint rechecked: %i, %i to %i, %i for %x (window name: %s)", PREGION->extents.x1, PREGION->extents.y1, PREGION->extents.x2, PREGION->extents.y2,
|
||||||
|
pMouse->currentConstraint->surface, PWINDOWNAME.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* constraint) {
|
void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* constraint) {
|
||||||
|
@ -937,7 +944,7 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
|
||||||
if (pMouse->currentConstraint == constraint)
|
if (pMouse->currentConstraint == constraint)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto PWINDOW = g_pCompositor->getWindowFromSurface(constraint->surface);
|
const auto PWINDOW = g_pCompositor->getWindowFromSurface(constraint->surface);
|
||||||
const auto MOUSECOORDS = getMouseCoordsInternal();
|
const auto MOUSECOORDS = getMouseCoordsInternal();
|
||||||
|
|
||||||
pMouse->hyprListener_commitConstraint.removeCallback();
|
pMouse->hyprListener_commitConstraint.removeCallback();
|
||||||
|
@ -949,13 +956,13 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
|
||||||
if (constraint->current.committed & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT) {
|
if (constraint->current.committed & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT) {
|
||||||
if (PWINDOW) {
|
if (PWINDOW) {
|
||||||
if (PWINDOW->m_bIsX11) {
|
if (PWINDOW->m_bIsX11) {
|
||||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr,
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, constraint->current.cursor_hint.x + PWINDOW->m_uSurface.xwayland->x,
|
||||||
constraint->current.cursor_hint.x + PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y + PWINDOW->m_vRealPosition.vec().y);
|
PWINDOW->m_uSurface.xwayland->y + PWINDOW->m_vRealPosition.vec().y);
|
||||||
|
|
||||||
wlr_seat_pointer_warp(constraint->seat, constraint->current.cursor_hint.x, constraint->current.cursor_hint.y);
|
wlr_seat_pointer_warp(constraint->seat, constraint->current.cursor_hint.x, constraint->current.cursor_hint.y);
|
||||||
} else {
|
} else {
|
||||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr,
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, constraint->current.cursor_hint.x + PWINDOW->m_vRealPosition.vec().x,
|
||||||
constraint->current.cursor_hint.x + PWINDOW->m_vRealPosition.vec().x, constraint->current.cursor_hint.y + PWINDOW->m_vRealPosition.vec().y);
|
constraint->current.cursor_hint.y + PWINDOW->m_vRealPosition.vec().y);
|
||||||
|
|
||||||
wlr_seat_pointer_warp(constraint->seat, constraint->current.cursor_hint.x, constraint->current.cursor_hint.y);
|
wlr_seat_pointer_warp(constraint->seat, constraint->current.cursor_hint.x, constraint->current.cursor_hint.y);
|
||||||
}
|
}
|
||||||
|
@ -964,7 +971,7 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
|
||||||
const auto PCONSTRAINT = constraintFromWlr(constraint);
|
const auto PCONSTRAINT = constraintFromWlr(constraint);
|
||||||
if (PCONSTRAINT) { // should never be null but who knows
|
if (PCONSTRAINT) { // should never be null but who knows
|
||||||
PCONSTRAINT->positionHint = Vector2D(constraint->current.cursor_hint.x, constraint->current.cursor_hint.y);
|
PCONSTRAINT->positionHint = Vector2D(constraint->current.cursor_hint.x, constraint->current.cursor_hint.y);
|
||||||
PCONSTRAINT->hintSet = true;
|
PCONSTRAINT->hintSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -973,7 +980,7 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
|
||||||
}
|
}
|
||||||
|
|
||||||
pMouse->currentConstraint = constraint;
|
pMouse->currentConstraint = constraint;
|
||||||
pMouse->constraintActive = true;
|
pMouse->constraintActive = true;
|
||||||
|
|
||||||
if (pixman_region32_not_empty(&constraint->current.region)) {
|
if (pixman_region32_not_empty(&constraint->current.region)) {
|
||||||
pixman_region32_intersect(&constraint->region, &constraint->surface->input_region, &constraint->current.region);
|
pixman_region32_intersect(&constraint->region, &constraint->surface->input_region, &constraint->current.region);
|
||||||
|
@ -1015,9 +1022,9 @@ void Events::listener_commitConstraint(void* owner, void* data) {
|
||||||
|
|
||||||
if (PMOUSE->currentConstraint->current.committed & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT) {
|
if (PMOUSE->currentConstraint->current.committed & WLR_POINTER_CONSTRAINT_V1_STATE_CURSOR_HINT) {
|
||||||
const auto PCONSTRAINT = g_pInputManager->constraintFromWlr(PMOUSE->currentConstraint);
|
const auto PCONSTRAINT = g_pInputManager->constraintFromWlr(PMOUSE->currentConstraint);
|
||||||
if (PCONSTRAINT) { // should never be null but who knows
|
if (PCONSTRAINT) { // should never be null but who knows
|
||||||
PCONSTRAINT->positionHint = Vector2D(PMOUSE->currentConstraint->current.cursor_hint.x, PMOUSE->currentConstraint->current.cursor_hint.y);
|
PCONSTRAINT->positionHint = Vector2D(PMOUSE->currentConstraint->current.cursor_hint.x, PMOUSE->currentConstraint->current.cursor_hint.y);
|
||||||
PCONSTRAINT->hintSet = true;
|
PCONSTRAINT->hintSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1053,9 +1060,9 @@ uint32_t CInputManager::accumulateModsFromAllKBs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CInputManager::getActiveLayoutForKeyboard(SKeyboard* pKeyboard) {
|
std::string CInputManager::getActiveLayoutForKeyboard(SKeyboard* pKeyboard) {
|
||||||
const auto WLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
|
const auto WLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
|
||||||
const auto KEYMAP = WLRKB->keymap;
|
const auto KEYMAP = WLRKB->keymap;
|
||||||
const auto STATE = WLRKB->xkb_state;
|
const auto STATE = WLRKB->xkb_state;
|
||||||
const auto LAYOUTSNUM = xkb_keymap_num_layouts(KEYMAP);
|
const auto LAYOUTSNUM = xkb_keymap_num_layouts(KEYMAP);
|
||||||
|
|
||||||
for (uint32_t i = 0; i < LAYOUTSNUM; ++i) {
|
for (uint32_t i = 0; i < LAYOUTSNUM; ++i) {
|
||||||
|
@ -1082,12 +1089,12 @@ void CInputManager::disableAllKeyboards(bool virt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::newTouchDevice(wlr_input_device* pDevice) {
|
void CInputManager::newTouchDevice(wlr_input_device* pDevice) {
|
||||||
const auto PNEWDEV = &m_lTouchDevices.emplace_back();
|
const auto PNEWDEV = &m_lTouchDevices.emplace_back();
|
||||||
PNEWDEV->pWlrDevice = pDevice;
|
PNEWDEV->pWlrDevice = pDevice;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PNEWDEV->name = getNameForNewDevice(pDevice->name);
|
PNEWDEV->name = getNameForNewDevice(pDevice->name);
|
||||||
} catch(std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
Debug::log(ERR, "Touch Device had no name???"); // logic error
|
Debug::log(ERR, "Touch Device had no name???"); // logic error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1096,47 +1103,28 @@ void CInputManager::newTouchDevice(wlr_input_device* pDevice) {
|
||||||
|
|
||||||
Debug::log(LOG, "New touch device added at %x", PNEWDEV);
|
Debug::log(LOG, "New touch device added at %x", PNEWDEV);
|
||||||
|
|
||||||
PNEWDEV->hyprListener_destroy.initCallback(&pDevice->events.destroy, [&](void* owner, void* data) {
|
PNEWDEV->hyprListener_destroy.initCallback(
|
||||||
destroyTouchDevice((STouchDevice*)data);
|
&pDevice->events.destroy, [&](void* owner, void* data) { destroyTouchDevice((STouchDevice*)data); }, PNEWDEV, "TouchDevice");
|
||||||
}, PNEWDEV, "TouchDevice");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::setTouchDeviceConfigs() {
|
void CInputManager::setTouchDeviceConfigs() {
|
||||||
// The third row is always 0 0 1 and is not expected by `libinput_device_config_calibration_set_matrix`
|
// The third row is always 0 0 1 and is not expected by `libinput_device_config_calibration_set_matrix`
|
||||||
static const float MATRICES[8][6] = {
|
static const float MATRICES[8][6] = {{// normal
|
||||||
{ // normal
|
1, 0, 0, 0, 1, 0},
|
||||||
1, 0, 0,
|
{// rotation 90°
|
||||||
0, 1, 0
|
0, -1, 1, 1, 0, 0},
|
||||||
},
|
{// rotation 180°
|
||||||
{ // rotation 90°
|
-1, 0, 1, 0, -1, 1},
|
||||||
0, -1, 1,
|
{// rotation 270°
|
||||||
1, 0, 0
|
0, 1, 0, -1, 0, 1},
|
||||||
},
|
{// flipped
|
||||||
{ // rotation 180°
|
-1, 0, 1, 0, 1, 0},
|
||||||
-1, 0, 1,
|
{// flipped + rotation 90°
|
||||||
0, -1, 1
|
0, 1, 0, 1, 0, 0},
|
||||||
},
|
{// flipped + rotation 180°
|
||||||
{ // rotation 270°
|
1, 0, 0, 0, -1, 1},
|
||||||
0, 1, 0,
|
{// flipped + rotation 270°
|
||||||
-1, 0, 1
|
0, -1, 1, -1, 0, 1}};
|
||||||
},
|
|
||||||
{ // flipped
|
|
||||||
-1, 0, 1,
|
|
||||||
0, 1, 0
|
|
||||||
},
|
|
||||||
{ // flipped + rotation 90°
|
|
||||||
0, 1, 0,
|
|
||||||
1, 0, 0
|
|
||||||
},
|
|
||||||
{ // flipped + rotation 180°
|
|
||||||
1, 0, 0,
|
|
||||||
0, -1, 1
|
|
||||||
},
|
|
||||||
{ // flipped + rotation 270°
|
|
||||||
0, -1, 1,
|
|
||||||
-1, 0, 1
|
|
||||||
}
|
|
||||||
};
|
|
||||||
for (auto& m : m_lTouchDevices) {
|
for (auto& m : m_lTouchDevices) {
|
||||||
const auto PTOUCHDEV = &m;
|
const auto PTOUCHDEV = &m;
|
||||||
|
|
||||||
|
@ -1145,7 +1133,8 @@ void CInputManager::setTouchDeviceConfigs() {
|
||||||
if (wlr_input_device_is_libinput(m.pWlrDevice)) {
|
if (wlr_input_device_is_libinput(m.pWlrDevice)) {
|
||||||
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.pWlrDevice);
|
const auto LIBINPUTDEV = (libinput_device*)wlr_libinput_get_device_handle(m.pWlrDevice);
|
||||||
|
|
||||||
const int ROTATION = std::clamp(HASCONFIG ? g_pConfigManager->getDeviceInt(PTOUCHDEV->name, "touch_transform") : g_pConfigManager->getInt("input:touchdevice:transform"), 0, 7);
|
const int ROTATION =
|
||||||
|
std::clamp(HASCONFIG ? g_pConfigManager->getDeviceInt(PTOUCHDEV->name, "touch_transform") : g_pConfigManager->getInt("input:touchdevice:transform"), 0, 7);
|
||||||
libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]);
|
libinput_device_config_calibration_set_matrix(LIBINPUTDEV, MATRICES[ROTATION]);
|
||||||
|
|
||||||
const auto OUTPUT = HASCONFIG ? g_pConfigManager->getDeviceString(PTOUCHDEV->name, "touch_output") : g_pConfigManager->getString("input:touchdevice:output");
|
const auto OUTPUT = HASCONFIG ? g_pConfigManager->getDeviceString(PTOUCHDEV->name, "touch_output") : g_pConfigManager->getString("input:touchdevice:output");
|
||||||
|
@ -1164,25 +1153,27 @@ void CInputManager::destroyTouchDevice(STouchDevice* pDevice) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::newSwitch(wlr_input_device* pDevice) {
|
void CInputManager::newSwitch(wlr_input_device* pDevice) {
|
||||||
const auto PNEWDEV = &m_lSwitches.emplace_back();
|
const auto PNEWDEV = &m_lSwitches.emplace_back();
|
||||||
PNEWDEV->pWlrDevice = pDevice;
|
PNEWDEV->pWlrDevice = pDevice;
|
||||||
|
|
||||||
Debug::log(LOG, "New switch with name \"%s\" added", pDevice->name);
|
Debug::log(LOG, "New switch with name \"%s\" added", pDevice->name);
|
||||||
|
|
||||||
PNEWDEV->hyprListener_destroy.initCallback(&pDevice->events.destroy, [&](void* owner, void* data) {
|
PNEWDEV->hyprListener_destroy.initCallback(
|
||||||
destroySwitch((SSwitchDevice*)owner);
|
&pDevice->events.destroy, [&](void* owner, void* data) { destroySwitch((SSwitchDevice*)owner); }, PNEWDEV, "SwitchDevice");
|
||||||
}, PNEWDEV, "SwitchDevice");
|
|
||||||
|
|
||||||
const auto PSWITCH = wlr_switch_from_input_device(pDevice);
|
const auto PSWITCH = wlr_switch_from_input_device(pDevice);
|
||||||
|
|
||||||
PNEWDEV->hyprListener_toggle.initCallback(&PSWITCH->events.toggle, [&](void* owner, void* data) {
|
PNEWDEV->hyprListener_toggle.initCallback(
|
||||||
const auto PDEVICE = (SSwitchDevice*)owner;
|
&PSWITCH->events.toggle,
|
||||||
const auto NAME = std::string(PDEVICE->pWlrDevice->name);
|
[&](void* owner, void* data) {
|
||||||
|
const auto PDEVICE = (SSwitchDevice*)owner;
|
||||||
|
const auto NAME = std::string(PDEVICE->pWlrDevice->name);
|
||||||
|
|
||||||
Debug::log(LOG, "Switch %s fired, triggering binds.", NAME.c_str());
|
Debug::log(LOG, "Switch %s fired, triggering binds.", NAME.c_str());
|
||||||
|
|
||||||
g_pKeybindManager->onSwitchEvent(NAME);
|
g_pKeybindManager->onSwitchEvent(NAME);
|
||||||
}, PNEWDEV, "SwitchDevice");
|
},
|
||||||
|
PNEWDEV, "SwitchDevice");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::destroySwitch(SSwitchDevice* pDevice) {
|
void CInputManager::destroySwitch(SSwitchDevice* pDevice) {
|
||||||
|
@ -1212,24 +1203,30 @@ std::string CInputManager::deviceNameToInternalString(std::string in) {
|
||||||
std::string CInputManager::getNameForNewDevice(std::string internalName) {
|
std::string CInputManager::getNameForNewDevice(std::string internalName) {
|
||||||
|
|
||||||
auto proposedNewName = deviceNameToInternalString(internalName);
|
auto proposedNewName = deviceNameToInternalString(internalName);
|
||||||
int dupeno = 0;
|
int dupeno = 0;
|
||||||
|
|
||||||
while (std::find_if(m_lKeyboards.begin(), m_lKeyboards.end(), [&] (const SKeyboard& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lKeyboards.end())
|
while (std::find_if(m_lKeyboards.begin(), m_lKeyboards.end(),
|
||||||
|
[&](const SKeyboard& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lKeyboards.end())
|
||||||
dupeno++;
|
dupeno++;
|
||||||
|
|
||||||
while (std::find_if(m_lMice.begin(), m_lMice.end(), [&] (const SMouse& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lMice.end())
|
while (std::find_if(m_lMice.begin(), m_lMice.end(), [&](const SMouse& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) !=
|
||||||
|
m_lMice.end())
|
||||||
dupeno++;
|
dupeno++;
|
||||||
|
|
||||||
while (std::find_if(m_lTouchDevices.begin(), m_lTouchDevices.end(), [&] (const STouchDevice& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTouchDevices.end())
|
while (std::find_if(m_lTouchDevices.begin(), m_lTouchDevices.end(),
|
||||||
|
[&](const STouchDevice& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTouchDevices.end())
|
||||||
dupeno++;
|
dupeno++;
|
||||||
|
|
||||||
while (std::find_if(m_lTabletPads.begin(), m_lTabletPads.end(), [&] (const STabletPad& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTabletPads.end())
|
while (std::find_if(m_lTabletPads.begin(), m_lTabletPads.end(),
|
||||||
|
[&](const STabletPad& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTabletPads.end())
|
||||||
dupeno++;
|
dupeno++;
|
||||||
|
|
||||||
while (std::find_if(m_lTablets.begin(), m_lTablets.end(), [&] (const STablet& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTablets.end())
|
while (std::find_if(m_lTablets.begin(), m_lTablets.end(),
|
||||||
|
[&](const STablet& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTablets.end())
|
||||||
dupeno++;
|
dupeno++;
|
||||||
|
|
||||||
while (std::find_if(m_lTabletTools.begin(), m_lTabletTools.end(), [&] (const STabletTool& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTabletTools.end())
|
while (std::find_if(m_lTabletTools.begin(), m_lTabletTools.end(),
|
||||||
|
[&](const STabletTool& other) { return other.name == proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno))); }) != m_lTabletTools.end())
|
||||||
dupeno++;
|
dupeno++;
|
||||||
|
|
||||||
return proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno)));
|
return proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno)));
|
||||||
|
|
|
@ -7,89 +7,90 @@
|
||||||
#include "../../helpers/Timer.hpp"
|
#include "../../helpers/Timer.hpp"
|
||||||
#include "InputMethodRelay.hpp"
|
#include "InputMethodRelay.hpp"
|
||||||
|
|
||||||
enum eClickBehaviorMode {
|
enum eClickBehaviorMode
|
||||||
|
{
|
||||||
CLICKMODE_DEFAULT = 0,
|
CLICKMODE_DEFAULT = 0,
|
||||||
CLICKMODE_KILL
|
CLICKMODE_KILL
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eMouseBindMode {
|
enum eMouseBindMode
|
||||||
|
{
|
||||||
MBIND_INVALID = -1,
|
MBIND_INVALID = -1,
|
||||||
MBIND_MOVE = 0,
|
MBIND_MOVE = 0,
|
||||||
MBIND_RESIZE
|
MBIND_RESIZE
|
||||||
};
|
};
|
||||||
|
|
||||||
struct STouchData {
|
struct STouchData {
|
||||||
CWindow* touchFocusWindow = nullptr;
|
CWindow* touchFocusWindow = nullptr;
|
||||||
SLayerSurface* touchFocusLS = nullptr;
|
SLayerSurface* touchFocusLS = nullptr;
|
||||||
wlr_surface* touchFocusSurface = nullptr;
|
wlr_surface* touchFocusSurface = nullptr;
|
||||||
Vector2D touchSurfaceOrigin;
|
Vector2D touchSurfaceOrigin;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CKeybindManager;
|
class CKeybindManager;
|
||||||
|
|
||||||
class CInputManager {
|
class CInputManager {
|
||||||
public:
|
public:
|
||||||
|
void onMouseMoved(wlr_pointer_motion_event*);
|
||||||
|
void onMouseWarp(wlr_pointer_motion_absolute_event*);
|
||||||
|
void onMouseButton(wlr_pointer_button_event*);
|
||||||
|
void onMouseWheel(wlr_pointer_axis_event*);
|
||||||
|
void onKeyboardKey(wlr_keyboard_key_event*, SKeyboard*);
|
||||||
|
void onKeyboardMod(void*, SKeyboard*);
|
||||||
|
|
||||||
void onMouseMoved(wlr_pointer_motion_event*);
|
void newKeyboard(wlr_input_device*);
|
||||||
void onMouseWarp(wlr_pointer_motion_absolute_event*);
|
void newVirtualKeyboard(wlr_input_device*);
|
||||||
void onMouseButton(wlr_pointer_button_event*);
|
void newMouse(wlr_input_device*, bool virt = false);
|
||||||
void onMouseWheel(wlr_pointer_axis_event*);
|
void newTouchDevice(wlr_input_device*);
|
||||||
void onKeyboardKey(wlr_keyboard_key_event*, SKeyboard*);
|
void newSwitch(wlr_input_device*);
|
||||||
void onKeyboardMod(void*, SKeyboard*);
|
void destroyTouchDevice(STouchDevice*);
|
||||||
|
void destroyKeyboard(SKeyboard*);
|
||||||
|
void destroyMouse(wlr_input_device*);
|
||||||
|
void destroySwitch(SSwitchDevice*);
|
||||||
|
|
||||||
void newKeyboard(wlr_input_device*);
|
void constrainMouse(SMouse*, wlr_pointer_constraint_v1*);
|
||||||
void newVirtualKeyboard(wlr_input_device*);
|
void recheckConstraint(SMouse*);
|
||||||
void newMouse(wlr_input_device*, bool virt = false);
|
void unconstrainMouse();
|
||||||
void newTouchDevice(wlr_input_device*);
|
SConstraint* constraintFromWlr(wlr_pointer_constraint_v1*);
|
||||||
void newSwitch(wlr_input_device*);
|
std::string getActiveLayoutForKeyboard(SKeyboard*);
|
||||||
void destroyTouchDevice(STouchDevice*);
|
|
||||||
void destroyKeyboard(SKeyboard*);
|
|
||||||
void destroyMouse(wlr_input_device*);
|
|
||||||
void destroySwitch(SSwitchDevice*);
|
|
||||||
|
|
||||||
void constrainMouse(SMouse*, wlr_pointer_constraint_v1*);
|
Vector2D getMouseCoordsInternal();
|
||||||
void recheckConstraint(SMouse*);
|
void refocus();
|
||||||
void unconstrainMouse();
|
|
||||||
SConstraint* constraintFromWlr(wlr_pointer_constraint_v1*);
|
|
||||||
std::string getActiveLayoutForKeyboard(SKeyboard*);
|
|
||||||
|
|
||||||
Vector2D getMouseCoordsInternal();
|
void setKeyboardLayout();
|
||||||
void refocus();
|
void setPointerConfigs();
|
||||||
|
void setTouchDeviceConfigs();
|
||||||
|
|
||||||
void setKeyboardLayout();
|
void updateDragIcon();
|
||||||
void setPointerConfigs();
|
void updateCapabilities();
|
||||||
void setTouchDeviceConfigs();
|
|
||||||
|
|
||||||
void updateDragIcon();
|
void setClickMode(eClickBehaviorMode);
|
||||||
void updateCapabilities();
|
|
||||||
|
|
||||||
void setClickMode(eClickBehaviorMode);
|
|
||||||
eClickBehaviorMode getClickMode();
|
eClickBehaviorMode getClickMode();
|
||||||
void processMouseRequest(wlr_seat_pointer_request_set_cursor_event*);
|
void processMouseRequest(wlr_seat_pointer_request_set_cursor_event*);
|
||||||
|
|
||||||
void onTouchDown(wlr_touch_down_event*);
|
void onTouchDown(wlr_touch_down_event*);
|
||||||
void onTouchUp(wlr_touch_up_event*);
|
void onTouchUp(wlr_touch_up_event*);
|
||||||
void onTouchMove(wlr_touch_motion_event*);
|
void onTouchMove(wlr_touch_motion_event*);
|
||||||
|
|
||||||
void onPointerHoldBegin(wlr_pointer_hold_begin_event*);
|
void onPointerHoldBegin(wlr_pointer_hold_begin_event*);
|
||||||
void onPointerHoldEnd(wlr_pointer_hold_end_event*);
|
void onPointerHoldEnd(wlr_pointer_hold_end_event*);
|
||||||
|
|
||||||
STouchData m_sTouchData;
|
STouchData m_sTouchData;
|
||||||
|
|
||||||
// for dragging floating windows
|
// for dragging floating windows
|
||||||
CWindow* currentlyDraggedWindow = nullptr;
|
CWindow* currentlyDraggedWindow = nullptr;
|
||||||
eMouseBindMode dragMode = MBIND_INVALID;
|
eMouseBindMode dragMode = MBIND_INVALID;
|
||||||
|
|
||||||
SDrag m_sDrag;
|
SDrag m_sDrag;
|
||||||
|
|
||||||
std::list<SConstraint> m_lConstraints;
|
std::list<SConstraint> m_lConstraints;
|
||||||
std::list<SKeyboard> m_lKeyboards;
|
std::list<SKeyboard> m_lKeyboards;
|
||||||
std::list<SMouse> m_lMice;
|
std::list<SMouse> m_lMice;
|
||||||
|
|
||||||
// tablets
|
// tablets
|
||||||
std::list<STablet> m_lTablets;
|
std::list<STablet> m_lTablets;
|
||||||
std::list<STabletTool> m_lTabletTools;
|
std::list<STabletTool> m_lTabletTools;
|
||||||
std::list<STabletPad> m_lTabletPads;
|
std::list<STabletPad> m_lTabletPads;
|
||||||
|
|
||||||
// idle inhibitors
|
// idle inhibitors
|
||||||
std::list<SIdleInhibitor> m_lIdleInhibitors;
|
std::list<SIdleInhibitor> m_lIdleInhibitors;
|
||||||
|
@ -100,73 +101,72 @@ public:
|
||||||
// Switches
|
// Switches
|
||||||
std::list<SSwitchDevice> m_lSwitches;
|
std::list<SSwitchDevice> m_lSwitches;
|
||||||
|
|
||||||
void newTabletTool(wlr_input_device*);
|
void newTabletTool(wlr_input_device*);
|
||||||
void newTabletPad(wlr_input_device*);
|
void newTabletPad(wlr_input_device*);
|
||||||
void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false);
|
void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false);
|
||||||
void newIdleInhibitor(wlr_idle_inhibitor_v1*);
|
void newIdleInhibitor(wlr_idle_inhibitor_v1*);
|
||||||
void recheckIdleInhibitorStatus();
|
void recheckIdleInhibitorStatus();
|
||||||
|
|
||||||
void onSwipeBegin(wlr_pointer_swipe_begin_event*);
|
void onSwipeBegin(wlr_pointer_swipe_begin_event*);
|
||||||
void onSwipeEnd(wlr_pointer_swipe_end_event*);
|
void onSwipeEnd(wlr_pointer_swipe_end_event*);
|
||||||
void onSwipeUpdate(wlr_pointer_swipe_update_event*);
|
void onSwipeUpdate(wlr_pointer_swipe_update_event*);
|
||||||
|
|
||||||
SSwipeGesture m_sActiveSwipe;
|
SSwipeGesture m_sActiveSwipe;
|
||||||
|
|
||||||
SKeyboard* m_pActiveKeyboard = nullptr;
|
SKeyboard* m_pActiveKeyboard = nullptr;
|
||||||
|
|
||||||
CTimer m_tmrLastCursorMovement;
|
CTimer m_tmrLastCursorMovement;
|
||||||
|
|
||||||
CInputMethodRelay m_sIMERelay;
|
CInputMethodRelay m_sIMERelay;
|
||||||
|
|
||||||
void updateKeyboardsLeds(wlr_input_device* pKeyboard);
|
void updateKeyboardsLeds(wlr_input_device* pKeyboard);
|
||||||
|
|
||||||
// for shared mods
|
// for shared mods
|
||||||
uint32_t accumulateModsFromAllKBs();
|
uint32_t accumulateModsFromAllKBs();
|
||||||
|
|
||||||
CWindow* m_pFollowOnDnDBegin = nullptr;
|
CWindow* m_pFollowOnDnDBegin = nullptr;
|
||||||
|
|
||||||
// for virtual keyboards: whether we should respect them as normal ones
|
// for virtual keyboards: whether we should respect them as normal ones
|
||||||
bool shouldIgnoreVirtualKeyboard(SKeyboard*);
|
bool shouldIgnoreVirtualKeyboard(SKeyboard*);
|
||||||
|
|
||||||
// for special cursors that we choose
|
// for special cursors that we choose
|
||||||
void setCursorImageUntilUnset(std::string);
|
void setCursorImageUntilUnset(std::string);
|
||||||
void unsetCursorImage();
|
void unsetCursorImage();
|
||||||
|
|
||||||
std::string deviceNameToInternalString(std::string);
|
std::string deviceNameToInternalString(std::string);
|
||||||
std::string getNameForNewDevice(std::string);
|
std::string getNameForNewDevice(std::string);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool m_bCursorImageOverriden = false;
|
||||||
bool m_bCursorImageOverriden = false;
|
|
||||||
|
|
||||||
// for click behavior override
|
// for click behavior override
|
||||||
eClickBehaviorMode m_ecbClickBehavior = CLICKMODE_DEFAULT;
|
eClickBehaviorMode m_ecbClickBehavior = CLICKMODE_DEFAULT;
|
||||||
bool m_bEmptyFocusCursorSet = false;
|
bool m_bEmptyFocusCursorSet = false;
|
||||||
Vector2D m_vLastCursorPosFloored = Vector2D();
|
Vector2D m_vLastCursorPosFloored = Vector2D();
|
||||||
|
|
||||||
// for some bugs in follow mouse 0
|
// for some bugs in follow mouse 0
|
||||||
bool m_bLastFocusOnLS = false;
|
bool m_bLastFocusOnLS = false;
|
||||||
|
|
||||||
void processMouseDownNormal(wlr_pointer_button_event* e);
|
void processMouseDownNormal(wlr_pointer_button_event* e);
|
||||||
void processMouseDownKill(wlr_pointer_button_event* e);
|
void processMouseDownKill(wlr_pointer_button_event* e);
|
||||||
|
|
||||||
void disableAllKeyboards(bool virt = false);
|
void disableAllKeyboards(bool virt = false);
|
||||||
|
|
||||||
uint32_t m_uiCapabilities = 0;
|
uint32_t m_uiCapabilities = 0;
|
||||||
|
|
||||||
void mouseMoveUnified(uint32_t, bool refocus = false);
|
void mouseMoveUnified(uint32_t, bool refocus = false);
|
||||||
|
|
||||||
STabletTool* ensureTabletToolPresent(wlr_tablet_tool*);
|
STabletTool* ensureTabletToolPresent(wlr_tablet_tool*);
|
||||||
|
|
||||||
void applyConfigToKeyboard(SKeyboard*);
|
void applyConfigToKeyboard(SKeyboard*);
|
||||||
|
|
||||||
// this will be set after a refocus()
|
// this will be set after a refocus()
|
||||||
wlr_surface* m_pFoundSurfaceToFocus = nullptr;
|
wlr_surface* m_pFoundSurfaceToFocus = nullptr;
|
||||||
SLayerSurface* m_pFoundLSToFocus = nullptr;
|
SLayerSurface* m_pFoundLSToFocus = nullptr;
|
||||||
CWindow* m_pFoundWindowToFocus = nullptr;
|
CWindow* m_pFoundWindowToFocus = nullptr;
|
||||||
|
|
||||||
// swipe
|
// swipe
|
||||||
void beginWorkspaceSwipe();
|
void beginWorkspaceSwipe();
|
||||||
|
|
||||||
friend class CKeybindManager;
|
friend class CKeybindManager;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "InputManager.hpp"
|
#include "InputManager.hpp"
|
||||||
#include "../../Compositor.hpp"
|
#include "../../Compositor.hpp"
|
||||||
|
|
||||||
CInputMethodRelay::CInputMethodRelay() { }
|
CInputMethodRelay::CInputMethodRelay() {}
|
||||||
|
|
||||||
void CInputMethodRelay::onNewIME(wlr_input_method_v2* pIME) {
|
void CInputMethodRelay::onNewIME(wlr_input_method_v2* pIME) {
|
||||||
if (m_pWLRIME) {
|
if (m_pWLRIME) {
|
||||||
|
@ -15,101 +15,107 @@ void CInputMethodRelay::onNewIME(wlr_input_method_v2* pIME) {
|
||||||
|
|
||||||
m_pWLRIME = pIME;
|
m_pWLRIME = pIME;
|
||||||
|
|
||||||
hyprListener_IMECommit.initCallback(&m_pWLRIME->events.commit, [&](void* owner, void* data) {
|
hyprListener_IMECommit.initCallback(
|
||||||
|
&m_pWLRIME->events.commit,
|
||||||
|
[&](void* owner, void* data) {
|
||||||
|
const auto PTI = getFocusedTextInput();
|
||||||
|
const auto PIMR = (CInputMethodRelay*)owner;
|
||||||
|
|
||||||
const auto PTI = getFocusedTextInput();
|
if (!PTI) {
|
||||||
const auto PIMR = (CInputMethodRelay*)owner;
|
Debug::log(LOG, "No focused TextInput on IME Commit");
|
||||||
|
return;
|
||||||
if (!PTI) {
|
|
||||||
Debug::log(LOG, "No focused TextInput on IME Commit");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PIMR->m_pWLRIME->current.preedit.text) {
|
|
||||||
wlr_text_input_v3_send_preedit_string(PTI->pWlrInput, PIMR->m_pWLRIME->current.preedit.text, PIMR->m_pWLRIME->current.preedit.cursor_begin, PIMR->m_pWLRIME->current.preedit.cursor_end);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PIMR->m_pWLRIME->current.commit_text) {
|
|
||||||
wlr_text_input_v3_send_commit_string(PTI->pWlrInput, PIMR->m_pWLRIME->current.commit_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PIMR->m_pWLRIME->current.delete_.before_length || PIMR->m_pWLRIME->current.delete_.after_length) {
|
|
||||||
wlr_text_input_v3_send_delete_surrounding_text(PTI->pWlrInput, PIMR->m_pWLRIME->current.delete_.before_length, PIMR->m_pWLRIME->current.delete_.after_length);
|
|
||||||
}
|
|
||||||
|
|
||||||
wlr_text_input_v3_send_done(PTI->pWlrInput);
|
|
||||||
|
|
||||||
}, this, "IMERelay");
|
|
||||||
|
|
||||||
hyprListener_IMEDestroy.initCallback(&m_pWLRIME->events.destroy, [&](void* owner, void* data) {
|
|
||||||
|
|
||||||
m_pWLRIME = nullptr;
|
|
||||||
|
|
||||||
hyprListener_IMEDestroy.removeCallback();
|
|
||||||
hyprListener_IMECommit.removeCallback();
|
|
||||||
hyprListener_IMEGrab.removeCallback();
|
|
||||||
hyprListener_IMENewPopup.removeCallback();
|
|
||||||
|
|
||||||
m_pKeyboardGrab.reset(nullptr);
|
|
||||||
|
|
||||||
const auto PTI = getFocusedTextInput();
|
|
||||||
|
|
||||||
Debug::log(LOG, "IME Destroy");
|
|
||||||
|
|
||||||
if (PTI) {
|
|
||||||
setPendingSurface(PTI, PTI->pWlrInput->focused_surface);
|
|
||||||
|
|
||||||
wlr_text_input_v3_send_leave(PTI->pWlrInput);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, this, "IMERelay");
|
|
||||||
|
|
||||||
hyprListener_IMEGrab.initCallback(&m_pWLRIME->events.grab_keyboard, [&](void* owner, void* data) {
|
|
||||||
|
|
||||||
Debug::log(LOG, "IME TextInput Keyboard Grab new");
|
|
||||||
|
|
||||||
m_pKeyboardGrab.reset(nullptr);
|
|
||||||
|
|
||||||
m_pKeyboardGrab = std::make_unique<SIMEKbGrab>();
|
|
||||||
|
|
||||||
m_pKeyboardGrab->pKeyboard = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
|
|
||||||
|
|
||||||
const auto PKBGRAB = (wlr_input_method_keyboard_grab_v2*)data;
|
|
||||||
|
|
||||||
m_pKeyboardGrab->pWlrKbGrab = PKBGRAB;
|
|
||||||
|
|
||||||
wlr_input_method_keyboard_grab_v2_set_keyboard(m_pKeyboardGrab->pWlrKbGrab, m_pKeyboardGrab->pKeyboard);
|
|
||||||
|
|
||||||
m_pKeyboardGrab->hyprListener_grabDestroy.initCallback(&PKBGRAB->events.destroy, [&](void* owner, void* data) {
|
|
||||||
|
|
||||||
m_pKeyboardGrab->hyprListener_grabDestroy.removeCallback();
|
|
||||||
|
|
||||||
Debug::log(LOG, "IME TextInput Keyboard Grab destroy");
|
|
||||||
|
|
||||||
if (m_pKeyboardGrab->pKeyboard) {
|
|
||||||
wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &m_pKeyboardGrab->pKeyboard->modifiers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (PIMR->m_pWLRIME->current.preedit.text) {
|
||||||
|
wlr_text_input_v3_send_preedit_string(PTI->pWlrInput, PIMR->m_pWLRIME->current.preedit.text, PIMR->m_pWLRIME->current.preedit.cursor_begin,
|
||||||
|
PIMR->m_pWLRIME->current.preedit.cursor_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PIMR->m_pWLRIME->current.commit_text) {
|
||||||
|
wlr_text_input_v3_send_commit_string(PTI->pWlrInput, PIMR->m_pWLRIME->current.commit_text);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PIMR->m_pWLRIME->current.delete_.before_length || PIMR->m_pWLRIME->current.delete_.after_length) {
|
||||||
|
wlr_text_input_v3_send_delete_surrounding_text(PTI->pWlrInput, PIMR->m_pWLRIME->current.delete_.before_length, PIMR->m_pWLRIME->current.delete_.after_length);
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_text_input_v3_send_done(PTI->pWlrInput);
|
||||||
|
},
|
||||||
|
this, "IMERelay");
|
||||||
|
|
||||||
|
hyprListener_IMEDestroy.initCallback(
|
||||||
|
&m_pWLRIME->events.destroy,
|
||||||
|
[&](void* owner, void* data) {
|
||||||
|
m_pWLRIME = nullptr;
|
||||||
|
|
||||||
|
hyprListener_IMEDestroy.removeCallback();
|
||||||
|
hyprListener_IMECommit.removeCallback();
|
||||||
|
hyprListener_IMEGrab.removeCallback();
|
||||||
|
hyprListener_IMENewPopup.removeCallback();
|
||||||
|
|
||||||
m_pKeyboardGrab.reset(nullptr);
|
m_pKeyboardGrab.reset(nullptr);
|
||||||
|
|
||||||
}, m_pKeyboardGrab.get(), "IME Keyboard Grab");
|
const auto PTI = getFocusedTextInput();
|
||||||
|
|
||||||
}, this, "IMERelay");
|
Debug::log(LOG, "IME Destroy");
|
||||||
|
|
||||||
hyprListener_IMENewPopup.initCallback(&m_pWLRIME->events.new_popup_surface, [&](void* owner, void* data) {
|
if (PTI) {
|
||||||
|
setPendingSurface(PTI, PTI->pWlrInput->focused_surface);
|
||||||
|
|
||||||
const auto PNEWPOPUP = &m_lIMEPopups.emplace_back();
|
wlr_text_input_v3_send_leave(PTI->pWlrInput);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
this, "IMERelay");
|
||||||
|
|
||||||
PNEWPOPUP->pSurface = (wlr_input_popup_surface_v2*)data;
|
hyprListener_IMEGrab.initCallback(
|
||||||
|
&m_pWLRIME->events.grab_keyboard,
|
||||||
|
[&](void* owner, void* data) {
|
||||||
|
Debug::log(LOG, "IME TextInput Keyboard Grab new");
|
||||||
|
|
||||||
PNEWPOPUP->hyprListener_commitPopup.initCallback(&PNEWPOPUP->pSurface->surface->events.commit, &Events::listener_commitInputPopup, PNEWPOPUP, "IME Popup");
|
m_pKeyboardGrab.reset(nullptr);
|
||||||
PNEWPOPUP->hyprListener_mapPopup.initCallback(&PNEWPOPUP->pSurface->events.map, &Events::listener_mapInputPopup, PNEWPOPUP, "IME Popup");
|
|
||||||
PNEWPOPUP->hyprListener_unmapPopup.initCallback(&PNEWPOPUP->pSurface->events.unmap, &Events::listener_unmapInputPopup, PNEWPOPUP, "IME Popup");
|
|
||||||
PNEWPOPUP->hyprListener_destroyPopup.initCallback(&PNEWPOPUP->pSurface->events.destroy, &Events::listener_destroyInputPopup, PNEWPOPUP, "IME Popup");
|
|
||||||
|
|
||||||
Debug::log(LOG, "New input popup");
|
m_pKeyboardGrab = std::make_unique<SIMEKbGrab>();
|
||||||
|
|
||||||
}, this, "IMERelay");
|
m_pKeyboardGrab->pKeyboard = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
|
||||||
|
|
||||||
|
const auto PKBGRAB = (wlr_input_method_keyboard_grab_v2*)data;
|
||||||
|
|
||||||
|
m_pKeyboardGrab->pWlrKbGrab = PKBGRAB;
|
||||||
|
|
||||||
|
wlr_input_method_keyboard_grab_v2_set_keyboard(m_pKeyboardGrab->pWlrKbGrab, m_pKeyboardGrab->pKeyboard);
|
||||||
|
|
||||||
|
m_pKeyboardGrab->hyprListener_grabDestroy.initCallback(
|
||||||
|
&PKBGRAB->events.destroy,
|
||||||
|
[&](void* owner, void* data) {
|
||||||
|
m_pKeyboardGrab->hyprListener_grabDestroy.removeCallback();
|
||||||
|
|
||||||
|
Debug::log(LOG, "IME TextInput Keyboard Grab destroy");
|
||||||
|
|
||||||
|
if (m_pKeyboardGrab->pKeyboard) {
|
||||||
|
wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &m_pKeyboardGrab->pKeyboard->modifiers);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pKeyboardGrab.reset(nullptr);
|
||||||
|
},
|
||||||
|
m_pKeyboardGrab.get(), "IME Keyboard Grab");
|
||||||
|
},
|
||||||
|
this, "IMERelay");
|
||||||
|
|
||||||
|
hyprListener_IMENewPopup.initCallback(
|
||||||
|
&m_pWLRIME->events.new_popup_surface,
|
||||||
|
[&](void* owner, void* data) {
|
||||||
|
const auto PNEWPOPUP = &m_lIMEPopups.emplace_back();
|
||||||
|
|
||||||
|
PNEWPOPUP->pSurface = (wlr_input_popup_surface_v2*)data;
|
||||||
|
|
||||||
|
PNEWPOPUP->hyprListener_commitPopup.initCallback(&PNEWPOPUP->pSurface->surface->events.commit, &Events::listener_commitInputPopup, PNEWPOPUP, "IME Popup");
|
||||||
|
PNEWPOPUP->hyprListener_mapPopup.initCallback(&PNEWPOPUP->pSurface->events.map, &Events::listener_mapInputPopup, PNEWPOPUP, "IME Popup");
|
||||||
|
PNEWPOPUP->hyprListener_unmapPopup.initCallback(&PNEWPOPUP->pSurface->events.unmap, &Events::listener_unmapInputPopup, PNEWPOPUP, "IME Popup");
|
||||||
|
PNEWPOPUP->hyprListener_destroyPopup.initCallback(&PNEWPOPUP->pSurface->events.destroy, &Events::listener_destroyInputPopup, PNEWPOPUP, "IME Popup");
|
||||||
|
|
||||||
|
Debug::log(LOG, "New input popup");
|
||||||
|
},
|
||||||
|
this, "IMERelay");
|
||||||
|
|
||||||
const auto PTI = getFocusableTextInput();
|
const auto PTI = getFocusableTextInput();
|
||||||
|
|
||||||
|
@ -131,25 +137,25 @@ void CInputMethodRelay::updateInputPopup(SIMEPopup* pPopup) {
|
||||||
if (!PFOCUSEDTI || !PFOCUSEDTI->pWlrInput->focused_surface)
|
if (!PFOCUSEDTI || !PFOCUSEDTI->pWlrInput->focused_surface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool cursorRect = PFOCUSEDTI->pWlrInput->current.features & WLR_TEXT_INPUT_V3_FEATURE_CURSOR_RECTANGLE;
|
bool cursorRect = PFOCUSEDTI->pWlrInput->current.features & WLR_TEXT_INPUT_V3_FEATURE_CURSOR_RECTANGLE;
|
||||||
const auto PFOCUSEDSURFACE = PFOCUSEDTI->pWlrInput->focused_surface;
|
const auto PFOCUSEDSURFACE = PFOCUSEDTI->pWlrInput->focused_surface;
|
||||||
auto cursorBox = PFOCUSEDTI->pWlrInput->current.cursor_rectangle;
|
auto cursorBox = PFOCUSEDTI->pWlrInput->current.cursor_rectangle;
|
||||||
|
|
||||||
Vector2D parentPos;
|
Vector2D parentPos;
|
||||||
Vector2D parentSize;
|
Vector2D parentSize;
|
||||||
|
|
||||||
if (wlr_surface_is_layer_surface(PFOCUSEDSURFACE)) {
|
if (wlr_surface_is_layer_surface(PFOCUSEDSURFACE)) {
|
||||||
const auto PLS = g_pCompositor->getLayerSurfaceFromWlr(wlr_layer_surface_v1_from_wlr_surface(PFOCUSEDSURFACE));
|
const auto PLS = g_pCompositor->getLayerSurfaceFromWlr(wlr_layer_surface_v1_from_wlr_surface(PFOCUSEDSURFACE));
|
||||||
|
|
||||||
if (PLS) {
|
if (PLS) {
|
||||||
parentPos = Vector2D(PLS->geometry.x, PLS->geometry.y) + g_pCompositor->getMonitorFromID(PLS->monitorID)->vecPosition;
|
parentPos = Vector2D(PLS->geometry.x, PLS->geometry.y) + g_pCompositor->getMonitorFromID(PLS->monitorID)->vecPosition;
|
||||||
parentSize = Vector2D(PLS->geometry.width, PLS->geometry.height);
|
parentSize = Vector2D(PLS->geometry.width, PLS->geometry.height);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const auto PWINDOW = g_pCompositor->getWindowFromSurface(PFOCUSEDSURFACE);
|
const auto PWINDOW = g_pCompositor->getWindowFromSurface(PFOCUSEDSURFACE);
|
||||||
|
|
||||||
if (PWINDOW) {
|
if (PWINDOW) {
|
||||||
parentPos = PWINDOW->m_vRealPosition.goalv();
|
parentPos = PWINDOW->m_vRealPosition.goalv();
|
||||||
parentSize = PWINDOW->m_vRealSize.goalv();
|
parentSize = PWINDOW->m_vRealSize.goalv();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +236,7 @@ void CInputMethodRelay::damagePopup(SIMEPopup* pPopup) {
|
||||||
if (!PFOCUSEDTI || !PFOCUSEDTI->pWlrInput->focused_surface)
|
if (!PFOCUSEDTI || !PFOCUSEDTI->pWlrInput->focused_surface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Vector2D parentPos;
|
Vector2D parentPos;
|
||||||
|
|
||||||
const auto PFOCUSEDSURFACE = PFOCUSEDTI->pWlrInput->focused_surface;
|
const auto PFOCUSEDSURFACE = PFOCUSEDTI->pWlrInput->focused_surface;
|
||||||
|
|
||||||
|
@ -296,82 +302,86 @@ void CInputMethodRelay::createNewTextInput(wlr_text_input_v3* pInput) {
|
||||||
|
|
||||||
PTEXTINPUT->pWlrInput = pInput;
|
PTEXTINPUT->pWlrInput = pInput;
|
||||||
|
|
||||||
PTEXTINPUT->hyprListener_textInputEnable.initCallback(&pInput->events.enable, [](void* owner, void* data) {
|
PTEXTINPUT->hyprListener_textInputEnable.initCallback(
|
||||||
|
&pInput->events.enable,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto PINPUT = (STextInput*)owner;
|
||||||
|
|
||||||
const auto PINPUT = (STextInput*)owner;
|
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
|
||||||
|
// Debug::log(WARN, "Enabling TextInput on no IME!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
|
Debug::log(LOG, "Enable TextInput");
|
||||||
// Debug::log(WARN, "Enabling TextInput on no IME!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug::log(LOG, "Enable TextInput");
|
wlr_input_method_v2_send_activate(g_pInputManager->m_sIMERelay.m_pWLRIME);
|
||||||
|
g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
|
||||||
|
},
|
||||||
|
PTEXTINPUT, "textInput");
|
||||||
|
|
||||||
wlr_input_method_v2_send_activate(g_pInputManager->m_sIMERelay.m_pWLRIME);
|
PTEXTINPUT->hyprListener_textInputCommit.initCallback(
|
||||||
g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
|
&pInput->events.commit,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto PINPUT = (STextInput*)owner;
|
||||||
|
|
||||||
}, PTEXTINPUT, "textInput");
|
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
|
||||||
|
// Debug::log(WARN, "Committing TextInput on no IME!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PTEXTINPUT->hyprListener_textInputCommit.initCallback(&pInput->events.commit, [](void* owner, void* data) {
|
if (!PINPUT->pWlrInput->current_enabled) {
|
||||||
|
Debug::log(WARN, "Disabled TextInput commit?");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const auto PINPUT = (STextInput*)owner;
|
g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
|
||||||
|
},
|
||||||
|
PTEXTINPUT, "textInput");
|
||||||
|
|
||||||
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
|
PTEXTINPUT->hyprListener_textInputDisable.initCallback(
|
||||||
// Debug::log(WARN, "Committing TextInput on no IME!");
|
&pInput->events.disable,
|
||||||
return;
|
[](void* owner, void* data) {
|
||||||
}
|
const auto PINPUT = (STextInput*)owner;
|
||||||
|
|
||||||
if (!PINPUT->pWlrInput->current_enabled) {
|
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
|
||||||
Debug::log(WARN, "Disabled TextInput commit?");
|
// Debug::log(WARN, "Disabling TextInput on no IME!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
|
Debug::log(LOG, "Disable TextInput");
|
||||||
|
|
||||||
}, PTEXTINPUT, "textInput");
|
|
||||||
|
|
||||||
PTEXTINPUT->hyprListener_textInputDisable.initCallback(&pInput->events.disable, [](void* owner, void* data) {
|
|
||||||
|
|
||||||
const auto PINPUT = (STextInput*)owner;
|
|
||||||
|
|
||||||
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
|
|
||||||
// Debug::log(WARN, "Disabling TextInput on no IME!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug::log(LOG, "Disable TextInput");
|
|
||||||
|
|
||||||
wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
|
|
||||||
|
|
||||||
g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
|
|
||||||
|
|
||||||
}, PTEXTINPUT, "textInput");
|
|
||||||
|
|
||||||
PTEXTINPUT->hyprListener_textInputDestroy.initCallback(&pInput->events.destroy, [](void* owner, void* data) {
|
|
||||||
|
|
||||||
const auto PINPUT = (STextInput*)owner;
|
|
||||||
|
|
||||||
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
|
|
||||||
// Debug::log(WARN, "Disabling TextInput on no IME!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PINPUT->pWlrInput->current_enabled) {
|
|
||||||
wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
|
wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
|
||||||
|
|
||||||
g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
|
g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
|
||||||
}
|
},
|
||||||
|
PTEXTINPUT, "textInput");
|
||||||
|
|
||||||
g_pInputManager->m_sIMERelay.setPendingSurface(PINPUT, nullptr);
|
PTEXTINPUT->hyprListener_textInputDestroy.initCallback(
|
||||||
|
&pInput->events.destroy,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto PINPUT = (STextInput*)owner;
|
||||||
|
|
||||||
PINPUT->hyprListener_textInputCommit.removeCallback();
|
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
|
||||||
PINPUT->hyprListener_textInputDestroy.removeCallback();
|
// Debug::log(WARN, "Disabling TextInput on no IME!");
|
||||||
PINPUT->hyprListener_textInputDisable.removeCallback();
|
return;
|
||||||
PINPUT->hyprListener_textInputEnable.removeCallback();
|
}
|
||||||
|
|
||||||
g_pInputManager->m_sIMERelay.removeTextInput(PINPUT->pWlrInput);
|
if (PINPUT->pWlrInput->current_enabled) {
|
||||||
|
wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
|
||||||
|
|
||||||
}, PTEXTINPUT, "textInput");
|
g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_pInputManager->m_sIMERelay.setPendingSurface(PINPUT, nullptr);
|
||||||
|
|
||||||
|
PINPUT->hyprListener_textInputCommit.removeCallback();
|
||||||
|
PINPUT->hyprListener_textInputDestroy.removeCallback();
|
||||||
|
PINPUT->hyprListener_textInputDisable.removeCallback();
|
||||||
|
PINPUT->hyprListener_textInputEnable.removeCallback();
|
||||||
|
|
||||||
|
g_pInputManager->m_sIMERelay.removeTextInput(PINPUT->pWlrInput);
|
||||||
|
},
|
||||||
|
PTEXTINPUT, "textInput");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputMethodRelay::removeTextInput(wlr_text_input_v3* pInput) {
|
void CInputMethodRelay::removeTextInput(wlr_text_input_v3* pInput) {
|
||||||
|
@ -417,7 +427,6 @@ void CInputMethodRelay::onKeyboardFocus(wlr_surface* pSurface) {
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSurface && wl_resource_get_client(ti.pWlrInput->resource) == wl_resource_get_client(pSurface->resource)) {
|
if (pSurface && wl_resource_get_client(ti.pWlrInput->resource) == wl_resource_get_client(pSurface->resource)) {
|
||||||
|
@ -427,7 +436,6 @@ void CInputMethodRelay::onKeyboardFocus(wlr_surface* pSurface) {
|
||||||
} else {
|
} else {
|
||||||
setPendingSurface(&ti, pSurface);
|
setPendingSurface(&ti, pSurface);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -436,13 +444,16 @@ void CInputMethodRelay::setPendingSurface(STextInput* pInput, wlr_surface* pSurf
|
||||||
pInput->pPendingSurface = pSurface;
|
pInput->pPendingSurface = pSurface;
|
||||||
|
|
||||||
if (pSurface) {
|
if (pSurface) {
|
||||||
pInput->hyprListener_pendingSurfaceDestroy.initCallback(&pSurface->events.destroy, [](void* owner, void* data) {
|
pInput->hyprListener_pendingSurfaceDestroy.initCallback(
|
||||||
const auto PINPUT = (STextInput*)owner;
|
&pSurface->events.destroy,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto PINPUT = (STextInput*)owner;
|
||||||
|
|
||||||
PINPUT->pPendingSurface = nullptr;
|
PINPUT->pPendingSurface = nullptr;
|
||||||
|
|
||||||
PINPUT->hyprListener_pendingSurfaceDestroy.removeCallback();
|
PINPUT->hyprListener_pendingSurfaceDestroy.removeCallback();
|
||||||
}, pInput, "TextInput");
|
},
|
||||||
|
pInput, "TextInput");
|
||||||
} else {
|
} else {
|
||||||
pInput->hyprListener_pendingSurfaceDestroy.removeCallback();
|
pInput->hyprListener_pendingSurfaceDestroy.removeCallback();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,37 +6,36 @@
|
||||||
class CInputManager;
|
class CInputManager;
|
||||||
|
|
||||||
class CInputMethodRelay {
|
class CInputMethodRelay {
|
||||||
public:
|
public:
|
||||||
CInputMethodRelay();
|
CInputMethodRelay();
|
||||||
|
|
||||||
void onNewIME(wlr_input_method_v2*);
|
void onNewIME(wlr_input_method_v2*);
|
||||||
void onNewTextInput(wlr_text_input_v3*);
|
void onNewTextInput(wlr_text_input_v3*);
|
||||||
|
|
||||||
wlr_input_method_v2* m_pWLRIME = nullptr;
|
wlr_input_method_v2* m_pWLRIME = nullptr;
|
||||||
|
|
||||||
void commitIMEState(wlr_text_input_v3*);
|
void commitIMEState(wlr_text_input_v3*);
|
||||||
void removeTextInput(wlr_text_input_v3*);
|
void removeTextInput(wlr_text_input_v3*);
|
||||||
|
|
||||||
void onKeyboardFocus(wlr_surface*);
|
void onKeyboardFocus(wlr_surface*);
|
||||||
|
|
||||||
STextInput* getFocusedTextInput();
|
STextInput* getFocusedTextInput();
|
||||||
STextInput* getFocusableTextInput();
|
STextInput* getFocusableTextInput();
|
||||||
|
|
||||||
void setPendingSurface(STextInput*, wlr_surface*);
|
void setPendingSurface(STextInput*, wlr_surface*);
|
||||||
|
|
||||||
SIMEKbGrab* getIMEKeyboardGrab(SKeyboard*);
|
SIMEKbGrab* getIMEKeyboardGrab(SKeyboard*);
|
||||||
|
|
||||||
void setIMEPopupFocus(SIMEPopup*, wlr_surface*);
|
void setIMEPopupFocus(SIMEPopup*, wlr_surface*);
|
||||||
void updateInputPopup(SIMEPopup*);
|
void updateInputPopup(SIMEPopup*);
|
||||||
void damagePopup(SIMEPopup*);
|
void damagePopup(SIMEPopup*);
|
||||||
void removePopup(SIMEPopup*);
|
void removePopup(SIMEPopup*);
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
|
private:
|
||||||
std::unique_ptr<SIMEKbGrab> m_pKeyboardGrab;
|
std::unique_ptr<SIMEKbGrab> m_pKeyboardGrab;
|
||||||
|
|
||||||
std::list<STextInput> m_lTextInputs;
|
std::list<STextInput> m_lTextInputs;
|
||||||
std::list<SIMEPopup> m_lIMEPopups;
|
std::list<SIMEPopup> m_lIMEPopups;
|
||||||
|
|
||||||
DYNLISTENER(textInputNew);
|
DYNLISTENER(textInputNew);
|
||||||
DYNLISTENER(IMECommit);
|
DYNLISTENER(IMECommit);
|
||||||
|
@ -44,7 +43,7 @@ private:
|
||||||
DYNLISTENER(IMEGrab);
|
DYNLISTENER(IMEGrab);
|
||||||
DYNLISTENER(IMENewPopup);
|
DYNLISTENER(IMENewPopup);
|
||||||
|
|
||||||
void createNewTextInput(wlr_text_input_v3*);
|
void createNewTextInput(wlr_text_input_v3*);
|
||||||
|
|
||||||
friend class CHyprRenderer;
|
friend class CHyprRenderer;
|
||||||
friend class CInputManager;
|
friend class CInputManager;
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#include "../../Compositor.hpp"
|
#include "../../Compositor.hpp"
|
||||||
|
|
||||||
void CInputManager::onSwipeBegin(wlr_pointer_swipe_begin_event* e) {
|
void CInputManager::onSwipeBegin(wlr_pointer_swipe_begin_event* e) {
|
||||||
static auto *const PSWIPE = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe")->intValue;
|
static auto* const PSWIPE = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe")->intValue;
|
||||||
static auto *const PSWIPEFINGERS = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_fingers")->intValue;
|
static auto* const PSWIPEFINGERS = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_fingers")->intValue;
|
||||||
static auto *const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
|
static auto* const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
|
||||||
|
|
||||||
if (e->fingers != *PSWIPEFINGERS || *PSWIPE == 0)
|
if (e->fingers != *PSWIPEFINGERS || *PSWIPE == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -28,10 +28,10 @@ void CInputManager::beginWorkspaceSwipe() {
|
||||||
Debug::log(LOG, "Starting a swipe from %s", PWORKSPACE->m_szName.c_str());
|
Debug::log(LOG, "Starting a swipe from %s", PWORKSPACE->m_szName.c_str());
|
||||||
|
|
||||||
m_sActiveSwipe.pWorkspaceBegin = PWORKSPACE;
|
m_sActiveSwipe.pWorkspaceBegin = PWORKSPACE;
|
||||||
m_sActiveSwipe.delta = 0;
|
m_sActiveSwipe.delta = 0;
|
||||||
m_sActiveSwipe.pMonitor = g_pCompositor->m_pLastMonitor;
|
m_sActiveSwipe.pMonitor = g_pCompositor->m_pLastMonitor;
|
||||||
m_sActiveSwipe.avgSpeed = 0;
|
m_sActiveSwipe.avgSpeed = 0;
|
||||||
m_sActiveSwipe.speedPoints = 0;
|
m_sActiveSwipe.speedPoints = 0;
|
||||||
|
|
||||||
if (PWORKSPACE->m_bHasFullscreenWindow) {
|
if (PWORKSPACE->m_bHasFullscreenWindow) {
|
||||||
for (auto& ls : g_pCompositor->m_pLastMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
|
for (auto& ls : g_pCompositor->m_pLastMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
|
||||||
|
@ -44,35 +44,37 @@ void CInputManager::onSwipeEnd(wlr_pointer_swipe_end_event* e) {
|
||||||
if (!m_sActiveSwipe.pWorkspaceBegin)
|
if (!m_sActiveSwipe.pWorkspaceBegin)
|
||||||
return; // no valid swipe
|
return; // no valid swipe
|
||||||
|
|
||||||
static auto *const PSWIPEPERC = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_cancel_ratio")->floatValue;
|
static auto* const PSWIPEPERC = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_cancel_ratio")->floatValue;
|
||||||
static auto *const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue;
|
static auto* const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue;
|
||||||
static auto *const PSWIPEFORC = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_min_speed_to_force")->intValue;
|
static auto* const PSWIPEFORC = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_min_speed_to_force")->intValue;
|
||||||
static auto *const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
|
static auto* const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
|
||||||
const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert";
|
const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert";
|
||||||
|
|
||||||
// commit
|
// commit
|
||||||
std::string wsname = "";
|
std::string wsname = "";
|
||||||
auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname);
|
auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname);
|
||||||
auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname);
|
auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname);
|
||||||
|
|
||||||
if ((workspaceIDRight <= m_sActiveSwipe.pWorkspaceBegin->m_iID || (workspaceIDRight == workspaceIDLeft && workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID)) && *PSWIPENEW) {
|
if ((workspaceIDRight <= m_sActiveSwipe.pWorkspaceBegin->m_iID || (workspaceIDRight == workspaceIDLeft && workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID)) &&
|
||||||
|
*PSWIPENEW) {
|
||||||
workspaceIDRight = m_sActiveSwipe.pWorkspaceBegin->m_iID > 0 ? m_sActiveSwipe.pWorkspaceBegin->m_iID + 1 : 1;
|
workspaceIDRight = m_sActiveSwipe.pWorkspaceBegin->m_iID > 0 ? m_sActiveSwipe.pWorkspaceBegin->m_iID + 1 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); // not guaranteed if PSWIPENEW
|
auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); // not guaranteed if PSWIPENEW
|
||||||
const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
|
const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
|
||||||
|
|
||||||
const auto RENDEROFFSETMIDDLE = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.vec();
|
const auto RENDEROFFSETMIDDLE = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.vec();
|
||||||
|
|
||||||
CWorkspace* pSwitchedTo = nullptr;
|
CWorkspace* pSwitchedTo = nullptr;
|
||||||
|
|
||||||
if ((abs(m_sActiveSwipe.delta) < *PSWIPEDIST * *PSWIPEPERC && (*PSWIPEFORC == 0 || (*PSWIPEFORC != 0 && m_sActiveSwipe.avgSpeed < *PSWIPEFORC))) || abs(m_sActiveSwipe.delta) < 2) {
|
if ((abs(m_sActiveSwipe.delta) < *PSWIPEDIST * *PSWIPEPERC && (*PSWIPEFORC == 0 || (*PSWIPEFORC != 0 && m_sActiveSwipe.avgSpeed < *PSWIPEFORC))) ||
|
||||||
|
abs(m_sActiveSwipe.delta) < 2) {
|
||||||
// revert
|
// revert
|
||||||
if (abs(m_sActiveSwipe.delta) < 2) {
|
if (abs(m_sActiveSwipe.delta) < 2) {
|
||||||
PWORKSPACEL->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
|
PWORKSPACEL->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
||||||
if (PWORKSPACER)
|
if (PWORKSPACER)
|
||||||
PWORKSPACER->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
|
PWORKSPACER->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
||||||
} else {
|
} else {
|
||||||
if (m_sActiveSwipe.delta < 0) {
|
if (m_sActiveSwipe.delta < 0) {
|
||||||
// to left
|
// to left
|
||||||
|
@ -163,21 +165,21 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
|
||||||
if (!m_sActiveSwipe.pWorkspaceBegin)
|
if (!m_sActiveSwipe.pWorkspaceBegin)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static auto *const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue;
|
static auto* const PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->intValue;
|
||||||
static auto *const PSWIPEINVR = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_invert")->intValue;
|
static auto* const PSWIPEINVR = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_invert")->intValue;
|
||||||
static auto *const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
|
static auto* const PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
|
||||||
static auto *const PSWIPEFOREVER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_forever")->intValue;
|
static auto* const PSWIPEFOREVER = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_forever")->intValue;
|
||||||
|
|
||||||
const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert";
|
const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert";
|
||||||
|
|
||||||
m_sActiveSwipe.delta += VERTANIMS ? (*PSWIPEINVR ? -e->dy : e->dy) : (*PSWIPEINVR ? -e->dx : e->dx);
|
m_sActiveSwipe.delta += VERTANIMS ? (*PSWIPEINVR ? -e->dy : e->dy) : (*PSWIPEINVR ? -e->dx : e->dx);
|
||||||
|
|
||||||
m_sActiveSwipe.avgSpeed = (m_sActiveSwipe.avgSpeed * m_sActiveSwipe.speedPoints + abs(e->dx)) / (m_sActiveSwipe.speedPoints + 1);
|
m_sActiveSwipe.avgSpeed = (m_sActiveSwipe.avgSpeed * m_sActiveSwipe.speedPoints + abs(e->dx)) / (m_sActiveSwipe.speedPoints + 1);
|
||||||
m_sActiveSwipe.speedPoints++;
|
m_sActiveSwipe.speedPoints++;
|
||||||
|
|
||||||
std::string wsname = "";
|
std::string wsname = "";
|
||||||
auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname);
|
auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname);
|
||||||
auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname);
|
auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname);
|
||||||
|
|
||||||
if ((workspaceIDLeft == INT_MAX || workspaceIDRight == INT_MAX || workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID) && !*PSWIPENEW) {
|
if ((workspaceIDLeft == INT_MAX || workspaceIDRight == INT_MAX || workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID) && !*PSWIPENEW) {
|
||||||
m_sActiveSwipe.pWorkspaceBegin = nullptr; // invalidate the swipe
|
m_sActiveSwipe.pWorkspaceBegin = nullptr; // invalidate the swipe
|
||||||
|
@ -189,7 +191,8 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
|
||||||
m_sActiveSwipe.delta = std::clamp(m_sActiveSwipe.delta, (double)-*PSWIPEDIST, (double)*PSWIPEDIST);
|
m_sActiveSwipe.delta = std::clamp(m_sActiveSwipe.delta, (double)-*PSWIPEDIST, (double)*PSWIPEDIST);
|
||||||
|
|
||||||
if ((m_sActiveSwipe.pWorkspaceBegin->m_iID == workspaceIDLeft && *PSWIPENEW && (m_sActiveSwipe.delta < 0)) ||
|
if ((m_sActiveSwipe.pWorkspaceBegin->m_iID == workspaceIDLeft && *PSWIPENEW && (m_sActiveSwipe.delta < 0)) ||
|
||||||
(m_sActiveSwipe.delta > 0 && g_pCompositor->getWindowsOnWorkspace(m_sActiveSwipe.pWorkspaceBegin->m_iID) == 0 && workspaceIDRight <= m_sActiveSwipe.pWorkspaceBegin->m_iID) ||
|
(m_sActiveSwipe.delta > 0 && g_pCompositor->getWindowsOnWorkspace(m_sActiveSwipe.pWorkspaceBegin->m_iID) == 0 &&
|
||||||
|
workspaceIDRight <= m_sActiveSwipe.pWorkspaceBegin->m_iID) ||
|
||||||
(m_sActiveSwipe.delta < 0 && m_sActiveSwipe.pWorkspaceBegin->m_iID <= workspaceIDLeft)) {
|
(m_sActiveSwipe.delta < 0 && m_sActiveSwipe.pWorkspaceBegin->m_iID <= workspaceIDLeft)) {
|
||||||
|
|
||||||
m_sActiveSwipe.delta = 0;
|
m_sActiveSwipe.delta = 0;
|
||||||
|
@ -197,7 +200,7 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_sActiveSwipe.delta < 0) {
|
if (m_sActiveSwipe.delta < 0) {
|
||||||
if (workspaceIDLeft > m_sActiveSwipe.pWorkspaceBegin->m_iID && !*PSWIPENEW){
|
if (workspaceIDLeft > m_sActiveSwipe.pWorkspaceBegin->m_iID && !*PSWIPENEW) {
|
||||||
m_sActiveSwipe.delta = 0;
|
m_sActiveSwipe.delta = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -215,10 +218,12 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VERTANIMS) {
|
if (VERTANIMS) {
|
||||||
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y - m_sActiveSwipe.pMonitor->vecSize.y));
|
PWORKSPACE->m_vRenderOffset.setValueAndWarp(
|
||||||
|
Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y - m_sActiveSwipe.pMonitor->vecSize.y));
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y));
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y));
|
||||||
} else {
|
} else {
|
||||||
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x - m_sActiveSwipe.pMonitor->vecSize.x, 0));
|
PWORKSPACE->m_vRenderOffset.setValueAndWarp(
|
||||||
|
Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x - m_sActiveSwipe.pMonitor->vecSize.x, 0));
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x, 0));
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,10 +258,12 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (VERTANIMS) {
|
if (VERTANIMS) {
|
||||||
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y + m_sActiveSwipe.pMonitor->vecSize.y));
|
PWORKSPACE->m_vRenderOffset.setValueAndWarp(
|
||||||
|
Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y + m_sActiveSwipe.pMonitor->vecSize.y));
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y));
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, ((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.y));
|
||||||
} else {
|
} else {
|
||||||
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x + m_sActiveSwipe.pMonitor->vecSize.x, 0));
|
PWORKSPACE->m_vRenderOffset.setValueAndWarp(
|
||||||
|
Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x + m_sActiveSwipe.pMonitor->vecSize.x, 0));
|
||||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x, 0));
|
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(((-m_sActiveSwipe.delta) / *PSWIPEDIST) * m_sActiveSwipe.pMonitor->vecSize.x, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,127 +7,136 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
|
||||||
try {
|
try {
|
||||||
PNEWTABLET->name = deviceNameToInternalString(pDevice->name);
|
PNEWTABLET->name = deviceNameToInternalString(pDevice->name);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
Debug::log(ERR, "Tablet had no name???"); // logic error
|
Debug::log(ERR, "Tablet had no name???"); // logic error
|
||||||
}
|
}
|
||||||
|
|
||||||
PNEWTABLET->wlrTablet = wlr_tablet_from_input_device(pDevice);
|
PNEWTABLET->wlrTablet = wlr_tablet_from_input_device(pDevice);
|
||||||
PNEWTABLET->wlrDevice = pDevice;
|
PNEWTABLET->wlrDevice = pDevice;
|
||||||
PNEWTABLET->wlrTabletV2 = wlr_tablet_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pDevice);
|
PNEWTABLET->wlrTabletV2 = wlr_tablet_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pDevice);
|
||||||
PNEWTABLET->wlrTablet->data = PNEWTABLET;
|
PNEWTABLET->wlrTablet->data = PNEWTABLET;
|
||||||
|
|
||||||
Debug::log(LOG, "Attaching tablet to cursor!");
|
Debug::log(LOG, "Attaching tablet to cursor!");
|
||||||
|
|
||||||
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, pDevice);
|
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, pDevice);
|
||||||
|
|
||||||
PNEWTABLET->hyprListener_Destroy.initCallback(&pDevice->events.destroy, [](void* owner, void* data) {
|
PNEWTABLET->hyprListener_Destroy.initCallback(
|
||||||
const auto PTAB = (STablet*)owner;
|
&pDevice->events.destroy,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto PTAB = (STablet*)owner;
|
||||||
|
|
||||||
g_pInputManager->m_lTablets.remove(*PTAB);
|
g_pInputManager->m_lTablets.remove(*PTAB);
|
||||||
|
|
||||||
Debug::log(LOG, "Removed a tablet");
|
Debug::log(LOG, "Removed a tablet");
|
||||||
}, PNEWTABLET, "Tablet");
|
},
|
||||||
|
PNEWTABLET, "Tablet");
|
||||||
|
|
||||||
PNEWTABLET->hyprListener_Axis.initCallback(&wlr_tablet_from_input_device(pDevice)->events.axis, [](void* owner, void* data) {
|
PNEWTABLET->hyprListener_Axis.initCallback(
|
||||||
|
&wlr_tablet_from_input_device(pDevice)->events.axis,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto EVENT = (wlr_tablet_tool_axis_event*)data;
|
||||||
|
const auto PTAB = (STablet*)owner;
|
||||||
|
|
||||||
const auto EVENT = (wlr_tablet_tool_axis_event*)data;
|
switch (EVENT->tool->type) {
|
||||||
const auto PTAB = (STablet*)owner;
|
case WLR_TABLET_TOOL_TYPE_MOUSE:
|
||||||
|
wlr_cursor_move(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, EVENT->dx, EVENT->dy);
|
||||||
switch (EVENT->tool->type) {
|
g_pInputManager->refocus();
|
||||||
case WLR_TABLET_TOOL_TYPE_MOUSE:
|
break;
|
||||||
wlr_cursor_move(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, EVENT->dx, EVENT->dy);
|
default:
|
||||||
g_pInputManager->refocus();
|
double x = (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_X) ? EVENT->x : NAN;
|
||||||
break;
|
double y = (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_Y) ? EVENT->y : NAN;
|
||||||
default:
|
wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, x, y);
|
||||||
double x = (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_X) ? EVENT->x : NAN;
|
g_pInputManager->refocus();
|
||||||
double y = (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_Y) ? EVENT->y : NAN;
|
break;
|
||||||
wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, x, y);
|
|
||||||
g_pInputManager->refocus();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
|
|
||||||
|
|
||||||
// TODO: this might be wrong
|
|
||||||
if (PTOOL->active) {
|
|
||||||
g_pInputManager->refocus();
|
|
||||||
|
|
||||||
g_pInputManager->focusTablet(PTAB, EVENT->tool, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_PRESSURE)
|
|
||||||
wlr_tablet_v2_tablet_tool_notify_pressure(PTOOL->wlrTabletToolV2, EVENT->pressure);
|
|
||||||
|
|
||||||
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_DISTANCE)
|
|
||||||
wlr_tablet_v2_tablet_tool_notify_distance(PTOOL->wlrTabletToolV2, EVENT->distance);
|
|
||||||
|
|
||||||
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_ROTATION)
|
|
||||||
wlr_tablet_v2_tablet_tool_notify_rotation(PTOOL->wlrTabletToolV2, EVENT->rotation);
|
|
||||||
|
|
||||||
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_SLIDER)
|
|
||||||
wlr_tablet_v2_tablet_tool_notify_slider(PTOOL->wlrTabletToolV2, EVENT->slider);
|
|
||||||
|
|
||||||
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_WHEEL)
|
|
||||||
wlr_tablet_v2_tablet_tool_notify_wheel(PTOOL->wlrTabletToolV2, EVENT->wheel_delta, 0);
|
|
||||||
|
|
||||||
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_X)
|
|
||||||
PTOOL->tiltX = EVENT->tilt_x;
|
|
||||||
|
|
||||||
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_Y)
|
|
||||||
PTOOL->tiltY = EVENT->tilt_y;
|
|
||||||
|
|
||||||
if (EVENT->updated_axes & (WLR_TABLET_TOOL_AXIS_TILT_X | WLR_TABLET_TOOL_AXIS_TILT_Y))
|
|
||||||
wlr_tablet_v2_tablet_tool_notify_tilt(PTOOL->wlrTabletToolV2, PTOOL->tiltX, PTOOL->tiltY);
|
|
||||||
|
|
||||||
}, PNEWTABLET, "Tablet");
|
|
||||||
|
|
||||||
PNEWTABLET->hyprListener_Tip.initCallback(&wlr_tablet_from_input_device(pDevice)->events.tip, [](void* owner, void* data) {
|
|
||||||
const auto EVENT = (wlr_tablet_tool_tip_event*)data;
|
|
||||||
const auto PTAB = (STablet*)owner;
|
|
||||||
|
|
||||||
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
|
|
||||||
|
|
||||||
// TODO: this might be wrong
|
|
||||||
if (EVENT->state == WLR_TABLET_TOOL_TIP_DOWN) {
|
|
||||||
g_pInputManager->refocus();
|
|
||||||
g_pInputManager->focusTablet(PTAB, EVENT->tool);
|
|
||||||
wlr_send_tablet_v2_tablet_tool_down(PTOOL->wlrTabletToolV2);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
wlr_send_tablet_v2_tablet_tool_up(PTOOL->wlrTabletToolV2);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, PNEWTABLET, "Tablet");
|
|
||||||
|
|
||||||
PNEWTABLET->hyprListener_Button.initCallback(&wlr_tablet_from_input_device(pDevice)->events.button, [](void* owner, void* data) {
|
|
||||||
const auto EVENT = (wlr_tablet_tool_button_event*)data;
|
|
||||||
|
|
||||||
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
|
|
||||||
|
|
||||||
wlr_tablet_v2_tablet_tool_notify_button(PTOOL->wlrTabletToolV2, (zwp_tablet_pad_v2_button_state)EVENT->button, (zwp_tablet_pad_v2_button_state)EVENT->state);
|
|
||||||
|
|
||||||
}, PNEWTABLET, "Tablet");
|
|
||||||
|
|
||||||
PNEWTABLET->hyprListener_Proximity.initCallback(&wlr_tablet_from_input_device(pDevice)->events.proximity, [](void* owner, void* data) {
|
|
||||||
const auto EVENT = (wlr_tablet_tool_proximity_event*)data;
|
|
||||||
const auto PTAB = (STablet*)owner;
|
|
||||||
|
|
||||||
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
|
|
||||||
|
|
||||||
if (EVENT->state == WLR_TABLET_TOOL_PROXIMITY_OUT) {
|
|
||||||
PTOOL->active = false;
|
|
||||||
|
|
||||||
if (PTOOL->pSurface) {
|
|
||||||
wlr_tablet_v2_tablet_tool_notify_proximity_out(PTOOL->wlrTabletToolV2);
|
|
||||||
PTOOL->pSurface = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
|
||||||
PTOOL->active = true;
|
|
||||||
g_pInputManager->refocus();
|
|
||||||
g_pInputManager->focusTablet(PTAB, EVENT->tool);
|
|
||||||
}
|
|
||||||
|
|
||||||
}, PNEWTABLET, "Tablet");
|
// TODO: this might be wrong
|
||||||
|
if (PTOOL->active) {
|
||||||
|
g_pInputManager->refocus();
|
||||||
|
|
||||||
|
g_pInputManager->focusTablet(PTAB, EVENT->tool, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_PRESSURE)
|
||||||
|
wlr_tablet_v2_tablet_tool_notify_pressure(PTOOL->wlrTabletToolV2, EVENT->pressure);
|
||||||
|
|
||||||
|
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_DISTANCE)
|
||||||
|
wlr_tablet_v2_tablet_tool_notify_distance(PTOOL->wlrTabletToolV2, EVENT->distance);
|
||||||
|
|
||||||
|
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_ROTATION)
|
||||||
|
wlr_tablet_v2_tablet_tool_notify_rotation(PTOOL->wlrTabletToolV2, EVENT->rotation);
|
||||||
|
|
||||||
|
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_SLIDER)
|
||||||
|
wlr_tablet_v2_tablet_tool_notify_slider(PTOOL->wlrTabletToolV2, EVENT->slider);
|
||||||
|
|
||||||
|
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_WHEEL)
|
||||||
|
wlr_tablet_v2_tablet_tool_notify_wheel(PTOOL->wlrTabletToolV2, EVENT->wheel_delta, 0);
|
||||||
|
|
||||||
|
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_X)
|
||||||
|
PTOOL->tiltX = EVENT->tilt_x;
|
||||||
|
|
||||||
|
if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_Y)
|
||||||
|
PTOOL->tiltY = EVENT->tilt_y;
|
||||||
|
|
||||||
|
if (EVENT->updated_axes & (WLR_TABLET_TOOL_AXIS_TILT_X | WLR_TABLET_TOOL_AXIS_TILT_Y))
|
||||||
|
wlr_tablet_v2_tablet_tool_notify_tilt(PTOOL->wlrTabletToolV2, PTOOL->tiltX, PTOOL->tiltY);
|
||||||
|
},
|
||||||
|
PNEWTABLET, "Tablet");
|
||||||
|
|
||||||
|
PNEWTABLET->hyprListener_Tip.initCallback(
|
||||||
|
&wlr_tablet_from_input_device(pDevice)->events.tip,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto EVENT = (wlr_tablet_tool_tip_event*)data;
|
||||||
|
const auto PTAB = (STablet*)owner;
|
||||||
|
|
||||||
|
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
|
||||||
|
|
||||||
|
// TODO: this might be wrong
|
||||||
|
if (EVENT->state == WLR_TABLET_TOOL_TIP_DOWN) {
|
||||||
|
g_pInputManager->refocus();
|
||||||
|
g_pInputManager->focusTablet(PTAB, EVENT->tool);
|
||||||
|
wlr_send_tablet_v2_tablet_tool_down(PTOOL->wlrTabletToolV2);
|
||||||
|
} else {
|
||||||
|
wlr_send_tablet_v2_tablet_tool_up(PTOOL->wlrTabletToolV2);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
PNEWTABLET, "Tablet");
|
||||||
|
|
||||||
|
PNEWTABLET->hyprListener_Button.initCallback(
|
||||||
|
&wlr_tablet_from_input_device(pDevice)->events.button,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto EVENT = (wlr_tablet_tool_button_event*)data;
|
||||||
|
|
||||||
|
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
|
||||||
|
|
||||||
|
wlr_tablet_v2_tablet_tool_notify_button(PTOOL->wlrTabletToolV2, (zwp_tablet_pad_v2_button_state)EVENT->button, (zwp_tablet_pad_v2_button_state)EVENT->state);
|
||||||
|
},
|
||||||
|
PNEWTABLET, "Tablet");
|
||||||
|
|
||||||
|
PNEWTABLET->hyprListener_Proximity.initCallback(
|
||||||
|
&wlr_tablet_from_input_device(pDevice)->events.proximity,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto EVENT = (wlr_tablet_tool_proximity_event*)data;
|
||||||
|
const auto PTAB = (STablet*)owner;
|
||||||
|
|
||||||
|
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
|
||||||
|
|
||||||
|
if (EVENT->state == WLR_TABLET_TOOL_PROXIMITY_OUT) {
|
||||||
|
PTOOL->active = false;
|
||||||
|
|
||||||
|
if (PTOOL->pSurface) {
|
||||||
|
wlr_tablet_v2_tablet_tool_notify_proximity_out(PTOOL->wlrTabletToolV2);
|
||||||
|
PTOOL->pSurface = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
PTOOL->active = true;
|
||||||
|
g_pInputManager->refocus();
|
||||||
|
g_pInputManager->focusTablet(PTAB, EVENT->tool);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
PNEWTABLET, "Tablet");
|
||||||
}
|
}
|
||||||
|
|
||||||
STabletTool* CInputManager::ensureTabletToolPresent(wlr_tablet_tool* pTool) {
|
STabletTool* CInputManager::ensureTabletToolPresent(wlr_tablet_tool* pTool) {
|
||||||
|
@ -137,16 +146,19 @@ STabletTool* CInputManager::ensureTabletToolPresent(wlr_tablet_tool* pTool) {
|
||||||
Debug::log(LOG, "Creating tablet tool v2 for %x", pTool);
|
Debug::log(LOG, "Creating tablet tool v2 for %x", pTool);
|
||||||
|
|
||||||
PTOOL->wlrTabletTool = pTool;
|
PTOOL->wlrTabletTool = pTool;
|
||||||
pTool->data = PTOOL;
|
pTool->data = PTOOL;
|
||||||
|
|
||||||
PTOOL->wlrTabletToolV2 = wlr_tablet_tool_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pTool);
|
PTOOL->wlrTabletToolV2 = wlr_tablet_tool_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pTool);
|
||||||
|
|
||||||
PTOOL->hyprListener_TabletToolDestroy.initCallback(&pTool->events.destroy, [](void* owner, void* data) {
|
PTOOL->hyprListener_TabletToolDestroy.initCallback(
|
||||||
const auto PTOOL = (STabletTool*)owner;
|
&pTool->events.destroy,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto PTOOL = (STabletTool*)owner;
|
||||||
|
|
||||||
PTOOL->wlrTabletTool->data = nullptr;
|
PTOOL->wlrTabletTool->data = nullptr;
|
||||||
g_pInputManager->m_lTabletTools.remove(*PTOOL);
|
g_pInputManager->m_lTabletTools.remove(*PTOOL);
|
||||||
}, PTOOL, "Tablet Tool V1");
|
},
|
||||||
|
PTOOL, "Tablet Tool V1");
|
||||||
|
|
||||||
//TODO: set cursor request
|
//TODO: set cursor request
|
||||||
}
|
}
|
||||||
|
@ -160,60 +172,65 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) {
|
||||||
try {
|
try {
|
||||||
PNEWPAD->name = deviceNameToInternalString(pDevice->name);
|
PNEWPAD->name = deviceNameToInternalString(pDevice->name);
|
||||||
} catch (std::exception& e) {
|
} catch (std::exception& e) {
|
||||||
Debug::log(ERR, "Pad had no name???"); // logic error
|
Debug::log(ERR, "Pad had no name???"); // logic error
|
||||||
}
|
}
|
||||||
|
|
||||||
PNEWPAD->wlrTabletPadV2 = wlr_tablet_pad_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pDevice);
|
PNEWPAD->wlrTabletPadV2 = wlr_tablet_pad_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pDevice);
|
||||||
|
|
||||||
PNEWPAD->hyprListener_Button.initCallback(&wlr_tablet_pad_from_input_device(pDevice)->events.button, [](void* owner, void* data) {
|
PNEWPAD->hyprListener_Button.initCallback(
|
||||||
|
&wlr_tablet_pad_from_input_device(pDevice)->events.button,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto EVENT = (wlr_tablet_pad_button_event*)data;
|
||||||
|
const auto PPAD = (STabletPad*)owner;
|
||||||
|
|
||||||
const auto EVENT = (wlr_tablet_pad_button_event*)data;
|
wlr_tablet_v2_tablet_pad_notify_mode(PPAD->wlrTabletPadV2, EVENT->group, EVENT->mode, EVENT->time_msec);
|
||||||
const auto PPAD = (STabletPad*)owner;
|
wlr_tablet_v2_tablet_pad_notify_button(PPAD->wlrTabletPadV2, EVENT->button, EVENT->time_msec, (zwp_tablet_pad_v2_button_state)EVENT->state);
|
||||||
|
},
|
||||||
|
PNEWPAD, "Tablet Pad");
|
||||||
|
|
||||||
wlr_tablet_v2_tablet_pad_notify_mode(PPAD->wlrTabletPadV2, EVENT->group, EVENT->mode, EVENT->time_msec);
|
PNEWPAD->hyprListener_Strip.initCallback(
|
||||||
wlr_tablet_v2_tablet_pad_notify_button(PPAD->wlrTabletPadV2, EVENT->button, EVENT->time_msec, (zwp_tablet_pad_v2_button_state)EVENT->state);
|
&wlr_tablet_pad_from_input_device(pDevice)->events.strip,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto EVENT = (wlr_tablet_pad_strip_event*)data;
|
||||||
|
const auto PPAD = (STabletPad*)owner;
|
||||||
|
|
||||||
}, PNEWPAD, "Tablet Pad");
|
wlr_tablet_v2_tablet_pad_notify_strip(PPAD->wlrTabletPadV2, EVENT->strip, EVENT->position, EVENT->source == WLR_TABLET_PAD_STRIP_SOURCE_FINGER, EVENT->time_msec);
|
||||||
|
},
|
||||||
|
PNEWPAD, "Tablet Pad");
|
||||||
|
|
||||||
PNEWPAD->hyprListener_Strip.initCallback(&wlr_tablet_pad_from_input_device(pDevice)->events.strip, [](void* owner, void* data) {
|
PNEWPAD->hyprListener_Ring.initCallback(
|
||||||
|
&wlr_tablet_pad_from_input_device(pDevice)->events.strip,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto EVENT = (wlr_tablet_pad_ring_event*)data;
|
||||||
|
const auto PPAD = (STabletPad*)owner;
|
||||||
|
|
||||||
const auto EVENT = (wlr_tablet_pad_strip_event*)data;
|
wlr_tablet_v2_tablet_pad_notify_ring(PPAD->wlrTabletPadV2, EVENT->ring, EVENT->position, EVENT->source == WLR_TABLET_PAD_RING_SOURCE_FINGER, EVENT->time_msec);
|
||||||
const auto PPAD = (STabletPad*)owner;
|
},
|
||||||
|
PNEWPAD, "Tablet Pad");
|
||||||
|
|
||||||
wlr_tablet_v2_tablet_pad_notify_strip(PPAD->wlrTabletPadV2, EVENT->strip, EVENT->position, EVENT->source == WLR_TABLET_PAD_STRIP_SOURCE_FINGER, EVENT->time_msec);
|
PNEWPAD->hyprListener_Attach.initCallback(
|
||||||
|
&wlr_tablet_pad_from_input_device(pDevice)->events.strip,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto TABLET = (wlr_tablet_tool*)data;
|
||||||
|
const auto PPAD = (STabletPad*)owner;
|
||||||
|
|
||||||
}, PNEWPAD, "Tablet Pad");
|
PPAD->pTabletParent = (STablet*)TABLET->data;
|
||||||
|
|
||||||
PNEWPAD->hyprListener_Ring.initCallback(&wlr_tablet_pad_from_input_device(pDevice)->events.strip, [](void* owner, void* data) {
|
if (!PPAD->pTabletParent)
|
||||||
|
Debug::log(ERR, "tabletpad got attached to a nullptr tablet!! this might be bad.");
|
||||||
|
},
|
||||||
|
PNEWPAD, "Tablet Pad");
|
||||||
|
|
||||||
const auto EVENT = (wlr_tablet_pad_ring_event*)data;
|
PNEWPAD->hyprListener_Destroy.initCallback(
|
||||||
const auto PPAD = (STabletPad*)owner;
|
&pDevice->events.destroy,
|
||||||
|
[](void* owner, void* data) {
|
||||||
|
const auto PPAD = (STabletPad*)owner;
|
||||||
|
|
||||||
wlr_tablet_v2_tablet_pad_notify_ring(PPAD->wlrTabletPadV2, EVENT->ring, EVENT->position, EVENT->source == WLR_TABLET_PAD_RING_SOURCE_FINGER, EVENT->time_msec);
|
g_pInputManager->m_lTabletPads.remove(*PPAD);
|
||||||
|
|
||||||
}, PNEWPAD, "Tablet Pad");
|
Debug::log(LOG, "Removed a tablet pad");
|
||||||
|
},
|
||||||
PNEWPAD->hyprListener_Attach.initCallback(&wlr_tablet_pad_from_input_device(pDevice)->events.strip, [](void* owner, void* data) {
|
PNEWPAD, "Tablet Pad");
|
||||||
|
|
||||||
const auto TABLET = (wlr_tablet_tool*)data;
|
|
||||||
const auto PPAD = (STabletPad*)owner;
|
|
||||||
|
|
||||||
PPAD->pTabletParent = (STablet*)TABLET->data;
|
|
||||||
|
|
||||||
if (!PPAD->pTabletParent)
|
|
||||||
Debug::log(ERR, "tabletpad got attached to a nullptr tablet!! this might be bad.");
|
|
||||||
|
|
||||||
}, PNEWPAD, "Tablet Pad");
|
|
||||||
|
|
||||||
PNEWPAD->hyprListener_Destroy.initCallback(&pDevice->events.destroy, [](void* owner, void* data) {
|
|
||||||
|
|
||||||
const auto PPAD = (STabletPad*)owner;
|
|
||||||
|
|
||||||
g_pInputManager->m_lTabletPads.remove(*PPAD);
|
|
||||||
|
|
||||||
Debug::log(LOG, "Removed a tablet pad");
|
|
||||||
|
|
||||||
}, PNEWPAD, "Tablet Pad");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::focusTablet(STablet* pTab, wlr_tablet_tool* pTool, bool motion) {
|
void CInputManager::focusTablet(STablet* pTab, wlr_tablet_tool* pTool, bool motion) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "../../Compositor.hpp"
|
#include "../../Compositor.hpp"
|
||||||
|
|
||||||
void CInputManager::onTouchDown(wlr_touch_down_event* e) {
|
void CInputManager::onTouchDown(wlr_touch_down_event* e) {
|
||||||
auto PMONITOR = g_pCompositor->getMonitorFromName(e->touch->output_name ? e->touch->output_name : "");
|
auto PMONITOR = g_pCompositor->getMonitorFromName(e->touch->output_name ? e->touch->output_name : "");
|
||||||
|
|
||||||
const auto PDEVIT = std::find_if(m_lTouchDevices.begin(), m_lTouchDevices.end(), [&](const STouchDevice& other) { return other.pWlrDevice == &e->touch->base; });
|
const auto PDEVIT = std::find_if(m_lTouchDevices.begin(), m_lTouchDevices.end(), [&](const STouchDevice& other) { return other.pWlrDevice == &e->touch->base; });
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) {
|
||||||
|
|
||||||
refocus();
|
refocus();
|
||||||
|
|
||||||
m_sTouchData.touchFocusWindow = m_pFoundWindowToFocus;
|
m_sTouchData.touchFocusWindow = m_pFoundWindowToFocus;
|
||||||
m_sTouchData.touchFocusSurface = m_pFoundSurfaceToFocus;
|
m_sTouchData.touchFocusSurface = m_pFoundSurfaceToFocus;
|
||||||
m_sTouchData.touchFocusLS = m_pFoundLSToFocus;
|
m_sTouchData.touchFocusLS = m_pFoundLSToFocus;
|
||||||
|
|
||||||
Vector2D local;
|
Vector2D local;
|
||||||
|
|
||||||
|
@ -30,7 +30,8 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) {
|
||||||
|
|
||||||
m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
|
m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
|
||||||
} else if (m_sTouchData.touchFocusLS) {
|
} else if (m_sTouchData.touchFocusLS) {
|
||||||
local = g_pInputManager->getMouseCoordsInternal() - Vector2D(m_sTouchData.touchFocusLS->geometry.x, m_sTouchData.touchFocusLS->geometry.y) - g_pCompositor->m_pLastMonitor->vecPosition;
|
local = g_pInputManager->getMouseCoordsInternal() - Vector2D(m_sTouchData.touchFocusLS->geometry.x, m_sTouchData.touchFocusLS->geometry.y) -
|
||||||
|
g_pCompositor->m_pLastMonitor->vecPosition;
|
||||||
|
|
||||||
m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
|
m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
|
||||||
} else {
|
} else {
|
||||||
|
@ -42,17 +43,18 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) {
|
||||||
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
|
wlr_idle_notify_activity(g_pCompositor->m_sWLRIdle, g_pCompositor->m_sSeat.seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::onTouchUp(wlr_touch_up_event* e){
|
void CInputManager::onTouchUp(wlr_touch_up_event* e) {
|
||||||
if (m_sTouchData.touchFocusSurface) {
|
if (m_sTouchData.touchFocusSurface) {
|
||||||
wlr_seat_touch_notify_up(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id);
|
wlr_seat_touch_notify_up(g_pCompositor->m_sSeat.seat, e->time_msec, e->touch_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CInputManager::onTouchMove(wlr_touch_motion_event* e){
|
void CInputManager::onTouchMove(wlr_touch_motion_event* e) {
|
||||||
if (m_sTouchData.touchFocusWindow && g_pCompositor->windowValidMapped(m_sTouchData.touchFocusWindow)) {
|
if (m_sTouchData.touchFocusWindow && g_pCompositor->windowValidMapped(m_sTouchData.touchFocusWindow)) {
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusWindow->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusWindow->m_iMonitorID);
|
||||||
|
|
||||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y);
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x,
|
||||||
|
PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y);
|
||||||
|
|
||||||
const auto local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchSurfaceOrigin;
|
const auto local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchSurfaceOrigin;
|
||||||
|
|
||||||
|
@ -60,7 +62,8 @@ void CInputManager::onTouchMove(wlr_touch_motion_event* e){
|
||||||
} else if (m_sTouchData.touchFocusLS) {
|
} else if (m_sTouchData.touchFocusLS) {
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusLS->monitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_sTouchData.touchFocusLS->monitorID);
|
||||||
|
|
||||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x, PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y);
|
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, g_pCompositor->m_sSeat.mouse->mouse, PMONITOR->vecPosition.x + e->x * PMONITOR->vecSize.x,
|
||||||
|
PMONITOR->vecPosition.y + e->y * PMONITOR->vecSize.y);
|
||||||
|
|
||||||
const auto local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchSurfaceOrigin;
|
const auto local = g_pInputManager->getMouseCoordsInternal() - m_sTouchData.touchSurfaceOrigin;
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,7 @@ CToplevelExportProtocolManager::CToplevelExportProtocolManager() {
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_pGlobal = wl_global_create(g_pCompositor->m_sWLDisplay, &hyprland_toplevel_export_manager_v1_interface,
|
m_pGlobal = wl_global_create(g_pCompositor->m_sWLDisplay, &hyprland_toplevel_export_manager_v1_interface, TOPLEVEL_EXPORT_VERSION, this, bindManagerInt);
|
||||||
TOPLEVEL_EXPORT_VERSION, this, bindManagerInt);
|
|
||||||
|
|
||||||
if (!m_pGlobal) {
|
if (!m_pGlobal) {
|
||||||
Debug::log(ERR, "ToplevelExportManager could not start! Sharing windows will not work!");
|
Debug::log(ERR, "ToplevelExportManager could not start! Sharing windows will not work!");
|
||||||
|
@ -67,17 +66,14 @@ void handleDestroyFrame(wl_client* client, wl_resource* resource) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct hyprland_toplevel_export_manager_v1_interface toplevelExportManagerImpl = {
|
static const struct hyprland_toplevel_export_manager_v1_interface toplevelExportManagerImpl = {
|
||||||
.capture_toplevel = handleCaptureToplevel,
|
.capture_toplevel = handleCaptureToplevel,
|
||||||
.destroy = handleDestroy,
|
.destroy = handleDestroy,
|
||||||
.capture_toplevel_with_wlr_toplevel_handle = handleCaptureToplevelWithWlr,
|
.capture_toplevel_with_wlr_toplevel_handle = handleCaptureToplevelWithWlr,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct hyprland_toplevel_export_frame_v1_interface toplevelFrameImpl = {
|
static const struct hyprland_toplevel_export_frame_v1_interface toplevelFrameImpl = {.copy = handleCopyFrame, .destroy = handleDestroyFrame};
|
||||||
.copy = handleCopyFrame,
|
|
||||||
.destroy = handleDestroyFrame
|
|
||||||
};
|
|
||||||
|
|
||||||
SToplevelClient* clientFromResource(wl_resource* resource) {
|
SToplevelClient* clientFromResource(wl_resource* resource) {
|
||||||
ASSERT(wl_resource_instance_of(resource, &hyprland_toplevel_export_manager_v1_interface, &toplevelExportManagerImpl));
|
ASSERT(wl_resource_instance_of(resource, &hyprland_toplevel_export_manager_v1_interface, &toplevelExportManagerImpl));
|
||||||
return (SToplevelClient*)wl_resource_get_user_data(resource);
|
return (SToplevelClient*)wl_resource_get_user_data(resource);
|
||||||
}
|
}
|
||||||
|
@ -108,8 +104,7 @@ void handleManagerResourceDestroy(wl_resource* resource) {
|
||||||
void CToplevelExportProtocolManager::bindManager(wl_client* client, void* data, uint32_t version, uint32_t id) {
|
void CToplevelExportProtocolManager::bindManager(wl_client* client, void* data, uint32_t version, uint32_t id) {
|
||||||
const auto PCLIENT = &m_lClients.emplace_back();
|
const auto PCLIENT = &m_lClients.emplace_back();
|
||||||
|
|
||||||
PCLIENT->resource = wl_resource_create(client, &hyprland_toplevel_export_manager_v1_interface,
|
PCLIENT->resource = wl_resource_create(client, &hyprland_toplevel_export_manager_v1_interface, version, id);
|
||||||
version, id);
|
|
||||||
|
|
||||||
if (!PCLIENT->resource) {
|
if (!PCLIENT->resource) {
|
||||||
Debug::log(ERR, "ToplevelExportManager could not bind! (out of memory?)");
|
Debug::log(ERR, "ToplevelExportManager could not bind! (out of memory?)");
|
||||||
|
@ -135,7 +130,7 @@ void CToplevelExportProtocolManager::removeFrame(SToplevelFrame* frame, bool for
|
||||||
if (!frame)
|
if (!frame)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::erase_if(m_vFramesAwaitingWrite, [&] (const auto& other) { return other == frame; });
|
std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return other == frame; });
|
||||||
|
|
||||||
wl_resource_set_user_data(frame->resource, nullptr);
|
wl_resource_set_user_data(frame->resource, nullptr);
|
||||||
wlr_buffer_unlock(frame->buffer);
|
wlr_buffer_unlock(frame->buffer);
|
||||||
|
@ -147,10 +142,10 @@ void CToplevelExportProtocolManager::captureToplevel(wl_client* client, wl_resou
|
||||||
const auto PCLIENT = clientFromResource(resource);
|
const auto PCLIENT = clientFromResource(resource);
|
||||||
|
|
||||||
// create a frame
|
// create a frame
|
||||||
const auto PFRAME = &m_lFrames.emplace_back();
|
const auto PFRAME = &m_lFrames.emplace_back();
|
||||||
PFRAME->overlayCursor = !!overlay_cursor;
|
PFRAME->overlayCursor = !!overlay_cursor;
|
||||||
PFRAME->resource = wl_resource_create(client, &hyprland_toplevel_export_frame_v1_interface, wl_resource_get_version(resource), frame);
|
PFRAME->resource = wl_resource_create(client, &hyprland_toplevel_export_frame_v1_interface, wl_resource_get_version(resource), frame);
|
||||||
PFRAME->pWindow = pWindow;
|
PFRAME->pWindow = pWindow;
|
||||||
|
|
||||||
if (!PFRAME->pWindow) {
|
if (!PFRAME->pWindow) {
|
||||||
Debug::log(ERR, "Client requested sharing of window handle %x which does not exist!", PFRAME->pWindow);
|
Debug::log(ERR, "Client requested sharing of window handle %x which does not exist!", PFRAME->pWindow);
|
||||||
|
@ -202,7 +197,7 @@ void CToplevelExportProtocolManager::captureToplevel(wl_client* client, wl_resou
|
||||||
PFRAME->dmabufFormat = DRM_FORMAT_INVALID;
|
PFRAME->dmabufFormat = DRM_FORMAT_INVALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
PFRAME->box = { 0, 0, (int)(PFRAME->pWindow->m_vRealSize.vec().x * PMONITOR->scale), (int)(PFRAME->pWindow->m_vRealSize.vec().y * PMONITOR->scale) };
|
PFRAME->box = {0, 0, (int)(PFRAME->pWindow->m_vRealSize.vec().x * PMONITOR->scale), (int)(PFRAME->pWindow->m_vRealSize.vec().y * PMONITOR->scale)};
|
||||||
int ow, oh;
|
int ow, oh;
|
||||||
wlr_output_effective_resolution(PMONITOR->output, &ow, &oh);
|
wlr_output_effective_resolution(PMONITOR->output, &ow, &oh);
|
||||||
wlr_box_transform(&PFRAME->box, &PFRAME->box, PMONITOR->transform, ow, oh);
|
wlr_box_transform(&PFRAME->box, &PFRAME->box, PMONITOR->transform, ow, oh);
|
||||||
|
@ -247,9 +242,9 @@ void CToplevelExportProtocolManager::copyFrame(wl_client* client, wl_resource* r
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_dmabuf_attributes dmabufAttrs;
|
wlr_dmabuf_attributes dmabufAttrs;
|
||||||
void* wlrBufferAccessData;
|
void* wlrBufferAccessData;
|
||||||
uint32_t wlrBufferAccessFormat;
|
uint32_t wlrBufferAccessFormat;
|
||||||
size_t wlrBufferAccessStride;
|
size_t wlrBufferAccessStride;
|
||||||
if (wlr_buffer_get_dmabuf(PBUFFER, &dmabufAttrs)) {
|
if (wlr_buffer_get_dmabuf(PBUFFER, &dmabufAttrs)) {
|
||||||
PFRAME->bufferCap = WLR_BUFFER_CAP_DMABUF;
|
PFRAME->bufferCap = WLR_BUFFER_CAP_DMABUF;
|
||||||
|
|
||||||
|
@ -287,7 +282,7 @@ void CToplevelExportProtocolManager::onMonitorRender(CMonitor* pMonitor) {
|
||||||
return; // nothing to share
|
return; // nothing to share
|
||||||
|
|
||||||
std::vector<SToplevelFrame*> framesToRemove;
|
std::vector<SToplevelFrame*> framesToRemove;
|
||||||
|
|
||||||
// share frame if correct output
|
// share frame if correct output
|
||||||
for (auto& f : m_vFramesAwaitingWrite) {
|
for (auto& f : m_vFramesAwaitingWrite) {
|
||||||
if (!f->pWindow) {
|
if (!f->pWindow) {
|
||||||
|
@ -295,12 +290,11 @@ void CToplevelExportProtocolManager::onMonitorRender(CMonitor* pMonitor) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_box geometry = { f->pWindow->m_vRealPosition.vec().x, f->pWindow->m_vRealPosition.vec().y,
|
wlr_box geometry = {f->pWindow->m_vRealPosition.vec().x, f->pWindow->m_vRealPosition.vec().y, f->pWindow->m_vRealSize.vec().x, f->pWindow->m_vRealSize.vec().y};
|
||||||
f->pWindow->m_vRealSize.vec().x, f->pWindow->m_vRealSize.vec().y };
|
|
||||||
|
|
||||||
if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, pMonitor->output, &geometry))
|
if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, pMonitor->output, &geometry))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
shareFrame(f);
|
shareFrame(f);
|
||||||
|
|
||||||
framesToRemove.push_back(f);
|
framesToRemove.push_back(f);
|
||||||
|
@ -342,14 +336,14 @@ void CToplevelExportProtocolManager::shareFrame(SToplevelFrame* frame) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CToplevelExportProtocolManager::copyFrameShm(SToplevelFrame* frame, timespec* now) {
|
bool CToplevelExportProtocolManager::copyFrameShm(SToplevelFrame* frame, timespec* now) {
|
||||||
void* data;
|
void* data;
|
||||||
uint32_t format;
|
uint32_t format;
|
||||||
size_t stride;
|
size_t stride;
|
||||||
if (!wlr_buffer_begin_data_ptr_access(frame->buffer, WLR_BUFFER_DATA_PTR_ACCESS_WRITE, &data, &format, &stride))
|
if (!wlr_buffer_begin_data_ptr_access(frame->buffer, WLR_BUFFER_DATA_PTR_ACCESS_WRITE, &data, &format, &stride))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// render the client
|
// render the client
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(frame->pWindow->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(frame->pWindow->m_iMonitorID);
|
||||||
pixman_region32_t fakeDamage;
|
pixman_region32_t fakeDamage;
|
||||||
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecPixelSize.x * 10, PMONITOR->vecPixelSize.y * 10);
|
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecPixelSize.x * 10, PMONITOR->vecPixelSize.y * 10);
|
||||||
|
|
||||||
|
|
|
@ -11,60 +11,60 @@ class CMonitor;
|
||||||
class CWindow;
|
class CWindow;
|
||||||
|
|
||||||
struct SToplevelClient {
|
struct SToplevelClient {
|
||||||
int ref = 0;
|
int ref = 0;
|
||||||
wl_resource* resource = nullptr;
|
wl_resource* resource = nullptr;
|
||||||
|
|
||||||
bool operator==(const SToplevelClient& other) {
|
bool operator==(const SToplevelClient& other) {
|
||||||
return resource == other.resource;
|
return resource == other.resource;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SToplevelFrame {
|
struct SToplevelFrame {
|
||||||
wl_resource* resource = nullptr;
|
wl_resource* resource = nullptr;
|
||||||
SToplevelClient* client = nullptr;
|
SToplevelClient* client = nullptr;
|
||||||
|
|
||||||
uint32_t shmFormat = 0;
|
uint32_t shmFormat = 0;
|
||||||
uint32_t dmabufFormat = 0;
|
uint32_t dmabufFormat = 0;
|
||||||
wlr_box box = { 0 };
|
wlr_box box = {0};
|
||||||
int shmStride = 0;
|
int shmStride = 0;
|
||||||
|
|
||||||
bool overlayCursor = false;
|
bool overlayCursor = false;
|
||||||
|
|
||||||
wlr_buffer_cap bufferCap = WLR_BUFFER_CAP_SHM;
|
wlr_buffer_cap bufferCap = WLR_BUFFER_CAP_SHM;
|
||||||
|
|
||||||
wlr_buffer* buffer = nullptr;
|
wlr_buffer* buffer = nullptr;
|
||||||
|
|
||||||
CWindow* pWindow = nullptr;
|
CWindow* pWindow = nullptr;
|
||||||
|
|
||||||
bool operator==(const SToplevelFrame& other) {
|
bool operator==(const SToplevelFrame& other) {
|
||||||
return resource == other.resource && client == other.client;
|
return resource == other.resource && client == other.client;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class CToplevelExportProtocolManager {
|
class CToplevelExportProtocolManager {
|
||||||
public:
|
public:
|
||||||
CToplevelExportProtocolManager();
|
CToplevelExportProtocolManager();
|
||||||
|
|
||||||
void bindManager(wl_client* client, void* data, uint32_t version, uint32_t id);
|
void bindManager(wl_client* client, void* data, uint32_t version, uint32_t id);
|
||||||
void captureToplevel(wl_client* client, wl_resource* resource, uint32_t frame, int32_t overlay_cursor, CWindow* handle);
|
void captureToplevel(wl_client* client, wl_resource* resource, uint32_t frame, int32_t overlay_cursor, CWindow* handle);
|
||||||
void removeClient(SToplevelClient* client, bool force = false);
|
void removeClient(SToplevelClient* client, bool force = false);
|
||||||
void removeFrame(SToplevelFrame* frame, bool force = false);
|
void removeFrame(SToplevelFrame* frame, bool force = false);
|
||||||
void copyFrame(wl_client* client, wl_resource* resource, wl_resource* buffer, int32_t ignore_damage);
|
void copyFrame(wl_client* client, wl_resource* resource, wl_resource* buffer, int32_t ignore_damage);
|
||||||
|
|
||||||
void onMonitorRender(CMonitor* pMonitor);
|
void onMonitorRender(CMonitor* pMonitor);
|
||||||
void displayDestroy();
|
void displayDestroy();
|
||||||
void onWindowUnmap(CWindow* pWindow);
|
void onWindowUnmap(CWindow* pWindow);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wl_global* m_pGlobal = nullptr;
|
wl_global* m_pGlobal = nullptr;
|
||||||
std::list<SToplevelFrame> m_lFrames;
|
std::list<SToplevelFrame> m_lFrames;
|
||||||
std::list<SToplevelClient> m_lClients;
|
std::list<SToplevelClient> m_lClients;
|
||||||
|
|
||||||
wl_listener m_liDisplayDestroy;
|
wl_listener m_liDisplayDestroy;
|
||||||
|
|
||||||
std::vector<SToplevelFrame*> m_vFramesAwaitingWrite;
|
std::vector<SToplevelFrame*> m_vFramesAwaitingWrite;
|
||||||
|
|
||||||
void shareFrame(SToplevelFrame* frame);
|
void shareFrame(SToplevelFrame* frame);
|
||||||
bool copyFrameDmabuf(SToplevelFrame* frame);
|
bool copyFrameDmabuf(SToplevelFrame* frame);
|
||||||
bool copyFrameShm(SToplevelFrame* frame, timespec* now);
|
bool copyFrameShm(SToplevelFrame* frame, timespec* now);
|
||||||
};
|
};
|
|
@ -10,7 +10,7 @@ bool CFramebuffer::alloc(int w, int h) {
|
||||||
glGenFramebuffers(1, &m_iFb);
|
glGenFramebuffers(1, &m_iFb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_cTex.m_iTexID == 0) {
|
if (m_cTex.m_iTexID == 0) {
|
||||||
firstAlloc = true;
|
firstAlloc = true;
|
||||||
glGenTextures(1, &m_cTex.m_iTexID);
|
glGenTextures(1, &m_cTex.m_iTexID);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_cTex.m_iTexID);
|
glBindTexture(GL_TEXTURE_2D, m_cTex.m_iTexID);
|
||||||
|
@ -27,8 +27,8 @@ bool CFramebuffer::alloc(int w, int h) {
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_iFb);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_iFb);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_cTex.m_iTexID, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_cTex.m_iTexID, 0);
|
||||||
|
|
||||||
// TODO: Allow this with gles2
|
// TODO: Allow this with gles2
|
||||||
#ifndef GLES2
|
#ifndef GLES2
|
||||||
if (m_pStencilTex) {
|
if (m_pStencilTex) {
|
||||||
glBindTexture(GL_TEXTURE_2D, m_pStencilTex->m_iTexID);
|
glBindTexture(GL_TEXTURE_2D, m_pStencilTex->m_iTexID);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, w, h, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, w, h, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, 0);
|
||||||
|
@ -37,7 +37,7 @@ bool CFramebuffer::alloc(int w, int h) {
|
||||||
|
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_pStencilTex->m_iTexID, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_pStencilTex->m_iTexID, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
auto status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
RASSERT((status == GL_FRAMEBUFFER_COMPLETE), "Framebuffer incomplete, couldn't create! (FB status: %i)", status);
|
RASSERT((status == GL_FRAMEBUFFER_COMPLETE), "Framebuffer incomplete, couldn't create! (FB status: %i)", status);
|
||||||
|
@ -54,11 +54,11 @@ bool CFramebuffer::alloc(int w, int h) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFramebuffer::bind() {
|
void CFramebuffer::bind() {
|
||||||
#ifndef GLES2
|
#ifndef GLES2
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_iFb);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_iFb);
|
||||||
#else
|
#else
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_iFb);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_iFb);
|
||||||
#endif
|
#endif
|
||||||
glViewport(0, 0, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize.x, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize.y);
|
glViewport(0, 0, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize.x, g_pHyprOpenGL->m_RenderData.pMonitor->vecPixelSize.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,8 +72,8 @@ void CFramebuffer::release() {
|
||||||
}
|
}
|
||||||
|
|
||||||
m_cTex.m_iTexID = 0;
|
m_cTex.m_iTexID = 0;
|
||||||
m_iFb = -1;
|
m_iFb = -1;
|
||||||
m_Size = Vector2D();
|
m_Size = Vector2D();
|
||||||
}
|
}
|
||||||
|
|
||||||
CFramebuffer::~CFramebuffer() {
|
CFramebuffer::~CFramebuffer() {
|
||||||
|
|
|
@ -4,24 +4,23 @@
|
||||||
#include "Texture.hpp"
|
#include "Texture.hpp"
|
||||||
|
|
||||||
class CFramebuffer {
|
class CFramebuffer {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
~CFramebuffer();
|
~CFramebuffer();
|
||||||
|
|
||||||
bool alloc(int w, int h);
|
bool alloc(int w, int h);
|
||||||
void bind();
|
void bind();
|
||||||
void release();
|
void release();
|
||||||
void reset();
|
void reset();
|
||||||
bool isAllocated();
|
bool isAllocated();
|
||||||
|
|
||||||
Vector2D m_Position;
|
Vector2D m_Position;
|
||||||
Vector2D m_Size;
|
Vector2D m_Size;
|
||||||
float m_fScale = 1;
|
float m_fScale = 1;
|
||||||
|
|
||||||
CTexture m_cTex;
|
CTexture m_cTex;
|
||||||
GLuint m_iFb = -1;
|
GLuint m_iFb = -1;
|
||||||
|
|
||||||
CTexture* m_pStencilTex = nullptr;
|
CTexture* m_pStencilTex = nullptr;
|
||||||
|
|
||||||
wl_output_transform m_tTransform; // for saving state
|
wl_output_transform m_tTransform; // for saving state
|
||||||
};
|
};
|
|
@ -5,9 +5,10 @@
|
||||||
#include "Shaders.hpp"
|
#include "Shaders.hpp"
|
||||||
|
|
||||||
CHyprOpenGLImpl::CHyprOpenGLImpl() {
|
CHyprOpenGLImpl::CHyprOpenGLImpl() {
|
||||||
RASSERT(eglMakeCurrent(wlr_egl_get_display(g_pCompositor->m_sWLREGL), EGL_NO_SURFACE, EGL_NO_SURFACE, wlr_egl_get_context(g_pCompositor->m_sWLREGL)), "Couldn't unset current EGL!");
|
RASSERT(eglMakeCurrent(wlr_egl_get_display(g_pCompositor->m_sWLREGL), EGL_NO_SURFACE, EGL_NO_SURFACE, wlr_egl_get_context(g_pCompositor->m_sWLREGL)),
|
||||||
|
"Couldn't unset current EGL!");
|
||||||
|
|
||||||
auto *const EXTENSIONS = (const char*)glGetString(GL_EXTENSIONS);
|
auto* const EXTENSIONS = (const char*)glGetString(GL_EXTENSIONS);
|
||||||
|
|
||||||
RASSERT(EXTENSIONS, "Couldn't retrieve openGL extensions!");
|
RASSERT(EXTENSIONS, "Couldn't retrieve openGL extensions!");
|
||||||
|
|
||||||
|
@ -21,9 +22,9 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() {
|
||||||
Debug::log(LOG, "Renderer: %s", glGetString(GL_RENDERER));
|
Debug::log(LOG, "Renderer: %s", glGetString(GL_RENDERER));
|
||||||
Debug::log(LOG, "Supported extensions size: %d", std::count(m_szExtensions.begin(), m_szExtensions.end(), ' '));
|
Debug::log(LOG, "Supported extensions size: %d", std::count(m_szExtensions.begin(), m_szExtensions.end(), ' '));
|
||||||
|
|
||||||
#ifdef GLES2
|
#ifdef GLES2
|
||||||
Debug::log(WARN, "!RENDERER: Using the legacy GLES2 renderer!");
|
Debug::log(WARN, "!RENDERER: Using the legacy GLES2 renderer!");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pixman_region32_init(&m_rOriginalDamageRegion);
|
pixman_region32_init(&m_rOriginalDamageRegion);
|
||||||
|
|
||||||
|
@ -111,8 +112,8 @@ void CHyprOpenGLImpl::begin(CMonitor* pMonitor, pixman_region32_t* pDamage, bool
|
||||||
if (m_mMonitorRenderResources.find(pMonitor) == m_mMonitorRenderResources.end() || m_RenderData.pCurrentMonData->primaryFB.m_Size != pMonitor->vecPixelSize) {
|
if (m_mMonitorRenderResources.find(pMonitor) == m_mMonitorRenderResources.end() || m_RenderData.pCurrentMonData->primaryFB.m_Size != pMonitor->vecPixelSize) {
|
||||||
m_RenderData.pCurrentMonData->stencilTex.allocate();
|
m_RenderData.pCurrentMonData->stencilTex.allocate();
|
||||||
|
|
||||||
m_RenderData.pCurrentMonData->primaryFB.m_pStencilTex = &m_RenderData.pCurrentMonData->stencilTex;
|
m_RenderData.pCurrentMonData->primaryFB.m_pStencilTex = &m_RenderData.pCurrentMonData->stencilTex;
|
||||||
m_RenderData.pCurrentMonData->mirrorFB.m_pStencilTex = &m_RenderData.pCurrentMonData->stencilTex;
|
m_RenderData.pCurrentMonData->mirrorFB.m_pStencilTex = &m_RenderData.pCurrentMonData->stencilTex;
|
||||||
m_RenderData.pCurrentMonData->mirrorSwapFB.m_pStencilTex = &m_RenderData.pCurrentMonData->stencilTex;
|
m_RenderData.pCurrentMonData->mirrorSwapFB.m_pStencilTex = &m_RenderData.pCurrentMonData->stencilTex;
|
||||||
|
|
||||||
m_RenderData.pCurrentMonData->primaryFB.alloc(pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y);
|
m_RenderData.pCurrentMonData->primaryFB.alloc(pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y);
|
||||||
|
@ -145,132 +146,132 @@ void CHyprOpenGLImpl::end() {
|
||||||
pixman_region32_copy(m_RenderData.pDamage, &m_rOriginalDamageRegion);
|
pixman_region32_copy(m_RenderData.pDamage, &m_rOriginalDamageRegion);
|
||||||
|
|
||||||
if (!m_RenderData.pMonitor->mirrors.empty())
|
if (!m_RenderData.pMonitor->mirrors.empty())
|
||||||
g_pHyprOpenGL->saveBufferForMirror(); // save with original damage region
|
g_pHyprOpenGL->saveBufferForMirror(); // save with original damage region
|
||||||
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_iWLROutputFb);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_iWLROutputFb);
|
||||||
wlr_box monbox = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
wlr_box monbox = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
||||||
|
|
||||||
clear(CColor(11, 11, 11, 255));
|
clear(CColor(11, 11, 11, 255));
|
||||||
|
|
||||||
m_bEndFrame = true;
|
m_bEndFrame = true;
|
||||||
m_bApplyFinalShader = true;
|
m_bApplyFinalShader = true;
|
||||||
|
|
||||||
renderTexture(m_RenderData.pCurrentMonData->primaryFB.m_cTex, &monbox, 255.f, 0);
|
renderTexture(m_RenderData.pCurrentMonData->primaryFB.m_cTex, &monbox, 255.f, 0);
|
||||||
|
|
||||||
m_bApplyFinalShader = false;
|
m_bApplyFinalShader = false;
|
||||||
m_bEndFrame = false;
|
m_bEndFrame = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset our data
|
// reset our data
|
||||||
m_RenderData.pMonitor = nullptr;
|
m_RenderData.pMonitor = nullptr;
|
||||||
m_iWLROutputFb = 0;
|
m_iWLROutputFb = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprOpenGLImpl::initShaders() {
|
void CHyprOpenGLImpl::initShaders() {
|
||||||
GLuint prog = createProgram(QUADVERTSRC, QUADFRAGSRC);
|
GLuint prog = createProgram(QUADVERTSRC, QUADFRAGSRC);
|
||||||
m_RenderData.pCurrentMonData->m_shQUAD.program = prog;
|
m_RenderData.pCurrentMonData->m_shQUAD.program = prog;
|
||||||
m_RenderData.pCurrentMonData->m_shQUAD.proj = glGetUniformLocation(prog, "proj");
|
m_RenderData.pCurrentMonData->m_shQUAD.proj = glGetUniformLocation(prog, "proj");
|
||||||
m_RenderData.pCurrentMonData->m_shQUAD.color = glGetUniformLocation(prog, "color");
|
m_RenderData.pCurrentMonData->m_shQUAD.color = glGetUniformLocation(prog, "color");
|
||||||
m_RenderData.pCurrentMonData->m_shQUAD.posAttrib = glGetAttribLocation(prog, "pos");
|
m_RenderData.pCurrentMonData->m_shQUAD.posAttrib = glGetAttribLocation(prog, "pos");
|
||||||
m_RenderData.pCurrentMonData->m_shQUAD.topLeft = glGetUniformLocation(prog, "topLeft");
|
m_RenderData.pCurrentMonData->m_shQUAD.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||||
m_RenderData.pCurrentMonData->m_shQUAD.fullSize = glGetUniformLocation(prog, "fullSize");
|
m_RenderData.pCurrentMonData->m_shQUAD.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||||
m_RenderData.pCurrentMonData->m_shQUAD.radius = glGetUniformLocation(prog, "radius");
|
m_RenderData.pCurrentMonData->m_shQUAD.radius = glGetUniformLocation(prog, "radius");
|
||||||
m_RenderData.pCurrentMonData->m_shQUAD.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
m_RenderData.pCurrentMonData->m_shQUAD.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
||||||
|
|
||||||
prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBA);
|
prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBA);
|
||||||
m_RenderData.pCurrentMonData->m_shRGBA.program = prog;
|
m_RenderData.pCurrentMonData->m_shRGBA.program = prog;
|
||||||
m_RenderData.pCurrentMonData->m_shRGBA.proj = glGetUniformLocation(prog, "proj");
|
m_RenderData.pCurrentMonData->m_shRGBA.proj = glGetUniformLocation(prog, "proj");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBA.tex = glGetUniformLocation(prog, "tex");
|
m_RenderData.pCurrentMonData->m_shRGBA.tex = glGetUniformLocation(prog, "tex");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBA.alpha = glGetUniformLocation(prog, "alpha");
|
m_RenderData.pCurrentMonData->m_shRGBA.alpha = glGetUniformLocation(prog, "alpha");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBA.texAttrib = glGetAttribLocation(prog, "texcoord");
|
m_RenderData.pCurrentMonData->m_shRGBA.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBA.posAttrib = glGetAttribLocation(prog, "pos");
|
m_RenderData.pCurrentMonData->m_shRGBA.posAttrib = glGetAttribLocation(prog, "pos");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBA.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
|
m_RenderData.pCurrentMonData->m_shRGBA.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBA.topLeft = glGetUniformLocation(prog, "topLeft");
|
m_RenderData.pCurrentMonData->m_shRGBA.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBA.fullSize = glGetUniformLocation(prog, "fullSize");
|
m_RenderData.pCurrentMonData->m_shRGBA.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBA.radius = glGetUniformLocation(prog, "radius");
|
m_RenderData.pCurrentMonData->m_shRGBA.radius = glGetUniformLocation(prog, "radius");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBA.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
m_RenderData.pCurrentMonData->m_shRGBA.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBA.applyTint = glGetUniformLocation(prog, "applyTint");
|
m_RenderData.pCurrentMonData->m_shRGBA.applyTint = glGetUniformLocation(prog, "applyTint");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBA.tint = glGetUniformLocation(prog, "tint");
|
m_RenderData.pCurrentMonData->m_shRGBA.tint = glGetUniformLocation(prog, "tint");
|
||||||
|
|
||||||
prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBX);
|
prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBX);
|
||||||
m_RenderData.pCurrentMonData->m_shRGBX.program = prog;
|
m_RenderData.pCurrentMonData->m_shRGBX.program = prog;
|
||||||
m_RenderData.pCurrentMonData->m_shRGBX.tex = glGetUniformLocation(prog, "tex");
|
m_RenderData.pCurrentMonData->m_shRGBX.tex = glGetUniformLocation(prog, "tex");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBX.proj = glGetUniformLocation(prog, "proj");
|
m_RenderData.pCurrentMonData->m_shRGBX.proj = glGetUniformLocation(prog, "proj");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBX.alpha = glGetUniformLocation(prog, "alpha");
|
m_RenderData.pCurrentMonData->m_shRGBX.alpha = glGetUniformLocation(prog, "alpha");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBX.texAttrib = glGetAttribLocation(prog, "texcoord");
|
m_RenderData.pCurrentMonData->m_shRGBX.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBX.posAttrib = glGetAttribLocation(prog, "pos");
|
m_RenderData.pCurrentMonData->m_shRGBX.posAttrib = glGetAttribLocation(prog, "pos");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBX.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
|
m_RenderData.pCurrentMonData->m_shRGBX.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBX.topLeft = glGetUniformLocation(prog, "topLeft");
|
m_RenderData.pCurrentMonData->m_shRGBX.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBX.fullSize = glGetUniformLocation(prog, "fullSize");
|
m_RenderData.pCurrentMonData->m_shRGBX.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBX.radius = glGetUniformLocation(prog, "radius");
|
m_RenderData.pCurrentMonData->m_shRGBX.radius = glGetUniformLocation(prog, "radius");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBX.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
m_RenderData.pCurrentMonData->m_shRGBX.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBX.applyTint = glGetUniformLocation(prog, "applyTint");
|
m_RenderData.pCurrentMonData->m_shRGBX.applyTint = glGetUniformLocation(prog, "applyTint");
|
||||||
m_RenderData.pCurrentMonData->m_shRGBX.tint = glGetUniformLocation(prog, "tint");
|
m_RenderData.pCurrentMonData->m_shRGBX.tint = glGetUniformLocation(prog, "tint");
|
||||||
|
|
||||||
prog = createProgram(TEXVERTSRC, TEXFRAGSRCEXT);
|
prog = createProgram(TEXVERTSRC, TEXFRAGSRCEXT);
|
||||||
m_RenderData.pCurrentMonData->m_shEXT.program = prog;
|
m_RenderData.pCurrentMonData->m_shEXT.program = prog;
|
||||||
m_RenderData.pCurrentMonData->m_shEXT.tex = glGetUniformLocation(prog, "tex");
|
m_RenderData.pCurrentMonData->m_shEXT.tex = glGetUniformLocation(prog, "tex");
|
||||||
m_RenderData.pCurrentMonData->m_shEXT.proj = glGetUniformLocation(prog, "proj");
|
m_RenderData.pCurrentMonData->m_shEXT.proj = glGetUniformLocation(prog, "proj");
|
||||||
m_RenderData.pCurrentMonData->m_shEXT.alpha = glGetUniformLocation(prog, "alpha");
|
m_RenderData.pCurrentMonData->m_shEXT.alpha = glGetUniformLocation(prog, "alpha");
|
||||||
m_RenderData.pCurrentMonData->m_shEXT.posAttrib = glGetAttribLocation(prog, "pos");
|
m_RenderData.pCurrentMonData->m_shEXT.posAttrib = glGetAttribLocation(prog, "pos");
|
||||||
m_RenderData.pCurrentMonData->m_shEXT.texAttrib = glGetAttribLocation(prog, "texcoord");
|
m_RenderData.pCurrentMonData->m_shEXT.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||||
m_RenderData.pCurrentMonData->m_shEXT.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
|
m_RenderData.pCurrentMonData->m_shEXT.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
|
||||||
m_RenderData.pCurrentMonData->m_shEXT.topLeft = glGetUniformLocation(prog, "topLeft");
|
m_RenderData.pCurrentMonData->m_shEXT.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||||
m_RenderData.pCurrentMonData->m_shEXT.fullSize = glGetUniformLocation(prog, "fullSize");
|
m_RenderData.pCurrentMonData->m_shEXT.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||||
m_RenderData.pCurrentMonData->m_shEXT.radius = glGetUniformLocation(prog, "radius");
|
m_RenderData.pCurrentMonData->m_shEXT.radius = glGetUniformLocation(prog, "radius");
|
||||||
m_RenderData.pCurrentMonData->m_shEXT.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
m_RenderData.pCurrentMonData->m_shEXT.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
||||||
m_RenderData.pCurrentMonData->m_shEXT.applyTint = glGetUniformLocation(prog, "applyTint");
|
m_RenderData.pCurrentMonData->m_shEXT.applyTint = glGetUniformLocation(prog, "applyTint");
|
||||||
m_RenderData.pCurrentMonData->m_shEXT.tint = glGetUniformLocation(prog, "tint");
|
m_RenderData.pCurrentMonData->m_shEXT.tint = glGetUniformLocation(prog, "tint");
|
||||||
|
|
||||||
prog = createProgram(TEXVERTSRC, FRAGBLUR1);
|
prog = createProgram(TEXVERTSRC, FRAGBLUR1);
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR1.program = prog;
|
m_RenderData.pCurrentMonData->m_shBLUR1.program = prog;
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR1.tex = glGetUniformLocation(prog, "tex");
|
m_RenderData.pCurrentMonData->m_shBLUR1.tex = glGetUniformLocation(prog, "tex");
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR1.alpha = glGetUniformLocation(prog, "alpha");
|
m_RenderData.pCurrentMonData->m_shBLUR1.alpha = glGetUniformLocation(prog, "alpha");
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR1.proj = glGetUniformLocation(prog, "proj");
|
m_RenderData.pCurrentMonData->m_shBLUR1.proj = glGetUniformLocation(prog, "proj");
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR1.posAttrib = glGetAttribLocation(prog, "pos");
|
m_RenderData.pCurrentMonData->m_shBLUR1.posAttrib = glGetAttribLocation(prog, "pos");
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR1.texAttrib = glGetAttribLocation(prog, "texcoord");
|
m_RenderData.pCurrentMonData->m_shBLUR1.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR1.radius = glGetUniformLocation(prog, "radius");
|
m_RenderData.pCurrentMonData->m_shBLUR1.radius = glGetUniformLocation(prog, "radius");
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR1.halfpixel = glGetUniformLocation(prog, "halfpixel");
|
m_RenderData.pCurrentMonData->m_shBLUR1.halfpixel = glGetUniformLocation(prog, "halfpixel");
|
||||||
|
|
||||||
prog = createProgram(TEXVERTSRC, FRAGBLUR2);
|
prog = createProgram(TEXVERTSRC, FRAGBLUR2);
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR2.program = prog;
|
m_RenderData.pCurrentMonData->m_shBLUR2.program = prog;
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR2.tex = glGetUniformLocation(prog, "tex");
|
m_RenderData.pCurrentMonData->m_shBLUR2.tex = glGetUniformLocation(prog, "tex");
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR2.alpha = glGetUniformLocation(prog, "alpha");
|
m_RenderData.pCurrentMonData->m_shBLUR2.alpha = glGetUniformLocation(prog, "alpha");
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR2.proj = glGetUniformLocation(prog, "proj");
|
m_RenderData.pCurrentMonData->m_shBLUR2.proj = glGetUniformLocation(prog, "proj");
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR2.posAttrib = glGetAttribLocation(prog, "pos");
|
m_RenderData.pCurrentMonData->m_shBLUR2.posAttrib = glGetAttribLocation(prog, "pos");
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR2.texAttrib = glGetAttribLocation(prog, "texcoord");
|
m_RenderData.pCurrentMonData->m_shBLUR2.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR2.radius = glGetUniformLocation(prog, "radius");
|
m_RenderData.pCurrentMonData->m_shBLUR2.radius = glGetUniformLocation(prog, "radius");
|
||||||
m_RenderData.pCurrentMonData->m_shBLUR2.halfpixel = glGetUniformLocation(prog, "halfpixel");
|
m_RenderData.pCurrentMonData->m_shBLUR2.halfpixel = glGetUniformLocation(prog, "halfpixel");
|
||||||
|
|
||||||
prog = createProgram(QUADVERTSRC, FRAGSHADOW);
|
prog = createProgram(QUADVERTSRC, FRAGSHADOW);
|
||||||
m_RenderData.pCurrentMonData->m_shSHADOW.program = prog;
|
m_RenderData.pCurrentMonData->m_shSHADOW.program = prog;
|
||||||
m_RenderData.pCurrentMonData->m_shSHADOW.proj = glGetUniformLocation(prog, "proj");
|
m_RenderData.pCurrentMonData->m_shSHADOW.proj = glGetUniformLocation(prog, "proj");
|
||||||
m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib = glGetAttribLocation(prog, "pos");
|
m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib = glGetAttribLocation(prog, "pos");
|
||||||
m_RenderData.pCurrentMonData->m_shSHADOW.texAttrib = glGetAttribLocation(prog, "texcoord");
|
m_RenderData.pCurrentMonData->m_shSHADOW.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||||
m_RenderData.pCurrentMonData->m_shSHADOW.topLeft = glGetUniformLocation(prog, "topLeft");
|
m_RenderData.pCurrentMonData->m_shSHADOW.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||||
m_RenderData.pCurrentMonData->m_shSHADOW.bottomRight = glGetUniformLocation(prog, "bottomRight");
|
m_RenderData.pCurrentMonData->m_shSHADOW.bottomRight = glGetUniformLocation(prog, "bottomRight");
|
||||||
m_RenderData.pCurrentMonData->m_shSHADOW.fullSize = glGetUniformLocation(prog, "fullSize");
|
m_RenderData.pCurrentMonData->m_shSHADOW.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||||
m_RenderData.pCurrentMonData->m_shSHADOW.radius = glGetUniformLocation(prog, "radius");
|
m_RenderData.pCurrentMonData->m_shSHADOW.radius = glGetUniformLocation(prog, "radius");
|
||||||
m_RenderData.pCurrentMonData->m_shSHADOW.range = glGetUniformLocation(prog, "range");
|
m_RenderData.pCurrentMonData->m_shSHADOW.range = glGetUniformLocation(prog, "range");
|
||||||
m_RenderData.pCurrentMonData->m_shSHADOW.shadowPower = glGetUniformLocation(prog, "shadowPower");
|
m_RenderData.pCurrentMonData->m_shSHADOW.shadowPower = glGetUniformLocation(prog, "shadowPower");
|
||||||
m_RenderData.pCurrentMonData->m_shSHADOW.color = glGetUniformLocation(prog, "color");
|
m_RenderData.pCurrentMonData->m_shSHADOW.color = glGetUniformLocation(prog, "color");
|
||||||
|
|
||||||
prog = createProgram(QUADVERTSRC, FRAGBORDER1);
|
prog = createProgram(QUADVERTSRC, FRAGBORDER1);
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.program = prog;
|
m_RenderData.pCurrentMonData->m_shBORDER1.program = prog;
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.proj = glGetUniformLocation(prog, "proj");
|
m_RenderData.pCurrentMonData->m_shBORDER1.proj = glGetUniformLocation(prog, "proj");
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.thick = glGetUniformLocation(prog, "thick");
|
m_RenderData.pCurrentMonData->m_shBORDER1.thick = glGetUniformLocation(prog, "thick");
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib = glGetAttribLocation(prog, "pos");
|
m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib = glGetAttribLocation(prog, "pos");
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.texAttrib = glGetAttribLocation(prog, "texcoord");
|
m_RenderData.pCurrentMonData->m_shBORDER1.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.topLeft = glGetUniformLocation(prog, "topLeft");
|
m_RenderData.pCurrentMonData->m_shBORDER1.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.bottomRight = glGetUniformLocation(prog, "bottomRight");
|
m_RenderData.pCurrentMonData->m_shBORDER1.bottomRight = glGetUniformLocation(prog, "bottomRight");
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.fullSize = glGetUniformLocation(prog, "fullSize");
|
m_RenderData.pCurrentMonData->m_shBORDER1.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.fullSizeUntransformed = glGetUniformLocation(prog, "fullSizeUntransformed");
|
m_RenderData.pCurrentMonData->m_shBORDER1.fullSizeUntransformed = glGetUniformLocation(prog, "fullSizeUntransformed");
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.radius = glGetUniformLocation(prog, "radius");
|
m_RenderData.pCurrentMonData->m_shBORDER1.radius = glGetUniformLocation(prog, "radius");
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
m_RenderData.pCurrentMonData->m_shBORDER1.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.gradient = glGetUniformLocation(prog, "gradient");
|
m_RenderData.pCurrentMonData->m_shBORDER1.gradient = glGetUniformLocation(prog, "gradient");
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.gradientLength = glGetUniformLocation(prog, "gradientLength");
|
m_RenderData.pCurrentMonData->m_shBORDER1.gradientLength = glGetUniformLocation(prog, "gradientLength");
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.angle = glGetUniformLocation(prog, "angle");
|
m_RenderData.pCurrentMonData->m_shBORDER1.angle = glGetUniformLocation(prog, "angle");
|
||||||
m_RenderData.pCurrentMonData->m_shBORDER1.alpha = glGetUniformLocation(prog, "alpha");
|
m_RenderData.pCurrentMonData->m_shBORDER1.alpha = glGetUniformLocation(prog, "alpha");
|
||||||
|
|
||||||
m_RenderData.pCurrentMonData->m_bShadersInitialized = true;
|
m_RenderData.pCurrentMonData->m_bShadersInitialized = true;
|
||||||
|
|
||||||
|
@ -294,14 +295,14 @@ void CHyprOpenGLImpl::applyScreenShader(const std::string& path) {
|
||||||
std::string fragmentShader((std::istreambuf_iterator<char>(infile)), (std::istreambuf_iterator<char>()));
|
std::string fragmentShader((std::istreambuf_iterator<char>(infile)), (std::istreambuf_iterator<char>()));
|
||||||
|
|
||||||
m_sFinalScreenShader.program = createProgram(TEXVERTSRC, fragmentShader, true);
|
m_sFinalScreenShader.program = createProgram(TEXVERTSRC, fragmentShader, true);
|
||||||
|
|
||||||
if (!m_sFinalScreenShader.program) {
|
if (!m_sFinalScreenShader.program) {
|
||||||
g_pConfigManager->addParseError("Screen shader parser: Screen shader parse failed");
|
g_pConfigManager->addParseError("Screen shader parser: Screen shader parse failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sFinalScreenShader.proj = glGetUniformLocation(m_sFinalScreenShader.program, "proj");
|
m_sFinalScreenShader.proj = glGetUniformLocation(m_sFinalScreenShader.program, "proj");
|
||||||
m_sFinalScreenShader.tex = glGetUniformLocation(m_sFinalScreenShader.program, "tex");
|
m_sFinalScreenShader.tex = glGetUniformLocation(m_sFinalScreenShader.program, "tex");
|
||||||
m_sFinalScreenShader.texAttrib = glGetAttribLocation(m_sFinalScreenShader.program, "texcoord");
|
m_sFinalScreenShader.texAttrib = glGetAttribLocation(m_sFinalScreenShader.program, "texcoord");
|
||||||
m_sFinalScreenShader.posAttrib = glGetAttribLocation(m_sFinalScreenShader.program, "pos");
|
m_sFinalScreenShader.posAttrib = glGetAttribLocation(m_sFinalScreenShader.program, "pos");
|
||||||
}
|
}
|
||||||
|
@ -359,13 +360,13 @@ void CHyprOpenGLImpl::scissor(const pixman_box32* pBox, bool transform) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprOpenGLImpl::scissor(const int x, const int y, const int w, const int h, bool transform) {
|
void CHyprOpenGLImpl::scissor(const int x, const int y, const int w, const int h, bool transform) {
|
||||||
wlr_box box = {x,y,w,h};
|
wlr_box box = {x, y, w, h};
|
||||||
scissor(&box, transform);
|
scissor(&box, transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprOpenGLImpl::renderRect(wlr_box* box, const CColor& col, int round) {
|
void CHyprOpenGLImpl::renderRect(wlr_box* box, const CColor& col, int round) {
|
||||||
if(pixman_region32_not_empty(m_RenderData.pDamage))
|
if (pixman_region32_not_empty(m_RenderData.pDamage))
|
||||||
renderRectWithDamage(box, col, m_RenderData.pDamage, round);
|
renderRectWithDamage(box, col, m_RenderData.pDamage, round);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixman_region32_t* damage, int round) {
|
void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixman_region32_t* damage, int round) {
|
||||||
|
@ -373,7 +374,8 @@ void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixm
|
||||||
RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!");
|
RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!");
|
||||||
|
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
wlr_matrix_project_box(matrix, box, wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), 0, m_RenderData.pMonitor->output->transform_matrix); // TODO: write own, don't use WLR here
|
wlr_matrix_project_box(matrix, box, wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), 0,
|
||||||
|
m_RenderData.pMonitor->output->transform_matrix); // TODO: write own, don't use WLR here
|
||||||
|
|
||||||
float glMatrix[9];
|
float glMatrix[9];
|
||||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||||
|
@ -392,13 +394,13 @@ void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixm
|
||||||
glUniform4f(m_RenderData.pCurrentMonData->m_shQUAD.color, col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f);
|
glUniform4f(m_RenderData.pCurrentMonData->m_shQUAD.color, col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f);
|
||||||
|
|
||||||
wlr_box transformedBox;
|
wlr_box transformedBox;
|
||||||
wlr_box_transform(&transformedBox, box, wlr_output_transform_invert(m_RenderData.pMonitor->transform),
|
wlr_box_transform(&transformedBox, box, wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x,
|
||||||
m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y);
|
m_RenderData.pMonitor->vecTransformedSize.y);
|
||||||
|
|
||||||
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
||||||
const auto FULLSIZE = Vector2D(transformedBox.width, transformedBox.height);
|
const auto FULLSIZE = Vector2D(transformedBox.width, transformedBox.height);
|
||||||
|
|
||||||
static auto *const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue;
|
static auto* const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue;
|
||||||
|
|
||||||
// Rounded corners
|
// Rounded corners
|
||||||
glUniform2f(m_RenderData.pCurrentMonData->m_shQUAD.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y);
|
glUniform2f(m_RenderData.pCurrentMonData->m_shQUAD.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y);
|
||||||
|
@ -425,13 +427,13 @@ void CHyprOpenGLImpl::renderRectWithDamage(wlr_box* box, const CColor& col, pixm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pixman_region32_fini(&damageClip);
|
pixman_region32_fini(&damageClip);
|
||||||
} else {
|
} else {
|
||||||
PIXMAN_DAMAGE_FOREACH(damage) {
|
PIXMAN_DAMAGE_FOREACH(damage) {
|
||||||
const auto RECT = RECTSARR[i];
|
const auto RECT = RECTSARR[i];
|
||||||
scissor(&RECT);
|
scissor(&RECT);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shQUAD.posAttrib);
|
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shQUAD.posAttrib);
|
||||||
|
@ -454,18 +456,19 @@ void CHyprOpenGLImpl::renderTexture(const CTexture& tex, wlr_box* pBox, float al
|
||||||
scissor((wlr_box*)nullptr);
|
scissor((wlr_box*)nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_box* pBox, float alpha, pixman_region32_t* damage, int round, bool discardOpaque, bool noAA, bool allowCustomUV, bool allowDim) {
|
void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_box* pBox, float alpha, pixman_region32_t* damage, int round, bool discardOpaque, bool noAA,
|
||||||
|
bool allowCustomUV, bool allowDim) {
|
||||||
RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!");
|
RASSERT(m_RenderData.pMonitor, "Tried to render texture without begin()!");
|
||||||
RASSERT((tex.m_iTexID > 0), "Attempted to draw NULL texture!");
|
RASSERT((tex.m_iTexID > 0), "Attempted to draw NULL texture!");
|
||||||
|
|
||||||
if (!pixman_region32_not_empty(m_RenderData.pDamage))
|
if (!pixman_region32_not_empty(m_RenderData.pDamage))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static auto *const PDIMINACTIVE = &g_pConfigManager->getConfigValuePtr("decoration:dim_inactive")->intValue;
|
static auto* const PDIMINACTIVE = &g_pConfigManager->getConfigValuePtr("decoration:dim_inactive")->intValue;
|
||||||
|
|
||||||
// get transform
|
// get transform
|
||||||
const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform);
|
const auto TRANSFORM = wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform);
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
wlr_matrix_project_box(matrix, pBox, TRANSFORM, 0, m_RenderData.pMonitor->output->transform_matrix);
|
wlr_matrix_project_box(matrix, pBox, TRANSFORM, 0, m_RenderData.pMonitor->output->transform_matrix);
|
||||||
|
|
||||||
float glMatrix[9];
|
float glMatrix[9];
|
||||||
|
@ -479,21 +482,14 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
|
||||||
bool usingFinalShader = false;
|
bool usingFinalShader = false;
|
||||||
|
|
||||||
if (m_bApplyFinalShader && m_sFinalScreenShader.program) {
|
if (m_bApplyFinalShader && m_sFinalScreenShader.program) {
|
||||||
shader = &m_sFinalScreenShader;
|
shader = &m_sFinalScreenShader;
|
||||||
usingFinalShader = true;
|
usingFinalShader = true;
|
||||||
} else {
|
} else {
|
||||||
switch (tex.m_iType) {
|
switch (tex.m_iType) {
|
||||||
case TEXTURE_RGBA:
|
case TEXTURE_RGBA: shader = &m_RenderData.pCurrentMonData->m_shRGBA; break;
|
||||||
shader = &m_RenderData.pCurrentMonData->m_shRGBA;
|
case TEXTURE_RGBX: shader = &m_RenderData.pCurrentMonData->m_shRGBX; break;
|
||||||
break;
|
case TEXTURE_EXTERNAL: shader = &m_RenderData.pCurrentMonData->m_shEXT; break;
|
||||||
case TEXTURE_RGBX:
|
default: RASSERT(false, "tex.m_iTarget unsupported!");
|
||||||
shader = &m_RenderData.pCurrentMonData->m_shRGBX;
|
|
||||||
break;
|
|
||||||
case TEXTURE_EXTERNAL:
|
|
||||||
shader = &m_RenderData.pCurrentMonData->m_shEXT;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
RASSERT(false, "tex.m_iTarget unsupported!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -517,12 +513,12 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_box transformedBox;
|
wlr_box transformedBox;
|
||||||
wlr_box_transform(&transformedBox, pBox, wlr_output_transform_invert(m_RenderData.pMonitor->transform),
|
wlr_box_transform(&transformedBox, pBox, wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x,
|
||||||
m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y);
|
m_RenderData.pMonitor->vecTransformedSize.y);
|
||||||
|
|
||||||
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
||||||
const auto FULLSIZE = Vector2D(transformedBox.width, transformedBox.height);
|
const auto FULLSIZE = Vector2D(transformedBox.width, transformedBox.height);
|
||||||
static auto *const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue;
|
static auto* const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue;
|
||||||
|
|
||||||
if (!usingFinalShader) {
|
if (!usingFinalShader) {
|
||||||
// Rounded corners
|
// Rounded corners
|
||||||
|
@ -541,10 +537,10 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
|
||||||
}
|
}
|
||||||
|
|
||||||
const float verts[] = {
|
const float verts[] = {
|
||||||
m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVTopLeft.y, // top right
|
m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVTopLeft.y, // top right
|
||||||
m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVTopLeft.y, // top left
|
m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVTopLeft.y, // top left
|
||||||
m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom right
|
m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom right
|
||||||
m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom left
|
m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom left
|
||||||
};
|
};
|
||||||
|
|
||||||
glVertexAttribPointer(shader->posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
|
glVertexAttribPointer(shader->posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
|
||||||
|
@ -571,13 +567,13 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pixman_region32_fini(&damageClip);
|
pixman_region32_fini(&damageClip);
|
||||||
} else {
|
} else {
|
||||||
PIXMAN_DAMAGE_FOREACH(damage) {
|
PIXMAN_DAMAGE_FOREACH(damage) {
|
||||||
const auto RECT = RECTSARR[i];
|
const auto RECT = RECTSARR[i];
|
||||||
scissor(&RECT);
|
scissor(&RECT);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisableVertexAttribArray(shader->posAttrib);
|
glDisableVertexAttribArray(shader->posAttrib);
|
||||||
|
@ -597,27 +593,28 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p
|
||||||
|
|
||||||
// get transforms for the full monitor
|
// get transforms for the full monitor
|
||||||
const auto TRANSFORM = wlr_output_transform_invert(m_RenderData.pMonitor->transform);
|
const auto TRANSFORM = wlr_output_transform_invert(m_RenderData.pMonitor->transform);
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
||||||
wlr_matrix_project_box(matrix, &MONITORBOX, TRANSFORM, 0, m_RenderData.pMonitor->output->transform_matrix);
|
wlr_matrix_project_box(matrix, &MONITORBOX, TRANSFORM, 0, m_RenderData.pMonitor->output->transform_matrix);
|
||||||
|
|
||||||
float glMatrix[9];
|
float glMatrix[9];
|
||||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||||
|
|
||||||
// get the config settings
|
// get the config settings
|
||||||
static auto *const PBLURSIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_size")->intValue;
|
static auto* const PBLURSIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_size")->intValue;
|
||||||
static auto *const PBLURPASSES = &g_pConfigManager->getConfigValuePtr("decoration:blur_passes")->intValue;
|
static auto* const PBLURPASSES = &g_pConfigManager->getConfigValuePtr("decoration:blur_passes")->intValue;
|
||||||
|
|
||||||
// prep damage
|
// prep damage
|
||||||
pixman_region32_t damage;
|
pixman_region32_t damage;
|
||||||
pixman_region32_init(&damage);
|
pixman_region32_init(&damage);
|
||||||
pixman_region32_copy(&damage, originalDamage);
|
pixman_region32_copy(&damage, originalDamage);
|
||||||
wlr_region_transform(&damage, &damage, wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y);
|
wlr_region_transform(&damage, &damage, wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x,
|
||||||
|
m_RenderData.pMonitor->vecTransformedSize.y);
|
||||||
wlr_region_expand(&damage, &damage, pow(2, *PBLURPASSES) * *PBLURSIZE);
|
wlr_region_expand(&damage, &damage, pow(2, *PBLURPASSES) * *PBLURSIZE);
|
||||||
|
|
||||||
// helper
|
// helper
|
||||||
const auto PMIRRORFB = &m_RenderData.pCurrentMonData->mirrorFB;
|
const auto PMIRRORFB = &m_RenderData.pCurrentMonData->mirrorFB;
|
||||||
const auto PMIRRORSWAPFB = &m_RenderData.pCurrentMonData->mirrorSwapFB;
|
const auto PMIRRORSWAPFB = &m_RenderData.pCurrentMonData->mirrorSwapFB;
|
||||||
|
|
||||||
CFramebuffer* currentRenderToFB = &m_RenderData.pCurrentMonData->primaryFB;
|
CFramebuffer* currentRenderToFB = &m_RenderData.pCurrentMonData->primaryFB;
|
||||||
|
|
||||||
|
@ -643,11 +640,13 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p
|
||||||
wlr_matrix_transpose(glMatrix, glMatrix);
|
wlr_matrix_transpose(glMatrix, glMatrix);
|
||||||
glUniformMatrix3fv(pShader->proj, 1, GL_FALSE, glMatrix);
|
glUniformMatrix3fv(pShader->proj, 1, GL_FALSE, glMatrix);
|
||||||
#endif
|
#endif
|
||||||
glUniform1f(pShader->radius, *PBLURSIZE * (a / 255.f)); // this makes the blursize change with a
|
glUniform1f(pShader->radius, *PBLURSIZE * (a / 255.f)); // this makes the blursize change with a
|
||||||
if (pShader == &m_RenderData.pCurrentMonData->m_shBLUR1)
|
if (pShader == &m_RenderData.pCurrentMonData->m_shBLUR1)
|
||||||
glUniform2f(m_RenderData.pCurrentMonData->m_shBLUR1.halfpixel, 0.5f / (m_RenderData.pMonitor->vecPixelSize.x / 2.f), 0.5f / (m_RenderData.pMonitor->vecPixelSize.y / 2.f));
|
glUniform2f(m_RenderData.pCurrentMonData->m_shBLUR1.halfpixel, 0.5f / (m_RenderData.pMonitor->vecPixelSize.x / 2.f),
|
||||||
|
0.5f / (m_RenderData.pMonitor->vecPixelSize.y / 2.f));
|
||||||
else
|
else
|
||||||
glUniform2f(m_RenderData.pCurrentMonData->m_shBLUR2.halfpixel, 0.5f / (m_RenderData.pMonitor->vecPixelSize.x * 2.f), 0.5f / (m_RenderData.pMonitor->vecPixelSize.y * 2.f));
|
glUniform2f(m_RenderData.pCurrentMonData->m_shBLUR2.halfpixel, 0.5f / (m_RenderData.pMonitor->vecPixelSize.x * 2.f),
|
||||||
|
0.5f / (m_RenderData.pMonitor->vecPixelSize.y * 2.f));
|
||||||
glUniform1i(pShader->tex, 0);
|
glUniform1i(pShader->tex, 0);
|
||||||
|
|
||||||
glVertexAttribPointer(pShader->posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
|
glVertexAttribPointer(pShader->posAttrib, 2, GL_FLOAT, GL_FALSE, 0, fullVerts);
|
||||||
|
@ -682,19 +681,19 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p
|
||||||
// damage region will be scaled, make a temp
|
// damage region will be scaled, make a temp
|
||||||
pixman_region32_t tempDamage;
|
pixman_region32_t tempDamage;
|
||||||
pixman_region32_init(&tempDamage);
|
pixman_region32_init(&tempDamage);
|
||||||
wlr_region_scale(&tempDamage, &damage, 1.f / 2.f); // when DOWNscaling, we make the region twice as small because it's the TARGET
|
wlr_region_scale(&tempDamage, &damage, 1.f / 2.f); // when DOWNscaling, we make the region twice as small because it's the TARGET
|
||||||
|
|
||||||
drawPass(&m_RenderData.pCurrentMonData->m_shBLUR1, &tempDamage);
|
drawPass(&m_RenderData.pCurrentMonData->m_shBLUR1, &tempDamage);
|
||||||
|
|
||||||
// and draw
|
// and draw
|
||||||
for (int i = 1; i < *PBLURPASSES; ++i) {
|
for (int i = 1; i < *PBLURPASSES; ++i) {
|
||||||
wlr_region_scale(&tempDamage, &damage, 1.f / (1 << (i + 1)));
|
wlr_region_scale(&tempDamage, &damage, 1.f / (1 << (i + 1)));
|
||||||
drawPass(&m_RenderData.pCurrentMonData->m_shBLUR1, &tempDamage); // down
|
drawPass(&m_RenderData.pCurrentMonData->m_shBLUR1, &tempDamage); // down
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = *PBLURPASSES - 1; i >= 0; --i) {
|
for (int i = *PBLURPASSES - 1; i >= 0; --i) {
|
||||||
wlr_region_scale(&tempDamage, &damage, 1.f / (1 << i)); // when upsampling we make the region twice as big
|
wlr_region_scale(&tempDamage, &damage, 1.f / (1 << i)); // when upsampling we make the region twice as big
|
||||||
drawPass(&m_RenderData.pCurrentMonData->m_shBLUR2, &tempDamage); // up
|
drawPass(&m_RenderData.pCurrentMonData->m_shBLUR2, &tempDamage); // up
|
||||||
}
|
}
|
||||||
|
|
||||||
// finish
|
// finish
|
||||||
|
@ -714,9 +713,9 @@ void CHyprOpenGLImpl::markBlurDirtyForMonitor(CMonitor* pMonitor) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprOpenGLImpl::preRender(CMonitor* pMonitor) {
|
void CHyprOpenGLImpl::preRender(CMonitor* pMonitor) {
|
||||||
static auto *const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue;
|
static auto* const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue;
|
||||||
static auto *const PBLURXRAY = &g_pConfigManager->getConfigValuePtr("decoration:blur_xray")->intValue;
|
static auto* const PBLURXRAY = &g_pConfigManager->getConfigValuePtr("decoration:blur_xray")->intValue;
|
||||||
static auto *const PBLUR = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue;
|
static auto* const PBLUR = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue;
|
||||||
|
|
||||||
if (!*PBLURNEWOPTIMIZE || !m_mMonitorRenderResources[pMonitor].blurFBDirty || !*PBLUR)
|
if (!*PBLURNEWOPTIMIZE || !m_mMonitorRenderResources[pMonitor].blurFBDirty || !*PBLUR)
|
||||||
return;
|
return;
|
||||||
|
@ -739,14 +738,14 @@ void CHyprOpenGLImpl::preBlurForCurrentMonitor() {
|
||||||
// make the fake dmg
|
// make the fake dmg
|
||||||
pixman_region32_t fakeDamage;
|
pixman_region32_t fakeDamage;
|
||||||
pixman_region32_init_rect(&fakeDamage, 0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y);
|
pixman_region32_init_rect(&fakeDamage, 0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y);
|
||||||
wlr_box wholeMonitor = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
wlr_box wholeMonitor = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
||||||
const auto POUTFB = blurMainFramebufferWithDamage(255, &wholeMonitor, &fakeDamage);
|
const auto POUTFB = blurMainFramebufferWithDamage(255, &wholeMonitor, &fakeDamage);
|
||||||
|
|
||||||
// render onto blurFB
|
// render onto blurFB
|
||||||
m_RenderData.pCurrentMonData->blurFB.alloc(m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y);
|
m_RenderData.pCurrentMonData->blurFB.alloc(m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y);
|
||||||
m_RenderData.pCurrentMonData->blurFB.bind();
|
m_RenderData.pCurrentMonData->blurFB.bind();
|
||||||
|
|
||||||
clear(CColor(0,0,0,0));
|
clear(CColor(0, 0, 0, 0));
|
||||||
|
|
||||||
m_bEndFrame = true; // fix transformed
|
m_bEndFrame = true; // fix transformed
|
||||||
renderTextureInternalWithDamage(POUTFB->m_cTex, &wholeMonitor, 255, &fakeDamage, 0, false, true, false);
|
renderTextureInternalWithDamage(POUTFB->m_cTex, &wholeMonitor, 255, &fakeDamage, 0, false, true, false);
|
||||||
|
@ -760,14 +759,14 @@ void CHyprOpenGLImpl::preBlurForCurrentMonitor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprOpenGLImpl::preWindowPass() {
|
void CHyprOpenGLImpl::preWindowPass() {
|
||||||
static auto *const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue;
|
static auto* const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue;
|
||||||
static auto *const PBLURXRAY = &g_pConfigManager->getConfigValuePtr("decoration:blur_xray")->intValue;
|
static auto* const PBLURXRAY = &g_pConfigManager->getConfigValuePtr("decoration:blur_xray")->intValue;
|
||||||
static auto *const PBLUR = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue;
|
static auto* const PBLUR = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue;
|
||||||
|
|
||||||
if (!m_RenderData.pCurrentMonData->blurFBDirty || !*PBLURNEWOPTIMIZE || !*PBLUR)
|
if (!m_RenderData.pCurrentMonData->blurFBDirty || !*PBLURNEWOPTIMIZE || !*PBLUR)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto windowShouldBeBlurred = [&] (CWindow* pWindow) -> bool {
|
auto windowShouldBeBlurred = [&](CWindow* pWindow) -> bool {
|
||||||
if (!pWindow)
|
if (!pWindow)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -781,8 +780,8 @@ void CHyprOpenGLImpl::preWindowPass() {
|
||||||
|
|
||||||
pixman_region32_t inverseOpaque;
|
pixman_region32_t inverseOpaque;
|
||||||
pixman_region32_init(&inverseOpaque);
|
pixman_region32_init(&inverseOpaque);
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
||||||
const float A = pWindow->m_fAlpha.fl() * pWindow->m_fActiveInactiveAlpha.fl() * PWORKSPACE->m_fAlpha.fl() / 255.f;
|
const float A = pWindow->m_fAlpha.fl() * pWindow->m_fActiveInactiveAlpha.fl() * PWORKSPACE->m_fAlpha.fl() / 255.f;
|
||||||
|
|
||||||
if (A >= 255.f) {
|
if (A >= 255.f) {
|
||||||
pixman_box32_t surfbox = {0, 0, PSURFACE->current.width, PSURFACE->current.height};
|
pixman_box32_t surfbox = {0, 0, PSURFACE->current.width, PSURFACE->current.height};
|
||||||
|
@ -808,7 +807,7 @@ void CHyprOpenGLImpl::preWindowPass() {
|
||||||
// check if window is valid
|
// check if window is valid
|
||||||
if (!windowShouldBeBlurred(w.get()))
|
if (!windowShouldBeBlurred(w.get()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
hasWindows = true;
|
hasWindows = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -824,20 +823,21 @@ void CHyprOpenGLImpl::preWindowPass() {
|
||||||
void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, float a, wlr_surface* pSurface, int round, bool blockBlurOptimization) {
|
void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox, float a, wlr_surface* pSurface, int round, bool blockBlurOptimization) {
|
||||||
RASSERT(m_RenderData.pMonitor, "Tried to render texture with blur without begin()!");
|
RASSERT(m_RenderData.pMonitor, "Tried to render texture with blur without begin()!");
|
||||||
|
|
||||||
static auto *const PBLURENABLED = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue;
|
static auto* const PBLURENABLED = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue;
|
||||||
static auto *const PNOBLUROVERSIZED = &g_pConfigManager->getConfigValuePtr("decoration:no_blur_on_oversized")->intValue;
|
static auto* const PNOBLUROVERSIZED = &g_pConfigManager->getConfigValuePtr("decoration:no_blur_on_oversized")->intValue;
|
||||||
static auto *const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue;
|
static auto* const PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue;
|
||||||
static auto *const PBLURXRAY = &g_pConfigManager->getConfigValuePtr("decoration:blur_xray")->intValue;
|
static auto* const PBLURXRAY = &g_pConfigManager->getConfigValuePtr("decoration:blur_xray")->intValue;
|
||||||
|
|
||||||
// make a damage region for this window
|
// make a damage region for this window
|
||||||
pixman_region32_t damage;
|
pixman_region32_t damage;
|
||||||
pixman_region32_init(&damage);
|
pixman_region32_init(&damage);
|
||||||
pixman_region32_intersect_rect(&damage, m_RenderData.pDamage, pBox->x, pBox->y, pBox->width, pBox->height); // clip it to the box
|
pixman_region32_intersect_rect(&damage, m_RenderData.pDamage, pBox->x, pBox->y, pBox->width, pBox->height); // clip it to the box
|
||||||
|
|
||||||
if(!pixman_region32_not_empty(&damage))
|
if (!pixman_region32_not_empty(&damage))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (*PBLURENABLED == 0 || (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) || (m_pCurrentWindow && m_pCurrentWindow->m_sAdditionalConfigData.forceNoBlur)) {
|
if (*PBLURENABLED == 0 || (*PNOBLUROVERSIZED && m_RenderData.primarySurfaceUVTopLeft != Vector2D(-1, -1)) ||
|
||||||
|
(m_pCurrentWindow && m_pCurrentWindow->m_sAdditionalConfigData.forceNoBlur)) {
|
||||||
renderTexture(tex, pBox, a, round, false, true);
|
renderTexture(tex, pBox, a, round, false, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -861,7 +861,9 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
|
||||||
}
|
}
|
||||||
|
|
||||||
// vvv TODO: layered blur fbs?
|
// vvv TODO: layered blur fbs?
|
||||||
const bool USENEWOPTIMIZE = (*PBLURNEWOPTIMIZE && !blockBlurOptimization && ((m_pCurrentWindow && !m_pCurrentWindow->m_bIsFloating) || *PBLURXRAY) && m_RenderData.pCurrentMonData->blurFB.m_cTex.m_iTexID && (!m_pCurrentWindow || !g_pCompositor->isWorkspaceSpecial(m_pCurrentWindow->m_iWorkspaceID) ));
|
const bool USENEWOPTIMIZE =
|
||||||
|
(*PBLURNEWOPTIMIZE && !blockBlurOptimization && ((m_pCurrentWindow && !m_pCurrentWindow->m_bIsFloating) || *PBLURXRAY) &&
|
||||||
|
m_RenderData.pCurrentMonData->blurFB.m_cTex.m_iTexID && (!m_pCurrentWindow || !g_pCompositor->isWorkspaceSpecial(m_pCurrentWindow->m_iWorkspaceID)));
|
||||||
|
|
||||||
CFramebuffer* POUTFB = nullptr;
|
CFramebuffer* POUTFB = nullptr;
|
||||||
if (!USENEWOPTIMIZE) {
|
if (!USENEWOPTIMIZE) {
|
||||||
|
@ -886,7 +888,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
|
||||||
m_RenderData.pCurrentMonData->primaryFB.bind();
|
m_RenderData.pCurrentMonData->primaryFB.bind();
|
||||||
|
|
||||||
// make a stencil for rounded corners to work with blur
|
// make a stencil for rounded corners to work with blur
|
||||||
scissor((wlr_box*)nullptr); // allow the entire window and stencil to render
|
scissor((wlr_box*)nullptr); // allow the entire window and stencil to render
|
||||||
glClearStencil(0);
|
glClearStencil(0);
|
||||||
glClear(GL_STENCIL_BUFFER_BIT);
|
glClear(GL_STENCIL_BUFFER_BIT);
|
||||||
|
|
||||||
|
@ -897,9 +899,9 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
|
||||||
|
|
||||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||||
if (USENEWOPTIMIZE)
|
if (USENEWOPTIMIZE)
|
||||||
renderRect(pBox, CColor(0,0,0,0), round);
|
renderRect(pBox, CColor(0, 0, 0, 0), round);
|
||||||
else
|
else
|
||||||
renderTexture(tex, pBox, a, round, true, true); // discard opaque
|
renderTexture(tex, pBox, a, round, true, true); // discard opaque
|
||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||||
|
|
||||||
glStencilFunc(GL_EQUAL, 1, -1);
|
glStencilFunc(GL_EQUAL, 1, -1);
|
||||||
|
@ -908,8 +910,8 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
|
||||||
// stencil done. Render everything.
|
// stencil done. Render everything.
|
||||||
wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
||||||
// render our great blurred FB
|
// render our great blurred FB
|
||||||
static auto *const PBLURIGNOREOPACITY = &g_pConfigManager->getConfigValuePtr("decoration:blur_ignore_opacity")->intValue;
|
static auto* const PBLURIGNOREOPACITY = &g_pConfigManager->getConfigValuePtr("decoration:blur_ignore_opacity")->intValue;
|
||||||
m_bEndFrame = true; // fix transformed
|
m_bEndFrame = true; // fix transformed
|
||||||
renderTextureInternalWithDamage(POUTFB->m_cTex, &MONITORBOX, *PBLURIGNOREOPACITY ? 255.f : a, &damage, 0, false, false, false);
|
renderTextureInternalWithDamage(POUTFB->m_cTex, &MONITORBOX, *PBLURIGNOREOPACITY ? 255.f : a, &damage, 0, false, false, false);
|
||||||
m_bEndFrame = false;
|
m_bEndFrame = false;
|
||||||
|
|
||||||
|
@ -939,10 +941,10 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad,
|
||||||
RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!");
|
RASSERT(m_RenderData.pMonitor, "Tried to render rect without begin()!");
|
||||||
|
|
||||||
if (!pixman_region32_not_empty(m_RenderData.pDamage) || (m_pCurrentWindow && m_pCurrentWindow->m_sAdditionalConfigData.forceNoBorder))
|
if (!pixman_region32_not_empty(m_RenderData.pDamage) || (m_pCurrentWindow && m_pCurrentWindow->m_sAdditionalConfigData.forceNoBorder))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static auto *const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||||
static auto *const PMULTISAMPLE = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue;
|
static auto* const PMULTISAMPLE = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue;
|
||||||
|
|
||||||
if (*PBORDERSIZE < 1)
|
if (*PBORDERSIZE < 1)
|
||||||
return;
|
return;
|
||||||
|
@ -958,7 +960,8 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad,
|
||||||
round += round == 0 ? 0 : scaledBorderSize;
|
round += round == 0 ? 0 : scaledBorderSize;
|
||||||
|
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
wlr_matrix_project_box(matrix, box, wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), 0, m_RenderData.pMonitor->output->transform_matrix); // TODO: write own, don't use WLR here
|
wlr_matrix_project_box(matrix, box, wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), 0,
|
||||||
|
m_RenderData.pMonitor->output->transform_matrix); // TODO: write own, don't use WLR here
|
||||||
|
|
||||||
float glMatrix[9];
|
float glMatrix[9];
|
||||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||||
|
@ -983,10 +986,10 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad,
|
||||||
glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.alpha, a);
|
glUniform1f(m_RenderData.pCurrentMonData->m_shBORDER1.alpha, a);
|
||||||
|
|
||||||
wlr_box transformedBox;
|
wlr_box transformedBox;
|
||||||
wlr_box_transform(&transformedBox, box, wlr_output_transform_invert(m_RenderData.pMonitor->transform),
|
wlr_box_transform(&transformedBox, box, wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x,
|
||||||
m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y);
|
m_RenderData.pMonitor->vecTransformedSize.y);
|
||||||
|
|
||||||
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
||||||
const auto FULLSIZE = Vector2D(transformedBox.width, transformedBox.height);
|
const auto FULLSIZE = Vector2D(transformedBox.width, transformedBox.height);
|
||||||
|
|
||||||
glUniform2f(m_RenderData.pCurrentMonData->m_shBORDER1.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y);
|
glUniform2f(m_RenderData.pCurrentMonData->m_shBORDER1.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y);
|
||||||
|
@ -1015,13 +1018,13 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pixman_region32_fini(&damageClip);
|
pixman_region32_fini(&damageClip);
|
||||||
} else {
|
} else {
|
||||||
PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) {
|
PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) {
|
||||||
const auto RECT = RECTSARR[i];
|
const auto RECT = RECTSARR[i];
|
||||||
scissor(&RECT);
|
scissor(&RECT);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib);
|
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib);
|
||||||
|
@ -1050,7 +1053,7 @@ void CHyprOpenGLImpl::makeRawWindowSnapshot(CWindow* pWindow, CFramebuffer* pFra
|
||||||
|
|
||||||
begin(PMONITOR, &fakeDamage, true);
|
begin(PMONITOR, &fakeDamage, true);
|
||||||
|
|
||||||
clear(CColor(0, 0, 0, 0)); // JIC
|
clear(CColor(0, 0, 0, 0)); // JIC
|
||||||
|
|
||||||
timespec now;
|
timespec now;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
@ -1072,7 +1075,7 @@ void CHyprOpenGLImpl::makeRawWindowSnapshot(CWindow* pWindow, CFramebuffer* pFra
|
||||||
|
|
||||||
pFramebuffer->bind();
|
pFramebuffer->bind();
|
||||||
|
|
||||||
clear(CColor(0, 0, 0, 0)); // JIC
|
clear(CColor(0, 0, 0, 0)); // JIC
|
||||||
|
|
||||||
g_pHyprRenderer->renderWindow(pWindow, PMONITOR, &now, false, RENDER_PASS_ALL, true);
|
g_pHyprRenderer->renderWindow(pWindow, PMONITOR, &now, false, RENDER_PASS_ALL, true);
|
||||||
|
|
||||||
|
@ -1105,7 +1108,7 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) {
|
||||||
|
|
||||||
begin(PMONITOR, &fakeDamage, true);
|
begin(PMONITOR, &fakeDamage, true);
|
||||||
|
|
||||||
clear(CColor(0, 0, 0, 0)); // JIC
|
clear(CColor(0, 0, 0, 0)); // JIC
|
||||||
|
|
||||||
timespec now;
|
timespec now;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
@ -1128,7 +1131,7 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) {
|
||||||
|
|
||||||
PFRAMEBUFFER->bind();
|
PFRAMEBUFFER->bind();
|
||||||
|
|
||||||
clear(CColor(0, 0, 0, 0)); // JIC
|
clear(CColor(0, 0, 0, 0)); // JIC
|
||||||
|
|
||||||
g_pHyprRenderer->renderWindow(pWindow, PMONITOR, &now, !pWindow->m_bX11DoesntWantBorders, RENDER_PASS_ALL);
|
g_pHyprRenderer->renderWindow(pWindow, PMONITOR, &now, !pWindow->m_bX11DoesntWantBorders, RENDER_PASS_ALL);
|
||||||
|
|
||||||
|
@ -1169,13 +1172,13 @@ void CHyprOpenGLImpl::makeLayerSnapshot(SLayerSurface* pLayer) {
|
||||||
|
|
||||||
PFRAMEBUFFER->bind();
|
PFRAMEBUFFER->bind();
|
||||||
|
|
||||||
clear(CColor(0, 0, 0, 0)); // JIC
|
clear(CColor(0, 0, 0, 0)); // JIC
|
||||||
|
|
||||||
timespec now;
|
timespec now;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
|
|
||||||
const auto BLURLSSTATUS = pLayer->forceBlur;
|
const auto BLURLSSTATUS = pLayer->forceBlur;
|
||||||
pLayer->forceBlur = false;
|
pLayer->forceBlur = false;
|
||||||
|
|
||||||
// draw the layer
|
// draw the layer
|
||||||
g_pHyprRenderer->renderLayer(pLayer, PMONITOR, &now);
|
g_pHyprRenderer->renderLayer(pLayer, PMONITOR, &now);
|
||||||
|
@ -1199,19 +1202,15 @@ void CHyprOpenGLImpl::makeLayerSnapshot(SLayerSurface* pLayer) {
|
||||||
wlr_output_rollback(PMONITOR->output);
|
wlr_output_rollback(PMONITOR->output);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprOpenGLImpl::onWindowResizeStart(CWindow* pWindow) {
|
void CHyprOpenGLImpl::onWindowResizeStart(CWindow* pWindow) {}
|
||||||
|
|
||||||
}
|
void CHyprOpenGLImpl::onWindowResizeEnd(CWindow* pWindow) {}
|
||||||
|
|
||||||
void CHyprOpenGLImpl::onWindowResizeEnd(CWindow* pWindow) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHyprOpenGLImpl::renderSnapshot(CWindow** pWindow) {
|
void CHyprOpenGLImpl::renderSnapshot(CWindow** pWindow) {
|
||||||
RASSERT(m_RenderData.pMonitor, "Tried to render snapshot rect without begin()!");
|
RASSERT(m_RenderData.pMonitor, "Tried to render snapshot rect without begin()!");
|
||||||
const auto PWINDOW = *pWindow;
|
const auto PWINDOW = *pWindow;
|
||||||
|
|
||||||
auto it = m_mWindowFramebuffers.begin();
|
auto it = m_mWindowFramebuffers.begin();
|
||||||
for (; it != m_mWindowFramebuffers.end(); it++) {
|
for (; it != m_mWindowFramebuffers.end(); it++) {
|
||||||
if (it->first == PWINDOW) {
|
if (it->first == PWINDOW) {
|
||||||
break;
|
break;
|
||||||
|
@ -1223,15 +1222,16 @@ void CHyprOpenGLImpl::renderSnapshot(CWindow** pWindow) {
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||||
|
|
||||||
wlr_box windowBox;
|
wlr_box windowBox;
|
||||||
// some mafs to figure out the correct box
|
// some mafs to figure out the correct box
|
||||||
// the originalClosedPos is relative to the monitor's pos
|
// the originalClosedPos is relative to the monitor's pos
|
||||||
Vector2D scaleXY = Vector2D((PMONITOR->scale * PWINDOW->m_vRealSize.vec().x / (PWINDOW->m_vOriginalClosedSize.x * PMONITOR->scale)), (PMONITOR->scale * PWINDOW->m_vRealSize.vec().y / (PWINDOW->m_vOriginalClosedSize.y * PMONITOR->scale)));
|
Vector2D scaleXY = Vector2D((PMONITOR->scale * PWINDOW->m_vRealSize.vec().x / (PWINDOW->m_vOriginalClosedSize.x * PMONITOR->scale)),
|
||||||
|
(PMONITOR->scale * PWINDOW->m_vRealSize.vec().y / (PWINDOW->m_vOriginalClosedSize.y * PMONITOR->scale)));
|
||||||
|
|
||||||
windowBox.width = PMONITOR->vecTransformedSize.x * scaleXY.x;
|
windowBox.width = PMONITOR->vecTransformedSize.x * scaleXY.x;
|
||||||
windowBox.height = PMONITOR->vecTransformedSize.y * scaleXY.y;
|
windowBox.height = PMONITOR->vecTransformedSize.y * scaleXY.y;
|
||||||
windowBox.x = ((PWINDOW->m_vRealPosition.vec().x - PMONITOR->vecPosition.x) * PMONITOR->scale) - ((PWINDOW->m_vOriginalClosedPos.x * PMONITOR->scale) * scaleXY.x);
|
windowBox.x = ((PWINDOW->m_vRealPosition.vec().x - PMONITOR->vecPosition.x) * PMONITOR->scale) - ((PWINDOW->m_vOriginalClosedPos.x * PMONITOR->scale) * scaleXY.x);
|
||||||
windowBox.y = ((PWINDOW->m_vRealPosition.vec().y - PMONITOR->vecPosition.y) * PMONITOR->scale) - ((PWINDOW->m_vOriginalClosedPos.y * PMONITOR->scale) * scaleXY.y);
|
windowBox.y = ((PWINDOW->m_vRealPosition.vec().y - PMONITOR->vecPosition.y) * PMONITOR->scale) - ((PWINDOW->m_vOriginalClosedPos.y * PMONITOR->scale) * scaleXY.y);
|
||||||
|
|
||||||
pixman_region32_t fakeDamage;
|
pixman_region32_t fakeDamage;
|
||||||
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y);
|
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y);
|
||||||
|
@ -1244,7 +1244,7 @@ void CHyprOpenGLImpl::renderSnapshot(CWindow** pWindow) {
|
||||||
|
|
||||||
pixman_region32_fini(&fakeDamage);
|
pixman_region32_fini(&fakeDamage);
|
||||||
|
|
||||||
static auto *const PDAMAGEMON = &g_pConfigManager->getConfigValuePtr("misc:damage_entire_on_snapshot")->intValue;
|
static auto* const PDAMAGEMON = &g_pConfigManager->getConfigValuePtr("misc:damage_entire_on_snapshot")->intValue;
|
||||||
|
|
||||||
if (*PDAMAGEMON)
|
if (*PDAMAGEMON)
|
||||||
PMONITOR->forceFullFrames += 1;
|
PMONITOR->forceFullFrames += 1;
|
||||||
|
@ -1254,7 +1254,7 @@ void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) {
|
||||||
RASSERT(m_RenderData.pMonitor, "Tried to render snapshot rect without begin()!");
|
RASSERT(m_RenderData.pMonitor, "Tried to render snapshot rect without begin()!");
|
||||||
const auto PLAYER = *pLayer;
|
const auto PLAYER = *pLayer;
|
||||||
|
|
||||||
auto it = m_mLayerFramebuffers.begin();
|
auto it = m_mLayerFramebuffers.begin();
|
||||||
for (; it != m_mLayerFramebuffers.end(); it++) {
|
for (; it != m_mLayerFramebuffers.end(); it++) {
|
||||||
if (it->first == PLAYER) {
|
if (it->first == PLAYER) {
|
||||||
break;
|
break;
|
||||||
|
@ -1264,9 +1264,9 @@ void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) {
|
||||||
if (it == m_mLayerFramebuffers.end() || !it->second.m_cTex.m_iTexID)
|
if (it == m_mLayerFramebuffers.end() || !it->second.m_cTex.m_iTexID)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PLAYER->monitorID);
|
const auto PMONITOR = g_pCompositor->getMonitorFromID(PLAYER->monitorID);
|
||||||
|
|
||||||
wlr_box monbox = {0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y};
|
wlr_box monbox = {0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y};
|
||||||
|
|
||||||
pixman_region32_t fakeDamage;
|
pixman_region32_t fakeDamage;
|
||||||
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y);
|
pixman_region32_init_rect(&fakeDamage, 0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y);
|
||||||
|
@ -1279,7 +1279,7 @@ void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) {
|
||||||
|
|
||||||
pixman_region32_fini(&fakeDamage);
|
pixman_region32_fini(&fakeDamage);
|
||||||
|
|
||||||
static auto *const PDAMAGEMON = &g_pConfigManager->getConfigValuePtr("misc:damage_entire_on_snapshot")->intValue;
|
static auto* const PDAMAGEMON = &g_pConfigManager->getConfigValuePtr("misc:damage_entire_on_snapshot")->intValue;
|
||||||
|
|
||||||
if (*PDAMAGEMON)
|
if (*PDAMAGEMON)
|
||||||
PMONITOR->forceFullFrames += 1;
|
PMONITOR->forceFullFrames += 1;
|
||||||
|
@ -1291,16 +1291,17 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl
|
||||||
RASSERT(m_pCurrentWindow, "Tried to render shadow without a window!");
|
RASSERT(m_pCurrentWindow, "Tried to render shadow without a window!");
|
||||||
|
|
||||||
if (!pixman_region32_not_empty(m_RenderData.pDamage))
|
if (!pixman_region32_not_empty(m_RenderData.pDamage))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static auto *const PSHADOWPOWER = &g_pConfigManager->getConfigValuePtr("decoration:shadow_render_power")->intValue;
|
static auto* const PSHADOWPOWER = &g_pConfigManager->getConfigValuePtr("decoration:shadow_render_power")->intValue;
|
||||||
|
|
||||||
const auto SHADOWPOWER = std::clamp((int)*PSHADOWPOWER, 1, 4);
|
const auto SHADOWPOWER = std::clamp((int)*PSHADOWPOWER, 1, 4);
|
||||||
|
|
||||||
const auto col = m_pCurrentWindow->m_cRealShadowColor.col();
|
const auto col = m_pCurrentWindow->m_cRealShadowColor.col();
|
||||||
|
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
wlr_matrix_project_box(matrix, box, wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), 0, m_RenderData.pMonitor->output->transform_matrix); // TODO: write own, don't use WLR here
|
wlr_matrix_project_box(matrix, box, wlr_output_transform_invert(!m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : m_RenderData.pMonitor->transform), 0,
|
||||||
|
m_RenderData.pMonitor->output->transform_matrix); // TODO: write own, don't use WLR here
|
||||||
|
|
||||||
float glMatrix[9];
|
float glMatrix[9];
|
||||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||||
|
@ -1318,9 +1319,9 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl
|
||||||
#endif
|
#endif
|
||||||
glUniform4f(m_RenderData.pCurrentMonData->m_shSHADOW.color, col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f * a);
|
glUniform4f(m_RenderData.pCurrentMonData->m_shSHADOW.color, col.r / 255.f, col.g / 255.f, col.b / 255.f, col.a / 255.f * a);
|
||||||
|
|
||||||
const auto TOPLEFT = Vector2D(range + round, range + round);
|
const auto TOPLEFT = Vector2D(range + round, range + round);
|
||||||
const auto BOTTOMRIGHT = Vector2D(box->width - (range + round), box->height - (range + round));
|
const auto BOTTOMRIGHT = Vector2D(box->width - (range + round), box->height - (range + round));
|
||||||
const auto FULLSIZE = Vector2D(box->width, box->height);
|
const auto FULLSIZE = Vector2D(box->width, box->height);
|
||||||
|
|
||||||
// Rounded corners
|
// Rounded corners
|
||||||
glUniform2f(m_RenderData.pCurrentMonData->m_shSHADOW.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y);
|
glUniform2f(m_RenderData.pCurrentMonData->m_shSHADOW.topLeft, (float)TOPLEFT.x, (float)TOPLEFT.y);
|
||||||
|
@ -1349,13 +1350,13 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pixman_region32_fini(&damageClip);
|
pixman_region32_fini(&damageClip);
|
||||||
} else {
|
} else {
|
||||||
PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) {
|
PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) {
|
||||||
const auto RECT = RECTSARR[i];
|
const auto RECT = RECTSARR[i];
|
||||||
scissor(&RECT);
|
scissor(&RECT);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib);
|
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib);
|
||||||
|
@ -1375,7 +1376,7 @@ void CHyprOpenGLImpl::saveBufferForMirror() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprOpenGLImpl::renderMirrored() {
|
void CHyprOpenGLImpl::renderMirrored() {
|
||||||
wlr_box monbox = {0, 0, m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y};
|
wlr_box monbox = {0, 0, m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y};
|
||||||
|
|
||||||
const auto PFB = &m_mMonitorRenderResources[m_RenderData.pMonitor->pMirrorOf].monitorMirrorFB;
|
const auto PFB = &m_mMonitorRenderResources[m_RenderData.pMonitor->pMirrorOf].monitorMirrorFB;
|
||||||
|
|
||||||
|
@ -1385,7 +1386,7 @@ void CHyprOpenGLImpl::renderMirrored() {
|
||||||
renderTexture(PFB->m_cTex, &monbox, 255.f, 0, false, false);
|
renderTexture(PFB->m_cTex, &monbox, 255.f, 0, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprOpenGLImpl::renderSplash(cairo_t *const CAIRO, cairo_surface_t *const CAIROSURFACE, double offsetY) {
|
void CHyprOpenGLImpl::renderSplash(cairo_t* const CAIRO, cairo_surface_t* const CAIROSURFACE, double offsetY) {
|
||||||
cairo_select_font_face(CAIRO, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
cairo_select_font_face(CAIRO, "Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
|
||||||
|
|
||||||
const auto FONTSIZE = (int)(m_RenderData.pMonitor->vecPixelSize.y / 76);
|
const auto FONTSIZE = (int)(m_RenderData.pMonitor->vecPixelSize.y / 76);
|
||||||
|
@ -1406,7 +1407,7 @@ void CHyprOpenGLImpl::renderSplash(cairo_t *const CAIRO, cairo_surface_t *const
|
||||||
void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
||||||
RASSERT(m_RenderData.pMonitor, "Tried to createBGTex without begin()!");
|
RASSERT(m_RenderData.pMonitor, "Tried to createBGTex without begin()!");
|
||||||
|
|
||||||
static auto *const PNOSPLASH = &g_pConfigManager->getConfigValuePtr("misc:disable_splash_rendering")->intValue;
|
static auto* const PNOSPLASH = &g_pConfigManager->getConfigValuePtr("misc:disable_splash_rendering")->intValue;
|
||||||
|
|
||||||
// release the last tex if exists
|
// release the last tex if exists
|
||||||
const auto PTEX = &m_mMonitorBGTextures[pMonitor];
|
const auto PTEX = &m_mMonitorBGTextures[pMonitor];
|
||||||
|
@ -1425,7 +1426,7 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
||||||
|
|
||||||
// get the adequate tex
|
// get the adequate tex
|
||||||
std::string texPath = "/usr/share/hyprland/wall_";
|
std::string texPath = "/usr/share/hyprland/wall_";
|
||||||
Vector2D textureSize;
|
Vector2D textureSize;
|
||||||
if (pMonitor->vecTransformedSize.x > 3850) {
|
if (pMonitor->vecTransformedSize.x > 3850) {
|
||||||
textureSize = Vector2D(7680, 4320);
|
textureSize = Vector2D(7680, 4320);
|
||||||
texPath += "8K.png";
|
texPath += "8K.png";
|
||||||
|
@ -1441,10 +1442,10 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
||||||
|
|
||||||
// calc the target box
|
// calc the target box
|
||||||
const double MONRATIO = m_RenderData.pMonitor->vecTransformedSize.x / m_RenderData.pMonitor->vecTransformedSize.y;
|
const double MONRATIO = m_RenderData.pMonitor->vecTransformedSize.x / m_RenderData.pMonitor->vecTransformedSize.y;
|
||||||
const double WPRATIO = 1.77;
|
const double WPRATIO = 1.77;
|
||||||
|
|
||||||
Vector2D origin;
|
Vector2D origin;
|
||||||
double scale;
|
double scale;
|
||||||
|
|
||||||
if (MONRATIO > WPRATIO) {
|
if (MONRATIO > WPRATIO) {
|
||||||
scale = m_RenderData.pMonitor->vecTransformedSize.x / PTEX->m_vSize.x;
|
scale = m_RenderData.pMonitor->vecTransformedSize.x / PTEX->m_vSize.x;
|
||||||
|
@ -1462,7 +1463,7 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
||||||
|
|
||||||
// create a new one with cairo
|
// create a new one with cairo
|
||||||
const auto CAIROSURFACE = cairo_image_surface_create_from_png(texPath.c_str());
|
const auto CAIROSURFACE = cairo_image_surface_create_from_png(texPath.c_str());
|
||||||
const auto CAIRO = cairo_create(CAIROSURFACE);
|
const auto CAIRO = cairo_create(CAIROSURFACE);
|
||||||
|
|
||||||
// scale it to fit the current monitor
|
// scale it to fit the current monitor
|
||||||
cairo_scale(CAIRO, textureSize.x / pMonitor->vecTransformedSize.x, textureSize.y / pMonitor->vecTransformedSize.y);
|
cairo_scale(CAIRO, textureSize.x / pMonitor->vecTransformedSize.x, textureSize.y / pMonitor->vecTransformedSize.y);
|
||||||
|
@ -1476,10 +1477,10 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
||||||
glBindTexture(GL_TEXTURE_2D, PTEX->m_iTexID);
|
glBindTexture(GL_TEXTURE_2D, PTEX->m_iTexID);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
#ifndef GLES2
|
#ifndef GLES2
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_BLUE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_RED);
|
||||||
#endif
|
#endif
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureSize.x, textureSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureSize.x, textureSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA);
|
||||||
|
|
||||||
cairo_surface_destroy(CAIROSURFACE);
|
cairo_surface_destroy(CAIROSURFACE);
|
||||||
|
@ -1491,7 +1492,7 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
||||||
void CHyprOpenGLImpl::clearWithTex() {
|
void CHyprOpenGLImpl::clearWithTex() {
|
||||||
RASSERT(m_RenderData.pMonitor, "Tried to render BGtex without begin()!");
|
RASSERT(m_RenderData.pMonitor, "Tried to render BGtex without begin()!");
|
||||||
|
|
||||||
static auto *const PRENDERTEX = &g_pConfigManager->getConfigValuePtr("misc:disable_hyprland_logo")->intValue;
|
static auto* const PRENDERTEX = &g_pConfigManager->getConfigValuePtr("misc:disable_hyprland_logo")->intValue;
|
||||||
|
|
||||||
if (!*PRENDERTEX) {
|
if (!*PRENDERTEX) {
|
||||||
auto TEXIT = m_mMonitorBGTextures.find(m_RenderData.pMonitor);
|
auto TEXIT = m_mMonitorBGTextures.find(m_RenderData.pMonitor);
|
||||||
|
|
|
@ -15,17 +15,12 @@
|
||||||
class CHyprRenderer;
|
class CHyprRenderer;
|
||||||
|
|
||||||
inline const float fullVerts[] = {
|
inline const float fullVerts[] = {
|
||||||
1, 0, // top right
|
1, 0, // top right
|
||||||
0, 0, // top left
|
0, 0, // top left
|
||||||
1, 1, // bottom right
|
1, 1, // bottom right
|
||||||
0, 1, // bottom left
|
0, 1, // bottom left
|
||||||
};
|
|
||||||
inline const float fanVertsFull[] = {
|
|
||||||
-1.0f, -1.0f,
|
|
||||||
1.0f, -1.0f,
|
|
||||||
1.0f, 1.0f,
|
|
||||||
-1.0f, 1.0f
|
|
||||||
};
|
};
|
||||||
|
inline const float fanVertsFull[] = {-1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f};
|
||||||
|
|
||||||
struct SMonitorRenderData {
|
struct SMonitorRenderData {
|
||||||
CFramebuffer primaryFB;
|
CFramebuffer primaryFB;
|
||||||
|
@ -42,118 +37,118 @@ struct SMonitorRenderData {
|
||||||
wlr_box backgroundTexBox;
|
wlr_box backgroundTexBox;
|
||||||
|
|
||||||
// Shaders
|
// Shaders
|
||||||
bool m_bShadersInitialized = false;
|
bool m_bShadersInitialized = false;
|
||||||
CShader m_shQUAD;
|
CShader m_shQUAD;
|
||||||
CShader m_shRGBA;
|
CShader m_shRGBA;
|
||||||
CShader m_shRGBX;
|
CShader m_shRGBX;
|
||||||
CShader m_shEXT;
|
CShader m_shEXT;
|
||||||
CShader m_shBLUR1;
|
CShader m_shBLUR1;
|
||||||
CShader m_shBLUR2;
|
CShader m_shBLUR2;
|
||||||
CShader m_shSHADOW;
|
CShader m_shSHADOW;
|
||||||
CShader m_shBORDER1;
|
CShader m_shBORDER1;
|
||||||
//
|
//
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SCurrentRenderData {
|
struct SCurrentRenderData {
|
||||||
CMonitor* pMonitor = nullptr;
|
CMonitor* pMonitor = nullptr;
|
||||||
float projection[9];
|
float projection[9];
|
||||||
|
|
||||||
SMonitorRenderData* pCurrentMonData = nullptr;
|
SMonitorRenderData* pCurrentMonData = nullptr;
|
||||||
|
|
||||||
pixman_region32_t* pDamage = nullptr;
|
pixman_region32_t* pDamage = nullptr;
|
||||||
|
|
||||||
Vector2D primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
Vector2D primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
||||||
Vector2D primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
Vector2D primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
||||||
|
|
||||||
wlr_box clipBox = {};
|
wlr_box clipBox = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
class CGradientValueData;
|
class CGradientValueData;
|
||||||
|
|
||||||
class CHyprOpenGLImpl {
|
class CHyprOpenGLImpl {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CHyprOpenGLImpl();
|
CHyprOpenGLImpl();
|
||||||
|
|
||||||
void begin(CMonitor*, pixman_region32_t*, bool fake = false);
|
void begin(CMonitor*, pixman_region32_t*, bool fake = false);
|
||||||
void end();
|
void end();
|
||||||
|
|
||||||
void renderRect(wlr_box*, const CColor&, int round = 0);
|
void renderRect(wlr_box*, const CColor&, int round = 0);
|
||||||
void renderRectWithDamage(wlr_box*, const CColor&, pixman_region32_t* damage, int round = 0);
|
void renderRectWithDamage(wlr_box*, const CColor&, pixman_region32_t* damage, int round = 0);
|
||||||
void renderTexture(wlr_texture*, wlr_box*, float a, int round = 0, bool allowCustomUV = false);
|
void renderTexture(wlr_texture*, wlr_box*, float a, int round = 0, bool allowCustomUV = false);
|
||||||
void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardOpaque = false, bool allowCustomUV = false);
|
void renderTexture(const CTexture&, wlr_box*, float a, int round = 0, bool discardOpaque = false, bool allowCustomUV = false);
|
||||||
void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0, bool blockBlurOptimization = false);
|
void renderTextureWithBlur(const CTexture&, wlr_box*, float a, wlr_surface* pSurface, int round = 0, bool blockBlurOptimization = false);
|
||||||
void renderRoundedShadow(wlr_box*, int round, int range, float a = 1.0);
|
void renderRoundedShadow(wlr_box*, int round, int range, float a = 1.0);
|
||||||
void renderBorder(wlr_box*, const CGradientValueData&, int round, float a = 1.0);
|
void renderBorder(wlr_box*, const CGradientValueData&, int round, float a = 1.0);
|
||||||
|
|
||||||
void makeWindowSnapshot(CWindow*);
|
void makeWindowSnapshot(CWindow*);
|
||||||
void makeRawWindowSnapshot(CWindow*, CFramebuffer*);
|
void makeRawWindowSnapshot(CWindow*, CFramebuffer*);
|
||||||
void makeLayerSnapshot(SLayerSurface*);
|
void makeLayerSnapshot(SLayerSurface*);
|
||||||
void renderSnapshot(CWindow**);
|
void renderSnapshot(CWindow**);
|
||||||
void renderSnapshot(SLayerSurface**);
|
void renderSnapshot(SLayerSurface**);
|
||||||
|
|
||||||
void clear(const CColor&);
|
void clear(const CColor&);
|
||||||
void clearWithTex();
|
void clearWithTex();
|
||||||
void scissor(const wlr_box*, bool transform = true);
|
void scissor(const wlr_box*, bool transform = true);
|
||||||
void scissor(const pixman_box32*, bool transform = true);
|
void scissor(const pixman_box32*, bool transform = true);
|
||||||
void scissor(const int x, const int y, const int w, const int h, bool transform = true);
|
void scissor(const int x, const int y, const int w, const int h, bool transform = true);
|
||||||
|
|
||||||
void destroyMonitorResources(CMonitor*);
|
void destroyMonitorResources(CMonitor*);
|
||||||
|
|
||||||
void markBlurDirtyForMonitor(CMonitor*);
|
void markBlurDirtyForMonitor(CMonitor*);
|
||||||
|
|
||||||
void preWindowPass();
|
void preWindowPass();
|
||||||
void preRender(CMonitor*);
|
void preRender(CMonitor*);
|
||||||
|
|
||||||
void saveBufferForMirror();
|
void saveBufferForMirror();
|
||||||
void renderMirrored();
|
void renderMirrored();
|
||||||
|
|
||||||
void onWindowResizeStart(CWindow*);
|
void onWindowResizeStart(CWindow*);
|
||||||
void onWindowResizeEnd(CWindow*);
|
void onWindowResizeEnd(CWindow*);
|
||||||
|
|
||||||
void applyScreenShader(const std::string& path);
|
void applyScreenShader(const std::string& path);
|
||||||
|
|
||||||
SCurrentRenderData m_RenderData;
|
SCurrentRenderData m_RenderData;
|
||||||
|
|
||||||
GLint m_iCurrentOutputFb = 0;
|
GLint m_iCurrentOutputFb = 0;
|
||||||
GLint m_iWLROutputFb = 0;
|
GLint m_iWLROutputFb = 0;
|
||||||
|
|
||||||
bool m_bReloadScreenShader = true; // at launch it can be set
|
bool m_bReloadScreenShader = true; // at launch it can be set
|
||||||
|
|
||||||
CWindow* m_pCurrentWindow = nullptr; // hack to get the current rendered window
|
CWindow* m_pCurrentWindow = nullptr; // hack to get the current rendered window
|
||||||
|
|
||||||
pixman_region32_t m_rOriginalDamageRegion; // used for storing the pre-expanded region
|
pixman_region32_t m_rOriginalDamageRegion; // used for storing the pre-expanded region
|
||||||
|
|
||||||
std::unordered_map<CWindow*, CFramebuffer> m_mWindowFramebuffers;
|
std::unordered_map<CWindow*, CFramebuffer> m_mWindowFramebuffers;
|
||||||
std::unordered_map<SLayerSurface*, CFramebuffer> m_mLayerFramebuffers;
|
std::unordered_map<SLayerSurface*, CFramebuffer> m_mLayerFramebuffers;
|
||||||
std::unordered_map<CMonitor*, SMonitorRenderData> m_mMonitorRenderResources;
|
std::unordered_map<CMonitor*, SMonitorRenderData> m_mMonitorRenderResources;
|
||||||
std::unordered_map<CMonitor*, CTexture> m_mMonitorBGTextures;
|
std::unordered_map<CMonitor*, CTexture> m_mMonitorBGTextures;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::list<GLuint> m_lBuffers;
|
std::list<GLuint> m_lBuffers;
|
||||||
std::list<GLuint> m_lTextures;
|
std::list<GLuint> m_lTextures;
|
||||||
|
|
||||||
int m_iDRMFD;
|
int m_iDRMFD;
|
||||||
std::string m_szExtensions;
|
std::string m_szExtensions;
|
||||||
|
|
||||||
bool m_bFakeFrame = false;
|
bool m_bFakeFrame = false;
|
||||||
bool m_bEndFrame = false;
|
bool m_bEndFrame = false;
|
||||||
bool m_bApplyFinalShader = false;
|
bool m_bApplyFinalShader = false;
|
||||||
|
|
||||||
CShader m_sFinalScreenShader;
|
CShader m_sFinalScreenShader;
|
||||||
|
|
||||||
GLuint createProgram(const std::string&, const std::string&, bool dynamic = false);
|
GLuint createProgram(const std::string&, const std::string&, bool dynamic = false);
|
||||||
GLuint compileShader(const GLuint&, std::string, bool dynamic = false);
|
GLuint compileShader(const GLuint&, std::string, bool dynamic = false);
|
||||||
void createBGTextureForMonitor(CMonitor*);
|
void createBGTextureForMonitor(CMonitor*);
|
||||||
void initShaders();
|
void initShaders();
|
||||||
|
|
||||||
// returns the out FB, can be either Mirror or MirrorSwap
|
// returns the out FB, can be either Mirror or MirrorSwap
|
||||||
CFramebuffer* blurMainFramebufferWithDamage(float a, wlr_box* pBox, pixman_region32_t* damage);
|
CFramebuffer* blurMainFramebufferWithDamage(float a, wlr_box* pBox, pixman_region32_t* damage);
|
||||||
|
|
||||||
void renderTextureInternalWithDamage(const CTexture&, wlr_box* pBox, float a, pixman_region32_t* damage, int round = 0, bool discardOpaque = false, bool noAA = false, bool allowCustomUV = false, bool allowDim = false);
|
void renderTextureInternalWithDamage(const CTexture&, wlr_box* pBox, float a, pixman_region32_t* damage, int round = 0, bool discardOpaque = false, bool noAA = false,
|
||||||
void renderSplash(cairo_t *const, cairo_surface_t *const, double);
|
bool allowCustomUV = false, bool allowDim = false);
|
||||||
|
void renderSplash(cairo_t* const, cairo_surface_t* const, double);
|
||||||
|
|
||||||
void preBlurForCurrentMonitor();
|
void preBlurForCurrentMonitor();
|
||||||
|
|
||||||
friend class CHyprRenderer;
|
friend class CHyprRenderer;
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
||||||
const auto TEXTURE = wlr_surface_get_texture(surface);
|
const auto TEXTURE = wlr_surface_get_texture(surface);
|
||||||
const auto RDATA = (SRenderData*)data;
|
const auto RDATA = (SRenderData*)data;
|
||||||
|
|
||||||
if (!TEXTURE)
|
if (!TEXTURE)
|
||||||
return;
|
return;
|
||||||
|
@ -15,7 +15,7 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
||||||
wlr_box windowBox;
|
wlr_box windowBox;
|
||||||
if (RDATA->surface && surface == RDATA->surface)
|
if (RDATA->surface && surface == RDATA->surface)
|
||||||
windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, RDATA->w, RDATA->h};
|
windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, RDATA->w, RDATA->h};
|
||||||
else // here we clamp to 2, these might be some tiny specks
|
else // here we clamp to 2, these might be some tiny specks
|
||||||
windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, std::max(surface->current.width, 2), std::max(surface->current.height, 2)};
|
windowBox = {(int)outputX + RDATA->x + x, (int)outputY + RDATA->y + y, std::max(surface->current.width, 2), std::max(surface->current.height, 2)};
|
||||||
|
|
||||||
if (RDATA->squishOversized) {
|
if (RDATA->squishOversized) {
|
||||||
|
@ -30,9 +30,9 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
||||||
|
|
||||||
scaleBox(&windowBox, RDATA->output->scale);
|
scaleBox(&windowBox, RDATA->output->scale);
|
||||||
|
|
||||||
static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
|
static auto* const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
|
||||||
|
|
||||||
float rounding = RDATA->dontRound ? 0 : RDATA->rounding == -1 ? *PROUNDING : RDATA->rounding;
|
float rounding = RDATA->dontRound ? 0 : RDATA->rounding == -1 ? *PROUNDING : RDATA->rounding;
|
||||||
rounding *= RDATA->output->scale;
|
rounding *= RDATA->output->scale;
|
||||||
|
|
||||||
rounding -= 1; // to fix a border issue
|
rounding -= 1; // to fix a border issue
|
||||||
|
@ -46,8 +46,7 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
||||||
else
|
else
|
||||||
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
|
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
|
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +56,7 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset the UV, we might've set it above
|
// reset the UV, we might've set it above
|
||||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
||||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +152,7 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWor
|
||||||
for (auto& w : g_pCompositor->m_vWindows) {
|
for (auto& w : g_pCompositor->m_vWindows) {
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(w->m_iWorkspaceID);
|
||||||
|
|
||||||
if (w->m_iWorkspaceID != pWorkspace->m_iID || !w->m_bIsFullscreen){
|
if (w->m_iWorkspaceID != pWorkspace->m_iID || !w->m_bIsFullscreen) {
|
||||||
if (!(PWORKSPACE && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated() || PWORKSPACE->m_bForceRendering)))
|
if (!(PWORKSPACE && (PWORKSPACE->m_vRenderOffset.isBeingAnimated() || PWORKSPACE->m_fAlpha.isBeingAnimated() || PWORKSPACE->m_bForceRendering)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -184,19 +183,20 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWor
|
||||||
}
|
}
|
||||||
|
|
||||||
// and then special windows
|
// and then special windows
|
||||||
if (pMonitor->specialWorkspaceID) for (auto& w : g_pCompositor->m_vWindows) {
|
if (pMonitor->specialWorkspaceID)
|
||||||
if (!g_pCompositor->windowValidMapped(w.get()) && !w->m_bFadingOut)
|
for (auto& w : g_pCompositor->m_vWindows) {
|
||||||
continue;
|
if (!g_pCompositor->windowValidMapped(w.get()) && !w->m_bFadingOut)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (w->m_iWorkspaceID != pMonitor->specialWorkspaceID)
|
if (w->m_iWorkspaceID != pMonitor->specialWorkspaceID)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!shouldRenderWindow(w.get(), pMonitor))
|
if (!shouldRenderWindow(w.get(), pMonitor))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// render the bad boy
|
// render the bad boy
|
||||||
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL);
|
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// and the overlay layers
|
// and the overlay layers
|
||||||
for (auto& ls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
|
for (auto& ls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_TOP]) {
|
||||||
|
@ -204,7 +204,6 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWor
|
||||||
renderLayer(ls.get(), pMonitor, time);
|
renderLayer(ls.get(), pMonitor, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (auto& ls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]) {
|
for (auto& ls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]) {
|
||||||
renderLayer(ls.get(), pMonitor, time);
|
renderLayer(ls.get(), pMonitor, time);
|
||||||
}
|
}
|
||||||
|
@ -226,11 +225,11 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
||||||
const auto REALPOS = pWindow->m_vRealPosition.vec() + (pWindow->m_bPinned ? Vector2D{} : PWORKSPACE->m_vRenderOffset.vec());
|
const auto REALPOS = pWindow->m_vRealPosition.vec() + (pWindow->m_bPinned ? Vector2D{} : PWORKSPACE->m_vRenderOffset.vec());
|
||||||
static auto *const PNOFLOATINGBORDERS = &g_pConfigManager->getConfigValuePtr("general:no_border_on_floating")->intValue;
|
static auto* const PNOFLOATINGBORDERS = &g_pConfigManager->getConfigValuePtr("general:no_border_on_floating")->intValue;
|
||||||
|
|
||||||
SRenderData renderdata = {pMonitor->output, time, REALPOS.x, REALPOS.y};
|
SRenderData renderdata = {pMonitor->output, time, REALPOS.x, REALPOS.y};
|
||||||
if (ignorePosition) {
|
if (ignorePosition) {
|
||||||
renderdata.x = pMonitor->vecPosition.x;
|
renderdata.x = pMonitor->vecPosition.x;
|
||||||
renderdata.y = pMonitor->vecPosition.y;
|
renderdata.y = pMonitor->vecPosition.y;
|
||||||
|
@ -239,19 +238,20 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
|
||||||
if (ignoreAllGeometry)
|
if (ignoreAllGeometry)
|
||||||
decorate = false;
|
decorate = false;
|
||||||
|
|
||||||
renderdata.surface = g_pXWaylandManager->getWindowSurface(pWindow);
|
renderdata.surface = g_pXWaylandManager->getWindowSurface(pWindow);
|
||||||
renderdata.w = std::max(pWindow->m_vRealSize.vec().x, 5.0); // clamp the size to min 5,
|
renderdata.w = std::max(pWindow->m_vRealSize.vec().x, 5.0); // clamp the size to min 5,
|
||||||
renderdata.h = std::max(pWindow->m_vRealSize.vec().y, 5.0); // otherwise we'll have issues later with invalid boxes
|
renderdata.h = std::max(pWindow->m_vRealSize.vec().y, 5.0); // otherwise we'll have issues later with invalid boxes
|
||||||
renderdata.dontRound = (pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) || (!pWindow->m_sSpecialRenderData.rounding);
|
renderdata.dontRound = (pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) || (!pWindow->m_sSpecialRenderData.rounding);
|
||||||
renderdata.fadeAlpha = pWindow->m_fAlpha.fl() * (pWindow->m_bPinned ? 1.f : (PWORKSPACE->m_fAlpha.fl() / 255.f));
|
renderdata.fadeAlpha = pWindow->m_fAlpha.fl() * (pWindow->m_bPinned ? 1.f : (PWORKSPACE->m_fAlpha.fl() / 255.f));
|
||||||
renderdata.alpha = pWindow->m_fActiveInactiveAlpha.fl();
|
renderdata.alpha = pWindow->m_fActiveInactiveAlpha.fl();
|
||||||
renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders && (pWindow->m_bIsFloating ? *PNOFLOATINGBORDERS == 0 : true) && (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL);
|
renderdata.decorate = decorate && !pWindow->m_bX11DoesntWantBorders && (pWindow->m_bIsFloating ? *PNOFLOATINGBORDERS == 0 : true) &&
|
||||||
|
(!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL);
|
||||||
renderdata.rounding = ignoreAllGeometry ? 0 : pWindow->m_sAdditionalConfigData.rounding;
|
renderdata.rounding = ignoreAllGeometry ? 0 : pWindow->m_sAdditionalConfigData.rounding;
|
||||||
renderdata.blur = !ignoreAllGeometry; // if it shouldn't, it will be ignored later
|
renderdata.blur = !ignoreAllGeometry; // if it shouldn't, it will be ignored later
|
||||||
renderdata.pWindow = pWindow;
|
renderdata.pWindow = pWindow;
|
||||||
|
|
||||||
if (ignoreAllGeometry) {
|
if (ignoreAllGeometry) {
|
||||||
renderdata.alpha = 1.f;
|
renderdata.alpha = 1.f;
|
||||||
renderdata.fadeAlpha = 255.f;
|
renderdata.fadeAlpha = 255.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,9 +265,9 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
|
||||||
Vector2D offset;
|
Vector2D offset;
|
||||||
if (!ignorePosition && pWindow->m_bIsFloating && !pWindow->m_bPinned) {
|
if (!ignorePosition && pWindow->m_bIsFloating && !pWindow->m_bPinned) {
|
||||||
if (PWORKSPACE->m_vRenderOffset.vec().x != 0) {
|
if (PWORKSPACE->m_vRenderOffset.vec().x != 0) {
|
||||||
const auto PWSMON = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
|
const auto PWSMON = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
|
||||||
const auto PROGRESS = PWORKSPACE->m_vRenderOffset.vec().x / PWSMON->vecSize.x;
|
const auto PROGRESS = PWORKSPACE->m_vRenderOffset.vec().x / PWSMON->vecSize.x;
|
||||||
const auto WINBB = pWindow->getFullWindowBoundingBox();
|
const auto WINBB = pWindow->getFullWindowBoundingBox();
|
||||||
|
|
||||||
if (WINBB.x < PWSMON->vecPosition.x) {
|
if (WINBB.x < PWSMON->vecPosition.x) {
|
||||||
offset.x = (PWSMON->vecPosition.x - WINBB.x) * PROGRESS;
|
offset.x = (PWSMON->vecPosition.x - WINBB.x) * PROGRESS;
|
||||||
|
@ -275,9 +275,9 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
|
||||||
offset.x = (WINBB.x + WINBB.width - PWSMON->vecPosition.x - PWSMON->vecSize.x) * PROGRESS;
|
offset.x = (WINBB.x + WINBB.width - PWSMON->vecPosition.x - PWSMON->vecSize.x) * PROGRESS;
|
||||||
}
|
}
|
||||||
} else if (PWORKSPACE->m_vRenderOffset.vec().y) {
|
} else if (PWORKSPACE->m_vRenderOffset.vec().y) {
|
||||||
const auto PWSMON = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
|
const auto PWSMON = g_pCompositor->getMonitorFromID(PWORKSPACE->m_iMonitorID);
|
||||||
const auto PROGRESS = PWORKSPACE->m_vRenderOffset.vec().y / PWSMON->vecSize.y;
|
const auto PROGRESS = PWORKSPACE->m_vRenderOffset.vec().y / PWSMON->vecSize.y;
|
||||||
const auto WINBB = pWindow->getFullWindowBoundingBox();
|
const auto WINBB = pWindow->getFullWindowBoundingBox();
|
||||||
|
|
||||||
if (WINBB.y < PWSMON->vecPosition.y) {
|
if (WINBB.y < PWSMON->vecPosition.y) {
|
||||||
offset.y = (PWSMON->vecPosition.y - WINBB.y) * PROGRESS;
|
offset.y = (PWSMON->vecPosition.y - WINBB.y) * PROGRESS;
|
||||||
|
@ -289,25 +289,26 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
|
||||||
renderdata.x += offset.x;
|
renderdata.x += offset.x;
|
||||||
renderdata.y += offset.y;
|
renderdata.y += offset.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// render window decorations first, if not fullscreen full
|
// render window decorations first, if not fullscreen full
|
||||||
if (mode == RENDER_PASS_ALL || mode == RENDER_PASS_MAIN) {
|
if (mode == RENDER_PASS_ALL || mode == RENDER_PASS_MAIN) {
|
||||||
if (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL) for (auto& wd : pWindow->m_dWindowDecorations)
|
if (!pWindow->m_bIsFullscreen || PWORKSPACE->m_efFullscreenMode != FULLSCREEN_FULL)
|
||||||
|
for (auto& wd : pWindow->m_dWindowDecorations)
|
||||||
wd->draw(pMonitor, renderdata.alpha * renderdata.fadeAlpha / 255.f, offset);
|
wd->draw(pMonitor, renderdata.alpha * renderdata.fadeAlpha / 255.f, offset);
|
||||||
|
|
||||||
wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(pWindow), renderSurface, &renderdata);
|
wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(pWindow), renderSurface, &renderdata);
|
||||||
|
|
||||||
if (renderdata.decorate && pWindow->m_sSpecialRenderData.border) {
|
if (renderdata.decorate && pWindow->m_sSpecialRenderData.border) {
|
||||||
static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
|
static auto* const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
|
||||||
|
|
||||||
float rounding = renderdata.dontRound ? 0 : renderdata.rounding == -1 ? *PROUNDING : renderdata.rounding;
|
float rounding = renderdata.dontRound ? 0 : renderdata.rounding == -1 ? *PROUNDING : renderdata.rounding;
|
||||||
rounding *= pMonitor->scale;
|
rounding *= pMonitor->scale;
|
||||||
|
|
||||||
auto grad = g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColor;
|
auto grad = g_pHyprOpenGL->m_pCurrentWindow->m_cRealBorderColor;
|
||||||
const bool ANIMATED = g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAnimationProgress.isBeingAnimated();
|
const bool ANIMATED = g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAnimationProgress.isBeingAnimated();
|
||||||
float a1 = renderdata.fadeAlpha * renderdata.alpha / 255.f * (ANIMATED ? g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAnimationProgress.fl() : 1.f);
|
float a1 = renderdata.fadeAlpha * renderdata.alpha / 255.f * (ANIMATED ? g_pHyprOpenGL->m_pCurrentWindow->m_fBorderAnimationProgress.fl() : 1.f);
|
||||||
|
|
||||||
wlr_box windowBox = {renderdata.x - pMonitor->vecPosition.x, renderdata.y - pMonitor->vecPosition.y, renderdata.w, renderdata.h};
|
wlr_box windowBox = {renderdata.x - pMonitor->vecPosition.x, renderdata.y - pMonitor->vecPosition.y, renderdata.w, renderdata.h};
|
||||||
|
|
||||||
scaleBox(&windowBox, pMonitor->scale);
|
scaleBox(&windowBox, pMonitor->scale);
|
||||||
|
|
||||||
|
@ -328,15 +329,15 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
|
||||||
renderdata.x -= geom.x;
|
renderdata.x -= geom.x;
|
||||||
renderdata.y -= geom.y;
|
renderdata.y -= geom.y;
|
||||||
|
|
||||||
renderdata.dontRound = true; // don't round popups
|
renderdata.dontRound = true; // don't round popups
|
||||||
renderdata.pMonitor = pMonitor;
|
renderdata.pMonitor = pMonitor;
|
||||||
renderdata.squishOversized = false; // don't squish popups
|
renderdata.squishOversized = false; // don't squish popups
|
||||||
wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata);
|
wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pHyprOpenGL->m_pCurrentWindow = nullptr;
|
g_pHyprOpenGL->m_pCurrentWindow = nullptr;
|
||||||
g_pHyprOpenGL->m_RenderData.clipBox = { 0, 0, 0, 0 };
|
g_pHyprOpenGL->m_RenderData.clipBox = {0, 0, 0, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, timespec* time) {
|
void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, timespec* time) {
|
||||||
|
@ -345,29 +346,29 @@ void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, times
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SRenderData renderdata = {pMonitor->output, time, pLayer->geometry.x, pLayer->geometry.y};
|
SRenderData renderdata = {pMonitor->output, time, pLayer->geometry.x, pLayer->geometry.y};
|
||||||
renderdata.fadeAlpha = pLayer->alpha.fl();
|
renderdata.fadeAlpha = pLayer->alpha.fl();
|
||||||
renderdata.blur = pLayer->forceBlur;
|
renderdata.blur = pLayer->forceBlur;
|
||||||
renderdata.surface = pLayer->layerSurface->surface;
|
renderdata.surface = pLayer->layerSurface->surface;
|
||||||
renderdata.decorate = false;
|
renderdata.decorate = false;
|
||||||
renderdata.w = pLayer->layerSurface->surface->current.width;
|
renderdata.w = pLayer->layerSurface->surface->current.width;
|
||||||
renderdata.h = pLayer->layerSurface->surface->current.height;
|
renderdata.h = pLayer->layerSurface->surface->current.height;
|
||||||
renderdata.blockBlurOptimization = pLayer->layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM || pLayer->layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND;
|
renderdata.blockBlurOptimization = pLayer->layer == ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM || pLayer->layer == ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND;
|
||||||
wlr_surface_for_each_surface(pLayer->layerSurface->surface, renderSurface, &renderdata);
|
wlr_surface_for_each_surface(pLayer->layerSurface->surface, renderSurface, &renderdata);
|
||||||
|
|
||||||
renderdata.squishOversized = false; // don't squish popups
|
renderdata.squishOversized = false; // don't squish popups
|
||||||
renderdata.dontRound = true;
|
renderdata.dontRound = true;
|
||||||
wlr_layer_surface_v1_for_each_popup_surface(pLayer->layerSurface, renderSurface, &renderdata);
|
wlr_layer_surface_v1_for_each_popup_surface(pLayer->layerSurface, renderSurface, &renderdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprRenderer::renderIMEPopup(SIMEPopup* pPopup, CMonitor* pMonitor, timespec* time) {
|
void CHyprRenderer::renderIMEPopup(SIMEPopup* pPopup, CMonitor* pMonitor, timespec* time) {
|
||||||
SRenderData renderdata = {pMonitor->output, time, pPopup->realX, pPopup->realY};
|
SRenderData renderdata = {pMonitor->output, time, pPopup->realX, pPopup->realY};
|
||||||
|
|
||||||
renderdata.blur = false;
|
renderdata.blur = false;
|
||||||
renderdata.surface = pPopup->pSurface->surface;
|
renderdata.surface = pPopup->pSurface->surface;
|
||||||
renderdata.decorate = false;
|
renderdata.decorate = false;
|
||||||
renderdata.w = pPopup->pSurface->surface->current.width;
|
renderdata.w = pPopup->pSurface->surface->current.width;
|
||||||
renderdata.h = pPopup->pSurface->surface->current.height;
|
renderdata.h = pPopup->pSurface->surface->current.height;
|
||||||
|
|
||||||
wlr_surface_for_each_surface(pPopup->pSurface->surface, renderSurface, &renderdata);
|
wlr_surface_for_each_surface(pPopup->pSurface->surface, renderSurface, &renderdata);
|
||||||
}
|
}
|
||||||
|
@ -406,14 +407,14 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (w->m_bIsFloating)
|
if (w->m_bIsFloating)
|
||||||
continue; // floating are in the second pass
|
continue; // floating are in the second pass
|
||||||
|
|
||||||
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
|
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
|
||||||
continue; // special are in the third pass
|
continue; // special are in the third pass
|
||||||
|
|
||||||
if (!shouldRenderWindow(w.get(), PMONITOR))
|
if (!shouldRenderWindow(w.get(), PMONITOR))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// render active window after all others of this pass
|
// render active window after all others of this pass
|
||||||
if (w.get() == g_pCompositor->m_pLastWindow) {
|
if (w.get() == g_pCompositor->m_pLastWindow) {
|
||||||
lastWindow = w.get();
|
lastWindow = w.get();
|
||||||
|
@ -433,7 +434,7 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (w->m_bIsFloating)
|
if (w->m_bIsFloating)
|
||||||
continue; // floating are in the second pass
|
continue; // floating are in the second pass
|
||||||
|
|
||||||
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
|
if (g_pCompositor->isWorkspaceSpecial(w->m_iWorkspaceID))
|
||||||
continue; // special are in the third pass
|
continue; // special are in the third pass
|
||||||
|
@ -500,7 +501,7 @@ void CHyprRenderer::calculateUVForWindowSurface(CWindow* pWindow, wlr_surface* p
|
||||||
Vector2D uvTL;
|
Vector2D uvTL;
|
||||||
Vector2D uvBR = Vector2D(1, 1);
|
Vector2D uvBR = Vector2D(1, 1);
|
||||||
|
|
||||||
wlr_box geom;
|
wlr_box geom;
|
||||||
wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, &geom);
|
wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, &geom);
|
||||||
|
|
||||||
const auto SUBSURFACE = g_pXWaylandManager->getWindowSurface(pWindow) != pSurface && main;
|
const auto SUBSURFACE = g_pXWaylandManager->getWindowSurface(pWindow) != pSurface && main;
|
||||||
|
@ -517,27 +518,34 @@ void CHyprRenderer::calculateUVForWindowSurface(CWindow* pWindow, wlr_surface* p
|
||||||
|
|
||||||
if (uvBR.x < 0.01f || uvBR.y < 0.01f) {
|
if (uvBR.x < 0.01f || uvBR.y < 0.01f) {
|
||||||
uvTL = Vector2D();
|
uvTL = Vector2D();
|
||||||
uvBR = Vector2D(1,1);
|
uvBR = Vector2D(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: (example: chromium) this still has a tiny "bump" at the end.
|
// TODO: (example: chromium) this still has a tiny "bump" at the end.
|
||||||
if (main) {
|
if (main) {
|
||||||
uvTL = uvTL + (Vector2D((double)geom.x / ((double)pWindow->m_uSurface.xdg->surface->current.width), (double)geom.y / ((double)pWindow->m_uSurface.xdg->surface->current.height)) * (((uvBR.x - uvTL.x) * surfaceSize.x) / surfaceSize.x));
|
uvTL = uvTL +
|
||||||
uvBR = uvBR * Vector2D((double)(geom.width + geom.x) / ((double)pWindow->m_uSurface.xdg->surface->current.width), (double)(geom.y + geom.height) / ((double)pWindow->m_uSurface.xdg->surface->current.height));
|
(Vector2D((double)geom.x / ((double)pWindow->m_uSurface.xdg->surface->current.width),
|
||||||
|
(double)geom.y / ((double)pWindow->m_uSurface.xdg->surface->current.height)) *
|
||||||
|
(((uvBR.x - uvTL.x) * surfaceSize.x) / surfaceSize.x));
|
||||||
|
uvBR = uvBR *
|
||||||
|
Vector2D((double)(geom.width + geom.x) / ((double)pWindow->m_uSurface.xdg->surface->current.width),
|
||||||
|
(double)(geom.y + geom.height) / ((double)pWindow->m_uSurface.xdg->surface->current.height));
|
||||||
}
|
}
|
||||||
} else if (main) {
|
} else if (main) {
|
||||||
// oversized windows' UV adjusting
|
// oversized windows' UV adjusting
|
||||||
uvTL = Vector2D((double)geom.x / ((double)pWindow->m_uSurface.xdg->surface->current.width), (double)geom.y / ((double)pWindow->m_uSurface.xdg->surface->current.height));
|
uvTL =
|
||||||
uvBR = Vector2D((double)(geom.width + geom.x) / ((double)pWindow->m_uSurface.xdg->surface->current.width), (double)(geom.y + geom.height) / ((double)pWindow->m_uSurface.xdg->surface->current.height));
|
Vector2D((double)geom.x / ((double)pWindow->m_uSurface.xdg->surface->current.width), (double)geom.y / ((double)pWindow->m_uSurface.xdg->surface->current.height));
|
||||||
|
uvBR = Vector2D((double)(geom.width + geom.x) / ((double)pWindow->m_uSurface.xdg->surface->current.width),
|
||||||
|
(double)(geom.y + geom.height) / ((double)pWindow->m_uSurface.xdg->surface->current.height));
|
||||||
}
|
}
|
||||||
|
|
||||||
// set UV
|
// set UV
|
||||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = uvTL;
|
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = uvTL;
|
||||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = uvBR;
|
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = uvBR;
|
||||||
|
|
||||||
if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D() && g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight == Vector2D(1, 1)) {
|
if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D() && g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight == Vector2D(1, 1)) {
|
||||||
// No special UV mods needed
|
// No special UV mods needed
|
||||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
||||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,12 +559,14 @@ void CHyprRenderer::calculateUVForWindowSurface(CWindow* pWindow, wlr_surface* p
|
||||||
if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D(-1, -1))
|
if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D(-1, -1))
|
||||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(0, 0);
|
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(0, 0);
|
||||||
|
|
||||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(
|
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight =
|
||||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x * (pWindow->m_vRealSize.vec().x / ((double)geom.width / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x)),
|
Vector2D(g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x *
|
||||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y * (pWindow->m_vRealSize.vec().y / ((double)geom.height / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y)));
|
(pWindow->m_vRealSize.vec().x / ((double)geom.width / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x)),
|
||||||
|
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y *
|
||||||
|
(pWindow->m_vRealSize.vec().y / ((double)geom.height / g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.y)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
||||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -582,7 +592,8 @@ bool CHyprRenderer::attemptDirectScanout(CMonitor* pMonitor) {
|
||||||
if (PCANDIDATE->m_fAlpha.fl() != 255.f || PCANDIDATE->m_fActiveInactiveAlpha.fl() != 1.f || PWORKSPACE->m_fAlpha.fl() != 255.f)
|
if (PCANDIDATE->m_fAlpha.fl() != 255.f || PCANDIDATE->m_fActiveInactiveAlpha.fl() != 1.f || PWORKSPACE->m_fAlpha.fl() != 255.f)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (PCANDIDATE->m_vRealSize.vec() != pMonitor->vecSize || PCANDIDATE->m_vRealPosition.vec() != pMonitor->vecPosition || PCANDIDATE->m_vRealPosition.isBeingAnimated() || PCANDIDATE->m_vRealSize.isBeingAnimated())
|
if (PCANDIDATE->m_vRealSize.vec() != pMonitor->vecSize || PCANDIDATE->m_vRealPosition.vec() != pMonitor->vecPosition || PCANDIDATE->m_vRealPosition.isBeingAnimated() ||
|
||||||
|
PCANDIDATE->m_vRealSize.isBeingAnimated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY].empty())
|
if (!pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY].empty())
|
||||||
|
@ -653,7 +664,7 @@ void CHyprRenderer::setWindowScanoutMode(CWindow* pWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto RENDERERDRMFD = wlr_renderer_get_drm_fd(g_pCompositor->m_sWLRRenderer);
|
const auto RENDERERDRMFD = wlr_renderer_get_drm_fd(g_pCompositor->m_sWLRRenderer);
|
||||||
const auto BACKENDDRMFD = wlr_backend_get_drm_fd(g_pCompositor->m_sWLRBackend);
|
const auto BACKENDDRMFD = wlr_backend_get_drm_fd(g_pCompositor->m_sWLRBackend);
|
||||||
|
|
||||||
if (RENDERERDRMFD < 0 || BACKENDDRMFD < 0)
|
if (RENDERERDRMFD < 0 || BACKENDDRMFD < 0)
|
||||||
return;
|
return;
|
||||||
|
@ -677,28 +688,17 @@ void CHyprRenderer::setWindowScanoutMode(CWindow* pWindow) {
|
||||||
if (!POUTPUTFORMATS)
|
if (!POUTPUTFORMATS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto PRENDERERFORMATS = wlr_renderer_get_dmabuf_texture_formats(g_pCompositor->m_sWLRRenderer);
|
const auto PRENDERERFORMATS = wlr_renderer_get_dmabuf_texture_formats(g_pCompositor->m_sWLRRenderer);
|
||||||
wlr_drm_format_set scanoutFormats = { 0 };
|
wlr_drm_format_set scanoutFormats = {0};
|
||||||
|
|
||||||
if (!wlr_drm_format_set_intersect(&scanoutFormats, POUTPUTFORMATS, PRENDERERFORMATS))
|
if (!wlr_drm_format_set_intersect(&scanoutFormats, POUTPUTFORMATS, PRENDERERFORMATS))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const wlr_linux_dmabuf_feedback_v1_tranche TRANCHES[] = {
|
const wlr_linux_dmabuf_feedback_v1_tranche TRANCHES[] = {
|
||||||
{
|
{.target_device = scanoutDevice, .flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT, .formats = &scanoutFormats},
|
||||||
.target_device = scanoutDevice,
|
{.target_device = rendererDevice, .formats = PRENDERERFORMATS}};
|
||||||
.flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT,
|
|
||||||
.formats = &scanoutFormats
|
|
||||||
}, {
|
|
||||||
.target_device = rendererDevice,
|
|
||||||
.formats = PRENDERERFORMATS
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const wlr_linux_dmabuf_feedback_v1 FEEDBACK = {
|
const wlr_linux_dmabuf_feedback_v1 FEEDBACK = {.main_device = rendererDevice, .tranches_len = sizeof(TRANCHES) / sizeof(TRANCHES[0]), .tranches = TRANCHES};
|
||||||
.main_device = rendererDevice,
|
|
||||||
.tranches_len = sizeof(TRANCHES) / sizeof(TRANCHES[0]),
|
|
||||||
.tranches = TRANCHES
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!wlr_linux_dmabuf_v1_set_surface_feedback(g_pCompositor->m_sWLRLinuxDMABuf, g_pXWaylandManager->getWindowSurface(pWindow), &FEEDBACK)) {
|
if (!wlr_linux_dmabuf_v1_set_surface_feedback(g_pCompositor->m_sWLRLinuxDMABuf, g_pXWaylandManager->getWindowSurface(pWindow), &FEEDBACK)) {
|
||||||
Debug::log(ERR, "Error in scanout mode setting: wlr_linux_dmabuf_v1_set_surface_feedback returned false.");
|
Debug::log(ERR, "Error in scanout mode setting: wlr_linux_dmabuf_v1_set_surface_feedback returned false.");
|
||||||
|
@ -711,12 +711,12 @@ void CHyprRenderer::setWindowScanoutMode(CWindow* pWindow) {
|
||||||
|
|
||||||
void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool test) {
|
void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool test) {
|
||||||
wlr_output_configuration_head_v1* head;
|
wlr_output_configuration_head_v1* head;
|
||||||
bool noError = true;
|
bool noError = true;
|
||||||
|
|
||||||
wl_list_for_each(head, &config->heads, link) {
|
wl_list_for_each(head, &config->heads, link) {
|
||||||
|
|
||||||
std::string commandForCfg = "";
|
std::string commandForCfg = "";
|
||||||
const auto OUTPUT = head->state.output;
|
const auto OUTPUT = head->state.output;
|
||||||
|
|
||||||
commandForCfg += std::string(OUTPUT->name) + ",";
|
commandForCfg += std::string(OUTPUT->name) + ",";
|
||||||
|
|
||||||
|
@ -730,9 +730,11 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool
|
||||||
wlr_output_enable(OUTPUT, head->state.enabled);
|
wlr_output_enable(OUTPUT, head->state.enabled);
|
||||||
|
|
||||||
if (head->state.mode)
|
if (head->state.mode)
|
||||||
commandForCfg += std::to_string(head->state.mode->width) + "x" + std::to_string(head->state.mode->height) + "@" + std::to_string(head->state.mode->refresh / 1000.f) + ",";
|
commandForCfg +=
|
||||||
|
std::to_string(head->state.mode->width) + "x" + std::to_string(head->state.mode->height) + "@" + std::to_string(head->state.mode->refresh / 1000.f) + ",";
|
||||||
else
|
else
|
||||||
commandForCfg += std::to_string(head->state.custom_mode.width) + "x" + std::to_string(head->state.custom_mode.height) + "@" + std::to_string(head->state.custom_mode.refresh / 1000.f) + ",";
|
commandForCfg += std::to_string(head->state.custom_mode.width) + "x" + std::to_string(head->state.custom_mode.height) + "@" +
|
||||||
|
std::to_string(head->state.custom_mode.refresh / 1000.f) + ",";
|
||||||
|
|
||||||
commandForCfg += std::to_string(head->state.x) + "x" + std::to_string(head->state.y) + "," + std::to_string(head->state.scale);
|
commandForCfg += std::to_string(head->state.x) + "x" + std::to_string(head->state.y) + "," + std::to_string(head->state.scale);
|
||||||
|
|
||||||
|
@ -741,7 +743,7 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool
|
||||||
|
|
||||||
std::string transformStr = std::string(OUTPUT->name) + ",transform," + std::to_string((int)OUTPUT->transform);
|
std::string transformStr = std::string(OUTPUT->name) + ",transform," + std::to_string((int)OUTPUT->transform);
|
||||||
|
|
||||||
const auto PMONITOR = g_pCompositor->getMonitorFromName(OUTPUT->name);
|
const auto PMONITOR = g_pCompositor->getMonitorFromName(OUTPUT->name);
|
||||||
|
|
||||||
if (!PMONITOR || OUTPUT->transform != PMONITOR->transform)
|
if (!PMONITOR || OUTPUT->transform != PMONITOR->transform)
|
||||||
g_pConfigManager->parseKeyword("monitor", transformStr);
|
g_pConfigManager->parseKeyword("monitor", transformStr);
|
||||||
|
@ -754,7 +756,7 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!test)
|
if (!test)
|
||||||
g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords
|
g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords
|
||||||
|
|
||||||
if (noError)
|
if (noError)
|
||||||
wlr_output_configuration_v1_send_succeeded(config);
|
wlr_output_configuration_v1_send_succeeded(config);
|
||||||
|
@ -774,53 +776,41 @@ void apply_exclusive(struct wlr_box* usable_area, uint32_t anchor, int32_t exclu
|
||||||
struct {
|
struct {
|
||||||
uint32_t singular_anchor;
|
uint32_t singular_anchor;
|
||||||
uint32_t anchor_triplet;
|
uint32_t anchor_triplet;
|
||||||
int* positive_axis;
|
int* positive_axis;
|
||||||
int* negative_axis;
|
int* negative_axis;
|
||||||
int margin;
|
int margin;
|
||||||
} edges[] = {
|
} edges[] = {
|
||||||
// Top
|
// Top
|
||||||
{
|
{
|
||||||
.singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP,
|
.singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP,
|
||||||
.anchor_triplet =
|
.anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP,
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
.positive_axis = &usable_area->y,
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
|
.negative_axis = &usable_area->height,
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP,
|
.margin = margin_top,
|
||||||
.positive_axis = &usable_area->y,
|
|
||||||
.negative_axis = &usable_area->height,
|
|
||||||
.margin = margin_top,
|
|
||||||
},
|
},
|
||||||
// Bottom
|
// Bottom
|
||||||
{
|
{
|
||||||
.singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
.singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
||||||
.anchor_triplet =
|
.anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
.positive_axis = NULL,
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
|
.negative_axis = &usable_area->height,
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
.margin = margin_bottom,
|
||||||
.positive_axis = NULL,
|
|
||||||
.negative_axis = &usable_area->height,
|
|
||||||
.margin = margin_bottom,
|
|
||||||
},
|
},
|
||||||
// Left
|
// Left
|
||||||
{
|
{
|
||||||
.singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT,
|
.singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT,
|
||||||
.anchor_triplet =
|
.anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
.positive_axis = &usable_area->x,
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
|
.negative_axis = &usable_area->width,
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
.margin = margin_left,
|
||||||
.positive_axis = &usable_area->x,
|
|
||||||
.negative_axis = &usable_area->width,
|
|
||||||
.margin = margin_left,
|
|
||||||
},
|
},
|
||||||
// Right
|
// Right
|
||||||
{
|
{
|
||||||
.singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT,
|
.singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT,
|
||||||
.anchor_triplet =
|
.anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
|
.positive_axis = NULL,
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
|
.negative_axis = &usable_area->width,
|
||||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
.margin = margin_right,
|
||||||
.positive_axis = NULL,
|
|
||||||
.negative_axis = &usable_area->width,
|
|
||||||
.margin = margin_right,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
for (size_t i = 0; i < sizeof(edges) / sizeof(edges[0]); ++i) {
|
for (size_t i = 0; i < sizeof(edges) / sizeof(edges[0]); ++i) {
|
||||||
|
@ -856,9 +846,7 @@ void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vector<std:
|
||||||
bounds = *usableArea;
|
bounds = *usableArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_box box = {
|
wlr_box box = {.width = PSTATE->desired_width, .height = PSTATE->desired_height};
|
||||||
.width = PSTATE->desired_width,
|
|
||||||
.height = PSTATE->desired_height};
|
|
||||||
// Horizontal axis
|
// Horizontal axis
|
||||||
const uint32_t both_horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
const uint32_t both_horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
||||||
if (box.width == 0) {
|
if (box.width == 0) {
|
||||||
|
@ -888,8 +876,7 @@ void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vector<std:
|
||||||
// Margin
|
// Margin
|
||||||
if (box.width == 0) {
|
if (box.width == 0) {
|
||||||
box.x += PSTATE->margin.left;
|
box.x += PSTATE->margin.left;
|
||||||
box.width = bounds.width -
|
box.width = bounds.width - (PSTATE->margin.left + PSTATE->margin.right);
|
||||||
(PSTATE->margin.left + PSTATE->margin.right);
|
|
||||||
} else if ((PSTATE->anchor & both_horiz) == both_horiz) {
|
} else if ((PSTATE->anchor & both_horiz) == both_horiz) {
|
||||||
// don't apply margins
|
// don't apply margins
|
||||||
} else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT)) {
|
} else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT)) {
|
||||||
|
@ -899,8 +886,7 @@ void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vector<std:
|
||||||
}
|
}
|
||||||
if (box.height == 0) {
|
if (box.height == 0) {
|
||||||
box.y += PSTATE->margin.top;
|
box.y += PSTATE->margin.top;
|
||||||
box.height = bounds.height -
|
box.height = bounds.height - (PSTATE->margin.top + PSTATE->margin.bottom);
|
||||||
(PSTATE->margin.top + PSTATE->margin.bottom);
|
|
||||||
} else if ((PSTATE->anchor & both_vert) == both_vert) {
|
} else if ((PSTATE->anchor & both_vert) == both_vert) {
|
||||||
// don't apply margins
|
// don't apply margins
|
||||||
} else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP)) {
|
} else if ((PSTATE->anchor & ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP)) {
|
||||||
|
@ -919,7 +905,8 @@ void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vector<std:
|
||||||
|
|
||||||
wlr_layer_surface_v1_configure(ls->layerSurface, box.width, box.height);
|
wlr_layer_surface_v1_configure(ls->layerSurface, box.width, box.height);
|
||||||
|
|
||||||
Debug::log(LOG, "LayerSurface %x arranged: x: %i y: %i w: %i h: %i with margins: t: %i l: %i r: %i b: %i", &ls, box.x, box.y, box.width, box.height, PSTATE->margin.top, PSTATE->margin.left, PSTATE->margin.right, PSTATE->margin.bottom);
|
Debug::log(LOG, "LayerSurface %x arranged: x: %i y: %i w: %i h: %i with margins: t: %i l: %i r: %i b: %i", &ls, box.x, box.y, box.width, box.height, PSTATE->margin.top,
|
||||||
|
PSTATE->margin.left, PSTATE->margin.right, PSTATE->margin.bottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -930,8 +917,8 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Reset the reserved
|
// Reset the reserved
|
||||||
PMONITOR->vecReservedBottomRight = Vector2D();
|
PMONITOR->vecReservedBottomRight = Vector2D();
|
||||||
PMONITOR->vecReservedTopLeft = Vector2D();
|
PMONITOR->vecReservedTopLeft = Vector2D();
|
||||||
|
|
||||||
wlr_box usableArea = {PMONITOR->vecPosition.x, PMONITOR->vecPosition.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};
|
wlr_box usableArea = {PMONITOR->vecPosition.x, PMONITOR->vecPosition.y, PMONITOR->vecSize.x, PMONITOR->vecSize.y};
|
||||||
|
|
||||||
|
@ -941,16 +928,16 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) {
|
||||||
for (auto& la : PMONITOR->m_aLayerSurfaceLists)
|
for (auto& la : PMONITOR->m_aLayerSurfaceLists)
|
||||||
arrangeLayerArray(PMONITOR, la, false, &usableArea);
|
arrangeLayerArray(PMONITOR, la, false, &usableArea);
|
||||||
|
|
||||||
PMONITOR->vecReservedTopLeft = Vector2D(usableArea.x, usableArea.y) - PMONITOR->vecPosition;
|
PMONITOR->vecReservedTopLeft = Vector2D(usableArea.x, usableArea.y) - PMONITOR->vecPosition;
|
||||||
PMONITOR->vecReservedBottomRight = PMONITOR->vecSize - Vector2D(usableArea.width, usableArea.height) - PMONITOR->vecReservedTopLeft;
|
PMONITOR->vecReservedBottomRight = PMONITOR->vecSize - Vector2D(usableArea.width, usableArea.height) - PMONITOR->vecReservedTopLeft;
|
||||||
|
|
||||||
auto ADDITIONALRESERVED = g_pConfigManager->m_mAdditionalReservedAreas.find(PMONITOR->szName);
|
auto ADDITIONALRESERVED = g_pConfigManager->m_mAdditionalReservedAreas.find(PMONITOR->szName);
|
||||||
if (ADDITIONALRESERVED == g_pConfigManager->m_mAdditionalReservedAreas.end()) {
|
if (ADDITIONALRESERVED == g_pConfigManager->m_mAdditionalReservedAreas.end()) {
|
||||||
ADDITIONALRESERVED = g_pConfigManager->m_mAdditionalReservedAreas.find(""); // glob wildcard
|
ADDITIONALRESERVED = g_pConfigManager->m_mAdditionalReservedAreas.find(""); // glob wildcard
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ADDITIONALRESERVED != g_pConfigManager->m_mAdditionalReservedAreas.end()) {
|
if (ADDITIONALRESERVED != g_pConfigManager->m_mAdditionalReservedAreas.end()) {
|
||||||
PMONITOR->vecReservedTopLeft = PMONITOR->vecReservedTopLeft + Vector2D(ADDITIONALRESERVED->second.left, ADDITIONALRESERVED->second.top);
|
PMONITOR->vecReservedTopLeft = PMONITOR->vecReservedTopLeft + Vector2D(ADDITIONALRESERVED->second.left, ADDITIONALRESERVED->second.top);
|
||||||
PMONITOR->vecReservedBottomRight = PMONITOR->vecReservedBottomRight + Vector2D(ADDITIONALRESERVED->second.right, ADDITIONALRESERVED->second.bottom);
|
PMONITOR->vecReservedBottomRight = PMONITOR->vecReservedBottomRight + Vector2D(ADDITIONALRESERVED->second.right, ADDITIONALRESERVED->second.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -960,7 +947,8 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& monitor) {
|
||||||
|
|
||||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitor);
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(monitor);
|
||||||
|
|
||||||
Debug::log(LOG, "Monitor %s layers arranged: reserved: %f %f %f %f", PMONITOR->szName.c_str(), PMONITOR->vecReservedTopLeft.x, PMONITOR->vecReservedTopLeft.y, PMONITOR->vecReservedBottomRight.x, PMONITOR->vecReservedBottomRight.y);
|
Debug::log(LOG, "Monitor %s layers arranged: reserved: %f %f %f %f", PMONITOR->szName.c_str(), PMONITOR->vecReservedTopLeft.x, PMONITOR->vecReservedTopLeft.y,
|
||||||
|
PMONITOR->vecReservedBottomRight.x, PMONITOR->vecReservedBottomRight.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) {
|
void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) {
|
||||||
|
@ -1001,10 +989,11 @@ void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) {
|
||||||
|
|
||||||
pixman_region32_fini(&damageBoxForEach);
|
pixman_region32_fini(&damageBoxForEach);
|
||||||
|
|
||||||
static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
|
static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
|
||||||
|
|
||||||
if (*PLOGDAMAGE)
|
if (*PLOGDAMAGE)
|
||||||
Debug::log(LOG, "Damage: Surface (extents): xy: %d, %d wh: %d, %d", damageBox.extents.x1, damageBox.extents.y1, damageBox.extents.x2 - damageBox.extents.x1, damageBox.extents.y2 - damageBox.extents.y1);
|
Debug::log(LOG, "Damage: Surface (extents): xy: %d, %d wh: %d, %d", damageBox.extents.x1, damageBox.extents.y1, damageBox.extents.x2 - damageBox.extents.x1,
|
||||||
|
damageBox.extents.y2 - damageBox.extents.y1);
|
||||||
|
|
||||||
pixman_region32_fini(&damageBox);
|
pixman_region32_fini(&damageBox);
|
||||||
}
|
}
|
||||||
|
@ -1020,7 +1009,7 @@ void CHyprRenderer::damageWindow(CWindow* pWindow) {
|
||||||
m->addDamage(&fixedDamageBox);
|
m->addDamage(&fixedDamageBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
|
static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
|
||||||
|
|
||||||
if (*PLOGDAMAGE)
|
if (*PLOGDAMAGE)
|
||||||
Debug::log(LOG, "Damage: Window (%s): xy: %d, %d wh: %d, %d", pWindow->m_szTitle.c_str(), damageBox.x, damageBox.y, damageBox.width, damageBox.height);
|
Debug::log(LOG, "Damage: Window (%s): xy: %d, %d wh: %d, %d", pWindow->m_szTitle.c_str(), damageBox.x, damageBox.y, damageBox.width, damageBox.height);
|
||||||
|
@ -1030,10 +1019,10 @@ void CHyprRenderer::damageMonitor(CMonitor* pMonitor) {
|
||||||
if (g_pCompositor->m_bUnsafeState || pMonitor->isMirror())
|
if (g_pCompositor->m_bUnsafeState || pMonitor->isMirror())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wlr_box damageBox = { 0, 0, INT16_MAX, INT16_MAX };
|
wlr_box damageBox = {0, 0, INT16_MAX, INT16_MAX};
|
||||||
pMonitor->addDamage(&damageBox);
|
pMonitor->addDamage(&damageBox);
|
||||||
|
|
||||||
static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
|
static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
|
||||||
|
|
||||||
if (*PLOGDAMAGE)
|
if (*PLOGDAMAGE)
|
||||||
Debug::log(LOG, "Damage: Monitor %s", pMonitor->szName.c_str());
|
Debug::log(LOG, "Damage: Monitor %s", pMonitor->szName.c_str());
|
||||||
|
@ -1052,7 +1041,7 @@ void CHyprRenderer::damageBox(wlr_box* pBox) {
|
||||||
m->addDamage(&damageBox);
|
m->addDamage(&damageBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto *const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
|
static auto* const PLOGDAMAGE = &g_pConfigManager->getConfigValuePtr("debug:log_damage")->intValue;
|
||||||
|
|
||||||
if (*PLOGDAMAGE)
|
if (*PLOGDAMAGE)
|
||||||
Debug::log(LOG, "Damage: Box: xy: %d, %d wh: %d, %d", pBox->x, pBox->y, pBox->width, pBox->height);
|
Debug::log(LOG, "Damage: Box: xy: %d, %d wh: %d, %d", pBox->x, pBox->y, pBox->width, pBox->height);
|
||||||
|
@ -1072,7 +1061,7 @@ void CHyprRenderer::damageRegion(pixman_region32_t* rg) {
|
||||||
|
|
||||||
void CHyprRenderer::damageMirrorsWith(CMonitor* pMonitor, pixman_region32_t* pRegion) {
|
void CHyprRenderer::damageMirrorsWith(CMonitor* pMonitor, pixman_region32_t* pRegion) {
|
||||||
for (auto& mirror : pMonitor->mirrors) {
|
for (auto& mirror : pMonitor->mirrors) {
|
||||||
Vector2D scale = {mirror->vecSize.x / pMonitor->vecSize.x, mirror->vecSize.y / pMonitor->vecSize.y};
|
Vector2D scale = {mirror->vecSize.x / pMonitor->vecSize.x, mirror->vecSize.y / pMonitor->vecSize.y};
|
||||||
|
|
||||||
pixman_region32_t rg;
|
pixman_region32_t rg;
|
||||||
pixman_region32_init(&rg);
|
pixman_region32_init(&rg);
|
||||||
|
@ -1088,13 +1077,14 @@ void CHyprRenderer::renderDragIcon(CMonitor* pMonitor, timespec* time) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SRenderData renderdata = {pMonitor->output, time, g_pInputManager->m_sDrag.pos.x, g_pInputManager->m_sDrag.pos.y};
|
SRenderData renderdata = {pMonitor->output, time, g_pInputManager->m_sDrag.pos.x, g_pInputManager->m_sDrag.pos.y};
|
||||||
renderdata.surface = g_pInputManager->m_sDrag.dragIcon->surface;
|
renderdata.surface = g_pInputManager->m_sDrag.dragIcon->surface;
|
||||||
renderdata.w = g_pInputManager->m_sDrag.dragIcon->surface->current.width;
|
renderdata.w = g_pInputManager->m_sDrag.dragIcon->surface->current.width;
|
||||||
renderdata.h = g_pInputManager->m_sDrag.dragIcon->surface->current.height;
|
renderdata.h = g_pInputManager->m_sDrag.dragIcon->surface->current.height;
|
||||||
|
|
||||||
wlr_surface_for_each_surface(g_pInputManager->m_sDrag.dragIcon->surface, renderSurface, &renderdata);
|
wlr_surface_for_each_surface(g_pInputManager->m_sDrag.dragIcon->surface, renderSurface, &renderdata);
|
||||||
|
|
||||||
wlr_box box = {g_pInputManager->m_sDrag.pos.x - 2, g_pInputManager->m_sDrag.pos.y - 2, g_pInputManager->m_sDrag.dragIcon->surface->current.width + 4, g_pInputManager->m_sDrag.dragIcon->surface->current.height + 4};
|
wlr_box box = {g_pInputManager->m_sDrag.pos.x - 2, g_pInputManager->m_sDrag.pos.y - 2, g_pInputManager->m_sDrag.dragIcon->surface->current.width + 4,
|
||||||
|
g_pInputManager->m_sDrag.dragIcon->surface->current.height + 4};
|
||||||
g_pHyprRenderer->damageBox(&box);
|
g_pHyprRenderer->damageBox(&box);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1128,14 +1118,11 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the rule isn't already applied
|
// Check if the rule isn't already applied
|
||||||
if (!force
|
if (!force && DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1) &&
|
||||||
&& DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1)
|
DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1) && pMonitor->scale == pMonitorRule->scale &&
|
||||||
&& DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1)
|
((DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1)) ||
|
||||||
&& DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1)
|
pMonitorRule->offset == Vector2D(-1, -1)) &&
|
||||||
&& pMonitor->scale == pMonitorRule->scale
|
pMonitor->transform == pMonitorRule->transform && pMonitorRule->enable10bit == pMonitor->enabled10bit) {
|
||||||
&& ((DELTALESSTHAN(pMonitor->vecPosition.x, pMonitorRule->offset.x, 1) && DELTALESSTHAN(pMonitor->vecPosition.y, pMonitorRule->offset.y, 1)) || pMonitorRule->offset == Vector2D(-1, -1))
|
|
||||||
&& pMonitor->transform == pMonitorRule->transform
|
|
||||||
&& pMonitorRule->enable10bit == pMonitor->enabled10bit) {
|
|
||||||
|
|
||||||
Debug::log(LOG, "Not applying a new rule to %s because it's already applied!", pMonitor->szName.c_str());
|
Debug::log(LOG, "Not applying a new rule to %s because it's already applied!", pMonitor->szName.c_str());
|
||||||
return true;
|
return true;
|
||||||
|
@ -1154,31 +1141,30 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
pMonitor->transform = pMonitorRule->transform;
|
pMonitor->transform = pMonitorRule->transform;
|
||||||
|
|
||||||
// loop over modes and choose an appropriate one.
|
// loop over modes and choose an appropriate one.
|
||||||
if (pMonitorRule->resolution != Vector2D() && pMonitorRule->resolution != Vector2D(-1,-1) && pMonitorRule->resolution != Vector2D(-1,-2)) {
|
if (pMonitorRule->resolution != Vector2D() && pMonitorRule->resolution != Vector2D(-1, -1) && pMonitorRule->resolution != Vector2D(-1, -2)) {
|
||||||
if (!wl_list_empty(&pMonitor->output->modes)) {
|
if (!wl_list_empty(&pMonitor->output->modes)) {
|
||||||
wlr_output_mode* mode;
|
wlr_output_mode* mode;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
wl_list_for_each(mode, &pMonitor->output->modes, link) {
|
wl_list_for_each(mode, &pMonitor->output->modes, link) {
|
||||||
// if delta of refresh rate, w and h chosen and mode is < 1 we accept it
|
// if delta of refresh rate, w and h chosen and mode is < 1 we accept it
|
||||||
if (DELTALESSTHAN(mode->width, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(mode->height, pMonitorRule->resolution.y, 1) && DELTALESSTHAN(mode->refresh / 1000.f, pMonitorRule->refreshRate, 1)) {
|
if (DELTALESSTHAN(mode->width, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(mode->height, pMonitorRule->resolution.y, 1) &&
|
||||||
|
DELTALESSTHAN(mode->refresh / 1000.f, pMonitorRule->refreshRate, 1)) {
|
||||||
wlr_output_set_mode(pMonitor->output, mode);
|
wlr_output_set_mode(pMonitor->output, mode);
|
||||||
|
|
||||||
if (!wlr_output_test(pMonitor->output)) {
|
if (!wlr_output_test(pMonitor->output)) {
|
||||||
Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!",
|
Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!", pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y,
|
||||||
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
|
(float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh / 1000.f);
|
||||||
mode->width, mode->height, mode->refresh / 1000.f);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.",
|
Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.", pMonitor->output->name, (int)pMonitorRule->resolution.x,
|
||||||
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
|
(int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh);
|
||||||
mode->width, mode->height, mode->refresh);
|
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
pMonitor->refreshRate = mode->refresh / 1000.f;
|
pMonitor->refreshRate = mode->refresh / 1000.f;
|
||||||
pMonitor->vecSize = Vector2D(mode->width, mode->height);
|
pMonitor->vecSize = Vector2D(mode->width, mode->height);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1186,7 +1172,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000);
|
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000);
|
||||||
pMonitor->vecSize = pMonitorRule->resolution;
|
pMonitor->vecSize = pMonitorRule->resolution;
|
||||||
pMonitor->refreshRate = pMonitorRule->refreshRate;
|
pMonitor->refreshRate = pMonitorRule->refreshRate;
|
||||||
|
|
||||||
if (!wlr_output_test(pMonitor->output)) {
|
if (!wlr_output_test(pMonitor->output)) {
|
||||||
|
@ -1195,27 +1181,28 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
|
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
|
||||||
|
|
||||||
if (!PREFERREDMODE) {
|
if (!PREFERREDMODE) {
|
||||||
Debug::log(ERR, "Monitor %s has NO PREFERRED MODE, and an INVALID one was requested: %ix%i@%2f",
|
Debug::log(ERR, "Monitor %s has NO PREFERRED MODE, and an INVALID one was requested: %ix%i@%2f", (int)pMonitorRule->resolution.x,
|
||||||
(int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
|
(int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preferred is valid
|
// Preferred is valid
|
||||||
wlr_output_set_mode(pMonitor->output, PREFERREDMODE);
|
wlr_output_set_mode(pMonitor->output, PREFERREDMODE);
|
||||||
|
|
||||||
Debug::log(ERR, "Monitor %s got an invalid requested mode: %ix%i@%2f, using the preferred one instead: %ix%i@%2f",
|
Debug::log(ERR, "Monitor %s got an invalid requested mode: %ix%i@%2f, using the preferred one instead: %ix%i@%2f", pMonitor->output->name,
|
||||||
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
|
(int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height,
|
||||||
PREFERREDMODE->width, PREFERREDMODE->height, PREFERREDMODE->refresh / 1000.f);
|
PREFERREDMODE->refresh / 1000.f);
|
||||||
|
|
||||||
pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f;
|
pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f;
|
||||||
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
||||||
} else {
|
} else {
|
||||||
Debug::log(LOG, "Set a custom mode %ix%i@%2f (mode not found in monitor modes)", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
|
Debug::log(LOG, "Set a custom mode %ix%i@%2f (mode not found in monitor modes)", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y,
|
||||||
|
(float)pMonitorRule->refreshRate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000);
|
wlr_output_set_custom_mode(pMonitor->output, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (int)pMonitorRule->refreshRate * 1000);
|
||||||
pMonitor->vecSize = pMonitorRule->resolution;
|
pMonitor->vecSize = pMonitorRule->resolution;
|
||||||
pMonitor->refreshRate = pMonitorRule->refreshRate;
|
pMonitor->refreshRate = pMonitorRule->refreshRate;
|
||||||
|
|
||||||
if (!wlr_output_test(pMonitor->output)) {
|
if (!wlr_output_test(pMonitor->output)) {
|
||||||
|
@ -1224,94 +1211,96 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
|
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
|
||||||
|
|
||||||
if (!PREFERREDMODE) {
|
if (!PREFERREDMODE) {
|
||||||
Debug::log(ERR, "Monitor %s has NO PREFERRED MODE, and an INVALID one was requested: %ix%i@%2f", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
|
Debug::log(ERR, "Monitor %s has NO PREFERRED MODE, and an INVALID one was requested: %ix%i@%2f", (int)pMonitorRule->resolution.x,
|
||||||
|
(int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preferred is valid
|
// Preferred is valid
|
||||||
wlr_output_set_mode(pMonitor->output, PREFERREDMODE);
|
wlr_output_set_mode(pMonitor->output, PREFERREDMODE);
|
||||||
|
|
||||||
Debug::log(ERR, "Monitor %s got an invalid requested mode: %ix%i@%2f, using the preferred one instead: %ix%i@%2f", pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height, PREFERREDMODE->refresh / 1000.f);
|
Debug::log(ERR, "Monitor %s got an invalid requested mode: %ix%i@%2f, using the preferred one instead: %ix%i@%2f", pMonitor->output->name,
|
||||||
|
(int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height,
|
||||||
|
PREFERREDMODE->refresh / 1000.f);
|
||||||
|
|
||||||
pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f;
|
pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f;
|
||||||
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
||||||
} else {
|
} else {
|
||||||
Debug::log(LOG, "Set a custom mode %ix%i@%2f (mode not found in monitor modes)", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
|
Debug::log(LOG, "Set a custom mode %ix%i@%2f (mode not found in monitor modes)", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y,
|
||||||
|
(float)pMonitorRule->refreshRate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (pMonitorRule->resolution != Vector2D()) {
|
} else if (pMonitorRule->resolution != Vector2D()) {
|
||||||
if (!wl_list_empty(&pMonitor->output->modes)) {
|
if (!wl_list_empty(&pMonitor->output->modes)) {
|
||||||
wlr_output_mode* mode;
|
wlr_output_mode* mode;
|
||||||
float currentWidth = 0;
|
float currentWidth = 0;
|
||||||
float currentHeight = 0;
|
float currentHeight = 0;
|
||||||
float currentRefresh = 0;
|
float currentRefresh = 0;
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
//(-1,-1) indicates a preference to refreshrate over resolution, (-1,-2) preference to resolution
|
//(-1,-1) indicates a preference to refreshrate over resolution, (-1,-2) preference to resolution
|
||||||
if(pMonitorRule->resolution == Vector2D(-1,-1)) {
|
if (pMonitorRule->resolution == Vector2D(-1, -1)) {
|
||||||
wl_list_for_each(mode, &pMonitor->output->modes, link) {
|
wl_list_for_each(mode, &pMonitor->output->modes, link) {
|
||||||
if( ( mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= ( currentRefresh - 1000.f ) ) || mode->refresh > ( currentRefresh + 3000.f ) ) {
|
if ((mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= (currentRefresh - 1000.f)) || mode->refresh > (currentRefresh + 3000.f)) {
|
||||||
wlr_output_set_mode(pMonitor->output, mode);
|
wlr_output_set_mode(pMonitor->output, mode);
|
||||||
if (wlr_output_test(pMonitor->output)) {
|
if (wlr_output_test(pMonitor->output)) {
|
||||||
currentWidth = mode->width;
|
currentWidth = mode->width;
|
||||||
currentHeight = mode->height;
|
currentHeight = mode->height;
|
||||||
currentRefresh = mode->refresh;
|
currentRefresh = mode->refresh;
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wl_list_for_each(mode, &pMonitor->output->modes, link) {
|
wl_list_for_each(mode, &pMonitor->output->modes, link) {
|
||||||
if( ( mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= ( currentRefresh - 1000.f ) ) || ( mode->width > currentWidth && mode->height > currentHeight ) ) {
|
if ((mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= (currentRefresh - 1000.f)) ||
|
||||||
wlr_output_set_mode(pMonitor->output, mode);
|
(mode->width > currentWidth && mode->height > currentHeight)) {
|
||||||
if (wlr_output_test(pMonitor->output)) {
|
wlr_output_set_mode(pMonitor->output, mode);
|
||||||
currentWidth = mode->width;
|
if (wlr_output_test(pMonitor->output)) {
|
||||||
currentHeight = mode->height;
|
currentWidth = mode->width;
|
||||||
currentRefresh = mode->refresh;
|
currentHeight = mode->height;
|
||||||
success = true;
|
currentRefresh = mode->refresh;
|
||||||
}
|
success = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
Debug::log(LOG, "Monitor %s: REJECTED mode: %ix%i@%2f! Falling back to preferred.",
|
Debug::log(LOG, "Monitor %s: REJECTED mode: %ix%i@%2f! Falling back to preferred.", pMonitor->output->name, (int)pMonitorRule->resolution.x,
|
||||||
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
|
(int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh / 1000.f);
|
||||||
mode->width, mode->height, mode->refresh / 1000.f);
|
|
||||||
|
|
||||||
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
|
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
|
||||||
|
|
||||||
if (!PREFERREDMODE) {
|
if (!PREFERREDMODE) {
|
||||||
Debug::log(ERR, "Monitor %s has NO PREFERRED MODE, and an INVALID one was requested: %ix%i@%2f",
|
Debug::log(ERR, "Monitor %s has NO PREFERRED MODE, and an INVALID one was requested: %ix%i@%2f", (int)pMonitorRule->resolution.x,
|
||||||
(int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
|
(int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preferred is valid
|
// Preferred is valid
|
||||||
wlr_output_set_mode(pMonitor->output, PREFERREDMODE);
|
wlr_output_set_mode(pMonitor->output, PREFERREDMODE);
|
||||||
|
|
||||||
Debug::log(ERR, "Monitor %s got an invalid requested mode: %ix%i@%2f, using the preferred one instead: %ix%i@%2f",
|
Debug::log(ERR, "Monitor %s got an invalid requested mode: %ix%i@%2f, using the preferred one instead: %ix%i@%2f", pMonitor->output->name,
|
||||||
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
|
(int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, PREFERREDMODE->width, PREFERREDMODE->height,
|
||||||
PREFERREDMODE->width, PREFERREDMODE->height, PREFERREDMODE->refresh / 1000.f);
|
PREFERREDMODE->refresh / 1000.f);
|
||||||
|
|
||||||
pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f;
|
pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f;
|
||||||
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Debug::log(LOG, "Monitor %s: Applying highest mode %ix%i@%2f.",
|
Debug::log(LOG, "Monitor %s: Applying highest mode %ix%i@%2f.", pMonitor->output->name, (int)currentWidth, (int)currentHeight, (int)currentRefresh / 1000.f,
|
||||||
pMonitor->output->name, (int)currentWidth, (int)currentHeight, (int)currentRefresh / 1000.f,
|
|
||||||
mode->width, mode->height, mode->refresh / 1000.f);
|
mode->width, mode->height, mode->refresh / 1000.f);
|
||||||
|
|
||||||
pMonitor->refreshRate = currentRefresh / 1000.f;
|
pMonitor->refreshRate = currentRefresh / 1000.f;
|
||||||
pMonitor->vecSize = Vector2D(currentWidth, currentHeight);
|
pMonitor->vecSize = Vector2D(currentWidth, currentHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
|
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
|
||||||
|
|
||||||
if (!PREFERREDMODE) {
|
if (!PREFERREDMODE) {
|
||||||
Debug::log(ERR, "Monitor %s has NO PREFERRED MODE",
|
Debug::log(ERR, "Monitor %s has NO PREFERRED MODE", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
|
||||||
(int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
|
|
||||||
|
|
||||||
if (!wl_list_empty(&pMonitor->output->modes)) {
|
if (!wl_list_empty(&pMonitor->output->modes)) {
|
||||||
wlr_output_mode* mode;
|
wlr_output_mode* mode;
|
||||||
|
@ -1320,18 +1309,16 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
wlr_output_set_mode(pMonitor->output, mode);
|
wlr_output_set_mode(pMonitor->output, mode);
|
||||||
|
|
||||||
if (!wlr_output_test(pMonitor->output)) {
|
if (!wlr_output_test(pMonitor->output)) {
|
||||||
Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!",
|
Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!", pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y,
|
||||||
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
|
(float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh / 1000.f);
|
||||||
mode->width, mode->height, mode->refresh / 1000.f);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.",
|
Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.", pMonitor->output->name, (int)pMonitorRule->resolution.x,
|
||||||
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
|
(int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh);
|
||||||
mode->width, mode->height, mode->refresh);
|
|
||||||
|
|
||||||
pMonitor->refreshRate = mode->refresh / 1000.f;
|
pMonitor->refreshRate = mode->refresh / 1000.f;
|
||||||
pMonitor->vecSize = Vector2D(mode->width, mode->height);
|
pMonitor->vecSize = Vector2D(mode->width, mode->height);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1340,14 +1327,14 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
// Preferred is valid
|
// Preferred is valid
|
||||||
wlr_output_set_mode(pMonitor->output, PREFERREDMODE);
|
wlr_output_set_mode(pMonitor->output, PREFERREDMODE);
|
||||||
|
|
||||||
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
||||||
pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f;
|
pMonitor->refreshRate = PREFERREDMODE->refresh / 1000.f;
|
||||||
|
|
||||||
Debug::log(LOG, "Setting preferred mode for %s", pMonitor->output->name);
|
Debug::log(LOG, "Setting preferred mode for %s", pMonitor->output->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pMonitor->vrrActive = pMonitor->output->pending.adaptive_sync_enabled; // disabled here, will be tested in CConfigManager::ensureVRR()
|
pMonitor->vrrActive = pMonitor->output->pending.adaptive_sync_enabled; // disabled here, will be tested in CConfigManager::ensureVRR()
|
||||||
|
|
||||||
pMonitor->vecPixelSize = pMonitor->vecSize;
|
pMonitor->vecPixelSize = pMonitor->vecSize;
|
||||||
|
|
||||||
|
@ -1382,12 +1369,13 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
wlr_output_transformed_resolution(pMonitor->output, &x, &y);
|
wlr_output_transformed_resolution(pMonitor->output, &x, &y);
|
||||||
pMonitor->vecSize = (Vector2D(x, y) / pMonitor->scale).floor();
|
pMonitor->vecSize = (Vector2D(x, y) / pMonitor->scale).floor();
|
||||||
pMonitor->vecTransformedSize = Vector2D(x,y);
|
pMonitor->vecTransformedSize = Vector2D(x, y);
|
||||||
|
|
||||||
if (pMonitor->createdByUser) {
|
if (pMonitor->createdByUser) {
|
||||||
wlr_box transformedBox = { 0, 0, (int)pMonitor->vecTransformedSize.x, (int)pMonitor->vecTransformedSize.y };
|
wlr_box transformedBox = {0, 0, (int)pMonitor->vecTransformedSize.x, (int)pMonitor->vecTransformedSize.y};
|
||||||
wlr_box_transform(&transformedBox, &transformedBox, wlr_output_transform_invert(pMonitor->output->transform), (int)pMonitor->vecTransformedSize.x, (int)pMonitor->vecTransformedSize.y);
|
wlr_box_transform(&transformedBox, &transformedBox, wlr_output_transform_invert(pMonitor->output->transform), (int)pMonitor->vecTransformedSize.x,
|
||||||
|
(int)pMonitor->vecTransformedSize.y);
|
||||||
|
|
||||||
pMonitor->vecPixelSize = Vector2D(transformedBox.width, transformedBox.height);
|
pMonitor->vecPixelSize = Vector2D(transformedBox.width, transformedBox.height);
|
||||||
}
|
}
|
||||||
|
@ -1431,9 +1419,9 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprRenderer::ensureCursorRenderingMode() {
|
void CHyprRenderer::ensureCursorRenderingMode() {
|
||||||
static auto *const PCURSORTIMEOUT = &g_pConfigManager->getConfigValuePtr("general:cursor_inactive_timeout")->intValue;
|
static auto* const PCURSORTIMEOUT = &g_pConfigManager->getConfigValuePtr("general:cursor_inactive_timeout")->intValue;
|
||||||
|
|
||||||
const auto PASSEDCURSORSECONDS = g_pInputManager->m_tmrLastCursorMovement.getSeconds();
|
const auto PASSEDCURSORSECONDS = g_pInputManager->m_tmrLastCursorMovement.getSeconds();
|
||||||
|
|
||||||
if (*PCURSORTIMEOUT > 0) {
|
if (*PCURSORTIMEOUT > 0) {
|
||||||
if (*PCURSORTIMEOUT < PASSEDCURSORSECONDS && m_bHasARenderedCursor) {
|
if (*PCURSORTIMEOUT < PASSEDCURSORSECONDS && m_bHasARenderedCursor) {
|
||||||
|
@ -1444,7 +1432,7 @@ void CHyprRenderer::ensureCursorRenderingMode() {
|
||||||
Debug::log(LOG, "Hiding the cursor (timeout)");
|
Debug::log(LOG, "Hiding the cursor (timeout)");
|
||||||
|
|
||||||
for (auto& m : g_pCompositor->m_vMonitors)
|
for (auto& m : g_pCompositor->m_vMonitors)
|
||||||
g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area?
|
g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area?
|
||||||
} else if (*PCURSORTIMEOUT > PASSEDCURSORSECONDS && !m_bHasARenderedCursor) {
|
} else if (*PCURSORTIMEOUT > PASSEDCURSORSECONDS && !m_bHasARenderedCursor) {
|
||||||
m_bHasARenderedCursor = true;
|
m_bHasARenderedCursor = true;
|
||||||
|
|
||||||
|
@ -1454,7 +1442,7 @@ void CHyprRenderer::ensureCursorRenderingMode() {
|
||||||
Debug::log(LOG, "Showing the cursor (timeout)");
|
Debug::log(LOG, "Showing the cursor (timeout)");
|
||||||
|
|
||||||
for (auto& m : g_pCompositor->m_vMonitors)
|
for (auto& m : g_pCompositor->m_vMonitors)
|
||||||
g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area?
|
g_pHyprRenderer->damageMonitor(m.get()); // TODO: maybe just damage the cursor area?
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_bHasARenderedCursor = true;
|
m_bHasARenderedCursor = true;
|
||||||
|
|
|
@ -10,14 +10,16 @@
|
||||||
struct SMonitorRule;
|
struct SMonitorRule;
|
||||||
|
|
||||||
// TODO: add fuller damage tracking for updating only parts of a window
|
// TODO: add fuller damage tracking for updating only parts of a window
|
||||||
enum DAMAGETRACKINGMODES {
|
enum DAMAGETRACKINGMODES
|
||||||
|
{
|
||||||
DAMAGE_TRACKING_INVALID = -1,
|
DAMAGE_TRACKING_INVALID = -1,
|
||||||
DAMAGE_TRACKING_NONE = 0,
|
DAMAGE_TRACKING_NONE = 0,
|
||||||
DAMAGE_TRACKING_MONITOR,
|
DAMAGE_TRACKING_MONITOR,
|
||||||
DAMAGE_TRACKING_FULL
|
DAMAGE_TRACKING_FULL
|
||||||
};
|
};
|
||||||
|
|
||||||
enum eRenderPassMode {
|
enum eRenderPassMode
|
||||||
|
{
|
||||||
RENDER_PASS_ALL = 0,
|
RENDER_PASS_ALL = 0,
|
||||||
RENDER_PASS_MAIN,
|
RENDER_PASS_MAIN,
|
||||||
RENDER_PASS_POPUP
|
RENDER_PASS_POPUP
|
||||||
|
@ -26,8 +28,7 @@ enum eRenderPassMode {
|
||||||
class CToplevelExportProtocolManager;
|
class CToplevelExportProtocolManager;
|
||||||
|
|
||||||
class CHyprRenderer {
|
class CHyprRenderer {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void renderAllClientsForMonitor(const int&, timespec*);
|
void renderAllClientsForMonitor(const int&, timespec*);
|
||||||
void outputMgrApplyTest(wlr_output_configuration_v1*, bool);
|
void outputMgrApplyTest(wlr_output_configuration_v1*, bool);
|
||||||
void arrangeLayersForMonitor(const int&);
|
void arrangeLayersForMonitor(const int&);
|
||||||
|
@ -46,24 +47,23 @@ public:
|
||||||
void calculateUVForWindowSurface(CWindow*, wlr_surface*, bool main = false);
|
void calculateUVForWindowSurface(CWindow*, wlr_surface*, bool main = false);
|
||||||
|
|
||||||
bool m_bWindowRequestedCursorHide = false;
|
bool m_bWindowRequestedCursorHide = false;
|
||||||
bool m_bBlockSurfaceFeedback = false;
|
bool m_bBlockSurfaceFeedback = false;
|
||||||
CWindow* m_pLastScanout = nullptr;
|
CWindow* m_pLastScanout = nullptr;
|
||||||
|
|
||||||
DAMAGETRACKINGMODES damageTrackingModeFromStr(const std::string&);
|
DAMAGETRACKINGMODES damageTrackingModeFromStr(const std::string&);
|
||||||
|
|
||||||
bool attemptDirectScanout(CMonitor*);
|
bool attemptDirectScanout(CMonitor*);
|
||||||
void setWindowScanoutMode(CWindow*);
|
void setWindowScanoutMode(CWindow*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*);
|
void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*);
|
||||||
void renderWorkspaceWithFullscreenWindow(CMonitor*, CWorkspace*, timespec*);
|
void renderWorkspaceWithFullscreenWindow(CMonitor*, CWorkspace*, timespec*);
|
||||||
void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false);
|
void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false);
|
||||||
void renderLayer(SLayerSurface*, CMonitor*, timespec*);
|
void renderLayer(SLayerSurface*, CMonitor*, timespec*);
|
||||||
void renderDragIcon(CMonitor*, timespec*);
|
void renderDragIcon(CMonitor*, timespec*);
|
||||||
void renderIMEPopup(SIMEPopup*, CMonitor*, timespec*);
|
void renderIMEPopup(SIMEPopup*, CMonitor*, timespec*);
|
||||||
|
|
||||||
bool m_bHasARenderedCursor = true;
|
|
||||||
|
|
||||||
|
bool m_bHasARenderedCursor = true;
|
||||||
|
|
||||||
friend class CHyprOpenGLImpl;
|
friend class CHyprOpenGLImpl;
|
||||||
friend class CToplevelExportProtocolManager;
|
friend class CToplevelExportProtocolManager;
|
||||||
|
|
|
@ -4,43 +4,43 @@
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
class CShader {
|
class CShader {
|
||||||
public:
|
public:
|
||||||
~CShader();
|
~CShader();
|
||||||
|
|
||||||
GLuint program = 0;
|
GLuint program = 0;
|
||||||
GLint proj;
|
GLint proj;
|
||||||
GLint color;
|
GLint color;
|
||||||
GLint tex;
|
GLint tex;
|
||||||
GLint alpha;
|
GLint alpha;
|
||||||
GLint posAttrib;
|
GLint posAttrib;
|
||||||
GLint texAttrib;
|
GLint texAttrib;
|
||||||
GLint discardOpaque;
|
GLint discardOpaque;
|
||||||
|
|
||||||
GLint topLeft;
|
GLint topLeft;
|
||||||
GLint bottomRight;
|
GLint bottomRight;
|
||||||
GLint fullSize;
|
GLint fullSize;
|
||||||
GLint fullSizeUntransformed;
|
GLint fullSizeUntransformed;
|
||||||
GLint radius;
|
GLint radius;
|
||||||
GLint primitiveMultisample;
|
GLint primitiveMultisample;
|
||||||
|
|
||||||
GLint thick;
|
GLint thick;
|
||||||
|
|
||||||
GLint halfpixel;
|
GLint halfpixel;
|
||||||
|
|
||||||
GLint range;
|
GLint range;
|
||||||
GLint shadowPower;
|
GLint shadowPower;
|
||||||
|
|
||||||
GLint applyTint;
|
GLint applyTint;
|
||||||
GLint tint;
|
GLint tint;
|
||||||
|
|
||||||
GLint gradient;
|
GLint gradient;
|
||||||
GLint gradientLength;
|
GLint gradientLength;
|
||||||
GLint angle;
|
GLint angle;
|
||||||
|
|
||||||
GLint getUniformLocation(const std::string&);
|
GLint getUniformLocation(const std::string&);
|
||||||
|
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unordered_map<std::string, GLint> m_muUniforms;
|
std::unordered_map<std::string, GLint> m_muUniforms;
|
||||||
};
|
};
|
|
@ -10,7 +10,7 @@ CTexture::CTexture(wlr_texture* tex) {
|
||||||
wlr_gles2_texture_get_attribs(tex, &attrs);
|
wlr_gles2_texture_get_attribs(tex, &attrs);
|
||||||
|
|
||||||
m_iTarget = attrs.target;
|
m_iTarget = attrs.target;
|
||||||
m_iTexID = attrs.tex;
|
m_iTexID = attrs.tex;
|
||||||
|
|
||||||
if (m_iTarget == GL_TEXTURE_2D) {
|
if (m_iTarget == GL_TEXTURE_2D) {
|
||||||
m_iType = attrs.has_alpha ? TEXTURE_RGBA : TEXTURE_RGBX;
|
m_iType = attrs.has_alpha ? TEXTURE_RGBA : TEXTURE_RGBX;
|
||||||
|
|
|
@ -2,23 +2,24 @@
|
||||||
|
|
||||||
#include "../defines.hpp"
|
#include "../defines.hpp"
|
||||||
|
|
||||||
enum TEXTURETYPE {
|
enum TEXTURETYPE
|
||||||
TEXTURE_INVALID, // Invalid
|
{
|
||||||
TEXTURE_RGBA, // 4 channels
|
TEXTURE_INVALID, // Invalid
|
||||||
TEXTURE_RGBX, // discard A
|
TEXTURE_RGBA, // 4 channels
|
||||||
TEXTURE_EXTERNAL, // EGLImage
|
TEXTURE_RGBX, // discard A
|
||||||
|
TEXTURE_EXTERNAL, // EGLImage
|
||||||
};
|
};
|
||||||
|
|
||||||
class CTexture {
|
class CTexture {
|
||||||
public:
|
public:
|
||||||
CTexture();
|
CTexture();
|
||||||
CTexture(wlr_texture*);
|
CTexture(wlr_texture*);
|
||||||
|
|
||||||
void destroyTexture();
|
void destroyTexture();
|
||||||
void allocate();
|
void allocate();
|
||||||
|
|
||||||
TEXTURETYPE m_iType = TEXTURE_RGBA;
|
TEXTURETYPE m_iType = TEXTURE_RGBA;
|
||||||
GLenum m_iTarget = GL_TEXTURE_2D;
|
GLenum m_iTarget = GL_TEXTURE_2D;
|
||||||
GLuint m_iTexID = 0;
|
GLuint m_iTexID = 0;
|
||||||
Vector2D m_vSize;
|
Vector2D m_vSize;
|
||||||
};
|
};
|
|
@ -11,7 +11,7 @@ CHyprDropShadowDecoration::~CHyprDropShadowDecoration() {
|
||||||
}
|
}
|
||||||
|
|
||||||
SWindowDecorationExtents CHyprDropShadowDecoration::getWindowDecorationExtents() {
|
SWindowDecorationExtents CHyprDropShadowDecoration::getWindowDecorationExtents() {
|
||||||
static auto *const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
|
static auto* const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
|
||||||
|
|
||||||
if (*PSHADOWS != 1)
|
if (*PSHADOWS != 1)
|
||||||
return {{}, {}};
|
return {{}, {}};
|
||||||
|
@ -24,12 +24,13 @@ eDecorationType CHyprDropShadowDecoration::getDecorationType() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprDropShadowDecoration::damageEntire() {
|
void CHyprDropShadowDecoration::damageEntire() {
|
||||||
static auto *const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
|
static auto* const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
|
||||||
|
|
||||||
if (*PSHADOWS != 1)
|
if (*PSHADOWS != 1)
|
||||||
return; // disabled
|
return; // disabled
|
||||||
|
|
||||||
wlr_box dm = {m_vLastWindowPos.x - m_seExtents.topLeft.x, m_vLastWindowPos.y - m_seExtents.topLeft.y, m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x, m_vLastWindowSize.y + m_seExtents.topLeft.y + m_seExtents.bottomRight.y};
|
wlr_box dm = {m_vLastWindowPos.x - m_seExtents.topLeft.x, m_vLastWindowPos.y - m_seExtents.topLeft.y, m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x,
|
||||||
|
m_vLastWindowSize.y + m_seExtents.topLeft.y + m_seExtents.bottomRight.y};
|
||||||
g_pHyprRenderer->damageBox(&dm);
|
g_pHyprRenderer->damageBox(&dm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) {
|
||||||
const auto WORKSPACEOFFSET = PWORKSPACE && !pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D();
|
const auto WORKSPACEOFFSET = PWORKSPACE && !pWindow->m_bPinned ? PWORKSPACE->m_vRenderOffset.vec() : Vector2D();
|
||||||
|
|
||||||
if (pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET != m_vLastWindowPos || pWindow->m_vRealSize.vec() != m_vLastWindowSize) {
|
if (pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET != m_vLastWindowPos || pWindow->m_vRealSize.vec() != m_vLastWindowSize) {
|
||||||
m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET;
|
m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET;
|
||||||
m_vLastWindowSize = pWindow->m_vRealSize.vec();
|
m_vLastWindowSize = pWindow->m_vRealSize.vec();
|
||||||
|
|
||||||
damageEntire();
|
damageEntire();
|
||||||
|
@ -62,21 +63,21 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
|
||||||
if (m_pWindow->m_sAdditionalConfigData.forceNoShadow)
|
if (m_pWindow->m_sAdditionalConfigData.forceNoShadow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static auto *const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
|
static auto* const PSHADOWS = &g_pConfigManager->getConfigValuePtr("decoration:drop_shadow")->intValue;
|
||||||
static auto *const PSHADOWSIZE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_range")->intValue;
|
static auto* const PSHADOWSIZE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_range")->intValue;
|
||||||
static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
|
static auto* const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
|
||||||
static auto *const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue;
|
static auto* const PSHADOWIGNOREWINDOW = &g_pConfigManager->getConfigValuePtr("decoration:shadow_ignore_window")->intValue;
|
||||||
static auto *const PSHADOWSCALE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_scale")->floatValue;
|
static auto* const PSHADOWSCALE = &g_pConfigManager->getConfigValuePtr("decoration:shadow_scale")->floatValue;
|
||||||
static auto *const PSHADOWOFFSET = &g_pConfigManager->getConfigValuePtr("decoration:shadow_offset")->vecValue;
|
static auto* const PSHADOWOFFSET = &g_pConfigManager->getConfigValuePtr("decoration:shadow_offset")->vecValue;
|
||||||
|
|
||||||
if (*PSHADOWS != 1)
|
if (*PSHADOWS != 1)
|
||||||
return; // disabled
|
return; // disabled
|
||||||
|
|
||||||
const auto ROUNDING = !m_pWindow->m_sSpecialRenderData.rounding ? 0 : (m_pWindow->m_sAdditionalConfigData.rounding == -1 ? *PROUNDING : m_pWindow->m_sAdditionalConfigData.rounding);
|
const auto ROUNDING =
|
||||||
|
!m_pWindow->m_sSpecialRenderData.rounding ? 0 : (m_pWindow->m_sAdditionalConfigData.rounding == -1 ? *PROUNDING : m_pWindow->m_sAdditionalConfigData.rounding);
|
||||||
|
|
||||||
// draw the shadow
|
// draw the shadow
|
||||||
wlr_box fullBox = { m_vLastWindowPos.x - *PSHADOWSIZE, m_vLastWindowPos.y - *PSHADOWSIZE,
|
wlr_box fullBox = {m_vLastWindowPos.x - *PSHADOWSIZE, m_vLastWindowPos.y - *PSHADOWSIZE, m_vLastWindowSize.x + 2.0 * *PSHADOWSIZE, m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE};
|
||||||
m_vLastWindowSize.x + 2.0 * *PSHADOWSIZE, m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE };
|
|
||||||
|
|
||||||
fullBox.x -= pMonitor->vecPosition.x;
|
fullBox.x -= pMonitor->vecPosition.x;
|
||||||
fullBox.y -= pMonitor->vecPosition.y;
|
fullBox.y -= pMonitor->vecPosition.y;
|
||||||
|
@ -84,9 +85,9 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
|
||||||
const float SHADOWSCALE = std::clamp(*PSHADOWSCALE, 0.f, 1.f);
|
const float SHADOWSCALE = std::clamp(*PSHADOWSCALE, 0.f, 1.f);
|
||||||
|
|
||||||
// scale the box in relation to the center of the box
|
// scale the box in relation to the center of the box
|
||||||
const Vector2D NEWSIZE = Vector2D { fullBox.width, fullBox.height } * SHADOWSCALE;
|
const Vector2D NEWSIZE = Vector2D{fullBox.width, fullBox.height} * SHADOWSCALE;
|
||||||
fullBox.width = NEWSIZE.x;
|
fullBox.width = NEWSIZE.x;
|
||||||
fullBox.height = NEWSIZE.y;
|
fullBox.height = NEWSIZE.y;
|
||||||
|
|
||||||
if (PSHADOWOFFSET->x < 0) {
|
if (PSHADOWOFFSET->x < 0) {
|
||||||
fullBox.x += PSHADOWOFFSET->x;
|
fullBox.x += PSHADOWOFFSET->x;
|
||||||
|
@ -104,16 +105,15 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
|
||||||
fullBox.y += ((m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE) - NEWSIZE.y) / 2.0;
|
fullBox.y += ((m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE) - NEWSIZE.y) / 2.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_seExtents = { { m_vLastWindowPos.x - fullBox.x - pMonitor->vecPosition.x + 2,
|
m_seExtents = {{m_vLastWindowPos.x - fullBox.x - pMonitor->vecPosition.x + 2, m_vLastWindowPos.y - fullBox.y - pMonitor->vecPosition.y + 2},
|
||||||
m_vLastWindowPos.y - fullBox.y - pMonitor->vecPosition.y + 2},
|
{fullBox.x + fullBox.width + pMonitor->vecPosition.x - m_vLastWindowPos.x - m_vLastWindowSize.x + 2,
|
||||||
{ fullBox.x + fullBox.width + pMonitor->vecPosition.x - m_vLastWindowPos.x - m_vLastWindowSize.x + 2,
|
fullBox.y + fullBox.height + pMonitor->vecPosition.y - m_vLastWindowPos.y - m_vLastWindowSize.y + 2}};
|
||||||
fullBox.y + fullBox.height + pMonitor->vecPosition.y - m_vLastWindowPos.y - m_vLastWindowSize.y + 2} };
|
|
||||||
|
|
||||||
fullBox.x += offset.x;
|
fullBox.x += offset.x;
|
||||||
fullBox.y += offset.y;
|
fullBox.y += offset.y;
|
||||||
|
|
||||||
if (fullBox.width < 1 || fullBox.height < 1)
|
if (fullBox.width < 1 || fullBox.height < 1)
|
||||||
return; // don't draw invisible shadows
|
return; // don't draw invisible shadows
|
||||||
|
|
||||||
g_pHyprOpenGL->scissor((wlr_box*)nullptr);
|
g_pHyprOpenGL->scissor((wlr_box*)nullptr);
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
|
||||||
glClearStencil(0);
|
glClearStencil(0);
|
||||||
glClear(GL_STENCIL_BUFFER_BIT);
|
glClear(GL_STENCIL_BUFFER_BIT);
|
||||||
glDisable(GL_STENCIL_TEST);
|
glDisable(GL_STENCIL_TEST);
|
||||||
return; // prevent assert failed
|
return; // prevent assert failed
|
||||||
}
|
}
|
||||||
|
|
||||||
g_pHyprOpenGL->renderRect(&windowBox, CColor(0, 0, 0, 0), ROUNDING * pMonitor->scale);
|
g_pHyprOpenGL->renderRect(&windowBox, CColor(0, 0, 0, 0), ROUNDING * pMonitor->scale);
|
||||||
|
|
|
@ -3,25 +3,25 @@
|
||||||
#include "IHyprWindowDecoration.hpp"
|
#include "IHyprWindowDecoration.hpp"
|
||||||
|
|
||||||
class CHyprDropShadowDecoration : public IHyprWindowDecoration {
|
class CHyprDropShadowDecoration : public IHyprWindowDecoration {
|
||||||
public:
|
public:
|
||||||
CHyprDropShadowDecoration(CWindow*);
|
CHyprDropShadowDecoration(CWindow*);
|
||||||
virtual ~CHyprDropShadowDecoration();
|
virtual ~CHyprDropShadowDecoration();
|
||||||
|
|
||||||
virtual SWindowDecorationExtents getWindowDecorationExtents();
|
virtual SWindowDecorationExtents getWindowDecorationExtents();
|
||||||
|
|
||||||
virtual void draw(CMonitor*, float a, const Vector2D& offset);
|
virtual void draw(CMonitor*, float a, const Vector2D& offset);
|
||||||
|
|
||||||
virtual eDecorationType getDecorationType();
|
virtual eDecorationType getDecorationType();
|
||||||
|
|
||||||
virtual void updateWindow(CWindow*);
|
virtual void updateWindow(CWindow*);
|
||||||
|
|
||||||
virtual void damageEntire();
|
virtual void damageEntire();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SWindowDecorationExtents m_seExtents;
|
SWindowDecorationExtents m_seExtents;
|
||||||
|
|
||||||
CWindow* m_pWindow = nullptr;
|
CWindow* m_pWindow = nullptr;
|
||||||
|
|
||||||
Vector2D m_vLastWindowPos;
|
Vector2D m_vLastWindowPos;
|
||||||
Vector2D m_vLastWindowSize;
|
Vector2D m_vLastWindowSize;
|
||||||
};
|
};
|
|
@ -5,9 +5,7 @@ CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) {
|
||||||
m_pWindow = pWindow;
|
m_pWindow = pWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
CHyprGroupBarDecoration::~CHyprGroupBarDecoration() {
|
CHyprGroupBarDecoration::~CHyprGroupBarDecoration() {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SWindowDecorationExtents CHyprGroupBarDecoration::getWindowDecorationExtents() {
|
SWindowDecorationExtents CHyprGroupBarDecoration::getWindowDecorationExtents() {
|
||||||
return m_seExtents;
|
return m_seExtents;
|
||||||
|
@ -28,10 +26,10 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) {
|
||||||
// we draw 3px above the window's border with 3px
|
// we draw 3px above the window's border with 3px
|
||||||
const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||||
|
|
||||||
m_seExtents.topLeft = Vector2D(0, *PBORDERSIZE + 3 + 3);
|
m_seExtents.topLeft = Vector2D(0, *PBORDERSIZE + 3 + 3);
|
||||||
m_seExtents.bottomRight = Vector2D();
|
m_seExtents.bottomRight = Vector2D();
|
||||||
|
|
||||||
m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET;
|
m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET;
|
||||||
m_vLastWindowSize = pWindow->m_vRealSize.vec();
|
m_vLastWindowSize = pWindow->m_vRealSize.vec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +57,8 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CHyprGroupBarDecoration::damageEntire() {
|
void CHyprGroupBarDecoration::damageEntire() {
|
||||||
wlr_box dm = {m_vLastWindowPos.x - m_seExtents.topLeft.x, m_vLastWindowPos.y - m_seExtents.topLeft.y, m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x, m_seExtents.topLeft.y};
|
wlr_box dm = {m_vLastWindowPos.x - m_seExtents.topLeft.x, m_vLastWindowPos.y - m_seExtents.topLeft.y, m_vLastWindowSize.x + m_seExtents.topLeft.x + m_seExtents.bottomRight.x,
|
||||||
|
m_seExtents.topLeft.y};
|
||||||
g_pHyprRenderer->damageBox(&dm);
|
g_pHyprRenderer->damageBox(&dm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +76,7 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
|
||||||
|
|
||||||
const int BARW = (m_vLastWindowSize.x - PAD * (barsToDraw - 1)) / barsToDraw;
|
const int BARW = (m_vLastWindowSize.x - PAD * (barsToDraw - 1)) / barsToDraw;
|
||||||
|
|
||||||
int xoff = 0;
|
int xoff = 0;
|
||||||
|
|
||||||
for (int i = 0; i < barsToDraw; ++i) {
|
for (int i = 0; i < barsToDraw; ++i) {
|
||||||
wlr_box rect = {m_vLastWindowPos.x + xoff - pMonitor->vecPosition.x + offset.x, m_vLastWindowPos.y - m_seExtents.topLeft.y - pMonitor->vecPosition.y + offset.y, BARW, 3};
|
wlr_box rect = {m_vLastWindowPos.x + xoff - pMonitor->vecPosition.x + offset.x, m_vLastWindowPos.y - m_seExtents.topLeft.y - pMonitor->vecPosition.y + offset.y, BARW, 3};
|
||||||
|
@ -87,10 +86,10 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
|
||||||
|
|
||||||
scaleBox(&rect, pMonitor->scale);
|
scaleBox(&rect, pMonitor->scale);
|
||||||
|
|
||||||
static auto *const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->intValue;
|
static auto* const PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->intValue;
|
||||||
static auto *const PGROUPCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border")->intValue;
|
static auto* const PGROUPCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border")->intValue;
|
||||||
|
|
||||||
CColor color = m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? CColor(*PGROUPCOLACTIVE) : CColor(*PGROUPCOLINACTIVE);
|
CColor color = m_dwGroupMembers[i] == g_pCompositor->m_pLastWindow ? CColor(*PGROUPCOLACTIVE) : CColor(*PGROUPCOLINACTIVE);
|
||||||
color.a *= a;
|
color.a *= a;
|
||||||
g_pHyprOpenGL->renderRect(&rect, color);
|
g_pHyprOpenGL->renderRect(&rect, color);
|
||||||
|
|
||||||
|
|
|
@ -4,27 +4,27 @@
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
class CHyprGroupBarDecoration : public IHyprWindowDecoration {
|
class CHyprGroupBarDecoration : public IHyprWindowDecoration {
|
||||||
public:
|
public:
|
||||||
CHyprGroupBarDecoration(CWindow*);
|
CHyprGroupBarDecoration(CWindow*);
|
||||||
virtual ~CHyprGroupBarDecoration();
|
virtual ~CHyprGroupBarDecoration();
|
||||||
|
|
||||||
virtual SWindowDecorationExtents getWindowDecorationExtents();
|
virtual SWindowDecorationExtents getWindowDecorationExtents();
|
||||||
|
|
||||||
virtual void draw(CMonitor*, float a, const Vector2D& offset);
|
virtual void draw(CMonitor*, float a, const Vector2D& offset);
|
||||||
|
|
||||||
virtual eDecorationType getDecorationType();
|
virtual eDecorationType getDecorationType();
|
||||||
|
|
||||||
virtual void updateWindow(CWindow*);
|
virtual void updateWindow(CWindow*);
|
||||||
|
|
||||||
virtual void damageEntire();
|
virtual void damageEntire();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SWindowDecorationExtents m_seExtents;
|
SWindowDecorationExtents m_seExtents;
|
||||||
|
|
||||||
CWindow* m_pWindow = nullptr;
|
CWindow* m_pWindow = nullptr;
|
||||||
|
|
||||||
Vector2D m_vLastWindowPos;
|
Vector2D m_vLastWindowPos;
|
||||||
Vector2D m_vLastWindowSize;
|
Vector2D m_vLastWindowSize;
|
||||||
|
|
||||||
std::deque<CWindow*> m_dwGroupMembers;
|
std::deque<CWindow*> m_dwGroupMembers;
|
||||||
};
|
};
|
|
@ -2,6 +2,4 @@
|
||||||
|
|
||||||
#include "../../Window.hpp"
|
#include "../../Window.hpp"
|
||||||
|
|
||||||
IHyprWindowDecoration::~IHyprWindowDecoration() {
|
IHyprWindowDecoration::~IHyprWindowDecoration() {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
#include "../../defines.hpp"
|
#include "../../defines.hpp"
|
||||||
|
|
||||||
enum eDecorationType {
|
enum eDecorationType
|
||||||
|
{
|
||||||
DECORATION_NONE = -1,
|
DECORATION_NONE = -1,
|
||||||
DECORATION_GROUPBAR,
|
DECORATION_GROUPBAR,
|
||||||
DECORATION_SHADOW
|
DECORATION_SHADOW
|
||||||
|
@ -17,16 +18,16 @@ class CWindow;
|
||||||
class CMonitor;
|
class CMonitor;
|
||||||
|
|
||||||
interface IHyprWindowDecoration {
|
interface IHyprWindowDecoration {
|
||||||
public:
|
public:
|
||||||
virtual ~IHyprWindowDecoration() = 0;
|
virtual ~IHyprWindowDecoration() = 0;
|
||||||
|
|
||||||
virtual SWindowDecorationExtents getWindowDecorationExtents() = 0;
|
virtual SWindowDecorationExtents getWindowDecorationExtents() = 0;
|
||||||
|
|
||||||
virtual void draw(CMonitor*, float a, const Vector2D& offset = Vector2D()) = 0;
|
virtual void draw(CMonitor*, float a, const Vector2D& offset = Vector2D()) = 0;
|
||||||
|
|
||||||
virtual eDecorationType getDecorationType() = 0;
|
virtual eDecorationType getDecorationType() = 0;
|
||||||
|
|
||||||
virtual void updateWindow(CWindow*) = 0;
|
virtual void updateWindow(CWindow*) = 0;
|
||||||
|
|
||||||
virtual void damageEntire() = 0;
|
virtual void damageEntire() = 0;
|
||||||
};
|
};
|
Loading…
Reference in a new issue