Skip to content

Commit

Permalink
Fix issue with event tap being disabled on timeouts caused by sleep.
Browse files Browse the repository at this point in the history
Also bump the version to 0.3.4.
  • Loading branch information
jmgao committed Jan 20, 2014
1 parent baf86b2 commit 3648d49
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#define VERSION 0.3.3
#define VERSION 0.3.4
#define VERSION_MAJOR 0
#define VERSION_MINOR 3
#define VERSION_PATCH 3
#define VERSION_PATCH 4

#define STRINGIFY_(x) #x
#define STRINGIFY(x) STRINGIFY_(x)
Expand Down
10 changes: 6 additions & 4 deletions src/event_tap.mm
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
{
auto event_tap = static_cast<EventTap *>(data);

if (type == kCGEventTapDisabledByTimeout) {
NSLog(@"Event tap was disabled by timeout, reenabling\n");
CGEventTapEnable(event_tap->event_tap, true);
return event;
}

CGEventMask event_type_mask = CGEventMaskBit(type);
if (event_type_mask == 0 || (event_type_mask & event_tap->event_mask) != event_type_mask) {
return event;
Expand Down Expand Up @@ -100,10 +106,6 @@
consume_event = event_tap->on_right_mouse_up(proxy, type, event);
break;

case kCGEventTapDisabledByTimeout:
NSLog(@"Event tap was disabled by timeout, aborting\n");
break;

default:
NSLog(@"Unknown event %d\n", type);
break;
Expand Down
1 change: 0 additions & 1 deletion src/window_event_tap.mm
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
std::this_thread::sleep_for(desired_duration - actual_duration);
}
}

}

bool WindowEventTap::on_mouse_down(CGEventTapProxy proxy, CGEventType type, CGEventRef event)
Expand Down

0 comments on commit 3648d49

Please sign in to comment.