Fix window show/hide on desktop being incorrectly considered the same as app going into and out of the background/suspend on mobile
The app's Timers should still continue when a window is hidden. Especially since an app could have multiple windows, with some being shown and some being hidden. If only one were hidden, the other shown windows would clearly behave in a broken manner because the one hidden window would cause all app timers, even those associated with other windows, to be paused.
Introduces new WINDOW_SHOW AND WINDOW_HIDE events from C++ to Haxe, and new onShow and onHide events on Haxe Window.
Followup to 0918ee2381
This commit is contained in:
@@ -25,6 +25,8 @@ namespace lime {
|
||||
WINDOW_MOVE,
|
||||
WINDOW_RESIZE,
|
||||
WINDOW_RESTORE,
|
||||
WINDOW_SHOW,
|
||||
WINDOW_HIDE
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -764,14 +764,9 @@ namespace lime {
|
||||
|
||||
switch (event->window.event) {
|
||||
|
||||
case SDL_WINDOWEVENT_SHOWN: windowEvent.type = WINDOW_ACTIVATE; break;
|
||||
case SDL_WINDOWEVENT_SHOWN: windowEvent.type = WINDOW_SHOW; break;
|
||||
case SDL_WINDOWEVENT_CLOSE: windowEvent.type = WINDOW_CLOSE; break;
|
||||
case SDL_WINDOWEVENT_HIDDEN:
|
||||
|
||||
inBackground = true;
|
||||
windowEvent.type = WINDOW_DEACTIVATE;
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT_HIDDEN: windowEvent.type = WINDOW_HIDE; break;
|
||||
case SDL_WINDOWEVENT_ENTER: windowEvent.type = WINDOW_ENTER; break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED: windowEvent.type = WINDOW_FOCUS_IN; break;
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST: windowEvent.type = WINDOW_FOCUS_OUT; break;
|
||||
@@ -801,15 +796,6 @@ namespace lime {
|
||||
windowEvent.windowID = event->window.windowID;
|
||||
WindowEvent::Dispatch (&windowEvent);
|
||||
|
||||
switch (event->window.event) {
|
||||
|
||||
case SDL_WINDOWEVENT_SHOWN:
|
||||
|
||||
inBackground = false;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -561,6 +561,12 @@ class NativeApplication
|
||||
window.__fullscreen = false;
|
||||
window.__minimized = false;
|
||||
window.onRestore.dispatch();
|
||||
|
||||
case WINDOW_SHOW:
|
||||
window.onShow.dispatch();
|
||||
|
||||
case WINDOW_HIDE:
|
||||
window.onHide.dispatch();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -967,4 +973,6 @@ class NativeApplication
|
||||
var WINDOW_MOVE = 10;
|
||||
var WINDOW_RESIZE = 11;
|
||||
var WINDOW_RESTORE = 12;
|
||||
var WINDOW_SHOW = 13;
|
||||
var WINDOW_HIDE = 14;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ class Window
|
||||
public var onFocusIn(default, null) = new Event<Void->Void>();
|
||||
public var onFocusOut(default, null) = new Event<Void->Void>();
|
||||
public var onFullscreen(default, null) = new Event<Void->Void>();
|
||||
public var onHide(default, null) = new Event<Void->Void>();
|
||||
public var onKeyDown(default, null) = new Event<KeyCode->KeyModifier->Void>();
|
||||
public var onKeyUp(default, null) = new Event<KeyCode->KeyModifier->Void>();
|
||||
public var onLeave(default, null) = new Event<Void->Void>();
|
||||
@@ -78,6 +79,7 @@ class Window
|
||||
public var onRenderContextRestored(default, null) = new Event<RenderContext->Void>();
|
||||
public var onResize(default, null) = new Event<Int->Int->Void>();
|
||||
public var onRestore(default, null) = new Event<Void->Void>();
|
||||
public var onShow(default, null) = new Event<Void->Void>();
|
||||
public var onTextEdit(default, null) = new Event<String->Int->Int->Void>();
|
||||
public var onTextInput(default, null) = new Event<String->Void>();
|
||||
public var parameters:Dynamic;
|
||||
|
||||
Reference in New Issue
Block a user