Merge lp:~3v1n0/unity/panelmenu-fixes into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Merged at revision: 1617
Proposed branch: lp:~3v1n0/unity/panelmenu-fixes
Merge into: lp:unity
Diff against target: 1499 lines (+470/-231)
12 files modified
plugins/unityshell/src/PanelIndicatorsView.cpp (+55/-41)
plugins/unityshell/src/PanelIndicatorsView.h (+13/-1)
plugins/unityshell/src/PanelMenuView.cpp (+146/-86)
plugins/unityshell/src/PanelMenuView.h (+9/-7)
plugins/unityshell/src/PanelTitlebarGrabAreaView.cpp (+35/-33)
plugins/unityshell/src/PanelTitlebarGrabAreaView.h (+11/-10)
plugins/unityshell/src/PanelView.cpp (+20/-9)
plugins/unityshell/src/PanelView.h (+3/-0)
plugins/unityshell/src/PluginAdapter.cpp (+33/-1)
plugins/unityshell/src/WindowButtons.cpp (+14/-2)
plugins/unityshell/src/WindowManager.cpp (+5/-1)
services/panel-service.c (+126/-40)
To merge this branch: bzr merge lp:~3v1n0/unity/panelmenu-fixes
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Jason Smith (community) Approve
Gord Allott (community) Approve
Review via email: mp+76133@code.launchpad.net

Description of the change

Fixed lots of other PanelMenuView related bugs (see the linked list of "In Progress bugs" for reference).

