[client] app: add and expose new app_handleButtonPress/Release methods

This commit is contained in:
Geoffrey McRae 2021-01-17 14:23:51 +11:00
parent 570abeda52
commit e106f2096b
2 changed files with 22 additions and 16 deletions

View File

@ -35,6 +35,8 @@ void app_handleResizeEvent(int w, int h);
void app_handleMouseGrabbed(double ex, double ey); void app_handleMouseGrabbed(double ex, double ey);
void app_handleMouseNormal(double ex, double ey); void app_handleMouseNormal(double ex, double ey);
void app_handleMouseBasic(void); void app_handleMouseBasic(void);
void app_handleButtonPress(int button);
void app_handleButtonRelease(int button);
void app_handleWindowEnter(void); void app_handleWindowEnter(void);
void app_handleWindowLeave(void); void app_handleWindowLeave(void);
void app_handleFocusEvent(bool focused); void app_handleFocusEvent(bool focused);

View File

@ -1015,6 +1015,24 @@ void app_handleMouseGrabbed(double ex, double ey)
DEBUG_ERROR("failed to send mouse motion message"); DEBUG_ERROR("failed to send mouse motion message");
} }
void app_handleButtonPress(int button)
{
if (!app_inputEnabled() || !g_cursor.inView)
return;
if (!spice_mouse_press(button))
DEBUG_ERROR("SDL_MOUSEBUTTONDOWN: failed to send message");
}
void app_handleButtonRelease(int button)
{
if (!app_inputEnabled())
return;
if (!spice_mouse_release(button))
DEBUG_ERROR("SDL_MOUSEBUTTONUP: failed to send message");
}
static void guestCurToLocal(struct DoublePoint *local) static void guestCurToLocal(struct DoublePoint *local)
{ {
local->x = g_state.dstRect.x + local->x = g_state.dstRect.x +
@ -1444,35 +1462,21 @@ int eventFilter(void * userdata, SDL_Event * event)
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
{ {
if (!app_inputEnabled() || !g_cursor.inView)
break;
int button = event->button.button; int button = event->button.button;
if (button > 3) if (button > 3)
button += 2; button += 2;
if (!spice_mouse_press(button)) app_handleButtonPress(button);
{
DEBUG_ERROR("SDL_MOUSEBUTTONDOWN: failed to send message");
break;
}
break; break;
} }
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
{ {
if (!app_inputEnabled())
break;
int button = event->button.button; int button = event->button.button;
if (button > 3) if (button > 3)
button += 2; button += 2;
if (!spice_mouse_release(button)) app_handleButtonRelease(button);
{
DEBUG_ERROR("SDL_MOUSEBUTTONUP: failed to send message");
break;
}
break; break;
} }
} }