~ubuntu-branches/ubuntu/precise/unity-2d/precise-security

« back to all changes in this revision

Viewing changes to libunity-2d-private/src/workspacesinfo.cpp

  • Committer: Package Import Robot
  • Author(s): Didier Roche, Didier Roche, Aurélien Gâteau
  • Date: 2012-01-13 09:12:36 UTC
  • mfrom: (1.1.25)
  • Revision ID: package-import@ubuntu.com-20120113091236-844z32uco10hs6ym
Tags: 5.2.0-0ubuntu1
[ Didier Roche ]
* New upstream release:
  - Select quicklist items with just one right click (LP: #688830)
  - Launcher - Dragging and dropping a running application in to the Trash
    should quit the application and (if the app is pinned to the Launcher)
    un-pin the application from the Launcher (LP: #870143)
  - Dash - "See more..." line should be base-aligned with section header
    (LP: #748101)
  - right click on the dash icon should display a list of the lenses
    (LP: #868452)
  - Top Bar - rename the "Desktop" title in the Top Bar (displayed when no
    window has focus)  to "Ubuntu Desktop" (LP: #869873)
  - Application title on quicklist should be bold (or more visible)
    (LP: #900400)
  - unity-2d-launcher crashed with SIGSEGV  when opening a folder on a CD
    (LP: #831868)
  - unity-2d-places crashed with SIGSEGV in QScriptValue::call()
    (LP: #836498)
  - unity-2d-launcher crashed with SIGSEGV in geis_finish() (LP: #850893)
  - unity-2d-places crashed with SIGABRT in raise() (LP: #857575)
  - unity-2d-launcher crashed with SIGSEGV in exit() (LP: #859596)
  - [spread] layout broken since bzr revision 799 of lp:unity-2d
    (LP: #900895)
  - [workspace switcher] keyboard navigation of workspace switcher broken
    for accessibility (LP: #744978)
  - [spread] workspace switcher performance is poor, especially on low
    powered CPUs (LP: #745764)
  - Launcher - the rendering of the BFB and Lens squircle does not match the
    design (LP: #838708)
  - [dash] Huge performance hit when scrolling search results with
    accessibility enabled (LP: #862956)
  - DBUS_STARTER_ADDRESS and DBUS_STARTER_BUS_TYPE aren't always unset from
    environment making gedit and possibly others fail to start (LP: #873027)
  - Win Key can not be disabled in Unity-2d (LP: #873580)
  - [dash] Unity-2d dash very slow to open (LP: #881756)
  - [tests] LauncherViewTest hanging (LP: #894380)
  - [tests] Unit tests failing due to lack of Xserver (LP: #894381)
  - [launcher] Alt+F1 broken: does not give the focus to the launcher's
    content (LP: #901505)
  - [tests] Add Automated User Experience testing (LP: #903495)
  - [workspace switcher] Performance can be poor when using the opengl
    backend because of window texture sizes that are not limited
    (LP: #808716)
  - [dash] no way to unmaximize (LP: #860400)
  - [launcher] In non-composite mode, background is black (LP: #879288)
  - [dash] Unity 2D shows 'Search' instead of 'Run Command' on ALT + F2
    (LP: #883392)
  - [launcher] Removing icon from launcher makes it hide immediately
    (LP: #884410)
  - OpenGL disabled regardless of use-opengl setting (LP: #887957)
  - if libdir does not equal lib (LP: #888164)
  - [launcher] Launcher stuck open while mouse moved to left corner of panel
    (LP: #892004)
  - [dash] Long results label are truncated instead of elided and a few
    pixels of the next line is visible (LP: #901491)
  - [launcher] Dash icon missing in PPA (LP: #903182)
  - [launcher] Tile context menu should appear at mouse click down event
    (LP: #813036)
  - [launcher] Trash tile highlight is truncated top and bottom
    (LP: #876589)
  - [dash] Text highlighting color is wrong (LP: #880222)
  - [launcher] left edge of panel should not reveal launcher (LP: #891636)
  - [dash] Word "Filter results" has underline when highlighted
    (LP: #893061)
  - [launcher] Alt+F1, change desktop, Alt+F1, hit Esc: launcher doesn't
    give away focus (LP: #897640)
  - Top Bar - rename the "Desktop" title in the Top Bar (displayed when no
    window has focus)  to "Ubuntu Desktop" (LP: #869873)
  - [launcher] Show desktop doesn't show launcher (LP: #898161)
  - [launcher] Context menu/tooltip not positioned at Tile center
    (LP: #898349)
  - The QT_LAYOUT_DIRECTION string needs a translator comment (LP: #863058)
  - unity panel menus don't stay open when clicked on second monitor
    (LP: #869196)
  - Dash- More fixes to layout and alignments (LP: #906235)
* debian/control:
  - bump libunitycore build-dep to 5.0.

[ Aurélien Gâteau ]
* debian/control:
  - bump build-dep versions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
 
85
85
void WorkspacesInfo::updateWorkspaceGeometry()
86
86
{
87
 
    int workspaceCount;
88
 
    int rows;
89
 
    int columns;
90
 
    Orientation orientation;
91
 
    Corner startingCorner;
 
87
    int workspaceCount = 0;
 
88
    Orientation orientation = WorkspacesInfo::OrientationHorizontal;
 
89
    int columns = 0;
 
90
    int rows = 0;
 
91
    int squareColumns;
 
92
    int squareRows;
 
93
    Corner startingCorner = WorkspacesInfo::CornerTopLeft;
 
94
    bool XWorkspaceCountNeedsUpdate = false;
 
95
    bool XLayoutNeedsUpdate = false;
 
96
 
 
97
    XWorkspaceCountNeedsUpdate = !getWorkspaceCountFromX(workspaceCount);
 
98
    XLayoutNeedsUpdate = !getWorkspaceLayoutFromX(orientation, columns, rows, startingCorner);
 
99
 
 
100
    /* If the number of workspaces was not set or set to 0 fallback to a default
 
101
       number of 4 workspaces. */
 
102
    if (workspaceCount == 0) {
 
103
        workspaceCount = 4;
 
104
        XWorkspaceCountNeedsUpdate = true;
 
105
    }
 
106
 
 
107
    /* Override the number of rows and columns possibly set by an external pager.
 
108
       The number of rows and columns is computed from the number of workspaces
 
109
       to make the layout square.
 
110
 
 
111
       We override external pagers because differentiating an external pager from
 
112
       oneself is hard. Example case where it matters:
 
113
       Starting with 9 workspaces, we decide on 3 rows and 3 columns. When the
 
114
       number of workspaces is then changed dynamically to 4 workspaces, without
 
115
       override, we would layout the 4 workspaces in a 3x3 grid.
 
116
    */
 
117
    squareColumns = ceil(sqrt((float)workspaceCount));
 
118
    squareRows = ceil((float) workspaceCount / (float) squareColumns);
 
119
 
 
120
    if (squareColumns != columns || squareRows != rows) {
 
121
        columns = squareColumns;
 
122
        rows = squareRows;
 
123
        XLayoutNeedsUpdate = true;
 
124
    }
 
125
 
 
126
    if (XWorkspaceCountNeedsUpdate) {
 
127
        setWorkspaceCountToX(workspaceCount);
 
128
    }
 
129
 
 
130
    if (XLayoutNeedsUpdate) {
 
131
        setWorkspaceLayoutToX(orientation, columns, rows, startingCorner);
 
132
    }
 
133
 
 
134
    updateWorkspaceGeometryProperties(workspaceCount, orientation, columns, rows, startingCorner);
 
135
}
 
136
 
 
137
bool WorkspacesInfo::getWorkspaceCountFromX(int& workspaceCount)
 
138
{
92
139
    unsigned long *result;
93
 
 
94
 
    /* First obtain the number of workspaces, that will be needed to
95
 
       also calculate some properties of the layout which could be missing
96
 
       from the property we will retrieve after this one */
97
140
    result = getX11IntProperty(_NET_NUMBER_OF_DESKTOPS, 1);
98
 
    if (result == NULL) {
99
 
        workspaceCount = 4;
100
 
    } else {
 
141
    if (result != NULL) {
101
142
        workspaceCount = result[0];
 
143
        XFree(result);
 
144
        return true;
 
145
    } else {
 
146
        return false;
102
147
    }
103
 
    XFree(result);
 
148
}
104
149
 
105
 
    /* Then ask X11 the layout of the workspaces. */
 
150
bool WorkspacesInfo::getWorkspaceLayoutFromX(Orientation& orientation, int& columns, int& rows, Corner& startingCorner)
 
151
{
 
152
    unsigned long *result;
106
153
    result = getX11IntProperty(_NET_DESKTOP_LAYOUT, 4);
107
154
    if (result != NULL) {
108
 
        /* If we read the values correctly (some pager or the user set them)
109
 
           then just use them. */
110
155
        orientation = (Orientation) result[0];
111
156
        columns = result[1];
112
157
        rows = result[2];
113
158
        startingCorner = (Corner) result[3];
114
 
 
115
 
        /* Perform some sanity checks, since it's possible according to
116
 
           the spec for rows or colums to be zero, and we are supposed to
117
 
           calculate these values ourselves by using the total count
118
 
        */
119
 
        if (rows == 0 && columns == 0) {
120
 
            rows = 2;
121
 
            columns = workspaceCount;
122
 
        } else {
123
 
            if (rows == 0) {
124
 
                rows = ceil((float) workspaceCount / (float) columns);
125
 
            } else if (columns == 0) {
126
 
                columns = ceil((float) workspaceCount / (float) rows);
127
 
            }
128
 
        }
129
 
 
130
159
        XFree(result);
 
160
        return true;
131
161
    } else {
132
 
        /* In this property does not exist (as is the case if you
133
 
           don't login into the regular gnome session before unity-2d),
134
 
           just fallback on reasonable defaults. */
135
 
        rows = 2;
136
 
        columns = ceil((float) workspaceCount / (float) rows);
137
 
        orientation = WorkspacesInfo::OrientationHorizontal;
138
 
        startingCorner = WorkspacesInfo::CornerTopLeft;
 
162
        return false;
139
163
    }
140
 
 
141
 
    /* Notify of changes, if any */
 
164
}
 
165
 
 
166
void WorkspacesInfo::setWorkspaceCountToX(int workspaceCount)
 
167
{
 
168
    unsigned long values[1];
 
169
    values[0] = workspaceCount;
 
170
    setX11IntProperty(_NET_NUMBER_OF_DESKTOPS, (unsigned char*)values, 1);
 
171
}
 
172
 
 
173
void WorkspacesInfo::setWorkspaceLayoutToX(Orientation orientation, int columns, int rows, Corner startingCorner)
 
174
{
 
175
    unsigned long values[4];
 
176
    values[0] = orientation;
 
177
    values[1] = columns;
 
178
    values[2] = rows;
 
179
    values[3] = startingCorner;
 
180
    setX11IntProperty(_NET_DESKTOP_LAYOUT, (unsigned char*)values, 4);
 
181
}
 
182
 
 
183
void WorkspacesInfo::updateWorkspaceGeometryProperties(int workspaceCount, Orientation orientation, int columns, int rows, Corner startingCorner)
 
184
{
142
185
    if (m_count != workspaceCount) {
143
186
        m_count = workspaceCount;
144
187
        Q_EMIT countChanged(m_count);
228
271
    return NULL;
229
272
}
230
273
 
 
274
/* Helper function to write the value of X11 window property of integer type of
 
275
   the length specified. */
 
276
void WorkspacesInfo::setX11IntProperty(Atom property, unsigned char *data, long length)
 
277
{
 
278
    XChangeProperty(QX11Info::display(), QX11Info::appRootWindow(),
 
279
                    property,
 
280
                    XA_CARDINAL, 32,
 
281
                    PropModeReplace,
 
282
                    data, length);
 
283
}
 
284
 
231
285
#include "workspacesinfo.moc"