Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 11-01-2004, 06:17 PM   #1
LQ Newbie
Registered: Nov 2004
Posts: 1

Rep: Reputation: 0
X11 program setting transparency for xcompmgr

Without using an external program, how does a X11 app change it's transparency? Using latest xorg and xcompmgr.

I want the following program to start up transparent but I don't really know how to go about it. I think a few changes in main should do it, if it's possible like this.

// Compile with - gcc main.c -o prog -L/usr/X11R6/lib -lX11 -I/usr/include/X11

#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <stdio.h>

unsigned int width, height;
Display *display;
int screen;
int depth;
Window win;

static void process_event(XEvent);
static void eventloop();
static void create();

void create() { // Squashed slightly, not that revelant
	char *window_name = "Simple Window"; char *icon_name = "window"; static XSizeHints size_hints; Window rootwin;
	width=400; height=400; display = XOpenDisplay(NULL);
	screen = DefaultScreen(display); depth = DefaultDepth(display, screen); rootwin = RootWindow(display, screen);
	win = XCreateSimpleWindow(display, rootwin, 10, 10, width, height, 5, BlackPixel(display, screen), BlackPixel(display, screen));
	size_hints.flags = PSize | PMinSize | PMaxSize; size_hints.min_width = width; size_hints.max_width = width; size_hints.min_height = height;size_hints.max_height = height;
	XSetStandardProperties(display, win, window_name, icon_name, None, 0, 0, &size_hints); 
	XSelectInput(display, win, ButtonPressMask | KeyPressMask);
	XMapWindow(display, win);
void eventloop() {
void process_event(XEvent report) {
void closewin() {
int main() {

	Window root_win, parent_win;
	Window* child_list;
	unsigned int num_children;

	Atom m_alphaatom = XInternAtom(display, "_NET_WM_WINDOW_OPACITY", False);
	unsigned int opacity = 0xc0000000;
	XChangeProperty(display, win, m_alphaatom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1l);
	XSync(display, 0);
	while(1) {
	return 0;


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
error while trying to install program: "X11/Xlib.h: No such file or directory" nate1 Linux - Newbie 3 05-21-2004 08:08 AM
help setting transparency in fluxbox rugal Linux - Software 5 12-16-2003 03:25 PM
Which script calls the X11 program on RedHat 8.0? yorambaron Linux - Software 2 12-13-2003 08:46 AM
Is there any way to reattach a program still running over a dead X11 connection? godOfThunder Linux - Networking 0 11-22-2003 11:01 PM
setting the default x11 font k4zau Linux - Software 5 05-05-2003 12:02 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:03 PM.

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