diff options
| author | Johan Althoff <teetow@gmail.com> | 2007-08-07 18:28:51 +0000 |
|---|---|---|
| committer | Johan Althoff <teetow@gmail.com> | 2007-08-07 18:28:51 +0000 |
| commit | 0c7e1fc6abef36bf41504fcae730b361d515c606 (patch) | |
| tree | 0fffb8bdf3af6bc301dce339dc07e65d98590dff /src/engine/client | |
| parent | f38f0f49d54f124ed385c609789bf834bbfde6cb (diff) | |
| download | zcatch-0c7e1fc6abef36bf41504fcae730b361d515c606.tar.gz zcatch-0c7e1fc6abef36bf41504fcae730b361d515c606.zip | |
fixed window focusing stuff, much better now.
Diffstat (limited to 'src/engine/client')
| -rw-r--r-- | src/engine/client/client.cpp | 37 | ||||
| -rw-r--r-- | src/engine/client/gfx.cpp | 5 |
2 files changed, 36 insertions, 6 deletions
diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 730aac6c..dc0a02d0 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -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()) diff --git a/src/engine/client/gfx.cpp b/src/engine/client/gfx.cpp index 1e11bb04..1c871e28 100644 --- a/src/engine/client/gfx.cpp +++ b/src/engine/client/gfx.cpp @@ -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}, |