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 direction = Horizontal | Vertical
|
||||||
type rect = { rect_x : int; rect_y : int; rect_width : int; rect_height : int }
|
|
||||||
|
|
||||||
type layout =
|
type layout =
|
||||||
| Nothing
|
| Nothing
|
||||||
@@ -11,7 +10,7 @@ type layout =
|
|||||||
layout_r : 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 }
|
type workspace = { mutable ws_root : layout; ws_fwindows : fwindow array }
|
||||||
|
|
||||||
let flip_direction = function Horizontal -> Vertical | Vertical -> Horizontal
|
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;
|
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
|
match direction with
|
||||||
| Horizontal ->
|
| Horizontal ->
|
||||||
let left_width = int_of_float (float rect.rect_width *. ratio) in
|
let left_width = int_of_float (float rect.rect_width *. ratio) in
|
||||||
let right_width = rect.rect_width - left_width in
|
let right_width = rect.rect_width - left_width in
|
||||||
let left =
|
let left =
|
||||||
{
|
{
|
||||||
rect_x = rect.rect_x;
|
Decl.Types.rect_x = rect.rect_x;
|
||||||
rect_y = rect.rect_y;
|
Decl.Types.rect_y = rect.rect_y;
|
||||||
rect_width = left_width;
|
Decl.Types.rect_width = left_width;
|
||||||
rect_height = rect.rect_height;
|
Decl.Types.rect_height = rect.rect_height;
|
||||||
}
|
}
|
||||||
in
|
in
|
||||||
let right =
|
let right =
|
||||||
{
|
{
|
||||||
rect_x = rect.rect_x + left_width;
|
Decl.Types.rect_x = rect.rect_x + left_width;
|
||||||
rect_y = rect.rect_y;
|
Decl.Types.rect_y = rect.rect_y;
|
||||||
rect_width = right_width;
|
Decl.Types.rect_width = right_width;
|
||||||
rect_height = rect.rect_height;
|
Decl.Types.rect_height = rect.rect_height;
|
||||||
}
|
}
|
||||||
in
|
in
|
||||||
(left, right)
|
(left, right)
|
||||||
@@ -62,18 +61,18 @@ let split_rect rect direction ratio =
|
|||||||
let bottom_height = rect.rect_height - top_height in
|
let bottom_height = rect.rect_height - top_height in
|
||||||
let top =
|
let top =
|
||||||
{
|
{
|
||||||
rect_x = rect.rect_x;
|
Decl.Types.rect_x = rect.rect_x;
|
||||||
rect_y = rect.rect_y;
|
Decl.Types.rect_y = rect.rect_y;
|
||||||
rect_width = rect.rect_width;
|
Decl.Types.rect_width = rect.rect_width;
|
||||||
rect_height = top_height;
|
Decl.Types.rect_height = top_height;
|
||||||
}
|
}
|
||||||
in
|
in
|
||||||
let bottom =
|
let bottom =
|
||||||
{
|
{
|
||||||
rect_x = rect.rect_x;
|
Decl.Types.rect_x = rect.rect_x;
|
||||||
rect_y = rect.rect_y + top_height;
|
Decl.Types.rect_y = rect.rect_y + top_height;
|
||||||
rect_width = rect.rect_width;
|
Decl.Types.rect_width = rect.rect_width;
|
||||||
rect_height = bottom_height;
|
Decl.Types.rect_height = bottom_height;
|
||||||
}
|
}
|
||||||
in
|
in
|
||||||
(top, bottom)
|
(top, bottom)
|
||||||
|
|||||||
+11
-11
@@ -6,7 +6,7 @@ type wm_state = {
|
|||||||
mutable focus : Xcb.Types.Window.t;
|
mutable focus : Xcb.Types.Window.t;
|
||||||
workspaces : Kutu.Layout.workspace array;
|
workspaces : Kutu.Layout.workspace array;
|
||||||
mutable current : int;
|
mutable current : int;
|
||||||
screen : Kutu.Layout.rect;
|
screen : Decl.Types.rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
@@ -14,22 +14,22 @@ let () =
|
|||||||
let conn = Xcb.Connection.connect () in
|
let conn = Xcb.Connection.connect () in
|
||||||
let mrb = Mruby.Core.mrb_open in
|
let mrb = Mruby.Core.mrb_open in
|
||||||
let root = Xcb.Utils.get_root conn 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;
|
running = true;
|
||||||
conn;
|
conn;
|
||||||
mrb;
|
mrb;
|
||||||
root;
|
root;
|
||||||
focus = root;
|
focus = root;
|
||||||
workspaces = [| { ws_root = Kutu.Layout.Nothing; ws_fwindows = [||] } |];
|
workspaces =
|
||||||
current = 0;
|
[|
|
||||||
screen =
|
|
||||||
{
|
{
|
||||||
Kutu.Layout.rect_x = 100;
|
Kutu.Layout.ws_root = Kutu.Layout.Nothing;
|
||||||
Kutu.Layout.rect_y = 100;
|
Kutu.Layout.ws_fwindows = [||];
|
||||||
Kutu.Layout.rect_width = 100;
|
|
||||||
Kutu.Layout.rect_height = 100;
|
|
||||||
};
|
};
|
||||||
|
|];
|
||||||
|
current = 0;
|
||||||
|
screen;
|
||||||
}
|
}
|
||||||
in
|
in
|
||||||
|
|
||||||
@@ -61,9 +61,9 @@ let () =
|
|||||||
let req = Xcb.Types.Events.Map_request.from ev in
|
let req = Xcb.Types.Events.Map_request.from ev in
|
||||||
let window = Xcb.Types.Events.Map_request.window req in
|
let window = Xcb.Types.Events.Map_request.window req in
|
||||||
state.focus <- window;
|
state.focus <- window;
|
||||||
state.workspaces.(state.current).ws_root <-
|
(*Kutu.Layout.ws_root state.workspaces.(state.current)) <-
|
||||||
Kutu.Layout.insert Kutu.Layout.Horizontal window
|
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.map state.conn window;
|
||||||
Xcb.Window.setup_window state.conn window;
|
Xcb.Window.setup_window state.conn window;
|
||||||
Xcb.Window.focus state.conn window;
|
Xcb.Window.focus state.conn window;
|
||||||
|
|||||||
@@ -9,4 +9,11 @@ let _xcb_get =
|
|||||||
foreign "xcb_setup_roots_iterator"
|
foreign "xcb_setup_roots_iterator"
|
||||||
(ptr Types.Setup.typ @-> returning Types.Screen_iterator.typ)
|
(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 allowed_depths_len = field typ "allowed_depths_len" uint8_t
|
||||||
let () = seal typ
|
let () = seal typ
|
||||||
let root ptr = getf ptr root
|
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
|
end
|
||||||
|
|
||||||
module Setup = struct
|
module Setup = struct
|
||||||
|
|||||||
Reference in New Issue
Block a user