diff --git a/server/cursor-channel.cpp b/server/cursor-channel.cpp index 4171da2b..c8d4a227 100644 --- a/server/cursor-channel.cpp +++ b/server/cursor-channel.cpp @@ -254,21 +254,19 @@ void CursorChannel::process_cmd(RedCursorCmd *cursor_cmd) } } -void cursor_channel_reset(CursorChannel *cursor) +void CursorChannel::reset() { - spice_return_if_fail(cursor); + cursor_channel_set_item(this, NULL); + cursor_visible = true; + cursor_position.x = cursor_position.y = 0; + cursor_trail_length = cursor_trail_frequency = 0; - cursor_channel_set_item(cursor, NULL); - cursor->cursor_visible = true; - cursor->cursor_position.x = cursor->cursor_position.y = 0; - cursor->cursor_trail_length = cursor->cursor_trail_frequency = 0; - - if (cursor->is_connected()) { - cursor->pipes_add_type(RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE); - if (!cursor->get_during_target_migrate()) { - cursor->pipes_add_empty_msg(SPICE_MSG_CURSOR_RESET); + if (is_connected()) { + pipes_add_type(RED_PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE); + if (!get_during_target_migrate()) { + pipes_add_empty_msg(SPICE_MSG_CURSOR_RESET); } - cursor->wait_all_sent(COMMON_CLIENT_TIMEOUT); + wait_all_sent(COMMON_CLIENT_TIMEOUT); } } diff --git a/server/cursor-channel.h b/server/cursor-channel.h index 126834da..d223c965 100644 --- a/server/cursor-channel.h +++ b/server/cursor-channel.h @@ -36,6 +36,7 @@ struct CursorChannel final: public CommonGraphicsChannel CursorChannel(RedsState *reds, uint32_t id, SpiceCoreInterfaceInternal *core=nullptr, Dispatcher *dispatcher=nullptr); ~CursorChannel(); + void reset(); void do_init(); void process_cmd(RedCursorCmd *cursor_cmd); void set_mouse_mode(uint32_t mode); @@ -61,8 +62,6 @@ red::shared_ptr cursor_channel_new(RedsState *server, int id, SpiceCoreInterfaceInternal *core, Dispatcher *dispatcher); -void cursor_channel_reset (CursorChannel *cursor); - #include "pop-visibility.h" #endif /* CURSOR_CHANNEL_H_ */ diff --git a/server/red-worker.cpp b/server/red-worker.cpp index e54e7a9e..86b02bfd 100644 --- a/server/red-worker.cpp +++ b/server/red-worker.cpp @@ -395,7 +395,7 @@ static void handle_dev_destroy_surfaces(void *opaque, void *payload) flush_all_qxl_commands(worker); display_channel_destroy_surfaces(worker->display_channel); - cursor_channel_reset(worker->cursor_channel); + worker->cursor_channel->reset(); } static void dev_create_primary_surface(RedWorker *worker, uint32_t surface_id, @@ -478,7 +478,7 @@ static void destroy_primary_surface(RedWorker *worker, uint32_t surface_id) */ spice_warn_if_fail(!display_channel_surface_has_canvas(display, surface_id)); - cursor_channel_reset(worker->cursor_channel); + worker->cursor_channel->reset(); } static void handle_dev_destroy_primary_surface(void *opaque, void *payload) @@ -583,7 +583,7 @@ static void handle_dev_reset_cursor(void *opaque, void *payload) { RedWorker *worker = (RedWorker*) opaque; - cursor_channel_reset(worker->cursor_channel); + worker->cursor_channel->reset(); } static void handle_dev_reset_image_cache(void *opaque, void *payload) @@ -609,7 +609,7 @@ static void handle_dev_destroy_surfaces_async(void *opaque, void *payload) flush_all_qxl_commands(worker); display_channel_destroy_surfaces(worker->display_channel); - cursor_channel_reset(worker->cursor_channel); + worker->cursor_channel->reset(); red_qxl_async_complete(worker->qxl, msg->base.cookie); }