Gdk::Window::add_filter



I'm trying to add an event filter function to intercept raw X messages (listening to messages on the root window).

I have the following code at this point:

-------------------------------------------------------

GdkFilterReturn filter_func(GdkXEvent *xevent,
			    GdkEvent *event,
			    gpointer data)
{
  return GDK_FILTER_TRANSLATE;
}

main_window::main_window()
{
  gpointer data = (gpointer*) new char [1024];

  get_window()->add_filter(filter_func, data);

-------------------------------------------------------

where main_window inherits from Gtk::Window
but there occurs a segmentation fault (this is on GNU/Linux) at the call to "add_filter". I don't understand why it segfaults at this call (I could understand if it cores when the callback is called, but according to gdb it happens at (or in) the "add_filter" call).
Maybe I'm doing something obviously wrong, but I don't see it.
What is there supposed to be where "data" points at, is it arbitrary data?

//Marcus




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]