| View previous topic :: View next topic |
 |
| Author |
Message |
 |
|
# 17 Dec 2008 16:10:01 Klicko 1.0.1 builds 119 and 120 out |
|
|
| Pushed out 119, then literally a second later got a bug report, had to do 120. Sorry about that. |
|
|
|
 |
|
# 15 Dec 2008 11:38:19 Re: Cocoa musings pt.1 |
|
|
In my post on event taps, I mentioned the following code to get a global event tap:
| Code: |
CFMachPortRef tapg = CGEventTapCreate(kCGAnnotatedSessionEventTap, kCGEventTapOptionDefault,
CGEventMaskBit(kCGEventLeftMouseDown)|CGEventMaskBit(kCGEventLeftMouseUp),
ProcessEvent,NULL);
|
This taps the event stream at the "annotated session" point (hence the kCGAnnotatedSessionEventTap parameter). Basically, this means that the event has already been analyzed as to destination application, and you can ask the passed event directly for that application's process ID. This is was I was using in Klicko.
Unfortunately the docs don't mention another step that takes place while "annotating" a mouse-down event: apparently, if the click was on a window's title bar (not elsewhere in the window), the owning process is brought to the front before the tap sees the event! Klicko's processing varied depending on the clicked-on window's and the owning process' state, so I was seeing different results depending on the click location - title bar or inside the window. Worse, a workaround I needed to do to bring non-main windows to the front for background processes wouldn't be applied at all if the user clicked on a title bar!
A more subtle consequence was that I was intercepting (and discarding) mouse clicks, while the system was expecting the click that brought the process to the front to actually arrive at the process... the result was that, while the menu bar changed to the process, its windows would remain in the back.
After beating my head against this wall for several days, I was rereading the CGEvent docs again for ideas and noticed that I hadn't tried applying a global tap before event annotation:
| Code: |
CFMachPortRef tapg = CGEventTapCreate(kCGSessionEventTap, kCGEventTapOptionDefault,
CGEventMaskBit(kCGEventLeftMouseDown)|CGEventMaskBit(kCGEventLeftMouseUp),
ProcessEvent,NULL);
|
Note the kCGSessionEventTap parameter. This meant that I had to discover the owning application's process ID myself (instead of asking the mouse-down event directly). Premature optimization strikes again; I'd selected the annotated tap just to avoid doing these steps.
At any rate, I immediately discovered that I now could properly intercept clicks anywhere, discard them, and do process and window activation as I wanted to. Well, almost; there was still some redundant window activation to do, as Carbon and Cocoa apps seem to still have some residual differences in that regard. I'll be filing bugs at Apple about some of these things. |
|
|
|
 |
|
# 15 Dec 2008 11:15:27 Klicko 1.0.1 (113) hopefully final |
|
|
This latest build of Klicko fixes all known bugs and edge cases, and some memory leaks. Hopefully this will be the last build for a long time.
In my next post I'll explain some technical details. |
|
|
|
 |
|
# 08 Dec 2008 19:25:47 Travel updates |
|
|
Oops. I just realized I forgot to update my travel maps. Here's the current world map (44 countries visited):
and here's zooming in on Europe (28 countries visited):
 |
|
|
|
 |
|
# 08 Dec 2008 12:30:42 Re: Klicko and Quay bug fixes |
|
|
Found an error in the code signature for both Klicko and Quay, induced by the presence of a newer signing certificate for iPhone apps.
So I pushed out new builds for Quay 1.1.1 (285) and Klicko 1.0.1 (103). Klicko also has other small improvements; see the release notes. |
|
|
|
 |
|
# 07 Dec 2008 21:17:33 Klicko 1.0.1 (97) |
|
|
I decided to rev the version number, not just the build number, for this release.
The main reason is that now we have a slight difference (and a UI difference) on first run. Klicko needs "access for assistive devices" turned on in the System Preference, and complains if that's not the case. However, now you have two options:
1- turn "access for assistive devices" on, and click "Continue"
2- click "Authorize" and enter your administrator password.
In the latter case - and this will work only if you installed Klicko inside the main /Applications folder - Klicko will set itself to run in a privileged group that can use the Accessibility API without that option.
Beyond small internal optimizations, the other notable feature in 1.0.1 is that you can change the icon, if you don't like it. Just make or copy your own icon, paste onto Klicko's icon in the Finder's "Get Info" panel, and there it is - you can do this even while Klicko is running! If your icon has a 16x16-pixel version, that one will be used in the menu bar.
Of course, if you have an icon for Klicko that's better than the default one, send it in! It shouldn't be too hard to do...  |
|
|
|
 |
