Problem with XID]
- From: Andre Lerche <a lerche gmx net>
- To: gtk-app-devel-list gnome org
- Subject: Problem with XID]
- Date: Mon, 27 Oct 2003 23:41:47 +0100
Hi List!
Currently I play a little bit with events/signals and wrote the following
program to send events to itself (this doesn't make much sense, it's only
for learning). If I try get the xid of my window with
gtk_widget_get_root_window and GDK_DRAWABLE_XID (drawable), the event is thrown,
but never receives. It works only if I search for the xid for example with
xwininfo and add it manual. What's causing this and how can I get the right
xid within gdk/gtk? I am using gtk 2.2.1-4 on Redhat 9.
Thanks in advance,
Andre
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <X11/Xutil.h>
typedef struct _details details;
struct _details {
GtkWidget *window;
GtkWidget *frame;
Window xid;
};
int ButtonPressEvent (GtkWidget *widget, GdkEventCrossing *event, gpointer data) {
GtkWidget *win;
gboolean send;
GdkEventClient ev;
details *p = data;
win = gtk_invisible_new ();
gtk_widget_realize (win);
ev.type = GDK_CLIENT_EVENT;
ev.window = win->window;
ev.send_event = TRUE;
ev.message_type = gdk_atom_intern ("MEVENT", FALSE);
ev.data_format = 8;
strcpy (ev.data.b, "reload");
send = gdk_event_send_client_message ((GdkEvent *) &ev, (GdkNativeWindow) p->xid);
//if I add the XID manually, it works
//send = gdk_event_send_client_message ((GdkEvent *) &ev, (GdkNativeWindow) 0x3000002);
gdk_flush ();
if (send) {
g_message ("Event OK");
} else {
g_message ("Event could not be send");
}
gtk_widget_destroy (win);
}
int ClientEvent (GtkWidget *widget, GdkEventCrossing *ev, gpointer data ) {
g_message ("Client event received");
}
int main (int argc, char *argv[]) {
GdkDrawable *drawable;
details *p;
gtk_init (&argc, &argv);
p = g_new0 (details, 1);
p->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
p->frame = gtk_frame_new (NULL);
gtk_container_add (GTK_CONTAINER(p->window), p->frame);
gtk_widget_show_all (p->window);
gtk_widget_set_size_request (p->window, 100, 100);
gtk_widget_add_events (p->window, GDK_ALL_EVENTS_MASK);
drawable = gtk_widget_get_root_window (p->frame);
p->xid = GDK_DRAWABLE_XID (drawable);
g_signal_connect (p->window, "button-press-event", G_CALLBACK(ButtonPressEvent), p);
g_signal_connect (p->window, "client-event", G_CALLBACK (ClientEvent), NULL);
gtk_main ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]