gdk: Remove GdkEventClient

... and all APIs making use of it.

That code like it hasn't been touched in years, Google codesearch
didn't find any users and most importantly it's a horrendous API, so
let's just make it die instead of having to port it over to
non-GdkNativeWindow usage, which would be required for multi-backend
GDK.

http://mail.gnome.org/archives/gtk-devel-list/2011-January/msg00049.html
This commit is contained in:
Benjamin Otte 2011-02-01 06:30:27 +01:00
parent 040b21e7d7
commit c332ac207a
11 changed files with 5 additions and 393 deletions

View File

@ -120,7 +120,6 @@ gdk_display_get_event
gdk_display_peek_event
gdk_display_put_event
gdk_display_has_pending
gdk_display_add_client_message_filter
gdk_display_set_double_click_time
gdk_display_set_double_click_distance
gdk_display_get_pointer
@ -204,7 +203,6 @@ gdk_screen_get_monitor_at_window
gdk_screen_get_monitor_height_mm
gdk_screen_get_monitor_width_mm
gdk_screen_get_monitor_plug_name
gdk_screen_broadcast_client_message
gdk_screen_get_setting
gdk_screen_get_font_options
gdk_screen_set_font_options
@ -777,12 +775,6 @@ gdk_events_get_distance
gdk_event_handler_set
GdkEventFunc
<SUBSECTION>
gdk_event_send_client_message
gdk_event_send_client_message_for_display
gdk_event_send_clientmessage_toall
gdk_add_client_message_filter
<SUBSECTION>
gdk_get_show_events
gdk_set_show_events
@ -822,7 +814,6 @@ GdkEventSelection
GdkNativeWindow
GdkEventDND
GdkEventProximity
GdkEventClient
GdkEventWindowState
GdkEventSetting
GdkEventOwnerChange

View File

@ -1,7 +1,6 @@
/* This file lists all exported symbols. It is used to generate
* the gdk.def file used to control exports on Windows.
*/
gdk_add_client_message_filter
gdk_add_option_entries_libgtk_only
gdk_app_launch_context_get_type G_GNUC_CONST
gdk_app_launch_context_new
@ -79,7 +78,6 @@ gdk_device_type_get_type G_GNUC_CONST
gdk_device_ungrab
gdk_device_warp
gdk_disable_multidevice
gdk_display_add_client_message_filter
gdk_display_beep
gdk_display_close
gdk_display_device_is_grabbed
@ -173,9 +171,6 @@ gdk_event_new
gdk_event_peek
gdk_event_put
gdk_event_request_motions
gdk_event_send_client_message
gdk_event_send_client_message_for_display
gdk_event_send_clientmessage_toall
gdk_event_set_device
gdk_event_set_screen
gdk_event_set_source_device
@ -260,7 +255,6 @@ gdk_rgba_get_type
gdk_rgba_hash
gdk_rgba_parse
gdk_rgba_to_string
gdk_screen_broadcast_client_message
gdk_screen_get_active_window
gdk_screen_get_default
gdk_screen_get_display

View File

