mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-26 14:41:25 +00:00
Use macros for casting Channel types
In preparation for converting RedChannel to GObject, switch to using RED_CHANNEL()-type macros for casting. For now they just do a regular cast, but it helps reduce the size of the GObject patch to make it easier to review. Acked-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
bcb8503659
commit
efe49fa275
@ -122,7 +122,7 @@ CommonGraphicsChannel* common_graphics_channel_new(RedsState *server,
|
||||
migration_flags);
|
||||
spice_return_val_if_fail(channel, NULL);
|
||||
|
||||
common = (CommonGraphicsChannel *)channel;
|
||||
common = COMMON_GRAPHICS_CHANNEL(channel);
|
||||
common->qxl = qxl;
|
||||
return common;
|
||||
}
|
||||
|
||||
@ -28,6 +28,8 @@
|
||||
#include "reds.h"
|
||||
#include "red-qxl.h"
|
||||
|
||||
#define CURSOR_CHANNEL(channel) ((CursorChannel*)(channel))
|
||||
|
||||
enum {
|
||||
RED_PIPE_ITEM_TYPE_CURSOR = RED_PIPE_ITEM_TYPE_COMMON_LAST,
|
||||
RED_PIPE_ITEM_TYPE_CURSOR_INIT,
|
||||
@ -170,7 +172,7 @@ static void cursor_fill(CursorChannelClient *ccc, SpiceCursor *red_cursor,
|
||||
|
||||
void cursor_channel_disconnect(CursorChannel *cursor_channel)
|
||||
{
|
||||
RedChannel *channel = (RedChannel *)cursor_channel;
|
||||
RedChannel *channel = RED_CHANNEL(cursor_channel);
|
||||
|
||||
if (!channel || !red_channel_is_connected(channel)) {
|
||||
return;
|
||||
@ -198,7 +200,7 @@ static void red_marshall_cursor_init(CursorChannelClient *ccc, SpiceMarshaller *
|
||||
AddBufInfo info;
|
||||
|
||||
spice_assert(rcc);
|
||||
cursor_channel = (CursorChannel*)red_channel_client_get_channel(rcc);
|
||||
cursor_channel = CURSOR_CHANNEL(red_channel_client_get_channel(rcc));
|
||||
|
||||
red_channel_client_init_send_data(rcc, SPICE_MSG_CURSOR_INIT, NULL);
|
||||
msg.visible = cursor_channel->priv->cursor_visible;
|
||||
@ -324,7 +326,7 @@ CursorChannel* cursor_channel_new(RedsState *server, QXLInstance *qxl,
|
||||
SPICE_CHANNEL_CURSOR, 0,
|
||||
&cbs, red_channel_client_handle_message);
|
||||
|
||||
cursor_channel = (CursorChannel *)channel;
|
||||
cursor_channel = CURSOR_CHANNEL(channel);
|
||||
cursor_channel->priv->cursor_visible = TRUE;
|
||||
cursor_channel->priv->mouse_mode = SPICE_MOUSE_MODE_SERVER;
|
||||
|
||||
|
||||
@ -1924,10 +1924,10 @@ DisplayChannel* display_channel_new(RedsState *reds,
|
||||
};
|
||||
|
||||
spice_info("create display channel");
|
||||
display = (DisplayChannel *)common_graphics_channel_new(
|
||||
display = DISPLAY_CHANNEL(common_graphics_channel_new(
|
||||
reds, qxl, core, sizeof(*display), SPICE_CHANNEL_DISPLAY,
|
||||
SPICE_MIGRATE_NEED_FLUSH | SPICE_MIGRATE_NEED_DATA_TRANSFER,
|
||||
&cbs, dcc_handle_message);
|
||||
&cbs, dcc_handle_message));
|
||||
spice_return_val_if_fail(display, NULL);
|
||||
display->priv->pub = display;
|
||||
|
||||
|
||||
@ -45,6 +45,8 @@
|
||||
#include "image-encoders.h"
|
||||
#include "common-graphics-channel.h"
|
||||
|
||||
#define DISPLAY_CHANNEL(channel) ((DisplayChannel*)(channel))
|
||||
|
||||
typedef struct DependItem {
|
||||
Drawable *drawable;
|
||||
RingItem ring_item;
|
||||
|
||||
@ -110,7 +110,7 @@ void inputs_channel_client_handle_migrate_data(InputsChannelClient *icc,
|
||||
|
||||
void inputs_channel_client_on_mouse_motion(InputsChannelClient *icc)
|
||||
{
|
||||
InputsChannel *inputs_channel = (InputsChannel *)red_channel_client_get_channel(RED_CHANNEL_CLIENT(icc));
|
||||
InputsChannel *inputs_channel = INPUTS_CHANNEL(red_channel_client_get_channel(RED_CHANNEL_CLIENT(icc)));
|
||||
|
||||
if (++icc->priv->motion_count % SPICE_INPUT_MOTION_ACK_BUNCH == 0 &&
|
||||
!inputs_channel_is_src_during_migrate(inputs_channel)) {
|
||||
|
||||
@ -151,7 +151,7 @@ static uint8_t *inputs_channel_alloc_msg_rcv_buf(RedChannelClient *rcc,
|
||||
uint16_t type,
|
||||
uint32_t size)
|
||||
{
|
||||
InputsChannel *inputs_channel = (InputsChannel*)red_channel_client_get_channel(rcc);
|
||||
InputsChannel *inputs_channel = INPUTS_CHANNEL(red_channel_client_get_channel(rcc));
|
||||
|
||||
if (size > RECEIVE_BUF_SIZE) {
|
||||
spice_printerr("error: too large incoming message");
|
||||
@ -259,7 +259,7 @@ static void inputs_channel_send_item(RedChannelClient *rcc, RedPipeItem *base)
|
||||
red_channel_client_init_send_data(rcc, SPICE_MSG_INPUTS_MOUSE_MOTION_ACK, base);
|
||||
break;
|
||||
case RED_PIPE_ITEM_MIGRATE_DATA:
|
||||
((InputsChannel*)red_channel_client_get_channel(rcc))->src_during_migrate = FALSE;
|
||||
INPUTS_CHANNEL(red_channel_client_get_channel(rcc))->src_during_migrate = FALSE;
|
||||
inputs_channel_client_send_migrate_data(rcc, m, base);
|
||||
break;
|
||||
default:
|
||||
@ -272,7 +272,7 @@ static void inputs_channel_send_item(RedChannelClient *rcc, RedPipeItem *base)
|
||||
static int inputs_channel_handle_parsed(RedChannelClient *rcc, uint32_t size, uint16_t type,
|
||||
void *message)
|
||||
{
|
||||
InputsChannel *inputs_channel = (InputsChannel *)red_channel_client_get_channel(rcc);
|
||||
InputsChannel *inputs_channel = INPUTS_CHANNEL(red_channel_client_get_channel(rcc));
|
||||
InputsChannelClient *icc = INPUTS_CHANNEL_CLIENT(rcc);
|
||||
uint32_t i;
|
||||
RedsState *reds = red_channel_get_server(&inputs_channel->base);
|
||||
@ -458,13 +458,13 @@ static void inputs_channel_on_disconnect(RedChannelClient *rcc)
|
||||
if (!rcc) {
|
||||
return;
|
||||
}
|
||||
inputs_release_keys((InputsChannel*)red_channel_client_get_channel(rcc));
|
||||
inputs_release_keys(INPUTS_CHANNEL(red_channel_client_get_channel(rcc)));
|
||||
}
|
||||
|
||||
static void inputs_pipe_add_init(RedChannelClient *rcc)
|
||||
{
|
||||
RedInputsInitPipeItem *item = spice_malloc(sizeof(RedInputsInitPipeItem));
|
||||
InputsChannel *inputs = (InputsChannel*)red_channel_client_get_channel(rcc);
|
||||
InputsChannel *inputs = INPUTS_CHANNEL(red_channel_client_get_channel(rcc));
|
||||
|
||||
red_pipe_item_init(&item->base, RED_PIPE_ITEM_INPUTS_INIT);
|
||||
item->modifiers = kbd_get_leds(inputs_channel_get_keyboard(inputs));
|
||||
@ -511,7 +511,7 @@ static void inputs_connect(RedChannel *channel, RedClient *client,
|
||||
|
||||
static void inputs_migrate(RedChannelClient *rcc)
|
||||
{
|
||||
InputsChannel *inputs = (InputsChannel*)red_channel_client_get_channel(rcc);
|
||||
InputsChannel *inputs = INPUTS_CHANNEL(red_channel_client_get_channel(rcc));
|
||||
inputs->src_during_migrate = TRUE;
|
||||
red_channel_client_default_migrate(rcc);
|
||||
}
|
||||
@ -548,7 +548,7 @@ static int inputs_channel_handle_migrate_data(RedChannelClient *rcc,
|
||||
void *message)
|
||||
{
|
||||
InputsChannelClient *icc = INPUTS_CHANNEL_CLIENT(rcc);
|
||||
InputsChannel *inputs = (InputsChannel*)red_channel_client_get_channel(rcc);
|
||||
InputsChannel *inputs = INPUTS_CHANNEL(red_channel_client_get_channel(rcc));
|
||||
SpiceMigrateDataHeader *header;
|
||||
SpiceMigrateDataInputs *mig_data;
|
||||
|
||||
@ -580,7 +580,7 @@ InputsChannel* inputs_channel_new(RedsState *reds)
|
||||
channel_cbs.handle_migrate_data = inputs_channel_handle_migrate_data;
|
||||
channel_cbs.handle_migrate_flush_mark = inputs_channel_handle_migrate_flush_mark;
|
||||
|
||||
inputs = (InputsChannel *)red_channel_create_parser(
|
||||
inputs = INPUTS_CHANNEL(red_channel_create_parser(
|
||||
sizeof(InputsChannel),
|
||||
reds,
|
||||
reds_get_core_interface(reds),
|
||||
@ -589,7 +589,7 @@ InputsChannel* inputs_channel_new(RedsState *reds)
|
||||
spice_get_client_channel_parser(SPICE_CHANNEL_INPUTS, NULL),
|
||||
inputs_channel_handle_parsed,
|
||||
&channel_cbs,
|
||||
SPICE_MIGRATE_NEED_FLUSH | SPICE_MIGRATE_NEED_DATA_TRANSFER);
|
||||
SPICE_MIGRATE_NEED_FLUSH | SPICE_MIGRATE_NEED_DATA_TRANSFER));
|
||||
|
||||
if (!inputs) {
|
||||
spice_error("failed to allocate Inputs Channel");
|
||||
|
||||
@ -26,6 +26,8 @@
|
||||
|
||||
#include "red-channel.h"
|
||||
|
||||
#define INPUTS_CHANNEL(channel) ((InputsChannel*)(channel))
|
||||
|
||||
typedef struct InputsChannel InputsChannel;
|
||||
|
||||
InputsChannel* inputs_channel_new(RedsState *reds);
|
||||
|
||||
@ -329,7 +329,7 @@ MainChannel* main_channel_new(RedsState *reds)
|
||||
client_cbs.migrate = main_channel_client_migrate;
|
||||
red_channel_register_client_cbs(channel, &client_cbs, NULL);
|
||||
|
||||
return (MainChannel *)channel;
|
||||
return MAIN_CHANNEL(channel);
|
||||
}
|
||||
|
||||
static int main_channel_connect_semi_seamless(MainChannel *main_channel)
|
||||
|
||||
@ -25,6 +25,8 @@
|
||||
#include "red-channel.h"
|
||||
#include "main-channel-client.h"
|
||||
|
||||
#define MAIN_CHANNEL(channel) ((MainChannel*)(channel))
|
||||
|
||||
// TODO: Defines used to calculate receive buffer size, and also by reds.c
|
||||
// other options: is to make a reds_main_consts.h, to duplicate defines.
|
||||
#define REDS_AGENT_WINDOW_SIZE 10
|
||||
|
||||
Loading…
Reference in New Issue
Block a user