Minor updates, breaking.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
type rect = { rect_x : int; rect_y : int; rect_width : int; rect_height : int }
|
||||
+18
-19
@@ -1,5 +1,4 @@
|
||||
type direction = Horizontal | Vertical
|
||||
type rect = { rect_x : int; rect_y : int; rect_width : int; rect_height : int }
|
||||
|
||||
type layout =
|
||||
| Nothing
|
||||
@@ -11,7 +10,7 @@ type layout =
|
||||
layout_r : layout;
|
||||
}
|
||||
|
||||
type fwindow = { fw_rect : rect; fw_window : Xcb.Types.Window.t }
|
||||
type fwindow = { fw_rect : Decl.Types.rect; fw_window : Xcb.Types.Window.t }
|
||||
type workspace = { mutable ws_root : layout; ws_fwindows : fwindow array }
|
||||
|
||||
let flip_direction = function Horizontal -> Vertical | Vertical -> Horizontal
|
||||
@@ -35,25 +34,25 @@ let rec insert direction window = function
|
||||
layout_r = insert (flip_direction layout_direction) window layout_r;
|
||||
}
|
||||
|
||||
let split_rect rect direction ratio =
|
||||
let split_rect (rect : Decl.Types.rect) direction ratio =
|
||||
match direction with
|
||||
| Horizontal ->
|
||||
let left_width = int_of_float (float rect.rect_width *. ratio) in
|
||||
let right_width = rect.rect_width - left_width in
|
||||
let left =
|
||||
{
|
||||
rect_x = rect.rect_x;
|
||||
rect_y = rect.rect_y;
|
||||
rect_width = left_width;
|
||||
rect_height = rect.rect_height;
|
||||
Decl.Types.rect_x = rect.rect_x;
|
||||
Decl.Types.rect_y = rect.rect_y;
|
||||
Decl.Types.rect_width = left_width;
|
||||
Decl.Types.rect_height = rect.rect_height;
|
||||
}
|
||||
in
|
||||
let right =
|
||||
{
|
||||
rect_x = rect.rect_x + left_width;
|
||||
rect_y = rect.rect_y;
|
||||
rect_width = right_width;
|
||||
rect_height = rect.rect_height;
|
||||
Decl.Types.rect_x = rect.rect_x + left_width;
|
||||
Decl.Types.rect_y = rect.rect_y;
|
||||
Decl.Types.rect_width = right_width;
|
||||
Decl.Types.rect_height = rect.rect_height;
|
||||
}
|
||||
in
|
||||
(left, right)
|
||||
@@ -62,18 +61,18 @@ let split_rect rect direction ratio =
|
||||
let bottom_height = rect.rect_height - top_height in
|
||||
let top =
|
||||
{
|
||||
rect_x = rect.rect_x;
|
||||
rect_y = rect.rect_y;
|
||||
rect_width = rect.rect_width;
|
||||
rect_height = top_height;
|
||||
Decl.Types.rect_x = rect.rect_x;
|
||||
Decl.Types.rect_y = rect.rect_y;
|
||||
Decl.Types.rect_width = rect.rect_width;
|
||||
Decl.Types.rect_height = top_height;
|
||||
}
|
||||
in
|
||||
let bottom =
|
||||
{
|
||||
rect_x = rect.rect_x;
|
||||
rect_y = rect.rect_y + top_height;
|
||||
rect_width = rect.rect_width;
|
||||
rect_height = bottom_height;
|
||||
Decl.Types.rect_x = rect.rect_x;
|
||||
Decl.Types.rect_y = rect.rect_y + top_height;
|
||||
Decl.Types.rect_width = rect.rect_width;
|
||||
Decl.Types.rect_height = bottom_height;
|
||||
}
|
||||
in
|
||||
(top, bottom)
|
||||
|
||||
+12
-12
@@ -6,7 +6,7 @@ type wm_state = {
|
||||
mutable focus : Xcb.Types.Window.t;
|
||||
workspaces : Kutu.Layout.workspace array;
|
||||
mutable current : int;
|
||||
screen : Kutu.Layout.rect;
|
||||
screen : Decl.Types.rect;
|
||||
}
|
||||
|
||||
let () =
|
||||
@@ -14,22 +14,22 @@ let () =
|
||||
let conn = Xcb.Connection.connect () in
|
||||
let mrb = Mruby.Core.mrb_open in
|
||||
let root = Xcb.Utils.get_root conn in
|
||||
let _ = Xcb.Window.setup conn root in
|
||||
let screen = Xcb.Window.setup conn root in
|
||||
{
|
||||
running = true;
|
||||
conn;
|
||||
mrb;
|
||||
root;
|
||||
focus = root;
|
||||
workspaces = [| { ws_root = Kutu.Layout.Nothing; ws_fwindows = [||] } |];
|
||||
workspaces =
|
||||
[|
|
||||
{
|
||||
Kutu.Layout.ws_root = Kutu.Layout.Nothing;
|
||||
Kutu.Layout.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;
|
||||
};
|
||||
screen;
|
||||
}
|
||||
in
|
||||
|
||||
@@ -61,9 +61,9 @@ let () =
|
||||
let req = Xcb.Types.Events.Map_request.from ev in
|
||||
let window = Xcb.Types.Events.Map_request.window req in
|
||||
state.focus <- window;
|
||||
state.workspaces.(state.current).ws_root <-
|
||||
(*Kutu.Layout.ws_root state.workspaces.(state.current)) <-
|
||||
Kutu.Layout.insert Kutu.Layout.Horizontal window
|
||||
state.workspaces.(state.current).ws_root;
|
||||
(Kutu.Layout.ws_root state.workspaces.(state.current)*)
|
||||
Xcb.Window.map state.conn window;
|
||||
Xcb.Window.setup_window state.conn window;
|
||||
Xcb.Window.focus state.conn window;
|
||||
|
||||
@@ -9,4 +9,11 @@ let _xcb_get =
|
||||
foreign "xcb_setup_roots_iterator"
|
||||
(ptr Types.Setup.typ @-> returning Types.Screen_iterator.typ)
|
||||
|
||||
let screen conn = get conn |> _xcb_get |> Types.Screen_iterator.screen
|
||||
let screen conn =
|
||||
let screen = get conn |> _xcb_get |> Types.Screen_iterator.screen in
|
||||
{
|
||||
Decl.Types.rect_x = 0;
|
||||
Decl.Types.rect_y = 0;
|
||||
Decl.Types.rect_height = Types.Screen.height screen;
|
||||
Decl.Types.rect_width = Types.Screen.width screen;
|
||||
}
|
||||
|
||||
@@ -150,6 +150,8 @@ module Screen = struct
|
||||
let allowed_depths_len = field typ "allowed_depths_len" uint8_t
|
||||
let () = seal typ
|
||||
let root ptr = getf ptr root
|
||||
let width ptr = Unsigned.UInt16.to_int (getf ptr width_in_pixels)
|
||||
let height ptr = Unsigned.UInt16.to_int (getf ptr height_in_pixels)
|
||||
end
|
||||
|
||||
module Setup = struct
|
||||
|
||||
Reference in New Issue
Block a user