Thread View: comp.unix.internals
1 messages
1 total messages
Started by km
Mon, 21 Dec 1992 08:47
Colormaps in OW 3
Author: km
Date: Mon, 21 Dec 1992 08:47
Date: Mon, 21 Dec 1992 08:47
268 lines
9472 bytes
9472 bytes
hi ,
We have a problem with colormaps on a SUN Sparcstation 2 (SUN OS 4.1.2)
We have an application which requires that the user can define his own
gammafunction in the colormap. At startup of the X-server he therefor
would like to have possible previous stored settings reloaded.
In fact it all boils down to the problem that at startup of the XSERVER
(xnews) we want to install our own colormap so that other newly created
Xclients also inherit this colormap-ID. We have written a small test-
program (which we sent you at the end of this mail) which installs a user-
defined colormap. To see clearly when our colormap gets loaded we have
taken a copy of the Default Colormap and made the red, green and blue
values equal, which gives some kind of gray-scale effect. However we have
the problem that when new Xclients are started, they keep on using the old
(initial default) colormap...
In fact even when we use XSetWindowColormap to set the colormap of the root
window, new clients keep on using the 'default startup' colormap. If we use
the DefaultColormap-macro we keep on getting the old initial colormap-ID.
And it is probably so that new xclients, (for instance xterm, xclock a.s.o.)
are using this DefaultColormap-macro to set their own window-colormap. so
they are not aware of our new colormap.
Is there a way to solve the above mentioned problem ?
Furthermore :
a. In theory, above problem has nothing to do with the OpenLookWindowManager.
The OLWM is just a 'special' client, that performs some house-keeping.
Altough I have one question about this. Suppose one uses XSetWindow-
Colormap to set the colormap of the root-window to a user-defined one,
together with the colormap of the window created in the program, and
the OLWM is running in ColorFollowsMouse mode. If one moves the mouse-
pointer above the newly created window the OLWM installs the user-defined
colormap (as it is supposed to do). However if one moves the mouse-pointer
to the root-window the OLWM does NOT install the user-defined colormap.
Hence, if one uses xwininfo to check the colormap ID of the ROOT-window
one gets the userdefined colormap ID...
Is there any explanation for this ?
b. If one assumes the same situation as above, it means we have a program
running and we use the CTRL-L2 key to lock our user-defined colormap.
If one then clicks on the RIGHT-MOUSE-BUTTON to get for instance the
root-menu, then the OLWM switches back in the default-colormap ?
Can one avoid this ?
c. Also is there a possibility to perform the CTRL-L2 (LockColorMap function)
from within a program ? Because the program that is to install our user-
defined colormap should run as a deamon, and should possibly have no visi-
ble window on the screen. At that moment it isn't any lobger possible to
use the CTRL-L2 ...
d. Also if we use the XSetStandardColormap (XSetRGBColormap) function to set
the XA_RGB_DEFAULT_MAP,XA_RGB_BEST_MAP... properties all behavior stays
the same. I assume this is normal, because in fact these STANDARD Color-
maps have nothing to do with the DEFAULT colormap. The concept of STANDARD
colormaps is only to make life easier when one wants to share colors
between Xclients. Is this right ?
We've got really stuck... Could anyone please give me some hints or give us
your opinion on the situation. We are not sure if it is even possible to force
the xnews X-server to use a user-defined colormap at startup ...
Thank you very much in advance.
Kind Regards.
Kurt MICHELS
R&D Department
BARCO N.V.
BELGIUM
E-mail : km@barco.be
Tel : 32 56 233 368
Fax : 32 56 233 332
--------------------------------------------------
/* File : INIT.C */
/*
This program allocates the entire colormap, ALL applications are
forced to use only this colormap. Of course they can install
themselves a total new colormap ... (this one can never avoid).
It can be used as daemon, because if one omits the XMapWindow
function, then nothing is displayed on the screen.
This program can easily be extented to read-in a colormap from a
file which was stored in some format...
*/
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <stdio.h>
#include <X11/keysymdef.h>
#define MYMAXCOLORS 256
void main()
{
Display *display;
Window win;
Window rootwin;
Window windowlist[10];
XWindowAttributes attributes;
int defaultscreen;
char dummy;
unsigned int width, height, x, y;
unsigned int borderwidth = 4;
unsigned int display_width, display_height;
XEvent report;
XEvent CTRL2Event;
XKeyEvent CTRL2KeyEvent;
Visual *defaultvisual;
/**************** ADDED FOR COLOR-MANAGEMENT *********************/
int i;
int myplane_masks[1];
int mypixelvalues[MYMAXCOLORS];
Colormap mycolormap;
Colormap defaultmap;
XStandardColormap standardcolormap;
XColor mycolors[MYMAXCOLORS];
XColor origcolors[MYMAXCOLORS];
XColor origcolor;
XColor newcolor;
/******************************************************************/
display = XOpenDisplay(NULL);
/* XGrabServer(display); */
defaultscreen = DefaultScreen(display);
defaultvisual = DefaultVisual(display, defaultscreen);
defaultmap = DefaultColormap(display, defaultscreen);
rootwin = RootWindow(display,defaultscreen);
XGetStandardColormap(display, rootwin, &standardcolormap, XA_RGB_DEFAULT_MAP);
printf("Standard Colormap ID : 0x%lx\n ", standardcolormap.colormap);
printf("Default Colormap ID : 0x%lx\n ",defaultmap);
display_width = DisplayWidth (display, defaultscreen);
display_height = DisplayHeight(display, defaultscreen);
x = display_width/3;
y = display_height/3;
width = display_width/3;
height = display_height/4;
win = XCreateSimpleWindow(display, rootwin,
x, y, width, height, borderwidth,
BlackPixel(display,defaultscreen),
WhitePixel(display,defaultscreen));
mycolormap = XCreateColormap (display, win, defaultvisual, AllocAll);
XAllocColorCells (display, mycolormap, False, myplane_masks, 0, mypixelvalues, MYMAXCOLORS);
for ( i=0; i < MYMAXCOLORS; i++) origcolors[i].pixel=i;
XQueryColors (display, defaultmap, origcolors, MYMAXCOLORS);
for ( i=0; i < MYMAXCOLORS; i++) { origcolors[i].red = origcolors[i].blue; origcolors[i].green = origcolors[i].blue; };
XStoreColors (display, mycolormap, origcolors, MYMAXCOLORS);
XSetWindowColormap (display, win, mycolormap);
/* Probably not necessary, because the Window Manager should do this ... */
XInstallColormap (display, mycolormap);
/* XSetCloseDownMode(display, RetainPermanent); */
/* XUngrabServer(display); */
XSelectInput (display, win, ExposureMask | StructureNotifyMask | ColormapNotify | KeyPressMask);
XSetStandardProperties(display, win, "INIT", "INIT", NULL, NULL, NULL, NULL);
XMapWindow(display, win);
XFlush(display);
/* Possibly needed for the OpenLookWindowManager */
/*
printf("If we are running in ColorLockedMode then if a client \n");
printf("changes the WM_COLORMAP_WINDOWS property the OLWM should \n");
printf("have to respond with installing the first Window in the \n");
printf("list named by WM_COLORMAP_WINDOWS ... \n");
printf("CONTINUE ... ");
getchar(&dummy);
printf("\n");
windowlist[0] = win;
windowlist[1] = rootwin;
XSetWMColormapWindows (display, win, windowlist, 2);
XSetWMColormapWindows (display, rootwin, windowlist, 2);
*/
/* Neccessary, because in the CALITALK program we are going to get */
/* the colormapID of this initial colormap, via the attributes of */
/* the ROOTWINDOW, so this ROOTWINDOW does also need to have our */
/* user-defined colormap ! */
XSetWindowColormap (display, rootwin, mycolormap);
/*
CTRL2KeyEvent.type = KeyPress;
CTRL2KeyEvent.send_event = True;
CTRL2KeyEvent.display = display;
CTRL2KeyEvent.window = win;
CTRL2KeyEvent.root = rootwin;
CTRL2KeyEvent.state = ControlMask;
CTRL2KeyEvent.keycode = 84;
CTRL2Event.type = KeyPress;
CTRL2Event.xkey = CTRL2KeyEvent;
XSendEvent(display, win, False, KeyPress, CTRL2Event);
*/
XSync(display,False);
XFlush(display);
while (1)
{
XNextEvent(display, &report);
switch (report.type)
{
case KeyPress:
printf("\nOK KeyPress Event Received !!\n");
printf("KeyCode : %d\n",report.xkey.keycode);
report.xkey.keycode = 70;
/*
XSendEvent(display, win, True, NULL, report);
*/
XFlush(display);
break;
default:
break;
}
}
}
.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads