~vanvugt/unity/fix-865006

« back to all changes in this revision

Viewing changes to panel/PanelController.cpp

  • Committer: Andrea Azzarone
  • Date: 2012-06-12 08:23:23 UTC
  • mfrom: (2400 unity)
  • mto: This revision was merged to the branch mainline in revision 2404.
  • Revision ID: azzaronea@gmail.com-20120612082323-zdw8jxwjcia8vi71
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
{
43
43
public:
44
44
  Impl();
45
 
  ~Impl();
46
45
 
47
46
  void FirstMenuShow();
48
47
  void QueueRedraw();
59
58
  void SetMenuShowTimings(int fadein, int fadeout, int discovery,
60
59
                          int discovery_fadein, int discovery_fadeout);
61
60
 
62
 
  void OnScreenChanged(int primary_monitor, std::vector<nux::Geometry>& monitors, Introspectable *iobj);
 
61
  void OnScreenChanged(unsigned int primary_monitor, std::vector<nux::Geometry>& monitors, Introspectable *iobj);
63
62
private:
64
 
  unity::PanelView* ViewForWindow(nux::BaseWindow* window) const;
 
63
  typedef nux::ObjectPtr<nux::BaseWindow> BaseWindowPtr;
 
64
 
 
65
  unity::PanelView* ViewForWindow(BaseWindowPtr const& window) const;
65
66
 
66
67
  static void WindowConfigureCallback(int            window_width,
67
68
                                      int            window_height,
69
70
                                      void*          user_data);
70
71
 
71
72
private:
72
 
  std::vector<nux::BaseWindow*> windows_;
 
73
  std::vector<BaseWindowPtr> windows_;
73
74
  float opacity_;
74
75
  bool opacity_maximized_toggle_;
75
76
  int menus_fadein_;
91
92
{
92
93
}
93
94
 
94
 
Controller::Impl::~Impl()
95
 
{
96
 
  for (auto window : windows_)
97
 
  {
98
 
    window->UnReference();
99
 
  }
100
 
}
101
 
 
102
95
std::vector<Window> Controller::Impl::GetTrayXids() const
103
96
{
104
97
  std::vector<Window> xids;
176
169
  }
177
170
}
178
171
 
179
 
PanelView* Controller::Impl::ViewForWindow(nux::BaseWindow* window) const
 
172
PanelView* Controller::Impl::ViewForWindow(BaseWindowPtr const& window) const
180
173
{
181
174
  nux::Layout* layout = window->GetLayout();
182
 
  std::list<nux::Area*>::iterator it = layout->GetChildren().begin();
 
175
  auto it = layout->GetChildren().begin();
183
176
 
184
177
  return static_cast<PanelView*>(*it);
185
178
}
186
179
 
187
180
// We need to put a panel on every monitor, and try and re-use the panels we already have
188
 
void Controller::Impl::OnScreenChanged(int primary_monitor,
 
181
void Controller::Impl::OnScreenChanged(unsigned int primary_monitor,
189
182
                                       std::vector<nux::Geometry>& monitors,
190
183
                                       Introspectable *iobj)
191
184
{
192
 
  std::vector<nux::BaseWindow*>::iterator it, eit = windows_.end();
193
 
  int n_monitors = monitors.size();
194
 
  int i = 0;
 
185
  std::vector<BaseWindowPtr>::iterator it;
 
186
  unsigned n_monitors = monitors.size();
 
187
  unsigned int i = 0;
195
188
 
196
 
  for (it = windows_.begin(); it != eit; ++it)
 
189
  for (it = windows_.begin(); it != windows_.end(); ++it)
197
190
  {
198
191
    if (i < n_monitors)
199
192
    {
243
236
      layout->SetVerticalExternalMargin(0);
244
237
      layout->SetHorizontalExternalMargin(0);
245
238
 
246
 
      nux::BaseWindow* window = new nux::BaseWindow("");
 
239
      BaseWindowPtr window(new nux::BaseWindow());
247
240
      nux::Geometry geo = monitors[i];
248
241
      geo.height = panel::Style::Instance().panel_height;
249
242
 
250
 
      window->SinkReference();
251
 
      window->SetConfigureNotifyCallback(&Impl::WindowConfigureCallback, window);
 
243
      window->SetConfigureNotifyCallback(&Impl::WindowConfigureCallback, window.GetPointer());
252
244
      window->SetBackgroundColor(nux::Color(0.0f, 0.0f, 0.0f, 0.0f));
253
245
      window->ShowWindow(true);
254
246
      window->EnableInputWindow(true, "panel", false, false);
266
258
    }
267
259
  }
268
260
 
269
 
  if ((int)windows_.size() > n_monitors)
 
261
  if (windows_.size() > n_monitors)
270
262
  {
271
 
    std::vector<nux::BaseWindow*>::iterator sit;
272
 
    for (sit = it; sit != eit; ++sit)
273
 
    {
274
 
      (*sit)->UnReference();
275
 
      LOG_DEBUG(logger) << "Removed extra Panel";
276
 
    }
277
 
 
 
263
    LOG_DEBUG(logger) << "Removed extra Panels";
278
264
    windows_.erase(it, windows_.end());
279
265
  }
280
266
}