fixed window focusing stuff, much better now.

This commit is contained in:
Johan Althoff 2007-08-07 18:28:51 +00:00
parent f38f0f49d5
commit 0c7e1fc6ab
3 changed files with 38 additions and 6 deletions

View file

@ -38,6 +38,7 @@ static net_client net;
static netaddr4 master_server;
static netaddr4 server_address;
static const char *server_spam_address=0;
static int window_must_refocus = 0;
// --- input wrappers ---
static int keyboard_state[2][input::last];
@ -872,11 +873,30 @@ static void client_run(const char *direct_connect_server)
// update input
inp_update();
//
if(input::pressed(input::f1))
input::set_mouse_mode(input::mode_absolute);
if(input::pressed(input::f2))
input::set_mouse_mode(input::mode_relative);
// refocus
if(!gfx_window_active())
{
if(window_must_refocus == 0)
{
input::set_mouse_mode(input::mode_absolute);
}
window_must_refocus = 1;
}
if(window_must_refocus && gfx_window_active())
{
if(window_must_refocus < 3)
{
input::set_mouse_mode(input::mode_absolute);
window_must_refocus++;
}
if(inp_button_pressed(input::mouse_1))
{
input::set_mouse_mode(input::mode_relative);
window_must_refocus = 0;
}
}
// screenshot button
if(inp_key_down(input::f10))
@ -885,6 +905,11 @@ static void client_run(const char *direct_connect_server)
// panic button
if(config.debug)
{
if(input::pressed(input::f1))
input::set_mouse_mode(input::mode_absolute);
if(input::pressed(input::f2))
input::set_mouse_mode(input::mode_relative);
if(input::pressed(input::lctrl) && input::pressed('Q'))
break;
@ -915,7 +940,7 @@ static void client_run(const char *direct_connect_server)
break;
// be nice
if(config.cpu_throttle)
if(config.cpu_throttle || !gfx_window_active())
thread_sleep(1);
if(reporttime < time_get())

View file

@ -213,6 +213,11 @@ bool gfx_init()
}
int gfx_window_active()
{
return context.active()?1:0;
}
video_mode fakemodes[] = {
{320,240,8,8,8}, {400,300,8,8,8}, {640,480,8,8,8},

View file

@ -71,6 +71,8 @@ void gfx_swap(); // NOT EXPOSED
int gfx_get_video_modes(video_mode *list, int maxcount);
void gfx_set_vsync(int val);
int gfx_window_active();
// textures
/*
Function: gfx_load_texture