mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-14 16:34:18 +09:00
[winpr,collections] fix PubSub_OnEvent return checks
* proper return checks on use * fix return on invalid input arguments * fix return on no event registered
This commit is contained in:
@@ -91,7 +91,9 @@ static CGContextRef mac_create_bitmap_context(rdpContext *context);
|
||||
EventArgsInit(&e, "mfreerdp");
|
||||
e.embed = TRUE;
|
||||
e.handle = (void *)self;
|
||||
PubSub_OnEmbedWindow(context->pubSub, context, &e);
|
||||
if (PubSub_OnEmbedWindow(context->pubSub, context, &e) < 0)
|
||||
return -1;
|
||||
|
||||
NSScreen *screen = [[NSScreen screens] objectAtIndex:0];
|
||||
NSRect screenFrame = [screen frame];
|
||||
|
||||
@@ -1495,7 +1497,8 @@ BOOL mac_desktop_resize(rdpContext *context)
|
||||
EventArgsInit(&e, "mfreerdp");
|
||||
e.width = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
|
||||
e.height = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
|
||||
PubSub_OnResizeWindow(context->pubSub, context, &e);
|
||||
if (PubSub_OnResizeWindow(context->pubSub, context, &e) < 0)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -477,7 +477,9 @@ static BOOL wf_post_connect(freerdp* instance)
|
||||
EventArgsInit(&e, "wfreerdp");
|
||||
e.embed = FALSE;
|
||||
e.handle = (void*)wfc->hwnd;
|
||||
PubSub_OnEmbedWindow(context->pubSub, context, &e);
|
||||
if (PubSub_OnEmbedWindow(context->pubSub, context, &e) < 0)
|
||||
return FALSE;
|
||||
|
||||
#ifdef WITH_PROGRESS_BAR
|
||||
if (wfc->taskBarList)
|
||||
{
|
||||
|
||||
@@ -927,8 +927,7 @@ static BOOL wf_pub_mouse_event(wfContext* wfc, UINT16 flags, UINT16 x, UINT16 y)
|
||||
eventArgs.flags = flags;
|
||||
eventArgs.x = x;
|
||||
eventArgs.y = y;
|
||||
PubSub_OnMouseEvent(wfc->common.context.pubSub, &wfc->common.context, &eventArgs);
|
||||
return TRUE;
|
||||
return PubSub_OnMouseEvent(wfc->common.context.pubSub, &wfc->common.context, &eventArgs) >= 0;
|
||||
}
|
||||
|
||||
static BOOL wf_scale_mouse_event(wfContext* wfc, UINT16 flags, INT32 x, INT32 y)
|
||||
|
||||
@@ -826,7 +826,10 @@ void xf_toggle_fullscreen(xfContext* xfc)
|
||||
xf_SetWindowFullscreen(xfc, xfc->window, xfc->fullscreen);
|
||||
EventArgsInit(&e, "xfreerdp");
|
||||
e.state = xfc->fullscreen ? FREERDP_WINDOW_STATE_FULLSCREEN : 0;
|
||||
PubSub_OnWindowStateChange(context->pubSub, context, &e);
|
||||
if (PubSub_OnWindowStateChange(context->pubSub, context, &e) < 0)
|
||||
{
|
||||
WLog_Print(xfc->log, WLOG_ERROR, "PubSub_OnWindowStateChange failed");
|
||||
}
|
||||
}
|
||||
|
||||
void xf_minimize(xfContext* xfc)
|
||||
@@ -845,7 +848,10 @@ void xf_minimize(xfContext* xfc)
|
||||
xf_SetWindowMinimized(xfc, xfc->window);
|
||||
|
||||
e.state = xfc->fullscreen ? FREERDP_WINDOW_STATE_FULLSCREEN : 0;
|
||||
PubSub_OnWindowStateChange(context->pubSub, context, &e);
|
||||
if (PubSub_OnWindowStateChange(context->pubSub, context, &e) < 0)
|
||||
{
|
||||
WLog_Print(xfc->log, WLOG_ERROR, "PubSub_OnWindowStateChange failed");
|
||||
}
|
||||
}
|
||||
|
||||
void xf_lock_x11_(xfContext* xfc, WINPR_ATTR_UNUSED const char* fkt)
|
||||
@@ -1471,8 +1477,7 @@ static BOOL xf_post_connect(freerdp* instance)
|
||||
WINPR_ASSERTING_INT_CAST(int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth));
|
||||
e.height =
|
||||
WINPR_ASSERTING_INT_CAST(int, freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight));
|
||||
PubSub_OnResizeWindow(context->pubSub, xfc, &e);
|
||||
return TRUE;
|
||||
return PubSub_OnResizeWindow(context->pubSub, xfc, &e) >= 0;
|
||||
}
|
||||
|
||||
static void xf_post_disconnect(freerdp* instance)
|
||||
|
||||
@@ -1369,7 +1369,10 @@ BOOL xf_event_process(freerdp* instance, const XEvent* event)
|
||||
|
||||
xf_cliprdr_handle_xevent(xfc, event);
|
||||
if (!xf_floatbar_check_event(floatbar, event) && !xf_floatbar_is_locked(floatbar))
|
||||
xf_input_handle_event(xfc, event);
|
||||
{
|
||||
if (xf_input_handle_event(xfc, event) < 0)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LogDynAndXSync(xfc->log, xfc->display, FALSE);
|
||||
return status;
|
||||
|
||||
@@ -321,7 +321,8 @@ static void xf_input_save_last_event(xfContext* xfc, const XGenericEventCookie*
|
||||
xfc->lastEvent.event_y = event->event_y;
|
||||
}
|
||||
|
||||
static void xf_input_detect_pan(xfContext* xfc)
|
||||
WINPR_ATTR_NODISCARD
|
||||
static BOOL xf_input_detect_pan(xfContext* xfc)
|
||||
{
|
||||
WINPR_ASSERT(xfc);
|
||||
rdpContext* ctx = &xfc->common.context;
|
||||
@@ -329,7 +330,7 @@ static void xf_input_detect_pan(xfContext* xfc)
|
||||
|
||||
if (xfc->active_contacts != 2)
|
||||
{
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const double dx[] = { xfc->contacts[0].pos_x - xfc->contacts[0].last_x,
|
||||
@@ -352,7 +353,8 @@ static void xf_input_detect_pan(xfContext* xfc)
|
||||
EventArgsInit(&e, "xfreerdp");
|
||||
e.dx = 5;
|
||||
e.dy = 0;
|
||||
PubSub_OnPanningChange(ctx->pubSub, xfc, &e);
|
||||
if (PubSub_OnPanningChange(ctx->pubSub, xfc, &e) < 0)
|
||||
return FALSE;
|
||||
}
|
||||
xfc->px_vector = 0;
|
||||
xfc->py_vector = 0;
|
||||
@@ -365,7 +367,8 @@ static void xf_input_detect_pan(xfContext* xfc)
|
||||
EventArgsInit(&e, "xfreerdp");
|
||||
e.dx = -5;
|
||||
e.dy = 0;
|
||||
PubSub_OnPanningChange(ctx->pubSub, xfc, &e);
|
||||
if (PubSub_OnPanningChange(ctx->pubSub, xfc, &e) < 0)
|
||||
return FALSE;
|
||||
}
|
||||
xfc->px_vector = 0;
|
||||
xfc->py_vector = 0;
|
||||
@@ -382,7 +385,8 @@ static void xf_input_detect_pan(xfContext* xfc)
|
||||
EventArgsInit(&e, "xfreerdp");
|
||||
e.dx = 0;
|
||||
e.dy = 5;
|
||||
PubSub_OnPanningChange(ctx->pubSub, xfc, &e);
|
||||
if (PubSub_OnPanningChange(ctx->pubSub, xfc, &e) < 0)
|
||||
return FALSE;
|
||||
}
|
||||
xfc->py_vector = 0;
|
||||
xfc->px_vector = 0;
|
||||
@@ -395,16 +399,19 @@ static void xf_input_detect_pan(xfContext* xfc)
|
||||
EventArgsInit(&e, "xfreerdp");
|
||||
e.dx = 0;
|
||||
e.dy = -5;
|
||||
PubSub_OnPanningChange(ctx->pubSub, xfc, &e);
|
||||
if (PubSub_OnPanningChange(ctx->pubSub, xfc, &e) < 0)
|
||||
return FALSE;
|
||||
}
|
||||
xfc->py_vector = 0;
|
||||
xfc->px_vector = 0;
|
||||
xfc->z_vector = 0;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void xf_input_detect_pinch(xfContext* xfc)
|
||||
WINPR_ATTR_NODISCARD
|
||||
static BOOL xf_input_detect_pinch(xfContext* xfc)
|
||||
{
|
||||
ZoomingChangeEventArgs e = WINPR_C_ARRAY_INIT;
|
||||
|
||||
@@ -415,7 +422,7 @@ static void xf_input_detect_pinch(xfContext* xfc)
|
||||
if (xfc->active_contacts != 2)
|
||||
{
|
||||
xfc->firstDist = -1.0;
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* first calculate the distance */
|
||||
@@ -449,7 +456,8 @@ static void xf_input_detect_pinch(xfContext* xfc)
|
||||
{
|
||||
EventArgsInit(&e, "xfreerdp");
|
||||
e.dx = e.dy = -10;
|
||||
PubSub_OnZoomingChange(ctx->pubSub, xfc, &e);
|
||||
if (PubSub_OnZoomingChange(ctx->pubSub, xfc, &e) < 0)
|
||||
return FALSE;
|
||||
xfc->z_vector = 0;
|
||||
xfc->px_vector = 0;
|
||||
xfc->py_vector = 0;
|
||||
@@ -459,12 +467,14 @@ static void xf_input_detect_pinch(xfContext* xfc)
|
||||
{
|
||||
EventArgsInit(&e, "xfreerdp");
|
||||
e.dx = e.dy = 10;
|
||||
PubSub_OnZoomingChange(ctx->pubSub, xfc, &e);
|
||||
if (PubSub_OnZoomingChange(ctx->pubSub, xfc, &e) < 0)
|
||||
return FALSE;
|
||||
xfc->z_vector = 0;
|
||||
xfc->px_vector = 0;
|
||||
xfc->py_vector = 0;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void xf_input_touch_begin(xfContext* xfc, const XIDeviceEvent* event)
|
||||
@@ -484,7 +494,8 @@ static void xf_input_touch_begin(xfContext* xfc, const XIDeviceEvent* event)
|
||||
}
|
||||
}
|
||||
|
||||
static void xf_input_touch_update(xfContext* xfc, const XIDeviceEvent* event)
|
||||
WINPR_ATTR_NODISCARD
|
||||
static BOOL xf_input_touch_update(xfContext* xfc, const XIDeviceEvent* event)
|
||||
{
|
||||
WINPR_ASSERT(xfc);
|
||||
WINPR_ASSERT(event);
|
||||
@@ -498,11 +509,15 @@ static void xf_input_touch_update(xfContext* xfc, const XIDeviceEvent* event)
|
||||
xfc->contacts[i].last_y = xfc->contacts[i].pos_y;
|
||||
xfc->contacts[i].pos_x = event->event_x;
|
||||
xfc->contacts[i].pos_y = event->event_y;
|
||||
xf_input_detect_pinch(xfc);
|
||||
xf_input_detect_pan(xfc);
|
||||
if (!xf_input_detect_pinch(xfc))
|
||||
return FALSE;
|
||||
if (!xf_input_detect_pan(xfc))
|
||||
return FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void xf_input_touch_end(xfContext* xfc, const XIDeviceEvent* event)
|
||||
@@ -543,7 +558,10 @@ static int xf_input_handle_event_local(xfContext* xfc, const XEvent* event)
|
||||
|
||||
case XI_TouchUpdate:
|
||||
if (xf_input_is_duplicate(xfc, cookie.cc) == FALSE)
|
||||
xf_input_touch_update(xfc, cookie.cc->data);
|
||||
{
|
||||
if (!xf_input_touch_update(xfc, cookie.cc->data))
|
||||
return -1;
|
||||
}
|
||||
|
||||
xf_input_save_last_event(xfc, cookie.cc);
|
||||
break;
|
||||
|
||||
@@ -27,8 +27,13 @@
|
||||
#include <X11/extensions/XInput2.h>
|
||||
#endif
|
||||
|
||||
WINPR_ATTR_NODISCARD
|
||||
int xf_input_init(xfContext* xfc, Window window);
|
||||
|
||||
WINPR_ATTR_NODISCARD
|
||||
int xf_input_handle_event(xfContext* xfc, const XEvent* event);
|
||||
|
||||
WINPR_ATTR_NODISCARD
|
||||
bool xf_use_rel_mouse(xfContext* xfc);
|
||||
|
||||
#endif /* FREERDP_CLIENT_X11_INPUT_H */
|
||||
|
||||
@@ -1466,7 +1466,8 @@ BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym)
|
||||
EventArgsInit(&e, "xfreerdp");
|
||||
e.dx = pdx;
|
||||
e.dy = pdy;
|
||||
PubSub_OnPanningChange(ctx->pubSub, xfc, &e);
|
||||
if (PubSub_OnPanningChange(ctx->pubSub, xfc, &e)<0)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1476,7 +1477,8 @@ BOOL xf_keyboard_handle_special_keys(xfContext* xfc, KeySym keysym)
|
||||
EventArgsInit(&e, "xfreerdp");
|
||||
e.dx = zdx;
|
||||
e.dy = zdy;
|
||||
PubSub_OnZoomingChange(ctx->pubSub, xfc, &e);
|
||||
if (PubSub_OnZoomingChange(ctx->pubSub, xfc, &e)<0)
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user