LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-05-2016, 03:30 PM   #1
xbunny
LQ Newbie
 
Registered: May 2016
Location: atlantic canada
Distribution: mint
Posts: 3

Rep: Reputation: Disabled
Unhappy 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
 
Old 05-05-2016, 05:39 PM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
If you don't mind a gtk color picker, check out yad in a repository near you.

I run it using
Code:
yad --color
eye-dropper > element > #<value_of_element>
 
Old 05-05-2016, 09:08 PM   #3
xbunny
LQ Newbie
 
Registered: May 2016
Location: atlantic canada
Distribution: mint
Posts: 3

Original Poster
Rep: Reputation: Disabled
Question 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
 
Old 05-07-2016, 08:37 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
I don't believe there are any.

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.
 
Old 05-07-2016, 03:22 PM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by xbunny View Post
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
  1. find out the current theme
  2. 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.
 
Old 05-21-2016, 10:01 AM   #6
xbunny
LQ Newbie
 
Registered: May 2016
Location: atlantic canada
Distribution: mint
Posts: 3

Original Poster
Rep: Reputation: Disabled
Question :}

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 :-)
 
Old 05-21-2016, 10:34 AM   #7
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Coding on border in re color style satimis Linux - General 4 08-24-2014 09:42 PM
sed syntax for changing color and border-top and similar sysslack Programming 4 07-21-2012 07:23 AM
xwindows, how can a client window be notified when parent window is moved/resized? shamju Linux - Desktop 1 02-03-2007 07:30 PM
dockapps - changing the color / border epoo Linux - Software 0 01-11-2007 07:48 PM
Desactivate Window Border.. Borelian Linux - Software 0 10-12-2003 08:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration