mirror of
https://github.com/gosticks/PaperWM.git
synced 2026-10-07 12:26:54 +00:00
Move window.paperActions into init()
Since it's not possible to reload action registration it's better to have it in init where it will never run more than once.
This commit is contained in:
+37
-38
@@ -23,44 +23,6 @@ let isDuringGnomeShellStartup = false;
|
||||
|
||||
window.PaperWM = Extension;
|
||||
|
||||
/*
|
||||
Keep track of some mappings mutter doesn't do/expose
|
||||
- action-name -> action-id mapping
|
||||
- action-id -> action mapping
|
||||
- action -> handler
|
||||
*/
|
||||
window.paperActions = {
|
||||
actions: [],
|
||||
nameMap: {},
|
||||
register: function(actionName, handler, metaKeyBindingFlags) {
|
||||
let id = registerMutterAction(actionName,
|
||||
handler,
|
||||
metaKeyBindingFlags)
|
||||
let action = { id: id
|
||||
, name: actionName
|
||||
, handler: handler
|
||||
};
|
||||
this.actions.push(action);
|
||||
this.nameMap[actionName] = action;
|
||||
return action;
|
||||
},
|
||||
idOf: function(name) {
|
||||
let action = this.byName(name);
|
||||
if (action) {
|
||||
return action.id;
|
||||
} else {
|
||||
return Meta.KeyBindingAction.NONE;
|
||||
}
|
||||
},
|
||||
byName: function(name) {
|
||||
return this.nameMap[name];
|
||||
},
|
||||
byId: function(mutterId) {
|
||||
return this.actions.find(action => action.id == mutterId);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function init() {
|
||||
SESSIONID += "#"
|
||||
debug('init', SESSIONID);
|
||||
@@ -72,6 +34,43 @@ function init() {
|
||||
}
|
||||
initCount++;
|
||||
|
||||
/*
|
||||
Keep track of some mappings mutter doesn't do/expose
|
||||
- action-name -> action-id mapping
|
||||
- action-id -> action mapping
|
||||
- action -> handler
|
||||
*/
|
||||
window.paperActions = {
|
||||
actions: [],
|
||||
nameMap: {},
|
||||
register: function(actionName, handler, metaKeyBindingFlags) {
|
||||
let id = registerMutterAction(actionName,
|
||||
handler,
|
||||
metaKeyBindingFlags)
|
||||
let action = { id: id
|
||||
, name: actionName
|
||||
, handler: handler
|
||||
};
|
||||
this.actions.push(action);
|
||||
this.nameMap[actionName] = action;
|
||||
return action;
|
||||
},
|
||||
idOf: function(name) {
|
||||
let action = this.byName(name);
|
||||
if (action) {
|
||||
return action.id;
|
||||
} else {
|
||||
return Meta.KeyBindingAction.NONE;
|
||||
}
|
||||
},
|
||||
byName: function(name) {
|
||||
return this.nameMap[name];
|
||||
},
|
||||
byId: function(mutterId) {
|
||||
return this.actions.find(action => action.id == mutterId);
|
||||
}
|
||||
};
|
||||
|
||||
let dynamic_function_ref = utils.dynamic_function_ref;
|
||||
let as_key_handler = utils.as_key_handler;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user