2024-01-03 06:12:18 +01:00
|
|
|
|
2024-01-21 01:06:50 +01:00
|
|
|
# (C) 2024 Vidar Hokstad <vidar@hokstad.com>
|
|
|
|
# Licensed under the MIT license.
|
|
|
|
#
|
2024-01-03 06:12:18 +01:00
|
|
|
# Based on TinyWM by Nick Welch
|
|
|
|
# Lots of inspiration from Katriawm
|
|
|
|
# https://www.uninformativ.de/git/katriawm/files.html
|
|
|
|
#
|
|
|
|
|
2024-01-21 22:35:29 +01:00
|
|
|
require 'bundler/setup'
|
2024-01-03 06:12:18 +01:00
|
|
|
require 'X11'
|
|
|
|
require 'set'
|
|
|
|
|
|
|
|
require_relative 'window.rb'
|
|
|
|
require_relative 'wm.rb'
|
|
|
|
require_relative 'desktop.rb'
|
|
|
|
require_relative 'tiled.rb'
|
2024-01-21 01:06:50 +01:00
|
|
|
require_relative 'type_dispatcher'
|
|
|
|
require_relative 'geom.rb'
|
|
|
|
require_relative 'leaf.rb'
|
|
|
|
require_relative 'node.rb'
|
2024-01-03 06:12:18 +01:00
|
|
|
|
2024-01-13 19:55:59 +01:00
|
|
|
Thread.abort_on_exception = true
|
|
|
|
|
2024-01-03 06:12:18 +01:00
|
|
|
dpy = X11::Display.new
|
2024-01-21 01:06:50 +01:00
|
|
|
$wm = WindowManager.new(dpy, num_desktops: 10)
|
2024-01-03 06:12:18 +01:00
|
|
|
|
2024-01-19 21:12:47 +01:00
|
|
|
# FIXME: This can also go into the WindowManager class
|
|
|
|
|
2024-01-21 01:06:50 +01:00
|
|
|
d = Dispatcher.new($wm)
|
2024-01-03 06:12:18 +01:00
|
|
|
d.on(:client_message) do |ev|
|
|
|
|
data = ev.data.unpack("V*")
|
|
|
|
name = dpy.get_atom_name(ev.type)
|
|
|
|
d.(name, ev.window, *data)
|
|
|
|
end
|
|
|
|
|
|
|
|
loop do
|
|
|
|
ev = nil
|
|
|
|
begin
|
|
|
|
ev = dpy.next_packet
|
|
|
|
rescue Interrupt
|
|
|
|
raise
|
|
|
|
rescue Exception => e
|
|
|
|
pp e
|
|
|
|
end
|
|
|
|
|
|
|
|
p ev
|
2024-01-14 22:09:00 +01:00
|
|
|
d.(ev.class, ev)
|
2024-01-03 06:12:18 +01:00
|
|
|
end
|