summaryrefslogtreecommitdiffstats
path: root/chrome/browser/web_drag_source.cc
blob: 9a197ae601fc05e1f76fbf26e7d1e5758448e029 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <atlbase.h>
#include <atlapp.h>
#include <atlmisc.h>

#include "chrome/browser/web_drag_source.h"

#include "chrome/browser/render_view_host.h"

namespace {

static void GetCursorPositions(HWND hwnd, CPoint* client, CPoint* screen) {
  GetCursorPos(screen);
  *client = *screen;
  ScreenToClient(hwnd, client);
}

}  // namespace
///////////////////////////////////////////////////////////////////////////////
// WebDragSource, public:

WebDragSource::WebDragSource(HWND source_hwnd,
                             RenderViewHost* render_view_host)
    : BaseDragSource(),
      source_hwnd_(source_hwnd),
      render_view_host_(render_view_host) {
}

void WebDragSource::OnDragSourceDrop() {
  CPoint client;
  CPoint screen;
  GetCursorPositions(source_hwnd_, &client, &screen);
  render_view_host_->DragSourceEndedAt(client.x, client.y, screen.x, screen.y);
}

void WebDragSource::OnDragSourceMove() {
  CPoint client;
  CPoint screen;
  GetCursorPositions(source_hwnd_, &client, &screen);
  render_view_host_->DragSourceMovedTo(client.x, client.y, screen.x, screen.y);
}