Cleanup.
This commit is contained in:
@@ -132,6 +132,77 @@ let focus conn window =
|
||||
in
|
||||
Error.check conn cookie
|
||||
|
||||
let _xcb_wm_n_hints =
|
||||
foreign "kutu_wm_n_hints"
|
||||
(ptr Types.Connection.typ @-> Types.Window.typ
|
||||
@-> returning Types.Size_hints.typ)
|
||||
|
||||
let has_flag flags flag =
|
||||
Unsigned.UInt32.logand flags (Unsigned.UInt32.of_int flag)
|
||||
<> Unsigned.UInt32.zero
|
||||
|
||||
let p_size = 1 lsl 3
|
||||
let p_min_size = 1 lsl 4
|
||||
let p_max_size = 1 lsl 5
|
||||
let p_resize_inc = 1 lsl 6
|
||||
let p_aspect = 1 lsl 7
|
||||
|
||||
let make_window conn window =
|
||||
let hints = _xcb_wm_n_hints conn window in
|
||||
let flags = getf hints Types.Size_hints.flags in
|
||||
let has_min = has_flag flags p_min_size in
|
||||
let has_size = has_flag flags p_size in
|
||||
let has_max = has_flag flags p_max_size in
|
||||
let has_aspect = has_flag flags p_aspect in
|
||||
let size =
|
||||
if has_size then
|
||||
Some
|
||||
(getf hints Types.Size_hints.width, getf hints Types.Size_hints.height)
|
||||
else None
|
||||
in
|
||||
let min =
|
||||
if has_min then
|
||||
Some
|
||||
( getf hints Types.Size_hints.min_width,
|
||||
getf hints Types.Size_hints.min_height )
|
||||
else None
|
||||
in
|
||||
let max =
|
||||
if has_max then
|
||||
Some
|
||||
( getf hints Types.Size_hints.max_width,
|
||||
getf hints Types.Size_hints.max_height )
|
||||
else None
|
||||
in
|
||||
let fixed_size =
|
||||
match (size, min, max) with
|
||||
| Some size, _, _ -> Some size
|
||||
| _, Some min, _ -> Some min
|
||||
| _, _, Some max -> Some max
|
||||
| _ -> None
|
||||
in
|
||||
let fixed_aspect =
|
||||
if has_aspect then
|
||||
let min_num = getf hints Types.Size_hints.min_aspect_num in
|
||||
let min_den = getf hints Types.Size_hints.min_aspect_den in
|
||||
let max_num = getf hints Types.Size_hints.max_aspect_num in
|
||||
let max_den = getf hints Types.Size_hints.max_aspect_den in
|
||||
if min_den <> Int32.zero then
|
||||
Some
|
||||
( Int32.div (Int32.mul (Int32.of_int 100) min_num) min_den,
|
||||
Int32.of_int 100 )
|
||||
else if max_den <> Int32.zero then
|
||||
Some
|
||||
( Int32.div (Int32.mul (Int32.of_int 100) max_num) max_den,
|
||||
Int32.of_int 100 )
|
||||
else None
|
||||
else None
|
||||
in
|
||||
match (fixed_size, fixed_aspect) with
|
||||
| Some (x, y), _ -> Some (x, y)
|
||||
| _, Some (x, y) -> Some (x, y)
|
||||
| _ -> None
|
||||
|
||||
let _xcb_kill_client =
|
||||
foreign "xcb_kill_client"
|
||||
(ptr Types.Connection.typ @-> Types.Window.typ
|
||||
|
||||
Reference in New Issue
Block a user