Skip to content

Commit

Permalink
Don't touch window title before an OSC is received.
Browse files Browse the repository at this point in the history
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 Mar 10, 2013
1 parent 13a1633 commit 5af90cc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/terminal/terminaldisplay.cc
Expand Up @@ -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()) ) ) {
Expand Down
2 changes: 1 addition & 1 deletion src/terminal/terminalframebuffer.cc
Expand Up @@ -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 );
Expand Down
3 changes: 3 additions & 0 deletions src/terminal/terminalframebuffer.h
Expand Up @@ -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() ); }

Expand Down Expand Up @@ -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; }
Expand Down
1 change: 1 addition & 0 deletions src/terminal/terminalfunctions.cc
Expand Up @@ -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 ); }
Expand Down

0 comments on commit 5af90cc

Please sign in to comment.