js: Port to modules
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1499>
This commit is contained in:

committed by
Florian Müllner

parent
d9198317ae
commit
a751e213f6
@ -1,21 +1,20 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
/* exported getKeyboardManager, holdKeyboard, releaseKeyboard */
|
||||
|
||||
const GLib = imports.gi.GLib;
|
||||
const GnomeDesktop = imports.gi.GnomeDesktop;
|
||||
import GLib from 'gi://GLib';
|
||||
import GnomeDesktop from 'gi://GnomeDesktop';
|
||||
|
||||
const Main = imports.ui.main;
|
||||
import * as Main from '../ui/main.js';
|
||||
|
||||
var DEFAULT_LOCALE = 'en_US';
|
||||
var DEFAULT_LAYOUT = 'us';
|
||||
var DEFAULT_VARIANT = '';
|
||||
export const DEFAULT_LOCALE = 'en_US';
|
||||
export const DEFAULT_LAYOUT = 'us';
|
||||
export const DEFAULT_VARIANT = '';
|
||||
|
||||
let _xkbInfo = null;
|
||||
|
||||
/**
|
||||
* @returns {GnomeDesktop.XkbInfo}
|
||||
*/
|
||||
function getXkbInfo() {
|
||||
export function getXkbInfo() {
|
||||
if (_xkbInfo == null)
|
||||
_xkbInfo = new GnomeDesktop.XkbInfo();
|
||||
return _xkbInfo;
|
||||
@ -26,24 +25,24 @@ let _keyboardManager = null;
|
||||
/**
|
||||
* @returns {KeyboardManager}
|
||||
*/
|
||||
function getKeyboardManager() {
|
||||
export function getKeyboardManager() {
|
||||
if (_keyboardManager == null)
|
||||
_keyboardManager = new KeyboardManager();
|
||||
return _keyboardManager;
|
||||
}
|
||||
|
||||
function releaseKeyboard() {
|
||||
export function releaseKeyboard() {
|
||||
if (Main.modalCount > 0)
|
||||
global.display.unfreeze_keyboard(global.get_current_time());
|
||||
else
|
||||
global.display.ungrab_keyboard(global.get_current_time());
|
||||
}
|
||||
|
||||
function holdKeyboard() {
|
||||
export function holdKeyboard() {
|
||||
global.display.freeze_keyboard(global.get_current_time());
|
||||
}
|
||||
|
||||
var KeyboardManager = class {
|
||||
class KeyboardManager {
|
||||
constructor() {
|
||||
// The XKB protocol doesn't allow for more that 4 layouts in a
|
||||
// keymap. Wayland doesn't impose this limit and libxkbcommon can
|
||||
@ -167,4 +166,4 @@ var KeyboardManager = class {
|
||||
get currentLayout() {
|
||||
return this._current;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user