~gerboland/qtubuntu/fix_1351024

« back to all changes in this revision

Viewing changes to src/ubuntumirclient/window.cpp

  • Committer: Gerry Boland
  • Date: 2014-08-08 14:04:13 UTC
  • Revision ID: gerry.boland@canonical.com-20140808140413-ehzc10l69o1arebo
Review comments addressed

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
public:
42
42
    void createEGLSurface(EGLNativeWindowType nativeWindow);
43
43
    void destroyEGLSurface();
 
44
    int panelHeight();
44
45
 
45
46
    UbuntuScreen* screen;
46
47
    EGLSurface eglSurface;
54
55
    QSize bufferSize;
55
56
    QSize targetBufferSize;
56
57
    QMutex mutex;
57
 
    int panelHeight; // FIXME - should be removed
58
58
};
59
59
 
60
60
static void eventCallback(void* context, const WindowEvent* event)
81
81
    static int id = 1;
82
82
    d->id = id++;
83
83
 
84
 
    // FIXME - in order to work around https://bugs.launchpad.net/mir/+bug/1346633
85
 
    // we need to guess the panel height (3GU + 2DP)
86
 
    const int defaultGridUnit = 8;
87
 
    int gridUnit = defaultGridUnit;
88
 
    QByteArray gridUnitString = qgetenv("GRID_UNIT_PX");
89
 
    if (!gridUnitString.isEmpty()) {
90
 
        bool ok;
91
 
        gridUnit = gridUnitString.toInt(&ok);
92
 
        if (!ok) {
93
 
            gridUnit = defaultGridUnit;
94
 
        }
95
 
    }
96
 
    qreal densityPixelRatio = static_cast<qreal>(gridUnit) / defaultGridUnit;
97
 
    d->panelHeight = gridUnit * 3 + qFloor(densityPixelRatio) * 2;
98
 
 
99
84
    // Use client geometry if set explicitly, use available screen geometry otherwise.
100
85
    d->geometry = window()->geometry() != screen->geometry() ?
101
86
        window()->geometry() : screen->availableGeometry();
131
116
    }
132
117
}
133
118
 
 
119
// FIXME - in order to work around https://bugs.launchpad.net/mir/+bug/1346633
 
120
// we need to guess the panel height (3GU + 2DP)
 
121
int UbuntuWindowPrivate::panelHeight()
 
122
{
 
123
    const int defaultGridUnit = 8;
 
124
    int gridUnit = defaultGridUnit;
 
125
    QByteArray gridUnitString = qgetenv("GRID_UNIT_PX");
 
126
    if (!gridUnitString.isEmpty()) {
 
127
        bool ok;
 
128
        gridUnit = gridUnitString.toInt(&ok);
 
129
        if (!ok) {
 
130
            gridUnit = defaultGridUnit;
 
131
        }
 
132
    }
 
133
    qreal densityPixelRatio = static_cast<qreal>(gridUnit) / defaultGridUnit;
 
134
    return gridUnit * 3 + qFloor(densityPixelRatio) * 2;
 
135
}
 
136
 
134
137
void UbuntuWindow::createWindow()
135
138
{
136
139
    DLOG("UbuntuWindow::createWindow (this=%p)", this);
147
150
    flags |= static_cast<uint>(IS_OPAQUE_FLAG);
148
151
 
149
152
    const QByteArray title = (!window()->title().isNull()) ? window()->title().toUtf8() : "Window 1"; // legacy title
 
153
    const int panelHeight = d->panelHeight();
150
154
 
151
155
    #if !defined(QT_NO_DEBUG)
152
 
    LOG("panelHeight: '%d'", d->panelHeight);
 
156
    LOG("panelHeight: '%d'", panelHeight);
153
157
    LOG("role: '%d'", role);
154
158
    LOG("flags: '%s'", (flags & static_cast<uint>(1)) ? "Opaque" : "NotOpaque");
155
159
    LOG("title: '%s'", title.constData());
171
175
         *
172
176
         * Assumption: this method only used on phone devices!
173
177
         */
174
 
        geometry.setY(d->panelHeight);
 
178
        geometry.setY(panelHeight);
175
179
    } else {
176
180
        printf("UbuntuWindow - regular geometry\n");
177
181
        geometry = d->geometry;
178
 
        geometry.setY(d->panelHeight);
 
182
        geometry.setY(panelHeight);
179
183
    }
180
184
 
181
185
    DLOG("[ubuntumirclient QPA] creating surface at (%d, %d) with size (%d, %d) with title '%s'\n",