How do you disable 'minimize window' in windows

I remember you used to be able to have the main window not even have a bar on top.
I am able to disable maximize window through the xml but the minimize isn’t available, is it because SDL versions were changed ? Is there a way around this ? All of this because I am using DateTime and the ‘if’ that compares the differential time to a specific time doesn’t trigger when the app is minimized.
Tough cookies, heh.

1 Like

You can set in your project.xml certain Window parameters, like:

<window resizable="false />
or
<window borderless="true" />

But I dont think you can prevent Window minimizing this way.

In Linux I belive you can’t have this kind of Window at all - no program can create something a User cannot minimize/hide or switch to another Desktop/Monitor etc.

I would say that’s not the right approach.

just handle the ACTIVATE and DEACTIVATE events (triggered by mimimize)
and use DELTA differences instead of ABSOLUTE ones, using Haxe.Timer.stamp() as feeder and adjusting the value when ACTIVATE and DEACTIVATE trigger.

I can give you an example if you don’t understand what I mean :wink:

1 Like

Thanks madneon, was thinking the borderless window wasn’t possible anymore.

Thanks.

I got the ACTIVATE/DEACTIVATE part, awesome tip.

I didn’t get the DELTA diffs instead of ABSOLUTE ones.
Maybe you’re saying: on deactivate/minimize -> delta starts and when the window is brought up again that delta gets adds on to the time count ?
Or maybe you’re referencing something else ?

I’ll explain it with some code

package;
import openfl.events.Event;
import openfl.Lib;

class APP {
    static var _delta:Float=0;
    static var _isActive:Bool=true; //avoid double listeners
    static var _lastTimeStamp:Float=haxe.Timer.stamp();

    static public var delta(get,set):Float;
    static function get_delta():Float { return _delta; }
    static function set_delta(value:Float):Float { return _delta = value; }



    static public var isActive(get,never):Bool;
    static function get_isActive():Bool { return _isActive; }

    public static function init() {
        Lib.current.stage.addEventListener(Event.ENTER_FRAME,onUpdate);
        Lib.current.stage.addEventListener(Event.ACTIVATE,onActivate);
        Lib.current.stage.addEventListener(Event.DEACTIVATE,onDeactivate);

        // Trigger deactivate also on FOCUS (comment next to lines to disable it)
        Lib.current.stage.addEventListener(openfl.events.FocusEvent.FOCUS_IN,onActivate);
        Lib.current.stage.addEventListener(openfl.events.FocusEvent.FOCUS_OUT,onDeactivate);
    }

    static function onUpdate(e:Event) {
        if (!_isActive) return;
        _delta+=haxe.Timer.stamp()-_lastTimeStamp;
        _lastTimeStamp = haxe.Timer.stamp();
    }

    static function onActivate(e:Event) {
        if (_isActive) return;
        _lastTimeStamp = haxe.Timer.stamp();
        _isActive = true;
        Lib.current.stage.addEventListener(Event.ENTER_FRAME,onUpdate);
    }

    static function onDeactivate(e:Event) {
        if (!_isActive) return;
        _isActive = false;
        Lib.current.stage.removeEventListener(Event.ENTER_FRAME,onUpdate);
    }
}

class Main {
   function new() {
        APP.init();
        Lib.current.stage.addEventListener(Event.ENTER_FRAME,onUpdate);
   }

   function onUpdate(e:Event) {
        // stuff to do all the time
        trace(APP.delta);

        // stuff to do only if active
        if (!APP.isActive) return;
        if (APP.delta > 5) {
                trace('Print this every 5 seconds');
                APP.delta = 0; //reset delta
        }
   }
}

if you launch this you will see printing the delta time until 5 seconds, and then the timer reset.

also, if you minimize or defocus the window you will see the timer stop.

I’ve just wrote this on the fly, it could be better, a lot better. Just to explain myself :wink:

if you find something not clear I’ll explain it more.

Thanks yupswing, going to study the code.