Back to index

unity  6.0.0
PanelView.cpp
Go to the documentation of this file.
00001 // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
00002 /*
00003  * Copyright (C) 2010-2012 Canonical Ltd
00004  *
00005  * This program is free software: you can redistribute it and/or modify
00006  * it under the terms of the GNU General Public License version 3 as
00007  * published by the Free Software Foundation.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  *
00017  * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
00018  *              Marco Trevisan (TreviƱo) <3v1n0@ubuntu.com>
00019  */
00020 
00021 #include <Nux/Nux.h>
00022 #include <Nux/BaseWindow.h>
00023 #include <Nux/HLayout.h>
00024 #include <Nux/Layout.h>
00025 #include <Nux/WindowCompositor.h>
00026 
00027 #include <NuxGraphics/CairoGraphics.h>
00028 #include <NuxGraphics/ImageSurface.h>
00029 #include <NuxCore/Logger.h>
00030 #include <UnityCore/GLibWrapper.h>
00031 
00032 #include <NuxGraphics/GLThread.h>
00033 #include <NuxGraphics/RenderingPipe.h>
00034 
00035 #include <glib.h>
00036 
00037 #include "unity-shared/PanelStyle.h"
00038 #include "PanelIndicatorsView.h"
00039 #include <UnityCore/Variant.h>
00040 
00041 #include "unity-shared/UBusMessages.h"
00042 
00043 #include "PanelView.h"
00044 
00045 namespace
00046 {
00047 nux::logging::Logger logger("unity.PanelView");
00048 }
00049 
00050 namespace unity
00051 {
00052 
00053 NUX_IMPLEMENT_OBJECT_TYPE(PanelView);
00054 
00055 PanelView::PanelView(NUX_FILE_LINE_DECL)
00056   : View(NUX_FILE_LINE_PARAM)
00057   , _is_dirty(true)
00058   , _opacity_maximized_toggle(false)
00059   , _needs_geo_sync(false)
00060   , _is_primary(false)
00061   , _overlay_is_open(false)
00062   , _opacity(1.0f)
00063   , _monitor(0)
00064 {
00065   panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelView::ForceUpdateBackground));
00066 
00067   _bg_layer.reset(new nux::ColorLayer(nux::Color(0xff595853), true));
00068 
00069   nux::ROPConfig rop;
00070   rop.Blend = true;
00071   rop.SrcBlend = GL_ZERO;
00072   rop.DstBlend = GL_SRC_COLOR;
00073 
00074   _bg_darken_layer.reset(new nux::ColorLayer(nux::Color(0.9f, 0.9f, 0.9f, 1.0f), false, rop));
00075 
00076   _layout = new nux::HLayout("", NUX_TRACKER_LOCATION);
00077   _layout->SetContentDistribution(nux::eStackLeft);
00078 
00079   _menu_view = new PanelMenuView();
00080   AddPanelView(_menu_view, 1);
00081 
00082   SetCompositionLayout(_layout);
00083 
00084   _tray = new PanelTray();
00085   _layout->AddView(_tray, 0, nux::eCenter, nux::eFull);
00086   AddChild(_tray);
00087 
00088   _indicators = new PanelIndicatorsView();
00089   AddPanelView(_indicators, 0);
00090 
00091   _remote = indicator::DBusIndicators::Ptr(new indicator::DBusIndicators());
00092   _remote->on_object_added.connect(sigc::mem_fun(this, &PanelView::OnObjectAdded));
00093   _remote->on_object_removed.connect(sigc::mem_fun(this, &PanelView::OnObjectRemoved));
00094   _remote->on_entry_activate_request.connect(sigc::mem_fun(this, &PanelView::OnEntryActivateRequest));
00095   _remote->on_entry_activated.connect(sigc::mem_fun(this, &PanelView::OnEntryActivated));
00096   _remote->on_entry_show_menu.connect(sigc::mem_fun(this, &PanelView::OnEntryShowMenu));
00097 
00098   _ubus_manager.RegisterInterest(UBUS_BACKGROUND_COLOR_CHANGED, sigc::mem_fun(this, &PanelView::OnBackgroundUpdate));
00099   _ubus_manager.RegisterInterest(UBUS_OVERLAY_HIDDEN, sigc::mem_fun(this, &PanelView::OnOverlayHidden));
00100   _ubus_manager.RegisterInterest(UBUS_OVERLAY_SHOWN, sigc::mem_fun(this, &PanelView::OnOverlayShown));
00101 
00102   // request the latest colour from bghash
00103   _ubus_manager.SendMessage(UBUS_BACKGROUND_REQUEST_COLOUR_EMIT);
00104 
00105   _bg_effect_helper.owner = this;
00106 
00107   //FIXME (gord)- replace with async loading
00108   glib::Object<GdkPixbuf> pixbuf;
00109   glib::Error error;
00110   pixbuf = gdk_pixbuf_new_from_file(PKGDATADIR "/dash_sheen.png", &error);
00111   if (error)
00112   {
00113     LOG_WARN(logger) << "Unable to texture " << PKGDATADIR << "/dash_sheen.png" << ": " << error;
00114   }
00115   else
00116   {
00117     _panel_sheen.Adopt(nux::CreateTexture2DFromPixbuf(pixbuf, true));
00118   }
00119 }
00120 
00121 PanelView::~PanelView()
00122 {
00123   for (auto conn : _on_indicator_updated_connections)
00124     conn.disconnect();
00125 
00126   for (auto conn : _maximized_opacity_toggle_connections)
00127     conn.disconnect();
00128 
00129   indicator::EntryLocationMap locations;
00130   _remote->SyncGeometries(GetName() + boost::lexical_cast<std::string>(_monitor), locations);
00131 }
00132 
00133 Window PanelView::GetTrayXid() const
00134 {
00135   if (!_tray)
00136     return 0;
00137 
00138   return _tray->xid();
00139 }
00140 
00141 void PanelView::OnBackgroundUpdate(GVariant *data)
00142 {
00143   gdouble red, green, blue, alpha;
00144   g_variant_get(data, "(dddd)", &red, &green, &blue, &alpha);
00145 
00146   _bg_color.red = red;
00147   _bg_color.green = green;
00148   _bg_color.blue = blue;
00149   _bg_color.alpha = alpha;
00150 
00151   ForceUpdateBackground();
00152 }
00153 
00154 void PanelView::OnOverlayHidden(GVariant* data)
00155 {
00156   unity::glib::String overlay_identity;
00157   gboolean can_maximise = FALSE;
00158   gint32 overlay_monitor = 0;
00159   g_variant_get(data, UBUS_OVERLAY_FORMAT_STRING,
00160                 &overlay_identity, &can_maximise, &overlay_monitor);
00161 
00162   if (_monitor == overlay_monitor && overlay_identity.Str() == _active_overlay)
00163   {
00164     if (_opacity >= 1.0f)
00165       _bg_effect_helper.enabled = false;
00166 
00167     _overlay_is_open = false;
00168     _active_overlay = "";
00169     _menu_view->OverlayHidden();
00170     _indicators->OverlayHidden();
00171     SetAcceptKeyNavFocusOnMouseDown(true);
00172     ForceUpdateBackground();
00173   }
00174 }
00175 
00176 void PanelView::OnOverlayShown(GVariant* data)
00177 {
00178   unity::glib::String overlay_identity;
00179   gboolean can_maximise = FALSE;
00180   gint32 overlay_monitor = 0;
00181   g_variant_get(data, UBUS_OVERLAY_FORMAT_STRING,
00182                 &overlay_identity, &can_maximise, &overlay_monitor);
00183 
00184   if (_monitor == overlay_monitor)
00185   {
00186     _bg_effect_helper.enabled = true;
00187     _active_overlay = overlay_identity.Str();
00188     _overlay_is_open = true;
00189     _indicators->OverlayShown();
00190     _menu_view->OverlayShown();
00191     SetAcceptKeyNavFocusOnMouseDown(false);
00192     ForceUpdateBackground();
00193   }
00194 }
00195 
00196 void PanelView::AddPanelView(PanelIndicatorsView* child,
00197                              unsigned int stretchFactor)
00198 {
00199   _layout->AddView(child, stretchFactor, nux::eCenter, nux::eFull);
00200   auto conn = child->on_indicator_updated.connect(sigc::mem_fun(this, &PanelView::OnIndicatorViewUpdated));
00201   _on_indicator_updated_connections.push_back(conn);
00202   AddChild(child);
00203 }
00204 
00205 std::string PanelView::GetName() const
00206 {
00207   return "UnityPanel";
00208 }
00209 
00210 void PanelView::AddProperties(GVariantBuilder* builder)
00211 {
00212   variant::BuilderWrapper(builder)
00213   .add("backend", "remote")
00214   .add("monitor", _monitor)
00215   .add("active", IsActive())
00216   .add(GetAbsoluteGeometry());
00217 }
00218 
00219 void
00220 PanelView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
00221 {
00222   nux::Geometry geo = GetGeometry();
00223   nux::Geometry geo_absolute = GetAbsoluteGeometry();
00224   UpdateBackground();
00225 
00226   GfxContext.PushClippingRectangle(GetGeometry());
00227 
00228   if ((_overlay_is_open || (_opacity != 1.0f && _opacity != 0.0f)))
00229   {
00230     nux::Geometry blur_geo(geo_absolute.x, geo_absolute.y, geo.width, geo.height);
00231 
00232     if (BackgroundEffectHelper::blur_type != BLUR_NONE)
00233     {
00234       _bg_blur_texture = _bg_effect_helper.GetBlurRegion(blur_geo);
00235     }
00236     else
00237     {
00238       _bg_blur_texture = _bg_effect_helper.GetRegion(blur_geo);
00239     }
00240 
00241     if (_bg_blur_texture.IsValid() && (_overlay_is_open || _opacity != 1.0f))
00242     {
00243       nux::TexCoordXForm texxform_blur_bg;
00244       texxform_blur_bg.flip_v_coord = true;
00245       texxform_blur_bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
00246       texxform_blur_bg.uoffset = geo.x / static_cast<float>(geo_absolute.width);
00247       texxform_blur_bg.voffset = geo.y / static_cast<float>(geo_absolute.height);
00248 
00249       nux::ROPConfig rop;
00250       rop.Blend = false;
00251       rop.SrcBlend = GL_ONE;
00252       rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
00253 
00254       nux::Geometry bg_clip = geo;
00255       GfxContext.PushClippingRectangle(bg_clip);
00256 
00257 #ifndef NUX_OPENGLES_20
00258       if (GfxContext.UsingGLSLCodePath())
00259         gPainter.PushDrawCompositionLayer(GfxContext, geo,
00260                                           _bg_blur_texture,
00261                                           texxform_blur_bg,
00262                                           nux::color::White,
00263                                           _bg_color,
00264                                           nux::LAYER_BLEND_MODE_OVERLAY,
00265                                           true, rop);
00266       else
00267         gPainter.PushDrawTextureLayer(GfxContext, geo,
00268                                       _bg_blur_texture,
00269                                       texxform_blur_bg,
00270                                       nux::color::White,
00271                                       true,
00272                                       rop);
00273 #else
00274         gPainter.PushDrawCompositionLayer(GfxContext, geo,
00275                                           _bg_blur_texture,
00276                                           texxform_blur_bg,
00277                                           nux::color::White,
00278                                           _bg_color,
00279                                           nux::LAYER_BLEND_MODE_OVERLAY,
00280                                           true, rop);
00281 #endif
00282 
00283       GfxContext.PopClippingRectangle();
00284     }
00285 
00286     if (_overlay_is_open)
00287     {
00288       nux::GetPainter().RenderSinglePaintLayer(GfxContext, GetGeometry(), _bg_darken_layer.get());
00289     }
00290   }
00291 
00292   if (!_overlay_is_open || GfxContext.UsingGLSLCodePath() == false)
00293     nux::GetPainter().RenderSinglePaintLayer(GfxContext, GetGeometry(), _bg_layer.get());
00294 
00295   GfxContext.PopClippingRectangle();
00296 
00297   if (_needs_geo_sync)
00298   {
00299     SyncGeometries();
00300     _needs_geo_sync = false;
00301   }
00302 }
00303 
00304 void
00305 PanelView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
00306 {
00307   nux::Geometry const& geo = GetGeometry();
00308   int bgs = 1;
00309 
00310   GfxContext.PushClippingRectangle(GetGeometry());
00311 
00312   GfxContext.GetRenderStates().SetBlend(true);
00313   GfxContext.GetRenderStates().SetPremultipliedBlend(nux::SRC_OVER);
00314 
00315   if (_bg_blur_texture.IsValid() &&
00316       (_overlay_is_open || (_opacity != 1.0f && _opacity != 0.0f)))
00317   {
00318     nux::Geometry geo_absolute = GetAbsoluteGeometry ();
00319     nux::TexCoordXForm texxform_blur_bg;
00320     texxform_blur_bg.flip_v_coord = true;
00321     texxform_blur_bg.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
00322     texxform_blur_bg.uoffset = geo.x / static_cast<float>(geo_absolute.width);
00323     texxform_blur_bg.voffset = geo.y / static_cast<float>(geo_absolute.height);
00324 
00325     nux::ROPConfig rop;
00326     rop.Blend = false;
00327     rop.SrcBlend = GL_ONE;
00328     rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
00329 
00330 #ifndef NUX_OPENGLES_20
00331     if (GfxContext.UsingGLSLCodePath())
00332       gPainter.PushCompositionLayer(GfxContext, geo,
00333                                     _bg_blur_texture,
00334                                     texxform_blur_bg,
00335                                     nux::color::White,
00336                                     _bg_color,
00337                                     nux::LAYER_BLEND_MODE_OVERLAY,
00338                                     true,
00339                                     rop);
00340     else
00341       gPainter.PushTextureLayer(GfxContext, geo,
00342                                 _bg_blur_texture,
00343                                 texxform_blur_bg,
00344                                 nux::color::White,
00345                                 true,
00346                                 rop);
00347 
00348 #else
00349       gPainter.PushCompositionLayer(GfxContext, geo,
00350                                     _bg_blur_texture,
00351                                     texxform_blur_bg,
00352                                     nux::color::White,
00353                                     _bg_color,
00354                                     nux::LAYER_BLEND_MODE_OVERLAY,
00355                                     true,
00356                                     rop);
00357 #endif
00358     bgs++;
00359 
00360     if (_overlay_is_open)
00361     {
00362       nux::GetPainter().PushLayer(GfxContext, GetGeometry(), _bg_darken_layer.get());
00363       bgs++;
00364     }
00365   }
00366 
00367   if (!_overlay_is_open || GfxContext.UsingGLSLCodePath() == false)
00368     gPainter.PushLayer(GfxContext, GetGeometry(), _bg_layer.get());
00369 
00370   if (_overlay_is_open)
00371   {
00372     // apply the shine
00373     nux::TexCoordXForm texxform;
00374     texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
00375     texxform.SetWrap(nux::TEXWRAP_CLAMP, nux::TEXWRAP_CLAMP);
00376 
00377     nux::ROPConfig rop;
00378     rop.Blend = true;
00379     rop.SrcBlend = GL_DST_COLOR;
00380     rop.DstBlend = GL_ONE;
00381     nux::GetPainter().PushTextureLayer(GfxContext, GetGeometry(),
00382                                        _panel_sheen->GetDeviceTexture(),
00383                                        texxform,
00384                                        nux::color::White,
00385                                        false,
00386                                        rop);
00387   }
00388   _layout->ProcessDraw(GfxContext, force_draw);
00389 
00390   gPainter.PopBackground(bgs);
00391 
00392   GfxContext.GetRenderStates().SetBlend(false);
00393   GfxContext.PopClippingRectangle();
00394 }
00395 
00396 void
00397 PanelView::UpdateBackground()
00398 {
00399   nux::Geometry const& geo = GetGeometry();
00400 
00401   if (!_is_dirty && geo == _last_geo)
00402     return;
00403 
00404   _last_geo = geo;
00405   _is_dirty = false;
00406 
00407   guint32 maximized_win = _menu_view->GetMaximizedWindow();
00408 
00409   if (_overlay_is_open)
00410   {
00411     nux::ROPConfig rop;
00412     rop.Blend = true;
00413     rop.SrcBlend = GL_ONE;
00414     rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
00415     _bg_layer.reset(new nux::ColorLayer (_bg_color, true, rop));
00416   }
00417   else
00418   {
00419     WindowManager* wm = WindowManager::Default();
00420     double opacity = _opacity;
00421 
00422     if (_opacity_maximized_toggle && (wm->IsExpoActive() ||
00423         (maximized_win != 0 && !wm->IsWindowObscured(maximized_win))))
00424     {
00425       opacity = 1.0f;
00426     }
00427 
00428     nux::NBitmapData* bitmap = panel::Style::Instance().GetBackground(geo.width, geo.height, opacity);
00429     nux::BaseTexture* texture2D = nux::GetGraphicsDisplay()->GetGpuDevice()->CreateSystemCapableTexture();
00430 
00431     texture2D->Update(bitmap);
00432     delete bitmap;
00433 
00434     nux::TexCoordXForm texxform;
00435     texxform.SetTexCoordType(nux::TexCoordXForm::OFFSET_COORD);
00436     texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_REPEAT);
00437 
00438     nux::ROPConfig rop;
00439     rop.Blend = true;
00440     rop.SrcBlend = GL_ONE;
00441     rop.DstBlend = GL_ONE_MINUS_SRC_ALPHA;
00442     nux::Color col = nux::color::White;
00443 
00444     _bg_layer.reset(new nux::TextureLayer(texture2D->GetDeviceTexture(),
00445                                       texxform,
00446                                       col,
00447                                       true,
00448                                       rop));
00449     texture2D->UnReference();
00450   }
00451 
00452   NeedRedraw();
00453 }
00454 
00455 void PanelView::ForceUpdateBackground()
00456 {
00457   _is_dirty = true;
00458   UpdateBackground();
00459 
00460   _indicators->QueueDraw();
00461   _menu_view->QueueDraw();
00462   _tray->QueueDraw();
00463   QueueDraw();
00464 }
00465 
00466 //
00467 // Signals
00468 //
00469 void PanelView::OnObjectAdded(indicator::Indicator::Ptr const& proxy)
00470 {
00471   // Appmenu is treated differently as it needs to expand
00472   // We could do this in a more special way, but who has the time for special?
00473   if (proxy->IsAppmenu())
00474   {
00475     _menu_view->AddIndicator(proxy);
00476   }
00477   else
00478   {
00479     _indicators->AddIndicator(proxy);
00480   }
00481 
00482   ComputeContentSize();
00483   NeedRedraw();
00484 }
00485 
00486 void PanelView::OnObjectRemoved(indicator::Indicator::Ptr const& proxy)
00487 {
00488   if (proxy->IsAppmenu())
00489   {
00490     _menu_view->RemoveIndicator(proxy);
00491   }
00492   else
00493   {
00494     _indicators->RemoveIndicator(proxy);
00495   }
00496 
00497   ComputeContentSize();
00498   NeedRedraw();
00499 }
00500 
00501 void PanelView::OnIndicatorViewUpdated(PanelIndicatorEntryView* view)
00502 {
00503   _needs_geo_sync = true;
00504   ComputeContentSize();
00505 }
00506 
00507 void PanelView::OnMenuPointerMoved(int x, int y)
00508 {
00509   nux::Geometry const& geo = GetAbsoluteGeometry();
00510 
00511   if (geo.IsPointInside(x, y))
00512   {
00513     PanelIndicatorEntryView* view = nullptr;
00514 
00515     if (_menu_view->GetControlsActive())
00516       view = _menu_view->ActivateEntryAt(x, y);
00517 
00518     if (!view) _indicators->ActivateEntryAt(x, y);
00519 
00520     _menu_view->SetMousePosition(x, y);
00521   }
00522   else
00523   {
00524     _menu_view->SetMousePosition(-1, -1);
00525   }
00526 }
00527 
00528 void PanelView::OnEntryActivateRequest(std::string const& entry_id)
00529 {
00530   if (!IsActive())
00531     return;
00532 
00533   bool ret;
00534 
00535   ret = _menu_view->ActivateEntry(entry_id, 0);
00536   if (!ret) _indicators->ActivateEntry(entry_id, 0);
00537 }
00538 
00539 bool PanelView::TrackMenuPointer()
00540 {
00541   auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
00542   if (_tracked_pointer_pos != mouse)
00543   {
00544     OnMenuPointerMoved(mouse.x, mouse.y);
00545     _tracked_pointer_pos = mouse;
00546   }
00547 
00548   return true;
00549 }
00550 
00551 void PanelView::OnEntryActivated(std::string const& entry_id, nux::Rect const& geo)
00552 {
00553   bool active = (entry_id.size() > 0);
00554   if (active && !_track_menu_pointer_timeout)
00555   {
00556     //
00557     // Track menus being scrubbed at 60Hz (about every 16 millisec)
00558     // It might sound ugly, but it's far nicer (and more responsive) than the
00559     // code it replaces which used to capture motion events in another process
00560     // (unity-panel-service) and send them to us over dbus.
00561     // NOTE: The reason why we have to use a timer instead of tracking motion
00562     // events is because the motion events will never be delivered to this
00563     // process. All the motion events will go to unity-panel-service while
00564     // scrubbing because the active panel menu has (needs) the pointer grab.
00565     //
00566     _track_menu_pointer_timeout.reset(new glib::Timeout(16));
00567     _track_menu_pointer_timeout->Run(sigc::mem_fun(this, &PanelView::TrackMenuPointer));
00568   }
00569   else if (!active)
00570   {
00571     _track_menu_pointer_timeout.reset();
00572     _menu_view->NotifyAllMenusClosed();
00573     _tracked_pointer_pos = {-1, -1};
00574   }
00575 
00576   _ubus_manager.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST);
00577 }
00578 
00579 void PanelView::OnEntryShowMenu(std::string const& entry_id, unsigned int xid,
00580                                 int x, int y, unsigned int button,
00581                                 unsigned int timestamp)
00582 {
00583   Display* d = nux::GetGraphicsDisplay()->GetX11Display();
00584   XUngrabPointer(d, CurrentTime);
00585   XFlush(d);
00586 
00587   // --------------------------------------------------------------------------
00588   // FIXME: This is a workaround until the non-paired events issue is fixed in
00589   // nux
00590   XButtonEvent ev =
00591   {
00592     ButtonRelease,
00593     0,
00594     False,
00595     d,
00596     0,
00597     0,
00598     0,
00599     CurrentTime,
00600     x, y,
00601     x, y,
00602     0,
00603     Button1,
00604     True
00605   };
00606   XEvent* e = (XEvent*)&ev;
00607   nux::GetWindowThread()->ProcessForeignEvent(e, NULL);
00608   // --------------------------------------------------------------------------
00609 }
00610 
00611 //
00612 // Useful Public Methods
00613 //
00614 
00615 bool PanelView::FirstMenuShow() const
00616 {
00617   bool ret = false;
00618 
00619   if (!IsActive())
00620     return ret;
00621 
00622   ret = _menu_view->ActivateIfSensitive();
00623   if (!ret) _indicators->ActivateIfSensitive();
00624 
00625   return ret;
00626 }
00627 
00628 void PanelView::SetOpacity(float opacity)
00629 {
00630   if (_opacity == opacity)
00631     return;
00632 
00633   _opacity = opacity;
00634   _bg_effect_helper.enabled = (_opacity < 1.0f || _overlay_is_open);
00635 
00636   ForceUpdateBackground();
00637 }
00638 
00639 void PanelView::SetMenuShowTimings(int fadein, int fadeout, int discovery,
00640                                    int discovery_fadein, int discovery_fadeout)
00641 {
00642   _menu_view->SetMenuShowTimings(fadein, fadeout, discovery, discovery_fadein, discovery_fadeout);
00643 }
00644 
00645 void PanelView::SetOpacityMaximizedToggle(bool enabled)
00646 {
00647   if (_opacity_maximized_toggle != enabled)
00648   {
00649     if (enabled)
00650     {
00651       auto win_manager = WindowManager::Default();
00652       auto update_bg_lambda = [&](guint32) { ForceUpdateBackground(); };
00653       auto conn = &_maximized_opacity_toggle_connections;
00654 
00655       conn->push_back(win_manager->window_minimized.connect(update_bg_lambda));
00656       conn->push_back(win_manager->window_unminimized.connect(update_bg_lambda));
00657       conn->push_back(win_manager->window_maximized.connect(update_bg_lambda));
00658       conn->push_back(win_manager->window_restored.connect(update_bg_lambda));
00659       conn->push_back(win_manager->window_mapped.connect(update_bg_lambda));
00660       conn->push_back(win_manager->window_unmapped.connect(update_bg_lambda));
00661       conn->push_back(win_manager->initiate_expo.connect(
00662         sigc::mem_fun(this, &PanelView::ForceUpdateBackground)));
00663       conn->push_back(win_manager->terminate_expo.connect(
00664         sigc::mem_fun(this, &PanelView::ForceUpdateBackground)));
00665       conn->push_back(win_manager->compiz_screen_viewport_switch_ended.connect(
00666         sigc::mem_fun(this, &PanelView::ForceUpdateBackground)));
00667     }
00668     else
00669     {
00670       for (auto conn : _maximized_opacity_toggle_connections)
00671         conn.disconnect();
00672 
00673       _maximized_opacity_toggle_connections.clear();
00674     }
00675 
00676     _opacity_maximized_toggle = enabled;
00677     ForceUpdateBackground();
00678   }
00679 }
00680 
00681 bool PanelView::GetPrimary() const
00682 {
00683   return _is_primary;
00684 }
00685 
00686 void PanelView::SetPrimary(bool primary)
00687 {
00688   _is_primary = primary;
00689 }
00690 
00691 void PanelView::SyncGeometries()
00692 {
00693   indicator::EntryLocationMap locations;
00694   std::string panel_id = GetName() + boost::lexical_cast<std::string>(_monitor);
00695 
00696   if (_menu_view->GetControlsActive())
00697     _menu_view->GetGeometryForSync(locations);
00698 
00699   _indicators->GetGeometryForSync(locations);
00700   _remote->SyncGeometries(panel_id, locations);
00701 }
00702 
00703 void PanelView::SetMonitor(int monitor)
00704 {
00705   _monitor = monitor;
00706   _menu_view->SetMonitor(monitor);
00707 }
00708 
00709 int PanelView::GetMonitor() const
00710 {
00711   return _monitor;
00712 }
00713 
00714 bool PanelView::IsActive() const
00715 {
00716   return _menu_view->GetControlsActive();
00717 }
00718 
00719 } // namespace unity