Re: Catching client events



So instead of using a GdkNativeWindow to send to (which doesn't gel with client side windows anyway) I 
thought I'd go looking for someway of sending a GdkEvent to a GtkWidget... and I found one! 
gtk_propagate_event does what I want but it's synchronous. I would like a asynchronous version, that simply 
puts the event into the message que for later processing... preferably in a thread safe way.

I've been using client messages to post results from worker threads (amongst other things) up to the gui for 
integration into the UI. On windows the function I'm looking for is PostMessage.

I have an open stack overflow post here:
http://stackoverflow.com/questions/3041869/receiving-client-event-on-a-gtkwindow

Original message:

I'm trying to catch a client event on a GtkWindow.

      static gboolean MyClientEvent(GtkWidget *widget, GdkEventClient *ev,
MyWnd *Wnd)   {
              // breakpoint here...
              return TRUE;
      }

      GtkWidget *Wnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
      g_signal_connect(       G_OBJECT(Wnd),
                              "client-event",
                              G_CALLBACK(MyClientEvent),
                              this);
      gtk_widget_add_events(Wnd, GDK_ALL_EVENTS_MASK);


Sending code:

      GtkWidget *Wnd;
      GdkNativeWindow Hnd =
      #ifdef WIN32
              GDK_WINDOW_HWND(Wnd->window);
      #else
              GDK_WINDOW_XWINDOW(Wnd->window);
      #endif
      GdkEvent *Event = gdk_event_new(GDK_CLIENT_EVENT);
      // fill out Event params
      gdk_event_send_client_message(Event, Hnd);

This is on windows at the moment and I see the client message get sent
using Spy++, but nothing at the receiving end catches it. Both sender and
receiver are in the same application.


--
Matthew Allen
http://www.memecode.com




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