ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
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.
I'm a newbie to linux XServer and X11 in general, so, I'm not quite sure as to if this question goes in the linux newbie forum or the programming forum. Anyways, I'm using Xlib to work with the Xserver, and I was wondering if anyone could tell me or point me to a block of code that I can use to set the background of the display or the screen (not the window) to an image rather than just have the it all black or white.
Usually that function is handled by the desktop of your choice.
Missing that - there is xsetroot which allows you to change various aspects/coloring of the background.
There are other tools - specifically in the Imagemagic package that allows various images to be put on the background using the "xloadimage" tool.
But usually, it is done by some tool of the desktop you are using.
One thing that can happen when mixing the desktop and using external tools is that sometimes the "refresh" of the display (multiple workspaces for instance) will replace the image with what that desktop tool is using.
Usually that function is handled by the desktop of your choice.
Missing that - there is xsetroot which allows you to change various aspects/coloring of the background.
There are other tools - specifically in the Imagemagic package that allows various images to be put on the background using the "xloadimage" tool.
But usually, it is done by some tool of the desktop you are using.
One thing that can happen when mixing the desktop and using external tools is that sometimes the "refresh" of the display (multiple workspaces for instance) will replace the image with what that desktop tool is using.
I should've mentioned this in the question, but there is no desktop environment or window manager, it's just a fresh copy of arch and x, and I just wanted to write almost everything from the bottom up just to teach myself how to work with the bare xserver. The way I'm setting a background now is by creating a window the size of the display screen and setting that window to be the root of all other windows, and setting the background of that root window. What I want to do right now is have the image directly displayed on the screen and not on the window. Do you think it is possible to maybe do that.
I should've mentioned this in the question, but there is no desktop environment or window manager, it's just a fresh copy of arch and x, and I just wanted to write almost everything from the bottom up just to teach myself how to work with the bare xserver. The way I'm setting a background now is by creating a window the size of the display screen and setting that window to be the root of all other windows, and setting the background of that root window. What I want to do right now is have the image directly displayed on the screen and not on the window. Do you think it is possible to maybe do that.
i am alittle unsure whther you are asking for a utility that does that at login, or whether you are writing a C program that is supposed to do that?
if the former, the advice given so far is correct.
there's a multitude of utilities that will do what you want: setroot, hsetroot, xsetroot, feh, nitrogen...
and you need to add that command to your autostart script so it gets excuted everytime you log in.
It doesn't matter how you load or create the background image, as I understand your question. But you just want to know how to put an image at the very back, so anything else is drawn in front of it? Like if the root window was invisible, you'd still see an image?
In X, as far as I get it, the root window IS the back. I know you can juggle things around, but that's it. X doesn't render outside of a drawable, and the drawable which you can see is a window, mapped to the screen.
Perhaps you mean drawing to the framebuffer? But you can create the root window with a backing store so it automagically buffers itself so you don't need to respond to expose events just to keep the image intact, you can sort of set and forget. For multiple screens, I dunno.
Below is a descriptive quote, clipped from the page pointed to by the above URL
Quote:
This is the conversion of the Xlib Programming Manual into HTML, brought to you by Christophe Tronche. This work is far from being complete, as you may soon notice, and is provided "as is" ("as usual"). Many links have been made provision for, but actually aren't translated yet. If you're more interested in some part of the manual, let me know and I'll push further on it.
By popular demand, you can now get the manual as one .tar.gz file (~ 330 Kb).
How to get a PostScript version of the manual.
This work is based on X11 release 6.
The X11/Xlib manual is copyrighted by the X Consortium.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.