Permalink
Browse files

Don't touch window title before an OSC is received.

Fixes the "window title being clobbered" issue raised in issue 137.

Signed-off-by: sqweek <sqweek@gmail.com>

Closes #380. Closes #137.
  • Loading branch information...
sqweek authored and keithw committed Jan 18, 2013
1 parent 13a1633 commit 5af90cc1ace1f01d4b36ee71c650441d0d97cdb4
@@ -56,7 +56,7 @@ std::string Display::new_frame( bool initialized, const Framebuffer &last, const
}
/* has icon name or window title changed? */
- if ( has_title &&
+ if ( has_title && f.is_title_initialized() &&
( (!initialized)
|| (f.get_icon_name() != frame.last_frame.get_icon_name())
|| (f.get_window_title() != frame.last_frame.get_window_title()) ) ) {
@@ -68,7 +68,7 @@ DrawState::DrawState( int s_width, int s_height )
}
Framebuffer::Framebuffer( int s_width, int s_height )
- : rows( s_height, Row( s_width, 0 ) ), icon_name(), window_title(), bell_count( 0 ), ds( s_width, s_height )
+ : rows( s_height, Row( s_width, 0 ) ), icon_name(), window_title(), bell_count( 0 ), title_initialized( false ), ds( s_width, s_height )
{
assert( s_height > 0 );
assert( s_width > 0 );
@@ -248,6 +248,7 @@ namespace Terminal {
std::deque<wchar_t> icon_name;
std::deque<wchar_t> window_title;
unsigned int bell_count;
+ bool title_initialized; /* true if the window title has been set via an OSC */
Row newrow( void ) { return Row( ds.get_width(), ds.get_background_rendition() ); }
@@ -311,6 +312,8 @@ namespace Terminal {
void reset( void );
void soft_reset( void );
+ void set_title_initialized( void ) { title_initialized = true; }
+ bool is_title_initialized( void ) const { return title_initialized; }
void set_icon_name( const std::deque<wchar_t> &s ) { icon_name = s; }
void set_window_title( const std::deque<wchar_t> &s ) { window_title = s; }
const std::deque<wchar_t> & get_icon_name( void ) const { return icon_name; }
@@ -544,6 +544,7 @@ void Dispatcher::OSC_dispatch( const Parser::OSC_End *act, Framebuffer *fb )
bool set_icon = (cmd_num == 0 || cmd_num == 1);
bool set_title = (cmd_num == 0 || cmd_num == 2);
if ( set_icon || set_title ) {
+ fb->set_title_initialized();
std::deque<wchar_t> newtitle( OSC_string.begin() + offset, OSC_string.end() );
if ( set_icon ) { fb->set_icon_name( newtitle ); }
if ( set_title ) { fb->set_window_title( newtitle ); }

0 comments on commit 5af90cc

Please sign in to comment.