David Olofson wrote:
Yeah… However, it’s not as simple as “send all events to the window under
the mouse pointer…”The usual solution seems to be to add the concepts “focused window”, “mouse
capture” and a few other, rather simple “filters”, and then provide an API
for that, for toolkits and to some extent, applications, to use. Every window
would have some kind of “event port”.Idea: If a window isn’t equipped with an event port, the events can fall
through to it’s parent, or something… Would make it possible to use the
same window abstraction like a more lightweight overlapping + clipping
rendering control primitive; an advanced cliprect object.
This is all true, and I agree with all of it. My point here though is
mostly that events in SDL are (currently) global. They are not
attached to a window in any way. And the event data doesn’t tell
you which window it is sent for either.
So, to support events for multiple windows, we will need some
way to change the SDL event API.
So I just thought that going “around” SDL for the moment would
be a hack (although very nasty) that makes anything possible.
It means that one will have to respond to native OS events -
but at least it makes multiple windows with events and all
possible
Considering that there already are things like flags for borderless windows,
fullscreen mode etc, it sounds like supporting multiple screen surfaces is
just another step - which could be extended with some way of snapping in
window managers for fullscreen modes and that kind of stuff. (In that case,
the fullscreen window manager would do the event dispatching, pretty much
like the target’s WM does with “normal” windows. No difference for SDL
applications.)It would be logical that these fullscreen window managers would show up
behind the existing window manager API, of course. In fact, the current SDL
WM code could probably use the same “plugin” API as the fullscreen window
managers.It might be a good idea to make sure that “WM inside WM” is possible, though.
Most importantly, that would allow a custom WM to be used inside a normal
window on windowed target.
Well, again - I’m not looking for the “Right Solution ™” at the
moment… just something that will get the job done, without having
to abandon all the great stuff in SDL
Maybe what you are thinking of would be the right way in the
long term, but… I just want something that "works for now"
and doesn’t break anything in SDL - until the right design
comes around
BTW, note that I’m thinking in terms of what may make sense for SDL 1.3, but
might be messy to hack into 1.2. Without multiple screen surface support and
complex region clipping, only half of the features can be done right… And
why mess with it if it’s going to be done right anyway?
Well, the deadline for SDL 1.3 just seems too long - and naturally
it’s better to spend enough time to get 1.3 right than to
make it yet another hack… but until then, a good and useful
hack might be a good idea
It’s probably possible to come up with some shortcut, but I’m failing to see
one that both provides something truly useful, and is still clean and
portable…
It’s not portable - nor intended to be. But I still think it can be
quite clean. And having access to interoperating with the native
OS sounds useful to me… There are times where an OS have features
which are just too special for a crossplatform API…
I’ll give a very quick idea of what I have in mind:
For Win32:----------
SDL_Surface SDLWin32_CreateRGBSurfaceForHWND
(Uint32 flags, int width, int height, int depth,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask,
HWND alreadyCreatedWindow
/ + some more SDL/Win32 specific parameters? */ );
HWND SDLWin32_CreateWindow(/* Standard SDL params for an SDL_Surface /
Uint32 flags, int width, int height, int
depth,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask,
Uint32 Amask,
/ These are just the standard parameters for
the Win32 API function CreateWindow… /
LPCSTR lpClassName, / name of window
class /
LPCSTR lpWinName, / title of window
/
DWORD dwStyle, / type of window /
int X, int Y, / top-left
co-ordinates /
/ This is redundant with the SDL params…
int Width, int Height, / /
dimensions of window /
HWND hParent, / handle of parent
window /
HINSTANCE hThisInst, / handle of
creator /
LPVOID lpszAdditional / pointer to
additional info */
);
HWND SDLWin32_CreateWindowLikeSurface(SDL_Surface compatible,
/ The CreateWindow params goes
here like above… */
);
For X-Windows etc., you could add similar functions…