mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-30 15:31:34 +00:00
x11: Use GdkX11Display::translate-event more
This commit is contained in:
parent
2d86c1a869
commit
4b33a34ce3
@ -54,10 +54,10 @@ struct GdkX11SelectionInputStreamPrivate {
|
|||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (GdkX11SelectionInputStream, gdk_x11_selection_input_stream, G_TYPE_INPUT_STREAM);
|
G_DEFINE_TYPE_WITH_PRIVATE (GdkX11SelectionInputStream, gdk_x11_selection_input_stream, G_TYPE_INPUT_STREAM);
|
||||||
|
|
||||||
static GdkFilterReturn
|
static GdkEvent *
|
||||||
gdk_x11_selection_input_stream_filter_event (GdkXEvent *xevent,
|
gdk_x11_selection_input_stream_translate_event (GdkDisplay *display,
|
||||||
GdkEvent *gdkevent,
|
const XEvent *xevent,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gdk_x11_selection_input_stream_has_data (GdkX11SelectionInputStream *stream)
|
gdk_x11_selection_input_stream_has_data (GdkX11SelectionInputStream *stream)
|
||||||
@ -161,7 +161,9 @@ gdk_x11_selection_input_stream_complete (GdkX11SelectionInputStream *stream)
|
|||||||
gdk_x11_selection_input_stream_flush (stream);
|
gdk_x11_selection_input_stream_flush (stream);
|
||||||
|
|
||||||
GDK_X11_DISPLAY (priv->display)->streams = g_slist_remove (GDK_X11_DISPLAY (priv->display)->streams, stream);
|
GDK_X11_DISPLAY (priv->display)->streams = g_slist_remove (GDK_X11_DISPLAY (priv->display)->streams, stream);
|
||||||
gdk_window_remove_filter (NULL, gdk_x11_selection_input_stream_filter_event, stream);
|
g_signal_handlers_disconnect_by_func (priv->display,
|
||||||
|
gdk_x11_selection_input_stream_translate_event,
|
||||||
|
stream);
|
||||||
|
|
||||||
g_object_unref (stream);
|
g_object_unref (stream);
|
||||||
}
|
}
|
||||||
@ -376,14 +378,13 @@ err:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static GdkFilterReturn
|
static GdkEvent *
|
||||||
gdk_x11_selection_input_stream_filter_event (GdkXEvent *xev,
|
gdk_x11_selection_input_stream_translate_event (GdkDisplay *display,
|
||||||
GdkEvent *gdkevent,
|
const XEvent *xevent,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GdkX11SelectionInputStream *stream = GDK_X11_SELECTION_INPUT_STREAM (data);
|
GdkX11SelectionInputStream *stream = GDK_X11_SELECTION_INPUT_STREAM (data);
|
||||||
GdkX11SelectionInputStreamPrivate *priv = gdk_x11_selection_input_stream_get_instance_private (stream);
|
GdkX11SelectionInputStreamPrivate *priv = gdk_x11_selection_input_stream_get_instance_private (stream);
|
||||||
XEvent *xevent = xev;
|
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
Window xwindow;
|
Window xwindow;
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
@ -395,7 +396,7 @@ gdk_x11_selection_input_stream_filter_event (GdkXEvent *xev,
|
|||||||
|
|
||||||
if (xevent->xany.display != xdisplay ||
|
if (xevent->xany.display != xdisplay ||
|
||||||
xevent->xany.window != xwindow)
|
xevent->xany.window != xwindow)
|
||||||
return GDK_FILTER_CONTINUE;
|
return NULL;
|
||||||
|
|
||||||
switch (xevent->type)
|
switch (xevent->type)
|
||||||
{
|
{
|
||||||
@ -403,7 +404,7 @@ gdk_x11_selection_input_stream_filter_event (GdkXEvent *xev,
|
|||||||
if (!priv->incr ||
|
if (!priv->incr ||
|
||||||
xevent->xproperty.atom != priv->xproperty ||
|
xevent->xproperty.atom != priv->xproperty ||
|
||||||
xevent->xproperty.state != PropertyNewValue)
|
xevent->xproperty.state != PropertyNewValue)
|
||||||
return GDK_FILTER_CONTINUE;
|
return NULL;
|
||||||
|
|
||||||
bytes = get_selection_property (xdisplay, xwindow, xevent->xproperty.atom, &type, &format);
|
bytes = get_selection_property (xdisplay, xwindow, xevent->xproperty.atom, &type, &format);
|
||||||
if (bytes == NULL)
|
if (bytes == NULL)
|
||||||
@ -431,7 +432,7 @@ gdk_x11_selection_input_stream_filter_event (GdkXEvent *xev,
|
|||||||
|
|
||||||
XDeleteProperty (xdisplay, xwindow, xevent->xproperty.atom);
|
XDeleteProperty (xdisplay, xwindow, xevent->xproperty.atom);
|
||||||
|
|
||||||
return GDK_FILTER_CONTINUE;
|
return NULL;
|
||||||
|
|
||||||
case SelectionNotify:
|
case SelectionNotify:
|
||||||
{
|
{
|
||||||
@ -440,12 +441,12 @@ gdk_x11_selection_input_stream_filter_event (GdkXEvent *xev,
|
|||||||
/* selection is not for us */
|
/* selection is not for us */
|
||||||
if (priv->xselection != xevent->xselection.selection ||
|
if (priv->xselection != xevent->xselection.selection ||
|
||||||
priv->xtarget != xevent->xselection.target)
|
priv->xtarget != xevent->xselection.target)
|
||||||
return GDK_FILTER_CONTINUE;
|
return NULL;
|
||||||
|
|
||||||
/* We already received a selectionNotify before */
|
/* We already received a selectionNotify before */
|
||||||
if (priv->pending_task == NULL ||
|
if (priv->pending_task == NULL ||
|
||||||
g_task_get_source_tag (priv->pending_task) != gdk_x11_selection_input_stream_new_async)
|
g_task_get_source_tag (priv->pending_task) != gdk_x11_selection_input_stream_new_async)
|
||||||
return GDK_FILTER_CONTINUE;
|
return NULL;
|
||||||
|
|
||||||
GDK_NOTE(SELECTION, g_printerr ("%s:%s: got SelectionNotify\n", priv->selection, priv->target));
|
GDK_NOTE(SELECTION, g_printerr ("%s:%s: got SelectionNotify\n", priv->selection, priv->target));
|
||||||
|
|
||||||
@ -497,10 +498,10 @@ gdk_x11_selection_input_stream_filter_event (GdkXEvent *xev,
|
|||||||
|
|
||||||
g_object_unref (task);
|
g_object_unref (task);
|
||||||
}
|
}
|
||||||
return GDK_FILTER_REMOVE;
|
return gdk_event_new (GDK_NOTHING);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return GDK_FILTER_CONTINUE;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,7 +530,7 @@ gdk_x11_selection_input_stream_new_async (GdkDisplay *display,
|
|||||||
priv->property = g_strdup_printf ("GDK_SELECTION_%p", stream);
|
priv->property = g_strdup_printf ("GDK_SELECTION_%p", stream);
|
||||||
priv->xproperty = gdk_x11_get_xatom_by_name_for_display (display, priv->property);
|
priv->xproperty = gdk_x11_get_xatom_by_name_for_display (display, priv->property);
|
||||||
|
|
||||||
gdk_window_add_filter (NULL, gdk_x11_selection_input_stream_filter_event, stream);
|
g_signal_connect (display, "translate-event", G_CALLBACK (gdk_x11_selection_input_stream_translate_event), stream);
|
||||||
|
|
||||||
XConvertSelection (GDK_DISPLAY_XDISPLAY (display),
|
XConvertSelection (GDK_DISPLAY_XDISPLAY (display),
|
||||||
priv->xselection,
|
priv->xselection,
|
||||||
|
@ -147,10 +147,10 @@ gdk_x11_pending_selection_notify_send (GdkX11PendingSelectionNotify *notify,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkFilterReturn
|
static GdkEvent *
|
||||||
gdk_x11_selection_output_stream_filter_event (GdkXEvent *xevent,
|
gdk_x11_selection_output_stream_translate_event (GdkDisplay *display,
|
||||||
GdkEvent *gdkevent,
|
const XEvent *xevent,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gdk_x11_selection_output_stream_can_flush (GdkX11SelectionOutputStream *stream)
|
gdk_x11_selection_output_stream_can_flush (GdkX11SelectionOutputStream *stream)
|
||||||
@ -492,7 +492,9 @@ gdk_x11_selection_output_stream_invoke_close (gpointer stream)
|
|||||||
GdkX11SelectionOutputStreamPrivate *priv = gdk_x11_selection_output_stream_get_instance_private (stream);
|
GdkX11SelectionOutputStreamPrivate *priv = gdk_x11_selection_output_stream_get_instance_private (stream);
|
||||||
|
|
||||||
GDK_X11_DISPLAY (priv->display)->streams = g_slist_remove (GDK_X11_DISPLAY (priv->display)->streams, stream);
|
GDK_X11_DISPLAY (priv->display)->streams = g_slist_remove (GDK_X11_DISPLAY (priv->display)->streams, stream);
|
||||||
gdk_window_remove_filter (NULL, gdk_x11_selection_output_stream_filter_event, stream);
|
g_signal_handlers_disconnect_by_func (priv->display,
|
||||||
|
gdk_x11_selection_output_stream_translate_event,
|
||||||
|
stream);
|
||||||
|
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
@ -587,21 +589,20 @@ gdk_x11_selection_output_stream_init (GdkX11SelectionOutputStream *stream)
|
|||||||
priv->data = g_byte_array_new ();
|
priv->data = g_byte_array_new ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static GdkFilterReturn
|
static GdkEvent *
|
||||||
gdk_x11_selection_output_stream_filter_event (GdkXEvent *xev,
|
gdk_x11_selection_output_stream_translate_event (GdkDisplay *display,
|
||||||
GdkEvent *gdkevent,
|
const XEvent *xevent,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GdkX11SelectionOutputStream *stream = GDK_X11_SELECTION_OUTPUT_STREAM (data);
|
GdkX11SelectionOutputStream *stream = GDK_X11_SELECTION_OUTPUT_STREAM (data);
|
||||||
GdkX11SelectionOutputStreamPrivate *priv = gdk_x11_selection_output_stream_get_instance_private (stream);
|
GdkX11SelectionOutputStreamPrivate *priv = gdk_x11_selection_output_stream_get_instance_private (stream);
|
||||||
XEvent *xevent = xev;
|
|
||||||
Display *xdisplay;
|
Display *xdisplay;
|
||||||
|
|
||||||
xdisplay = gdk_x11_display_get_xdisplay (priv->display);
|
xdisplay = gdk_x11_display_get_xdisplay (priv->display);
|
||||||
|
|
||||||
if (xevent->xany.display != xdisplay ||
|
if (xevent->xany.display != xdisplay ||
|
||||||
xevent->xany.window != priv->xwindow)
|
xevent->xany.window != priv->xwindow)
|
||||||
return GDK_FILTER_CONTINUE;
|
return NULL;
|
||||||
|
|
||||||
switch (xevent->type)
|
switch (xevent->type)
|
||||||
{
|
{
|
||||||
@ -609,14 +610,18 @@ gdk_x11_selection_output_stream_filter_event (GdkXEvent *xev,
|
|||||||
if (!priv->incr ||
|
if (!priv->incr ||
|
||||||
xevent->xproperty.atom != priv->xproperty ||
|
xevent->xproperty.atom != priv->xproperty ||
|
||||||
xevent->xproperty.state != PropertyDelete)
|
xevent->xproperty.state != PropertyDelete)
|
||||||
return GDK_FILTER_CONTINUE;
|
return NULL;
|
||||||
|
|
||||||
GDK_NOTE(SELECTION, g_printerr ("%s:%s: got PropertyNotify Delete during INCR\n",
|
GDK_NOTE(SELECTION, g_printerr ("%s:%s: got PropertyNotify Delete during INCR\n",
|
||||||
priv->selection, priv->target));
|
priv->selection, priv->target));
|
||||||
return GDK_FILTER_CONTINUE;
|
priv->delete_pending = FALSE;
|
||||||
|
if (gdk_x11_selection_output_stream_needs_flush (stream) &
|
||||||
|
gdk_x11_selection_output_stream_can_flush (stream))
|
||||||
|
gdk_x11_selection_output_stream_perform_flush (stream);
|
||||||
|
return NULL;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return GDK_FILTER_CONTINUE;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -652,7 +657,10 @@ gdk_x11_selection_output_stream_new (GdkDisplay *display,
|
|||||||
priv->format = format;
|
priv->format = format;
|
||||||
priv->timestamp = timestamp;
|
priv->timestamp = timestamp;
|
||||||
|
|
||||||
gdk_window_add_filter (NULL, gdk_x11_selection_output_stream_filter_event, stream);
|
g_signal_connect (display,
|
||||||
|
"translate-event",
|
||||||
|
G_CALLBACK (gdk_x11_selection_output_stream_translate_event),
|
||||||
|
stream);
|
||||||
|
|
||||||
return G_OUTPUT_STREAM (stream);
|
return G_OUTPUT_STREAM (stream);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user