Commit Graph

41 Commits

Author SHA1 Message Date
1a59599388 fix(modules): Avoid downcast in module constructor
The previous CAST_MOD(Impl) for the action_router constructor was
illegal because `this` is not yet of type Impl (because the subclass
constructor has not run yet).

The action_router now accepts std::function for its callbacks.

Fixes #2519
2021-10-03 03:18:39 +02:00
26be83f893 module: Implement action router (#2336)
* module: Implement proof of concept action router

Action implementation inside module becomes much cleaner because each
module just registers action names together with a callback (pointer to
member function) and the action router does the rest.

* Make input function final

This forces all modules to use the action router

* modules: Catch exceptions in action handlers

* Use action router for all modules

* Use action_ prefix for function names

The mpd module's 'stop' action overwrote the base module's stop function
which caused difficult to debug behavior.

To prevent this in the future we now prefix each function that is
responsible for an action with 'action_'

* Cleanup

* actions: Throw exception when re-registering action

Action names are unique inside modules. Unfortunately there is no way to
ensure this statically, the next best thing is to crash the module and
let the user know that this is a bug.

* Formatting

* actions: Ignore data for actions without data

This is the same behavior as before.

* action_router: Write tests
2021-01-04 10:25:52 +01:00
9fb75779f3 Incorporate reviews 2020-11-26 20:53:53 +01:00
bc1b86c584 actions: Separate data from action string
Modules now no longer need to manually parse the action string and
extract data from it.
2020-11-26 20:53:53 +01:00
ae2350167b actions: Switch all modules over to new system
All modules now expose their actions as public static constants

Issues: The menu module no longer closes when an item is clicked (before
it would intercept any executed command and look if it matches one of
its exec commands)
2020-11-26 20:53:53 +01:00
52000c194a fix(xrandr): Fetch cloned monitors where possible
Removing monitors is not really necessary when selecting the monitor
where to render the bar or choosing the backlight. Since both monitors
occupy the same coordinates rendering can be done on both and it's
better to give people felxibility for the backlight.

Fixes #1191
2020-04-21 23:59:01 +02:00
4a506d429d xbacklight: Use monitor-strict from bar settings
monitor-strict in the xbacklight module was never documented anywhere so
it's fine to remove it.
2019-01-08 17:23:28 +01:00
e793082008 randr: Add separate key for exact monitor matching
This adds `monitor-exact = true` in the bar section

This also properly does best-match instead of first-match if multiple
matches exists. For example if there are two monitors HDMI2 and HDMI-2
and we try to match HDMI-2 with monitor-exact = false, until now HDMI2
would be matched. Now exact matches are always preferred.

Fixes #1532
2019-01-08 17:23:28 +01:00
1ac5c23fd2 fix(xbacklight): respect enable-scroll 2018-02-11 17:22:44 +01:00
eb5c82a5c3 fix(modules): Warmup in runner thread to avoid block 2017-01-27 13:29:10 +01:00
6692b4a8da refactor(x11): Cleanup 2017-01-24 10:49:14 +01:00
3292cea786 refactor(tokens): Move token suffix to configuration 2017-01-14 18:00:35 +01:00
385572ec64 feat(xrandr): Support for monitors
Refs #280
2017-01-13 03:52:57 +01:00
5c9bfc147c fix(xbacklight): Lower inc/dec value to 5 and fix flooring 2017-01-11 04:40:10 +01:00
210695d377 refactor(x11): Merge xlib/xutils with connection 2016-12-31 10:02:32 +01:00
78bb3695e6 refactor(config): Deduce return type from default value 2016-12-30 23:32:05 +01:00
b422d1d1a4 refactor(modules): Input handling 2016-12-23 20:43:52 +01:00
97fa7052fe refactor(clang-tidy): Apply fixes 2016-12-23 15:54:06 +01:00
8cff01e3d8 refactor(event_handler): Abstract sink attaching 2016-12-23 05:08:19 +01:00
788a7ca3a3 refactor(modules): Get rid of .inl files 2016-12-21 09:21:35 +01:00
7979f5b3d4 refactor(modules): Handle events using signal_receiver 2016-12-21 08:38:44 +01:00
c01f111e34 refactor(modules): Move setup to constructor 2016-12-21 08:00:09 +01:00
418dadf0b9 fix(xbacklight): Close cmd blocks 2016-12-20 07:04:13 +01:00
f9062d031c refactor(clang-tidy): Apply fixes 2016-12-15 03:30:41 +01:00
4fca0c89b4 refactor: Object construction 2016-12-14 11:01:44 +01:00
1a2a6e5fab refactor: Construction methods 2016-12-14 11:01:44 +01:00
08be86fbe1 wip(refactor): Improve signal and event handling 2016-12-14 11:01:44 +01:00
3854515521 fix: Wrap format pre/suffix within cmd 2016-12-05 05:32:10 +01:00
4776ec49df fix: Use defined event sink priority 2016-12-03 13:00:40 +01:00
608519363d feat(xkeyboard): New module
New module that uses the X keyboard extension
to show keyboard layout and indicators.

Ref #84, #200
2016-11-30 10:08:44 +01:00
9f4638f42c refactor: Cleanup 2016-11-26 06:13:20 +01:00
ff9be848c7 refactor(clang-tidy): Apply fixes 2016-11-25 21:58:49 +01:00
9fdc22843b refactor: Cleanup rendering 2016-11-25 04:42:27 +01:00
84d58e7619 refactor: Cleanup handling of syntax tags 2016-11-25 04:34:24 +01:00
c6d85b2b92 refactor: Optimize build 2016-11-20 23:04:31 +01:00
88c8bbd940 refactor: Fwd declare drawtypes
Ref #164
2016-11-19 15:49:06 +01:00
fd57ab0f3d fix: project rename 2016-11-19 06:26:07 +01:00
51d8f289fa feat(xwindow): New module "xwindow"
Add module to display title of active window.
Requires WM with support for the _NET_ACTIVE_WINDOW hint.

Ref #84
2016-11-19 04:05:13 +01:00
4d7f6c14e6 fix(xrandr): Less strict monitor matching
Be less strict when matching randr outputs
against specified name. This is a workaround
to fix the output naming issue when switching
between graphic drivers.

On my system the output names include a dash
when using the nvidia drivers but the intel
driver does not.

   nvidia:
      HDMI-1
      eDP-1
   xf86-video-intel:
      HDMI1
      eDP1

When strict mode is disabled the matching
won't care about the connection state.

The user can re-enable exact matching and
connection state testing by setting the
config parameter `monitor-strict = true`
2016-11-12 20:42:56 +01:00
f2bbd301f2 feat(xbacklight): Change value on scroll
- Add action handlers for scroll up/down (conf: enable-sroll = true)
- Use xcb_timestamps instead of the throttle util
2016-11-12 13:07:05 +01:00
e7cb345cec wip: Separate source from definitions 2016-11-03 12:54:32 +01:00