Skip to content

Commit

Permalink
Fixing resizing not working.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nexarian committed Jul 11, 2022
1 parent a9a72bd commit c5e2e23
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions xrdp/xrdp_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,8 @@ dynamic_monitor_data(intptr_t id, int chan_id, char *data, int bytes)
}
list_add_item(wm->mm->resize_queue, (tintptr)display_size_data);
g_set_wait_obj(wm->mm->resize_ready);
LOG(LOG_LEVEL_DEBUG, "dynamic_monitor_data:"
" received width %d, received height %d.", display_size_data->session_width, display_size_data->session_height);
return 0;
}

Expand Down Expand Up @@ -1303,7 +1305,7 @@ process_display_control_monitor_layout_data(struct xrdp_wm *wm)
static int
dynamic_monitor_process_queue(struct xrdp_mm *self)
{
LOG_DEVEL(LOG_LEVEL_INFO, "dynamic_monitor_process_queue:");
LOG_DEVEL(LOG_LEVEL_TRACE, "dynamic_monitor_process_queue:");

if (self == 0)
{
Expand All @@ -1321,10 +1323,11 @@ dynamic_monitor_process_queue(struct xrdp_mm *self)
{
if (self->resize_queue->count <= 0)
{
LOG_DEVEL(LOG_LEVEL_DEBUG, "Resize queue is empty.");
return 0;
}
LOG_DEVEL(LOG_LEVEL_INFO, "dynamic_monitor_process_queue: Queue is"
"not empty. Filling out description.");
LOG_DEVEL(LOG_LEVEL_DEBUG, "dynamic_monitor_process_queue: Queue is"
" not empty. Filling out description.");
const struct display_size_description *queue_head =
(struct display_size_description *)
list_get_item(self->resize_queue, 0);
Expand All @@ -1334,8 +1337,8 @@ dynamic_monitor_process_queue(struct xrdp_mm *self)

if (invalid_dimensions)
{
LOG(LOG_LEVEL_INFO,
"process_display_control_monitor_layout_data: Not allowing"
LOG(LOG_LEVEL_DEBUG,
"dynamic_monitor_process_queue: Not allowing"
" resize due to invalid dimensions (w: %d x h: %d)",
queue_head->session_width,
queue_head->session_height);
Expand All @@ -1351,9 +1354,9 @@ dynamic_monitor_process_queue(struct xrdp_mm *self)

if (already_this_size)
{
LOG(LOG_LEVEL_INFO,
"process_display_control_monitor_layout_data: Not"
" resizing. Already this size. (w: %d x h: %d)",
LOG(LOG_LEVEL_DEBUG,
"dynamic_monitor_process_queue: Not resizing."
" Already this size. (w: %d x h: %d)",
queue_head->session_width,
queue_head->session_height);
}
Expand All @@ -1371,9 +1374,18 @@ dynamic_monitor_process_queue(struct xrdp_mm *self)
self->resize_data->last_state_update_timestamp = time;
advance_resize_state_machine(self, WMRZ_ENCODER_DELETE);
}
else
{
g_set_wait_obj(self->resize_ready);
}
list_remove_item(self->resize_queue, 0);
return 0;
}
else
{
LOG_DEVEL(LOG_LEVEL_DEBUG, "dynamic_monitor_process_queue:"
" Resize data is not null.");
}

if (self->resize_data->state == WMRZ_COMPLETE)
{
Expand All @@ -1382,13 +1394,15 @@ dynamic_monitor_process_queue(struct xrdp_mm *self)
self->resize_data->description.session_width,
self->resize_data->description.session_height,
g_time3() - self->resize_data->start_time);
g_set_wait_obj(self->resize_ready);
}
else if (self->resize_data->state == WMRZ_ERROR)
{
LOG(LOG_LEVEL_INFO, "dynamic_monitor_process_queue: Clearing"
" failed request to resize to: (w: %d x h: %d)",
self->resize_data->description.session_width,
self->resize_data->description.session_height);
g_set_wait_obj(self->resize_ready);
}
else
{
Expand Down Expand Up @@ -3082,13 +3096,10 @@ xrdp_mm_check_wait_objs(struct xrdp_mm *self)
}
}

if (self->resize_queue != 0 && self->resize_queue->count > 0)
if (g_is_wait_obj_set(self->resize_ready))
{
if (g_is_wait_obj_set(self->resize_ready))
{
g_reset_wait_obj(self->resize_ready);
dynamic_monitor_process_queue(self);
}
g_reset_wait_obj(self->resize_ready);
dynamic_monitor_process_queue(self);
}

if (self->encoder != NULL)
Expand Down

0 comments on commit c5e2e23

Please sign in to comment.