TimUntersberger / nog

A tiling window manager for Windows
MIT License
697 stars 20 forks source link

Event system #258

Open TimUntersberger opened 3 years ago

TimUntersberger commented 3 years ago

What if we replace rules with an event handler system.

So instead of writing the following

nog.config.rules = {
  ["notepad.exe"] = {
    ignore: true
  }
}

we could do this

nog.events.on("win_detected", function (event)
  -- event has the settings as payload so it would look like this:
  -- {
  --   type: "win_detected",
  --   payload: {
  --     ignore: false,
  --     workspace: nil,
  --     ...
  --   }
  -- }
  event.payload.ignore = true
end)

I am not too sure about how we could implement rules with such a system. The things I mentioned above are my first ideas.

We could then have more events for different things. A few examples:

Maybe a plugin could even emit custom events through here? Not too sure about this one as they could provide their own event management (Having one central place for events could be cleaner I guess)

keepitsane commented 3 years ago

This could also be useful for installers. Not sure if you guys have this issue as well, but anytime I run an installer most of the time it is jumping all over the place. Not sure if there would be a way to detect this, but would be nice if possible.

ramirezmike commented 3 years ago

This could also be useful for installers. Not sure if you guys have this issue as well, but anytime I run an installer most of the time it is jumping all over the place. Not sure if there would be a way to detect this, but would be nice if possible.

Yeah, I had a similar problem and added the minHeight/minWidth settings here https://timuntersberger.github.io/nog/configuration/settings.html to handle that. It's not a perfect solution but it helps.

I'm not sure how we could detect an installer but an event system would totally help attack issues like that.