delay title updates

Notably shells will cause brief interim titles when calling
short-lived commands (try "ls"...)
This covers such by waiting 100ms after every title update before
reacting (the title will have returned in the mentioned cases, the UI
remains steady)
This commit is contained in:
Thomas Lübking 2016-08-03 23:55:26 +02:00
parent a8b0b3632b
commit 59d9b0703b
4 changed files with 20 additions and 2 deletions

View file

@ -51,8 +51,12 @@ IconButton::IconButton(const FbTk::FbWindow &parent,
m_theme(win, focused_theme, unfocused_theme),
m_pm(win.screen().imageControl()) {
m_title_update_timer.setTimeout(100 * FbTk::FbTime::IN_MILLISECONDS);
m_title_update_timer.fireOnce(true);
FbTk::RefCount<FbTk::Command<void> > ets(new FbTk::SimpleCommand<IconButton>(*this, &IconButton::clientTitleChanged));
m_title_update_timer.setCommand(ets);
m_signals.join(m_win.titleSig(),
MemFunIgnoreArgs(*this, &IconButton::clientTitleChanged));
MemFunIgnoreArgs(m_title_update_timer, &FbTk::Timer::start));
m_signals.join(m_win.focusSig(),
MemFunIgnoreArgs(*this, &IconButton::reconfigAndClear));

View file

@ -28,6 +28,7 @@
#include "FbTk/CachedPixmap.hh"
#include "FbTk/FbPixmap.hh"
#include "FbTk/TextButton.hh"
#include "FbTk/Timer.hh"
#include "FbTk/Signal.hh"
class IconbarTheme;
@ -92,6 +93,7 @@ private:
FbTk::CachedPixmap m_pm;
FbTk::SignalTracker m_signals;
FbTk::Signal<> m_title_changed;
FbTk::Timer m_title_update_timer;
};
#endif // ICONBUTTON_HH

View file

@ -119,6 +119,11 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):
s_transient_wait.erase(win);
}
m_title_update_timer.setTimeout(100 * FbTk::FbTime::IN_MILLISECONDS);
m_title_update_timer.fireOnce(true);
FbTk::RefCount<FbTk::Command<void> > ets(new FbTk::SimpleCommand<WinClient>(*this, &WinClient::emitTitleSig));
m_title_update_timer.setCommand(ets);
// also check if this window is a transient
// this needs to be done before creating an fbwindow, so this doesn't get
// tabbed using the apps file
@ -314,13 +319,17 @@ void WinClient::updateTitle() {
return;
m_title.setLogical(FbTk::FbString(Xutil::getWMName(window()), 0, 512));
m_title_update_timer.start();
}
void WinClient::emitTitleSig() {
titleSig().emit(m_title.logical(), *this);
}
void WinClient::setTitle(const FbTk::FbString &title) {
m_title.setLogical(title);
m_title_override = true;
titleSig().emit(m_title.logical(), *this);
m_title_update_timer.start();
}
void WinClient::setIcon(const FbTk::PixmapWithMask& pm) {

View file

@ -149,6 +149,9 @@ private:
// some transient (or us) is no longer modal
void removeModal() { --m_modal_count; }
FbTk::Timer m_title_update_timer;
void emitTitleSig();
// number of transients which we are modal for
int m_modal_count;
bool m_modal;