[Goodies-dev] GTK+/GDK Question

Jannis Pohlmann jannis at xfce.org
Sat Dec 27 16:56:04 CET 2008


Am Sat, 27 Dec 2008 23:20:58 +1100
schrieb David Collins <david.8.collins at gmail.com>:

> Hello.  I am working with Mike Massonnet on xfce4-clipman-plugin, so I
> am using GTK+ and GDK.
> 
> Can anyone tell me how I can -
> 
> 1. set up an event-driven function that fires off whenever the shift
> key is released anywhere on the screen (ie. regardless of what
> application is being used at the time) 

For that you'll need to register a GDK event filter. You could have a
look at http://tinyurl.com/93cjky. The following functions might be of
interest here:

  xfce_shortcuts_grabber_constructed() - this registers the filter
  using gdk_event_add_filter().

  xfce_shortcuts_grabber_event_filter() - this is the event filter
    which is triggered whenever an X event occurs. It ignores everything
    but KeyPress events.

In addition to this filter you'll also need to grab certain key
combinations (in your case everything related to the Shift modifier).
This is slightly more complicated as it requires a bit of knowledge
about X keymaps and keysyms. In case of libxfce4kbd-private, this
happens inside xfce_shortcuts_grabber_grab(). 
Note that you also want to connect to the "keys-changed" signal of the
default GdkKeymap in order to re-grab your key bindings when the
keyboard layout changes.

> 2. set up an event-driven function that fires off every time the left
> mouse is released anywhere on the screen (ie. regardless of what
> application is being used at the time).

I guess you could use gdk_event_add_filter() again.

Cheers,
Jannis
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://mail.xfce.org/pipermail/goodies-dev/attachments/20081227/5033c03a/attachment.pgp>


More information about the Goodies-dev mailing list