summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2011-07-04 11:12:33 +0300
committerAlon Levy <alevy@redhat.com>2011-07-21 15:09:29 +0300
commit84ff23cd2b641af4eb92f2ba83c641016db34653 (patch)
treec5dda7daa523d308806561ac669233dee4af546a
parent7db7212c3a336c9499bfcd10d2affbf76bf1d6b1 (diff)
downloadspice-84ff23cd2b641af4eb92f2ba83c641016db34653.tar.gz
spice-84ff23cd2b641af4eb92f2ba83c641016db34653.tar.xz
spice-84ff23cd2b641af4eb92f2ba83c641016db34653.zip
server: replace redundant code with red_cursor_reset
In addition (1) make handle_dev_destroy_surfaces call red_release_cursor (2) call red_wait_outgoing_item(cursor_channel) only after adding msgs to pipe [3d3066b175ee2dec8e73c8c56f418a6ae98b1c26 cherry-pick with modifications]
-rw-r--r--server/red_worker.c71
1 files changed, 24 insertions, 47 deletions
diff --git a/server/red_worker.c b/server/red_worker.c
index 45686963..12ad74a7 100644
--- a/server/red_worker.c
+++ b/server/red_worker.c
@@ -9716,6 +9716,27 @@ static inline void handle_dev_destroy_surface_wait(RedWorker *worker)
write_message(worker->channel, &message);
}
+static inline void red_cursor_reset(RedWorker *worker)
+{
+ if (worker->cursor) {
+ red_release_cursor(worker, worker->cursor);
+ worker->cursor = NULL;
+ }
+
+ worker->cursor_visible = TRUE;
+ worker->cursor_position.x = worker->cursor_position.y = 0;
+ worker->cursor_trail_length = worker->cursor_trail_frequency = 0;
+
+ if (worker->cursor_channel) {
+ red_pipe_add_type(&worker->cursor_channel->base, PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
+ if (!worker->cursor_channel->base.migrate) {
+ red_pipe_add_verb(&worker->cursor_channel->base, SPICE_MSG_CURSOR_RESET);
+ }
+ red_wait_outgoing_item((RedChannel *)worker->cursor_channel);
+ ASSERT(!worker->cursor_channel->base.send_data.item);
+ }
+}
+
/* called upon device reset */
static inline void handle_dev_destroy_surfaces(RedWorker *worker)
{
@@ -9735,15 +9756,6 @@ static inline void handle_dev_destroy_surfaces(RedWorker *worker)
}
ASSERT(ring_is_empty(&worker->streams));
- red_wait_outgoing_item((RedChannel *)worker->cursor_channel);
- if (worker->cursor_channel) {
- red_pipe_add_type(&worker->cursor_channel->base, PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
- if (!worker->cursor_channel->base.migrate) {
- red_pipe_add_verb(&worker->cursor_channel->base, SPICE_MSG_CURSOR_RESET);
- }
- ASSERT(!worker->cursor_channel->base.send_data.item);
- }
-
if (worker->display_channel) {
red_pipe_add_type(&worker->display_channel->base, PIPE_ITEM_TYPE_INVAL_PALLET_CACHE);
red_pipe_add_verb(&worker->display_channel->base, SPICE_MSG_DISPLAY_STREAM_DESTROY_ALL);
@@ -9751,9 +9763,7 @@ static inline void handle_dev_destroy_surfaces(RedWorker *worker)
red_display_clear_glz_drawables(worker->display_channel);
- worker->cursor_visible = TRUE;
- worker->cursor_position.x = worker->cursor_position.y = 0;
- worker->cursor_trail_length = worker->cursor_trail_frequency = 0;
+ red_cursor_reset(worker);
message = RED_WORKER_MESSAGE_READY;
write_message(worker->channel, &message);
@@ -9806,20 +9816,6 @@ static inline void handle_dev_destroy_primary_surface(RedWorker *worker)
PANIC_ON(surface_id != 0);
PANIC_ON(!worker->surfaces[surface_id].context.canvas);
- if (worker->cursor) {
- red_release_cursor(worker, worker->cursor);
- worker->cursor = NULL;
- }
-
- red_wait_outgoing_item((RedChannel *)worker->cursor_channel);
- if (worker->cursor_channel) {
- red_pipe_add_type(&worker->cursor_channel->base, PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
- if (!worker->cursor_channel->base.migrate) {
- red_pipe_add_verb(&worker->cursor_channel->base, SPICE_MSG_CURSOR_RESET);
- }
- ASSERT(!worker->cursor_channel->base.send_data.item);
- }
-
flush_all_qxl_commands(worker);
destroy_surface_wait(worker, 0);
red_destroy_surface(worker, 0);
@@ -9827,9 +9823,7 @@ static inline void handle_dev_destroy_primary_surface(RedWorker *worker)
ASSERT(!worker->surfaces[surface_id].context.canvas);
- worker->cursor_visible = TRUE;
- worker->cursor_position.x = worker->cursor_position.y = 0;
- worker->cursor_trail_length = worker->cursor_trail_frequency = 0;
+ red_cursor_reset(worker);
message = RED_WORKER_MESSAGE_READY;
write_message(worker->channel, &message);
@@ -9865,24 +9859,7 @@ static void handle_dev_input(EventListener *listener, uint32_t events)
clear_bit(RED_WORKER_PENDING_OOM, worker->pending);
break;
case RED_WORKER_MESSAGE_RESET_CURSOR:
- if (worker->cursor) {
- red_release_cursor(worker, worker->cursor);
- worker->cursor = NULL;
- }
-
- red_wait_outgoing_item((RedChannel *)worker->cursor_channel);
- if (worker->cursor_channel) {
- red_pipe_add_type(&worker->cursor_channel->base, PIPE_ITEM_TYPE_INVAL_CURSOR_CACHE);
- if (!worker->cursor_channel->base.migrate) {
- red_pipe_add_verb(&worker->cursor_channel->base, SPICE_MSG_CURSOR_RESET);
- }
- ASSERT(!worker->cursor_channel->base.send_data.item);
-
- worker->cursor_visible = TRUE;
- worker->cursor_position.x = worker->cursor_position.y = 0;
- worker->cursor_trail_length = worker->cursor_trail_frequency = 0;
- }
-
+ red_cursor_reset(worker);
message = RED_WORKER_MESSAGE_READY;
write_message(worker->channel, &message);
break;