gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r11188: Get rid of delay loop becaus


From: Udo Giacomozzi
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r11188: Get rid of delay loop because of the new heartbeat interval (correct timing is up to advance() now).
Date: Mon, 29 Jun 2009 21:13:26 +0200
User-agent: Bazaar (1.13.1)

------------------------------------------------------------
revno: 11188
committer: Udo Giacomozzi <address@hidden>
branch nick: trunk
timestamp: Mon 2009-06-29 21:13:26 +0200
message:
  Get rid of delay loop because of the new heartbeat interval (correct timing 
is up to advance() now).
  Make check_mouse() and check_keyboard() return true on activity even if 
that's completely unnecessary now since there is no delay loop anymore... ;-)
modified:
  gui/fb.cpp
  gui/fbsup.h
=== modified file 'gui/fb.cpp'
--- a/gui/fb.cpp        2009-06-29 17:52:28 +0000
+++ b/gui/fb.cpp        2009-06-29 19:13:26 +0000
@@ -374,22 +374,21 @@
 
   while (!terminate_request) {
   
-    double prevtimer = timer; 
-    
-    while ((timer-prevtimer)*1000 < _interval) {
-    
-      gnashSleep(1); // task switch
-      
-      check_mouse(); // TODO: Exit delay loop on mouse events! 
-      check_keyboard(); // TODO: Exit delay loop on keyboard events!
-            
-      if (!gettimeofday(&tv, NULL))
-        timer = (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0;
-    }
-  
-  // advance movie  
-  Gui::advance_movie(this);
+    // wait the "heartbeat" inteval
+    gnashSleep(_interval * 1000);    
+    // TODO: Do we need to check the real time slept or is it OK when we woke
+    // up early because of some Linux signal sent to our process (and thus
+    // "advance" faster than the "heartbeat" interval)? - Udo
+  
+    // check input devices
+    check_mouse();
+    check_keyboard();
+  
+    // advance movie  
+    Gui::advance_movie(this);
+    
   }
+  
   return true;
 }
 
@@ -842,9 +841,9 @@
 #endif
 
 #ifdef USE_MOUSE_PS2    
-void FBGui::check_mouse() 
+bool FBGui::check_mouse() 
 {
-  if (input_fd<0) return;   // no mouse available
+  if (input_fd<0) return false;   // no mouse available
   
   int i;
   int xmove, ymove, btn, btn_changed;
@@ -858,7 +857,7 @@
     pos = i;
     break;    
   }
-  if (pos<0) return; // no sync or no data
+  if (pos<0) return false; // no sync or no data
   
   if (pos>0) {
     // remove garbage:
@@ -906,6 +905,7 @@
     memmove(mouse_buf, mouse_buf + pos, mouse_buf_size - pos);
     mouse_buf_size -= pos;  
     
+    return true;
   
   }
   
@@ -943,9 +943,11 @@
 #endif
 
 #ifdef USE_MOUSE_ETT    
-void FBGui::check_mouse() 
+bool FBGui::check_mouse() 
 {
-  if (input_fd<0) return;   // no mouse available
+  bool activity = false;
+  
+  if (input_fd<0) return false;   // no mouse available
   
   read_mouse_data();
   
@@ -957,7 +959,7 @@
     pos = i;
     break;    
   }
-  if (pos<0) return; // no sync or no data
+  if (pos<0) return false; // no sync or no data
   
   if (pos>0) {
     //printf("touchscreen: removing %d bytes garbage!\n", pos);  
@@ -996,11 +998,13 @@
       mouse_x = new_x;
       mouse_y = new_y;
       notify_mouse_moved(mouse_x, mouse_y);
+      activity = true;
     }
     
     if (new_btn != mouse_btn) {
       mouse_btn = new_btn;      
       notify_mouse_clicked(mouse_btn, 1);  // mask=?
+      activity = true;
     }
     
     // remove from buffer
@@ -1009,6 +1013,8 @@
     mouse_buf_size -= pos;    
   }
   
+  return activity;
+  
 }
 #endif
 
@@ -1134,10 +1140,11 @@
   *cy = (rawy-cal1y) / (cal2y-cal1y) * (ref2y-ref1y) + ref1y;
 }
 
-void FBGui::check_mouse()
+bool FBGui::check_mouse()
 {
-
-  if (input_fd < 0) return;
+  bool activity = false;
+  
+  if (input_fd < 0) return false;
 
   struct input_event ev;  // time,type,code,value
   
@@ -1188,11 +1195,13 @@
       
         if (move_pending) {
           notify_mouse_moved(notify_x, notify_y);
+          activity = true;
           move_pending = false;
         }
       
         mouse_btn = new_mouse_btn;
         notify_mouse_clicked(mouse_btn, 1);  // mark=??
+        activity = true;
       }
 
       if (coordinatedebug)
@@ -1225,8 +1234,12 @@
   
   } 
   
-  if (move_pending) 
+  if (move_pending) {
     notify_mouse_moved(notify_x, notify_y);
+    activity = true;
+  }
+  
+  return activity;
  
 } //check_mouse
 #endif
@@ -1380,10 +1393,11 @@
   return gnash::key::INVALID;  
 }
 
-void FBGui::check_keyboard()
+bool FBGui::check_keyboard()
 {
-
-  if (keyb_fd < 0) return;
+  bool activity = false;
+  
+  if (keyb_fd < 0) return false;
 
   struct input_event ev;  // time,type,code,value
 
@@ -1435,14 +1449,18 @@
           
           
         // send event
-        if (c != gnash::key::INVALID) 
-            Gui::notify_key_event(c, modifier, ev.value);
+        if (c != gnash::key::INVALID) {
+          Gui::notify_key_event(c, modifier, ev.value);
+          activity=true;
+        }
               
       } //if normal key
 
     } //if EV_KEY      
   
   } //while
+  
+  return activity;
 
 }
 

=== modified file 'gui/fbsup.h'
--- a/gui/fbsup.h       2009-02-25 22:33:03 +0000
+++ b/gui/fbsup.h       2009-06-29 19:13:26 +0000
@@ -168,8 +168,8 @@
        /// Initializes mouse routines
        bool init_mouse();
        
-       /// Checks for any mouse activity
-       void check_mouse();
+       /// Checks for and processes any mouse activity. Returns true on 
activity.
+       bool check_mouse();
        
        /// Initializes keyboard routines 
        bool init_keyboard();
@@ -177,8 +177,8 @@
        /// Translates a scancode from the Linux Input Subsystem to a Gnash key 
code 
     gnash::key::code scancode_to_gnash_key(int code, bool shift);
        
-       /// Checks for any keyboard activity
-       void check_keyboard();
+       /// Checks for and processes any keyboard activity. Returns true on 
activity.
+       bool check_keyboard();
        
 #ifdef USE_INPUT_EVENTS        
     /// Applies builtin touchscreen calibration


reply via email to

[Prev in Thread] Current Thread [Next in Thread]