~canonical-dx-team/unity/unity.fix-ql-losing-focus

853.4.7 by Neil Jagdish Patel
Size and position systray window
1
/*
572.1.11 by Neil Jagdish Patel
Import the work done so far with Compiz
2
 * Copyright (C) 2010 Canonical Ltd
3
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License version 3 as
6
 * published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 * GNU General Public License for more details.
12
 *
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
 *
16
 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
17
 */
18
19
#include "Nux/Nux.h"
20
#include "Nux/HLayout.h"
21
#include "Nux/VLayout.h"
22
23
#include "NuxGraphics/GLThread.h"
24
#include "Nux/BaseWindow.h"
25
#include "Nux/WindowCompositor.h"
26
27
#include "PanelIndicatorObjectView.h"
28
29
#include "IndicatorObjectEntryProxy.h"
30
31
#include <glib.h>
32
33
PanelIndicatorObjectView::PanelIndicatorObjectView ()
669.3.1 by Neil Jagdish Patel
Move the menubar into it's own object, which is always created to at least fill up the space
34
: View (NUX_TRACKER_LOCATION),
35
  _layout (NULL),
853.4.15 by Neil Jagdish Patel
Add support for swtiching themes properly
36
  _proxy (NULL),
669.3.1 by Neil Jagdish Patel
Move the menubar into it's own object, which is always created to at least fill up the space
37
  _entries ()
38
{
39
}
40
41
PanelIndicatorObjectView::PanelIndicatorObjectView (IndicatorObjectProxy *proxy)
572.1.11 by Neil Jagdish Patel
Import the work done so far with Compiz
42
: View (NUX_TRACKER_LOCATION),
43
  _proxy (proxy),
44
  _entries ()
