mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
feat: Implement messaging support for Linux
This commit is contained in:
@@ -71,9 +71,8 @@ namespace hex {
|
||||
|
||||
/**
|
||||
* @brief Called when a native message was received from another ImHex instance
|
||||
* @param eventType Type name of the event
|
||||
* @param args Decoded arguments sent from other instance
|
||||
* @param rawData Raw bytes received from other instance
|
||||
*/
|
||||
EVENT_DEF(EventNativeMessageReceived, std::string, std::vector<u8>);
|
||||
EVENT_DEF(EventNativeMessageReceived, std::vector<u8>);
|
||||
|
||||
}
|
||||
@@ -866,27 +866,7 @@ namespace hex {
|
||||
}
|
||||
|
||||
extern "C" void macosEventDataReceived(const u8 *data, size_t length) {
|
||||
ssize_t nullIndex = -1;
|
||||
|
||||
auto messageData = reinterpret_cast<const char*>(data);
|
||||
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
if (messageData[i] == '\0') {
|
||||
nullIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nullIndex == -1) {
|
||||
log::warn("Received invalid forwarded event");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string eventName(messageData, nullIndex);
|
||||
|
||||
std::vector<u8> eventData(messageData + nullIndex + 1, messageData + length);
|
||||
|
||||
EventNativeMessageReceived::post(eventName, eventData);
|
||||
EventNativeMessageReceived::post(std::vector<u8>(data, data + length));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user