Added pinning windows

This commit is contained in:
vaxerski 2022-04-04 21:40:10 +02:00
parent 1a5ed05758
commit 83d69cb233
6 changed files with 20 additions and 4 deletions

View file

@ -182,6 +182,7 @@ void KeybindManager::toggleActiveWindowFloating(std::string arg) {
if (const auto PWINDOW = g_pWindowManager->getWindowFromDrawable(g_pWindowManager->LastWindow); PWINDOW) {
PWINDOW->setIsFloating(!PWINDOW->getIsFloating());
PWINDOW->setDirty(true);
PWINDOW->setPinned(false);
// Fix window as if it's closed if we just made it floating
if (PWINDOW->getIsFloating()) {
@ -277,3 +278,13 @@ void KeybindManager::lastWorkspace(std::string args) {
g_pWindowManager->changeWorkspaceByID(g_pWindowManager->activeWorkspaces[PMONITOR->ID] < 2 ? 1 : g_pWindowManager->activeWorkspaces[PMONITOR->ID] - 1);
}
void KeybindManager::pinActive(std::string agrs) {
const auto PWINDOW = g_pWindowManager->getWindowFromDrawable(g_pWindowManager->LastWindow);
if (!PWINDOW)
return;
if (PWINDOW->getIsFloating())
PWINDOW->setPinned(!PWINDOW->getPinned());
}

View file

@ -32,4 +32,5 @@ namespace KeybindManager {
void toggleScratchpad(std::string args);
void nextWorkspace(std::string args);
void lastWorkspace(std::string args);
void pinActive(std::string args);
};

View file

@ -130,6 +130,7 @@ void handleBind(const std::string& command, const std::string& value) {
if (HANDLER == "scratchpad") dispatcher = KeybindManager::toggleScratchpad;
if (HANDLER == "nextworkspace") dispatcher = KeybindManager::nextWorkspace;
if (HANDLER == "lastworkspace") dispatcher = KeybindManager::lastWorkspace;
if (HANDLER == "pin") dispatcher = KeybindManager::pinActive;
if (dispatcher && KEY != 0)
KeybindManager::keybinds.push_back(Keybind(KeybindManager::modToMask(MOD), KEY, COMMAND, dispatcher));

View file

@ -1,7 +1,7 @@
#include "window.hpp"
#include "windowManager.hpp"
CWindow::CWindow() { this->setDraggingTiled(false); this->setIsPseudotiled(false); this->setSplitRatio(1); this->setDockHidden(false); this->setRealBorderColor(0); this->setEffectiveBorderColor(0); this->setFirstOpen(true); this->setConstructed(false); this->setTransient(false); this->setLastUpdatePosition(Vector2D(0,0)); this->setLastUpdateSize(Vector2D(0,0)); this->setDock(false); this->setUnderFullscreen(false); this->setIsSleeping(true); this->setFirstAnimFrame(true); this->setIsAnimated(false); this->setDead(false); this->setMasterChildIndex(0); this->setMaster(false); this->setCanKill(false); this->setImmovable(false); this->setNoInterventions(false); this->setDirty(true); this->setFullscreen(false); this->setIsFloating(false); this->setParentNodeID(0); this->setChildNodeAID(0); this->setChildNodeBID(0); this->setName(""); }
CWindow::CWindow() { this->setPinned(false); this->setDraggingTiled(false); this->setIsPseudotiled(false); this->setSplitRatio(1); this->setDockHidden(false); this->setRealBorderColor(0); this->setEffectiveBorderColor(0); this->setFirstOpen(true); this->setConstructed(false); this->setTransient(false); this->setLastUpdatePosition(Vector2D(0,0)); this->setLastUpdateSize(Vector2D(0,0)); this->setDock(false); this->setUnderFullscreen(false); this->setIsSleeping(true); this->setFirstAnimFrame(true); this->setIsAnimated(false); this->setDead(false); this->setMasterChildIndex(0); this->setMaster(false); this->setCanKill(false); this->setImmovable(false); this->setNoInterventions(false); this->setDirty(true); this->setFullscreen(false); this->setIsFloating(false); this->setParentNodeID(0); this->setChildNodeAID(0); this->setChildNodeBID(0); this->setName(""); }
CWindow::~CWindow() { }
void CWindow::generateNodeID() {

View file

@ -115,6 +115,9 @@ public:
// For dragging tiled windows
EXPOSED_MEMBER(DraggingTiled, bool, b);
// For pinning floating
EXPOSED_MEMBER(Pinned, bool, b);
private:
};

View file

@ -406,7 +406,7 @@ void CWindowManager::refreshDirtyWindows() {
if (window.getChildNodeAID() != 0 || window.getNoInterventions() || window.getDock())
continue;
setEffectiveSizePosUsingConfig(&window);
setEffectiveSizePosUsingConrgifig(&window);
const auto PWORKSPACE = getWorkspaceByID(window.getWorkspaceID());
@ -416,7 +416,7 @@ void CWindowManager::refreshDirtyWindows() {
// first and foremost, let's check if the window isn't on a hidden workspace
// or an animated workspace
if (PWORKSPACE && (!isWorkspaceVisible(window.getWorkspaceID())
|| PWORKSPACE->getAnimationInProgress())) {
|| PWORKSPACE->getAnimationInProgress()) && !window.getPinned()) {
const auto MONITOR = getMonitorFromWindow(&window);
@ -447,7 +447,7 @@ void CWindowManager::refreshDirtyWindows() {
}
// or that it is not a non-fullscreen window in a fullscreen workspace thats under
if (bHasFullscreenWindow && !window.getFullscreen() && (window.getUnderFullscreen() || !window.getIsFloating())) {
if (bHasFullscreenWindow && !window.getFullscreen() && (window.getUnderFullscreen() || !window.getIsFloating()) && !window.getPinned()) {
Values[0] = 150000;
Values[1] = 150000;
if (VECTORDELTANONZERO(window.getLastUpdatePosition(), Vector2D(Values[0], Values[1]))) {