Esempio n. 1
0
static void
data_source_cancelled (void                  *data,
                       struct wl_data_source *source)
{
  GdkWaylandSelection *wayland_selection = data;
  GdkDragContext *context;
  GdkDisplay *display;

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

  display = gdk_display_get_default ();

  if (source == wayland_selection->dnd_source)
    {
      gdk_wayland_selection_unset_data_source (display, atoms[ATOM_DND]);

      context = gdk_wayland_drag_context_lookup_by_data_source (source);

      if (context)
        gdk_wayland_device_unset_grab (gdk_drag_context_get_device (context));
    }
  else if (source == wayland_selection->clipboard_source)
    gdk_wayland_selection_unset_data_source (display, atoms[ATOM_CLIPBOARD]);
}
Esempio n. 2
0
static void
data_source_cancelled (void                  *data,
                       struct wl_data_source *source)
{
  GdkWaylandSelection *wayland_selection = data;
  GdkDragContext *context;
  GdkDisplay *display;
  GdkAtom atom;

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

  display = gdk_display_get_default ();

  if (source == wayland_selection->dnd_source)
    atom = atoms[ATOM_DND];
  else if (source == wayland_selection->clipboard_source)
    atom = atoms[ATOM_CLIPBOARD];
  else
    return;

  gdk_wayland_selection_unset_data_source (display, atom);
  gdk_selection_owner_set (NULL, atom, GDK_CURRENT_TIME, TRUE);

  if (source == wayland_selection->dnd_source)
    {
      context = gdk_wayland_drag_context_lookup_by_data_source (source);

      if (context)
        gdk_wayland_device_unset_grab (gdk_drag_context_get_device (context));
    }
}
Esempio n. 3
0
static void
gcal_event_widget_drag_begin (GtkWidget      *widget,
                              GdkDragContext *context)
{
  GcalEventWidget *self;
  cairo_surface_t *surface;
  GdkWindow *window;
  GdkDevice *device;
  gint x, y;
  GtkAllocation allocation;

  self = GCAL_EVENT_WIDGET (widget);
  window = gtk_widget_get_window (widget);
  device = gdk_drag_context_get_device (context);

  if (self->read_only)
    {
      gtk_drag_cancel (context);
      return;
    }

  /* Setup the drag n' drop icon */
  surface = get_dnd_icon (widget);

  gtk_drag_set_icon_surface (context, surface);

  /* reposition drag surface to the point the GCalEvent was */
  gtk_widget_get_allocation (widget, &allocation);
  gdk_window_get_device_position (window, device, &x, &y, NULL);
  gdk_drag_context_set_hotspot (context, x - allocation.x, y - allocation.y);

  g_clear_pointer (&surface, cairo_surface_destroy);
}
Esempio n. 4
0
void DragAndDropHandler::finishDrag(GdkDragContext* context)
{
#if GTK_CHECK_VERSION(3, 16, 0)
    // This can happen when attempting to call finish drag from webkitWebViewBaseDragEnd()
    // for a obsolete DnD operation that got previously cancelled in startDrag().
    if (m_dragContext.get() != context)
        return;

    if (!m_draggingSelectionData)
        return;

    m_dragContext = nullptr;
    m_draggingSelectionData = nullptr;
#else
    if (!m_draggingSelectionDataMap.remove(context))
        return;
#endif

    GdkDevice* device = gdk_drag_context_get_device(context);
    int x = 0, y = 0;
    gdk_device_get_window_at_position(device, &x, &y);
    int xRoot = 0, yRoot = 0;
    gdk_device_get_position(device, nullptr, &xRoot, &yRoot);
    m_page.dragEnded(IntPoint(x, y), IntPoint(xRoot, yRoot), gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context)));
}
Esempio n. 5
0
void DragAndDropHandler::finishDrag(GdkDragContext* context)
{
    if (!m_draggingDataObjects.remove(context))
        return;

    GdkDevice* device = gdk_drag_context_get_device(context);
    int x = 0, y = 0;
    gdk_device_get_window_at_position(device, &x, &y);
    int xRoot = 0, yRoot = 0;
    gdk_device_get_position(device, nullptr, &xRoot, &yRoot);
    m_page.dragEnded(IntPoint(x, y), IntPoint(xRoot, yRoot), gdkDragActionToDragOperation(gdk_drag_context_get_selected_action(context)));
}
Esempio n. 6
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));
    }
}