mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 23:32:04 +02:00
Merge pull request #41 from Rafostar/pinephone
Fix mobile devices transitions and detection
This commit is contained in:
5
src/controls.js
vendored
5
src/controls.js
vendored
@@ -28,6 +28,8 @@ class ClapperControls extends Gtk.Box
|
|||||||
this.currentPosition = 0;
|
this.currentPosition = 0;
|
||||||
this.currentDuration = 0;
|
this.currentDuration = 0;
|
||||||
this.isPositionDragging = false;
|
this.isPositionDragging = false;
|
||||||
|
|
||||||
|
this.isMobileMonitor = false;
|
||||||
this.isMobile = false;
|
this.isMobile = false;
|
||||||
|
|
||||||
this.showHours = false;
|
this.showHours = false;
|
||||||
@@ -507,10 +509,9 @@ class ClapperControls extends Gtk.Box
|
|||||||
: Misc.getCubicValue(settings.get_double('volume-last'));
|
: Misc.getCubicValue(settings.get_double('volume-last'));
|
||||||
|
|
||||||
this.volumeScale.set_value(initialVolume);
|
this.volumeScale.set_value(initialVolume);
|
||||||
player.widget.connect('resize', this._onPlayerResize.bind(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onPlayerResize(widget, width, height)
|
_onPlayerResize(width, height)
|
||||||
{
|
{
|
||||||
const isMobile = (width < 560);
|
const isMobile = (width < 560);
|
||||||
if(this.isMobile === isMobile)
|
if(this.isMobile === isMobile)
|
||||||
|
@@ -22,6 +22,7 @@ class ClapperWidget extends Gtk.Grid
|
|||||||
|
|
||||||
this.windowSize = JSON.parse(settings.get_string('window-size'));
|
this.windowSize = JSON.parse(settings.get_string('window-size'));
|
||||||
this.floatSize = JSON.parse(settings.get_string('float-size'));
|
this.floatSize = JSON.parse(settings.get_string('float-size'));
|
||||||
|
this.layoutWidth = 0;
|
||||||
|
|
||||||
this.fullscreenMode = false;
|
this.fullscreenMode = false;
|
||||||
this.floatingMode = false;
|
this.floatingMode = false;
|
||||||
@@ -574,6 +575,15 @@ class ClapperWidget extends Gtk.Grid
|
|||||||
debug(`interface in fullscreen mode: ${isFullscreen}`);
|
debug(`interface in fullscreen mode: ${isFullscreen}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onLayoutUpdate(surface, width, height)
|
||||||
|
{
|
||||||
|
if(width === this.layoutWidth)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.layoutWidth = width;
|
||||||
|
this.controls._onPlayerResize(width, height);
|
||||||
|
}
|
||||||
|
|
||||||
_onLeave(controller)
|
_onLeave(controller)
|
||||||
{
|
{
|
||||||
if(
|
if(
|
||||||
@@ -596,13 +606,21 @@ class ClapperWidget extends Gtk.Grid
|
|||||||
const geometry = monitor.geometry;
|
const geometry = monitor.geometry;
|
||||||
const size = this.windowSize;
|
const size = this.windowSize;
|
||||||
|
|
||||||
debug(`detected monitor resolution: ${geometry.width}x${geometry.height}`);
|
debug(`monitor application-pixels: ${geometry.width}x${geometry.height}`);
|
||||||
|
|
||||||
if(geometry.width >= size[0] && geometry.height >= size[1]) {
|
if(geometry.width >= size[0] && geometry.height >= size[1]) {
|
||||||
root.set_default_size(size[0], size[1]);
|
root.set_default_size(size[0], size[1]);
|
||||||
debug(`restored window size: ${size[0]}x${size[1]}`);
|
debug(`restored window size: ${size[0]}x${size[1]}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const monitorWidth = Math.max(geometry.width, geometry.height);
|
||||||
|
|
||||||
|
if(monitorWidth < 1280) {
|
||||||
|
this.controls.isMobileMonitor = true;
|
||||||
|
debug('mobile monitor detected');
|
||||||
|
}
|
||||||
|
|
||||||
surface.connect('notify::state', this._onStateNotify.bind(this));
|
surface.connect('notify::state', this._onStateNotify.bind(this));
|
||||||
|
surface.connect('layout', this._onLayoutUpdate.bind(this));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user