mirror of
https://github.com/chenasraf/webview_cef.git
synced 2026-05-18 01:49:03 +00:00
[Windows] touchpad support
This commit is contained in:
@@ -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()) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user