Merge lp:~azzar1/unity/fix-973386 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 2270
Proposed branch: lp:~azzar1/unity/fix-973386
Merge into: lp:unity
Diff against target: 287 lines (+85/-47)
7 files modified
manual-tests/ShortcutsOverlay.txt (+14/-0)
plugins/unityshell/src/ShortcutController.cpp (+28/-12)
plugins/unityshell/src/ShortcutController.h (+3/-2)
plugins/unityshell/src/ShortcutView.cpp (+30/-0)
plugins/unityshell/src/ShortcutView.h (+5/-0)
plugins/unityshell/src/unityshell.cpp (+5/-22)
tests/autopilot/autopilot/tests/test_shortcut_hint.py (+0/-11)
To merge this branch: bzr merge lp:~azzar1/unity/fix-973386
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+101451@code.launchpad.net

Commit message

The keyboard shortcuts overlay bottom is truncated.

Description of the change

== Problem ==
The keyboard shortcuts overlay bottom is truncated. I think that this regression is due to Ubuntu fonts updates.

== Fix ==
Make the size of the shortcut overlay more dynamic.

== Test ==
Manual test added. Removed an obsolete AP test too.

This branch is partially inspired by https://code.launchpad.net/~3v1n0/unity/unity-dialog. Kudos to Marco Trevisan :)

UNBLOCK

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Appears to work.

