mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-07-28 11:49:10 +00:00
Rename "event" to "message"
After the recent refactorings, a "control event" is not necessarily an "event" (it may be a "command"). Similarly, the unique "device event" used to send the device clipboard content is more a "reponse" to the request from the client than an "event". Rename both to "message", and rename the message types to better describe their intent.
This commit is contained in:
parent
f710d76c9e
commit
28980bbc90
28 changed files with 777 additions and 778 deletions
|
@ -4,8 +4,7 @@
|
|||
#include <SDL2/SDL_clipboard.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "device_event.h"
|
||||
#include "events.h"
|
||||
#include "device_msg.h"
|
||||
#include "lock_util.h"
|
||||
#include "log.h"
|
||||
|
||||
|
@ -24,21 +23,20 @@ receiver_destroy(struct receiver *receiver) {
|
|||
}
|
||||
|
||||
static void
|
||||
process_event(struct receiver *receiver, struct device_event *event) {
|
||||
switch (event->type) {
|
||||
case DEVICE_EVENT_TYPE_GET_CLIPBOARD:
|
||||
SDL_SetClipboardText(event->clipboard_event.text);
|
||||
process_msg(struct receiver *receiver, struct device_msg *msg) {
|
||||
switch (msg->type) {
|
||||
case DEVICE_MSG_TYPE_CLIPBOARD:
|
||||
SDL_SetClipboardText(msg->clipboard.text);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static ssize_t
|
||||
process_events(struct receiver *receiver, const unsigned char *buf,
|
||||
size_t len) {
|
||||
process_msgs(struct receiver *receiver, const unsigned char *buf, size_t len) {
|
||||
size_t head = 0;
|
||||
for (;;) {
|
||||
struct device_event event;
|
||||
ssize_t r = device_event_deserialize(&buf[head], len - head, &event);
|
||||
struct device_msg msg;
|
||||
ssize_t r = device_msg_deserialize(&buf[head], len - head, &msg);
|
||||
if (r == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -46,8 +44,8 @@ process_events(struct receiver *receiver, const unsigned char *buf,
|
|||
return head;
|
||||
}
|
||||
|
||||
process_event(receiver, &event);
|
||||
device_event_destroy(&event);
|
||||
process_msg(receiver, &msg);
|
||||
device_msg_destroy(&msg);
|
||||
|
||||
head += r;
|
||||
SDL_assert(head <= len);
|
||||
|
@ -61,19 +59,19 @@ static int
|
|||
run_receiver(void *data) {
|
||||
struct receiver *receiver = data;
|
||||
|
||||
unsigned char buf[DEVICE_EVENT_SERIALIZED_MAX_SIZE];
|
||||
unsigned char buf[DEVICE_MSG_SERIALIZED_MAX_SIZE];
|
||||
size_t head = 0;
|
||||
|
||||
for (;;) {
|
||||
SDL_assert(head < DEVICE_EVENT_SERIALIZED_MAX_SIZE);
|
||||
SDL_assert(head < DEVICE_MSG_SERIALIZED_MAX_SIZE);
|
||||
ssize_t r = net_recv(receiver->control_socket, buf,
|
||||
DEVICE_EVENT_SERIALIZED_MAX_SIZE - head);
|
||||
DEVICE_MSG_SERIALIZED_MAX_SIZE - head);
|
||||
if (r <= 0) {
|
||||
LOGD("Receiver stopped");
|
||||
break;
|
||||
}
|
||||
|
||||
ssize_t consumed = process_events(receiver, buf, r);
|
||||
ssize_t consumed = process_msgs(receiver, buf, r);
|
||||
if (consumed == -1) {
|
||||
// an error occurred
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue