I use libgpm in order to read mouse events in my console application. It works fine if started right from the shell. It doesn't receive any mouse events if started from mc (midnight commander).
Problem is related to pseudo terminal mc creates for my process. I can semi-solve this problem by forcing gpm to use specified console screen passed as second argument to Gpm_Open (instead of 0 - auto?).
int Gpm_Open(Gpm_Connect*,int);
Is there any way to know which virtual console screen should I use when running on pseudo tty (created by mc)? I've considered using active console but it may not be the one my application is running on. Probably traversing process tree and checking if its TTY is a real console would work but I don't know how to get tty(name) for given pid and I'm afraid I'd need elevated privileges for that.
Or hopefully is there any simpler workaround?
Edit: I've just noticed that starting my process from mc but via sudo (using command line) without forcing gpm to use patricular vc screen - simply works!