45
{
46
  g_debug ("IndicatorAdded: %s", _proxy->GetName ().c_str ());
784.2.1 by Didier Roche
remove double debug print, commented PADDING variable and use g_debug (even if not functional yet)
47
  _layout = new nux::HLayout ("", NUX_TRACKER_LOCATION);
572.1.11 by Neil Jagdish Patel
Import the work done so far with Compiz
48
49
  SetCompositionLayout (_layout);
50
  
784.2.3 by Didier Roche
set the default PanelIndicatorObjectView size to 12, has the default in nux is 32 and we have some PanelIndicatorObjectEntryView which are smaller than that (LP: #705803)
51
  // default in Nux is 32, we have some PanelIndicatorObjectEntryView which are smaller than that.
52
  // so redefining the minimum value for them.
53
  SetMinimumWidth (MINIMUM_INDICATOR_WIDTH);
54
 
572.1.11 by Neil Jagdish Patel
Import the work done so far with Compiz
55
  _proxy->OnEntryAdded.connect (sigc::mem_fun (this, &PanelIndicatorObjectView::OnEntryAdded));
56
  _proxy->OnEntryMoved.connect (sigc::mem_fun (this, &PanelIndicatorObjectView::OnEntryMoved));
57
  _proxy->OnEntryRemoved.connect (sigc::mem_fun (this, &PanelIndicatorObjectView::OnEntryRemoved));
58
}
59
60
PanelIndicatorObjectView::~PanelIndicatorObjectView ()
61
{
62
}
63
64
long
65
PanelIndicatorObjectView::ProcessEvent (nux::IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
66
{
67
  long ret = TraverseInfo;
68
853.4.7 by Neil Jagdish Patel
Size and position systray window
69
  if (_layout)
70
    ret = _layout->ProcessEvent (ievent, ret, ProcessEventInfo);
71
  return ret;
572.1.11 by Neil Jagdish Patel
Import the work done so far with Compiz
72
}
73
74
void
75
PanelIndicatorObjectView::Draw (nux::GraphicsEngine& GfxContext, bool force_draw)
572.3.2 by Jay Taoko
* Connected rendering to the data provided by RenderArgs
76
{
572.1.11 by Neil Jagdish Patel
Import the work done so far with Compiz
77
78
}
79
80
void
81
PanelIndicatorObjectView::DrawContent (nux::GraphicsEngine &GfxContext, bool force_draw)
572.1.21 by Jay Taoko
* Removed unused files VScrollBarSlim.cpp/.h
82
{
572.1.11 by Neil Jagdish Patel
Import the work done so far with Compiz
83
  GfxContext.PushClippingRectangle (GetGeometry() );
84
  if (_layout)
853.4.7 by Neil Jagdish Patel
Size and position systray window
85
    _layout->ProcessDraw (GfxContext, force_draw);
86
  GfxContext.PopClippingRectangle();
572.1.11 by Neil Jagdish Patel
Import the work done so far with Compiz
87
}
88
89
void
90
PanelIndicatorObjectView::OnEntryAdded (IndicatorObjectEntryProxy *proxy)
91
{
92
  PanelIndicatorObjectEntryView *view = new PanelIndicatorObjectEntryView (proxy);
93
  _layout->AddView (view, 0, nux::eCenter, nux::eFull);
94
  _layout->SetContentDistribution (nux::eStackRight);
784.2.2 by Didier Roche
stack PanelIndicatorObjectView on Right, this enables to not mess with Fitt even if we don't have the right width (LP: #705697)
95
572.1.11 by Neil Jagdish Patel
Import the work done so far with Compiz
96
  _entries.push_back (view);
97
98
  AddChild (view);
650.1.2 by Neil Jagdish Patel
Add introspection to the rest of the panel (some bits left still) and clean up the Introspect function to handle GetName() == NULL, and also to not Indent the children, rather keep them as child objects
99
100
  QueueRelayout();
871.4.17 by Neil Jagdish Patel
Switch to QueueRelayout where possible
101
  QueueDraw ();
102
}
572.1.11 by Neil Jagdish Patel
Import the work done so far with Compiz
103
104
void
105
PanelIndicatorObjectView::OnEntryMoved (IndicatorObjectEntryProxy *proxy)
106
{
107
  printf ("ERROR: Moving IndicatorObjectEntry not supported\n");
108
}
109
110
void
111
PanelIndicatorObjectView::OnEntryRemoved(IndicatorObjectEntryProxy *proxy)
112
{
113
  std::vector<PanelIndicatorObjectEntryView *>::iterator it;
114
  
115
  for (it = _entries.begin(); it != _entries.end(); it++)
116
  {
117
    PanelIndicatorObjectEntryView *view = static_cast<PanelIndicatorObjectEntryView *> (*it);
118
    if (view->_proxy == proxy)
119
      {
120
        RemoveChild (view);
650.1.2 by Neil Jagdish Patel
Add introspection to the rest of the panel (some bits left still) and clean up the Introspect function to handle GetName() == NULL, and also to not Indent the children, rather keep them as child objects
121
        _entries.erase (it);
572.1.11 by Neil Jagdish Patel
Import the work done so far with Compiz
122
        _layout->RemoveChildObject (view);
123
124
        break;
125
      }
126
  }
127
128
  QueueRelayout ();
871.4.17 by Neil Jagdish Patel
Switch to QueueRelayout where possible
129
  QueueDraw ();
130
}
572.1.11 by Neil Jagdish Patel
Import the work done so far with Compiz
131
650.1.2 by Neil Jagdish Patel
Add introspection to the rest of the panel (some bits left still) and clean up the Introspect function to handle GetName() == NULL, and also to not Indent the children, rather keep them as child objects
132
const gchar *
133
PanelIndicatorObjectView::GetName ()
134
{
135
  return _proxy->GetName ().c_str ();
136
}
137
138
const gchar *
650.1.5 by Neil Jagdish Patel
Clean up the Introspect function, implement GetChildsName() for some nicer results
139
PanelIndicatorObjectView::GetChildsName ()
140
{
141
  return "entries";
142
}
143
144
void
650.1.2 by Neil Jagdish Patel
Add introspection to the rest of the panel (some bits left still) and clean up the Introspect function to handle GetName() == NULL, and also to not Indent the children, rather keep them as child objects
145
PanelIndicatorObjectView::AddProperties (GVariantBuilder *builder)
146
{
147
  nux::Geometry geo = GetGeometry ();
148
149
  /* Now some props from ourselves */
150
  g_variant_builder_add (builder, "{sv}", "x", g_variant_new_int32 (geo.x));
151
  g_variant_builder_add (builder, "{sv}", "y", g_variant_new_int32 (geo.y));
152
  g_variant_builder_add (builder, "{sv}", "width", g_variant_new_int32 (geo.width));
153
  g_variant_builder_add (builder, "{sv}", "height", g_variant_new_int32 (geo.height));
154
}
155