OSDN Git Service

drop keyevents when Surfaceflinger give up the screen
authorChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 8 Feb 2011 08:39:15 +0000 (16:39 +0800)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Tue, 8 Feb 2011 08:39:15 +0000 (16:39 +0800)
It fixes the 100% CPU usage problem switching to Alt-F1 console.

libs/ui/EventHub.cpp

index 7498d39..0e11823 100755 (executable)
@@ -375,10 +375,12 @@ bool EventHub::getEvent(int32_t* outDeviceId, int32_t* outType,
 
         // mFDs[0] is used for inotify, so process regular events starting at mFDs[1]
         for(i = 1; i < mFDCount; i++) {
-            if(mFDs[i].revents && keyGrab::isGrabOn()) {
+            if (mFDs[i].revents) {
                 LOGV("revents for %d = 0x%08x", i, mFDs[i].revents);
                 if(mFDs[i].revents & POLLIN) {
                     res = read(mFDs[i].fd, &iev, sizeof(iev));
+                    if (!keyGrab::isGrabOn())
+                        continue;
                     if (res == sizeof(iev)) {
                         LOGV("%s got: t0=%d, t1=%d, type=%d, code=%d, v=%d",
                              mDevices[i]->path.string(),