Exemple #1
0
static void
primary_source_send (void                                *data,
                     struct gtk_primary_selection_source *source,
                     const char                          *mime_type,
                     int32_t                              fd)
{
  GdkWaylandSelection *wayland_selection = data;

  GDK_NOTE (EVENTS,
            g_message ("primary source send, source = %p, mime_type = %s, fd = %d",
                       source, mime_type, fd));

  if (!mime_type || !wayland_selection->primary_owner)
    {
      close (fd);
      return;
    }

  if (!gdk_wayland_selection_request_target (wayland_selection,
                                             wayland_selection->primary_owner,
                                             atoms[ATOM_PRIMARY],
                                             gdk_atom_intern (mime_type, FALSE),
                                             fd))
    gdk_wayland_selection_check_write (wayland_selection);
}
Exemple #2
0
void
gdk_wayland_selection_store (GdkWindow    *window,
                             GdkAtom       type,
                             GdkPropMode   mode,
                             const guchar *data,
                             gint          len)
{
  GdkDisplay *display = gdk_window_get_display (window);
  GdkWaylandSelection *selection = gdk_wayland_display_get_selection (display);
  GArray *array;

  if (type == gdk_atom_intern_static_string ("NULL"))
    return;

  array = g_array_new (TRUE, FALSE, sizeof (guchar));
  g_array_append_vals (array, data, len);

  if (selection->stored_selection.data)
    {
      if (mode != GDK_PROP_MODE_REPLACE &&
          type != selection->stored_selection.type)
        {
          gchar *type_str, *stored_str;

          type_str = gdk_atom_name (type);
          stored_str = gdk_atom_name (selection->stored_selection.type);

          g_warning (G_STRLOC ": Attempted to append/prepend selection data with "
                     "type %s into the current selection with type %s",
                     type_str, stored_str);
          g_free (type_str);
          g_free (stored_str);
          return;
        }

      /* In these cases we also replace the stored data, so we
       * apply the inverse operation into the just given data.
       */
      if (mode == GDK_PROP_MODE_APPEND)
        g_array_prepend_vals (array, selection->stored_selection.data,
                              selection->stored_selection.data_len - 1);
      else if (mode == GDK_PROP_MODE_PREPEND)
        g_array_append_vals (array, selection->stored_selection.data,
                             selection->stored_selection.data_len - 1);

      g_free (selection->stored_selection.data);
    }

  selection->stored_selection.source = window;
  selection->stored_selection.data_len = array->len;
  selection->stored_selection.data = (guchar *) g_array_free (array, FALSE);
  selection->stored_selection.type = type;

  gdk_wayland_selection_check_write (selection);
}
Exemple #3
0
static void
data_source_send (void                  *data,
                  struct wl_data_source *source,
                  const char            *mime_type,
                  int32_t                fd)
{
  GdkWaylandSelection *wayland_selection = data;
  GdkDragContext *context;
  GdkWindow *window;

  g_debug (G_STRLOC ": %s source = %p, mime_type = %s, fd = %d",
           G_STRFUNC, source, mime_type, fd);

  if (!mime_type)
    {
      close (fd);
      return;
    }

  context = gdk_wayland_drag_context_lookup_by_data_source (source);

  if (source == wayland_selection->dnd_source)
    window = wayland_selection->dnd_owner;
  else if (source == wayland_selection->clipboard_source)
    window = wayland_selection->clipboard_owner;
  else
    {
      close (fd);
      return;
    }

  if (!window)
    return;

  if (!gdk_wayland_selection_request_target (wayland_selection, window,
                                             gdk_atom_intern (mime_type, FALSE),
                                             fd))
    gdk_wayland_selection_check_write (wayland_selection);

  if (context)
    {
      _gdk_wayland_drag_context_emit_event (context, GDK_DROP_FINISHED,
                                            GDK_CURRENT_TIME);
      gdk_wayland_device_unset_grab (gdk_drag_context_get_device (context));
    }
}
Exemple #4
0
static void
data_source_send (void                  *data,
                  struct wl_data_source *source,
                  const char            *mime_type,
                  int32_t                fd)
{
  GdkWaylandSelection *wayland_selection = data;
  GdkWindow *window;
  GdkAtom selection;

  GDK_NOTE (EVENTS,
            g_message ("data source send, source = %p, mime_type = %s, fd = %d",
                       source, mime_type, fd));

  if (!mime_type)
    {
      close (fd);
      return;
    }

  if (source == wayland_selection->dnd_source)
    {
      window = wayland_selection->dnd_owner;
      selection = atoms[ATOM_DND];
    }
  else if (source == wayland_selection->clipboard_source)
    {
      window = wayland_selection->clipboard_owner;
      selection = atoms[ATOM_CLIPBOARD];
    }
  else
    {
      close (fd);
      return;
    }

  if (!window)
    return;

  if (!gdk_wayland_selection_request_target (wayland_selection, window,
                                             selection,
                                             gdk_atom_intern (mime_type, FALSE),
                                             fd))
    gdk_wayland_selection_check_write (wayland_selection);
}