diff --git a/ChangeLog b/ChangeLog index 0c88235112..688b7601da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2007-01-03 Matthias Clasen + * gtk/*.c: + * gdk/x11/*.c: Apply a patch by Chris Wilson to + avoid spurious valgrind warnings from XSendEvent() + calls. (#392532) + * modules/printbackends/cups/gtkprintbackendcups.c: Close the http connection after getting the PPD. diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index fd48807f50..fa1524e0ad 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -996,24 +996,25 @@ broadcast_xmessage (GdkDisplay *display, message_type_begin); { - XEvent xevent; + XClientMessageEvent xclient; const char *src; const char *src_end; char *dest; char *dest_end; - xevent.xclient.type = ClientMessage; - xevent.xclient.message_type = type_atom_begin; - xevent.xclient.display =xdisplay; - xevent.xclient.window = xwindow; - xevent.xclient.format = 8; + memset(&xclient, 0, sizeof (xclient)); + xclient.type = ClientMessage; + xclient.message_type = type_atom_begin; + xclient.display =xdisplay; + xclient.window = xwindow; + xclient.format = 8; src = message; src_end = message + strlen (message) + 1; /* +1 to include nul byte */ while (src != src_end) { - dest = &xevent.xclient.data.b[0]; + dest = &xclient.data.b[0]; dest_end = dest + 20; while (dest != dest_end && @@ -1034,9 +1035,9 @@ broadcast_xmessage (GdkDisplay *display, xroot_window, False, PropertyChangeMask, - &xevent); + (XEvent *)&xclient); - xevent.xclient.message_type = type_atom; + xclient.message_type = type_atom; } } diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c index 83b45789a3..0dd3b847a9 100644 --- a/gdk/x11/gdkevents-x11.c +++ b/gdk/x11/gdkevents-x11.c @@ -2191,13 +2191,13 @@ gdk_wm_protocols_filter (GdkXEvent *xev, !_gdk_x11_display_is_root_window (display, xevent->xclient.window)) { - XEvent xev = *xevent; + XClientMessageEvent xclient = xevent->xclient; - xev.xclient.window = GDK_WINDOW_XROOTWIN (win); + xclient.window = GDK_WINDOW_XROOTWIN (win); XSendEvent (GDK_WINDOW_XDISPLAY (win), - xev.xclient.window, + xclient.window, False, - SubstructureRedirectMask | SubstructureNotifyMask, &xev); + SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&xclient); return GDK_FILTER_REMOVE; } diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index 75e69479d3..36b51ec242 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -804,7 +804,10 @@ _gdk_send_xevent (GdkDisplay *display, propagate, event_mask, event_send); XSync (GDK_DISPLAY_XDISPLAY (display), False); - return result && gdk_error_trap_pop() == Success; + if (gdk_error_trap_pop ()) + return FALSE; + + return result; } void diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index d8bffba951..719ba01618 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -1146,27 +1146,28 @@ _gdk_windowing_window_destroy_foreign (GdkWindow *window) * so reparent it to the root window, and then send * it a delete event, as if we were a WM */ - XClientMessageEvent xevent; + XClientMessageEvent xclient; gdk_error_trap_push (); gdk_window_hide (window); gdk_window_reparent (window, NULL, 0, 0); - xevent.type = ClientMessage; - xevent.window = GDK_WINDOW_XID (window); - xevent.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), + memset (&xclient, 0, sizeof (xclient)); + xclient.type = ClientMessage; + xclient.window = GDK_WINDOW_XID (window); + xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), "WM_PROTOCOLS"); - xevent.format = 32; - xevent.data.l[0] = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), + xclient.format = 32; + xclient.data.l[0] = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), "WM_DELETE_WINDOW"); - xevent.data.l[1] = CurrentTime; - xevent.data.l[2] = 0; - xevent.data.l[3] = 0; - xevent.data.l[4] = 0; + xclient.data.l[1] = CurrentTime; + xclient.data.l[2] = 0; + xclient.data.l[3] = 0; + xclient.data.l[4] = 0; XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XID (window), - False, 0, (XEvent *)&xevent); + False, 0, (XEvent *)&xclient); gdk_display_sync (GDK_WINDOW_DISPLAY (window)); gdk_error_trap_pop (); } @@ -2033,7 +2034,6 @@ move_to_current_desktop (GdkWindow *window) if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window), gdk_atom_intern_static_string ("_NET_WM_DESKTOP"))) { - XEvent xev; Atom type; gint format; gulong nitems; @@ -2056,26 +2056,28 @@ move_to_current_desktop (GdkWindow *window) if (type == XA_CARDINAL) { + XClientMessageEvent xclient; current_desktop = (gulong *)data; - xev.xclient.type = ClientMessage; - xev.xclient.serial = 0; - xev.xclient.send_event = True; - xev.xclient.window = GDK_WINDOW_XWINDOW (window); - xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"); - xev.xclient.format = 32; + memset (&xclient, 0, sizeof (xclient)); + xclient.type = ClientMessage; + xclient.serial = 0; + xclient.send_event = True; + xclient.window = GDK_WINDOW_XWINDOW (window); + xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_DESKTOP"); + xclient.format = 32; - xev.xclient.data.l[0] = *current_desktop; - xev.xclient.data.l[1] = 0; - xev.xclient.data.l[2] = 0; - xev.xclient.data.l[3] = 0; - xev.xclient.data.l[4] = 0; + xclient.data.l[0] = *current_desktop; + xclient.data.l[1] = 0; + xclient.data.l[2] = 0; + xclient.data.l[3] = 0; + xclient.data.l[4] = 0; XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False, SubstructureRedirectMask | SubstructureNotifyMask, - &xev); + (XEvent *)&xclient); XFree (current_desktop); } @@ -2107,24 +2109,23 @@ gdk_window_focus (GdkWindow *window, if (gdk_x11_screen_supports_net_wm_hint (GDK_WINDOW_SCREEN (window), gdk_atom_intern_static_string ("_NET_ACTIVE_WINDOW"))) { - XEvent xev; + XClientMessageEvent xclient; - xev.xclient.type = ClientMessage; - xev.xclient.serial = 0; - xev.xclient.send_event = True; - xev.xclient.window = GDK_WINDOW_XWINDOW (window); - xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, + memset (&xclient, 0, sizeof (xclient)); + xclient.type = ClientMessage; + xclient.window = GDK_WINDOW_XWINDOW (window); + xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_ACTIVE_WINDOW"); - xev.xclient.format = 32; - xev.xclient.data.l[0] = 1; /* requestor type; we're an app */ - xev.xclient.data.l[1] = timestamp; - xev.xclient.data.l[2] = None; /* currently active window */ - xev.xclient.data.l[3] = 0; - xev.xclient.data.l[4] = 0; + xclient.format = 32; + xclient.data.l[0] = 1; /* requestor type; we're an app */ + xclient.data.l[1] = timestamp; + xclient.data.l[2] = None; /* currently active window */ + xclient.data.l[3] = 0; + xclient.data.l[4] = 0; XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False, SubstructureRedirectMask | SubstructureNotifyMask, - &xev); + (XEvent *)&xclient); } else { @@ -2370,27 +2371,26 @@ gdk_wmspec_change_state (gboolean add, GdkAtom state2) { GdkDisplay *display = GDK_WINDOW_DISPLAY (window); - XEvent xev; + XClientMessageEvent xclient; #define _NET_WM_STATE_REMOVE 0 /* remove/unset property */ #define _NET_WM_STATE_ADD 1 /* add/set property */ #define _NET_WM_STATE_TOGGLE 2 /* toggle property */ - xev.xclient.type = ClientMessage; - xev.xclient.serial = 0; - xev.xclient.send_event = True; - xev.xclient.window = GDK_WINDOW_XID (window); - xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"); - xev.xclient.format = 32; - xev.xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; - xev.xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1); - xev.xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2); - xev.xclient.data.l[3] = 0; - xev.xclient.data.l[4] = 0; + memset (&xclient, 0, sizeof (xclient)); + xclient.type = ClientMessage; + xclient.window = GDK_WINDOW_XID (window); + xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_STATE"); + xclient.format = 32; + xclient.data.l[0] = add ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; + xclient.data.l[1] = gdk_x11_atom_to_xatom_for_display (display, state1); + xclient.data.l[2] = gdk_x11_atom_to_xatom_for_display (display, state2); + xclient.data.l[3] = 0; + xclient.data.l[4] = 0; XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False, SubstructureRedirectMask | SubstructureNotifyMask, - &xev); + (XEvent *)&xclient); } /** @@ -4563,7 +4563,7 @@ gdk_window_stick (GdkWindow *window) * viewport. i.e. glue to the monitor glass in all cases. */ - XEvent xev; + XClientMessageEvent xclient; /* Request stick during viewport scroll */ gdk_wmspec_change_state (TRUE, window, @@ -4571,24 +4571,23 @@ gdk_window_stick (GdkWindow *window) NULL); /* Request desktop 0xFFFFFFFF */ - xev.xclient.type = ClientMessage; - xev.xclient.serial = 0; - xev.xclient.send_event = True; - xev.xclient.window = GDK_WINDOW_XWINDOW (window); - xev.xclient.display = GDK_WINDOW_XDISPLAY (window); - xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), + memset (&xclient, 0, sizeof (xclient)); + xclient.type = ClientMessage; + xclient.window = GDK_WINDOW_XWINDOW (window); + xclient.display = GDK_WINDOW_XDISPLAY (window); + xclient.message_type = gdk_x11_get_xatom_by_name_for_display (GDK_WINDOW_DISPLAY (window), "_NET_WM_DESKTOP"); - xev.xclient.format = 32; + xclient.format = 32; - xev.xclient.data.l[0] = 0xFFFFFFFF; - xev.xclient.data.l[1] = 0; - xev.xclient.data.l[2] = 0; - xev.xclient.data.l[3] = 0; - xev.xclient.data.l[4] = 0; + xclient.data.l[0] = 0xFFFFFFFF; + xclient.data.l[1] = 0; + xclient.data.l[2] = 0; + xclient.data.l[3] = 0; + xclient.data.l[4] = 0; XSendEvent (GDK_WINDOW_XDISPLAY (window), GDK_WINDOW_XROOTWIN (window), False, SubstructureRedirectMask | SubstructureNotifyMask, - &xev); + (XEvent *)&xclient); } else { @@ -5628,27 +5627,26 @@ wmspec_moveresize (GdkWindow *window, { GdkDisplay *display = GDK_WINDOW_DISPLAY (window); - XEvent xev; + XClientMessageEvent xclient; /* Release passive grab */ gdk_display_pointer_ungrab (display, timestamp); - xev.xclient.type = ClientMessage; - xev.xclient.serial = 0; - xev.xclient.send_event = True; - xev.xclient.window = GDK_WINDOW_XID (window); - xev.xclient.message_type = + memset (&xclient, 0, sizeof (xclient)); + xclient.type = ClientMessage; + xclient.window = GDK_WINDOW_XID (window); + xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_NET_WM_MOVERESIZE"); - xev.xclient.format = 32; - xev.xclient.data.l[0] = root_x; - xev.xclient.data.l[1] = root_y; - xev.xclient.data.l[2] = direction; - xev.xclient.data.l[3] = 0; - xev.xclient.data.l[4] = 0; + xclient.format = 32; + xclient.data.l[0] = root_x; + xclient.data.l[1] = root_y; + xclient.data.l[2] = direction; + xclient.data.l[3] = 0; + xclient.data.l[4] = 0; XSendEvent (GDK_DISPLAY_XDISPLAY (display), GDK_WINDOW_XROOTWIN (window), False, SubstructureRedirectMask | SubstructureNotifyMask, - &xev); + (XEvent *)&xclient); } typedef struct _MoveResizeData MoveResizeData; diff --git a/gtk/gtksocket-x11.c b/gtk/gtksocket-x11.c index 25fe9c914c..5d1f6935b8 100644 --- a/gtk/gtksocket-x11.c +++ b/gtk/gtksocket-x11.c @@ -119,28 +119,29 @@ _gtk_socket_windowing_send_key_event (GtkSocket *socket, GdkEvent *gdk_event, gboolean mask_key_presses) { - XEvent xevent; + XKeyEvent xkey; GdkScreen *screen = gdk_drawable_get_screen (socket->plug_window); - xevent.xkey.type = (gdk_event->type == GDK_KEY_PRESS) ? KeyPress : KeyRelease; - xevent.xkey.window = GDK_WINDOW_XWINDOW (socket->plug_window); - xevent.xkey.root = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen)); - xevent.xkey.subwindow = None; - xevent.xkey.time = gdk_event->key.time; - xevent.xkey.x = 0; - xevent.xkey.y = 0; - xevent.xkey.x_root = 0; - xevent.xkey.y_root = 0; - xevent.xkey.state = gdk_event->key.state; - xevent.xkey.keycode = gdk_event->key.hardware_keycode; - xevent.xkey.same_screen = True;/* FIXME ? */ + memset (&xkey, 0, sizeof (xkey)); + xkey.type = (gdk_event->type == GDK_KEY_PRESS) ? KeyPress : KeyRelease; + xkey.window = GDK_WINDOW_XWINDOW (socket->plug_window); + xkey.root = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen)); + xkey.subwindow = None; + xkey.time = gdk_event->key.time; + xkey.x = 0; + xkey.y = 0; + xkey.x_root = 0; + xkey.y_root = 0; + xkey.state = gdk_event->key.state; + xkey.keycode = gdk_event->key.hardware_keycode; + xkey.same_screen = True;/* FIXME ? */ gdk_error_trap_push (); XSendEvent (GDK_WINDOW_XDISPLAY (socket->plug_window), GDK_WINDOW_XWINDOW (socket->plug_window), False, (mask_key_presses ? KeyPressMask : NoEventMask), - &xevent); + (XEvent *)&xkey); gdk_display_sync (gdk_screen_get_display (screen)); gdk_error_trap_pop (); } @@ -201,15 +202,16 @@ _gtk_socket_windowing_focus (GtkSocket *socket, void _gtk_socket_windowing_send_configure_event (GtkSocket *socket) { - XEvent event; + XConfigureEvent xconfigure; gint x, y; g_return_if_fail (socket->plug_window != NULL); - event.xconfigure.type = ConfigureNotify; + memset (&xconfigure, 0, sizeof (xconfigure)); + xconfigure.type = ConfigureNotify; - event.xconfigure.event = GDK_WINDOW_XWINDOW (socket->plug_window); - event.xconfigure.window = GDK_WINDOW_XWINDOW (socket->plug_window); + xconfigure.event = GDK_WINDOW_XWINDOW (socket->plug_window); + xconfigure.window = GDK_WINDOW_XWINDOW (socket->plug_window); /* The ICCCM says that synthetic events should have root relative * coordinates. We still aren't really ICCCM compliant, since @@ -219,19 +221,19 @@ _gtk_socket_windowing_send_configure_event (GtkSocket *socket) gdk_window_get_origin (socket->plug_window, &x, &y); gdk_error_trap_pop (); - event.xconfigure.x = x; - event.xconfigure.y = y; - event.xconfigure.width = GTK_WIDGET(socket)->allocation.width; - event.xconfigure.height = GTK_WIDGET(socket)->allocation.height; + xconfigure.x = x; + xconfigure.y = y; + xconfigure.width = GTK_WIDGET(socket)->allocation.width; + xconfigure.height = GTK_WIDGET(socket)->allocation.height; - event.xconfigure.border_width = 0; - event.xconfigure.above = None; - event.xconfigure.override_redirect = False; + xconfigure.border_width = 0; + xconfigure.above = None; + xconfigure.override_redirect = False; gdk_error_trap_push (); XSendEvent (GDK_WINDOW_XDISPLAY (socket->plug_window), GDK_WINDOW_XWINDOW (socket->plug_window), - False, NoEventMask, &event); + False, NoEventMask, (XEvent *)&xconfigure); gdk_display_sync (gtk_widget_get_display (GTK_WIDGET (socket))); gdk_error_trap_pop (); } diff --git a/gtk/gtktrayicon-x11.c b/gtk/gtktrayicon-x11.c index e85ad9c085..16d8bc35c7 100755 --- a/gtk/gtktrayicon-x11.c +++ b/gtk/gtktrayicon-x11.c @@ -266,6 +266,7 @@ gtk_tray_icon_send_manager_message (GtkTrayIcon *icon, XClientMessageEvent ev; Display *display; + memset (&ev, 0, sizeof (ev)); ev.type = ClientMessage; ev.window = window; ev.message_type = icon->priv->system_tray_opcode_atom; @@ -451,6 +452,7 @@ _gtk_tray_icon_send_message (GtkTrayIcon *icon, xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); + memset (&ev, 0, sizeof (ev)); ev.type = ClientMessage; ev.window = (Window)gtk_plug_get_id (GTK_PLUG (icon)); ev.format = 8; diff --git a/gtk/gtkxembed.c b/gtk/gtkxembed.c index 723ed93cd1..2c56b0ba4a 100644 --- a/gtk/gtkxembed.c +++ b/gtk/gtkxembed.c @@ -19,6 +19,7 @@ */ #include +#include #include "gtkmain.h" #include "gtkprivate.h" #include "gtkxembed.h" @@ -139,7 +140,7 @@ _gtk_xembed_send_message (GdkWindow *recipient, glong data2) { GdkDisplay *display; - XEvent xevent; + XClientMessageEvent xclient; if (!recipient) return; @@ -150,20 +151,21 @@ _gtk_xembed_send_message (GdkWindow *recipient, GTK_NOTE (PLUGSOCKET, g_message ("Sending %s", _gtk_xembed_message_name (message))); - xevent.xclient.window = GDK_WINDOW_XWINDOW (recipient); - xevent.xclient.type = ClientMessage; - xevent.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED"); - xevent.xclient.format = 32; - xevent.xclient.data.l[0] = gtk_xembed_get_time (); - xevent.xclient.data.l[1] = message; - xevent.xclient.data.l[2] = detail; - xevent.xclient.data.l[3] = data1; - xevent.xclient.data.l[4] = data2; + memset (&xclient, 0, sizeof (xclient)); + xclient.window = GDK_WINDOW_XWINDOW (recipient); + xclient.type = ClientMessage; + xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "_XEMBED"); + xclient.format = 32; + xclient.data.l[0] = gtk_xembed_get_time (); + xclient.data.l[1] = message; + xclient.data.l[2] = detail; + xclient.data.l[3] = data1; + xclient.data.l[4] = data2; gdk_error_trap_push (); XSendEvent (GDK_WINDOW_XDISPLAY(recipient), GDK_WINDOW_XWINDOW (recipient), - False, NoEventMask, &xevent); + False, NoEventMask, &xclient); gdk_display_sync (display); gdk_error_trap_pop (); }