review: Approve
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Cool.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'manual-tests/ShortcutsOverlay.txt'
2--- manual-tests/ShortcutsOverlay.txt 1970-01-01 00:00:00 +0000
3+++ manual-tests/ShortcutsOverlay.txt 2012-04-10 22:26:19 +0000
4@@ -0,0 +1,14 @@
5+The keyboard shortcuts overlay bottom is truncated
6+---------------------------
7+This test ensures that the keyboard shortcuts overlay bottom is not truncated.
8+(see lp:973386)
9+
10+Setup:
11+#. Make sure you have a monitor with a resoultion bigger than 1024x768.
12+
13+Action:
14+#. Move your mouse in that monitor.
15+#. Press "Super" key.
16+
17+Outcome:
18+ The keyboard shortcuts overlay bottom is not truncated.
19
20=== modified file 'plugins/unityshell/src/ShortcutController.cpp'
21--- plugins/unityshell/src/ShortcutController.cpp 2012-03-29 05:14:03 +0000
22+++ plugins/unityshell/src/ShortcutController.cpp 2012-04-10 22:26:19 +0000
23@@ -109,18 +109,22 @@
24 view_->background_color = bg_color_;
25 }
26
27-void Controller::Show()
28+bool Controller::Show()
29 {
30 if (show_timer_)
31- g_source_remove (show_timer_);
32+ g_source_remove(show_timer_);
33+ show_timer_ = 0;
34
35 if (enabled_)
36 {
37 show_timer_ = g_timeout_add(SUPER_TAP_DURATION, &Controller::OnShowTimer, this);
38 model_->Fill();
39 visible_ = true;
40+
41+ return true;
42 }
43
44+ return false;
45 }
46
47 gboolean Controller::OnShowTimer(gpointer data)
48@@ -132,14 +136,15 @@
49 return FALSE;
50 }
51
52- if (!self->view_window_)
53- self->ConstructView();
54+ self->EnsureView();
55
56- self->ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST);
57+ nux::Geometry geo;
58+ if (!self->view_->GetBaseGeometry(geo))
59+ return FALSE;
60+ self->view_window_->SetGeometry(geo);
61
62 if (self->visible_)
63 {
64- self->view_window_->SetGeometry(self->workarea_);
65 self->view_->SetupBackground(true);
66 self->fade_out_animator_.Stop();
67 self->fade_in_animator_.Start(self->view_window_->GetOpacity());
68@@ -167,17 +172,26 @@
69 view_window_->SetBackgroundColor(nux::Color(0x00000000));
70 }
71
72- main_layout_->AddView(view_.GetPointer(), 1);
73+ main_layout_->AddView(view_.GetPointer());
74
75 view_->SetupBackground(false);
76 view_window_->SetOpacity(0.0);
77 view_window_->ShowWindow(true);
78 }
79
80-void Controller::SetWorkspace(nux::Geometry const& geo)
81-{
82- workarea_ = geo;
83-}
84+void Controller::EnsureView()
85+{
86+ if (!view_window_)
87+ ConstructView();
88+}
89+
90+void Controller::SetAdjustment(int x, int y)
91+{
92+ EnsureView();
93+
94+ view_->SetAdjustment(x, y);
95+}
96+
97
98 void Controller::Hide()
99 {
100@@ -215,6 +229,9 @@
101 enabled_ = enabled;
102 }
103
104+//
105+// Introspection
106+//
107 std::string Controller::GetName() const
108 {
109 return "ShortcutController";
110@@ -223,7 +240,6 @@
111 void Controller::AddProperties(GVariantBuilder* builder)
112 {
113 unity::variant::BuilderWrapper(builder)
114- .add(workarea_)
115 .add("timeout_duration", SUPER_TAP_DURATION + FADE_DURATION)
116 .add("enabled", IsEnabled())
117 .add("about_to_show", (Visible() && !fade_out_animator_.IsRunning() && view_window_ && view_window_->GetOpacity() != 1.0f))
118
119=== modified file 'plugins/unityshell/src/ShortcutController.h'
120--- plugins/unityshell/src/ShortcutController.h 2012-03-29 05:14:03 +0000
121+++ plugins/unityshell/src/ShortcutController.h 2012-04-10 22:26:19 +0000
122@@ -48,13 +48,13 @@
123 ~Controller();
124
125 // Public Methods
126- void Show();
127+ bool Show();
128 void Hide();
129
130 bool Visible();
131 bool IsEnabled();
132
133- void SetWorkspace(nux::Geometry const& geo);
134+ void SetAdjustment(int x, int y);
135 void SetEnabled(bool enabled);
136
137 protected:
138@@ -64,6 +64,7 @@
139 private:
140 // Private Methods
141 void ConstructView();
142+ void EnsureView();
143 void OnBackgroundUpdate(GVariant* data);
144 void OnFadeInUpdated(double opacity);
145 void OnFadeInEnded();
146
147=== modified file 'plugins/unityshell/src/ShortcutView.cpp'
148--- plugins/unityshell/src/ShortcutView.cpp 2012-04-03 19:29:13 +0000
149+++ plugins/unityshell/src/ShortcutView.cpp 2012-04-10 22:26:19 +0000
150@@ -25,6 +25,7 @@
151
152 #include "LineSeparator.h"
153 #include "StaticCairoText.h"
154+#include "UScreen.h"
155
156 namespace unity
157 {
158@@ -66,6 +67,8 @@
159
160 View::View()
161 : ui::UnityWindowView()
162+ , x_adjustment_(0)
163+ , y_adjustment_(0)
164 {
165 layout_ = new nux::VLayout();
166 layout_->SetPadding(50, 38);
167@@ -113,6 +116,33 @@
168 return model_;
169 }
170
171+void View::SetAdjustment(int x, int y)
172+{
173+ x_adjustment_ = x;
174+ y_adjustment_ = y;
175+}
176+
177+bool View::GetBaseGeometry(nux::Geometry& geo)
178+{
179+ UScreen* uscreen = UScreen::GetDefault();
180+ int primary_monitor = uscreen->GetMonitorWithMouse();
181+ auto monitor_geo = uscreen->GetMonitorGeometry(primary_monitor);
182+
183+ int w = GetAbsoluteWidth();
184+ int h = GetAbsoluteHeight();
185+
186+ if (x_adjustment_ + w > monitor_geo.width ||
187+ y_adjustment_ + h > monitor_geo.height)
188+ return false;
189+
190+ geo.width = w;
191+ geo.height = h;
192+
193+ geo.x = monitor_geo.x + x_adjustment_ + (monitor_geo.width - geo.width - x_adjustment_) / 2;
194+ geo.y = monitor_geo.y + y_adjustment_ + (monitor_geo.height - geo.height - y_adjustment_) / 2;
195+ return true;
196+}
197+
198 nux::LinearLayout* View::CreateSectionLayout(const char* section_name)
199 {
200 nux::VLayout* layout = new nux::VLayout(NUX_TRACKER_LOCATION);
201
202=== modified file 'plugins/unityshell/src/ShortcutView.h'
203--- plugins/unityshell/src/ShortcutView.h 2012-04-03 19:20:08 +0000
204+++ plugins/unityshell/src/ShortcutView.h 2012-04-10 22:26:19 +0000
205@@ -48,6 +48,8 @@
206 ~View();
207
208 // Public methods
209+ bool GetBaseGeometry(nux::Geometry&);
210+ void SetAdjustment(int x, int y);
211 void SetModel(Model::Ptr model);
212 Model::Ptr GetModel();
213
214@@ -70,6 +72,9 @@
215 nux::VLayout* layout_;
216 nux::HLayout* columns_layout_;
217 std::vector<nux::VLayout*> columns_;
218+
219+ int x_adjustment_;
220+ int y_adjustment_;
221 };
222
223 } // namespace shortcut
224
225=== modified file 'plugins/unityshell/src/unityshell.cpp'
226--- plugins/unityshell/src/unityshell.cpp 2012-04-10 04:03:33 +0000
227+++ plugins/unityshell/src/unityshell.cpp 2012-04-10 22:26:19 +0000
228@@ -1560,32 +1560,15 @@
229
230 if (!shortcut_controller_->Visible() && shortcut_controller_->IsEnabled())
231 {
232- static nux::Geometry last_geo;
233- UScreen* uscreen = UScreen::GetDefault();
234- int primary_monitor = uscreen->GetMonitorWithMouse();
235- auto monitor_geo = uscreen->GetMonitorGeometry(primary_monitor);
236-
237- int width = 970;
238- int height = 680;
239 int launcher_width = optionGetIconSize() + 18;
240 int panel_height = panel_style_.panel_height;
241- int x = monitor_geo.x + launcher_width + (monitor_geo.width - launcher_width- width) / 2;
242- int y = monitor_geo.y + panel_height + (monitor_geo.height - panel_height - height) / 2;
243-
244- nux::Geometry geo (x, y, width, height);
245-
246- if (last_geo != geo)
247- {
248- shortcut_controller_->SetWorkspace(geo);
249- last_geo = geo;
250- }
251-
252- if (last_geo.x > monitor_geo.x and last_geo.y > monitor_geo.y)
253- {
254+
255+ if (shortcut_controller_->Show())
256+ {
257+ shortcut_controller_->SetAdjustment(launcher_width, panel_height);
258 EnableCancelAction(CancelActionTarget::SHORTCUT_HINT, true, action->key().modifiers());
259- shortcut_controller_->Show();
260 }
261- }
262+ }
263
264 return true;
265 }
266
267=== modified file 'tests/autopilot/autopilot/tests/test_shortcut_hint.py'
268--- tests/autopilot/autopilot/tests/test_shortcut_hint.py 2012-04-02 20:18:58 +0000
269+++ tests/autopilot/autopilot/tests/test_shortcut_hint.py 2012-04-10 22:26:19 +0000
270@@ -103,17 +103,6 @@
271 sleep(self.shortcut_hint.get_show_timeout())
272 self.assertThat(self.shortcut_hint.is_visible(), Equals(False))
273
274- def test_shortcut_hint_geometries(self):
275- """Test that the shortcut hint has the wanted geometries."""
276- sleep(.5)
277- self.shortcut_hint.show()
278- self.addCleanup(self.shortcut_hint.hide)
279- sleep(self.shortcut_hint.get_show_timeout())
280-
281- (x, y, w, h) = self.shortcut_hint.get_geometry()
282- self.assertThat(w, Equals(self.DEFAULT_WIDTH))
283- self.assertThat(h, Equals(self.DEFAULT_HEIGHT))
284-
285
286 class ShortcutHintInteractionsTests(BaseShortcutHintTests):
287 """Test the shortcuthint interactions with other Unity parts."""