1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170 | === modified file 'src/ubuntumirclient/window.cpp'
--- src/ubuntumirclient/window.cpp 2015-02-06 11:26:14 +0000
+++ src/ubuntumirclient/window.cpp 2015-02-11 16:57:38 +0000
@@ -28,6 +28,7 @@
#include <QMutexLocker>
#include <QSize>
#include <QtMath>
+#include <QDebug>
// Platform API
#include <ubuntu/application/instance.h>
@@ -131,7 +132,7 @@
// FIXME - in order to work around https://bugs.launchpad.net/mir/+bug/1346633
// we need to guess the panel height (3GU + 2DP)
int UbuntuWindowPrivate::panelHeight()
-{
+{ return 0;
const int defaultGridUnit = 8;
int gridUnit = defaultGridUnit;
QByteArray gridUnitString = qgetenv("GRID_UNIT_PX");
@@ -198,7 +199,7 @@
if (d->state == Qt::WindowFullScreen) {
printf("UbuntuWindow - fullscreen geometry\n");
geometry = screen()->geometry();
- } else if (d->state == Qt::WindowMaximized) {
+ } else if (d->state == Qt::WindowMaximized && window()->type() == Qt::Window) {
printf("UbuntuWindow - maximized geometry\n");
geometry = screen()->availableGeometry();
/*
@@ -215,12 +216,28 @@
geometry = d->geometry;
}
- DLOG("[ubuntumirclient QPA] creating surface at (%d, %d) with size (%d, %d) with title '%s'\n",
- geometry.x(), geometry.y(), geometry.width(), geometry.height(), title.data());
-
- auto spec = createSpec(geometry.width(), geometry.height());
+ if (window()->parent() && window()->type() == Qt::Window) { qDebug() << "overriding to POPUP";
+ window()->setFlags(Qt::Popup);
+ }
+
+ // Qt thinks that it knows the absolute position of its window on screen. It uses that info to
+ // calculate the position for menus and other child surfaces. But with Mir, Qt has wrong idea
+ // so we need to always inform it it is positioned at (0, 0)
+ if (geometry.topLeft() != QPoint(0, 0) && (window()->type() == Qt::Window || window()->type() == Qt::Dialog)) { qDebug() << "regular surface reposition to 0,0";
+ geometry.moveTopLeft(QPoint(0, 0));
+ QWindowSystemInterface::handleGeometryChange(window(), geometry);
+ }
+
+ DLOG("[ubuntumirclient QPA] creating surface at (%d, %d) with size (%d, %d) with title '%s', type %d, parent %p, transientParent %p\n",
+ geometry.x(), geometry.y(), geometry.width(), geometry.height(), title.data(), window()->type(), window()->parent(), window()->transientParent());
+
+ auto spec = createSpec(geometry);
mir_surface_spec_set_name(spec, title.data());
+ if (d->state == Qt::WindowFullScreen) {
+ mir_surface_spec_set_fullscreen_on_output(spec, 0);
+ }
+
// Create platform window
mir_wait_for(mir_surface_create(spec, surfaceCreateCallback, this));
mir_surface_spec_release(spec);
@@ -228,11 +245,6 @@
DASSERT(d->surface != NULL);
d->createEGLSurface((EGLNativeWindowType)mir_surface_get_egl_native_window(d->surface));
- if (d->state == Qt::WindowFullScreen) {
- // TODO: We could set this on creation once surface spec supports it (mps already up)
- mir_wait_for(mir_surface_set_state(d->surface, mir_surface_state_fullscreen));
- }
-
// Window manager can give us a final size different from what we asked for
// so let's check what we ended up getting
{
@@ -260,46 +272,59 @@
return parent ? dynamic_cast<UbuntuWindow *>(parent->handle()) : nullptr;
}
-MirSurfaceSpec *UbuntuWindow::createSpec(int width, int height) const
+MirSurfaceSpec *UbuntuWindow::createSpec(const QRect &geometry) const
{
UAUiWindowRole role = role_for(window());
if (role == U_ON_SCREEN_KEYBOARD_ROLE)
{
- return mir_connection_create_spec_for_input_method(d->connection, width,
- height, mir_choose_default_pixel_format(d->connection));
+ return mir_connection_create_spec_for_input_method(d->connection, geometry.width(),
+ geometry.height(), mir_choose_default_pixel_format(d->connection));
}
Qt::WindowType type = window()->type();
auto pixel_format = mir_choose_default_pixel_format(d->connection);
if (type == Qt::Popup) {
- auto parent = transient_parent();
- if (parent) {
- auto pos = window()->geometry().topLeft();
- pos -= parent->geometry().topLeft();
- MirRectangle location{pos.x(), pos.y(), 0, 0};
+ // If surface has a parent or a transient parent, get the parent surface handle
+ UbuntuWindow *parentPlatformWindow = transient_parent();
+ if (!parentPlatformWindow
+ && window()->parent() && window()->parent()->handle()) {
+ parentPlatformWindow = static_cast<UbuntuWindow *>(window()->parent()->handle());
+ }
+
+ if (parentPlatformWindow) {
+ if (parentPlatformWindow->d->surface == nullptr) {
+ qDebug() << "Parent window not created yet as not marked visible by client. We need it now, so force creating it";
+ parentPlatformWindow->createWindow();
+ }
+
+ MirRectangle location{geometry.x(), geometry.y(), 0, 0};
return mir_connection_create_spec_for_menu(
- d->connection, width, height, pixel_format, parent->d->surface,
- &location, mir_edge_attachment_any);
- }
+ d->connection, geometry.width(), geometry.height(), pixel_format, parentPlatformWindow->d->surface,
+ &location, mir_edge_attachment_vertical);
+ } // else fallback to Regular
} else if (type == Qt::Dialog) {
auto parent = transient_parent();
if (parent) {
// Modal dialog
return mir_connection_create_spec_for_modal_dialog(
- d->connection, width, height, pixel_format, parent->d->surface);
+ d->connection, geometry.width(), geometry.height(), pixel_format, parent->d->surface);
} else {
// TODO: do Qt parentless dialogs have the same semantics as mir?
- return mir_connection_create_spec_for_dialog(d->connection, width, height, pixel_format);
+ return mir_connection_create_spec_for_dialog(d->connection, geometry.width(), geometry.height(), pixel_format);
}
}
+ qDebug() << "fall through to REGULAR";
return mir_connection_create_spec_for_normal_surface(
- d->connection, width, height, pixel_format);
+ d->connection, geometry.width(), geometry.height(), pixel_format);
}
void UbuntuWindow::moveResize(const QRect& rect)
{
- (void) rect;
+ DLOG("[ubuntumirclient QPA] resizing surface at (%d, %d) with size (%d, %d) - ERROR NOT SUPPORTED!!!\n",
+ rect.x(), rect.y(), rect.width(), rect.height());
+ d->geometry = rect;
+
// TODO: Not yet supported by mir.
}
@@ -433,6 +458,7 @@
if (visible) {
createWindow();
+
setWindowState(Qt::WindowNoState);
QWindowSystemInterface::handleExposeEvent(window(), QRect());
=== modified file 'src/ubuntumirclient/window.h'
--- src/ubuntumirclient/window.h 2015-02-05 13:24:35 +0000
+++ src/ubuntumirclient/window.h 2015-02-10 10:45:18 +0000
@@ -57,7 +57,7 @@
private:
void createWindow();
void moveResize(const QRect& rect);
- MirSurfaceSpec *createSpec(int width, int height) const;
+ MirSurfaceSpec *createSpec(const QRect &geometry) const;
UbuntuWindow *transient_parent() const;
UbuntuWindowPrivate *d;
|