This source file includes following definitions.
- RepostLocatedEventWin
#include "ui/views/event_utils.h"
#include <windowsx.h>
#include "base/logging.h"
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/gfx/point.h"
namespace views {
bool RepostLocatedEventWin(HWND window,
const ui::LocatedEvent& event) {
if (!window)
return false;
const gfx::Point screen_loc = event.location();
LRESULT nc_hit_result = SendMessage(window, WM_NCHITTEST, 0,
MAKELPARAM(screen_loc.x(),
screen_loc.y()));
const bool in_client_area = nc_hit_result == HTCLIENT;
int event_type;
int flags = event.flags();
if (flags & ui::EF_LEFT_MOUSE_BUTTON) {
event_type = in_client_area ? WM_LBUTTONDOWN : WM_NCLBUTTONDOWN;
} else if (flags & ui::EF_MIDDLE_MOUSE_BUTTON) {
event_type = in_client_area ? WM_MBUTTONDOWN : WM_NCMBUTTONDOWN;
} else if (flags & ui::EF_RIGHT_MOUSE_BUTTON) {
event_type = in_client_area ? WM_RBUTTONDOWN : WM_NCRBUTTONDOWN;
} else {
NOTREACHED();
return false;
}
int window_x = screen_loc.x();
int window_y = screen_loc.y();
if (in_client_area) {
POINT pt = {window_x, window_y};
ScreenToClient(window, &pt);
window_x = pt.x;
window_y = pt.y;
}
WPARAM target = in_client_area ? event.native_event().wParam : nc_hit_result;
PostMessage(window, event_type, target, MAKELPARAM(window_x, window_y));
return true;
}
}