| Unix Content | Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
|
| Note: Ideally, I'd like a shell (tool) solution, but if I have to write a C program for it, that's OK, too. Hence the crosspost. Now, to the question. Using either xwininfo or xprop, I can get some information about a given window (including its window ID). What I need is a way to tell whether or not that window has the focus. I could not see anything in either xwininfo or xprop that changed, based on the window gaining or losing focus. |
|
#2
|
| Kenny McCormack writes: > Note: Ideally, I'd like a shell (tool) solution, but if I have to write > a C program for it, that's OK, too. Hence the crosspost. > Now, to the question. Using either xwininfo or xprop, I can get some > information about a given window (including its window ID). What I need > is a way to tell whether or not that window has the focus. I could not > see anything in either xwininfo or xprop that changed, based on the > window gaining or losing focus. I'm not sure, but I think it is the responsibility of WM to decide which window has the focus, so how about querying root window for the property "_NET_ACTIVE_WINDOW", hmm...? HTH Ashish -- () ascii ribbon campaign - against HTML e-mail /\ www.asciiribbon.org - against proprietary attachments ·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- -- -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkjlIWcACgkQHy+EEHYuXnTspACgtn8tdEYxB2 xC4PmtHSX8KscU o8AAn1ptRjgq0DoVrr+zVjR1fajSNm1o =074U -----END PGP SIGNATURE----- |
|
#3
|
| In news:gc33eo$eir$1@news.xmission.com, Kenny McCormack > Now, to the question. Using either xwininfo or xprop, I can get some > information about a given window (including its window ID). What I > need is a way to tell whether or not that window has the focus. I > could not see anything in either xwininfo or xprop that changed, > based on the window gaining or losing focus. xdpyinfo | grep focus |
|
#4
|
| In article <8763oapzfq.fsf@chateau.d.lf>, Ashish Shukla श ष श ल >-=-=-=-=-=- .... >I'm not sure, but I think it is the responsibility of WM to decide which >window has the focus, so how about querying root window for the property >"_NET_ACTIVE_WINDOW", hmm...? Yes; we have a winner! Thanks! xprop -root (then parsing the result) does the trick. |
|
#5
|
| In article >In news:gc33eo$eir$1@news.xmission.com, >Kenny McCormack > >> Now, to the question. Using either xwininfo or xprop, I can get some >> information about a given window (including its window ID). What I >> need is a way to tell whether or not that window has the focus. I >> could not see anything in either xwininfo or xprop that changed, >> based on the window gaining or losing focus. > >xdpyinfo | grep focus Yes, looks like that would work too. Any particular reason to prefer that or the method with xprop? Which one is more efficient? |
|
#6
|
| In news:gc3d88$m85$2@news.xmission.com, Kenny McCormack >> xdpyinfo | grep focus > > Yes, looks like that would work too. Any particular reason to prefer > that or the method with xprop? Which one is more efficient? One of the beauties of Unix is that there are several different ways to accomplish a given task. Choose the one that best meets your needs. Notice the different hexadecimal values returned, however; they differ by 1: $ time xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" _NET_ACTIVE_WINDOW(WINDOW): window id # 0x320cbe1, 0x0 real 0m0.144s user 0m0.006s sys 0m0.010s $ time xdpyinfo | grep focus focus: window 0x320cbe2, revert to Parent real 0m0.015s user 0m0.002s sys 0m0.012s |
|
#7
|
| -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 b jeswine writes: [...] > $ time xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" > _NET_ACTIVE_WINDOW(WINDOW): window id # 0x320cbe1, 0x0 > real 0m0.144s > user 0m0.006s > sys 0m0.010s Or you can only retrieve the value of property "_NET_ACTIVE_WINDOW" instead of retreiving values of all properties: % xprop -root _NET_ACTIVE_WINDOW _NET_ACTIVE_WINDOW(WINDOW): window id # 0x105cd9d Ashish - -- () ascii ribbon campaign - against HTML e-mail /\ www.asciiribbon.org - against proprietary attachments ·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- -- -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkjlw1EACgkQHy+EEHYuXnRn6gCgrWbZdk5G+t g3W0pjlWaJ9n82 TJcAoMJ/V+EiJpZ3e74suhZeuH4qompZ =8JLy -----END PGP SIGNATURE----- |
|
#8
|
| On 10/3/2008 2:01 AM, Ashish Shukla आशीष शुक्ल wrote: > Ashish > - -- > () ascii ribbon campaign - against HTML e-mail > /\ www.asciiribbon.org - against proprietary attachments > ·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- -- > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.9 (GNU/Linux) > > iEYEARECAAYFAkjlw1EACgkQHy+EEHYuXnRn6gCgrWbZdk5G+t g3W0pjlWaJ9n82 > TJcAoMJ/V+EiJpZ3e74suhZeuH4qompZ > =8JLy > -----END PGP SIGNATURE----- That's pretty good - being against HTML email and proprietary attachmentswhile using a PGP signature in a newsgroup. It's like espousing the virtues of being a vegetarian while eating a hamburger. Ed. |
|
#9
|
| -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ed Morton writes: > On 10/3/2008 2:01 AM, Ashish Shukla आशीष शुक्ल wrote: > >> Ashish >> - -- >> () ascii ribbon campaign - against HTML e-mail >> /\ www.asciiribbon.org - against proprietary attachments >> ·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- -- >> -----BEGIN PGP SIGNATURE----- >> Version: GnuPG v2.0.9 (GNU/Linux) >> >> iEYEARECAAYFAkjlw1EACgkQHy+EEHYuXnRn6gCgrWbZdk5G+t g3W0pjlWaJ9n82 >> TJcAoMJ/V+EiJpZ3e74suhZeuH4qompZ >> =8JLy >> -----END PGP SIGNATURE----- > That's pretty good - being against HTML email and proprietary attachments while > using a PGP signature in a newsgroup. It's like espousing the virtues of being a > vegetarian while eating a hamburger. You can parse a OpenPGP signature using GnuPG, which is a free software, AFAIK, OpenPGP is also documented in RFC 4880. Ashish - -- () ascii ribbon campaign - against HTML e-mail /\ www.asciiribbon.org - against proprietary attachments ·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- -- -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkjmIBsACgkQHy+EEHYuXnQfPQCeLazTfZVKhH zZtrRF15esrHr4 SzkAniXopUGOrvcV7rCOAxFuMsewWOxZ =8ZNC -----END PGP SIGNATURE----- |
|
#10
|
| In article <87wsgqw4ae.fsf@chateau.d.lf>, Ashish Shukla श ष श ल >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >b jeswine writes: > >[...] > >> $ time xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" >> _NET_ACTIVE_WINDOW(WINDOW): window id # 0x320cbe1, 0x0 > >> real 0m0.144s >> user 0m0.006s >> sys 0m0.010s > >Or you can only retrieve the value of property "_NET_ACTIVE_WINDOW" >instead of retreiving values of all properties: > >% xprop -root _NET_ACTIVE_WINDOW >_NET_ACTIVE_WINDOW(WINDOW): window id # 0x105cd9d My testing of comparing run times of xprop vs. xdpyinfo was inconclusive, due, I think, to caching effects - i.e., the first time retrieving the information took longer than subsequent runs. After that, results were, as I say, inconclusive. I think it is fair to say that both commands are basically pulling from the same information store. Anyway, I'm glad to see that the xprop command you give (where it gets only the property in which one is interested) does work, and, to the extent that anything conclusive can be said about timings, seems to be the best. It's funny; although I thought that it had to be possible, I couldn't tease it out of the manpage that that syntax would work. |
|
#11
|
| In article <87wsgqw4ae.fsf@chateau.d.lf>, Ashish Shukla श ष श ल >-----BEGIN PGP SIGNED MESSAGE----- >Hash: SHA1 > >b jeswine writes: > >[...] > >> $ time xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" >> _NET_ACTIVE_WINDOW(WINDOW): window id # 0x320cbe1, 0x0 > >> real 0m0.144s >> user 0m0.006s >> sys 0m0.010s > >Or you can only retrieve the value of property "_NET_ACTIVE_WINDOW" >instead of retreiving values of all properties: > >% xprop -root _NET_ACTIVE_WINDOW >_NET_ACTIVE_WINDOW(WINDOW): window id # 0x105cd9d My testing of comparing run times of xprop vs. xdpyinfo was inconclusive, due, I think, to caching effects - i.e., the first time retrieving the information took longer than subsequent runs. After that, results were, as I say, inconclusive. I think it is fair to say that both commands are basically pulling from the same information store. Anyway, I'm glad to see that the xprop command you give (where it gets only the property in which one is interested) does work, and, to the extent that anything conclusive can be said about timings, seems to be the best. It's funny; although I thought that it had to be possible, I couldn't tease it out of the manpage that that syntax would work. P.S. Sorry for posting twice - I got screwed up because somebody changed the newsgroups - I am following this thread in c.u.s. |
|
#12
|
| In article <87iqs9x0ix.fsf@chateau.d.lf>, Ashish Shukla श ष श ल .... >You can parse a OpenPGP signature using GnuPG, which is a free software, You can parse HTML using lynx, which is free software, etc, etc. Which: a) completely misses the point, and b) doesn't change the fact that HTML in Usenet postings is evil. |
|
#13
|
| -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Kenny McCormack writes: > In article <87iqs9x0ix.fsf@chateau.d.lf>, > Ashish Shukla *¤ *¤¶*¥ *¤· *¤¶ *¥ *¤ *¥ *¤² > ... >> You can parse a OpenPGP signature using GnuPG, which is a free software, > You can parse HTML using lynx, which is free software, etc, etc. > Which: a) completely misses the point, and b) doesn't change the fact that > HTML in Usenet postings is evil. but OpenPGP is not any proprietary standard or HTML. Ashish - -- () ascii ribbon campaign - against HTML e-mail /\ www.asciiribbon.org - against proprietary attachments ·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- -- -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkjmW60ACgkQHy+EEHYuXnScAACfZ6v4wuNpdA C9HoQsk4k4k9xY mCwAnRCHmxTST7mvikiIS6vUNy5u0PZF =7aYC -----END PGP SIGNATURE----- |
|
#14
|
| On Oct 3, 11:27*am, gaze...@shell.xmission.com (Kenny McCormack) wrote: > In article <87wsgqw4ae....@chateau.d.lf>, > Ashish Shukla श ष श ल > > > > >-----BEGIN PGP SIGNED MESSAGE----- > >Hash: SHA1 > > >b jeswine writes: > > >[...] > > >> $ time xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" > >> _NET_ACTIVE_WINDOW(WINDOW): window id # 0x320cbe1, 0x0 > > >> real * *0m0.144s > >> user * *0m0.006s > >> sys * * 0m0.010s > > >Or you can only retrieve the value of property "_NET_ACTIVE_WINDOW" > >instead of retreiving values of all properties: > > >% xprop -root _NET_ACTIVE_WINDOW > >_NET_ACTIVE_WINDOW(WINDOW): window id # 0x105cd9d > > My testing of comparing run times of xprop vs. xdpyinfo was > inconclusive, due, I think, to caching effects - i.e., the first time > retrieving the information took longer than subsequent runs. *After > that, results were, as I say, inconclusive. *I think it is fair to say > that both commands are basically pulling from the same information store. > > Anyway, I'm glad to see that the xprop command you give (where it gets > only the property in which one is interested) does work, and, to the > extent that anything conclusive can be said about timings, seems to be > the best. *It's funny; although I thought that it had to be possible, I > couldn't tease it out of the manpage that that syntax would work. > > P.S. *Sorry for posting twice - I got screwed up because somebody > changed the newsgroups - I am following this thread in c.u.s. From the example at the bottom of the manpage: EXAMPLES To display the name of the root window: xprop -root WM_NAME |