mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-25 14:29:03 -06:00
Made these changes only apply on Win32 builds
This commit is contained in:
committed by
Mikael Pettersson
parent
c9b5ffd021
commit
3210dfd315
@@ -84,7 +84,9 @@ public:
|
||||
void draw();
|
||||
void close(bool force = false);
|
||||
|
||||
#ifdef WIN32
|
||||
void sendTouchEvent(const CefTouchEvent& event) const;
|
||||
#endif
|
||||
|
||||
bool sendKeyEvent(const CefKeyEvent& event);
|
||||
bool sendMouseClickEvent(const CefMouseEvent& event,
|
||||
|
||||
@@ -84,8 +84,19 @@ private:
|
||||
*/
|
||||
CefMouseEvent mouseEvent(KeyModifier mods = KeyModifier::NoModifier);
|
||||
|
||||
#ifdef WIN32
|
||||
/**
|
||||
* Build a CEF touch event based on our internal structure
|
||||
*
|
||||
* Note: as of 02/21/2020 we are using an older version of CEF on OSX
|
||||
* than WIN32.
|
||||
* This version does not handle the CefTouchEvent type and does
|
||||
* not have any internal touch handling.
|
||||
*/
|
||||
CefTouchEvent touchEvent(const TouchInput& input,
|
||||
const cef_touch_event_type_t eventType) const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Find the CEF key event to use for a given action.
|
||||
*
|
||||
|
||||
@@ -149,9 +149,11 @@ bool BrowserInstance::sendMouseClickEvent(const CefMouseEvent& event,
|
||||
return hasContent(event.x, event.y);
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
void BrowserInstance::sendTouchEvent(const CefTouchEvent& event) const{
|
||||
_browser->GetHost()->SendTouchEvent(event);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool BrowserInstance::sendMouseMoveEvent(const CefMouseEvent& event) {
|
||||
constexpr const bool DidNotLeaveWindow = false;
|
||||
|
||||
@@ -208,11 +208,23 @@ void EventHandler::initialize() {
|
||||
}
|
||||
|
||||
if (_validTouchStates.empty()) {
|
||||
#ifdef WIN32
|
||||
CefTouchEvent event = touchEvent(
|
||||
input,
|
||||
cef_touch_event_type_t::CEF_TET_PRESSED
|
||||
);
|
||||
_browserInstance->sendTouchEvent(event);
|
||||
#else
|
||||
_mousePosition.x = windowPos.x;
|
||||
_mousePosition.y = windowPos.y;
|
||||
_leftButton.down = true;
|
||||
_browserInstance->sendMouseClickEvent(
|
||||
mouseEvent(),
|
||||
MBT_LEFT,
|
||||
false,
|
||||
BrowserInstance::SingleClick
|
||||
);
|
||||
#endif
|
||||
_validTouchStates.emplace_back(input);
|
||||
}
|
||||
else {
|
||||
@@ -241,11 +253,20 @@ void EventHandler::initialize() {
|
||||
);
|
||||
|
||||
if (it == _validTouchStates.cbegin()) {
|
||||
#ifdef WIN32
|
||||
|
||||
CefTouchEvent event = touchEvent(
|
||||
input,
|
||||
cef_touch_event_type_t::CEF_TET_MOVED
|
||||
);
|
||||
_browserInstance->sendTouchEvent(event);
|
||||
#else
|
||||
glm::vec2 windowPos = input.currentWindowCoordinates();
|
||||
_mousePosition.x = windowPos.x;
|
||||
_mousePosition.y = windowPos.y;
|
||||
_leftButton.down = true;
|
||||
_browserInstance->sendMouseMoveEvent(mouseEvent());
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
else if (it != _validTouchStates.cend()){
|
||||
@@ -276,12 +297,28 @@ void EventHandler::initialize() {
|
||||
if (found == _validTouchStates.cend()) {
|
||||
return;
|
||||
}
|
||||
#ifdef WIN32
|
||||
CefTouchEvent event = touchEvent(
|
||||
input,
|
||||
cef_touch_event_type_t::CEF_TET_RELEASED
|
||||
);
|
||||
_browserInstance->sendTouchEvent(event);
|
||||
#endif
|
||||
_validTouchStates.erase(found);
|
||||
#ifndef WIN32
|
||||
if (_validTouchStates.empty()) {
|
||||
glm::vec2 windowPos = input.currentWindowCoordinates();
|
||||
_mousePosition.x = windowPos.x;
|
||||
_mousePosition.y = windowPos.y;
|
||||
_leftButton.down = false;
|
||||
_browserInstance->sendMouseClickEvent(
|
||||
mouseEvent(),
|
||||
MBT_LEFT,
|
||||
true,
|
||||
BrowserInstance::SingleClick
|
||||
);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -426,6 +463,7 @@ CefMouseEvent EventHandler::mouseEvent(KeyModifier mods) {
|
||||
return event;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
CefTouchEvent EventHandler::touchEvent(const TouchInput& input,
|
||||
const cef_touch_event_type_t eventType) const
|
||||
{
|
||||
@@ -440,6 +478,7 @@ CefTouchEvent EventHandler::touchEvent(const TouchInput& input,
|
||||
event.pointer_type = cef_pointer_type_t::CEF_POINTER_TYPE_TOUCH;
|
||||
return event;
|
||||
}
|
||||
#endif
|
||||
|
||||
void EventHandler::setBrowserInstance(BrowserInstance* browserInstance) {
|
||||
LDEBUG("Setting browser instance.");
|
||||
|
||||
Reference in New Issue
Block a user