91 lines
3.1 KiB
Ruby
91 lines
3.1 KiB
Ruby
require "ffi"
|
|
|
|
module X
|
|
extend FFI::Library
|
|
ffi_lib File.join(__dir__, "X-kutu.so")
|
|
|
|
typedef :uint32, :xcb_window_t
|
|
typedef :uint32, :xcb_pixmap_t
|
|
|
|
class Geometry < FFI::Struct
|
|
layout :x, :int16,
|
|
:y, :int16,
|
|
:width, :uint16,
|
|
:height, :uint16
|
|
end
|
|
|
|
class Event < FFI::Struct
|
|
layout :type, :int32,
|
|
:window, :xcb_window_t,
|
|
:override_redirect, :int8,
|
|
:btn, :uint32,
|
|
:x, :int32,
|
|
:y, :int32,
|
|
:height, :uint32,
|
|
:width, :uint32,
|
|
:state, :uint32,
|
|
:is_root, :int8
|
|
end
|
|
|
|
class SizeHints < FFI::Struct
|
|
layout :flags, :uint32,
|
|
:x, :int32,
|
|
:y, :int32,
|
|
:width, :int32,
|
|
:height, :int32,
|
|
:min_width, :int32,
|
|
:min_height, :int32,
|
|
:max_width, :int32,
|
|
:max_height, :int32,
|
|
:width_inc, :int32,
|
|
:height_inc, :int32,
|
|
:min_aspect_num, :int32,
|
|
:min_aspect_den, :int32,
|
|
:max_aspect_num, :int32,
|
|
:max_aspect_den, :int32,
|
|
:base_width, :int32,
|
|
:base_height, :int32,
|
|
:win_gravity, :uint32
|
|
end
|
|
|
|
class WMHints < FFI::Struct
|
|
layout :flags, :int32,
|
|
:input, :uint32,
|
|
:initial_state,:int32,
|
|
:icon_pixmap, :xcb_pixmap_t,
|
|
:icon_window, :xcb_window_t,
|
|
:icon_x, :int32,
|
|
:icon_y, :int32,
|
|
:icon_mask, :xcb_pixmap_t,
|
|
:window_group, :xcb_window_t
|
|
end
|
|
|
|
attach_function :deploy, [], :int
|
|
attach_function :add_keybind, [:int], :void
|
|
attach_function :add_mousebind, [:int], :void
|
|
attach_function :cleanup, [], :void
|
|
attach_function :focus, [:xcb_window_t], :void
|
|
attach_function :get_focus, [], :xcb_window_t
|
|
attach_function :subscribe, [:xcb_window_t], :void
|
|
attach_function :kill, [:xcb_window_t], :void
|
|
attach_function :show, [:xcb_window_t], :void
|
|
attach_function :hide, [:xcb_window_t], :void
|
|
attach_function :send_to_top, [:xcb_window_t], :void
|
|
attach_function :free_geometry, [:pointer], :void
|
|
attach_function :get_geometry, [:xcb_window_t], Geometry.by_value
|
|
attach_function :get_pointer, [], Geometry.by_value
|
|
attach_function :get_screen, [], Geometry.by_value
|
|
attach_function :warp_pointer, [:xcb_window_t, :int, :int], :void
|
|
attach_function :move_window, [:xcb_window_t, :int, :int], :void
|
|
attach_function :resize_window, [:xcb_window_t, :int, :int], :void
|
|
attach_function :wait_for_event, [], Event.by_value
|
|
attach_function :get_wm_name, [:xcb_window_t], :string
|
|
attach_function :get_wm_n_hints, [:xcb_window_t], SizeHints.by_value
|
|
attach_function :get_wm_hints, [:xcb_window_t], WMHints.by_value
|
|
attach_function :get_wm_transient_for, [:xcb_window_t], :uint8
|
|
attach_function :set_wm_state, [:xcb_window_t, :int], :void
|
|
attach_function :draw_rectangle, [:int, :int, :int, :int, :uint32], :xcb_window_t
|
|
attach_function :grab_pointer, [:xcb_window_t], :void
|
|
attach_function :ungrab_pointer, [], :void
|
|
end
|