mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 14:21:57 +00:00
[client] added -Q feature to prevent accidental applicaiton closure
Closes #21
This commit is contained in:
parent
e6c6c16d56
commit
71c7f30265
1 changed files with 26 additions and 3 deletions
|
@ -18,6 +18,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
#include <signal.h>
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <SDL2/SDL_syswm.h>
|
#include <SDL2/SDL_syswm.h>
|
||||||
#include <SDL2/SDL_ttf.h>
|
#include <SDL2/SDL_ttf.h>
|
||||||
|
@ -81,6 +82,7 @@ struct AppParams
|
||||||
unsigned int spicePort;
|
unsigned int spicePort;
|
||||||
bool scaleMouseInput;
|
bool scaleMouseInput;
|
||||||
bool hideMouse;
|
bool hideMouse;
|
||||||
|
bool ignoreQuit;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AppState state;
|
struct AppState state;
|
||||||
|
@ -104,7 +106,8 @@ struct AppParams params =
|
||||||
.spiceHost = "127.0.0.1",
|
.spiceHost = "127.0.0.1",
|
||||||
.spicePort = 5900,
|
.spicePort = 5900,
|
||||||
.scaleMouseInput = true,
|
.scaleMouseInput = true,
|
||||||
.hideMouse = true
|
.hideMouse = true,
|
||||||
|
.ignoreQuit = false
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void updatePositionInfo()
|
inline void updatePositionInfo()
|
||||||
|
@ -469,6 +472,7 @@ int eventThread(void * arg)
|
||||||
switch(event.type)
|
switch(event.type)
|
||||||
{
|
{
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
|
if (!params.ignoreQuit)
|
||||||
state.running = false;
|
state.running = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -643,6 +647,16 @@ int eventThread(void * arg)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void intHandler(int signal)
|
||||||
|
{
|
||||||
|
switch(signal)
|
||||||
|
{
|
||||||
|
case SIGINT:
|
||||||
|
state.running = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int run()
|
int run()
|
||||||
{
|
{
|
||||||
DEBUG_INFO("Looking Glass (" BUILD_VERSION ")");
|
DEBUG_INFO("Looking Glass (" BUILD_VERSION ")");
|
||||||
|
@ -658,6 +672,10 @@ int run()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// override SDL's SIGINIT handler so that we can tell the difference between
|
||||||
|
// SIGINT and the user sending a close event, such as ALT+F4
|
||||||
|
signal(SIGINT, intHandler);
|
||||||
|
|
||||||
if (params.showFPS)
|
if (params.showFPS)
|
||||||
{
|
{
|
||||||
if (TTF_Init() < 0)
|
if (TTF_Init() < 0)
|
||||||
|
@ -928,6 +946,7 @@ void doHelp(char * app)
|
||||||
" -y YPOS Initial window Y position [current: %s]\n"
|
" -y YPOS Initial window Y position [current: %s]\n"
|
||||||
" -w WIDTH Initial window width [current: %u]\n"
|
" -w WIDTH Initial window width [current: %u]\n"
|
||||||
" -b HEIGHT Initial window height [current: %u]\n"
|
" -b HEIGHT Initial window height [current: %u]\n"
|
||||||
|
" -Q Ignore requests to quit (ie: Alt+F4)\n"
|
||||||
"\n"
|
"\n"
|
||||||
" -l License information\n"
|
" -l License information\n"
|
||||||
"\n",
|
"\n",
|
||||||
|
@ -970,7 +989,7 @@ void doLicense()
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
while((c = getopt(argc, argv, "hf:sc:p:jMmvkanrdFx:y:w:b:l")) != -1)
|
while((c = getopt(argc, argv, "hf:sc:p:jMmvkanrdFx:y:w:b:Ql")) != -1)
|
||||||
switch(c)
|
switch(c)
|
||||||
{
|
{
|
||||||
case '?':
|
case '?':
|
||||||
|
@ -1053,6 +1072,10 @@ int main(int argc, char * argv[])
|
||||||
params.h = atoi(optarg);
|
params.h = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'Q':
|
||||||
|
params.ignoreQuit = true;
|
||||||
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
doLicense();
|
doLicense();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in a new issue