Code Monkey home page Code Monkey logo

Comments (5)

markstos avatar markstos commented on August 10, 2024

I looked at this some today and believe I ran into an issue related this comment about a "kinda hacky" solution:
https://github.com/edzdez/sway-easyfocus/blob/main/src/ui.rs#L28

The way I understand the current code, the Sway windows are iterated over in a fixed order and the Easy Focus window labels are also assigned in a fixed order: Starting with "a" and extending through the alphabet.

To find which window to focus, it's assumed that the letter of the alphabets corresponds to the order of the Sway window nodes, so the letter can be used as an index of sorts. That assumption would break if random letter orders is allowed.


Looking deeper, it appears that one "GTK window" is used per-output currently, so there is only listener per keyboard events per output currently.

A proposed solution is to render one GTK overlay window per Sway "window node". I believe this would enable defining unique keyboard listener per GTK window. These listeners could defined using a closure where Sway's "window node id" can be captured and used to call the function to focus the window.

If I've understanding things correctly, this would solve the problem if the letters pressed being bound to the order of the windows. Also, it would support more than one letter per window-- setting the foundation of supporting more than 26 windows as well.

from sway-easyfocus.

edzdez avatar edzdez commented on August 10, 2024

Your understanding of the current code is indeed correct. Additionally, our solution seems like it may work, but I'm not sure if it's possible for multiple Gtk windows to listen for keypresses simultaneously (rather than only the one focused GtkWindow, as it is right now).

Unfortunately, I'm a bit busy this week so I don't think I'll be able to make progress on this immediately, but if you're interested, I'm open to PRs!

from sway-easyfocus.

markstos avatar markstos commented on August 10, 2024

According to Google Bard, there are a couple options to register a single global keyboard event handler, which could then contain a dispatch table which maps specific keypresses to corresponding window IDs.

from sway-easyfocus.

markstos avatar markstos commented on August 10, 2024

Fixed by #16

from sway-easyfocus.

edzdez avatar edzdez commented on August 10, 2024

Thank you for fixing this!

from sway-easyfocus.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.