summaryrefslogtreecommitdiff
path: root/src/managers
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2022-12-16 17:17:31 +0000
committerGitHub <noreply@github.com>2022-12-16 17:17:31 +0000
commit98a4fa2b0d79298fa29b048a3ba15c3bf5aed8cd (patch)
tree64e78342cf08e5f9ad87bd5f6ea36233133be7bb /src/managers
parent7c33c7fc64203c17b4f3625a16ae6b4774992c0e (diff)
Added clang format (#1239)
* clang-format stuff and format files
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/AnimationManager.cpp126
-rw-r--r--src/managers/AnimationManager.hpp33
-rw-r--r--src/managers/EventManager.cpp29
-rw-r--r--src/managers/EventManager.hpp17
-rw-r--r--src/managers/KeybindManager.cpp290
-rw-r--r--src/managers/KeybindManager.hpp163
-rw-r--r--src/managers/LayoutManager.cpp6
-rw-r--r--src/managers/LayoutManager.hpp14
-rw-r--r--src/managers/ProtocolManager.hpp2
-rw-r--r--src/managers/ThreadManager.cpp4
-rw-r--r--src/managers/ThreadManager.hpp4
-rw-r--r--src/managers/XWaylandManager.cpp91
-rw-r--r--src/managers/XWaylandManager.hpp34
-rw-r--r--src/managers/input/IdleInhibitor.cpp17
-rw-r--r--src/managers/input/InputManager.cpp429
-rw-r--r--src/managers/input/InputManager.hpp194
-rw-r--r--src/managers/input/InputMethodRelay.cpp291
-rw-r--r--src/managers/input/InputMethodRelay.hpp37
-rw-r--r--src/managers/input/Swipe.cpp81
-rw-r--r--src/managers/input/Tablets.cpp307
-rw-r--r--src/managers/input/Touch.cpp19
21 files changed, 1118 insertions, 1070 deletions
diff --git a/src/managers/AnimationManager.cpp b/src/managers/AnimationManager.cpp
index b15e96a9..c257622a 100644
--- a/src/managers/AnimationManager.cpp
+++ b/src/managers/AnimationManager.cpp
@@ -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 "";
}
diff --git a/src/managers/AnimationManager.hpp b/src/managers/AnimationManager.hpp
index b3148d25..3a2905b0 100644
--- a/src/managers/AnimationManager.hpp
+++ b/src/managers/AnimationManager.hpp
@@ -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; \ No newline at end of file
diff --git a/src/managers/EventManager.cpp b/src/managers/EventManager.cpp
index e1b3d26b..81acd379 100644
--- a/src/managers/EventManager.cpp
+++ b/src/managers/EventManager.cpp
@@ -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();
}
diff --git a/src/managers/EventManager.hpp b/src/managers/EventManager.hpp
index 348e3361..dbb1e8a1 100644
--- a/src/managers/EventManager.hpp
+++ b/src/managers/EventManager.hpp
@@ -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;
};
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 388a1df4..a2de8162 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -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;
}
}
}
diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp
index 3d3dbce0..bc9c2437 100644
--- a/src/managers/KeybindManager.hpp
+++ b/src/managers/KeybindManager.hpp
@@ -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;
diff --git a/src/managers/LayoutManager.cpp b/src/managers/LayoutManager.cpp
index 155b0bfc..8e352184 100644
--- a/src/managers/LayoutManager.cpp
+++ b/src/managers/LayoutManager.cpp
@@ -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
diff --git a/src/managers/LayoutManager.hpp b/src/managers/LayoutManager.hpp
index aa340e79..103aa7b9 100644
--- a/src/managers/LayoutManager.hpp
+++ b/src/managers/LayoutManager.hpp
@@ -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;
diff --git a/src/managers/ProtocolManager.hpp b/src/managers/ProtocolManager.hpp
index 810bb547..4e583a02 100644
--- a/src/managers/ProtocolManager.hpp
+++ b/src/managers/ProtocolManager.hpp
@@ -4,7 +4,7 @@
#include "../protocols/ToplevelExport.hpp"
class CProtocolManager {
-public:
+ public:
CProtocolManager();
std::unique_ptr<CToplevelExportProtocolManager> m_pToplevelExportProtocolManager;
diff --git a/src/managers/ThreadManager.cpp b/src/managers/ThreadManager.cpp
index efe0ac10..a268258f 100644
--- a/src/managers/ThreadManager.cpp
+++ b/src/managers/ThreadManager.cpp
@@ -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();
diff --git a/src/managers/ThreadManager.hpp b/src/managers/ThreadManager.hpp
index 0a716e0b..5c77d6a0 100644
--- a/src/managers/ThreadManager.hpp
+++ b/src/managers/ThreadManager.hpp
@@ -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; \ No newline at end of file
diff --git a/src/managers/XWaylandManager.cpp b/src/managers/XWaylandManager.cpp
index e41d2e82..ed56ebf1 100644
--- a/src/managers/XWaylandManager.cpp
+++ b/src/managers/XWaylandManager.cpp
@@ -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;
-
- pWindow->m_bNoInitialFocus = true;
- return 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;
+ }
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;
diff --git a/src/managers/XWaylandManager.hpp b/src/managers/XWaylandManager.hpp
index 6ac1ffde..cb3daaf5 100644
--- a/src/managers/XWaylandManager.hpp
+++ b/src/managers/XWaylandManager.hpp
@@ -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; \ No newline at end of file
diff --git a/src/managers/input/IdleInhibitor.cpp b/src/managers/input/IdleInhibitor.cpp
index 8c0a3267..3e3411fb 100644
--- a/src/managers/input/IdleInhibitor.cpp
+++ b/src/managers/input/IdleInhibitor.cpp
@@ -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);
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 41233f92..d3cd9079 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -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;
-
- m_pFoundSurfaceToFocus = nullptr;
- m_pFoundLSToFocus = nullptr;
- m_pFoundWindowToFocus = nullptr;
- wlr_surface* foundSurface = nullptr;
- Vector2D surfaceCoords;
- Vector2D surfacePos = Vector2D(-1337, -1337);
- CWindow* pFoundWindow = nullptr;
+ 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;
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;
-
- g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," +getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
+ PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(
+ &wlr_keyboard_from_input_device(keyboard)->events.keymap,
+ [&](void* owner, void* data) {
+ const auto PKEYBOARD = (SKeyboard*)owner;
- }, 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;
-
- g_pEventManager->postEvent(SHyprIPCEvent{"activelayout", PKEYBOARD->name + "," +getActiveLayoutForKeyboard(PKEYBOARD)}, true); // force as this should ALWAYS be sent
+ PNEWKEYBOARD->hyprListener_keyboardKeymap.initCallback(
+ &wlr_keyboard_from_input_device(keyboard)->events.keymap,
+ [&](void* owner, void* data) {
+ const auto PKEYBOARD = (SKeyboard*)owner;
- }, 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);
- }
- }
-
+ 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)));
diff --git a/src/managers/input/InputManager.hpp b/src/managers/input/InputManager.hpp
index 5645f163..460b5ac2 100644
--- a/src/managers/input/InputManager.hpp
+++ b/src/managers/input/InputManager.hpp
@@ -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:
-
- 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 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();
-
- void setKeyboardLayout();
- void setPointerConfigs();
- void setTouchDeviceConfigs();
-
- void updateDragIcon();
- void updateCapabilities();
-
- void setClickMode(eClickBehaviorMode);
+ 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 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*);
+
+ Vector2D getMouseCoordsInternal();
+ void refocus();
+
+ void setKeyboardLayout();
+ void setPointerConfigs();
+ void setTouchDeviceConfigs();
+
+ void updateDragIcon();
+ void updateCapabilities();
+
+ 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;
};
diff --git a/src/managers/input/InputMethodRelay.cpp b/src/managers/input/InputMethodRelay.cpp
index d49623db..93c7040b 100644
--- a/src/managers/input/InputMethodRelay.cpp
+++ b/src/managers/input/InputMethodRelay.cpp
@@ -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);
+ if (!PTI) {
+ Debug::log(LOG, "No focused TextInput on IME Commit");
+ return;
+ }
- const auto PTI = getFocusedTextInput();
+ 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);
+ }
- Debug::log(LOG, "IME Destroy");
+ if (PIMR->m_pWLRIME->current.commit_text) {
+ wlr_text_input_v3_send_commit_string(PTI->pWlrInput, PIMR->m_pWLRIME->current.commit_text);
+ }
- if (PTI) {
- setPendingSurface(PTI, PTI->pWlrInput->focused_surface);
+ 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_leave(PTI->pWlrInput);
- }
+ wlr_text_input_v3_send_done(PTI->pWlrInput);
+ },
+ this, "IMERelay");
- }, this, "IMERelay");
+ hyprListener_IMEDestroy.initCallback(
+ &m_pWLRIME->events.destroy,
+ [&](void* owner, void* data) {
+ m_pWLRIME = nullptr;
- hyprListener_IMEGrab.initCallback(&m_pWLRIME->events.grab_keyboard, [&](void* owner, void* data) {
+ hyprListener_IMEDestroy.removeCallback();
+ hyprListener_IMECommit.removeCallback();
+ hyprListener_IMEGrab.removeCallback();
+ hyprListener_IMENewPopup.removeCallback();
- Debug::log(LOG, "IME TextInput Keyboard Grab new");
+ m_pKeyboardGrab.reset(nullptr);
- m_pKeyboardGrab.reset(nullptr);
+ const auto PTI = getFocusedTextInput();
- m_pKeyboardGrab = std::make_unique<SIMEKbGrab>();
+ Debug::log(LOG, "IME Destroy");
- m_pKeyboardGrab->pKeyboard = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
+ if (PTI) {
+ setPendingSurface(PTI, PTI->pWlrInput->focused_surface);
- const auto PKBGRAB = (wlr_input_method_keyboard_grab_v2*)data;
+ wlr_text_input_v3_send_leave(PTI->pWlrInput);
+ }
+ },
+ this, "IMERelay");
- m_pKeyboardGrab->pWlrKbGrab = PKBGRAB;
+ hyprListener_IMEGrab.initCallback(
+ &m_pWLRIME->events.grab_keyboard,
+ [&](void* owner, void* data) {
+ Debug::log(LOG, "IME TextInput Keyboard Grab new");
- wlr_input_method_keyboard_grab_v2_set_keyboard(m_pKeyboardGrab->pWlrKbGrab, m_pKeyboardGrab->pKeyboard);
+ m_pKeyboardGrab.reset(nullptr);
- m_pKeyboardGrab->hyprListener_grabDestroy.initCallback(&PKBGRAB->events.destroy, [&](void* owner, void* data) {
+ m_pKeyboardGrab = std::make_unique<SIMEKbGrab>();
- m_pKeyboardGrab->hyprListener_grabDestroy.removeCallback();
+ m_pKeyboardGrab->pKeyboard = wlr_seat_get_keyboard(g_pCompositor->m_sSeat.seat);
- Debug::log(LOG, "IME TextInput Keyboard Grab destroy");
+ const auto PKBGRAB = (wlr_input_method_keyboard_grab_v2*)data;
- if (m_pKeyboardGrab->pKeyboard) {
- wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &m_pKeyboardGrab->pKeyboard->modifiers);
- }
+ m_pKeyboardGrab->pWlrKbGrab = PKBGRAB;
- m_pKeyboardGrab.reset(nullptr);
+ wlr_input_method_keyboard_grab_v2_set_keyboard(m_pKeyboardGrab->pWlrKbGrab, m_pKeyboardGrab->pKeyboard);
- }, m_pKeyboardGrab.get(), "IME Keyboard Grab");
+ m_pKeyboardGrab->hyprListener_grabDestroy.initCallback(
+ &PKBGRAB->events.destroy,
+ [&](void* owner, void* data) {
+ m_pKeyboardGrab->hyprListener_grabDestroy.removeCallback();
- }, this, "IMERelay");
+ Debug::log(LOG, "IME TextInput Keyboard Grab destroy");
- hyprListener_IMENewPopup.initCallback(&m_pWLRIME->events.new_popup_surface, [&](void* owner, void* data) {
+ if (m_pKeyboardGrab->pKeyboard) {
+ wlr_seat_keyboard_notify_modifiers(g_pCompositor->m_sSeat.seat, &m_pKeyboardGrab->pKeyboard->modifiers);
+ }
- const auto PNEWPOPUP = &m_lIMEPopups.emplace_back();
+ m_pKeyboardGrab.reset(nullptr);
+ },
+ m_pKeyboardGrab.get(), "IME Keyboard Grab");
+ },
+ this, "IMERelay");
- PNEWPOPUP->pSurface = (wlr_input_popup_surface_v2*)data;
+ hyprListener_IMENewPopup.initCallback(
+ &m_pWLRIME->events.new_popup_surface,
+ [&](void* owner, void* data) {
+ const auto PNEWPOPUP = &m_lIMEPopups.emplace_back();
- 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");
+ PNEWPOPUP->pSurface = (wlr_input_popup_surface_v2*)data;
- Debug::log(LOG, "New input popup");
+ 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");
- }, this, "IMERelay");
+ 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) {
-
- const auto PINPUT = (STextInput*)owner;
-
- if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
- // Debug::log(WARN, "Enabling TextInput on no IME!");
- return;
- }
-
- Debug::log(LOG, "Enable TextInput");
-
- wlr_input_method_v2_send_activate(g_pInputManager->m_sIMERelay.m_pWLRIME);
- g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
-
- }, PTEXTINPUT, "textInput");
-
- PTEXTINPUT->hyprListener_textInputCommit.initCallback(&pInput->events.commit, [](void* owner, void* data) {
-
- const auto PINPUT = (STextInput*)owner;
-
- if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
- // Debug::log(WARN, "Committing TextInput on no IME!");
- return;
- }
+ PTEXTINPUT->hyprListener_textInputEnable.initCallback(
+ &pInput->events.enable,
+ [](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, "Enabling TextInput on no IME!");
+ return;
+ }
- g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
+ Debug::log(LOG, "Enable TextInput");
- }, PTEXTINPUT, "textInput");
+ wlr_input_method_v2_send_activate(g_pInputManager->m_sIMERelay.m_pWLRIME);
+ g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
+ },
+ PTEXTINPUT, "textInput");
- PTEXTINPUT->hyprListener_textInputDisable.initCallback(&pInput->events.disable, [](void* owner, void* data) {
+ PTEXTINPUT->hyprListener_textInputCommit.initCallback(
+ &pInput->events.commit,
+ [](void* owner, void* data) {
+ const auto PINPUT = (STextInput*)owner;
- const auto PINPUT = (STextInput*)owner;
+ if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
+ // Debug::log(WARN, "Committing TextInput on no IME!");
+ return;
+ }
- if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
- // Debug::log(WARN, "Disabling TextInput on no IME!");
- return;
- }
+ if (!PINPUT->pWlrInput->current_enabled) {
+ Debug::log(WARN, "Disabled TextInput commit?");
+ return;
+ }
- Debug::log(LOG, "Disable TextInput");
+ g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
+ },
+ PTEXTINPUT, "textInput");
- wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
+ PTEXTINPUT->hyprListener_textInputDisable.initCallback(
+ &pInput->events.disable,
+ [](void* owner, void* data) {
+ const auto PINPUT = (STextInput*)owner;
- g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
+ if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
+ // Debug::log(WARN, "Disabling TextInput on no IME!");
+ return;
+ }
- }, PTEXTINPUT, "textInput");
+ Debug::log(LOG, "Disable TextInput");
- PTEXTINPUT->hyprListener_textInputDestroy.initCallback(&pInput->events.destroy, [](void* owner, void* data) {
+ wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
- const auto PINPUT = (STextInput*)owner;
+ g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
+ },
+ PTEXTINPUT, "textInput");
- if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
- // Debug::log(WARN, "Disabling TextInput on no IME!");
- return;
- }
+ PTEXTINPUT->hyprListener_textInputDestroy.initCallback(
+ &pInput->events.destroy,
+ [](void* owner, void* data) {
+ const auto PINPUT = (STextInput*)owner;
- if (PINPUT->pWlrInput->current_enabled) {
- wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
+ if (!g_pInputManager->m_sIMERelay.m_pWLRIME) {
+ // Debug::log(WARN, "Disabling TextInput on no IME!");
+ return;
+ }
- g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
- }
+ if (PINPUT->pWlrInput->current_enabled) {
+ wlr_input_method_v2_send_deactivate(g_pInputManager->m_sIMERelay.m_pWLRIME);
- g_pInputManager->m_sIMERelay.setPendingSurface(PINPUT, nullptr);
+ g_pInputManager->m_sIMERelay.commitIMEState(PINPUT->pWlrInput);
+ }
- PINPUT->hyprListener_textInputCommit.removeCallback();
- PINPUT->hyprListener_textInputDestroy.removeCallback();
- PINPUT->hyprListener_textInputDisable.removeCallback();
- PINPUT->hyprListener_textInputEnable.removeCallback();
+ g_pInputManager->m_sIMERelay.setPendingSurface(PINPUT, nullptr);
- g_pInputManager->m_sIMERelay.removeTextInput(PINPUT->pWlrInput);
+ PINPUT->hyprListener_textInputCommit.removeCallback();
+ PINPUT->hyprListener_textInputDestroy.removeCallback();
+ PINPUT->hyprListener_textInputDisable.removeCallback();
+ PINPUT->hyprListener_textInputEnable.removeCallback();
- }, PTEXTINPUT, "textInput");
+ 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();
}
diff --git a/src/managers/input/InputMethodRelay.hpp b/src/managers/input/InputMethodRelay.hpp
index 5f4e9752..76746487 100644
--- a/src/managers/input/InputMethodRelay.hpp
+++ b/src/managers/input/InputMethodRelay.hpp
@@ -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;
diff --git a/src/managers/input/Swipe.cpp b/src/managers/input/Swipe.cpp
index ab85a988..f2a31172 100644
--- a/src/managers/input/Swipe.cpp
+++ b/src/managers/input/Swipe.cpp
@@ -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));
}
diff --git a/src/managers/input/Tablets.cpp b/src/managers/input/Tablets.cpp
index eef466ec..00cedb09 100644
--- a/src/managers/input/Tablets.cpp
+++ b/src/managers/input/Tablets.cpp
@@ -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;
-
- g_pInputManager->m_lTablets.remove(*PTAB);
-
- 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_Destroy.initCallback(
+ &pDevice->events.destroy,
+ [](void* owner, void* data) {
+ const auto PTAB = (STablet*)owner;
+
+ g_pInputManager->m_lTablets.remove(*PTAB);
+
+ Debug::log(LOG, "Removed a tablet");
+ },
+ PNEWTABLET, "Tablet");
+
+ 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;
+
+ 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 EVENT = (wlr_tablet_tool_axis_event*)data;
- const auto PTAB = (STablet*)owner;
+ const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
- 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);
+ // TODO: this might be wrong
+ if (PTOOL->active) {
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);
+ g_pInputManager->focusTablet(PTAB, EVENT->tool, true);
+ }
- 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_PRESSURE)
+ wlr_tablet_v2_tablet_tool_notify_pressure(PTOOL->wlrTabletToolV2, EVENT->pressure);
- 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_DISTANCE)
+ wlr_tablet_v2_tablet_tool_notify_distance(PTOOL->wlrTabletToolV2, EVENT->distance);
- 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_ROTATION)
+ wlr_tablet_v2_tablet_tool_notify_rotation(PTOOL->wlrTabletToolV2, EVENT->rotation);
- if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_X)
- PTOOL->tiltX = EVENT->tilt_x;
+ 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_TILT_Y)
- PTOOL->tiltY = EVENT->tilt_y;
+ 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 | WLR_TABLET_TOOL_AXIS_TILT_Y))
- wlr_tablet_v2_tablet_tool_notify_tilt(PTOOL->wlrTabletToolV2, PTOOL->tiltX, PTOOL->tiltY);
+ if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_X)
+ PTOOL->tiltX = EVENT->tilt_x;
- }, PNEWTABLET, "Tablet");
+ if (EVENT->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_Y)
+ PTOOL->tiltY = EVENT->tilt_y;
- 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;
+ 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");
- const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
+ 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;
- // 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);
- }
+ const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
- }, PNEWTABLET, "Tablet");
+ // 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;
+ 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);
+ 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);
+ 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, "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;
- 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);
- const auto PTOOL = g_pInputManager->ensureTabletToolPresent(EVENT->tool);
+ if (EVENT->state == WLR_TABLET_TOOL_PROXIMITY_OUT) {
+ PTOOL->active = false;
- 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;
+ }
- 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);
}
-
- } else {
- PTOOL->active = true;
- g_pInputManager->refocus();
- g_pInputManager->focusTablet(PTAB, EVENT->tool);
- }
-
- }, PNEWTABLET, "Tablet");
+ },
+ 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) {
-
- 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");
-
- 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;
-
- 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_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;
-
- 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");
-
- 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");
+ 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;
+
+ 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");
+
+ 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;
+
+ 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_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;
+
+ 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");
+
+ 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");
}
void CInputManager::focusTablet(STablet* pTab, wlr_tablet_tool* pTool, bool motion) {
diff --git a/src/managers/input/Touch.cpp b/src/managers/input/Touch.cpp
index b07bb915..9c0c2a8d 100644
--- a/src/managers/input/Touch.cpp
+++ b/src/managers/input/Touch.cpp
@@ -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;