Failed to pass keypress/release event to nw app
Opened this issue · 2 comments
yilang2007lw commented
I use node-x11 to grab keyboard for a screensaver node-webkit app.I grabbed the keyboard and mouse event succeed, but only pointer events can delivery to my html input widget, the keypress/release not.
Below is my code:
function grab_window(wid) {
console.log("-----------grab window----------------");
console.log(wid);
var x11 = require('x11');
x11.createClient(function(err, display) {
var X = display.client;
X.ChangeWindowAttributes(wid, { eventMask: x11.eventMask.ResizeRedirect|x11.eventMask.KeyPress|x11.eventMask.KeyRelease|x11.eventMask.StructureNotify|x11.eventMask.SubstructureNotify});
X.LowerWindow(wid);
X.GrabKeyboard(wid, false, 0, 1, 1);
X.on('event', function(ev) {
console.log(ev.name);
});
});
};
var gui = require('nw.gui');
var win = gui.Window.get();
win.title = "cscreensaver";
//win.enterKioskMode();
onload = function () {
win.setAlwaysOnTop(true);
win.setShowInTaskbar(false);
var child_process = require('child_process');
var cmd = "xwininfo -name 'cscreensaver' -int |grep 'cscreensaver' | awk '{print $4}'";
var wid = 0;
child_process.exec(cmd, function(err, stdout, stderr) {
wid = parseInt(stdout);
win.show();
grab_window(wid);
});
};
//code end
The '"console.log(ev.name);" can print the key event when I press my keyboard, but it can't go into my html input, how to solve this, thanks for any reply.
sidorares commented
Are you using linux?
yilang2007lw commented
Yes