Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Programming for OSX, Mouse Controls

Programming for OSX, Mouse Controls
Thread Tools
kashirat
Fresh-Faced Recruit
Join Date: May 2004
Location: Alberta, Canada
Status: Offline
Reply With Quote
May 13, 2004, 02:02 PM
 
Hey all,

I'm looking to write some sort of plugin that will modify mouse+keyboard interactions in _all_ of OSX, but I don't really know where to start. The docs on the apple site seem pretty big, anyone experienced with the OSX Api(?) that could direct me in the right direction?

An example of the functionality I'm looking to modify is, for example, apple + left click and drag, (anywhere on a window) could move the window... and other derivatives of this.

Thanks!

'kash
     
Basilisk
Forum Regular
Join Date: Dec 2002
Status: Offline
Reply With Quote
May 13, 2004, 02:51 PM
 
There's no general way of overriding mouse/keyboard events in OS X. That's actually a fairly vague question because it really depends on what you are trying to do with the events.

With that in mind, I'll answer your specific example, please understand that if you wanted a different type of override (for example, not one that deals with window movement/resizing) the answer might be completely different.

There are two ways of moving windows around on OS X, both rely on hacking into undocumented portions of the OS, and both require you to inject code into the applications you want to affect.

The first method is to inject your code into the Dock process that can be used to control all windows. The Dock has a special, magic connection to the WindowServer that lets it do things to all windows (this is how Expose works). The internal Dock functions (actually CoreGraphics private functions) are completely undocumented, but some folks have reverse engineered some of the calls. This is the method used by Desktop Manager (http://wsmanager.sf.net) and its derivatives like GeekBind (http://geekbind.sf.net).

The other option is to inject your code into every running application and modify each application's behavior appropriately. Specifically one patches various WindowServer-related functions at runtime with your own customized version. Bear in mind that in many cases you will need to patch functions lower than the documented API (patching framework internals). This is apparently the approach used by Unsanity's WindowShade X and their other products.

Of course you also need a method to inject your code. Unsanity's Application Enhancer Framework (APE) is one option, it handles a lot of the heavy lifting for you. The other option is mach_inject which does much the same thing, but is perhaps not as polished (you have to do more work). Desktop Manager is mach_inject based, Unsanity's products are APE based. Sample code exists for each.

In general this stuff is all deep voodoo, not for the faint of heart. Its all undocumented, and though Apple's documentation is quite good none of this stuff is covered.

Good luck,

Alex
     
AirSluf
Senior User
Join Date: Nov 2000
Status: Offline
Reply With Quote
May 18, 2004, 09:47 PM
 
( Last edited by AirSluf; Nov 9, 2004 at 01:39 AM. )
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 11:51 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,