package oxbow

  1. Overview
  2. Docs
Dynamic window manager for the river Wayland compositor

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v0.1.0.tar.gz
md5=a637acaa0e19046cd65fff733874eb97
sha512=76230cbecd7510de7a05b5d1f335915ef7b6c4aa557d8dbfd23591606618d2cfa25082d17b93f2f4b53a118d1cbf6a80e4ad51cf0f099b4921fb83d6df0c9801

doc/src/oxbow.runtime/lifecycle.ml.html

Source file lifecycle.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
open! Oxbow_state

let request_exit ?(origin = `Local) (wm : Wm.t) =
  match wm.lifecycle with
  | Running ->
    Wm.set_lifecycle wm @@ Pending_exit origin;
    Schedule.manage ()
  | Pending_exit _ | Exited | Close_requested ->
    Log.warn
    @@ fun m ->
    m
      "ignoring exit request for non-running state: %s"
      (Wm.Lifecycle.to_string wm.lifecycle)
;;

let stop ~on_ignored (wm : Wm.t) =
  match wm.lifecycle with
  | Running ->
    List.iter Seat.clear_pending wm.seats;
    Wm.set_lifecycle wm Close_requested;
    Eio.Condition.broadcast wm.shutdown
  | Pending_exit _ | Exited | Close_requested -> on_ignored ()
;;

let request_close (wm : Wm.t) =
  stop wm ~on_ignored:(fun () ->
    Log.warn
    @@ fun m ->
    m
      "ignoring close request for non-running state: %s"
      (Wm.Lifecycle.to_string wm.lifecycle))
;;

let dispatch_pending (wm : Wm.t) =
  match wm.lifecycle with
  | Pending_exit _ ->
    List.iter Seat.clear_pending wm.seats;
    Wm.set_lifecycle wm Exited;
    Emit.exit_session wm.river_wm_v1;
    Eio.Condition.broadcast wm.shutdown
  | Running | Exited | Close_requested ->
    Log.err
    @@ fun m ->
    m
      "got dispatch_pending request for unhandled state: %s"
      (Wm.Lifecycle.to_string wm.lifecycle)
;;

let notify_finished (wm : Wm.t) =
  stop wm ~on_ignored:(fun () ->
    Log.err
    @@ fun m ->
    m "got notify_finished for unhandled state: %s" (Wm.Lifecycle.to_string wm.lifecycle))
;;

let await_shutdown (wm : Wm.t) =
  Eio.Condition.loop_no_mutex wm.shutdown
  @@ fun () ->
  match wm.lifecycle with
  | Exited | Close_requested -> Some ()
  | Running | Pending_exit _ -> None
;;

let teardown ~clock (wm : Wm.t) =
  Option.iter Init_script.shutdown wm.init_handle;
  match wm.lifecycle with
  | Exited ->
    (try
       Eio.Time.with_timeout_exn clock 1.0 (fun () ->
         let rec wait () =
           if Wayland.Proxy.transport_up wm.river_wm_v1
           then (
             Eio.Time.sleep clock 0.05;
             wait ())
         in
         wait ())
     with
     | Eio.Time.Timeout ->
       Log.warn @@ fun m -> m "teardown: river did not close after exit_session within 1s")
  | Close_requested -> ()
  | Running | Pending_exit _ ->
    Log.err
    @@ fun m ->
    m "teardown triggered in unexpected state: %s" (Wm.Lifecycle.to_string wm.lifecycle)
;;