mirror of
https://github.com/vidarh/rubywm.git
synced 2024-11-15 19:48:30 +01:00
Cleanups
This commit is contained in:
parent
67d0e1465a
commit
2cb2f4ac19
2 changed files with 22 additions and 6 deletions
13
rubywm.rb
13
rubywm.rb
|
@ -1,4 +1,7 @@
|
|||
|
||||
# (C) 2024 Vidar Hokstad <vidar@hokstad.com>
|
||||
# Licensed under the MIT license.
|
||||
#
|
||||
# Based on TinyWM by Nick Welch
|
||||
# Lots of inspiration from Katriawm
|
||||
# https://www.uninformativ.de/git/katriawm/files.html
|
||||
|
@ -11,20 +14,22 @@ require_relative 'window.rb'
|
|||
require_relative 'wm.rb'
|
||||
require_relative 'desktop.rb'
|
||||
require_relative 'tiled.rb'
|
||||
require_relative '../type_dispatcher'
|
||||
require_relative 'type_dispatcher'
|
||||
require_relative 'geom.rb'
|
||||
require_relative 'leaf.rb'
|
||||
require_relative 'node.rb'
|
||||
|
||||
Thread.abort_on_exception = true
|
||||
|
||||
dpy = X11::Display.new
|
||||
wm = WindowManager.new(dpy, num_desktops: 10)
|
||||
$wm = WindowManager.new(dpy, num_desktops: 10)
|
||||
|
||||
# FIXME: This can also go into the WindowManager class
|
||||
|
||||
d = TypeDispatcher.new(wm)
|
||||
d = Dispatcher.new($wm)
|
||||
d.on(:client_message) do |ev|
|
||||
data = ev.data.unpack("V*")
|
||||
name = dpy.get_atom_name(ev.type)
|
||||
p [name, data, ev]
|
||||
d.(name, ev.window, *data)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
class TypeDispatcher
|
||||
def initialize(target)
|
||||
# # Dispatcher
|
||||
#
|
||||
# Dispatch `call(method, *args)` to `@target.on_<name>(*args)` or `@on[method].call(*args)`
|
||||
# where <name> is a cleaned up string representation of method, so that:
|
||||
#
|
||||
# dispatch.(X11::Form::MotionNotify, arg1, arg2)
|
||||
#
|
||||
# Becomes:
|
||||
#
|
||||
# @target.on_motion_notify(arg1, arg2)
|
||||
#
|
||||
class Dispatcher
|
||||
def initialize(target=nil)
|
||||
@target = target
|
||||
@on = {}
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue