Clicking on taskbar, SDL application stops (on Win32)

Hi,
I have written a simple console for colinux using SDL.
Now it works well enought to be used.

I have a simple question.
On win32 I run my SDL application (my new SDL console).
When I press mouse button on the taskbar of my application, my
application STOPS until I release the mouse button.
I have verified that this happens also to other SDL applications, for
example qemu under win32.
Under linux I have not this trouble !
Is there a way to avoid this on win32 ?
Thanks,
Paolo

This is a Win32 problem, and impacts any applications using the normal
Windows window frame.

I don’t know if there is a proper fix for it, but one (ugly) way
around it is to make the window borderless and implement your own
title bar and any buttons/icons you want. That is, you’ll have to
render your own window framework, detect grab/drag and move the
window yourself.

It might be possible to work around it by manipulating messages before
handing them over to Windows, but I haven’t tried that. The problem
seems to be that when Windows sees a “mouse down” message that hits
the title bar, it just sits around waiting for further events,
preventing your application’s main loop from running. Basically,
you’d have to hide the “mouse down” messages from the title bar, and
implement window dragging by other means.

Another way around (if Win32 is ok with it; I haven’t touched it
directly in ages), would be to split the window message handling out
into a background thread that Windows is free to abuse without
stalling your application.

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Monday 18 August 2008, Paolo Minazzi wrote:

Hi,
I have written a simple console for colinux using SDL.
Now it works well enought to be used.

I have a simple question.
On win32 I run my SDL application (my new SDL console).
When I press mouse button on the taskbar of my application, my
application STOPS until I release the mouse button.
I have verified that this happens also to other SDL applications,
for example qemu under win32.
Under linux I have not this trouble !
Is there a way to avoid this on win32 ?

Thanks David for the fast replay.
I0m studying the case but I have not found a patch for now.

I don’t know if there is a proper fix for it, but one (ugly) way
around it is to make the window borderless and implement your own
title bar and any buttons/icons you want. That is, you’ll have to
render your own window framework, detect grab/drag and move the
window yourself.

This is a little complicated because we have to write code to move,
enlarge and iconize the windows. And I don’t know how to do it. :=(

It might be possible to work around it by manipulating messages before
handing them over to Windows, but I haven’t tried that. The problem
seems to be that when Windows sees a “mouse down” message that hits
the title bar, it just sits around waiting for further events,
preventing your application’s main loop from running. Basically,
you’d have to hide the “mouse down” messages from the title bar, and
implement window dragging by other means.

Yes, I agree.
Also for me this is the real problem.
I will investigate on it.
More exacly, I will investigate on NOT-CLIENT messages.
In my opinion, this is the way …

If I found something, I will post on the list.

Thanks
Paolo

I know absolutely nothing (well, very little) about Windows but wasn’t the
original question about taskbar and not title bar? Or did I misunderstand
something? Not that clicking either one should stop your application from
responding.

And to further poke about a subject I don’t really know about:) Writing
duplicate code for work that a window manager should handle seems like a
wrong path in every imaginable situation.

Just my .02On Tuesday 19 August 2008, David Olofson wrote:

On Monday 18 August 2008, Paolo Minazzi wrote:

Hi,
I have written a simple console for colinux using SDL.
Now it works well enought to be used.

I have a simple question.
On win32 I run my SDL application (my new SDL console).
When I press mouse button on the taskbar of my application, my
application STOPS until I release the mouse button.
I have verified that this happens also to other SDL applications,
for example qemu under win32.
Under linux I have not this trouble !
Is there a way to avoid this on win32 ?

This is a Win32 problem, and impacts any applications using the normal
Windows window frame.

I don’t know if there is a proper fix for it, but one (ugly) way
around it is to make the window borderless and implement your own
title bar and any buttons/icons you want. That is, you’ll have to
render your own window framework, detect grab/drag and move the
window yourself.

It might be possible to work around it by manipulating messages before
handing them over to Windows, but I haven’t tried that. The problem
seems to be that when Windows sees a “mouse down” message that hits
the title bar, it just sits around waiting for further events,
preventing your application’s main loop from running. Basically,
you’d have to hide the “mouse down” messages from the title bar, and
implement window dragging by other means.

Another way around (if Win32 is ok with it; I haven’t touched it
directly in ages), would be to split the window message handling out
into a background thread that Windows is free to abuse without
stalling your application.

//David Olofson - Programmer, Composer, Open Source Advocate


Aki Koskinen
http://www.akikoskinen.info/

[…]

When I press mouse button on the taskbar of my application, my
application STOPS until I release the mouse button.
[…]
I know absolutely nothing (well, very little) about Windows but
wasn’t the original question about taskbar and not title bar? Or did
I misunderstand something?
[…]

Well, the original poster wrote “the taskbar of my application”. Since
a Windows application doesn’t have a taskbar of it’s own, and since
I’ve run into the “titlebar grab” problem before, I assumed that was
what it was about. :slight_smile:

Not that clicking either one should stop your application from
responding.

Exactly - but it does. (Actually, holding the button down on it,
rather than clicking.)

And to further poke about a subject I don’t really know about:)
Writing duplicate code for work that a window manager should handle
seems like a wrong path in every imaginable situation.

