Exemplo n.º 1
0
static VALUE
rg_m_owner_set(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
{
    VALUE owner, selection, time, send_event;
    int ret;

    if (argc == 4){
        rb_scan_args(argc, argv, "40", &owner, &selection, &time, &send_event);
        ret = gdk_selection_owner_set(GDK_WINDOW(RVAL2GOBJ(owner)), 
                                      RVAL2ATOM(selection), 
                                      NUM2UINT(time), RVAL2CBOOL(send_event));
    } else {
#if GTK_CHECK_VERSION(2,2,0)
      VALUE display = Qnil;
      rb_scan_args(argc, argv, "50", &display, &owner, &selection, &time, &send_event);
      ret = gdk_selection_owner_set_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)),
                                                GDK_WINDOW(RVAL2GOBJ(owner)), 
                                                RVAL2ATOM(selection), 
                                                NUM2UINT(time), RVAL2CBOOL(send_event));
#else
      rb_raise(rb_eArgError, "Wrong number of arguments: %d", argc);
#endif

    }
    return CBOOL2RVAL(ret);
}
Exemplo n.º 2
0
void process_dnd_source(GdkWindow *window, GdkEvent *event) {
    switch(event->type) {
        case GDK_MOTION_NOTIFY:
            process_dnd_source_mouse_motion(window, &event->motion);
            break;
        case GDK_BUTTON_RELEASE:
            process_dnd_source_mouse_release(window, &event->button);
            break;
        case GDK_DRAG_STATUS:
            process_dnd_source_drag_status(window, &event->dnd);
            break;
        case GDK_DROP_FINISHED:
            process_dnd_source_drop_finished(window, &event->dnd);
            break;
        case GDK_KEY_PRESS:
        case GDK_KEY_RELEASE:
            process_dnd_source_key_press_release(window, &event->key);
            break;
        case GDK_DRAG_ENTER:
            gdk_selection_owner_set(dnd_window, gdk_drag_get_selection(get_drag_context()), GDK_CURRENT_TIME, FALSE);
            break;
        case GDK_SELECTION_REQUEST:
            process_dnd_source_selection_req(window, &event->selection);
            break;
        default:
            break;
    }
}
Exemplo n.º 3
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));
    }
}
Exemplo n.º 4
0
static void
data_source_cancelled (void                  *data,
                       struct wl_data_source *source)
{
  GdkWaylandSelection *wayland_selection = data;
  GdkDragContext *context;
  GdkDisplay *display;
  GdkAtom atom;

  GDK_NOTE (EVENTS,
            g_message ("data source cancelled, source = %p", 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;

  context = gdk_wayland_drag_context_lookup_by_data_source (source);

  if (context)
    gdk_drag_context_cancel (context, GDK_DRAG_CANCEL_ERROR);

  emit_selection_clear (display, atom);
  gdk_selection_owner_set (NULL, atom, GDK_CURRENT_TIME, TRUE);
  gdk_wayland_selection_unset_data_source (display, atom);
}
Exemplo n.º 5
0
static void
primary_source_cancelled (void                                *data,
                          struct gtk_primary_selection_source *source)
{
  GdkDisplay *display;
  GdkAtom atom;

  GDK_NOTE (EVENTS,
            g_message ("primary source cancelled, source = %p", source));

  display = gdk_display_get_default ();

  atom = atoms[ATOM_PRIMARY];
  emit_selection_clear (display, atom);
  gdk_selection_owner_set (NULL, atom, GDK_CURRENT_TIME, TRUE);
  gdk_wayland_selection_unset_data_source (display, atom);
}
Exemplo n.º 6
0
static VALUE
rg_m_owner_set(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
{
    VALUE owner, selection, time, send_event;
    int ret;

    if (argc == 4){
        rb_scan_args(argc, argv, "40", &owner, &selection, &time, &send_event);
        ret = gdk_selection_owner_set(GDK_WINDOW(RVAL2GOBJ(owner)), 
                                      RVAL2ATOM(selection), 
                                      NUM2UINT(time), RVAL2CBOOL(send_event));
    } else {
      VALUE display = Qnil;
      rb_scan_args(argc, argv, "50", &display, &owner, &selection, &time, &send_event);
      ret = gdk_selection_owner_set_for_display(GDK_DISPLAY_OBJECT(RVAL2GOBJ(display)),
                                                GDK_WINDOW(RVAL2GOBJ(owner)), 
                                                RVAL2ATOM(selection), 
                                                NUM2UINT(time), RVAL2CBOOL(send_event));
    }
    return CBOOL2RVAL(ret);
}
Exemplo n.º 7
0
static void
data_source_dnd_finished (void                  *data,
                          struct wl_data_source *source)
{
  GdkDisplay *display = gdk_display_get_default ();
  GdkDragContext *context;

  context = gdk_wayland_drag_context_lookup_by_data_source (source);

  if (!context)
    return;

  if (context->action == GDK_ACTION_MOVE)
    {
      gdk_wayland_selection_emit_request (context->source_window,
                                          atoms[ATOM_DND],
                                          gdk_atom_intern_static_string ("DELETE"));
    }

  g_signal_emit_by_name (context, "dnd-finished");
  gdk_selection_owner_set (NULL, atoms[ATOM_DND], GDK_CURRENT_TIME, TRUE);
  gdk_wayland_selection_clear_targets (display, atoms[ATOM_DND]);
}