Added drag to move window

This commit is contained in:
vaxerski 2022-04-03 13:49:21 +02:00
parent df6a3c6877
commit 462781b16f
5 changed files with 27 additions and 3 deletions

View File

@ -42,6 +42,7 @@ public:
uint64_t m_iTags = 0; uint64_t m_iTags = 0;
bool m_bIsFloating = false; bool m_bIsFloating = false;
bool m_bDraggingTiled = false; // for dragging around tiled windows
bool m_bIsFullscreen = false; bool m_bIsFullscreen = false;
uint64_t m_iMonitorID = -1; uint64_t m_iMonitorID = -1;
std::string m_szTitle = ""; std::string m_szTitle = "";

View File

@ -324,12 +324,25 @@ void CHyprDwindleLayout::onBeginDragWindow() {
return; return;
} }
if (!DRAGGINGWINDOW->m_bIsFloating) {
DRAGGINGWINDOW->m_bDraggingTiled = true;
changeWindowFloatingMode(DRAGGINGWINDOW);
} else {
DRAGGINGWINDOW->m_bDraggingTiled = false;
}
m_vBeginDragXY = g_pInputManager->getMouseCoordsInternal(); m_vBeginDragXY = g_pInputManager->getMouseCoordsInternal();
m_vBeginDragPositionXY = DRAGGINGWINDOW->m_vRealPosition; m_vBeginDragPositionXY = DRAGGINGWINDOW->m_vRealPosition;
m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize; m_vBeginDragSizeXY = DRAGGINGWINDOW->m_vRealSize;
} }
void CHyprDwindleLayout::onEndDragWindow() {
const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow;
if (DRAGGINGWINDOW->m_bDraggingTiled)
changeWindowFloatingMode(DRAGGINGWINDOW);
}
void CHyprDwindleLayout::onMouseMove(const Vector2D& mousePos) { void CHyprDwindleLayout::onMouseMove(const Vector2D& mousePos) {
const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow; const auto DRAGGINGWINDOW = g_pInputManager->currentlyDraggedWindow;

View File

@ -35,6 +35,7 @@ public:
virtual void recalculateWindow(CWindow*); virtual void recalculateWindow(CWindow*);
virtual void changeWindowFloatingMode(CWindow*); virtual void changeWindowFloatingMode(CWindow*);
virtual void onBeginDragWindow(); virtual void onBeginDragWindow();
virtual void onEndDragWindow();
virtual void onMouseMove(const Vector2D&); virtual void onMouseMove(const Vector2D&);
virtual void onWindowCreatedFloating(CWindow*); virtual void onWindowCreatedFloating(CWindow*);
virtual void fullscreenRequestForWindow(CWindow*); virtual void fullscreenRequestForWindow(CWindow*);

View File

@ -36,6 +36,11 @@ public:
as. as.
*/ */
virtual void onBeginDragWindow() = 0; virtual void onBeginDragWindow() = 0;
/*
Called when a window is ended being dragged
(mouse up)
*/
virtual void onEndDragWindow() = 0;
/* /*
Called whenever the mouse moves, should the layout want to Called whenever the mouse moves, should the layout want to
do anything with it. do anything with it.

View File

@ -122,7 +122,7 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
refocus(); refocus();
if ((e->button == BTN_LEFT || e->button == BTN_RIGHT) && wlr_keyboard_get_modifiers(PKEYBOARD) == (uint32_t)g_pConfigManager->getInt("general:main_mod_internal")) { if ((e->button == BTN_LEFT || e->button == BTN_RIGHT) && wlr_keyboard_get_modifiers(PKEYBOARD) == (uint32_t)g_pConfigManager->getInt("general:main_mod_internal")) {
currentlyDraggedWindow = g_pCompositor->windowFloatingFromCursor(); currentlyDraggedWindow = g_pCompositor->windowFromCursor();
dragButton = e->button; dragButton = e->button;
g_pLayoutManager->getCurrentLayout()->onBeginDragWindow(); g_pLayoutManager->getCurrentLayout()->onBeginDragWindow();
@ -131,8 +131,12 @@ void CInputManager::onMouseButton(wlr_pointer_button_event* e) {
} }
break; break;
case WLR_BUTTON_RELEASED: case WLR_BUTTON_RELEASED:
currentlyDraggedWindow = nullptr; if (currentlyDraggedWindow) {
dragButton = -1; g_pLayoutManager->getCurrentLayout()->onEndDragWindow();
currentlyDraggedWindow = nullptr;
dragButton = -1;
}
break; break;
} }