[Spice-devel] [PATCH spice-server 2/4] red-qxl: remove use of g_object_get_data()
Jonathon Jongsma
jjongsma at redhat.com
Tue Aug 29 22:28:07 UTC 2017
Rather than using g_object_set_data() to attach the dispatcher to the
channel, we can simply retrieve it from the QXLInstance that is
associated with the Cursor/DisplayChannel
Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
---
server/common-graphics-channel.c | 1 -
server/red-qxl.c | 28 ++++++++++++++++++++--------
server/red-worker.c | 5 +----
3 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/server/common-graphics-channel.c b/server/common-graphics-channel.c
index e8c18a523..8c87d4dbb 100644
--- a/server/common-graphics-channel.c
+++ b/server/common-graphics-channel.c
@@ -141,7 +141,6 @@ bool common_channel_client_config_socket(RedChannelClient *rcc)
return TRUE;
}
-
static void
common_graphics_channel_class_init(CommonGraphicsChannelClass *klass)
{
diff --git a/server/red-qxl.c b/server/red-qxl.c
index 53f3338b0..4a8f523b7 100644
--- a/server/red-qxl.c
+++ b/server/red-qxl.c
@@ -37,6 +37,7 @@
#include "dispatcher.h"
#include "red-parse-qxl.h"
#include "red-channel-client.h"
+#include "common-graphics-channel.h"
#include "red-qxl.h"
@@ -79,10 +80,10 @@ static void red_qxl_set_display_peer(RedChannel *channel, RedClient *client,
RedChannelCapabilities *caps)
{
RedWorkerMessageDisplayConnect payload = {0,};
- Dispatcher *dispatcher;
+ QXLInstance *qxl = common_graphics_channel_get_qxl(COMMON_GRAPHICS_CHANNEL(channel));
+ Dispatcher *dispatcher = red_qxl_get_dispatcher(qxl);
spice_debug("%s", "");
- dispatcher = (Dispatcher *)g_object_get_data(G_OBJECT(channel), "dispatcher");
payload.client = client;
payload.stream = stream;
payload.migration = migration;
@@ -96,6 +97,7 @@ static void red_qxl_set_display_peer(RedChannel *channel, RedClient *client,
static void red_qxl_disconnect_display_peer(RedChannelClient *rcc)
{
RedWorkerMessageDisplayDisconnect payload;
+ QXLInstance *qxl;
Dispatcher *dispatcher;
RedChannel *channel = red_channel_client_get_channel(rcc);
@@ -103,7 +105,8 @@ static void red_qxl_disconnect_display_peer(RedChannelClient *rcc)
return;
}
- dispatcher = (Dispatcher *)g_object_get_data(G_OBJECT(channel), "dispatcher");
+ qxl = common_graphics_channel_get_qxl(COMMON_GRAPHICS_CHANNEL(channel));
+ dispatcher = red_qxl_get_dispatcher(qxl);
spice_printerr("");
payload.rcc = rcc;
@@ -118,6 +121,7 @@ static void red_qxl_disconnect_display_peer(RedChannelClient *rcc)
static void red_qxl_display_migrate(RedChannelClient *rcc)
{
RedWorkerMessageDisplayMigrate payload;
+ QXLInstance *qxl;
Dispatcher *dispatcher;
RedChannel *channel = red_channel_client_get_channel(rcc);
uint32_t type, id;
@@ -125,8 +129,11 @@ static void red_qxl_display_migrate(RedChannelClient *rcc)
if (!channel) {
return;
}
- g_object_get(channel, "channel-type", &type, "id", &id, NULL);
- dispatcher = (Dispatcher *)g_object_get_data(G_OBJECT(channel), "dispatcher");
+ g_object_get(channel, "channel-type", &type, "id", &id,
+ NULL);
+
+ qxl = common_graphics_channel_get_qxl(COMMON_GRAPHICS_CHANNEL(channel));
+ dispatcher = red_qxl_get_dispatcher(qxl);
spice_printerr("channel type %u id %u", type, id);
payload.rcc = rcc;
dispatcher_send_message(dispatcher,
@@ -139,7 +146,8 @@ static void red_qxl_set_cursor_peer(RedChannel *channel, RedClient *client, Reds
RedChannelCapabilities *caps)
{
RedWorkerMessageCursorConnect payload = {0,};
- Dispatcher *dispatcher = (Dispatcher *)g_object_get_data(G_OBJECT(channel), "dispatcher");
+ QXLInstance *qxl = common_graphics_channel_get_qxl(COMMON_GRAPHICS_CHANNEL(channel));
+ Dispatcher *dispatcher = red_qxl_get_dispatcher(qxl);
spice_printerr("");
payload.client = client;
payload.stream = stream;
@@ -154,6 +162,7 @@ static void red_qxl_set_cursor_peer(RedChannel *channel, RedClient *client, Reds
static void red_qxl_disconnect_cursor_peer(RedChannelClient *rcc)
{
RedWorkerMessageCursorDisconnect payload;
+ QXLInstance *qxl;
Dispatcher *dispatcher;
RedChannel *channel = red_channel_client_get_channel(rcc);
@@ -161,7 +170,8 @@ static void red_qxl_disconnect_cursor_peer(RedChannelClient *rcc)
return;
}
- dispatcher = (Dispatcher *)g_object_get_data(G_OBJECT(channel), "dispatcher");
+ qxl = common_graphics_channel_get_qxl(COMMON_GRAPHICS_CHANNEL(channel));
+ dispatcher = red_qxl_get_dispatcher(qxl);
spice_printerr("");
payload.rcc = rcc;
@@ -173,6 +183,7 @@ static void red_qxl_disconnect_cursor_peer(RedChannelClient *rcc)
static void red_qxl_cursor_migrate(RedChannelClient *rcc)
{
RedWorkerMessageCursorMigrate payload;
+ QXLInstance *qxl;
Dispatcher *dispatcher;
RedChannel *channel = red_channel_client_get_channel(rcc);
uint32_t type, id;
@@ -181,8 +192,9 @@ static void red_qxl_cursor_migrate(RedChannelClient *rcc)
return;
}
g_object_get(channel, "channel-type", &type, "id", &id, NULL);
- dispatcher = (Dispatcher *)g_object_get_data(G_OBJECT(channel), "dispatcher");
spice_printerr("channel type %u id %u", type, id);
+ qxl = common_graphics_channel_get_qxl(COMMON_GRAPHICS_CHANNEL(channel));
+ dispatcher = red_qxl_get_dispatcher(qxl);
payload.rcc = rcc;
dispatcher_send_message(dispatcher,
RED_WORKER_MESSAGE_CURSOR_MIGRATE,
diff --git a/server/red-worker.c b/server/red-worker.c
index 812a40b4b..c43bb1244 100644
--- a/server/red-worker.c
+++ b/server/red-worker.c
@@ -1341,12 +1341,10 @@ RedWorker* red_worker_new(QXLInstance *qxl,
worker->event_timeout = INF_EVENT_WAIT;
- worker->cursor_channel = cursor_channel_new(reds, qxl,
- &worker->core);
+ worker->cursor_channel = cursor_channel_new(reds, qxl, &worker->core);
channel = RED_CHANNEL(worker->cursor_channel);
red_channel_init_stat_node(channel, &worker->stat, "cursor_channel");
red_channel_register_client_cbs(channel, client_cursor_cbs, NULL);
- g_object_set_data(G_OBJECT(channel), "dispatcher", dispatcher);
reds_register_channel(reds, channel);
// TODO: handle seemless migration. Temp, setting migrate to FALSE
@@ -1357,7 +1355,6 @@ RedWorker* red_worker_new(QXLInstance *qxl,
channel = RED_CHANNEL(worker->display_channel);
red_channel_init_stat_node(channel, &worker->stat, "display_channel");
red_channel_register_client_cbs(channel, client_display_cbs, NULL);
- g_object_set_data(G_OBJECT(channel), "dispatcher", dispatcher);
reds_register_channel(reds, channel);
return worker;
--
2.13.3
More information about the Spice-devel
mailing list