- WRootWin *rootwin;
- int nxi=0, fail=0;
-#ifdef CF_XINERAMA
- XineramaScreenInfo *xi=NULL;
- int i;
- int event_base, error_base;
-#elif defined(CF_SUN_XINERAMA)
- XRectangle monitors[MAXFRAMEBUFFERS];
- int i;
-#endif
-
- if(!noxinerama){
-#ifdef CF_XINERAMA
- if(XineramaQueryExtension(ioncore_g.dpy, &event_base, &error_base)){
- xi=XineramaQueryScreens(ioncore_g.dpy, &nxi);
-
- if(xi!=NULL && ioncore_g.rootwins!=NULL){
- warn(TR("Don't know how to get Xinerama information for "
- "multiple X root windows."));
- XFree(xi);
- xi=NULL;
- nxi=0;
- }
- }
-#elif defined(CF_SUN_XINERAMA)
- if(XineramaGetState(ioncore_g.dpy, xscr)){
- unsigned char hints[16];
- int num;
-
- if(XineramaGetInfo(ioncore_g.dpy, xscr, monitors, hints,
- &nxi)==0){
- warn(TR("Error retrieving Xinerama information."));
- nxi=0;
- }else{
- if(ioncore_g.rootwins!=NULL){
- warn(TR("Don't know how to get Xinerama information for "
- "multiple X root windows."));
- nxi=0;
- }
- }
- }
-#endif
- }
-
- rootwin=preinit_rootwin(xscr);
-
- if(rootwin==NULL){
-#ifdef CF_XINERAMA
- if(xi!=NULL)
- XFree(xi);
-#endif
- return NULL;
- }
-
- net_virtual_roots=XInternAtom(ioncore_g.dpy, "_NET_VIRTUAL_ROOTS", False);
- XDeleteProperty(ioncore_g.dpy, WROOTWIN_ROOT(rootwin), net_virtual_roots);
-
-#ifdef CF_XINERAMA
- if(xi!=NULL && nxi!=0 && xinerama_sanity_check(xi, nxi)){
- bool useroot=FALSE;
- WRectangle geom;
-
- for(i=0; i<nxi; i++){
- geom.x=xi[i].x_org;
- geom.y=xi[i].y_org;
- geom.w=xi[i].width;
- geom.h=xi[i].height;
- /*if(nxi==1)
- useroot=(geom.x==0 && geom.y==0);*/
- if(!add_screen(rootwin, i, &geom, useroot)){
- warn(TR("Unable to setup Xinerama screen %d."), i);
- fail++;
- }
- }
- XFree(xi);
- }else
-#elif defined(CF_SUN_XINERAMA)
- if(nxi!=0 && xinerama_sanity_check(monitors, nxi)){
- bool useroot=FALSE;
- WRectangle geom;
-
- for(i=0; i<nxi; i++){
- geom.x=monitors[i].x;
- geom.y=monitors[i].y;
- geom.w=monitors[i].width;
- geom.h=monitors[i].height;
- /*if(nxi==1)
- useroot=(geom.x==0 && geom.y==0);*/
- if(!add_screen(rootwin, i, &geom, useroot)){
- warn(TR("Unable to setup Xinerama screen %d."), i);
- fail++;
- }
- }
- }else
-#endif
- {
- nxi=1;
- if(!add_screen(rootwin, xscr, ®ION_GEOM(rootwin), TRUE))
- fail++;
- }
-
- if(fail==nxi){
- warn(TR("Unable to setup X screen %d."), xscr);
- destroy_obj((Obj*)rootwin);
- return NULL;
- }
-
- /* */ {
- /* TODO: typed LINK_ITEM */
- WRegion *tmp=(WRegion*)ioncore_g.rootwins;
- LINK_ITEM(tmp, (WRegion*)rootwin, p_next, p_prev);
- ioncore_g.rootwins=(WRootWin*)tmp;
- }
-
- xwindow_set_cursor(WROOTWIN_ROOT(rootwin), IONCORE_CURSOR_DEFAULT);
-
- return rootwin;