Setup basic layout system
- add Enter event bindings - Add some more window bindings.
This commit is contained in:
+44
-3
@@ -4,6 +4,9 @@ type wm_state = {
|
||||
mrb : Mruby.Types.Mrb_state.mrb_ptr;
|
||||
root : Xcb.Types.Window.t;
|
||||
mutable focus : Xcb.Types.Window.t;
|
||||
workspaces : Kutu.Layout.workspace array;
|
||||
mutable current : int;
|
||||
screen : Kutu.Layout.rect;
|
||||
}
|
||||
|
||||
let () =
|
||||
@@ -11,12 +14,27 @@ let () =
|
||||
let conn = Xcb.Connection.connect () in
|
||||
let mrb = Mruby.Core.mrb_open in
|
||||
let root = Xcb.Utils.get_root conn in
|
||||
{ running = true; conn; mrb; root; focus = root }
|
||||
let _ = Xcb.Window.setup conn root in
|
||||
{
|
||||
running = true;
|
||||
conn;
|
||||
mrb;
|
||||
root;
|
||||
focus = root;
|
||||
workspaces = [| { ws_root = Kutu.Layout.Nothing; ws_fwindows = [||] } |];
|
||||
current = 0;
|
||||
screen =
|
||||
{
|
||||
Kutu.Layout.rect_x = 100;
|
||||
Kutu.Layout.rect_y = 100;
|
||||
Kutu.Layout.rect_width = 100;
|
||||
Kutu.Layout.rect_height = 100;
|
||||
};
|
||||
}
|
||||
in
|
||||
|
||||
print_endline "Started Kutu WM";
|
||||
|
||||
Xcb.Window.setup state.conn state.root;
|
||||
Xcb.Window.keybind state.conn state.root 0 24;
|
||||
Xcb.Window.keybind state.conn state.root 0 25;
|
||||
Xcb.Window.keybind state.conn state.root 0 26;
|
||||
@@ -43,7 +61,30 @@ let () =
|
||||
let req = Xcb.Types.Events.Map_request.from ev in
|
||||
let window = Xcb.Types.Events.Map_request.window req in
|
||||
state.focus <- window;
|
||||
Xcb.Window.map state.conn window
|
||||
state.workspaces.(state.current).ws_root <-
|
||||
Kutu.Layout.insert Kutu.Layout.Horizontal window
|
||||
state.workspaces.(state.current).ws_root;
|
||||
Xcb.Window.map state.conn window;
|
||||
Xcb.Window.setup_window state.conn window;
|
||||
Xcb.Window.focus state.conn window;
|
||||
List.iter
|
||||
(fun {
|
||||
Kutu.Layout.fw_window = window;
|
||||
fw_rect =
|
||||
{
|
||||
rect_x = x;
|
||||
rect_y = y;
|
||||
rect_width = width;
|
||||
rect_height = height;
|
||||
};
|
||||
} -> Xcb.Window.reshape state.conn window x y width height)
|
||||
(Kutu.Layout.calculate state.screen
|
||||
state.workspaces.(state.current).ws_root)
|
||||
| Enter ->
|
||||
let req = Xcb.Types.Events.Enter.from ev in
|
||||
let window = Xcb.Types.Events.Enter.window req in
|
||||
state.focus <- window;
|
||||
Xcb.Window.focus state.conn window
|
||||
| _ -> ());
|
||||
Xcb.Utils.free ev);
|
||||
Mruby.Core.error_check state.mrb;
|
||||
|
||||
Reference in New Issue
Block a user