Class: Uh::WM::Manager
- Inherits:
-
Object
- Object
- Uh::WM::Manager
- Defined in:
- lib/uh/wm/manager.rb
Constant Summary collapse
- INPUT_MASK =
Events::SUBSTRUCTURE_REDIRECT_MASK
- ROOT_MASK =
Events::PROPERTY_CHANGE_MASK | Events::SUBSTRUCTURE_REDIRECT_MASK | Events::SUBSTRUCTURE_NOTIFY_MASK | Events::STRUCTURE_NOTIFY_MASK
- DEFAULT_GEO =
Geo.new(0, 0, 320, 240).freeze
Instance Attribute Summary collapse
-
#clients ⇒ Object
readonly
Returns the value of attribute clients.
-
#display ⇒ Object
readonly
Returns the value of attribute display.
-
#modifier ⇒ Object
readonly
Returns the value of attribute modifier.
-
#modifier_ignore ⇒ Object
readonly
Returns the value of attribute modifier_ignore.
Instance Method Summary collapse
- #configure(window) ⇒ Object
- #connect ⇒ Object
- #destroy(window) ⇒ Object
- #disconnect ⇒ Object
- #flush ⇒ Object
- #grab_key(keysym, mod = nil) ⇒ Object
- #handle(event) ⇒ Object
- #handle_next_event ⇒ Object
- #handle_pending_events ⇒ Object
-
#initialize(events, mod, mod_ignore = [], display = Display.new) ⇒ Manager
constructor
A new instance of Manager.
- #map(window) ⇒ Object
- #to_io ⇒ Object
- #unmap(window) ⇒ Object
- #update_properties(window) ⇒ Object
Constructor Details
#initialize(events, mod, mod_ignore = [], display = Display.new) ⇒ Manager
Returns a new instance of Manager.
13 14 15 16 17 18 19 |
# File 'lib/uh/wm/manager.rb', line 13 def initialize events, mod, mod_ignore = [], display = Display.new @events = events @modifier = mod @modifier_ignore = mod_ignore @display = display @clients = [] end |
Instance Attribute Details
#clients ⇒ Object (readonly)
Returns the value of attribute clients.
11 12 13 |
# File 'lib/uh/wm/manager.rb', line 11 def clients @clients end |
#display ⇒ Object (readonly)
Returns the value of attribute display.
11 12 13 |
# File 'lib/uh/wm/manager.rb', line 11 def display @display end |
#modifier ⇒ Object (readonly)
Returns the value of attribute modifier.
11 12 13 |
# File 'lib/uh/wm/manager.rb', line 11 def modifier @modifier end |
#modifier_ignore ⇒ Object (readonly)
Returns the value of attribute modifier_ignore.
11 12 13 |
# File 'lib/uh/wm/manager.rb', line 11 def modifier_ignore @modifier_ignore end |
Instance Method Details
#configure(window) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/uh/wm/manager.rb', line 52 def configure window if client = client_for(window) client.configure else geo = @events.emit :configure, args: window window.configure_event geo ? geo : DEFAULT_GEO end end |
#connect ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/uh/wm/manager.rb', line 25 def connect @events.emit :connecting, args: @display @display.open check_other_wm! Display.on_error { |*args| handle_error *args } @display.sync false @events.emit :connected, args: @display @display.root.mask = ROOT_MASK end |
#destroy(window) ⇒ Object
77 78 79 80 |
# File 'lib/uh/wm/manager.rb', line 77 def destroy window return unless client = client_for(window) unmanage client end |
#disconnect ⇒ Object
35 36 37 38 |
# File 'lib/uh/wm/manager.rb', line 35 def disconnect @display.close @events.emit :disconnected end |
#flush ⇒ Object
40 41 42 |
# File 'lib/uh/wm/manager.rb', line 40 def flush @display.flush end |
#grab_key(keysym, mod = nil) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/uh/wm/manager.rb', line 44 def grab_key keysym, mod = nil mod_mask = KEY_MODIFIERS[@modifier] mod_mask |= KEY_MODIFIERS[mod] if mod combine_modifier_masks(@modifier_ignore) do |ignore_mask| @display.grab_key keysym.to_s, mod_mask | ignore_mask end end |
#handle(event) ⇒ Object
96 97 98 99 100 |
# File 'lib/uh/wm/manager.rb', line 96 def handle event @events.emit :xevent, args: event return unless respond_to? handler = "handle_#{event.type}".to_sym, true send handler, event end |
#handle_next_event ⇒ Object
88 89 90 |
# File 'lib/uh/wm/manager.rb', line 88 def handle_next_event handle @display.next_event end |
#handle_pending_events ⇒ Object
92 93 94 |
# File 'lib/uh/wm/manager.rb', line 92 def handle_pending_events handle_next_event while @display.pending? end |
#map(window) ⇒ Object
61 62 63 64 65 66 |
# File 'lib/uh/wm/manager.rb', line 61 def map window return if window.override_redirect? || client_for(window) @clients << client = Client.new(window) @events.emit :manage, args: client @display.listen_events window, Events::PROPERTY_CHANGE_MASK end |
#to_io ⇒ Object
21 22 23 |
# File 'lib/uh/wm/manager.rb', line 21 def to_io IO.new(@display.fileno) end |
#unmap(window) ⇒ Object
68 69 70 71 72 73 74 75 |
# File 'lib/uh/wm/manager.rb', line 68 def unmap window return unless client = client_for(window) if client.unmap_count > 0 client.unmap_count -= 1 else unmanage client end end |
#update_properties(window) ⇒ Object
82 83 84 85 86 |
# File 'lib/uh/wm/manager.rb', line 82 def update_properties window return unless client = client_for(window) client.update_window_properties @events.emit :change, args: client end |