inline bool monitor_x_compare(const Msp::Graphics::Monitor &m1, const Msp::Graphics::Monitor &m2)
{
- if(m1.desktop_mode && !m2.desktop_mode)
+ if(m1.desktop_settings.mode && !m2.desktop_settings.mode)
return true;
- return m1.x<m2.x;
+ return m1.desktop_settings.x<m2.desktop_settings.x;
}
#endif
if(crtc)
{
- monitor.desktop_rotation = rotation_from_sys(crtc->rotation);
- monitor.current_rotation = monitor.desktop_rotation;
- monitor.x = crtc->x;
- monitor.y = crtc->y;
+ monitor.desktop_settings.rotation = rotation_from_sys(crtc->rotation);
+ monitor.desktop_settings.x = crtc->x;
+ monitor.desktop_settings.y = crtc->y;
}
if(res->outputs[i]==primary)
monitor.video_modes.push_back(&modes.back());
if(crtc && info->id==crtc->mode)
- {
- monitor.desktop_mode = &modes.back();
- monitor.current_mode = monitor.desktop_mode;
- }
+ monitor.desktop_settings.mode = &modes.back();
}
+ monitor.current_settings = monitor.desktop_settings;
+
XRRFreeOutputInfo(output);
if(crtc)
XRRFreeCrtcInfo(crtc);
monitors.sort(monitor_x_compare);
Monitor *prev_enabled = 0;
for(list<Monitor>::iterator i=monitors.begin(); i!=monitors.end(); ++i)
- if(i->desktop_mode)
+ if(i->desktop_settings.mode)
{
i->next_left = prev_enabled;
if(prev_enabled)
prev_enabled = &*i;
}
- if(!primary_monitor || !primary_monitor->desktop_mode)
+ if(!primary_monitor || !primary_monitor->desktop_settings.mode)
{
// XRandR didn't give a sensible primary monitor. Try to guess one.
unsigned largest = 0;
for(list<Monitor>::iterator i=monitors.begin(); i!=monitors.end(); ++i)
- if(i->desktop_mode)
+ if(const VideoMode *desktop_mode = i->desktop_settings.mode)
{
- unsigned size = i->desktop_mode->width*i->desktop_mode->height;
+ unsigned size = desktop_mode->width*desktop_mode->height;
if(size>largest)
{
largest = size;
VideoRotation requested_rotation = requested_mode.rotation;
if(requested_rotation==ROTATE_ANY)
- requested_rotation = mode->monitor->desktop_rotation;
+ requested_rotation = mode->monitor->desktop_settings.rotation;
XRRScreenResources *res = XRRGetScreenResources(priv->display, priv->root_window);
RROutput output = priv->monitors[mode->monitor->index];
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;
+ i->current_settings.mode = 0;
+ i->current_settings.rotation = ROTATE_NORMAL;
+ i->current_settings.x = 0;
+ i->current_settings.y = 0;
}
}
else
{
const Monitor *left = mode->monitor->next_left;
- while(left && !left->current_mode)
+ while(left && !left->current_settings.mode)
left = left->next_left;
if(left)
{
- x = left->x+mode_width(*left->current_mode, left->current_rotation);
- y = left->y;
+ const Monitor::Settings &cs = left->current_settings;
+ x = cs.x+mode_width(*cs.mode, cs.rotation);
+ y = cs.y;
}
}
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;
+ i->current_settings.mode = mode;
+ i->current_settings.rotation = requested_rotation;
+ i->current_settings.x = x;
+ i->current_settings.y = y;
x += mode_width(*mode, requested_rotation);
++i;
}
for(; i!=monitors.end(); ++i)
- if(i->current_mode)
+ if(i->current_settings.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);
+ XRRSetCrtcConfig(priv->display, res, o->crtc, CurrentTime, x, y, priv->modes[i->current_settings.mode->index], rotation_to_sys(i->current_settings.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.width = i->current_settings.mode->width;
+ panning.height = i->current_settings.mode->height;
panning.track_left = panning.left;
panning.track_top = panning.top;
panning.track_width = panning.width;
XRRFreeOutputInfo(o);
- i->x = x;
- i->y = y;
+ i->current_settings.x = x;
+ i->current_settings.y = y;
- x += mode_width(*i->current_mode, i->current_rotation);
+ x += mode_width(*i->current_settings.mode, i->current_settings.rotation);
}
XRRFreeOutputInfo(output_info);