Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if(CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES "Release")
endif()

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY ON)
Expand Down Expand Up @@ -473,4 +473,4 @@ if( USE_SPOTIFY_CEF )
install( FILES ${CEF_RESOURCE_DIR}/${resFile} DESTINATION resources)
endif()
endforeach()
endif()
endif()
10 changes: 5 additions & 5 deletions autobuild.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
<key>archive</key>
<map>
<key>hash</key>
<string>f6803c42c9468419d281cbc5afb99ed21942fd30</string>
<string>3218ee0b5acc5e3fa4d5e9e9e24929b9913688ad</string>
<key>hash_algorithm</key>
<string>sha1</string>
<key>url</key>
<string>https://automated-builds-secondlife-com.s3.us-east-1.amazonaws.com/gh/secondlife/cef/cef_bin-139.0.40_g465474a_chromium-139.0.7258.139-darwin64-252542250.tar.zst</string>
<string>https://automated-builds-secondlife-com.s3.us-east-1.amazonaws.com/gh/secondlife/cef/cef_bin-148.0.9_g0d9d52a_chromium-148.0.7778.180-darwin64-261471908.tar.zst</string>
</map>
<key>name</key>
<string>darwin64</string>
Expand All @@ -33,18 +33,18 @@
<key>archive</key>
<map>
<key>hash</key>
<string>1b09d806f4fe041f800c4bf2e1e0e0884f76973b</string>
<string>f677be20cd859b2a7cf6925cf60bd6ab4829266a</string>
<key>hash_algorithm</key>
<string>sha1</string>
<key>url</key>
<string>https://automated-builds-secondlife-com.s3.us-east-1.amazonaws.com/gh/secondlife/cef/cef_bin-139.0.40_g465474a_chromium-139.0.7258.139-windows64-252550005.tar.zst</string>
<string>https://automated-builds-secondlife-com.s3.us-east-1.amazonaws.com/gh/secondlife/cef/cef_bin-148.0.9_g0d9d52a_chromium-148.0.7778.180-windows64-261470050.tar.zst</string>
</map>
<key>name</key>
<string>windows64</string>
</map>
</map>
<key>version</key>
<string>139.0.17_g6c347eb_chromium-139.0.7258.31</string>
<string>cef_bin-148.0.9_g0d9d52a_chromium-148.0.7778.180</string>
</map>
</map>
<key>package_description</key>
Expand Down
30 changes: 28 additions & 2 deletions examples/opengl-example/src/opengl-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ void openglExample::handleKeyEvent(int key, int scancode, int action, int mods)
{
mDullahan->requestExit();
}
else if (mods & GLFW_MOD_CONTROL)
{
if (key >= '1' && key <= '9')
{
std::ostringstream cmd("fromCPP", std::ios::ate);
cmd << "(";
cmd << "{ ";
cmd << "name: 'Key-" + std::to_string(key - '0') << "'";
cmd << ", ";
cmd << "id: '" + std::to_string(key - '0') << "'";
cmd << ", ";
cmd << "content : 'Payload for key " + std::to_string(key - '0') << "'";
cmd << " }";
cmd << ");";
std::cout << "--> cmd.str(): " << cmd.str() << std::endl;
mDullahan->executeJavaScript(cmd.str());
}
}
}
}

Expand Down Expand Up @@ -311,7 +329,8 @@ bool openglExample::init()

mDullahan->setOnPageChangedCallback(std::bind(&openglExample::onPageChanged, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5));
mDullahan->setOnRequestExitCallback(std::bind(&openglExample::onRequestExitCallback, this));

mDullahan->setOnJStoCPPMsgCallback(std::bind(&openglExample::onJStoCPPMsgCallback, this, std::placeholders::_1, std::placeholders::_2));

mDullahan->navigate(mHomeUrl);
}

Expand Down Expand Up @@ -463,6 +482,12 @@ void openglExample::onRequestExitCallback()
glfwSetWindowShouldClose(mWindow, GLFW_TRUE);
}

std::string openglExample::onJStoCPPMsgCallback(const std::string id, const std::string msg)
{
std::cout << "Received message with ID: " << id << " from JavaScript: " << msg << std::endl;
return "Message received loud and clear by C++!";
}

void openglExample::initUI()
{
IMGUI_CHECKVERSION();
Expand Down Expand Up @@ -624,7 +649,8 @@ void openglExample::updateUI()
"chrome://version",
"https://sl-viewer-media-system.s3.amazonaws.com/bookmarks/index.html",
"https://viewer-login.agni.lindenlab.com/",
"https://secondlife.com"
"https://secondlife.com",
"https://sl-viewer-media-system.s3.amazonaws.com/apps/v8-msg/index.html",
};
static const char* current_item = "Select a bookmark";
ImGui::SetNextItemWidth(main_viewport->Size.x);
Expand Down
1 change: 1 addition & 0 deletions examples/opengl-example/src/opengl-example.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class openglExample
// callbacks
void onPageChanged(const unsigned char* pixels, int x, int y, const int width, const int height);
void onRequestExitCallback();
std::string onJStoCPPMsgCallback(const std::string id, const std::string msg);

