// Bug 135978
// Testing wrap_event()

#include <gtkmm.h>
#include <iostream>
#include <cstring>

void on_some_signal(Gdk::EventKey& event)
{
  std::cout << "Address of Gdk::EventKey event = " << &event << std::endl;
  std::cout << "Address of Gdk::EventKey event.gobj() = " << event.gobj() << std::endl;
  std::cout << "keyval = " << event.get_keyval()
            << ", hardware_keycode = " << event.get_hardware_keycode() << std::endl;

  event.gobj()->keyval += 2;
}

void mm_signal_handler(GdkEventKey* event)
{
  on_some_signal(Gdk::wrap_event(event));
}

void send_some_signal()
{
  GdkEventKey event1;
  std::memset(&event1, 0, sizeof event1);
  event1.type = GDK_KEY_PRESS;
  event1.keyval = 17;
  event1.hardware_keycode = 42;

  std::cout << "Address of GdkEventKey event1 = " << &event1 << std::endl;

  mm_signal_handler(&event1);

  std::cout << "keyval after signal emission = " << event1.keyval << std::endl;
}

int main()
{
  send_some_signal();
  return 0;
}

