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

« back to all changes in this revision

Viewing changes to panel/applets/appname/windowhelper.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:
25
25
// Local
26
26
 
27
27
// unity-2d
 
28
#include <dashsettings.h>
28
29
#include <debug_p.h>
29
30
#include <gconnector.h>
 
31
#include <screeninfo.h>
30
32
 
31
33
// Bamf
32
34
#include <bamf-matcher.h>
49
51
#include <X11/Xatom.h>
50
52
#include <QX11Info>
51
53
 
 
54
using namespace Unity2d;
 
55
 
52
56
struct WindowHelperPrivate
53
57
{
 
58
    void updateDashCanResize()
 
59
    {
 
60
        WnckScreen* screen = wnck_window_get_screen(m_window);
 
61
        int screenNumber = wnck_screen_get_number(screen);
 
62
        QRect rect = QApplication::desktop()->screenGeometry(screenNumber);
 
63
 
 
64
        /* If the screen size too small, we don't allow the Dash to be used
 
65
         * in Desktop mode (not fullscreen) */
 
66
        QSize minSize = DashSettings::minimumSizeForDesktop();
 
67
        if (rect.width() < minSize.width() &&
 
68
            rect.height() < minSize.height()) {
 
69
            m_dashCanResize = false;
 
70
        } else {
 
71
            m_dashCanResize = true;
 
72
        }
 
73
    }
 
74
 
 
75
    DashSettings* m_dashSettings;
54
76
    WnckWindow* m_window;
55
77
    GConnector m_connector;
 
78
    bool m_activeWindowIsDash;
 
79
    bool m_dashCanResize;
56
80
};
57
81
 
58
82
WindowHelper::WindowHelper(QObject* parent)
60
84
, d(new WindowHelperPrivate)
61
85
{
62
86
    d->m_window = 0;
 
87
    d->m_dashSettings = new DashSettings(this);
63
88
 
64
89
    WnckScreen* screen = wnck_screen_get_default();
65
90
    wnck_screen_force_update(screen);
98
123
    QMetaObject::invokeMethod(watcher, "nameChanged");
99
124
}
100
125
 
 
126
static void geometryChangedCB(GObject* window,
 
127
    WindowHelper*  watcher)
 
128
{
 
129
    QMetaObject::invokeMethod(watcher, "stateChanged");
 
130
}
 
131
 
101
132
void WindowHelper::update()
102
133
{
103
134
    BamfWindow* bamfWindow = BamfMatcher::get_default().active_window();
109
140
    }
110
141
    if (xid != 0) {
111
142
        d->m_window = wnck_window_get(xid);
 
143
 
 
144
        const char *name = wnck_window_get_name(d->m_window);
 
145
        d->m_activeWindowIsDash = qstrcmp(name, "unity-2d-places") == 0;
 
146
        if (d->m_activeWindowIsDash) {
 
147
            /* Since we are not really minimizing and maximizing the dash we
 
148
             * cannot rely on the wnck "state-changed" signal to be emitted;
 
149
             * instead, listen for the "geometry-changed" and emit our
 
150
             * stateChanged() from that. */
 
151
            d->m_connector.connect(G_OBJECT(d->m_window), "geometry-changed",
 
152
                                   G_CALLBACK(geometryChangedCB), this);
 
153
 
 
154
            d->updateDashCanResize();
 
155
        }
 
156
 
112
157
        d->m_connector.connect(G_OBJECT(d->m_window), "name-changed", G_CALLBACK(nameChangedCB), this);
113
158
        d->m_connector.connect(G_OBJECT(d->m_window), "state-changed", G_CALLBACK(stateChangedCB), this);
114
159
    }
121
166
    if (!d->m_window) {
122
167
        return false;
123
168
    }
124
 
    return wnck_window_is_maximized(d->m_window);
 
169
    if (d->m_activeWindowIsDash) {
 
170
        int x, y, width, height;
 
171
        wnck_window_get_geometry(d->m_window, &x, &y, &width, &height);
 
172
        const QRect windowGeometry(x, y, width, height);
 
173
        ScreenInfo* screenInfo = ScreenInfo::instance();
 
174
        return screenInfo->panelsFreeGeometry() == windowGeometry;
 
175
    } else {
 
176
        return wnck_window_is_maximized(d->m_window);
 
177
    }
125
178
}
126
179
 
127
180
bool WindowHelper::isMostlyOnScreen(int screen) const
147
200
    return true;
148
201
}
149
202
 
 
203
bool WindowHelper::dashIsVisible() const
 
204
{
 
205
    return d->m_window != 0 && d->m_activeWindowIsDash;
 
206
}
 
207
 
 
208
bool WindowHelper::dashCanResize() const
 
209
{
 
210
    return d->m_dashCanResize;
 
211
}
 
212
 
150
213
void WindowHelper::close()
151
214
{
152
215
    guint32 timestamp = QDateTime::currentDateTime().toTime_t();
155
218
 
156
219
void WindowHelper::minimize()
157
220
{
158
 
    wnck_window_minimize(d->m_window);
 
221
    if (!d->m_activeWindowIsDash) {
 
222
        wnck_window_minimize(d->m_window);
 
223
    }
 
224
}
 
225
 
 
226
void WindowHelper::maximize()
 
227
{
 
228
    if (d->m_activeWindowIsDash) {
 
229
        d->m_dashSettings->setFormFactor(DashSettings::Netbook);
 
230
    } else {
 
231
        /* This currently cannot happen, because the window buttons are not
 
232
         * shown in the panel for non maximized windows. It's here just for
 
233
         * completeness. */
 
234
        wnck_window_maximize(d->m_window);
 
235
    }
159
236
}
160
237
 
161
238
void WindowHelper::unmaximize()
162
239
{
163
 
    wnck_window_unmaximize(d->m_window);
 
240
    if (d->m_activeWindowIsDash) {
 
241
        d->m_dashSettings->setFormFactor(DashSettings::Desktop);
 
242
    } else {
 
243
        wnck_window_unmaximize(d->m_window);
 
244
    }
 
245
}
 
246
 
 
247
void WindowHelper::toggleMaximize()
 
248
{
 
249
    if (isMaximized()) {
 
250
        unmaximize();
 
251
    } else {
 
252
        maximize();
 
253
    }
164
254
}
165
255
 
166
256
void WindowHelper::drag(const QPoint& pos)