+ int x = 0;
+ int y = 0;
+
+ if(exclusive)
+ {
+ // Disable other outputs for exclusive mode
+ for(list<Monitor>::iterator i=monitors.begin(); i!=monitors.end(); ++i)
+ if(&*i!=mode->monitor)
+ {
+ XRROutputInfo *o = XRRGetOutputInfo(priv->display, res, priv->monitors[i->index]);
+ if(o->crtc)
+ XRRSetCrtcConfig(priv->display, res, o->crtc, CurrentTime, 0, 0, 0, RR_Rotate_0, 0, 0);
+ XRRFreeOutputInfo(o);
+
+ i->current_mode = 0;
+ i->current_rotation = ROTATE_NORMAL;
+ i->x = 0;
+ i->y = 0;
+ }
+ }
+ else
+ {
+ const Monitor *left = mode->monitor->next_left;
+ while(left && !left->current_mode)
+ left = left->next_left;
+
+ if(left)
+ {
+ x = left->x+mode_width(*left->current_mode, left->current_rotation);
+ y = left->y;
+ }
+ }
+
+ XRRSetCrtcConfig(priv->display, res, crtc, CurrentTime, x, y, priv->modes[mode->index], rotation_to_sys(requested_rotation), &output, 1);
+
+ list<Monitor>::iterator i;
+ for(i=monitors.begin(); i!=monitors.end(); ++i)
+ if(&*i==mode->monitor)
+ {
+ i->current_mode = mode;
+ i->current_rotation = requested_rotation;
+ i->x = x;
+ i->y = y;
+
+ x += mode_width(*mode, requested_rotation);
+ ++i;
+ break;
+ }
+
+ for(; i!=monitors.end(); ++i)
+ if(i->current_mode)
+ {
+ XRROutputInfo *o = XRRGetOutputInfo(priv->display, res, priv->monitors[i->index]);
+ XRRSetCrtcConfig(priv->display, res, o->crtc, CurrentTime, x, y, priv->modes[i->current_mode->index], rotation_to_sys(i->current_rotation), &priv->monitors[i->index], 1);
+
+ XRRPanning panning;
+ panning.timestamp = CurrentTime;
+ panning.left = x;
+ panning.top = y;
+ panning.width = i->current_mode->width;
+ panning.height = i->current_mode->height;
+ panning.track_left = panning.left;
+ panning.track_top = panning.top;
+ panning.track_width = panning.width;
+ panning.track_height = panning.height;
+ panning.border_left = 0;
+ panning.border_top = 0;
+ panning.border_right = 0;
+ panning.border_bottom = 0;
+ XRRSetPanning(priv->display, res, o->crtc, &panning);
+
+ XRRFreeOutputInfo(o);
+
+ i->x = x;
+ i->y = y;
+
+ x += mode_width(*i->current_mode, i->current_rotation);
+ }
+
+ XRRFreeOutputInfo(output_info);
+ XRRFreeCrtcInfo(crtc_info);
+ XRRFreeScreenResources(res);