Changeset 3946
- Timestamp:
- 11/18/09 18:09:26 (4 years ago)
- Location:
- neercs/trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/neercs.h
r3944 r3946 164 164 long long unsigned int last_key_time; 165 165 int command; 166 int was_in_bell; 167 long long unsigned int last_refresh_time; 168 166 169 167 170 /* Detaching */ -
neercs/trunk/src/server.c
r3945 r3946 37 37 38 38 static void server_init(struct screen_list *screen_list); 39 static int handle_key(struct screen_list *screen_list, unsigned int c); 39 static int refresh_screen(struct screen_list *screen_list, int refresh); 40 static int handle_key(struct screen_list *screen_list, unsigned int c, int refresh); 40 41 static int handle_attach(struct screen_list *screen_list, char *buf); 41 42 … … 65 66 char buf[1024]; 66 67 int bytes; 67 char *title ;68 char *title = NULL; 68 69 69 70 if (screen_list->attached) … … 204 205 { 205 206 int i; 206 int eof = 0, refresh = 1, was_in_bell = 0; 207 long long unsigned int last_refresh_time = 0; 207 int eof = 0, refresh = 1; 208 208 209 209 screen_list->last_key_time = 0; 210 210 screen_list->attached = 0; 211 211 screen_list->command = 0; 212 screen_list->was_in_bell = 0; 213 screen_list->last_refresh_time = 0; 212 214 213 215 server_init(screen_list); … … 255 257 { 256 258 unsigned int c = atoi(buf + 4); 257 refresh |= handle_key(screen_list, c );259 refresh |= handle_key(screen_list, c, refresh); 258 260 } 259 261 else … … 278 280 279 281 /* Refresh screen */ 280 if (!screen_list->attached) 281 { 282 /* No need to refresh Don't use the CPU too much Would be better 283 to select on terms + socket */ 284 sleep(1); 285 } 286 else 287 { 288 long long unsigned int current_time = get_us(); 289 long long int tdiff = (current_time - last_refresh_time) / 1000; 290 /* Draw lock window */ 291 if (screen_list->locked) 292 { 293 draw_lock(screen_list); 294 refresh = 1; 295 } 296 else if ((current_time - screen_list->last_key_time >= 297 screen_list->autolock_timeout)) 298 { 299 screen_list->locked = 1; 300 refresh = 1; 301 } 302 else if ((current_time - screen_list->last_key_time >= 303 screen_list->screensaver_timeout)) 304 { 305 if (!screen_list->in_screensaver) 306 { 307 screensaver_init(screen_list); 308 screen_list->in_screensaver = 1; 309 set_cursor(0, screen_list); 310 } 311 draw_screensaver(screen_list); 312 refresh = 1; 313 } 314 else if (refresh || was_in_bell) 315 { 316 if (tdiff >= screen_list->delay) 317 { 318 was_in_bell = screen_list->in_bell; 319 refresh_screens(screen_list); 320 set_title(screen_list); 321 refresh = 1; 322 } 323 } 324 if (refresh) 325 { 326 if (tdiff >= screen_list->delay) 327 { 328 request_refresh(screen_list); 329 refresh = 0; 330 last_refresh_time = current_time; 331 } 332 else 333 debug("Skipping refresh (%lld < %d)", tdiff, 334 screen_list->delay); 335 } 336 } 337 338 if (screen_list->force_refresh) 339 { 340 wm_refresh(screen_list); 341 request_refresh(screen_list); 342 } 282 refresh |= refresh_screen(screen_list, refresh); 343 283 344 284 eof = 1; … … 357 297 } 358 298 299 static int refresh_screen(struct screen_list *screen_list, int refresh) 300 { 301 if (!screen_list->attached) 302 { 303 /* No need to refresh Don't use the CPU too much Would be better to 304 select on terms + socket */ 305 sleep(1); 306 } 307 else 308 { 309 long long unsigned int current_time = get_us(); 310 long long int tdiff = (current_time - screen_list->last_refresh_time) / 1000; 311 312 313 if (screen_list->force_refresh) 314 { 315 wm_refresh(screen_list); 316 request_refresh(screen_list); 317 } 318 319 320 /* Draw lock window */ 321 if (screen_list->locked) 322 { 323 draw_lock(screen_list); 324 refresh = 1; 325 } 326 else if ((current_time - screen_list->last_key_time >= 327 screen_list->autolock_timeout)) 328 { 329 screen_list->locked = 1; 330 refresh = 1; 331 } 332 else if ((current_time - screen_list->last_key_time >= 333 screen_list->screensaver_timeout)) 334 { 335 if (!screen_list->in_screensaver) 336 { 337 screensaver_init(screen_list); 338 screen_list->in_screensaver = 1; 339 set_cursor(0, screen_list); 340 } 341 draw_screensaver(screen_list); 342 refresh = 1; 343 } 344 else if (refresh || screen_list->was_in_bell) 345 { 346 if (tdiff >= screen_list->delay) 347 { 348 screen_list->was_in_bell = screen_list->in_bell; 349 refresh_screens(screen_list); 350 set_title(screen_list); 351 refresh = 1; 352 } 353 } 354 if (refresh) 355 { 356 if (tdiff >= screen_list->delay) 357 { 358 request_refresh(screen_list); 359 refresh = 0; 360 screen_list->last_refresh_time = current_time; 361 } 362 else 363 { 364 debug("Skipping refresh (%lld < %d)", tdiff, 365 screen_list->delay); 366 } 367 } 368 } 369 370 return 1; 371 } 359 372 360 373 static void server_init(struct screen_list *screen_list) … … 428 441 } 429 442 430 static int handle_key(struct screen_list *screen_list, unsigned int c) 431 { 432 int refresh = 0; 443 static int handle_key(struct screen_list *screen_list, unsigned int c, int refresh) 444 { 433 445 char *str = NULL; 434 446 int size = 0; … … 549 561 screen_list->cv = caca_create_canvas(0, 0); 550 562 screen_list->dp = caca_create_display(screen_list->cv); 551 563 552 564 if (!screen_list->dp) 553 565 return -3; 554 566 555 567 caca_set_display_time(screen_list->dp, screen_list->delay * 1000); 556 568 caca_set_cursor(screen_list->dp, 1);
Note: See TracChangeset
for help on using the changeset viewer.
