Class: RosettAi::DBus::FocusAdapters::Base
- Inherits:
-
Object
- Object
- RosettAi::DBus::FocusAdapters::Base
- Defined in:
- lib/rosett_ai/dbus/focus_adapters/base.rb
Overview
Base class for compositor-specific focus adapters.
Each adapter implements the same interface:
- #start: Begin monitoring focus changes
- #stop: Stop monitoring
- #on_focus_change(&block): Register callback for focus changes
Callbacks receive (app_id, title) arguments.
Direct Known Subclasses
GnomeAdapter, HyprlandAdapter, I3Adapter, KwinAdapter, X11Adapter
Instance Method Summary collapse
-
#initialize ⇒ Base
constructor
A new instance of Base.
-
#notify_focus_change(app_id, title) ⇒ Object
protected
Notify all registered callbacks of a focus change.
-
#on_focus_change {|app_id, title| ... } ⇒ Object
Register callback for focus changes.
-
#running? ⇒ Boolean
Check if monitoring is active.
-
#start ⇒ Object
Start monitoring focus changes.
-
#stop ⇒ Object
Stop monitoring.
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
18 19 20 21 |
# File 'lib/rosett_ai/dbus/focus_adapters/base.rb', line 18 def initialize @callbacks = [] @running = false end |
Instance Method Details
#notify_focus_change(app_id, title) ⇒ Object (protected)
Notify all registered callbacks of a focus change
53 54 55 |
# File 'lib/rosett_ai/dbus/focus_adapters/base.rb', line 53 def notify_focus_change(app_id, title) @callbacks.each { |cb| cb.call(app_id.to_s, title.to_s) } end |
#on_focus_change {|app_id, title| ... } ⇒ Object
Register callback for focus changes
26 27 28 |
# File 'lib/rosett_ai/dbus/focus_adapters/base.rb', line 26 def on_focus_change(&block) @callbacks << block end |
#running? ⇒ Boolean
Check if monitoring is active
43 44 45 |
# File 'lib/rosett_ai/dbus/focus_adapters/base.rb', line 43 def running? @running end |
#start ⇒ Object
Start monitoring focus changes
31 32 33 |
# File 'lib/rosett_ai/dbus/focus_adapters/base.rb', line 31 def start raise NotImplementedError, "#{self.class}#start must be implemented" end |
#stop ⇒ Object
Stop monitoring
36 37 38 |
# File 'lib/rosett_ai/dbus/focus_adapters/base.rb', line 36 def stop @running = false end |