mirror of https://github.com/k0kubun/xremap
Implement key press handler
parent
fc993cee6e
commit
cc4730f517
@ -0,0 +1,25 @@
|
||||
module Xkremap
|
||||
class ActiveWindow
|
||||
# @param [Fixnum] current_window
|
||||
attr_reader :current_window
|
||||
|
||||
# @param [Xkremap::Display] display
|
||||
def initialize(display)
|
||||
@display = display
|
||||
@current_window = fetch_active_window
|
||||
end
|
||||
|
||||
def changed?
|
||||
next_window = fetch_active_window
|
||||
@current_window != next_window
|
||||
ensure
|
||||
@current_window = next_window
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def fetch_active_window
|
||||
XlibWrapper.fetch_active_window(@display)
|
||||
end
|
||||
end
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
module Xkremap
|
||||
class KeyGrabManager
|
||||
class GrabManager
|
||||
# @param [Xkremap::Display] display
|
||||
def initialize(display)
|
||||
@display = display
|
@ -1,33 +0,0 @@
|
||||
module Xkremap
|
||||
class KeyRemapBuilder
|
||||
# @attribute [Hash] prebuilt
|
||||
# [Fixnum] keycode -> [Fixnum] state -> [Proc] handler
|
||||
attr_reader :prebuilt
|
||||
|
||||
# @param [Xkremap::Config] config
|
||||
# @param [Xkremap::Display] display
|
||||
def initialize(config, display)
|
||||
@config = config
|
||||
@display = display
|
||||
@prebuilt = Hash.new { |h, k| h[k] = {} }
|
||||
@current_window = fetch_active_window
|
||||
end
|
||||
|
||||
def build
|
||||
puts 'rebuilt!'
|
||||
end
|
||||
|
||||
def active_window_changed?
|
||||
next_window = fetch_active_window
|
||||
@current_window != next_window
|
||||
ensure
|
||||
@current_window = next_window
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def fetch_active_window
|
||||
XlibWrapper.fetch_active_window(@display)
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,23 @@
|
||||
module Xkremap
|
||||
class KeyRemapCompiler
|
||||
def initialize(config, display)
|
||||
@config = config
|
||||
@display = display
|
||||
end
|
||||
|
||||
# @return [Hash] : keycode(Fixnum) -> state(Fixnum) -> handler(Proc)
|
||||
def compile
|
||||
result = Hash.new { |h, k| h[k] = {} }
|
||||
result[to_keycode(0x0062)][1<<2] = Proc.new do
|
||||
puts 'C-b pressed!'
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def to_keycode(keysym)
|
||||
XlibWrapper.keysym_to_keycode(@display, keysym)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue