Skip to content

Commit

Permalink
jump: fix cancelling with empty monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
dawsers committed Dec 3, 2024
1 parent 9db866f commit ccd626b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/scroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,7 @@ typedef struct JumpData {
bool overview;
} Rows;
PHLWINDOWREF from_window;
PHLMONITORREF from_monitor;
std::vector<Rows> workspaces;
std::vector<PHLWINDOWREF> windows;
std::vector<JumpDecoration *> decorations;
Expand Down Expand Up @@ -1133,6 +1134,7 @@ void ScrollerLayout::jump() {
static auto const *KEYS = (Hyprlang::STRING const *)HyprlandAPI::getConfigValue(PHANDLE, "plugin:scroller:jump_labels_keys")->getDataStaticPtr();
jump_data->keys = *KEYS;
jump_data->from_window = g_pCompositor->m_pLastWindow;
jump_data->from_monitor = g_pCompositor->m_pLastMonitor;
jump_data->nkeys = std::ceil(std::log10(jump_data->windows.size()) / std::log10(jump_data->keys.size()));

// Set overview mode for those workspaces that are not
Expand Down Expand Up @@ -1203,7 +1205,12 @@ void ScrollerLayout::jump() {
switch_to_window(jump_data->from_window.lock(),
jump_data->windows[jump_data->window_number].lock());
} else {
g_pCompositor->warpCursorTo(jump_data->from_window.lock()->middle());
if (jump_data->from_window != nullptr)
g_pCompositor->warpCursorTo(jump_data->from_window.lock()->middle());
else {
g_pCompositor->warpCursorTo(jump_data->from_monitor.lock()->middle());
g_pCompositor->setActiveMonitor(jump_data->from_monitor.lock());
}
}
info.cancelled = true;
jump_data->keyPressHookCallback.reset();
Expand Down

0 comments on commit ccd626b

Please sign in to comment.