- region_add_bindmap((WRegion*)rootwin, ioncore_rootwin_bindmap);
-
- return rootwin;
-}
-
-
-static Atom net_virtual_roots=None;
-
-
-static WScreen *add_screen(WRootWin *rw, int id, const WRectangle *geom,
- bool useroot)
-{
- WScreen *scr;
- CARD32 p[1];
- WFitParams fp;
-
- fp.g=*geom;
- fp.mode=REGION_FIT_EXACT;
-
-#ifdef CF_ALWAYS_VIRTUAL_ROOT
- useroot=FALSE;
-#endif
-
- scr=create_screen(rw, id, &fp, useroot);
-
- if(scr==NULL)
- return NULL;
-
- region_set_manager((WRegion*)scr, (WRegion*)rw);
-
- region_map((WRegion*)scr);
-
- if(!useroot){
- p[0]=region_xwindow((WRegion*)scr);
- XChangeProperty(ioncore_g.dpy, WROOTWIN_ROOT(rw), net_virtual_roots,
- XA_WINDOW, 32, PropModeAppend, (uchar*)&(p[0]), 1);
- }
-
- return scr;
-}
-
-
-#ifdef CF_XINERAMA
-static bool xinerama_sanity_check(XineramaScreenInfo *xi, int nxi)
-{
- int i, j;
-
- for(i=0; i<nxi; i++){
- for(j=0; j<nxi; j++){
- if(i!=j &&
- (xi[j].x_org>=xi[i].x_org && xi[j].x_org<xi[i].x_org+xi[i].width) &&
- (xi[j].y_org>=xi[i].y_org && xi[j].y_org<xi[i].y_org+xi[i].height)){
- warn(TR("Xinerama sanity check failed; overlapping "
- "screens detected."));
- return FALSE;
- }
- }
-
- if(xi[i].width<=0 || xi[i].height<=0){
- warn(TR("Xinerama sanity check failed; zero size detected."));
- return FALSE;
- }
- }
- return TRUE;
-}
-#elif defined(CF_SUN_XINERAMA)
-static bool xinerama_sanity_check(XRectangle *monitors, int nxi)
-{
- int i, j;
-
- for(i=0; i<nxi; i++){
- for(j=0; j<nxi; j++){
- if(i!=j &&
- (monitors[j].x>=monitors[i].x &&
- monitors[j].x<monitors[i].x+monitors[i].width) &&
- (monitors[j].y>=monitors[i].y &&
- monitors[j].y<monitors[i].y+monitors[i].height)){
- warn(TR("Xinerama sanity check failed; overlapping "
- "screens detected."));
- return FALSE;
- }
- }
-
- if(monitors[i].width<=0 || monitors[i].height<=0){
- warn(TR("Xinerama sanity check failed; zero size detected."));
- return FALSE;
- }
- }
- return TRUE;
-}
-#endif
-
-
-WRootWin *ioncore_manage_rootwin(int xscr, bool noxinerama)
-{
- 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;
- }
-