[warnings] fix float/double warnings

This commit is contained in:
Armin Novak 2024-09-02 14:57:55 +02:00
parent 7c537d681f
commit fe4cb6de65
No known key found for this signature in database
GPG Key ID: 2CF4A2D2D3D72105
19 changed files with 154 additions and 167 deletions

View File

@ -777,10 +777,7 @@ BOOL wlf_copy_image(const void* src, size_t srcStride, size_t srcWidth, size_t s
BOOL wlf_scale_coordinates(rdpContext* context, UINT32* px, UINT32* py, BOOL fromLocalToRDP) BOOL wlf_scale_coordinates(rdpContext* context, UINT32* px, UINT32* py, BOOL fromLocalToRDP)
{ {
wlfContext* wlf = (wlfContext*)context; wlfContext* wlf = (wlfContext*)context;
rdpGdi* gdi = NULL; UwacSize geometry = { 0 };
UwacSize geometry;
double sx = NAN;
double sy = NAN;
if (!context || !px || !py || !context->gdi) if (!context || !px || !py || !context->gdi)
return FALSE; return FALSE;
@ -788,23 +785,23 @@ BOOL wlf_scale_coordinates(rdpContext* context, UINT32* px, UINT32* py, BOOL fro
if (!freerdp_settings_get_bool(context->settings, FreeRDP_SmartSizing)) if (!freerdp_settings_get_bool(context->settings, FreeRDP_SmartSizing))
return TRUE; return TRUE;
gdi = context->gdi; rdpGdi* gdi = context->gdi;
if (UwacWindowGetDrawingBufferGeometry(wlf->window, &geometry, NULL) != UWAC_SUCCESS) if (UwacWindowGetDrawingBufferGeometry(wlf->window, &geometry, NULL) != UWAC_SUCCESS)
return FALSE; return FALSE;
sx = geometry.width / (double)gdi->width; const double sx = 1.0 * geometry.width / (double)gdi->width;
sy = geometry.height / (double)gdi->height; const double sy = 1.0 * geometry.height / (double)gdi->height;
if (!fromLocalToRDP) if (!fromLocalToRDP)
{ {
*px *= sx; *px *= (UINT32)lround(sx);
*py *= sy; *py *= (UINT32)lround(sy);
} }
else else
{ {
*px /= sx; *px /= (UINT32)lround(sx);
*py /= sy; *py /= (UINT32)lround(sy);
} }
return TRUE; return TRUE;

View File

@ -168,20 +168,17 @@ static BOOL xf_get_pixmap_info(xfContext* xfc);
#ifdef WITH_XRENDER #ifdef WITH_XRENDER
static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h) static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h)
{ {
XTransform transform; XTransform transform = { 0 };
Picture windowPicture = 0; Picture windowPicture = 0;
Picture primaryPicture = 0; Picture primaryPicture = 0;
XRenderPictureAttributes pa; XRenderPictureAttributes pa;
XRenderPictFormat* picFormat = NULL; XRenderPictFormat* picFormat = NULL;
double xScalingFactor = NAN;
double yScalingFactor = NAN;
int x2 = 0; int x2 = 0;
int y2 = 0; int y2 = 0;
const char* filter = NULL; const char* filter = NULL;
rdpSettings* settings = NULL;
WINPR_ASSERT(xfc); WINPR_ASSERT(xfc);
settings = xfc->common.context.settings; rdpSettings* settings = xfc->common.context.settings;
WINPR_ASSERT(settings); WINPR_ASSERT(settings);
if (xfc->scaledWidth <= 0 || xfc->scaledHeight <= 0) if (xfc->scaledWidth <= 0 || xfc->scaledHeight <= 0)
@ -197,10 +194,12 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h)
return; return;
} }
xScalingFactor = const double xScalingFactor = 1.0 *
freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) / (double)xfc->scaledWidth; freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth) /
yScalingFactor = (double)xfc->scaledWidth;
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) / (double)xfc->scaledHeight; const double yScalingFactor = 1.0 *
freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight) /
(double)xfc->scaledHeight;
XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, 0); XSetForeground(xfc->display, xfc->gc, 0);
/* Black out possible space between desktop and window borders */ /* Black out possible space between desktop and window borders */
@ -254,10 +253,15 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h)
/* calculate and fix up scaled coordinates */ /* calculate and fix up scaled coordinates */
x2 = x + w; x2 = x + w;
y2 = y + h; y2 = y + h;
x = ((int)floor(x / xScalingFactor)) - 1;
y = ((int)floor(y / yScalingFactor)) - 1; const double dx1 = floor(x / xScalingFactor);
w = ((int)ceil(x2 / xScalingFactor)) + 1 - x; const double dy1 = floor(y / yScalingFactor);
h = ((int)ceil(y2 / yScalingFactor)) + 1 - y; const double dx2 = ceil(x2 / xScalingFactor);
const double dy2 = ceil(y2 / yScalingFactor);
x = ((int)dx1) - 1;
y = ((int)dy1) - 1;
w = ((int)dx2) + 1 - x;
h = ((int)dy2) + 1 - y;
XRenderSetPictureTransform(xfc->display, primaryPicture, &transform); XRenderSetPictureTransform(xfc->display, primaryPicture, &transform);
XRenderComposite(xfc->display, PictOpSrc, primaryPicture, 0, windowPicture, x, y, 0, 0, XRenderComposite(xfc->display, PictOpSrc, primaryPicture, 0, windowPicture, x, y, 0, 0,
xfc->offset_x + x, xfc->offset_y + y, w, h); xfc->offset_x + x, xfc->offset_y + y, w, h);