@ -523,48 +523,6 @@ gdk_flush (void)
g_slist_free (list);
}
/**
* gdk_event_send_client_message:
* @event: the #GdkEvent to send, which should be a #GdkEventClient.
* @winid: the window to send the X ClientMessage event to.
*
* Sends an X ClientMessage event to a given window (which must be
* on the default #GdkDisplay.)
* This could be used for communicating between different applications,
* though the amount of data is limited to 20 bytes.
*
* Return value: non-zero on success.
**/
gboolean
gdk_event_send_client_message (GdkEvent *event,
GdkNativeWindow winid)
{
g_return_val_if_fail (event != NULL, FALSE);
return gdk_event_send_client_message_for_display (gdk_display_get_default (),
event, winid);
}
/**
* gdk_event_send_clientmessage_toall:
* @event: the #GdkEvent to send, which should be a #GdkEventClient.
*
* Sends an X ClientMessage event to all toplevel windows on the default
* #GdkScreen.
*
* Toplevel windows are determined by checking for the WM_STATE property, as
* described in the Inter-Client Communication Conventions Manual (ICCCM).
* If no windows are found with the WM_STATE property set, the message is sent
* to all children of the root window.
**/
void
gdk_event_send_clientmessage_toall (GdkEvent *event)
{
g_return_if_fail (event != NULL);
gdk_screen_broadcast_client_message (gdk_screen_get_default (), event);
}
void
_gdk_display_enable_motion_hints (GdkDisplay *display,
GdkDevice *device)
@ -1675,76 +1633,6 @@ gdk_display_list_devices (GdkDisplay *display)
return GDK_DISPLAY_GET_CLASS(display)->list_devices (display);
}
/**
* gdk_event_send_client_message_for_display:
* @display: the #GdkDisplay for the window where the message is to be sent.
* @event: the #GdkEvent to send, which should be a #GdkEventClient.
* @winid: the window to send the client message to.
*
* On X11, sends an X ClientMessage event to a given window. On
* Windows, sends a message registered with the name
* GDK_WIN32_CLIENT_MESSAGE.
*
* This could be used for communicating between different
* applications, though the amount of data is limited to 20 bytes on
* X11, and to just four bytes on Windows.
*
* Returns: non-zero on success.
*
* Since: 2.2
*/
gboolean
gdk_event_send_client_message_for_display (GdkDisplay *display,
GdkEvent *event,
GdkNativeWindow winid)
{
return GDK_DISPLAY_GET_CLASS(display)->send_client_message (display, event, winid);
}
/**
* gdk_display_add_client_message_filter: (skip)
* @display: a #GdkDisplay for which this message filter applies
* @message_type: the type of ClientMessage events to receive.
* This will be checked against the @message_type field
* of the XClientMessage event struct.
* @func: the function to call to process the event.
* @data: user data to pass to @func.
*
* Adds a filter to be called when X ClientMessage events are received.
* See gdk_window_add_filter() if you are interested in filtering other
* types of events.
*
* Since: 2.2
**/
void
gdk_display_add_client_message_filter (GdkDisplay *display,
GdkAtom message_type,
GdkFilterFunc func,
gpointer data)
{
GDK_DISPLAY_GET_CLASS(display)->add_client_message_filter (display, message_type, func, data);
}
/**
* gdk_add_client_message_filter: (skip)
* @message_type: the type of ClientMessage events to receive. This will be
* checked against the <structfield>message_type</structfield> field of the
* XClientMessage event struct.
* @func: the function to call to process the event.
* @data: user data to pass to @func.
*
* Adds a filter to the default display to be called when X ClientMessage events
* are received. See gdk_display_add_client_message_filter().
**/
void
gdk_add_client_message_filter (GdkAtom message_type,
GdkFilterFunc func,
gpointer data)
{
gdk_display_add_client_message_filter (gdk_display_get_default (),
message_type, func, data);
}
static GdkAppLaunchContext *
gdk_display_real_get_app_launch_context (GdkDisplay *display)
{

View File

@ -80,11 +80,6 @@ void gdk_display_put_event (GdkDisplay *display,
const GdkEvent *event);
gboolean gdk_display_has_pending (GdkDisplay *display);
void gdk_display_add_client_message_filter (GdkDisplay *display,
GdkAtom message_type,
GdkFilterFunc func,
gpointer data);
void gdk_display_set_double_click_time (GdkDisplay *display,
guint msec);
void gdk_display_set_double_click_distance (GdkDisplay *display,

View File

@ -163,13 +163,6 @@ struct _GdkDisplayClass
gint y);
GList * (*list_devices) (GdkDisplay *display);
gboolean (*send_client_message) (GdkDisplay *display,
GdkEvent *event,
GdkNativeWindow winid);
void (*add_client_message_filter) (GdkDisplay *display,
GdkAtom message_type,
GdkFilterFunc func,
gpointer data);
GdkAppLaunchContext * (*get_app_launch_context) (GdkDisplay *display);
GdkNativeWindow (*get_drag_protocol) (GdkDisplay *display,
GdkNativeWindow winid,

View File

@ -89,7 +89,6 @@ typedef struct _GdkEventProperty GdkEventProperty;
typedef struct _GdkEventSelection GdkEventSelection;
typedef struct _GdkEventOwnerChange GdkEventOwnerChange;
typedef struct _GdkEventProximity GdkEventProximity;
typedef struct _GdkEventClient GdkEventClient;
typedef struct _GdkEventDND GdkEventDND;
typedef struct _GdkEventWindowState GdkEventWindowState;
typedef struct _GdkEventSetting GdkEventSetting;
@ -874,35 +873,6 @@ struct _GdkEventProximity
GdkDevice *device;
};
/**
* GdkEventClient:
* @type: the type of the event (%GDK_CLIENT_EVENT).
* @window: the window which received the event.
* @send_event: %TRUE if the event was sent explicitly (e.g. using
* <function>XSendEvent</function>).
* @message_type: the type of the message, which can be defined by the
* application.
* @data_format: the format of the data, given as the number of bits in each
* data element, i.e. 8, 16, or 32. 8-bit data uses the b array of the
* data union, 16-bit data uses the s array, and 32-bit data uses the l
* array.
*
* An event sent by another client application.
*/
struct _GdkEventClient
{
GdkEventType type;
GdkWindow *window;
gint8 send_event;
GdkAtom message_type;
gushort data_format;
union {
char b[20];
short s[10];
long l[5];
} data;
};
/**
* GdkEventSetting:
* @type: the type of the event (%GDK_SETTING).
@ -1060,7 +1030,6 @@ union _GdkEvent
GdkEventSelection selection;
GdkEventOwnerChange owner_change;
GdkEventProximity proximity;
GdkEventClient client;
GdkEventDND dnd;
GdkEventWindowState window_state;
GdkEventSetting setting;
@ -1125,19 +1094,9 @@ gboolean gdk_get_show_events (void);
gboolean gdk_setting_get (const gchar *name,
GValue *value);
void gdk_add_client_message_filter (GdkAtom message_type,
GdkFilterFunc func,
gpointer data);
gboolean gdk_event_send_client_message (GdkEvent *event,
GdkNativeWindow winid);
void gdk_event_send_clientmessage_toall (GdkEvent *event);
#endif /* GDK_MULTIHEAD_SAFE */
gboolean gdk_event_send_client_message_for_display (GdkDisplay *display,
GdkEvent *event,
GdkNativeWindow winid);
G_END_DECLS
#endif /* __GDK_EVENTS_H__ */

View File

@ -934,32 +934,6 @@ gdk_screen_get_window_stack (GdkScreen *screen)
return GDK_SCREEN_GET_CLASS(screen)->get_window_stack (screen);
}
/**
* gdk_screen_broadcast_client_message:
* @screen: the #GdkScreen where the event will be broadcasted.
* @event: the #GdkEvent.
*
* On X11, sends an X ClientMessage event to all toplevel windows on
* @screen.
*
* Toplevel windows are determined by checking for the WM_STATE property,
* as described in the Inter-Client Communication Conventions Manual (ICCCM).
* If no windows are found with the WM_STATE property set, the message is
* sent to all children of the root window.
*
* On Windows, broadcasts a message registered with the name
* GDK_WIN32_CLIENT_MESSAGE to all top-level windows. The amount of
* data is limited to one long, i.e. four bytes.
*
* Since: 2.2
*/
void
gdk_screen_broadcast_client_message (GdkScreen *screen,
GdkEvent *event)
{
return GDK_SCREEN_GET_CLASS(screen)->broadcast_client_message (screen, event);
}
/**
* gdk_screen_get_setting:
* @screen: the #GdkScreen where the setting is located

View File

@ -74,9 +74,6 @@ gint gdk_screen_get_monitor_height_mm (GdkScreen *screen,
gchar * gdk_screen_get_monitor_plug_name (GdkScreen *screen,
gint monitor_num);
void gdk_screen_broadcast_client_message (GdkScreen *screen,
GdkEvent *event);
GdkScreen *gdk_screen_get_default (void);
gboolean gdk_screen_get_setting (GdkScreen *screen,

View File

@ -846,56 +846,12 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
break;
case ClientMessage:
{
GList *tmp_list;
GdkFilterReturn result = GDK_FILTER_CONTINUE;
GdkAtom message_type = gdk_x11_xatom_to_atom_for_display (display, xevent->xclient.message_type);
GDK_NOTE (EVENTS,
g_message ("client message:\twindow: %ld",
xevent->xclient.window));
tmp_list = display_x11->client_filters;
while (tmp_list)
{
GdkClientFilter *filter = tmp_list->data;
tmp_list = tmp_list->next;
if (filter->type == message_type)
{
result = (*filter->function) (xevent, event, filter->data);
if (result != GDK_FILTER_CONTINUE)
break;
}
}
switch (result)
{
case GDK_FILTER_REMOVE:
return_val = FALSE;
break;
case GDK_FILTER_TRANSLATE:
return_val = TRUE;
break;
case GDK_FILTER_CONTINUE:
/* Send unknown ClientMessage's on to Gtk for it to use */
if (window == NULL)
{
return_val = FALSE;
}
else
{
event->client.type = GDK_CLIENT_EVENT;
event->client.window = window;
event->client.message_type = message_type;
event->client.data_format = xevent->xclient.format;
memcpy(&event->client.data, &xevent->xclient.data,
sizeof(event->client.data));
}
break;
}
}
GDK_NOTE (EVENTS,
g_message ("client message:\twindow: %ld",
xevent->xclient.window));
/* Not currently handled */
return_val = FALSE;
break;
case MappingNotify:
@ -1771,10 +1727,6 @@ gdk_x11_display_finalize (GObject *object)
/* Leader Window */
XDestroyWindow (display_x11->xdisplay, display_x11->leader_window);
/* list of filters for client messages */
g_list_foreach (display_x11->client_filters, (GFunc) g_free, NULL);
g_list_free (display_x11->client_filters);
/* List of event window extraction functions */
g_slist_foreach (display_x11->event_types, (GFunc)g_free, NULL);
g_slist_free (display_x11->event_types);
@ -2311,45 +2263,6 @@ gdk_x11_display_list_devices (GdkDisplay *display)
return GDK_X11_DISPLAY (display)->input_devices;
}
static gboolean
gdk_x11_display_send_client_message (GdkDisplay *display,
GdkEvent *event,
GdkNativeWindow winid)
{
XEvent sev;
g_return_val_if_fail(event != NULL, FALSE);
/* Set up our event to send, with the exception of its target window */
sev.xclient.type = ClientMessage;
sev.xclient.display = GDK_DISPLAY_XDISPLAY (display);
sev.xclient.format = event->client.data_format;
sev.xclient.window = winid;
memcpy(&sev.xclient.data, &event->client.data, sizeof (sev.xclient.data));
sev.xclient.message_type = gdk_x11_atom_to_xatom_for_display (display, event->client.message_type);
return _gdk_x11_display_send_xevent (display, winid, False, NoEventMask, &sev);
}
static void
gdk_x11_display_add_client_message_filter (GdkDisplay *display,
GdkAtom message_type,
GdkFilterFunc func,
gpointer data)
{
GdkClientFilter *filter;
g_return_if_fail (GDK_IS_DISPLAY (display));
filter = g_new (GdkClientFilter, 1);
filter->type = message_type;
filter->function = func;
filter->data = data;
GDK_X11_DISPLAY(display)->client_filters =
g_list_append (GDK_X11_DISPLAY (display)->client_filters,
filter);
}
/**
* gdk_x11_register_standard_event_type:
* @display: a #GdkDisplay
@ -2747,8 +2660,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
display_class->supports_input_shapes = gdk_x11_display_supports_input_shapes;
display_class->supports_composite = gdk_x11_display_supports_composite;
display_class->list_devices = gdk_x11_display_list_devices;
display_class->send_client_message = gdk_x11_display_send_client_message;
display_class->add_client_message_filter = gdk_x11_display_add_client_message_filter;
display_class->get_app_launch_context = _gdk_x11_display_get_app_launch_context;
display_class->get_drag_protocol = _gdk_x11_display_get_drag_protocol;
display_class->get_cursor_for_type = _gdk_x11_display_get_cursor_for_type;

View File

@ -95,9 +95,6 @@ struct _GdkX11Display
GdkWindow *leader_gdk_window;
gboolean leader_window_title_set;
/* list of filters for client messages */
GList *client_filters;
/* List of functions to go from extension event => X window */
GSList *event_types;