In particular, I've also changed these things:
 - Moving to nux::GetGraphicsDisplay()->GetMouseScreenCoord() (instead of gdk functions,
   warning this needs nux bzr-453 or newer not to crash, thanks to Jay for fixing!)
 - Checking for mouse position after closing menus to hide/show them (bug bug #843670)
 - Checking for mouse position after dragging a window to to hide/show menus
 - Fix for PluginAdapter not to consider unmapped windows as maximized (bug #781215)
 - Panel-service: correctly close menus when releasing mouse outside a menu title (bug #844309)
 - Panel-service: cache the indicator entries geometry and use the values for checking mouse position
 - Don't redecorate windows on maximization drag (bug #838923)
 - panel-service: Remove id2entry_hash and use sscanf to parse the entries IDs
 - PanelView: track mouse position only when it has been changed (fix bug #834065)
 - PanelMenuView / PanelIndicatorsView: remove code duplication for adding an entry
 - Better mouse grab management using only PanelTitleGrabArea
 - PanelMenuView: even more checks to avoid to show/hide menus when we shouldn't
 - PanelView: sync geometries for real

See the related commit logs for more informations.

This branch, to work properly, needs the updated UnityCore code that I've pushed in my lp:~3v1n0/unity/menus-switching-hacks branch (for the entries geometry things), so in the case that the other branch isn't accepted, we need to port its UnityCore changes here.

PS: for the record, this is the previous merge request for this branch: https://code.launchpad.net/~3v1n0/unity/panelmenu-fixes/+merge/73622

To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote :

Has a merge conflict if you merge your other branch in first. Conflicts are non-trivial (at least for me to fix)

review: Needs Fixing
Revision history for this message
Gord Allott (gordallott) wrote :

looks okay from here +1

review: Approve
Revision history for this message
Jason Smith (jassmith) wrote :

Switching to approved

review: Approve
Revision history for this message
Neil J. Patel (njpatel) wrote :

Excellent work Marco, approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/unityshell/src/PanelIndicatorsView.cpp'
--- plugins/unityshell/src/PanelIndicatorsView.cpp 2011-09-20 17:25:06 +0000
+++ plugins/unityshell/src/PanelIndicatorsView.cpp 2011-09-25 12:09:24 +0000
@@ -21,14 +21,9 @@
21#include <Nux/Nux.h>21#include <Nux/Nux.h>
22#include <Nux/Area.h>22#include <Nux/Area.h>
23#include <Nux/HLayout.h>23#include <Nux/HLayout.h>
24#include <Nux/VLayout.h>
2524
26#include <NuxCore/Logger.h>25#include <NuxCore/Logger.h>
2726
28#include <NuxGraphics/GLThread.h>
29#include <Nux/BaseWindow.h>
30#include <Nux/WindowCompositor.h>
31
32#include "PanelIndicatorsView.h"27#include "PanelIndicatorsView.h"
3328
34#include <UnityCore/Variant.h>29#include <UnityCore/Variant.h>
@@ -55,9 +50,9 @@
5550
56PanelIndicatorsView::~PanelIndicatorsView()51PanelIndicatorsView::~PanelIndicatorsView()
57{52{
58 for (auto it = indicators_connections_.begin(); it != indicators_connections_.end(); it++)53 for (auto ind : indicators_connections_)
59 {54 {
60 for (auto conn : it->second)55 for (auto conn : ind.second)
61 conn.disconnect();56 conn.disconnect();
62 }57 }
63}58}
@@ -130,11 +125,9 @@
130PanelIndicatorsView::QueueDraw()125PanelIndicatorsView::QueueDraw()
131{126{
132 nux::View::QueueDraw();127 nux::View::QueueDraw();
133 for (auto i = entries_.begin(), end = entries_.end(); i != end; ++i)128
134 {129 for (auto entry : entries_)
135 if (i->second)130 entry.second->QueueDraw();
136 i->second->QueueDraw();
137 }
138}131}
139132
140bool133bool
@@ -155,9 +148,9 @@
155bool148bool
156PanelIndicatorsView::ActivateIfSensitive()149PanelIndicatorsView::ActivateIfSensitive()
157{150{
158 for (auto i = entries_.begin(), end = entries_.end(); i != end; ++i)151 for (auto entry : entries_)
159 {152 {
160 PanelIndicatorEntryView* view = i->second;153 PanelIndicatorEntryView* view = entry.second;
161 if (view->IsSensitive())154 if (view->IsSensitive())
162 {155 {
163 view->Activate();156 view->Activate();
@@ -170,11 +163,8 @@
170void163void
171PanelIndicatorsView::GetGeometryForSync(indicator::EntryLocationMap& locations)164PanelIndicatorsView::GetGeometryForSync(indicator::EntryLocationMap& locations)
172{165{
173 for (auto i = entries_.begin(), end = entries_.end(); i != end; ++i)166 for (auto entry : entries_)
174 {167 entry.second->GetGeometryForSync(locations);
175 if (i->second)
176 i->second->GetGeometryForSync(locations);
177 }
178}168}
179169
180bool170bool
@@ -228,37 +218,45 @@
228PanelIndicatorsView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)218PanelIndicatorsView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw)
229{219{
230 GfxContext.PushClippingRectangle(GetGeometry());220 GfxContext.PushClippingRectangle(GetGeometry());
231 if (layout_)221 layout_->ProcessDraw(GfxContext, force_draw);
232 layout_->ProcessDraw(GfxContext, force_draw);
233 GfxContext.PopClippingRectangle();222 GfxContext.PopClippingRectangle();
234}223}
235224
236void225PanelIndicatorEntryView *
237PanelIndicatorsView::OnEntryAdded(indicator::Entry::Ptr const& entry)226PanelIndicatorsView::AddEntry(indicator::Entry::Ptr const& entry, int padding, IndicatorEntryPosition pos)
238{227{
239 auto view = new PanelIndicatorEntryView(entry);228 PanelIndicatorEntryView *view;
229 int entry_pos = pos;
230
231 if (padding > -1)
232 view = new PanelIndicatorEntryView(entry, padding);
233 else
234 view = new PanelIndicatorEntryView(entry);
235
240 view->refreshed.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryRefreshed));236 view->refreshed.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryRefreshed));
241237
242 int indicator_pos = nux::NUX_LAYOUT_BEGIN;238 if (entry_pos == IndicatorEntryPosition::AUTO)
243
244 if (entry->priority() > -1)
245 {239 {
246 for (nux::Area* &area : layout_->GetChildren())240 entry_pos = nux::NUX_LAYOUT_BEGIN;
241
242 if (entry->priority() > -1)
247 {243 {
248 auto en = dynamic_cast<PanelIndicatorEntryView*>(area);244 for (auto area : layout_->GetChildren())
249
250 if (en)
251 {245 {
252 if (en && entry->priority() <= en->GetEntryPriority())246 auto en = dynamic_cast<PanelIndicatorEntryView*>(area);
253 break;247
254248 if (en)
255 indicator_pos++;249 {
250 if (en && entry->priority() <= en->GetEntryPriority())
251 break;
252
253 entry_pos++;
254 }
256 }255 }
257 }256 }
258 }257 }
259258
260 nux::LayoutPosition pos = (nux::LayoutPosition) indicator_pos;259 layout_->AddView(view, 0, nux::eCenter, nux::eFull, 1.0, (nux::LayoutPosition) entry_pos);
261 layout_->AddView(view, 0, nux::eCenter, nux::eFull, 1.0, pos);
262 layout_->SetContentDistribution(nux::eStackRight);260 layout_->SetContentDistribution(nux::eStackRight);
263 entries_[entry->id()] = view;261 entries_[entry->id()] = view;
264262
@@ -267,6 +265,14 @@
267 QueueDraw();265 QueueDraw();
268266
269 on_indicator_updated.emit(view);267 on_indicator_updated.emit(view);
268
269 return view;
270}
271
272void
273PanelIndicatorsView::OnEntryAdded(indicator::Entry::Ptr const& entry)
274{
275 AddEntry(entry);
270}276}
271277
272void278void
@@ -279,28 +285,36 @@
279}285}
280286
281void287void
282PanelIndicatorsView::OnEntryRemoved(std::string const& entry_id)288PanelIndicatorsView::RemoveEntry(std::string const& entry_id)
283{289{
284 PanelIndicatorEntryView* view = entries_[entry_id];290 PanelIndicatorEntryView* view = entries_[entry_id];
285291
286 if (view)292 if (view)
287 {293 {
288 on_indicator_updated.emit(view);
289 layout_->RemoveChildObject(view);294 layout_->RemoveChildObject(view);
290 entries_.erase(entry_id);295 entries_.erase(entry_id);
296 on_indicator_updated.emit(view);
291297
292 QueueRelayout();298 QueueRelayout();
293 QueueDraw();299 QueueDraw();
294 }300 }
295}301}
296302
297void PanelIndicatorsView::DashShown()303void
304PanelIndicatorsView::OnEntryRemoved(std::string const& entry_id)
305{
306 RemoveEntry(entry_id);
307}
308
309void
310PanelIndicatorsView::DashShown()
298{311{
299 for (auto entry: entries_)312 for (auto entry: entries_)
300 entry.second->DashShown();313 entry.second->DashShown();
301}314}
302315
303void PanelIndicatorsView::DashHidden()316void
317PanelIndicatorsView::DashHidden()
304{318{
305 for (auto entry: entries_)319 for (auto entry: entries_)
306 entry.second->DashHidden();320 entry.second->DashHidden();
307321
=== modified file 'plugins/unityshell/src/PanelIndicatorsView.h'
--- plugins/unityshell/src/PanelIndicatorsView.h 2011-09-15 11:33:58 +0000
+++ plugins/unityshell/src/PanelIndicatorsView.h 2011-09-25 12:09:24 +0000
@@ -22,6 +22,7 @@
22#define PANEL_INDICATORS_VIEW_H22#define PANEL_INDICATORS_VIEW_H
2323
24#include <Nux/View.h>24#include <Nux/View.h>
25#include <Nux/Layout.h>
2526
26#include <UnityCore/Indicator.h>27#include <UnityCore/Indicator.h>
2728
@@ -41,6 +42,17 @@
41 void AddIndicator(indicator::Indicator::Ptr const& indicator);42 void AddIndicator(indicator::Indicator::Ptr const& indicator);
42 void RemoveIndicator(indicator::Indicator::Ptr const& indicator);43 void RemoveIndicator(indicator::Indicator::Ptr const& indicator);
4344
45 typedef enum {
46 AUTO = -1,
47 START = nux::NUX_LAYOUT_BEGIN,
48 END = nux::NUX_LAYOUT_END,
49 } IndicatorEntryPosition;
50
51 PanelIndicatorEntryView* AddEntry(indicator::Entry::Ptr const& entry,
52 int padding = -1,
53 IndicatorEntryPosition pos = AUTO);
54 void RemoveEntry(std::string const& entry_id);
55
44 bool OnPointerMoved(int x, int y);56 bool OnPointerMoved(int x, int y);
45 bool ActivateEntry(std::string const& entry_id);57 bool ActivateEntry(std::string const& entry_id);
46 bool ActivateIfSensitive();58 bool ActivateIfSensitive();
@@ -51,7 +63,7 @@
51 virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);63 virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw);
52 virtual void QueueDraw();64 virtual void QueueDraw();
5365
54 virtual void OnEntryAdded(indicator::Entry::Ptr const& proxy);66 virtual void OnEntryAdded(indicator::Entry::Ptr const& entry);
55 virtual void OnEntryRefreshed(PanelIndicatorEntryView* view);67 virtual void OnEntryRefreshed(PanelIndicatorEntryView* view);
56 virtual void OnEntryRemoved(std::string const& entry_id);68 virtual void OnEntryRemoved(std::string const& entry_id);
5769
5870
=== modified file 'plugins/unityshell/src/PanelMenuView.cpp'
--- plugins/unityshell/src/PanelMenuView.cpp 2011-09-19 03:03:53 +0000
+++ plugins/unityshell/src/PanelMenuView.cpp 2011-09-25 12:09:24 +0000
@@ -15,11 +15,11 @@
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *16 *
17 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>17 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
18 * Marco Trevisan <mail@3v1n0.net>
18 */19 */
19#include <glib.h>20#include <glib.h>
20#include <pango/pangocairo.h>21#include <pango/pangocairo.h>
21#include <gtk/gtk.h>22#include <gtk/gtk.h>
22#include <X11/cursorfont.h>
2323
24#include <Nux/Nux.h>24#include <Nux/Nux.h>
25#include <Nux/HLayout.h>25#include <Nux/HLayout.h>
@@ -64,7 +64,6 @@
64 _title_layer(NULL),64 _title_layer(NULL),
65 _util_cg(CAIRO_FORMAT_ARGB32, 1, 1),65 _util_cg(CAIRO_FORMAT_ARGB32, 1, 1),
66 _gradient_texture(NULL),66 _gradient_texture(NULL),
67 _title_tex(NULL),
68 _is_inside(false),67 _is_inside(false),
69 _is_maximized(false),68 _is_maximized(false),
70 _is_own_window(false),69 _is_own_window(false),
@@ -77,15 +76,12 @@
77 _monitor(0),76 _monitor(0),
78 _active_xid(0),77 _active_xid(0),
79 _active_moved_id(0),78 _active_moved_id(0),
79 _update_show_now_id(0),
80 _place_shown_interest(0),80 _place_shown_interest(0),
81 _place_hidden_interest(0)81 _place_hidden_interest(0)
82{82{
83 WindowManager* win_manager;83 WindowManager* win_manager;
8484
85 _matcher = bamf_matcher_get_default();
86 _activate_window_changed_id = g_signal_connect(_matcher, "active-window-changed",
87 G_CALLBACK(on_active_window_changed), this);
88
89 // TODO: kill _menu_layout - should just use the _layout defined85 // TODO: kill _menu_layout - should just use the _layout defined
90 // in the base class.86 // in the base class.
91 _menu_layout = new nux::HLayout("", NUX_TRACKER_LOCATION);87 _menu_layout = new nux::HLayout("", NUX_TRACKER_LOCATION);
@@ -96,6 +92,10 @@
96 */92 */
97 layout_ = _menu_layout;93 layout_ = _menu_layout;
9894
95 _matcher = bamf_matcher_get_default();
96 _activate_window_changed_id = g_signal_connect(_matcher, "active-window-changed",
97 G_CALLBACK(on_active_window_changed), this);
98
99 _padding = padding;99 _padding = padding;
100 _name_changed_callback_instance = NULL;100 _name_changed_callback_instance = NULL;
101 _name_changed_callback_id = 0;101 _name_changed_callback_id = 0;
@@ -109,23 +109,23 @@
109 _window_buttons->restore_clicked.connect(sigc::mem_fun(this, &PanelMenuView::OnRestoreClicked));109 _window_buttons->restore_clicked.connect(sigc::mem_fun(this, &PanelMenuView::OnRestoreClicked));
110 _window_buttons->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter));110 _window_buttons->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter));
111 _window_buttons->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave));111 _window_buttons->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave));
112 _window_buttons->mouse_move.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseMove));112 //_window_buttons->mouse_move.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseMove));
113113
114 _panel_titlebar_grab_area = new PanelTitlebarGrabArea();114 _panel_titlebar_grab_area = new PanelTitlebarGrabArea();
115 _panel_titlebar_grab_area->SetParentObject(this);115 _panel_titlebar_grab_area->SetParentObject(this);
116 _panel_titlebar_grab_area->SinkReference();116 _panel_titlebar_grab_area->SinkReference();
117 _panel_titlebar_grab_area->mouse_down.connect(sigc::mem_fun(this, &PanelMenuView::OnMouseMiddleClicked));
117 _panel_titlebar_grab_area->mouse_down.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabStart));118 _panel_titlebar_grab_area->mouse_down.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabStart));
118 _panel_titlebar_grab_area->mouse_drag.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabMove));119 _panel_titlebar_grab_area->mouse_drag.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabMove));
119 _panel_titlebar_grab_area->mouse_up.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabEnd));120 _panel_titlebar_grab_area->mouse_up.connect(sigc::mem_fun(this, &PanelMenuView::OnMaximizedGrabEnd));
120 _panel_titlebar_grab_area->mouse_doubleleftclick.connect(sigc::mem_fun(this, &PanelMenuView::OnMouseDoubleClicked));121 _panel_titlebar_grab_area->mouse_double_click.connect(sigc::mem_fun(this, &PanelMenuView::OnMouseDoubleClicked));
121 _panel_titlebar_grab_area->mouse_middleclick.connect(sigc::mem_fun(this, &PanelMenuView::OnMouseMiddleClicked));
122122
123 win_manager = WindowManager::Default();123 win_manager = WindowManager::Default();
124124
125 win_manager->window_minimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMinimized));125 win_manager->window_minimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMinimized));
126 win_manager->window_unminimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowUnminimized));126 win_manager->window_unminimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowUnminimized));
127 win_manager->initiate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadInitiate));127 //win_manager->initiate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadInitiate));
128 win_manager->terminate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadTerminate));128 //win_manager->terminate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadTerminate));
129129
130 win_manager->window_maximized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMaximized));130 win_manager->window_maximized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMaximized));
131 win_manager->window_restored.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowRestored));131 win_manager->window_restored.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowRestored));
@@ -136,7 +136,7 @@
136136
137 mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter));137 mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter));
138 mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave));138 mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave));
139 mouse_move.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseMove));139 //mouse_move.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseMove));
140140
141 _panel_titlebar_grab_area->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter));141 _panel_titlebar_grab_area->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter));
142 _panel_titlebar_grab_area->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave));142 _panel_titlebar_grab_area->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave));
@@ -166,8 +166,6 @@
166166
167 if (_title_layer)167 if (_title_layer)
168 delete _title_layer;168 delete _title_layer;
169 if (_title_tex)
170 _title_tex->UnReference();
171169
172 _menu_layout->UnReference();170 _menu_layout->UnReference();
173 _window_buttons->UnReference();171 _window_buttons->UnReference();
@@ -345,11 +343,9 @@
345 else343 else
346 {344 {
347 bool have_valid_entries = false;345 bool have_valid_entries = false;
348 Entries::iterator it, eit = entries_.end();346 for (auto entry : entries_)
349
350 for (it = entries_.begin(); it != eit; ++it)
351 {347 {
352 if (it->second->IsEntryValid())348 if (entry.second->IsEntryValid())
353 {349 {
354 have_valid_entries = true;350 have_valid_entries = true;
355 break;351 break;
@@ -408,12 +404,12 @@
408 nux::TexCoordXForm texxform1;404 nux::TexCoordXForm texxform1;
409405
410 // Modulate the checkboard and the gradient texture406 // Modulate the checkboard and the gradient texture
411 if (_title_tex)407 if (_title_layer)
412 GfxContext.QRP_2TexMod(geo.x, geo.y,408 GfxContext.QRP_2TexMod(geo.x, geo.y,
413 geo.width, geo.height,409 geo.width, geo.height,
414 _gradient_texture, texxform0,410 _gradient_texture, texxform0,
415 nux::color::White,411 nux::color::White,
416 _title_tex->GetDeviceTexture(),412 _title_layer->GetDeviceTexture(),
417 texxform1,413 texxform1,
418 nux::color::White);414 nux::color::White);
419415
@@ -449,14 +445,16 @@
449 if (!_is_own_window && !_places_showing && _we_control_active)445 if (!_is_own_window && !_places_showing && _we_control_active)
450 {446 {
451 if (_is_inside || _last_active_view || _show_now_activated)447 if (_is_inside || _last_active_view || _show_now_activated)
452 layout_->ProcessDraw(GfxContext, force_draw);
453 }
454
455 if ((!_is_own_window && _we_control_active && _is_maximized && (_is_inside || _show_now_activated)) ||
456 _places_showing)
457 {448 {
458 _window_buttons->ProcessDraw(GfxContext, true);449 _menu_layout->ProcessDraw(GfxContext, force_draw);
459 }450 }
451 }
452
453 if ((!_is_own_window && _we_control_active && _is_maximized &&
454 (_is_inside || _show_now_activated)) || _places_showing)
455 {
456 _window_buttons->ProcessDraw(GfxContext, true);
457 }
460458
461 GfxContext.PopClippingRectangle();459 GfxContext.PopClippingRectangle();
462}460}
@@ -682,12 +680,7 @@
682 nux::color::White,680 nux::color::White,
683 true,681 true,
684 rop);682 rop);
685683 texture2D->UnReference();
686 if (_title_tex)
687 _title_tex->UnReference();
688
689 _title_tex = texture2D;
690
691 g_free(label);684 g_free(label);
692}685}
693686
@@ -709,26 +702,26 @@
709 FullRedraw();702 FullRedraw();
710}703}
711704
712void PanelMenuView::OnEntryAdded(unity::indicator::Entry::Ptr const& proxy)705void
706PanelMenuView::OnEntryAdded(unity::indicator::Entry::Ptr const& entry)
713{707{
714 PanelIndicatorEntryView* view = new PanelIndicatorEntryView(proxy, 6);708 auto view = AddEntry(entry, 6, IndicatorEntryPosition::END);
709
710 entry->show_now_changed.connect(sigc::mem_fun(this, &PanelMenuView::UpdateShowNow));
711
715 view->active_changed.connect(sigc::mem_fun(this, &PanelMenuView::OnActiveChanged));712 view->active_changed.connect(sigc::mem_fun(this, &PanelMenuView::OnActiveChanged));
716 view->refreshed.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryRefreshed));
717 proxy->show_now_changed.connect(sigc::mem_fun(this, &PanelMenuView::UpdateShowNow));
718
719 _menu_layout->AddView(view, 0, nux::eCenter, nux::eFull, 1.0, nux::NUX_LAYOUT_END);
720 _menu_layout->SetContentDistribution(nux::eStackLeft);
721
722 entries_[proxy->id()] = view;
723 AddChild(view);
724
725 view->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter));713 view->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter));
726 view->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave));714 view->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave));
727715}
728 QueueRelayout();716
729 QueueDraw();717void
730718PanelMenuView::AllMenusClosed()
731 on_indicator_updated.emit(view);719{
720 auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
721 _is_inside = GetAbsoluteGeometry().IsPointInside(mouse.x, mouse.y);
722 _last_active_view = NULL;
723
724 FullRedraw();
732}725}
733726
734void727void
@@ -815,7 +808,6 @@
815void808void
816PanelMenuView::OnWindowMinimized(guint32 xid)809PanelMenuView::OnWindowMinimized(guint32 xid)
817{810{
818
819 if (WindowManager::Default()->IsWindowMaximized(xid))811 if (WindowManager::Default()->IsWindowMaximized(xid))
820 {812 {
821 WindowManager::Default()->Decorate(xid);813 WindowManager::Default()->Decorate(xid);
@@ -844,25 +836,32 @@
844PanelMenuView::OnWindowMaximized(guint xid)836PanelMenuView::OnWindowMaximized(guint xid)
845{837{
846 BamfWindow* window;838 BamfWindow* window;
839 bool updated = false;
847840
848 window = bamf_matcher_get_active_window(_matcher);841 window = bamf_matcher_get_active_window(_matcher);
849 if (BAMF_IS_WINDOW(window) && bamf_window_get_xid(window) == xid)842 if (BAMF_IS_WINDOW(window) && bamf_window_get_xid(window) == xid)
850 {843 {
851 _is_maximized = true;844 _is_maximized = true;
845
846 // We need to update the _is_inside state in the case of maximization by grab
847 auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
848 _is_inside = GetAbsoluteGeometry().IsPointInside(mouse.x, mouse.y);
849 updated = true;
852 }850 }
853851
854 // update the state of the window in the _decor_map852 // update the state of the window in the _decor_map
855 _decor_map[xid] = WindowManager::Default()->IsWindowDecorated(xid);853 _decor_map[xid] = WindowManager::Default()->IsWindowDecorated(xid);
856854
857 if (_decor_map[xid])855 if (_decor_map[xid])
858 {
859 WindowManager::Default()->Undecorate(xid);856 WindowManager::Default()->Undecorate(xid);
860 }
861857
862 _maximized_set.insert(xid);858 _maximized_set.insert(xid);
863859
864 Refresh();860 if (updated)
865 FullRedraw();861 {
862 Refresh();
863 FullRedraw();
864 }
866}865}
867866
868void867void
@@ -870,6 +869,9 @@
870{869{
871 BamfWindow* window;870 BamfWindow* window;
872871
872 if (_maximized_set.find(xid) == _maximized_set.end())
873 return;
874
873 window = bamf_matcher_get_active_window(_matcher);875 window = bamf_matcher_get_active_window(_matcher);
874 if (BAMF_IS_WINDOW(window) && bamf_window_get_xid(window) == xid)876 if (BAMF_IS_WINDOW(window) && bamf_window_get_xid(window) == xid)
875 {877 {
@@ -878,9 +880,7 @@
878 }880 }
879881
880 if (_decor_map[xid])882 if (_decor_map[xid])
881 {
882 WindowManager::Default()->Decorate(xid);883 WindowManager::Default()->Decorate(xid);
883 }
884884
885 _maximized_set.erase(xid);885 _maximized_set.erase(xid);
886886
@@ -976,7 +976,7 @@
976 nux::Geometry monitor = UScreen::GetDefault()->GetMonitorGeometry(_monitor);976 nux::Geometry monitor = UScreen::GetDefault()->GetMonitorGeometry(_monitor);
977977
978 // Find the front-most of the maximized windows we are controlling978 // Find the front-most of the maximized windows we are controlling
979 foreach(guint32 xid, _maximized_set)979 for (auto xid : _maximized_set)
980 {980 {
981 // We can safely assume only the front-most is visible981 // We can safely assume only the front-most is visible
982 if (WindowManager::Default()->IsWindowOnCurrentDesktop(xid)982 if (WindowManager::Default()->IsWindowOnCurrentDesktop(xid)
@@ -994,37 +994,48 @@
994}994}
995995
996void996void
997PanelMenuView::OnMaximizedGrabStart(int x, int y)997PanelMenuView::OnMaximizedGrabStart(int x, int y, unsigned long button_flags, unsigned long)
998{998{
999 if (nux::GetEventButton(button_flags) != 1 || _places_showing)
1000 return;
1001
999 // When Start dragging the panelmenu of a maximized window, change cursor1002 // When Start dragging the panelmenu of a maximized window, change cursor
1000 // to simulate the dragging, waiting to go out of the panel area.1003 // to simulate the dragging, waiting to go out of the panel area.
1001 //1004 //
1002 // This is a workaround to avoid that the grid plugin would be fired1005 // This is a workaround to avoid that the grid plugin would be fired
1003 // showing the window shape preview effect. See bug #8389231006 // showing the window shape preview effect. See bug #838923
1004 if (GetMaximizedWindow() != 0)1007 if (GetMaximizedWindow() != 0)
1005 {1008 _panel_titlebar_grab_area->SetGrabbed(true);
1006 Display* d = nux::GetGraphicsDisplay()->GetX11Display();
1007 nux::BaseWindow *bw = static_cast<nux::BaseWindow*>(GetTopLevelViewWindow());
1008 Cursor c = XCreateFontCursor(d, XC_fleur);
1009 XDefineCursor(d, bw->GetInputWindowId(), c);
1010 XFreeCursor(d, c);
1011 }
1012}1009}
10131010
1014void1011void
1015PanelMenuView::OnMaximizedGrabMove(int x, int y, int, int, unsigned long, unsigned long)1012PanelMenuView::OnMaximizedGrabMove(int x, int y, int, int, unsigned long button_flags, unsigned long)
1016{1013{
1014// FIXME nux doesn't export it with drag event.
1015// if (nux::GetEventButton(button_flags) != 1)
1016// return;
1017
1018 // We use this, due to the problem above
1019 if (!_panel_titlebar_grab_area->IsGrabbed())
1020 return;
1021
1022 auto panel = static_cast<nux::BaseWindow*>(GetTopLevelViewWindow());
1023
1024 if (!panel)
1025 return;
1026
1027 x += _panel_titlebar_grab_area->GetAbsoluteX();
1028 y += _panel_titlebar_grab_area->GetAbsoluteY();
1029
1017 guint32 window_xid = GetMaximizedWindow();1030 guint32 window_xid = GetMaximizedWindow();
10181031
1019 // When the drag goes out from the Panel, start the real movement.1032 // When the drag goes out from the Panel, start the real movement.
1020 //1033 //
1021 // This is a workaround to avoid that the grid plugin would be fired1034 // This is a workaround to avoid that the grid plugin would be fired
1022 // showing the window shape preview effect. See bug #8389231035 // showing the window shape preview effect. See bug #838923
1023 if (window_xid != 0 && !GetAbsoluteGeometry().IsPointInside(x, y))1036 if (window_xid != 0 && panel && !panel->GetAbsoluteGeometry().IsPointInside(x, y))
1024 {1037 {
1025 Display* d = nux::GetGraphicsDisplay()->GetX11Display();1038 _panel_titlebar_grab_area->SetGrabbed(false);
1026 nux::BaseWindow *bw = static_cast<nux::BaseWindow*>(GetTopLevelViewWindow());
1027 XUndefineCursor(d, bw->GetInputWindowId());
10281039
1029 WindowManager::Default()->Activate(window_xid);1040 WindowManager::Default()->Activate(window_xid);
1030 _is_inside = true;1041 _is_inside = true;
@@ -1038,15 +1049,25 @@
1038void1049void
1039PanelMenuView::OnMaximizedGrabEnd(int x, int y, unsigned long, unsigned long)1050PanelMenuView::OnMaximizedGrabEnd(int x, int y, unsigned long, unsigned long)
1040{1051{
1041 // Restore the window cursor to default.1052 _panel_titlebar_grab_area->SetGrabbed(false);
1042 Display* d = nux::GetGraphicsDisplay()->GetX11Display();1053
1043 nux::BaseWindow *bw = static_cast<nux::BaseWindow*>(GetTopLevelViewWindow());1054 x += _panel_titlebar_grab_area->GetAbsoluteX();
1044 XUndefineCursor(d, bw->GetInputWindowId());1055 y += _panel_titlebar_grab_area->GetAbsoluteY();
1056 _is_inside = GetAbsoluteGeometry().IsPointInside(x, y);
1057
1058 if (!_is_inside)
1059 _is_grabbed = false;
1060
1061 Refresh();
1062 FullRedraw();
1045}1063}
10461064
1047void1065void
1048PanelMenuView::OnMouseDoubleClicked()1066PanelMenuView::OnMouseDoubleClicked(int x, int y, unsigned long button_flags, unsigned long)
1049{1067{
1068 if (nux::GetEventButton(button_flags) != 1)
1069 return;
1070
1050 guint32 window_xid = GetMaximizedWindow();1071 guint32 window_xid = GetMaximizedWindow();
10511072
1052 if (window_xid != 0)1073 if (window_xid != 0)
@@ -1057,8 +1078,11 @@
1057}1078}
10581079
1059void1080void
1060PanelMenuView::OnMouseMiddleClicked()1081PanelMenuView::OnMouseMiddleClicked(int x, int y, unsigned long button_flags, unsigned long)
1061{1082{
1083 if (nux::GetEventButton(button_flags) != 2)
1084 return;
1085
1062 guint32 window_xid = GetMaximizedWindow();1086 guint32 window_xid = GetMaximizedWindow();
10631087
1064 if (window_xid != 0)1088 if (window_xid != 0)
@@ -1120,23 +1144,58 @@
1120 self->QueueDraw();1144 self->QueueDraw();
1121}1145}
11221146
1123void PanelMenuView::UpdateShowNow(bool ignore)1147gboolean
1148PanelMenuView::UpdateShowNowWithDelay(PanelMenuView *self)
1124{1149{
1125 // NOTE: This is sub-optimal. We are getting a dbus event for every menu,1150 bool active = false;
1126 // and every time that is setting the show now status of an indicator entry,
1127 // we are getting the event raised, and we are ignoring the status, and
1128 // looking through all the entries to see if any are shown.
1129 _show_now_activated = false;
11301151
1131 for (Entries::iterator it = entries_.begin(); it != entries_.end(); ++it)1152 for (auto entry : self->entries_)
1132 {1153 {
1133 PanelIndicatorEntryView* view = it->second;1154 if (entry.second->GetShowNow())
1134 if (view->GetShowNow()) {1155 {
1135 _show_now_activated = true;1156 active = true;
1136 break;1157 break;
1137 }1158 }
1138 }1159 }
1139 QueueDraw();1160
1161 self->_update_show_now_id = 0;
1162
1163 if (active)
1164 {
1165 self->_show_now_activated = true;
1166 self->QueueDraw();
1167 }
1168
1169 return FALSE;
1170}
1171
1172void
1173PanelMenuView::UpdateShowNow(bool status)
1174{
1175 /* When we get a show now event, if we are requested to show the menus,
1176 * we take the last incoming event and we wait for small delay (to avoid the
1177 * Alt+Tab conflict) then we check if any menuitem has requested to show.
1178 * If the status is false, we just check that the menus entries are hidden
1179 * and we remove any eventual delayed request */
1180
1181 if (!status && _show_now_activated)
1182 {
1183 _show_now_activated = false;
1184 QueueDraw();
1185 }
1186
1187 if (_update_show_now_id != 0)
1188 {
1189 g_source_remove(_update_show_now_id);
1190 _update_show_now_id = 0;
1191 }
1192
1193 if (status && !_show_now_activated)
1194 {
1195 _update_show_now_id = g_timeout_add(180, (GSourceFunc)
1196 &PanelMenuView::UpdateShowNowWithDelay,
1197 this);
1198 }
1140}1199}
11411200
1142void1201void
@@ -1167,6 +1226,7 @@
1167 _is_grabbed = false;1226 _is_grabbed = false;
1168 else1227 else
1169 _is_inside = true;1228 _is_inside = true;
1229
1170 FullRedraw();1230 FullRedraw();
1171 }1231 }
1172}1232}
11731233
=== modified file 'plugins/unityshell/src/PanelMenuView.h'
--- plugins/unityshell/src/PanelMenuView.h 2011-09-03 02:47:41 +0000
+++ plugins/unityshell/src/PanelMenuView.h 2011-09-25 12:09:24 +0000
@@ -76,13 +76,14 @@
7676
77 guint32 GetMaximizedWindow();77 guint32 GetMaximizedWindow();
7878
79 void OnMaximizedGrabStart(int x, int y);79 void OnMaximizedGrabStart(int, int, unsigned long, unsigned long);
80 void OnMaximizedGrabMove(int, int, int, int, unsigned long, unsigned long);80 void OnMaximizedGrabMove(int, int, int, int, unsigned long, unsigned long);
81 void OnMaximizedGrabEnd(int x, int y, unsigned long, unsigned long);81 void OnMaximizedGrabEnd(int, int, unsigned long, unsigned long);
82 void OnMouseDoubleClicked();82 void OnMouseDoubleClicked(int, int, unsigned long, unsigned long);
83 void OnMouseMiddleClicked();83 void OnMouseMiddleClicked(int, int, unsigned long, unsigned long);
8484
85 void Refresh();85 void Refresh();
86 void AllMenusClosed();
8687
87 void OnCloseClicked();88 void OnCloseClicked();
88 void OnMinimizeClicked();89 void OnMinimizeClicked();
@@ -101,7 +102,7 @@
101 void OnPanelViewMouseEnter(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state);102 void OnPanelViewMouseEnter(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state);
102 void OnPanelViewMouseLeave(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state);103 void OnPanelViewMouseLeave(int x, int y, unsigned long mouse_button_state, unsigned long special_keys_state);
103 void OnPanelViewMouseMove(int x, int y, int dx, int dy, unsigned long mouse_button_state, unsigned long special_keys_state);104 void OnPanelViewMouseMove(int x, int y, int dx, int dy, unsigned long mouse_button_state, unsigned long special_keys_state);
104 virtual void OnEntryAdded(unity::indicator::Entry::Ptr const& proxy);105 virtual void OnEntryAdded(unity::indicator::Entry::Ptr const& entry);
105106
106private:107private:
107 gchar* GetActiveViewName();108 gchar* GetActiveViewName();
@@ -109,15 +110,15 @@
109 static void OnPlaceViewHidden(GVariant* data, PanelMenuView* self);110 static void OnPlaceViewHidden(GVariant* data, PanelMenuView* self);
110 void UpdateShowNow(bool ignore);111 void UpdateShowNow(bool ignore);
111 static gboolean UpdateActiveWindowPosition(PanelMenuView* self);112 static gboolean UpdateActiveWindowPosition(PanelMenuView* self);
113 static gboolean UpdateShowNowWithDelay(PanelMenuView* self);
112114
113private:115private:
114 BamfMatcher* _matcher;116 BamfMatcher* _matcher;
115117
116 nux::AbstractPaintLayer* _title_layer;118 nux::TextureLayer* _title_layer;
117 nux::HLayout* _menu_layout;119 nux::HLayout* _menu_layout;
118 nux::CairoGraphics _util_cg;120 nux::CairoGraphics _util_cg;
119 nux::ObjectPtr<nux::IOpenGLBaseTexture> _gradient_texture;121 nux::ObjectPtr<nux::IOpenGLBaseTexture> _gradient_texture;
120 nux::BaseTexture* _title_tex;
121122
122 bool _is_inside;123 bool _is_inside;
123 bool _is_grabbed;124 bool _is_grabbed;
@@ -144,6 +145,7 @@
144 int _monitor;145 int _monitor;
145 guint32 _active_xid;146 guint32 _active_xid;
146 guint32 _active_moved_id;147 guint32 _active_moved_id;
148 guint32 _update_show_now_id;
147 nux::Geometry _monitor_geo;149 nux::Geometry _monitor_geo;
148150
149 gulong _activate_window_changed_id;151 gulong _activate_window_changed_id;
150152
=== modified file 'plugins/unityshell/src/PanelTitlebarGrabAreaView.cpp'
--- plugins/unityshell/src/PanelTitlebarGrabAreaView.cpp 2011-09-06 18:30:26 +0000
+++ plugins/unityshell/src/PanelTitlebarGrabAreaView.cpp 2011-09-25 12:09:24 +0000
@@ -1,3 +1,4 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
1/*2/*
2 * Copyright (C) 2010 Canonical Ltd3 * Copyright (C) 2010 Canonical Ltd
3 *4 *
@@ -14,8 +15,9 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *16 *
16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>17 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
17 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>18 * Sam Spilsbury <sam.spilsbury@canonical.com>
18 * Authored by: Didier Roche <didier.roche@canonical.com>19 * Didier Roche <didier.roche@canonical.com>
20 * Marco Trevisan (Treviño) <mail@3v1n0.net>
19 */21 */
2022
21#include <Nux/Nux.h>23#include <Nux/Nux.h>
@@ -31,19 +33,13 @@
31#include <UnityCore/Variant.h>33#include <UnityCore/Variant.h>
3234
33#include <glib.h>35#include <glib.h>
36#include <X11/cursorfont.h>
3437
35#define DELTA_MOUSE_DOUBLE_CLICK 50000000038#define DELTA_MOUSE_DOUBLE_CLICK 500000000
3639
37enum
38{
39 BUTTON_CLOSE = 0,
40 BUTTON_MINIMISE,
41 BUTTON_UNMAXIMISE
42};
43
44
45PanelTitlebarGrabArea::PanelTitlebarGrabArea()40PanelTitlebarGrabArea::PanelTitlebarGrabArea()
46 : InputArea(NUX_TRACKER_LOCATION)41 : InputArea(NUX_TRACKER_LOCATION)
42 , _grab_cursor(None)
47{43{
48 // FIXME: the two following functions should be used instead of the insane trick with fixed value. But nux is broken44 // FIXME: the two following functions should be used instead of the insane trick with fixed value. But nux is broken
49 // right now and we need jay to focus on other things45 // right now and we need jay to focus on other things
@@ -52,38 +48,44 @@
52 InputArea::mouse_up.connect(sigc::mem_fun(this, &PanelTitlebarGrabArea::RecvMouseUp));48 InputArea::mouse_up.connect(sigc::mem_fun(this, &PanelTitlebarGrabArea::RecvMouseUp));
53 _last_click_time.tv_sec = 0;49 _last_click_time.tv_sec = 0;
54 _last_click_time.tv_nsec = 0;50 _last_click_time.tv_nsec = 0;
55
56 // connect the *Click events before the *Down ones otherwise, weird race happens
57 InputArea::mouse_down.connect(sigc::mem_fun(this, &PanelTitlebarGrabArea::RecvMouseDown));
58}51}
5952
6053
61PanelTitlebarGrabArea::~PanelTitlebarGrabArea()54PanelTitlebarGrabArea::~PanelTitlebarGrabArea()
62{55{
63}56 if (_grab_cursor)
6457 XFreeCursor(nux::GetGraphicsDisplay()->GetX11Display(), _grab_cursor);
65void PanelTitlebarGrabArea::RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)58}
66{59
67 int button = nux::GetEventButton(button_flags);60void PanelTitlebarGrabArea::SetGrabbed(bool enabled)
68 if (button == 1)61{
69 {62 auto display = nux::GetGraphicsDisplay()->GetX11Display();
70 mouse_down.emit(x, y);63 auto panel_window = static_cast<nux::BaseWindow*>(GetTopLevelViewWindow());
71 }64
72 else if (button == 2)65 if (!panel_window || !display)
73 {66 return;
74 mouse_middleclick.emit();67
75 }68 if (enabled && !_grab_cursor)
69 {
70 _grab_cursor = XCreateFontCursor(display, XC_fleur);
71 XDefineCursor(display, panel_window->GetInputWindowId(), _grab_cursor);
72 }
73 else if (!enabled && _grab_cursor)
74 {
75 XUndefineCursor(display, panel_window->GetInputWindowId());
76 XFreeCursor(display, _grab_cursor);
77 _grab_cursor = None;
78 }
79}
80
81bool PanelTitlebarGrabArea::IsGrabbed()
82{
83 return _grab_cursor != None;
76}84}
7785
78void PanelTitlebarGrabArea::RecvMouseDoubleClick(int x, int y, unsigned long button_flags, unsigned long key_flags)86void PanelTitlebarGrabArea::RecvMouseDoubleClick(int x, int y, unsigned long button_flags, unsigned long key_flags)
79{87{
80 int button = nux::GetEventButton(button_flags);88 mouse_double_click.emit(x, y, button_flags, key_flags);
81 if (button == 1)
82 {
83 mouse_doubleleftclick.emit();
84 return;
85 }
86 mouse_doubleclick.emit();
87}89}
8890
89// TODO: can be safely removed once OnMouseDoubleClick is fixed in nux91// TODO: can be safely removed once OnMouseDoubleClick is fixed in nux
9092
=== modified file 'plugins/unityshell/src/PanelTitlebarGrabAreaView.h'
--- plugins/unityshell/src/PanelTitlebarGrabAreaView.h 2011-07-21 14:59:25 +0000
+++ plugins/unityshell/src/PanelTitlebarGrabAreaView.h 2011-09-25 12:09:24 +0000
@@ -1,3 +1,4 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
1/*2/*
2 * Copyright (C) 2010 Canonical Ltd3 * Copyright (C) 2010 Canonical Ltd
3 *4 *
@@ -14,8 +15,9 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *16 *
16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>17 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
17 * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>18 * Sam Spilsbury <sam.spilsbury@canonical.com>
18 * Authored by: Didier Roche <didier.roche@canonical.com>19 * Didier Roche <didier.roche@canonical.com>
20 * Marco Trevisan (Treviño) <mail@3v1n0.net>
19 */21 */
2022
21#ifndef PANEL_TITLEBAR_GRAB_AREA_H23#ifndef PANEL_TITLEBAR_GRAB_AREA_H
@@ -38,23 +40,22 @@
38 PanelTitlebarGrabArea();40 PanelTitlebarGrabArea();
39 ~PanelTitlebarGrabArea();41 ~PanelTitlebarGrabArea();
4042
41 sigc::signal <void, int, int> mouse_down;43 void SetGrabbed(bool enabled);
42 sigc::signal <void> mouse_middleclick;44 bool IsGrabbed();
43 sigc::signal <void> mouse_doubleclick;
44 sigc::signal <void> mouse_doubleleftclick;
4545
46protected:46private:
47 void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);47 void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
48 void RecvMouseDoubleClick(int x, int y, unsigned long button_flags, unsigned long key_flags);48 void RecvMouseDoubleClick(int x, int y, unsigned long button_flags, unsigned long key_flags);
49 // TODO: can be safely removed once OnMouseDoubleClick is fixed in nux49 // TODO: can be safely removed once OnMouseDoubleClick is fixed in nux
50 void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);50 void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
51 struct timespec time_diff(struct timespec start, struct timespec end);51 struct timespec time_diff(struct timespec start, struct timespec end);
5252
53 struct timespec _last_click_time;
54
55 const gchar* GetName();53 const gchar* GetName();
56 const gchar* GetChildsName();54 const gchar* GetChildsName();
57 void AddProperties(GVariantBuilder* builder);55 void AddProperties(GVariantBuilder* builder);
56
57 struct timespec _last_click_time;
58 Cursor _grab_cursor;
58};59};
5960
60#endif61#endif
6162
=== modified file 'plugins/unityshell/src/PanelView.cpp'
--- plugins/unityshell/src/PanelView.cpp 2011-09-20 16:23:55 +0000
+++ plugins/unityshell/src/PanelView.cpp 2011-09-25 12:09:24 +0000
@@ -190,7 +190,7 @@
190190
191const gchar* PanelView::GetName()191const gchar* PanelView::GetName()
192{192{
193 return "Panel";193 return "UnityPanel";
194}194}
195195
196const gchar*196const gchar*
@@ -459,6 +459,7 @@
459459
460void PanelView::OnIndicatorViewUpdated(PanelIndicatorEntryView* view)460void PanelView::OnIndicatorViewUpdated(PanelIndicatorEntryView* view)
461{461{
462 _needs_geo_sync = true;
462 ComputeChildLayout();463 ComputeChildLayout();
463}464}
464465
@@ -488,12 +489,19 @@
488 if (!ret) _indicators->ActivateEntry(entry_id);489 if (!ret) _indicators->ActivateEntry(entry_id);
489}490}
490491
491static gboolean track_menu_pointer(gpointer data)492void PanelView::TrackMenuPointer()
492{493{
493 PanelView *self = (PanelView*)data;494 auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord();
494 gint x, y;495 if (_tracked_pointer_pos != mouse)
495 gdk_display_get_pointer(gdk_display_get_default(), NULL, &x, &y, NULL);496 {
496 self->OnMenuPointerMoved(x, y);497 OnMenuPointerMoved(mouse.x, mouse.y);
498 _tracked_pointer_pos = mouse;
499 }
500}
501
502static gboolean track_menu_pointer(PanelView *self)
503{
504 self->TrackMenuPointer();
497 return TRUE;505 return TRUE;
498}506}
499507
@@ -512,7 +520,7 @@
512 // process. All the motion events will go to unity-panel-service while520 // process. All the motion events will go to unity-panel-service while
513 // scrubbing because the active panel menu has (needs) the pointer grab.521 // scrubbing because the active panel menu has (needs) the pointer grab.
514 //522 //
515 _track_menu_pointer_id = g_timeout_add(16, track_menu_pointer, this);523 _track_menu_pointer_id = g_timeout_add(16, (GSourceFunc) track_menu_pointer, this);
516 }524 }
517 else if (!active)525 else if (!active)
518 {526 {
@@ -521,6 +529,8 @@
521 g_source_remove(_track_menu_pointer_id);529 g_source_remove(_track_menu_pointer_id);
522 _track_menu_pointer_id = 0;530 _track_menu_pointer_id = 0;
523 }531 }
532 _menu_view->AllMenusClosed();
533 _tracked_pointer_pos = {-1, -1};
524 }534 }
525}535}
526536
@@ -603,7 +613,8 @@
603 _is_primary = primary;613 _is_primary = primary;
604}614}
605615
606void PanelView::SyncGeometries()616void
617PanelView::SyncGeometries()
607{618{
608 indicator::EntryLocationMap locations;619 indicator::EntryLocationMap locations;
609 _menu_view->GetGeometryForSync(locations);620 _menu_view->GetGeometryForSync(locations);
610621
=== modified file 'plugins/unityshell/src/PanelView.h'
--- plugins/unityshell/src/PanelView.h 2011-09-15 09:58:21 +0000
+++ plugins/unityshell/src/PanelView.h 2011-09-25 12:09:24 +0000
@@ -72,6 +72,8 @@
72 void EndFirstMenuShow();72 void EndFirstMenuShow();
7373
74 void SetOpacity(float opacity);74 void SetOpacity(float opacity);
75
76 void TrackMenuPointer();
7577
76 unsigned int GetTrayXid ();78 unsigned int GetTrayXid ();
7779
@@ -120,6 +122,7 @@
120 guint _handle_dash_shown;122 guint _handle_dash_shown;
121 guint _handle_bg_color_update;123 guint _handle_bg_color_update;
122 guint _track_menu_pointer_id;124 guint _track_menu_pointer_id;
125 nux::Point _tracked_pointer_pos;
123126
124 std::vector<sigc::connection> _on_indicator_updated_connections;127 std::vector<sigc::connection> _on_indicator_updated_connections;
125 BackgroundEffectHelper bg_effect_helper_;128 BackgroundEffectHelper bg_effect_helper_;
126129
=== modified file 'plugins/unityshell/src/PluginAdapter.cpp'
--- plugins/unityshell/src/PluginAdapter.cpp 2011-09-21 03:40:33 +0000
+++ plugins/unityshell/src/PluginAdapter.cpp 2011-09-25 12:09:24 +0000
@@ -375,7 +375,36 @@
375bool375bool
376PluginAdapter::IsWindowDecorated(guint32 xid)376PluginAdapter::IsWindowDecorated(guint32 xid)
377{377{
378 Window win = (Window)xid;378 Display* display = m_Screen->dpy();
379 Window win = xid;
380 Atom hints_atom = None;
381 MotifWmHints* hints = NULL;
382 Atom type = None;
383 gint format;
384 gulong nitems;
385 gulong bytes_after;
386 bool ret = true;
387
388 hints_atom = XInternAtom(display, _XA_MOTIF_WM_HINTS, false);
389
390 XGetWindowProperty(display, win, hints_atom, 0,
391 sizeof(MotifWmHints) / sizeof(long), False,
392 hints_atom, &type, &format, &nitems, &bytes_after,
393 (guchar**)&hints);
394
395 if (!hints)
396 return ret;
397
398 if (type == hints_atom && format != 0 && hints->flags & MWM_HINTS_DECORATIONS)
399 {
400 ret = hints->decorations & (MwmDecorAll | MwmDecorTitle);
401 }
402
403 XFree(hints);
404 return ret;
405
406/* FIXME compiz is too slow to update this value, and this could lead to
407 * issues like the bug #838923, since the read value isn't valid anymore
379 CompWindow* window;408 CompWindow* window;
380409
381 window = m_Screen->findWindow(win);410 window = m_Screen->findWindow(win);
@@ -386,6 +415,7 @@
386 return decor & (MwmDecorAll | MwmDecorTitle);415 return decor & (MwmDecorAll | MwmDecorTitle);
387 }416 }
388 return true;417 return true;
418*/
389}419}
390420
391bool421bool
@@ -419,6 +449,8 @@
419 {449 {
420 if (sibling->defaultViewport() == window_vp450 if (sibling->defaultViewport() == window_vp
421 && !sibling->minimized()451 && !sibling->minimized()
452 && sibling->isMapped()
453 && sibling->isViewable()
422 && (sibling->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE)454 && (sibling->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE)
423 return true;455 return true;
424 }456 }
425457
=== modified file 'plugins/unityshell/src/WindowButtons.cpp'
--- plugins/unityshell/src/WindowButtons.cpp 2011-09-06 18:30:26 +0000
+++ plugins/unityshell/src/WindowButtons.cpp 2011-09-25 12:09:24 +0000
@@ -55,6 +55,7 @@
55 _prelight_dash_tex(NULL),55 _prelight_dash_tex(NULL),
56 _pressed_dash_tex(NULL),56 _pressed_dash_tex(NULL),
57 _dash_is_open(false),57 _dash_is_open(false),
58 _mouse_is_down(false),
58 _place_shown_interest(0),59 _place_shown_interest(0),
59 _place_hidden_interest(0)60 _place_hidden_interest(0)
60 {61 {
@@ -69,6 +70,14 @@
69 _place_hidden_interest = ubus_server_register_interest(ubus, UBUS_PLACE_VIEW_HIDDEN,70 _place_hidden_interest = ubus_server_register_interest(ubus, UBUS_PLACE_VIEW_HIDDEN,
70 (UBusCallback)&WindowButton::OnPlaceViewHidden,71 (UBusCallback)&WindowButton::OnPlaceViewHidden,
71 this);72 this);
73
74 /* FIXME HasMouseFocus() doesn't seem to work correctly, so we use this workaround */
75 mouse_down.connect([&_mouse_is_down](int, int, unsigned long, unsigned long) {
76 _mouse_is_down = true;
77 });
78 mouse_up.connect([&_mouse_is_down](int, int, unsigned long, unsigned long) {
79 _mouse_is_down = false;
80 });
72 }81 }
7382
74 ~WindowButton()83 ~WindowButton()
@@ -98,7 +107,8 @@
98107
99 if (_dash_is_open)108 if (_dash_is_open)
100 {109 {
101 if (HasMouseFocus() && IsMouseInside())110 //FIXME should use HasMouseFocus()
111 if (_mouse_is_down && IsMouseInside())
102 tex = _pressed_dash_tex;112 tex = _pressed_dash_tex;
103 else if (IsMouseInside())113 else if (IsMouseInside())
104 tex = _prelight_dash_tex;114 tex = _prelight_dash_tex;
@@ -107,7 +117,8 @@
107 }117 }
108 else118 else
109 {119 {
110 if (HasMouseFocus() && IsMouseInside())120 //FIXME should use HasMouseFocus()
121 if (_mouse_is_down && IsMouseInside())
111 tex = _pressed_tex;122 tex = _pressed_tex;
112 else if (IsMouseInside())123 else if (IsMouseInside())
113 tex = _prelight_tex;124 tex = _prelight_tex;
@@ -217,6 +228,7 @@
217 nux::BaseTexture* _prelight_dash_tex;228 nux::BaseTexture* _prelight_dash_tex;
218 nux::BaseTexture* _pressed_dash_tex;229 nux::BaseTexture* _pressed_dash_tex;
219 bool _dash_is_open;230 bool _dash_is_open;
231 bool _mouse_is_down;
220 guint32 _place_shown_interest;232 guint32 _place_shown_interest;
221 guint32 _place_hidden_interest;233 guint32 _place_hidden_interest;
222234
223235
=== modified file 'plugins/unityshell/src/WindowManager.cpp'
--- plugins/unityshell/src/WindowManager.cpp 2011-09-19 16:36:21 +0000
+++ plugins/unityshell/src/WindowManager.cpp 2011-09-25 12:09:24 +0000
@@ -1,3 +1,4 @@
1// -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*-
1/*2/*
2 * Copyright (C) 2010 Canonical Ltd3 * Copyright (C) 2010 Canonical Ltd
3 *4 *
@@ -26,7 +27,7 @@
26 {27 {
27 return 0;28 return 0;
28 }29 }
29 30
30 bool IsScreenGrabbed()31 bool IsScreenGrabbed()
31 {32 {
32 return false;33 return false;
@@ -181,6 +182,9 @@
181void182void
182WindowManager::StartMove(guint32 xid, int x, int y)183WindowManager::StartMove(guint32 xid, int x, int y)
183{184{
185 if (x < 0 || y < 0)
186 return;
187
184 XEvent ev;188 XEvent ev;
185 Display* d = nux::GetGraphicsDisplay()->GetX11Display();189 Display* d = nux::GetGraphicsDisplay()->GetX11Display();
186190
187191
=== modified file 'services/panel-service.c'
--- services/panel-service.c 2011-09-08 11:53:46 +0000
+++ services/panel-service.c 2011-09-25 12:09:24 +0000
@@ -16,6 +16,7 @@
16 *16 *
17 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>17 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
18 * Rodrigo Moya <rodrigo.moya@canonical.com>18 * Rodrigo Moya <rodrigo.moya@canonical.com>
19 * Marco Trevisan (Treviño) <mail@3v1n0.net>
19 */20 */
2021
21#if HAVE_CONFIG_H22#if HAVE_CONFIG_H
@@ -47,8 +48,8 @@
47struct _PanelServicePrivate48struct _PanelServicePrivate
48{49{
49 GSList *indicators;50 GSList *indicators;
50 GHashTable *id2entry_hash;
51 GHashTable *entry2indicator_hash;51 GHashTable *entry2indicator_hash;
52 GHashTable *entry2geometry_hash;
5253
53 guint initial_sync_id;54 guint initial_sync_id;
54 gint32 timeouts[N_TIMEOUT_SLOTS];55 gint32 timeouts[N_TIMEOUT_SLOTS];
@@ -64,6 +65,9 @@
64 gint last_right;65 gint last_right;
65 gint last_bottom;66 gint last_bottom;
66 guint32 last_menu_button;67 guint32 last_menu_button;
68
69 IndicatorObjectEntry *pressed_entry;
70 gboolean use_event;
67};71};
6872
69/* Globals */73/* Globals */
@@ -113,6 +117,7 @@
113static void sort_indicators (PanelService *self);117static void sort_indicators (PanelService *self);
114118
115static void notify_object (IndicatorObject *object);119static void notify_object (IndicatorObject *object);
120static IndicatorObjectEntry *get_entry_at (PanelService *self, gint x, gint y);
116121
117static GdkFilterReturn event_filter (GdkXEvent *ev,122static GdkFilterReturn event_filter (GdkXEvent *ev,
118 GdkEvent *gev,123 GdkEvent *gev,
@@ -128,8 +133,8 @@
128 PanelServicePrivate *priv = PANEL_SERVICE (object)->priv;133 PanelServicePrivate *priv = PANEL_SERVICE (object)->priv;
129 gint i;134 gint i;
130135
131 g_hash_table_destroy (priv->id2entry_hash);
132 g_hash_table_destroy (priv->entry2indicator_hash);136 g_hash_table_destroy (priv->entry2indicator_hash);
137 g_hash_table_destroy (priv->entry2geometry_hash);
133138
134 gdk_window_remove_filter (NULL, (GdkFilterFunc)event_filter, object);139 gdk_window_remove_filter (NULL, (GdkFilterFunc)event_filter, object);
135140
@@ -239,25 +244,83 @@
239 if (cookie->type == GenericEvent)244 if (cookie->type == GenericEvent)
240 {245 {
241 XIDeviceEvent *event = cookie->data;246 XIDeviceEvent *event = cookie->data;
242247 if (!event)
243 if (event && event->evtype == XI_ButtonRelease &&248 return ret;
244 priv->last_menu_button != 0) //FocusChange249
245 {250 if (event->evtype == XI_ButtonPress)
246 if (event->root_x < priv->last_left ||251 {
247 event->root_x > priv->last_right ||252 priv->pressed_entry = get_entry_at (self, event->root_x, event->root_y);
248 event->root_y < priv->last_top ||253 priv->use_event = (priv->pressed_entry == NULL);
249 event->root_y > priv->last_bottom)254 }
250 {255
251 ret = GDK_FILTER_REMOVE;256 if (event->evtype == XI_ButtonRelease)
252 }257 {
253258 if (priv->use_event)
254 priv->last_menu_button = 0;259 {
260 priv->use_event = FALSE;
261 }
262 else
263 {
264 IndicatorObjectEntry *entry;
265 entry = get_entry_at (self, event->root_x, event->root_y);
266
267 if (entry)
268 {
269 if (entry != priv->pressed_entry)
270 {
271 ret = GDK_FILTER_REMOVE;
272 priv->use_event = TRUE;
273 }
274 else if (priv->last_entry && entry != priv->last_entry)
275 {
276 /* If we were navigating over indicators using the keyboard
277 * and now we click over the indicator under the mouse, we
278 * must force it to show back again, not make it close */
279 gchar *entry_id = g_strdup_printf ("%p", entry);
280 g_signal_emit (self, _service_signals[ENTRY_ACTIVATE_REQUEST], 0, entry_id);
281 g_free (entry_id);
282 }
283 }
284 }
255 }285 }
256 }286 }
257287
258 return ret;288 return ret;
259}289}
260290
291static IndicatorObjectEntry *
292get_entry_at (PanelService *self, gint x, gint y)
293{
294 GHashTableIter iter;
295 gpointer key, value;
296
297 g_hash_table_iter_init (&iter, self->priv->entry2geometry_hash);
298 while (g_hash_table_iter_next (&iter, &key, &value))
299 {
300 IndicatorObjectEntry *entry = key;
301 GdkRectangle *geo = value;
302
303 if (x >= geo->x && x <= (geo->x + geo->width) &&
304 y >= geo->y && y <= (geo->y + geo->height))
305 {
306 return entry;
307 }
308 }
309
310 return NULL;
311}
312
313static IndicatorObjectEntry *
314get_entry_by_id (const gchar *entry_id)
315{
316 IndicatorObjectEntry *entry;
317
318 if (sscanf (entry_id, "%p", &entry) == 1)
319 return entry;
320
321 return NULL;
322}
323
261static gboolean324static gboolean
262initial_resync (PanelService *self)325initial_resync (PanelService *self)
263{326{
@@ -277,9 +340,9 @@
277340
278 gdk_window_add_filter (NULL, (GdkFilterFunc)event_filter, self);341 gdk_window_add_filter (NULL, (GdkFilterFunc)event_filter, self);
279342
280 priv->id2entry_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
281 g_free, NULL);
282 priv->entry2indicator_hash = g_hash_table_new (g_direct_hash, g_direct_equal);343 priv->entry2indicator_hash = g_hash_table_new (g_direct_hash, g_direct_equal);
344 priv->entry2geometry_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal,
345 NULL, g_free);
283346
284 suppress_signals = TRUE;347 suppress_signals = TRUE;
285 load_indicators (self);348 load_indicators (self);
@@ -315,10 +378,8 @@
315 {378 {
316 for (l = entries; l; l = l->next)379 for (l = entries; l; l = l->next)
317 {380 {
318 gchar *id = g_strdup_printf ("%p", l->data);
319 g_hash_table_remove (self->priv->id2entry_hash, id);
320 g_hash_table_remove (self->priv->entry2indicator_hash, l->data);381 g_hash_table_remove (self->priv->entry2indicator_hash, l->data);
321 g_free (id);382 g_hash_table_remove (self->priv->entry2geometry_hash, l->data);
322 }383 }
323384
324 g_list_free (entries);385 g_list_free (entries);
@@ -520,14 +581,11 @@
520 PanelService *self)581 PanelService *self)
521{582{
522 PanelServicePrivate *priv;583 PanelServicePrivate *priv;
523 gchar *id;
524584
525 g_return_if_fail (PANEL_IS_SERVICE (self));585 g_return_if_fail (PANEL_IS_SERVICE (self));
526 g_return_if_fail (entry != NULL);586 g_return_if_fail (entry != NULL);
527 priv = self->priv;587 priv = self->priv;
528588
529 id = g_strdup_printf ("%p", entry);
530 g_hash_table_insert (priv->id2entry_hash, id, entry);
531 g_hash_table_insert (priv->entry2indicator_hash, entry, object);589 g_hash_table_insert (priv->entry2indicator_hash, entry, object);
532590
533 if (GTK_IS_LABEL (entry->label))591 if (GTK_IS_LABEL (entry->label))
@@ -576,17 +634,16 @@
576 PanelService *self)634 PanelService *self)
577{635{
578 PanelServicePrivate *priv;636 PanelServicePrivate *priv;
579 gchar *id;
580
581 g_return_if_fail (PANEL_IS_SERVICE (self));637 g_return_if_fail (PANEL_IS_SERVICE (self));
582 g_return_if_fail (entry != NULL);638 g_return_if_fail (entry != NULL);
583639
584 priv = self->priv;640 priv = self->priv;
585641
586 id = g_strdup_printf ("%p", entry);
587 g_hash_table_remove (priv->entry2indicator_hash, entry);642 g_hash_table_remove (priv->entry2indicator_hash, entry);
588 g_hash_table_remove (priv->id2entry_hash, id);643 /* Don't remove here the value from priv->entry2geometry_hash, this should
589 g_free (id);644 * be done in during the sync, to avoid false positive.
645 * FIXME this in libappmenu.so to avoid to send an "entry-removed" signal
646 * when switching the focus from a window to one of its dialog children */
590647
591 notify_object (object);648 notify_object (object);
592}649}
@@ -628,7 +685,7 @@
628 PanelService *self)685 PanelService *self)
629{686{
630 gchar *entry_id;687 gchar *entry_id;
631688
632 g_return_if_fail (PANEL_IS_SERVICE (self));689 g_return_if_fail (PANEL_IS_SERVICE (self));
633 if (entry == NULL)690 if (entry == NULL)
634 {691 {
@@ -637,7 +694,7 @@
637 }694 }
638695
639 entry_id = g_strdup_printf ("%p", entry);696 entry_id = g_strdup_printf ("%p", entry);
640 697
641 g_signal_emit (self, _service_signals[ENTRY_SHOW_NOW_CHANGED], 0, entry_id, show_now_changed);698 g_signal_emit (self, _service_signals[ENTRY_SHOW_NOW_CHANGED], 0, entry_id, show_now_changed);
642699
643 g_free (entry_id);700 g_free (entry_id);
@@ -967,6 +1024,8 @@
967 priv->last_top = 0;1024 priv->last_top = 0;
968 priv->last_bottom = 0;1025 priv->last_bottom = 0;
9691026
1027 priv->pressed_entry = NULL;
1028
970 g_signal_emit (self, _service_signals[ENTRY_ACTIVATED], 0, "");1029 g_signal_emit (self, _service_signals[ENTRY_ACTIVATED], 0, "");
971}1030}
9721031
@@ -1045,9 +1104,32 @@
1045 gint height)1104 gint height)
1046{1105{
1047 PanelServicePrivate *priv = self->priv;1106 PanelServicePrivate *priv = self->priv;
1048 IndicatorObjectEntry *entry = g_hash_table_lookup (priv->id2entry_hash, entry_id);1107 IndicatorObjectEntry *entry = get_entry_by_id (entry_id);
1049 IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry);1108 IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry);
10501109
1110 if (entry)
1111 {
1112 if (width < 0 || height < 0)
1113 {
1114 g_hash_table_remove (priv->entry2geometry_hash, entry);
1115 }
1116 else
1117 {
1118 GdkRectangle *geo = g_hash_table_lookup (priv->entry2geometry_hash, entry);
1119
1120 if (geo == NULL)
1121 {
1122 geo = g_new (GdkRectangle, 1);
1123 g_hash_table_insert (priv->entry2geometry_hash, entry, geo);
1124 }
1125
1126 geo->x = x;
1127 geo->y = y;
1128 geo->width = width;
1129 geo->height = height;
1130 }
1131 }
1132
1051 g_signal_emit (self, _service_signals[GEOMETRIES_CHANGED], 0, object, entry, x, y, width, height);1133 g_signal_emit (self, _service_signals[GEOMETRIES_CHANGED], 0, object, entry, x, y, width, height);
1052}1134}
10531135
@@ -1176,8 +1258,7 @@
1176 priv = self->priv;1258 priv = self->priv;
11771259
1178 /* Not interested in up or down */1260 /* Not interested in up or down */
1179 if (direction == GTK_MENU_DIR_NEXT1261 if (direction == GTK_MENU_DIR_NEXT || direction == GTK_MENU_DIR_PREV)
1180 || direction == GTK_MENU_DIR_PREV)
1181 return;1262 return;
11821263
1183 /* We don't want to distrupt going into submenus */1264 /* We don't want to distrupt going into submenus */
@@ -1221,15 +1302,17 @@
1221 gint32 button)1302 gint32 button)
1222{1303{
1223 PanelServicePrivate *priv = self->priv;1304 PanelServicePrivate *priv = self->priv;
1224 IndicatorObjectEntry *entry = g_hash_table_lookup (priv->id2entry_hash, entry_id);1305 IndicatorObjectEntry *entry = get_entry_by_id (entry_id);
1225 IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry);1306 IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry);
1226 GtkWidget *last_menu;1307 GtkWidget *last_menu;
12271308
1309 g_return_if_fail (entry);
1310
1228 if (priv->last_entry == entry)1311 if (priv->last_entry == entry)
1229 return;1312 return;
12301313
1231 last_menu = GTK_WIDGET (priv->last_menu);1314 last_menu = GTK_WIDGET (priv->last_menu);
1232 1315
1233 if (GTK_IS_MENU (priv->last_menu))1316 if (GTK_IS_MENU (priv->last_menu))
1234 {1317 {
1235 priv->last_x = 0;1318 priv->last_x = 0;
@@ -1247,6 +1330,8 @@
12471330
1248 if (entry != NULL)1331 if (entry != NULL)
1249 {1332 {
1333 g_signal_emit (self, _service_signals[ENTRY_ACTIVATED], 0, entry_id);
1334
1250 if (GTK_IS_MENU (entry->menu))1335 if (GTK_IS_MENU (entry->menu))
1251 {1336 {
1252 priv->last_menu = entry->menu;1337 priv->last_menu = entry->menu;
@@ -1294,8 +1379,6 @@
1294 priv->last_top = 0;1379 priv->last_top = 0;
1295 priv->last_bottom = 0;1380 priv->last_bottom = 0;
1296 }1381 }
1297
1298 g_signal_emit (self, _service_signals[ENTRY_ACTIVATED], 0, entry_id);
1299 }1382 }
13001383
1301 /* We popdown the old one last so we don't accidently send key focus back to the1384 /* We popdown the old one last so we don't accidently send key focus back to the
@@ -1312,7 +1395,9 @@
1312 guint32 timestamp)1395 guint32 timestamp)
1313{1396{
1314 PanelServicePrivate *priv = self->priv;1397 PanelServicePrivate *priv = self->priv;
1315 IndicatorObjectEntry *entry = g_hash_table_lookup (priv->id2entry_hash, entry_id);1398 IndicatorObjectEntry *entry = get_entry_by_id (entry_id);
1399 g_return_if_fail (entry);
1400
1316 IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry);1401 IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry);
13171402
1318 g_signal_emit_by_name(object, INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE, entry,1403 g_signal_emit_by_name(object, INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE, entry,
@@ -1325,11 +1410,12 @@
1325 gint32 delta)1410 gint32 delta)
1326{1411{
1327 PanelServicePrivate *priv = self->priv;1412 PanelServicePrivate *priv = self->priv;
1328 IndicatorObjectEntry *entry = g_hash_table_lookup (priv->id2entry_hash, entry_id);1413 IndicatorObjectEntry *entry = get_entry_by_id (entry_id);
1414 g_return_if_fail (entry);
1415
1329 IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry);1416 IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry);
1330 GdkScrollDirection direction = delta < 0 ? GDK_SCROLL_DOWN : GDK_SCROLL_UP;1417 GdkScrollDirection direction = delta < 0 ? GDK_SCROLL_DOWN : GDK_SCROLL_UP;
13311418
1332 g_signal_emit_by_name(object, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, entry,1419 g_signal_emit_by_name(object, INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, entry,
1333 abs(delta/120), direction);1420 abs(delta/120), direction);
1334}1421}
1335