Skip to content

Commit

Permalink
[wayland] fix crash on startup with lv3:ralt_alt XKB option
Browse files Browse the repository at this point in the history
With lv3:ralt_alt ("Right Alt never chooses 3rd level") option set, we
get more layouts from libxkbcommon than it was configured, see
xkbcommon/libxkbcommon#262
It might be correct lib's behavior, still.

The extra layouts are redundant, so we stream them out from usual usage.

BUG: 440027
  • Loading branch information
bam80 committed Oct 8, 2021
1 parent ef06b8e commit cc09af7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/xkb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,7 @@ void Xkb::switchToNextLayout()
if (!m_keymap || !m_state) {
return;
}
const xkb_layout_index_t numLayouts = xkb_keymap_num_layouts(m_keymap);
const xkb_layout_index_t nextLayout = (xkb_state_serialize_layout(m_state, XKB_STATE_LAYOUT_EFFECTIVE) + 1) % numLayouts;
switchToLayout(nextLayout);
switchToLayout( (xkb_state_serialize_layout(m_state, XKB_STATE_LAYOUT_EFFECTIVE) + 1) % numberOfLayouts() );
}

void Xkb::switchToPreviousLayout()
Expand Down Expand Up @@ -560,7 +558,7 @@ quint32 Xkb::numberOfLayouts() const
if (!m_keymap) {
return 0;
}
return xkb_keymap_num_layouts(m_keymap);
return qMin( xkb_keymap_num_layouts(m_keymap), uint(m_layoutList.size()) );
}

void Xkb::setSeat(KWaylandServer::SeatInterface *seat)
Expand Down

0 comments on commit cc09af7

Please sign in to comment.