mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 13:37:22 +00:00
[client] added -Q feature to prevent accidental applicaiton closure
Closes #21
This commit is contained in:
parent
e6c6c16d56
commit
71c7f30265
@ -18,6 +18,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_syswm.h>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
@ -81,6 +82,7 @@ struct AppParams
|
||||
unsigned int spicePort;
|
||||
bool scaleMouseInput;
|
||||
bool hideMouse;
|
||||
bool ignoreQuit;
|
||||
};
|
||||
|
||||
struct AppState state;
|
||||
@ -104,7 +106,8 @@ struct AppParams params =
|
||||
.spiceHost = "127.0.0.1",
|
||||
.spicePort = 5900,
|
||||
.scaleMouseInput = true,
|
||||
.hideMouse = true
|
||||
.hideMouse = true,
|
||||
.ignoreQuit = false
|
||||
};
|
||||
|
||||
inline void updatePositionInfo()
|
||||
@ -469,7 +472,8 @@ int eventThread(void * arg)
|
||||
switch(event.type)
|
||||
{
|
||||
case SDL_QUIT:
|
||||
state.running = false;
|
||||
if (!params.ignoreQuit)
|
||||
state.running = false;
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT:
|
||||
@ -643,6 +647,16 @@ int eventThread(void * arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void intHandler(int signal)
|
||||
{
|
||||
switch(signal)
|
||||
{
|
||||
case SIGINT:
|
||||
state.running = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int run()
|
||||
{
|
||||
DEBUG_INFO("Looking Glass (" BUILD_VERSION ")");
|
||||
@ -658,6 +672,10 @@ int run()
|
||||
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 (TTF_Init() < 0)
|
||||
@ -928,6 +946,7 @@ void doHelp(char * app)
|
||||
" -y YPOS Initial window Y position [current: %s]\n"
|
||||
" -w WIDTH Initial window width [current: %u]\n"
|
||||
" -b HEIGHT Initial window height [current: %u]\n"
|
||||
" -Q Ignore requests to quit (ie: Alt+F4)\n"
|
||||
"\n"
|
||||
" -l License information\n"
|
||||
"\n",
|
||||
@ -970,7 +989,7 @@ void doLicense()
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
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)
|
||||
{
|
||||
case '?':
|
||||
@ -1053,6 +1072,10 @@ int main(int argc, char * argv[])
|
||||
params.h = atoi(optarg);
|
||||
break;
|
||||
|
||||
case 'Q':
|
||||
params.ignoreQuit = true;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
doLicense();
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user