Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Why is Gridmove using longer labels than would suffice. #240

Closed
Guscccc opened this issue Apr 25, 2024 · 2 comments
Closed

[Question] Why is Gridmove using longer labels than would suffice. #240

Guscccc opened this issue Apr 25, 2024 · 2 comments

Comments

@Guscccc
Copy link

Guscccc commented Apr 25, 2024

Question
First of all, thanks for your work! I've been searching for something like win-vind for quite a while, and loved it!

But when I was trying to use the Gridmove, I noticed that it is using longer labels than would suffice.

For example, I have set gridmove_size=20x30 in the .vindrc, which would need 600 distinct labels to fill out, and since the default value of hintkeys is all the 26 letters, which provides 26x26=676 labels using just 2 letter combinations, technically all the labels should use just 2 letters. But they use 3 letters for my case, and all of which starts with the same letter A, seemingly redundant.

Is this intended behaviour? If not, can it be fixed so that only as many as needed letters are used for labelling?

@pit-ray
Copy link
Owner

pit-ray commented Jun 2, 2024

gridmove assigns a hint for each monitor, then assigns a unique hint sequence. This allows you to only have to pay attention to the target monitor after you have entered the first letter.

void GridMove::Impl::assign_hints(
std::vector<util::Point2D>& points,
std::vector<core::Hint>& hints,
std::vector<std::string>& hint_texts) {
auto& settable = core::SetTable::get_instance() ;
const auto hintkeys = settable.get("hintkeys").get<std::string>() ;
auto monitors = util::get_all_monitor_metrics() ;
// Assign hints for all monitors.
std::vector<core::Hint> m_hints ;
std::vector<std::string> m_hint_texts ;
core::assign_identifier_hints(
monitors.size(), m_hints, m_hint_texts, hintkeys) ;
// Assign hints for grid cells of each monitor.
std::vector<core::Hint> c_hints ;
std::vector<std::string> c_hint_texts ;
auto cell_nums = static_cast<std::size_t>(grid_h_ * grid_w_) ;
core::assign_identifier_hints(
cell_nums, c_hints, c_hint_texts, hintkeys) ;
for(std::size_t mi = 0 ; mi < monitors.size() ; mi ++) {
const auto& rect = monitors[mi].rect ;
auto cell_w = rect.width() / grid_w_ ;
auto cell_h = rect.height() / grid_h_ ;
// the center of the cell at (0, 0).
auto base_x = rect.left() + cell_w / 2 ;
auto base_y = rect.top() + cell_h / 2 ;
for(int ci = 0 ; ci < (grid_h_ * grid_w_) ; ci ++) {
points.emplace_back(
base_x + (ci % grid_w_) * cell_w,
base_y + (ci / grid_w_) * cell_h) ;
hint_texts.push_back(m_hint_texts[mi] + c_hint_texts[ci]) ;
auto hint = m_hints[mi] ;
hint.insert(hint.end(), c_hints[ci].begin(), c_hints[ci].end()) ;
hints.push_back(hint) ;

It can be modified to assign only the required strings, but there is a drawback to search hints.

@Guscccc
Copy link
Author

Guscccc commented Jun 2, 2024

Got it, Thank you very much for answering!

@Guscccc Guscccc closed this as completed Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants