mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-21 05:18:06 +01:00
fixed problem with default visual ID for multi-screen setups by using multiple IDs for each screen
Since a single default visual ID cannot be used for multiple screens, thus Window Maker refused to start. There is now a global function for getting the default visual ID. The command line argument --visual-id can be a comma separated list of visual IDs for each screen. A default value is only set for the first screen.
This commit is contained in:
committed by
Carlos R. Mafra
parent
d8ef209c9a
commit
629b118767
@@ -148,4 +148,6 @@ char* GetProgramNameForWindow(Window win);
|
||||
|
||||
Bool GetCommandForPid(int pid, char ***argv, int *argc);
|
||||
|
||||
int getWVisualID(int screen);
|
||||
|
||||
#endif
|
||||
|
||||
103
src/main.c
103
src/main.c
@@ -145,9 +145,6 @@ char WProgramSigState = 0;
|
||||
char WProgramState = WSTATE_NORMAL;
|
||||
char WDelayedActionSet = 0;
|
||||
|
||||
/* temporary stuff */
|
||||
int wVisualID = -1;
|
||||
|
||||
/* notifications */
|
||||
const char *WMNManaged = "WMNManaged";
|
||||
const char *WMNUnmanaged = "WMNUnmanaged";
|
||||
@@ -178,8 +175,100 @@ extern int MonitorLoop(int argc, char **argv);
|
||||
|
||||
static Bool multiHead = True;
|
||||
|
||||
static int *wVisualID = NULL;
|
||||
static int wVisualID_len = 0;
|
||||
|
||||
static int real_main(int argc, char **argv);
|
||||
|
||||
int getWVisualID(int screen)
|
||||
{
|
||||
if (wVisualID == NULL)
|
||||
return -1;
|
||||
if (screen < 0 || screen >= wVisualID_len)
|
||||
return -1;
|
||||
|
||||
return wVisualID[screen];
|
||||
}
|
||||
|
||||
static void setWVisualID(int screen, int val)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (screen < 0)
|
||||
return;
|
||||
|
||||
if (wVisualID == NULL) {
|
||||
/* no array at all, alloc space for screen + 1 entries
|
||||
* and init with default value */
|
||||
wVisualID_len = screen + 1;
|
||||
wVisualID = (int *)malloc(wVisualID_len * sizeof(int));
|
||||
for (i = 0; i < wVisualID_len; i++) {
|
||||
wVisualID[i] = -1;
|
||||
}
|
||||
} else if (screen >= wVisualID_len) {
|
||||
/* larger screen number than previously allocated
|
||||
so enlarge array */
|
||||
int oldlen = wVisualID_len;
|
||||
|
||||
wVisualID_len = screen + 1;
|
||||
wVisualID = (int *)realloc(wVisualID, wVisualID_len * sizeof(int));
|
||||
for (i = oldlen; i < wVisualID_len; i++) {
|
||||
wVisualID[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
wVisualID[screen] = val;
|
||||
}
|
||||
|
||||
/*
|
||||
* this function splits a given string at the comma into tokens
|
||||
* and set the wVisualID variable to each parsed number
|
||||
*/
|
||||
static int initWVisualID(const char *user_str)
|
||||
{
|
||||
char *mystr = strdup(user_str);
|
||||
int cur_in_pos = 0;
|
||||
int cur_out_pos = 0;
|
||||
int cur_screen = 0;
|
||||
int error_found = 0;
|
||||
|
||||
for (;;) {
|
||||
/* check for delimiter */
|
||||
if (user_str[cur_in_pos] == '\0' || user_str[cur_in_pos] == ',') {
|
||||
int v;
|
||||
|
||||
mystr[cur_out_pos] = '\0';
|
||||
|
||||
if (sscanf(mystr, "%i", &v) != 1) {
|
||||
error_found = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
setWVisualID(cur_screen, v);
|
||||
|
||||
cur_screen++;
|
||||
cur_out_pos = 0;
|
||||
}
|
||||
|
||||
/* break in case last char has been consumed */
|
||||
if (user_str[cur_in_pos] == '\0')
|
||||
break;
|
||||
|
||||
/* if the current char is no delimiter put it into mystr */
|
||||
if (user_str[cur_in_pos] != ',') {
|
||||
mystr[cur_out_pos++] = user_str[cur_in_pos];
|
||||
}
|
||||
cur_in_pos++;
|
||||
}
|
||||
|
||||
free(mystr);
|
||||
|
||||
if (cur_screen == 0||error_found != 0)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Exit(int status)
|
||||
{
|
||||
#ifdef XSMP_ENABLED
|
||||
@@ -640,7 +729,7 @@ static int real_main(int argc, char **argv)
|
||||
wwarning(_("too few arguments for %s"), argv[i - 1]);
|
||||
exit(0);
|
||||
}
|
||||
if (sscanf(argv[i], "%i", &wVisualID) != 1) {
|
||||
if (initWVisualID(argv[i]) != 0) {
|
||||
wwarning(_("bad value for visualid: \"%s\""), argv[i]);
|
||||
exit(0);
|
||||
}
|
||||
@@ -722,7 +811,8 @@ static int real_main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (wVisualID < 0)
|
||||
|
||||
if (getWVisualID(0) < 0) {
|
||||
/*
|
||||
* If unspecified, use default visual instead of waiting
|
||||
* for wrlib/context.c:bestContext() that may end up choosing
|
||||
@@ -730,7 +820,8 @@ static int real_main(int argc, char **argv)
|
||||
* This is required to avoid all sort of corruptions when
|
||||
* composite is enabled, and at a depth other than 24.
|
||||
*/
|
||||
wVisualID = (int)DefaultVisual(dpy, DefaultScreen(dpy))->visualid;
|
||||
setWVisualID(0, (int)DefaultVisual(dpy, DefaultScreen(dpy))->visualid);
|
||||
}
|
||||
|
||||
/* check if the user specified a complete display name (with screen).
|
||||
* If so, only manage the specified screen */
|
||||
|
||||
@@ -538,7 +538,6 @@ WScreen *wScreenInit(int screen_number)
|
||||
WScreen *scr;
|
||||
XIconSize icon_size[1];
|
||||
RContextAttributes rattr;
|
||||
extern int wVisualID;
|
||||
long event_mask;
|
||||
XErrorHandler oldHandler;
|
||||
int i;
|
||||
@@ -625,9 +624,9 @@ WScreen *wScreenInit(int screen_number)
|
||||
rattr.standard_colormap_mode = RUseStdColormap;
|
||||
}
|
||||
|
||||
if (wVisualID >= 0) {
|
||||
if (getWVisualID(screen_number) >= 0) {
|
||||
rattr.flags |= RC_VisualID;
|
||||
rattr.visualid = wVisualID;
|
||||
rattr.visualid = getWVisualID(screen_number);
|
||||
}
|
||||
|
||||
scr->rcontext = RCreateContext(dpy, screen_number, &rattr);
|
||||
|
||||
Reference in New Issue
Block a user