Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOT GOING INSIDE x.on('event', #128

Open
himanshuoodles opened this issue May 25, 2016 · 9 comments
Open

NOT GOING INSIDE x.on('event', #128

himanshuoodles opened this issue May 25, 2016 · 9 comments
Labels

Comments

@himanshuoodles
Copy link

This is the code i get from you and when i run on mac it working fine but not going in side x.on('event'
var x11 = require('x11');

x11.createClient(function(err, display) {
                  var X = display.client;
                  X.InternAtom(false, '_NET_WM_PID', function(err, pidAtom ) {
                               X.ChangeWindowAttributes(display.screen[0].root, { eventMask: x11.eventMask.PropertyChange });
                               X.on('event', function(ev) {
                                    if(ev.name == 'PropertyNotify') {
                                    X.GetAtomName(ev.atom, function(err, name) {
                                                  if (name == '_NET_ACTIVE_WINDOW') {
                                                  X.GetProperty(0, display.screen[0].root, ev.atom, X.atoms.WINDOW, 0, 4, function(err, prop) {
                                                                var active = prop.data.readUInt32LE(0);
                                                                X.GetProperty(0, active, pidAtom, X.atoms.CARDINAL, 0, 4, function(err, prop) {
                                                                              console.log('PID:', prop.data.readUInt32LE(0));
                                                                              });
                                                                });
                                                  }
                                                  });
                                    }
                                    });
                               });
                  });

screen shot 2016-05-25 at 6 26 33 am

i am not enter in step 4

screen shot 2016-05-25 at 6 26 39 am

@sidorares
Copy link
Owner

Try to launch second x11 application while your script is running ( for example, type xeyes in terminal ) and switch focus to / from that application.

@himanshuoodles
Copy link
Author

himanshuoodles commented May 25, 2016

Basically, what i meant to say is that the event ( PropertyNotify ) is not getting fired when i switch active windows.

However, it the event fires when i switch focus to / from xeyes . What does xeyes has to do with it?

I understood the earlier issue of not having X server but now when i have the X server, why isn't the Client responding to events from the server?

Am I missing something here?

@himanshuoodles
Copy link
Author

so whats the advantage of it . I am making an app which will detect active current focus window it give everything in windows but in MAC it is not working good . Is x11 is not sufficient to use for MAC system in node webkit ? . and If it is sufficient plz tell now to do so by your plugin .

@sidorares
Copy link
Owner

this depends on integration between X and cocoa ( which is not great ).
Your example is even more complicated because it involves window manager - it's separate process that is responsible for changing _NET_ACTIVE_WINDOW property of root window, and window manager ( in your example it's probably opt/X11/bin/quartz-wm ) does not care about non-X apps

@sidorares
Copy link
Owner

sidorares commented May 25, 2016

so whats the advantage of it

X over more "native" (in osx - Cocoa / Quartz )?

It's more portable and currently "native" for unixes. If you intend to use on osx only there is n advantage.
Also X clients are easy to connect remotely over network (from computer with potentially no real hardware display)

@sidorares
Copy link
Owner

this is a good introduction to what X is - http://magcius.github.io/xplain/article/

@himanshuoodles
Copy link
Author

nice link but @sidorares can you give me an example or docs of x11 which gives active window detail in MAC .that would we very helpful

@sidorares
Copy link
Owner

x11 know nothing about osx windows. You may have some luck with AppleWM extension ( node-x11 partially implements it )

@sidorares
Copy link
Owner

sidorares commented May 25, 2016

this prints you some events from AppleWM, but it looks that at most you'll get notifications when your x11 windows are shown:

var x11 = require('../../lib');

x11.createClient(function(err, display) {
    var X = display.client;
    X.require('apple-wm', function(err, AppleWM) {
         AppleWM.SelectInput(AppleWM.NotifyMask.All)
         X.on('event', function(ev) {
           console.log("Event", ev); //df();
         });
    });
});

See http://www.xfree86.org/4.6.0/AppleWM.3.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants