diff options
author | Thomas Letan <lthms@soap.coffee> | 2022-09-10 14:56:20 +0200 |
---|---|---|
committer | Thomas Letan <lthms@soap.coffee> | 2022-09-10 14:56:20 +0200 |
commit | 310f4cffa3be782e76329541fbea64daa876092e (patch) | |
tree | 42b5c4ba12165ee36d1776e5f37a777926924233 | |
parent | Allow to take window’s name into account to assign an icon (diff) |
Handle window’s renaming
-rw-r--r-- | bin/spatial/main.ml | 7 | ||||
-rw-r--r-- | bin/spatial/state.ml | 16 | ||||
-rw-r--r-- | bin/spatial/windows_registry.ml | 1 |
3 files changed, 22 insertions, 2 deletions
diff --git a/bin/spatial/main.ml b/bin/spatial/main.ml index 20e055c..3a3a136 100644 --- a/bin/spatial/main.ml +++ b/bin/spatial/main.ml @@ -22,8 +22,11 @@ let window_handle (ev : Event.window_event) state = | Event.Close -> let state = State.unregister_window state ev.container.id in (state, true, None) - | Event.Focus | Event.Title | Event.Fullscreen_mode | Event.Move | Event.Mark - | Event.Urgent -> + | Event.Title -> + let state = State.record_window_title_change state ev.container in + (state, false, None) + | Event.Focus | Event.Fullscreen_mode | Event.Move | Event.Mark | Event.Urgent + -> (state, false, None) | Event.Floating -> ( match ev.container.node_type with diff --git a/bin/spatial/state.ml b/bin/spatial/state.ml index 0bbc849..71d2427 100644 --- a/bin/spatial/state.ml +++ b/bin/spatial/state.ml @@ -109,6 +109,22 @@ let register_window default_full_view default_maximum_visible workspace state } | _ -> state +let record_window_title_change state (node : Node.t) = + { + state with + windows = + Windows_registry.update node.id + (function + | Some info -> + Some + { + info with + Spatial_ipc.name = Option.value ~default:"" node.name; + } + | None -> None) + state.windows; + } + let unregister_window state window = match Windows_registry.find_opt window state.windows with | Some info -> diff --git a/bin/spatial/windows_registry.ml b/bin/spatial/windows_registry.ml index 13ae3e1..7c9ecf2 100644 --- a/bin/spatial/windows_registry.ml +++ b/bin/spatial/windows_registry.ml @@ -8,6 +8,7 @@ let register : int64 -> window_info -> t -> t = Map.add let unregister = Map.remove let find = Map.find let find_opt = Map.find_opt +let update = Map.update let pp_window fmt (id, { app_id; name; workspace }) = Format.fprintf fmt "{ id = %Ld; app_id = %s; name = %s; workspace = %s }" id |