/* 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 <gdk/gdk.h>
#include <gdkmm/cursor.h>
#include <gdkmm/device.h>
#include <gdkmm/types.h>
#include <gdkmm/glcontext.h>
#include <gdkmm/drawcontext.h>
#include <gdkmm/drawingcontext.h>

namespace Gdk
{

void Window::set_cursor()
{
  gdk_window_set_cursor(gobj(), nullptr);
}

void Window::set_device_cursor(const Glib::RefPtr<Gdk::Device>& device)
{
  gdk_window_set_device_cursor(gobj(), Glib::unwrap(device), nullptr);
}

void Window::unset_icon()
{
  gdk_window_set_icon_name(gobj(), nullptr); /* See GDK docs */
}

void Window::invalidate(bool invalidate_children)
{
  gdk_window_invalidate_rect(gobj(), nullptr, invalidate_children);
}

void Window::restack(bool above)
{
  gdk_window_restack(gobj(), nullptr, above);
}

Glib::RefPtr<DragContext> Window::drag_begin (const std::vector<Glib::ustring>& targets)
{
  return Glib::wrap (gdk_drag_begin (gobj (), Glib::ListHandler<Glib::ustring, AtomUstringTraits>::vector_to_list(targets).data ()), true);
}

DragProtocol Window::get_drag_protocol(Glib::RefPtr<Window>& target) const
{
  GdkWindow* window = nullptr;
  auto result = gdk_window_get_drag_protocol(
    const_cast<GdkWindow*>(gobj()),
    &window);

  target = Glib::wrap(window, true /* take ref */);
  return (DragProtocol)result;
}

DragProtocol Window::get_drag_protocol() const
{
  return (DragProtocol)gdk_window_get_drag_protocol(
    const_cast<GdkWindow*>(gobj()),
    nullptr);
}

} // namespace Gdk
