diff --git a/repos/gems/src/lib/vfs/ttf/glyphs_file_system.h b/repos/gems/src/lib/vfs/ttf/glyphs_file_system.h index 7e0ace54ff..ed1fb10395 100644 --- a/repos/gems/src/lib/vfs/ttf/glyphs_file_system.h +++ b/repos/gems/src/lib/vfs/ttf/glyphs_file_system.h @@ -109,6 +109,11 @@ class Vfs::Glyphs_file_system : public Vfs::Single_file_system bool read_ready() override { return true; } }; + typedef Registered Registered_watch_handle; + typedef Registry Watch_handle_registry; + + Watch_handle_registry _handle_registry { }; + public: Glyphs_file_system(Font const &font) @@ -123,6 +128,16 @@ class Vfs::Glyphs_file_system : public Vfs::Single_file_system char const *type() override { return type_name(); } + /** + * Propagate font change to watch handlers + */ + void trigger_watch_response() + { + _handle_registry.for_each([this] (Registered_watch_handle &handle) { + handle.watch_response(); }); + } + + /********************************* ** Directory-service interface ** *********************************/ @@ -139,8 +154,8 @@ class Vfs::Glyphs_file_system : public Vfs::Single_file_system Vfs_handle(*this, *this, alloc, _font); return OPEN_OK; } - catch (Genode::Out_of_ram) { return OPEN_ERR_OUT_OF_RAM; } - catch (Genode::Out_of_caps) { return OPEN_ERR_OUT_OF_CAPS; } + catch (Out_of_ram) { return OPEN_ERR_OUT_OF_RAM; } + catch (Out_of_caps) { return OPEN_ERR_OUT_OF_CAPS; } } Stat_result stat(char const *path, Stat &out) override @@ -149,6 +164,29 @@ class Vfs::Glyphs_file_system : public Vfs::Single_file_system out.size = FILE_SIZE; return result; } + + Watch_result watch(char const *path, + Vfs_watch_handle **handle, + Allocator &alloc) override + { + if (!_single_file(path)) + return WATCH_ERR_UNACCESSIBLE; + + try { + *handle = new (alloc) + Registered_watch_handle(_handle_registry, *this, alloc); + + return WATCH_OK; + } + catch (Out_of_ram) { return WATCH_ERR_OUT_OF_RAM; } + catch (Out_of_caps) { return WATCH_ERR_OUT_OF_CAPS; } + } + + void close(Vfs_watch_handle *handle) override + { + destroy(handle->alloc(), + static_cast(handle)); + } }; #endif /* _GLYPHS_FILE_SYSTEM_H_ */ diff --git a/repos/gems/src/lib/vfs/ttf/vfs.cc b/repos/gems/src/lib/vfs/ttf/vfs.cc index 8913eac71a..5fddaa0ee8 100644 --- a/repos/gems/src/lib/vfs/ttf/vfs.cc +++ b/repos/gems/src/lib/vfs/ttf/vfs.cc @@ -127,6 +127,7 @@ struct Vfs_ttf::Local_factory : File_system_factory { _font.construct(_env, config); _update_attributes(); + _glyphs_fs.trigger_watch_response(); } };