View File

@ -17,6 +17,7 @@
* limitations under the License. * limitations under the License.
*/ */
#include <math.h>
#include <winpr/assert.h> #include <winpr/assert.h>
#include <winpr/sysinfo.h> #include <winpr/sysinfo.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
@ -163,8 +164,11 @@ static BOOL xf_disp_sendResize(xfDispContext* xfDisp)
layout.DesktopScaleFactor = layout.DesktopScaleFactor =
freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor); freerdp_settings_get_uint32(settings, FreeRDP_DesktopScaleFactor);
layout.DeviceScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor); layout.DeviceScaleFactor = freerdp_settings_get_uint32(settings, FreeRDP_DeviceScaleFactor);
layout.PhysicalWidth = xfDisp->targetWidth / 75.0 * 25.4;
layout.PhysicalHeight = xfDisp->targetHeight / 75.0 * 25.4; const double dw = xfDisp->targetWidth / 75.0 * 25.4;
const double dh = xfDisp->targetHeight / 75.0 * 25.4;
layout.PhysicalWidth = (UINT32)lround(dw);
layout.PhysicalHeight = (UINT32)lround(dh);
if (IFCALLRESULT(CHANNEL_RC_OK, xfDisp->disp->SendMonitorLayout, xfDisp->disp, 1, if (IFCALLRESULT(CHANNEL_RC_OK, xfDisp->disp->SendMonitorLayout, xfDisp->disp, 1,
&layout) != CHANNEL_RC_OK) &layout) != CHANNEL_RC_OK)

View File

@ -24,6 +24,7 @@
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <string.h> #include <string.h>
#include <math.h>
#include <winpr/assert.h> #include <winpr/assert.h>
#include <winpr/path.h> #include <winpr/path.h>
@ -314,36 +315,32 @@ static BOOL xf_event_execute_action_script(xfContext* xfc, const XEvent* event)
void xf_adjust_coordinates_to_screen(xfContext* xfc, UINT32* x, UINT32* y) void xf_adjust_coordinates_to_screen(xfContext* xfc, UINT32* x, UINT32* y)
{ {
rdpSettings* settings = NULL;
INT64 tx = 0;
INT64 ty = 0;
if (!xfc || !xfc->common.context.settings || !y || !x) if (!xfc || !xfc->common.context.settings || !y || !x)
return; return;
settings = xfc->common.context.settings; rdpSettings* settings = xfc->common.context.settings;
tx = *x; INT64 tx = *x;
ty = *y; INT64 ty = *y;
if (!xfc->remote_app) if (!xfc->remote_app)
{ {
#ifdef WITH_XRENDER #ifdef WITH_XRENDER
if (xf_picture_transform_required(xfc)) if (xf_picture_transform_required(xfc))
{ {
double xScalingFactor = xfc->scaledWidth / (double)freerdp_settings_get_uint32( const double dw = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
settings, FreeRDP_DesktopWidth); const double dh = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
double yScalingFactor = xfc->scaledHeight / (double)freerdp_settings_get_uint32( double xScalingFactor = xfc->scaledWidth / dw;
settings, FreeRDP_DesktopHeight); double yScalingFactor = xfc->scaledHeight / dh;
tx = ((tx + xfc->offset_x) * xScalingFactor); tx = (INT64)lround((1.0 * (*x) + xfc->offset_x) * xScalingFactor);
ty = ((ty + xfc->offset_y) * yScalingFactor); ty = (INT64)lround((1.0 * (*y) + xfc->offset_y) * yScalingFactor);
} }
#endif #endif
} }
CLAMP_COORDINATES(tx, ty); CLAMP_COORDINATES(tx, ty);
*x = tx; *x = (UINT32)tx;
*y = ty; *y = (UINT32)ty;
} }
void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y) void xf_event_adjust_coordinates(xfContext* xfc, int* x, int* y)

View File

