[PATCH] GrabInput

Hi,

file: SDL_sysevents.c
function: WinMessage

case WM_ACTIVATE: {
SDL_VideoDevice this = current_video;
BOOL minimized;
Uint8 appstate;
minimized = HIWORD(wParam);
if ( !minimized && (LOWORD(wParam) != WA_INACTIVE) ) {
/
Gain the following states */
appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS;
if ( this->input_grab != SDL_GRAB_OFF ) {

The last line must be:

               if ( this->input_grab != SDL_GRAB_ON ) {

otherwise we never call WIN_GrabInput(this, SDL_GRAB_ON)–
Best regards,
Dmitry Yakimov, ISDEF member
ActiveKitten.com

Hi,

file: SDL_sysevents.c
function: WinMessage

case WM_ACTIVATE: {
SDL_VideoDevice this = current_video;
BOOL minimized;
Uint8 appstate;
minimized = HIWORD(wParam);
if ( !minimized && (LOWORD(wParam) != WA_INACTIVE) ) {
/
Gain the following states */
appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS;
if ( this->input_grab != SDL_GRAB_OFF ) {

The last line must be:

               if ( this->input_grab != SDL_GRAB_ON ) {

otherwise we never call WIN_GrabInput(this, SDL_GRAB_ON)

Must be? No.

The fragment (this->input_grab != SDL_GRAB_OFF) is a synomym for:
‘Is grabbing requested by the application?’. It is used because there
are multiple values that mean grab requested, but only one value, 0,
that means grabbing is not requested.

In case WM_ACTIVATE:, there are two code paths that either switch
grabbing on or switch grabbing off (if grabbing is requested) depending
on whether the application window is minimized/maximized,
active/inactive, etc.

There might be a bug in the input grabbing behaviour, but that isn’t it,

cheers,
John Popplewell.On Wed, Dec 15, 2004 at 10:39:57PM +0300, Dmitry Yakimov wrote:


Best regards,
Dmitry Yakimov, ISDEF member
ActiveKitten.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi,

Thursday, December 16, 2004, 11:00:17 PM, you wrote:

Hi,

file: SDL_sysevents.c
function: WinMessage

case WM_ACTIVATE: {
SDL_VideoDevice this = current_video;
BOOL minimized;
Uint8 appstate;
minimized = HIWORD(wParam);
if ( !minimized && (LOWORD(wParam) != WA_INACTIVE) ) {
/
Gain the following states */
appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS;
if ( this->input_grab != SDL_GRAB_OFF ) {

The last line must be:

               if ( this->input_grab != SDL_GRAB_ON ) {

otherwise we never call WIN_GrabInput(this, SDL_GRAB_ON)

Must be? No.

Why do you know this?
I checked it in the debugger.

The fragment (this->>input_grab != SDL_GRAB_OFF) is a synomym for:
‘Is grabbing requested by the application?’.

No, it is a synonym for
’when activate application please grab input for me if it was not
grabbed before by user’

Grabbing is always requested by application that is why we have got
flags SDL_INIT_AUDIO and SDL_INIT_VIDEO and do not have flag
like SDL_INIT_INPUT.

I write SDL backend for PocketPC & WinCE and in GrabInput we are to
grab input because video system does not do it for us (like in
Windows). But pity, this function is never called by SDL.> On Wed, Dec 15, 2004 at 10:39:57PM +0300, Dmitry Yakimov wrote:

cheers,
John Popplewell.


Best regards,
Dmitry Yakimov, ISDEF member
ActiveKitten.com

Hi,

Thursday, December 16, 2004, 11:00:17 PM, you wrote:

Hi,

file: SDL_sysevents.c
function: WinMessage

case WM_ACTIVATE: {
SDL_VideoDevice this = current_video;
BOOL minimized;
Uint8 appstate;
minimized = HIWORD(wParam);
if ( !minimized && (LOWORD(wParam) != WA_INACTIVE) ) {
/
Gain the following states */
appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS;
if ( this->input_grab != SDL_GRAB_OFF ) {

The last line must be:

               if ( this->input_grab != SDL_GRAB_ON ) {

otherwise we never call WIN_GrabInput(this, SDL_GRAB_ON)

Must be? No.

Why do you know this?
I checked it in the debugger.
And you (presumably) discovered that the application wasn’t requesting
grabbing…

The fragment (this->>input_grab != SDL_GRAB_OFF) is a synomym for:
‘Is grabbing requested by the application?’.

No, it is a synonym for ‘when activate application please grab input
for me if it was not grabbed before by user’

Ah, I see. Have a look at this:
http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fWM_5fGrabInput

I quote:
“Grabbing means that the mouse is confined to the application window, and
nearly all keyboard input is passed directly to the application, and not
interpreted by a window manager, if any.”

The code you have highlighted allows the mouse out of a windowed
application when grabbing is on but the window is minimized, and then
captures the mouse again when the window is restored.

Grabbing is always requested by application that is why we have got
flags SDL_INIT_AUDIO and SDL_INIT_VIDEO and do not have flag like
SDL_INIT_INPUT.

I think you are confusing ‘grabbing’ with something else here.

I write SDL backend for PocketPC & WinCE and in GrabInput we are to
grab input because video system does not do it for us (like in
Windows). But pity, this function is never called by SDL.

It is called by SDL when the application enables grabbing by calling
SDL_WM_GrabInput(SDL_GRAB_ON).

I know nothing of the PocketPC & WinCE so I can’t be of any real use to
you, sorry. I’m only familiar with the windib/directx back-ends, but
found inspecting the others for comparison useful in understanding them.

Good luck with it,

best regards,
John.On Thu, Dec 16, 2004 at 11:40:37PM +0300, Dmitry Yakimov wrote:

On Wed, Dec 15, 2004 at 10:39:57PM +0300, Dmitry Yakimov wrote:

cheers, John Popplewell.

– Best regards, Dmitry Yakimov, ISDEF member ActiveKitten.com

_______________________________________________ SDL mailing list
SDL at libsdl.org http://www.libsdl.org/mailman/listinfo/sdl

Hi,

Thursday, December 16, 2004, 11:00:17 PM, you wrote:

Hi,

file: SDL_sysevents.c
function: WinMessage

case WM_ACTIVATE: {
SDL_VideoDevice this = current_video;
BOOL minimized;
Uint8 appstate;
minimized = HIWORD(wParam);
if ( !minimized && (LOWORD(wParam) != WA_INACTIVE) ) {
/
Gain the following states */
appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS;
if ( this->input_grab != SDL_GRAB_OFF ) {

The last line must be:

               if ( this->input_grab != SDL_GRAB_ON ) {

otherwise we never call WIN_GrabInput(this, SDL_GRAB_ON)

Must be? No.

Why do you know this?
I checked it in the debugger.
And you (presumably) discovered that the application wasn’t requesting
grabbing…

The fragment (this->>input_grab != SDL_GRAB_OFF) is a synomym for:
‘Is grabbing requested by the application?’.

No, it is a synonym for ‘when activate application please grab input
for me if it was not grabbed before by user’

Ah, I see. Have a look at this:
http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fWM_5fGrabInput

I quote:
“Grabbing means that the mouse is confined to the application window, and
nearly all keyboard input is passed directly to the application, and not
interpreted by a window manager, if any.”

The code you have highlighted allows the mouse out of a windowed
application when grabbing is on but the window is minimized, and then
captures the mouse again when the window is restored.

Grabbing is always requested by application that is why we have got
flags SDL_INIT_AUDIO and SDL_INIT_VIDEO and do not have flag like
SDL_INIT_INPUT.

I think you are confusing ‘grabbing’ with something else here.

I write SDL backend for PocketPC & WinCE and in GrabInput we are to
grab input because video system does not do it for us (like in
Windows). But pity, this function is never called by SDL.

It is called by SDL when the application enables grabbing by calling
SDL_WM_GrabInput(SDL_GRAB_ON).

Sorry, forgot to mention. Have a look at the ‘testwm’ example code
supplied with SDL. CTRL-G toggles grabbing and shows that it is
working fine, although I’ve not tested with the latest release :slight_smile:

cheers,
John.On Fri, Dec 17, 2004 at 12:13:12AM +0000, John Popplewell wrote:

On Thu, Dec 16, 2004 at 11:40:37PM +0300, Dmitry Yakimov wrote:

On Wed, Dec 15, 2004 at 10:39:57PM +0300, Dmitry Yakimov wrote:

I know nothing of the PocketPC & WinCE so I can’t be of any real use to
you, sorry. I’m only familiar with the windib/directx back-ends, but
found inspecting the others for comparison useful in understanding them.

Good luck with it,

best regards,
John.

cheers, John Popplewell.

– Best regards, Dmitry Yakimov, ISDEF member ActiveKitten.com

_______________________________________________ SDL mailing list
SDL at libsdl.org http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl