2019-03-30 01:26:06 +00:00
|
|
|
/*
|
|
|
|
Looking Glass - KVM FrameRelay (KVMFR) Client
|
|
|
|
Copyright (C) 2017-2019 Geoffrey McRae <geoff@hostfission.com>
|
|
|
|
https://looking-glass.hostfission.com
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it under
|
|
|
|
the terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation; either version 2 of the License, or (at your option) any later
|
|
|
|
version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
|
|
|
Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2020-08-09 05:14:17 +00:00
|
|
|
#include <stdatomic.h>
|
2019-03-30 01:26:06 +00:00
|
|
|
#include <SDL2/SDL.h>
|
|
|
|
|
|
|
|
#include "interface/app.h"
|
|
|
|
#include "dynamic/renderers.h"
|
|
|
|
#include "dynamic/clipboards.h"
|
2020-01-03 04:17:14 +00:00
|
|
|
#include "common/ivshmem.h"
|
2019-03-30 01:26:06 +00:00
|
|
|
|
|
|
|
#include "spice/spice.h"
|
2020-01-09 09:32:42 +00:00
|
|
|
#include <lgmp/client.h>
|
2019-03-30 01:26:06 +00:00
|
|
|
|
2020-08-11 05:14:58 +00:00
|
|
|
enum RunState
|
|
|
|
{
|
|
|
|
APP_STATE_RUNNING,
|
|
|
|
APP_STATE_RESTART,
|
|
|
|
APP_STATE_SHUTDOWN
|
|
|
|
};
|
|
|
|
|
2020-08-20 03:46:18 +00:00
|
|
|
struct CursorInfo
|
|
|
|
{
|
|
|
|
int x , y;
|
|
|
|
int hx, hy;
|
|
|
|
};
|
|
|
|
|
2020-08-20 04:52:24 +00:00
|
|
|
enum WarpState
|
|
|
|
{
|
|
|
|
WARP_STATE_ARMED,
|
|
|
|
WARP_STATE_ON,
|
|
|
|
WARP_STATE_ACTIVE,
|
|
|
|
WARP_STATE_OFF
|
|
|
|
};
|
|
|
|
|
2019-03-30 01:26:06 +00:00
|
|
|
struct AppState
|
|
|
|
{
|
2020-08-11 05:14:58 +00:00
|
|
|
enum RunState state;
|
2020-10-14 08:32:21 +00:00
|
|
|
bool stopVideo;
|
2019-03-30 01:26:06 +00:00
|
|
|
bool ignoreInput;
|
|
|
|
bool escapeActive;
|
|
|
|
SDL_Scancode escapeAction;
|
|
|
|
KeybindHandle bindings[SDL_NUM_SCANCODES];
|
|
|
|
bool keyDown[SDL_NUM_SCANCODES];
|
|
|
|
|
|
|
|
bool haveSrcSize;
|
|
|
|
int windowW, windowH;
|
|
|
|
SDL_Point srcSize;
|
|
|
|
LG_RendererRect dstRect;
|
2020-08-20 03:46:18 +00:00
|
|
|
struct CursorInfo cursor;
|
2019-03-30 01:26:06 +00:00
|
|
|
bool cursorVisible;
|
2020-01-10 18:22:12 +00:00
|
|
|
|
|
|
|
bool serverMode;
|
|
|
|
bool haveCursorPos;
|
2020-01-10 19:03:16 +00:00
|
|
|
bool drawCursor;
|
2020-01-11 01:56:46 +00:00
|
|
|
bool cursorInView;
|
2020-01-10 19:03:16 +00:00
|
|
|
bool updateCursor;
|
2020-01-11 05:03:28 +00:00
|
|
|
bool initialCursorSync;
|
2020-01-10 18:22:12 +00:00
|
|
|
float scaleX, scaleY;
|
|
|
|
float accX, accY;
|
|
|
|
int curLastX;
|
|
|
|
int curLastY;
|
2020-01-10 19:03:16 +00:00
|
|
|
bool haveCurLocal;
|
|
|
|
int curLocalX;
|
|
|
|
int curLocalY;
|
|
|
|
bool haveAligned;
|
2019-03-30 01:26:06 +00:00
|
|
|
|
2020-08-20 04:52:24 +00:00
|
|
|
enum WarpState warpState;
|
|
|
|
int warpFromX, warpFromY;
|
|
|
|
int warpToX , warpToY;
|
|
|
|
|
2019-03-30 01:26:06 +00:00
|
|
|
const LG_Renderer * lgr;
|
|
|
|
void * lgrData;
|
|
|
|
bool lgrResize;
|
|
|
|
|
|
|
|
const LG_Clipboard * lgc;
|
|
|
|
SpiceDataType cbType;
|
|
|
|
struct ll * cbRequestList;
|
|
|
|
|
2020-01-03 05:51:24 +00:00
|
|
|
SDL_SysWMinfo wminfo;
|
2019-03-30 01:26:06 +00:00
|
|
|
SDL_Window * window;
|
2020-01-03 04:17:14 +00:00
|
|
|
|
|
|
|
struct IVSHMEM shm;
|
2020-01-09 09:32:42 +00:00
|
|
|
PLGMPClient lgmp;
|
2020-01-10 00:00:46 +00:00
|
|
|
PLGMPClientQueue frameQueue;
|
|
|
|
PLGMPClientQueue pointerQueue;
|
2019-03-30 01:26:06 +00:00
|
|
|
|
2020-08-09 05:14:17 +00:00
|
|
|
atomic_uint_least64_t frameTime;
|
|
|
|
uint64_t lastFrameTime;
|
|
|
|
uint64_t renderTime;
|
2020-10-29 02:30:15 +00:00
|
|
|
atomic_uint_least64_t frameCount;
|
2020-08-09 05:14:17 +00:00
|
|
|
uint64_t renderCount;
|
2019-03-30 01:26:06 +00:00
|
|
|
|
2020-01-03 04:53:44 +00:00
|
|
|
|
|
|
|
uint64_t resizeTimeout;
|
|
|
|
bool resizeDone;
|
|
|
|
|
2019-03-30 01:26:06 +00:00
|
|
|
KeybindHandle kbFS;
|
2020-10-14 08:32:21 +00:00
|
|
|
KeybindHandle kbVideo;
|
2019-03-30 01:26:06 +00:00
|
|
|
KeybindHandle kbInput;
|
2020-04-22 16:31:30 +00:00
|
|
|
KeybindHandle kbQuit;
|
2019-05-23 19:29:38 +00:00
|
|
|
KeybindHandle kbMouseSensInc;
|
|
|
|
KeybindHandle kbMouseSensDec;
|
2019-05-31 06:39:55 +00:00
|
|
|
KeybindHandle kbCtrlAltFn[12];
|
2019-05-23 19:29:38 +00:00
|
|
|
|
|
|
|
int mouseSens;
|
|
|
|
float sensX, sensY;
|
2019-03-30 01:26:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct AppParams
|
|
|
|
{
|
|
|
|
bool autoResize;
|
|
|
|
bool allowResize;
|
|
|
|
bool keepAspect;
|
2020-01-03 04:53:44 +00:00
|
|
|
bool forceAspect;
|
2020-10-12 12:27:33 +00:00
|
|
|
bool dontUpscale;
|
2019-03-30 01:26:06 +00:00
|
|
|
bool borderless;
|
|
|
|
bool fullscreen;
|
2019-05-26 06:30:24 +00:00
|
|
|
bool maximize;
|
2019-07-01 07:53:12 +00:00
|
|
|
bool minimizeOnFocusLoss;
|
2019-03-30 01:26:06 +00:00
|
|
|
bool center;
|
|
|
|
int x, y;
|
|
|
|
unsigned int w, h;
|
2020-05-22 08:15:17 +00:00
|
|
|
unsigned int fpsMin;
|
2019-03-30 01:26:06 +00:00
|
|
|
bool showFPS;
|
|
|
|
bool useSpiceInput;
|
|
|
|
bool useSpiceClipboard;
|
2019-05-21 05:03:59 +00:00
|
|
|
const char * spiceHost;
|
2019-03-30 01:26:06 +00:00
|
|
|
unsigned int spicePort;
|
|
|
|
bool clipboardToVM;
|
|
|
|
bool clipboardToLocal;
|
|
|
|
bool scaleMouseInput;
|
|
|
|
bool hideMouse;
|
|
|
|
bool ignoreQuit;
|
2019-05-21 05:03:59 +00:00
|
|
|
bool noScreensaver;
|
2019-03-30 01:26:06 +00:00
|
|
|
bool grabKeyboard;
|
|
|
|
SDL_Scancode escapeKey;
|
2019-05-21 05:03:59 +00:00
|
|
|
bool showAlerts;
|
2020-05-21 01:13:42 +00:00
|
|
|
bool captureOnStart;
|
2020-07-19 04:29:29 +00:00
|
|
|
bool quickSplash;
|
2019-03-30 01:26:06 +00:00
|
|
|
|
2019-05-22 02:00:06 +00:00
|
|
|
unsigned int cursorPollInterval;
|
|
|
|
unsigned int framePollInterval;
|
|
|
|
|
2019-03-30 01:26:06 +00:00
|
|
|
bool forceRenderer;
|
|
|
|
unsigned int forceRendererIndex;
|
|
|
|
|
2019-05-21 05:03:59 +00:00
|
|
|
const char * windowTitle;
|
2019-05-23 19:29:38 +00:00
|
|
|
int mouseSens;
|
2020-08-20 05:50:33 +00:00
|
|
|
bool mouseRedraw;
|
2019-03-30 01:26:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CBRequest
|
|
|
|
{
|
|
|
|
SpiceDataType type;
|
|
|
|
LG_ClipboardReplyFn replyFn;
|
|
|
|
void * opaque;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct KeybindHandle
|
|
|
|
{
|
|
|
|
SDL_Scancode key;
|
|
|
|
SuperEventFn callback;
|
|
|
|
void * opaque;
|
|
|
|
};
|
|
|
|
|
|
|
|
// forwards
|
|
|
|
extern struct AppState state;
|
2020-05-22 08:15:17 +00:00
|
|
|
extern struct AppParams params;
|