floating windows support

This commit is contained in:
vaxerski 2022-03-20 11:14:24 +01:00
parent a4d69a15b3
commit a4b026df2b
12 changed files with 123 additions and 12 deletions

View file

@ -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;
}

View file

@ -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;

View file

@ -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);
}
}

View file

@ -25,6 +25,7 @@ private:
// -------------- Dispatchers -------------- //
void killActive(std::string);
void spawn(std::string);
void toggleActiveFloating(std::string);
};