@ -36,21 +36,17 @@ static UINT xf_OutputUpdate(xfContext* xfc, xfGfxSurface* surface)
UINT rc = ERROR_INTERNAL_ERROR; UINT rc = ERROR_INTERNAL_ERROR;
UINT32 surfaceX = 0; UINT32 surfaceX = 0;
UINT32 surfaceY = 0; UINT32 surfaceY = 0;
RECTANGLE_16 surfaceRect; RECTANGLE_16 surfaceRect = { 0 };
rdpGdi* gdi = NULL;
const rdpSettings* settings = NULL;
UINT32 nbRects = 0; UINT32 nbRects = 0;
double sx = NAN;
double sy = NAN;
const RECTANGLE_16* rects = NULL; const RECTANGLE_16* rects = NULL;
WINPR_ASSERT(xfc); WINPR_ASSERT(xfc);
WINPR_ASSERT(surface); WINPR_ASSERT(surface);
gdi = xfc->common.context.gdi; rdpGdi* gdi = xfc->common.context.gdi;
WINPR_ASSERT(gdi); WINPR_ASSERT(gdi);
settings = xfc->common.context.settings; rdpSettings* settings = xfc->common.context.settings;
WINPR_ASSERT(settings); WINPR_ASSERT(settings);
surfaceX = surface->gdi.outputOriginX; surfaceX = surface->gdi.outputOriginX;
@ -64,8 +60,8 @@ static UINT xf_OutputUpdate(xfContext* xfc, xfGfxSurface* surface)
XSetFillStyle(xfc->display, xfc->gc, FillSolid); XSetFillStyle(xfc->display, xfc->gc, FillSolid);
region16_intersect_rect(&(surface->gdi.invalidRegion), &(surface->gdi.invalidRegion), region16_intersect_rect(&(surface->gdi.invalidRegion), &(surface->gdi.invalidRegion),
&surfaceRect); &surfaceRect);
sx = surface->gdi.outputTargetWidth / (double)surface->gdi.mappedWidth; const double sx = 1.0 * surface->gdi.outputTargetWidth / (double)surface->gdi.mappedWidth;
sy = surface->gdi.outputTargetHeight / (double)surface->gdi.mappedHeight; const double sy = 1.0 * surface->gdi.outputTargetHeight / (double)surface->gdi.mappedHeight;
if (!(rects = region16_rects(&surface->gdi.invalidRegion, &nbRects))) if (!(rects = region16_rects(&surface->gdi.invalidRegion, &nbRects)))
return CHANNEL_RC_OK; return CHANNEL_RC_OK;
@ -77,10 +73,10 @@ static UINT xf_OutputUpdate(xfContext* xfc, xfGfxSurface* surface)
const UINT32 nYSrc = rect->top; const UINT32 nYSrc = rect->top;
const UINT32 swidth = rect->right - nXSrc; const UINT32 swidth = rect->right - nXSrc;
const UINT32 sheight = rect->bottom - nYSrc; const UINT32 sheight = rect->bottom - nYSrc;
const UINT32 nXDst = surfaceX + nXSrc * sx; const UINT32 nXDst = (UINT32)lround(1.0 * surfaceX + nXSrc * sx);
const UINT32 nYDst = surfaceY + nYSrc * sy; const UINT32 nYDst = (UINT32)lround(1.0 * surfaceY + nYSrc * sy);
const UINT32 dwidth = swidth * sx; const UINT32 dwidth = (UINT32)lround(1.0 * swidth * sx);
const UINT32 dheight = sheight * sy; const UINT32 dheight = (UINT32)lround(1.0 * sheight * sy);
if (surface->stage) if (surface->stage)
{ {

View File

@ -118,16 +118,16 @@ static BOOL xf_Pointer_GetCursorForCurrentScale(rdpContext* context, rdpPointer*
if (!settings) if (!settings)
return FALSE; return FALSE;
const double xscale = (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) const double dw = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
? xfc->scaledWidth / (double)freerdp_settings_get_uint32( const double xscale =
settings, FreeRDP_DesktopWidth) (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) ? 1.0 * xfc->scaledWidth / dw
: 1); : 1);
const double yscale = (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) const double dh = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
? xfc->scaledHeight / (double)freerdp_settings_get_uint32( const double yscale =
settings, FreeRDP_DesktopHeight) (freerdp_settings_get_bool(settings, FreeRDP_SmartSizing) ? 1.0 * xfc->scaledHeight / dh
: 1); : 1);
const UINT32 xTargetSize = MAX(1, pointer->width * xscale); const UINT32 xTargetSize = MAX(1, (UINT32)lround(1.0 * pointer->width * xscale));
const UINT32 yTargetSize = MAX(1, pointer->height * yscale); const UINT32 yTargetSize = MAX(1, (UINT32)lround(1.0 * pointer->height * yscale));
WLog_DBG(TAG, "scaled: %" PRIu32 "x%" PRIu32 ", desktop: %" PRIu32 "x%" PRIu32, WLog_DBG(TAG, "scaled: %" PRIu32 "x%" PRIu32 ", desktop: %" PRIu32 "x%" PRIu32,
xfc->scaledWidth, xfc->scaledHeight, xfc->scaledWidth, xfc->scaledHeight,
@ -186,8 +186,8 @@ static BOOL xf_Pointer_GetCursorForCurrentScale(rdpContext* context, rdpPointer*
ci.size = sizeof(ci); ci.size = sizeof(ci);
ci.width = xTargetSize; ci.width = xTargetSize;
ci.height = yTargetSize; ci.height = yTargetSize;
ci.xhot = pointer->xPos * xscale; ci.xhot = (XcursorDim)lround(1.0 * pointer->xPos * xscale);
ci.yhot = pointer->yPos * yscale; ci.yhot = (XcursorDim)lround(1.0 * pointer->yPos * yscale);
const size_t size = 1ull * ci.height * ci.width * FreeRDPGetBytesPerPixel(CursorFormat); const size_t size = 1ull * ci.height * ci.width * FreeRDPGetBytesPerPixel(CursorFormat);
void* tmp = winpr_aligned_malloc(size, 16); void* tmp = winpr_aligned_malloc(size, 16);

View File

@ -333,16 +333,8 @@ static void xf_input_save_last_event(xfContext* xfc, const XGenericEventCookie*
static void xf_input_detect_pan(xfContext* xfc) static void xf_input_detect_pan(xfContext* xfc)
{ {
double dx[2];
double dy[2];
double px = NAN;
double py = NAN;
double dist_x = NAN;
double dist_y = NAN;
rdpContext* ctx = NULL;
WINPR_ASSERT(xfc); WINPR_ASSERT(xfc);
ctx = &xfc->common.context; rdpContext* ctx = &xfc->common.context;
WINPR_ASSERT(ctx); WINPR_ASSERT(ctx);
if (xfc->active_contacts != 2) if (xfc->active_contacts != 2)
@ -350,16 +342,16 @@ static void xf_input_detect_pan(xfContext* xfc)
return; return;
} }
dx[0] = xfc->contacts[0].pos_x - xfc->contacts[0].last_x; const double dx[] = { xfc->contacts[0].pos_x - xfc->contacts[0].last_x,
dx[1] = xfc->contacts[1].pos_x - xfc->contacts[1].last_x; xfc->contacts[1].pos_x - xfc->contacts[1].last_x };
dy[0] = xfc->contacts[0].pos_y - xfc->contacts[0].last_y; const double dy[] = { xfc->contacts[0].pos_y - xfc->contacts[0].last_y,
dy[1] = xfc->contacts[1].pos_y - xfc->contacts[1].last_y; xfc->contacts[1].pos_y - xfc->contacts[1].last_y };
px = fabs(dx[0]) < fabs(dx[1]) ? dx[0] : dx[1]; const double px = fabs(dx[0]) < fabs(dx[1]) ? dx[0] : dx[1];
py = fabs(dy[0]) < fabs(dy[1]) ? dy[0] : dy[1]; const double py = fabs(dy[0]) < fabs(dy[1]) ? dy[0] : dy[1];
xfc->px_vector += px; xfc->px_vector += px;
xfc->py_vector += py; xfc->py_vector += py;
dist_x = fabs(xfc->contacts[0].pos_x - xfc->contacts[1].pos_x); const double dist_x = fabs(xfc->contacts[0].pos_x - xfc->contacts[1].pos_x);
dist_y = fabs(xfc->contacts[0].pos_y - xfc->contacts[1].pos_y); const double dist_y = fabs(xfc->contacts[0].pos_y - xfc->contacts[1].pos_y);
if (dist_y > MIN_FINGER_DIST) if (dist_y > MIN_FINGER_DIST)
{ {
@ -424,13 +416,10 @@ static void xf_input_detect_pan(xfContext* xfc)
static void xf_input_detect_pinch(xfContext* xfc) static void xf_input_detect_pinch(xfContext* xfc)
{ {
double dist = NAN; ZoomingChangeEventArgs e = { 0 };
double delta = NAN;
ZoomingChangeEventArgs e;
rdpContext* ctx = NULL;
WINPR_ASSERT(xfc); WINPR_ASSERT(xfc);
ctx = &xfc->common.context; rdpContext* ctx = &xfc->common.context;
WINPR_ASSERT(ctx); WINPR_ASSERT(ctx);
if (xfc->active_contacts != 2) if (xfc->active_contacts != 2)
@ -440,7 +429,7 @@ static void xf_input_detect_pinch(xfContext* xfc)
} }
/* first calculate the distance */ /* first calculate the distance */
dist = sqrt(pow(xfc->contacts[1].pos_x - xfc->contacts[0].last_x, 2.0) + const double dist = sqrt(pow(xfc->contacts[1].pos_x - xfc->contacts[0].last_x, 2.0) +
pow(xfc->contacts[1].pos_y - xfc->contacts[0].last_y, 2.0)); pow(xfc->contacts[1].pos_y - xfc->contacts[0].last_y, 2.0));
/* if this is the first 2pt touch */ /* if this is the first 2pt touch */
@ -454,7 +443,7 @@ static void xf_input_detect_pinch(xfContext* xfc)
} }
else else
{ {
delta = xfc->lastDist - dist; double delta = xfc->lastDist - dist;
if (delta > 1.0) if (delta > 1.0)
delta = 1.0; delta = 1.0;

View File

@ -523,22 +523,17 @@ BOOL xf_detect_monitors(xfContext* xfc, UINT32* pMaxWidth, UINT32* pMaxHeight)
if (vB != destB) if (vB != destB)
xfc->fullscreenMonitors.bottom = monitor->orig_screen; xfc->fullscreenMonitors.bottom = monitor->orig_screen;
vX = destX / ((freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth) const UINT32 ps = freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen);
? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen) WINPR_ASSERT(ps <= 100);
: 100) /
100.); const int psuw =
vY = destY / ((freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight) freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth) ? (int)ps : 100;
? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen) const int psuh =
: 100) / freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight) ? (int)ps : 100;
100.); vX = (destX * psuw) / 100;
vR = destR / ((freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseWidth) vY = (destY * psuh) / 100;
? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen) vR = (destR * psuw) / 100;
: 100) / vB = (destB * psuh) / 100;
100.);
vB = destB / ((freerdp_settings_get_bool(settings, FreeRDP_PercentScreenUseHeight)
? freerdp_settings_get_uint32(settings, FreeRDP_PercentScreen)
: 100) /
100.);
} }
vscreen->area.left = 0; vscreen->area.left = 0;

