mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
feat: Implemented macOS messaging support (#2088)
This commit is contained in:
@@ -26,6 +26,10 @@ namespace hex::messaging {
|
||||
sendToOtherInstance(eventName, eventData);
|
||||
}
|
||||
});
|
||||
|
||||
EventNativeMessageReceived::subscribe([](const std::string &eventName, const std::vector<u8> &eventData) {
|
||||
messageReceived(eventName, eventData);
|
||||
});
|
||||
}
|
||||
|
||||
void setupMessaging() {
|
||||
|
||||
@@ -3,20 +3,30 @@
|
||||
#include <stdexcept>
|
||||
|
||||
#include <hex/helpers/logger.hpp>
|
||||
#include <hex/helpers/utils_macos.hpp>
|
||||
|
||||
#include "messaging.hpp"
|
||||
|
||||
namespace hex::messaging {
|
||||
|
||||
void sendToOtherInstance(const std::string &eventName, const std::vector<u8> &args) {
|
||||
std::ignore = eventName;
|
||||
std::ignore = args;
|
||||
log::error("Unimplemented function 'sendToOtherInstance()' called");
|
||||
log::debug("Sending event {} to another instance (not us)", eventName);
|
||||
|
||||
// Create the message
|
||||
std::vector<u8> fullEventData(eventName.begin(), eventName.end());
|
||||
fullEventData.push_back('\0');
|
||||
|
||||
fullEventData.insert(fullEventData.end(), args.begin(), args.end());
|
||||
|
||||
u8 *data = &fullEventData[0];
|
||||
auto dataSize = fullEventData.size();
|
||||
|
||||
macosSendMessageToMainInstance(data, dataSize);
|
||||
}
|
||||
|
||||
// Not implemented, so lets say we are the main instance every time so events are forwarded to ourselves
|
||||
bool setupNative() {
|
||||
return true;
|
||||
macosInstallEventListener();
|
||||
return macosIsMainInstance();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,16 +42,20 @@ namespace hex::messaging {
|
||||
log::debug("Sending event {} to another instance (not us)", eventName);
|
||||
|
||||
// Get the window we want to send it to
|
||||
HWND imHexWindow = *getImHexWindow();
|
||||
auto potentialWindow = getImHexWindow();
|
||||
if (!potentialWindow.has_value())
|
||||
return;
|
||||
|
||||
HWND imHexWindow = potentialWindow.value();
|
||||
|
||||
// Create the message
|
||||
std::vector<u8> fulleventData(eventName.begin(), eventName.end());
|
||||
fulleventData.push_back('\0');
|
||||
std::vector<u8> fullEventData(eventName.begin(), eventName.end());
|
||||
fullEventData.push_back('\0');
|
||||
|
||||
fulleventData.insert(fulleventData.end(), args.begin(), args.end());
|
||||
fullEventData.insert(fullEventData.end(), args.begin(), args.end());
|
||||
|
||||
u8 *data = &fulleventData[0];
|
||||
DWORD dataSize = fulleventData.size();
|
||||
u8 *data = &fullEventData[0];
|
||||
DWORD dataSize = fullEventData.size();
|
||||
|
||||
COPYDATASTRUCT message = {
|
||||
.dwData = 0,
|
||||
|
||||
Reference in New Issue
Block a user