How to ascertain the parent window border color used by the WM
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.
How to ascertain the parent window border color used by the WM
Hi all. I'm writting a program in 'c' using x11. I'm NOT using any tool kits for my buttons menu's etc as I prefer to do them myself. I need to know of a way to discern what colour value '0xFFFFFF' is being used by the window manager so that I may maintain congruity with the parent window colour scheme.
Any help much appreciated
Communication with X window manager using 'C' language
Hi Habitual,
I'm thinking that you mean to manually use an eye dropper to choose the colour and then hard code it as a value into
my program. What I'm trying to do is have my program launch (run) and then query the window manager as to what colour is
being used for the window border so that my program can dynamically set the face colour of my buttons ,child window border(s) (if any) to match. The tool kits are built on X so there must be a way to do this as they do it. I don't see any
X functions to achieve this directly outside of Atoms maybe and I really have a very limited understanding of what they are
about.
Thank you for the reply
The Window manager borders are a window owned by the window manager. The application window is on top of that window manager border window.
It might be possible to walk the window tree and get the parent window of the application... you would then have to find some place to get the color without capturing any text/icons/other windows that may be there (usually WM buttons). Getting pixel 0,0 might work... assuming the WM isn't using shading (many do, so this won't get you a "color" as there is no single color).
Note: It is not necessary that a window manager border even exist. Usually this results in the window parent being the root window, so you can't get such information.
This is USED to be handled through X resource definitions - until Gnome and other toolkits decided that X resources were "not useful", thus they don't set any.
What I'm trying to do is have my program launch (run) and then query the window manager as to what colour is
being used for the window border so that my program can dynamically set the face colour of my buttons ,child window border(s) (if any) to match. The tool kits are built on X so there must be a way to do this as they do it. I don't see any X functions to achieve this directly outside of Atoms maybe and I really have a very limited understanding of what they are about.
so do i.
but i know that X itself does not come with a window manager.
so whichever solution, it will be inelegant, because you can't utilize those libraries.
first you need to ask yourself: which window manager?
now i'm using openbox, and it would be fairly easy to
find out the current theme
query the theme's config file for, let's say the main color of the active window title.
similar things are possible for other window managers, but it will never be an elegant or failproof solution.
you should really just go with Xresources and trust that the user has set up their stuff aesthetically.
Thanx for the reply. I shall probably take your advice.
Here is a new problem lol. We are using Xcine(sp) on our system. LCD monitor and also using our LCD tv as a monitor. The problem is this. I create my first window by first obtaining the XWindowAttributes for root window. Then use width and height from that to make my window maximized. This is placing a maximized window on the tv when mapped BUT when using the XGetWindowAttributes() on this window it is returning a height value for both monitors rather then returning the height for that window on that particular monitor. I require the correct height s I nrrd to be able to pop up child windows preferably
centered vertically/horizontally for error messages/data input etc. Thanx :-)
You are confusing the use of the root window with the size of the monitor - which is not the same.
Frequently the root window will span both displays... thus the size will be the combined size (usually done horizontally).
You likely need the X server to have the XRandR extension, which will allow you to determine the size of the monitors used. I haven't used it within an X application, and the documentation is rather skimpy.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.