Start loading media after window is shown

This commit is contained in:
Rafostar
2020-10-19 13:26:15 +02:00
parent b383a89107
commit 82840d5852

View File

@@ -12,13 +12,8 @@ const APP_NAME = pkg.name.substring(
let { debug } = Debug; let { debug } = Debug;
var App = GObject.registerClass({ var App = GObject.registerClass(
Signals: { class ClapperApp extends Gtk.Application
'ready': {
param_types: [GObject.TYPE_BOOLEAN]
},
}
}, class ClapperApp extends Gtk.Application
{ {
_init(opts) _init(opts)
{ {
@@ -90,7 +85,11 @@ var App = GObject.registerClass({
{ {
super.vfunc_activate(); super.vfunc_activate();
this.window.present(); this.windowShowSignal = this.active_window.connect(
'show', this._onWindowShow.bind(this)
);
this.active_window.present();
Gtk.StyleContext.add_provider_for_display( Gtk.StyleContext.add_provider_for_display(
Gdk.Display.get_default(), Gdk.Display.get_default(),
this.cssProvider, this.cssProvider,
@@ -196,9 +195,6 @@ var App = GObject.registerClass({
this._playerRealizeSignal = this.player.widget.connect( this._playerRealizeSignal = this.player.widget.connect(
'realize', this._onPlayerRealize.bind(this) 'realize', this._onPlayerRealize.bind(this)
); );
this._playerMapSignal = this.player.widget.connect(
'map', this._onPlayerMap.bind(this)
);
} }
_onWindowFullscreenChanged(window, isFullscreen) _onWindowFullscreenChanged(window, isFullscreen)
@@ -261,10 +257,10 @@ var App = GObject.registerClass({
this.setHideCursorTimeout(); this.setHideCursorTimeout();
} }
_onPlayerMap(self, data) _onWindowShow(window)
{ {
this.player.widget.disconnect(this._playerMapSignal); this.window.disconnect(this.windowShowSignal);
this.emit('ready', true); this.windowShowSignal = null;
if(this.playlist.length) if(this.playlist.length)
this.player.set_playlist(this.playlist); this.player.set_playlist(this.playlist);
@@ -338,37 +334,34 @@ var App = GObject.registerClass({
this.clearTimeout('hideControls'); this.clearTimeout('hideControls');
} }
_onPlayerMotion(self, posX, posY) _onPlayerMotion(controller, posX, posY)
{ {
/* GTK4 sometimes generates motions with same coords */ /* GTK4 sometimes generates motions with same coords */
if(this.posX === posX && this.posY === posY) if(this.posX === posX && this.posY === posY)
return; return;
/* Do not show cursor on small movements */ /* Do not show cursor on small movements */
let ignoreMovement = ( if(
Math.abs(this.posX - posX) <= 0.5 Math.abs(this.posX - posX) >= 0.5
&& Math.abs(this.posY - posY) <= 0.5 || Math.abs(this.posY - posY) >= 0.5
); ) {
this.player.widget.set_cursor(this.defaultCursor);
this.setHideCursorTimeout();
if(this.window.isFullscreen) {
if(!this.interface.revealerTop.get_reveal_child()) {
this.setUpdateTimeInterval();
this.interface.revealControls(true);
}
this.setHideControlsTimeout();
}
else if(this.hideControlsTimeout) {
this.clearTimeout('hideControls');
}
}
this.posX = posX; this.posX = posX;
this.posY = posY; this.posY = posY;
if(ignoreMovement)
return;
this.player.widget.set_cursor(this.defaultCursor);
this.setHideCursorTimeout();
if(this.window.isFullscreen) {
if(!this.interface.revealerTop.get_reveal_child()) {
this.setUpdateTimeInterval();
this.interface.revealControls(true);
}
this.setHideControlsTimeout();
}
else if(this.hideControlsTimeout) {
this.clearTimeout('hideControls');
}
} }
_onPlayerDragUpdate(gesture, offsetX, offsetY) _onPlayerDragUpdate(gesture, offsetX, offsetY)