Ignore:
Timestamp:
Aug 27, 2008, 5:03:06 PM (15 years ago)
Author:
Pascal Terjan
Message:
  • Only send title when it has changed
File:
1 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/server.c

    r2673 r2784  
    5353}
    5454
    55 static int set_title(const char * title, struct screen_list* screen_list)
     55static int set_title(struct screen_list* screen_list)
    5656{
    5757    char buf[1024];
    5858    int bytes;
     59    char *title;
     60
     61    if(screen_list->attached)
     62    {
     63        if(screen_list->pty < screen_list->count &&
     64           screen_list->screen[screen_list->pty]->title)
     65            title = screen_list->screen[screen_list->pty]->title;
     66        else
     67            title = PACKAGE_STRING;
     68    }
     69
     70    if(screen_list->title)
     71    {
     72        if(!strcmp(screen_list->title, title))
     73            return 0;
     74        free(screen_list->title);
     75    }
     76
     77    screen_list->title = strdup(title);
    5978
    6079    bytes = snprintf(buf, sizeof(buf)-1, "TITLE %s", title);
     
    309328            {
    310329                refresh_screens(screen_list);
    311                 if(screen_list->attached)
    312                 {
    313                     if(screen_list->pty < screen_list->count &&
    314                        screen_list->screen[screen_list->pty]->title)
    315                         set_title(screen_list->screen[screen_list->pty]->title, screen_list);
    316                     else
    317                         set_title(PACKAGE_STRING, screen_list);
    318                 }
     330                set_title(screen_list);
    319331                refresh = 1;
    320332
     
    395407        screen_list->session_name = NULL;
    396408    }
     409
     410    if(screen_list->title)
     411        free(screen_list->title);
    397412
    398413    if(screen_list) {
Note: See TracChangeset for help on using the changeset viewer.