/*
 * Copyright 1998-2002 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <vector>

#include <gdkmm/applaunchcontext.h>
#include <gdkmm/devicemanager.h>
#include <gdkmm/window.h>
#include <gdk/gdk.h>

namespace Gdk
{

bool Display::set_selection_owner(const Glib::RefPtr<Window>& owner, Glib::ustring& selection, guint32 time_, bool send_event)
{
  return gdk_selection_owner_set_for_display(gobj(), owner->gobj(), Gdk::AtomUstring::to_c_type(selection), time_, (gboolean)send_event);
}

Glib::RefPtr<Window> Display::get_selection_owner(const Glib::ustring& selection)
{
  return Glib::wrap(gdk_selection_owner_get_for_display(gobj(), Gdk::AtomUstring::to_c_type(selection)) , true);
}

void Display::selection_send_notify(const Glib::RefPtr<Window>& requestor, Glib::ustring& selection, Glib::ustring& target, Glib::ustring& property, guint32 time_)
{
  gdk_selection_send_notify_for_display(gobj(), Glib::unwrap(requestor), Gdk::AtomUstring::to_c_type(selection), Gdk::AtomUstring::to_c_type(target), Gdk::AtomUstring::to_c_type(property), time_);
}

void Display::store_clipboard(const Glib::RefPtr<Gdk::Window>& clipboard_window, guint32 time_)
{
  gdk_display_store_clipboard(gobj(), clipboard_window->gobj(), time_, nullptr /* see the C docs */, 0);
}

void Display::store_clipboard(const Glib::RefPtr<Gdk::Window>& clipboard_window, guint32 time_, const std::vector<Glib::ustring>& targets)
{
  if (!targets.size ())
  {
    gdk_display_store_clipboard(gobj(),
                                Glib::unwrap (clipboard_window),
                                time_,
                                Glib::ArrayHandler<Glib::ustring, AtomUstringTraits>::vector_to_array(targets).data (),
                                targets.size ());
  }
}

} //namespace Gdk
