Changeset 15462


Ignore:
Timestamp:
05/03/12 19:16:59 (12 years ago)
Author:
nit
Message:

[titan] add flushrc

Location:
titan
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • titan/plugins/browser/browser.h

    r15438 r15462  
    222222        if(status.lastservice != NULL)
    223223                servicestart(status.lastservice->channel, NULL, NULL, 0);
    224         sleep(2);
     224        flushrc(500);
    225225}
    226226
  • titan/plugins/news/news.h

    r15434 r15462  
    216216      if(status.lastservice != NULL)
    217217        servicestart(status.lastservice->channel, NULL, NULL, 0);
    218       sleep(2);
     218      flushrc(500);
    219219     
    220220                        goto start;
  • titan/plugins/stock/stock.h

    r15434 r15462  
    276276      if(status.lastservice != NULL)
    277277        servicestart(status.lastservice->channel, NULL, NULL, 0);
    278       sleep(2);
     278      flushrc(500);
    279279     
    280280      drawscreen(stock, 0);
  • titan/titan/header.h

    r15367 r15462  
    416416void delownerrc(struct skin* owner);
    417417void delrc(int key, struct skin* owner, struct skin* screennode);
     418int flushrc(unsigned int timeout);
    418419
    419420//rcfunc.h
  • titan/titan/rc.h

    r15424 r15462  
    1414        }
    1515
    16   closeonexec(status.fdrcsim);
     16        closeonexec(status.fdrcsim);
    1717        return 0;
    1818}
     
    133133}
    134134
     135int flushrc(unsigned int timeout)
     136{
     137        fd_set rfds;
     138        struct timeval tv;
     139        struct input_event rcdata;
     140        int rest = 0, count = 0;
     141        int ret = 0, len = 0;
     142
     143        rest = timeout % 1000;
     144        timeout = (timeout - rest) / 1000;
     145
     146        while(count < 10)
     147        {
     148                count++;
     149                tv.tv_sec = timeout;
     150                tv.tv_usec = rest * 1000;
     151                FD_ZERO(&rfds);
     152                FD_SET(status.fdrc, &rfds);
     153
     154                ret = TEMP_FAILURE_RETRY(select(status.fdrc + 1, &rfds, NULL, NULL, &tv));
     155
     156                if(ret < 1) break;
     157                if(FD_ISSET(status.fdrc, &rfds))
     158                {
     159                        count = 0;
     160                        len = TEMP_FAILURE_RETRY(read(status.fdrc, &rcdata, sizeof(struct input_event)));
     161                }
     162        }
     163 
     164  return 0;
     165}
     166
    135167int waitrc(struct skin* owner, unsigned int timeout, int flag)
    136168{
     
    140172        struct input_event rcdata;
    141173        int treffer = 0, rest = 0;
    142         int ret = 0, len, fromthread = 0, longpress = 0, longpresscount = 0;
     174        int ret = 0, len = 0, fromthread = 0, longpress = 0, longpresscount = 0;
    143175        struct rc *node;
    144176
Note: See TracChangeset for help on using the changeset viewer.