View File

@ -64,6 +64,12 @@ AddTargetWithResourceFile(${MODULE_NAME} FALSE "${FREERDP_VERSION}" SRCS)
list(APPEND LIBS freerdp winpr) list(APPEND LIBS freerdp winpr)
include(CheckLibraryExists)
CHECK_LIBRARY_EXISTS(m lround "" HAVE_LIB_M)
if(HAVE_LIB_M)
list(APPEND LIBS m)
endif()
target_include_directories(${MODULE_NAME} INTERFACE $<INSTALL_INTERFACE:include>) target_include_directories(${MODULE_NAME} INTERFACE $<INSTALL_INTERFACE:include>)
target_link_libraries(${MODULE_NAME} PRIVATE ${FREERDP_CHANNELS_CLIENT_LIBS}) target_link_libraries(${MODULE_NAME} PRIVATE ${FREERDP_CHANNELS_CLIENT_LIBS})
target_link_libraries(${MODULE_NAME} PUBLIC ${LIBS}) target_link_libraries(${MODULE_NAME} PUBLIC ${LIBS})

View File

@ -21,6 +21,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <math.h>
#include <limits.h> #include <limits.h>
#include <float.h> #include <float.h>
@ -2012,7 +2013,8 @@ BOOL freerdp_client_handle_pen(rdpClientContext* cctx, UINT32 flags, INT32 devic
if ((flags & FREERDP_PEN_HAS_PRESSURE) != 0) if ((flags & FREERDP_PEN_HAS_PRESSURE) != 0)
{ {
const double pressure = va_arg(args, double); const double pressure = va_arg(args, double);
normalizedpressure = (pressure * 1024) / pen->max_pressure; const double np = (pressure * 1024.0) / pen->max_pressure;
normalizedpressure = (UINT32)lround(np);
WLog_DBG(TAG, "pen pressure %lf -> %" PRIu32, pressure, normalizedpressure); WLog_DBG(TAG, "pen pressure %lf -> %" PRIu32, pressure, normalizedpressure);
fieldFlags |= RDPINPUT_PEN_CONTACT_PRESSURE_PRESENT; fieldFlags |= RDPINPUT_PEN_CONTACT_PRESSURE_PRESENT;
} }

View File

@ -150,12 +150,7 @@ int bulk_decompress(rdpBulk* WINPR_RESTRICT bulk, const BYTE* WINPR_RESTRICT pSr
UINT32 SrcSize, const BYTE** WINPR_RESTRICT ppDstData, UINT32 SrcSize, const BYTE** WINPR_RESTRICT ppDstData,
UINT32* WINPR_RESTRICT pDstSize, UINT32 flags) UINT32* WINPR_RESTRICT pDstSize, UINT32 flags)
{ {
UINT32 type = 0;
int status = -1; int status = -1;
rdpMetrics* metrics = NULL;
UINT32 CompressedBytes = 0;
UINT32 UncompressedBytes = 0;
double CompressionRatio = NAN;
WINPR_ASSERT(bulk); WINPR_ASSERT(bulk);
WINPR_ASSERT(bulk->context); WINPR_ASSERT(bulk->context);
@ -163,11 +158,11 @@ int bulk_decompress(rdpBulk* WINPR_RESTRICT bulk, const BYTE* WINPR_RESTRICT pSr
WINPR_ASSERT(ppDstData); WINPR_ASSERT(ppDstData);
WINPR_ASSERT(pDstSize); WINPR_ASSERT(pDstSize);
metrics = bulk->context->metrics; rdpMetrics* metrics = bulk->context->metrics;
WINPR_ASSERT(metrics); WINPR_ASSERT(metrics);
bulk_compression_max_size(bulk); bulk_compression_max_size(bulk);
type = flags & BULK_COMPRESSION_TYPE_MASK; const UINT32 type = flags & BULK_COMPRESSION_TYPE_MASK;
if (flags & BULK_COMPRESSION_FLAGS_MASK) if (flags & BULK_COMPRESSION_FLAGS_MASK)
{ {
@ -215,9 +210,10 @@ int bulk_decompress(rdpBulk* WINPR_RESTRICT bulk, const BYTE* WINPR_RESTRICT pSr
if (status >= 0) if (status >= 0)
{ {
CompressedBytes = SrcSize; const UINT32 CompressedBytes = SrcSize;
UncompressedBytes = *pDstSize; const UINT32 UncompressedBytes = *pDstSize;
CompressionRatio = metrics_write_bytes(metrics, UncompressedBytes, CompressedBytes); const double CompressionRatio =
metrics_write_bytes(metrics, UncompressedBytes, CompressedBytes);
#ifdef WITH_BULK_DEBUG #ifdef WITH_BULK_DEBUG
{ {
WLog_DBG(TAG, WLog_DBG(TAG,
@ -245,10 +241,6 @@ int bulk_compress(rdpBulk* WINPR_RESTRICT bulk, const BYTE* WINPR_RESTRICT pSrcD
UINT32* WINPR_RESTRICT pFlags) UINT32* WINPR_RESTRICT pFlags)
{ {
int status = -1; int status = -1;
rdpMetrics* metrics = NULL;
UINT32 CompressedBytes = 0;
UINT32 UncompressedBytes = 0;
double CompressionRatio = NAN;
WINPR_ASSERT(bulk); WINPR_ASSERT(bulk);
WINPR_ASSERT(bulk->context); WINPR_ASSERT(bulk->context);
@ -256,7 +248,7 @@ int bulk_compress(rdpBulk* WINPR_RESTRICT bulk, const BYTE* WINPR_RESTRICT pSrcD
WINPR_ASSERT(ppDstData); WINPR_ASSERT(ppDstData);
WINPR_ASSERT(pDstSize); WINPR_ASSERT(pDstSize);
metrics = bulk->context->metrics; rdpMetrics* metrics = bulk->context->metrics;
WINPR_ASSERT(metrics); WINPR_ASSERT(metrics);
if ((SrcSize <= 50) || (SrcSize >= 16384)) if ((SrcSize <= 50) || (SrcSize >= 16384))
@ -298,9 +290,10 @@ int bulk_compress(rdpBulk* WINPR_RESTRICT bulk, const BYTE* WINPR_RESTRICT pSrcD
if (status >= 0) if (status >= 0)
{ {
CompressedBytes = *pDstSize; const UINT32 CompressedBytes = *pDstSize;
UncompressedBytes = SrcSize; const UINT32 UncompressedBytes = SrcSize;
CompressionRatio = metrics_write_bytes(metrics, UncompressedBytes, CompressedBytes); const double CompressionRatio =
metrics_write_bytes(metrics, UncompressedBytes, CompressedBytes);
#ifdef WITH_BULK_DEBUG #ifdef WITH_BULK_DEBUG
{ {
WLog_DBG(TAG, WLog_DBG(TAG,

View File

@ -915,11 +915,11 @@ static BOOL rdp_write_info_packet(rdpRdp* rdp, wStream* s)
Stream_Write_UINT32(s, settings->KeyboardCodePage); /* CodePage (4 bytes) */ Stream_Write_UINT32(s, settings->KeyboardCodePage); /* CodePage (4 bytes) */
Stream_Write_UINT32(s, flags); /* flags (4 bytes) */ Stream_Write_UINT32(s, flags); /* flags (4 bytes) */
Stream_Write_UINT16(s, (UINT32)cbDomain); /* cbDomain (2 bytes) */ Stream_Write_UINT16(s, (UINT16)cbDomain); /* cbDomain (2 bytes) */
Stream_Write_UINT16(s, (UINT32)cbUserName); /* cbUserName (2 bytes) */ Stream_Write_UINT16(s, (UINT16)cbUserName); /* cbUserName (2 bytes) */
Stream_Write_UINT16(s, (UINT32)cbPassword); /* cbPassword (2 bytes) */ Stream_Write_UINT16(s, (UINT16)cbPassword); /* cbPassword (2 bytes) */
Stream_Write_UINT16(s, (UINT32)cbAlternateShell); /* cbAlternateShell (2 bytes) */ Stream_Write_UINT16(s, (UINT16)cbAlternateShell); /* cbAlternateShell (2 bytes) */
Stream_Write_UINT16(s, (UINT32)cbWorkingDir); /* cbWorkingDir (2 bytes) */ Stream_Write_UINT16(s, (UINT16)cbWorkingDir); /* cbWorkingDir (2 bytes) */
Stream_Write(s, domainW, cbDomain); Stream_Write(s, domainW, cbDomain);

View File

@ -168,8 +168,6 @@ static UINT gdi_OutputUpdate(rdpGdi* gdi, gdiGfxSurface* surface)
RECTANGLE_16 surfaceRect; RECTANGLE_16 surfaceRect;
const RECTANGLE_16* rects = NULL; const RECTANGLE_16* rects = NULL;
UINT32 nbRects = 0; UINT32 nbRects = 0;
double sx = NAN;
double sy = NAN;
rdpUpdate* update = NULL; rdpUpdate* update = NULL;
WINPR_ASSERT(gdi); WINPR_ASSERT(gdi);
@ -189,8 +187,8 @@ static UINT gdi_OutputUpdate(rdpGdi* gdi, gdiGfxSurface* surface)
surfaceRect.right = (UINT16)MIN(UINT16_MAX, surface->mappedWidth); surfaceRect.right = (UINT16)MIN(UINT16_MAX, surface->mappedWidth);
surfaceRect.bottom = (UINT16)MIN(UINT16_MAX, surface->mappedHeight); surfaceRect.bottom = (UINT16)MIN(UINT16_MAX, surface->mappedHeight);
region16_intersect_rect(&(surface->invalidRegion), &(surface->invalidRegion), &surfaceRect); region16_intersect_rect(&(surface->invalidRegion), &(surface->invalidRegion), &surfaceRect);
sx = surface->outputTargetWidth / (double)surface->mappedWidth; const double sx = surface->outputTargetWidth / (double)surface->mappedWidth;
sy = surface->outputTargetHeight / (double)surface->mappedHeight; const double sy = surface->outputTargetHeight / (double)surface->mappedHeight;
if (!(rects = region16_rects(&surface->invalidRegion, &nbRects)) || !nbRects) if (!(rects = region16_rects(&surface->invalidRegion, &nbRects)) || !nbRects)
return CHANNEL_RC_OK; return CHANNEL_RC_OK;

View File

@ -318,7 +318,7 @@ BOOL freerdp_write_four_byte_float(wStream* s, double value)
exp = 7; exp = 7;
} }
UINT64 base = aval; UINT64 base = (UINT64)llround(aval);
while (exp >= 0) while (exp >= 0)
{ {
const double div = pow(10.0, exp); const double div = pow(10.0, exp);

View File

@ -68,7 +68,8 @@ void stopwatch_reset(STOPWATCH* stopwatch)
double stopwatch_get_elapsed_time_in_seconds(STOPWATCH* stopwatch) double stopwatch_get_elapsed_time_in_seconds(STOPWATCH* stopwatch)
{ {
return (stopwatch->elapsed / 1000000.0); const long double ld = stopwatch->elapsed / 1000000.0L;
return (double)ld;
} }
void stopwatch_get_elapsed_time_in_useconds(STOPWATCH* stopwatch, UINT32* sec, UINT32* usec) void stopwatch_get_elapsed_time_in_useconds(STOPWATCH* stopwatch, UINT32* sec, UINT32* usec)

View File

@ -534,11 +534,11 @@ static void touch_handle_down(void* data, struct wl_touch* wl_touch, uint32_t se
tdata->seat = seat; tdata->seat = seat;
tdata->id = id; tdata->id = id;
float sx = wl_fixed_to_double(x_w); double sx = wl_fixed_to_double(x_w);
float sy = wl_fixed_to_double(y_w); double sy = wl_fixed_to_double(y_w);
tdata->x = sx; tdata->x = (wl_fixed_t)lround(sx);
tdata->y = sy; tdata->y = (wl_fixed_t)lround(sy);
#if 0 #if 0
struct widget *widget; struct widget *widget;
@ -644,11 +644,11 @@ static void touch_handle_motion(void* data, struct wl_touch* wl_touch, uint32_t
tdata->seat = seat; tdata->seat = seat;
tdata->id = id; tdata->id = id;
float sx = wl_fixed_to_double(x_w); double sx = wl_fixed_to_double(x_w);
float sy = wl_fixed_to_double(y_w); double sy = wl_fixed_to_double(y_w);
tdata->x = sx; tdata->x = (wl_fixed_t)lround(sx);
tdata->y = sy; tdata->y = (wl_fixed_t)lround(sy);
#if 0 #if 0
struct touch_point *tp; struct touch_point *tp;
@ -757,8 +757,8 @@ static void pointer_handle_enter(void* data, struct wl_pointer* pointer, uint32_
assert(input); assert(input);
float sx = wl_fixed_to_double(sx_w); double sx = wl_fixed_to_double(sx_w);
float sy = wl_fixed_to_double(sy_w); double sy = wl_fixed_to_double(sy_w);
if (!surface) if (!surface)
{ {
@ -782,8 +782,8 @@ static void pointer_handle_enter(void* data, struct wl_pointer* pointer, uint32_
event->seat = input; event->seat = input;
event->window = window; event->window = window;
event->x = sx; event->x = (uint32_t)lround(sx);
event->y = sy; event->y = (uint32_t)lround(sy);
/* Apply cursor theme */ /* Apply cursor theme */
set_cursor_image(input, serial); set_cursor_image(input, serial);
@ -861,8 +861,8 @@ static void pointer_handle_button(void* data, struct wl_pointer* pointer, uint32
event->seat = seat; event->seat = seat;
event->window = window; event->window = window;
event->x = seat->sx; event->x = (uint32_t)lround(seat->sx);
event->y = seat->sy; event->y = (uint32_t)lround(seat->sy);
event->button = button; event->button = button;
event->state = (enum wl_pointer_button_state)state_w; event->state = (enum wl_pointer_button_state)state_w;
} }
@ -885,8 +885,8 @@ static void pointer_handle_axis(void* data, struct wl_pointer* pointer, uint32_t
event->seat = seat; event->seat = seat;
event->window = window; event->window = window;
event->x = seat->sx; event->x = (uint32_t)lround(seat->sx);
event->y = seat->sy; event->y = (uint32_t)lround(seat->sy);
event->axis = axis; event->axis = axis;
event->value = value; event->value = value;
} }
@ -957,8 +957,8 @@ static void pointer_axis_discrete(void* data, struct wl_pointer* wl_pointer, uin
event->seat = seat; event->seat = seat;
event->window = window; event->window = window;
event->x = seat->sx; event->x = (uint32_t)lround(seat->sx);
event->y = seat->sy; event->y = (uint32_t)lround(seat->sy);
event->axis = axis; event->axis = axis;
event->value = discrete; event->value = discrete;
} }
@ -983,8 +983,8 @@ static void pointer_axis_value120(void* data, struct wl_pointer* wl_pointer, uin
event->seat = seat; event->seat = seat;
event->window = window; event->window = window;
event->x = seat->sx; event->x = (uint32_t)lround(seat->sx);
event->y = seat->sy; event->y = (uint32_t)lround(seat->sy);
event->axis = axis; event->axis = axis;
event->value = value120 / 120; event->value = value120 / 120;
} }

View File

@ -209,7 +209,7 @@ struct uwac_seat
int repeat_timer_fd; int repeat_timer_fd;
UwacTask repeat_task; UwacTask repeat_task;
float sx, sy; double sx, sy;
struct wl_list link; struct wl_list link;
void* data_context; void* data_context;

View File

@ -710,14 +710,19 @@ static void damage_surface(UwacWindow* window, UwacBuffer* buffer, int scale)
static void damage_surface(UwacWindow* window, UwacBuffer* buffer, int scale) static void damage_surface(UwacWindow* window, UwacBuffer* buffer, int scale)
{ {
uint32_t nrects = 0; uint32_t nrects = 0;
const RECTANGLE_16* box = region16_rects(&buffer->damage, &nrects); const RECTANGLE_16* boxes = region16_rects(&buffer->damage, &nrects);
for (UINT32 i = 0; i < nrects; i++, box++) for (UINT32 i = 0; i < nrects; i++)
{ {
const int x = ((int)floor(box->left / scale)) - 1; const RECTANGLE_16* box = &boxes[i];
const int y = ((int)floor(box->top / scale)) - 1; const double dx = floor(1.0 * box->left / scale);
const int w = ((int)ceil((box->right - box->left) / scale)) + 2; const double dy = floor(1.0 * box->top / scale);
const int h = ((int)ceil((box->bottom - box->top) / scale)) + 2; const double dw = ceil(1.0 * (box->right - box->left) / scale);
const double dh = ceil(1.0 * (box->bottom - box->top) / scale);
const int x = ((int)dx) - 1;
const int y = ((int)dy) - 1;
const int w = ((int)dw) + 2;
const int h = ((int)dh) + 2;
wl_surface_damage(window->surface, x, y, w, h); wl_surface_damage(window->surface, x, y, w, h);
} }

View File

@ -772,9 +772,9 @@ wHashTable* HashTable_New(BOOL synchronized)
if (!table->bucketArray) if (!table->bucketArray)
goto fail; goto fail;
table->idealRatio = 3.0; table->idealRatio = 3.0f;
table->lowerRehashThreshold = 0.0; table->lowerRehashThreshold = 0.0f;
table->upperRehashThreshold = 15.0; table->upperRehashThreshold = 15.0f;
table->hash = HashTable_PointerHash; table->hash = HashTable_PointerHash;
table->key.fnObjectEquals = HashTable_PointerCompare; table->key.fnObjectEquals = HashTable_PointerCompare;
table->value.fnObjectEquals = HashTable_PointerCompare; table->value.fnObjectEquals = HashTable_PointerCompare;