fix(image): don't block the main loop with exec in the multiple-image path
MultipleImageStrategy::update() and handleClick() ran util::command::exec (a blocking fork+exec+read) on the GTK main thread, so the whole bar froze for the script's duration on every interval and on every click. Move the exec into a new IStrategy::fetch() hook that the SleeperThread worker runs before dp.emit(); update() now only parses the cached output and draws on the main thread (mirroring how custom.cpp separates exec from formatting). handleClick() uses forkExec() so clicks fire-and-forget instead of blocking on the command's output. The entries and single-image paths are unchanged.
This commit is contained in:
@@ -19,6 +19,9 @@ namespace image {
|
||||
class IStrategy {
|
||||
public:
|
||||
virtual ~IStrategy() = default;
|
||||
// Runs on the worker thread before update(). Use it for blocking work (e.g.
|
||||
// spawning a user script) so the GTK main loop isn't stalled. Default no-op.
|
||||
virtual void fetch() {}
|
||||
virtual void update() = 0;
|
||||
};
|
||||
|
||||
@@ -46,6 +49,7 @@ class MultipleImageStrategy : public IStrategy {
|
||||
public:
|
||||
MultipleImageStrategy(const std::string&, const Json::Value&, const std::string&, Gtk::EventBox&);
|
||||
~MultipleImageStrategy() override = default;
|
||||
void fetch() override;
|
||||
void update() override;
|
||||
|
||||
private:
|
||||
@@ -67,6 +71,8 @@ class MultipleImageStrategy : public IStrategy {
|
||||
int size_;
|
||||
Gtk::Box box_;
|
||||
std::vector<ImageData> images_data_;
|
||||
// stdout captured by fetch() on the worker thread and consumed by update()
|
||||
std::string exec_output_;
|
||||
};
|
||||
|
||||
} // namespace image
|
||||
|
||||
Reference in New Issue
Block a user