Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update handling of scale factor #2301

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions libxrdp/libxrdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1959,30 +1959,33 @@ libxrdp_process_monitor_stream(struct stream *s,
}

in_uint32_le(s, monitor_layout->desktop_scale_factor);
if (monitor_layout->desktop_scale_factor < 100
|| monitor_layout->desktop_scale_factor > 500
|| (monitor_layout->desktop_scale_factor != 100
&& monitor_layout->desktop_scale_factor != 140
&& monitor_layout->desktop_scale_factor != 180))
int check_desktop_scale_factor
= monitor_layout->desktop_scale_factor < 100
|| monitor_layout->desktop_scale_factor > 500;
if (check_desktop_scale_factor)
{
LOG(LOG_LEVEL_WARNING, "libxrdp_process_monitor_stream:"
" desktop_scale_factor is not within valid range. Assuming 100."
" Value was: %d",
" desktop_scale_factor is not within valid range"
" of [100, 500]. Assuming 100. Value was: %d",
monitor_layout->desktop_scale_factor);
monitor_layout->desktop_scale_factor = 100;
}

in_uint32_le(s, monitor_layout->device_scale_factor);
if (monitor_layout->device_scale_factor < 100
|| monitor_layout->device_scale_factor > 500
|| (monitor_layout->device_scale_factor != 100
&& monitor_layout->device_scale_factor != 140
&& monitor_layout->device_scale_factor != 180))
int check_device_scale_factor
= monitor_layout->device_scale_factor != 100
&& monitor_layout->device_scale_factor != 140
&& monitor_layout->device_scale_factor != 180;
if (check_device_scale_factor)
{
LOG(LOG_LEVEL_WARNING, "libxrdp_process_monitor_stream:"
" device_scale_factor is not within valid range. Assuming 100."
" Value was: %d",
" device_scale_factor a valid value (One of 100, 140, 180)."
" Assuming 100. Value was: %d",
monitor_layout->device_scale_factor);
}

if (check_desktop_scale_factor || check_device_scale_factor)
{
monitor_layout->desktop_scale_factor = 100;
monitor_layout->device_scale_factor = 100;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/libxrdp/test_libxrdp_process_monitor_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ START_TEST(test_libxrdp_process_monitor_stream__with_sextuple_monitor_happy_path
ck_assert_int_eq(description->minfo[2].physical_height, 1000);
ck_assert_int_eq(description->minfo[2].orientation, 0);
ck_assert_int_eq(description->minfo[2].desktop_scale_factor, 100);
ck_assert_int_eq(description->minfo[2].device_scale_factor, 140);
ck_assert_int_eq(description->minfo[2].device_scale_factor, 100);
ck_assert_int_eq(description->minfo[2].is_primary, 0);

ck_assert_int_eq(description->minfo[3].left, 0);
Expand Down Expand Up @@ -342,7 +342,7 @@ START_TEST(test_libxrdp_process_monitor_stream__with_sextuple_monitor_happy_path
ck_assert_int_eq(description->minfo_wm[2].physical_height, 1000);
ck_assert_int_eq(description->minfo_wm[2].orientation, 0);
ck_assert_int_eq(description->minfo_wm[2].desktop_scale_factor, 100);
ck_assert_int_eq(description->minfo_wm[2].device_scale_factor, 140);
ck_assert_int_eq(description->minfo_wm[2].device_scale_factor, 100);
ck_assert_int_eq(description->minfo_wm[2].is_primary, 0);

ck_assert_int_eq(description->minfo_wm[3].left, 0);
Expand Down