Hi all The attached patch adds a new "byclient" colour directive, allowing a metacity theme to automatically determine colours based upon the hostname that a window is running from. The hostname (window->wm_client_machine) is hashed and a HLS colour is determined from that hash. This idea was shamelessly stolen from monotone-viz, a Gtk UI for the monotone version control system. The syntax of the new directive is: byclient,Hue,Luminance,Saturation,fallback eg: byclient,1,1,1,gtk:bg[NORMAL] The fallback is used if the window's hostname cannot be determined, or is equal to the hostname on which metacity is running. This allows windows to look as normal unless they are being run from a remote X server. The hue, luminance and saturation values are scalars in the range [0,1]. This allows the determined HLS colour to be modified - for example, to scale the luminance down on an unfocussed window. A complete example: <draw_ops name="title_background_unfocused"> <gradient type="vertical" x="0" y="1" width="width" height="top_height / 2"> <color value="shade/byclient,1,.8,1,gtk:bg[NORMAL]/1.05"/> <color value="shade/byclient,1,.8,1,gtk:bg[NORMAL]/1.0"/> </gradient> <gradient type="vertical" x="0" y="top_height / 2" width="width" height="top_height / 2"> <color value="shade/byclient,1,.8,1,gtk:bg[NORMAL]/0.99"/> <color value="shade/byclient,1,.8,1,gtk:bg[NORMAL]/1.0"/> </gradient> <line color="shade/byclient,1,.8,1,gtk:bg[NORMAL]/0.45" x1="0" y1="0" x2="width" y2="0"/> <line color="shade/byclient,1,.8,1,gtk:bg[NORMAL]/1.3" x1="0" y1="1" x2="width" y2="1"/> </draw_ops> This is from Ubuntu's Human theme, converted over to make use of byclient. Most of the patch is devoted to adding a new render context structure, and passing it around inside of the theme rendering code. This structure includes the window which is being rendered, allowing metacity's theming code to make use of information about the current window. Feedback would be great. This feature is very useful in environments where remote X forwarded windows are used a lot. Even if the byclient feature isn't considered suitable for inclusion, the changes to pass around the current window are useful and might allow for other interesting extensions. The attached patch is against latest metacity trunk. Cheers Grahame
Attachment:
metacity-byclient.diff
Description: Binary data