hi ,
i am new to linux.

but has some experience on programming gtk apps.
i would like to do the following things on on my linux workstations
1. get which window is active at any given time. That is need a notification when a window ,thread , and process bewcomes active, gets focus , a new application or process is launched and similar events .
2. also get the input monitor inplace , i.e., something that can give me everything on keyboard and mouse, the events they generated and for which application's which window they were targeted on
These r basically to monitor what the user is doing .
Iwould like to know the best solution to it and how to solve it.
i think that i should install some sort of message and event logger on the X itself but don't know how to do it .
any help will be greatly appreciated