~osomon/unity-2d/one-panel-per-screen

« back to all changes in this revision

Viewing changes to panel/app/panelmanager.cpp

  • Committer: Olivier Tilloy
  • Date: 2011-04-26 15:11:07 UTC
  • Revision ID: olivier.tilloy@canonical.com-20110426151107-x0lcwrw4my9g5936
Always update the position of the main panel (the one on the leftmost monitor) first.
This avoids instantiating several panels with the Ubuntu button and the systray.

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
void
112
112
PanelManager::onScreenCountChanged(int newCount)
113
113
{
114
 
    QDesktopWidget* desktop = QApplication::desktop();
115
 
    int size = m_panels.size();
116
 
    /* Update the position of existing panels, and instantiate new panels. */
117
 
    for (int i = 0; i < newCount; ++i) {
 
114
    if (newCount > 0) {
 
115
        QDesktopWidget* desktop = QApplication::desktop();
 
116
        int size = m_panels.size();
118
117
        Unity2dPanel* panel;
119
 
        if (i < size) {
120
 
            panel = m_panels[i];
 
118
 
 
119
        /* The first panel is always the one on the leftmost screen. */
 
120
        int leftmost = desktop->screenNumber(QPoint());
 
121
        if (size > 0) {
 
122
            panel = m_panels[0];
121
123
        } else {
122
 
            panel = instantiatePanel(i);
 
124
            panel = instantiatePanel(leftmost);
123
125
            m_panels.append(panel);
124
126
        }
125
127
        panel->show();
126
 
        panel->move(desktop->screenGeometry(i).topLeft());
 
128
        panel->move(desktop->screenGeometry(leftmost).topLeft());
 
129
 
 
130
        /* Update the position of other existing panels, and instantiate new
 
131
           panels as needed. */
 
132
        int i = 1;
 
133
        for (int screen = 0; screen < newCount; ++screen) {
 
134
            if (screen == leftmost) {
 
135
                continue;
 
136
            }
 
137
            if (i < size) {
 
138
                panel = m_panels[i];
 
139
            } else {
 
140
                panel = instantiatePanel(screen);
 
141
                m_panels.append(panel);
 
142
            }
 
143
            panel->show();
 
144
            panel->move(desktop->screenGeometry(screen).topLeft());
 
145
            ++i;
 
146
        }
127
147
    }
128
148
    /* Remove extra panels if any. */
129
149
    while (m_panels.size() > newCount) {