mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-31 00:11:59 +02:00
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
const { Gdk, GObject, Gtk } = imports.gi;
|
|
|
|
var Window = GObject.registerClass({
|
|
Signals: {
|
|
'fullscreen-changed': {
|
|
param_types: [GObject.TYPE_BOOLEAN]
|
|
},
|
|
}
|
|
}, class ClapperWindow extends Gtk.ApplicationWindow
|
|
{
|
|
_init(application, title)
|
|
{
|
|
super._init({
|
|
application: application,
|
|
title: title || 'Clapper',
|
|
resizable: true,
|
|
destroy_with_parent: true,
|
|
});
|
|
this.isFullscreen = false;
|
|
|
|
this.keyController = new Gtk.EventControllerKey();
|
|
this.add_controller(this.keyController);
|
|
|
|
this.mapSignal = this.connect('map', this._onMap.bind(this));
|
|
}
|
|
|
|
toggleFullscreen()
|
|
{
|
|
let un = (this.isFullscreen) ? 'un' : '';
|
|
this[`${un}fullscreen`]();
|
|
}
|
|
|
|
_onStateNotify(toplevel)
|
|
{
|
|
let { state } = toplevel;
|
|
let isFullscreen = Boolean(state & Gdk.ToplevelState.FULLSCREEN);
|
|
|
|
if(this.isFullscreen === isFullscreen)
|
|
return;
|
|
|
|
this.isFullscreen = isFullscreen;
|
|
this.emit('fullscreen-changed', this.isFullscreen);
|
|
}
|
|
|
|
_onMap()
|
|
{
|
|
this.disconnect(this.mapSignal);
|
|
|
|
let surface = this.get_surface();
|
|
surface.connect('notify::state', this._onStateNotify.bind(this));
|
|
}
|
|
});
|