Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
03-06-2014, 10:07 AM
|
#1
|
Member
Registered: Mar 2009
Location: Pennsylvania
Distribution: gentoo
Posts: 372
Rep:
|
X Events from other (all) windows
Hi everybody,
I wrote a program which is basically just a fullscreen clock. It looks great and I am really happy with it. I intend to use it as sort of a screensaver, so I wrote it to be compatible with xscreensaver and I got that working. However, the problem is that xscreensaver kills it whenever there is mouse or keyboard activity. I want it to shut off when the mouse is moved, but I want it to keep running when keys are pressed because I want to use the keyboard to switch between some different options in the program (different clock styles).
So, I have been thinking of other solutions (besides xscreensaver). There aren't a lot (or any) other screensaver daemons available besides xscreensaver, so I think I should write my own. Nothing too complicated, just something that waits until the machine is idle and then starts up a program. However, to check if the machine is idle, I would need to be able to get mouse events from all windows simultaneously, which I am not sure how to do, and I can't find any documentation online about how to do something like that. I would like to use XCB or XLib.
Anybody know where I could start, or does anybody know of another screensaver program that will allow me to continue running after a keypress?
Thanks!
p.s. Sorry if this is the wrong place to ask, its kind of a hybrid question though and it relates to Linux Software so thats where I am posting it.
EDIT: Found how to get events from everything. http://www.google.co.kr/url?sa=t&rct...0nPcSvgOUa1Ajg
Anyways, if anybody has a better solution than me writing my own screensaver program, that would be cool!
Last edited by prushik; 03-06-2014 at 10:57 AM.
Reason: Better info / refine question
|
|
|
03-10-2014, 01:23 AM
|
#2
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
The problem with writing your own screensaver is that the keyboard is used for security functions - entering a password to unlock.
Thus you don't want anything/anyone to tamper with it. Any time you allow a bypass of that function, you risk having the screensaver terminate in inappropriate ways.... or being unable to enter the password, and unlock.
|
|
|
03-10-2014, 09:59 AM
|
#3
|
Member
Registered: Mar 2009
Location: Pennsylvania
Distribution: gentoo
Posts: 372
Original Poster
Rep:
|
Quote:
Originally Posted by jpollard
The problem with writing your own screensaver is that the keyboard is used for security functions - entering a password to unlock.
Thus you don't want anything/anyone to tamper with it. Any time you allow a bypass of that function, you risk having the screensaver terminate in inappropriate ways.... or being unable to enter the password, and unlock.
|
That's true, although I am not really that afraid of breaking the rules a little bit. I personally never use screen locking and find it annoying on my single-user system. The purpose of the screensaver clock is actually my raspberry pi wearable computer that I built with a 1.8 inch screen attached to a watch band (so when I'm not using it, it looks like a watch). However, I plan to use it on my personal computer too once I add an alarm clock function. The screensaver will probably show up after only a minute or two of sitting idle, so I don't want to have the screen lock all the time, especially since nobody else can use a computer I am wearing, I think its a little bit extraneous.
What I think I meant when I asked the question was actually about a replacement for the xscreensaver daemon. I had a look at the source code for xscreensaver and I think right now I am working on just writing my own from scratch, the xscreensaver code is commented pretty well (though filled with obscenities, mainly because of weird things X does) and easy to read, I successfully converted some of the basic parts of it into XCB, but I ran into a strange issue with XCB not selecting new windows properly, although I am convinced that my XCB code is equivalent to the xscreensaver Xlib code. I think I will be able to work around the problem for now (until I figure out what I am doing wrong) using the actual Xorg screensaver extension (which xscreensaver should use also, but doesn't seem to on my system, even though its available).
When I am done with it I will release my code if anybody is interested.
|
|
|
03-10-2014, 10:08 AM
|
#4
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
Replacing the daemon is trivial - just change the reference to the utility.
But it is no longer a lock - but a screen "blanking" feature. All you have to do is disable dpms (which does the normal blanking) and have the application do a Xserver keyboard grab. The only time this is blocked is by certain keyboard based applications (usually account related) to prevent interposing events...
The usual problem with this is that the first key entry (which stops the blanking) gets lost. It is possible to pass on the event.. but a number of utilities don't accept interposed keyboard events.
Such applications then just open a window (without decoration) the size of the root window, thus covering all other windows.
One thing you can think about is whether to direct a window manager to unmap all other windows - this should allow the X server to dump the displays (reclaiming the memory) and provide better response. When the blanking is done, it then direct applications to remap the display (it does have to record what windows are active at the start of the blanking though).
Last edited by jpollard; 03-10-2014 at 10:12 AM.
|
|
|
03-10-2014, 10:39 AM
|
#5
|
Member
Registered: Mar 2009
Location: Pennsylvania
Distribution: gentoo
Posts: 372
Original Poster
Rep:
|
Quote:
Originally Posted by jpollard
Replacing the daemon is trivial - just change the reference to the utility.
But it is no longer a lock - but a screen "blanking" feature. All you have to do is disable dpms (which does the normal blanking) and have the application do a Xserver keyboard grab. The only time this is blocked is by certain keyboard based applications (usually account related) to prevent interposing events...
|
Right, I am not interested in locking. However, I think I will implement dpms in my program to switch of the display after a while in order to reduce power usage. I am unsure why I would have to do a keyboard grab though, do you mean to prevent xscreensaver from detecting the keyboard as activity? For now I am planning to completely do away with xscreensaver and use the xorg mit-screensaver extension instead, in that case I can control everything including when to shut down my screensaver.
Quote:
Originally Posted by jpollard
The usual problem with this is that the first key entry (which stops the blanking) gets lost. It is possible to pass on the event.. but a number of utilities don't accept interposed keyboard events.
Such applications then just open a window (without decoration) the size of the root window, thus covering all other windows.
|
That is basically what my screensaver does now. I'm not sure what you mean about losing a keypress though, but I am not sure why I would need to grab the keyboard either.
Quote:
Originally Posted by jpollard
One thing you can think about is whether to direct a window manager to unmap all other windows - this should allow the X server to dump the displays (reclaiming the memory) and provide better response. When the blanking is done, it then direct applications to remap the display (it does have to record what windows are active at the start of the blanking though).
|
That's a good idea, I don't see how it helps improve response though, wouldn't it take time for the WM to remap the windows?
|
|
|
03-10-2014, 01:10 PM
|
#6
|
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,908
|
Quote:
Originally Posted by prushik
That is basically what my screensaver does now. I'm not sure what you mean about losing a keypress though, but I am not sure why I would need to grab the keyboard either.
|
You might not have to grab the keyboard since all events would get sent to the application with the top level open window. The "lost keypress" is sent to the top level application, so none of the covered applications will get it.
Quote:
That's a good idea, I don't see how it helps improve response though, wouldn't it take time for the WM to remap the windows?
|
The response would be for your clock, not the covered windows. In either case, the applications supplying the data for those windows will get an even to redraw them anyway. Its just a thought. I have worked with window managers that do unmapping/mapping events (see ctwm... a nice window manager - I extended it from a maximum of 32 workspaces to allow for a compile time option for the number of workspaces).
|
|
|
03-10-2014, 01:34 PM
|
#7
|
Member
Registered: Mar 2009
Location: Pennsylvania
Distribution: gentoo
Posts: 372
Original Poster
Rep:
|
Quote:
Originally Posted by jpollard
You might not have to grab the keyboard since all events would get sent to the application with the top level open window. The "lost keypress" is sent to the top level application, so none of the covered applications will get it.
|
Well, my application would be the top level window, so that would be what I want, right? Although what I really want is _all_ keypresses to get "lost" in my application until I decide to close it.
Quote:
Originally Posted by jpollard
The response would be for your clock, not the covered windows. In either case, the applications supplying the data for those windows will get an even to redraw them anyway. Its just a thought. I have worked with window managers that do unmapping/mapping events (see ctwm... a nice window manager - I extended it from a maximum of 32 workspaces to allow for a compile time option for the number of workspaces).
|
Right, although I doubt that my response time would suffer at all with such a tiny program, its always good to save resources.
|
|
|
All times are GMT -5. The time now is 01:28 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|