mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-22 08:29:49 +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!");
|
||||
}
|
||||
|
||||
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_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_screencopy_manager_v1_create(m_sWLDisplay);
|
||||
|
@ -134,13 +134,13 @@ CCompositor::CCompositor() {
|
|||
m_sWLRLayerShell = wlr_layer_shell_v1_create(m_sWLDisplay, 4);
|
||||
|
||||
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_xdg_output_manager_v1_create(m_sWLDisplay, m_sWLROutputLayout);
|
||||
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_sWLREXTWorkspaceMgr = wlr_ext_workspace_manager_v1_create(m_sWLDisplay);
|
||||
|
@ -193,8 +193,8 @@ CCompositor::~CCompositor() {
|
|||
}
|
||||
|
||||
void CCompositor::setRandomSplash() {
|
||||
std::random_device dev;
|
||||
std::mt19937 engine(dev());
|
||||
std::random_device dev;
|
||||
std::mt19937 engine(dev());
|
||||
std::uniform_int_distribution<> distribution(0, SPLASHES.size() - 1);
|
||||
|
||||
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_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");
|
||||
|
||||
if (m_sWLRSession)
|
||||
|
@ -257,7 +257,7 @@ void CCompositor::cleanup() {
|
|||
|
||||
m_bIsShuttingDown = true;
|
||||
|
||||
m_pLastFocus = nullptr;
|
||||
m_pLastFocus = nullptr;
|
||||
m_pLastWindow = nullptr;
|
||||
|
||||
// accumulate all PIDs for killing, also request closing.
|
||||
|
@ -288,8 +288,8 @@ void CCompositor::cleanup() {
|
|||
|
||||
wl_display_terminate(m_sWLDisplay);
|
||||
|
||||
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.
|
||||
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.
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (!OUTPUT) {
|
||||
float bestDistance = 0.f;
|
||||
CMonitor* pBestMon = nullptr;
|
||||
float bestDistance = 0.f;
|
||||
CMonitor* pBestMon = nullptr;
|
||||
|
||||
for (auto& m : m_vMonitors) {
|
||||
float dist = vecToRectDistanceSquared(point, m->vecPosition, m->vecPosition + m->vecSize);
|
||||
|
||||
if (dist < bestDistance || !pBestMon) {
|
||||
bestDistance = dist;
|
||||
pBestMon = m.get();
|
||||
pBestMon = m.get();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -436,7 +436,7 @@ CMonitor* CCompositor::getMonitorFromVector(const Vector2D& point) {
|
|||
}
|
||||
|
||||
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) {
|
||||
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.
|
||||
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};
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -534,7 +535,7 @@ CWindow* CCompositor::vectorToWindowTiled(const Vector2D& pos) {
|
|||
void findExtensionForVector2D(wlr_surface* surface, int x, int y, void* 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))
|
||||
*DATA->found = surface;
|
||||
|
@ -547,13 +548,15 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
|||
if (PMONITOR->specialWorkspaceID) {
|
||||
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};
|
||||
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();
|
||||
}
|
||||
|
||||
for (auto& w : m_vWindows) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -566,9 +569,9 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
|||
return w->get();
|
||||
|
||||
if (!(*w)->m_bIsX11) {
|
||||
wlr_surface* resultSurf = nullptr;
|
||||
Vector2D origin = (*w)->m_vRealPosition.vec();
|
||||
SExtensionFindingData data = {origin, pos, &resultSurf};
|
||||
wlr_surface* resultSurf = nullptr;
|
||||
Vector2D origin = (*w)->m_vRealPosition.vec();
|
||||
SExtensionFindingData data = {origin, pos, &resultSurf};
|
||||
wlr_xdg_surface_for_each_popup_surface((*w)->m_uSurface.xdg, findExtensionForVector2D, &data);
|
||||
|
||||
if (resultSurf)
|
||||
|
@ -589,7 +592,7 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
|||
|
||||
if ((*w)->m_iX11Type == 2) {
|
||||
// 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.
|
||||
}
|
||||
|
||||
|
@ -597,9 +600,9 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
|||
}
|
||||
|
||||
if (!(*w)->m_bIsX11) {
|
||||
wlr_surface* resultSurf = nullptr;
|
||||
Vector2D origin =(*w)->m_vRealPosition.vec();
|
||||
SExtensionFindingData data = {origin, pos, &resultSurf};
|
||||
wlr_surface* resultSurf = nullptr;
|
||||
Vector2D origin = (*w)->m_vRealPosition.vec();
|
||||
SExtensionFindingData data = {origin, pos, &resultSurf};
|
||||
wlr_xdg_surface_for_each_popup_surface((*w)->m_uSurface.xdg, findExtensionForVector2D, &data);
|
||||
|
||||
if (resultSurf)
|
||||
|
@ -611,9 +614,9 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
|||
// for windows, we need to check their extensions too, first.
|
||||
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) {
|
||||
wlr_surface* resultSurf = nullptr;
|
||||
Vector2D origin = w->m_vRealPosition.vec();
|
||||
SExtensionFindingData data = {origin, pos, &resultSurf};
|
||||
wlr_surface* resultSurf = nullptr;
|
||||
Vector2D origin = w->m_vRealPosition.vec();
|
||||
SExtensionFindingData data = {origin, pos, &resultSurf};
|
||||
wlr_xdg_surface_for_each_popup_surface(w->m_uSurface.xdg, findExtensionForVector2D, &data);
|
||||
|
||||
if (resultSurf)
|
||||
|
@ -622,7 +625,8 @@ CWindow* CCompositor::vectorToWindowIdeal(const Vector2D& pos) {
|
|||
}
|
||||
for (auto& w : m_vWindows) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -635,7 +639,8 @@ CWindow* CCompositor::windowFromCursor() {
|
|||
if (PMONITOR->specialWorkspaceID) {
|
||||
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};
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
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};
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -678,7 +684,8 @@ CWindow* CCompositor::windowFloatingFromCursor() {
|
|||
|
||||
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};
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -694,7 +701,7 @@ wlr_surface* CCompositor::vectorWindowToSurface(const Vector2D& pos, CWindow* pW
|
|||
|
||||
const auto PSURFACE = pWindow->m_uSurface.xdg;
|
||||
|
||||
double subx, suby;
|
||||
double subx, suby;
|
||||
|
||||
// calc for oversized windows... fucking bullshit, again.
|
||||
wlr_box geom;
|
||||
|
@ -736,7 +743,7 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
|
|||
|
||||
if (!pWindow || !windowValidMapped(pWindow)) {
|
||||
const auto PLASTWINDOW = m_pLastWindow;
|
||||
m_pLastWindow = nullptr;
|
||||
m_pLastWindow = nullptr;
|
||||
|
||||
if (windowValidMapped(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));
|
||||
|
||||
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
|
||||
if (windowValidMapped(PLASTWINDOW)) {
|
||||
|
@ -821,8 +828,9 @@ void CCompositor::focusWindow(CWindow* pWindow, wlr_surface* pSurface) {
|
|||
|
||||
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)))
|
||||
return; // Don't focus when already focused on this.
|
||||
if (m_sSeat.seat->keyboard_state.focused_surface == pSurface ||
|
||||
(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
|
||||
if (m_pLastFocus && !pWindowOwner)
|
||||
|
@ -835,7 +843,6 @@ void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) {
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
const auto KEYBOARD = wlr_seat_get_keyboard(m_sSeat.seat);
|
||||
|
||||
if (!KEYBOARD)
|
||||
|
@ -846,7 +853,7 @@ void CCompositor::focusSurface(wlr_surface* pSurface, CWindow* pWindowOwner) {
|
|||
g_pInputManager->m_sIMERelay.onKeyboardFocus(pSurface);
|
||||
|
||||
wlr_seat_keyboard_focus_change_event event = {
|
||||
.seat = m_sSeat.seat,
|
||||
.seat = m_sSeat.seat,
|
||||
.old_surface = m_pLastFocus,
|
||||
.new_surface = pSurface,
|
||||
};
|
||||
|
@ -889,7 +896,8 @@ CWindow* CCompositor::getWindowForPopup(wlr_xdg_popup* popup) {
|
|||
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++) {
|
||||
if ((*it)->fadingOut || !(*it)->layerSurface || ((*it)->layerSurface && !(*it)->layerSurface->mapped) || (*it)->alpha.fl() == 0.f)
|
||||
continue;
|
||||
|
@ -1096,7 +1104,7 @@ void CCompositor::cleanupFadingOut(const int& monid) {
|
|||
|
||||
Debug::log(LOG, "Cleanup: destroyed a window");
|
||||
|
||||
glFlush(); // to free mem NOW.
|
||||
glFlush(); // to free mem NOW.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1123,7 +1131,7 @@ void CCompositor::cleanupFadingOut(const int& monid) {
|
|||
}
|
||||
|
||||
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??");
|
||||
|
||||
|
@ -1144,16 +1152,16 @@ void CCompositor::cleanupFadingOut(const int& monid) {
|
|||
for (auto& m : m_vMonitors) {
|
||||
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()) {
|
||||
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");
|
||||
|
||||
glFlush(); // to free mem NOW.
|
||||
glFlush(); // to free mem NOW.
|
||||
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; });
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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; });
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -1181,11 +1189,11 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
|||
|
||||
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);
|
||||
|
||||
auto longestIntersect = -1;
|
||||
CWindow* longestIntersectWindow = nullptr;
|
||||
auto longestIntersect = -1;
|
||||
CWindow* longestIntersectWindow = nullptr;
|
||||
|
||||
for (auto& w : m_vWindows) {
|
||||
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 POSB = Vector2D(BWINDOWIDEALBB.x, BWINDOWIDEALBB.y);
|
||||
const auto POSB = Vector2D(BWINDOWIDEALBB.x, BWINDOWIDEALBB.y);
|
||||
const auto SIZEB = Vector2D(BWINDOWIDEALBB.width, BWINDOWIDEALBB.height);
|
||||
|
||||
switch (dir) {
|
||||
|
@ -1205,7 +1213,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
|||
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));
|
||||
if (INTERSECTLEN > longestIntersect) {
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersectWindow = w.get();
|
||||
}
|
||||
}
|
||||
|
@ -1214,7 +1222,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
|||
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));
|
||||
if (INTERSECTLEN > longestIntersect) {
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersectWindow = w.get();
|
||||
}
|
||||
}
|
||||
|
@ -1224,7 +1232,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
|||
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));
|
||||
if (INTERSECTLEN > longestIntersect) {
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersectWindow = w.get();
|
||||
}
|
||||
}
|
||||
|
@ -1234,7 +1242,7 @@ CWindow* CCompositor::getWindowInDirection(CWindow* pWindow, char dir) {
|
|||
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));
|
||||
if (INTERSECTLEN > longestIntersect) {
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersectWindow = w.get();
|
||||
}
|
||||
}
|
||||
|
@ -1328,9 +1336,7 @@ CWorkspace* CCompositor::getWorkspaceByString(const std::string& str) {
|
|||
try {
|
||||
std::string name = "";
|
||||
return getWorkspaceByID(getWorkspaceIDFromString(str, name));
|
||||
} catch (std::exception& e) {
|
||||
Debug::log(ERR, "Error in getWorkspaceByString, invalid id");
|
||||
}
|
||||
} catch (std::exception& e) { Debug::log(ERR, "Error in getWorkspaceByString, invalid id"); }
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1345,7 +1351,7 @@ bool CCompositor::isPointOnAnyMonitor(const Vector2D& point) {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1375,24 +1381,24 @@ CWindow* CCompositor::getConstraintWindow(SMouse* pMouse) {
|
|||
}
|
||||
|
||||
CMonitor* CCompositor::getMonitorInDirection(const char& dir) {
|
||||
const auto POSA = m_pLastMonitor->vecPosition;
|
||||
const auto POSA = m_pLastMonitor->vecPosition;
|
||||
const auto SIZEA = m_pLastMonitor->vecSize;
|
||||
|
||||
auto longestIntersect = -1;
|
||||
CMonitor* longestIntersectMonitor = nullptr;
|
||||
auto longestIntersect = -1;
|
||||
CMonitor* longestIntersectMonitor = nullptr;
|
||||
|
||||
for (auto& m : m_vMonitors) {
|
||||
if (m.get() == m_pLastMonitor)
|
||||
continue;
|
||||
|
||||
const auto POSB = m->vecPosition;
|
||||
const auto POSB = m->vecPosition;
|
||||
const auto SIZEB = m->vecSize;
|
||||
switch (dir) {
|
||||
case 'l':
|
||||
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));
|
||||
if (INTERSECTLEN > longestIntersect) {
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersectMonitor = m.get();
|
||||
}
|
||||
}
|
||||
|
@ -1401,7 +1407,7 @@ CMonitor* CCompositor::getMonitorInDirection(const char& dir) {
|
|||
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));
|
||||
if (INTERSECTLEN > longestIntersect) {
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersectMonitor = m.get();
|
||||
}
|
||||
}
|
||||
|
@ -1411,7 +1417,7 @@ CMonitor* CCompositor::getMonitorInDirection(const char& dir) {
|
|||
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));
|
||||
if (INTERSECTLEN > longestIntersect) {
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersectMonitor = m.get();
|
||||
}
|
||||
}
|
||||
|
@ -1421,7 +1427,7 @@ CMonitor* CCompositor::getMonitorInDirection(const char& dir) {
|
|||
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));
|
||||
if (INTERSECTLEN > longestIntersect) {
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersect = INTERSECTLEN;
|
||||
longestIntersectMonitor = m.get();
|
||||
}
|
||||
}
|
||||
|
@ -1446,22 +1452,21 @@ void CCompositor::updateAllWindowsAnimatedDecorationValues() {
|
|||
|
||||
void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
|
||||
// optimization
|
||||
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 PINACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:inactive_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 PSHADOWCOL = &g_pConfigManager->getConfigValuePtr("decoration:col.shadow")->intValue;
|
||||
static auto *const PSHADOWCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("decoration:col.shadow_inactive")->intValue;
|
||||
static auto *const PDIMSTRENGTH = &g_pConfigManager->getConfigValuePtr("decoration:dim_strength")->floatValue;
|
||||
|
||||
auto setBorderColor = [&] (CGradientValueData grad) -> void {
|
||||
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 PINACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:inactive_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 PSHADOWCOL = &g_pConfigManager->getConfigValuePtr("decoration:col.shadow")->intValue;
|
||||
static auto* const PSHADOWCOLINACTIVE = &g_pConfigManager->getConfigValuePtr("decoration:col.shadow_inactive")->intValue;
|
||||
static auto* const PDIMSTRENGTH = &g_pConfigManager->getConfigValuePtr("decoration:dim_strength")->floatValue;
|
||||
|
||||
auto setBorderColor = [&](CGradientValueData grad) -> void {
|
||||
if (grad == pWindow->m_cRealBorderColor)
|
||||
return;
|
||||
|
||||
pWindow->m_cRealBorderColorPrevious = pWindow->m_cRealBorderColor;
|
||||
pWindow->m_cRealBorderColor = grad;
|
||||
pWindow->m_cRealBorderColor = grad;
|
||||
pWindow->m_fBorderAnimationProgress.setValueAndWarp(0.f);
|
||||
pWindow->m_fBorderAnimationProgress = 1.f;
|
||||
};
|
||||
|
@ -1471,10 +1476,11 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
|
|||
if (RENDERDATA.isBorderColor)
|
||||
setBorderColor(RENDERDATA.borderColor * (1.f / 255.f));
|
||||
else
|
||||
setBorderColor(pWindow == m_pLastWindow ?
|
||||
(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));
|
||||
|
||||
setBorderColor(
|
||||
pWindow == m_pLastWindow ?
|
||||
(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
|
||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
||||
|
@ -1482,9 +1488,13 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
|
|||
pWindow->m_fActiveInactiveAlpha = *PFULLSCREENALPHA;
|
||||
} else {
|
||||
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
|
||||
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
|
||||
|
@ -1534,7 +1544,7 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
|
|||
|
||||
if (w->m_bIsFullscreen) {
|
||||
w->m_vRealPosition = pMonitorB->vecPosition;
|
||||
w->m_vRealSize = pMonitorB->vecSize;
|
||||
w->m_vRealSize = pMonitorB->vecSize;
|
||||
}
|
||||
|
||||
w->updateToplevel();
|
||||
|
@ -1554,7 +1564,7 @@ void CCompositor::swapActiveWorkspaces(CMonitor* pMonitorA, CMonitor* pMonitorB)
|
|||
|
||||
if (w->m_bIsFullscreen) {
|
||||
w->m_vRealPosition = pMonitorA->vecPosition;
|
||||
w->m_vRealSize = pMonitorA->vecSize;
|
||||
w->m_vRealSize = pMonitorA->vecSize;
|
||||
}
|
||||
|
||||
w->updateToplevel();
|
||||
|
@ -1596,7 +1606,7 @@ CMonitor* CCompositor::getMonitorFromString(const std::string& name) {
|
|||
}
|
||||
|
||||
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;
|
||||
for (int i = 0; i < (int)m_vMonitors.size(); i++) {
|
||||
|
@ -1683,7 +1693,10 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
|
|||
if (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++;
|
||||
|
||||
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) {
|
||||
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);
|
||||
|
||||
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
|
||||
|
@ -1742,7 +1756,7 @@ void CCompositor::moveWorkspaceToMonitor(CWorkspace* pWorkspace, CMonitor* pMoni
|
|||
}
|
||||
|
||||
bool CCompositor::workspaceIDOutOfBounds(const int& id) {
|
||||
int lowestID = 99999;
|
||||
int lowestID = 99999;
|
||||
int highestID = -99999;
|
||||
|
||||
for (auto& w : m_vWorkspaces) {
|
||||
|
@ -1855,16 +1869,16 @@ void CCompositor::scheduleFrameForMonitor(CMonitor* pMonitor) {
|
|||
CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
|
||||
eFocusWindowMode mode = MODE_CLASS_REGEX;
|
||||
|
||||
std::regex regexCheck(regexp);
|
||||
std::string matchCheck;
|
||||
std::regex regexCheck(regexp);
|
||||
std::string matchCheck;
|
||||
if (regexp.find("title:") == 0) {
|
||||
mode = MODE_TITLE_REGEX;
|
||||
mode = MODE_TITLE_REGEX;
|
||||
regexCheck = std::regex(regexp.substr(6));
|
||||
} else if (regexp.find("address:") == 0) {
|
||||
mode = MODE_ADDRESS;
|
||||
mode = MODE_ADDRESS;
|
||||
matchCheck = regexp.substr(8);
|
||||
} else if (regexp.find("pid:") == 0) {
|
||||
mode = MODE_PID;
|
||||
mode = MODE_PID;
|
||||
matchCheck = regexp.substr(4);
|
||||
}
|
||||
|
||||
|
@ -1897,8 +1911,7 @@ CWindow* CCompositor::getWindowByRegex(const std::string& regexp) {
|
|||
continue;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return w.get();
|
||||
|
@ -1912,7 +1925,7 @@ void CCompositor::warpCursorTo(const Vector2D& pos) {
|
|||
// warpCursorTo should only be used for warps that
|
||||
// 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)
|
||||
return;
|
||||
|
@ -2015,8 +2028,8 @@ bool CCompositor::cursorOnReservedArea() {
|
|||
}
|
||||
|
||||
CWorkspace* CCompositor::createNewWorkspace(const int& id, const int& monid, const std::string& name) {
|
||||
const auto NAME = name == "" ? std::to_string(id) : name;
|
||||
auto monID = monid;
|
||||
const auto NAME = name == "" ? std::to_string(id) : name;
|
||||
auto monID = monid;
|
||||
|
||||
// check if bound
|
||||
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)
|
||||
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;
|
||||
|
||||
return PWORKSPACE;
|
||||
|
|
|
@ -25,180 +25,177 @@
|
|||
#include "hyprerror/HyprError.hpp"
|
||||
|
||||
class CCompositor {
|
||||
public:
|
||||
public:
|
||||
CCompositor();
|
||||
~CCompositor();
|
||||
|
||||
// ------------------ WLR BASICS ------------------ //
|
||||
wl_display* m_sWLDisplay;
|
||||
wl_event_loop* m_sWLEventLoop;
|
||||
wlr_backend* m_sWLRBackend;
|
||||
wlr_session* m_sWLRSession;
|
||||
wlr_renderer* m_sWLRRenderer;
|
||||
wlr_allocator* m_sWLRAllocator;
|
||||
wlr_compositor* m_sWLRCompositor;
|
||||
wlr_subcompositor* m_sWLRSubCompositor;
|
||||
wlr_data_device_manager* m_sWLRDataDevMgr;
|
||||
wlr_drm* m_sWRLDRM;
|
||||
wlr_drm_lease_v1_manager* m_sWRLDRMLeaseMgr;
|
||||
wlr_xdg_activation_v1* m_sWLRXDGActivation;
|
||||
wlr_output_layout* m_sWLROutputLayout;
|
||||
wlr_idle* m_sWLRIdle;
|
||||
wlr_layer_shell_v1* m_sWLRLayerShell;
|
||||
wlr_xdg_shell* m_sWLRXDGShell;
|
||||
wlr_cursor* m_sWLRCursor;
|
||||
wlr_xcursor_manager* m_sWLRXCursorMgr;
|
||||
wlr_virtual_keyboard_manager_v1* m_sWLRVKeyboardMgr;
|
||||
wlr_output_manager_v1* m_sWLROutputMgr;
|
||||
wlr_presentation* m_sWLRPresentation;
|
||||
wlr_scene* m_sWLRScene;
|
||||
wlr_input_inhibit_manager* m_sWLRInhibitMgr;
|
||||
wl_display* m_sWLDisplay;
|
||||
wl_event_loop* m_sWLEventLoop;
|
||||
wlr_backend* m_sWLRBackend;
|
||||
wlr_session* m_sWLRSession;
|
||||
wlr_renderer* m_sWLRRenderer;
|
||||
wlr_allocator* m_sWLRAllocator;
|
||||
wlr_compositor* m_sWLRCompositor;
|
||||
wlr_subcompositor* m_sWLRSubCompositor;
|
||||
wlr_data_device_manager* m_sWLRDataDevMgr;
|
||||
wlr_drm* m_sWRLDRM;
|
||||
wlr_drm_lease_v1_manager* m_sWRLDRMLeaseMgr;
|
||||
wlr_xdg_activation_v1* m_sWLRXDGActivation;
|
||||
wlr_output_layout* m_sWLROutputLayout;
|
||||
wlr_idle* m_sWLRIdle;
|
||||
wlr_layer_shell_v1* m_sWLRLayerShell;
|
||||
wlr_xdg_shell* m_sWLRXDGShell;
|
||||
wlr_cursor* m_sWLRCursor;
|
||||
wlr_xcursor_manager* m_sWLRXCursorMgr;
|
||||
wlr_virtual_keyboard_manager_v1* m_sWLRVKeyboardMgr;
|
||||
wlr_output_manager_v1* m_sWLROutputMgr;
|
||||
wlr_presentation* m_sWLRPresentation;
|
||||
wlr_scene* m_sWLRScene;
|
||||
wlr_input_inhibit_manager* m_sWLRInhibitMgr;
|
||||
wlr_keyboard_shortcuts_inhibit_manager_v1* m_sWLRKbShInhibitMgr;
|
||||
wlr_egl* m_sWLREGL;
|
||||
int m_iDRMFD;
|
||||
wlr_ext_workspace_manager_v1* m_sWLREXTWorkspaceMgr;
|
||||
wlr_pointer_constraints_v1* m_sWLRPointerConstraints;
|
||||
wlr_relative_pointer_manager_v1* m_sWLRRelPointerMgr;
|
||||
wlr_server_decoration_manager* m_sWLRServerDecoMgr;
|
||||
wlr_xdg_decoration_manager_v1* m_sWLRXDGDecoMgr;
|
||||
wlr_virtual_pointer_manager_v1* m_sWLRVirtPtrMgr;
|
||||
wlr_foreign_toplevel_manager_v1* m_sWLRToplevelMgr;
|
||||
wlr_tablet_manager_v2* m_sWLRTabletManager;
|
||||
wlr_xdg_foreign_registry* m_sWLRForeignRegistry;
|
||||
wlr_idle_inhibit_manager_v1* m_sWLRIdleInhibitMgr;
|
||||
wlr_pointer_gestures_v1* m_sWLRPointerGestures;
|
||||
wlr_output_power_manager_v1* m_sWLROutputPowerMgr;
|
||||
wlr_input_method_manager_v2* m_sWLRIMEMgr;
|
||||
wlr_text_input_manager_v3* m_sWLRTextInputMgr;
|
||||
wlr_xdg_activation_v1* m_sWLRActivation;
|
||||
wlr_linux_dmabuf_v1* m_sWLRLinuxDMABuf;
|
||||
wlr_backend* m_sWLRHeadlessBackend;
|
||||
wlr_egl* m_sWLREGL;
|
||||
int m_iDRMFD;
|
||||
wlr_ext_workspace_manager_v1* m_sWLREXTWorkspaceMgr;
|
||||
wlr_pointer_constraints_v1* m_sWLRPointerConstraints;
|
||||
wlr_relative_pointer_manager_v1* m_sWLRRelPointerMgr;
|
||||
wlr_server_decoration_manager* m_sWLRServerDecoMgr;
|
||||
wlr_xdg_decoration_manager_v1* m_sWLRXDGDecoMgr;
|
||||
wlr_virtual_pointer_manager_v1* m_sWLRVirtPtrMgr;
|
||||
wlr_foreign_toplevel_manager_v1* m_sWLRToplevelMgr;
|
||||
wlr_tablet_manager_v2* m_sWLRTabletManager;
|
||||
wlr_xdg_foreign_registry* m_sWLRForeignRegistry;
|
||||
wlr_idle_inhibit_manager_v1* m_sWLRIdleInhibitMgr;
|
||||
wlr_pointer_gestures_v1* m_sWLRPointerGestures;
|
||||
wlr_output_power_manager_v1* m_sWLROutputPowerMgr;
|
||||
wlr_input_method_manager_v2* m_sWLRIMEMgr;
|
||||
wlr_text_input_manager_v3* m_sWLRTextInputMgr;
|
||||
wlr_xdg_activation_v1* m_sWLRActivation;
|
||||
wlr_linux_dmabuf_v1* m_sWLRLinuxDMABuf;
|
||||
wlr_backend* m_sWLRHeadlessBackend;
|
||||
// ------------------------------------------------- //
|
||||
|
||||
std::string m_szWLDisplaySocket = "";
|
||||
std::string m_szInstanceSignature = "";
|
||||
std::string m_szCurrentSplash = "error";
|
||||
|
||||
std::string m_szWLDisplaySocket = "";
|
||||
std::string m_szInstanceSignature = "";
|
||||
std::string m_szCurrentSplash = "error";
|
||||
std::vector<std::shared_ptr<CMonitor>> m_vMonitors;
|
||||
std::vector<std::shared_ptr<CMonitor>> m_vRealMonitors; // for all monitors, even those turned off
|
||||
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;
|
||||
std::vector<std::shared_ptr<CMonitor>> m_vRealMonitors; // for all monitors, even those turned off
|
||||
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();
|
||||
void cleanup();
|
||||
|
||||
void startCompositor();
|
||||
void cleanup();
|
||||
wlr_surface* m_pLastFocus = nullptr;
|
||||
CWindow* m_pLastWindow = nullptr;
|
||||
CMonitor* m_pLastMonitor = nullptr;
|
||||
|
||||
wlr_surface* m_pLastFocus = nullptr;
|
||||
CWindow* m_pLastWindow = nullptr;
|
||||
CMonitor* m_pLastMonitor = nullptr;
|
||||
SSeat m_sSeat;
|
||||
|
||||
SSeat m_sSeat;
|
||||
|
||||
bool m_bReadyToProcess = false;
|
||||
bool m_bSessionActive = true;
|
||||
bool m_bDPMSStateON = true;
|
||||
bool m_bUnsafeState = false; // unsafe state is when there is no monitors.
|
||||
bool m_bIsShuttingDown = false;
|
||||
std::deque<uint64_t> m_dProcessPIDsOnShutdown; // stores PIDs of apps to kill later when shutting down
|
||||
bool m_bReadyToProcess = false;
|
||||
bool m_bSessionActive = true;
|
||||
bool m_bDPMSStateON = true;
|
||||
bool m_bUnsafeState = false; // unsafe state is when there is no monitors.
|
||||
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* getMonitorFromName(const std::string&);
|
||||
CMonitor* getMonitorFromCursor();
|
||||
CMonitor* getMonitorFromVector(const Vector2D&);
|
||||
void removeWindowFromVectorSafe(CWindow*);
|
||||
void focusWindow(CWindow*, wlr_surface* pSurface = nullptr);
|
||||
void focusSurface(wlr_surface*, CWindow* pWindowOwner = nullptr);
|
||||
bool windowExists(CWindow*);
|
||||
bool windowValidMapped(CWindow*);
|
||||
CWindow* vectorToWindow(const Vector2D&);
|
||||
CWindow* vectorToWindowIdeal(const Vector2D&); // used only for finding a window to focus on, basically a "findFocusableWindow"
|
||||
CWindow* vectorToWindowTiled(const Vector2D&);
|
||||
wlr_surface* vectorToLayerSurface(const Vector2D&, std::vector<std::unique_ptr<SLayerSurface>>*, Vector2D*, SLayerSurface**);
|
||||
wlr_surface* vectorWindowToSurface(const Vector2D&, CWindow*, Vector2D& sl);
|
||||
CWindow* windowFromCursor();
|
||||
CWindow* windowFloatingFromCursor();
|
||||
CMonitor* getMonitorFromOutput(wlr_output*);
|
||||
CWindow* getWindowForPopup(wlr_xdg_popup*);
|
||||
CWindow* getWindowFromSurface(wlr_surface*);
|
||||
CWindow* getWindowFromHandle(uint32_t);
|
||||
CWindow* getWindowFromZWLRHandle(wl_resource*);
|
||||
bool isWorkspaceVisible(const int&);
|
||||
CWorkspace* getWorkspaceByID(const int&);
|
||||
CWorkspace* getWorkspaceByName(const std::string&);
|
||||
CWorkspace* getWorkspaceByString(const std::string&);
|
||||
void sanityCheckWorkspaces();
|
||||
void updateWorkspaceWindowDecos(const int&);
|
||||
int getWindowsOnWorkspace(const int&);
|
||||
CWindow* getFirstWindowOnWorkspace(const int&);
|
||||
CWindow* getFullscreenWindowOnWorkspace(const int&);
|
||||
bool doesSeatAcceptInput(wlr_surface*);
|
||||
bool isWindowActive(CWindow*);
|
||||
void moveWindowToTop(CWindow*);
|
||||
void cleanupFadingOut(const int& monid);
|
||||
CWindow* getWindowInDirection(CWindow*, char);
|
||||
void deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude = nullptr);
|
||||
CWindow* getNextWindowOnWorkspace(CWindow*, bool focusableOnly = false);
|
||||
CWindow* getPrevWindowOnWorkspace(CWindow*, bool focusableOnly = false);
|
||||
int getNextAvailableNamedWorkspace();
|
||||
bool isPointOnAnyMonitor(const Vector2D&);
|
||||
CWindow* getConstraintWindow(SMouse*);
|
||||
CMonitor* getMonitorInDirection(const char&);
|
||||
void updateAllWindowsAnimatedDecorationValues();
|
||||
void updateWindowAnimatedDecorationValues(CWindow*);
|
||||
int getNextAvailableMonitorID();
|
||||
void moveWorkspaceToMonitor(CWorkspace*, CMonitor*);
|
||||
void swapActiveWorkspaces(CMonitor*, CMonitor*);
|
||||
CMonitor* getMonitorFromString(const std::string&);
|
||||
bool workspaceIDOutOfBounds(const int&);
|
||||
void setWindowFullscreen(CWindow*, bool, eFullscreenMode);
|
||||
void moveUnmanagedX11ToWindows(CWindow*);
|
||||
CWindow* getX11Parent(CWindow*);
|
||||
void scheduleFrameForMonitor(CMonitor*);
|
||||
void addToFadingOutSafe(SLayerSurface*);
|
||||
void addToFadingOutSafe(CWindow*);
|
||||
CWindow* getWindowByRegex(const std::string&);
|
||||
void warpCursorTo(const Vector2D&);
|
||||
SLayerSurface* getLayerSurfaceFromWlr(wlr_layer_surface_v1*);
|
||||
SLayerSurface* getLayerSurfaceFromSurface(wlr_surface*);
|
||||
void closeWindow(CWindow*);
|
||||
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
|
||||
void forceReportSizesToWindowsOnWorkspace(const int&);
|
||||
bool cursorOnReservedArea();
|
||||
CWorkspace* createNewWorkspace(const int&, const int&, const std::string& name = ""); // will be deleted next frame if left empty and unfocused!
|
||||
void setActiveMonitor(CMonitor*);
|
||||
bool isWorkspaceSpecial(const int&);
|
||||
int getNewSpecialID();
|
||||
CMonitor* getMonitorFromID(const int&);
|
||||
CMonitor* getMonitorFromName(const std::string&);
|
||||
CMonitor* getMonitorFromCursor();
|
||||
CMonitor* getMonitorFromVector(const Vector2D&);
|
||||
void removeWindowFromVectorSafe(CWindow*);
|
||||
void focusWindow(CWindow*, wlr_surface* pSurface = nullptr);
|
||||
void focusSurface(wlr_surface*, CWindow* pWindowOwner = nullptr);
|
||||
bool windowExists(CWindow*);
|
||||
bool windowValidMapped(CWindow*);
|
||||
CWindow* vectorToWindow(const Vector2D&);
|
||||
CWindow* vectorToWindowIdeal(const Vector2D&); // used only for finding a window to focus on, basically a "findFocusableWindow"
|
||||
CWindow* vectorToWindowTiled(const Vector2D&);
|
||||
wlr_surface* vectorToLayerSurface(const Vector2D&, std::vector<std::unique_ptr<SLayerSurface>>*, Vector2D*, SLayerSurface**);
|
||||
wlr_surface* vectorWindowToSurface(const Vector2D&, CWindow*, Vector2D& sl);
|
||||
CWindow* windowFromCursor();
|
||||
CWindow* windowFloatingFromCursor();
|
||||
CMonitor* getMonitorFromOutput(wlr_output*);
|
||||
CWindow* getWindowForPopup(wlr_xdg_popup*);
|
||||
CWindow* getWindowFromSurface(wlr_surface*);
|
||||
CWindow* getWindowFromHandle(uint32_t);
|
||||
CWindow* getWindowFromZWLRHandle(wl_resource*);
|
||||
bool isWorkspaceVisible(const int&);
|
||||
CWorkspace* getWorkspaceByID(const int&);
|
||||
CWorkspace* getWorkspaceByName(const std::string&);
|
||||
CWorkspace* getWorkspaceByString(const std::string&);
|
||||
void sanityCheckWorkspaces();
|
||||
void updateWorkspaceWindowDecos(const int&);
|
||||
int getWindowsOnWorkspace(const int&);
|
||||
CWindow* getFirstWindowOnWorkspace(const int&);
|
||||
CWindow* getFullscreenWindowOnWorkspace(const int&);
|
||||
bool doesSeatAcceptInput(wlr_surface*);
|
||||
bool isWindowActive(CWindow*);
|
||||
void moveWindowToTop(CWindow*);
|
||||
void cleanupFadingOut(const int& monid);
|
||||
CWindow* getWindowInDirection(CWindow*, char);
|
||||
void deactivateAllWLRWorkspaces(wlr_ext_workspace_handle_v1* exclude = nullptr);
|
||||
CWindow* getNextWindowOnWorkspace(CWindow*, bool focusableOnly = false);
|
||||
CWindow* getPrevWindowOnWorkspace(CWindow*, bool focusableOnly = false);
|
||||
int getNextAvailableNamedWorkspace();
|
||||
bool isPointOnAnyMonitor(const Vector2D&);
|
||||
CWindow* getConstraintWindow(SMouse*);
|
||||
CMonitor* getMonitorInDirection(const char&);
|
||||
void updateAllWindowsAnimatedDecorationValues();
|
||||
void updateWindowAnimatedDecorationValues(CWindow*);
|
||||
int getNextAvailableMonitorID();
|
||||
void moveWorkspaceToMonitor(CWorkspace*, CMonitor*);
|
||||
void swapActiveWorkspaces(CMonitor*, CMonitor*);
|
||||
CMonitor* getMonitorFromString(const std::string&);
|
||||
bool workspaceIDOutOfBounds(const int&);
|
||||
void setWindowFullscreen(CWindow*, bool, eFullscreenMode);
|
||||
void moveUnmanagedX11ToWindows(CWindow*);
|
||||
CWindow* getX11Parent(CWindow*);
|
||||
void scheduleFrameForMonitor(CMonitor*);
|
||||
void addToFadingOutSafe(SLayerSurface*);
|
||||
void addToFadingOutSafe(CWindow*);
|
||||
CWindow* getWindowByRegex(const std::string&);
|
||||
void warpCursorTo(const Vector2D&);
|
||||
SLayerSurface* getLayerSurfaceFromWlr(wlr_layer_surface_v1*);
|
||||
SLayerSurface* getLayerSurfaceFromSurface(wlr_surface*);
|
||||
void closeWindow(CWindow*);
|
||||
Vector2D parseWindowVectorArgsRelative(const std::string&, const Vector2D&);
|
||||
void forceReportSizesToWindowsOnWorkspace(const int&);
|
||||
bool cursorOnReservedArea();
|
||||
CWorkspace* createNewWorkspace(const int&, const int&, const std::string& name = ""); // will be deleted next frame if left empty and unfocused!
|
||||
void setActiveMonitor(CMonitor*);
|
||||
bool isWorkspaceSpecial(const int&);
|
||||
int getNewSpecialID();
|
||||
|
||||
std::string explicitConfigPath;
|
||||
std::string explicitConfigPath;
|
||||
|
||||
private:
|
||||
void initAllSignals();
|
||||
void setRandomSplash();
|
||||
private:
|
||||
void initAllSignals();
|
||||
void setRandomSplash();
|
||||
|
||||
uint64_t m_iHyprlandPID = 0;
|
||||
uint64_t m_iHyprlandPID = 0;
|
||||
};
|
||||
|
||||
|
||||
inline std::unique_ptr<CCompositor> g_pCompositor;
|
||||
|
||||
// For XWayland
|
||||
inline std::map<std::string, xcb_atom_t> HYPRATOMS = {
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_NORMAL"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_DOCK"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_DIALOG"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_UTILITY"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_TOOLBAR"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_SPLASH"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_MENU"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_POPUP_MENU"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_TOOLTIP"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_NOTIFICATION")};
|
||||
inline std::map<std::string, xcb_atom_t> HYPRATOMS = {HYPRATOM("_NET_WM_WINDOW_TYPE"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_NORMAL"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_DOCK"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_DIALOG"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_UTILITY"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_TOOLBAR"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_SPLASH"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_MENU"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_DROPDOWN_MENU"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_POPUP_MENU"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_TOOLTIP"),
|
||||
HYPRATOM("_NET_WM_WINDOW_TYPE_NOTIFICATION")};
|
||||
|
|
101
src/Window.cpp
101
src/Window.cpp
|
@ -16,13 +16,13 @@ CWindow::CWindow() {
|
|||
|
||||
CWindow::~CWindow() {
|
||||
if (g_pCompositor->isWindowActive(this)) {
|
||||
g_pCompositor->m_pLastFocus = nullptr;
|
||||
g_pCompositor->m_pLastFocus = nullptr;
|
||||
g_pCompositor->m_pLastWindow = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
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}};
|
||||
|
||||
|
@ -44,10 +44,8 @@ wlr_box CWindow::getFullWindowBoundingBox() {
|
|||
}
|
||||
|
||||
// Add extents to the real base BB and return
|
||||
wlr_box finalBox = {m_vRealPosition.vec().x - maxExtents.topLeft.x,
|
||||
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};
|
||||
wlr_box finalBox = {m_vRealPosition.vec().x - maxExtents.topLeft.x, 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};
|
||||
|
||||
return finalBox;
|
||||
}
|
||||
|
@ -56,11 +54,11 @@ wlr_box CWindow::getWindowIdealBoundingBoxIgnoreReserved() {
|
|||
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(m_iMonitorID);
|
||||
|
||||
auto POS = m_vPosition;
|
||||
auto SIZE = m_vSize;
|
||||
auto POS = m_vPosition;
|
||||
auto SIZE = m_vSize;
|
||||
|
||||
if (m_bIsFullscreen) {
|
||||
POS = PMONITOR->vecPosition;
|
||||
POS = PMONITOR->vecPosition;
|
||||
SIZE = PMONITOR->vecSize;
|
||||
|
||||
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);
|
||||
|
||||
// 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) {
|
||||
|
||||
const auto EV = (wlr_foreign_toplevel_handle_v1_fullscreen_event*)data;
|
||||
|
||||
g_pCompositor->setWindowFullscreen(this, EV->fullscreen, FULLSCREEN_FULL);
|
||||
|
||||
}, this, "Toplevel");
|
||||
|
||||
hyprListener_toplevelClose.initCallback(&m_phForeignToplevel->events.request_close, [&](void* owner, void* data) {
|
||||
|
||||
g_pCompositor->closeWindow(this);
|
||||
|
||||
}, this, "Toplevel");
|
||||
hyprListener_toplevelClose.initCallback(
|
||||
&m_phForeignToplevel->events.request_close,
|
||||
[&](void* owner, void* data) {
|
||||
g_pCompositor->closeWindow(this);
|
||||
},
|
||||
this, "Toplevel");
|
||||
|
||||
m_iLastToplevelMonitorID = m_iMonitorID;
|
||||
}
|
||||
|
@ -290,12 +291,8 @@ void CWindow::onMap() {
|
|||
m_cRealShadowColor.registerVar();
|
||||
m_fDimPercent.registerVar();
|
||||
|
||||
m_vRealSize.setCallbackOnEnd([&] (void* ptr) {
|
||||
g_pHyprOpenGL->onWindowResizeEnd(this);
|
||||
}, false);
|
||||
m_vRealSize.setCallbackOnBegin([&] (void* ptr) {
|
||||
g_pHyprOpenGL->onWindowResizeStart(this);
|
||||
}, false);
|
||||
m_vRealSize.setCallbackOnEnd([&](void* ptr) { g_pHyprOpenGL->onWindowResizeEnd(this); }, false);
|
||||
m_vRealSize.setCallbackOnBegin([&](void* ptr) { g_pHyprOpenGL->onWindowResizeStart(this); }, false);
|
||||
}
|
||||
|
||||
void CWindow::setHidden(bool hidden) {
|
||||
|
@ -323,9 +320,7 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
|
|||
} else if (r.szRule.find("rounding") == 0) {
|
||||
try {
|
||||
m_sAdditionalConfigData.rounding = std::stoi(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
|
||||
} catch (std::exception& e) {
|
||||
Debug::log(ERR, "Rounding rule \"%s\" failed with: %s", r.szRule.c_str(), e.what());
|
||||
}
|
||||
} catch (std::exception& e) { Debug::log(ERR, "Rounding rule \"%s\" failed with: %s", r.szRule.c_str(), e.what()); }
|
||||
} else if (r.szRule.find("opacity") == 0) {
|
||||
try {
|
||||
CVarList vars(r.szRule, 0, ' ');
|
||||
|
@ -346,44 +341,40 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch(std::exception& e) {
|
||||
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.find("animation") == 0) {
|
||||
auto STYLE = r.szRule.substr(r.szRule.find_first_of(' ') + 1);
|
||||
m_sAdditionalConfigData.animationStyle = STYLE;
|
||||
} else if (r.szRule.find("bordercolor") == 0) {
|
||||
} catch (std::exception& e) { 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.find("animation") == 0) {
|
||||
auto STYLE = r.szRule.substr(r.szRule.find_first_of(' ') + 1);
|
||||
m_sAdditionalConfigData.animationStyle = STYLE;
|
||||
} else if (r.szRule.find("bordercolor") == 0) {
|
||||
try {
|
||||
std::string colorPart = removeBeginEndSpacesTabs(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
|
||||
|
||||
if (colorPart.contains(' ')) {
|
||||
// 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));
|
||||
} else {
|
||||
m_sSpecialRenderData.activeBorderColor = configStringToInt(colorPart);
|
||||
}
|
||||
} catch(std::exception& e) {
|
||||
Debug::log(ERR, "BorderColor rule \"%s\" failed with: %s", r.szRule.c_str(), e.what());
|
||||
}
|
||||
} catch (std::exception& e) { Debug::log(ERR, "BorderColor rule \"%s\" failed with: %s", r.szRule.c_str(), e.what()); }
|
||||
}
|
||||
}
|
||||
|
||||
void CWindow::updateDynamicRules() {
|
||||
m_sSpecialRenderData.activeBorderColor = -1;
|
||||
m_sSpecialRenderData.activeBorderColor = -1;
|
||||
m_sSpecialRenderData.inactiveBorderColor = -1;
|
||||
m_sSpecialRenderData.alpha = 1.f;
|
||||
m_sSpecialRenderData.alphaInactive = -1.f;
|
||||
m_sAdditionalConfigData.forceNoBlur = false;
|
||||
m_sAdditionalConfigData.forceNoBorder = false;
|
||||
m_sAdditionalConfigData.forceNoShadow = false;
|
||||
m_sSpecialRenderData.alpha = 1.f;
|
||||
m_sSpecialRenderData.alphaInactive = -1.f;
|
||||
m_sAdditionalConfigData.forceNoBlur = false;
|
||||
m_sAdditionalConfigData.forceNoBorder = false;
|
||||
m_sAdditionalConfigData.forceNoShadow = false;
|
||||
if (!m_sAdditionalConfigData.forceOpaqueOverriden)
|
||||
m_sAdditionalConfigData.forceOpaque = false;
|
||||
m_sAdditionalConfigData.forceNoAnims = false;
|
||||
m_sAdditionalConfigData.forceNoAnims = false;
|
||||
m_sAdditionalConfigData.animationStyle = "";
|
||||
m_sAdditionalConfigData.rounding = -1;
|
||||
m_sAdditionalConfigData.rounding = -1;
|
||||
|
||||
const auto WINDOWRULES = g_pConfigManager->getMatchingRules(this);
|
||||
for (auto& r : WINDOWRULES) {
|
||||
|
|
205
src/Window.hpp
205
src/Window.hpp
|
@ -8,7 +8,8 @@
|
|||
#include <deque>
|
||||
#include "config/ConfigDataValues.hpp"
|
||||
|
||||
enum eIdleInhibitMode {
|
||||
enum eIdleInhibitMode
|
||||
{
|
||||
IDLEINHIBIT_NONE = 0,
|
||||
IDLEINHIBIT_ALWAYS,
|
||||
IDLEINHIBIT_FULLSCREEN,
|
||||
|
@ -16,49 +17,49 @@ enum eIdleInhibitMode {
|
|||
};
|
||||
|
||||
struct SWindowSpecialRenderData {
|
||||
bool alphaOverride = false;
|
||||
float alpha = 1.f;
|
||||
bool alphaInactiveOverride = false;
|
||||
float alphaInactive = -1.f; // -1 means unset
|
||||
bool alphaOverride = false;
|
||||
float alpha = 1.f;
|
||||
bool alphaInactiveOverride = false;
|
||||
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
|
||||
|
||||
// set by the layout
|
||||
bool rounding = true;
|
||||
bool border = true;
|
||||
bool decorate = true;
|
||||
bool rounding = true;
|
||||
bool border = true;
|
||||
bool decorate = true;
|
||||
};
|
||||
|
||||
struct SWindowAdditionalConfigData {
|
||||
std::string animationStyle = "";
|
||||
int rounding = -1; // -1 means no
|
||||
bool forceNoBlur = false;
|
||||
bool forceOpaque = false;
|
||||
bool forceOpaqueOverriden = false; // if true, a rule will not change the forceOpaque state. This is for the force opaque dispatcher.
|
||||
bool forceAllowsInput = false;
|
||||
bool forceNoAnims = false;
|
||||
bool forceNoBorder = false;
|
||||
bool forceNoShadow = false;
|
||||
bool windowDanceCompat = false;
|
||||
bool noMaxSize = false;
|
||||
std::string animationStyle = "";
|
||||
int rounding = -1; // -1 means no
|
||||
bool forceNoBlur = false;
|
||||
bool forceOpaque = false;
|
||||
bool forceOpaqueOverriden = false; // if true, a rule will not change the forceOpaque state. This is for the force opaque dispatcher.
|
||||
bool forceAllowsInput = false;
|
||||
bool forceNoAnims = false;
|
||||
bool forceNoBorder = false;
|
||||
bool forceNoShadow = false;
|
||||
bool windowDanceCompat = false;
|
||||
bool noMaxSize = false;
|
||||
};
|
||||
|
||||
struct SWindowRule {
|
||||
std::string szRule;
|
||||
std::string szValue;
|
||||
|
||||
bool v2 = false;
|
||||
bool v2 = false;
|
||||
std::string szTitle;
|
||||
std::string szClass;
|
||||
int bX11 = -1; // -1 means "ANY"
|
||||
int bFloating = -1;
|
||||
int bFullscreen = -1;
|
||||
int bPinned = -1;
|
||||
int bX11 = -1; // -1 means "ANY"
|
||||
int bFloating = -1;
|
||||
int bFullscreen = -1;
|
||||
int bPinned = -1;
|
||||
};
|
||||
|
||||
class CWindow {
|
||||
public:
|
||||
public:
|
||||
CWindow();
|
||||
~CWindow();
|
||||
|
||||
|
@ -79,142 +80,142 @@ public:
|
|||
DYNLISTENER(toplevelClose);
|
||||
DYNLISTENER(toplevelActivate);
|
||||
DYNLISTENER(toplevelFullscreen);
|
||||
// DYNLISTENER(newSubsurfaceWindow);
|
||||
// DYNLISTENER(newSubsurfaceWindow);
|
||||
|
||||
union {
|
||||
wlr_xdg_surface* xdg;
|
||||
wlr_xdg_surface* xdg;
|
||||
wlr_xwayland_surface* xwayland;
|
||||
} m_uSurface;
|
||||
|
||||
// this is the position and size of the "bounding box"
|
||||
Vector2D m_vPosition = Vector2D(0,0);
|
||||
Vector2D m_vSize = Vector2D(0,0);
|
||||
Vector2D m_vPosition = Vector2D(0, 0);
|
||||
Vector2D m_vSize = Vector2D(0, 0);
|
||||
|
||||
// this is the real position and size used to draw the thing
|
||||
CAnimatedVariable m_vRealPosition;
|
||||
CAnimatedVariable m_vRealSize;
|
||||
CAnimatedVariable m_vRealPosition;
|
||||
CAnimatedVariable m_vRealSize;
|
||||
|
||||
// for not spamming the protocols
|
||||
Vector2D m_vReportedPosition;
|
||||
Vector2D m_vReportedSize;
|
||||
Vector2D m_vReportedPosition;
|
||||
Vector2D m_vReportedSize;
|
||||
|
||||
// for restoring floating statuses
|
||||
Vector2D m_vLastFloatingSize;
|
||||
Vector2D m_vLastFloatingSize;
|
||||
|
||||
// this is used for pseudotiling
|
||||
bool m_bIsPseudotiled = false;
|
||||
Vector2D m_vPseudoSize = Vector2D(0,0);
|
||||
bool m_bIsPseudotiled = false;
|
||||
Vector2D m_vPseudoSize = Vector2D(0, 0);
|
||||
|
||||
uint64_t m_iTags = 0;
|
||||
bool m_bIsFloating = false;
|
||||
bool m_bDraggingTiled = false; // for dragging around tiled windows
|
||||
bool m_bIsFullscreen = false;
|
||||
uint64_t m_iMonitorID = -1;
|
||||
std::string m_szTitle = "";
|
||||
int m_iWorkspaceID = -1;
|
||||
uint64_t m_iTags = 0;
|
||||
bool m_bIsFloating = false;
|
||||
bool m_bDraggingTiled = false; // for dragging around tiled windows
|
||||
bool m_bIsFullscreen = false;
|
||||
uint64_t m_iMonitorID = -1;
|
||||
std::string m_szTitle = "";
|
||||
int m_iWorkspaceID = -1;
|
||||
|
||||
bool m_bIsMapped = false;
|
||||
bool m_bIsMapped = false;
|
||||
|
||||
bool m_bRequestsFloat = false;
|
||||
bool m_bRequestsFloat = false;
|
||||
|
||||
// This is for fullscreen apps
|
||||
bool m_bCreatedOverFullscreen = false;
|
||||
bool m_bCreatedOverFullscreen = false;
|
||||
|
||||
// XWayland stuff
|
||||
bool m_bIsX11 = false;
|
||||
bool m_bMappedX11 = false;
|
||||
CWindow* m_pX11Parent = nullptr;
|
||||
uint64_t m_iX11Type = 0;
|
||||
bool m_bIsModal = false;
|
||||
bool m_bX11DoesntWantBorders = false;
|
||||
bool m_bX11ShouldntFocus = false;
|
||||
bool m_bIsX11 = false;
|
||||
bool m_bMappedX11 = false;
|
||||
CWindow* m_pX11Parent = nullptr;
|
||||
uint64_t m_iX11Type = 0;
|
||||
bool m_bIsModal = false;
|
||||
bool m_bX11DoesntWantBorders = false;
|
||||
bool m_bX11ShouldntFocus = false;
|
||||
//
|
||||
|
||||
// For nofocus
|
||||
bool m_bNoFocus = false;
|
||||
bool m_bNoInitialFocus = false;
|
||||
bool m_bNoFocus = false;
|
||||
bool m_bNoInitialFocus = false;
|
||||
|
||||
// initial fullscreen and fullscreen disabled
|
||||
bool m_bWantsInitialFullscreen = false;
|
||||
bool m_bNoFullscreenRequest = false;
|
||||
bool m_bWantsInitialFullscreen = false;
|
||||
bool m_bNoFullscreenRequest = false;
|
||||
|
||||
SSurfaceTreeNode* m_pSurfaceTree = nullptr;
|
||||
SSurfaceTreeNode* m_pSurfaceTree = nullptr;
|
||||
|
||||
// Animated border
|
||||
CGradientValueData m_cRealBorderColor = {0};
|
||||
CGradientValueData m_cRealBorderColorPrevious = {0};
|
||||
CAnimatedVariable m_fBorderAnimationProgress;
|
||||
CGradientValueData m_cRealBorderColor = {0};
|
||||
CGradientValueData m_cRealBorderColorPrevious = {0};
|
||||
CAnimatedVariable m_fBorderAnimationProgress;
|
||||
|
||||
// Fade in-out
|
||||
CAnimatedVariable m_fAlpha;
|
||||
bool m_bFadingOut = false;
|
||||
bool m_bReadyToDelete = false;
|
||||
Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in
|
||||
Vector2D m_vOriginalClosedSize; // drawing the closing animations
|
||||
CAnimatedVariable m_fAlpha;
|
||||
bool m_bFadingOut = false;
|
||||
bool m_bReadyToDelete = false;
|
||||
Vector2D m_vOriginalClosedPos; // these will be used for calculations later on in
|
||||
Vector2D m_vOriginalClosedSize; // drawing the closing animations
|
||||
|
||||
// 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.
|
||||
CWindow* m_pLastCycledWindow = nullptr;
|
||||
CWindow* m_pLastCycledWindow = nullptr;
|
||||
|
||||
// Foreign Toplevel proto
|
||||
wlr_foreign_toplevel_handle_v1* m_phForeignToplevel = nullptr;
|
||||
wlr_foreign_toplevel_handle_v1* m_phForeignToplevel = nullptr;
|
||||
|
||||
// Window decorations
|
||||
std::deque<std::unique_ptr<IHyprWindowDecoration>> m_dWindowDecorations;
|
||||
std::vector<IHyprWindowDecoration*> m_vDecosToRemove;
|
||||
std::vector<IHyprWindowDecoration*> m_vDecosToRemove;
|
||||
|
||||
// Special render data, rules, etc
|
||||
SWindowSpecialRenderData m_sSpecialRenderData;
|
||||
SWindowAdditionalConfigData m_sAdditionalConfigData;
|
||||
SWindowSpecialRenderData m_sSpecialRenderData;
|
||||
SWindowAdditionalConfigData m_sAdditionalConfigData;
|
||||
|
||||
// for alpha
|
||||
CAnimatedVariable m_fActiveInactiveAlpha;
|
||||
CAnimatedVariable m_fActiveInactiveAlpha;
|
||||
|
||||
// animated shadow color
|
||||
CAnimatedVariable m_cRealShadowColor;
|
||||
CAnimatedVariable m_cRealShadowColor;
|
||||
|
||||
// animated tint
|
||||
CAnimatedVariable m_fDimPercent;
|
||||
CAnimatedVariable m_fDimPercent;
|
||||
|
||||
// swallowing
|
||||
CWindow* m_pSwallowed = nullptr;
|
||||
CWindow* m_pSwallowed = nullptr;
|
||||
|
||||
// for toplevel monitor events
|
||||
uint64_t m_iLastToplevelMonitorID = -1;
|
||||
uint64_t m_iLastSurfaceMonitorID = -1;
|
||||
uint64_t m_iLastToplevelMonitorID = -1;
|
||||
uint64_t m_iLastSurfaceMonitorID = -1;
|
||||
|
||||
// for idle inhibiting windows
|
||||
eIdleInhibitMode m_eIdleInhibitMode = IDLEINHIBIT_NONE;
|
||||
eIdleInhibitMode m_eIdleInhibitMode = IDLEINHIBIT_NONE;
|
||||
|
||||
// For the list lookup
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
// methods
|
||||
wlr_box getFullWindowBoundingBox();
|
||||
wlr_box getWindowIdealBoundingBoxIgnoreReserved();
|
||||
void updateWindowDecos();
|
||||
pid_t getPID();
|
||||
wlr_box getFullWindowBoundingBox();
|
||||
wlr_box getWindowIdealBoundingBoxIgnoreReserved();
|
||||
void updateWindowDecos();
|
||||
pid_t getPID();
|
||||
IHyprWindowDecoration* getDecorationByType(eDecorationType);
|
||||
void removeDecorationByType(eDecorationType);
|
||||
void createToplevelHandle();
|
||||
void destroyToplevelHandle();
|
||||
void updateToplevel();
|
||||
void updateSurfaceOutputs();
|
||||
void moveToWorkspace(int);
|
||||
CWindow* X11TransientFor();
|
||||
void onUnmap();
|
||||
void onMap();
|
||||
void setHidden(bool hidden);
|
||||
bool isHidden();
|
||||
void applyDynamicRule(const SWindowRule& r);
|
||||
void updateDynamicRules();
|
||||
void removeDecorationByType(eDecorationType);
|
||||
void createToplevelHandle();
|
||||
void destroyToplevelHandle();
|
||||
void updateToplevel();
|
||||
void updateSurfaceOutputs();
|
||||
void moveToWorkspace(int);
|
||||
CWindow* X11TransientFor();
|
||||
void onUnmap();
|
||||
void onMap();
|
||||
void setHidden(bool hidden);
|
||||
bool isHidden();
|
||||
void applyDynamicRule(const SWindowRule& r);
|
||||
void updateDynamicRules();
|
||||
|
||||
private:
|
||||
private:
|
||||
// For hidden windows and stuff
|
||||
bool m_bHidden = false;
|
||||
|
||||
bool m_bHidden = false;
|
||||
};
|
||||
|
|
|
@ -1,24 +1,26 @@
|
|||
#pragma once
|
||||
#include "../defines.hpp"
|
||||
#include <vector>
|
||||
|
||||
enum eConfigValueDataTypes {
|
||||
CVD_TYPE_INVALID = -1,
|
||||
enum eConfigValueDataTypes
|
||||
{
|
||||
CVD_TYPE_INVALID = -1,
|
||||
CVD_TYPE_GRADIENT = 0
|
||||
};
|
||||
|
||||
interface ICustomConfigValueData {
|
||||
public:
|
||||
public:
|
||||
virtual ~ICustomConfigValueData() = 0;
|
||||
|
||||
virtual eConfigValueDataTypes getDataType() = 0;
|
||||
};
|
||||
|
||||
class CGradientValueData : public ICustomConfigValueData {
|
||||
public:
|
||||
public:
|
||||
CGradientValueData(CColor col) {
|
||||
m_vColors.push_back(col);
|
||||
};
|
||||
virtual ~CGradientValueData() { };
|
||||
virtual ~CGradientValueData(){};
|
||||
|
||||
virtual eConfigValueDataTypes getDataType() {
|
||||
return CVD_TYPE_GRADIENT;
|
||||
|
@ -34,14 +36,15 @@ public:
|
|||
std::vector<CColor> m_vColors;
|
||||
|
||||
/* Float corresponding to the angle (rad) */
|
||||
float m_fAngle = 0;
|
||||
float m_fAngle = 0;
|
||||
|
||||
bool operator==(const CGradientValueData& other) {
|
||||
if (other.m_vColors.size() != m_vColors.size() || m_fAngle != other.m_fAngle)
|
||||
return false;
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <iostream>
|
||||
|
||||
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);
|
||||
|
||||
setDefaultVars();
|
||||
|
@ -20,7 +20,7 @@ CConfigManager::CConfigManager() {
|
|||
std::string CONFIGPATH;
|
||||
if (g_pCompositor->explicitConfigPath == "") {
|
||||
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 {
|
||||
CONFIGPATH = g_pCompositor->explicitConfigPath;
|
||||
}
|
||||
|
@ -32,146 +32,146 @@ CConfigManager::CConfigManager() {
|
|||
}
|
||||
|
||||
void CConfigManager::setDefaultVars() {
|
||||
configValues["general:max_fps"].intValue = 60;
|
||||
configValues["general:sensitivity"].floatValue = 1.0f;
|
||||
configValues["general:max_fps"].intValue = 60;
|
||||
configValues["general:sensitivity"].floatValue = 1.0f;
|
||||
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_internal"].intValue = g_pKeybindManager->stringToModMask("SUPER"); // actually used and automatically calculated
|
||||
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:border_size"].intValue = 1;
|
||||
configValues["general:border_size"].intValue = 1;
|
||||
configValues["general:no_border_on_floating"].intValue = 0;
|
||||
configValues["general:gaps_in"].intValue = 5;
|
||||
configValues["general:gaps_out"].intValue = 20;
|
||||
configValues["general:gaps_in"].intValue = 5;
|
||||
configValues["general:gaps_out"].intValue = 20;
|
||||
((CGradientValueData*)configValues["general:col.active_border"].data.get())->reset(0xffffffff);
|
||||
((CGradientValueData*)configValues["general:col.inactive_border"].data.get())->reset(0xff444444);
|
||||
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["misc:disable_hyprland_logo"].intValue = 0;
|
||||
configValues["misc:disable_splash_rendering"].intValue = 0;
|
||||
configValues["misc:no_vfr"].intValue = 1;
|
||||
configValues["misc:disable_hyprland_logo"].intValue = 0;
|
||||
configValues["misc:disable_splash_rendering"].intValue = 0;
|
||||
configValues["misc:no_vfr"].intValue = 1;
|
||||
configValues["misc:damage_entire_on_snapshot"].intValue = 0;
|
||||
configValues["misc:mouse_move_enables_dpms"].intValue = 0;
|
||||
configValues["misc:always_follow_on_dnd"].intValue = 1;
|
||||
configValues["misc:mouse_move_enables_dpms"].intValue = 0;
|
||||
configValues["misc:always_follow_on_dnd"].intValue = 1;
|
||||
configValues["misc:layers_hog_keyboard_focus"].intValue = 1;
|
||||
configValues["misc:animate_manual_resizes"].intValue = 0;
|
||||
configValues["misc:disable_autoreload"].intValue = 0;
|
||||
configValues["misc:enable_swallow"].intValue = 0;
|
||||
configValues["misc:swallow_regex"].strValue = STRVAL_EMPTY;
|
||||
configValues["misc:focus_on_activate"].intValue = 0;
|
||||
configValues["misc:no_direct_scanout"].intValue = 0;
|
||||
configValues["misc:animate_manual_resizes"].intValue = 0;
|
||||
configValues["misc:disable_autoreload"].intValue = 0;
|
||||
configValues["misc:enable_swallow"].intValue = 0;
|
||||
configValues["misc:swallow_regex"].strValue = STRVAL_EMPTY;
|
||||
configValues["misc:focus_on_activate"].intValue = 0;
|
||||
configValues["misc:no_direct_scanout"].intValue = 0;
|
||||
|
||||
configValues["debug:int"].intValue = 0;
|
||||
configValues["debug:log_damage"].intValue = 0;
|
||||
configValues["debug:overlay"].intValue = 0;
|
||||
configValues["debug:damage_blink"].intValue = 0;
|
||||
configValues["debug:disable_logs"].intValue = 0;
|
||||
configValues["debug:disable_time"].intValue = 1;
|
||||
configValues["debug:int"].intValue = 0;
|
||||
configValues["debug:log_damage"].intValue = 0;
|
||||
configValues["debug:overlay"].intValue = 0;
|
||||
configValues["debug:damage_blink"].intValue = 0;
|
||||
configValues["debug:disable_logs"].intValue = 0;
|
||||
configValues["debug:disable_time"].intValue = 1;
|
||||
configValues["debug:damage_tracking"].intValue = DAMAGE_TRACKING_FULL;
|
||||
|
||||
configValues["decoration:rounding"].intValue = 0;
|
||||
configValues["decoration:blur"].intValue = 1;
|
||||
configValues["decoration:blur_size"].intValue = 8;
|
||||
configValues["decoration:blur_passes"].intValue = 1;
|
||||
configValues["decoration:blur_ignore_opacity"].intValue = 0;
|
||||
configValues["decoration:rounding"].intValue = 0;
|
||||
configValues["decoration:blur"].intValue = 1;
|
||||
configValues["decoration:blur_size"].intValue = 8;
|
||||
configValues["decoration:blur_passes"].intValue = 1;
|
||||
configValues["decoration:blur_ignore_opacity"].intValue = 0;
|
||||
configValues["decoration:blur_new_optimizations"].intValue = 1;
|
||||
configValues["decoration:blur_xray"].intValue = 0;
|
||||
configValues["decoration:active_opacity"].floatValue = 1;
|
||||
configValues["decoration:inactive_opacity"].floatValue = 1;
|
||||
configValues["decoration:fullscreen_opacity"].floatValue = 1;
|
||||
configValues["decoration:multisample_edges"].intValue = 1;
|
||||
configValues["decoration:no_blur_on_oversized"].intValue = 0;
|
||||
configValues["decoration:drop_shadow"].intValue = 1;
|
||||
configValues["decoration:shadow_range"].intValue = 4;
|
||||
configValues["decoration:shadow_render_power"].intValue = 3;
|
||||
configValues["decoration:shadow_ignore_window"].intValue = 1;
|
||||
configValues["decoration:shadow_offset"].vecValue = Vector2D();
|
||||
configValues["decoration:shadow_scale"].floatValue = 1.f;
|
||||
configValues["decoration:col.shadow"].intValue = 0xee1a1a1a;
|
||||
configValues["decoration:col.shadow_inactive"].intValue = INT_MAX;
|
||||
configValues["decoration:dim_inactive"].intValue = 0;
|
||||
configValues["decoration:dim_strength"].floatValue = 0.5f;
|
||||
configValues["decoration:screen_shader"].strValue = STRVAL_EMPTY;
|
||||
configValues["decoration:blur_xray"].intValue = 0;
|
||||
configValues["decoration:active_opacity"].floatValue = 1;
|
||||
configValues["decoration:inactive_opacity"].floatValue = 1;
|
||||
configValues["decoration:fullscreen_opacity"].floatValue = 1;
|
||||
configValues["decoration:multisample_edges"].intValue = 1;
|
||||
configValues["decoration:no_blur_on_oversized"].intValue = 0;
|
||||
configValues["decoration:drop_shadow"].intValue = 1;
|
||||
configValues["decoration:shadow_range"].intValue = 4;
|
||||
configValues["decoration:shadow_render_power"].intValue = 3;
|
||||
configValues["decoration:shadow_ignore_window"].intValue = 1;
|
||||
configValues["decoration:shadow_offset"].vecValue = Vector2D();
|
||||
configValues["decoration:shadow_scale"].floatValue = 1.f;
|
||||
configValues["decoration:col.shadow"].intValue = 0xee1a1a1a;
|
||||
configValues["decoration:col.shadow_inactive"].intValue = INT_MAX;
|
||||
configValues["decoration:dim_inactive"].intValue = 0;
|
||||
configValues["decoration:dim_strength"].floatValue = 0.5f;
|
||||
configValues["decoration:screen_shader"].strValue = STRVAL_EMPTY;
|
||||
|
||||
configValues["dwindle:pseudotile"].intValue = 0;
|
||||
configValues["dwindle:col.group_border"].intValue = 0x66777700;
|
||||
configValues["dwindle:col.group_border_active"].intValue = 0x66ffff00;
|
||||
configValues["dwindle:force_split"].intValue = 0;
|
||||
configValues["dwindle:preserve_split"].intValue = 0;
|
||||
configValues["dwindle:special_scale_factor"].floatValue = 0.8f;
|
||||
configValues["dwindle:pseudotile"].intValue = 0;
|
||||
configValues["dwindle:col.group_border"].intValue = 0x66777700;
|
||||
configValues["dwindle:col.group_border_active"].intValue = 0x66ffff00;
|
||||
configValues["dwindle:force_split"].intValue = 0;
|
||||
configValues["dwindle:preserve_split"].intValue = 0;
|
||||
configValues["dwindle:special_scale_factor"].floatValue = 0.8f;
|
||||
configValues["dwindle:split_width_multiplier"].floatValue = 1.0f;
|
||||
configValues["dwindle:no_gaps_when_only"].intValue = 0;
|
||||
configValues["dwindle:use_active_for_splits"].intValue = 1;
|
||||
configValues["dwindle:no_gaps_when_only"].intValue = 0;
|
||||
configValues["dwindle:use_active_for_splits"].intValue = 1;
|
||||
|
||||
configValues["master:special_scale_factor"].floatValue = 0.8f;
|
||||
configValues["master:new_is_master"].intValue = 1;
|
||||
configValues["master:new_on_top"].intValue = 0;
|
||||
configValues["master:no_gaps_when_only"].intValue = 0;
|
||||
configValues["master:orientation"].strValue = "left";
|
||||
configValues["master:inherit_fullscreen"].intValue = 1;
|
||||
configValues["master:new_is_master"].intValue = 1;
|
||||
configValues["master:new_on_top"].intValue = 0;
|
||||
configValues["master:no_gaps_when_only"].intValue = 0;
|
||||
configValues["master:orientation"].strValue = "left";
|
||||
configValues["master:inherit_fullscreen"].intValue = 1;
|
||||
|
||||
configValues["animations:enabled"].intValue = 1;
|
||||
configValues["animations:speed"].floatValue = 7.f;
|
||||
configValues["animations:curve"].strValue = "default";
|
||||
configValues["animations:windows_style"].strValue = STRVAL_EMPTY;
|
||||
configValues["animations:windows_curve"].strValue = "[[f]]";
|
||||
configValues["animations:windows_speed"].floatValue = 0.f;
|
||||
configValues["animations:windows"].intValue = 1;
|
||||
configValues["animations:borders_style"].strValue = STRVAL_EMPTY;
|
||||
configValues["animations:borders_curve"].strValue = "[[f]]";
|
||||
configValues["animations:borders_speed"].floatValue = 0.f;
|
||||
configValues["animations:borders"].intValue = 1;
|
||||
configValues["animations:fadein_style"].strValue = STRVAL_EMPTY;
|
||||
configValues["animations:fadein_curve"].strValue = "[[f]]";
|
||||
configValues["animations:fadein_speed"].floatValue = 0.f;
|
||||
configValues["animations:fadein"].intValue = 1;
|
||||
configValues["animations:workspaces_style"].strValue = STRVAL_EMPTY;
|
||||
configValues["animations:workspaces_curve"].strValue = "[[f]]";
|
||||
configValues["animations:enabled"].intValue = 1;
|
||||
configValues["animations:speed"].floatValue = 7.f;
|
||||
configValues["animations:curve"].strValue = "default";
|
||||
configValues["animations:windows_style"].strValue = STRVAL_EMPTY;
|
||||
configValues["animations:windows_curve"].strValue = "[[f]]";
|
||||
configValues["animations:windows_speed"].floatValue = 0.f;
|
||||
configValues["animations:windows"].intValue = 1;
|
||||
configValues["animations:borders_style"].strValue = STRVAL_EMPTY;
|
||||
configValues["animations:borders_curve"].strValue = "[[f]]";
|
||||
configValues["animations:borders_speed"].floatValue = 0.f;
|
||||
configValues["animations:borders"].intValue = 1;
|
||||
configValues["animations:fadein_style"].strValue = STRVAL_EMPTY;
|
||||
configValues["animations:fadein_curve"].strValue = "[[f]]";
|
||||
configValues["animations:fadein_speed"].floatValue = 0.f;
|
||||
configValues["animations:fadein"].intValue = 1;
|
||||
configValues["animations:workspaces_style"].strValue = STRVAL_EMPTY;
|
||||
configValues["animations:workspaces_curve"].strValue = "[[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:accel_profile"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:kb_file"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:kb_layout"].strValue = "us";
|
||||
configValues["input:kb_variant"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:kb_options"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:kb_rules"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:kb_model"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:repeat_rate"].intValue = 25;
|
||||
configValues["input:repeat_delay"].intValue = 600;
|
||||
configValues["input:natural_scroll"].intValue = 0;
|
||||
configValues["input:numlock_by_default"].intValue = 0;
|
||||
configValues["input:force_no_accel"].intValue = 0;
|
||||
configValues["input:float_switch_override_focus"].intValue = 1;
|
||||
configValues["input:left_handed"].intValue = 0;
|
||||
configValues["input:scroll_method"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:scroll_button"].intValue = 0;
|
||||
configValues["input:touchpad:natural_scroll"].intValue = 0;
|
||||
configValues["input:touchpad:disable_while_typing"].intValue = 1;
|
||||
configValues["input:touchpad:clickfinger_behavior"].intValue = 0;
|
||||
configValues["input:sensitivity"].floatValue = 0.f;
|
||||
configValues["input:accel_profile"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:kb_file"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:kb_layout"].strValue = "us";
|
||||
configValues["input:kb_variant"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:kb_options"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:kb_rules"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:kb_model"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:repeat_rate"].intValue = 25;
|
||||
configValues["input:repeat_delay"].intValue = 600;
|
||||
configValues["input:natural_scroll"].intValue = 0;
|
||||
configValues["input:numlock_by_default"].intValue = 0;
|
||||
configValues["input:force_no_accel"].intValue = 0;
|
||||
configValues["input:float_switch_override_focus"].intValue = 1;
|
||||
configValues["input:left_handed"].intValue = 0;
|
||||
configValues["input:scroll_method"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:scroll_button"].intValue = 0;
|
||||
configValues["input:touchpad:natural_scroll"].intValue = 0;
|
||||
configValues["input:touchpad:disable_while_typing"].intValue = 1;
|
||||
configValues["input:touchpad:clickfinger_behavior"].intValue = 0;
|
||||
configValues["input:touchpad:middle_button_emulation"].intValue = 0;
|
||||
configValues["input:touchpad:tap-to-click"].intValue = 1;
|
||||
configValues["input:touchpad:drag_lock"].intValue = 0;
|
||||
configValues["input:touchpad:scroll_factor"].floatValue = 1.f;
|
||||
configValues["input:touchdevice:transform"].intValue = 0;
|
||||
configValues["input:touchdevice:output"].strValue = STRVAL_EMPTY;
|
||||
configValues["input:touchpad:tap-to-click"].intValue = 1;
|
||||
configValues["input:touchpad:drag_lock"].intValue = 0;
|
||||
configValues["input:touchpad:scroll_factor"].floatValue = 1.f;
|
||||
configValues["input:touchdevice:transform"].intValue = 0;
|
||||
configValues["input:touchdevice:output"].strValue = STRVAL_EMPTY;
|
||||
|
||||
configValues["binds:pass_mouse_when_bound"].intValue = 0;
|
||||
configValues["binds:scroll_event_delay"].intValue = 300;
|
||||
configValues["binds:pass_mouse_when_bound"].intValue = 0;
|
||||
configValues["binds:scroll_event_delay"].intValue = 300;
|
||||
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_fingers"].intValue = 3;
|
||||
configValues["gestures:workspace_swipe_distance"].intValue = 300;
|
||||
configValues["gestures:workspace_swipe_invert"].intValue = 1;
|
||||
configValues["gestures:workspace_swipe"].intValue = 0;
|
||||
configValues["gestures:workspace_swipe_fingers"].intValue = 3;
|
||||
configValues["gestures:workspace_swipe_distance"].intValue = 300;
|
||||
configValues["gestures:workspace_swipe_invert"].intValue = 1;
|
||||
configValues["gestures:workspace_swipe_min_speed_to_force"].intValue = 30;
|
||||
configValues["gestures:workspace_swipe_cancel_ratio"].floatValue = 0.5f;
|
||||
configValues["gestures:workspace_swipe_create_new"].intValue = 1;
|
||||
configValues["gestures:workspace_swipe_forever"].intValue = 0;
|
||||
configValues["gestures:workspace_swipe_cancel_ratio"].floatValue = 0.5f;
|
||||
configValues["gestures:workspace_swipe_create_new"].intValue = 1;
|
||||
configValues["gestures:workspace_swipe_forever"].intValue = 0;
|
||||
|
||||
configValues["input:follow_mouse"].intValue = 1;
|
||||
|
||||
|
@ -181,29 +181,29 @@ void CConfigManager::setDefaultVars() {
|
|||
void CConfigManager::setDeviceDefaultVars(const std::string& dev) {
|
||||
auto& cfgValues = deviceConfigs[dev];
|
||||
|
||||
cfgValues["sensitivity"].floatValue = 0.f;
|
||||
cfgValues["accel_profile"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["kb_file"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["kb_layout"].strValue = "us";
|
||||
cfgValues["kb_variant"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["kb_options"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["kb_rules"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["kb_model"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["repeat_rate"].intValue = 25;
|
||||
cfgValues["repeat_delay"].intValue = 600;
|
||||
cfgValues["natural_scroll"].intValue = 0;
|
||||
cfgValues["numlock_by_default"].intValue = 0;
|
||||
cfgValues["disable_while_typing"].intValue = 1;
|
||||
cfgValues["clickfinger_behavior"].intValue = 0;
|
||||
cfgValues["sensitivity"].floatValue = 0.f;
|
||||
cfgValues["accel_profile"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["kb_file"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["kb_layout"].strValue = "us";
|
||||
cfgValues["kb_variant"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["kb_options"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["kb_rules"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["kb_model"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["repeat_rate"].intValue = 25;
|
||||
cfgValues["repeat_delay"].intValue = 600;
|
||||
cfgValues["natural_scroll"].intValue = 0;
|
||||
cfgValues["numlock_by_default"].intValue = 0;
|
||||
cfgValues["disable_while_typing"].intValue = 1;
|
||||
cfgValues["clickfinger_behavior"].intValue = 0;
|
||||
cfgValues["middle_button_emulation"].intValue = 0;
|
||||
cfgValues["tap-to-click"].intValue = 1;
|
||||
cfgValues["drag_lock"].intValue = 0;
|
||||
cfgValues["left_handed"].intValue = 0;
|
||||
cfgValues["scroll_method"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["scroll_button"].intValue = 0;
|
||||
cfgValues["touch_transform"].intValue = 0;
|
||||
cfgValues["touch_output"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["enabled"].intValue = 1; // only for mice / touchpads
|
||||
cfgValues["tap-to-click"].intValue = 1;
|
||||
cfgValues["drag_lock"].intValue = 0;
|
||||
cfgValues["left_handed"].intValue = 0;
|
||||
cfgValues["scroll_method"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["scroll_button"].intValue = 0;
|
||||
cfgValues["touch_transform"].intValue = 0;
|
||||
cfgValues["touch_output"].strValue = STRVAL_EMPTY;
|
||||
cfgValues["enabled"].intValue = 1; // only for mice / touchpads
|
||||
}
|
||||
|
||||
void CConfigManager::setDefaultAnimationVars() {
|
||||
|
@ -233,15 +233,7 @@ void CConfigManager::setDefaultAnimationVars() {
|
|||
}
|
||||
|
||||
// init the values
|
||||
animationConfig["global"] = {
|
||||
false,
|
||||
"default",
|
||||
"",
|
||||
8.f,
|
||||
1,
|
||||
&animationConfig["general"],
|
||||
nullptr
|
||||
};
|
||||
animationConfig["global"] = {false, "default", "", 8.f, 1, &animationConfig["general"], nullptr};
|
||||
|
||||
CREATEANIMCFG("windows", "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");
|
||||
|
||||
struct stat fileStat;
|
||||
int err = stat(CONFIGPATH.c_str(), &fileStat);
|
||||
int err = stat(CONFIGPATH.c_str(), &fileStat);
|
||||
if (err != 0) {
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
if (!deviceConfigExists(DEVICE))
|
||||
|
@ -360,7 +352,7 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s
|
|||
|
||||
switch (CONFIGENTRY->data->getDataType()) {
|
||||
case CVD_TYPE_GRADIENT: {
|
||||
|
||||
|
||||
CVarList varlist(VALUE, 0, ' ');
|
||||
|
||||
CGradientValueData* data = (CGradientValueData*)CONFIGENTRY->data.get();
|
||||
|
@ -414,7 +406,7 @@ void CConfigManager::configSetValueSafe(const std::string& COMMAND, const std::s
|
|||
configPaths.push_back(PATH);
|
||||
|
||||
struct stat fileStat;
|
||||
int err = stat(PATH.c_str(), &fileStat);
|
||||
int err = stat(PATH.c_str(), &fileStat);
|
||||
if (err != 0) {
|
||||
Debug::log(WARN, "Error at ticking config at %s, error %i: %s", PATH.c_str(), err, strerror(err));
|
||||
return;
|
||||
|
@ -470,8 +462,7 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
|
|||
return;
|
||||
}
|
||||
|
||||
if (std::find_if(m_dMonitorRules.begin(), m_dMonitorRules.end(), [&](const auto& other) { return other.name == newrule.name; }) != m_dMonitorRules.end())
|
||||
m_dMonitorRules.erase(std::remove_if(m_dMonitorRules.begin(), m_dMonitorRules.end(), [&](const auto& other) { return other.name == newrule.name; }));
|
||||
std::erase_if(m_dMonitorRules, [&](const auto& other) { return other.name == newrule.name; });
|
||||
|
||||
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) {
|
||||
newrule.resolution = Vector2D();
|
||||
} else if (ARGS[1].find("highrr") == 0) {
|
||||
newrule.resolution = Vector2D(-1,-1);
|
||||
newrule.resolution = Vector2D(-1, -1);
|
||||
} else if (ARGS[1].find("highres") == 0) {
|
||||
newrule.resolution = Vector2D(-1,-2);
|
||||
newrule.resolution = Vector2D(-1, -2);
|
||||
} else {
|
||||
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('@')));
|
||||
|
@ -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));
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -510,7 +501,7 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
|
|||
newrule.scale = stof(ARGS[3]);
|
||||
|
||||
if (newrule.scale < 0.25f) {
|
||||
parseError = "not a valid scale.";
|
||||
parseError = "not a valid scale.";
|
||||
newrule.scale = 1;
|
||||
}
|
||||
}
|
||||
|
@ -533,8 +524,7 @@ void CConfigManager::handleMonitor(const std::string& command, const std::string
|
|||
argno++;
|
||||
}
|
||||
|
||||
if (std::find_if(m_dMonitorRules.begin(), m_dMonitorRules.end(), [&](const auto& other) { return other.name == newrule.name; }) != m_dMonitorRules.end())
|
||||
m_dMonitorRules.erase(std::remove_if(m_dMonitorRules.begin(), m_dMonitorRules.end(), [&](const auto& other) { return other.name == newrule.name; }));
|
||||
std::erase_if(m_dMonitorRules, [&](const auto& other) { return other.name == newrule.name; });
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
void CConfigManager::setAnimForChildren(SAnimationPropertyConfig *const ANIM) {
|
||||
void CConfigManager::setAnimForChildren(SAnimationPropertyConfig* const ANIM) {
|
||||
for (auto& [name, anim] : animationConfig) {
|
||||
if (anim.pParentAnimation == ANIM && !anim.overriden) {
|
||||
// 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.pValues = &PANIM->second;
|
||||
PANIM->second.pValues = &PANIM->second;
|
||||
|
||||
// on/off
|
||||
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]);
|
||||
|
||||
if (PANIM->second.internalSpeed <= 0) {
|
||||
parseError = "invalid speed";
|
||||
parseError = "invalid speed";
|
||||
PANIM->second.internalSpeed = 1.f;
|
||||
}
|
||||
} else {
|
||||
PANIM->second.internalSpeed = 10.f;
|
||||
parseError = "invalid speed";
|
||||
parseError = "invalid speed";
|
||||
}
|
||||
|
||||
// curve
|
||||
PANIM->second.internalBezier = ARGS[3];
|
||||
|
||||
if (!g_pAnimationManager->bezierExists(ARGS[3])) {
|
||||
parseError = "no such bezier";
|
||||
parseError = "no such bezier";
|
||||
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>
|
||||
|
||||
// flags
|
||||
bool locked = false;
|
||||
bool release = false;
|
||||
bool repeat = false;
|
||||
bool mouse = false;
|
||||
bool locked = false;
|
||||
bool release = false;
|
||||
bool repeat = false;
|
||||
bool mouse = false;
|
||||
const auto BINDARGS = command.substr(4);
|
||||
|
||||
for (auto& arg : BINDARGS) {
|
||||
|
@ -683,7 +673,7 @@ void CConfigManager::handleBind(const std::string& command, const std::string& v
|
|||
return;
|
||||
}
|
||||
|
||||
const auto MOD = g_pKeybindManager->stringToModMask(ARGS[0]);
|
||||
const auto MOD = g_pKeybindManager->stringToModMask(ARGS[0]);
|
||||
const auto MODSTR = ARGS[0];
|
||||
|
||||
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) {
|
||||
return !(RULE != "float"
|
||||
&& RULE != "tile"
|
||||
&& RULE.find("opacity") != 0
|
||||
&& RULE.find("move") != 0
|
||||
&& RULE.find("size") != 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);
|
||||
return !(RULE != "float" && RULE != "tile" && RULE.find("opacity") != 0 && RULE.find("move") != 0 && RULE.find("size") != 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) {
|
||||
const auto RULE = removeBeginEndSpacesTabs(value.substr(0, value.find_first_of(",")));
|
||||
const auto VALUE = removeBeginEndSpacesTabs(value.substr(value.find_first_of(",") + 1));
|
||||
const auto RULE = removeBeginEndSpacesTabs(value.substr(0, value.find_first_of(',')));
|
||||
const auto VALUE = removeBeginEndSpacesTabs(value.substr(value.find_first_of(',') + 1));
|
||||
|
||||
// check rule and value
|
||||
if (RULE == "" || VALUE == "") {
|
||||
|
@ -775,9 +743,7 @@ void CConfigManager::handleWindowRule(const std::string& command, const std::str
|
|||
}
|
||||
|
||||
if (RULE == "unset") {
|
||||
std::erase_if(m_dWindowRules, [&] (const SWindowRule& other) {
|
||||
return other.szValue == VALUE;
|
||||
});
|
||||
std::erase_if(m_dWindowRules, [&](const SWindowRule& other) { return other.szValue == VALUE; });
|
||||
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) {
|
||||
const auto RULE = value.substr(0, value.find_first_of(","));
|
||||
const auto VALUE = value.substr(value.find_first_of(",") + 1);
|
||||
const auto RULE = value.substr(0, value.find_first_of(','));
|
||||
const auto VALUE = value.substr(value.find_first_of(',') + 1);
|
||||
|
||||
if (!windowRuleValid(RULE) && RULE != "unset") {
|
||||
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
|
||||
SWindowRule rule;
|
||||
rule.v2 = true;
|
||||
rule.szRule = RULE;
|
||||
rule.v2 = true;
|
||||
rule.szRule = RULE;
|
||||
rule.szValue = VALUE;
|
||||
|
||||
const auto TITLEPOS = VALUE.find("title:");
|
||||
const auto CLASSPOS = VALUE.find("class:");
|
||||
const auto X11POS = VALUE.find("xwayland:");
|
||||
const auto FLOATPOS = VALUE.find("floating:");
|
||||
const auto TITLEPOS = VALUE.find("title:");
|
||||
const auto CLASSPOS = VALUE.find("class:");
|
||||
const auto X11POS = VALUE.find("xwayland:");
|
||||
const auto FLOATPOS = VALUE.find("floating:");
|
||||
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 &&
|
||||
X11POS == std::string::npos && FLOATPOS == std::string::npos &&
|
||||
FULLSCREENPOS == std::string::npos && PINNEDPOS == std::string::npos) {
|
||||
if (TITLEPOS == std::string::npos && CLASSPOS == std::string::npos && X11POS == std::string::npos && FLOATPOS == std::string::npos && FULLSCREENPOS == std::string::npos &&
|
||||
PINNEDPOS == std::string::npos) {
|
||||
Debug::log(ERR, "Invalid rulev2 syntax: %s", VALUE.c_str());
|
||||
parseError = "Invalid rulev2 syntax: " + VALUE;
|
||||
return;
|
||||
|
@ -827,12 +792,18 @@ void CConfigManager::handleWindowRuleV2(const std::string& command, const std::s
|
|||
result = VALUE.substr(pos);
|
||||
|
||||
size_t min = 999999;
|
||||
if (TITLEPOS > pos && TITLEPOS < min) min = TITLEPOS;
|
||||
if (CLASSPOS > pos && CLASSPOS < min) min = CLASSPOS;
|
||||
if (X11POS > pos && X11POS < min) min = X11POS;
|
||||
if (FLOATPOS > pos && FLOATPOS < min) min = FLOATPOS;
|
||||
if (FULLSCREENPOS > pos && FULLSCREENPOS < min) min = FULLSCREENPOS;
|
||||
if (PINNEDPOS > pos && PINNEDPOS < min) min = PINNEDPOS;
|
||||
if (TITLEPOS > pos && TITLEPOS < min)
|
||||
min = TITLEPOS;
|
||||
if (CLASSPOS > pos && CLASSPOS < min)
|
||||
min = CLASSPOS;
|
||||
if (X11POS > pos && X11POS < min)
|
||||
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);
|
||||
|
||||
|
@ -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) {
|
||||
if (value.find("remove,") == 0) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -952,7 +923,7 @@ void CConfigManager::handleSource(const std::string& command, const std::string&
|
|||
configPaths.push_back(value);
|
||||
|
||||
struct stat fileStat;
|
||||
int err = stat(value.c_str(), &fileStat);
|
||||
int err = stat(value.c_str(), &fileStat);
|
||||
if (err != 0) {
|
||||
Debug::log(WARN, "Error at ticking config at %s, error %i: %s", value.c_str(), err, strerror(err));
|
||||
return;
|
||||
|
@ -962,8 +933,8 @@ void CConfigManager::handleSource(const std::string& command, const std::string&
|
|||
|
||||
std::ifstream ifs;
|
||||
ifs.open(value);
|
||||
std::string line = "";
|
||||
int linenum = 1;
|
||||
std::string line = "";
|
||||
int linenum = 1;
|
||||
if (ifs.is_open()) {
|
||||
while (std::getline(ifs, 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) {
|
||||
if (dynamic) {
|
||||
parseError = "";
|
||||
parseError = "";
|
||||
currentCategory = "";
|
||||
}
|
||||
|
||||
|
@ -1019,19 +990,30 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
|
|||
if (isFirstLaunch) {
|
||||
firstExecRequests.push_back(VALUE);
|
||||
}
|
||||
}
|
||||
else if (COMMAND == "monitor") handleMonitor(COMMAND, VALUE);
|
||||
else if (COMMAND.find("bind") == 0) handleBind(COMMAND, VALUE);
|
||||
else if (COMMAND == "unbind") handleUnbind(COMMAND, VALUE);
|
||||
else if (COMMAND == "workspace") handleDefaultWorkspace(COMMAND, VALUE);
|
||||
else if (COMMAND == "windowrule") handleWindowRule(COMMAND, VALUE);
|
||||
else if (COMMAND == "windowrulev2") handleWindowRuleV2(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 if (COMMAND == "monitor")
|
||||
handleMonitor(COMMAND, VALUE);
|
||||
else if (COMMAND.find("bind") == 0)
|
||||
handleBind(COMMAND, VALUE);
|
||||
else if (COMMAND == "unbind")
|
||||
handleUnbind(COMMAND, VALUE);
|
||||
else if (COMMAND == "workspace")
|
||||
handleDefaultWorkspace(COMMAND, VALUE);
|
||||
else if (COMMAND == "windowrule")
|
||||
handleWindowRule(COMMAND, VALUE);
|
||||
else if (COMMAND == "windowrulev2")
|
||||
handleWindowRuleV2(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 {
|
||||
configSetValueSafe(currentCategory + (currentCategory == "" ? "" : ":") + COMMAND, VALUE);
|
||||
needsLayoutRecalc = 2;
|
||||
|
@ -1039,7 +1021,7 @@ std::string CConfigManager::parseKeyword(const std::string& COMMAND, const std::
|
|||
|
||||
if (dynamic) {
|
||||
std::string retval = parseError;
|
||||
parseError = "";
|
||||
parseError = "";
|
||||
|
||||
// invalidate layouts if they changed
|
||||
if (needsLayoutRecalc) {
|
||||
|
@ -1064,7 +1046,7 @@ void CConfigManager::applyUserDefinedVars(std::string& line, const size_t equals
|
|||
while (dollarPlace != std::string::npos) {
|
||||
|
||||
const auto STRAFTERDOLLAR = line.substr(dollarPlace + 1);
|
||||
for (auto&[var, value] : configDynamicVars) {
|
||||
for (auto& [var, value] : configDynamicVars) {
|
||||
if (STRAFTERDOLLAR.find(var) == 0) {
|
||||
line.replace(dollarPlace, var.length() + 1, value);
|
||||
break;
|
||||
|
@ -1110,8 +1092,7 @@ void CConfigManager::parseLine(std::string& line) {
|
|||
if (currentCategory.length() != 0) {
|
||||
currentCategory.push_back(':');
|
||||
currentCategory.append(cat);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
currentCategory = cat;
|
||||
}
|
||||
|
||||
|
@ -1141,7 +1122,7 @@ void CConfigManager::parseLine(std::string& line) {
|
|||
return;
|
||||
|
||||
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);
|
||||
|
@ -1149,8 +1130,8 @@ void CConfigManager::parseLine(std::string& line) {
|
|||
|
||||
void CConfigManager::loadConfigLoadVars() {
|
||||
Debug::log(LOG, "Reloading the config!");
|
||||
parseError = ""; // reset the error
|
||||
currentCategory = ""; // reset the category
|
||||
parseError = ""; // reset the error
|
||||
currentCategory = ""; // reset the category
|
||||
|
||||
// reset all vars before loading
|
||||
setDefaultVars();
|
||||
|
@ -1170,8 +1151,8 @@ void CConfigManager::loadConfigLoadVars() {
|
|||
|
||||
std::string CONFIGPATH;
|
||||
|
||||
static const char* const ENVHOME = getenv("HOME");
|
||||
const std::string CONFIGPARENTPATH = ENVHOME + (std::string) "/.config/hypr/";
|
||||
static const char* const ENVHOME = getenv("HOME");
|
||||
const std::string CONFIGPARENTPATH = ENVHOME + (std::string) "/.config/hypr/";
|
||||
|
||||
if (g_pCompositor->explicitConfigPath == "") {
|
||||
CONFIGPATH = CONFIGPARENTPATH + (ISDEBUG ? "hyprlandd.conf" : "hyprland.conf");
|
||||
|
@ -1185,17 +1166,17 @@ void CConfigManager::loadConfigLoadVars() {
|
|||
ifs.open(CONFIGPATH);
|
||||
|
||||
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)");
|
||||
try {
|
||||
std::filesystem::rename(CONFIGPATH, CONFIGPATH + ".backup");
|
||||
} catch(...) { /* Probably doesn't exist */}
|
||||
} catch (...) { /* Probably doesn't exist */
|
||||
}
|
||||
|
||||
try {
|
||||
if (!std::filesystem::is_directory(CONFIGPARENTPATH))
|
||||
std::filesystem::create_directories(CONFIGPARENTPATH);
|
||||
}
|
||||
catch (...) {
|
||||
} catch (...) {
|
||||
parseError = "Broken config file! (Could not create directory)";
|
||||
return;
|
||||
}
|
||||
|
@ -1216,8 +1197,8 @@ void CConfigManager::loadConfigLoadVars() {
|
|||
}
|
||||
}
|
||||
|
||||
std::string line = "";
|
||||
int linenum = 1;
|
||||
std::string line = "";
|
||||
int linenum = 1;
|
||||
if (ifs.is_open()) {
|
||||
while (std::getline(ifs, line)) {
|
||||
// Read line by line.
|
||||
|
@ -1261,7 +1242,8 @@ void CConfigManager::loadConfigLoadVars() {
|
|||
if (parseError != "")
|
||||
g_pHyprError->queueCreate(parseError + "\nHyprland may not work correctly.", CColor(255, 50, 50, 255));
|
||||
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
|
||||
g_pHyprError->destroy();
|
||||
|
||||
|
@ -1308,7 +1290,7 @@ void CConfigManager::tick() {
|
|||
|
||||
for (auto& cf : configPaths) {
|
||||
struct stat fileStat;
|
||||
int err = stat(cf.c_str(), &fileStat);
|
||||
int err = stat(cf.c_str(), &fileStat);
|
||||
if (err != 0) {
|
||||
Debug::log(WARN, "Error at ticking config at %s, error %i: %s", cf.c_str(), err, strerror(err));
|
||||
return;
|
||||
|
@ -1316,7 +1298,7 @@ void CConfigManager::tick() {
|
|||
|
||||
// check if we need to reload cfg
|
||||
if (fileStat.st_mtime != configModifyTimes[cf] || m_bForceReload) {
|
||||
parse = true;
|
||||
parse = true;
|
||||
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) {
|
||||
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) {
|
||||
const auto VAL = getConfigValueSafe(v).strValue;
|
||||
auto VAL = getConfigValueSafe(v).strValue;
|
||||
|
||||
if (VAL == STRVAL_EMPTY)
|
||||
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) {
|
||||
const auto VAL = getConfigValueSafeDevice(dev, v).strValue;
|
||||
auto VAL = getConfigValueSafeDevice(dev, v).strValue;
|
||||
|
||||
if (VAL == STRVAL_EMPTY)
|
||||
return "";
|
||||
|
@ -1399,23 +1381,25 @@ std::string CConfigManager::getDeviceString(const std::string& dev, const std::s
|
|||
return VAL;
|
||||
}
|
||||
|
||||
void CConfigManager::setInt(std::string v, int val) {
|
||||
void CConfigManager::setInt(const std::string& v, int 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;
|
||||
}
|
||||
|
||||
void CConfigManager::setString(std::string v, std::string val) {
|
||||
void CConfigManager::setString(const std::string& v, const std::string& 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;
|
||||
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
@ -1447,7 +1431,7 @@ std::vector<SWindowRule> CConfigManager::getMatchingRules(CWindow* pWindow) {
|
|||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
const uint64_t PID = pWindow->getPID();
|
||||
bool anyExecFound = false;
|
||||
const uint64_t PID = pWindow->getPID();
|
||||
bool anyExecFound = false;
|
||||
|
||||
for (auto& er : execRequestedRules) {
|
||||
if (er.iPid == PID) {
|
||||
|
@ -1585,11 +1569,11 @@ void CConfigManager::performMonitorReload() {
|
|||
m_bWantsMonitorReload = false;
|
||||
}
|
||||
|
||||
SConfigValue* CConfigManager::getConfigValuePtr(std::string val) {
|
||||
SConfigValue* CConfigManager::getConfigValuePtr(const std::string& val) {
|
||||
return &configValues[val];
|
||||
}
|
||||
|
||||
SConfigValue* CConfigManager::getConfigValuePtrSafe(std::string val) {
|
||||
SConfigValue* CConfigManager::getConfigValuePtrSafe(const std::string& val) {
|
||||
const auto IT = configValues.find(val);
|
||||
|
||||
if (IT == configValues.end())
|
||||
|
@ -1622,14 +1606,14 @@ void CConfigManager::ensureDPMS() {
|
|||
auto rule = getMonitorRuleFor(rm->szName, rm->output->description ? rm->output->description : "");
|
||||
|
||||
if (rule.disabled == rm->m_bEnabled) {
|
||||
rm->m_pThisWrap = &rm;
|
||||
rm->m_pThisWrap = &rm;
|
||||
g_pHyprRenderer->applyMonitorRule(rm.get(), &rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
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));
|
||||
}
|
||||
|
||||
CMonitor* CConfigManager::getBoundMonitorForWS(std::string wsname) {
|
||||
for (auto&[ws, mon] : boundWorkspaces) {
|
||||
CMonitor* CConfigManager::getBoundMonitorForWS(const std::string& wsname) {
|
||||
for (auto& [ws, mon] : boundWorkspaces) {
|
||||
const auto WSNAME = ws.find("name:") == 0 ? ws.substr(5) : ws;
|
||||
|
||||
if (WSNAME == wsname) {
|
||||
|
@ -1694,7 +1678,7 @@ CMonitor* CConfigManager::getBoundMonitorForWS(std::string wsname) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
std::string CConfigManager::getBoundMonitorStringForWS(std::string wsname) {
|
||||
std::string CConfigManager::getBoundMonitorStringForWS(const std::string& wsname) {
|
||||
for (auto& [ws, mon] : boundWorkspaces) {
|
||||
const auto WSNAME = ws.find("name:") == 0 ? ws.substr(5) : ws;
|
||||
|
||||
|
@ -1706,7 +1690,7 @@ std::string CConfigManager::getBoundMonitorStringForWS(std::string wsname) {
|
|||
return "";
|
||||
}
|
||||
|
||||
void CConfigManager::addExecRule(SExecRequestedRule rule) {
|
||||
void CConfigManager::addExecRule(const SExecRequestedRule& rule) {
|
||||
execRequestedRules.push_back(rule);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,71 +17,71 @@
|
|||
|
||||
#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]}
|
||||
|
||||
struct SConfigValue {
|
||||
int64_t intValue = -INT64_MAX;
|
||||
float floatValue = -__FLT_MAX__;
|
||||
std::string strValue = "";
|
||||
Vector2D vecValue = Vector2D(-__FLT_MAX__, -__FLT_MAX__);
|
||||
int64_t intValue = -INT64_MAX;
|
||||
float floatValue = -__FLT_MAX__;
|
||||
std::string strValue = "";
|
||||
Vector2D vecValue = Vector2D(-__FLT_MAX__, -__FLT_MAX__);
|
||||
std::shared_ptr<ICustomConfigValueData> data;
|
||||
|
||||
bool set = false; // used for device configs
|
||||
bool set = false; // used for device configs
|
||||
};
|
||||
|
||||
struct SMonitorRule {
|
||||
std::string name = "";
|
||||
Vector2D resolution = Vector2D(1280,720);
|
||||
Vector2D offset = Vector2D(0,0);
|
||||
float scale = 1;
|
||||
float refreshRate = 60;
|
||||
std::string defaultWorkspace = "";
|
||||
bool disabled = false;
|
||||
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
std::string mirrorOf = "";
|
||||
bool enable10bit = false;
|
||||
std::string name = "";
|
||||
Vector2D resolution = Vector2D(1280, 720);
|
||||
Vector2D offset = Vector2D(0, 0);
|
||||
float scale = 1;
|
||||
float refreshRate = 60;
|
||||
std::string defaultWorkspace = "";
|
||||
bool disabled = false;
|
||||
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
std::string mirrorOf = "";
|
||||
bool enable10bit = false;
|
||||
};
|
||||
|
||||
struct SMonitorAdditionalReservedArea {
|
||||
int top = 0;
|
||||
int bottom = 0;
|
||||
int left = 0;
|
||||
int right = 0;
|
||||
int top = 0;
|
||||
int bottom = 0;
|
||||
int left = 0;
|
||||
int right = 0;
|
||||
};
|
||||
|
||||
struct SAnimationPropertyConfig {
|
||||
bool overriden = true;
|
||||
bool overriden = true;
|
||||
|
||||
std::string internalBezier = "";
|
||||
std::string internalStyle = "";
|
||||
float internalSpeed = 0.f;
|
||||
int internalEnabled = -1;
|
||||
std::string internalBezier = "";
|
||||
std::string internalStyle = "";
|
||||
float internalSpeed = 0.f;
|
||||
int internalEnabled = -1;
|
||||
|
||||
SAnimationPropertyConfig* pValues = nullptr;
|
||||
SAnimationPropertyConfig* pValues = nullptr;
|
||||
SAnimationPropertyConfig* pParentAnimation = nullptr;
|
||||
};
|
||||
|
||||
struct SExecRequestedRule {
|
||||
std::string szRule = "";
|
||||
uint64_t iPid = 0;
|
||||
std::string szRule = "";
|
||||
uint64_t iPid = 0;
|
||||
};
|
||||
|
||||
class CVarList {
|
||||
public:
|
||||
public:
|
||||
CVarList(const std::string& in, long unsigned int lastArgNo = 0, const char separator = ',') {
|
||||
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);
|
||||
|
||||
if (idx != std::string::npos) {
|
||||
curitem = argZ.substr(0, idx);
|
||||
argZ = argZ.substr(idx + 1);
|
||||
argZ = argZ.substr(idx + 1);
|
||||
} else {
|
||||
curitem = argZ;
|
||||
argZ = STRVAL_EMPTY;
|
||||
argZ = STRVAL_EMPTY;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -106,122 +106,130 @@ public:
|
|||
}
|
||||
|
||||
// for range-based loops
|
||||
std::vector<std::string>::iterator begin() { return m_vArgs.begin(); }
|
||||
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(); }
|
||||
std::vector<std::string>::iterator begin() {
|
||||
return m_vArgs.begin();
|
||||
}
|
||||
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:
|
||||
std::vector<std::string> m_vArgs;
|
||||
};
|
||||
|
||||
class CConfigManager {
|
||||
public:
|
||||
public:
|
||||
CConfigManager();
|
||||
|
||||
void tick();
|
||||
void init();
|
||||
void tick();
|
||||
void init();
|
||||
|
||||
int getInt(const std::string&);
|
||||
float getFloat(const std::string&);
|
||||
std::string getString(const std::string&);
|
||||
void setFloat(std::string, float);
|
||||
void setInt(std::string, int);
|
||||
void setString(std::string, std::string);
|
||||
int getInt(const std::string&);
|
||||
float getFloat(const std::string&);
|
||||
std::string getString(const std::string&);
|
||||
void setFloat(const std::string&, float);
|
||||
void setInt(const std::string&, int);
|
||||
void setString(const std::string&, const std::string&);
|
||||
|
||||
int getDeviceInt(const std::string&, const std::string&);
|
||||
float getDeviceFloat(const std::string&, const std::string&);
|
||||
std::string getDeviceString(const std::string&, const std::string&);
|
||||
bool deviceConfigExists(const std::string&);
|
||||
bool shouldBlurLS(const std::string&);
|
||||
int getDeviceInt(const std::string&, const std::string&);
|
||||
float getDeviceFloat(const std::string&, const std::string&);
|
||||
std::string getDeviceString(const std::string&, const std::string&);
|
||||
bool deviceConfigExists(const std::string&);
|
||||
bool shouldBlurLS(const std::string&);
|
||||
|
||||
SConfigValue* getConfigValuePtr(std::string);
|
||||
SConfigValue* getConfigValuePtrSafe(std::string);
|
||||
SConfigValue* getConfigValuePtr(const 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);
|
||||
std::string getBoundMonitorStringForWS(std::string);
|
||||
CMonitor* getBoundMonitorForWS(const 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;
|
||||
|
||||
// no-op when done.
|
||||
void dispatchExecOnce();
|
||||
void dispatchExecOnce();
|
||||
|
||||
void performMonitorReload();
|
||||
bool m_bWantsMonitorReload = false;
|
||||
bool m_bForceReload = false;
|
||||
bool m_bNoMonitorReload = false;
|
||||
void ensureDPMS();
|
||||
void ensureVRR(CMonitor* pMonitor = nullptr);
|
||||
void performMonitorReload();
|
||||
bool m_bWantsMonitorReload = false;
|
||||
bool m_bForceReload = false;
|
||||
bool m_bNoMonitorReload = false;
|
||||
void ensureDPMS();
|
||||
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&);
|
||||
|
||||
void addExecRule(SExecRequestedRule);
|
||||
void addExecRule(const SExecRequestedRule&);
|
||||
|
||||
std::string configCurrentPath;
|
||||
std::string configCurrentPath;
|
||||
|
||||
private:
|
||||
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, std::string> configDynamicVars; // stores dynamic vars declared by the user
|
||||
std::unordered_map<std::string, SConfigValue> configValues;
|
||||
private:
|
||||
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, std::string> configDynamicVars; // stores dynamic vars declared by the user
|
||||
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, 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<SWindowRule> m_dWindowRules;
|
||||
std::deque<std::string> m_dBlurLSNamespaces;
|
||||
std::deque<SMonitorRule> m_dMonitorRules;
|
||||
std::deque<SWindowRule> m_dWindowRules;
|
||||
std::deque<std::string> m_dBlurLSNamespaces;
|
||||
|
||||
bool firstExecDispatched = false;
|
||||
std::deque<std::string> firstExecRequests;
|
||||
bool firstExecDispatched = false;
|
||||
std::deque<std::string> firstExecRequests;
|
||||
|
||||
// internal methods
|
||||
void setDefaultVars();
|
||||
void setDefaultAnimationVars();
|
||||
void setDeviceDefaultVars(const std::string&);
|
||||
void setDefaultVars();
|
||||
void setDefaultAnimationVars();
|
||||
void setDeviceDefaultVars(const std::string&);
|
||||
|
||||
void setAnimForChildren(SAnimationPropertyConfig *const);
|
||||
void setAnimForChildren(SAnimationPropertyConfig* const);
|
||||
|
||||
void applyUserDefinedVars(std::string&, const size_t);
|
||||
void loadConfigLoadVars();
|
||||
SConfigValue getConfigValueSafe(const std::string&);
|
||||
SConfigValue getConfigValueSafeDevice(const std::string&, const std::string&);
|
||||
void parseLine(std::string&);
|
||||
void configSetValueSafe(const std::string&, const std::string&);
|
||||
void handleDeviceConfig(const std::string&, const std::string&);
|
||||
void handleRawExec(const std::string&, const std::string&);
|
||||
void handleMonitor(const std::string&, const std::string&);
|
||||
void handleBind(const std::string&, const std::string&);
|
||||
void handleUnbind(const std::string&, const std::string&);
|
||||
void handleWindowRule(const std::string&, const std::string&);
|
||||
void handleWindowRuleV2(const std::string&, const std::string&);
|
||||
void handleDefaultWorkspace(const std::string&, const std::string&);
|
||||
void handleBezier(const std::string&, const std::string&);
|
||||
void handleAnimation(const std::string&, const std::string&);
|
||||
void handleSource(const std::string&, const std::string&);
|
||||
void handleSubmap(const std::string&, const std::string&);
|
||||
void handleBlurLS(const std::string&, const std::string&);
|
||||
void handleBindWS(const std::string&, const std::string&);
|
||||
void applyUserDefinedVars(std::string&, const size_t);
|
||||
void loadConfigLoadVars();
|
||||
SConfigValue getConfigValueSafe(const std::string&);
|
||||
SConfigValue getConfigValueSafeDevice(const std::string&, const std::string&);
|
||||
void parseLine(std::string&);
|
||||
void configSetValueSafe(const std::string&, const std::string&);
|
||||
void handleDeviceConfig(const std::string&, const std::string&);
|
||||
void handleRawExec(const std::string&, const std::string&);
|
||||
void handleMonitor(const std::string&, const std::string&);
|
||||
void handleBind(const std::string&, const std::string&);
|
||||
void handleUnbind(const std::string&, const std::string&);
|
||||
void handleWindowRule(const std::string&, const std::string&);
|
||||
void handleWindowRuleV2(const std::string&, const std::string&);
|
||||
void handleDefaultWorkspace(const std::string&, const std::string&);
|
||||
void handleBezier(const std::string&, const std::string&);
|
||||
void handleAnimation(const std::string&, const std::string&);
|
||||
void handleSource(const std::string&, const std::string&);
|
||||
void handleSubmap(const std::string&, const std::string&);
|
||||
void handleBlurLS(const std::string&, const std::string&);
|
||||
void handleBindWS(const std::string&, const std::string&);
|
||||
};
|
||||
|
||||
inline std::unique_ptr<CConfigManager> g_pConfigManager;
|
||||
|
|
|
@ -20,7 +20,7 @@ std::string monitorsRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
|||
|
||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||
result += getFormat(
|
||||
R"#({
|
||||
R"#({
|
||||
"id": %i,
|
||||
"name": "%s",
|
||||
"description": "%s",
|
||||
|
@ -39,19 +39,11 @@ R"#({
|
|||
"focused": %s,
|
||||
"dpmsStatus": %s
|
||||
},)#",
|
||||
m->ID,
|
||||
escapeJSONStrings(m->szName).c_str(),
|
||||
escapeJSONStrings(m->output->description ? m->output->description : "").c_str(),
|
||||
(int)m->vecPixelSize.x, (int)m->vecPixelSize.y,
|
||||
m->refreshRate,
|
||||
(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")
|
||||
);
|
||||
m->ID, escapeJSONStrings(m->szName).c_str(), escapeJSONStrings(m->output->description ? m->output->description : "").c_str(), (int)m->vecPixelSize.x,
|
||||
(int)m->vecPixelSize.y, m->refreshRate, (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
|
||||
|
@ -60,8 +52,12 @@ R"#({
|
|||
result += "]";
|
||||
} else {
|
||||
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",
|
||||
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);
|
||||
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",
|
||||
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";
|
||||
|
||||
SLayoutMessageHeader header;
|
||||
header.pWindow = w;
|
||||
header.pWindow = w;
|
||||
const auto groupMembers = std::any_cast<std::deque<CWindow*>>(g_pLayoutManager->getCurrentLayout()->layoutMessage(header, "groupinfo"));
|
||||
if (groupMembers.empty())
|
||||
return isJson ? "" : "0";
|
||||
|
||||
const auto comma = isJson ? ", " : ",";
|
||||
const auto fmt = isJson ? "\"0x%x\"" : "%x";
|
||||
const auto comma = isJson ? ", " : ",";
|
||||
const auto fmt = isJson ? "\"0x%x\"" : "%x";
|
||||
std::ostringstream result;
|
||||
|
||||
bool first = true;
|
||||
bool first = true;
|
||||
for (auto& gw : groupMembers) {
|
||||
if (first)
|
||||
first = false;
|
||||
|
@ -99,7 +95,7 @@ static std::string getGroupedData(CWindow* w, HyprCtl::eHyprCtlOutputFormat form
|
|||
static std::string getWindowData(CWindow* w, HyprCtl::eHyprCtlOutputFormat format) {
|
||||
if (format == HyprCtl::FORMAT_JSON) {
|
||||
return getFormat(
|
||||
R"#({
|
||||
R"#({
|
||||
"address": "0x%x",
|
||||
"at": [%i, %i],
|
||||
"size": [%i, %i],
|
||||
|
@ -119,25 +115,29 @@ R"#({
|
|||
"grouped": [%s],
|
||||
"swallowing": %s
|
||||
},)#",
|
||||
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, 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(),
|
||||
((int)w->m_bIsFloating == 1 ? "true" : "false"),
|
||||
w->m_iMonitorID,
|
||||
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"),
|
||||
(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")
|
||||
);
|
||||
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,
|
||||
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(),
|
||||
((int)w->m_bIsFloating == 1 ? "true" : "false"), w->m_iMonitorID, 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"),
|
||||
(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 {
|
||||
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",
|
||||
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);
|
||||
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",
|
||||
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
|
||||
if (result != "[")
|
||||
result.pop_back();
|
||||
result.pop_back();
|
||||
|
||||
result += "]";
|
||||
} else {
|
||||
|
@ -176,7 +176,7 @@ std::string workspacesRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
|||
const auto PLASTW = w->getLastFocusedWindow();
|
||||
|
||||
result += getFormat(
|
||||
R"#({
|
||||
R"#({
|
||||
"id": %i,
|
||||
"name": "%s",
|
||||
"monitor": "%s",
|
||||
|
@ -185,14 +185,9 @@ R"#({
|
|||
"lastwindow": "0x%x",
|
||||
"lastwindowtitle": "%s"
|
||||
},)#",
|
||||
w->m_iID,
|
||||
escapeJSONStrings(w->m_szName).c_str(),
|
||||
escapeJSONStrings(g_pCompositor->getMonitorFromID(w->m_iMonitorID)->szName).c_str(),
|
||||
g_pCompositor->getWindowsOnWorkspace(w->m_iID),
|
||||
((int)w->m_bHasFullscreenWindow == 1 ? "true" : "false"),
|
||||
PLASTW,
|
||||
PLASTW ? escapeJSONStrings(PLASTW->m_szTitle).c_str() : ""
|
||||
);
|
||||
w->m_iID, escapeJSONStrings(w->m_szName).c_str(), escapeJSONStrings(g_pCompositor->getMonitorFromID(w->m_iMonitorID)->szName).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
|
||||
|
@ -202,8 +197,9 @@ R"#({
|
|||
} else {
|
||||
for (auto& w : g_pCompositor->m_vWorkspaces) {
|
||||
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",
|
||||
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() : "");
|
||||
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_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;
|
||||
|
@ -216,7 +212,7 @@ std::string activeWindowRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
|||
return format == HyprCtl::FORMAT_JSON ? "{}" : "Invalid";
|
||||
|
||||
auto result = getWindowData(PWINDOW, format);
|
||||
|
||||
|
||||
if (format == HyprCtl::FORMAT_JSON)
|
||||
result.pop_back();
|
||||
|
||||
|
@ -231,23 +227,21 @@ std::string layersRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
|||
|
||||
for (auto& mon : g_pCompositor->m_vMonitors) {
|
||||
result += getFormat(
|
||||
R"#("%s": {
|
||||
R"#("%s": {
|
||||
"levels": {
|
||||
)#",
|
||||
escapeJSONStrings(mon->szName).c_str()
|
||||
);
|
||||
escapeJSONStrings(mon->szName).c_str());
|
||||
|
||||
int layerLevel = 0;
|
||||
for (auto& level : mon->m_aLayerSurfaceLists) {
|
||||
result += getFormat(
|
||||
R"#(
|
||||
R"#(
|
||||
"%i": [
|
||||
)#",
|
||||
layerLevel
|
||||
);
|
||||
layerLevel);
|
||||
for (auto& layer : level) {
|
||||
result += getFormat(
|
||||
R"#( {
|
||||
R"#( {
|
||||
"address": "0x%x",
|
||||
"x": %i,
|
||||
"y": %i,
|
||||
|
@ -255,13 +249,7 @@ R"#( {
|
|||
"h": %i,
|
||||
"namespace": "%s"
|
||||
},)#",
|
||||
layer.get(),
|
||||
layer->geometry.x,
|
||||
layer->geometry.y,
|
||||
layer->geometry.width,
|
||||
layer->geometry.height,
|
||||
escapeJSONStrings(layer->szNamespace).c_str()
|
||||
);
|
||||
layer.get(), layer->geometry.x, layer->geometry.y, layer->geometry.width, layer->geometry.height, escapeJSONStrings(layer->szNamespace).c_str());
|
||||
}
|
||||
|
||||
// remove trailing comma
|
||||
|
@ -294,7 +282,8 @@ R"#( {
|
|||
result += getFormat("\tLayer level %i:\n", layerLevel);
|
||||
|
||||
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++;
|
||||
|
@ -315,15 +304,13 @@ std::string devicesRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
|||
|
||||
for (auto& m : g_pInputManager->m_lMice) {
|
||||
result += getFormat(
|
||||
R"#( {
|
||||
R"#( {
|
||||
"address": "0x%x",
|
||||
"name": "%s",
|
||||
"defaultSpeed": %f
|
||||
},)#",
|
||||
&m,
|
||||
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
|
||||
);
|
||||
&m, 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);
|
||||
}
|
||||
|
||||
// remove trailing comma
|
||||
|
@ -334,7 +321,7 @@ R"#( {
|
|||
for (auto& k : g_pInputManager->m_lKeyboards) {
|
||||
const auto KM = g_pInputManager->getActiveLayoutForKeyboard(&k);
|
||||
result += getFormat(
|
||||
R"#( {
|
||||
R"#( {
|
||||
"address": "0x%x",
|
||||
"name": "%s",
|
||||
"rules": "%s",
|
||||
|
@ -345,16 +332,9 @@ R"#( {
|
|||
"active_keymap": "%s",
|
||||
"main": %s
|
||||
},)#",
|
||||
&k,
|
||||
escapeJSONStrings(k.name).c_str(),
|
||||
escapeJSONStrings(k.currentRules.rules).c_str(),
|
||||
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")
|
||||
);
|
||||
&k, escapeJSONStrings(k.name).c_str(), escapeJSONStrings(k.currentRules.rules).c_str(), 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
|
||||
|
@ -365,7 +345,7 @@ R"#( {
|
|||
|
||||
for (auto& d : g_pInputManager->m_lTabletPads) {
|
||||
result += getFormat(
|
||||
R"#( {
|
||||
R"#( {
|
||||
"address": "0x%x",
|
||||
"type": "tabletPad",
|
||||
"belongsTo": {
|
||||
|
@ -373,33 +353,26 @@ R"#( {
|
|||
"name": "%s"
|
||||
}
|
||||
},)#",
|
||||
&d,
|
||||
d.pTabletParent,
|
||||
escapeJSONStrings(d.pTabletParent ? d.pTabletParent->name : "").c_str()
|
||||
);
|
||||
&d, d.pTabletParent, escapeJSONStrings(d.pTabletParent ? d.pTabletParent->name : "").c_str());
|
||||
}
|
||||
|
||||
for (auto& d : g_pInputManager->m_lTablets) {
|
||||
result += getFormat(
|
||||
R"#( {
|
||||
R"#( {
|
||||
"address": "0x%x",
|
||||
"name": "%s"
|
||||
},)#",
|
||||
&d,
|
||||
escapeJSONStrings(d.name).c_str()
|
||||
);
|
||||
&d, escapeJSONStrings(d.name).c_str());
|
||||
}
|
||||
|
||||
for (auto& d : g_pInputManager->m_lTabletTools) {
|
||||
result += getFormat(
|
||||
R"#( {
|
||||
R"#( {
|
||||
"address": "0x%x",
|
||||
"type": "tabletTool",
|
||||
"belongsTo": "0x%x"
|
||||
},)#",
|
||||
&d,
|
||||
d.wlrTabletTool ? d.wlrTabletTool->data : 0
|
||||
);
|
||||
&d, d.wlrTabletTool ? d.wlrTabletTool->data : 0);
|
||||
}
|
||||
|
||||
// remove trailing comma
|
||||
|
@ -410,13 +383,11 @@ R"#( {
|
|||
|
||||
for (auto& d : g_pInputManager->m_lTouchDevices) {
|
||||
result += getFormat(
|
||||
R"#( {
|
||||
R"#( {
|
||||
"address": "0x%x",
|
||||
"name": "%s"
|
||||
},)#",
|
||||
&d,
|
||||
d.name.c_str()
|
||||
);
|
||||
&d, d.name.c_str());
|
||||
}
|
||||
|
||||
// remove trailing comma
|
||||
|
@ -428,13 +399,11 @@ R"#( {
|
|||
|
||||
for (auto& d : g_pInputManager->m_lSwitches) {
|
||||
result += getFormat(
|
||||
R"#( {
|
||||
R"#( {
|
||||
"address": "0x%x",
|
||||
"name": "%s"
|
||||
},)#",
|
||||
&d,
|
||||
d.pWlrDevice ? d.pWlrDevice->name : ""
|
||||
);
|
||||
&d, d.pWlrDevice ? d.pWlrDevice->name : "");
|
||||
}
|
||||
|
||||
// remove trailing comma
|
||||
|
@ -448,14 +417,18 @@ R"#( {
|
|||
result += "mice:\n";
|
||||
|
||||
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";
|
||||
|
||||
for (auto& k : g_pInputManager->m_lKeyboards) {
|
||||
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";
|
||||
|
@ -491,7 +464,8 @@ R"#( {
|
|||
std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
||||
|
||||
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
|
||||
result += "legacyrenderer\n";
|
||||
|
@ -500,7 +474,7 @@ std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
|||
result += "debug\n";
|
||||
#endif
|
||||
#ifdef HYPRLAND_DEBUG
|
||||
result += "debug\n";
|
||||
result += "debug\n";
|
||||
#endif
|
||||
#ifdef NO_XWAYLAND
|
||||
result += "no xwayland\n";
|
||||
|
@ -509,12 +483,13 @@ std::string versionRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
|||
return result;
|
||||
} else {
|
||||
std::string result = getFormat(
|
||||
R"#({
|
||||
R"#({
|
||||
"branch": "%s",
|
||||
"commit": "%s",
|
||||
"dirty": %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
|
||||
result += "\"legacyrenderer\",";
|
||||
|
@ -523,7 +498,7 @@ R"#({
|
|||
result += "\"debug\",";
|
||||
#endif
|
||||
#ifdef HYPRLAND_DEBUG
|
||||
result += "\"debug\",";
|
||||
result += "\"debug\",";
|
||||
#endif
|
||||
#ifdef NO_XWAYLAND
|
||||
result += "\"no xwayland\",";
|
||||
|
@ -563,9 +538,9 @@ std::string dispatchKeyword(std::string in) {
|
|||
// get rid of the keyword keyword
|
||||
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);
|
||||
|
||||
|
@ -573,14 +548,14 @@ std::string dispatchKeyword(std::string in) {
|
|||
g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords
|
||||
|
||||
if (COMMAND.contains("input") || COMMAND.contains("device:")) {
|
||||
g_pInputManager->setKeyboardLayout(); // update kb layout
|
||||
g_pInputManager->setPointerConfigs(); // update mouse cfgs
|
||||
g_pInputManager->setKeyboardLayout(); // update kb layout
|
||||
g_pInputManager->setPointerConfigs(); // update mouse cfgs
|
||||
g_pInputManager->setTouchDeviceConfigs(); // update touch device cfgs
|
||||
}
|
||||
|
||||
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"))
|
||||
g_pHyprOpenGL->m_bReloadScreenShader = true;
|
||||
|
||||
|
@ -592,7 +567,7 @@ std::string dispatchKeyword(std::string in) {
|
|||
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);
|
||||
|
||||
|
@ -628,7 +603,8 @@ std::string cursorPosRequest(HyprCtl::eHyprCtlOutputFormat format) {
|
|||
"x": %i,
|
||||
"y": %i
|
||||
}
|
||||
)#", (int)CURSORPOS.x, (int)CURSORPOS.y);
|
||||
)#",
|
||||
(int)CURSORPOS.x, (int)CURSORPOS.y);
|
||||
}
|
||||
|
||||
return "error";
|
||||
|
@ -639,11 +615,11 @@ std::string getReply(std::string);
|
|||
std::string dispatchBatch(std::string request) {
|
||||
// split by ;
|
||||
|
||||
request = request.substr(9);
|
||||
request = request.substr(9);
|
||||
std::string curitem = "";
|
||||
std::string reply = "";
|
||||
std::string reply = "";
|
||||
|
||||
auto nextItem = [&]() {
|
||||
auto nextItem = [&]() {
|
||||
auto idx = request.find_first_of(';');
|
||||
|
||||
if (idx != std::string::npos) {
|
||||
|
@ -671,7 +647,7 @@ std::string dispatchBatch(std::string request) {
|
|||
std::string dispatchSetCursor(std::string request) {
|
||||
std::string curitem = "";
|
||||
|
||||
auto nextItem = [&]() {
|
||||
auto nextItem = [&]() {
|
||||
auto idx = request.find_first_of(' ');
|
||||
|
||||
if (idx != std::string::npos) {
|
||||
|
@ -718,20 +694,21 @@ std::string dispatchSetCursor(std::string request) {
|
|||
return "ok";
|
||||
}
|
||||
|
||||
std::string switchXKBLayoutRequest(std::string request) {
|
||||
CVarList vars(request, 0, ' ');
|
||||
std::string switchXKBLayoutRequest(const std::string& request) {
|
||||
CVarList vars(request, 0, ' ');
|
||||
|
||||
const auto KB = vars[1];
|
||||
const auto KB = vars[1];
|
||||
const auto CMD = vars[2];
|
||||
|
||||
// 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())
|
||||
return "device not found";
|
||||
|
||||
const auto PWLRKEYBOARD = wlr_keyboard_from_input_device(PKEYBOARD->keyboard);
|
||||
const auto LAYOUTS = xkb_keymap_num_layouts(PWLRKEYBOARD->keymap);
|
||||
const auto PWLRKEYBOARD = wlr_keyboard_from_input_device(PKEYBOARD->keyboard);
|
||||
const auto LAYOUTS = xkb_keymap_num_layouts(PWLRKEYBOARD->keymap);
|
||||
xkb_layout_index_t activeLayout = 0;
|
||||
while (activeLayout < LAYOUTS) {
|
||||
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") {
|
||||
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") {
|
||||
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 {
|
||||
|
||||
|
||||
int requestedLayout = 0;
|
||||
try {
|
||||
requestedLayout = std::stoi(CMD);
|
||||
} catch (std::exception& e) {
|
||||
return "invalid arg 2";
|
||||
}
|
||||
} catch (std::exception& e) { return "invalid arg 2"; }
|
||||
|
||||
if (requestedLayout < 0 || (uint64_t)requestedLayout > LAYOUTS - 1) {
|
||||
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";
|
||||
|
@ -766,7 +743,7 @@ std::string switchXKBLayoutRequest(std::string request) {
|
|||
std::string dispatchGetOption(std::string request, HyprCtl::eHyprCtlOutputFormat format) {
|
||||
std::string curitem = "";
|
||||
|
||||
auto nextItem = [&]() {
|
||||
auto nextItem = [&]() {
|
||||
auto idx = request.find_first_of(' ');
|
||||
|
||||
if (idx != std::string::npos) {
|
||||
|
@ -789,10 +766,11 @@ std::string dispatchGetOption(std::string request, HyprCtl::eHyprCtlOutputFormat
|
|||
return "no such option";
|
||||
|
||||
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 {
|
||||
return getFormat(
|
||||
R"#(
|
||||
R"#(
|
||||
{
|
||||
"option": "%s",
|
||||
"int": %lld,
|
||||
|
@ -800,8 +778,8 @@ R"#(
|
|||
"str": "%s",
|
||||
"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 curitem = "";
|
||||
|
||||
auto nextItem = [&]() {
|
||||
auto nextItem = [&]() {
|
||||
auto idx = request.find_first_of(' ');
|
||||
|
||||
if (idx != std::string::npos) {
|
||||
|
@ -863,7 +841,7 @@ std::string dispatchOutput(std::string request) {
|
|||
const auto NAME = curitem;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -951,13 +929,13 @@ int hyprCtlFDTick(int fd, uint32_t mask, void* data) {
|
|||
return 0;
|
||||
|
||||
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';
|
||||
|
||||
std::string request(readBuffer);
|
||||
|
@ -997,7 +975,10 @@ void HyprCtl::startHyprCtlSocket() {
|
|||
|
||||
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.
|
||||
listen(iSocketFD, 10);
|
||||
|
|
|
@ -5,20 +5,21 @@
|
|||
#include "../helpers/MiscFunctions.hpp"
|
||||
|
||||
namespace HyprCtl {
|
||||
void startHyprCtlSocket();
|
||||
void startHyprCtlSocket();
|
||||
|
||||
// very simple thread-safe request method
|
||||
inline bool requestMade = false;
|
||||
inline bool requestReady = false;
|
||||
inline std::string request = "";
|
||||
inline bool requestMade = false;
|
||||
inline bool requestReady = false;
|
||||
inline std::string request = "";
|
||||
|
||||
inline std::ifstream requestStream;
|
||||
inline std::ifstream requestStream;
|
||||
|
||||
inline wl_event_source* hyprCtlTickSource = nullptr;
|
||||
|
||||
inline int iSocketFD = -1;
|
||||
inline int iSocketFD = -1;
|
||||
|
||||
enum eHyprCtlOutputFormat {
|
||||
enum eHyprCtlOutputFormat
|
||||
{
|
||||
FORMAT_NORMAL = 0,
|
||||
FORMAT_JSON
|
||||
};
|
||||
|
|
|
@ -38,10 +38,10 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
|||
if (!m_pMonitor)
|
||||
return 0;
|
||||
|
||||
int yOffset = offset;
|
||||
int yOffset = offset;
|
||||
cairo_text_extents_t cairoExtents;
|
||||
float maxX = 0;
|
||||
std::string text = "";
|
||||
float maxX = 0;
|
||||
std::string text = "";
|
||||
|
||||
// get avg fps
|
||||
float avgFrametime = 0;
|
||||
|
@ -62,7 +62,7 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
|||
}
|
||||
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();
|
||||
|
||||
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;
|
||||
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
||||
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);
|
||||
|
||||
|
@ -91,7 +92,8 @@ int CHyprMonitorDebugOverlay::draw(int offset) {
|
|||
text = std::string(std::to_string((int)FPS) + " FPS");
|
||||
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
||||
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_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");
|
||||
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
||||
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;
|
||||
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");
|
||||
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
||||
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;
|
||||
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");
|
||||
cairo_show_text(g_pDebugOverlay->m_pCairo, text.c_str());
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
return yOffset - offset;
|
||||
|
@ -144,7 +150,7 @@ void CHyprDebugOverlay::draw() {
|
|||
|
||||
if (!m_pCairoSurface || !m_pCairo) {
|
||||
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
|
||||
|
@ -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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -8,38 +8,36 @@
|
|||
#include <unordered_map>
|
||||
|
||||
class CHyprMonitorDebugOverlay {
|
||||
public:
|
||||
int draw(int offset);
|
||||
public:
|
||||
int draw(int offset);
|
||||
|
||||
void renderData(CMonitor* pMonitor, float µs);
|
||||
void renderDataNoOverlay(CMonitor* pMonitor, float µs);
|
||||
void frameData(CMonitor* pMonitor);
|
||||
|
||||
private:
|
||||
std::deque<float> m_dLastFrametimes;
|
||||
std::deque<float> m_dLastRenderTimes;
|
||||
std::deque<float> m_dLastRenderTimesNoOverlay;
|
||||
private:
|
||||
std::deque<float> m_dLastFrametimes;
|
||||
std::deque<float> m_dLastRenderTimes;
|
||||
std::deque<float> m_dLastRenderTimesNoOverlay;
|
||||
std::chrono::high_resolution_clock::time_point m_tpLastFrame;
|
||||
CMonitor* m_pMonitor = nullptr;
|
||||
wlr_box m_wbLastDrawnBox;
|
||||
CMonitor* m_pMonitor = nullptr;
|
||||
wlr_box m_wbLastDrawnBox;
|
||||
};
|
||||
|
||||
class CHyprDebugOverlay {
|
||||
public:
|
||||
|
||||
public:
|
||||
void draw();
|
||||
void renderData(CMonitor*, float µs);
|
||||
void renderDataNoOverlay(CMonitor*, float µs);
|
||||
void frameData(CMonitor*);
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
std::unordered_map<CMonitor*, CHyprMonitorDebugOverlay> m_mMonitorOverlays;
|
||||
|
||||
cairo_surface_t* m_pCairoSurface = nullptr;
|
||||
cairo_t* m_pCairo = nullptr;
|
||||
cairo_surface_t* m_pCairoSurface = nullptr;
|
||||
cairo_t* m_pCairo = nullptr;
|
||||
|
||||
CTexture m_tTexture;
|
||||
CTexture m_tTexture;
|
||||
|
||||
friend class CHyprMonitorDebugOverlay;
|
||||
};
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
void Debug::init(std::string IS) {
|
||||
void Debug::init(const std::string& IS) {
|
||||
logFile = "/tmp/hypr/" + IS + (ISDEBUG ? "/hyprlandd.log" : "/hyprland.log");
|
||||
}
|
||||
|
||||
void Debug::wlrLog(wlr_log_importance level, const char* fmt, va_list args) {
|
||||
char* outputStr = nullptr;
|
||||
char* outputStr = nullptr;
|
||||
|
||||
std::ofstream ofs;
|
||||
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);
|
||||
|
||||
switch (level) {
|
||||
case LOG:
|
||||
ofs << "[LOG] ";
|
||||
break;
|
||||
case WARN:
|
||||
ofs << "[WARN] ";
|
||||
break;
|
||||
case ERR:
|
||||
ofs << "[ERR] ";
|
||||
break;
|
||||
case CRIT:
|
||||
ofs << "[CRITICAL] ";
|
||||
break;
|
||||
case INFO:
|
||||
ofs << "[INFO] ";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case LOG: ofs << "[LOG] "; break;
|
||||
case WARN: ofs << "[WARN] "; 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
|
||||
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;
|
||||
|
||||
ofs << std::put_time(std::localtime(&timet), "[%H:%M:%S:");
|
||||
|
@ -71,7 +60,7 @@ void Debug::log(LogLevel level, const char* fmt, ...) {
|
|||
ofs << "] ";
|
||||
}
|
||||
|
||||
char* outputStr = nullptr;
|
||||
char* outputStr = nullptr;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
|
|
@ -4,9 +4,10 @@
|
|||
|
||||
#define LOGMESSAGESIZE 1024
|
||||
|
||||
enum LogLevel {
|
||||
enum LogLevel
|
||||
{
|
||||
NONE = -1,
|
||||
LOG = 0,
|
||||
LOG = 0,
|
||||
WARN,
|
||||
ERR,
|
||||
CRIT,
|
||||
|
@ -14,11 +15,11 @@ enum LogLevel {
|
|||
};
|
||||
|
||||
namespace Debug {
|
||||
void init(std::string IS);
|
||||
void log(LogLevel level, const char* fmt, ...);
|
||||
void wlrLog(wlr_log_importance level, const char* fmt, va_list args);
|
||||
void init(const std::string& IS);
|
||||
void log(LogLevel level, const char* fmt, ...);
|
||||
void wlrLog(wlr_log_importance level, const char* fmt, va_list args);
|
||||
|
||||
inline std::string logFile;
|
||||
inline int64_t* disableLogs = nullptr;
|
||||
inline int64_t* disableTime = nullptr;
|
||||
inline int64_t* disableLogs = nullptr;
|
||||
inline int64_t* disableTime = nullptr;
|
||||
};
|
|
@ -18,39 +18,44 @@
|
|||
#define ISDEBUG false
|
||||
#endif
|
||||
|
||||
#define LISTENER(name) void listener_##name(wl_listener*, void*); inline wl_listener listen_##name = { .notify = listener_##name }
|
||||
#define DYNLISTENFUNC(name) void listener_##name(void*, void*)
|
||||
#define DYNLISTENER(name) CHyprWLListener hyprListener_##name
|
||||
#define LISTENER(name) \
|
||||
void listener_##name(wl_listener*, void*); \
|
||||
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 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; \
|
||||
const auto RECTSARR = pixman_region32_rectangles(region, &rectsNum); \
|
||||
#define PIXMAN_DAMAGE_FOREACH(region) \
|
||||
int rectsNum = 0; \
|
||||
const auto RECTSARR = pixman_region32_rectangles(region, &rectsNum); \
|
||||
for (int i = 0; i < rectsNum; ++i)
|
||||
|
||||
#define PIXMAN_REGION_FOREACH(region) PIXMAN_DAMAGE_FOREACH(region)
|
||||
|
||||
|
||||
#define interface class
|
||||
|
||||
#define STICKS(a, b) abs((a) - (b)) < 2
|
||||
|
||||
#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 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__
|
||||
#define RASSERT(expr, reason, ...) \
|
||||
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()); \
|
||||
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 */ \
|
||||
#define RASSERT(expr, reason, ...) \
|
||||
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()); \
|
||||
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
|
||||
#define RASSERT(expr, reason, ...)
|
||||
|
@ -59,7 +64,11 @@
|
|||
#define ASSERT(expr) RASSERT(expr, "?")
|
||||
|
||||
#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
|
||||
#define UNREACHABLE() std::unreachable();
|
||||
#endif
|
||||
|
@ -78,6 +87,6 @@
|
|||
#define GIT_DIRTY "?"
|
||||
#endif
|
||||
|
||||
#define SPECIAL_WORKSPACE_START -99
|
||||
#define SPECIAL_WORKSPACE_START (-99)
|
||||
|
||||
#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) {
|
||||
const auto DEVICE = (wlr_input_device*)data;
|
||||
|
||||
switch(DEVICE->type) {
|
||||
switch (DEVICE->type) {
|
||||
case WLR_INPUT_DEVICE_KEYBOARD:
|
||||
Debug::log(LOG, "Attached a keyboard with name %s", DEVICE->name);
|
||||
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);
|
||||
g_pInputManager->newSwitch(DEVICE);
|
||||
break;
|
||||
default:
|
||||
Debug::log(WARN, "Unrecognized input device plugged in: %s", DEVICE->name);
|
||||
break;
|
||||
default: Debug::log(WARN, "Unrecognized input device plugged in: %s", DEVICE->name); break;
|
||||
}
|
||||
|
||||
g_pInputManager->updateCapabilities();
|
||||
|
@ -102,7 +100,7 @@ void Events::listener_newConstraint(wl_listener* listener, void* data) {
|
|||
g_pInputManager->m_lConstraints.emplace_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->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);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -128,13 +126,13 @@ void Events::listener_destroyConstraint(void* owner, void* data) {
|
|||
|
||||
if (PWINDOW) {
|
||||
if (PWINDOW->m_bIsX11) {
|
||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr,
|
||||
PCONSTRAINT->positionHint.x + PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y + PCONSTRAINT->positionHint.y);
|
||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, PCONSTRAINT->positionHint.x + PWINDOW->m_uSurface.xwayland->x,
|
||||
PWINDOW->m_uSurface.xwayland->y + PCONSTRAINT->positionHint.y);
|
||||
|
||||
wlr_seat_pointer_warp(PCONSTRAINT->constraint->seat, PCONSTRAINT->positionHint.x, PCONSTRAINT->positionHint.y);
|
||||
} else {
|
||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr,
|
||||
PCONSTRAINT->positionHint.x + PWINDOW->m_vRealPosition.vec().x, PCONSTRAINT->positionHint.y + PWINDOW->m_vRealPosition.vec().y);
|
||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, PCONSTRAINT->positionHint.x + PWINDOW->m_vRealPosition.vec().x,
|
||||
PCONSTRAINT->positionHint.y + PWINDOW->m_vRealPosition.vec().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) {
|
||||
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 DEVICE = &POINTER->pointer.base;
|
||||
const auto DEVICE = &POINTER->pointer.base;
|
||||
|
||||
g_pInputManager->newMouse(DEVICE, true);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace Events {
|
|||
DYNLISTENFUNC(commitSubsurface);
|
||||
|
||||
// Popups
|
||||
DYNLISTENFUNC(newPopup); // LayerSurface
|
||||
DYNLISTENFUNC(newPopup); // LayerSurface
|
||||
|
||||
DYNLISTENFUNC(newPopupXDG);
|
||||
DYNLISTENFUNC(mapPopupXDG);
|
||||
|
@ -60,7 +60,7 @@ namespace Events {
|
|||
DYNLISTENFUNC(requestMaximize);
|
||||
|
||||
// Window subsurfaces
|
||||
// LISTENER(newSubsurfaceWindow);
|
||||
// LISTENER(newSubsurfaceWindow);
|
||||
|
||||
// Input events
|
||||
LISTENER(mouseMove);
|
||||
|
|
|
@ -34,7 +34,7 @@ void Events::listener_newLayerSurface(wl_listener* listener, void* data) {
|
|||
auto PMONITOR = (CMonitor*)g_pCompositor->getMonitorFromOutput(WLRLAYERSURFACE->output);
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -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->layerSurface = WLRLAYERSURFACE;
|
||||
layerSurface->layer = WLRLAYERSURFACE->current.layer;
|
||||
WLRLAYERSURFACE->data = layerSurface;
|
||||
layerSurface->monitorID = PMONITOR->ID;
|
||||
layerSurface->layer = WLRLAYERSURFACE->current.layer;
|
||||
WLRLAYERSURFACE->data = layerSurface;
|
||||
layerSurface->monitorID = PMONITOR->ID;
|
||||
|
||||
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) {
|
||||
|
@ -94,12 +95,13 @@ void Events::listener_destroyLayerSurface(void* owner, void* data) {
|
|||
PMONITOR->scheduledRecalc = true;
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
layersurface->readyToDelete = true;
|
||||
layersurface->layerSurface = nullptr;
|
||||
layersurface->layerSurface = nullptr;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
layersurface->layerSurface->mapped = true;
|
||||
layersurface->mapped = true;
|
||||
layersurface->mapped = true;
|
||||
|
||||
// anim
|
||||
layersurface->alpha.setConfig(g_pConfigManager->getAnimationPropertyConfig("fadeIn"));
|
||||
|
@ -128,7 +130,7 @@ void Events::listener_mapLayerSurface(void* owner, void* data) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
layersurface->monitorID = PMONITOR->ID;
|
||||
layersurface->monitorID = PMONITOR->ID;
|
||||
PMONITOR->scheduledRecalc = true;
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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_motion(g_pCompositor->m_sSeat.seat, 0, LOCAL.x, LOCAL.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);
|
||||
|
||||
layersurface->alpha.setValue(0);
|
||||
layersurface->alpha = 255.f;
|
||||
layersurface->alpha = 255.f;
|
||||
layersurface->readyToDelete = false;
|
||||
layersurface->fadingOut = false;
|
||||
layersurface->fadingOut = false;
|
||||
|
||||
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
|
||||
if (layersurface->layerSurface->surface == g_pCompositor->m_pLastFocus) {
|
||||
|
||||
Vector2D surfaceCoords;
|
||||
|
||||
Vector2D surfaceCoords;
|
||||
SLayerSurface* pFoundLayerSurface = nullptr;
|
||||
wlr_surface* foundSurface = nullptr;
|
||||
wlr_surface* foundSurface = nullptr;
|
||||
|
||||
g_pCompositor->m_pLastFocus = nullptr;
|
||||
|
||||
// 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)
|
||||
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 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);
|
||||
|
||||
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);
|
||||
|
||||
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?
|
||||
}
|
||||
|
||||
|
@ -248,7 +257,7 @@ void Events::listener_commitLayerSurface(void* owner, void* data) {
|
|||
return;
|
||||
|
||||
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};
|
||||
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;
|
||||
g_pHyprRenderer->arrangeLayersForMonitor(POLDMON->ID);
|
||||
}
|
||||
|
@ -284,7 +293,7 @@ void Events::listener_commitLayerSurface(void* owner, void* data) {
|
|||
layersurface->layer = layersurface->layerSurface->current.layer;
|
||||
|
||||
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);
|
||||
|
@ -295,7 +304,8 @@ void Events::listener_commitLayerSurface(void* owner, void* data) {
|
|||
layersurface->position = Vector2D(layersurface->geometry.x, layersurface->geometry.y);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ void Events::listener_outputMgrTest(wl_listener* listener, void* data) {
|
|||
}
|
||||
|
||||
void Events::listener_leaseRequest(wl_listener* listener, void* data) {
|
||||
const auto REQUEST = (wlr_drm_lease_request_v1*)data;
|
||||
struct wlr_drm_lease_v1* lease = wlr_drm_lease_request_v1_grant(REQUEST);
|
||||
const auto REQUEST = (wlr_drm_lease_request_v1*)data;
|
||||
struct wlr_drm_lease_v1* lease = wlr_drm_lease_request_v1_grant(REQUEST);
|
||||
if (!lease) {
|
||||
Debug::log(ERR, "Failed to grant lease 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) {
|
||||
#ifndef NO_XWAYLAND
|
||||
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) {
|
||||
Debug::log(LogLevel::ERR, "XWayland -> xcb_connection_has_error failed with %i", ERR);
|
||||
return;
|
||||
|
@ -55,7 +55,7 @@ void Events::listener_readyXWayland(wl_listener* listener, void* data) {
|
|||
|
||||
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_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) {
|
||||
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);
|
||||
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);
|
||||
|
@ -107,15 +108,16 @@ void Events::listener_startDrag(wl_listener* listener, void* data) {
|
|||
Debug::log(LOG, "Drag started with an icon %x", 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_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_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)
|
||||
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) {
|
||||
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)
|
||||
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.hyprListener_destroy.removeCallback();
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
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.
|
||||
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);
|
||||
|
||||
//m->vecSize.x = BOX.width;
|
||||
// m->vecSize.y = BOX.height;
|
||||
// m->vecSize.y = BOX.height;
|
||||
m->vecPosition.x = BOX.x;
|
||||
m->vecPosition.y = BOX.y;
|
||||
|
||||
CONFIGHEAD->state.enabled = m->output->enabled;
|
||||
CONFIGHEAD->state.mode = m->output->current_mode;
|
||||
CONFIGHEAD->state.x = m->vecPosition.x;
|
||||
CONFIGHEAD->state.y = m->vecPosition.y;
|
||||
CONFIGHEAD->state.mode = m->output->current_mode;
|
||||
CONFIGHEAD->state.x = m->vecPosition.x;
|
||||
CONFIGHEAD->state.y = m->vecPosition.y;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
PNEWMONITOR->output = OUTPUT;
|
||||
PNEWMONITOR->output = OUTPUT;
|
||||
PNEWMONITOR->m_pThisWrap = PNEWMONITORWRAP;
|
||||
|
||||
PNEWMONITOR->onConnect(false);
|
||||
|
@ -86,7 +86,7 @@ void Events::listener_newOutput(wl_listener* listener, void* data) {
|
|||
// ready to process cuz we have a monitor
|
||||
if (PNEWMONITOR->m_bEnabled) {
|
||||
g_pCompositor->m_bReadyToProcess = true;
|
||||
g_pCompositor->m_bUnsafeState = false;
|
||||
g_pCompositor->m_bUnsafeState = false;
|
||||
}
|
||||
|
||||
g_pConfigManager->m_bWantsMonitorReload = true;
|
||||
|
@ -104,17 +104,17 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
|||
if (!PMONITOR->m_bEnabled)
|
||||
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 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 PDAMAGETRACKINGMODE = &g_pConfigManager->getConfigValuePtr("debug:damage_tracking")->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 PNODIRECTSCANOUT = &g_pConfigManager->getConfigValuePtr("misc:no_direct_scanout")->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 PDAMAGEBLINK = &g_pConfigManager->getConfigValuePtr("debug:damage_blink")->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 int damageBlinkCleanup = 0; // because double-buffered
|
||||
static int damageBlinkCleanup = 0; // because double-buffered
|
||||
|
||||
if (!*PDAMAGEBLINK)
|
||||
damageBlinkCleanup = 0;
|
||||
|
@ -140,16 +140,17 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
|||
}
|
||||
|
||||
// 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_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)
|
||||
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
|
||||
pixman_region32_t damage;
|
||||
bool hasChanged;
|
||||
bool hasChanged;
|
||||
pixman_region32_init(&damage);
|
||||
|
||||
if (*PDAMAGETRACKINGMODE == -1) {
|
||||
|
@ -183,7 +184,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
|||
|
||||
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());
|
||||
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 (*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_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage);
|
||||
} 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 (*PBLURENABLED == 1) {
|
||||
// TODO: can this be optimized?
|
||||
static auto *const PBLURSIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_size")->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.
|
||||
static auto* const PBLURSIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_size")->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.
|
||||
|
||||
pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage);
|
||||
|
||||
// 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 {
|
||||
pixman_region32_copy(&g_pHyprOpenGL->m_rOriginalDamageRegion, &damage);
|
||||
}
|
||||
|
@ -231,7 +233,6 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
|||
PMONITOR->forceFullFrames = 0;
|
||||
}
|
||||
|
||||
|
||||
// TODO: this is getting called with extents being 0,0,0,0 should it be?
|
||||
// potentially can save on resources.
|
||||
|
||||
|
@ -241,7 +242,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
|||
g_pHyprOpenGL->renderMirrored();
|
||||
} else {
|
||||
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);
|
||||
|
||||
|
@ -318,7 +319,7 @@ void Events::listener_monitorFrame(void* owner, void* data) {
|
|||
void Events::listener_monitorDestroy(void* owner, void* data) {
|
||||
const auto OUTPUT = (wlr_output*)data;
|
||||
|
||||
CMonitor* pMonitor = nullptr;
|
||||
CMonitor* pMonitor = nullptr;
|
||||
|
||||
for (auto& m : g_pCompositor->m_vRealMonitors) {
|
||||
if (m->output == OUTPUT) {
|
||||
|
@ -338,16 +339,16 @@ void Events::listener_monitorDestroy(void* owner, void* data) {
|
|||
if (!g_pCompositor->m_bUnsafeState) {
|
||||
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) {
|
||||
int mostHz = 0;
|
||||
int mostHz = 0;
|
||||
CMonitor* pMonitorMostHz = nullptr;
|
||||
|
||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||
if (m->refreshRate > mostHz) {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
// --------------------------------------------- //
|
||||
|
||||
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 py = 0;
|
||||
int px = 0;
|
||||
int py = 0;
|
||||
|
||||
while (true) {
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
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) {
|
||||
|
@ -85,9 +86,9 @@ void Events::listener_newPopup(void* owner, void* data) {
|
|||
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(layersurface->monitorID);
|
||||
|
||||
PNEWPOPUP->popup = WLRPOPUP;
|
||||
PNEWPOPUP->lx = layersurface->position.x;
|
||||
PNEWPOPUP->ly = layersurface->position.y;
|
||||
PNEWPOPUP->popup = WLRPOPUP;
|
||||
PNEWPOPUP->lx = layersurface->position.x;
|
||||
PNEWPOPUP->ly = layersurface->position.y;
|
||||
PNEWPOPUP->monitor = PMONITOR;
|
||||
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
||||
}
|
||||
|
@ -108,11 +109,11 @@ void Events::listener_newPopupXDG(void* owner, void* data) {
|
|||
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||
|
||||
PNEWPOPUP->popup = WLRPOPUP;
|
||||
PNEWPOPUP->lx = PWINDOW->m_vRealPosition.goalv().x;
|
||||
PNEWPOPUP->ly = PWINDOW->m_vRealPosition.goalv().y;
|
||||
PNEWPOPUP->popup = WLRPOPUP;
|
||||
PNEWPOPUP->lx = PWINDOW->m_vRealPosition.goalv().x;
|
||||
PNEWPOPUP->ly = PWINDOW->m_vRealPosition.goalv().y;
|
||||
PNEWPOPUP->parentWindow = PWINDOW;
|
||||
PNEWPOPUP->monitor = PMONITOR;
|
||||
PNEWPOPUP->monitor = PMONITOR;
|
||||
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();
|
||||
|
||||
PNEWPOPUP->popup = WLRPOPUP;
|
||||
PNEWPOPUP->parentPopup = PPOPUP;
|
||||
PNEWPOPUP->lx = PPOPUP->lx;
|
||||
PNEWPOPUP->ly = PPOPUP->ly;
|
||||
PNEWPOPUP->popup = WLRPOPUP;
|
||||
PNEWPOPUP->parentPopup = PPOPUP;
|
||||
PNEWPOPUP->lx = PPOPUP->lx;
|
||||
PNEWPOPUP->ly = PPOPUP->ly;
|
||||
PNEWPOPUP->parentWindow = PPOPUP->parentWindow;
|
||||
PNEWPOPUP->monitor = PPOPUP->monitor;
|
||||
PNEWPOPUP->monitor = PPOPUP->monitor;
|
||||
|
||||
createNewPopup(WLRPOPUP, PNEWPOPUP);
|
||||
}
|
||||
|
@ -182,7 +183,7 @@ void Events::listener_unmapPopupXDG(void* owner, void* data) {
|
|||
void Events::listener_commitPopupXDG(void* owner, void* data) {
|
||||
SXDGPopup* PPOPUP = (SXDGPopup*)owner;
|
||||
|
||||
int lx = 0, ly = 0;
|
||||
int lx = 0, ly = 0;
|
||||
addPopupGlobalCoords(PPOPUP, &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;
|
||||
}
|
||||
|
||||
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) {
|
||||
auto *const PANIMCFG = g_pConfigManager->getAnimationPropertyConfig("windowsMove");
|
||||
auto* const PANIMCFG = g_pConfigManager->getAnimationPropertyConfig("windowsMove");
|
||||
|
||||
CAnimatedVariable* animvar = (CAnimatedVariable*)data;
|
||||
|
||||
|
@ -38,23 +38,24 @@ void setAnimToMove(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 PACTIVEALPHA = &g_pConfigManager->getConfigValuePtr("decoration:active_opacity")->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 PSWALLOWREGEX = &g_pConfigManager->getConfigValuePtr("misc:swallow_regex")->strValue;
|
||||
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 PDIMSTRENGTH = &g_pConfigManager->getConfigValuePtr("decoration:dim_strength")->floatValue;
|
||||
static auto* const PSWALLOW = &g_pConfigManager->getConfigValuePtr("misc:enable_swallow")->intValue;
|
||||
static auto* const PSWALLOWREGEX = &g_pConfigManager->getConfigValuePtr("misc:swallow_regex")->strValue;
|
||||
|
||||
auto PMONITOR = g_pCompositor->m_pLastMonitor;
|
||||
const auto PWORKSPACE = PMONITOR->specialWorkspaceID ? g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID) : g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
||||
PWINDOW->m_iMonitorID = PMONITOR->ID;
|
||||
PWINDOW->m_bMappedX11 = true;
|
||||
PWINDOW->m_iWorkspaceID = PMONITOR->specialWorkspaceID ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace;
|
||||
PWINDOW->m_bIsMapped = true;
|
||||
auto PMONITOR = g_pCompositor->m_pLastMonitor;
|
||||
const auto PWORKSPACE =
|
||||
PMONITOR->specialWorkspaceID ? g_pCompositor->getWorkspaceByID(PMONITOR->specialWorkspaceID) : g_pCompositor->getWorkspaceByID(PMONITOR->activeWorkspace);
|
||||
PWINDOW->m_iMonitorID = PMONITOR->ID;
|
||||
PWINDOW->m_bMappedX11 = true;
|
||||
PWINDOW->m_iWorkspaceID = PMONITOR->specialWorkspaceID ? PMONITOR->specialWorkspaceID : PMONITOR->activeWorkspace;
|
||||
PWINDOW->m_bIsMapped = true;
|
||||
PWINDOW->m_bReadyToDelete = false;
|
||||
PWINDOW->m_bFadingOut = false;
|
||||
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
|
||||
PWINDOW->m_bFadingOut = false;
|
||||
PWINDOW->m_szTitle = g_pXWaylandManager->getTitle(PWINDOW);
|
||||
|
||||
if (PWINDOW->m_iX11Type == 2)
|
||||
g_pCompositor->moveUnmanagedX11ToWindows(PWINDOW);
|
||||
|
@ -79,7 +80,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||
}
|
||||
|
||||
if (g_pXWaylandManager->shouldBeFloated(PWINDOW)) {
|
||||
PWINDOW->m_bIsFloating = true;
|
||||
PWINDOW->m_bIsFloating = true;
|
||||
PWINDOW->m_bRequestsFloat = true;
|
||||
}
|
||||
|
||||
|
@ -90,7 +91,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||
|
||||
if (PWORKSPACE->m_bDefaultPseudo) {
|
||||
PWINDOW->m_bIsPseudotiled = true;
|
||||
wlr_box desiredGeometry = {0};
|
||||
wlr_box desiredGeometry = {0};
|
||||
g_pXWaylandManager->getGeometryForWindow(PWINDOW, &desiredGeometry);
|
||||
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) {
|
||||
const auto PFULLWINDOW = g_pCompositor->getFullscreenWindowOnWorkspace(PWORKSPACE->m_iID);
|
||||
pFullscreenWindow = PFULLWINDOW;
|
||||
pFullscreenWindow = PFULLWINDOW;
|
||||
g_pCompositor->setWindowFullscreen(PFULLWINDOW, false, PWORKSPACE->m_efFullscreenMode);
|
||||
}
|
||||
|
||||
// window rules
|
||||
const auto WINDOWRULES = g_pConfigManager->getMatchingRules(PWINDOW);
|
||||
const auto WINDOWRULES = g_pConfigManager->getMatchingRules(PWINDOW);
|
||||
std::string requestedWorkspace = "";
|
||||
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 shouldFocus = true;
|
||||
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 shouldFocus = true;
|
||||
bool workspaceSpecial = false;
|
||||
|
||||
for (auto& r : WINDOWRULES) {
|
||||
if (r.szRule.find("monitor") == 0) {
|
||||
try {
|
||||
const auto MONITORSTR = r.szRule.substr(r.szRule.find(" "));
|
||||
const auto MONITORSTR = r.szRule.substr(r.szRule.find(' '));
|
||||
|
||||
if (MONITORSTR == "unset") {
|
||||
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);
|
||||
} 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());
|
||||
}
|
||||
} 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()); }
|
||||
} else if (r.szRule.find("workspace") == 0) {
|
||||
// check if it isnt unset
|
||||
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
|
||||
if (requestedWorkspace.contains("silent")) {
|
||||
workspaceSilent = true;
|
||||
shouldFocus = false;
|
||||
shouldFocus = false;
|
||||
|
||||
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) {
|
||||
workspaceSpecial = true;
|
||||
workspaceSilent = true;
|
||||
workspaceSilent = true;
|
||||
}
|
||||
|
||||
if (!workspaceSilent) {
|
||||
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;
|
||||
|
||||
PMONITOR = g_pCompositor->m_pLastMonitor;
|
||||
|
@ -231,14 +232,14 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||
|
||||
if (!PWORKSPACE) {
|
||||
std::string workspaceName = "";
|
||||
int workspaceID = 0;
|
||||
int workspaceID = 0;
|
||||
|
||||
if (requestedWorkspace.find("name:") == 0) {
|
||||
workspaceName = requestedWorkspace.substr(5);
|
||||
workspaceID = g_pCompositor->getNextAvailableNamedWorkspace();
|
||||
workspaceID = g_pCompositor->getNextAvailableNamedWorkspace();
|
||||
} else if (workspaceSpecial) {
|
||||
workspaceName = "";
|
||||
workspaceID = getWorkspaceIDFromString(requestedWorkspace, workspaceName);
|
||||
workspaceID = getWorkspaceIDFromString(requestedWorkspace, workspaceName);
|
||||
} else {
|
||||
try {
|
||||
workspaceID = std::stoi(requestedWorkspace);
|
||||
|
@ -258,7 +259,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||
|
||||
if (PWORKSPACE) {
|
||||
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) {
|
||||
if (r.szRule.find("size") == 0) {
|
||||
try {
|
||||
const auto VALUE = r.szRule.substr(r.szRule.find(" ") + 1);
|
||||
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(" "));
|
||||
const auto SIZEYSTR = VALUE.substr(VALUE.find(" ") + 1);
|
||||
const auto VALUE = r.szRule.substr(r.szRule.find(' ') + 1);
|
||||
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(' '));
|
||||
const auto SIZEYSTR = VALUE.substr(VALUE.find(' ') + 1);
|
||||
|
||||
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 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);
|
||||
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 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);
|
||||
|
||||
|
@ -285,58 +290,55 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
|
||||
|
||||
PWINDOW->setHidden(false);
|
||||
} catch (...) {
|
||||
Debug::log(LOG, "Rule size failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
|
||||
}
|
||||
} catch (...) { Debug::log(LOG, "Rule size failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); }
|
||||
} else if (r.szRule.find("minsize") == 0) {
|
||||
try {
|
||||
const auto VALUE = r.szRule.substr(r.szRule.find(" ") + 1);
|
||||
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(" "));
|
||||
const auto SIZEYSTR = VALUE.substr(VALUE.find(" ") + 1);
|
||||
const auto VALUE = r.szRule.substr(r.szRule.find(' ') + 1);
|
||||
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(' '));
|
||||
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;
|
||||
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
|
||||
|
||||
PWINDOW->setHidden(false);
|
||||
} catch (...) {
|
||||
Debug::log(LOG, "Rule minsize failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
|
||||
}
|
||||
} catch (...) { Debug::log(LOG, "Rule minsize failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); }
|
||||
} else if (r.szRule.find("maxsize") == 0) {
|
||||
try {
|
||||
const auto VALUE = r.szRule.substr(r.szRule.find(" ") + 1);
|
||||
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(" "));
|
||||
const auto SIZEYSTR = VALUE.substr(VALUE.find(" ") + 1);
|
||||
const auto VALUE = r.szRule.substr(r.szRule.find(' ') + 1);
|
||||
const auto SIZEXSTR = VALUE.substr(0, VALUE.find(' '));
|
||||
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;
|
||||
g_pXWaylandManager->setWindowSize(PWINDOW, PWINDOW->m_vRealSize.goalv());
|
||||
|
||||
PWINDOW->setHidden(false);
|
||||
} catch (...) {
|
||||
Debug::log(LOG, "Rule maxsize failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
|
||||
}
|
||||
} catch (...) { Debug::log(LOG, "Rule maxsize failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); }
|
||||
} else if (r.szRule.find("move") == 0) {
|
||||
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;
|
||||
|
||||
if (CURSOR)
|
||||
value = value.substr(value.find_first_of(' ') + 1);
|
||||
|
||||
const auto POSXSTR = value.substr(0, value.find(" "));
|
||||
const auto POSYSTR = value.substr(value.find(" ") + 1);
|
||||
const auto POSXSTR = value.substr(0, value.find(' '));
|
||||
const auto POSYSTR = value.substr(value.find(' ') + 1);
|
||||
|
||||
int posX = 0;
|
||||
int posY = 0;
|
||||
int posX = 0;
|
||||
int posY = 0;
|
||||
|
||||
if (POSXSTR.find("100%-") == 0) {
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||
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);
|
||||
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);
|
||||
|
||||
if (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") {
|
||||
posX = g_pInputManager->getMouseCoordsInternal().x - PMONITOR->vecPosition.x;
|
||||
} 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) {
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||
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);
|
||||
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);
|
||||
|
||||
if (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") {
|
||||
posY = g_pInputManager->getMouseCoordsInternal().y - PMONITOR->vecPosition.y;
|
||||
} 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->setHidden(false);
|
||||
} catch (...) {
|
||||
Debug::log(LOG, "Rule move failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str());
|
||||
}
|
||||
} catch (...) { Debug::log(LOG, "Rule move failed, rule: %s -> %s", r.szRule.c_str(), r.szValue.c_str()); }
|
||||
} else if (r.szRule == "center") {
|
||||
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);
|
||||
|
||||
// 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;
|
||||
|
||||
if (PWINDOW->m_sAdditionalConfigData.forceAllowsInput) {
|
||||
PWINDOW->m_bNoFocus = false;
|
||||
PWINDOW->m_bNoInitialFocus = false;
|
||||
PWINDOW->m_bNoFocus = false;
|
||||
PWINDOW->m_bNoInitialFocus = 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_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_requestMaximize.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_maximize, &Events::listener_requestMaximize, PWINDOW, "XDG Window Late");
|
||||
PWINDOW->hyprListener_requestMinimize.initCallback(&PWINDOW->m_uSurface.xdg->toplevel->events.request_minimize, &Events::listener_requestMinimize, 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_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_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 {
|
||||
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_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_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_maximize, &Events::listener_requestMaximize, 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_maximize, &Events::listener_requestMaximize, PWINDOW,
|
||||
"Xwayland Window Late");
|
||||
|
||||
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
|
||||
|
@ -502,7 +512,7 @@ void Events::listener_mapWindow(void* owner, void* data) {
|
|||
if (ppid) {
|
||||
// get window by pid
|
||||
std::vector<CWindow*> found;
|
||||
CWindow* finalFound = nullptr;
|
||||
CWindow* finalFound = nullptr;
|
||||
for (auto& w : g_pCompositor->m_vWindows) {
|
||||
if (!w->m_bIsMapped || w->isHidden())
|
||||
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;
|
||||
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
|
||||
g_pCompositor->updateWindowAnimatedDecorationValues(PWINDOW);
|
||||
|
@ -595,9 +607,9 @@ void Events::listener_unmapWindow(void* owner, void* data) {
|
|||
bool wasLastWindow = false;
|
||||
|
||||
if (PWINDOW == g_pCompositor->m_pLastWindow) {
|
||||
wasLastWindow = true;
|
||||
wasLastWindow = true;
|
||||
g_pCompositor->m_pLastWindow = nullptr;
|
||||
g_pCompositor->m_pLastFocus = nullptr;
|
||||
g_pCompositor->m_pLastFocus = nullptr;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
// 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();
|
||||
|
||||
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
|
||||
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
|
||||
|
||||
// anims
|
||||
g_pAnimationManager->onWindowPostCreateClose(PWINDOW, true);
|
||||
|
@ -689,7 +701,7 @@ void Events::listener_destroyWindow(void* owner, void* data) {
|
|||
|
||||
if (PWINDOW == g_pCompositor->m_pLastWindow) {
|
||||
g_pCompositor->m_pLastWindow = nullptr;
|
||||
g_pCompositor->m_pLastFocus = nullptr;
|
||||
g_pCompositor->m_pLastFocus = nullptr;
|
||||
}
|
||||
|
||||
PWINDOW->hyprListener_mapWindow.removeCallback();
|
||||
|
@ -705,7 +717,7 @@ void Events::listener_destroyWindow(void* owner, void* data) {
|
|||
}
|
||||
|
||||
PWINDOW->m_bReadyToDelete = true;
|
||||
|
||||
|
||||
if (!PWINDOW->m_bFadingOut) {
|
||||
g_pCompositor->removeWindowFromVectorSafe(PWINDOW); // most likely X11 unmanaged or sumn
|
||||
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;
|
||||
|
||||
if (!g_pCompositor->windowValidMapped(PWINDOW))
|
||||
return;
|
||||
return;
|
||||
|
||||
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) {
|
||||
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);
|
||||
|
||||
|
@ -781,9 +793,9 @@ void Events::listener_activateXDG(wl_listener* listener, 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);
|
||||
|
||||
|
@ -824,7 +836,7 @@ void Events::listener_configureX11(void* owner, void* data) {
|
|||
PWINDOW->m_vRealPosition.setValueAndWarp(Vector2D(E->x, E->y));
|
||||
PWINDOW->m_vRealSize.setValueAndWarp(Vector2D(E->width, E->height));
|
||||
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);
|
||||
|
||||
|
@ -862,8 +874,10 @@ void Events::listener_unmanagedSetGeometry(void* owner, void* data) {
|
|||
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) {
|
||||
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);
|
||||
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) {
|
||||
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);
|
||||
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)
|
||||
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_iX11Type = XWSURFACE->override_redirect ? 2 : 1;
|
||||
PNEWWINDOW->m_bIsX11 = true;
|
||||
PNEWWINDOW->m_iX11Type = XWSURFACE->override_redirect ? 2 : 1;
|
||||
PNEWWINDOW->m_bIsX11 = true;
|
||||
|
||||
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);
|
||||
|
||||
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->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) {
|
||||
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);
|
||||
} else {
|
||||
|
|
|
@ -7,10 +7,10 @@ CAnimatedVariable::CAnimatedVariable() {
|
|||
}
|
||||
|
||||
void CAnimatedVariable::create(ANIMATEDVARTYPE type, SAnimationPropertyConfig* pAnimConfig, void* pWindow, AVARDAMAGEPOLICY policy) {
|
||||
m_eVarType = type;
|
||||
m_eVarType = type;
|
||||
m_eDamagePolicy = policy;
|
||||
m_pConfig = pAnimConfig;
|
||||
m_pWindow = pWindow;
|
||||
m_pConfig = pAnimConfig;
|
||||
m_pWindow = pWindow;
|
||||
|
||||
m_bDummy = false;
|
||||
}
|
||||
|
@ -22,25 +22,23 @@ void CAnimatedVariable::create(ANIMATEDVARTYPE type, std::any val, SAnimationPro
|
|||
switch (type) {
|
||||
case AVARTYPE_FLOAT: {
|
||||
const auto V = std::any_cast<float>(val);
|
||||
m_fValue = V;
|
||||
m_fGoal = V;
|
||||
m_fValue = V;
|
||||
m_fGoal = V;
|
||||
break;
|
||||
}
|
||||
case AVARTYPE_VECTOR: {
|
||||
const auto V = std::any_cast<Vector2D>(val);
|
||||
m_vValue = V;
|
||||
m_vGoal = V;
|
||||
m_vValue = V;
|
||||
m_vGoal = V;
|
||||
break;
|
||||
}
|
||||
case AVARTYPE_COLOR: {
|
||||
const auto V = std::any_cast<CColor>(val);
|
||||
m_cValue = V;
|
||||
m_cGoal = V;
|
||||
m_cValue = V;
|
||||
m_cGoal = V;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ASSERT(false);
|
||||
break;
|
||||
default: ASSERT(false); break;
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
Debug::log(ERR, "CAnimatedVariable create error: %s", e.what());
|
||||
|
@ -64,7 +62,8 @@ void CAnimatedVariable::registerVar() {
|
|||
}
|
||||
|
||||
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() {
|
||||
|
|
|
@ -3,16 +3,18 @@
|
|||
#include "../defines.hpp"
|
||||
#include <any>
|
||||
|
||||
enum ANIMATEDVARTYPE {
|
||||
enum ANIMATEDVARTYPE
|
||||
{
|
||||
AVARTYPE_INVALID = -1,
|
||||
AVARTYPE_FLOAT,
|
||||
AVARTYPE_VECTOR,
|
||||
AVARTYPE_COLOR
|
||||
};
|
||||
|
||||
enum AVARDAMAGEPOLICY {
|
||||
enum AVARDAMAGEPOLICY
|
||||
{
|
||||
AVARDAMAGE_INVALID = -1,
|
||||
AVARDAMAGE_ENTIRE = 0,
|
||||
AVARDAMAGE_ENTIRE = 0,
|
||||
AVARDAMAGE_BORDER,
|
||||
AVARDAMAGE_SHADOW
|
||||
};
|
||||
|
@ -24,7 +26,7 @@ struct SAnimationPropertyConfig;
|
|||
class CHyprRenderer;
|
||||
|
||||
class CAnimatedVariable {
|
||||
public:
|
||||
public:
|
||||
CAnimatedVariable(); // dummy var
|
||||
|
||||
void create(ANIMATEDVARTYPE, SAnimationPropertyConfig*, void* pWindow, AVARDAMAGEPOLICY);
|
||||
|
@ -65,53 +67,59 @@ public:
|
|||
return m_cGoal;
|
||||
}
|
||||
|
||||
void operator=(const Vector2D& v) {
|
||||
m_vGoal = v;
|
||||
CAnimatedVariable& operator=(const Vector2D& v) {
|
||||
m_vGoal = v;
|
||||
animationBegin = std::chrono::system_clock::now();
|
||||
m_vBegun = m_vValue;
|
||||
m_vBegun = m_vValue;
|
||||
|
||||
onAnimationBegin();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void operator=(const float& v) {
|
||||
m_fGoal = v;
|
||||
CAnimatedVariable& operator=(const float& v) {
|
||||
m_fGoal = v;
|
||||
animationBegin = std::chrono::system_clock::now();
|
||||
m_fBegun = m_fValue;
|
||||
m_fBegun = m_fValue;
|
||||
|
||||
onAnimationBegin();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void operator=(const CColor& v) {
|
||||
m_cGoal = v;
|
||||
CAnimatedVariable& operator=(const CColor& v) {
|
||||
m_cGoal = v;
|
||||
animationBegin = std::chrono::system_clock::now();
|
||||
m_cBegun = m_cValue;
|
||||
m_cBegun = m_cValue;
|
||||
|
||||
onAnimationBegin();
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Sets the actual stored value, without affecting the goal, but resets the timer
|
||||
void setValue(const Vector2D& v) {
|
||||
m_vValue = v;
|
||||
m_vValue = v;
|
||||
animationBegin = std::chrono::system_clock::now();
|
||||
m_vBegun = m_vValue;
|
||||
m_vBegun = m_vValue;
|
||||
|
||||
onAnimationBegin();
|
||||
}
|
||||
|
||||
// Sets the actual stored value, without affecting the goal, but resets the timer
|
||||
void setValue(const float& v) {
|
||||
m_fValue = v;
|
||||
m_fValue = v;
|
||||
animationBegin = std::chrono::system_clock::now();
|
||||
m_vBegun = m_vValue;
|
||||
m_vBegun = m_vValue;
|
||||
|
||||
onAnimationBegin();
|
||||
}
|
||||
|
||||
// Sets the actual stored value, without affecting the goal, but resets the timer
|
||||
void setValue(const CColor& v) {
|
||||
m_cValue = v;
|
||||
m_cValue = v;
|
||||
animationBegin = std::chrono::system_clock::now();
|
||||
m_vBegun = m_vValue;
|
||||
m_vBegun = m_vValue;
|
||||
|
||||
onAnimationBegin();
|
||||
}
|
||||
|
@ -137,14 +145,10 @@ public:
|
|||
// checks if an animation is in progress
|
||||
bool isBeingAnimated() {
|
||||
switch (m_eVarType) {
|
||||
case AVARTYPE_FLOAT:
|
||||
return m_fValue != m_fGoal;
|
||||
case AVARTYPE_VECTOR:
|
||||
return m_vValue != m_vGoal;
|
||||
case AVARTYPE_COLOR:
|
||||
return m_cValue != m_cGoal;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
case AVARTYPE_FLOAT: return m_fValue != m_fGoal;
|
||||
case AVARTYPE_VECTOR: return m_vValue != m_vGoal;
|
||||
case AVARTYPE_COLOR: return m_cValue != m_cGoal;
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
|
||||
UNREACHABLE();
|
||||
|
@ -166,8 +170,7 @@ public:
|
|||
m_cValue = m_cGoal;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
default: UNREACHABLE();
|
||||
}
|
||||
|
||||
if (endCallback)
|
||||
|
@ -191,7 +194,7 @@ public:
|
|||
if an animation is not running, runs instantly.
|
||||
if "remove" is set to true, will remove the callback when ran. */
|
||||
void setCallbackOnEnd(std::function<void(void* thisptr)> func, bool remove = true) {
|
||||
m_fEndCallback = func;
|
||||
m_fEndCallback = func;
|
||||
m_bRemoveEndAfterRan = remove;
|
||||
|
||||
if (!isBeingAnimated())
|
||||
|
@ -201,58 +204,57 @@ public:
|
|||
/* sets a function to be ran when an animation is started.
|
||||
if "remove" is set to true, will remove the callback when ran. */
|
||||
void setCallbackOnBegin(std::function<void(void* thisptr)> func, bool remove = true) {
|
||||
m_fBeginCallback = func;
|
||||
m_fBeginCallback = func;
|
||||
m_bRemoveBeginAfterRan = remove;
|
||||
}
|
||||
|
||||
/* resets all callbacks. Does not call any. */
|
||||
void resetAllCallbacks() {
|
||||
m_fBeginCallback = nullptr;
|
||||
m_fEndCallback = nullptr;
|
||||
m_fBeginCallback = nullptr;
|
||||
m_fEndCallback = nullptr;
|
||||
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);
|
||||
float m_fValue = 0;
|
||||
CColor m_cValue;
|
||||
Vector2D m_vGoal = Vector2D(0, 0);
|
||||
float m_fGoal = 0;
|
||||
CColor m_cGoal;
|
||||
|
||||
Vector2D m_vGoal = Vector2D(0,0);
|
||||
float m_fGoal = 0;
|
||||
CColor m_cGoal;
|
||||
|
||||
Vector2D m_vBegun = Vector2D(0,0);
|
||||
float m_fBegun = 0;
|
||||
CColor m_cBegun;
|
||||
Vector2D m_vBegun = Vector2D(0, 0);
|
||||
float m_fBegun = 0;
|
||||
CColor m_cBegun;
|
||||
|
||||
// owners
|
||||
void* m_pWindow = nullptr;
|
||||
void* m_pWorkspace = nullptr;
|
||||
void* m_pLayer = nullptr;
|
||||
void* m_pWindow = nullptr;
|
||||
void* m_pWorkspace = nullptr;
|
||||
void* m_pLayer = nullptr;
|
||||
|
||||
SAnimationPropertyConfig* m_pConfig = nullptr;
|
||||
SAnimationPropertyConfig* m_pConfig = nullptr;
|
||||
|
||||
bool m_bDummy = true;
|
||||
bool m_bIsRegistered = false;
|
||||
bool m_bDummy = true;
|
||||
bool m_bIsRegistered = false;
|
||||
|
||||
std::chrono::system_clock::time_point animationBegin;
|
||||
|
||||
ANIMATEDVARTYPE m_eVarType = AVARTYPE_INVALID;
|
||||
AVARDAMAGEPOLICY m_eDamagePolicy = AVARDAMAGE_INVALID;
|
||||
ANIMATEDVARTYPE m_eVarType = AVARTYPE_INVALID;
|
||||
AVARDAMAGEPOLICY m_eDamagePolicy = AVARDAMAGE_INVALID;
|
||||
|
||||
bool m_bRemoveEndAfterRan = true;
|
||||
bool m_bRemoveBeginAfterRan = true;
|
||||
std::function<void(void* thisptr)> m_fEndCallback;
|
||||
std::function<void(void* thisptr)> m_fBeginCallback;
|
||||
bool m_bRemoveEndAfterRan = true;
|
||||
bool m_bRemoveBeginAfterRan = true;
|
||||
std::function<void(void* thisptr)> m_fEndCallback;
|
||||
std::function<void(void* thisptr)> m_fBeginCallback;
|
||||
|
||||
// methods
|
||||
void onAnimationEnd() {
|
||||
if (m_fEndCallback) {
|
||||
m_fEndCallback(this);
|
||||
if (m_bRemoveEndAfterRan)
|
||||
m_fEndCallback = nullptr; // reset
|
||||
m_fEndCallback = nullptr; // reset
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,7 +262,7 @@ private:
|
|||
if (m_fBeginCallback) {
|
||||
m_fBeginCallback(this);
|
||||
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();
|
||||
|
||||
m_dPoints.emplace_back(Vector2D(0,0));
|
||||
m_dPoints.emplace_back(Vector2D(0, 0));
|
||||
|
||||
for (auto& p : *pVec) {
|
||||
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());
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
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 BEGINCALC = std::chrono::high_resolution_clock::now();
|
||||
|
@ -29,9 +29,8 @@ void CBezierCurve::setup(std::vector<Vector2D>* pVec) {
|
|||
getYForPoint(i);
|
||||
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.",
|
||||
BAKEDPOINTS, POINTSSIZE, ELAPSEDUS, ELAPSEDCALCAVG);
|
||||
|
||||
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,
|
||||
ELAPSEDCALCAVG);
|
||||
}
|
||||
|
||||
float CBezierCurve::getYForT(float t) {
|
||||
|
@ -47,9 +46,9 @@ float CBezierCurve::getYForPoint(float x) {
|
|||
// binary search for the range UPDOWN X
|
||||
float upperT = 1;
|
||||
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) {
|
||||
upperT = mid;
|
||||
} else {
|
||||
|
@ -65,7 +64,7 @@ float CBezierCurve::getYForPoint(float 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 LOWERPOINT->y + (UPPERPOINT->y - UPPERPOINT->y) * PERCINDELTA;
|
||||
|
|
|
@ -3,25 +3,25 @@
|
|||
#include "../defines.hpp"
|
||||
#include <deque>
|
||||
|
||||
constexpr int BAKEDPOINTS = 200;
|
||||
constexpr int BAKEDPOINTS = 200;
|
||||
constexpr float INVBAKEDPOINTS = 1.f / BAKEDPOINTS;
|
||||
|
||||
// an implementation of a cubic bezier curve
|
||||
// might do better later
|
||||
// TODO: n-point curves
|
||||
class CBezierCurve {
|
||||
public:
|
||||
public:
|
||||
// sets up the bezier curve.
|
||||
// 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 getXForT(float t);
|
||||
float getYForPoint(float x);
|
||||
float getYForT(float t);
|
||||
float getXForT(float t);
|
||||
float getYForPoint(float x);
|
||||
|
||||
private:
|
||||
private:
|
||||
// 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 "../defines.hpp"
|
||||
|
||||
CColor::CColor() { }
|
||||
CColor::CColor() {}
|
||||
|
||||
CColor::CColor(float r, float g, float b, float a) {
|
||||
this->r = r;
|
||||
|
|
|
@ -3,24 +3,24 @@
|
|||
#include "../includes.hpp"
|
||||
|
||||
class CColor {
|
||||
public:
|
||||
public:
|
||||
CColor();
|
||||
CColor(float, float, float, float);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
CColor operator* (const float& v) const {
|
||||
CColor operator*(const float& v) const {
|
||||
return CColor(r * v, g * v, b * v, a * v);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,29 +5,28 @@
|
|||
#include <sys/utsname.h>
|
||||
#include <iomanip>
|
||||
|
||||
#if defined(__DragonFly__) || defined(__FreeBSD__) || \
|
||||
defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
# include <sys/sysctl.h>
|
||||
# if defined(__DragonFly__)
|
||||
# include <sys/kinfo.h> // struct kinfo_proc
|
||||
# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
# include <sys/user.h> // struct kinfo_proc
|
||||
# endif
|
||||
#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#include <sys/sysctl.h>
|
||||
#if defined(__DragonFly__)
|
||||
#include <sys/kinfo.h> // struct kinfo_proc
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#include <sys/user.h> // struct kinfo_proc
|
||||
#endif
|
||||
|
||||
# if defined(__NetBSD__)
|
||||
# undef KERN_PROC
|
||||
# define KERN_PROC KERN_PROC2
|
||||
# define KINFO_PROC struct kinfo_proc2
|
||||
# else
|
||||
# define KINFO_PROC struct kinfo_proc
|
||||
# endif
|
||||
# if defined(__DragonFly__)
|
||||
# define KP_PPID(kp) kp.kp_ppid
|
||||
# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
# define KP_PPID(kp) kp.ki_ppid
|
||||
# else
|
||||
# define KP_PPID(kp) kp.p_ppid
|
||||
# endif
|
||||
#if defined(__NetBSD__)
|
||||
#undef KERN_PROC
|
||||
#define KERN_PROC KERN_PROC2
|
||||
#define KINFO_PROC struct kinfo_proc2
|
||||
#else
|
||||
#define KINFO_PROC struct kinfo_proc
|
||||
#endif
|
||||
#if defined(__DragonFly__)
|
||||
#define KP_PPID(kp) kp.kp_ppid
|
||||
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
#define KP_PPID(kp) kp.ki_ppid
|
||||
#else
|
||||
#define KP_PPID(kp) kp.p_ppid
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static const float transforms[][9] = {{
|
||||
|
@ -87,7 +86,7 @@ std::string absolutePath(const std::string& rawpath, const std::string& currentP
|
|||
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(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());
|
||||
}
|
||||
|
||||
void handleNoop(struct wl_listener *listener, void *data) {
|
||||
void handleNoop(struct wl_listener* listener, void* data) {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
std::string getFormat(const char *fmt, ...) {
|
||||
char* outputStr = nullptr;
|
||||
std::string getFormat(const char* fmt, ...) {
|
||||
char* outputStr = nullptr;
|
||||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
|
@ -116,32 +115,31 @@ std::string getFormat(const char *fmt, ...) {
|
|||
|
||||
std::string escapeJSONStrings(const std::string& str) {
|
||||
std::ostringstream oss;
|
||||
for (auto &c : str) {
|
||||
for (auto& c : str) {
|
||||
switch (c) {
|
||||
case '"': oss << "\\\""; break;
|
||||
case '\\': oss << "\\\\"; break;
|
||||
case '\b': oss << "\\b"; break;
|
||||
case '\f': oss << "\\f"; break;
|
||||
case '\n': oss << "\\n"; break;
|
||||
case '\r': oss << "\\r"; break;
|
||||
case '\t': oss << "\\t"; break;
|
||||
default:
|
||||
if ('\x00' <= c && c <= '\x1f') {
|
||||
oss << "\\u"
|
||||
<< std::hex << std::setw(4) << std::setfill('0') << static_cast<int>(c);
|
||||
} else {
|
||||
oss << c;
|
||||
}
|
||||
case '"': oss << "\\\""; break;
|
||||
case '\\': oss << "\\\\"; break;
|
||||
case '\b': oss << "\\b"; break;
|
||||
case '\f': oss << "\\f"; break;
|
||||
case '\n': oss << "\\n"; break;
|
||||
case '\r': oss << "\\r"; break;
|
||||
case '\t': oss << "\\t"; break;
|
||||
default:
|
||||
if ('\x00' <= c && c <= '\x1f') {
|
||||
oss << "\\u" << std::hex << std::setw(4) << std::setfill('0') << static_cast<int>(c);
|
||||
} else {
|
||||
oss << c;
|
||||
}
|
||||
}
|
||||
}
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
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->x = std::round(box->x * scale);
|
||||
box->y = std::round(box->y * scale);
|
||||
box->x = std::round(box->x * scale);
|
||||
box->y = std::round(box->y * scale);
|
||||
}
|
||||
|
||||
std::string removeBeginEndSpacesTabs(std::string str) {
|
||||
|
@ -166,9 +164,9 @@ std::string removeBeginEndSpacesTabs(std::string str) {
|
|||
float getPlusMinusKeywordResult(std::string source, float relative) {
|
||||
float result = INT_MAX;
|
||||
|
||||
if (source.find_first_of("+") == 0) {
|
||||
if (source[0] == '+') {
|
||||
try {
|
||||
if (source.contains("."))
|
||||
if (source.contains('.'))
|
||||
result = relative + std::stof(source.substr(1));
|
||||
else
|
||||
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());
|
||||
return INT_MAX;
|
||||
}
|
||||
} else if (source.find_first_of("-") == 0) {
|
||||
} else if (source[0] == '-') {
|
||||
try {
|
||||
if (source.contains("."))
|
||||
if (source.contains('.'))
|
||||
result = relative - std::stof(source.substr(1));
|
||||
else
|
||||
result = relative - std::stoi(source.substr(1));
|
||||
|
@ -188,7 +186,7 @@ float getPlusMinusKeywordResult(std::string source, float relative) {
|
|||
}
|
||||
} else {
|
||||
try {
|
||||
if (source.contains("."))
|
||||
if (source.contains('.'))
|
||||
result = stof(source);
|
||||
else
|
||||
result = stoi(source);
|
||||
|
@ -239,7 +237,7 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
|||
const auto NAME = in.substr(8);
|
||||
|
||||
const auto WS = g_pCompositor->getWorkspaceByName("special:" + NAME);
|
||||
|
||||
|
||||
outName = "special:" + NAME;
|
||||
|
||||
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;
|
||||
} else if (in.find("name:") == 0) {
|
||||
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) {
|
||||
result = g_pCompositor->getNextAvailableNamedWorkspace();
|
||||
} else {
|
||||
|
@ -276,8 +274,8 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
|
|||
result = (int)getPlusMinusKeywordResult(in.substr(1), 0);
|
||||
|
||||
// result now has +/- what we should move on mon
|
||||
int remains = (int)result;
|
||||
|
||||
int remains = (int)result;
|
||||
|
||||
std::vector<int> validWSes;
|
||||
for (auto& ws : g_pCompositor->m_vWorkspaces) {
|
||||
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;
|
||||
}
|
||||
|
||||
result = validWSes[currentItem];
|
||||
result = validWSes[currentItem];
|
||||
outName = g_pCompositor->getWorkspaceByID(validWSes[currentItem])->m_szName;
|
||||
|
||||
} else {
|
||||
|
@ -345,8 +343,8 @@ float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Ve
|
|||
|
||||
// Execute a shell command and get the output
|
||||
std::string execAndGet(const char* cmd) {
|
||||
std::array<char, 128> buffer;
|
||||
std::string result;
|
||||
std::array<char, 128> buffer;
|
||||
std::string result;
|
||||
const std::unique_ptr<FILE, decltype(&pclose)> pipe(popen(cmd, "r"), pclose);
|
||||
if (!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);
|
||||
|
||||
const float* t = transforms[tr];
|
||||
float x = 2.0f / w;
|
||||
float y = 2.0f / h;
|
||||
float x = 2.0f / w;
|
||||
float y = 2.0f / h;
|
||||
|
||||
// Rotation + reflection
|
||||
mat[0] = x * t[0];
|
||||
|
@ -411,35 +409,35 @@ int64_t getPPIDof(int64_t pid) {
|
|||
KERN_PROC,
|
||||
KERN_PROC_PID,
|
||||
(int)pid,
|
||||
# if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
#if defined(__NetBSD__) || defined(__OpenBSD__)
|
||||
sizeof(KINFO_PROC),
|
||||
1,
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
u_int miblen = sizeof(mib) / sizeof(mib[0]);
|
||||
u_int miblen = sizeof(mib) / sizeof(mib[0]);
|
||||
KINFO_PROC kp;
|
||||
size_t sz = sizeof(KINFO_PROC);
|
||||
size_t sz = sizeof(KINFO_PROC);
|
||||
if (sysctl(mib, miblen, &kp, &sz, NULL, 0) != -1)
|
||||
return KP_PPID(kp);
|
||||
|
||||
return 0;
|
||||
#else
|
||||
std::string dir = "/proc/" + std::to_string(pid) + "/status";
|
||||
FILE* infile;
|
||||
FILE* infile;
|
||||
|
||||
infile = fopen(dir.c_str(), "r");
|
||||
if (!infile)
|
||||
return 0;
|
||||
|
||||
char* line = nullptr;
|
||||
size_t len = 0;
|
||||
ssize_t len2 = 0;
|
||||
char* line = nullptr;
|
||||
size_t len = 0;
|
||||
ssize_t len2 = 0;
|
||||
|
||||
std::string pidstr;
|
||||
|
||||
while ((len2 = getline(&line, &len, infile)) != -1) {
|
||||
if (strstr(line, "PPid:")) {
|
||||
pidstr = std::string(line, len2);
|
||||
pidstr = std::string(line, len2);
|
||||
const auto tabpos = pidstr.find_last_of('\t');
|
||||
if (tabpos != std::string::npos)
|
||||
pidstr = pidstr.substr(tabpos);
|
||||
|
@ -453,9 +451,7 @@ int64_t getPPIDof(int64_t pid) {
|
|||
|
||||
try {
|
||||
return std::stoll(pidstr);
|
||||
} catch (std::exception& e) {
|
||||
return 0;
|
||||
}
|
||||
} catch (std::exception& e) { return 0; }
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -464,7 +460,7 @@ int64_t configStringToInt(const std::string& VALUE) {
|
|||
// Values with 0x are hex
|
||||
const auto VALUEWITHOUTHEX = VALUE.substr(2);
|
||||
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);
|
||||
|
||||
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.
|
||||
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);
|
||||
|
||||
if (removeBeginEndSpacesTabs(VALUEWITHOUTFUNC).length() != 6) {
|
||||
|
|
|
@ -3,20 +3,20 @@
|
|||
#include "../includes.hpp"
|
||||
|
||||
std::string absolutePath(const std::string&, const std::string&);
|
||||
void addWLSignal(wl_signal*, wl_listener*, void* pOwner, std::string ownerString);
|
||||
std::string getFormat(const char *fmt, ...); // Basically Debug::log to a string
|
||||
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 escapeJSONStrings(const std::string& str);
|
||||
void scaleBox(wlr_box*, float);
|
||||
void scaleBox(wlr_box*, float);
|
||||
std::string removeBeginEndSpacesTabs(std::string);
|
||||
bool isNumber(const std::string&, bool allowfloat = false);
|
||||
bool isDirection(const std::string&);
|
||||
int getWorkspaceIDFromString(const std::string&, std::string&);
|
||||
float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2);
|
||||
void logSystemInfo();
|
||||
bool isNumber(const std::string&, bool allowfloat = false);
|
||||
bool isDirection(const std::string&);
|
||||
int getWorkspaceIDFromString(const std::string&, std::string&);
|
||||
float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2);
|
||||
void logSystemInfo();
|
||||
std::string execAndGet(const char*);
|
||||
int64_t getPPIDof(int64_t pid);
|
||||
int64_t configStringToInt(const std::string&);
|
||||
int64_t getPPIDof(int64_t pid);
|
||||
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) {
|
||||
Debug::log(LOG, "Not configuring non-desktop output");
|
||||
if (g_pCompositor->m_sWRLDRMLeaseMgr) {
|
||||
wlr_drm_lease_v1_manager_offer_output(g_pCompositor->m_sWRLDRMLeaseMgr, output);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (g_pCompositor->m_sWRLDRMLeaseMgr) {
|
||||
wlr_drm_lease_v1_manager_offer_output(g_pCompositor->m_sWRLDRMLeaseMgr, output);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_bRenderingInitPassed) {
|
||||
output->allocator = nullptr;
|
||||
output->renderer = nullptr;
|
||||
output->renderer = nullptr;
|
||||
wlr_output_init_render(output, g_pCompositor->m_sWLRAllocator, g_pCompositor->m_sWLRRenderer);
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ void CMonitor::onConnect(bool noRule) {
|
|||
|
||||
// create it in the arr
|
||||
vecPosition = monitorRule.offset;
|
||||
vecSize = monitorRule.resolution;
|
||||
vecSize = monitorRule.resolution;
|
||||
refreshRate = monitorRule.refreshRate;
|
||||
|
||||
wlr_output_enable(output, 1);
|
||||
|
@ -110,7 +110,8 @@ void CMonitor::onConnect(bool noRule) {
|
|||
|
||||
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);
|
||||
|
||||
|
@ -127,12 +128,12 @@ void CMonitor::onConnect(bool noRule) {
|
|||
|
||||
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});
|
||||
|
||||
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);
|
||||
|
||||
wlr_xcursor_manager_load(g_pCompositor->m_sWLRXCursorMgr, scale);
|
||||
|
@ -189,7 +190,7 @@ void CMonitor::onDisconnect() {
|
|||
g_pConfigManager->m_bWantsMonitorReload = true;
|
||||
}
|
||||
|
||||
m_bEnabled = false;
|
||||
m_bEnabled = false;
|
||||
m_bRenderingInitPassed = false;
|
||||
|
||||
hyprListener_monitorFrame.removeCallback();
|
||||
|
@ -206,7 +207,8 @@ void CMonitor::onDisconnect() {
|
|||
}
|
||||
|
||||
// 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
|
||||
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)
|
||||
continue;
|
||||
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
|
@ -269,10 +271,10 @@ int CMonitor::findAvailableDefaultWS() {
|
|||
void CMonitor::setupDefaultWS(const SMonitorRule& monitorRule) {
|
||||
// Workspace
|
||||
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)) {
|
||||
WORKSPACEID = g_pCompositor->m_vWorkspaces.size() + 1;
|
||||
WORKSPACEID = g_pCompositor->m_vWorkspaces.size() + 1;
|
||||
newDefaultWorkspaceName = std::to_string(WORKSPACEID);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -387,9 +390,7 @@ void CMonitor::setMirror(const std::string& mirrorOf) {
|
|||
pMirrorOf->mirrors.push_back(this);
|
||||
|
||||
// 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()) {
|
||||
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; }));
|
||||
}
|
||||
std::erase_if(g_pCompositor->m_vMonitors, [&](const auto& other) { return other.get() == this; });
|
||||
|
||||
g_pCompositor->setActiveMonitor(g_pCompositor->m_vMonitors.front().get());
|
||||
}
|
||||
|
@ -401,10 +402,10 @@ float CMonitor::getDefaultScale() {
|
|||
|
||||
static constexpr double MMPERINCH = 25.4;
|
||||
|
||||
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 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 PPI = DIAGONALPX / DIAGONALIN;
|
||||
const auto PPI = DIAGONALPX / DIAGONALIN;
|
||||
|
||||
if (PPI > 200 /* High PPI, 2x*/)
|
||||
return 2;
|
||||
|
|
|
@ -10,49 +10,49 @@
|
|||
struct SMonitorRule;
|
||||
|
||||
class CMonitor {
|
||||
public:
|
||||
Vector2D vecPosition = Vector2D(-1,-1); // means unset
|
||||
Vector2D vecSize = Vector2D(0,0);
|
||||
Vector2D vecPixelSize = Vector2D(0,0);
|
||||
Vector2D vecTransformedSize = Vector2D(0,0);
|
||||
public:
|
||||
Vector2D vecPosition = Vector2D(-1, -1); // means unset
|
||||
Vector2D vecSize = Vector2D(0, 0);
|
||||
Vector2D vecPixelSize = Vector2D(0, 0);
|
||||
Vector2D vecTransformedSize = Vector2D(0, 0);
|
||||
|
||||
bool primary = false;
|
||||
bool primary = false;
|
||||
|
||||
uint64_t ID = -1;
|
||||
int activeWorkspace = -1;
|
||||
float scale = 1;
|
||||
|
||||
std::string szName = "";
|
||||
std::string szName = "";
|
||||
|
||||
Vector2D vecReservedTopLeft = Vector2D(0,0);
|
||||
Vector2D vecReservedBottomRight = Vector2D(0,0);
|
||||
Vector2D vecReservedTopLeft = Vector2D(0, 0);
|
||||
Vector2D vecReservedBottomRight = Vector2D(0, 0);
|
||||
|
||||
// WLR stuff
|
||||
wlr_output* output = nullptr;
|
||||
float refreshRate = 60;
|
||||
wlr_output_damage* damage = nullptr;
|
||||
int framesToSkip = 0;
|
||||
int forceFullFrames = 0;
|
||||
bool noFrameSchedule = false;
|
||||
bool scheduledRecalc = false;
|
||||
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
wlr_output* output = nullptr;
|
||||
float refreshRate = 60;
|
||||
wlr_output_damage* damage = nullptr;
|
||||
int framesToSkip = 0;
|
||||
int forceFullFrames = 0;
|
||||
bool noFrameSchedule = false;
|
||||
bool scheduledRecalc = false;
|
||||
wl_output_transform transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
|
||||
bool dpmsStatus = true;
|
||||
bool vrrActive = false; // this can be TRUE even if VRR is not active in the case that this display does not support it.
|
||||
bool enabled10bit = false; // as above, this can be TRUE even if 10 bit failed.
|
||||
bool createdByUser = false;
|
||||
bool dpmsStatus = true;
|
||||
bool vrrActive = false; // this can be TRUE even if VRR is not active in the case that this display does not support it.
|
||||
bool enabled10bit = false; // as above, this can be TRUE even if 10 bit failed.
|
||||
bool createdByUser = false;
|
||||
|
||||
// mirroring
|
||||
CMonitor* pMirrorOf = nullptr;
|
||||
CMonitor* pMirrorOf = nullptr;
|
||||
std::vector<CMonitor*> mirrors;
|
||||
|
||||
// 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
|
||||
// We have to store pointers and use raw new/delete because they might be moved between them
|
||||
// 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(monitorDestroy);
|
||||
|
@ -62,19 +62,18 @@ public:
|
|||
// I don't really care lol :P
|
||||
wlr_ext_workspace_group_handle_v1* pWLRWorkspaceGroupHandle = nullptr;
|
||||
|
||||
|
||||
// methods
|
||||
void onConnect(bool noRule);
|
||||
void onDisconnect();
|
||||
void addDamage(pixman_region32_t* rg);
|
||||
void addDamage(wlr_box* box);
|
||||
void setMirror(const std::string&);
|
||||
bool isMirror();
|
||||
float getDefaultScale();
|
||||
void onConnect(bool noRule);
|
||||
void onDisconnect();
|
||||
void addDamage(pixman_region32_t* rg);
|
||||
void addDamage(wlr_box* box);
|
||||
void setMirror(const std::string&);
|
||||
bool isMirror();
|
||||
float getDefaultScale();
|
||||
|
||||
std::shared_ptr<CMonitor>* m_pThisWrap = nullptr;
|
||||
bool m_bEnabled = false;
|
||||
bool m_bRenderingInitPassed = false;
|
||||
std::shared_ptr<CMonitor>* m_pThisWrap = nullptr;
|
||||
bool m_bEnabled = false;
|
||||
bool m_bRenderingInitPassed = false;
|
||||
|
||||
// For the list lookup
|
||||
|
||||
|
@ -82,7 +81,7 @@ public:
|
|||
return vecPosition == rhs.vecPosition && vecSize == rhs.vecSize && szName == rhs.szName;
|
||||
}
|
||||
|
||||
private:
|
||||
void setupDefaultWS(const SMonitorRule&);
|
||||
int findAvailableDefaultWS();
|
||||
private:
|
||||
void setupDefaultWS(const SMonitorRule&);
|
||||
int findAvailableDefaultWS();
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@ void addSurfaceGlobalOffset(SSurfaceTreeNode* node, int* lx, int* ly) {
|
|||
SSurfaceTreeNode* createTree(wlr_surface* pSurface, CWindow* pWindow) {
|
||||
const auto PNODE = &SubsurfaceTree::surfaceTreeNodes.emplace_back();
|
||||
|
||||
PNODE->pSurface = pSurface;
|
||||
PNODE->pSurface = pSurface;
|
||||
PNODE->pWindowOwner = pWindow;
|
||||
|
||||
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) {
|
||||
const auto PNODE = createTree(surface, pWindow);
|
||||
PNODE->pParent = pParent;
|
||||
const auto PNODE = createTree(surface, pWindow);
|
||||
PNODE->pParent = pParent;
|
||||
PNODE->pSubsurface = pSubsurface;
|
||||
|
||||
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);
|
||||
|
||||
PNODE->offsetfn = fn;
|
||||
PNODE->offsetfn = fn;
|
||||
PNODE->globalOffsetData = data;
|
||||
|
||||
return PNODE;
|
||||
|
@ -74,8 +74,8 @@ void SubsurfaceTree::destroySurfaceTree(SSurfaceTreeNode* pNode) {
|
|||
}
|
||||
|
||||
if (!exists) {
|
||||
Debug::log(ERR, "Tried to remove a SurfaceTreeNode that doesn't exist?? (Node %x)", pNode);
|
||||
return;
|
||||
Debug::log(ERR, "Tried to remove a SurfaceTreeNode that doesn't exist?? (Node %x)", pNode);
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto& c : pNode->childSubsurfaces)
|
||||
|
@ -132,14 +132,14 @@ void destroySubsurface(SSubsurface* pSubsurface) {
|
|||
void Events::listener_newSubsurfaceNode(void* owner, void* data) {
|
||||
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);
|
||||
|
||||
PNEWSUBSURFACE->pSubsurface = PSUBSURFACE;
|
||||
PNEWSUBSURFACE->pParent = pNode;
|
||||
PNEWSUBSURFACE->pParent = pNode;
|
||||
|
||||
PNEWSUBSURFACE->hyprListener_map.initCallback(&PSUBSURFACE->events.map, &Events::listener_mapSubsurface, 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) {
|
||||
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()) {
|
||||
int lx = 0, ly = 0;
|
||||
|
@ -186,7 +187,7 @@ void Events::listener_unmapSubsurface(void* owner, void* data) {
|
|||
|
||||
wlr_box extents = {lx, ly, 0, 0};
|
||||
if (PNODE->pSurface) {
|
||||
extents.width = PNODE->pSurface->current.width;
|
||||
extents.width = PNODE->pSurface->current.width;
|
||||
extents.height = PNODE->pSurface->current.height;
|
||||
|
||||
g_pHyprRenderer->damageBox(&extents);
|
||||
|
@ -203,7 +204,7 @@ void Events::listener_commitSubsurface(void* owner, void* data) {
|
|||
|
||||
// no damaging if it's not visible
|
||||
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)
|
||||
Debug::log(LOG, "Refusing to commit damage from %x because it's invisible.", pNode->pWindowOwner);
|
||||
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)
|
||||
// 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.
|
||||
if (pNode->pParent) for (auto& cs : pNode->pParent->childSubsurfaces) {
|
||||
const auto NODECOORDS = pNode->pSubsurface ? Vector2D(pNode->pSubsurface->pSubsurface->current.x, pNode->pSubsurface->pSubsurface->current.y) : Vector2D();
|
||||
if (pNode->pParent)
|
||||
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) {
|
||||
g_pHyprRenderer->damageSurface(cs.pSubsurface->surface, lx - NODECOORDS.x + cs.pSubsurface->current.x, ly - NODECOORDS.y + cs.pSubsurface->current.y);
|
||||
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(pNode->pSurface, lx, ly);
|
||||
}
|
||||
|
|
|
@ -6,49 +6,49 @@
|
|||
struct SSubsurface;
|
||||
class CWindow;
|
||||
|
||||
typedef void (*applyGlobalOffsetFn)(void *, int *, int *);
|
||||
typedef void (*applyGlobalOffsetFn)(void*, int*, int*);
|
||||
|
||||
struct SSurfaceTreeNode {
|
||||
wlr_surface* pSurface = nullptr;
|
||||
wlr_surface* pSurface = nullptr;
|
||||
|
||||
DYNLISTENER(newSubsurface);
|
||||
DYNLISTENER(commit);
|
||||
DYNLISTENER(destroy);
|
||||
|
||||
SSurfaceTreeNode* pParent = nullptr;
|
||||
SSubsurface* pSubsurface = nullptr;
|
||||
SSurfaceTreeNode* pParent = nullptr;
|
||||
SSubsurface* pSubsurface = nullptr;
|
||||
|
||||
std::list<SSubsurface> childSubsurfaces;
|
||||
|
||||
applyGlobalOffsetFn offsetfn;
|
||||
void *globalOffsetData;
|
||||
CWindow* pWindowOwner = nullptr;
|
||||
applyGlobalOffsetFn offsetfn;
|
||||
void* globalOffsetData;
|
||||
CWindow* pWindowOwner = nullptr;
|
||||
|
||||
bool operator==(const SSurfaceTreeNode& rhs) {
|
||||
bool operator==(const SSurfaceTreeNode& rhs) {
|
||||
return pSurface == rhs.pSurface;
|
||||
}
|
||||
};
|
||||
|
||||
struct SSubsurface {
|
||||
wlr_subsurface* pSubsurface = nullptr;
|
||||
wlr_subsurface* pSubsurface = nullptr;
|
||||
|
||||
SSurfaceTreeNode* pParent = nullptr;
|
||||
SSurfaceTreeNode* pChild = nullptr;
|
||||
SSurfaceTreeNode* pParent = nullptr;
|
||||
SSurfaceTreeNode* pChild = nullptr;
|
||||
|
||||
DYNLISTENER(map);
|
||||
DYNLISTENER(unmap);
|
||||
DYNLISTENER(destroy);
|
||||
|
||||
CWindow* pWindowOwner = nullptr;
|
||||
CWindow* pWindowOwner = nullptr;
|
||||
|
||||
bool operator==(const SSubsurface& rhs) {
|
||||
bool operator==(const SSubsurface& rhs) {
|
||||
return pSubsurface == rhs.pSubsurface;
|
||||
}
|
||||
};
|
||||
|
||||
namespace SubsurfaceTree {
|
||||
SSurfaceTreeNode* createTreeRoot(wlr_surface*, applyGlobalOffsetFn, void*, CWindow* pWindow = nullptr);
|
||||
void destroySurfaceTree(SSurfaceTreeNode*);
|
||||
SSurfaceTreeNode* createTreeRoot(wlr_surface*, applyGlobalOffsetFn, void*, CWindow* pWindow = nullptr);
|
||||
void destroySurfaceTree(SSurfaceTreeNode*);
|
||||
|
||||
inline std::list<SSurfaceTreeNode> surfaceTreeNodes;
|
||||
};
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
#include "../defines.hpp"
|
||||
|
||||
class CTimer {
|
||||
public:
|
||||
void reset();
|
||||
float getSeconds();
|
||||
int getMillis();
|
||||
public:
|
||||
void reset();
|
||||
float getSeconds();
|
||||
int getMillis();
|
||||
|
||||
private:
|
||||
private:
|
||||
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;
|
||||
}
|
||||
|
||||
Vector2D::Vector2D() { x = 0; y = 0; }
|
||||
Vector2D::Vector2D() {
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
|
||||
Vector2D::~Vector2D() {}
|
||||
|
||||
double Vector2D::normalize() {
|
||||
|
@ -24,8 +28,5 @@ Vector2D Vector2D::floor() {
|
|||
}
|
||||
|
||||
Vector2D Vector2D::clamp(const Vector2D& min, const Vector2D& max) {
|
||||
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)
|
||||
);
|
||||
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));
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
#include <math.h>
|
||||
|
||||
class Vector2D {
|
||||
public:
|
||||
public:
|
||||
Vector2D(double, double);
|
||||
Vector2D();
|
||||
~Vector2D();
|
||||
|
@ -12,18 +12,18 @@ class Vector2D {
|
|||
double y = 0;
|
||||
|
||||
// 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);
|
||||
}
|
||||
Vector2D operator-(const Vector2D a) const {
|
||||
Vector2D operator-(const Vector2D& a) const {
|
||||
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);
|
||||
}
|
||||
Vector2D operator/(const float a) const {
|
||||
Vector2D operator/(const float& a) const {
|
||||
return Vector2D(this->x / a, this->y / a);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
struct SLayerSurface {
|
||||
SLayerSurface();
|
||||
|
||||
wlr_layer_surface_v1* layerSurface;
|
||||
wl_list link;
|
||||
wlr_layer_surface_v1* layerSurface;
|
||||
wl_list link;
|
||||
|
||||
DYNLISTENER(destroyLayerSurface);
|
||||
DYNLISTENER(mapLayerSurface);
|
||||
|
@ -19,22 +19,22 @@ struct SLayerSurface {
|
|||
DYNLISTENER(commitLayerSurface);
|
||||
DYNLISTENER(newPopup);
|
||||
|
||||
wlr_box geometry = {0,0,0,0};
|
||||
Vector2D position;
|
||||
wlr_box geometry = {0, 0, 0, 0};
|
||||
Vector2D position;
|
||||
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;
|
||||
bool fadingOut = false;
|
||||
bool readyToDelete = false;
|
||||
bool noProcess = false;
|
||||
CAnimatedVariable alpha;
|
||||
bool fadingOut = false;
|
||||
bool readyToDelete = false;
|
||||
bool noProcess = false;
|
||||
|
||||
bool forceBlur = false;
|
||||
bool forceBlur = false;
|
||||
|
||||
// For the list lookup
|
||||
bool operator==(const SLayerSurface& rhs) {
|
||||
|
@ -44,14 +44,14 @@ struct SLayerSurface {
|
|||
|
||||
struct SRenderData {
|
||||
wlr_output* output;
|
||||
timespec* when;
|
||||
int x, y;
|
||||
timespec* when;
|
||||
int x, y;
|
||||
|
||||
// for iters
|
||||
void* data = nullptr;
|
||||
void* data = nullptr;
|
||||
wlr_surface* surface = nullptr;
|
||||
int w, h;
|
||||
void* pMonitor = nullptr;
|
||||
int w, h;
|
||||
void* pMonitor = nullptr;
|
||||
|
||||
// for rounding
|
||||
bool dontRound = true;
|
||||
|
@ -69,7 +69,7 @@ struct SRenderData {
|
|||
int rounding = -1; // -1 means not set
|
||||
|
||||
// for blurring
|
||||
bool blur = false;
|
||||
bool blur = false;
|
||||
bool blockBlurOptimization = false;
|
||||
|
||||
// only for windows, not popups
|
||||
|
@ -80,17 +80,17 @@ struct SRenderData {
|
|||
};
|
||||
|
||||
struct SExtensionFindingData {
|
||||
Vector2D origin;
|
||||
Vector2D vec;
|
||||
Vector2D origin;
|
||||
Vector2D vec;
|
||||
wlr_surface** found;
|
||||
};
|
||||
|
||||
struct SStringRuleNames {
|
||||
std::string layout = "";
|
||||
std::string model = "";
|
||||
std::string layout = "";
|
||||
std::string model = "";
|
||||
std::string variant = "";
|
||||
std::string options = "";
|
||||
std::string rules = "";
|
||||
std::string rules = "";
|
||||
};
|
||||
|
||||
struct SKeyboard {
|
||||
|
@ -101,18 +101,18 @@ struct SKeyboard {
|
|||
DYNLISTENER(keyboardKeymap);
|
||||
DYNLISTENER(keyboardDestroy);
|
||||
|
||||
bool isVirtual = false;
|
||||
bool active = false;
|
||||
bool isVirtual = false;
|
||||
bool active = false;
|
||||
|
||||
xkb_layout_index_t activeLayout = 0;
|
||||
|
||||
std::string name = "";
|
||||
std::string xkbFilePath = "";
|
||||
std::string name = "";
|
||||
std::string xkbFilePath = "";
|
||||
|
||||
SStringRuleNames currentRules;
|
||||
int repeatRate = 0;
|
||||
int repeatDelay = 0;
|
||||
int numlockOn = -1;
|
||||
SStringRuleNames currentRules;
|
||||
int repeatRate = 0;
|
||||
int repeatDelay = 0;
|
||||
int numlockOn = -1;
|
||||
|
||||
// For the list lookup
|
||||
bool operator==(const SKeyboard& rhs) {
|
||||
|
@ -121,18 +121,18 @@ struct SKeyboard {
|
|||
};
|
||||
|
||||
struct SMouse {
|
||||
wlr_input_device* mouse = nullptr;
|
||||
wlr_input_device* mouse = 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(destroyMouse);
|
||||
|
@ -143,11 +143,11 @@ struct SMouse {
|
|||
};
|
||||
|
||||
struct SConstraint {
|
||||
SMouse* pMouse = nullptr;
|
||||
SMouse* pMouse = nullptr;
|
||||
wlr_pointer_constraint_v1* constraint = nullptr;
|
||||
|
||||
bool hintSet = false;
|
||||
Vector2D positionHint; // the position hint, but will be set to the current cursor pos if not set.
|
||||
bool hintSet = false;
|
||||
Vector2D positionHint; // the position hint, but will be set to the current cursor pos if not set.
|
||||
|
||||
DYNLISTENER(setConstraintRegion);
|
||||
DYNLISTENER(destroyConstraint);
|
||||
|
@ -160,10 +160,10 @@ struct SConstraint {
|
|||
class CMonitor;
|
||||
|
||||
struct SXDGPopup {
|
||||
CWindow* parentWindow = nullptr;
|
||||
SXDGPopup* parentPopup = nullptr;
|
||||
wlr_xdg_popup* popup = nullptr;
|
||||
CMonitor* monitor = nullptr;
|
||||
CWindow* parentWindow = nullptr;
|
||||
SXDGPopup* parentPopup = nullptr;
|
||||
wlr_xdg_popup* popup = nullptr;
|
||||
CMonitor* monitor = nullptr;
|
||||
|
||||
DYNLISTENER(newPopupFromPopupXDG);
|
||||
DYNLISTENER(destroyPopupXDG);
|
||||
|
@ -171,8 +171,8 @@ struct SXDGPopup {
|
|||
DYNLISTENER(unmapPopupXDG);
|
||||
DYNLISTENER(commitPopupXDG);
|
||||
|
||||
double lx;
|
||||
double ly;
|
||||
double lx;
|
||||
double ly;
|
||||
|
||||
SSurfaceTreeNode* pSurfaceTree = nullptr;
|
||||
|
||||
|
@ -183,24 +183,24 @@ struct SXDGPopup {
|
|||
};
|
||||
|
||||
struct SSeat {
|
||||
wlr_seat* seat = nullptr;
|
||||
wl_client* exclusiveClient = nullptr;
|
||||
wlr_seat* seat = nullptr;
|
||||
wl_client* exclusiveClient = nullptr;
|
||||
|
||||
SMouse* mouse = nullptr;
|
||||
SMouse* mouse = nullptr;
|
||||
};
|
||||
|
||||
struct SDrag {
|
||||
wlr_drag* drag = nullptr;
|
||||
wlr_drag* drag = nullptr;
|
||||
|
||||
DYNLISTENER(destroy);
|
||||
|
||||
// Icon
|
||||
|
||||
bool iconMapped = false;
|
||||
bool iconMapped = false;
|
||||
|
||||
wlr_drag_icon* dragIcon = nullptr;
|
||||
wlr_drag_icon* dragIcon = nullptr;
|
||||
|
||||
Vector2D pos;
|
||||
Vector2D pos;
|
||||
|
||||
DYNLISTENER(destroyIcon);
|
||||
DYNLISTENER(mapIcon);
|
||||
|
@ -215,31 +215,31 @@ struct STablet {
|
|||
DYNLISTENER(Proximity);
|
||||
DYNLISTENER(Destroy);
|
||||
|
||||
wlr_tablet* wlrTablet = nullptr;
|
||||
wlr_tablet* wlrTablet = 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;
|
||||
}
|
||||
};
|
||||
|
||||
struct STabletTool {
|
||||
wlr_tablet_tool* wlrTabletTool = nullptr;
|
||||
wlr_tablet_tool* wlrTabletTool = 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 tiltY = 0;
|
||||
double tiltX = 0;
|
||||
double tiltY = 0;
|
||||
|
||||
bool active = true;
|
||||
bool active = true;
|
||||
|
||||
std::string name = "";
|
||||
std::string name = "";
|
||||
|
||||
DYNLISTENER(TabletToolDestroy);
|
||||
DYNLISTENER(TabletToolSetCursor);
|
||||
|
@ -251,9 +251,9 @@ struct STabletTool {
|
|||
|
||||
struct STabletPad {
|
||||
wlr_tablet_v2_tablet_pad* wlrTabletPadV2 = nullptr;
|
||||
STablet* pTabletParent = nullptr;
|
||||
STablet* pTabletParent = nullptr;
|
||||
|
||||
std::string name = "";
|
||||
std::string name = "";
|
||||
|
||||
DYNLISTENER(Attach);
|
||||
DYNLISTENER(Button);
|
||||
|
@ -268,7 +268,7 @@ struct STabletPad {
|
|||
|
||||
struct SIdleInhibitor {
|
||||
wlr_idle_inhibitor_v1* pWlrInhibitor = nullptr;
|
||||
CWindow* pWindow = nullptr;
|
||||
CWindow* pWindow = nullptr;
|
||||
|
||||
DYNLISTENER(Destroy);
|
||||
|
||||
|
@ -278,20 +278,20 @@ struct SIdleInhibitor {
|
|||
};
|
||||
|
||||
struct SSwipeGesture {
|
||||
CWorkspace* pWorkspaceBegin = nullptr;
|
||||
CWorkspace* pWorkspaceBegin = nullptr;
|
||||
|
||||
double delta = 0;
|
||||
double delta = 0;
|
||||
|
||||
float avgSpeed = 0;
|
||||
int speedPoints = 0;
|
||||
float avgSpeed = 0;
|
||||
int speedPoints = 0;
|
||||
|
||||
CMonitor* pMonitor = nullptr;
|
||||
CMonitor* pMonitor = nullptr;
|
||||
};
|
||||
|
||||
struct STextInput {
|
||||
wlr_text_input_v3* pWlrInput = nullptr;
|
||||
|
||||
wlr_surface* pPendingSurface = nullptr;
|
||||
wlr_surface* pPendingSurface = nullptr;
|
||||
|
||||
DYNLISTENER(textInputEnable);
|
||||
DYNLISTENER(textInputDisable);
|
||||
|
@ -304,7 +304,7 @@ struct STextInput {
|
|||
struct SIMEKbGrab {
|
||||
wlr_input_method_keyboard_grab_v2* pWlrKbGrab = nullptr;
|
||||
|
||||
wlr_keyboard* pKeyboard = nullptr;
|
||||
wlr_keyboard* pKeyboard = nullptr;
|
||||
|
||||
DYNLISTENER(grabDestroy);
|
||||
};
|
||||
|
@ -312,10 +312,10 @@ struct SIMEKbGrab {
|
|||
struct SIMEPopup {
|
||||
wlr_input_popup_surface_v2* pSurface = nullptr;
|
||||
|
||||
int x, y;
|
||||
int realX, realY;
|
||||
bool visible;
|
||||
Vector2D lastSize;
|
||||
int x, y;
|
||||
int realX, realY;
|
||||
bool visible;
|
||||
Vector2D lastSize;
|
||||
|
||||
DYNLISTENER(mapPopup);
|
||||
DYNLISTENER(unmapPopup);
|
||||
|
@ -332,9 +332,9 @@ struct SIMEPopup {
|
|||
struct STouchDevice {
|
||||
wlr_input_device* pWlrDevice = nullptr;
|
||||
|
||||
std::string name = "";
|
||||
std::string name = "";
|
||||
|
||||
std::string boundOutput = "";
|
||||
std::string boundOutput = "";
|
||||
|
||||
DYNLISTENER(destroy);
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ CHyprWLListener::CHyprWLListener(wl_signal* pSignal, std::function<void(void*, v
|
|||
}
|
||||
|
||||
CHyprWLListener::CHyprWLListener() {
|
||||
m_swWrapper.m_pSelf = this;
|
||||
m_swWrapper.m_pSelf = this;
|
||||
m_swWrapper.m_sListener.notify = &handleWrapped;
|
||||
wl_list_init(&m_swWrapper.m_sListener.link);
|
||||
}
|
||||
|
@ -41,9 +41,9 @@ void CHyprWLListener::initCallback(wl_signal* pSignal, std::function<void(void*,
|
|||
return;
|
||||
}
|
||||
|
||||
m_pOwner = pOwner;
|
||||
m_pOwner = pOwner;
|
||||
m_pCallback = callback;
|
||||
m_szAuthor = author;
|
||||
m_szAuthor = author;
|
||||
|
||||
addWLSignal(pSignal, &m_swWrapper.m_sListener, pOwner, m_szAuthor);
|
||||
}
|
||||
|
|
|
@ -4,35 +4,35 @@
|
|||
#include <functional>
|
||||
|
||||
class CHyprWLListener {
|
||||
public:
|
||||
public:
|
||||
CHyprWLListener(wl_signal*, std::function<void(void*, void*)>, void* owner);
|
||||
CHyprWLListener();
|
||||
~CHyprWLListener();
|
||||
|
||||
CHyprWLListener(const CHyprWLListener&) = delete;
|
||||
CHyprWLListener(CHyprWLListener&&) = delete;
|
||||
CHyprWLListener(CHyprWLListener&&) = delete;
|
||||
CHyprWLListener& operator=(const 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 {
|
||||
wl_listener m_sListener;
|
||||
wl_listener m_sListener;
|
||||
CHyprWLListener* m_pSelf;
|
||||
};
|
||||
|
||||
void emit(void*);
|
||||
|
||||
private:
|
||||
SWrapper m_swWrapper;
|
||||
private:
|
||||
SWrapper m_swWrapper;
|
||||
|
||||
void* m_pOwner = nullptr;
|
||||
void* m_pOwner = 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;
|
||||
}
|
||||
|
||||
m_iMonitorID = monitorID;
|
||||
m_szName = name;
|
||||
m_iMonitorID = monitorID;
|
||||
m_szName = name;
|
||||
m_bIsSpecialWorkspace = special;
|
||||
|
||||
if (!special) {
|
||||
|
@ -26,9 +26,11 @@ CWorkspace::CWorkspace(int monitorID, std::string name, bool special) {
|
|||
}
|
||||
|
||||
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.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_vRenderOffset.registerVar();
|
||||
|
@ -68,7 +70,7 @@ void CWorkspace::startAnim(bool in, bool left, bool instant) {
|
|||
// fallback is slide
|
||||
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) {
|
||||
m_vRenderOffset.setValueAndWarp(Vector2D(0, left ? PMONITOR->vecSize.y : -PMONITOR->vecSize.y));
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#include "../defines.hpp"
|
||||
#include "AnimatedVariable.hpp"
|
||||
|
||||
enum eFullscreenMode : uint8_t {
|
||||
enum eFullscreenMode : uint8_t
|
||||
{
|
||||
FULLSCREEN_FULL = 0,
|
||||
FULLSCREEN_MAXIMIZED
|
||||
};
|
||||
|
@ -11,24 +12,24 @@ enum eFullscreenMode : uint8_t {
|
|||
class CWindow;
|
||||
|
||||
class CWorkspace {
|
||||
public:
|
||||
public:
|
||||
CWorkspace(int monitorID, std::string name, bool special = false);
|
||||
~CWorkspace();
|
||||
|
||||
// Workspaces ID-based have IDs > 0
|
||||
// and workspaces name-based have IDs starting with -1337
|
||||
int m_iID = -1;
|
||||
std::string m_szName = "";
|
||||
uint64_t m_iMonitorID = -1;
|
||||
int m_iID = -1;
|
||||
std::string m_szName = "";
|
||||
uint64_t m_iMonitorID = -1;
|
||||
// Previous workspace ID is stored during a workspace change, allowing travel
|
||||
// to the previous workspace.
|
||||
int m_iPrevWorkspaceID = -1;
|
||||
bool m_bHasFullscreenWindow = false;
|
||||
eFullscreenMode m_efFullscreenMode = FULLSCREEN_FULL;
|
||||
int m_iPrevWorkspaceID = -1;
|
||||
bool m_bHasFullscreenWindow = false;
|
||||
eFullscreenMode m_efFullscreenMode = FULLSCREEN_FULL;
|
||||
|
||||
wlr_ext_workspace_handle_v1* m_pWlrHandle = nullptr;
|
||||
|
||||
wl_array m_wlrCoordinateArr;
|
||||
wl_array m_wlrCoordinateArr;
|
||||
|
||||
// for animations
|
||||
CAnimatedVariable m_vRenderOffset;
|
||||
|
@ -36,19 +37,19 @@ public:
|
|||
bool m_bForceRendering = false;
|
||||
|
||||
// "scratchpad"
|
||||
bool m_bIsSpecialWorkspace = false;
|
||||
bool m_bIsSpecialWorkspace = false;
|
||||
|
||||
// last window
|
||||
CWindow* m_pLastFocusedWindow = nullptr;
|
||||
CWindow* m_pLastFocusedWindow = nullptr;
|
||||
|
||||
// user-set
|
||||
bool m_bDefaultFloating = false;
|
||||
bool m_bDefaultPseudo = false;
|
||||
bool m_bDefaultFloating = false;
|
||||
bool m_bDefaultPseudo = false;
|
||||
|
||||
void startAnim(bool in, bool left, bool instant = false);
|
||||
void setActive(bool on);
|
||||
void startAnim(bool in, bool left, bool instant = false);
|
||||
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;
|
||||
typedef unsigned int xcb_window_t;
|
||||
|
||||
typedef enum xcb_stack_mode_t {
|
||||
XCB_STACK_MODE_ABOVE = 0,
|
||||
XCB_STACK_MODE_BELOW = 1,
|
||||
XCB_STACK_MODE_TOP_IF = 2,
|
||||
typedef enum xcb_stack_mode_t
|
||||
{
|
||||
XCB_STACK_MODE_ABOVE = 0,
|
||||
XCB_STACK_MODE_BELOW = 1,
|
||||
XCB_STACK_MODE_TOP_IF = 2,
|
||||
XCB_STACK_MODE_BOTTOM_IF = 3,
|
||||
XCB_STACK_MODE_OPPOSITE = 4
|
||||
XCB_STACK_MODE_OPPOSITE = 4
|
||||
} xcb_stack_mode_t;
|
||||
|
||||
struct wlr_xwayland {
|
||||
struct wlr_xwayland_server *server;
|
||||
struct wlr_xwm *xwm;
|
||||
struct wlr_xwayland_cursor *cursor;
|
||||
struct wlr_xwayland_server* server;
|
||||
struct wlr_xwm* xwm;
|
||||
struct wlr_xwayland_cursor* cursor;
|
||||
|
||||
const char *display_name;
|
||||
const char* display_name;
|
||||
|
||||
struct wl_display *wl_display;
|
||||
struct wlr_compositor *compositor;
|
||||
struct wlr_seat *seat;
|
||||
struct wl_display* wl_display;
|
||||
struct wlr_compositor* compositor;
|
||||
struct wlr_seat* seat;
|
||||
|
||||
void *data;
|
||||
void* data;
|
||||
};
|
||||
|
||||
struct wlr_xwayland_surface {
|
||||
xcb_window_t window_id;
|
||||
struct wlr_xwm *xwm;
|
||||
uint32_t surface_id;
|
||||
xcb_window_t window_id;
|
||||
struct wlr_xwm* xwm;
|
||||
uint32_t surface_id;
|
||||
|
||||
struct wl_list link;
|
||||
struct wl_list stack_link;
|
||||
struct wl_list unpaired_link;
|
||||
struct wl_list link;
|
||||
struct wl_list stack_link;
|
||||
struct wl_list unpaired_link;
|
||||
|
||||
struct wlr_surface *surface;
|
||||
int16_t x, y;
|
||||
uint16_t width, height;
|
||||
uint16_t saved_width, saved_height;
|
||||
bool override_redirect;
|
||||
bool mapped;
|
||||
struct wlr_surface* surface;
|
||||
int16_t x, y;
|
||||
uint16_t width, height;
|
||||
uint16_t saved_width, saved_height;
|
||||
bool override_redirect;
|
||||
bool mapped;
|
||||
|
||||
char *title;
|
||||
char *_class;
|
||||
char *instance;
|
||||
char *role;
|
||||
char *startup_id;
|
||||
pid_t pid;
|
||||
bool has_utf8_title;
|
||||
char* title;
|
||||
char* _class;
|
||||
char* instance;
|
||||
char* role;
|
||||
char* startup_id;
|
||||
pid_t pid;
|
||||
bool has_utf8_title;
|
||||
|
||||
struct wl_list children; // wlr_xwayland_surface::parent_link
|
||||
struct wlr_xwayland_surface *parent;
|
||||
struct wl_list parent_link; // wlr_xwayland_surface::children
|
||||
struct wl_list children; // wlr_xwayland_surface::parent_link
|
||||
struct wlr_xwayland_surface* parent;
|
||||
struct wl_list parent_link; // wlr_xwayland_surface::children
|
||||
|
||||
xcb_atom_t *window_type;
|
||||
size_t window_type_len;
|
||||
xcb_atom_t* window_type;
|
||||
size_t window_type_len;
|
||||
|
||||
xcb_atom_t *protocols;
|
||||
size_t protocols_len;
|
||||
xcb_atom_t* protocols;
|
||||
size_t protocols_len;
|
||||
|
||||
uint32_t decorations;
|
||||
xcb_icccm_wm_hints_t *hints;
|
||||
xcb_size_hints_t *size_hints;
|
||||
uint32_t decorations;
|
||||
xcb_icccm_wm_hints_t* hints;
|
||||
xcb_size_hints_t* size_hints;
|
||||
|
||||
bool pinging;
|
||||
struct wl_event_source *ping_timer;
|
||||
bool pinging;
|
||||
struct wl_event_source* ping_timer;
|
||||
|
||||
// _NET_WM_STATE
|
||||
bool modal;
|
||||
|
@ -127,35 +128,41 @@ struct wlr_xwayland_surface {
|
|||
};
|
||||
|
||||
struct wlr_xwayland_surface_configure_event {
|
||||
struct wlr_xwayland_surface *surface;
|
||||
int16_t x, y;
|
||||
uint16_t width, height;
|
||||
uint16_t mask; // xcb_config_window_t
|
||||
struct wlr_xwayland_surface* surface;
|
||||
int16_t x, y;
|
||||
uint16_t width, height;
|
||||
uint16_t mask; // xcb_config_window_t
|
||||
};
|
||||
|
||||
struct wlr_xwayland_minimize_event {
|
||||
struct wlr_xwayland_surface *surface;
|
||||
bool minimize;
|
||||
struct wlr_xwayland_surface* surface;
|
||||
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) {
|
||||
m_szQueued = message;
|
||||
m_cQueued = color;
|
||||
m_cQueued = color;
|
||||
}
|
||||
|
||||
void CHyprError::createQueued() {
|
||||
|
@ -32,9 +32,9 @@ void CHyprError::createQueued() {
|
|||
cairo_rectangle(CAIRO, 0, 0, PMONITOR->vecPixelSize.x, (FONTSIZE + 2 * (FONTSIZE / 10.f)) * LINECOUNT);
|
||||
|
||||
// outline
|
||||
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, 0, PMONITOR->vecPixelSize.y - 1, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y); // bottom
|
||||
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, 0, PMONITOR->vecPixelSize.y - 1, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y); // bottom
|
||||
|
||||
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);
|
||||
|
||||
float yoffset = FONTSIZE;
|
||||
while(m_szQueued != "") {
|
||||
while (m_szQueued != "") {
|
||||
std::string current = m_szQueued.substr(0, m_szQueued.find('\n'));
|
||||
if (const auto NEWLPOS = m_szQueued.find('\n'); NEWLPOS != std::string::npos)
|
||||
m_szQueued = m_szQueued.substr(NEWLPOS + 1);
|
||||
|
@ -57,7 +57,6 @@ void CHyprError::createQueued() {
|
|||
yoffset += FONTSIZE + (FONTSIZE / 10.f);
|
||||
}
|
||||
|
||||
|
||||
cairo_surface_flush(CAIROSURFACE);
|
||||
|
||||
// copy the data to an OpenGL texture we have
|
||||
|
@ -79,8 +78,8 @@ void CHyprError::createQueued() {
|
|||
cairo_surface_destroy(CAIROSURFACE);
|
||||
|
||||
m_bIsCreated = true;
|
||||
m_szQueued = "";
|
||||
m_cQueued = CColor();
|
||||
m_szQueued = "";
|
||||
m_cQueued = CColor();
|
||||
|
||||
g_pHyprRenderer->damageMonitor(PMONITOR);
|
||||
}
|
||||
|
@ -96,7 +95,7 @@ void CHyprError::draw() {
|
|||
m_bQueuedDestroy = false;
|
||||
m_tTexture.destroyTexture();
|
||||
m_bIsCreated = false;
|
||||
m_szQueued = "";
|
||||
m_szQueued = "";
|
||||
g_pHyprRenderer->damageMonitor(g_pCompositor->m_vMonitors.front().get());
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,18 +6,18 @@
|
|||
#include <cairo/cairo.h>
|
||||
|
||||
class CHyprError {
|
||||
public:
|
||||
void queueCreate(std::string message, const CColor& color);
|
||||
void draw();
|
||||
void destroy();
|
||||
public:
|
||||
void queueCreate(std::string message, const CColor& color);
|
||||
void draw();
|
||||
void destroy();
|
||||
|
||||
private:
|
||||
void createQueued();
|
||||
std::string m_szQueued = "";
|
||||
CColor m_cQueued;
|
||||
bool m_bQueuedDestroy = false;
|
||||
bool m_bIsCreated = false;
|
||||
CTexture m_tTexture;
|
||||
private:
|
||||
void createQueued();
|
||||
std::string m_szQueued = "";
|
||||
CColor m_cQueued;
|
||||
bool m_bQueuedDestroy = false;
|
||||
bool m_bIsCreated = false;
|
||||
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.
|
|
@ -4,10 +4,10 @@
|
|||
void SDwindleNodeData::recalcSizePosRecursive(bool force) {
|
||||
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 PFLMULT = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
|
||||
static auto* const PPRESERVESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:preserve_split")->intValue;
|
||||
static auto* const PFLMULT = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
|
||||
|
||||
if (*PPRESERVESPLIT == 0) {
|
||||
splitTop = size.y * *PFLMULT > size.x;
|
||||
|
@ -18,15 +18,15 @@ void SDwindleNodeData::recalcSizePosRecursive(bool force) {
|
|||
if (SPLITSIDE) {
|
||||
// split left/right
|
||||
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]->size = Vector2D(size.x / 2.f * REVERSESPLITRATIO, size.y);
|
||||
children[1]->size = Vector2D(size.x / 2.f * REVERSESPLITRATIO, size.y);
|
||||
} else {
|
||||
// split top/bottom
|
||||
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]->size = Vector2D(size.x, size.y / 2.f * REVERSESPLITRATIO);
|
||||
children[1]->size = Vector2D(size.x, size.y / 2.f * REVERSESPLITRATIO);
|
||||
}
|
||||
|
||||
children[0]->recalcSizePosRecursive(force);
|
||||
|
@ -93,7 +93,7 @@ void SDwindleNodeData::setGroupFocusedNode(SDwindleNodeData* pMember) {
|
|||
int SDwindleNodeData::getGroupMemberCount() {
|
||||
SDwindleNodeData* current = this->pNextGroupMember;
|
||||
|
||||
int no = 1;
|
||||
int no = 1;
|
||||
|
||||
while (current != this) {
|
||||
current = current->pNextGroupMember;
|
||||
|
@ -161,14 +161,14 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
|||
}
|
||||
|
||||
// for gaps outer
|
||||
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 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 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 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 auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||
const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
||||
const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
||||
const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||
const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
||||
const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
||||
|
||||
const auto PWINDOW = pNode->pWindow;
|
||||
|
||||
|
@ -178,40 +178,40 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
|||
return;
|
||||
}
|
||||
|
||||
PWINDOW->m_vSize = pNode->size;
|
||||
PWINDOW->m_vSize = pNode->size;
|
||||
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 calcSize = PWINDOW->m_vSize - Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
||||
auto calcPos = PWINDOW->m_vPosition + Vector2D(*PBORDERSIZE, *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_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
||||
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
||||
|
||||
PWINDOW->updateWindowDecos();
|
||||
|
||||
PWINDOW->m_sSpecialRenderData.rounding = false;
|
||||
PWINDOW->m_sSpecialRenderData.border = false;
|
||||
PWINDOW->m_sSpecialRenderData.border = false;
|
||||
PWINDOW->m_sSpecialRenderData.decorate = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PWINDOW->m_sSpecialRenderData.rounding = true;
|
||||
PWINDOW->m_sSpecialRenderData.border = true;
|
||||
PWINDOW->m_sSpecialRenderData.border = true;
|
||||
PWINDOW->m_sSpecialRenderData.decorate = true;
|
||||
|
||||
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN,
|
||||
DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
|
||||
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN, DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
|
||||
|
||||
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN,
|
||||
DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
|
||||
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN, DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
|
||||
|
||||
calcPos = calcPos + OFFSETTOPLEFT;
|
||||
calcPos = calcPos + OFFSETTOPLEFT;
|
||||
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
|
||||
|
||||
if (PWINDOW->m_bIsPseudotiled) {
|
||||
|
@ -229,25 +229,25 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
|||
}
|
||||
|
||||
auto DELTA = calcSize - PWINDOW->m_vPseudoSize * scale;
|
||||
calcSize = PWINDOW->m_vPseudoSize * scale;
|
||||
calcPos = calcPos + DELTA / 2.f; // center
|
||||
calcSize = PWINDOW->m_vPseudoSize * scale;
|
||||
calcPos = calcPos + DELTA / 2.f; // center
|
||||
} else {
|
||||
auto DELTA = calcSize - PWINDOW->m_vPseudoSize;
|
||||
calcPos = calcPos + DELTA / 2.f; // center
|
||||
calcSize = PWINDOW->m_vPseudoSize;
|
||||
calcPos = calcPos + DELTA / 2.f; // center
|
||||
calcSize = PWINDOW->m_vPseudoSize;
|
||||
}
|
||||
}
|
||||
|
||||
if (g_pCompositor->isWorkspaceSpecial(PWINDOW->m_iWorkspaceID)) {
|
||||
// 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_vRealSize = calcSize * *PSCALEFACTOR;
|
||||
PWINDOW->m_vRealSize = calcSize * *PSCALEFACTOR;
|
||||
|
||||
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize * *PSCALEFACTOR);
|
||||
} else {
|
||||
PWINDOW->m_vRealSize = calcSize;
|
||||
PWINDOW->m_vRealSize = calcSize;
|
||||
PWINDOW->m_vRealPosition = calcPos;
|
||||
|
||||
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize);
|
||||
|
@ -266,7 +266,7 @@ void CHyprDwindleLayout::applyNodeDataToWindow(SDwindleNodeData* pNode, bool for
|
|||
// update visible node
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -278,22 +278,23 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
|||
return;
|
||||
|
||||
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
|
||||
PNODE->workspaceID = pWindow->m_iWorkspaceID;
|
||||
PNODE->pWindow = pWindow;
|
||||
PNODE->isNode = false;
|
||||
PNODE->layout = this;
|
||||
PNODE->pWindow = pWindow;
|
||||
PNODE->isNode = false;
|
||||
PNODE->layout = this;
|
||||
|
||||
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()));
|
||||
|
||||
// happens on reserved area
|
||||
|
@ -301,7 +302,8 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
|||
OPENINGON = getFirstNodeOnWorkspace(PMONITOR->activeWorkspace);
|
||||
|
||||
} 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);
|
||||
} else {
|
||||
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 (!OPENINGON || OPENINGON->pWindow == pWindow) {
|
||||
PNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||
PNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||
PNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||
|
||||
applyNodeDataToWindow(PNODE);
|
||||
|
||||
|
@ -363,15 +365,15 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
|||
const auto PTAIL = PHEAD->pPreviousGroupMember;
|
||||
|
||||
PHEAD->pPreviousGroupMember = PNODE;
|
||||
PTAIL->pNextGroupMember = PNODE;
|
||||
PTAIL->pNextGroupMember = PNODE;
|
||||
|
||||
PNODE->pNextGroupMember = PHEAD;
|
||||
PNODE->pNextGroupMember = PHEAD;
|
||||
PNODE->pPreviousGroupMember = PTAIL;
|
||||
|
||||
PHEAD->setGroupFocusedNode(PNODE);
|
||||
|
||||
PNODE->position = PHEAD->position;
|
||||
PNODE->size = PHEAD->size;
|
||||
PNODE->size = PHEAD->size;
|
||||
|
||||
applyNodeDataToWindow(PNODE);
|
||||
|
||||
|
@ -386,25 +388,29 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
|||
const auto NEWPARENT = &m_lDwindleNodesData.back();
|
||||
|
||||
// make the parent have the OPENINGON's stats
|
||||
NEWPARENT->position = OPENINGON->position;
|
||||
NEWPARENT->size = OPENINGON->size;
|
||||
NEWPARENT->position = OPENINGON->position;
|
||||
NEWPARENT->size = OPENINGON->size;
|
||||
NEWPARENT->workspaceID = OPENINGON->workspaceID;
|
||||
NEWPARENT->pParent = OPENINGON->pParent;
|
||||
NEWPARENT->isNode = true; // it is a node
|
||||
NEWPARENT->pParent = OPENINGON->pParent;
|
||||
NEWPARENT->isNode = true; // it is a node
|
||||
|
||||
const auto PWIDTHMULTIPLIER = &g_pConfigManager->getConfigValuePtr("dwindle:split_width_multiplier")->floatValue;
|
||||
|
||||
// if cursor over first child, make it first, etc
|
||||
const auto SIDEBYSIDE = NEWPARENT->size.x > NEWPARENT->size.y * *PWIDTHMULTIPLIER;
|
||||
NEWPARENT->splitTop = !SIDEBYSIDE;
|
||||
NEWPARENT->splitTop = !SIDEBYSIDE;
|
||||
|
||||
const auto MOUSECOORDS = g_pInputManager->getMouseCoordsInternal();
|
||||
|
||||
const auto PFORCESPLIT = &g_pConfigManager->getConfigValuePtr("dwindle:force_split")->intValue;
|
||||
|
||||
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))
|
||||
|| (!SIDEBYSIDE && VECINRECT(MOUSECOORDS, NEWPARENT->position.x, NEWPARENT->position.y / *PWIDTHMULTIPLIER, NEWPARENT->position.x + NEWPARENT->size.x, NEWPARENT->position.y + NEWPARENT->size.y / 2.f))) {
|
||||
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)) ||
|
||||
(!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.
|
||||
NEWPARENT->children[1] = OPENINGON;
|
||||
NEWPARENT->children[0] = PNODE;
|
||||
|
@ -434,23 +440,22 @@ void CHyprDwindleLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
|||
|
||||
// Update the children
|
||||
|
||||
|
||||
if (NEWPARENT->size.x * *PWIDTHMULTIPLIER > NEWPARENT->size.y) {
|
||||
// split left/right
|
||||
OPENINGON->position = NEWPARENT->position;
|
||||
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->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->size = Vector2D(NEWPARENT->size.x / 2.f, NEWPARENT->size.y);
|
||||
} else {
|
||||
// split top/bottom
|
||||
OPENINGON->position = NEWPARENT->position;
|
||||
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->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->size = Vector2D(NEWPARENT->size.x, NEWPARENT->size.y / 2.f);
|
||||
}
|
||||
|
||||
OPENINGON->pParent = NEWPARENT;
|
||||
PNODE->pParent = NEWPARENT;
|
||||
PNODE->pParent = NEWPARENT;
|
||||
|
||||
NEWPARENT->recalcSizePosRecursive();
|
||||
|
||||
|
@ -468,7 +473,7 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
|||
}
|
||||
|
||||
pWindow->m_sSpecialRenderData.rounding = true;
|
||||
pWindow->m_sSpecialRenderData.border = true;
|
||||
pWindow->m_sSpecialRenderData.border = true;
|
||||
pWindow->m_sSpecialRenderData.decorate = true;
|
||||
|
||||
if (pWindow->m_bIsFullscreen)
|
||||
|
@ -480,12 +485,12 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
|||
const auto PPREV = PNODE->pPreviousGroupMember;
|
||||
const auto PNEXT = PNODE->pNextGroupMember;
|
||||
|
||||
PPREV->pNextGroupMember = PNEXT;
|
||||
PPREV->pNextGroupMember = PNEXT;
|
||||
PNEXT->pPreviousGroupMember = PPREV;
|
||||
|
||||
if (PNODE->groupHead) {
|
||||
PNEXT->groupHead = true;
|
||||
PNEXT->pParent = PNODE->pParent;
|
||||
PNEXT->pParent = PNODE->pParent;
|
||||
|
||||
if (PNODE->pParent) {
|
||||
if (PNODE->pParent->children[0] == PNODE) {
|
||||
|
@ -496,12 +501,12 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
|||
}
|
||||
|
||||
PNEXT->position = PNODE->position;
|
||||
PNEXT->size = PNODE->size;
|
||||
PNEXT->size = PNODE->size;
|
||||
} else {
|
||||
const auto PHEAD = PNODE->getGroupHead();
|
||||
|
||||
PNEXT->position = PHEAD->position;
|
||||
PNEXT->size = PHEAD->size;
|
||||
PNEXT->size = PHEAD->size;
|
||||
}
|
||||
|
||||
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];
|
||||
|
||||
PSIBLING->position = PPARENT->position;
|
||||
PSIBLING->size = PPARENT->size;
|
||||
PSIBLING->pParent = PPARENT->pParent;
|
||||
PSIBLING->size = PPARENT->size;
|
||||
PSIBLING->pParent = PPARENT->pParent;
|
||||
|
||||
if (PSIBLING->isGroupMember()) {
|
||||
// apply to all group members
|
||||
|
@ -539,8 +544,8 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
|||
|
||||
while (current != PSIBLING) {
|
||||
current->position = PPARENT->position;
|
||||
current->size = PPARENT->size;
|
||||
current = current->pNextGroupMember;
|
||||
current->size = PPARENT->size;
|
||||
current = current->pNextGroupMember;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -553,7 +558,7 @@ void CHyprDwindleLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
|||
}
|
||||
|
||||
PPARENT->valid = false;
|
||||
PNODE->valid = false;
|
||||
PNODE->valid = false;
|
||||
|
||||
if (PSIBLING->pParent)
|
||||
PSIBLING->pParent->recalcSizePosRecursive();
|
||||
|
@ -582,7 +587,7 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
|
|||
|
||||
if (TOPNODE && PMONITOR) {
|
||||
TOPNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||
TOPNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||
TOPNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||
TOPNODE->recalcSizePosRecursive();
|
||||
}
|
||||
}
|
||||
|
@ -599,12 +604,12 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
|
|||
PWORKSPACE->m_bHasFullscreenWindow = false;
|
||||
} else {
|
||||
SDwindleNodeData fakeNode;
|
||||
fakeNode.pWindow = PFULLWINDOW;
|
||||
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||
fakeNode.workspaceID = PWORKSPACE->m_iID;
|
||||
fakeNode.pWindow = PFULLWINDOW;
|
||||
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||
fakeNode.workspaceID = PWORKSPACE->m_iID;
|
||||
PFULLWINDOW->m_vPosition = fakeNode.position;
|
||||
PFULLWINDOW->m_vSize = fakeNode.size;
|
||||
PFULLWINDOW->m_vSize = fakeNode.size;
|
||||
|
||||
applyNodeDataToWindow(&fakeNode);
|
||||
|
||||
|
@ -616,7 +621,7 @@ void CHyprDwindleLayout::recalculateMonitor(const int& monid) {
|
|||
|
||||
if (TOPNODE && PMONITOR) {
|
||||
TOPNODE->position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||
TOPNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||
TOPNODE->size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||
TOPNODE->recalcSizePosRecursive();
|
||||
}
|
||||
}
|
||||
|
@ -643,10 +648,10 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
|
|||
const auto PANIMATE = &g_pConfigManager->getConfigValuePtr("misc:animate_manual_resizes")->intValue;
|
||||
|
||||
// get some data about our window
|
||||
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 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 auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||
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 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);
|
||||
|
||||
// construct allowed movement
|
||||
|
@ -661,7 +666,7 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
|
|||
const auto PPARENT = PNODE->pParent;
|
||||
|
||||
if (!PPARENT)
|
||||
return; // the only window on a workspace, ignore
|
||||
return; // the only window on a workspace, ignore
|
||||
|
||||
const bool PARENTSIDEBYSIDE = !PPARENT->splitTop;
|
||||
|
||||
|
@ -704,13 +709,13 @@ void CHyprDwindleLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow*
|
|||
|
||||
// 2 axes of freedom
|
||||
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.y *= 2.f / TOPCONTAINER->size.y;
|
||||
|
||||
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);
|
||||
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))
|
||||
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);
|
||||
|
||||
if (PWORKSPACE->m_bHasFullscreenWindow && on) {
|
||||
|
@ -732,7 +737,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
|
|||
}
|
||||
|
||||
// otherwise, accept it.
|
||||
pWindow->m_bIsFullscreen = on;
|
||||
pWindow->m_bIsFullscreen = on;
|
||||
PWORKSPACE->m_bHasFullscreenWindow = !PWORKSPACE->m_bHasFullscreenWindow;
|
||||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"fullscreen", std::to_string((int)on)});
|
||||
|
@ -745,7 +750,7 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
|
|||
else {
|
||||
// get back its' dimensions from position and size
|
||||
pWindow->m_vRealPosition = pWindow->m_vPosition;
|
||||
pWindow->m_vRealSize = pWindow->m_vSize;
|
||||
pWindow->m_vRealSize = pWindow->m_vSize;
|
||||
}
|
||||
} else {
|
||||
// if it now got fullscreen, make it fullscreen
|
||||
|
@ -755,25 +760,25 @@ void CHyprDwindleLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscree
|
|||
// save position and size if floating
|
||||
if (pWindow->m_bIsFloating) {
|
||||
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
|
||||
if (fullscreenMode == FULLSCREEN_FULL) {
|
||||
pWindow->m_vRealPosition = PMONITOR->vecPosition;
|
||||
pWindow->m_vRealSize = PMONITOR->vecSize;
|
||||
pWindow->m_vRealSize = PMONITOR->vecSize;
|
||||
} else {
|
||||
// This is a massive hack.
|
||||
// We make a fake "only" node and apply
|
||||
// To keep consistent with the settings without C+P code
|
||||
|
||||
SDwindleNodeData fakeNode;
|
||||
fakeNode.pWindow = pWindow;
|
||||
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||
fakeNode.pWindow = pWindow;
|
||||
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||
fakeNode.workspaceID = pWindow->m_iWorkspaceID;
|
||||
pWindow->m_vPosition = fakeNode.position;
|
||||
pWindow->m_vSize = fakeNode.size;
|
||||
pWindow->m_vSize = fakeNode.size;
|
||||
|
||||
applyNodeDataToWindow(&fakeNode);
|
||||
}
|
||||
|
@ -828,7 +833,7 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
|
|||
|
||||
if (PNODE->isGroupMember()) {
|
||||
// dissolve group
|
||||
const auto PHEAD = PNODE->getGroupHead();
|
||||
const auto PHEAD = PNODE->getGroupHead();
|
||||
|
||||
SDwindleNodeData* current = PNODE->pNextGroupMember;
|
||||
|
||||
|
@ -836,26 +841,26 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
|
|||
|
||||
std::deque<CWindow*> toAddWindows;
|
||||
|
||||
const auto PWINDOWNODE = PNODE->pWindow;
|
||||
const auto PWINDOWNODE = PNODE->pWindow;
|
||||
toAddWindows.push_back(PWINDOWNODE);
|
||||
|
||||
while (current != PNODE) {
|
||||
const auto PWINDOW = current->pWindow;
|
||||
current = current->pNextGroupMember;
|
||||
current = current->pNextGroupMember;
|
||||
|
||||
toAddWindows.push_back(PWINDOW);
|
||||
|
||||
PWINDOW->setHidden(false);
|
||||
}
|
||||
|
||||
if (PHEAD->pPreviousGroupMember)
|
||||
PHEAD->pPreviousGroupMember->pNextGroupMember = PHEAD->pNextGroupMember;
|
||||
if (PHEAD->pPreviousGroupMember)
|
||||
PHEAD->pPreviousGroupMember->pNextGroupMember = PHEAD->pNextGroupMember;
|
||||
|
||||
if (PHEAD->pNextGroupMember)
|
||||
PHEAD->pNextGroupMember->pPreviousGroupMember = PHEAD->pPreviousGroupMember;
|
||||
if (PHEAD->pNextGroupMember)
|
||||
PHEAD->pNextGroupMember->pPreviousGroupMember = PHEAD->pPreviousGroupMember;
|
||||
|
||||
PHEAD->pPreviousGroupMember = nullptr;
|
||||
PHEAD->pNextGroupMember = nullptr;
|
||||
PHEAD->pPreviousGroupMember = nullptr;
|
||||
PHEAD->pNextGroupMember = nullptr;
|
||||
|
||||
onWindowRemoved(PHEAD->pWindow);
|
||||
|
||||
|
@ -902,7 +907,7 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
|
|||
}
|
||||
|
||||
PNODE->position = PNODE->pParent->position;
|
||||
PNODE->size = PNODE->pParent->size;
|
||||
PNODE->size = PNODE->pParent->size;
|
||||
|
||||
applyNodeDataToWindow(PNODE);
|
||||
|
||||
|
@ -925,14 +930,14 @@ void CHyprDwindleLayout::toggleWindowGroup(CWindow* pWindow) {
|
|||
for (int i = 0; i < (int)newGroupMembers.size(); ++i) {
|
||||
if (i != 0) {
|
||||
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 NEXTMEMBER = i == (int)newGroupMembers.size() - 1 ? newGroupMembers[0] : newGroupMembers[i + 1];
|
||||
|
||||
newGroupMembers[i]->pPreviousGroupMember = PREVMEMBER;
|
||||
newGroupMembers[i]->pNextGroupMember = NEXTMEMBER;
|
||||
newGroupMembers[i]->pNextGroupMember = NEXTMEMBER;
|
||||
|
||||
// add the deco
|
||||
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);
|
||||
|
||||
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;
|
||||
|
||||
result.push_back(HEAD->pWindow);
|
||||
|
@ -985,7 +990,7 @@ void CHyprDwindleLayout::switchGroupWindow(CWindow* pWindow, bool forward, CWind
|
|||
if (!PNODE || !PNODE->isGroupMember())
|
||||
return; // reject
|
||||
|
||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PNODE->workspaceID);
|
||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(PNODE->workspaceID);
|
||||
|
||||
SDwindleNodeData* pNewNode;
|
||||
|
||||
|
@ -1003,8 +1008,8 @@ void CHyprDwindleLayout::switchGroupWindow(CWindow* pWindow, bool forward, CWind
|
|||
|
||||
PNODE->setGroupFocusedNode(pNewNode);
|
||||
|
||||
pNewNode->position = PNODE->position;
|
||||
pNewNode->size = PNODE->size;
|
||||
pNewNode->position = PNODE->position;
|
||||
pNewNode->size = PNODE->size;
|
||||
pNewNode->workspaceID = PNODE->workspaceID;
|
||||
|
||||
applyNodeDataToWindow(pNewNode);
|
||||
|
@ -1037,10 +1042,10 @@ SWindowRenderLayoutHints CHyprDwindleLayout::requestRenderHints(CWindow* pWindow
|
|||
|
||||
SWindowRenderLayoutHints hints;
|
||||
|
||||
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 PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->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)
|
||||
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) {
|
||||
// windows should be valid, insallah
|
||||
|
||||
auto PNODE = getNodeFromWindow(pWindow);
|
||||
auto PNODE = getNodeFromWindow(pWindow);
|
||||
auto PNODE2 = getNodeFromWindow(pWindow2);
|
||||
|
||||
if (!PNODE2 || !PNODE) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
SDwindleNodeData* ACTIVE1 = nullptr;
|
||||
SDwindleNodeData* ACTIVE2 = nullptr;
|
||||
SDwindleNodeData* ACTIVE2 = nullptr;
|
||||
|
||||
if (PNODE2->isGroupMember() || PNODE->isGroupMember()) {
|
||||
if (PNODE2->isGroupMember() || PNODE->isGroupMember()) {
|
||||
|
||||
if (PNODE->workspaceID != PNODE2->workspaceID) {
|
||||
Debug::log(ERR, "Groups are confined to a monitor");
|
||||
|
@ -1078,82 +1083,82 @@ void CHyprDwindleLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
|||
|
||||
if (PNODE->isGroupMember()) {
|
||||
ACTIVE1 = PNODE;
|
||||
PNODE = PNODE->getGroupHead();
|
||||
}
|
||||
PNODE = PNODE->getGroupHead();
|
||||
}
|
||||
|
||||
if (PNODE2->isGroupMember()) {
|
||||
if (PNODE2->isGroupMember()) {
|
||||
ACTIVE2 = PNODE2;
|
||||
PNODE2 = PNODE2->getGroupHead();
|
||||
}
|
||||
PNODE2 = PNODE2->getGroupHead();
|
||||
}
|
||||
|
||||
if (PNODE2->pParent == PNODE->pParent) {
|
||||
const auto PPARENT = PNODE->pParent;
|
||||
if (PNODE2->pParent == PNODE->pParent) {
|
||||
const auto PPARENT = PNODE->pParent;
|
||||
|
||||
if (PPARENT->children[0] == PNODE) {
|
||||
PPARENT->children[0] = PNODE2;
|
||||
PPARENT->children[1] = PNODE;
|
||||
} else {
|
||||
PPARENT->children[0] = PNODE;
|
||||
PPARENT->children[1] = PNODE2;
|
||||
}
|
||||
} else {
|
||||
if (PNODE->pParent) {
|
||||
const auto PPARENT = PNODE->pParent;
|
||||
if (PPARENT->children[0] == PNODE) {
|
||||
PPARENT->children[0] = PNODE2;
|
||||
PPARENT->children[1] = PNODE;
|
||||
} else {
|
||||
PPARENT->children[0] = PNODE;
|
||||
PPARENT->children[1] = PNODE2;
|
||||
}
|
||||
} else {
|
||||
if (PNODE->pParent) {
|
||||
const auto PPARENT = PNODE->pParent;
|
||||
|
||||
if (PPARENT->children[0] == PNODE) {
|
||||
PPARENT->children[0] = PNODE2;
|
||||
} else {
|
||||
PPARENT->children[1] = PNODE2;
|
||||
}
|
||||
}
|
||||
if (PPARENT->children[0] == PNODE) {
|
||||
PPARENT->children[0] = PNODE2;
|
||||
} else {
|
||||
PPARENT->children[1] = PNODE2;
|
||||
}
|
||||
}
|
||||
|
||||
if (PNODE2->pParent) {
|
||||
const auto PPARENT = PNODE2->pParent;
|
||||
if (PNODE2->pParent) {
|
||||
const auto PPARENT = PNODE2->pParent;
|
||||
|
||||
if (PPARENT->children[0] == PNODE2) {
|
||||
PPARENT->children[0] = PNODE;
|
||||
} else {
|
||||
PPARENT->children[1] = PNODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (PPARENT->children[0] == PNODE2) {
|
||||
PPARENT->children[0] = PNODE;
|
||||
} else {
|
||||
PPARENT->children[1] = PNODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const auto PPARENTNODE2 = PNODE2->pParent;
|
||||
PNODE2->pParent = PNODE->pParent;
|
||||
PNODE->pParent = PPARENTNODE2;
|
||||
const auto PPARENTNODE2 = PNODE2->pParent;
|
||||
PNODE2->pParent = PNODE->pParent;
|
||||
PNODE->pParent = PPARENTNODE2;
|
||||
|
||||
std::swap(PNODE2->workspaceID, PNODE->workspaceID);
|
||||
} else {
|
||||
// swap the windows and recalc
|
||||
PNODE2->pWindow = pWindow;
|
||||
PNODE->pWindow = pWindow2;
|
||||
}
|
||||
std::swap(PNODE2->workspaceID, PNODE->workspaceID);
|
||||
} else {
|
||||
// swap the windows and recalc
|
||||
PNODE2->pWindow = pWindow;
|
||||
PNODE->pWindow = pWindow2;
|
||||
}
|
||||
|
||||
if (PNODE->workspaceID != PNODE2->workspaceID) {
|
||||
std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID);
|
||||
std::swap(pWindow2->m_iWorkspaceID, pWindow->m_iWorkspaceID);
|
||||
}
|
||||
if (PNODE->workspaceID != PNODE2->workspaceID) {
|
||||
std::swap(pWindow2->m_iMonitorID, pWindow->m_iMonitorID);
|
||||
std::swap(pWindow2->m_iWorkspaceID, pWindow->m_iWorkspaceID);
|
||||
}
|
||||
|
||||
// recalc the workspace
|
||||
// recalc the workspace
|
||||
getMasterNodeOnWorkspace(PNODE->workspaceID)->recalcSizePosRecursive();
|
||||
|
||||
if (PNODE2->workspaceID != PNODE->workspaceID) {
|
||||
getMasterNodeOnWorkspace(PNODE2->workspaceID)->recalcSizePosRecursive();
|
||||
}
|
||||
|
||||
if (ACTIVE1) {
|
||||
ACTIVE1->position = PNODE->position;
|
||||
ACTIVE1->size = PNODE->size;
|
||||
ACTIVE1->pWindow->m_vPosition = ACTIVE1->position;
|
||||
ACTIVE1->pWindow->m_vSize = ACTIVE1->size;
|
||||
}
|
||||
if (ACTIVE1) {
|
||||
ACTIVE1->position = PNODE->position;
|
||||
ACTIVE1->size = PNODE->size;
|
||||
ACTIVE1->pWindow->m_vPosition = ACTIVE1->position;
|
||||
ACTIVE1->pWindow->m_vSize = ACTIVE1->size;
|
||||
}
|
||||
|
||||
if (ACTIVE2) {
|
||||
ACTIVE2->position = PNODE2->position;
|
||||
ACTIVE2->size = PNODE2->size;
|
||||
ACTIVE2->pWindow->m_vPosition = ACTIVE2->position;
|
||||
ACTIVE2->pWindow->m_vSize = ACTIVE2->size;
|
||||
}
|
||||
if (ACTIVE2) {
|
||||
ACTIVE2->position = PNODE2->position;
|
||||
ACTIVE2->size = PNODE2->size;
|
||||
ACTIVE2->pWindow->m_vPosition = ACTIVE2->position;
|
||||
ACTIVE2->pWindow->m_vSize = ACTIVE2->size;
|
||||
}
|
||||
|
||||
g_pHyprRenderer->damageWindow(pWindow);
|
||||
g_pHyprRenderer->damageWindow(pWindow2);
|
||||
|
|
|
@ -4,80 +4,81 @@
|
|||
#include <list>
|
||||
#include <deque>
|
||||
#include "../render/decorations/CHyprGroupBarDecoration.hpp"
|
||||
#include <array>
|
||||
|
||||
class CHyprDwindleLayout;
|
||||
enum eFullscreenMode : uint8_t;
|
||||
|
||||
struct SDwindleNodeData {
|
||||
SDwindleNodeData* pParent = nullptr;
|
||||
bool isNode = false;
|
||||
SDwindleNodeData* pParent = nullptr;
|
||||
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;
|
||||
SDwindleNodeData* pNextGroupMember = nullptr;
|
||||
SDwindleNodeData* pPreviousGroupMember = nullptr;
|
||||
bool groupHead = false;
|
||||
SDwindleNodeData* pNextGroupMember = nullptr;
|
||||
SDwindleNodeData* pPreviousGroupMember = nullptr;
|
||||
|
||||
Vector2D position;
|
||||
Vector2D size;
|
||||
Vector2D position;
|
||||
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
|
||||
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 getAllChildrenRecursive(std::deque<SDwindleNodeData*>*);
|
||||
bool isGroupMember();
|
||||
SDwindleNodeData* getGroupHead();
|
||||
SDwindleNodeData* getGroupVisible();
|
||||
int getGroupMemberCount();
|
||||
void setGroupFocusedNode(SDwindleNodeData*);
|
||||
void recalcSizePosRecursive(bool force = false);
|
||||
void getAllChildrenRecursive(std::deque<SDwindleNodeData*>*);
|
||||
bool isGroupMember();
|
||||
SDwindleNodeData* getGroupHead();
|
||||
SDwindleNodeData* getGroupVisible();
|
||||
int getGroupMemberCount();
|
||||
void setGroupFocusedNode(SDwindleNodeData*);
|
||||
CHyprDwindleLayout* layout = nullptr;
|
||||
};
|
||||
|
||||
class CHyprDwindleLayout : public IHyprLayout {
|
||||
public:
|
||||
virtual void onWindowCreatedTiling(CWindow*);
|
||||
virtual void onWindowRemovedTiling(CWindow*);
|
||||
virtual bool isWindowTiled(CWindow*);
|
||||
virtual void recalculateMonitor(const int&);
|
||||
virtual void recalculateWindow(CWindow*);
|
||||
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
|
||||
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
|
||||
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
||||
public:
|
||||
virtual void onWindowCreatedTiling(CWindow*);
|
||||
virtual void onWindowRemovedTiling(CWindow*);
|
||||
virtual bool isWindowTiled(CWindow*);
|
||||
virtual void recalculateMonitor(const int&);
|
||||
virtual void recalculateWindow(CWindow*);
|
||||
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
|
||||
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
|
||||
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
||||
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
||||
virtual void switchWindows(CWindow*, CWindow*);
|
||||
virtual void alterSplitRatioBy(CWindow*, float);
|
||||
virtual std::string getLayoutName();
|
||||
virtual void switchWindows(CWindow*, CWindow*);
|
||||
virtual void alterSplitRatioBy(CWindow*, float);
|
||||
virtual std::string getLayoutName();
|
||||
|
||||
virtual void onEnable();
|
||||
virtual void onDisable();
|
||||
virtual void onEnable();
|
||||
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 applyNodeDataToWindow(SDwindleNodeData*, bool force = false);
|
||||
SDwindleNodeData* getNodeFromWindow(CWindow*);
|
||||
SDwindleNodeData* getFirstNodeOnWorkspace(const int&);
|
||||
SDwindleNodeData* getMasterNodeOnWorkspace(const int&);
|
||||
|
||||
void toggleWindowGroup(CWindow*);
|
||||
void switchGroupWindow(CWindow*, bool forward, CWindow* to = nullptr);
|
||||
void toggleSplit(CWindow*);
|
||||
std::deque<CWindow*> getGroupMembers(CWindow*);
|
||||
void toggleWindowGroup(CWindow*);
|
||||
void switchGroupWindow(CWindow*, bool forward, CWindow* to = nullptr);
|
||||
void toggleSplit(CWindow*);
|
||||
std::deque<CWindow*> getGroupMembers(CWindow*);
|
||||
|
||||
friend struct SDwindleNodeData;
|
||||
};
|
|
@ -10,7 +10,7 @@ void IHyprLayout::onWindowCreated(CWindow* pWindow) {
|
|||
g_pXWaylandManager->getGeometryForWindow(pWindow, &desiredGeometry);
|
||||
|
||||
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;
|
||||
} else {
|
||||
pWindow->m_vLastFloatingSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
|
||||
|
@ -50,9 +50,10 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
|
|||
|
||||
if (desiredGeometry.width <= 5 || desiredGeometry.height <= 5) {
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -62,7 +63,8 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
|
|||
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 {
|
||||
// we respect the size.
|
||||
pWindow->m_vRealSize = Vector2D(desiredGeometry.width, desiredGeometry.height);
|
||||
|
@ -75,10 +77,14 @@ void IHyprLayout::onWindowCreatedFloating(CWindow* pWindow) {
|
|||
|
||||
if (!pWindow->m_bIsX11) {
|
||||
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)
|
||||
|| 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)
|
||||
|| 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)) {
|
||||
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) ||
|
||||
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) ||
|
||||
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;
|
||||
break;
|
||||
|
@ -144,17 +150,17 @@ void IHyprLayout::onBeginDragWindow() {
|
|||
if (!DRAGGINGWINDOW->m_bIsFloating) {
|
||||
if (g_pInputManager->dragMode == MBIND_MOVE) {
|
||||
changeWindowFloatingMode(DRAGGINGWINDOW);
|
||||
DRAGGINGWINDOW->m_bIsFloating = true;
|
||||
DRAGGINGWINDOW->m_bIsFloating = true;
|
||||
DRAGGINGWINDOW->m_bDraggingTiled = true;
|
||||
|
||||
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_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize.goalv();
|
||||
m_vLastDragXY = m_vBeginDragXY;
|
||||
m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize.goalv();
|
||||
m_vLastDragXY = m_vBeginDragXY;
|
||||
|
||||
// get the grab corner
|
||||
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 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 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
|
||||
|
||||
Vector2D newSize = m_vBeginDragSizeXY;
|
||||
Vector2D newPos = m_vBeginDragPositionXY;
|
||||
Vector2D newPos = m_vBeginDragPositionXY;
|
||||
|
||||
if (m_iGrabbedCorner == 3) {
|
||||
newSize = newSize + DELTA;
|
||||
} else if (m_iGrabbedCorner == 0) {
|
||||
newSize = newSize - DELTA;
|
||||
newPos = newPos + DELTA;
|
||||
newPos = newPos + DELTA;
|
||||
} else if (m_iGrabbedCorner == 1) {
|
||||
newSize = newSize + Vector2D(DELTA.x, -DELTA.y);
|
||||
newPos = newPos + Vector2D(0, DELTA.y);
|
||||
newPos = newPos + Vector2D(0, DELTA.y);
|
||||
} else if (m_iGrabbedCorner == 4) {
|
||||
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) {
|
||||
DRAGGINGWINDOW->m_vRealSize = newSize;
|
||||
DRAGGINGWINDOW->m_vRealSize = newSize;
|
||||
DRAGGINGWINDOW->m_vRealPosition = newPos;
|
||||
} else {
|
||||
DRAGGINGWINDOW->m_vRealSize.setValueAndWarp(newSize);
|
||||
|
@ -301,15 +307,15 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
|
|||
const auto TILED = isWindowTiled(pWindow);
|
||||
|
||||
// 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) {
|
||||
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->moveToWorkspace(PNEWMON->activeWorkspace);
|
||||
|
||||
// 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();
|
||||
|
||||
// if the window is pseudo, update its size
|
||||
|
@ -336,9 +342,9 @@ void IHyprLayout::changeWindowFloatingMode(CWindow* pWindow) {
|
|||
g_pCompositor->moveWindowToTop(pWindow);
|
||||
|
||||
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();
|
||||
|
||||
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
|
||||
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 (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)) {
|
||||
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 (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();
|
||||
}
|
||||
}
|
||||
|
@ -406,7 +414,8 @@ CWindow* IHyprLayout::getNextWindowCandidate(CWindow* pWindow) {
|
|||
|
||||
// if not, floating window
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
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 PWINDOWCANDIDATE;
|
||||
}
|
||||
|
||||
IHyprLayout::~IHyprLayout() {
|
||||
}
|
||||
IHyprLayout::~IHyprLayout() {}
|
||||
|
|
|
@ -2,103 +2,104 @@
|
|||
|
||||
#include "../defines.hpp"
|
||||
#include "../Window.hpp"
|
||||
#include <any>
|
||||
|
||||
struct SWindowRenderLayoutHints {
|
||||
bool isBorderColor = false;
|
||||
CColor borderColor;
|
||||
bool isBorderColor = false;
|
||||
CColor borderColor;
|
||||
};
|
||||
|
||||
struct SLayoutMessageHeader {
|
||||
CWindow* pWindow = nullptr;
|
||||
CWindow* pWindow = nullptr;
|
||||
};
|
||||
|
||||
enum eFullscreenMode : uint8_t;
|
||||
|
||||
interface IHyprLayout {
|
||||
public:
|
||||
virtual ~IHyprLayout() = 0;
|
||||
virtual void onEnable() = 0;
|
||||
virtual void onDisable() = 0;
|
||||
public:
|
||||
virtual ~IHyprLayout() = 0;
|
||||
virtual void onEnable() = 0;
|
||||
virtual void onDisable() = 0;
|
||||
|
||||
/*
|
||||
Called when a window is created (mapped)
|
||||
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.
|
||||
*/
|
||||
virtual void onWindowCreated(CWindow*);
|
||||
virtual void onWindowCreatedTiling(CWindow*) = 0;
|
||||
virtual void onWindowCreatedFloating(CWindow*);
|
||||
virtual void onWindowCreated(CWindow*);
|
||||
virtual void onWindowCreatedTiling(CWindow*) = 0;
|
||||
virtual void onWindowCreatedFloating(CWindow*);
|
||||
|
||||
/*
|
||||
Return tiled status
|
||||
*/
|
||||
virtual bool isWindowTiled(CWindow*) = 0;
|
||||
virtual bool isWindowTiled(CWindow*) = 0;
|
||||
|
||||
/*
|
||||
Called when a window is removed (unmapped)
|
||||
*/
|
||||
virtual void onWindowRemoved(CWindow*);
|
||||
virtual void onWindowRemovedTiling(CWindow*) = 0;
|
||||
virtual void onWindowRemovedFloating(CWindow*);
|
||||
virtual void onWindowRemoved(CWindow*);
|
||||
virtual void onWindowRemovedTiling(CWindow*) = 0;
|
||||
virtual void onWindowRemovedFloating(CWindow*);
|
||||
/*
|
||||
Called when the monitor requires a layout recalculation
|
||||
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
|
||||
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
|
||||
*/
|
||||
virtual void changeWindowFloatingMode(CWindow*);
|
||||
virtual void changeWindowFloatingMode(CWindow*);
|
||||
/*
|
||||
Called when a window is clicked on, beginning a drag
|
||||
this might be a resize, move, whatever the layout defines it
|
||||
as.
|
||||
*/
|
||||
virtual void onBeginDragWindow();
|
||||
virtual void onBeginDragWindow();
|
||||
/*
|
||||
Called when a user requests a resize of the current window by a vec
|
||||
Vector2D holds pixel values
|
||||
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
|
||||
Vector2D holds pixel values
|
||||
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
|
||||
(mouse up)
|
||||
*/
|
||||
virtual void onEndDragWindow();
|
||||
virtual void onEndDragWindow();
|
||||
/*
|
||||
Called whenever the mouse moves, should the layout want to
|
||||
do anything with it.
|
||||
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
|
||||
The layout sets all the fullscreen flags.
|
||||
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
|
||||
The layout is free to ignore.
|
||||
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()
|
||||
|
@ -111,35 +112,35 @@ public:
|
|||
Called when the user requests two windows to be swapped places.
|
||||
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
|
||||
on a window
|
||||
*/
|
||||
virtual void alterSplitRatioBy(CWindow*, float) = 0;
|
||||
virtual void alterSplitRatioBy(CWindow*, float) = 0;
|
||||
|
||||
/*
|
||||
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
|
||||
*/
|
||||
virtual CWindow* getNextWindowCandidate(CWindow*);
|
||||
virtual CWindow* getNextWindowCandidate(CWindow*);
|
||||
|
||||
/*
|
||||
Internal: called when window focus changes
|
||||
*/
|
||||
virtual void onWindowFocusChange(CWindow*);
|
||||
virtual void onWindowFocusChange(CWindow*);
|
||||
|
||||
private:
|
||||
Vector2D m_vBeginDragXY;
|
||||
Vector2D m_vLastDragXY;
|
||||
Vector2D m_vBeginDragPositionXY;
|
||||
Vector2D m_vBeginDragSizeXY;
|
||||
int m_iGrabbedCorner = 0;
|
||||
private:
|
||||
Vector2D m_vBeginDragXY;
|
||||
Vector2D m_vLastDragXY;
|
||||
Vector2D m_vBeginDragPositionXY;
|
||||
Vector2D m_vBeginDragSizeXY;
|
||||
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
|
||||
const auto PWORKSPACEDATA = &m_lMasterWorkspacesData.emplace_back();
|
||||
const auto PWORKSPACEDATA = &m_lMasterWorkspacesData.emplace_back();
|
||||
PWORKSPACEDATA->workspaceID = ws;
|
||||
const auto orientation = &g_pConfigManager->getConfigValuePtr("master:orientation")->strValue;
|
||||
const auto orientation = &g_pConfigManager->getConfigValuePtr("master:orientation")->strValue;
|
||||
if (*orientation == "top") {
|
||||
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
|
||||
} else if (*orientation == "right") {
|
||||
|
@ -69,30 +69,30 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
|||
if (pWindow->m_bIsFloating)
|
||||
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->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);
|
||||
float lastSplitPercent = 0.5f;
|
||||
const auto WINDOWSONWORKSPACE = getNodesOnWorkspace(PNODE->workspaceID);
|
||||
float lastSplitPercent = 0.5f;
|
||||
|
||||
if (*PNEWISMASTER || WINDOWSONWORKSPACE == 1) {
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
if (nd.isMaster && nd.workspaceID == PNODE->workspaceID) {
|
||||
nd.isMaster = false;
|
||||
nd.isMaster = false;
|
||||
lastSplitPercent = nd.percMaster;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PNODE->isMaster = true;
|
||||
PNODE->isMaster = true;
|
||||
PNODE->percMaster = lastSplitPercent;
|
||||
|
||||
// first, check if it isn't too big.
|
||||
|
@ -107,7 +107,8 @@ void CHyprMasterLayout::onWindowCreatedTiling(CWindow* pWindow) {
|
|||
PNODE->isMaster = false;
|
||||
|
||||
// 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.
|
||||
pWindow->m_bIsFloating = true;
|
||||
m_lMasterNodesData.remove(*PNODE);
|
||||
|
@ -134,7 +135,7 @@ void CHyprMasterLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
|||
return;
|
||||
|
||||
pWindow->m_sSpecialRenderData.rounding = true;
|
||||
pWindow->m_sSpecialRenderData.border = true;
|
||||
pWindow->m_sSpecialRenderData.border = true;
|
||||
pWindow->m_sSpecialRenderData.decorate = true;
|
||||
|
||||
if (pWindow->m_bIsFullscreen)
|
||||
|
@ -169,7 +170,7 @@ void CHyprMasterLayout::onWindowRemovedTiling(CWindow* pWindow) {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
if (!PWORKSPACE)
|
||||
|
@ -186,15 +187,15 @@ void CHyprMasterLayout::recalculateMonitor(const int& monid) {
|
|||
return;
|
||||
|
||||
// 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;
|
||||
fakeNode.pWindow = PFULLWINDOW;
|
||||
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||
fakeNode.workspaceID = PWORKSPACE->m_iID;
|
||||
fakeNode.pWindow = PFULLWINDOW;
|
||||
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||
fakeNode.workspaceID = PWORKSPACE->m_iID;
|
||||
PFULLWINDOW->m_vPosition = fakeNode.position;
|
||||
PFULLWINDOW->m_vSize = fakeNode.size;
|
||||
PFULLWINDOW->m_vSize = fakeNode.size;
|
||||
|
||||
applyNodeDataToWindow(&fakeNode);
|
||||
|
||||
|
@ -225,14 +226,15 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
|
|||
//compute placement of master window(s)
|
||||
if (getNodesOnWorkspace(PWORKSPACE->m_iID) < 2) {
|
||||
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);
|
||||
return;
|
||||
} else if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT || PWORKSPACEDATA->orientation == ORIENTATION_RIGHT) {
|
||||
float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
|
||||
int nodesLeft = MASTERS;
|
||||
float nextY = 0;
|
||||
const float WIDTH = (PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x) * PMASTERNODE->percMaster;
|
||||
float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
|
||||
int nodesLeft = MASTERS;
|
||||
float nextY = 0;
|
||||
const float WIDTH = (PMONITOR->vecSize.x - PMONITOR->vecReservedTopLeft.x - PMONITOR->vecReservedBottomRight.x) * PMASTERNODE->percMaster;
|
||||
|
||||
for (auto& n : m_lMasterNodesData) {
|
||||
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) {
|
||||
float widthLeft = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x;
|
||||
int nodesLeft = MASTERS;
|
||||
float nextX = 0;
|
||||
const float HEIGHT = (PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y) * PMASTERNODE->percMaster;
|
||||
float widthLeft = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x;
|
||||
int nodesLeft = MASTERS;
|
||||
float nextX = 0;
|
||||
const float HEIGHT = (PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y) * PMASTERNODE->percMaster;
|
||||
|
||||
for (auto& n : m_lMasterNodesData) {
|
||||
if (n.workspaceID == PWORKSPACE->m_iID && n.isMaster) {
|
||||
if (PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
|
||||
n.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX,PMONITOR->vecSize.y - HEIGHT - PMONITOR->vecReservedBottomRight.y);
|
||||
if (PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
|
||||
n.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX, PMONITOR->vecSize.y - HEIGHT - PMONITOR->vecReservedBottomRight.y);
|
||||
} else {
|
||||
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)
|
||||
int slavesLeft = getNodesOnWorkspace(PWORKSPACE->m_iID) - MASTERS;
|
||||
if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT || PWORKSPACEDATA->orientation == ORIENTATION_RIGHT) {
|
||||
float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
|
||||
float nextY = 0;
|
||||
const float WIDTH = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x - PMASTERNODE->size.x;
|
||||
float heightLeft = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y;
|
||||
float nextY = 0;
|
||||
const float WIDTH = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x - PMASTERNODE->size.x;
|
||||
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
if (nd.workspaceID != PWORKSPACE->m_iID || nd.isMaster)
|
||||
continue;
|
||||
|
||||
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 {
|
||||
nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(0, nextY);
|
||||
}
|
||||
|
@ -309,15 +311,16 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
|
|||
applyNodeDataToWindow(&nd);
|
||||
}
|
||||
} else if (PWORKSPACEDATA->orientation == ORIENTATION_TOP || PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
|
||||
float widthLeft = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x;
|
||||
float nextX = 0;
|
||||
const float HEIGHT = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y - PMASTERNODE->size.y;
|
||||
float widthLeft = PMONITOR->vecSize.x - PMONITOR->vecReservedBottomRight.x - PMONITOR->vecReservedTopLeft.x;
|
||||
float nextX = 0;
|
||||
const float HEIGHT = PMONITOR->vecSize.y - PMONITOR->vecReservedBottomRight.y - PMONITOR->vecReservedTopLeft.y - PMASTERNODE->size.y;
|
||||
|
||||
for (auto& nd : m_lMasterNodesData) {
|
||||
if (nd.workspaceID != PWORKSPACE->m_iID || nd.isMaster)
|
||||
continue;
|
||||
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 {
|
||||
nd.position = PMONITOR->vecReservedTopLeft + PMONITOR->vecPosition + Vector2D(nextX, 0);
|
||||
}
|
||||
|
@ -333,8 +336,6 @@ void CHyprMasterLayout::calculateWorkspace(const int& ws) {
|
|||
applyNodeDataToWindow(&nd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
||||
|
@ -357,14 +358,14 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
|||
}
|
||||
|
||||
// for gaps outer
|
||||
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 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 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 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 auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||
const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
||||
const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
||||
const auto PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||
const auto PGAPSIN = &g_pConfigManager->getConfigValuePtr("general:gaps_in")->intValue;
|
||||
const auto PGAPSOUT = &g_pConfigManager->getConfigValuePtr("general:gaps_out")->intValue;
|
||||
|
||||
const auto PWINDOW = pNode->pWindow;
|
||||
|
||||
|
@ -373,49 +374,49 @@ void CHyprMasterLayout::applyNodeDataToWindow(SMasterNodeData* pNode) {
|
|||
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;
|
||||
|
||||
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);
|
||||
|
||||
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_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
||||
PWINDOW->m_vRealSize = calcSize + Vector2D(2 * *PBORDERSIZE, 2 * *PBORDERSIZE);
|
||||
|
||||
PWINDOW->updateWindowDecos();
|
||||
|
||||
PWINDOW->m_sSpecialRenderData.rounding = false;
|
||||
PWINDOW->m_sSpecialRenderData.border = false;
|
||||
PWINDOW->m_sSpecialRenderData.border = false;
|
||||
PWINDOW->m_sSpecialRenderData.decorate = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PWINDOW->m_sSpecialRenderData.rounding = true;
|
||||
PWINDOW->m_sSpecialRenderData.border = true;
|
||||
PWINDOW->m_sSpecialRenderData.border = true;
|
||||
PWINDOW->m_sSpecialRenderData.decorate = true;
|
||||
|
||||
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN,
|
||||
DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
|
||||
const auto OFFSETTOPLEFT = Vector2D(DISPLAYLEFT ? *PGAPSOUT : *PGAPSIN, DISPLAYTOP ? *PGAPSOUT : *PGAPSIN);
|
||||
|
||||
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN,
|
||||
DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
|
||||
const auto OFFSETBOTTOMRIGHT = Vector2D(DISPLAYRIGHT ? *PGAPSOUT : *PGAPSIN, DISPLAYBOTTOM ? *PGAPSOUT : *PGAPSIN);
|
||||
|
||||
calcPos = calcPos + OFFSETTOPLEFT;
|
||||
calcPos = calcPos + OFFSETTOPLEFT;
|
||||
calcSize = calcSize - OFFSETTOPLEFT - OFFSETBOTTOMRIGHT;
|
||||
|
||||
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_vRealSize = calcSize * *PSCALEFACTOR;
|
||||
PWINDOW->m_vRealSize = calcSize * *PSCALEFACTOR;
|
||||
|
||||
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize * *PSCALEFACTOR);
|
||||
} else {
|
||||
PWINDOW->m_vRealSize = calcSize;
|
||||
PWINDOW->m_vRealSize = calcSize;
|
||||
PWINDOW->m_vRealPosition = calcPos;
|
||||
|
||||
g_pXWaylandManager->setWindowSize(PWINDOW, calcSize);
|
||||
|
@ -471,10 +472,10 @@ void CHyprMasterLayout::resizeActiveWindow(const Vector2D& pixResize, CWindow* p
|
|||
if (PNODE->isMaster && getMastersOnWorkspace(PNODE->workspaceID) > 1) {
|
||||
// check master size
|
||||
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) {
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
if (PWORKSPACE->m_bHasFullscreenWindow && on) {
|
||||
|
@ -500,7 +501,7 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
|
|||
}
|
||||
|
||||
// otherwise, accept it.
|
||||
pWindow->m_bIsFullscreen = on;
|
||||
pWindow->m_bIsFullscreen = on;
|
||||
PWORKSPACE->m_bHasFullscreenWindow = !PWORKSPACE->m_bHasFullscreenWindow;
|
||||
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"fullscreen", std::to_string((int)on)});
|
||||
|
@ -513,7 +514,7 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
|
|||
else {
|
||||
// get back its' dimensions from position and size
|
||||
pWindow->m_vRealPosition = pWindow->m_vPosition;
|
||||
pWindow->m_vRealSize = pWindow->m_vSize;
|
||||
pWindow->m_vRealSize = pWindow->m_vSize;
|
||||
}
|
||||
} else {
|
||||
// if it now got fullscreen, make it fullscreen
|
||||
|
@ -523,25 +524,25 @@ void CHyprMasterLayout::fullscreenRequestForWindow(CWindow* pWindow, eFullscreen
|
|||
// save position and size if floating
|
||||
if (pWindow->m_bIsFloating) {
|
||||
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
|
||||
if (fullscreenMode == FULLSCREEN_FULL) {
|
||||
pWindow->m_vRealPosition = PMONITOR->vecPosition;
|
||||
pWindow->m_vRealSize = PMONITOR->vecSize;
|
||||
pWindow->m_vRealSize = PMONITOR->vecSize;
|
||||
} else {
|
||||
// This is a massive hack.
|
||||
// We make a fake "only" node and apply
|
||||
// To keep consistent with the settings without C+P code
|
||||
|
||||
SMasterNodeData fakeNode;
|
||||
fakeNode.pWindow = pWindow;
|
||||
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||
fakeNode.pWindow = pWindow;
|
||||
fakeNode.position = PMONITOR->vecPosition + PMONITOR->vecReservedTopLeft;
|
||||
fakeNode.size = PMONITOR->vecSize - PMONITOR->vecReservedTopLeft - PMONITOR->vecReservedBottomRight;
|
||||
fakeNode.workspaceID = pWindow->m_iWorkspaceID;
|
||||
pWindow->m_vPosition = fakeNode.position;
|
||||
pWindow->m_vSize = fakeNode.size;
|
||||
pWindow->m_vSize = fakeNode.size;
|
||||
|
||||
applyNodeDataToWindow(&fakeNode);
|
||||
}
|
||||
|
@ -576,7 +577,7 @@ SWindowRenderLayoutHints CHyprMasterLayout::requestRenderHints(CWindow* pWindow)
|
|||
void CHyprMasterLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
||||
// windows should be valid, insallah
|
||||
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
const auto PNODE = getNodeFromWindow(pWindow);
|
||||
const auto PNODE2 = getNodeFromWindow(pWindow2);
|
||||
|
||||
if (!PNODE2 || !PNODE)
|
||||
|
@ -590,7 +591,7 @@ void CHyprMasterLayout::switchWindows(CWindow* pWindow, CWindow* pWindow2) {
|
|||
}
|
||||
|
||||
// massive hack: just swap window pointers, lol
|
||||
PNODE->pWindow = pWindow2;
|
||||
PNODE->pWindow = pWindow2;
|
||||
PNODE2->pWindow = pWindow;
|
||||
|
||||
recalculateMonitor(pWindow->m_iMonitorID);
|
||||
|
@ -635,7 +636,7 @@ CWindow* CHyprMasterLayout::getNextWindow(CWindow* pWindow, bool next) {
|
|||
} else {
|
||||
// focus next
|
||||
bool reached = false;
|
||||
bool found = false;
|
||||
bool found = false;
|
||||
for (auto n : m_lMasterNodesData) {
|
||||
if (n.pWindow == pWindow) {
|
||||
reached = true;
|
||||
|
@ -664,7 +665,7 @@ CWindow* CHyprMasterLayout::getNextWindow(CWindow* pWindow, bool next) {
|
|||
} else {
|
||||
// focus previous
|
||||
bool reached = false;
|
||||
bool found = false;
|
||||
bool found = false;
|
||||
for (auto it = m_lMasterNodesData.rbegin(); it != m_lMasterNodesData.rend(); it++) {
|
||||
if (it->pWindow == pWindow) {
|
||||
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 (pWindow->m_bIsFullscreen) {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -732,7 +733,6 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
|||
if (!PMASTER)
|
||||
return 0;
|
||||
|
||||
|
||||
if (PMASTER->pWindow != PWINDOW) {
|
||||
switchWindows(PWINDOW, PMASTER->pWindow);
|
||||
switchToWindow(PWINDOW);
|
||||
|
@ -835,7 +835,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
|||
if (header.pWindow->m_bIsFloating)
|
||||
return 0;
|
||||
|
||||
const auto PNODE = getNodeFromWindow(header.pWindow);
|
||||
const auto PNODE = getNodeFromWindow(header.pWindow);
|
||||
|
||||
const auto WINDOWS = getNodesOnWorkspace(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);
|
||||
|
||||
if (message == "orientationleft")
|
||||
if (message == "orientationleft")
|
||||
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
|
||||
else if (message == "orientationright")
|
||||
else if (message == "orientationright")
|
||||
PWORKSPACEDATA->orientation = ORIENTATION_RIGHT;
|
||||
else if (message == "orientationtop")
|
||||
else if (message == "orientationtop")
|
||||
PWORKSPACEDATA->orientation = ORIENTATION_TOP;
|
||||
else if (message == "orientationbottom")
|
||||
else if (message == "orientationbottom")
|
||||
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
|
||||
|
||||
recalculateMonitor(header.pWindow->m_iMonitorID);
|
||||
|
@ -924,7 +924,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
|||
if (PWORKSPACEDATA->orientation == ORIENTATION_BOTTOM) {
|
||||
PWORKSPACEDATA->orientation = ORIENTATION_LEFT;
|
||||
} else {
|
||||
PWORKSPACEDATA->orientation = (eOrientation) (PWORKSPACEDATA->orientation + 1);
|
||||
PWORKSPACEDATA->orientation = (eOrientation)(PWORKSPACEDATA->orientation + 1);
|
||||
}
|
||||
|
||||
recalculateMonitor(header.pWindow->m_iMonitorID);
|
||||
|
@ -941,7 +941,7 @@ std::any CHyprMasterLayout::layoutMessage(SLayoutMessageHeader header, std::stri
|
|||
if (PWORKSPACEDATA->orientation == ORIENTATION_LEFT) {
|
||||
PWORKSPACEDATA->orientation = ORIENTATION_BOTTOM;
|
||||
} else {
|
||||
PWORKSPACEDATA->orientation = (eOrientation) (PWORKSPACEDATA->orientation - 1);
|
||||
PWORKSPACEDATA->orientation = (eOrientation)(PWORKSPACEDATA->orientation - 1);
|
||||
}
|
||||
|
||||
recalculateMonitor(header.pWindow->m_iMonitorID);
|
||||
|
|
|
@ -4,11 +4,13 @@
|
|||
#include <vector>
|
||||
#include <list>
|
||||
#include <deque>
|
||||
#include <any>
|
||||
|
||||
enum eFullscreenMode : uint8_t;
|
||||
|
||||
//orientation determines which side of the screen the master area resides
|
||||
enum eOrientation : uint8_t {
|
||||
enum eOrientation : uint8_t
|
||||
{
|
||||
ORIENTATION_LEFT = 0,
|
||||
ORIENTATION_TOP,
|
||||
ORIENTATION_RIGHT,
|
||||
|
@ -16,67 +18,66 @@ enum eOrientation : uint8_t {
|
|||
};
|
||||
|
||||
struct SMasterNodeData {
|
||||
bool isMaster = false;
|
||||
float percMaster = 0.5f;
|
||||
bool isMaster = false;
|
||||
float percMaster = 0.5f;
|
||||
|
||||
CWindow* pWindow = nullptr;
|
||||
|
||||
Vector2D position;
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
struct SMasterWorkspaceData {
|
||||
int workspaceID = -1;
|
||||
int workspaceID = -1;
|
||||
eOrientation orientation = ORIENTATION_LEFT;
|
||||
|
||||
bool operator==(const SMasterWorkspaceData& rhs) {
|
||||
bool operator==(const SMasterWorkspaceData& rhs) {
|
||||
return workspaceID == rhs.workspaceID;
|
||||
}
|
||||
};
|
||||
|
||||
class CHyprMasterLayout : public IHyprLayout {
|
||||
public:
|
||||
virtual void onWindowCreatedTiling(CWindow*);
|
||||
virtual void onWindowRemovedTiling(CWindow*);
|
||||
virtual bool isWindowTiled(CWindow*);
|
||||
virtual void recalculateMonitor(const int&);
|
||||
virtual void recalculateWindow(CWindow*);
|
||||
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
|
||||
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
|
||||
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
||||
public:
|
||||
virtual void onWindowCreatedTiling(CWindow*);
|
||||
virtual void onWindowRemovedTiling(CWindow*);
|
||||
virtual bool isWindowTiled(CWindow*);
|
||||
virtual void recalculateMonitor(const int&);
|
||||
virtual void recalculateWindow(CWindow*);
|
||||
virtual void resizeActiveWindow(const Vector2D&, CWindow* pWindow = nullptr);
|
||||
virtual void fullscreenRequestForWindow(CWindow*, eFullscreenMode, bool);
|
||||
virtual std::any layoutMessage(SLayoutMessageHeader, std::string);
|
||||
virtual SWindowRenderLayoutHints requestRenderHints(CWindow*);
|
||||
virtual void switchWindows(CWindow*, CWindow*);
|
||||
virtual void alterSplitRatioBy(CWindow*, float);
|
||||
virtual std::string getLayoutName();
|
||||
virtual void switchWindows(CWindow*, CWindow*);
|
||||
virtual void alterSplitRatioBy(CWindow*, float);
|
||||
virtual std::string getLayoutName();
|
||||
|
||||
virtual void onEnable();
|
||||
virtual void onDisable();
|
||||
virtual void onEnable();
|
||||
virtual void onDisable();
|
||||
|
||||
private:
|
||||
|
||||
std::list<SMasterNodeData> m_lMasterNodesData;
|
||||
private:
|
||||
std::list<SMasterNodeData> m_lMasterNodesData;
|
||||
std::vector<SMasterWorkspaceData> m_lMasterWorkspacesData;
|
||||
|
||||
bool m_bForceWarps = false;
|
||||
bool m_bForceWarps = false;
|
||||
|
||||
int getNodesOnWorkspace(const int&);
|
||||
void applyNodeDataToWindow(SMasterNodeData*);
|
||||
SMasterNodeData* getNodeFromWindow(CWindow*);
|
||||
SMasterNodeData* getMasterNodeOnWorkspace(const int&);
|
||||
SMasterWorkspaceData* getMasterWorkspaceData(const int&);
|
||||
void calculateWorkspace(const int&);
|
||||
CWindow* getNextWindow(CWindow*, bool);
|
||||
int getMastersOnWorkspace(const int&);
|
||||
bool prepareLoseFocus(CWindow*);
|
||||
void prepareNewFocus(CWindow*, bool inherit_fullscreen);
|
||||
int getNodesOnWorkspace(const int&);
|
||||
void applyNodeDataToWindow(SMasterNodeData*);
|
||||
SMasterNodeData* getNodeFromWindow(CWindow*);
|
||||
SMasterNodeData* getMasterNodeOnWorkspace(const int&);
|
||||
SMasterWorkspaceData* getMasterWorkspaceData(const int&);
|
||||
void calculateWorkspace(const int&);
|
||||
CWindow* getNextWindow(CWindow*, bool);
|
||||
int getMastersOnWorkspace(const int&);
|
||||
bool prepareLoseFocus(CWindow*);
|
||||
void prepareNewFocus(CWindow*, bool inherit_fullscreen);
|
||||
|
||||
friend struct SMasterNodeData;
|
||||
friend struct SMasterWorkspaceData;
|
||||
|
|
12
src/main.cpp
12
src/main.cpp
|
@ -20,7 +20,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
// parse some args
|
||||
std::string configPath;
|
||||
bool ignoreSudo = false;
|
||||
bool ignoreSudo = false;
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (!strcmp(argv[i], "--i-am-really-stupid"))
|
||||
ignoreSudo = true;
|
||||
|
@ -28,9 +28,9 @@ int main(int argc, char** argv) {
|
|||
configPath = std::string(argv[++i]);
|
||||
Debug::log(LOG, "Using config location %s.", configPath.c_str());
|
||||
} else {
|
||||
std::cout << "Hyprland usage: Hyprland [arg [...]].\n\nArguments:\n" <<
|
||||
"--help -h | Show this help message\n" <<
|
||||
"--config -c | Specify config file to use\n";
|
||||
std::cout << "Hyprland usage: Hyprland [arg [...]].\n\nArguments:\n"
|
||||
<< "--help -h | Show this help message\n"
|
||||
<< "--config -c | Specify config file to use\n";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ int main(int argc, char** argv) {
|
|||
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";
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::cout << "Running with ignored root checks, I surely hope you know what you're doing.\n";
|
||||
sleep(1);
|
||||
|
@ -55,7 +55,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
// let's init the compositor.
|
||||
// it initializes basic Wayland stuff in the constructor.
|
||||
g_pCompositor = std::make_unique<CCompositor>();
|
||||
g_pCompositor = std::make_unique<CCompositor>();
|
||||
g_pCompositor->explicitConfigPath = configPath;
|
||||
|
||||
Debug::log(LOG, "Hyprland init finished.");
|
||||
|
|
|
@ -21,17 +21,17 @@ void CAnimationManager::addBezierWithName(std::string name, const Vector2D& p1,
|
|||
|
||||
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)
|
||||
animGlobalDisabled = true;
|
||||
|
||||
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 PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->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;
|
||||
|
||||
|
@ -50,23 +50,23 @@ void CAnimationManager::tick() {
|
|||
const float SPENT = av->getPercent();
|
||||
|
||||
// window stuff
|
||||
const auto PWINDOW = (CWindow*)av->m_pWindow;
|
||||
const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace;
|
||||
const auto PLAYER = (SLayerSurface*)av->m_pLayer;
|
||||
CMonitor* PMONITOR = nullptr;
|
||||
bool animationsDisabled = animGlobalDisabled;
|
||||
const auto PWINDOW = (CWindow*)av->m_pWindow;
|
||||
const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace;
|
||||
const auto PLAYER = (SLayerSurface*)av->m_pLayer;
|
||||
CMonitor* PMONITOR = nullptr;
|
||||
bool animationsDisabled = animGlobalDisabled;
|
||||
|
||||
wlr_box WLRBOXPREV = {0,0,0,0};
|
||||
wlr_box WLRBOXPREV = {0, 0, 0, 0};
|
||||
if (PWINDOW) {
|
||||
WLRBOXPREV = PWINDOW->getFullWindowBoundingBox();
|
||||
PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||
WLRBOXPREV = PWINDOW->getFullWindowBoundingBox();
|
||||
PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||
animationsDisabled = animationsDisabled || PWINDOW->m_sAdditionalConfigData.forceNoAnims;
|
||||
} 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};
|
||||
} else if (PLAYER) {
|
||||
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
|
||||
|
@ -85,7 +85,7 @@ void CAnimationManager::tick() {
|
|||
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);
|
||||
|
||||
if (BEZIER != m_mBezierCurves.end())
|
||||
|
@ -106,7 +106,7 @@ void CAnimationManager::tick() {
|
|||
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);
|
||||
|
||||
if (BEZIER != m_mBezierCurves.end())
|
||||
|
@ -127,7 +127,7 @@ void CAnimationManager::tick() {
|
|||
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);
|
||||
|
||||
if (BEZIER != m_mBezierCurves.end())
|
||||
|
@ -164,40 +164,45 @@ void CAnimationManager::tick() {
|
|||
g_pHyprOpenGL->markBlurDirtyForMonitor(PMONITOR);
|
||||
}
|
||||
break;
|
||||
} case AVARDAMAGE_BORDER: {
|
||||
}
|
||||
case AVARDAMAGE_BORDER: {
|
||||
RASSERT(PWINDOW, "Tried to AVARDAMAGE_BORDER a non-window AVAR!");
|
||||
|
||||
// damage only the border.
|
||||
static auto *const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
|
||||
const auto ROUNDINGSIZE = *PROUNDING + 1;
|
||||
const auto BORDERSIZE = *PBORDERSIZE;
|
||||
static auto* const PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->intValue;
|
||||
const auto ROUNDINGSIZE = *PROUNDING + 1;
|
||||
const auto BORDERSIZE = *PBORDERSIZE;
|
||||
|
||||
// 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, 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.y + WLRBOXPREV.height - ROUNDINGSIZE, WLRBOXPREV.width + 2 * BORDERSIZE, BORDERSIZE + ROUNDINGSIZE); // bottom
|
||||
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 + WLRBOXPREV.width - ROUNDINGSIZE, WLRBOXPREV.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE,
|
||||
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
|
||||
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, 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.y + WLRBOXNEW.height - ROUNDINGSIZE, WLRBOXNEW.width + 2 * BORDERSIZE, BORDERSIZE + ROUNDINGSIZE); // bottom
|
||||
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 + WLRBOXNEW.width - ROUNDINGSIZE, WLRBOXNEW.y - BORDERSIZE, BORDERSIZE + ROUNDINGSIZE,
|
||||
WLRBOXNEW.height + 2 * BORDERSIZE); // right
|
||||
g_pHyprRenderer->damageBox(WLRBOXNEW.x, WLRBOXNEW.y + WLRBOXNEW.height - ROUNDINGSIZE, WLRBOXNEW.width + 2 * BORDERSIZE, BORDERSIZE + ROUNDINGSIZE); // bottom
|
||||
|
||||
break;
|
||||
} case AVARDAMAGE_SHADOW: {
|
||||
}
|
||||
case AVARDAMAGE_SHADOW: {
|
||||
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) {
|
||||
const auto EXTENTS = PDECO->getWindowDecorationExtents();
|
||||
|
||||
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};
|
||||
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};
|
||||
|
||||
if (!*PSHADOWIGNOREWINDOW) {
|
||||
// easy, damage the entire box
|
||||
|
@ -206,7 +211,8 @@ void CAnimationManager::tick() {
|
|||
pixman_region32_t rg;
|
||||
pixman_region32_init_rect(&rg, dmg.x, dmg.y, dmg.width, dmg.height);
|
||||
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);
|
||||
g_pHyprRenderer->damageRegion(&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) {
|
||||
for (auto&[bc, bz] : m_mBezierCurves) {
|
||||
for (auto& [bc, bz] : m_mBezierCurves) {
|
||||
if (bc == bezier)
|
||||
return true;
|
||||
}
|
||||
|
@ -279,33 +285,37 @@ bool CAnimationManager::bezierExists(const std::string& bezier) {
|
|||
//
|
||||
|
||||
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();
|
||||
|
||||
if (!close) {
|
||||
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);
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
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 PMONITOR = g_pCompositor->getMonitorFromID(pWindow->m_iMonitorID);
|
||||
|
||||
Vector2D posOffset;
|
||||
Vector2D posOffset;
|
||||
|
||||
if (force != "") {
|
||||
if (force == "bottom") posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y);
|
||||
else if (force == "left") 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 (force == "bottom")
|
||||
posOffset = Vector2D(GOALPOS.x, PMONITOR->vecPosition.y + PMONITOR->vecSize.y);
|
||||
else if (force == "left")
|
||||
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)
|
||||
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;
|
||||
|
||||
// check sides it touches
|
||||
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 DISPLAYTOP = STICKS(pWindow->m_vPosition.y, PMONITOR->vecPosition.y + PMONITOR->vecReservedTopLeft.y);
|
||||
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 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);
|
||||
|
||||
if (DISPLAYBOTTOM && DISPLAYTOP) {
|
||||
|
@ -351,12 +361,12 @@ void CAnimationManager::animationSlide(CWindow* pWindow, std::string force, bool
|
|||
void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
|
||||
if (!close) {
|
||||
pWindow->m_vRealPosition.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_vRealSize.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsIn");
|
||||
pWindow->m_fAlpha.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("fadeIn");
|
||||
} else {
|
||||
pWindow->m_vRealPosition.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_vRealSize.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("windowsOut");
|
||||
pWindow->m_fAlpha.m_pConfig = g_pConfigManager->getAnimationPropertyConfig("fadeOut");
|
||||
}
|
||||
|
||||
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) {
|
||||
try {
|
||||
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) {
|
||||
; // oops
|
||||
}
|
||||
|
@ -404,7 +414,7 @@ void CAnimationManager::onWindowPostCreateClose(CWindow* pWindow, bool close) {
|
|||
if (ANIMSTYLE.find("%") != 0) {
|
||||
try {
|
||||
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) {
|
||||
; // oops
|
||||
}
|
||||
|
@ -425,10 +435,8 @@ std::string CAnimationManager::styleValidInConfigVar(const std::string& config,
|
|||
if (style.find("%") != std::string::npos) {
|
||||
try {
|
||||
auto percstr = style.substr(style.find_last_of(' '));
|
||||
minPerc = std::stoi(percstr.substr(0, percstr.length() - 1));
|
||||
} catch (std::exception& e) {
|
||||
return "invalid minperc";
|
||||
}
|
||||
minPerc = std::stoi(percstr.substr(0, percstr.length() - 1));
|
||||
} catch (std::exception& e) { return "invalid minperc"; }
|
||||
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -8,35 +8,34 @@
|
|||
#include "../Window.hpp"
|
||||
|
||||
class CAnimationManager {
|
||||
public:
|
||||
|
||||
public:
|
||||
CAnimationManager();
|
||||
|
||||
void tick();
|
||||
void addBezierWithName(std::string, const Vector2D&, const Vector2D&);
|
||||
void removeAllBeziers();
|
||||
void tick();
|
||||
void addBezierWithName(std::string, const Vector2D&, const Vector2D&);
|
||||
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;
|
||||
|
||||
private:
|
||||
bool deltaSmallToFlip(const Vector2D& a, const Vector2D& b);
|
||||
bool deltaSmallToFlip(const CColor& a, const CColor& b);
|
||||
bool deltaSmallToFlip(const float& a, const float& b);
|
||||
bool deltazero(const Vector2D& a, const Vector2D& b);
|
||||
bool deltazero(const CColor& a, const CColor& b);
|
||||
bool deltazero(const float& a, const float& b);
|
||||
private:
|
||||
bool deltaSmallToFlip(const Vector2D& a, const Vector2D& b);
|
||||
bool deltaSmallToFlip(const CColor& a, const CColor& b);
|
||||
bool deltaSmallToFlip(const float& a, const float& b);
|
||||
bool deltazero(const Vector2D& a, const Vector2D& b);
|
||||
bool deltazero(const CColor& a, const CColor& b);
|
||||
bool deltazero(const float& a, const float& b);
|
||||
|
||||
std::unordered_map<std::string, CBezierCurve> m_mBezierCurves;
|
||||
|
||||
// Anim stuff
|
||||
void animationPopin(CWindow*, bool close = false, float minPerc = 0.f);
|
||||
void animationSlide(CWindow*, std::string force = "", bool close = false);
|
||||
void animationPopin(CWindow*, bool close = false, float minPerc = 0.f);
|
||||
void animationSlide(CWindow*, std::string force = "", bool close = false);
|
||||
};
|
||||
|
||||
inline std::unique_ptr<CAnimationManager> g_pAnimationManager;
|
|
@ -15,14 +15,13 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
CEventManager::CEventManager() {
|
||||
}
|
||||
CEventManager::CEventManager() {}
|
||||
|
||||
int fdHandleWrite(int fd, uint32_t mask, void* data) {
|
||||
if (mask & WL_EVENT_ERROR || mask & WL_EVENT_HANGUP) {
|
||||
// remove, hanged up
|
||||
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) {
|
||||
wl_event_source_remove(it->second); // remove this fd listener
|
||||
it = ACCEPTEDFDS->erase(it);
|
||||
|
@ -45,7 +44,7 @@ void CEventManager::startThread() {
|
|||
}
|
||||
|
||||
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());
|
||||
|
||||
bind(SOCKET, (sockaddr*)&SERVERADDRESS, SUN_LEN(&SERVERADDRESS));
|
||||
|
@ -54,7 +53,7 @@ void CEventManager::startThread() {
|
|||
listen(SOCKET, 10);
|
||||
|
||||
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());
|
||||
|
||||
|
@ -70,7 +69,8 @@ void CEventManager::startThread() {
|
|||
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
|
||||
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) {
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
std::thread([&](const SHyprIPCEvent ev) {
|
||||
eventQueueMutex.lock();
|
||||
m_dQueuedEvents.push_back(ev);
|
||||
eventQueueMutex.unlock();
|
||||
std::thread(
|
||||
[&](const SHyprIPCEvent ev) {
|
||||
eventQueueMutex.lock();
|
||||
m_dQueuedEvents.push_back(ev);
|
||||
eventQueueMutex.unlock();
|
||||
|
||||
flushEvents();
|
||||
}, event).detach();
|
||||
flushEvents();
|
||||
},
|
||||
event)
|
||||
.detach();
|
||||
}
|
||||
|
|
|
@ -12,23 +12,22 @@ struct SHyprIPCEvent {
|
|||
};
|
||||
|
||||
class CEventManager {
|
||||
public:
|
||||
public:
|
||||
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;
|
||||
|
||||
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;
|
||||
};
|
||||
|
|
|
@ -5,47 +5,47 @@
|
|||
CKeybindManager::CKeybindManager() {
|
||||
// initialize all dispatchers
|
||||
|
||||
m_mDispatchers["exec"] = spawn;
|
||||
m_mDispatchers["killactive"] = killActive;
|
||||
m_mDispatchers["closewindow"] = kill;
|
||||
m_mDispatchers["togglefloating"] = toggleActiveFloating;
|
||||
m_mDispatchers["workspace"] = changeworkspace;
|
||||
m_mDispatchers["fullscreen"] = fullscreenActive;
|
||||
m_mDispatchers["movetoworkspace"] = moveActiveToWorkspace;
|
||||
m_mDispatchers["movetoworkspacesilent"] = moveActiveToWorkspaceSilent;
|
||||
m_mDispatchers["pseudo"] = toggleActivePseudo;
|
||||
m_mDispatchers["movefocus"] = moveFocusTo;
|
||||
m_mDispatchers["movewindow"] = moveActiveTo;
|
||||
m_mDispatchers["centerwindow"] = centerWindow;
|
||||
m_mDispatchers["togglegroup"] = toggleGroup;
|
||||
m_mDispatchers["changegroupactive"] = changeGroupActive;
|
||||
m_mDispatchers["togglesplit"] = toggleSplit;
|
||||
m_mDispatchers["splitratio"] = alterSplitRatio;
|
||||
m_mDispatchers["focusmonitor"] = focusMonitor;
|
||||
m_mDispatchers["movecursortocorner"] = moveCursorToCorner;
|
||||
m_mDispatchers["workspaceopt"] = workspaceOpt;
|
||||
m_mDispatchers["exit"] = exitHyprland;
|
||||
m_mDispatchers["exec"] = spawn;
|
||||
m_mDispatchers["killactive"] = killActive;
|
||||
m_mDispatchers["closewindow"] = kill;
|
||||
m_mDispatchers["togglefloating"] = toggleActiveFloating;
|
||||
m_mDispatchers["workspace"] = changeworkspace;
|
||||
m_mDispatchers["fullscreen"] = fullscreenActive;
|
||||
m_mDispatchers["movetoworkspace"] = moveActiveToWorkspace;
|
||||
m_mDispatchers["movetoworkspacesilent"] = moveActiveToWorkspaceSilent;
|
||||
m_mDispatchers["pseudo"] = toggleActivePseudo;
|
||||
m_mDispatchers["movefocus"] = moveFocusTo;
|
||||
m_mDispatchers["movewindow"] = moveActiveTo;
|
||||
m_mDispatchers["centerwindow"] = centerWindow;
|
||||
m_mDispatchers["togglegroup"] = toggleGroup;
|
||||
m_mDispatchers["changegroupactive"] = changeGroupActive;
|
||||
m_mDispatchers["togglesplit"] = toggleSplit;
|
||||
m_mDispatchers["splitratio"] = alterSplitRatio;
|
||||
m_mDispatchers["focusmonitor"] = focusMonitor;
|
||||
m_mDispatchers["movecursortocorner"] = moveCursorToCorner;
|
||||
m_mDispatchers["workspaceopt"] = workspaceOpt;
|
||||
m_mDispatchers["exit"] = exitHyprland;
|
||||
m_mDispatchers["movecurrentworkspacetomonitor"] = moveCurrentWorkspaceToMonitor;
|
||||
m_mDispatchers["moveworkspacetomonitor"] = moveWorkspaceToMonitor;
|
||||
m_mDispatchers["togglespecialworkspace"] = toggleSpecialWorkspace;
|
||||
m_mDispatchers["forcerendererreload"] = forceRendererReload;
|
||||
m_mDispatchers["resizeactive"] = resizeActive;
|
||||
m_mDispatchers["moveactive"] = moveActive;
|
||||
m_mDispatchers["cyclenext"] = circleNext;
|
||||
m_mDispatchers["focuswindowbyclass"] = focusWindow;
|
||||
m_mDispatchers["focuswindow"] = focusWindow;
|
||||
m_mDispatchers["submap"] = setSubmap;
|
||||
m_mDispatchers["pass"] = pass;
|
||||
m_mDispatchers["layoutmsg"] = layoutmsg;
|
||||
m_mDispatchers["toggleopaque"] = toggleOpaque;
|
||||
m_mDispatchers["dpms"] = dpms;
|
||||
m_mDispatchers["movewindowpixel"] = moveWindow;
|
||||
m_mDispatchers["resizewindowpixel"] = resizeWindow;
|
||||
m_mDispatchers["swapnext"] = swapnext;
|
||||
m_mDispatchers["swapactiveworkspaces"] = swapActiveWorkspaces;
|
||||
m_mDispatchers["pin"] = pinActive;
|
||||
m_mDispatchers["mouse"] = mouse;
|
||||
m_mDispatchers["bringactivetotop"] = bringActiveToTop;
|
||||
m_mDispatchers["moveworkspacetomonitor"] = moveWorkspaceToMonitor;
|
||||
m_mDispatchers["togglespecialworkspace"] = toggleSpecialWorkspace;
|
||||
m_mDispatchers["forcerendererreload"] = forceRendererReload;
|
||||
m_mDispatchers["resizeactive"] = resizeActive;
|
||||
m_mDispatchers["moveactive"] = moveActive;
|
||||
m_mDispatchers["cyclenext"] = circleNext;
|
||||
m_mDispatchers["focuswindowbyclass"] = focusWindow;
|
||||
m_mDispatchers["focuswindow"] = focusWindow;
|
||||
m_mDispatchers["submap"] = setSubmap;
|
||||
m_mDispatchers["pass"] = pass;
|
||||
m_mDispatchers["layoutmsg"] = layoutmsg;
|
||||
m_mDispatchers["toggleopaque"] = toggleOpaque;
|
||||
m_mDispatchers["dpms"] = dpms;
|
||||
m_mDispatchers["movewindowpixel"] = moveWindow;
|
||||
m_mDispatchers["resizewindowpixel"] = resizeWindow;
|
||||
m_mDispatchers["swapnext"] = swapnext;
|
||||
m_mDispatchers["swapactiveworkspaces"] = swapActiveWorkspaces;
|
||||
m_mDispatchers["pin"] = pinActive;
|
||||
m_mDispatchers["mouse"] = mouse;
|
||||
m_mDispatchers["bringactivetotop"] = bringActiveToTop;
|
||||
|
||||
m_tScrollTimer.reset();
|
||||
}
|
||||
|
@ -67,8 +67,7 @@ void CKeybindManager::removeKeybind(uint32_t mod, const std::string& key) {
|
|||
if (it == m_lKeybinds.end())
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (it->modmask == mod && it->key == key) {
|
||||
} else if (it->modmask == mod && it->key == key) {
|
||||
it = m_lKeybinds.erase(it);
|
||||
|
||||
if (it == m_lKeybinds.end())
|
||||
|
@ -109,28 +108,27 @@ void CKeybindManager::updateXKBTranslationState() {
|
|||
m_pXKBTranslationState = nullptr;
|
||||
}
|
||||
|
||||
const auto FILEPATH = g_pConfigManager->getString("input:kb_file");
|
||||
const auto RULES = g_pConfigManager->getString("input:kb_rules");
|
||||
const auto MODEL = g_pConfigManager->getString("input:kb_model");
|
||||
const auto LAYOUT = g_pConfigManager->getString("input:kb_layout");
|
||||
const auto VARIANT = g_pConfigManager->getString("input:kb_variant");
|
||||
const auto OPTIONS = g_pConfigManager->getString("input:kb_options");
|
||||
const auto FILEPATH = g_pConfigManager->getString("input:kb_file");
|
||||
const auto RULES = g_pConfigManager->getString("input:kb_rules");
|
||||
const auto MODEL = g_pConfigManager->getString("input:kb_model");
|
||||
const auto LAYOUT = g_pConfigManager->getString("input:kb_layout");
|
||||
const auto VARIANT = g_pConfigManager->getString("input:kb_variant");
|
||||
const auto OPTIONS = g_pConfigManager->getString("input:kb_options");
|
||||
|
||||
xkb_rule_names rules = {
|
||||
.rules = RULES.c_str(),
|
||||
.model = MODEL.c_str(),
|
||||
.layout = LAYOUT.c_str(),
|
||||
.variant = VARIANT.c_str(),
|
||||
.options = OPTIONS.c_str()};
|
||||
xkb_rule_names rules = {.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) {
|
||||
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));
|
||||
|
||||
PKEYMAP = xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||
|
@ -148,7 +146,7 @@ bool CKeybindManager::ensureMouseBindState() {
|
|||
m_bIsMouseBindActive = false;
|
||||
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
||||
g_pInputManager->currentlyDraggedWindow = nullptr;
|
||||
g_pInputManager->dragMode = MBIND_INVALID;
|
||||
g_pInputManager->dragMode = MBIND_INVALID;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -176,9 +174,9 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard
|
|||
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);
|
||||
|
||||
if (handleInternalKeybinds(internalKeysym))
|
||||
|
@ -186,8 +184,8 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard
|
|||
|
||||
const auto MODS = g_pInputManager->accumulateModsFromAllKBs();
|
||||
|
||||
m_uTimeLastMs = e->time_msec;
|
||||
m_uLastCode = KEYCODE;
|
||||
m_uTimeLastMs = e->time_msec;
|
||||
m_uLastCode = KEYCODE;
|
||||
m_uLastMouseCode = 0;
|
||||
|
||||
bool mouseBindWasActive = ensureMouseBindState();
|
||||
|
@ -198,7 +196,7 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard
|
|||
if (m_pActiveKeybindEventSource) {
|
||||
wl_event_source_remove(m_pActiveKeybindEventSource);
|
||||
m_pActiveKeybindEventSource = nullptr;
|
||||
m_pActiveKeybind = nullptr;
|
||||
m_pActiveKeybind = nullptr;
|
||||
}
|
||||
|
||||
m_dPressedKeycodes.push_back(KEYCODE);
|
||||
|
@ -215,7 +213,7 @@ bool CKeybindManager::onKeyEvent(wlr_keyboard_key_event* e, SKeyboard* pKeyboard
|
|||
if (m_pActiveKeybindEventSource) {
|
||||
wl_event_source_remove(m_pActiveKeybindEventSource);
|
||||
m_pActiveKeybindEventSource = nullptr;
|
||||
m_pActiveKeybind = nullptr;
|
||||
m_pActiveKeybind = nullptr;
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
m_tScrollTimer.reset();
|
||||
|
@ -261,11 +259,11 @@ bool CKeybindManager::onAxisEvent(wlr_pointer_axis_event* e) {
|
|||
bool CKeybindManager::onMouseEvent(wlr_pointer_button_event* e) {
|
||||
const auto MODS = g_pInputManager->accumulateModsFromAllKBs();
|
||||
|
||||
bool found = false;
|
||||
bool found = false;
|
||||
|
||||
m_uLastMouseCode = e->button;
|
||||
m_uLastCode = 0;
|
||||
m_uTimeLastMs = e->time_msec;
|
||||
m_uLastCode = 0;
|
||||
m_uTimeLastMs = e->time_msec;
|
||||
|
||||
bool mouseBindWasActive = ensureMouseBindState();
|
||||
|
||||
|
@ -316,7 +314,8 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string&
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
if (!key.empty()) {
|
||||
|
@ -327,11 +326,11 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const std::string&
|
|||
continue;
|
||||
} else {
|
||||
if (keysym == 0)
|
||||
continue; // this is a keycode check run
|
||||
continue; // this is a keycode check run
|
||||
|
||||
// oMg such performance hit!!11!
|
||||
// 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);
|
||||
// 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) {
|
||||
m_pActiveKeybind = &k;
|
||||
m_pActiveKeybind = &k;
|
||||
m_pActiveKeybindEventSource = wl_event_loop_add_timer(g_pCompositor->m_sWLEventLoop, repeatKeyHandler, &m_pActiveKeybind);
|
||||
|
||||
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) {
|
||||
|
||||
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);
|
||||
|
||||
for (auto& pk : m_dPressedKeysyms) {
|
||||
|
@ -433,10 +432,10 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) {
|
|||
|
||||
// vtnr is bugged for some reason.
|
||||
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 {
|
||||
ttynum = std::stoll(TTYSTR);
|
||||
} catch (std::exception &e) {
|
||||
} catch (std::exception& e) {
|
||||
; // oops?
|
||||
}
|
||||
|
||||
|
@ -452,7 +451,7 @@ bool CKeybindManager::handleVT(xkb_keysym_t keysym) {
|
|||
|
||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||
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);
|
||||
|
@ -491,7 +490,7 @@ void CKeybindManager::spawn(std::string args) {
|
|||
if (args[0] == '[') {
|
||||
// we have exec rules
|
||||
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)
|
||||
|
@ -613,7 +612,7 @@ void CKeybindManager::centerWindow(std::string args) {
|
|||
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_vPosition = PWINDOW->m_vRealPosition.goalv();
|
||||
PWINDOW->m_vPosition = PWINDOW->m_vRealPosition.goalv();
|
||||
}
|
||||
|
||||
void CKeybindManager::toggleActivePseudo(std::string args) {
|
||||
|
@ -629,8 +628,8 @@ void CKeybindManager::toggleActivePseudo(std::string args) {
|
|||
}
|
||||
|
||||
void CKeybindManager::changeworkspace(std::string args) {
|
||||
int workspaceToChangeTo = 0;
|
||||
std::string workspaceName = "";
|
||||
int workspaceToChangeTo = 0;
|
||||
std::string workspaceName = "";
|
||||
|
||||
// Flag needed so that the previous workspace is not recorded when switching
|
||||
// to a previous workspace.
|
||||
|
@ -639,7 +638,7 @@ void CKeybindManager::changeworkspace(std::string args) {
|
|||
bool internal = false;
|
||||
|
||||
if (args.find("[internal]") == 0) {
|
||||
workspaceToChangeTo = std::stoi(args.substr(10));
|
||||
workspaceToChangeTo = std::stoi(args.substr(10));
|
||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(workspaceToChangeTo);
|
||||
if (PWORKSPACE)
|
||||
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
|
||||
// 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)
|
||||
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
|
||||
// the current workspace will instead switch to the previous.
|
||||
const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
|
||||
static auto *const PBACKANDFORTH = &g_pConfigManager->getConfigValuePtr("binds:workspace_back_and_forth")->intValue;
|
||||
const auto PCURRENTWORKSPACE = g_pCompositor->getWorkspaceByID(g_pCompositor->m_pLastMonitor->activeWorkspace);
|
||||
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) {
|
||||
|
||||
|
@ -874,7 +873,7 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
|
|||
|
||||
if (args.contains(',')) {
|
||||
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 {
|
||||
PWINDOW = g_pCompositor->m_pLastWindow;
|
||||
}
|
||||
|
@ -886,7 +885,7 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
|
|||
|
||||
// hack
|
||||
std::string workspaceName;
|
||||
const auto WORKSPACEID = getWorkspaceIDFromString(args, workspaceName);
|
||||
const auto WORKSPACEID = getWorkspaceIDFromString(args, workspaceName);
|
||||
|
||||
if (WORKSPACEID == INT_MAX) {
|
||||
Debug::log(LOG, "Invalid workspace in moveActiveToWorkspace");
|
||||
|
@ -898,8 +897,8 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
|
|||
return;
|
||||
}
|
||||
|
||||
auto PSAVEDSIZE = PWINDOW->m_vRealSize.goalv();
|
||||
auto PSAVEDPOS = PWINDOW->m_vRealPosition.goalv();
|
||||
auto PSAVEDSIZE = PWINDOW->m_vRealSize.goalv();
|
||||
auto PSAVEDPOS = PWINDOW->m_vRealPosition.goalv();
|
||||
const bool WASFULLSCREEN = PWINDOW->m_bIsFullscreen;
|
||||
|
||||
g_pLayoutManager->getCurrentLayout()->onWindowRemoved(PWINDOW);
|
||||
|
@ -931,7 +930,8 @@ void CKeybindManager::moveActiveToWorkspace(std::string args) {
|
|||
// and restore it
|
||||
if (PWINDOW->m_bIsFloating) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -952,13 +952,13 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
|||
// hacky, but works lol
|
||||
// TODO: this sucks
|
||||
|
||||
CWindow* PWINDOW = nullptr;
|
||||
CWindow* PWINDOW = nullptr;
|
||||
|
||||
const auto ORIGINALARGS = args;
|
||||
|
||||
if (args.contains(',')) {
|
||||
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 {
|
||||
PWINDOW = g_pCompositor->m_pLastWindow;
|
||||
}
|
||||
|
@ -966,8 +966,8 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
|||
if (!PWINDOW)
|
||||
return;
|
||||
|
||||
int workspaceToMoveTo = 0;
|
||||
std::string workspaceName = "";
|
||||
int workspaceToMoveTo = 0;
|
||||
std::string workspaceName = "";
|
||||
|
||||
workspaceToMoveTo = getWorkspaceIDFromString(args, workspaceName);
|
||||
|
||||
|
@ -992,9 +992,9 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
|||
}
|
||||
|
||||
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);
|
||||
|
||||
g_pEventManager->m_bIgnoreEvents = true;
|
||||
|
@ -1007,7 +1007,7 @@ void CKeybindManager::moveActiveToWorkspaceSilent(std::string args) {
|
|||
changeworkspace("[internal]" + std::to_string(OLDWORKSPACEIDRETURN));
|
||||
|
||||
// revert animations
|
||||
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
|
||||
PWORKSPACE->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
||||
PWORKSPACE->m_fAlpha.setValueAndWarp(0.f);
|
||||
|
||||
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
|
||||
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);
|
||||
PWINDOW->m_iWorkspaceID = workspaceToMoveTo;
|
||||
PWINDOW->m_iWorkspaceID = workspaceToMoveTo;
|
||||
|
||||
g_pCompositor->focusWindow(PNEXTCANDIDATE);
|
||||
}
|
||||
|
@ -1045,10 +1045,9 @@ void CKeybindManager::moveFocusTo(std::string args) {
|
|||
g_pInputManager->unconstrainMouse();
|
||||
|
||||
auto switchToWindow = [&](CWindow* PWINDOWTOCHANGETO) {
|
||||
|
||||
if (PLASTWINDOW->m_iWorkspaceID == PWINDOWTOCHANGETO->m_iWorkspaceID && PLASTWINDOW->m_bIsFullscreen) {
|
||||
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)
|
||||
g_pCompositor->setWindowFullscreen(PLASTWINDOW, false, FULLSCREEN_FULL);
|
||||
|
@ -1084,7 +1083,7 @@ void CKeybindManager::moveFocusTo(std::string args) {
|
|||
}
|
||||
|
||||
void CKeybindManager::moveActiveTo(std::string args) {
|
||||
char arg = args[0];
|
||||
char arg = args[0];
|
||||
|
||||
const auto LASTMONITOR = g_pCompositor->m_pLastMonitor;
|
||||
|
||||
|
@ -1202,15 +1201,18 @@ void CKeybindManager::moveCursorToCorner(std::string arg) {
|
|||
switch (CORNER) {
|
||||
case 0:
|
||||
// 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;
|
||||
case 1:
|
||||
// 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;
|
||||
case 2:
|
||||
// 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;
|
||||
case 3:
|
||||
// top left
|
||||
|
@ -1251,7 +1253,7 @@ void CKeybindManager::workspaceOpt(std::string args) {
|
|||
continue;
|
||||
|
||||
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();
|
||||
|
||||
w->m_bIsFloating = PWORKSPACE->m_bDefaultFloating;
|
||||
|
@ -1261,8 +1263,8 @@ void CKeybindManager::workspaceOpt(std::string args) {
|
|||
w->m_vRealPosition.setValueAndWarp(SAVEDPOS);
|
||||
w->m_vRealSize.setValueAndWarp(SAVEDSIZE);
|
||||
g_pXWaylandManager->setWindowSize(w, SAVEDSIZE);
|
||||
w->m_vRealSize = w->m_vRealSize.vec() + Vector2D(4,4);
|
||||
w->m_vRealPosition = w->m_vRealPosition.vec() - Vector2D(2,2);
|
||||
w->m_vRealSize = w->m_vRealSize.vec() + Vector2D(4, 4);
|
||||
w->m_vRealPosition = w->m_vRealPosition.vec() - Vector2D(2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1299,17 +1301,17 @@ void CKeybindManager::moveWorkspaceToMonitor(std::string args) {
|
|||
return;
|
||||
|
||||
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");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string workspaceName;
|
||||
const int WORKSPACEID = getWorkspaceIDFromString(workspace, workspaceName);
|
||||
const int WORKSPACEID = getWorkspaceIDFromString(workspace, workspaceName);
|
||||
|
||||
if (WORKSPACEID == INT_MAX) {
|
||||
Debug::log(ERR, "moveWorkspaceToMonitor invalid workspace!");
|
||||
|
@ -1328,10 +1330,10 @@ void CKeybindManager::moveWorkspaceToMonitor(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 = "";
|
||||
int workspaceID = getWorkspaceIDFromString("special:" + args, workspaceName);
|
||||
std::string workspaceName = "";
|
||||
int workspaceID = getWorkspaceIDFromString("special:" + args, workspaceName);
|
||||
|
||||
if (workspaceID == INT_MAX || !g_pCompositor->isWorkspaceSpecial(workspaceID)) {
|
||||
Debug::log(ERR, "Invalid workspace passed to special");
|
||||
|
@ -1343,9 +1345,9 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) {
|
|||
return;
|
||||
}
|
||||
|
||||
bool requestedWorkspaceIsAlreadyOpen = false;
|
||||
const auto PMONITOR = *PFOLLOWMOUSE == 1 ? g_pCompositor->getMonitorFromCursor() : g_pCompositor->m_pLastMonitor;
|
||||
int specialOpenOnMonitor = PMONITOR->specialWorkspaceID;
|
||||
bool requestedWorkspaceIsAlreadyOpen = false;
|
||||
const auto PMONITOR = *PFOLLOWMOUSE == 1 ? g_pCompositor->getMonitorFromCursor() : g_pCompositor->m_pLastMonitor;
|
||||
int specialOpenOnMonitor = PMONITOR->specialWorkspaceID;
|
||||
|
||||
for (auto& m : g_pCompositor->m_vMonitors) {
|
||||
if (m->specialWorkspaceID == workspaceID) {
|
||||
|
@ -1382,7 +1384,7 @@ void CKeybindManager::toggleSpecialWorkspace(std::string args) {
|
|||
|
||||
// move to current
|
||||
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;
|
||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(POLDMON->ID);
|
||||
|
@ -1451,8 +1453,8 @@ void CKeybindManager::resizeActive(std::string args) {
|
|||
}
|
||||
|
||||
void CKeybindManager::moveActive(std::string args) {
|
||||
if (!g_pCompositor->m_pLastWindow || g_pCompositor->m_pLastWindow->m_bIsFullscreen)
|
||||
return;
|
||||
if (!g_pCompositor->m_pLastWindow || g_pCompositor->m_pLastWindow->m_bIsFullscreen)
|
||||
return;
|
||||
|
||||
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) {
|
||||
|
||||
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);
|
||||
|
||||
|
@ -1482,7 +1484,7 @@ void CKeybindManager::moveWindow(std::string args) {
|
|||
void CKeybindManager::resizeWindow(std::string args) {
|
||||
|
||||
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);
|
||||
|
||||
|
@ -1491,10 +1493,10 @@ void CKeybindManager::resizeWindow(std::string args) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (PWINDOW->m_bIsFullscreen)
|
||||
return;
|
||||
if (PWINDOW->m_bIsFullscreen)
|
||||
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);
|
||||
|
||||
|
@ -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) {
|
||||
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)
|
||||
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);
|
||||
|
||||
if (!KEYBOARD){
|
||||
if (!KEYBOARD) {
|
||||
Debug::log(ERR, "No kb in pass?");
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
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_keyboard_modifiers kbmods = {g_pInputManager->accumulateModsFromAllKBs(), 0, 0, 0};
|
||||
wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &kbmods);
|
||||
|
||||
|
@ -1640,10 +1641,10 @@ void CKeybindManager::pass(std::string regexp) {
|
|||
// please kill me
|
||||
if (PWINDOW->m_bIsX11) {
|
||||
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;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
@ -1665,15 +1666,15 @@ void CKeybindManager::toggleOpaque(std::string unused) {
|
|||
if (!PWINDOW)
|
||||
return;
|
||||
|
||||
PWINDOW->m_sAdditionalConfigData.forceOpaque = !PWINDOW->m_sAdditionalConfigData.forceOpaque;
|
||||
PWINDOW->m_sAdditionalConfigData.forceOpaque = !PWINDOW->m_sAdditionalConfigData.forceOpaque;
|
||||
PWINDOW->m_sAdditionalConfigData.forceOpaqueOverriden = true;
|
||||
|
||||
g_pHyprRenderer->damageWindow(PWINDOW);
|
||||
}
|
||||
|
||||
void CKeybindManager::dpms(std::string arg) {
|
||||
bool enable = arg.find("on") == 0;
|
||||
std::string port = "";
|
||||
bool enable = arg.find("on") == 0;
|
||||
std::string port = "";
|
||||
|
||||
if (arg.find_first_of(' ') != std::string::npos) {
|
||||
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 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")
|
||||
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)
|
||||
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->updateDynamicRules();
|
||||
|
@ -1767,7 +1771,7 @@ void CKeybindManager::mouse(std::string args) {
|
|||
g_pKeybindManager->m_bIsMouseBindActive = true;
|
||||
|
||||
g_pInputManager->currentlyDraggedWindow = g_pCompositor->vectorToWindowIdeal(g_pInputManager->getMouseCoordsInternal());
|
||||
g_pInputManager->dragMode = MBIND_MOVE;
|
||||
g_pInputManager->dragMode = MBIND_MOVE;
|
||||
|
||||
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
|
||||
} else {
|
||||
|
@ -1776,7 +1780,7 @@ void CKeybindManager::mouse(std::string args) {
|
|||
if (g_pInputManager->currentlyDraggedWindow) {
|
||||
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
||||
g_pInputManager->currentlyDraggedWindow = nullptr;
|
||||
g_pInputManager->dragMode = MBIND_INVALID;
|
||||
g_pInputManager->dragMode = MBIND_INVALID;
|
||||
}
|
||||
}
|
||||
} else if (TRUEARG == "resizewindow") {
|
||||
|
@ -1784,7 +1788,7 @@ void CKeybindManager::mouse(std::string args) {
|
|||
g_pKeybindManager->m_bIsMouseBindActive = true;
|
||||
|
||||
g_pInputManager->currentlyDraggedWindow = g_pCompositor->vectorToWindowIdeal(g_pInputManager->getMouseCoordsInternal());
|
||||
g_pInputManager->dragMode = MBIND_RESIZE;
|
||||
g_pInputManager->dragMode = MBIND_RESIZE;
|
||||
|
||||
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
|
||||
} else {
|
||||
|
@ -1793,7 +1797,7 @@ void CKeybindManager::mouse(std::string args) {
|
|||
if (g_pInputManager->currentlyDraggedWindow) {
|
||||
g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
|
||||
g_pInputManager->currentlyDraggedWindow = nullptr;
|
||||
g_pInputManager->dragMode = MBIND_INVALID;
|
||||
g_pInputManager->dragMode = MBIND_INVALID;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,22 +10,23 @@ class CInputManager;
|
|||
class CConfigManager;
|
||||
|
||||
struct SKeybind {
|
||||
std::string key = "";
|
||||
int keycode = -1;
|
||||
uint32_t modmask = 0;
|
||||
std::string handler = "";
|
||||
std::string arg = "";
|
||||
bool locked = false;
|
||||
std::string submap = "";
|
||||
bool release = false;
|
||||
bool repeat = false;
|
||||
bool mouse = false;
|
||||
std::string key = "";
|
||||
int keycode = -1;
|
||||
uint32_t modmask = 0;
|
||||
std::string handler = "";
|
||||
std::string arg = "";
|
||||
bool locked = false;
|
||||
std::string submap = "";
|
||||
bool release = false;
|
||||
bool repeat = false;
|
||||
bool mouse = false;
|
||||
|
||||
// DO NOT INITIALIZE
|
||||
bool shadowed = false;
|
||||
bool shadowed = false;
|
||||
};
|
||||
|
||||
enum eFocusWindowMode {
|
||||
enum eFocusWindowMode
|
||||
{
|
||||
MODE_CLASS_REGEX = 0,
|
||||
MODE_TITLE_REGEX,
|
||||
MODE_ADDRESS,
|
||||
|
@ -33,96 +34,96 @@ enum eFocusWindowMode {
|
|||
};
|
||||
|
||||
class CKeybindManager {
|
||||
public:
|
||||
public:
|
||||
CKeybindManager();
|
||||
|
||||
bool onKeyEvent(wlr_keyboard_key_event*, SKeyboard*);
|
||||
bool onAxisEvent(wlr_pointer_axis_event*);
|
||||
bool onMouseEvent(wlr_pointer_button_event*);
|
||||
void onSwitchEvent(const std::string&);
|
||||
bool onKeyEvent(wlr_keyboard_key_event*, SKeyboard*);
|
||||
bool onAxisEvent(wlr_pointer_axis_event*);
|
||||
bool onMouseEvent(wlr_pointer_button_event*);
|
||||
void onSwitchEvent(const std::string&);
|
||||
|
||||
void addKeybind(SKeybind);
|
||||
void removeKeybind(uint32_t, const std::string&);
|
||||
uint32_t stringToModMask(std::string);
|
||||
void clearKeybinds();
|
||||
void shadowKeybinds(const xkb_keysym_t& doesntHave = 0, const int& doesntHaveCode = 0);
|
||||
void addKeybind(SKeybind);
|
||||
void removeKeybind(uint32_t, const std::string&);
|
||||
uint32_t stringToModMask(std::string);
|
||||
void clearKeybinds();
|
||||
void shadowKeybinds(const xkb_keysym_t& doesntHave = 0, const int& doesntHaveCode = 0);
|
||||
|
||||
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:
|
||||
std::list<SKeybind> m_lKeybinds;
|
||||
std::deque<xkb_keysym_t> m_dPressedKeysyms;
|
||||
std::deque<int> m_dPressedKeycodes;
|
||||
private:
|
||||
std::list<SKeybind> m_lKeybinds;
|
||||
std::deque<xkb_keysym_t> m_dPressedKeysyms;
|
||||
std::deque<int> m_dPressedKeycodes;
|
||||
|
||||
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_uLastCode = 0;
|
||||
uint32_t m_uLastMouseCode = 0;
|
||||
uint32_t m_uTimeLastMs = 0;
|
||||
uint32_t m_uLastCode = 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 handleVT(xkb_keysym_t);
|
||||
bool handleInternalKeybinds(xkb_keysym_t);
|
||||
bool handleVT(xkb_keysym_t);
|
||||
|
||||
xkb_state* m_pXKBTranslationState = nullptr;
|
||||
xkb_state* m_pXKBTranslationState = nullptr;
|
||||
|
||||
void updateXKBTranslationState();
|
||||
bool ensureMouseBindState();
|
||||
void updateXKBTranslationState();
|
||||
bool ensureMouseBindState();
|
||||
|
||||
// -------------- Dispatchers -------------- //
|
||||
static void killActive(std::string);
|
||||
static void kill(std::string);
|
||||
static void spawn(std::string);
|
||||
static void toggleActiveFloating(std::string);
|
||||
static void toggleActivePseudo(std::string);
|
||||
static void changeworkspace(std::string);
|
||||
static void fullscreenActive(std::string);
|
||||
static void moveActiveToWorkspace(std::string);
|
||||
static void moveActiveToWorkspaceSilent(std::string);
|
||||
static void moveFocusTo(std::string);
|
||||
static void centerWindow(std::string);
|
||||
static void moveActiveTo(std::string);
|
||||
static void toggleGroup(std::string);
|
||||
static void changeGroupActive(std::string);
|
||||
static void alterSplitRatio(std::string);
|
||||
static void focusMonitor(std::string);
|
||||
static void toggleSplit(std::string);
|
||||
static void moveCursorToCorner(std::string);
|
||||
static void workspaceOpt(std::string);
|
||||
static void exitHyprland(std::string);
|
||||
static void moveCurrentWorkspaceToMonitor(std::string);
|
||||
static void moveWorkspaceToMonitor(std::string);
|
||||
static void toggleSpecialWorkspace(std::string);
|
||||
static void forceRendererReload(std::string);
|
||||
static void resizeActive(std::string);
|
||||
static void moveActive(std::string);
|
||||
static void moveWindow(std::string);
|
||||
static void resizeWindow(std::string);
|
||||
static void circleNext(std::string);
|
||||
static void focusWindow(std::string);
|
||||
static void setSubmap(std::string);
|
||||
static void pass(std::string);
|
||||
static void layoutmsg(std::string);
|
||||
static void toggleOpaque(std::string);
|
||||
static void dpms(std::string);
|
||||
static void swapnext(std::string);
|
||||
static void swapActiveWorkspaces(std::string);
|
||||
static void pinActive(std::string);
|
||||
static void mouse(std::string);
|
||||
static void bringActiveToTop(std::string);
|
||||
static void killActive(std::string);
|
||||
static void kill(std::string);
|
||||
static void spawn(std::string);
|
||||
static void toggleActiveFloating(std::string);
|
||||
static void toggleActivePseudo(std::string);
|
||||
static void changeworkspace(std::string);
|
||||
static void fullscreenActive(std::string);
|
||||
static void moveActiveToWorkspace(std::string);
|
||||
static void moveActiveToWorkspaceSilent(std::string);
|
||||
static void moveFocusTo(std::string);
|
||||
static void centerWindow(std::string);
|
||||
static void moveActiveTo(std::string);
|
||||
static void toggleGroup(std::string);
|
||||
static void changeGroupActive(std::string);
|
||||
static void alterSplitRatio(std::string);
|
||||
static void focusMonitor(std::string);
|
||||
static void toggleSplit(std::string);
|
||||
static void moveCursorToCorner(std::string);
|
||||
static void workspaceOpt(std::string);
|
||||
static void exitHyprland(std::string);
|
||||
static void moveCurrentWorkspaceToMonitor(std::string);
|
||||
static void moveWorkspaceToMonitor(std::string);
|
||||
static void toggleSpecialWorkspace(std::string);
|
||||
static void forceRendererReload(std::string);
|
||||
static void resizeActive(std::string);
|
||||
static void moveActive(std::string);
|
||||
static void moveWindow(std::string);
|
||||
static void resizeWindow(std::string);
|
||||
static void circleNext(std::string);
|
||||
static void focusWindow(std::string);
|
||||
static void setSubmap(std::string);
|
||||
static void pass(std::string);
|
||||
static void layoutmsg(std::string);
|
||||
static void toggleOpaque(std::string);
|
||||
static void dpms(std::string);
|
||||
static void swapnext(std::string);
|
||||
static void swapActiveWorkspaces(std::string);
|
||||
static void pinActive(std::string);
|
||||
static void mouse(std::string);
|
||||
static void bringActiveToTop(std::string);
|
||||
|
||||
friend class CCompositor;
|
||||
friend class CInputManager;
|
||||
|
|
|
@ -2,10 +2,8 @@
|
|||
|
||||
IHyprLayout* CLayoutManager::getCurrentLayout() {
|
||||
switch (m_iCurrentLayoutID) {
|
||||
case DWINDLE:
|
||||
return &m_cDwindleLayout;
|
||||
case MASTER:
|
||||
return &m_cMasterLayout;
|
||||
case DWINDLE: return &m_cDwindleLayout;
|
||||
case MASTER: return &m_cMasterLayout;
|
||||
}
|
||||
|
||||
// fallback
|
||||
|
|
|
@ -4,19 +4,19 @@
|
|||
#include "../layout/MasterLayout.hpp"
|
||||
|
||||
class CLayoutManager {
|
||||
public:
|
||||
public:
|
||||
IHyprLayout* getCurrentLayout();
|
||||
|
||||
IHyprLayout* getCurrentLayout();
|
||||
void switchToLayout(std::string);
|
||||
|
||||
void switchToLayout(std::string);
|
||||
|
||||
private:
|
||||
enum HYPRLAYOUTS {
|
||||
private:
|
||||
enum HYPRLAYOUTS
|
||||
{
|
||||
DWINDLE = 0,
|
||||
MASTER
|
||||
};
|
||||
|
||||
HYPRLAYOUTS m_iCurrentLayoutID = DWINDLE;
|
||||
HYPRLAYOUTS m_iCurrentLayoutID = DWINDLE;
|
||||
|
||||
CHyprDwindleLayout m_cDwindleLayout;
|
||||
CHyprMasterLayout m_cMasterLayout;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include "../protocols/ToplevelExport.hpp"
|
||||
|
||||
class CProtocolManager {
|
||||
public:
|
||||
public:
|
||||
CProtocolManager();
|
||||
|
||||
std::unique_ptr<CToplevelExportProtocolManager> m_pToplevelExportProtocolManager;
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
int slowUpdate = 0;
|
||||
|
||||
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)
|
||||
g_pConfigManager->tick();
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
#include "../Compositor.hpp"
|
||||
|
||||
class CThreadManager {
|
||||
public:
|
||||
public:
|
||||
CThreadManager();
|
||||
~CThreadManager();
|
||||
|
||||
wl_event_source* m_esConfigTimer;
|
||||
|
||||
private:
|
||||
private:
|
||||
};
|
||||
|
||||
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);
|
||||
#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
|
||||
}
|
||||
|
||||
CHyprXWaylandManager::~CHyprXWaylandManager() {
|
||||
|
||||
}
|
||||
CHyprXWaylandManager::~CHyprXWaylandManager() {}
|
||||
|
||||
wlr_surface* CHyprXWaylandManager::getWindowSurface(CWindow* pWindow) {
|
||||
if (pWindow->m_bIsX11)
|
||||
|
@ -48,7 +46,6 @@ void CHyprXWaylandManager::activateSurface(wlr_surface* pSurface, bool activate)
|
|||
if (activate)
|
||||
wlr_xwayland_surface_restack(wlr_xwayland_surface_from_wlr_surface(pSurface), NULL, XCB_STACK_MODE_ABOVE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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_restack(pWindow->m_uSurface.xwayland, NULL, XCB_STACK_MODE_ABOVE);
|
||||
}
|
||||
|
||||
|
||||
wlr_xwayland_surface_activate(pWindow->m_uSurface.xwayland, activate);
|
||||
}
|
||||
else
|
||||
} else
|
||||
wlr_xdg_toplevel_set_activated(pWindow->m_uSurface.xdg->toplevel, activate);
|
||||
|
||||
if (activate) {
|
||||
g_pCompositor->m_pLastFocus = getWindowSurface(pWindow);
|
||||
g_pCompositor->m_pLastFocus = getWindowSurface(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;
|
||||
|
||||
if (SIZEHINTS && pWindow->m_iX11Type != 2) {
|
||||
pbox->x = SIZEHINTS->x;
|
||||
pbox->y = SIZEHINTS->y;
|
||||
pbox->width = SIZEHINTS->width;
|
||||
pbox->x = SIZEHINTS->x;
|
||||
pbox->y = SIZEHINTS->y;
|
||||
pbox->width = SIZEHINTS->width;
|
||||
pbox->height = SIZEHINTS->height;
|
||||
} else {
|
||||
pbox->x = pWindow->m_uSurface.xwayland->x;
|
||||
pbox->y = pWindow->m_uSurface.xwayland->y;
|
||||
pbox->width = pWindow->m_uSurface.xwayland->width;
|
||||
pbox->x = pWindow->m_uSurface.xwayland->x;
|
||||
pbox->y = pWindow->m_uSurface.xwayland->y;
|
||||
pbox->width = pWindow->m_uSurface.xwayland->width;
|
||||
pbox->height = pWindow->m_uSurface.xwayland->height;
|
||||
}
|
||||
} else {
|
||||
|
@ -106,9 +102,7 @@ std::string CHyprXWaylandManager::getTitle(CWindow* pWindow) {
|
|||
} else {
|
||||
return "";
|
||||
}
|
||||
} catch (...) {
|
||||
Debug::log(ERR, "Error in getTitle (probably null title)");
|
||||
}
|
||||
} catch (...) { Debug::log(ERR, "Error in getTitle (probably null title)"); }
|
||||
|
||||
return "";
|
||||
}
|
||||
|
@ -129,9 +123,7 @@ std::string CHyprXWaylandManager::getAppIDClass(CWindow* pWindow) {
|
|||
} else {
|
||||
return "";
|
||||
}
|
||||
} catch (std::logic_error& e) {
|
||||
Debug::log(ERR, "Error in getAppIDClass: %s", e.what());
|
||||
}
|
||||
} catch (std::logic_error& e) { Debug::log(ERR, "Error in getAppIDClass: %s", e.what()); }
|
||||
|
||||
return "";
|
||||
}
|
||||
|
@ -146,11 +138,12 @@ void CHyprXWaylandManager::sendCloseWindow(CWindow* pWindow) {
|
|||
|
||||
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;
|
||||
|
||||
pWindow->m_vReportedPosition = pWindow->m_vRealPosition.vec();
|
||||
pWindow->m_vReportedSize = size;
|
||||
pWindow->m_vReportedSize = size;
|
||||
|
||||
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);
|
||||
|
@ -173,18 +166,23 @@ wlr_surface* CHyprXWaylandManager::surfaceAt(CWindow* pWindow, const Vector2D& c
|
|||
bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) {
|
||||
if (pWindow->m_bIsX11) {
|
||||
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"] ||
|
||||
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_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_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_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;
|
||||
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"] ||
|
||||
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_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_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_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;
|
||||
return true;
|
||||
}
|
||||
pWindow->m_bNoInitialFocus = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pWindow->m_uSurface.xwayland->role) {
|
||||
try {
|
||||
|
@ -192,9 +190,7 @@ bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) {
|
|||
if (winrole.contains("pop-up") || winrole.contains("task_dialog")) {
|
||||
return true;
|
||||
}
|
||||
} catch (std::exception& e) {
|
||||
Debug::log(ERR, "Error in shouldBeFloated, winrole threw %s", e.what());
|
||||
}
|
||||
} catch (std::exception& e) { Debug::log(ERR, "Error in shouldBeFloated, winrole threw %s", e.what()); }
|
||||
}
|
||||
|
||||
if (pWindow->m_uSurface.xwayland->modal) {
|
||||
|
@ -212,7 +208,8 @@ bool CHyprXWaylandManager::shouldBeFloated(CWindow* pWindow) {
|
|||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -233,9 +230,12 @@ void CHyprXWaylandManager::checkBorders(CWindow* pWindow) {
|
|||
return;
|
||||
|
||||
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"] ||
|
||||
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"] ||
|
||||
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"] ||
|
||||
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_bX11DoesntWantBorders = true;
|
||||
|
@ -263,11 +263,12 @@ Vector2D CHyprXWaylandManager::getMaxSizeForWindow(CWindow* pWindow) {
|
|||
if (!g_pCompositor->windowValidMapped(pWindow))
|
||||
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);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
if (MAXSIZE.x < 5)
|
||||
MAXSIZE.x = 99999;
|
||||
|
|
|
@ -4,27 +4,27 @@
|
|||
#include "../Window.hpp"
|
||||
|
||||
class CHyprXWaylandManager {
|
||||
public:
|
||||
public:
|
||||
CHyprXWaylandManager();
|
||||
~CHyprXWaylandManager();
|
||||
|
||||
wlr_xwayland* m_sWLRXWayland = nullptr;
|
||||
wlr_xwayland* m_sWLRXWayland = nullptr;
|
||||
|
||||
wlr_surface* getWindowSurface(CWindow*);
|
||||
void activateSurface(wlr_surface*, bool);
|
||||
void activateWindow(CWindow*, bool);
|
||||
void getGeometryForWindow(CWindow*, wlr_box*);
|
||||
std::string getTitle(CWindow*);
|
||||
std::string getAppIDClass(CWindow*);
|
||||
void sendCloseWindow(CWindow*);
|
||||
void setWindowSize(CWindow*, const Vector2D&, bool force = false);
|
||||
void setWindowStyleTiled(CWindow*, uint32_t);
|
||||
void setWindowFullscreen(CWindow*, bool);
|
||||
wlr_surface* surfaceAt(CWindow*, const Vector2D&, Vector2D&);
|
||||
bool shouldBeFloated(CWindow*);
|
||||
void moveXWaylandWindow(CWindow*, const Vector2D&);
|
||||
void checkBorders(CWindow*);
|
||||
Vector2D getMaxSizeForWindow(CWindow*);
|
||||
wlr_surface* getWindowSurface(CWindow*);
|
||||
void activateSurface(wlr_surface*, bool);
|
||||
void activateWindow(CWindow*, bool);
|
||||
void getGeometryForWindow(CWindow*, wlr_box*);
|
||||
std::string getTitle(CWindow*);
|
||||
std::string getAppIDClass(CWindow*);
|
||||
void sendCloseWindow(CWindow*);
|
||||
void setWindowSize(CWindow*, const Vector2D&, bool force = false);
|
||||
void setWindowStyleTiled(CWindow*, uint32_t);
|
||||
void setWindowFullscreen(CWindow*, bool);
|
||||
wlr_surface* surfaceAt(CWindow*, const Vector2D&, Vector2D&);
|
||||
bool shouldBeFloated(CWindow*);
|
||||
void moveXWaylandWindow(CWindow*, const Vector2D&);
|
||||
void checkBorders(CWindow*);
|
||||
Vector2D getMaxSizeForWindow(CWindow*);
|
||||
};
|
||||
|
||||
inline std::unique_ptr<CHyprXWaylandManager> g_pXWaylandManager;
|
|
@ -17,17 +17,18 @@ void CInputManager::newIdleInhibitor(wlr_idle_inhibitor_v1* 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();
|
||||
|
||||
}, PINHIBIT, "IdleInhibitor");
|
||||
g_pInputManager->recheckIdleInhibitorStatus();
|
||||
},
|
||||
PINHIBIT, "IdleInhibitor");
|
||||
|
||||
PINHIBIT->pWindow = g_pCompositor->getWindowFromSurface(pInhibitor->surface);
|
||||
|
||||
|
|
|
@ -2,16 +2,18 @@
|
|||
#include "../../Compositor.hpp"
|
||||
|
||||
void CInputManager::onMouseMoved(wlr_pointer_motion_event* e) {
|
||||
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 PSENS = &g_pConfigManager->getConfigValuePtr("general:sensitivity")->floatValue;
|
||||
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;
|
||||
|
||||
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)
|
||||
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
|
||||
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);
|
||||
|
||||
|
@ -29,19 +31,19 @@ void CInputManager::onMouseWarp(wlr_pointer_motion_absolute_event* e) {
|
|||
}
|
||||
|
||||
void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
||||
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 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 PFLOATBEHAVIOR = &g_pConfigManager->getConfigValuePtr("input:float_switch_override_focus")->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 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 PFLOATBEHAVIOR = &g_pConfigManager->getConfigValuePtr("input:float_switch_override_focus")->intValue;
|
||||
|
||||
m_pFoundSurfaceToFocus = nullptr;
|
||||
m_pFoundLSToFocus = nullptr;
|
||||
m_pFoundWindowToFocus = nullptr;
|
||||
wlr_surface* foundSurface = nullptr;
|
||||
Vector2D surfaceCoords;
|
||||
Vector2D surfacePos = Vector2D(-1337, -1337);
|
||||
CWindow* pFoundWindow = nullptr;
|
||||
m_pFoundSurfaceToFocus = nullptr;
|
||||
m_pFoundLSToFocus = nullptr;
|
||||
m_pFoundWindowToFocus = nullptr;
|
||||
wlr_surface* foundSurface = nullptr;
|
||||
Vector2D surfaceCoords;
|
||||
Vector2D surfacePos = Vector2D(-1337, -1337);
|
||||
CWindow* pFoundWindow = nullptr;
|
||||
SLayerSurface* pFoundLayerSurface = nullptr;
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
Vector2D mouseCoords = getMouseCoordsInternal();
|
||||
Vector2D mouseCoords = getMouseCoordsInternal();
|
||||
const auto MOUSECOORDSFLOORED = mouseCoords.floor();
|
||||
|
||||
if (MOUSECOORDSFLOORED == m_vLastCursorPosFloored && !refocus)
|
||||
|
@ -73,20 +75,22 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
// XWayland windows sometimes issue constraints weirdly.
|
||||
// TODO: We probably should search their parent. wlr_xwayland_surface->parent
|
||||
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) {
|
||||
unconstrainMouse();
|
||||
} else {
|
||||
// Native Wayland apps know how 2 constrain themselves.
|
||||
// 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 CONSTRAINTSIZE = CONSTRAINTWINDOW->m_bIsX11 ? Vector2D(CONSTRAINTWINDOW->m_uSurface.xwayland->width, CONSTRAINTWINDOW->m_uSurface.xwayland->height) : CONSTRAINTWINDOW->m_vRealSize.vec();
|
||||
const auto CONSTRAINTPOS =
|
||||
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) {
|
||||
// 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);
|
||||
|
||||
|
@ -108,7 +112,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
|
||||
if (CONSTRAINTWINDOW->m_bIsX11) {
|
||||
foundSurface = g_pXWaylandManager->getWindowSurface(CONSTRAINTWINDOW);
|
||||
surfacePos = CONSTRAINTWINDOW->m_vRealPosition.vec();
|
||||
surfacePos = CONSTRAINTWINDOW->m_vRealPosition.vec();
|
||||
} else {
|
||||
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
|
||||
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};
|
||||
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();
|
||||
break;
|
||||
}
|
||||
|
@ -160,10 +166,10 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
|
||||
if (!pFoundWindow->m_bIsX11) {
|
||||
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
|
||||
surfacePos = Vector2D(-1337, -1337);
|
||||
surfacePos = Vector2D(-1337, -1337);
|
||||
} else {
|
||||
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);
|
||||
|
||||
// TODO: this causes crashes, sometimes. ???
|
||||
// if (refocus && !pFoundWindow) {
|
||||
// pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace);
|
||||
// }
|
||||
// if (refocus && !pFoundWindow) {
|
||||
// pFoundWindow = g_pCompositor->getFirstWindowOnWorkspace(PMONITOR->activeWorkspace);
|
||||
// }
|
||||
}
|
||||
|
||||
if (pFoundWindow) {
|
||||
|
@ -197,7 +203,7 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
foundSurface = g_pCompositor->vectorWindowToSurface(mouseCoords, pFoundWindow, surfaceCoords);
|
||||
} else {
|
||||
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);
|
||||
else
|
||||
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "left_ptr", g_pCompositor->m_sWLRCursor);
|
||||
|
||||
|
||||
m_bEmptyFocusCursorSet = true;
|
||||
}
|
||||
|
||||
|
@ -258,14 +264,15 @@ void CInputManager::mouseMoveUnified(uint32_t time, bool refocus) {
|
|||
|
||||
// set the values for use
|
||||
if (refocus) {
|
||||
m_pFoundLSToFocus = pFoundLayerSurface;
|
||||
m_pFoundWindowToFocus = pFoundWindow;
|
||||
m_pFoundLSToFocus = pFoundLayerSurface;
|
||||
m_pFoundWindowToFocus = pFoundWindow;
|
||||
m_pFoundSurfaceToFocus = foundSurface;
|
||||
}
|
||||
|
||||
if (pFoundWindow) {
|
||||
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
|
||||
if (*PFOLLOWMOUSE != 3 && allowKeyboardRefocus)
|
||||
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);
|
||||
|
||||
m_bLastFocusOnLS = false;
|
||||
return; // don't enter any new surfaces
|
||||
return; // don't enter any new surfaces
|
||||
} else {
|
||||
if ((*PFOLLOWMOUSE != 3 && allowKeyboardRefocus) || refocus)
|
||||
g_pCompositor->focusWindow(pFoundWindow, foundSurface);
|
||||
|
@ -315,14 +322,9 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
|
|||
m_tmrLastCursorMovement.reset();
|
||||
|
||||
switch (m_ecbClickBehavior) {
|
||||
case CLICKMODE_DEFAULT:
|
||||
processMouseDownNormal(e);
|
||||
break;
|
||||
case CLICKMODE_KILL:
|
||||
processMouseDownKill(e);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case CLICKMODE_DEFAULT: processMouseDownNormal(e); break;
|
||||
case CLICKMODE_KILL: processMouseDownKill(e); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,17 +374,16 @@ void CInputManager::setClickMode(eClickBehaviorMode mode) {
|
|||
// set cursor
|
||||
wlr_xcursor_manager_set_cursor_image(g_pCompositor->m_sWLRXCursorMgr, "crosshair", g_pCompositor->m_sWLRCursor);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
|
||||
|
||||
|
||||
// notify the keybind manager
|
||||
static auto *const PPASSMOUSE = &g_pConfigManager->getConfigValuePtr("binds:pass_mouse_when_bound")->intValue;
|
||||
const auto PASS = g_pKeybindManager->onMouseEvent(e);
|
||||
static auto *const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
||||
static auto* const PPASSMOUSE = &g_pConfigManager->getConfigValuePtr("binds:pass_mouse_when_bound")->intValue;
|
||||
const auto PASS = g_pKeybindManager->onMouseEvent(e);
|
||||
static auto* const PFOLLOWMOUSE = &g_pConfigManager->getConfigValuePtr("input:follow_mouse")->intValue;
|
||||
|
||||
if (!PASS && !*PPASSMOUSE)
|
||||
return;
|
||||
|
@ -400,8 +401,7 @@ void CInputManager::processMouseDownNormal(wlr_pointer_button_event* e) {
|
|||
g_pCompositor->moveWindowToTop(g_pCompositor->m_pLastWindow);
|
||||
|
||||
break;
|
||||
case WLR_BUTTON_RELEASED:
|
||||
break;
|
||||
case WLR_BUTTON_RELEASED: break;
|
||||
}
|
||||
|
||||
// notify app if we didnt handle it
|
||||
|
@ -424,10 +424,8 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_event* e) {
|
|||
kill(PWINDOW->getPID(), SIGKILL);
|
||||
break;
|
||||
}
|
||||
case WLR_BUTTON_RELEASED:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case WLR_BUTTON_RELEASED: break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
// reset click behavior mode
|
||||
|
@ -435,17 +433,16 @@ void CInputManager::processMouseDownKill(wlr_pointer_button_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);
|
||||
|
||||
if (passEvent) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,19 +458,21 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
|
|||
try {
|
||||
PNEWKEYBOARD->name = getNameForNewDevice(keyboard->name);
|
||||
} 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_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_keyboardKeymap.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.keymap, [&](void* owner, void* data) {
|
||||
const auto PKEYBOARD = (SKeyboard*)owner;
|
||||
PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(
|
||||
&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
|
||||
|
||||
}, PNEWKEYBOARD, "Keyboard");
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," + getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
|
||||
},
|
||||
PNEWKEYBOARD, "Keyboard");
|
||||
|
||||
disableAllKeyboards(false);
|
||||
|
||||
|
@ -491,24 +490,26 @@ void CInputManager::newKeyboard(wlr_input_device* keyboard) {
|
|||
void CInputManager::newVirtualKeyboard(wlr_input_device* keyboard) {
|
||||
const auto PNEWKEYBOARD = &m_lKeyboards.emplace_back();
|
||||
|
||||
PNEWKEYBOARD->keyboard = keyboard;
|
||||
PNEWKEYBOARD->keyboard = keyboard;
|
||||
PNEWKEYBOARD->isVirtual = true;
|
||||
|
||||
try {
|
||||
PNEWKEYBOARD->name = getNameForNewDevice(keyboard->name);
|
||||
} 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_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_keyboardKeymap.initCallback(&wlr_keyboard_from_input_device(keyboard)->events.keymap, [&](void* owner, void* data) {
|
||||
const auto PKEYBOARD = (SKeyboard*)owner;
|
||||
PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(
|
||||
&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
|
||||
|
||||
}, PNEWKEYBOARD, "Keyboard");
|
||||
g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," + getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
|
||||
},
|
||||
PNEWKEYBOARD, "Keyboard");
|
||||
|
||||
disableAllKeyboards(true);
|
||||
|
||||
|
@ -531,7 +532,7 @@ void CInputManager::setKeyboardLayout() {
|
|||
}
|
||||
|
||||
void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
|
||||
auto devname = pKeyboard->name;
|
||||
auto devname = pKeyboard->name;
|
||||
|
||||
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
|
||||
|
||||
|
@ -542,20 +543,22 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
|
|||
if (!wlr_keyboard_from_input_device(pKeyboard->keyboard))
|
||||
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 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 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 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 OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_options") : g_pConfigManager->getString("input:kb_options");
|
||||
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 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 OPTIONS = HASCONFIG ? g_pConfigManager->getDeviceString(devname, "kb_options") : g_pConfigManager->getString("input:kb_options");
|
||||
|
||||
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.");
|
||||
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));
|
||||
|
||||
pKeyboard->repeatDelay = REPEATDELAY;
|
||||
pKeyboard->repeatRate = REPEATRATE;
|
||||
pKeyboard->numlockOn = NUMLOCKON;
|
||||
pKeyboard->repeatRate = REPEATRATE;
|
||||
pKeyboard->numlockOn = NUMLOCKON;
|
||||
pKeyboard->xkbFilePath = FILEPATH.c_str();
|
||||
|
||||
xkb_rule_names rules = {
|
||||
.rules = RULES.c_str(),
|
||||
.model = MODEL.c_str(),
|
||||
.layout = LAYOUT.c_str(),
|
||||
.variant = VARIANT.c_str(),
|
||||
.options = OPTIONS.c_str()};
|
||||
xkb_rule_names rules = {.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.model = MODEL;
|
||||
pKeyboard->currentRules.rules = RULES;
|
||||
pKeyboard->currentRules.model = MODEL;
|
||||
pKeyboard->currentRules.variant = VARIANT;
|
||||
pKeyboard->currentRules.options = OPTIONS;
|
||||
pKeyboard->currentRules.layout = LAYOUT;
|
||||
pKeyboard->currentRules.layout = LAYOUT;
|
||||
|
||||
const auto CONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
|
||||
|
||||
|
@ -591,35 +589,38 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
|
|||
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()) {
|
||||
auto path = absolutePath(FILEPATH, g_pConfigManager->configCurrentPath);
|
||||
auto path = absolutePath(FILEPATH, g_pConfigManager->configCurrentPath);
|
||||
|
||||
if (!std::filesystem::exists(path)) {
|
||||
Debug::log(ERR, "input:kb_file= file doesnt exist");
|
||||
} else {
|
||||
KEYMAP = xkb_keymap_new_from_file(CONTEXT, fopen(path.c_str(), "r"), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||
}
|
||||
if (!std::filesystem::exists(path)) {
|
||||
Debug::log(ERR, "input:kb_file= file doesnt exist");
|
||||
} else {
|
||||
KEYMAP = xkb_keymap_new_from_file(CONTEXT, fopen(path.c_str(), "r"), XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
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));
|
||||
|
||||
pKeyboard->currentRules.rules = "";
|
||||
pKeyboard->currentRules.model = "";
|
||||
pKeyboard->currentRules.rules = "";
|
||||
pKeyboard->currentRules.model = "";
|
||||
pKeyboard->currentRules.variant = "";
|
||||
pKeyboard->currentRules.options = "";
|
||||
pKeyboard->currentRules.layout = "";
|
||||
pKeyboard->currentRules.layout = "";
|
||||
|
||||
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_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);
|
||||
}
|
||||
|
@ -653,17 +654,19 @@ void CInputManager::newMouse(wlr_input_device* mouse, bool virt) {
|
|||
const auto PMOUSE = &m_lMice.back();
|
||||
|
||||
PMOUSE->mouse = mouse;
|
||||
PMOUSE->virt = virt;
|
||||
PMOUSE->virt = virt;
|
||||
try {
|
||||
PMOUSE->name = getNameForNewDevice(mouse->name);
|
||||
} catch(std::exception& e) {
|
||||
} catch (std::exception& e) {
|
||||
Debug::log(ERR, "Mouse had no name???"); // logic error
|
||||
}
|
||||
|
||||
if (wlr_input_device_is_libinput(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);
|
||||
|
@ -685,7 +688,7 @@ void CInputManager::setPointerConfigs() {
|
|||
for (auto& m : m_lMice) {
|
||||
const auto PPOINTER = &m;
|
||||
|
||||
auto devname = PPOINTER->name;
|
||||
auto devname = PPOINTER->name;
|
||||
|
||||
const auto HASCONFIG = g_pConfigManager->deviceConfigExists(devname);
|
||||
|
||||
|
@ -703,7 +706,8 @@ void CInputManager::setPointerConfigs() {
|
|||
if (wlr_input_device_is_libinput(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);
|
||||
else
|
||||
libinput_device_config_click_set_method(LIBINPUTDEV, LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER);
|
||||
|
@ -713,7 +717,7 @@ void CInputManager::setPointerConfigs() {
|
|||
else
|
||||
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)
|
||||
libinput_device_config_middle_emulation_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED);
|
||||
else
|
||||
|
@ -740,25 +744,30 @@ void CInputManager::setPointerConfigs() {
|
|||
else
|
||||
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)
|
||||
libinput_device_config_tap_set_enabled(LIBINPUTDEV, LIBINPUT_CONFIG_TAP_ENABLED);
|
||||
|
||||
if (libinput_device_config_scroll_has_natural_scroll(LIBINPUTDEV)) {
|
||||
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
|
||||
libinput_device_config_scroll_set_natural_scroll_enabled(LIBINPUTDEV, (HASCONFIG ? g_pConfigManager->getDeviceInt(devname, "natural_scroll") : g_pConfigManager->getInt("input:touchpad:natural_scroll")));
|
||||
if (libinput_device_has_capability(LIBINPUTDEV, LIBINPUT_DEVICE_CAP_POINTER) &&
|
||||
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
|
||||
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)) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
if (m_lKeyboards.size() > 0) {
|
||||
m_pActiveKeyboard = &m_lKeyboards.back();
|
||||
m_pActiveKeyboard = &m_lKeyboards.back();
|
||||
m_pActiveKeyboard->active = true;
|
||||
} else {
|
||||
m_pActiveKeyboard = nullptr;
|
||||
|
@ -815,22 +824,20 @@ void CInputManager::destroyMouse(wlr_input_device* mouse) {
|
|||
unconstrainMouse();
|
||||
}
|
||||
|
||||
|
||||
void CInputManager::updateKeyboardsLeds(wlr_input_device* pKeyboard) {
|
||||
void CInputManager::updateKeyboardsLeds(wlr_input_device* pKeyboard) {
|
||||
auto keyboard = wlr_keyboard_from_input_device(pKeyboard);
|
||||
|
||||
if (keyboard->xkb_state == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (keyboard->xkb_state == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
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) {
|
||||
if ((kb.isVirtual && shouldIgnoreVirtualKeyboard(&kb)) || kb.keyboard == pKeyboard)
|
||||
continue;
|
||||
|
@ -839,7 +846,6 @@ void CInputManager::updateKeyboardsLeds(wlr_input_device* pKeyboard) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void CInputManager::onKeyboardKey(wlr_keyboard_key_event* e, SKeyboard* pKeyboard) {
|
||||
bool passEvent = g_pKeybindManager->onKeyEvent(e, pKeyboard);
|
||||
|
||||
|
@ -866,8 +872,8 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
|
|||
|
||||
const auto ALLMODS = accumulateModsFromAllKBs();
|
||||
|
||||
auto MODS = wlr_keyboard_from_input_device(pKeyboard->keyboard)->modifiers;
|
||||
MODS.depressed = ALLMODS;
|
||||
auto MODS = wlr_keyboard_from_input_device(pKeyboard->keyboard)->modifiers;
|
||||
MODS.depressed = ALLMODS;
|
||||
|
||||
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));
|
||||
|
@ -882,14 +888,16 @@ void CInputManager::onKeyboardMod(void* data, SKeyboard* pKeyboard) {
|
|||
const auto PWLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
|
@ -901,16 +909,14 @@ void CInputManager::updateDragIcon() {
|
|||
return;
|
||||
|
||||
switch (m_sDrag.dragIcon->drag->grab_type) {
|
||||
case WLR_DRAG_GRAB_KEYBOARD:
|
||||
break;
|
||||
case WLR_DRAG_GRAB_KEYBOARD: break;
|
||||
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};
|
||||
g_pHyprRenderer->damageBox(&box);
|
||||
m_sDrag.pos = getMouseCoordsInternal();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -926,10 +932,11 @@ void CInputManager::recheckConstraint(SMouse* pMouse) {
|
|||
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 : "";
|
||||
|
||||
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) {
|
||||
|
@ -937,7 +944,7 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
|
|||
if (pMouse->currentConstraint == constraint)
|
||||
return;
|
||||
|
||||
const auto PWINDOW = g_pCompositor->getWindowFromSurface(constraint->surface);
|
||||
const auto PWINDOW = g_pCompositor->getWindowFromSurface(constraint->surface);
|
||||
const auto MOUSECOORDS = getMouseCoordsInternal();
|
||||
|
||||
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 (PWINDOW) {
|
||||
if (PWINDOW->m_bIsX11) {
|
||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr,
|
||||
constraint->current.cursor_hint.x + PWINDOW->m_uSurface.xwayland->x, PWINDOW->m_uSurface.xwayland->y + PWINDOW->m_vRealPosition.vec().y);
|
||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, constraint->current.cursor_hint.x + PWINDOW->m_uSurface.xwayland->x,
|
||||
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);
|
||||
} else {
|
||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr,
|
||||
constraint->current.cursor_hint.x + PWINDOW->m_vRealPosition.vec().x, constraint->current.cursor_hint.y + PWINDOW->m_vRealPosition.vec().y);
|
||||
wlr_cursor_warp(g_pCompositor->m_sWLRCursor, nullptr, constraint->current.cursor_hint.x + PWINDOW->m_vRealPosition.vec().x,
|
||||
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);
|
||||
}
|
||||
|
@ -964,7 +971,7 @@ void CInputManager::constrainMouse(SMouse* pMouse, wlr_pointer_constraint_v1* co
|
|||
const auto PCONSTRAINT = constraintFromWlr(constraint);
|
||||
if (PCONSTRAINT) { // should never be null but who knows
|
||||
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->constraintActive = true;
|
||||
pMouse->constraintActive = true;
|
||||
|
||||
if (pixman_region32_not_empty(&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) {
|
||||
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->hintSet = true;
|
||||
PCONSTRAINT->hintSet = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1053,9 +1060,9 @@ uint32_t CInputManager::accumulateModsFromAllKBs() {
|
|||
}
|
||||
|
||||
std::string CInputManager::getActiveLayoutForKeyboard(SKeyboard* pKeyboard) {
|
||||
const auto WLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
|
||||
const auto KEYMAP = WLRKB->keymap;
|
||||
const auto STATE = WLRKB->xkb_state;
|
||||
const auto WLRKB = wlr_keyboard_from_input_device(pKeyboard->keyboard);
|
||||
const auto KEYMAP = WLRKB->keymap;
|
||||
const auto STATE = WLRKB->xkb_state;
|
||||
const auto LAYOUTSNUM = xkb_keymap_num_layouts(KEYMAP);
|
||||
|
||||
for (uint32_t i = 0; i < LAYOUTSNUM; ++i) {
|
||||
|
@ -1082,12 +1089,12 @@ void CInputManager::disableAllKeyboards(bool virt) {
|
|||
}
|
||||
|
||||
void CInputManager::newTouchDevice(wlr_input_device* pDevice) {
|
||||
const auto PNEWDEV = &m_lTouchDevices.emplace_back();
|
||||
const auto PNEWDEV = &m_lTouchDevices.emplace_back();
|
||||
PNEWDEV->pWlrDevice = pDevice;
|
||||
|
||||
try {
|
||||
PNEWDEV->name = getNameForNewDevice(pDevice->name);
|
||||
} catch(std::exception& e) {
|
||||
} catch (std::exception& e) {
|
||||
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);
|
||||
|
||||
PNEWDEV->hyprListener_destroy.initCallback(&pDevice->events.destroy, [&](void* owner, void* data) {
|
||||
destroyTouchDevice((STouchDevice*)data);
|
||||
}, PNEWDEV, "TouchDevice");
|
||||
PNEWDEV->hyprListener_destroy.initCallback(
|
||||
&pDevice->events.destroy, [&](void* owner, void* data) { destroyTouchDevice((STouchDevice*)data); }, PNEWDEV, "TouchDevice");
|
||||
}
|
||||
|
||||
void CInputManager::setTouchDeviceConfigs() {
|
||||
// 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] = {
|
||||
{ // normal
|
||||
1, 0, 0,
|
||||
0, 1, 0
|
||||
},
|
||||
{ // rotation 90°
|
||||
0, -1, 1,
|
||||
1, 0, 0
|
||||
},
|
||||
{ // rotation 180°
|
||||
-1, 0, 1,
|
||||
0, -1, 1
|
||||
},
|
||||
{ // rotation 270°
|
||||
0, 1, 0,
|
||||
-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
|
||||
}
|
||||
};
|
||||
static const float MATRICES[8][6] = {{// normal
|
||||
1, 0, 0, 0, 1, 0},
|
||||
{// rotation 90°
|
||||
0, -1, 1, 1, 0, 0},
|
||||
{// rotation 180°
|
||||
-1, 0, 1, 0, -1, 1},
|
||||
{// rotation 270°
|
||||
0, 1, 0, -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) {
|
||||
const auto PTOUCHDEV = &m;
|
||||
|
||||
|
@ -1145,7 +1133,8 @@ void CInputManager::setTouchDeviceConfigs() {
|
|||
if (wlr_input_device_is_libinput(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]);
|
||||
|
||||
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) {
|
||||
const auto PNEWDEV = &m_lSwitches.emplace_back();
|
||||
const auto PNEWDEV = &m_lSwitches.emplace_back();
|
||||
PNEWDEV->pWlrDevice = pDevice;
|
||||
|
||||
Debug::log(LOG, "New switch with name \"%s\" added", pDevice->name);
|
||||
|
||||
PNEWDEV->hyprListener_destroy.initCallback(&pDevice->events.destroy, [&](void* owner, void* data) {
|
||||
destroySwitch((SSwitchDevice*)owner);
|
||||
}, PNEWDEV, "SwitchDevice");
|
||||
PNEWDEV->hyprListener_destroy.initCallback(
|
||||
&pDevice->events.destroy, [&](void* owner, void* data) { destroySwitch((SSwitchDevice*)owner); }, PNEWDEV, "SwitchDevice");
|
||||
|
||||
const auto PSWITCH = wlr_switch_from_input_device(pDevice);
|
||||
|
||||
PNEWDEV->hyprListener_toggle.initCallback(&PSWITCH->events.toggle, [&](void* owner, void* data) {
|
||||
const auto PDEVICE = (SSwitchDevice*)owner;
|
||||
const auto NAME = std::string(PDEVICE->pWlrDevice->name);
|
||||
PNEWDEV->hyprListener_toggle.initCallback(
|
||||
&PSWITCH->events.toggle,
|
||||
[&](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);
|
||||
}, PNEWDEV, "SwitchDevice");
|
||||
g_pKeybindManager->onSwitchEvent(NAME);
|
||||
},
|
||||
PNEWDEV, "SwitchDevice");
|
||||
}
|
||||
|
||||
void CInputManager::destroySwitch(SSwitchDevice* pDevice) {
|
||||
|
@ -1212,24 +1203,30 @@ std::string CInputManager::deviceNameToInternalString(std::string in) {
|
|||
std::string CInputManager::getNameForNewDevice(std::string 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++;
|
||||
|
||||
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++;
|
||||
|
||||
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++;
|
||||
|
||||
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++;
|
||||
|
||||
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++;
|
||||
|
||||
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++;
|
||||
|
||||
return proposedNewName + (dupeno == 0 ? "" : ("-" + std::to_string(dupeno)));
|
||||
|
|
|
@ -7,89 +7,90 @@
|
|||
#include "../../helpers/Timer.hpp"
|
||||
#include "InputMethodRelay.hpp"
|
||||
|
||||
enum eClickBehaviorMode {
|
||||
enum eClickBehaviorMode
|
||||
{
|
||||
CLICKMODE_DEFAULT = 0,
|
||||
CLICKMODE_KILL
|
||||
};
|
||||
|
||||
enum eMouseBindMode {
|
||||
enum eMouseBindMode
|
||||
{
|
||||
MBIND_INVALID = -1,
|
||||
MBIND_MOVE = 0,
|
||||
MBIND_MOVE = 0,
|
||||
MBIND_RESIZE
|
||||
};
|
||||
|
||||
struct STouchData {
|
||||
CWindow* touchFocusWindow = nullptr;
|
||||
SLayerSurface* touchFocusLS = nullptr;
|
||||
wlr_surface* touchFocusSurface = nullptr;
|
||||
Vector2D touchSurfaceOrigin;
|
||||
CWindow* touchFocusWindow = nullptr;
|
||||
SLayerSurface* touchFocusLS = nullptr;
|
||||
wlr_surface* touchFocusSurface = nullptr;
|
||||
Vector2D touchSurfaceOrigin;
|
||||
};
|
||||
|
||||
class CKeybindManager;
|
||||
|
||||
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 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 newKeyboard(wlr_input_device*);
|
||||
void newVirtualKeyboard(wlr_input_device*);
|
||||
void newMouse(wlr_input_device*, bool virt = false);
|
||||
void newTouchDevice(wlr_input_device*);
|
||||
void newSwitch(wlr_input_device*);
|
||||
void destroyTouchDevice(STouchDevice*);
|
||||
void destroyKeyboard(SKeyboard*);
|
||||
void destroyMouse(wlr_input_device*);
|
||||
void destroySwitch(SSwitchDevice*);
|
||||
|
||||
void newKeyboard(wlr_input_device*);
|
||||
void newVirtualKeyboard(wlr_input_device*);
|
||||
void newMouse(wlr_input_device*, bool virt = false);
|
||||
void newTouchDevice(wlr_input_device*);
|
||||
void newSwitch(wlr_input_device*);
|
||||
void destroyTouchDevice(STouchDevice*);
|
||||
void destroyKeyboard(SKeyboard*);
|
||||
void destroyMouse(wlr_input_device*);
|
||||
void destroySwitch(SSwitchDevice*);
|
||||
void constrainMouse(SMouse*, wlr_pointer_constraint_v1*);
|
||||
void recheckConstraint(SMouse*);
|
||||
void unconstrainMouse();
|
||||
SConstraint* constraintFromWlr(wlr_pointer_constraint_v1*);
|
||||
std::string getActiveLayoutForKeyboard(SKeyboard*);
|
||||
|
||||
void constrainMouse(SMouse*, wlr_pointer_constraint_v1*);
|
||||
void recheckConstraint(SMouse*);
|
||||
void unconstrainMouse();
|
||||
SConstraint* constraintFromWlr(wlr_pointer_constraint_v1*);
|
||||
std::string getActiveLayoutForKeyboard(SKeyboard*);
|
||||
Vector2D getMouseCoordsInternal();
|
||||
void refocus();
|
||||
|
||||
Vector2D getMouseCoordsInternal();
|
||||
void refocus();
|
||||
void setKeyboardLayout();
|
||||
void setPointerConfigs();
|
||||
void setTouchDeviceConfigs();
|
||||
|
||||
void setKeyboardLayout();
|
||||
void setPointerConfigs();
|
||||
void setTouchDeviceConfigs();
|
||||
void updateDragIcon();
|
||||
void updateCapabilities();
|
||||
|
||||
void updateDragIcon();
|
||||
void updateCapabilities();
|
||||
|
||||
void setClickMode(eClickBehaviorMode);
|
||||
void setClickMode(eClickBehaviorMode);
|
||||
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 onTouchUp(wlr_touch_up_event*);
|
||||
void onTouchMove(wlr_touch_motion_event*);
|
||||
void onTouchDown(wlr_touch_down_event*);
|
||||
void onTouchUp(wlr_touch_up_event*);
|
||||
void onTouchMove(wlr_touch_motion_event*);
|
||||
|
||||
void onPointerHoldBegin(wlr_pointer_hold_begin_event*);
|
||||
void onPointerHoldEnd(wlr_pointer_hold_end_event*);
|
||||
void onPointerHoldBegin(wlr_pointer_hold_begin_event*);
|
||||
void onPointerHoldEnd(wlr_pointer_hold_end_event*);
|
||||
|
||||
STouchData m_sTouchData;
|
||||
STouchData m_sTouchData;
|
||||
|
||||
// for dragging floating windows
|
||||
CWindow* currentlyDraggedWindow = nullptr;
|
||||
eMouseBindMode dragMode = MBIND_INVALID;
|
||||
CWindow* currentlyDraggedWindow = nullptr;
|
||||
eMouseBindMode dragMode = MBIND_INVALID;
|
||||
|
||||
SDrag m_sDrag;
|
||||
SDrag m_sDrag;
|
||||
|
||||
std::list<SConstraint> m_lConstraints;
|
||||
std::list<SKeyboard> m_lKeyboards;
|
||||
std::list<SMouse> m_lMice;
|
||||
std::list<SConstraint> m_lConstraints;
|
||||
std::list<SKeyboard> m_lKeyboards;
|
||||
std::list<SMouse> m_lMice;
|
||||
|
||||
// tablets
|
||||
std::list<STablet> m_lTablets;
|
||||
std::list<STabletTool> m_lTabletTools;
|
||||
std::list<STabletPad> m_lTabletPads;
|
||||
std::list<STablet> m_lTablets;
|
||||
std::list<STabletTool> m_lTabletTools;
|
||||
std::list<STabletPad> m_lTabletPads;
|
||||
|
||||
// idle inhibitors
|
||||
std::list<SIdleInhibitor> m_lIdleInhibitors;
|
||||
|
@ -100,73 +101,72 @@ public:
|
|||
// Switches
|
||||
std::list<SSwitchDevice> m_lSwitches;
|
||||
|
||||
void newTabletTool(wlr_input_device*);
|
||||
void newTabletPad(wlr_input_device*);
|
||||
void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false);
|
||||
void newIdleInhibitor(wlr_idle_inhibitor_v1*);
|
||||
void recheckIdleInhibitorStatus();
|
||||
void newTabletTool(wlr_input_device*);
|
||||
void newTabletPad(wlr_input_device*);
|
||||
void focusTablet(STablet*, wlr_tablet_tool*, bool motion = false);
|
||||
void newIdleInhibitor(wlr_idle_inhibitor_v1*);
|
||||
void recheckIdleInhibitorStatus();
|
||||
|
||||
void onSwipeBegin(wlr_pointer_swipe_begin_event*);
|
||||
void onSwipeEnd(wlr_pointer_swipe_end_event*);
|
||||
void onSwipeUpdate(wlr_pointer_swipe_update_event*);
|
||||
void onSwipeBegin(wlr_pointer_swipe_begin_event*);
|
||||
void onSwipeEnd(wlr_pointer_swipe_end_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
|
||||
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
|
||||
bool shouldIgnoreVirtualKeyboard(SKeyboard*);
|
||||
bool shouldIgnoreVirtualKeyboard(SKeyboard*);
|
||||
|
||||
// for special cursors that we choose
|
||||
void setCursorImageUntilUnset(std::string);
|
||||
void unsetCursorImage();
|
||||
void setCursorImageUntilUnset(std::string);
|
||||
void unsetCursorImage();
|
||||
|
||||
std::string deviceNameToInternalString(std::string);
|
||||
std::string getNameForNewDevice(std::string);
|
||||
std::string deviceNameToInternalString(std::string);
|
||||
std::string getNameForNewDevice(std::string);
|
||||
|
||||
private:
|
||||
|
||||
bool m_bCursorImageOverriden = false;
|
||||
private:
|
||||
bool m_bCursorImageOverriden = false;
|
||||
|
||||
// for click behavior override
|
||||
eClickBehaviorMode m_ecbClickBehavior = CLICKMODE_DEFAULT;
|
||||
bool m_bEmptyFocusCursorSet = false;
|
||||
Vector2D m_vLastCursorPosFloored = Vector2D();
|
||||
eClickBehaviorMode m_ecbClickBehavior = CLICKMODE_DEFAULT;
|
||||
bool m_bEmptyFocusCursorSet = false;
|
||||
Vector2D m_vLastCursorPosFloored = Vector2D();
|
||||
|
||||
// for some bugs in follow mouse 0
|
||||
bool m_bLastFocusOnLS = false;
|
||||
bool m_bLastFocusOnLS = false;
|
||||
|
||||
void processMouseDownNormal(wlr_pointer_button_event* e);
|
||||
void processMouseDownKill(wlr_pointer_button_event* e);
|
||||
void processMouseDownNormal(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()
|
||||
wlr_surface* m_pFoundSurfaceToFocus = nullptr;
|
||||
SLayerSurface* m_pFoundLSToFocus = nullptr;
|
||||
CWindow* m_pFoundWindowToFocus = nullptr;
|
||||
wlr_surface* m_pFoundSurfaceToFocus = nullptr;
|
||||
SLayerSurface* m_pFoundLSToFocus = nullptr;
|
||||
CWindow* m_pFoundWindowToFocus = nullptr;
|
||||
|
||||
// swipe
|
||||
void beginWorkspaceSwipe();
|
||||
void beginWorkspaceSwipe();
|
||||
|
||||
friend class CKeybindManager;
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "InputManager.hpp"
|
||||
#include "../../Compositor.hpp"
|
||||
|
||||
CInputMethodRelay::CInputMethodRelay() { }
|
||||
CInputMethodRelay::CInputMethodRelay() {}
|
||||
|
||||
void CInputMethodRelay::onNewIME(wlr_input_method_v2* pIME) {
|
||||
if (m_pWLRIME) {
|
||||
|
@ -15,101 +15,107 @@ void CInputMethodRelay::onNewIME(wlr_input_method_v2* 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();
|
||||
const auto PIMR = (CInputMethodRelay*)owner;
|
||||
|
||||
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 (!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);
|
||||
|
||||
}, 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");
|
||||
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");
|
||||
m_pKeyboardGrab.reset(nullptr);
|
||||
|
||||
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();
|
||||
|
||||
|
@ -131,25 +137,25 @@ void CInputMethodRelay::updateInputPopup(SIMEPopup* pPopup) {
|
|||
if (!PFOCUSEDTI || !PFOCUSEDTI->pWlrInput->focused_surface)
|
||||
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;
|
||||
auto cursorBox = PFOCUSEDTI->pWlrInput->current.cursor_rectangle;
|
||||
auto cursorBox = PFOCUSEDTI->pWlrInput->current.cursor_rectangle;
|
||||
|
||||
Vector2D parentPos;
|
||||
Vector2D parentSize;
|
||||
Vector2D parentPos;
|
||||
Vector2D parentSize;
|
||||
|
||||
if (wlr_surface_is_layer_surface(PFOCUSEDSURFACE)) {
|
||||
const auto PLS = g_pCompositor->getLayerSurfaceFromWlr(wlr_layer_surface_v1_from_wlr_surface(PFOCUSEDSURFACE));
|
||||
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
const auto PWINDOW = g_pCompositor->getWindowFromSurface(PFOCUSEDSURFACE);
|
||||
|
||||
if (PWINDOW) {
|
||||
parentPos = PWINDOW->m_vRealPosition.goalv();
|
||||
parentPos = PWINDOW->m_vRealPosition.goalv();
|
||||
parentSize = PWINDOW->m_vRealSize.goalv();
|
||||
}
|
||||
}
|
||||
|
@ -230,7 +236,7 @@ void CInputMethodRelay::damagePopup(SIMEPopup* pPopup) {
|
|||
if (!PFOCUSEDTI || !PFOCUSEDTI->pWlrInput->focused_surface)
|
||||
return;
|
||||
|
||||
Vector2D parentPos;
|
||||
Vector2D parentPos;
|
||||
|
||||
const auto PFOCUSEDSURFACE = PFOCUSEDTI->pWlrInput->focused_surface;
|
||||
|
||||
|
@ -296,82 +302,86 @@ void CInputMethodRelay::createNewTextInput(wlr_text_input_v3* 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(WARN, "Enabling TextInput on no IME!");
|
||||
return;
|
||||
}
|
||||
Debug::log(LOG, "Enable TextInput");
|
||||
|
||||
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);
|
||||
g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
|
||||
PTEXTINPUT->hyprListener_textInputCommit.initCallback(
|
||||
&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) {
|
||||
// Debug::log(WARN, "Committing TextInput on no IME!");
|
||||
return;
|
||||
}
|
||||
PTEXTINPUT->hyprListener_textInputDisable.initCallback(
|
||||
&pInput->events.disable,
|
||||
[](void* owner, void* data) {
|
||||
const auto PINPUT = (STextInput*)owner;
|
||||
|
||||
if (!PINPUT->pWlrInput->current_enabled) {
|
||||
Debug::log(WARN, "Disabled TextInput commit?");
|
||||
return;
|
||||
}
|
||||
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
|
||||
// Debug::log(WARN, "Disabling TextInput on no IME!");
|
||||
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);
|
||||
|
||||
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();
|
||||
PINPUT->hyprListener_textInputDestroy.removeCallback();
|
||||
PINPUT->hyprListener_textInputDisable.removeCallback();
|
||||
PINPUT->hyprListener_textInputEnable.removeCallback();
|
||||
if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
|
||||
// Debug::log(WARN, "Disabling TextInput on no IME!");
|
||||
return;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -417,7 +427,6 @@ void CInputMethodRelay::onKeyboardFocus(wlr_surface* pSurface) {
|
|||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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 {
|
||||
setPendingSurface(&ti, pSurface);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -436,13 +444,16 @@ void CInputMethodRelay::setPendingSurface(STextInput* pInput, wlr_surface* pSurf
|
|||
pInput->pPendingSurface = pSurface;
|
||||
|
||||
if (pSurface) {
|
||||
pInput->hyprListener_pendingSurfaceDestroy.initCallback(&pSurface->events.destroy, [](void* owner, void* data) {
|
||||
const auto PINPUT = (STextInput*)owner;
|
||||
pInput->hyprListener_pendingSurfaceDestroy.initCallback(
|
||||
&pSurface->events.destroy,
|
||||
[](void* owner, void* data) {
|
||||
const auto PINPUT = (STextInput*)owner;
|
||||
|
||||
PINPUT->pPendingSurface = nullptr;
|
||||
PINPUT->pPendingSurface = nullptr;
|
||||
|
||||
PINPUT->hyprListener_pendingSurfaceDestroy.removeCallback();
|
||||
}, pInput, "TextInput");
|
||||
PINPUT->hyprListener_pendingSurfaceDestroy.removeCallback();
|
||||
},
|
||||
pInput, "TextInput");
|
||||
} else {
|
||||
pInput->hyprListener_pendingSurfaceDestroy.removeCallback();
|
||||
}
|
||||
|
|
|
@ -6,37 +6,36 @@
|
|||
class CInputManager;
|
||||
|
||||
class CInputMethodRelay {
|
||||
public:
|
||||
public:
|
||||
CInputMethodRelay();
|
||||
|
||||
void onNewIME(wlr_input_method_v2*);
|
||||
void onNewTextInput(wlr_text_input_v3*);
|
||||
void onNewIME(wlr_input_method_v2*);
|
||||
void onNewTextInput(wlr_text_input_v3*);
|
||||
|
||||
wlr_input_method_v2* m_pWLRIME = nullptr;
|
||||
|
||||
void commitIMEState(wlr_text_input_v3*);
|
||||
void removeTextInput(wlr_text_input_v3*);
|
||||
void commitIMEState(wlr_text_input_v3*);
|
||||
void removeTextInput(wlr_text_input_v3*);
|
||||
|
||||
void onKeyboardFocus(wlr_surface*);
|
||||
void onKeyboardFocus(wlr_surface*);
|
||||
|
||||
STextInput* getFocusedTextInput();
|
||||
STextInput* getFocusableTextInput();
|
||||
STextInput* getFocusedTextInput();
|
||||
STextInput* getFocusableTextInput();
|
||||
|
||||
void setPendingSurface(STextInput*, wlr_surface*);
|
||||
void setPendingSurface(STextInput*, wlr_surface*);
|
||||
|
||||
SIMEKbGrab* getIMEKeyboardGrab(SKeyboard*);
|
||||
SIMEKbGrab* getIMEKeyboardGrab(SKeyboard*);
|
||||
|
||||
void setIMEPopupFocus(SIMEPopup*, wlr_surface*);
|
||||
void updateInputPopup(SIMEPopup*);
|
||||
void damagePopup(SIMEPopup*);
|
||||
void removePopup(SIMEPopup*);
|
||||
|
||||
private:
|
||||
void setIMEPopupFocus(SIMEPopup*, wlr_surface*);
|
||||
void updateInputPopup(SIMEPopup*);
|
||||
void damagePopup(SIMEPopup*);
|
||||
void removePopup(SIMEPopup*);
|
||||
|
||||
private:
|
||||
std::unique_ptr<SIMEKbGrab> m_pKeyboardGrab;
|
||||
|
||||
std::list<STextInput> m_lTextInputs;
|
||||
std::list<SIMEPopup> m_lIMEPopups;
|
||||
std::list<STextInput> m_lTextInputs;
|
||||
std::list<SIMEPopup> m_lIMEPopups;
|
||||
|
||||
DYNLISTENER(textInputNew);
|
||||
DYNLISTENER(IMECommit);
|
||||
|
@ -44,7 +43,7 @@ private:
|
|||
DYNLISTENER(IMEGrab);
|
||||
DYNLISTENER(IMENewPopup);
|
||||
|
||||
void createNewTextInput(wlr_text_input_v3*);
|
||||
void createNewTextInput(wlr_text_input_v3*);
|
||||
|
||||
friend class CHyprRenderer;
|
||||
friend class CInputManager;
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
#include "../../Compositor.hpp"
|
||||
|
||||
void CInputManager::onSwipeBegin(wlr_pointer_swipe_begin_event* e) {
|
||||
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 PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->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 PSWIPENEW = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_create_new")->intValue;
|
||||
|
||||
if (e->fingers != *PSWIPEFINGERS || *PSWIPE == 0)
|
||||
return;
|
||||
|
@ -28,10 +28,10 @@ void CInputManager::beginWorkspaceSwipe() {
|
|||
Debug::log(LOG, "Starting a swipe from %s", PWORKSPACE->m_szName.c_str());
|
||||
|
||||
m_sActiveSwipe.pWorkspaceBegin = PWORKSPACE;
|
||||
m_sActiveSwipe.delta = 0;
|
||||
m_sActiveSwipe.pMonitor = g_pCompositor->m_pLastMonitor;
|
||||
m_sActiveSwipe.avgSpeed = 0;
|
||||
m_sActiveSwipe.speedPoints = 0;
|
||||
m_sActiveSwipe.delta = 0;
|
||||
m_sActiveSwipe.pMonitor = g_pCompositor->m_pLastMonitor;
|
||||
m_sActiveSwipe.avgSpeed = 0;
|
||||
m_sActiveSwipe.speedPoints = 0;
|
||||
|
||||
if (PWORKSPACE->m_bHasFullscreenWindow) {
|
||||
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)
|
||||
return; // no valid swipe
|
||||
|
||||
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 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;
|
||||
const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert";
|
||||
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 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;
|
||||
const bool VERTANIMS = m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.getConfig()->pValues->internalStyle == "slidevert";
|
||||
|
||||
// commit
|
||||
std::string wsname = "";
|
||||
auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname);
|
||||
auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname);
|
||||
std::string wsname = "";
|
||||
auto workspaceIDLeft = 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;
|
||||
}
|
||||
|
||||
auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); // not guaranteed if PSWIPENEW
|
||||
const auto PWORKSPACEL = g_pCompositor->getWorkspaceByID(workspaceIDLeft);
|
||||
auto PWORKSPACER = g_pCompositor->getWorkspaceByID(workspaceIDRight); // not guaranteed if PSWIPENEW
|
||||
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;
|
||||
|
||||
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
|
||||
if (abs(m_sActiveSwipe.delta) < 2) {
|
||||
PWORKSPACEL->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
|
||||
PWORKSPACEL->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
||||
if (PWORKSPACER)
|
||||
PWORKSPACER->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
|
||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0,0));
|
||||
PWORKSPACER->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
||||
m_sActiveSwipe.pWorkspaceBegin->m_vRenderOffset.setValueAndWarp(Vector2D(0, 0));
|
||||
} else {
|
||||
if (m_sActiveSwipe.delta < 0) {
|
||||
// to left
|
||||
|
@ -163,21 +165,21 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
|
|||
if (!m_sActiveSwipe.pWorkspaceBegin)
|
||||
return;
|
||||
|
||||
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 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 PSWIPEDIST = &g_pConfigManager->getConfigValuePtr("gestures:workspace_swipe_distance")->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 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.avgSpeed = (m_sActiveSwipe.avgSpeed * m_sActiveSwipe.speedPoints + abs(e->dx)) / (m_sActiveSwipe.speedPoints + 1);
|
||||
m_sActiveSwipe.speedPoints++;
|
||||
|
||||
std::string wsname = "";
|
||||
auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname);
|
||||
auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname);
|
||||
std::string wsname = "";
|
||||
auto workspaceIDLeft = getWorkspaceIDFromString("m-1", wsname);
|
||||
auto workspaceIDRight = getWorkspaceIDFromString("m+1", wsname);
|
||||
|
||||
if ((workspaceIDLeft == INT_MAX || workspaceIDRight == INT_MAX || workspaceIDLeft == m_sActiveSwipe.pWorkspaceBegin->m_iID) && !*PSWIPENEW) {
|
||||
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);
|
||||
|
||||
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;
|
||||
|
@ -197,7 +200,7 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
|
|||
}
|
||||
|
||||
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;
|
||||
return;
|
||||
}
|
||||
|
@ -215,10 +218,12 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
|
|||
}
|
||||
|
||||
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));
|
||||
} 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));
|
||||
}
|
||||
|
||||
|
@ -253,10 +258,12 @@ void CInputManager::onSwipeUpdate(wlr_pointer_swipe_update_event* e) {
|
|||
}
|
||||
|
||||
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));
|
||||
} 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));
|
||||
}
|
||||
|
||||
|
|
|
@ -7,127 +7,136 @@ void CInputManager::newTabletTool(wlr_input_device* pDevice) {
|
|||
try {
|
||||
PNEWTABLET->name = deviceNameToInternalString(pDevice->name);
|
||||
} 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->wlrDevice = pDevice;
|
||||
PNEWTABLET->wlrTabletV2 = wlr_tablet_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pDevice);
|
||||
PNEWTABLET->wlrTablet = wlr_tablet_from_input_device(pDevice);
|
||||
PNEWTABLET->wlrDevice = pDevice;
|
||||
PNEWTABLET->wlrTabletV2 = wlr_tablet_create(g_pCompositor->m_sWLRTabletManager, g_pCompositor->m_sSeat.seat, pDevice);
|
||||
PNEWTABLET->wlrTablet->data = PNEWTABLET;
|
||||
|
||||
Debug::log(LOG, "Attaching tablet to cursor!");
|
||||
|
||||
wlr_cursor_attach_input_device(g_pCompositor->m_sWLRCursor, pDevice);
|
||||
|
||||
PNEWTABLET->hyprListener_Destroy.initCallback(&pDevice->events.destroy, [](void* owner, void* data) {
|
||||
const auto PTAB = (STablet*)owner;
|
||||
PNEWTABLET->hyprListener_Destroy.initCallback(
|
||||
&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");
|
||||
}, PNEWTABLET, "Tablet");
|
||||
Debug::log(LOG, "Removed a 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;
|
||||
const auto PTAB = (STablet*)owner;
|
||||
|
||||
switch (EVENT->tool->type) {
|
||||
case WLR_TABLET_TOOL_TYPE_MOUSE:
|
||||
wlr_cursor_move(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, EVENT->dx, EVENT->dy);
|
||||
g_pInputManager->refocus();
|
||||
break;
|
||||
default:
|
||||
double x = (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_X) ? EVENT->x : NAN;
|
||||
double y = (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_Y) ? EVENT->y : NAN;
|
||||
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;
|
||||
switch (EVENT->tool->type) {
|
||||
case WLR_TABLET_TOOL_TYPE_MOUSE:
|
||||
wlr_cursor_move(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, EVENT->dx, EVENT->dy);
|
||||
g_pInputManager->refocus();
|
||||
break;
|
||||
default:
|
||||
double x = (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_X) ? EVENT->x : NAN;
|
||||
double y = (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_Y) ? EVENT->y : NAN;
|
||||
wlr_cursor_warp_absolute(g_pCompositor->m_sWLRCursor, PTAB->wlrDevice, x, y);
|
||||
g_pInputManager->refocus();
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
PTOOL->active = true;
|
||||
g_pInputManager->refocus();
|
||||
g_pInputManager->focusTablet(PTAB, EVENT->tool);
|
||||
}
|
||||
const auto PTOOL = g_pInputManager->ensureTabletToolPresent(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) {
|
||||
|
@ -137,16 +146,19 @@ STabletTool* CInputManager::ensureTabletToolPresent(wlr_tablet_tool* pTool) {
|
|||
Debug::log(LOG, "Creating tablet tool v2 for %x", 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->hyprListener_TabletToolDestroy.initCallback(&pTool->events.destroy, [](void* owner, void* data) {
|
||||
const auto PTOOL = (STabletTool*)owner;
|
||||
PTOOL->hyprListener_TabletToolDestroy.initCallback(
|
||||
&pTool->events.destroy,
|
||||
[](void* owner, void* data) {
|
||||
const auto PTOOL = (STabletTool*)owner;
|
||||
|
||||
PTOOL->wlrTabletTool->data = nullptr;
|
||||
g_pInputManager->m_lTabletTools.remove(*PTOOL);
|
||||
}, PTOOL, "Tablet Tool V1");
|
||||
PTOOL->wlrTabletTool->data = nullptr;
|
||||
g_pInputManager->m_lTabletTools.remove(*PTOOL);
|
||||
},
|
||||
PTOOL, "Tablet Tool V1");
|
||||
|
||||
//TODO: set cursor request
|
||||
}
|
||||
|
@ -160,60 +172,65 @@ void CInputManager::newTabletPad(wlr_input_device* pDevice) {
|
|||
try {
|
||||
PNEWPAD->name = deviceNameToInternalString(pDevice->name);
|
||||
} 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->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;
|
||||
const auto PPAD = (STabletPad*)owner;
|
||||
wlr_tablet_v2_tablet_pad_notify_mode(PPAD->wlrTabletPadV2, EVENT->group, EVENT->mode, EVENT->time_msec);
|
||||
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);
|
||||
wlr_tablet_v2_tablet_pad_notify_button(PPAD->wlrTabletPadV2, EVENT->button, EVENT->time_msec, (zwp_tablet_pad_v2_button_state)EVENT->state);
|
||||
PNEWPAD->hyprListener_Strip.initCallback(
|
||||
&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;
|
||||
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);
|
||||
},
|
||||
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;
|
||||
const auto PPAD = (STabletPad*)owner;
|
||||
PNEWPAD->hyprListener_Destroy.initCallback(
|
||||
&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");
|
||||
|
||||
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;
|
||||
|
||||
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");
|
||||
Debug::log(LOG, "Removed a tablet pad");
|
||||
},
|
||||
PNEWPAD, "Tablet Pad");
|
||||
}
|
||||
|
||||
void CInputManager::focusTablet(STablet* pTab, wlr_tablet_tool* pTool, bool motion) {
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "../../Compositor.hpp"
|
||||
|
||||
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; });
|
||||
|
||||
|
@ -15,9 +15,9 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) {
|
|||
|
||||
refocus();
|
||||
|
||||
m_sTouchData.touchFocusWindow = m_pFoundWindowToFocus;
|
||||
m_sTouchData.touchFocusWindow = m_pFoundWindowToFocus;
|
||||
m_sTouchData.touchFocusSurface = m_pFoundSurfaceToFocus;
|
||||
m_sTouchData.touchFocusLS = m_pFoundLSToFocus;
|
||||
m_sTouchData.touchFocusLS = m_pFoundLSToFocus;
|
||||
|
||||
Vector2D local;
|
||||
|
||||
|
@ -30,7 +30,8 @@ void CInputManager::onTouchDown(wlr_touch_down_event* e) {
|
|||
|
||||
m_sTouchData.touchSurfaceOrigin = g_pInputManager->getMouseCoordsInternal() - local;
|
||||
} 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;
|
||||
} 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);
|
||||
}
|
||||
|
||||
void CInputManager::onTouchUp(wlr_touch_up_event* e){
|
||||
void CInputManager::onTouchUp(wlr_touch_up_event* e) {
|
||||
if (m_sTouchData.touchFocusSurface) {
|
||||
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)) {
|
||||
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;
|
||||
|
||||
|
@ -60,7 +62,8 @@ void CInputManager::onTouchMove(wlr_touch_motion_event* e){
|
|||
} else if (m_sTouchData.touchFocusLS) {
|
||||
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;
|
||||
|
||||
|
|
|
@ -27,8 +27,7 @@ CToplevelExportProtocolManager::CToplevelExportProtocolManager() {
|
|||
return;
|
||||
#endif
|
||||
|
||||
m_pGlobal = wl_global_create(g_pCompositor->m_sWLDisplay, &hyprland_toplevel_export_manager_v1_interface,
|
||||
TOPLEVEL_EXPORT_VERSION, this, bindManagerInt);
|
||||
m_pGlobal = wl_global_create(g_pCompositor->m_sWLDisplay, &hyprland_toplevel_export_manager_v1_interface, TOPLEVEL_EXPORT_VERSION, this, bindManagerInt);
|
||||
|
||||
if (!m_pGlobal) {
|
||||
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 = {
|
||||
.capture_toplevel = handleCaptureToplevel,
|
||||
.destroy = handleDestroy,
|
||||
.capture_toplevel = handleCaptureToplevel,
|
||||
.destroy = handleDestroy,
|
||||
.capture_toplevel_with_wlr_toplevel_handle = handleCaptureToplevelWithWlr,
|
||||
};
|
||||
|
||||
static const struct hyprland_toplevel_export_frame_v1_interface toplevelFrameImpl = {
|
||||
.copy = handleCopyFrame,
|
||||
.destroy = handleDestroyFrame
|
||||
};
|
||||
static const struct hyprland_toplevel_export_frame_v1_interface toplevelFrameImpl = {.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));
|
||||
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) {
|
||||
const auto PCLIENT = &m_lClients.emplace_back();
|
||||
|
||||
PCLIENT->resource = wl_resource_create(client, &hyprland_toplevel_export_manager_v1_interface,
|
||||
version, id);
|
||||
PCLIENT->resource = wl_resource_create(client, &hyprland_toplevel_export_manager_v1_interface, version, id);
|
||||
|
||||
if (!PCLIENT->resource) {
|
||||
Debug::log(ERR, "ToplevelExportManager could not bind! (out of memory?)");
|
||||
|
@ -135,7 +130,7 @@ void CToplevelExportProtocolManager::removeFrame(SToplevelFrame* frame, bool for
|
|||
if (!frame)
|
||||
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);
|
||||
wlr_buffer_unlock(frame->buffer);
|
||||
|
@ -147,10 +142,10 @@ void CToplevelExportProtocolManager::captureToplevel(wl_client* client, wl_resou
|
|||
const auto PCLIENT = clientFromResource(resource);
|
||||
|
||||
// create a frame
|
||||
const auto PFRAME = &m_lFrames.emplace_back();
|
||||
const auto PFRAME = &m_lFrames.emplace_back();
|
||||
PFRAME->overlayCursor = !!overlay_cursor;
|
||||
PFRAME->resource = wl_resource_create(client, &hyprland_toplevel_export_frame_v1_interface, wl_resource_get_version(resource), frame);
|
||||
PFRAME->pWindow = pWindow;
|
||||
PFRAME->resource = wl_resource_create(client, &hyprland_toplevel_export_frame_v1_interface, wl_resource_get_version(resource), frame);
|
||||
PFRAME->pWindow = pWindow;
|
||||
|
||||
if (!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->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;
|
||||
wlr_output_effective_resolution(PMONITOR->output, &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;
|
||||
void* wlrBufferAccessData;
|
||||
uint32_t wlrBufferAccessFormat;
|
||||
size_t wlrBufferAccessStride;
|
||||
void* wlrBufferAccessData;
|
||||
uint32_t wlrBufferAccessFormat;
|
||||
size_t wlrBufferAccessStride;
|
||||
if (wlr_buffer_get_dmabuf(PBUFFER, &dmabufAttrs)) {
|
||||
PFRAME->bufferCap = WLR_BUFFER_CAP_DMABUF;
|
||||
|
||||
|
@ -287,7 +282,7 @@ void CToplevelExportProtocolManager::onMonitorRender(CMonitor* pMonitor) {
|
|||
return; // nothing to share
|
||||
|
||||
std::vector<SToplevelFrame*> framesToRemove;
|
||||
|
||||
|
||||
// share frame if correct output
|
||||
for (auto& f : m_vFramesAwaitingWrite) {
|
||||
if (!f->pWindow) {
|
||||
|
@ -295,12 +290,11 @@ void CToplevelExportProtocolManager::onMonitorRender(CMonitor* pMonitor) {
|
|||
continue;
|
||||
}
|
||||
|
||||
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 };
|
||||
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};
|
||||
|
||||
if (!wlr_output_layout_intersects(g_pCompositor->m_sWLROutputLayout, pMonitor->output, &geometry))
|
||||
continue;
|
||||
|
||||
|
||||
shareFrame(f);
|
||||
|
||||
framesToRemove.push_back(f);
|
||||
|
@ -342,14 +336,14 @@ void CToplevelExportProtocolManager::shareFrame(SToplevelFrame* frame) {
|
|||
}
|
||||
|
||||
bool CToplevelExportProtocolManager::copyFrameShm(SToplevelFrame* frame, timespec* now) {
|
||||
void* data;
|
||||
void* data;
|
||||
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))
|
||||
return false;
|
||||
|
||||
// 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_init_rect(&fakeDamage, 0, 0, PMONITOR->vecPixelSize.x * 10, PMONITOR->vecPixelSize.y * 10);
|
||||
|
||||
|
|
|
@ -11,60 +11,60 @@ class CMonitor;
|
|||
class CWindow;
|
||||
|
||||
struct SToplevelClient {
|
||||
int ref = 0;
|
||||
int ref = 0;
|
||||
wl_resource* resource = nullptr;
|
||||
|
||||
bool operator==(const SToplevelClient& other) {
|
||||
bool operator==(const SToplevelClient& other) {
|
||||
return resource == other.resource;
|
||||
}
|
||||
};
|
||||
|
||||
struct SToplevelFrame {
|
||||
wl_resource* resource = nullptr;
|
||||
SToplevelClient* client = nullptr;
|
||||
wl_resource* resource = nullptr;
|
||||
SToplevelClient* client = nullptr;
|
||||
|
||||
uint32_t shmFormat = 0;
|
||||
uint32_t dmabufFormat = 0;
|
||||
wlr_box box = { 0 };
|
||||
int shmStride = 0;
|
||||
uint32_t shmFormat = 0;
|
||||
uint32_t dmabufFormat = 0;
|
||||
wlr_box box = {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;
|
||||
}
|
||||
};
|
||||
|
||||
class CToplevelExportProtocolManager {
|
||||
public:
|
||||
public:
|
||||
CToplevelExportProtocolManager();
|
||||
|
||||
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 removeClient(SToplevelClient* client, 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 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 removeClient(SToplevelClient* client, 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 onMonitorRender(CMonitor* pMonitor);
|
||||
void displayDestroy();
|
||||
void onWindowUnmap(CWindow* pWindow);
|
||||
void onMonitorRender(CMonitor* pMonitor);
|
||||
void displayDestroy();
|
||||
void onWindowUnmap(CWindow* pWindow);
|
||||
|
||||
private:
|
||||
wl_global* m_pGlobal = nullptr;
|
||||
std::list<SToplevelFrame> m_lFrames;
|
||||
std::list<SToplevelClient> m_lClients;
|
||||
private:
|
||||
wl_global* m_pGlobal = nullptr;
|
||||
std::list<SToplevelFrame> m_lFrames;
|
||||
std::list<SToplevelClient> m_lClients;
|
||||
|
||||
wl_listener m_liDisplayDestroy;
|
||||
wl_listener m_liDisplayDestroy;
|
||||
|
||||
std::vector<SToplevelFrame*> m_vFramesAwaitingWrite;
|
||||
|
||||
void shareFrame(SToplevelFrame* frame);
|
||||
bool copyFrameDmabuf(SToplevelFrame* frame);
|
||||
bool copyFrameShm(SToplevelFrame* frame, timespec* now);
|
||||
void shareFrame(SToplevelFrame* frame);
|
||||
bool copyFrameDmabuf(SToplevelFrame* frame);
|
||||
bool copyFrameShm(SToplevelFrame* frame, timespec* now);
|
||||
};
|
|
@ -10,7 +10,7 @@ bool CFramebuffer::alloc(int w, int h) {
|
|||
glGenFramebuffers(1, &m_iFb);
|
||||
}
|
||||
|
||||
if (m_cTex.m_iTexID == 0) {
|
||||
if (m_cTex.m_iTexID == 0) {
|
||||
firstAlloc = true;
|
||||
glGenTextures(1, &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);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_cTex.m_iTexID, 0);
|
||||
|
||||
// TODO: Allow this with gles2
|
||||
#ifndef GLES2
|
||||
// TODO: Allow this with gles2
|
||||
#ifndef GLES2
|
||||
if (m_pStencilTex) {
|
||||
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);
|
||||
|
@ -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);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
auto status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
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() {
|
||||
#ifndef GLES2
|
||||
#ifndef GLES2
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_iFb);
|
||||
#else
|
||||
#else
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_iFb);
|
||||
#endif
|
||||
#endif
|
||||
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_iFb = -1;
|
||||
m_Size = Vector2D();
|
||||
m_iFb = -1;
|
||||
m_Size = Vector2D();
|
||||
}
|
||||
|
||||
CFramebuffer::~CFramebuffer() {
|
||||
|
|
|
@ -4,24 +4,23 @@
|
|||
#include "Texture.hpp"
|
||||
|
||||
class CFramebuffer {
|
||||
public:
|
||||
|
||||
public:
|
||||
~CFramebuffer();
|
||||
|
||||
bool alloc(int w, int h);
|
||||
void bind();
|
||||
void release();
|
||||
void reset();
|
||||
bool isAllocated();
|
||||
bool alloc(int w, int h);
|
||||
void bind();
|
||||
void release();
|
||||
void reset();
|
||||
bool isAllocated();
|
||||
|
||||
Vector2D m_Position;
|
||||
Vector2D m_Size;
|
||||
float m_fScale = 1;
|
||||
Vector2D m_Position;
|
||||
Vector2D m_Size;
|
||||
float m_fScale = 1;
|
||||
|
||||
CTexture m_cTex;
|
||||
GLuint m_iFb = -1;
|
||||
CTexture m_cTex;
|
||||
GLuint m_iFb = -1;
|
||||
|
||||
CTexture* m_pStencilTex = nullptr;
|
||||
CTexture* m_pStencilTex = nullptr;
|
||||
|
||||
wl_output_transform m_tTransform; // for saving state
|
||||
};
|
|
@ -5,9 +5,10 @@
|
|||
#include "Shaders.hpp"
|
||||
|
||||
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!");
|
||||
|
||||
|
@ -21,9 +22,9 @@ CHyprOpenGLImpl::CHyprOpenGLImpl() {
|
|||
Debug::log(LOG, "Renderer: %s", glGetString(GL_RENDERER));
|
||||
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!");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
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) {
|
||||
m_RenderData.pCurrentMonData->stencilTex.allocate();
|
||||
|
||||
m_RenderData.pCurrentMonData->primaryFB.m_pStencilTex = &m_RenderData.pCurrentMonData->stencilTex;
|
||||
m_RenderData.pCurrentMonData->mirrorFB.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->mirrorSwapFB.m_pStencilTex = &m_RenderData.pCurrentMonData->stencilTex;
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
wlr_box monbox = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
||||
|
||||
clear(CColor(11, 11, 11, 255));
|
||||
|
||||
m_bEndFrame = true;
|
||||
m_bEndFrame = true;
|
||||
m_bApplyFinalShader = true;
|
||||
|
||||
renderTexture(m_RenderData.pCurrentMonData->primaryFB.m_cTex, &monbox, 255.f, 0);
|
||||
|
||||
m_bApplyFinalShader = false;
|
||||
m_bEndFrame = false;
|
||||
m_bEndFrame = false;
|
||||
}
|
||||
|
||||
// reset our data
|
||||
m_RenderData.pMonitor = nullptr;
|
||||
m_iWLROutputFb = 0;
|
||||
m_iWLROutputFb = 0;
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::initShaders() {
|
||||
GLuint prog = createProgram(QUADVERTSRC, QUADFRAGSRC);
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.proj = glGetUniformLocation(prog, "proj");
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.color = glGetUniformLocation(prog, "color");
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.radius = glGetUniformLocation(prog, "radius");
|
||||
GLuint prog = createProgram(QUADVERTSRC, QUADFRAGSRC);
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.proj = glGetUniformLocation(prog, "proj");
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.color = glGetUniformLocation(prog, "color");
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.radius = glGetUniformLocation(prog, "radius");
|
||||
m_RenderData.pCurrentMonData->m_shQUAD.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
||||
|
||||
prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBA);
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.proj = glGetUniformLocation(prog, "proj");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.tex = glGetUniformLocation(prog, "tex");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.alpha = glGetUniformLocation(prog, "alpha");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.radius = glGetUniformLocation(prog, "radius");
|
||||
prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBA);
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.proj = glGetUniformLocation(prog, "proj");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.tex = glGetUniformLocation(prog, "tex");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.alpha = glGetUniformLocation(prog, "alpha");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.radius = glGetUniformLocation(prog, "radius");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.applyTint = glGetUniformLocation(prog, "applyTint");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.tint = glGetUniformLocation(prog, "tint");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.applyTint = glGetUniformLocation(prog, "applyTint");
|
||||
m_RenderData.pCurrentMonData->m_shRGBA.tint = glGetUniformLocation(prog, "tint");
|
||||
|
||||
prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBX);
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.tex = glGetUniformLocation(prog, "tex");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.proj = glGetUniformLocation(prog, "proj");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.alpha = glGetUniformLocation(prog, "alpha");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.radius = glGetUniformLocation(prog, "radius");
|
||||
prog = createProgram(TEXVERTSRC, TEXFRAGSRCRGBX);
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.tex = glGetUniformLocation(prog, "tex");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.proj = glGetUniformLocation(prog, "proj");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.alpha = glGetUniformLocation(prog, "alpha");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.radius = glGetUniformLocation(prog, "radius");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.applyTint = glGetUniformLocation(prog, "applyTint");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.tint = glGetUniformLocation(prog, "tint");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.applyTint = glGetUniformLocation(prog, "applyTint");
|
||||
m_RenderData.pCurrentMonData->m_shRGBX.tint = glGetUniformLocation(prog, "tint");
|
||||
|
||||
prog = createProgram(TEXVERTSRC, TEXFRAGSRCEXT);
|
||||
m_RenderData.pCurrentMonData->m_shEXT.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shEXT.tex = glGetUniformLocation(prog, "tex");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.proj = glGetUniformLocation(prog, "proj");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.alpha = glGetUniformLocation(prog, "alpha");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.radius = glGetUniformLocation(prog, "radius");
|
||||
prog = createProgram(TEXVERTSRC, TEXFRAGSRCEXT);
|
||||
m_RenderData.pCurrentMonData->m_shEXT.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shEXT.tex = glGetUniformLocation(prog, "tex");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.proj = glGetUniformLocation(prog, "proj");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.alpha = glGetUniformLocation(prog, "alpha");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.discardOpaque = glGetUniformLocation(prog, "discardOpaque");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.radius = glGetUniformLocation(prog, "radius");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.applyTint = glGetUniformLocation(prog, "applyTint");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.tint = glGetUniformLocation(prog, "tint");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.applyTint = glGetUniformLocation(prog, "applyTint");
|
||||
m_RenderData.pCurrentMonData->m_shEXT.tint = glGetUniformLocation(prog, "tint");
|
||||
|
||||
prog = createProgram(TEXVERTSRC, FRAGBLUR1);
|
||||
m_RenderData.pCurrentMonData->m_shBLUR1.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shBLUR1.tex = glGetUniformLocation(prog, "tex");
|
||||
m_RenderData.pCurrentMonData->m_shBLUR1.alpha = glGetUniformLocation(prog, "alpha");
|
||||
m_RenderData.pCurrentMonData->m_shBLUR1.proj = glGetUniformLocation(prog, "proj");
|
||||
prog = createProgram(TEXVERTSRC, FRAGBLUR1);
|
||||
m_RenderData.pCurrentMonData->m_shBLUR1.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shBLUR1.tex = glGetUniformLocation(prog, "tex");
|
||||
m_RenderData.pCurrentMonData->m_shBLUR1.alpha = glGetUniformLocation(prog, "alpha");
|
||||
m_RenderData.pCurrentMonData->m_shBLUR1.proj = glGetUniformLocation(prog, "proj");
|
||||
m_RenderData.pCurrentMonData->m_shBLUR1.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
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");
|
||||
|
||||
prog = createProgram(TEXVERTSRC, FRAGBLUR2);
|
||||
m_RenderData.pCurrentMonData->m_shBLUR2.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shBLUR2.tex = glGetUniformLocation(prog, "tex");
|
||||
m_RenderData.pCurrentMonData->m_shBLUR2.alpha = glGetUniformLocation(prog, "alpha");
|
||||
m_RenderData.pCurrentMonData->m_shBLUR2.proj = glGetUniformLocation(prog, "proj");
|
||||
prog = createProgram(TEXVERTSRC, FRAGBLUR2);
|
||||
m_RenderData.pCurrentMonData->m_shBLUR2.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shBLUR2.tex = glGetUniformLocation(prog, "tex");
|
||||
m_RenderData.pCurrentMonData->m_shBLUR2.alpha = glGetUniformLocation(prog, "alpha");
|
||||
m_RenderData.pCurrentMonData->m_shBLUR2.proj = glGetUniformLocation(prog, "proj");
|
||||
m_RenderData.pCurrentMonData->m_shBLUR2.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
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");
|
||||
|
||||
prog = createProgram(QUADVERTSRC, FRAGSHADOW);
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.proj = glGetUniformLocation(prog, "proj");
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||
prog = createProgram(QUADVERTSRC, FRAGSHADOW);
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.proj = glGetUniformLocation(prog, "proj");
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.bottomRight = glGetUniformLocation(prog, "bottomRight");
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.radius = glGetUniformLocation(prog, "radius");
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.range = glGetUniformLocation(prog, "range");
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.radius = glGetUniformLocation(prog, "radius");
|
||||
m_RenderData.pCurrentMonData->m_shSHADOW.range = glGetUniformLocation(prog, "range");
|
||||
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);
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.proj = glGetUniformLocation(prog, "proj");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.thick = glGetUniformLocation(prog, "thick");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.bottomRight = glGetUniformLocation(prog, "bottomRight");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||
prog = createProgram(QUADVERTSRC, FRAGBORDER1);
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.program = prog;
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.proj = glGetUniformLocation(prog, "proj");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.thick = glGetUniformLocation(prog, "thick");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib = glGetAttribLocation(prog, "pos");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.texAttrib = glGetAttribLocation(prog, "texcoord");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.topLeft = glGetUniformLocation(prog, "topLeft");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.bottomRight = glGetUniformLocation(prog, "bottomRight");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.fullSize = glGetUniformLocation(prog, "fullSize");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.fullSizeUntransformed = glGetUniformLocation(prog, "fullSizeUntransformed");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.radius = glGetUniformLocation(prog, "radius");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.gradient = glGetUniformLocation(prog, "gradient");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.gradientLength = glGetUniformLocation(prog, "gradientLength");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.angle = glGetUniformLocation(prog, "angle");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.alpha = glGetUniformLocation(prog, "alpha");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.radius = glGetUniformLocation(prog, "radius");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.primitiveMultisample = glGetUniformLocation(prog, "primitiveMultisample");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.gradient = glGetUniformLocation(prog, "gradient");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.gradientLength = glGetUniformLocation(prog, "gradientLength");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.angle = glGetUniformLocation(prog, "angle");
|
||||
m_RenderData.pCurrentMonData->m_shBORDER1.alpha = glGetUniformLocation(prog, "alpha");
|
||||
|
||||
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>()));
|
||||
|
||||
m_sFinalScreenShader.program = createProgram(TEXVERTSRC, fragmentShader, true);
|
||||
|
||||
|
||||
if (!m_sFinalScreenShader.program) {
|
||||
g_pConfigManager->addParseError("Screen shader parser: Screen shader parse failed");
|
||||
return;
|
||||
}
|
||||
|
||||
m_sFinalScreenShader.proj = glGetUniformLocation(m_sFinalScreenShader.program, "proj");
|
||||
m_sFinalScreenShader.tex = glGetUniformLocation(m_sFinalScreenShader.program, "tex");
|
||||
m_sFinalScreenShader.proj = glGetUniformLocation(m_sFinalScreenShader.program, "proj");
|
||||
m_sFinalScreenShader.tex = glGetUniformLocation(m_sFinalScreenShader.program, "tex");
|
||||
m_sFinalScreenShader.texAttrib = glGetAttribLocation(m_sFinalScreenShader.program, "texcoord");
|
||||
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) {
|
||||
wlr_box box = {x,y,w,h};
|
||||
wlr_box box = {x, y, w, h};
|
||||
scissor(&box, transform);
|
||||
}
|
||||
|
||||
void CHyprOpenGLImpl::renderRect(wlr_box* box, const CColor& col, int round) {
|
||||
if(pixman_region32_not_empty(m_RenderData.pDamage))
|
||||
renderRectWithDamage(box, col, m_RenderData.pDamage, round);
|
||||
if (pixman_region32_not_empty(m_RenderData.pDamage))
|
||||
renderRectWithDamage(box, col, m_RenderData.pDamage, 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()!");
|
||||
|
||||
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];
|
||||
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);
|
||||
|
||||
wlr_box transformedBox;
|
||||
wlr_box_transform(&transformedBox, box, wlr_output_transform_invert(m_RenderData.pMonitor->transform),
|
||||
m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y);
|
||||
wlr_box_transform(&transformedBox, box, wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x,
|
||||
m_RenderData.pMonitor->vecTransformedSize.y);
|
||||
|
||||
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
||||
const auto FULLSIZE = Vector2D(transformedBox.width, transformedBox.height);
|
||||
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
||||
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
|
||||
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 {
|
||||
PIXMAN_DAMAGE_FOREACH(damage) {
|
||||
const auto RECT = RECTSARR[i];
|
||||
scissor(&RECT);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
PIXMAN_DAMAGE_FOREACH(damage) {
|
||||
const auto RECT = RECTSARR[i];
|
||||
scissor(&RECT);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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((tex.m_iTexID > 0), "Attempted to draw NULL texture!");
|
||||
|
||||
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
|
||||
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);
|
||||
|
||||
float glMatrix[9];
|
||||
|
@ -479,21 +482,14 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
|
|||
bool usingFinalShader = false;
|
||||
|
||||
if (m_bApplyFinalShader && m_sFinalScreenShader.program) {
|
||||
shader = &m_sFinalScreenShader;
|
||||
shader = &m_sFinalScreenShader;
|
||||
usingFinalShader = true;
|
||||
} else {
|
||||
switch (tex.m_iType) {
|
||||
case TEXTURE_RGBA:
|
||||
shader = &m_RenderData.pCurrentMonData->m_shRGBA;
|
||||
break;
|
||||
case TEXTURE_RGBX:
|
||||
shader = &m_RenderData.pCurrentMonData->m_shRGBX;
|
||||
break;
|
||||
case TEXTURE_EXTERNAL:
|
||||
shader = &m_RenderData.pCurrentMonData->m_shEXT;
|
||||
break;
|
||||
default:
|
||||
RASSERT(false, "tex.m_iTarget unsupported!");
|
||||
case TEXTURE_RGBA: shader = &m_RenderData.pCurrentMonData->m_shRGBA; break;
|
||||
case TEXTURE_RGBX: 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_transform(&transformedBox, pBox, wlr_output_transform_invert(m_RenderData.pMonitor->transform),
|
||||
m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y);
|
||||
wlr_box_transform(&transformedBox, pBox, wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x,
|
||||
m_RenderData.pMonitor->vecTransformedSize.y);
|
||||
|
||||
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
||||
const auto FULLSIZE = Vector2D(transformedBox.width, transformedBox.height);
|
||||
static auto *const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue;
|
||||
const auto TOPLEFT = Vector2D(transformedBox.x, transformedBox.y);
|
||||
const auto FULLSIZE = Vector2D(transformedBox.width, transformedBox.height);
|
||||
static auto* const PMULTISAMPLEEDGES = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue;
|
||||
|
||||
if (!usingFinalShader) {
|
||||
// Rounded corners
|
||||
|
@ -541,10 +537,10 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b
|
|||
}
|
||||
|
||||
const float verts[] = {
|
||||
m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVTopLeft.y, // top right
|
||||
m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVTopLeft.y, // top left
|
||||
m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom right
|
||||
m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom left
|
||||
m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVTopLeft.y, // top right
|
||||
m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVTopLeft.y, // top left
|
||||
m_RenderData.primarySurfaceUVBottomRight.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom right
|
||||
m_RenderData.primarySurfaceUVTopLeft.x, m_RenderData.primarySurfaceUVBottomRight.y, // bottom left
|
||||
};
|
||||
|
||||
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 {
|
||||
PIXMAN_DAMAGE_FOREACH(damage) {
|
||||
const auto RECT = RECTSARR[i];
|
||||
scissor(&RECT);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
PIXMAN_DAMAGE_FOREACH(damage) {
|
||||
const auto RECT = RECTSARR[i];
|
||||
scissor(&RECT);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
glDisableVertexAttribArray(shader->posAttrib);
|
||||
|
@ -597,27 +593,28 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p
|
|||
|
||||
// get transforms for the full monitor
|
||||
const auto TRANSFORM = wlr_output_transform_invert(m_RenderData.pMonitor->transform);
|
||||
float matrix[9];
|
||||
wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
||||
float matrix[9];
|
||||
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);
|
||||
|
||||
float glMatrix[9];
|
||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||
|
||||
// get the config settings
|
||||
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 PBLURSIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_size")->intValue;
|
||||
static auto* const PBLURPASSES = &g_pConfigManager->getConfigValuePtr("decoration:blur_passes")->intValue;
|
||||
|
||||
// prep damage
|
||||
pixman_region32_t damage;
|
||||
pixman_region32_init(&damage);
|
||||
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);
|
||||
|
||||
// helper
|
||||
const auto PMIRRORFB = &m_RenderData.pCurrentMonData->mirrorFB;
|
||||
const auto PMIRRORSWAPFB = &m_RenderData.pCurrentMonData->mirrorSwapFB;
|
||||
const auto PMIRRORFB = &m_RenderData.pCurrentMonData->mirrorFB;
|
||||
const auto PMIRRORSWAPFB = &m_RenderData.pCurrentMonData->mirrorSwapFB;
|
||||
|
||||
CFramebuffer* currentRenderToFB = &m_RenderData.pCurrentMonData->primaryFB;
|
||||
|
||||
|
@ -643,11 +640,13 @@ CFramebuffer* CHyprOpenGLImpl::blurMainFramebufferWithDamage(float a, wlr_box* p
|
|||
wlr_matrix_transpose(glMatrix, glMatrix);
|
||||
glUniformMatrix3fv(pShader->proj, 1, GL_FALSE, glMatrix);
|
||||
#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)
|
||||
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
|
||||
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);
|
||||
|
||||
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
|
||||
pixman_region32_t 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);
|
||||
|
||||
// and draw
|
||||
for (int i = 1; i < *PBLURPASSES; ++i) {
|
||||
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) {
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
// finish
|
||||
|
@ -714,9 +713,9 @@ void CHyprOpenGLImpl::markBlurDirtyForMonitor(CMonitor* pMonitor) {
|
|||
}
|
||||
|
||||
void CHyprOpenGLImpl::preRender(CMonitor* pMonitor) {
|
||||
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 PBLUR = &g_pConfigManager->getConfigValuePtr("decoration:blur")->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 PBLUR = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue;
|
||||
|
||||
if (!*PBLURNEWOPTIMIZE || !m_mMonitorRenderResources[pMonitor].blurFBDirty || !*PBLUR)
|
||||
return;
|
||||
|
@ -739,14 +738,14 @@ void CHyprOpenGLImpl::preBlurForCurrentMonitor() {
|
|||
// make the fake dmg
|
||||
pixman_region32_t fakeDamage;
|
||||
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};
|
||||
const auto POUTFB = blurMainFramebufferWithDamage(255, &wholeMonitor, &fakeDamage);
|
||||
wlr_box wholeMonitor = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
||||
const auto POUTFB = blurMainFramebufferWithDamage(255, &wholeMonitor, &fakeDamage);
|
||||
|
||||
// render onto blurFB
|
||||
m_RenderData.pCurrentMonData->blurFB.alloc(m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y);
|
||||
m_RenderData.pCurrentMonData->blurFB.bind();
|
||||
|
||||
clear(CColor(0,0,0,0));
|
||||
clear(CColor(0, 0, 0, 0));
|
||||
|
||||
m_bEndFrame = true; // fix transformed
|
||||
renderTextureInternalWithDamage(POUTFB->m_cTex, &wholeMonitor, 255, &fakeDamage, 0, false, true, false);
|
||||
|
@ -760,14 +759,14 @@ void CHyprOpenGLImpl::preBlurForCurrentMonitor() {
|
|||
}
|
||||
|
||||
void CHyprOpenGLImpl::preWindowPass() {
|
||||
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 PBLUR = &g_pConfigManager->getConfigValuePtr("decoration:blur")->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 PBLUR = &g_pConfigManager->getConfigValuePtr("decoration:blur")->intValue;
|
||||
|
||||
if (!m_RenderData.pCurrentMonData->blurFBDirty || !*PBLURNEWOPTIMIZE || !*PBLUR)
|
||||
return;
|
||||
|
||||
auto windowShouldBeBlurred = [&] (CWindow* pWindow) -> bool {
|
||||
auto windowShouldBeBlurred = [&](CWindow* pWindow) -> bool {
|
||||
if (!pWindow)
|
||||
return false;
|
||||
|
||||
|
@ -781,8 +780,8 @@ void CHyprOpenGLImpl::preWindowPass() {
|
|||
|
||||
pixman_region32_t inverseOpaque;
|
||||
pixman_region32_init(&inverseOpaque);
|
||||
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 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;
|
||||
|
||||
if (A >= 255.f) {
|
||||
pixman_box32_t surfbox = {0, 0, PSURFACE->current.width, PSURFACE->current.height};
|
||||
|
@ -808,7 +807,7 @@ void CHyprOpenGLImpl::preWindowPass() {
|
|||
// check if window is valid
|
||||
if (!windowShouldBeBlurred(w.get()))
|
||||
continue;
|
||||
|
||||
|
||||
hasWindows = true;
|
||||
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) {
|
||||
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 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 PBLURXRAY = &g_pConfigManager->getConfigValuePtr("decoration:blur_xray")->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 PBLURNEWOPTIMIZE = &g_pConfigManager->getConfigValuePtr("decoration:blur_new_optimizations")->intValue;
|
||||
static auto* const PBLURXRAY = &g_pConfigManager->getConfigValuePtr("decoration:blur_xray")->intValue;
|
||||
|
||||
// make a damage region for this window
|
||||
pixman_region32_t 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))
|
||||
return;
|
||||
if (!pixman_region32_not_empty(&damage))
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
@ -861,7 +861,9 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
|
|||
}
|
||||
|
||||
// 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;
|
||||
if (!USENEWOPTIMIZE) {
|
||||
|
@ -886,7 +888,7 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
|
|||
m_RenderData.pCurrentMonData->primaryFB.bind();
|
||||
|
||||
// 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);
|
||||
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);
|
||||
if (USENEWOPTIMIZE)
|
||||
renderRect(pBox, CColor(0,0,0,0), round);
|
||||
renderRect(pBox, CColor(0, 0, 0, 0), round);
|
||||
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);
|
||||
|
||||
glStencilFunc(GL_EQUAL, 1, -1);
|
||||
|
@ -908,8 +910,8 @@ void CHyprOpenGLImpl::renderTextureWithBlur(const CTexture& tex, wlr_box* pBox,
|
|||
// stencil done. Render everything.
|
||||
wlr_box MONITORBOX = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y};
|
||||
// render our great blurred FB
|
||||
static auto *const PBLURIGNOREOPACITY = &g_pConfigManager->getConfigValuePtr("decoration:blur_ignore_opacity")->intValue;
|
||||
m_bEndFrame = true; // fix transformed
|
||||
static auto* const PBLURIGNOREOPACITY = &g_pConfigManager->getConfigValuePtr("decoration:blur_ignore_opacity")->intValue;
|
||||
m_bEndFrame = true; // fix transformed
|
||||
renderTextureInternalWithDamage(POUTFB->m_cTex, &MONITORBOX, *PBLURIGNOREOPACITY ? 255.f : a, &damage, 0, false, false, 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()!");
|
||||
|
||||
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 PMULTISAMPLE = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue;
|
||||
static auto* const PBORDERSIZE = &g_pConfigManager->getConfigValuePtr("general:border_size")->intValue;
|
||||
static auto* const PMULTISAMPLE = &g_pConfigManager->getConfigValuePtr("decoration:multisample_edges")->intValue;
|
||||
|
||||
if (*PBORDERSIZE < 1)
|
||||
return;
|
||||
|
@ -958,7 +960,8 @@ void CHyprOpenGLImpl::renderBorder(wlr_box* box, const CGradientValueData& grad,
|
|||
round += round == 0 ? 0 : scaledBorderSize;
|
||||
|
||||
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];
|
||||
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);
|
||||
|
||||
wlr_box transformedBox;
|
||||
wlr_box_transform(&transformedBox, box, wlr_output_transform_invert(m_RenderData.pMonitor->transform),
|
||||
m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y);
|
||||
wlr_box_transform(&transformedBox, box, wlr_output_transform_invert(m_RenderData.pMonitor->transform), m_RenderData.pMonitor->vecTransformedSize.x,
|
||||
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);
|
||||
|
||||
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 {
|
||||
PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) {
|
||||
const auto RECT = RECTSARR[i];
|
||||
scissor(&RECT);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) {
|
||||
const auto RECT = RECTSARR[i];
|
||||
scissor(&RECT);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shBORDER1.posAttrib);
|
||||
|
@ -1050,7 +1053,7 @@ void CHyprOpenGLImpl::makeRawWindowSnapshot(CWindow* pWindow, CFramebuffer* pFra
|
|||
|
||||
begin(PMONITOR, &fakeDamage, true);
|
||||
|
||||
clear(CColor(0, 0, 0, 0)); // JIC
|
||||
clear(CColor(0, 0, 0, 0)); // JIC
|
||||
|
||||
timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
|
@ -1072,7 +1075,7 @@ void CHyprOpenGLImpl::makeRawWindowSnapshot(CWindow* pWindow, CFramebuffer* pFra
|
|||
|
||||
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);
|
||||
|
||||
|
@ -1105,7 +1108,7 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) {
|
|||
|
||||
begin(PMONITOR, &fakeDamage, true);
|
||||
|
||||
clear(CColor(0, 0, 0, 0)); // JIC
|
||||
clear(CColor(0, 0, 0, 0)); // JIC
|
||||
|
||||
timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
|
@ -1128,7 +1131,7 @@ void CHyprOpenGLImpl::makeWindowSnapshot(CWindow* pWindow) {
|
|||
|
||||
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);
|
||||
|
||||
|
@ -1169,13 +1172,13 @@ void CHyprOpenGLImpl::makeLayerSnapshot(SLayerSurface* pLayer) {
|
|||
|
||||
PFRAMEBUFFER->bind();
|
||||
|
||||
clear(CColor(0, 0, 0, 0)); // JIC
|
||||
clear(CColor(0, 0, 0, 0)); // JIC
|
||||
|
||||
timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
|
||||
const auto BLURLSSTATUS = pLayer->forceBlur;
|
||||
pLayer->forceBlur = false;
|
||||
pLayer->forceBlur = false;
|
||||
|
||||
// draw the layer
|
||||
g_pHyprRenderer->renderLayer(pLayer, PMONITOR, &now);
|
||||
|
@ -1199,19 +1202,15 @@ void CHyprOpenGLImpl::makeLayerSnapshot(SLayerSurface* pLayer) {
|
|||
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) {
|
||||
RASSERT(m_RenderData.pMonitor, "Tried to render snapshot rect without begin()!");
|
||||
const auto PWINDOW = *pWindow;
|
||||
|
||||
auto it = m_mWindowFramebuffers.begin();
|
||||
auto it = m_mWindowFramebuffers.begin();
|
||||
for (; it != m_mWindowFramebuffers.end(); it++) {
|
||||
if (it->first == PWINDOW) {
|
||||
break;
|
||||
|
@ -1223,15 +1222,16 @@ void CHyprOpenGLImpl::renderSnapshot(CWindow** pWindow) {
|
|||
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromID(PWINDOW->m_iMonitorID);
|
||||
|
||||
wlr_box windowBox;
|
||||
wlr_box windowBox;
|
||||
// some mafs to figure out the correct box
|
||||
// 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.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.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);
|
||||
|
||||
pixman_region32_t fakeDamage;
|
||||
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);
|
||||
|
||||
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)
|
||||
PMONITOR->forceFullFrames += 1;
|
||||
|
@ -1254,7 +1254,7 @@ void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) {
|
|||
RASSERT(m_RenderData.pMonitor, "Tried to render snapshot rect without begin()!");
|
||||
const auto PLAYER = *pLayer;
|
||||
|
||||
auto it = m_mLayerFramebuffers.begin();
|
||||
auto it = m_mLayerFramebuffers.begin();
|
||||
for (; it != m_mLayerFramebuffers.end(); it++) {
|
||||
if (it->first == PLAYER) {
|
||||
break;
|
||||
|
@ -1264,9 +1264,9 @@ void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) {
|
|||
if (it == m_mLayerFramebuffers.end() || !it->second.m_cTex.m_iTexID)
|
||||
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_init_rect(&fakeDamage, 0, 0, PMONITOR->vecTransformedSize.x, PMONITOR->vecTransformedSize.y);
|
||||
|
@ -1279,7 +1279,7 @@ void CHyprOpenGLImpl::renderSnapshot(SLayerSurface** pLayer) {
|
|||
|
||||
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)
|
||||
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!");
|
||||
|
||||
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];
|
||||
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 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
|
||||
|
||||
float glMatrix[9];
|
||||
wlr_matrix_multiply(glMatrix, m_RenderData.projection, matrix);
|
||||
|
@ -1318,9 +1319,9 @@ void CHyprOpenGLImpl::renderRoundedShadow(wlr_box* box, int round, int range, fl
|
|||
#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);
|
||||
|
||||
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 FULLSIZE = Vector2D(box->width, box->height);
|
||||
const auto FULLSIZE = Vector2D(box->width, box->height);
|
||||
|
||||
// Rounded corners
|
||||
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 {
|
||||
PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) {
|
||||
const auto RECT = RECTSARR[i];
|
||||
scissor(&RECT);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
PIXMAN_DAMAGE_FOREACH(m_RenderData.pDamage) {
|
||||
const auto RECT = RECTSARR[i];
|
||||
scissor(&RECT);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
}
|
||||
|
||||
glDisableVertexAttribArray(m_RenderData.pCurrentMonData->m_shSHADOW.posAttrib);
|
||||
|
@ -1375,7 +1376,7 @@ void CHyprOpenGLImpl::saveBufferForMirror() {
|
|||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -1385,7 +1386,7 @@ void CHyprOpenGLImpl::renderMirrored() {
|
|||
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);
|
||||
|
||||
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) {
|
||||
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
|
||||
const auto PTEX = &m_mMonitorBGTextures[pMonitor];
|
||||
|
@ -1425,7 +1426,7 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
|||
|
||||
// get the adequate tex
|
||||
std::string texPath = "/usr/share/hyprland/wall_";
|
||||
Vector2D textureSize;
|
||||
Vector2D textureSize;
|
||||
if (pMonitor->vecTransformedSize.x > 3850) {
|
||||
textureSize = Vector2D(7680, 4320);
|
||||
texPath += "8K.png";
|
||||
|
@ -1441,10 +1442,10 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
|||
|
||||
// calc the target box
|
||||
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;
|
||||
double scale;
|
||||
Vector2D origin;
|
||||
double scale;
|
||||
|
||||
if (MONRATIO > WPRATIO) {
|
||||
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
|
||||
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
|
||||
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);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_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_B, GL_RED);
|
||||
#endif
|
||||
#endif
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureSize.x, textureSize.y, 0, GL_RGBA, GL_UNSIGNED_BYTE, DATA);
|
||||
|
||||
cairo_surface_destroy(CAIROSURFACE);
|
||||
|
@ -1491,7 +1492,7 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
|||
void CHyprOpenGLImpl::clearWithTex() {
|
||||
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) {
|
||||
auto TEXIT = m_mMonitorBGTextures.find(m_RenderData.pMonitor);
|
||||
|
|
|
@ -15,17 +15,12 @@
|
|||
class CHyprRenderer;
|
||||
|
||||
inline const float fullVerts[] = {
|
||||
1, 0, // top right
|
||||
0, 0, // top left
|
||||
1, 1, // bottom right
|
||||
0, 1, // bottom left
|
||||
};
|
||||
inline const float fanVertsFull[] = {
|
||||
-1.0f, -1.0f,
|
||||
1.0f, -1.0f,
|
||||
1.0f, 1.0f,
|
||||
-1.0f, 1.0f
|
||||
1, 0, // top right
|
||||
0, 0, // top left
|
||||
1, 1, // bottom right
|
||||
0, 1, // bottom left
|
||||
};
|
||||
inline const float fanVertsFull[] = {-1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f};
|
||||
|
||||
struct SMonitorRenderData {
|
||||
CFramebuffer primaryFB;
|
||||
|
@ -42,118 +37,118 @@ struct SMonitorRenderData {
|
|||
wlr_box backgroundTexBox;
|
||||
|
||||
// Shaders
|
||||
bool m_bShadersInitialized = false;
|
||||
CShader m_shQUAD;
|
||||
CShader m_shRGBA;
|
||||
CShader m_shRGBX;
|
||||
CShader m_shEXT;
|
||||
CShader m_shBLUR1;
|
||||
CShader m_shBLUR2;
|
||||
CShader m_shSHADOW;
|
||||
CShader m_shBORDER1;
|
||||
bool m_bShadersInitialized = false;
|
||||
CShader m_shQUAD;
|
||||
CShader m_shRGBA;
|
||||
CShader m_shRGBX;
|
||||
CShader m_shEXT;
|
||||
CShader m_shBLUR1;
|
||||
CShader m_shBLUR2;
|
||||
CShader m_shSHADOW;
|
||||
CShader m_shBORDER1;
|
||||
//
|
||||
};
|
||||
|
||||
struct SCurrentRenderData {
|
||||
CMonitor* pMonitor = nullptr;
|
||||
float projection[9];
|
||||
CMonitor* pMonitor = nullptr;
|
||||
float projection[9];
|
||||
|
||||
SMonitorRenderData* pCurrentMonData = nullptr;
|
||||
|
||||
pixman_region32_t* pDamage = nullptr;
|
||||
pixman_region32_t* pDamage = nullptr;
|
||||
|
||||
Vector2D primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
||||
Vector2D primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
||||
Vector2D primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
||||
Vector2D primarySurfaceUVBottomRight = Vector2D(-1, -1);
|
||||
|
||||
wlr_box clipBox = {};
|
||||
wlr_box clipBox = {};
|
||||
};
|
||||
|
||||
class CGradientValueData;
|
||||
|
||||
class CHyprOpenGLImpl {
|
||||
public:
|
||||
|
||||
public:
|
||||
CHyprOpenGLImpl();
|
||||
|
||||
void begin(CMonitor*, pixman_region32_t*, bool fake = false);
|
||||
void end();
|
||||
void begin(CMonitor*, pixman_region32_t*, bool fake = false);
|
||||
void end();
|
||||
|
||||
void renderRect(wlr_box*, const CColor&, 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(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 renderRoundedShadow(wlr_box*, int round, int range, float a = 1.0);
|
||||
void renderBorder(wlr_box*, const CGradientValueData&, int round, float a = 1.0);
|
||||
void renderRect(wlr_box*, const CColor&, 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(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 renderRoundedShadow(wlr_box*, int round, int range, float a = 1.0);
|
||||
void renderBorder(wlr_box*, const CGradientValueData&, int round, float a = 1.0);
|
||||
|
||||
void makeWindowSnapshot(CWindow*);
|
||||
void makeRawWindowSnapshot(CWindow*, CFramebuffer*);
|
||||
void makeLayerSnapshot(SLayerSurface*);
|
||||
void renderSnapshot(CWindow**);
|
||||
void renderSnapshot(SLayerSurface**);
|
||||
void makeWindowSnapshot(CWindow*);
|
||||
void makeRawWindowSnapshot(CWindow*, CFramebuffer*);
|
||||
void makeLayerSnapshot(SLayerSurface*);
|
||||
void renderSnapshot(CWindow**);
|
||||
void renderSnapshot(SLayerSurface**);
|
||||
|
||||
void clear(const CColor&);
|
||||
void clearWithTex();
|
||||
void scissor(const wlr_box*, 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 clear(const CColor&);
|
||||
void clearWithTex();
|
||||
void scissor(const wlr_box*, 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 destroyMonitorResources(CMonitor*);
|
||||
void destroyMonitorResources(CMonitor*);
|
||||
|
||||
void markBlurDirtyForMonitor(CMonitor*);
|
||||
void markBlurDirtyForMonitor(CMonitor*);
|
||||
|
||||
void preWindowPass();
|
||||
void preRender(CMonitor*);
|
||||
void preWindowPass();
|
||||
void preRender(CMonitor*);
|
||||
|
||||
void saveBufferForMirror();
|
||||
void renderMirrored();
|
||||
void saveBufferForMirror();
|
||||
void renderMirrored();
|
||||
|
||||
void onWindowResizeStart(CWindow*);
|
||||
void onWindowResizeEnd(CWindow*);
|
||||
void onWindowResizeStart(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_iWLROutputFb = 0;
|
||||
GLint m_iCurrentOutputFb = 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<SLayerSurface*, CFramebuffer> m_mLayerFramebuffers;
|
||||
std::unordered_map<SLayerSurface*, CFramebuffer> m_mLayerFramebuffers;
|
||||
std::unordered_map<CMonitor*, SMonitorRenderData> m_mMonitorRenderResources;
|
||||
std::unordered_map<CMonitor*, CTexture> m_mMonitorBGTextures;
|
||||
std::unordered_map<CMonitor*, CTexture> m_mMonitorBGTextures;
|
||||
|
||||
private:
|
||||
std::list<GLuint> m_lBuffers;
|
||||
std::list<GLuint> m_lTextures;
|
||||
private:
|
||||
std::list<GLuint> m_lBuffers;
|
||||
std::list<GLuint> m_lTextures;
|
||||
|
||||
int m_iDRMFD;
|
||||
std::string m_szExtensions;
|
||||
int m_iDRMFD;
|
||||
std::string m_szExtensions;
|
||||
|
||||
bool m_bFakeFrame = false;
|
||||
bool m_bEndFrame = false;
|
||||
bool m_bApplyFinalShader = false;
|
||||
bool m_bFakeFrame = false;
|
||||
bool m_bEndFrame = false;
|
||||
bool m_bApplyFinalShader = false;
|
||||
|
||||
CShader m_sFinalScreenShader;
|
||||
CShader m_sFinalScreenShader;
|
||||
|
||||
GLuint createProgram(const std::string&, const std::string&, bool dynamic = false);
|
||||
GLuint compileShader(const GLuint&, std::string, bool dynamic = false);
|
||||
void createBGTextureForMonitor(CMonitor*);
|
||||
void initShaders();
|
||||
GLuint createProgram(const std::string&, const std::string&, bool dynamic = false);
|
||||
GLuint compileShader(const GLuint&, std::string, bool dynamic = false);
|
||||
void createBGTextureForMonitor(CMonitor*);
|
||||
void initShaders();
|
||||
|
||||
// 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 renderSplash(cairo_t *const, cairo_surface_t *const, double);
|
||||
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 renderSplash(cairo_t* const, cairo_surface_t* const, double);
|
||||
|
||||
void preBlurForCurrentMonitor();
|
||||
void preBlurForCurrentMonitor();
|
||||
|
||||
friend class CHyprRenderer;
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
||||
const auto TEXTURE = wlr_surface_get_texture(surface);
|
||||
const auto RDATA = (SRenderData*)data;
|
||||
const auto RDATA = (SRenderData*)data;
|
||||
|
||||
if (!TEXTURE)
|
||||
return;
|
||||
|
@ -15,7 +15,7 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
|||
wlr_box windowBox;
|
||||
if (RDATA->surface && surface == RDATA->surface)
|
||||
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)};
|
||||
|
||||
if (RDATA->squishOversized) {
|
||||
|
@ -30,9 +30,9 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
|||
|
||||
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 -= 1; // to fix a border issue
|
||||
|
@ -46,8 +46,7 @@ void renderSurface(struct wlr_surface* surface, int x, int y, void* data) {
|
|||
else
|
||||
g_pHyprOpenGL->renderTexture(TEXTURE, &windowBox, RDATA->fadeAlpha * RDATA->alpha, rounding, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
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
|
||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = 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) {
|
||||
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)))
|
||||
continue;
|
||||
|
||||
|
@ -184,19 +183,20 @@ void CHyprRenderer::renderWorkspaceWithFullscreenWindow(CMonitor* pMonitor, CWor
|
|||
}
|
||||
|
||||
// and then special windows
|
||||
if (pMonitor->specialWorkspaceID) for (auto& w : g_pCompositor->m_vWindows) {
|
||||
if (!g_pCompositor->windowValidMapped(w.get()) && !w->m_bFadingOut)
|
||||
continue;
|
||||
if (pMonitor->specialWorkspaceID)
|
||||
for (auto& w : g_pCompositor->m_vWindows) {
|
||||
if (!g_pCompositor->windowValidMapped(w.get()) && !w->m_bFadingOut)
|
||||
continue;
|
||||
|
||||
if (w->m_iWorkspaceID != pMonitor->specialWorkspaceID)
|
||||
continue;
|
||||
if (w->m_iWorkspaceID != pMonitor->specialWorkspaceID)
|
||||
continue;
|
||||
|
||||
if (!shouldRenderWindow(w.get(), pMonitor))
|
||||
continue;
|
||||
if (!shouldRenderWindow(w.get(), pMonitor))
|
||||
continue;
|
||||
|
||||
// render the bad boy
|
||||
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL);
|
||||
}
|
||||
// render the bad boy
|
||||
renderWindow(w.get(), pMonitor, time, true, RENDER_PASS_ALL);
|
||||
}
|
||||
|
||||
// and the overlay layers
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
for (auto& ls : pMonitor->m_aLayerSurfaceLists[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]) {
|
||||
renderLayer(ls.get(), pMonitor, time);
|
||||
}
|
||||
|
@ -226,11 +225,11 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
|
|||
return;
|
||||
}
|
||||
|
||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
||||
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;
|
||||
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
|
||||
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;
|
||||
|
||||
SRenderData renderdata = {pMonitor->output, time, REALPOS.x, REALPOS.y};
|
||||
SRenderData renderdata = {pMonitor->output, time, REALPOS.x, REALPOS.y};
|
||||
if (ignorePosition) {
|
||||
renderdata.x = pMonitor->vecPosition.x;
|
||||
renderdata.y = pMonitor->vecPosition.y;
|
||||
|
@ -239,19 +238,20 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
|
|||
if (ignoreAllGeometry)
|
||||
decorate = false;
|
||||
|
||||
renderdata.surface = g_pXWaylandManager->getWindowSurface(pWindow);
|
||||
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.surface = g_pXWaylandManager->getWindowSurface(pWindow);
|
||||
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.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.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.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.rounding = ignoreAllGeometry ? 0 : pWindow->m_sAdditionalConfigData.rounding;
|
||||
renderdata.blur = !ignoreAllGeometry; // if it shouldn't, it will be ignored later
|
||||
renderdata.pWindow = pWindow;
|
||||
renderdata.blur = !ignoreAllGeometry; // if it shouldn't, it will be ignored later
|
||||
renderdata.pWindow = pWindow;
|
||||
|
||||
if (ignoreAllGeometry) {
|
||||
renderdata.alpha = 1.f;
|
||||
renderdata.alpha = 1.f;
|
||||
renderdata.fadeAlpha = 255.f;
|
||||
}
|
||||
|
||||
|
@ -265,9 +265,9 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
|
|||
Vector2D offset;
|
||||
if (!ignorePosition && pWindow->m_bIsFloating && !pWindow->m_bPinned) {
|
||||
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 WINBB = pWindow->getFullWindowBoundingBox();
|
||||
const auto WINBB = pWindow->getFullWindowBoundingBox();
|
||||
|
||||
if (WINBB.x < PWSMON->vecPosition.x) {
|
||||
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;
|
||||
}
|
||||
} 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 WINBB = pWindow->getFullWindowBoundingBox();
|
||||
const auto WINBB = pWindow->getFullWindowBoundingBox();
|
||||
|
||||
if (WINBB.y < PWSMON->vecPosition.y) {
|
||||
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.y += offset.y;
|
||||
}
|
||||
|
||||
|
||||
// render window decorations first, if not fullscreen full
|
||||
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);
|
||||
|
||||
wlr_surface_for_each_surface(g_pXWaylandManager->getWindowSurface(pWindow), renderSurface, &renderdata);
|
||||
|
||||
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;
|
||||
|
||||
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();
|
||||
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);
|
||||
|
||||
|
@ -328,15 +329,15 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
|
|||
renderdata.x -= geom.x;
|
||||
renderdata.y -= geom.y;
|
||||
|
||||
renderdata.dontRound = true; // don't round popups
|
||||
renderdata.pMonitor = pMonitor;
|
||||
renderdata.dontRound = true; // don't round popups
|
||||
renderdata.pMonitor = pMonitor;
|
||||
renderdata.squishOversized = false; // don't squish popups
|
||||
wlr_xdg_surface_for_each_popup_surface(pWindow->m_uSurface.xdg, renderSurface, &renderdata);
|
||||
}
|
||||
}
|
||||
|
||||
g_pHyprOpenGL->m_pCurrentWindow = nullptr;
|
||||
g_pHyprOpenGL->m_RenderData.clipBox = { 0, 0, 0, 0 };
|
||||
g_pHyprOpenGL->m_pCurrentWindow = nullptr;
|
||||
g_pHyprOpenGL->m_RenderData.clipBox = {0, 0, 0, 0};
|
||||
}
|
||||
|
||||
void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, timespec* time) {
|
||||
|
@ -345,29 +346,29 @@ void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, times
|
|||
return;
|
||||
}
|
||||
|
||||
SRenderData renderdata = {pMonitor->output, time, pLayer->geometry.x, pLayer->geometry.y};
|
||||
renderdata.fadeAlpha = pLayer->alpha.fl();
|
||||
renderdata.blur = pLayer->forceBlur;
|
||||
renderdata.surface = pLayer->layerSurface->surface;
|
||||
renderdata.decorate = false;
|
||||
renderdata.w = pLayer->layerSurface->surface->current.width;
|
||||
renderdata.h = pLayer->layerSurface->surface->current.height;
|
||||
SRenderData renderdata = {pMonitor->output, time, pLayer->geometry.x, pLayer->geometry.y};
|
||||
renderdata.fadeAlpha = pLayer->alpha.fl();
|
||||
renderdata.blur = pLayer->forceBlur;
|
||||
renderdata.surface = pLayer->layerSurface->surface;
|
||||
renderdata.decorate = false;
|
||||
renderdata.w = pLayer->layerSurface->surface->current.width;
|
||||
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;
|
||||
wlr_surface_for_each_surface(pLayer->layerSurface->surface, renderSurface, &renderdata);
|
||||
|
||||
renderdata.squishOversized = false; // don't squish popups
|
||||
renderdata.dontRound = true;
|
||||
renderdata.squishOversized = false; // don't squish popups
|
||||
renderdata.dontRound = true;
|
||||
wlr_layer_surface_v1_for_each_popup_surface(pLayer->layerSurface, renderSurface, &renderdata);
|
||||
}
|
||||
|
||||
void CHyprRenderer::renderIMEPopup(SIMEPopup* pPopup, CMonitor* pMonitor, timespec* time) {
|
||||
SRenderData renderdata = {pMonitor->output, time, pPopup->realX, pPopup->realY};
|
||||
|
||||
renderdata.blur = false;
|
||||
renderdata.surface = pPopup->pSurface->surface;
|
||||
renderdata.blur = false;
|
||||
renderdata.surface = pPopup->pSurface->surface;
|
||||
renderdata.decorate = false;
|
||||
renderdata.w = pPopup->pSurface->surface->current.width;
|
||||
renderdata.h = pPopup->pSurface->surface->current.height;
|
||||
renderdata.w = pPopup->pSurface->surface->current.width;
|
||||
renderdata.h = pPopup->pSurface->surface->current.height;
|
||||
|
||||
wlr_surface_for_each_surface(pPopup->pSurface->surface, renderSurface, &renderdata);
|
||||
}
|
||||
|
@ -406,14 +407,14 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
|
|||
continue;
|
||||
|
||||
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))
|
||||
continue; // special are in the third pass
|
||||
continue; // special are in the third pass
|
||||
|
||||
if (!shouldRenderWindow(w.get(), PMONITOR))
|
||||
continue;
|
||||
|
||||
|
||||
// render active window after all others of this pass
|
||||
if (w.get() == g_pCompositor->m_pLastWindow) {
|
||||
lastWindow = w.get();
|
||||
|
@ -433,7 +434,7 @@ void CHyprRenderer::renderAllClientsForMonitor(const int& ID, timespec* time) {
|
|||
continue;
|
||||
|
||||
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))
|
||||
continue; // special are in the third pass
|
||||
|
@ -500,7 +501,7 @@ void CHyprRenderer::calculateUVForWindowSurface(CWindow* pWindow, wlr_surface* p
|
|||
Vector2D uvTL;
|
||||
Vector2D uvBR = Vector2D(1, 1);
|
||||
|
||||
wlr_box geom;
|
||||
wlr_box geom;
|
||||
wlr_xdg_surface_get_geometry(pWindow->m_uSurface.xdg, &geom);
|
||||
|
||||
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) {
|
||||
uvTL = Vector2D();
|
||||
uvBR = Vector2D(1,1);
|
||||
uvBR = Vector2D(1, 1);
|
||||
}
|
||||
|
||||
// TODO: (example: chromium) this still has a tiny "bump" at the end.
|
||||
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));
|
||||
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));
|
||||
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));
|
||||
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) {
|
||||
// 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));
|
||||
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));
|
||||
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 = 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
|
||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = uvTL;
|
||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = uvTL;
|
||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = uvBR;
|
||||
|
||||
if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D() && g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight == Vector2D(1, 1)) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -551,12 +559,14 @@ void CHyprRenderer::calculateUVForWindowSurface(CWindow* pWindow, wlr_surface* p
|
|||
if (g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft == Vector2D(-1, -1))
|
||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(0, 0);
|
||||
|
||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight = Vector2D(
|
||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x * (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)));
|
||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight =
|
||||
Vector2D(g_pHyprOpenGL->m_RenderData.primarySurfaceUVBottomRight.x *
|
||||
(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 {
|
||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = Vector2D(-1, -1);
|
||||
g_pHyprOpenGL->m_RenderData.primarySurfaceUVTopLeft = 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)
|
||||
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;
|
||||
|
||||
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 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)
|
||||
return;
|
||||
|
@ -677,28 +688,17 @@ void CHyprRenderer::setWindowScanoutMode(CWindow* pWindow) {
|
|||
if (!POUTPUTFORMATS)
|
||||
return;
|
||||
|
||||
const auto PRENDERERFORMATS = wlr_renderer_get_dmabuf_texture_formats(g_pCompositor->m_sWLRRenderer);
|
||||
wlr_drm_format_set scanoutFormats = { 0 };
|
||||
const auto PRENDERERFORMATS = wlr_renderer_get_dmabuf_texture_formats(g_pCompositor->m_sWLRRenderer);
|
||||
wlr_drm_format_set scanoutFormats = {0};
|
||||
|
||||
if (!wlr_drm_format_set_intersect(&scanoutFormats, POUTPUTFORMATS, PRENDERERFORMATS))
|
||||
return;
|
||||
|
||||
const wlr_linux_dmabuf_feedback_v1_tranche TRANCHES[] = {
|
||||
{
|
||||
.target_device = scanoutDevice,
|
||||
.flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT,
|
||||
.formats = &scanoutFormats
|
||||
}, {
|
||||
.target_device = rendererDevice,
|
||||
.formats = PRENDERERFORMATS
|
||||
}
|
||||
};
|
||||
{.target_device = scanoutDevice, .flags = ZWP_LINUX_DMABUF_FEEDBACK_V1_TRANCHE_FLAGS_SCANOUT, .formats = &scanoutFormats},
|
||||
{.target_device = rendererDevice, .formats = PRENDERERFORMATS}};
|
||||
|
||||
const wlr_linux_dmabuf_feedback_v1 FEEDBACK = {
|
||||
.main_device = rendererDevice,
|
||||
.tranches_len = sizeof(TRANCHES) / sizeof(TRANCHES[0]),
|
||||
.tranches = TRANCHES
|
||||
};
|
||||
const wlr_linux_dmabuf_feedback_v1 FEEDBACK = {.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)) {
|
||||
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) {
|
||||
wlr_output_configuration_head_v1* head;
|
||||
bool noError = true;
|
||||
bool noError = true;
|
||||
|
||||
wl_list_for_each(head, &config->heads, link) {
|
||||
|
||||
std::string commandForCfg = "";
|
||||
const auto OUTPUT = head->state.output;
|
||||
const auto OUTPUT = head->state.output;
|
||||
|
||||
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);
|
||||
|
||||
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
|
||||
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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromName(OUTPUT->name);
|
||||
const auto PMONITOR = g_pCompositor->getMonitorFromName(OUTPUT->name);
|
||||
|
||||
if (!PMONITOR || OUTPUT->transform != PMONITOR->transform)
|
||||
g_pConfigManager->parseKeyword("monitor", transformStr);
|
||||
|
@ -754,7 +756,7 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool
|
|||
}
|
||||
|
||||
if (!test)
|
||||
g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords
|
||||
g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords
|
||||
|
||||
if (noError)
|
||||
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 {
|
||||
uint32_t singular_anchor;
|
||||
uint32_t anchor_triplet;
|
||||
int* positive_axis;
|
||||
int* negative_axis;
|
||||
int margin;
|
||||
int* positive_axis;
|
||||
int* negative_axis;
|
||||
int margin;
|
||||
} edges[] = {
|
||||
// Top
|
||||
{
|
||||
.singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP,
|
||||
.anchor_triplet =
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP,
|
||||
.positive_axis = &usable_area->y,
|
||||
.negative_axis = &usable_area->height,
|
||||
.margin = margin_top,
|
||||
.anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP,
|
||||
.positive_axis = &usable_area->y,
|
||||
.negative_axis = &usable_area->height,
|
||||
.margin = margin_top,
|
||||
},
|
||||
// Bottom
|
||||
{
|
||||
.singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
||||
.anchor_triplet =
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
||||
.positive_axis = NULL,
|
||||
.negative_axis = &usable_area->height,
|
||||
.margin = margin_bottom,
|
||||
.anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
||||
.positive_axis = NULL,
|
||||
.negative_axis = &usable_area->height,
|
||||
.margin = margin_bottom,
|
||||
},
|
||||
// Left
|
||||
{
|
||||
.singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT,
|
||||
.anchor_triplet =
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT |
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
||||
.positive_axis = &usable_area->x,
|
||||
.negative_axis = &usable_area->width,
|
||||
.margin = margin_left,
|
||||
.anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
||||
.positive_axis = &usable_area->x,
|
||||
.negative_axis = &usable_area->width,
|
||||
.margin = margin_left,
|
||||
},
|
||||
// Right
|
||||
{
|
||||
.singular_anchor = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT,
|
||||
.anchor_triplet =
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP |
|
||||
ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
||||
.positive_axis = NULL,
|
||||
.negative_axis = &usable_area->width,
|
||||
.margin = margin_right,
|
||||
.anchor_triplet = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,
|
||||
.positive_axis = NULL,
|
||||
.negative_axis = &usable_area->width,
|
||||
.margin = margin_right,
|
||||
},
|
||||
};
|
||||
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;
|
||||
}
|
||||
|
||||
wlr_box box = {
|
||||
.width = PSTATE->desired_width,
|
||||
.height = PSTATE->desired_height};
|
||||
wlr_box box = {.width = PSTATE->desired_width, .height = PSTATE->desired_height};
|
||||
// Horizontal axis
|
||||
const uint32_t both_horiz = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT;
|
||||
if (box.width == 0) {
|
||||
|
@ -888,8 +876,7 @@ void CHyprRenderer::arrangeLayerArray(CMonitor* pMonitor, const std::vector<std:
|
|||
// Margin
|
||||
if (box.width == 0) {
|
||||
box.x += PSTATE->margin.left;
|
||||
box.width = bounds.width -
|
||||
(PSTATE->margin.left + PSTATE->margin.right);
|
||||
box.width = bounds.width - (PSTATE->margin.left + PSTATE->margin.right);
|
||||
} else if ((PSTATE->anchor & both_horiz) == both_horiz) {
|
||||
// don't apply margins
|
||||
} 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) {
|
||||
box.y += PSTATE->margin.top;
|
||||
box.height = bounds.height -
|
||||
(PSTATE->margin.top + PSTATE->margin.bottom);
|
||||
box.height = bounds.height - (PSTATE->margin.top + PSTATE->margin.bottom);
|
||||
} else if ((PSTATE->anchor & both_vert) == both_vert) {
|
||||
// don't apply margins
|
||||
} 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);
|
||||
|
||||
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;
|
||||
|
||||
// Reset the reserved
|
||||
PMONITOR->vecReservedBottomRight = Vector2D();
|
||||
PMONITOR->vecReservedTopLeft = Vector2D();
|
||||
PMONITOR->vecReservedBottomRight = Vector2D();
|
||||
PMONITOR->vecReservedTopLeft = Vector2D();
|
||||
|
||||
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)
|
||||
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;
|
||||
|
||||
auto ADDITIONALRESERVED = g_pConfigManager->m_mAdditionalReservedAreas.find(PMONITOR->szName);
|
||||
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()) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -960,7 +947,8 @@ void CHyprRenderer::arrangeLayersForMonitor(const int& 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) {
|
||||
|
@ -1001,10 +989,11 @@ void CHyprRenderer::damageSurface(wlr_surface* pSurface, double x, double y) {
|
|||
|
||||
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)
|
||||
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);
|
||||
}
|
||||
|
@ -1020,7 +1009,7 @@ void CHyprRenderer::damageWindow(CWindow* pWindow) {
|
|||
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)
|
||||
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())
|
||||
return;
|
||||
|
||||
wlr_box damageBox = { 0, 0, INT16_MAX, INT16_MAX };
|
||||
wlr_box damageBox = {0, 0, INT16_MAX, INT16_MAX};
|
||||
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)
|
||||
Debug::log(LOG, "Damage: Monitor %s", pMonitor->szName.c_str());
|
||||
|
@ -1052,7 +1041,7 @@ void CHyprRenderer::damageBox(wlr_box* pBox) {
|
|||
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)
|
||||
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) {
|
||||
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_init(&rg);
|
||||
|
@ -1088,13 +1077,14 @@ void CHyprRenderer::renderDragIcon(CMonitor* pMonitor, timespec* time) {
|
|||
return;
|
||||
|
||||
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.w = g_pInputManager->m_sDrag.dragIcon->surface->current.width;
|
||||
renderdata.h = g_pInputManager->m_sDrag.dragIcon->surface->current.height;
|
||||
renderdata.surface = g_pInputManager->m_sDrag.dragIcon->surface;
|
||||
renderdata.w = g_pInputManager->m_sDrag.dragIcon->surface->current.width;
|
||||
renderdata.h = g_pInputManager->m_sDrag.dragIcon->surface->current.height;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -1128,14 +1118,11 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||
}
|
||||
|
||||
// Check if the rule isn't already applied
|
||||
if (!force
|
||||
&& DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1)
|
||||
&& DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1)
|
||||
&& DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1)
|
||||
&& pMonitor->scale == pMonitorRule->scale
|
||||
&& ((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) {
|
||||
if (!force && DELTALESSTHAN(pMonitor->vecPixelSize.x, pMonitorRule->resolution.x, 1) && DELTALESSTHAN(pMonitor->vecPixelSize.y, pMonitorRule->resolution.y, 1) &&
|
||||
DELTALESSTHAN(pMonitor->refreshRate, pMonitorRule->refreshRate, 1) && pMonitor->scale == pMonitorRule->scale &&
|
||||
((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());
|
||||
return true;
|
||||
|
@ -1154,31 +1141,30 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||
pMonitor->transform = pMonitorRule->transform;
|
||||
|
||||
// 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)) {
|
||||
wlr_output_mode* mode;
|
||||
bool found = false;
|
||||
bool found = false;
|
||||
|
||||
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 (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);
|
||||
|
||||
if (!wlr_output_test(pMonitor->output)) {
|
||||
Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!",
|
||||
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
|
||||
mode->width, mode->height, mode->refresh / 1000.f);
|
||||
Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!", pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y,
|
||||
(float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh / 1000.f);
|
||||
continue;
|
||||
}
|
||||
|
||||
Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.",
|
||||
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
|
||||
mode->width, mode->height, mode->refresh);
|
||||
Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.", pMonitor->output->name, (int)pMonitorRule->resolution.x,
|
||||
(int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh);
|
||||
|
||||
found = true;
|
||||
|
||||
pMonitor->refreshRate = mode->refresh / 1000.f;
|
||||
pMonitor->vecSize = Vector2D(mode->width, mode->height);
|
||||
pMonitor->vecSize = Vector2D(mode->width, mode->height);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -1186,7 +1172,7 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||
|
||||
if (!found) {
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Preferred is valid
|
||||
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->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
||||
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
||||
} 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 {
|
||||
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;
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Preferred is valid
|
||||
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->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
||||
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
||||
} 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()) {
|
||||
if (!wl_list_empty(&pMonitor->output->modes)) {
|
||||
wlr_output_mode* mode;
|
||||
float currentWidth = 0;
|
||||
float currentHeight = 0;
|
||||
float currentRefresh = 0;
|
||||
bool success = false;
|
||||
float currentWidth = 0;
|
||||
float currentHeight = 0;
|
||||
float currentRefresh = 0;
|
||||
bool success = false;
|
||||
|
||||
//(-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) {
|
||||
if( ( mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= ( currentRefresh - 1000.f ) ) || mode->refresh > ( currentRefresh + 3000.f ) ) {
|
||||
wlr_output_set_mode(pMonitor->output, mode);
|
||||
if (wlr_output_test(pMonitor->output)) {
|
||||
currentWidth = mode->width;
|
||||
currentHeight = mode->height;
|
||||
currentRefresh = mode->refresh;
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
if ((mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= (currentRefresh - 1000.f)) || mode->refresh > (currentRefresh + 3000.f)) {
|
||||
wlr_output_set_mode(pMonitor->output, mode);
|
||||
if (wlr_output_test(pMonitor->output)) {
|
||||
currentWidth = mode->width;
|
||||
currentHeight = mode->height;
|
||||
currentRefresh = mode->refresh;
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
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 ) ) {
|
||||
wlr_output_set_mode(pMonitor->output, mode);
|
||||
if (wlr_output_test(pMonitor->output)) {
|
||||
currentWidth = mode->width;
|
||||
currentHeight = mode->height;
|
||||
currentRefresh = mode->refresh;
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
if ((mode->width >= currentWidth && mode->height >= currentHeight && mode->refresh >= (currentRefresh - 1000.f)) ||
|
||||
(mode->width > currentWidth && mode->height > currentHeight)) {
|
||||
wlr_output_set_mode(pMonitor->output, mode);
|
||||
if (wlr_output_test(pMonitor->output)) {
|
||||
currentWidth = mode->width;
|
||||
currentHeight = mode->height;
|
||||
currentRefresh = mode->refresh;
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
Debug::log(LOG, "Monitor %s: REJECTED mode: %ix%i@%2f! Falling back to preferred.",
|
||||
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
|
||||
mode->width, mode->height, mode->refresh / 1000.f);
|
||||
Debug::log(LOG, "Monitor %s: REJECTED mode: %ix%i@%2f! Falling back to preferred.", pMonitor->output->name, (int)pMonitorRule->resolution.x,
|
||||
(int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh / 1000.f);
|
||||
|
||||
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Preferred is valid
|
||||
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->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
||||
pMonitor->vecSize = Vector2D(PREFERREDMODE->width, PREFERREDMODE->height);
|
||||
} else {
|
||||
|
||||
Debug::log(LOG, "Monitor %s: Applying highest mode %ix%i@%2f.",
|
||||
pMonitor->output->name, (int)currentWidth, (int)currentHeight, (int)currentRefresh / 1000.f,
|
||||
Debug::log(LOG, "Monitor %s: Applying highest mode %ix%i@%2f.", pMonitor->output->name, (int)currentWidth, (int)currentHeight, (int)currentRefresh / 1000.f,
|
||||
mode->width, mode->height, mode->refresh / 1000.f);
|
||||
|
||||
pMonitor->refreshRate = currentRefresh / 1000.f;
|
||||
pMonitor->vecSize = Vector2D(currentWidth, currentHeight);
|
||||
pMonitor->vecSize = Vector2D(currentWidth, currentHeight);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const auto PREFERREDMODE = wlr_output_preferred_mode(pMonitor->output);
|
||||
|
||||
if (!PREFERREDMODE) {
|
||||
Debug::log(ERR, "Monitor %s has NO PREFERRED MODE",
|
||||
(int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
|
||||
Debug::log(ERR, "Monitor %s has NO PREFERRED MODE", (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate);
|
||||
|
||||
if (!wl_list_empty(&pMonitor->output->modes)) {
|
||||
wlr_output_mode* mode;
|
||||
|
@ -1320,18 +1309,16 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||
wlr_output_set_mode(pMonitor->output, mode);
|
||||
|
||||
if (!wlr_output_test(pMonitor->output)) {
|
||||
Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!",
|
||||
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
|
||||
mode->width, mode->height, mode->refresh / 1000.f);
|
||||
Debug::log(LOG, "Monitor %s: REJECTED available mode: %ix%i@%2f!", pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y,
|
||||
(float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh / 1000.f);
|
||||
continue;
|
||||
}
|
||||
|
||||
Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.",
|
||||
pMonitor->output->name, (int)pMonitorRule->resolution.x, (int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate,
|
||||
mode->width, mode->height, mode->refresh);
|
||||
Debug::log(LOG, "Monitor %s: requested %ix%i@%2f, found available mode: %ix%i@%imHz, applying.", pMonitor->output->name, (int)pMonitorRule->resolution.x,
|
||||
(int)pMonitorRule->resolution.y, (float)pMonitorRule->refreshRate, mode->width, mode->height, mode->refresh);
|
||||
|
||||
pMonitor->refreshRate = mode->refresh / 1000.f;
|
||||
pMonitor->vecSize = Vector2D(mode->width, mode->height);
|
||||
pMonitor->vecSize = Vector2D(mode->width, mode->height);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -1340,14 +1327,14 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||
// Preferred is valid
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
|
@ -1382,12 +1369,13 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||
|
||||
int x, y;
|
||||
wlr_output_transformed_resolution(pMonitor->output, &x, &y);
|
||||
pMonitor->vecSize = (Vector2D(x, y) / pMonitor->scale).floor();
|
||||
pMonitor->vecTransformedSize = Vector2D(x,y);
|
||||
pMonitor->vecSize = (Vector2D(x, y) / pMonitor->scale).floor();
|
||||
pMonitor->vecTransformedSize = Vector2D(x, y);
|
||||
|
||||
if (pMonitor->createdByUser) {
|
||||
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 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);
|
||||
|
||||
pMonitor->vecPixelSize = Vector2D(transformedBox.width, transformedBox.height);
|
||||
}
|
||||
|
@ -1431,9 +1419,9 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
|||
}
|
||||
|
||||
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 < PASSEDCURSORSECONDS && m_bHasARenderedCursor) {
|
||||
|
@ -1444,7 +1432,7 @@ void CHyprRenderer::ensureCursorRenderingMode() {
|
|||
Debug::log(LOG, "Hiding the cursor (timeout)");
|
||||
|
||||
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) {
|
||||
m_bHasARenderedCursor = true;
|
||||
|
||||
|
@ -1454,7 +1442,7 @@ void CHyprRenderer::ensureCursorRenderingMode() {
|
|||
Debug::log(LOG, "Showing the cursor (timeout)");
|
||||
|
||||
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 {
|
||||
m_bHasARenderedCursor = true;
|
||||
|
|
|
@ -10,14 +10,16 @@
|
|||
struct SMonitorRule;
|
||||
|
||||
// TODO: add fuller damage tracking for updating only parts of a window
|
||||
enum DAMAGETRACKINGMODES {
|
||||
enum DAMAGETRACKINGMODES
|
||||
{
|
||||
DAMAGE_TRACKING_INVALID = -1,
|
||||
DAMAGE_TRACKING_NONE = 0,
|
||||
DAMAGE_TRACKING_NONE = 0,
|
||||
DAMAGE_TRACKING_MONITOR,
|
||||
DAMAGE_TRACKING_FULL
|
||||
};
|
||||
|
||||
enum eRenderPassMode {
|
||||
enum eRenderPassMode
|
||||
{
|
||||
RENDER_PASS_ALL = 0,
|
||||
RENDER_PASS_MAIN,
|
||||
RENDER_PASS_POPUP
|
||||
|
@ -26,8 +28,7 @@ enum eRenderPassMode {
|
|||
class CToplevelExportProtocolManager;
|
||||
|
||||
class CHyprRenderer {
|
||||
public:
|
||||
|
||||
public:
|
||||
void renderAllClientsForMonitor(const int&, timespec*);
|
||||
void outputMgrApplyTest(wlr_output_configuration_v1*, bool);
|
||||
void arrangeLayersForMonitor(const int&);
|
||||
|
@ -46,24 +47,23 @@ public:
|
|||
void calculateUVForWindowSurface(CWindow*, wlr_surface*, bool main = false);
|
||||
|
||||
bool m_bWindowRequestedCursorHide = false;
|
||||
bool m_bBlockSurfaceFeedback = false;
|
||||
CWindow* m_pLastScanout = nullptr;
|
||||
bool m_bBlockSurfaceFeedback = false;
|
||||
CWindow* m_pLastScanout = nullptr;
|
||||
|
||||
DAMAGETRACKINGMODES damageTrackingModeFromStr(const std::string&);
|
||||
|
||||
bool attemptDirectScanout(CMonitor*);
|
||||
void setWindowScanoutMode(CWindow*);
|
||||
|
||||
private:
|
||||
void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*);
|
||||
void renderWorkspaceWithFullscreenWindow(CMonitor*, CWorkspace*, timespec*);
|
||||
void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false);
|
||||
void renderLayer(SLayerSurface*, CMonitor*, timespec*);
|
||||
void renderDragIcon(CMonitor*, timespec*);
|
||||
void renderIMEPopup(SIMEPopup*, CMonitor*, timespec*);
|
||||
|
||||
bool m_bHasARenderedCursor = true;
|
||||
private:
|
||||
void arrangeLayerArray(CMonitor*, const std::vector<std::unique_ptr<SLayerSurface>>&, bool, wlr_box*);
|
||||
void renderWorkspaceWithFullscreenWindow(CMonitor*, CWorkspace*, timespec*);
|
||||
void renderWindow(CWindow*, CMonitor*, timespec*, bool, eRenderPassMode, bool ignorePosition = false, bool ignoreAllGeometry = false);
|
||||
void renderLayer(SLayerSurface*, CMonitor*, timespec*);
|
||||
void renderDragIcon(CMonitor*, timespec*);
|
||||
void renderIMEPopup(SIMEPopup*, CMonitor*, timespec*);
|
||||
|
||||
bool m_bHasARenderedCursor = true;
|
||||
|
||||
friend class CHyprOpenGLImpl;
|
||||
friend class CToplevelExportProtocolManager;
|
||||
|
|
|
@ -4,43 +4,43 @@
|
|||
#include <unordered_map>
|
||||
|
||||
class CShader {
|
||||
public:
|
||||
public:
|
||||
~CShader();
|
||||
|
||||
GLuint program = 0;
|
||||
GLint proj;
|
||||
GLint color;
|
||||
GLint tex;
|
||||
GLint alpha;
|
||||
GLint posAttrib;
|
||||
GLint texAttrib;
|
||||
GLint discardOpaque;
|
||||
GLint proj;
|
||||
GLint color;
|
||||
GLint tex;
|
||||
GLint alpha;
|
||||
GLint posAttrib;
|
||||
GLint texAttrib;
|
||||
GLint discardOpaque;
|
||||
|
||||
GLint topLeft;
|
||||
GLint bottomRight;
|
||||
GLint fullSize;
|
||||
GLint fullSizeUntransformed;
|
||||
GLint radius;
|
||||
GLint primitiveMultisample;
|
||||
GLint topLeft;
|
||||
GLint bottomRight;
|
||||
GLint fullSize;
|
||||
GLint fullSizeUntransformed;
|
||||
GLint radius;
|
||||
GLint primitiveMultisample;
|
||||
|
||||
GLint thick;
|
||||
GLint thick;
|
||||
|
||||
GLint halfpixel;
|
||||
GLint halfpixel;
|
||||
|
||||
GLint range;
|
||||
GLint shadowPower;
|
||||
GLint range;
|
||||
GLint shadowPower;
|
||||
|
||||
GLint applyTint;
|
||||
GLint tint;
|
||||
GLint applyTint;
|
||||
GLint tint;
|
||||
|
||||
GLint gradient;
|
||||
GLint gradientLength;
|
||||
GLint angle;
|
||||
GLint gradient;
|
||||
GLint gradientLength;
|
||||
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;
|
||||
};
|
|
@ -10,7 +10,7 @@ CTexture::CTexture(wlr_texture* tex) {
|
|||
wlr_gles2_texture_get_attribs(tex, &attrs);
|
||||
|
||||
m_iTarget = attrs.target;
|
||||
m_iTexID = attrs.tex;
|
||||
m_iTexID = attrs.tex;
|
||||
|
||||
if (m_iTarget == GL_TEXTURE_2D) {
|
||||
m_iType = attrs.has_alpha ? TEXTURE_RGBA : TEXTURE_RGBX;
|
||||
|
|
|
@ -2,23 +2,24 @@
|
|||
|
||||
#include "../defines.hpp"
|
||||
|
||||
enum TEXTURETYPE {
|
||||
TEXTURE_INVALID, // Invalid
|
||||
TEXTURE_RGBA, // 4 channels
|
||||
TEXTURE_RGBX, // discard A
|
||||
TEXTURE_EXTERNAL, // EGLImage
|
||||
enum TEXTURETYPE
|
||||
{
|
||||
TEXTURE_INVALID, // Invalid
|
||||
TEXTURE_RGBA, // 4 channels
|
||||
TEXTURE_RGBX, // discard A
|
||||
TEXTURE_EXTERNAL, // EGLImage
|
||||
};
|
||||
|
||||
class CTexture {
|
||||
public:
|
||||
public:
|
||||
CTexture();
|
||||
CTexture(wlr_texture*);
|
||||
|
||||
void destroyTexture();
|
||||
void allocate();
|
||||
void destroyTexture();
|
||||
void allocate();
|
||||
|
||||
TEXTURETYPE m_iType = TEXTURE_RGBA;
|
||||
GLenum m_iTarget = GL_TEXTURE_2D;
|
||||
GLuint m_iTexID = 0;
|
||||
Vector2D m_vSize;
|
||||
TEXTURETYPE m_iType = TEXTURE_RGBA;
|
||||
GLenum m_iTarget = GL_TEXTURE_2D;
|
||||
GLuint m_iTexID = 0;
|
||||
Vector2D m_vSize;
|
||||
};
|
|
@ -11,7 +11,7 @@ CHyprDropShadowDecoration::~CHyprDropShadowDecoration() {
|
|||
}
|
||||
|
||||
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)
|
||||
return {{}, {}};
|
||||
|
@ -24,12 +24,13 @@ eDecorationType CHyprDropShadowDecoration::getDecorationType() {
|
|||
}
|
||||
|
||||
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)
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -41,7 +42,7 @@ void CHyprDropShadowDecoration::updateWindow(CWindow* pWindow) {
|
|||
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) {
|
||||
m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET;
|
||||
m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET;
|
||||
m_vLastWindowSize = pWindow->m_vRealSize.vec();
|
||||
|
||||
damageEntire();
|
||||
|
@ -62,21 +63,21 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
|
|||
if (m_pWindow->m_sAdditionalConfigData.forceNoShadow)
|
||||
return;
|
||||
|
||||
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 PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->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 PSHADOWOFFSET = &g_pConfigManager->getConfigValuePtr("decoration:shadow_offset")->vecValue;
|
||||
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 PROUNDING = &g_pConfigManager->getConfigValuePtr("decoration:rounding")->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 PSHADOWOFFSET = &g_pConfigManager->getConfigValuePtr("decoration:shadow_offset")->vecValue;
|
||||
|
||||
if (*PSHADOWS != 1)
|
||||
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
|
||||
wlr_box fullBox = { m_vLastWindowPos.x - *PSHADOWSIZE, m_vLastWindowPos.y - *PSHADOWSIZE,
|
||||
m_vLastWindowSize.x + 2.0 * *PSHADOWSIZE, m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE };
|
||||
wlr_box fullBox = {m_vLastWindowPos.x - *PSHADOWSIZE, m_vLastWindowPos.y - *PSHADOWSIZE, m_vLastWindowSize.x + 2.0 * *PSHADOWSIZE, m_vLastWindowSize.y + 2.0 * *PSHADOWSIZE};
|
||||
|
||||
fullBox.x -= pMonitor->vecPosition.x;
|
||||
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);
|
||||
|
||||
// scale the box in relation to the center of the box
|
||||
const Vector2D NEWSIZE = Vector2D { fullBox.width, fullBox.height } * SHADOWSCALE;
|
||||
fullBox.width = NEWSIZE.x;
|
||||
fullBox.height = NEWSIZE.y;
|
||||
const Vector2D NEWSIZE = Vector2D{fullBox.width, fullBox.height} * SHADOWSCALE;
|
||||
fullBox.width = NEWSIZE.x;
|
||||
fullBox.height = NEWSIZE.y;
|
||||
|
||||
if (PSHADOWOFFSET->x < 0) {
|
||||
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;
|
||||
}
|
||||
|
||||
m_seExtents = { { m_vLastWindowPos.x - fullBox.x - pMonitor->vecPosition.x + 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.y + fullBox.height + pMonitor->vecPosition.y - m_vLastWindowPos.y - m_vLastWindowSize.y + 2} };
|
||||
m_seExtents = {{m_vLastWindowPos.x - fullBox.x - pMonitor->vecPosition.x + 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.y + fullBox.height + pMonitor->vecPosition.y - m_vLastWindowPos.y - m_vLastWindowSize.y + 2}};
|
||||
|
||||
fullBox.x += offset.x;
|
||||
fullBox.y += offset.y;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -134,7 +134,7 @@ void CHyprDropShadowDecoration::draw(CMonitor* pMonitor, float a, const Vector2D
|
|||
glClearStencil(0);
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
return; // prevent assert failed
|
||||
return; // prevent assert failed
|
||||
}
|
||||
|
||||
g_pHyprOpenGL->renderRect(&windowBox, CColor(0, 0, 0, 0), ROUNDING * pMonitor->scale);
|
||||
|
|
|
@ -3,25 +3,25 @@
|
|||
#include "IHyprWindowDecoration.hpp"
|
||||
|
||||
class CHyprDropShadowDecoration : public IHyprWindowDecoration {
|
||||
public:
|
||||
public:
|
||||
CHyprDropShadowDecoration(CWindow*);
|
||||
virtual ~CHyprDropShadowDecoration();
|
||||
|
||||
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:
|
||||
SWindowDecorationExtents m_seExtents;
|
||||
private:
|
||||
SWindowDecorationExtents m_seExtents;
|
||||
|
||||
CWindow* m_pWindow = nullptr;
|
||||
CWindow* m_pWindow = nullptr;
|
||||
|
||||
Vector2D m_vLastWindowPos;
|
||||
Vector2D m_vLastWindowSize;
|
||||
Vector2D m_vLastWindowPos;
|
||||
Vector2D m_vLastWindowSize;
|
||||
};
|
|
@ -5,9 +5,7 @@ CHyprGroupBarDecoration::CHyprGroupBarDecoration(CWindow* pWindow) {
|
|||
m_pWindow = pWindow;
|
||||
}
|
||||
|
||||
CHyprGroupBarDecoration::~CHyprGroupBarDecoration() {
|
||||
|
||||
}
|
||||
CHyprGroupBarDecoration::~CHyprGroupBarDecoration() {}
|
||||
|
||||
SWindowDecorationExtents CHyprGroupBarDecoration::getWindowDecorationExtents() {
|
||||
return m_seExtents;
|
||||
|
@ -28,10 +26,10 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) {
|
|||
// we draw 3px above the window's border with 3px
|
||||
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_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET;
|
||||
m_vLastWindowPos = pWindow->m_vRealPosition.vec() + WORKSPACEOFFSET;
|
||||
m_vLastWindowSize = pWindow->m_vRealSize.vec();
|
||||
}
|
||||
|
||||
|
@ -59,7 +57,8 @@ void CHyprGroupBarDecoration::updateWindow(CWindow* pWindow) {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -77,7 +76,7 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
|
|||
|
||||
const int BARW = (m_vLastWindowSize.x - PAD * (barsToDraw - 1)) / barsToDraw;
|
||||
|
||||
int xoff = 0;
|
||||
int xoff = 0;
|
||||
|
||||
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};
|
||||
|
@ -87,10 +86,10 @@ void CHyprGroupBarDecoration::draw(CMonitor* pMonitor, float a, const Vector2D&
|
|||
|
||||
scaleBox(&rect, pMonitor->scale);
|
||||
|
||||
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 PGROUPCOLACTIVE = &g_pConfigManager->getConfigValuePtr("dwindle:col.group_border_active")->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;
|
||||
g_pHyprOpenGL->renderRect(&rect, color);
|
||||
|
||||
|
|
|
@ -4,27 +4,27 @@
|
|||
#include <deque>
|
||||
|
||||
class CHyprGroupBarDecoration : public IHyprWindowDecoration {
|
||||
public:
|
||||
public:
|
||||
CHyprGroupBarDecoration(CWindow*);
|
||||
virtual ~CHyprGroupBarDecoration();
|
||||
|
||||
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:
|
||||
SWindowDecorationExtents m_seExtents;
|
||||
private:
|
||||
SWindowDecorationExtents m_seExtents;
|
||||
|
||||
CWindow* m_pWindow = nullptr;
|
||||
CWindow* m_pWindow = nullptr;
|
||||
|
||||
Vector2D m_vLastWindowPos;
|
||||
Vector2D m_vLastWindowSize;
|
||||
Vector2D m_vLastWindowPos;
|
||||
Vector2D m_vLastWindowSize;
|
||||
|
||||
std::deque<CWindow*> m_dwGroupMembers;
|
||||
std::deque<CWindow*> m_dwGroupMembers;
|
||||
};
|
|
@ -2,6 +2,4 @@
|
|||
|
||||
#include "../../Window.hpp"
|
||||
|
||||
IHyprWindowDecoration::~IHyprWindowDecoration() {
|
||||
|
||||
}
|
||||
IHyprWindowDecoration::~IHyprWindowDecoration() {}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
#include "../../defines.hpp"
|
||||
|
||||
enum eDecorationType {
|
||||
enum eDecorationType
|
||||
{
|
||||
DECORATION_NONE = -1,
|
||||
DECORATION_GROUPBAR,
|
||||
DECORATION_SHADOW
|
||||
|
@ -17,16 +18,16 @@ class CWindow;
|
|||
class CMonitor;
|
||||
|
||||
interface IHyprWindowDecoration {
|
||||
public:
|
||||
public:
|
||||
virtual ~IHyprWindowDecoration() = 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