private:
GLFWwindow* mWindow;
Expand Down
5 changes: 5 additions & 0 deletions src/dullahan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,8 @@ void dullahan::setOnJSBeforeUnloadCallback(std::function<bool()> callback)
{
mImpl->getCallbackManager()->setOnJSBeforeUnloadCallback(callback);
}

void dullahan::setOnJStoCPPMsgCallback(std::function<std::string(const std::string id, const std::string msg)> callback)
{
mImpl->getCallbackManager()->setOnJStoCPPMsgCallback(callback);
}
3 changes: 3 additions & 0 deletions src/dullahan.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ class dullahan
// JS before unload callback (alert)
void setOnJSBeforeUnloadCallback(std::function<bool()> callback);

// Message from JS to CPP
void setOnJStoCPPMsgCallback(std::function<std::string(const std::string id, const std::string msg)> callback);

private:
std::unique_ptr <dullahan_impl> mImpl;
};
Expand Down
25 changes: 25 additions & 0 deletions src/dullahan_browser_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include <algorithm>
#include <chrono>
#include <iostream>
#include <thread>

dullahan_browser_client::dullahan_browser_client(dullahan_impl* parent,
Expand All @@ -58,6 +59,30 @@ CefRefPtr<CefRenderHandler> dullahan_browser_client::GetRenderHandler()
return mRenderHandler;
}

// CefClient override
bool dullahan_browser_client::OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message)
{
CEF_REQUIRE_UI_THREAD();

if (message->GetName() == "JSONtoCPP_MSG")
{
CefRefPtr<CefListValue> args = message->GetArgumentList();
if (args)
{
//std::cout << ">>> Received JSONtoCPP_MSG from render process: " << args->GetString(0).ToString() << std::endl;
mParent->getCallbackManager()->onJStoCPPMsgCallback(args->GetString(0).ToString(), args->GetString(1).ToString());
}

// Indicate we processed this message and it should not be sent to other handlers
return true;
}

return false;
}

// CefLifeSpanHandler override
bool dullahan_browser_client::OnBeforePopup(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
Expand Down
5 changes: 5 additions & 0 deletions src/dullahan_browser_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class dullahan_browser_client :
return this;
}

bool OnProcessMessageReceived(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) override;

bool OnBeforePopup(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
int popup_id,
Expand Down
15 changes: 15 additions & 0 deletions src/dullahan_callback_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,18 @@ bool dullahan_callback_manager::onJSBeforeUnloadCallback()
return false;
}

void dullahan_callback_manager::setOnJStoCPPMsgCallback(
std::function<std::string(const std::string id, const std::string msg)> callback)
{
mOnJStoCPPMsgCallbackFunc = callback;
}

std::string dullahan_callback_manager::onJStoCPPMsgCallback(const std::string id, const std::string msg)
{
if (mOnJStoCPPMsgCallbackFunc)
{
return mOnJStoCPPMsgCallbackFunc(id, msg);
}

return std::string();
}
4 changes: 4 additions & 0 deletions src/dullahan_callback_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class dullahan_callback_manager
void setOnJSBeforeUnloadCallback(std::function<bool()> callback);
bool onJSBeforeUnloadCallback();

void setOnJStoCPPMsgCallback(std::function<std::string(const std::string id, const std::string msg)> callback);
std::string onJStoCPPMsgCallback(const std::string id, const std::string msg);

private:
std::function<void(const std::string)> mOnAddressChangeCallbackFunc;
std::function<void(const std::string, const std::string, int)> mOnConsoleMessageCallbackFunc;
Expand All @@ -111,6 +114,7 @@ class dullahan_callback_manager
std::function<const std::vector<std::string>(dullahan::EFileDialogType, const std::string, const std::string, const std::string, bool&)> mOnFileDialogCallbackFunc;
std::function<bool(const std::string, const std::string, const std::string)> mOnJSDialogCallbackFunc;
std::function<bool()> mOnJSBeforeUnloadCallbackFunc;
std::function<std::string(const std::string id, const std::string)> mOnJStoCPPMsgCallbackFunc;
};

#endif //_DULLAHAN_CALLBACK_MANAGER
2 changes: 1 addition & 1 deletion src/dullahan_version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

// version of this package
#define DULLAHAN_VERSION_MAJOR 1
#define DULLAHAN_VERSION_MINOR 26
#define DULLAHAN_VERSION_MINOR 35
#define DULLAHAN_VERSION_POINT 0

// The build version number as of v1.2 is now the date/time the build was made
Expand Down
Loading
Loading