mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-10 00:28:20 +00:00
parent
899dbff7e9
commit
2196516e2b
@ -151,6 +151,13 @@ static struct Option options[] =
|
||||
.type = OPTION_TYPE_BOOL,
|
||||
.value.x_bool = true,
|
||||
},
|
||||
{
|
||||
.module = "win",
|
||||
.name = "forceAspect",
|
||||
.description = "Force the window to maintain the aspect ratio",
|
||||
.type = OPTION_TYPE_BOOL,
|
||||
.value.x_bool = true,
|
||||
},
|
||||
{
|
||||
.module = "win",
|
||||
.name = "borderless",
|
||||
@ -389,6 +396,7 @@ bool config_load(int argc, char * argv[])
|
||||
params.autoResize = option_get_bool ("win", "autoResize" );
|
||||
params.allowResize = option_get_bool ("win", "allowResize" );
|
||||
params.keepAspect = option_get_bool ("win", "keepAspect" );
|
||||
params.forceAspect = option_get_bool ("win", "forceAspect" );
|
||||
params.borderless = option_get_bool ("win", "borderless" );
|
||||
params.fullscreen = option_get_bool ("win", "fullScreen" );
|
||||
params.maximize = option_get_bool ("win", "maximize" );
|
||||
@ -568,4 +576,4 @@ static char * optScancodeToString(struct Option * opt)
|
||||
char * str;
|
||||
alloc_sprintf(&str, "%d = %s", opt->value.x_int, SDL_GetScancodeName(opt->value.x_int));
|
||||
return str;
|
||||
}
|
||||
}
|
@ -42,11 +42,14 @@ Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "common/thread.h"
|
||||
#include "common/event.h"
|
||||
#include "common/ivshmem.h"
|
||||
#include "common/time.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "kb.h"
|
||||
#include "ll.h"
|
||||
|
||||
#define RESIZE_TIMEOUT (10 * 1000) // 10ms
|
||||
|
||||
// forwards
|
||||
static int cursorThread(void * unused);
|
||||
static int renderThread(void * unused);
|
||||
@ -98,6 +101,12 @@ static void updatePositionInfo()
|
||||
|
||||
state.scaleX = (float)state.srcSize.y / (float)state.dstRect.h;
|
||||
state.scaleY = (float)state.srcSize.x / (float)state.dstRect.w;
|
||||
|
||||
if (params.forceAspect)
|
||||
{
|
||||
state.resizeTimeout = getMicrotime() + RESIZE_TIMEOUT;
|
||||
state.resizeDone = false;
|
||||
}
|
||||
}
|
||||
|
||||
state.lgrResize = true;
|
||||
@ -161,6 +170,16 @@ static int renderThread(void * unused)
|
||||
time.tv_nsec = nsec;
|
||||
|
||||
clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &time, NULL);
|
||||
|
||||
if (!state.resizeDone && state.resizeTimeout < getMicrotime())
|
||||
{
|
||||
SDL_SetWindowSize(
|
||||
state.window,
|
||||
state.dstRect.w,
|
||||
state.dstRect.h
|
||||
);
|
||||
state.resizeDone = true;
|
||||
}
|
||||
}
|
||||
|
||||
state.running = false;
|
||||
@ -988,9 +1007,10 @@ static void release_key_binds()
|
||||
static int lg_run()
|
||||
{
|
||||
memset(&state, 0, sizeof(state));
|
||||
state.running = true;
|
||||
state.scaleX = 1.0f;
|
||||
state.scaleY = 1.0f;
|
||||
state.running = true;
|
||||
state.scaleX = 1.0f;
|
||||
state.scaleY = 1.0f;
|
||||
state.resizeDone = true;
|
||||
|
||||
state.mouseSens = params.mouseSens;
|
||||
if (state.mouseSens < -9) state.mouseSens = -9;
|
||||
|
@ -65,6 +65,10 @@ struct AppState
|
||||
uint64_t frameCount;
|
||||
uint64_t renderCount;
|
||||
|
||||
|
||||
uint64_t resizeTimeout;
|
||||
bool resizeDone;
|
||||
|
||||
KeybindHandle kbFS;
|
||||
KeybindHandle kbInput;
|
||||
KeybindHandle kbMouseSensInc;
|
||||
@ -80,6 +84,7 @@ struct AppParams
|
||||
bool autoResize;
|
||||
bool allowResize;
|
||||
bool keepAspect;
|
||||
bool forceAspect;
|
||||
bool borderless;
|
||||
bool fullscreen;
|
||||
bool maximize;
|
||||
|
Loading…
Reference in New Issue
Block a user