[Windows Legacy] How to make task bar icon flashing

Well, did everything correctly but didnt flash…

void SDLWindow::Alert (int count, int speed) {
	
	SDL_SysWMinfo info;
	SDL_GetWindowWMInfo(sdlWindow, &info);

	FLASHWINFO fi;
	fi.cbSize = sizeof(FLASHWINFO);
	fi.hwnd = info.info.win.window;
	fi.dwFlags = FLASHW_ALL;
	fi.uCount = count;
	fi.dwTimeout = speed;
	FlashWindowEx(&fi);
	
}
...
Lib.application.window.alert(5, 0);

Nothing happened…

Never mind, adding

SDL_VERSION (&info.version);

Fixed it :smiley:

Can’t believe I actually did it… without c++ skills 0.0
Anyways, please advise on how to do it for legacy :stuck_out_tongue:

Did you get it all working now for Lime? Can you use it from the Window class cleanly? :smile:

I think it would be best to probably hack it in if you want it for legacy. There’s a Frame/Stage system that would require you to make additions in multiple stages (iOS/Android/etc) which could be complex. For now, perhaps you should add a function in https://github.com/openfl/lime/blob/master/legacy/project/src/ExternalInterface.cpp with your functionality.

At the head, you would do something like:

#ifdef HX_WINDOWS
#include <SDL.h>

and toward the bottom:

value lime_window_alert () {
    
    #ifdef HX_WINDOWS
    SDL_SysWMinfo info;
    SDL_GetWindowWMInfo(sdlWindow, &info);
    ...
    #endif
    
    return alloc_null ();
    
}
DEFINE_PRIM (lime_window_alert, 0)

Great! :smile: I’m hoping that Lime can be simple enough that even without C++ knowledge, it’s not scary to get into :success:

After making your changes, lime rebuild windows -Dlegacy for legacy :slight_smile:

Yep it’s working, right now I have to use it like this:

Lib.application.window.alert(5, 0);

I will try the legacy part when I get home :stuck_out_tongue:

So if I added the method in ExternalInterface.cpp with the same arguments and such, will it be usable right away without even changing the stuffs at the .hx end?

Similar to what you did already with Lime, you will need something on the Haxe side with Lib.load (legacy) or System.load (current OpenFL/Lime) :smile:

The Lime API is not available in Lime legacy, so you won’t be able to use the Window class. One way to do it would be to handle it conditionally in your project:

#if !lime_legacy

stage.window.alert (5, 0);

#elseif windows

var lime_window_alert = Lib.load ("lime", "lime_window_alert", 2);
lime_window_alert (5, 0);

#end
1 Like

Or maybe I can add a method in Stage class and direct it to window.alert when it’s not legacy. Is that okay?

Also, how can I get the window handle in ExternalInterface.cpp?

1 Like

bump 0.0 a little help here plz

You can’t access Lime 2 code in legacy, so there is no Lime window class

However, if you did a quick ExternalInterface hack, maybe this would help?

https://wiki.libsdl.org/SDL_GL_GetCurrentWindow?highlight=(\bCategoryVideo\b)|(CategoryEnum)|(CategoryStruct)

Thanks for the API doc. The legacy version of alert method is now perfectly functional.

What I meant was, can I add a method in openfl.display.Stage for both legacy and lime 2? and in lime 2 I will use window.alert and in legacy I will use the external interface call. If the target is not windows, the function will be empty. I just need a permission to edit that class because I kinda feel like it’s important lol

Oh, what I would recommend is handling this on your side, like:

#if !openfl_legacy
stage.window.alert ();
#else
var alert = Lib.load ("lime", "lime_window_alert", 0);
alert ();
#end

something like that

I would be a bit less bothered if there was a function added to openfl._legacy.display.Stage, since it won’t show in code completion, but I want to make sure that the primary Stage class remains clean :slight_smile:

Good, then I will have it remain like this. Submitting PR now

Travis CI build failed… Does that mean it can never be merged?

Don’t worry about it, it’s normal :smile:

Thank you! I’ll take a look soon :smile:

Oh okay thx, can’t wait :smiley:

For a moment, I was debating whether to call it “alert” (actually) because of confusion with popup boxes. After considering whether this should pair with more general notification support (with or without the popup dialog) or an alert box, I settled on the alert.

I believe this is meant to be immediate, where notifications may be scheduled for when you are not running.

We might decide to make this better or a little different, but for now I’ve added support for window.alert (type, title, message) if these left null, it will blink the taskbar on Windows while the application is minimized, but if they are not, then it shows an OS popup message box

We can add support for OS X bouncing in the dock, or a flash on different X window systems, I think :slight_smile:

2 Likes

Nice! Is there any ways still to specify flashing speed and count?

I was trying to understand the case for controlling the speed or count. Why would it make sense to do something other than the OS default, or to flash only a certain number of times instead of until the user opens the application?

Well I thought about that too, but just kinda gave the option anyways…

Oh yea and also, how does legacy handle the alert function?

Here’s what it looks like right now:

https://github.com/openfl/lime/blob/master/legacy/project/src/ExternalInterface.cpp#L575