View File

@ -1086,92 +1086,6 @@ gdk_x11_screen_get_window_stack (GdkScreen *screen)
return ret;
}
/* Sends a ClientMessage to all toplevel client windows */
static gboolean
gdk_event_send_client_message_to_all_recurse (GdkDisplay *display,
XEvent *xev,
guint32 xid,
guint level)
{
Atom type = None;
int format;
unsigned long nitems, after;
unsigned char *data;
Window *ret_children, ret_root, ret_parent;
unsigned int ret_nchildren;
gboolean send = FALSE;
gboolean found = FALSE;
gboolean result = FALSE;
int i;
gdk_x11_display_error_trap_push (display);
if (XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), xid,
gdk_x11_get_xatom_by_name_for_display (display, "WM_STATE"),
0, 0, False, AnyPropertyType,
&type, &format, &nitems, &after, &data) != Success)
goto out;
if (type)
{
send = TRUE;
XFree (data);
}
else
{
/* OK, we're all set, now let's find some windows to send this to */
if (!XQueryTree (GDK_DISPLAY_XDISPLAY (display), xid,
&ret_root, &ret_parent,
&ret_children, &ret_nchildren))
goto out;
for(i = 0; i < ret_nchildren; i++)
if (gdk_event_send_client_message_to_all_recurse (display, xev, ret_children[i], level + 1))
found = TRUE;
XFree (ret_children);
}
if (send || (!found && (level == 1)))
{
xev->xclient.window = xid;
_gdk_x11_display_send_xevent (display, xid, False, NoEventMask, xev);
}
result = send || found;
out:
gdk_x11_display_error_trap_pop_ignored (display);
return result;
}
static void
gdk_x11_screen_broadcast_client_message (GdkScreen *screen,
GdkEvent *event)
{
XEvent sev;
GdkWindow *root_window;
g_return_if_fail (event != NULL);
root_window = gdk_screen_get_root_window (screen);
/* Set up our event to send, with the exception of its target window */
sev.xclient.type = ClientMessage;
sev.xclient.display = GDK_WINDOW_XDISPLAY (root_window);
sev.xclient.format = event->client.data_format;
memcpy(&sev.xclient.data, &event->client.data, sizeof (sev.xclient.data));
sev.xclient.message_type =
gdk_x11_atom_to_xatom_for_display (GDK_WINDOW_DISPLAY (root_window),
event->client.message_type);
gdk_event_send_client_message_to_all_recurse (gdk_screen_get_display (screen),
&sev,
GDK_WINDOW_XID (root_window),
0);
}
static gboolean
check_transform (const gchar *xsettings_name,
GType src_type,
@ -1691,7 +1605,6 @@ gdk_x11_screen_class_init (GdkX11ScreenClass *klass)
screen_class->make_display_name = gdk_x11_screen_make_display_name;
screen_class->get_active_window = gdk_x11_screen_get_active_window;
screen_class->get_window_stack = gdk_x11_screen_get_window_stack;
screen_class->broadcast_client_message = gdk_x11_screen_broadcast_client_message;
screen_class->get_setting = gdk_x11_screen_get_setting;
screen_class->visual_get_best_depth = _gdk_x11_screen_visual_get_best_depth;
screen_class->visual_get_best_type = _gdk_x11_screen_visual_get_best_type;