It is definitely wrong, and also ugly and somewhat risky, but as the
bug is there in all Windows versions, including the current ones
(with the possible exception of Vista; haven’t checked), all we can
do is work around it, in cases where it matters.

Of course, we can also ignore the problem, but all that does is have
users blame us for writing crappy applications… Just re-read the
original post to see what I mean: It’s blamed on SDL.

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --'On Tuesday 19 August 2008, Aki Koskinen wrote:

On Tuesday 19 August 2008, David Olofson wrote:

On Monday 18 August 2008, Paolo Minazzi wrote:

Hi,
Hi have seen the SDL code.

FILE = src/video/wincommon/SDL_sysevents.c
FUNCTION = WinMessage

The problem is that if we receive a NOT-CLIENT message we call
DefWindowProc (at the end of the WinMessage function).
In this case the DefWindowProc is blocking.

A solution could be manage directly these events.
Moving the window is not too difficult (I think … and hope …)
but we have to manage the small buttons on the right and the button on
the left.

I have tried to call the DefWindowProc (in response to NOT_CLIENT
messages) using a thread (to execute it in background) but it does not
work because (I think) the next calls to DefWindowProc are blocked.

It is not easy solve in a good way this problem.

Thanks for replays.

PaoloOn Tue, Aug 19, 2008 at 7:28 PM, David Olofson wrote:

On Tuesday 19 August 2008, Aki Koskinen wrote:

On Tuesday 19 August 2008, David Olofson wrote:

On Monday 18 August 2008, Paolo Minazzi wrote:
[…]

When I press mouse button on the taskbar of my application, my
application STOPS until I release the mouse button.
[…]
I know absolutely nothing (well, very little) about Windows but
wasn’t the original question about taskbar and not title bar? Or did
I misunderstand something?
[…]

Well, the original poster wrote “the taskbar of my application”. Since
a Windows application doesn’t have a taskbar of it’s own, and since
I’ve run into the “titlebar grab” problem before, I assumed that was
what it was about. :slight_smile:

Not that clicking either one should stop your application from
responding.

Exactly - but it does. (Actually, holding the button down on it,
rather than clicking.)

And to further poke about a subject I don’t really know about:)
Writing duplicate code for work that a window manager should handle
seems like a wrong path in every imaginable situation.

It is definitely wrong, and also ugly and somewhat risky, but as the
bug is there in all Windows versions, including the current ones
(with the possible exception of Vista; haven’t checked), all we can
do is work around it, in cases where it matters.

Of course, we can also ignore the problem, but all that does is have
users blame us for writing crappy applications… Just re-read the
original post to see what I mean: It’s blamed on SDL.

//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
’-- http://www.reologica.se - Rheology instrumentation --’


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

David Olofson wrote:On Tuesday 19 August 2008, Aki Koskinen wrote:

On Tuesday 19 August 2008, David Olofson wrote:

On Monday 18 August 2008, Paolo Minazzi wrote:

[…]

When I press mouse button on the taskbar of my application, my
application STOPS until I release the mouse button.

[…]

I know absolutely nothing (well, very little) about Windows but
wasn’t the original question about taskbar and not title bar? Or did
I misunderstand something?

Yes, excuse me
I was saying about titlebar, not taskbar !
I have studied the problem, and I think the more clean solution is to
write the drawing code in a different thread, exacly,

  • in the main()there is the event loop code
  • in a different thread the drawing code

I solved in this way.

Thanks for your time.

Regards
Paolo Minazzi

There was a discussion some days ago why you cannot (should not) do the
drawing in a different thread than the main thread.

So better move the event loop out of the main thread instead of the
drawing code.On Wed, 2008-08-27 at 14:32 +0200, Paolo Minazzi wrote:

Yes, excuse me
I was saying about titlebar, not taskbar !
I have studied the problem, and I think the more clean solution is to
write the drawing code in a different thread, exacly,

  • in the main()there is the event loop code
  • in a different thread the drawing code

I solved in this way.

Thanks for your time.

Regards
Paolo Minazzi

From what I’ve understood on win32 you cannot poll events outside the main thread.

Yes, excuse me
I was saying about titlebar, not taskbar !
I have studied the problem, and I think the more clean solution is to
write the drawing code in a different thread, exacly,

  • in the main()there is the event loop code
  • in a different thread the drawing code

I solved in this way.

Thanks for your time.

Regards
Paolo Minazzi

There was a discussion some days ago why you cannot (should not) do the
drawing in a different thread than the main thread.

So better move the event loop out of the main thread instead of the
drawing code.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org> Date: Wed, 27 Aug 2008 14:47:10 +0200
From: albert.zeyer at rwth-aachen.de
To: sdl at lists.libsdl.org
Subject: Re: [SDL] Clicking on taskbar, SDL application stops (on Win32)
On Wed, 2008-08-27 at 14:32 +0200, Paolo Minazzi wrote:


Invite your mail contacts to join your friends list with Windows Live Spaces. It’s easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us

Eliott Coyac wrote:

From what I’ve understood on win32 you cannot poll events outside the
main thread.

I wanted to post the same thing, but I decide to wait to verify an other
time it.
I agree with you.
On Win32 events must be checked in the main loop.
If you do it in a thread, the application don’t work. I don’t understand
why, but it is so !
Bye,
Paolo