package oxbow

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file scratchpad.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
open! Oxbow_state

let set wm seat target name =
  Result.map (fun _ -> None)
  @@ Targets.transact_all_windows wm seat target ~plan:(fun w ->
    Ok (fun () -> Window.set_scratchpad w name))
;;

let clear wm seat target =
  Result.map (fun _ -> None)
  @@ Targets.transact_all_windows wm seat target ~plan:(fun w ->
    Ok
      (fun () ->
        Window.set_scratchpad w None;
        Window.set_stashed w false))
;;

let toggle (wm : Wm.t) (seat : Seat.t) name =
  let members =
    List.filter (fun (w : Window.t) -> w.scratchpad.name = Some name) wm.windows
  in
  let shown = List.exists Window.tag_visible members in
  With.focused_output seat
  @@ fun o ->
  match members with
  | [] -> Error (Printf.sprintf "no scratchpad named %S" name)
  | _ when shown ->
    List.iter (fun w -> Window.set_stashed w true) members;
    Schedule.manage ();
    Ok None
  | head :: _ ->
    List.iter
      (fun w ->
         Window.set_stashed w false;
         Placement.move_window w o;
         Window.set_tags w o.tags.selected;
         Window.float w)
      members;
    Focus.focus_window wm seat head;
    Schedule.manage ();
    Ok None
;;