~unity-team/unity/lockscreen-indicators-debugging

« back to all changes in this revision

Viewing changes to lockscreen/LockScreenPanel.cpp

  • Committer: Marco Trevisan (Treviño)
  • Date: 2017-01-11 18:36:36 UTC
  • Revision ID: mail@3v1n0.net-20170111183636-4jkl15q3uy9jiwmn
Revert 4186

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
 
25
25
#include "LockScreenSettings.h"
26
26
#include "panel/PanelIndicatorsView.h"
27
 
#include "unity-shared/InputMonitor.h"
 
27
#include "unity-shared/CairoTexture.h"
28
28
#include "unity-shared/StaticCairoText.h"
29
29
#include "unity-shared/PanelStyle.h"
30
30
#include "unity-shared/RawPixel.h"
38
38
namespace
39
39
{
40
40
const RawPixel PADDING = 5_em;
41
 
const nux::Color BG_COLOR(0.1, 0.1, 0.1, 0.4);
42
41
}
43
42
 
44
43
using namespace indicator;
55
54
  auto* layout = new nux::HLayout();
56
55
  layout->SetLeftAndRightPadding(PADDING.CP(scale), 0);
57
56
  SetLayout(layout);
58
 
  UpdateSize();
 
57
 
 
58
  BuildTexture();
59
59
 
60
60
  // Add setting
61
61
  auto *hostname = new StaticCairoText(session_manager->HostName());
86
86
    hostname->SetScale(scale);
87
87
    static_cast<nux::HLayout*>(GetLayout())->SetLeftAndRightPadding(PADDING.CP(scale), 0);
88
88
    indicators_view_->SetMonitor(monitor);
89
 
    UpdateSize();
 
89
    BuildTexture();
90
90
    QueueRelayout();
91
91
  });
92
92
}
93
93
 
94
 
void Panel::UpdateSize()
 
94
void Panel::BuildTexture()
95
95
{
96
96
  int height = panel::Style::Instance().PanelHeight(monitor);
 
97
  nux::CairoGraphics context(CAIRO_FORMAT_ARGB32, 1, height);
 
98
  auto* cr = context.GetInternalContext();
 
99
  cairo_set_source_rgb(cr, 0.1, 0.1, 0.1);
 
100
  cairo_paint_with_alpha(cr, 0.4);
 
101
  bg_texture_ = texture_ptr_from_cairo_graphics(context);
 
102
 
97
103
  view_layout_->SetMinimumHeight(height);
98
104
  view_layout_->SetMaximumHeight(height);
99
105
}
186
192
    nux::GetWindowCompositor().GrabKeyboardAdd(static_cast<nux::BaseWindow*>(GetTopLevelViewWindow()));
187
193
  }
188
194
 
189
 
  auto& im = input::Monitor::Get();
190
 
  auto const& event_cb = sigc::mem_fun(this, &Panel::OnEntryEvent);
191
 
 
192
 
  if (active)
193
 
  {
194
 
    if (im.RegisterClient(input::Events::POINTER, event_cb))
195
 
      indicators_view_->ActivateEntry(entry_id);
196
 
  }
197
 
  else
198
 
  {
199
 
    im.UnregisterClient(event_cb);
200
 
    this->active = active;
201
 
  }
202
 
}
203
 
 
204
 
void Panel::OnEntryEvent(XEvent const& e)
205
 
{
206
 
  if (e.type == MotionNotify && GetAbsoluteGeometry().IsPointInside(e.xmotion.x, e.xmotion.y))
207
 
    indicators_view_->ActivateEntryAt(e.xmotion.x, e.xmotion.y);
 
195
  if (active && !track_menu_pointer_timeout_)
 
196
  {
 
197
    track_menu_pointer_timeout_.reset(new glib::Timeout(16));
 
198
    track_menu_pointer_timeout_->Run([this] {
 
199
      nux::Point const& mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
 
200
      if (tracked_pointer_pos_ != mouse)
 
201
      {
 
202
        if (GetAbsoluteGeometry().IsPointInside(mouse.x, mouse.y))
 
203
          indicators_view_->ActivateEntryAt(mouse.x, mouse.y);
 
204
 
 
205
        tracked_pointer_pos_ = mouse;
 
206
      }
 
207
 
 
208
      return true;
 
209
    });
 
210
  }
 
211
  else if (!active)
 
212
  {
 
213
    track_menu_pointer_timeout_.reset();
 
214
    tracked_pointer_pos_ = {-1, -1};
 
215
    this->active = false;
 
216
  }
208
217
}
209
218
 
210
219
void Panel::Draw(nux::GraphicsEngine& graphics_engine, bool force_draw)
218
227
  graphics_engine.PushClippingRectangle(geo);
219
228
  nux::GetPainter().PaintBackground(graphics_engine, geo);
220
229
 
221
 
  graphics_engine.QRP_Color(geo.x, geo.y, geo.width, geo.height, BG_COLOR);
 
230
  nux::TexCoordXForm texxform;
 
231
  texxform.SetWrap(nux::TEXWRAP_REPEAT, nux::TEXWRAP_CLAMP);
 
232
  graphics_engine.QRP_1Tex(geo.x, geo.y, geo.width, geo.height,
 
233
                           bg_texture_->GetDeviceTexture(), texxform,
 
234
                           nux::color::White);
 
235
 
222
236
  view_layout_->ProcessDraw(graphics_engine, force_draw);
223
237
 
224
238
  graphics_engine.PopClippingRectangle();