Skip to content

Commit

Permalink
print note if 'secure keyboard entry' is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
koekeishiya committed Jul 2, 2016
1 parent 766709c commit 2cfe49c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
30 changes: 16 additions & 14 deletions kwm/kwm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,20 +249,7 @@ int main(int argc, char **argv)
if(CheckArguments(argc, argv))
return 0;

KwmInit();
KWMMach.EventMask = ((1 << kCGEventKeyDown) |
(1 << kCGEventMouseMoved));

KWMMach.EventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, kCGEventTapOptionDefault, KWMMach.EventMask, CGEventCallback, NULL);
if(!KWMMach.EventTap || !CGEventTapIsEnabled(KWMMach.EventTap))
Fatal("Error: Could not create event-tap!");

CFRunLoopAddSource(CFRunLoopGetMain(),
CFMachPortCreateRunLoopSource(kCFAllocatorDefault, KWMMach.EventTap, 0),
kCFRunLoopCommonModes);
CGEventTapEnable(KWMMach.EventTap, true);
NSApplicationLoad();

if(!AXLibDisplayHasSeparateSpaces())
Fatal("Error: 'Displays have separate spaces' must be enabled!");

Expand All @@ -282,12 +269,27 @@ int main(int argc, char **argv)

FocusedDisplay = MainDisplay;
FocusedApplication = AXLibGetFocusedApplication();
/* ----------------------------------- */

KwmInit();
KwmExecuteConfig();
KwmExecuteInitScript();
CreateWindowNodeTree(MainDisplay);
/* ----------------------------------- */

if(CGSIsSecureEventInputSet())
fprintf(stderr, "Secure Keyboard Entry is enabled, hotkeys will not work!\n");

KWMMach.EventMask = ((1 << kCGEventKeyDown) |
(1 << kCGEventMouseMoved));

KWMMach.EventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, kCGEventTapOptionDefault, KWMMach.EventMask, CGEventCallback, NULL);
if(!KWMMach.EventTap || !CGEventTapIsEnabled(KWMMach.EventTap))
Fatal("Error: Could not create event-tap!");

CFRunLoopAddSource(CFRunLoopGetMain(),
CFMachPortCreateRunLoopSource(kCFAllocatorDefault, KWMMach.EventTap, 0),
kCFRunLoopCommonModes);
CGEventTapEnable(KWMMach.EventTap, true);
CFRunLoopRun();
return 0;
}
1 change: 1 addition & 0 deletions kwm/kwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "types.h"

extern "C" bool CGSIsSecureEventInputSet(void);
extern "C" void NSApplicationLoad(void);
extern void CreateWorkspaceWatcher(void *Watcher);

Expand Down

0 comments on commit 2cfe49c

Please sign in to comment.