|
# 06 Dec 2008 11:42:54 Re: Cocoa musings pt.1 |
|
|
Just saw Rob Keniger's Wrapster plug-in for Coda, an interesting use of event taps; it's a plug-in that intercepts key events for its master application.
The version I looked at (1.2) uses a global tap and checks if its master application is active:
| Code: |
if(![NSApp isActive]) {
return event;
}
|
Of course, it would be conceptually more reliable to obtain the event's destination process PSN and test against that; but the best way would be to tap the current process like this:
| Code: |
ProcessSerialNumber psn = {kNoProcess, kCurrentProcess};
CFMachPortRef tapg = CGEventTapCreateForPSN(&psn, kCGTailAppendEventTap, kCGEventTapOptionDefault, CGEventMaskBit(kCGEventKeyDown), ProcessEvent, NULL);
|
Global event taps are a great tool, but they're also easy to abuse, and I suppose that in a year or two we might have dozens of utilities or plug-ins tapping events; the actual results might be dependent on the order they run or load, for instance, and overall responsiveness might suffer. Therefore, please make absolutely sure that you need a global tap to do whatever you want to do, that it takes as little time as possible, and that it does careful parameter checking.
One great application to test event taps (and to check their presence) is Event Tap Testbench. It's author, Bill Cheeseman, has helped me a lot with subtle details of both event taps and the Accessibility APIs; thanks Bill! Do also check out their other products.
Rob tests if Accessibility is enabled by trying to create a tap and seeing if it succeeds. While this works, I think it's easier to do it like this:
| Code: |
if (!AXAPIEnabled()&&!AXIsProcessTrusted()) {
// error dialog here
}
|
The first call checks if Accessibility is enabled in System Preferences; the second checks if your process is allowed to set a key tap even with Accessibility disabled. To achieve this, you must (from a process running as root) call AXMakeProcessTrusted() on the tapping application's executable - this will take effect on its next run.
In the case of Klicko, it taps only mouse button events, for which Accessibility doesn't need to be on; however, it uses the Accessibility APIs to check out details about the clicked-on windows. Some people dislike turning Accessibility on in System Preferences, so a future version of Klicko might use AXMakeProcessTrusted() to avoid this; this means asking the user for an Administrator password and running a separate tool, like Quay does. I'm still evaluating the trade-offs for that: it precludes running Klicko from ~/Applications or from the disk image, adds to the application size, and the user has to navigate an extra dialog on first run.
Update:Klicko now uses AXMakeProcessTrusted().
Last edited by Rainer Brockerhoff on 08 Dec 2008 12:45:56; edited 1 time in total |
|
|
|
 |
|
# 04 Dec 2008 19:44:12 Re: Klicko and Quay bug fixes |
|
|
| And, yet another small bug fix release (87). This one allows clicking on windows belonging to background or GUI enhancement apps like Growl, Default Folder X and others. |
|
|
|
 |
|
# 02 Dec 2008 15:49:04 Klicko and Quay bug fixes |
|
|
| Just pushed out Klicko version 1.0 (79) and Quay 1.1.1 (283). Both are just small bug fix releases. Hopefully this will make Quay useable again for everybody while I work on the upcoming 1.2, which should be a huge step forward in functionality. There are still a few outstanding Klicko bugs, so be sure to check for updates over the next days, too. |
|
|
|
 |
|
# 02 Dec 2008 10:23:21 Re: Klicko 1.0 went Golden Master |
|
|
Many thanks to Matt Neuburg for my favorite review line ever: | Quote: | | Like Superman swooping down out of the sky to save the day, here comes Klicko, brainchild of Rainer Brockerhoff... |
 |
|
|
|
 |
|