[Windows] touchpad support

This commit is contained in:
Prome
2022-09-12 22:08:19 +08:00
parent c4992ccf73
commit 7f06fc2b7e
3 changed files with 12 additions and 38 deletions

View File

@@ -172,28 +172,6 @@ bool SimpleHandler::IsChromeRuntimeEnabled() {
return value == 1;
}
void SimpleHandler::scrollUp()
{
BrowserList::const_iterator it = browser_list_.begin();
if (it != browser_list_.end()) {
CefMouseEvent ev;
ev.x = 500;
ev.y = 500;
(*it)->GetHost()->SendMouseWheelEvent(ev, 0, -100);
}
}
void SimpleHandler::scrollDown()
{
BrowserList::const_iterator it = browser_list_.begin();
if (it != browser_list_.end()) {
CefMouseEvent ev;
ev.x = 500;
ev.y = 500;
(*it)->GetHost()->SendMouseWheelEvent(ev, 0, 100);
}
}
void SimpleHandler::sendScrollEvent(int x, int y, int deltaX, int deltaY) {
BrowserList::const_iterator it = browser_list_.begin();
if (it != browser_list_.end()) {

View File

@@ -75,10 +75,6 @@ public:
// Returns true if the Chrome runtime is enabled.
static bool IsChromeRuntimeEnabled();
void scrollUp();
void scrollDown();
void sendScrollEvent(int x, int y, int deltaX, int deltaY);
void changeSize(float a_dpi, int width, int height);
@@ -88,8 +84,8 @@ public:
void loadUrl(std::string url);
private:
uint32_t width = 1280;
uint32_t height = 720;
uint32_t width = 1;
uint32_t height = 1;
float dpi = 1.0;
// Platform-specific implementation.

View File

@@ -176,9 +176,9 @@ namespace webview_cef {
const flutter::EncodableList* list =
std::get_if<flutter::EncodableList>(method_call.arguments());
const auto dpi = *std::get_if<double>(&(*list)[0]);
const auto width = *std::get_if<int>(&(*list)[1]);
const auto height =*std::get_if<int>(&(*list)[2]);
handler.get()->changeSize((float)dpi, width, height);
const auto width = *std::get_if<double>(&(*list)[1]);
const auto height =*std::get_if<double>(&(*list)[2]);
handler.get()->changeSize((float)dpi,(int) std::round(width),(int) std::round(height));
result->Success();
}
else if (method_call.method_name().compare("cursorClickDown") == 0) {
@@ -192,13 +192,13 @@ namespace webview_cef {
result->Success();
}
else if (method_call.method_name().compare("setScrollDelta") == 0) {
const auto point = GetPointFromArgs(method_call.arguments());
if (point->second > 0) {
handler.get()->scrollDown();
}
else if (point->second < 0) {
handler.get()->scrollUp();
}
const flutter::EncodableList* list =
std::get_if<flutter::EncodableList>(method_call.arguments());
const auto x = *std::get_if<int>(&(*list)[0]);
const auto y = *std::get_if<int>(&(*list)[1]);
const auto deltaX = *std::get_if<int>(&(*list)[2]);
const auto deltaY = *std::get_if<int>(&(*list)[3]);
handler.get()->sendScrollEvent(x, y, deltaX, deltaY);
result->Success();
}
else {