From 59d9b0703ba8efb24893528f2eb9c84aaa8f5f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Wed, 3 Aug 2016 23:55:26 +0200 Subject: 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) --- src/IconButton.cc | 6 +++++- src/IconButton.hh | 2 ++ src/WinClient.cc | 11 ++++++++++- src/WinClient.hh | 3 +++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/IconButton.cc b/src/IconButton.cc index d2bf4d3..4997365 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -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 > ets(new FbTk::SimpleCommand(*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)); diff --git a/src/IconButton.hh b/src/IconButton.hh index 957374e..876cfe2 100644 --- a/src/IconButton.hh +++ b/src/IconButton.hh @@ -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 diff --git a/src/WinClient.cc b/src/WinClient.cc index b73f27c..22ee766 100644 --- a/src/WinClient.cc +++ b/src/WinClient.cc @@ -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 > ets(new FbTk::SimpleCommand(*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) { diff --git a/src/WinClient.hh b/src/WinClient.hh index 5a29a5e..c46bddf 100644 --- a/src/WinClient.hh +++ b/src/WinClient.hh @@ -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; -- cgit v0.11.2