summaryrefslogtreecommitdiff
path: root/src/managers
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-03-20 11:14:24 +0100
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-03-20 11:14:24 +0100
commita4b026df2b7f94b2985d38b1ef6fb127782c1a27 (patch)
treec85f054baed6951fa096a358096fecc4e5c08a19 /src/managers
parenta4d69a15b34e54d8438a7242b151b1d31cbef46a (diff)
floating windows support
Diffstat (limited to 'src/managers')
-rw-r--r--src/managers/InputManager.cpp11
-rw-r--r--src/managers/InputManager.hpp6
-rw-r--r--src/managers/KeybindManager.cpp12
-rw-r--r--src/managers/KeybindManager.hpp1
4 files changed, 28 insertions, 2 deletions
diff --git a/src/managers/InputManager.cpp b/src/managers/InputManager.cpp
index ecf63bf2..cc7d302c 100644
--- a/src/managers/InputManager.cpp
+++ b/src/managers/InputManager.cpp
@@ -41,6 +41,7 @@ void CInputManager::mouseMoveUnified(uint32_t time) {
wlr_seat_pointer_notify_motion(g_pCompositor->m_sWLRSeat, time, surfaceLocal.x, surfaceLocal.y);
g_pCompositor->m_pLastMonitor = g_pCompositor->getMonitorFromCursor();
+ g_pLayoutManager->getCurrentLayout()->onMouseMove(getMouseCoordsInternal());
}
void CInputManager::onMouseButton(wlr_event_pointer_button* e) {
@@ -48,10 +49,16 @@ void CInputManager::onMouseButton(wlr_event_pointer_button* e) {
switch (e->state) {
case WLR_BUTTON_PRESSED:
- // todo: keybinds
+ if (e->button == BTN_LEFT || e->button == BTN_RIGHT) {
+ currentlyDraggedWindow = g_pCompositor->windowFloatingFromCursor();
+ dragButton = e->button;
+
+ g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
+ }
break;
case WLR_BUTTON_RELEASED:
- // todo: keybinds
+ currentlyDraggedWindow = nullptr;
+ dragButton = -1;
break;
}
diff --git a/src/managers/InputManager.hpp b/src/managers/InputManager.hpp
index 75ad75d6..ce1afcea 100644
--- a/src/managers/InputManager.hpp
+++ b/src/managers/InputManager.hpp
@@ -3,6 +3,7 @@
#include "../defines.hpp"
#include <list>
#include "../helpers/WLClasses.hpp"
+#include "../Window.hpp"
class CInputManager {
public:
@@ -20,6 +21,11 @@ public:
Vector2D getMouseCoordsInternal();
+
+ // for dragging floating windows
+ CWindow* currentlyDraggedWindow = nullptr;
+ int dragButton = -1;
+
private:
std::list<SKeyboard> m_lKeyboards;
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index a4206340..96bf65fa 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -42,6 +42,7 @@ bool CKeybindManager::handleKeybinds(const uint32_t& modmask, const xkb_keysym_t
// yes.
if (k.handler == "exec") { spawn(k.arg); }
else if (k.handler == "killactive") { killActive(k.arg); }
+ else if (k.handler == "togglefloating") { toggleActiveFloating(k.arg); }
found = true;
}
@@ -64,8 +65,19 @@ void CKeybindManager::spawn(std::string args) {
void CKeybindManager::killActive(std::string args) {
if (g_pCompositor->m_pLastFocus && g_pCompositor->windowValidMapped(g_pCompositor->m_pLastFocus))
g_pXWaylandManager->sendCloseWindow(g_pCompositor->m_pLastFocus);
+
+ g_pCompositor->focusWindow(g_pCompositor->windowFromCursor());
}
void CKeybindManager::clearKeybinds() {
m_dKeybinds.clear();
+}
+
+void CKeybindManager::toggleActiveFloating(std::string args) {
+ const auto ACTIVEWINDOW = g_pCompositor->m_pLastFocus;
+
+ if (g_pCompositor->windowValidMapped(ACTIVEWINDOW)) {
+ ACTIVEWINDOW->m_bIsFloating = !ACTIVEWINDOW->m_bIsFloating;
+ g_pLayoutManager->getCurrentLayout()->changeWindowFloatingMode(ACTIVEWINDOW);
+ }
} \ No newline at end of file
diff --git a/src/managers/KeybindManager.hpp b/src/managers/KeybindManager.hpp
index 6400b193..5aeb3a05 100644
--- a/src/managers/KeybindManager.hpp
+++ b/src/managers/KeybindManager.hpp
@@ -25,6 +25,7 @@ private:
// -------------- Dispatchers -------------- //
void killActive(std::string);
void spawn(std::string);
+ void toggleActiveFloating(std::string);
};