mirror of
https://github.com/vidarh/rubywm.git
synced 2024-11-15 19:48:30 +01:00
Copy changes
This commit is contained in:
parent
84a1eba123
commit
67d0e1465a
2 changed files with 35 additions and 4 deletions
11
README.md
11
README.md
|
@ -1,8 +1,6 @@
|
|||
|
||||
# A Ruby X11 Window Manager
|
||||
|
||||
(Name suggestions welcome)
|
||||
|
||||
**WARNING**:
|
||||
|
||||
This is experimental. It will eat your cat and burn down your house,
|
||||
|
@ -13,7 +11,8 @@ Also it *will* likely crash on you.
|
|||
If you're not comfortable figuring out how to recover from an X session
|
||||
where your window manager is gone and lots of your windows appears to have
|
||||
disappeared ... somewhere, and you might not be able to get focus to a
|
||||
terminal window, this is not yet for you.
|
||||
terminal window without switching to the text console, this is not yet
|
||||
for you.
|
||||
|
||||
## So why should I run this?
|
||||
|
||||
|
@ -29,13 +28,17 @@ there is *no window decoration* and windows are not draggable or
|
|||
resizable by pulling on borders (but you can do that with Windows
|
||||
key + left/right mouse button)
|
||||
|
||||
Like bspwm, which was an inspiration, supports *no* keyboard
|
||||
Like bspwm, which was an inspiration, the wm supports *no* keyboard
|
||||
handling - all keyboard handling is deferred to separate tools like
|
||||
sxhkd. Unlike bspwm this WM has no dedicated IPC mechanism. Instead,
|
||||
so far, all communication happens via X11 ClientMessage events, which
|
||||
means any tool, like xdotool etc. that can produce those events can
|
||||
control the WM.
|
||||
|
||||
It currently does *not* do anything to facilitate working on multiple
|
||||
monitors, as in my current setup I'm only using a single monitor for
|
||||
my Linux machine.
|
||||
|
||||
## Why did you write this?
|
||||
|
||||
It started with mild frustration that bspwm handled my desire for one of
|
||||
|
|
28
type_dispatcher.rb
Normal file
28
type_dispatcher.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
class TypeDispatcher
|
||||
def initialize(target)
|
||||
@target = target
|
||||
@on = {}
|
||||
end
|
||||
|
||||
def name_to_event(ob)
|
||||
name = ob.to_s.split("::").last.split(/([A-Z][a-z]+)/).join("_").downcase
|
||||
"on_#{name}".gsub(/__+/,"_").to_sym
|
||||
end
|
||||
|
||||
def on(event, &block)
|
||||
@on[name_to_event(event)] = block
|
||||
end
|
||||
|
||||
def call(ob, *args)
|
||||
sym = name_to_event(ob)
|
||||
|
||||
if @on[sym]
|
||||
@on[sym].(*args)
|
||||
elsif @target.respond_to?(sym)
|
||||
arity = @target.method(sym).arity
|
||||
@target.send(sym, *args[0...arity])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in a new issue