Skip to content

Commit 541a3e1

Browse files
committed
Add a timer for plasma theme reloading.
This helps workaround a bug in fcitx5-configtool, but also batches multiple updates together.
1 parent 953dd9d commit 541a3e1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/ui/classic/plasmathemewatchdog.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fcitx::classicui::PlasmaThemeWatchdog::PlasmaThemeWatchdog(
5151
ioEvent_ = event->addIOEvent(
5252
monitorFD_.fd(),
5353
{IOEventFlag::In, IOEventFlag::Err, IOEventFlag::Hup},
54-
[this](EventSourceIO *, int fd, IOEventFlags flags) {
54+
[this, event](EventSourceIO *, int fd, IOEventFlags flags) {
5555
if ((flags & IOEventFlag::Err) || (flags & IOEventFlag::Hup)) {
5656
cleanup();
5757
return true;
@@ -60,7 +60,12 @@ fcitx::classicui::PlasmaThemeWatchdog::PlasmaThemeWatchdog(
6060
uint8_t dummy;
6161
while (fs::safeRead(fd, &dummy, sizeof(dummy)) > 0) {
6262
}
63-
callback_();
63+
timerEvent_ = event->addTimeEvent(
64+
CLOCK_MONOTONIC, now(CLOCK_MONOTONIC) + 1000000, 0,
65+
[this](EventSourceTime *, uint64_t) {
66+
callback_();
67+
return true;
68+
});
6469
}
6570
return true;
6671
});

src/ui/classic/plasmathemewatchdog.h

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class PlasmaThemeWatchdog {
2626
std::function<void()> callback_;
2727
UnixFD monitorFD_;
2828
std::unique_ptr<EventSourceIO> ioEvent_;
29+
std::unique_ptr<EventSourceTime> timerEvent_;
2930
pid_t generator_ = 0;
3031
};
3132

0 commit comments

Comments
 (0)