Merge lp:~3v1n0/unity/panel-p-panel-view into lp:~3v1n0/unity/panel-p-menu-view

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merge reported by: Marco Trevisan (Treviño)
Merged at revision: not available
Proposed branch: lp:~3v1n0/unity/panel-p-panel-view
Merge into: lp:~3v1n0/unity/panel-p-menu-view
Diff against target: 764 lines (+159/-192)
2 files modified
plugins/unityshell/src/PanelView.cpp (+119/-147)
plugins/unityshell/src/PanelView.h (+40/-45)
To merge this branch: bzr merge lp:~3v1n0/unity/panel-p-panel-view
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+100393@code.launchpad.net

Description of the change

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

Looks fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/PanelView.cpp'
2--- plugins/unityshell/src/PanelView.cpp 2012-04-03 22:58:51 +0000
3+++ plugins/unityshell/src/PanelView.cpp 2012-04-05 02:16:28 +0000
4@@ -1,6 +1,6 @@
5 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
6 /*
7- * Copyright (C) 2010 Canonical Ltd
8+ * Copyright (C) 2010-2012 Canonical Ltd
9 *
10 * This program is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 3 as
12@@ -15,6 +15,7 @@
13 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 *
15 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
16+ * Marco Trevisan (Treviño) <3v1n0@ubuntu.com>
17 */
18
19 #include <Nux/Nux.h>
20@@ -37,7 +38,6 @@
21 #include "PanelIndicatorsView.h"
22 #include <UnityCore/Variant.h>
23
24-#include "ubus-server.h"
25 #include "UBusMessages.h"
26
27 #include "PanelView.h"
28@@ -53,35 +53,34 @@
29 NUX_IMPLEMENT_OBJECT_TYPE(PanelView);
30
31 PanelView::PanelView(NUX_FILE_LINE_DECL)
32- : View(NUX_FILE_LINE_PARAM),
33- _last_width(0),
34- _last_height(0),
35- _is_dirty(true),
36- _opacity(1.0f),
37- _opacity_maximized_toggle(false),
38- _is_primary(false),
39- _monitor(0),
40- _overlay_is_open(false)
41+ : View(NUX_FILE_LINE_PARAM)
42+ , _is_dirty(true)
43+ , _opacity_maximized_toggle(false)
44+ , _needs_geo_sync(false)
45+ , _is_primary(false)
46+ , _overlay_is_open(false)
47+ , _opacity(1.0f)
48+ , _monitor(0)
49 {
50- _needs_geo_sync = false;
51 panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelView::ForceUpdateBackground));
52
53- bg_layer_.reset(new nux::ColorLayer(nux::Color(0xff595853), true));
54+ _bg_layer.reset(new nux::ColorLayer(nux::Color(0xff595853), true));
55
56 nux::ROPConfig rop;
57 rop.Blend = true;
58 rop.SrcBlend = GL_ZERO;
59 rop.DstBlend = GL_SRC_COLOR;
60- bg_darken_layer_.reset(new nux::ColorLayer(nux::Color(0.9f, 0.9f, 0.9f, 1.0f), false, rop));
61+
62+ _bg_darken_layer.reset(new nux::ColorLayer(nux::Color(0.9f, 0.9f, 0.9f, 1.0f), false, rop));
63
64 _layout = new nux::HLayout("", NUX_TRACKER_LOCATION);
65+ _layout->SetContentDistribution(nux::eStackLeft);
66
67 _menu_view = new PanelMenuView();
68 AddPanelView(_menu_view, 1);
69
70 SetCompositionLayout(_layout);
71
72- // Pannel tray shouldn't be an indicator view
73 _tray = new PanelTray();
74 _layout->AddView(_tray, 0, nux::eCenter, nux::eFull);
75 AddChild(_tray);
76@@ -94,43 +93,29 @@
77 _remote->on_object_removed.connect(sigc::mem_fun(this, &PanelView::OnObjectRemoved));
78 _remote->on_entry_activate_request.connect(sigc::mem_fun(this, &PanelView::OnEntryActivateRequest));
79 _remote->on_entry_activated.connect(sigc::mem_fun(this, &PanelView::OnEntryActivated));
80- _remote->on_synced.connect(sigc::mem_fun(this, &PanelView::OnSynced));
81 _remote->on_entry_show_menu.connect(sigc::mem_fun(this, &PanelView::OnEntryShowMenu));
82
83- UBusServer *ubus = ubus_server_get_default();
84-
85- _handle_bg_color_update = ubus_server_register_interest(ubus, UBUS_BACKGROUND_COLOR_CHANGED,
86- (UBusCallback)&PanelView::OnBackgroundUpdate,
87- this);
88-
89- _handle_dash_hidden = ubus_server_register_interest(ubus, UBUS_OVERLAY_HIDDEN,
90- (UBusCallback)&PanelView::OnDashHidden,
91- this);
92-
93- _handle_dash_shown = ubus_server_register_interest(ubus, UBUS_OVERLAY_SHOWN,
94- (UBusCallback)&PanelView::OnDashShown,
95- this);
96- // request the latest colour from bghash
97- ubus_server_send_message (ubus, UBUS_BACKGROUND_REQUEST_COLOUR_EMIT, NULL);
98+ _ubus_manager.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, sigc::mem_fun(this, &PanelView::OnBackgroundUpdate));
99+ _ubus_manager.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &PanelView::OnOverlayHidden));
100+ _ubus_manager.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &PanelView::OnOverlayShown));
101+
102+ // request the latest colour from bghash
103+ _ubus_manager.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT);
104
105 _track_menu_pointer_id = 0;
106- bg_effect_helper_.owner = this;
107+ _bg_effect_helper.owner = this;
108
109 //FIXME (gord)- replace with async loading
110 glib::Object<GdkPixbuf> pixbuf;
111 glib::Error error;
112- pixbuf = gdk_pixbuf_new_from_file(PKGDATADIR"/dash_sheen.png", &error);
113+ pixbuf = gdk_pixbuf_new_from_file(PKGDATADIR "/dash_sheen.png", &error);
114 if (error)
115 {
116 LOG_WARN(logger) << "Unable to texture " << PKGDATADIR << "/dash_sheen.png" << ": " << error;
117 }
118 else
119 {
120- _panel_sheen = nux::CreateTexture2DFromPixbuf(pixbuf, true);
121- // TODO: when nux has the ability to create a smart pointer that takes
122- // ownership without adding a reference, we can remove the unref here. By
123- // unreferencing, the object is solely owned by the smart pointer.
124- _panel_sheen->UnReference();
125+ _panel_sheen.Adopt(nux::CreateTexture2DFromPixbuf(pixbuf, true));
126 }
127 }
128
129@@ -138,10 +123,6 @@
130 {
131 if (_track_menu_pointer_id)
132 g_source_remove(_track_menu_pointer_id);
133- UBusServer *ubus = ubus_server_get_default();
134- ubus_server_unregister_interest(ubus, _handle_bg_color_update);
135- ubus_server_unregister_interest(ubus, _handle_dash_hidden);
136- ubus_server_unregister_interest(ubus, _handle_dash_shown);
137
138 for (auto conn : _on_indicator_updated_connections)
139 conn.disconnect();
140@@ -153,23 +134,28 @@
141 _remote->SyncGeometries(GetName() + boost::lexical_cast<std::string>(_monitor), locations);
142 }
143
144-unsigned int PanelView::GetTrayXid ()
145+Window PanelView::GetTrayXid() const
146 {
147 if (!_tray)
148 return 0;
149
150- return _tray->xid ();
151+ return _tray->xid();
152 }
153
154-void PanelView::OnBackgroundUpdate (GVariant *data, PanelView *self)
155+void PanelView::OnBackgroundUpdate(GVariant *data)
156 {
157 gdouble red, green, blue, alpha;
158 g_variant_get(data, "(dddd)", &red, &green, &blue, &alpha);
159- self->_bg_color = nux::Color (red, green, blue, alpha);
160- self->ForceUpdateBackground();
161+
162+ _bg_color.red = red;
163+ _bg_color.green = green;
164+ _bg_color.blue = blue;
165+ _bg_color.alpha = alpha;
166+
167+ ForceUpdateBackground();
168 }
169
170-void PanelView::OnDashHidden(GVariant* data, PanelView* self)
171+void PanelView::OnOverlayHidden(GVariant* data)
172 {
173 unity::glib::String overlay_identity;
174 gboolean can_maximise = FALSE;
175@@ -177,20 +163,20 @@
176 g_variant_get(data, UBUS_OVERLAY_FORMAT_STRING,
177 &overlay_identity, &can_maximise, &overlay_monitor);
178
179- if (self->_monitor == overlay_monitor &&
180- overlay_identity.Str() == self->_active_overlay)
181+ if (_monitor == overlay_monitor && overlay_identity.Str() == _active_overlay)
182 {
183- if (self->_opacity >= 1.0f)
184- self->bg_effect_helper_.enabled = false;
185- self->_overlay_is_open = false;
186- self->_active_overlay = "";
187- self->_menu_view->OverlayHidden();
188- self->_indicators->OverlayHidden();
189- self->ForceUpdateBackground();
190+ if (_opacity >= 1.0f)
191+ _bg_effect_helper.enabled = false;
192+
193+ _overlay_is_open = false;
194+ _active_overlay = "";
195+ _menu_view->OverlayHidden();
196+ _indicators->OverlayHidden();
197+ ForceUpdateBackground();
198 }
199 }
200
201-void PanelView::OnDashShown(GVariant* data, PanelView* self)
202+void PanelView::OnOverlayShown(GVariant* data)
203 {
204 unity::glib::String overlay_identity;
205 gboolean can_maximise = FALSE;
206@@ -198,14 +184,14 @@
207 g_variant_get(data, UBUS_OVERLAY_FORMAT_STRING,
208 &overlay_identity, &can_maximise, &overlay_monitor);
209
210- if (self->_monitor == overlay_monitor)
211+ if (_monitor == overlay_monitor)
212 {
213- self->bg_effect_helper_.enabled = true;
214- self->_overlay_is_open = true;
215- self->_active_overlay = overlay_identity.Str();
216- self->_menu_view->OverlayShown();
217- self->_indicators->OverlayShown();
218- self->ForceUpdateBackground();
219+ _bg_effect_helper.enabled = true;
220+ _active_overlay = overlay_identity.Str();
221+ _overlay_is_open = true;
222+ _indicators->OverlayShown();
223+ _menu_view->OverlayShown();
224+ ForceUpdateBackground();
225 }
226 }
227
228@@ -227,6 +213,8 @@
229 {
230 variant::BuilderWrapper(builder)
231 .add("backend", "remote")
232+ .add("monitor", _monitor)
233+ .add("active", IsActive())
234 .add(GetGeometry());
235 }
236
237@@ -242,15 +230,15 @@
238 if (BackgroundEffectHelper::blur_type != BLUR_NONE && (_overlay_is_open || (_opacity != 1.0f && _opacity != 0.0f)))
239 {
240 nux::Geometry blur_geo(geo_absolute.x, geo_absolute.y, geo.width, geo.height);
241- bg_blur_texture_ = bg_effect_helper_.GetBlurRegion(blur_geo);
242+ _bg_blur_texture = _bg_effect_helper.GetBlurRegion(blur_geo);
243
244- if (bg_blur_texture_.IsValid() && BackgroundEffectHelper::blur_type != BLUR_NONE && (_overlay_is_open || _opacity != 1.0f))
245+ if (_bg_blur_texture.IsValid() && BackgroundEffectHelper::blur_type != BLUR_NONE && (_overlay_is_open || _opacity != 1.0f))
246 {
247 nux::TexCoordXForm texxform_blur_bg;
248 texxform_blur_bg.flip_v_coord = true;
249 texxform_blur_bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
250- texxform_blur_bg.uoffset = ((float) geo.x) / geo_absolute.width;
251- texxform_blur_bg.voffset = ((float) geo.y) / geo_absolute.height;
252+ texxform_blur_bg.uoffset = geo.x / static_cast<float>(geo_absolute.width);
253+ texxform_blur_bg.voffset = geo.y / static_cast<float>(geo_absolute.height);
254
255 nux::ROPConfig rop;
256 rop.Blend = false;
257@@ -263,7 +251,7 @@
258 #ifndef NUX_OPENGLES_20
259 if (GfxContext.UsingGLSLCodePath())
260 gPainter.PushDrawCompositionLayer(GfxContext, geo,
261- bg_blur_texture_,
262+ _bg_blur_texture,
263 texxform_blur_bg,
264 nux::color::White,
265 _bg_color,
266@@ -271,14 +259,14 @@
267 true, rop);
268 else
269 gPainter.PushDrawTextureLayer(GfxContext, geo,
270- bg_blur_texture_,
271+ _bg_blur_texture,
272 texxform_blur_bg,
273 nux::color::White,
274 true,
275 rop);
276 #else
277 gPainter.PushDrawCompositionLayer(GfxContext, geo,
278- bg_blur_texture_,
279+ _bg_blur_texture,
280 texxform_blur_bg,
281 nux::color::White,
282 _bg_color,
283@@ -291,14 +279,12 @@
284
285 if (_overlay_is_open)
286 {
287- nux::GetPainter().RenderSinglePaintLayer(GfxContext, GetGeometry(), bg_darken_layer_.get());
288+ nux::GetPainter().RenderSinglePaintLayer(GfxContext, GetGeometry(), _bg_darken_layer.get());
289 }
290 }
291
292-
293-
294- if (_overlay_is_open == false)
295- nux::GetPainter().RenderSinglePaintLayer(GfxContext, GetGeometry(), bg_layer_.get());
296+ if (!_overlay_is_open)
297+ nux::GetPainter().RenderSinglePaintLayer(GfxContext, GetGeometry(), _bg_layer.get());
298
299 GfxContext.PopClippingRectangle();
300
301@@ -312,7 +298,7 @@
302 void
303 PanelView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
304 {
305- nux::Geometry geo = GetGeometry();
306+ nux::Geometry const& geo = GetGeometry();
307 int bgs = 1;
308
309 GfxContext.PushClippingRectangle(GetGeometry());
310@@ -320,14 +306,15 @@
311 GfxContext.GetRenderStates().SetBlend(true);
312 GfxContext.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
313
314- if (bg_blur_texture_.IsValid() && BackgroundEffectHelper::blur_type != BLUR_NONE && (_overlay_is_open || (_opacity != 1.0f && _opacity != 0.0f)))
315+ if (_bg_blur_texture.IsValid() && BackgroundEffectHelper::blur_type != BLUR_NONE &&
316+ (_overlay_is_open || (_opacity != 1.0f && _opacity != 0.0f)))
317 {
318 nux::Geometry geo_absolute = GetAbsoluteGeometry ();
319 nux::TexCoordXForm texxform_blur_bg;
320 texxform_blur_bg.flip_v_coord = true;
321 texxform_blur_bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
322- texxform_blur_bg.uoffset = ((float) geo.x) / geo_absolute.width;
323- texxform_blur_bg.voffset = ((float) geo.y) / geo_absolute.height;
324+ texxform_blur_bg.uoffset = geo.x / static_cast<float>(geo_absolute.width);
325+ texxform_blur_bg.voffset = geo.y / static_cast<float>(geo_absolute.height);
326
327 nux::ROPConfig rop;
328 rop.Blend = false;
329@@ -337,7 +324,7 @@
330 #ifndef NUX_OPENGLES_20
331 if (GfxContext.UsingGLSLCodePath())
332 gPainter.PushCompositionLayer(GfxContext, geo,
333- bg_blur_texture_,
334+ _bg_blur_texture,
335 texxform_blur_bg,
336 nux::color::White,
337 _bg_color,
338@@ -346,7 +333,7 @@
339 rop);
340 else
341 gPainter.PushTextureLayer(GfxContext, geo,
342- bg_blur_texture_,
343+ _bg_blur_texture,
344 texxform_blur_bg,
345 nux::color::White,
346 true,
347@@ -354,7 +341,7 @@
348
349 #else
350 gPainter.PushCompositionLayer(GfxContext, geo,
351- bg_blur_texture_,
352+ _bg_blur_texture,
353 texxform_blur_bg,
354 nux::color::White,
355 _bg_color,
356@@ -366,13 +353,13 @@
357
358 if (_overlay_is_open)
359 {
360- nux::GetPainter().PushLayer(GfxContext, GetGeometry(), bg_darken_layer_.get());
361+ nux::GetPainter().PushLayer(GfxContext, GetGeometry(), _bg_darken_layer.get());
362 bgs++;
363 }
364 }
365
366- if (_overlay_is_open == FALSE)
367- gPainter.PushLayer(GfxContext, GetGeometry(), bg_layer_.get());
368+ if (!_overlay_is_open)
369+ gPainter.PushLayer(GfxContext, GetGeometry(), _bg_layer.get());
370
371 if (_overlay_is_open)
372 {
373@@ -401,27 +388,14 @@
374 }
375
376 void
377-PanelView::PreLayoutManagement()
378-{
379- nux::View::PreLayoutManagement();
380-}
381-
382-long
383-PanelView::PostLayoutManagement(long LayoutResult)
384-{
385- return nux::View::PostLayoutManagement(LayoutResult);
386-}
387-
388-void
389 PanelView::UpdateBackground()
390 {
391- nux::Geometry geo = GetGeometry();
392+ nux::Geometry const& geo = GetGeometry();
393
394- if (!_is_dirty && geo.width == _last_width && geo.height == _last_height)
395+ if (!_is_dirty && geo == _last_geo)
396 return;
397
398- _last_width = geo.width;
399- _last_height = geo.height;
400+ _last_geo = geo;
401 _is_dirty = false;
402
403 guint32 maximized_win = _menu_view->GetMaximizedWindow();
404@@ -432,13 +406,15 @@
405 rop.Blend = true;
406 rop.SrcBlend = GL_ONE;
407 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
408- bg_layer_.reset(new nux::ColorLayer (_bg_color, true, rop));
409+ _bg_layer.reset(new nux::ColorLayer (_bg_color, true, rop));
410 }
411 else
412 {
413+ WindowManager* wm = WindowManager::Default();
414 double opacity = _opacity;
415- if (_opacity_maximized_toggle && maximized_win != 0 &&
416- !WindowManager::Default()->IsWindowObscured(maximized_win))
417+
418+ if (_opacity_maximized_toggle && (wm->IsExpoActive() ||
419+ (maximized_win != 0 && !wm->IsWindowObscured(maximized_win))))
420 {
421 opacity = 1.0f;
422 }
423@@ -459,7 +435,7 @@
424 rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
425 nux::Color col = nux::color::White;
426
427- bg_layer_.reset(new nux::TextureLayer(texture2D->GetDeviceTexture(),
428+ _bg_layer.reset(new nux::TextureLayer(texture2D->GetDeviceTexture(),
429 texxform,
430 col,
431 true,
432@@ -497,8 +473,6 @@
433 _indicators->AddIndicator(proxy);
434 }
435
436- _layout->SetContentDistribution(nux::eStackLeft);
437-
438 ComputeContentSize();
439 NeedRedraw();
440 }
441@@ -514,8 +488,6 @@
442 _indicators->RemoveIndicator(proxy);
443 }
444
445- _layout->SetContentDistribution(nux::eStackLeft);
446-
447 ComputeContentSize();
448 NeedRedraw();
449 }
450@@ -528,7 +500,7 @@
451
452 void PanelView::OnMenuPointerMoved(int x, int y)
453 {
454- nux::Geometry geo = GetAbsoluteGeometry();
455+ nux::Geometry const& geo = GetAbsoluteGeometry();
456
457 if (geo.IsPointInside(x, y))
458 {
459@@ -549,13 +521,13 @@
460
461 void PanelView::OnEntryActivateRequest(std::string const& entry_id)
462 {
463- if (!_menu_view->GetControlsActive())
464+ if (!IsActive())
465 return;
466
467 bool ret;
468
469- ret = _menu_view->ActivateEntry(entry_id);
470- if (!ret) _indicators->ActivateEntry(entry_id);
471+ ret = _menu_view->ActivateEntry(entry_id, 0);
472+ if (!ret) _indicators->ActivateEntry(entry_id, 0);
473 }
474
475 void PanelView::TrackMenuPointer()
476@@ -568,12 +540,6 @@
477 }
478 }
479
480-static gboolean track_menu_pointer(PanelView *self)
481-{
482- self->TrackMenuPointer();
483- return TRUE;
484-}
485-
486 void PanelView::OnEntryActivated(std::string const& entry_id, nux::Rect const& geo)
487 {
488 bool active = (entry_id.size() > 0);
489@@ -589,7 +555,11 @@
490 // process. All the motion events will go to unity-panel-service while
491 // scrubbing because the active panel menu has (needs) the pointer grab.
492 //
493- _track_menu_pointer_id = g_timeout_add(16, (GSourceFunc) track_menu_pointer, this);
494+ _track_menu_pointer_id = g_timeout_add(16, [] (gpointer data) -> gboolean {
495+ auto self = static_cast<PanelView*>(data);
496+ self->TrackMenuPointer();
497+ return TRUE;
498+ }, this);
499 }
500 else if (!active)
501 {
502@@ -602,12 +572,7 @@
503 _tracked_pointer_pos = {-1, -1};
504 }
505
506- ubus_server_send_message(ubus_server_get_default(), UBUS_PLACE_VIEW_CLOSE_REQUEST, NULL);
507-}
508-
509-void PanelView::OnSynced()
510-{
511- _needs_geo_sync = true;
512+ _ubus_manager.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST);
513 }
514
515 void PanelView::OnEntryShowMenu(std::string const& entry_id, unsigned int xid,
516@@ -645,11 +610,12 @@
517 //
518 // Useful Public Methods
519 //
520-bool PanelView::FirstMenuShow()
521+
522+bool PanelView::FirstMenuShow() const
523 {
524 bool ret = false;
525
526- if (!_menu_view->GetControlsActive())
527+ if (!IsActive())
528 return ret;
529
530 ret = _menu_view->ActivateIfSensitive();
531@@ -658,28 +624,24 @@
532 return ret;
533 }
534
535-void
536-PanelView::SetOpacity(float opacity)
537+void PanelView::SetOpacity(float opacity)
538 {
539 if (_opacity == opacity)
540 return;
541
542 _opacity = opacity;
543-
544- bg_effect_helper_.enabled = (_opacity < 1.0f || _overlay_is_open);
545+ _bg_effect_helper.enabled = (_opacity < 1.0f || _overlay_is_open);
546
547 ForceUpdateBackground();
548 }
549
550-void
551-PanelView::SetMenuShowTimings(int fadein, int fadeout, int discovery,
552- int discovery_fadein, int discovery_fadeout)
553+void PanelView::SetMenuShowTimings(int fadein, int fadeout, int discovery,
554+ int discovery_fadein, int discovery_fadeout)
555 {
556 _menu_view->SetMenuShowTimings(fadein, fadeout, discovery, discovery_fadein, discovery_fadeout);
557 }
558
559-void
560-PanelView::SetOpacityMaximizedToggle(bool enabled)
561+void PanelView::SetOpacityMaximizedToggle(bool enabled)
562 {
563 if (_opacity_maximized_toggle != enabled)
564 {
565@@ -695,6 +657,10 @@
566 conn->push_back(win_manager->window_restored.connect(update_bg_lambda));
567 conn->push_back(win_manager->window_mapped.connect(update_bg_lambda));
568 conn->push_back(win_manager->window_unmapped.connect(update_bg_lambda));
569+ conn->push_back(win_manager->initiate_expo.connect(
570+ sigc::mem_fun(this, &PanelView::ForceUpdateBackground)));
571+ conn->push_back(win_manager->terminate_expo.connect(
572+ sigc::mem_fun(this, &PanelView::ForceUpdateBackground)));
573 conn->push_back(win_manager->compiz_screen_viewport_switch_ended.connect(
574 sigc::mem_fun(this, &PanelView::ForceUpdateBackground)));
575 }
576@@ -711,20 +677,17 @@
577 }
578 }
579
580-bool
581-PanelView::GetPrimary()
582+bool PanelView::GetPrimary() const
583 {
584 return _is_primary;
585 }
586
587-void
588-PanelView::SetPrimary(bool primary)
589+void PanelView::SetPrimary(bool primary)
590 {
591 _is_primary = primary;
592 }
593
594-void
595-PanelView::SyncGeometries()
596+void PanelView::SyncGeometries()
597 {
598 indicator::EntryLocationMap locations;
599 std::string panel_id = GetName() + boost::lexical_cast<std::string>(_monitor);
600@@ -736,11 +699,20 @@
601 _remote->SyncGeometries(panel_id, locations);
602 }
603
604-void
605-PanelView::SetMonitor(int monitor)
606+void PanelView::SetMonitor(int monitor)
607 {
608 _monitor = monitor;
609 _menu_view->SetMonitor(monitor);
610 }
611
612+int PanelView::GetMonitor() const
613+{
614+ return _monitor;
615+}
616+
617+bool PanelView::IsActive() const
618+{
619+ return _menu_view->GetControlsActive();
620+}
621+
622 } // namespace unity
623
624=== modified file 'plugins/unityshell/src/PanelView.h'
625--- plugins/unityshell/src/PanelView.h 2012-03-29 03:22:41 +0000
626+++ plugins/unityshell/src/PanelView.h 2012-04-05 02:16:28 +0000
627@@ -36,6 +36,7 @@
628 #include "PanelMenuView.h"
629 #include "PanelTray.h"
630 #include "PanelIndicatorsView.h"
631+#include "UBusWrapper.h"
632
633 namespace unity
634 {
635@@ -47,11 +48,29 @@
636 PanelView(NUX_FILE_LINE_PROTO);
637 ~PanelView();
638
639+ void SetPrimary(bool primary);
640+ bool GetPrimary() const;
641+
642+ void SetMonitor(int monitor);
643+ int GetMonitor() const;
644+
645+ bool IsActive() const;
646+ bool FirstMenuShow() const;
647+
648+ void SetOpacity(float opacity);
649+ void SetOpacityMaximizedToggle(bool enabled);
650+ void SetMenuShowTimings(int fadein, int fadeout, int discovery,
651+ int discovery_fadein, int discovery_fadeout);
652+
653+ Window GetTrayXid() const;
654+
655+protected:
656 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw);
657 void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
658
659- void PreLayoutManagement();
660- long PostLayoutManagement(long LayoutResult);
661+ // Introspectable methods
662+ std::string GetName() const;
663+ void AddProperties(GVariantBuilder* builder);
664
665 void OnObjectAdded(indicator::Indicator::Ptr const& proxy);
666 void OnObjectRemoved(indicator::Indicator::Ptr const& proxy);
667@@ -59,78 +78,54 @@
668 void OnMenuPointerMoved(int x, int y);
669 void OnEntryActivateRequest(std::string const& entry_id);
670 void OnEntryActivated(std::string const& entry_id, nux::Rect const& geo);
671- void OnSynced();
672 void OnEntryShowMenu(std::string const& entry_id, unsigned int xid, int x, int y,
673 unsigned int button, unsigned int timestamp);
674
675- void SetPrimary(bool primary);
676- bool GetPrimary();
677- void SetMonitor(int monitor);
678-
679- bool FirstMenuShow();
680-
681- void SetOpacity(float opacity);
682- void SetOpacityMaximizedToggle(bool enabled);
683- void SetMenuShowTimings(int fadein, int fadeout, int discovery,
684- int discovery_fadein, int discovery_fadeout);
685-
686- void TrackMenuPointer();
687-
688- unsigned int GetTrayXid ();
689-
690-protected:
691- // Introspectable methods
692- std::string GetName() const;
693- void AddProperties(GVariantBuilder* builder);
694-
695 private:
696- static void OnBackgroundUpdate (GVariant *data, PanelView *self);
697- static void OnDashShown (GVariant *data, PanelView *self);
698- static void OnDashHidden (GVariant *data, PanelView *self);
699+ void OnBackgroundUpdate(GVariant *data);
700+ void OnOverlayShown(GVariant *data);
701+ void OnOverlayHidden(GVariant *data);
702
703 void UpdateBackground();
704 void ForceUpdateBackground();
705+ void TrackMenuPointer();
706 void SyncGeometries();
707 void AddPanelView(PanelIndicatorsView* child, unsigned int stretchFactor);
708
709-private:
710- typedef nux::ObjectPtr<nux::BaseTexture> BaseTexturePtr;
711 indicator::DBusIndicators::Ptr _remote;
712+
713 // No ownership is taken for these views, that is done by the AddChild method.
714-
715- PanelMenuView* _menu_view;
716- PanelTray* _tray;
717- PanelIndicatorsView* _indicators;
718+ PanelMenuView* _menu_view;
719+ PanelTray* _tray;
720+ PanelIndicatorsView* _indicators;
721
722 typedef std::unique_ptr<nux::AbstractPaintLayer> PaintLayerPtr;
723- PaintLayerPtr bg_layer_;
724- PaintLayerPtr bg_darken_layer_;
725- BaseTexturePtr _panel_sheen;
726- nux::HLayout* _layout;
727+ PaintLayerPtr _bg_layer;
728+ PaintLayerPtr _bg_darken_layer;
729+ nux::ObjectPtr<nux::BaseTexture> _panel_sheen;
730+ nux::HLayout* _layout;
731
732- int _last_width;
733- int _last_height;
734+ nux::Geometry _last_geo;
735
736 nux::Color _bg_color;
737 bool _is_dirty;
738- float _opacity;
739 bool _opacity_maximized_toggle;
740 bool _needs_geo_sync;
741 bool _is_primary;
742+ bool _overlay_is_open;
743+ float _opacity;
744 int _monitor;
745
746- bool _overlay_is_open;
747 std::string _active_overlay;
748- guint _handle_dash_hidden;
749- guint _handle_dash_shown;
750- guint _handle_bg_color_update;
751+
752 guint _track_menu_pointer_id;
753 nux::Point _tracked_pointer_pos;
754
755 std::vector<sigc::connection> _on_indicator_updated_connections;
756 std::vector<sigc::connection> _maximized_opacity_toggle_connections;
757- BackgroundEffectHelper bg_effect_helper_;
758- nux::ObjectPtr <nux::IOpenGLBaseTexture> bg_blur_texture_;
759+ BackgroundEffectHelper _bg_effect_helper;
760+ nux::ObjectPtr<nux::IOpenGLBaseTexture> _bg_blur_texture;
761+ UBusManager _ubus_manager;
762 };
763
764 }

Subscribers

People subscribed via source and target branches

to all changes: