Merge lp:~3v1n0/unity/panelmenu-fixes into lp:unity
- panelmenu-fixes
- Merge into trunk
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 |
Commit message
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::GetGraphic
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 / PanelIndicators
- 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:/
Gord Allott (gordallott) wrote : | # |
looks okay from here +1
Jason Smith (jassmith) wrote : | # |
Switching to approved
Neil J. Patel (njpatel) wrote : | # |
Excellent work Marco, approved.
Preview Diff
1 | === modified file 'plugins/unityshell/src/PanelIndicatorsView.cpp' | |||
2 | --- plugins/unityshell/src/PanelIndicatorsView.cpp 2011-09-20 17:25:06 +0000 | |||
3 | +++ plugins/unityshell/src/PanelIndicatorsView.cpp 2011-09-25 12:09:24 +0000 | |||
4 | @@ -21,14 +21,9 @@ | |||
5 | 21 | #include <Nux/Nux.h> | 21 | #include <Nux/Nux.h> |
6 | 22 | #include <Nux/Area.h> | 22 | #include <Nux/Area.h> |
7 | 23 | #include <Nux/HLayout.h> | 23 | #include <Nux/HLayout.h> |
8 | 24 | #include <Nux/VLayout.h> | ||
9 | 25 | 24 | ||
10 | 26 | #include <NuxCore/Logger.h> | 25 | #include <NuxCore/Logger.h> |
11 | 27 | 26 | ||
12 | 28 | #include <NuxGraphics/GLThread.h> | ||
13 | 29 | #include <Nux/BaseWindow.h> | ||
14 | 30 | #include <Nux/WindowCompositor.h> | ||
15 | 31 | |||
16 | 32 | #include "PanelIndicatorsView.h" | 27 | #include "PanelIndicatorsView.h" |
17 | 33 | 28 | ||
18 | 34 | #include <UnityCore/Variant.h> | 29 | #include <UnityCore/Variant.h> |
19 | @@ -55,9 +50,9 @@ | |||
20 | 55 | 50 | ||
21 | 56 | PanelIndicatorsView::~PanelIndicatorsView() | 51 | PanelIndicatorsView::~PanelIndicatorsView() |
22 | 57 | { | 52 | { |
24 | 58 | for (auto it = indicators_connections_.begin(); it != indicators_connections_.end(); it++) | 53 | for (auto ind : indicators_connections_) |
25 | 59 | { | 54 | { |
27 | 60 | for (auto conn : it->second) | 55 | for (auto conn : ind.second) |
28 | 61 | conn.disconnect(); | 56 | conn.disconnect(); |
29 | 62 | } | 57 | } |
30 | 63 | } | 58 | } |
31 | @@ -130,11 +125,9 @@ | |||
32 | 130 | PanelIndicatorsView::QueueDraw() | 125 | PanelIndicatorsView::QueueDraw() |
33 | 131 | { | 126 | { |
34 | 132 | nux::View::QueueDraw(); | 127 | nux::View::QueueDraw(); |
40 | 133 | for (auto i = entries_.begin(), end = entries_.end(); i != end; ++i) | 128 | |
41 | 134 | { | 129 | for (auto entry : entries_) |
42 | 135 | if (i->second) | 130 | entry.second->QueueDraw(); |
38 | 136 | i->second->QueueDraw(); | ||
39 | 137 | } | ||
43 | 138 | } | 131 | } |
44 | 139 | 132 | ||
45 | 140 | bool | 133 | bool |
46 | @@ -155,9 +148,9 @@ | |||
47 | 155 | bool | 148 | bool |
48 | 156 | PanelIndicatorsView::ActivateIfSensitive() | 149 | PanelIndicatorsView::ActivateIfSensitive() |
49 | 157 | { | 150 | { |
51 | 158 | for (auto i = entries_.begin(), end = entries_.end(); i != end; ++i) | 151 | for (auto entry : entries_) |
52 | 159 | { | 152 | { |
54 | 160 | PanelIndicatorEntryView* view = i->second; | 153 | PanelIndicatorEntryView* view = entry.second; |
55 | 161 | if (view->IsSensitive()) | 154 | if (view->IsSensitive()) |
56 | 162 | { | 155 | { |
57 | 163 | view->Activate(); | 156 | view->Activate(); |
58 | @@ -170,11 +163,8 @@ | |||
59 | 170 | void | 163 | void |
60 | 171 | PanelIndicatorsView::GetGeometryForSync(indicator::EntryLocationMap& locations) | 164 | PanelIndicatorsView::GetGeometryForSync(indicator::EntryLocationMap& locations) |
61 | 172 | { | 165 | { |
67 | 173 | for (auto i = entries_.begin(), end = entries_.end(); i != end; ++i) | 166 | for (auto entry : entries_) |
68 | 174 | { | 167 | entry.second->GetGeometryForSync(locations); |
64 | 175 | if (i->second) | ||
65 | 176 | i->second->GetGeometryForSync(locations); | ||
66 | 177 | } | ||
69 | 178 | } | 168 | } |
70 | 179 | 169 | ||
71 | 180 | bool | 170 | bool |
72 | @@ -228,37 +218,45 @@ | |||
73 | 228 | PanelIndicatorsView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) | 218 | PanelIndicatorsView::DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw) |
74 | 229 | { | 219 | { |
75 | 230 | GfxContext.PushClippingRectangle(GetGeometry()); | 220 | GfxContext.PushClippingRectangle(GetGeometry()); |
78 | 231 | if (layout_) | 221 | layout_->ProcessDraw(GfxContext, force_draw); |
77 | 232 | layout_->ProcessDraw(GfxContext, force_draw); | ||
79 | 233 | GfxContext.PopClippingRectangle(); | 222 | GfxContext.PopClippingRectangle(); |
80 | 234 | } | 223 | } |
81 | 235 | 224 | ||
84 | 236 | void | 225 | PanelIndicatorEntryView * |
85 | 237 | PanelIndicatorsView::OnEntryAdded(indicator::Entry::Ptr const& entry) | 226 | PanelIndicatorsView::AddEntry(indicator::Entry::Ptr const& entry, int padding, IndicatorEntryPosition pos) |
86 | 238 | { | 227 | { |
88 | 239 | auto view = new PanelIndicatorEntryView(entry); | 228 | PanelIndicatorEntryView *view; |
89 | 229 | int entry_pos = pos; | ||
90 | 230 | |||
91 | 231 | if (padding > -1) | ||
92 | 232 | view = new PanelIndicatorEntryView(entry, padding); | ||
93 | 233 | else | ||
94 | 234 | view = new PanelIndicatorEntryView(entry); | ||
95 | 235 | |||
96 | 240 | view->refreshed.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryRefreshed)); | 236 | view->refreshed.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryRefreshed)); |
97 | 241 | 237 | ||
101 | 242 | int indicator_pos = nux::NUX_LAYOUT_BEGIN; | 238 | if (entry_pos == IndicatorEntryPosition::AUTO) |
99 | 243 | |||
100 | 244 | if (entry->priority() > -1) | ||
102 | 245 | { | 239 | { |
104 | 246 | for (nux::Area* &area : layout_->GetChildren()) | 240 | entry_pos = nux::NUX_LAYOUT_BEGIN; |
105 | 241 | |||
106 | 242 | if (entry->priority() > -1) | ||
107 | 247 | { | 243 | { |
111 | 248 | auto en = dynamic_cast<PanelIndicatorEntryView*>(area); | 244 | for (auto area : layout_->GetChildren()) |
109 | 249 | |||
110 | 250 | if (en) | ||
112 | 251 | { | 245 | { |
117 | 252 | if (en && entry->priority() <= en->GetEntryPriority()) | 246 | auto en = dynamic_cast<PanelIndicatorEntryView*>(area); |
118 | 253 | break; | 247 | |
119 | 254 | 248 | if (en) | |
120 | 255 | indicator_pos++; | 249 | { |
121 | 250 | if (en && entry->priority() <= en->GetEntryPriority()) | ||
122 | 251 | break; | ||
123 | 252 | |||
124 | 253 | entry_pos++; | ||
125 | 254 | } | ||
126 | 256 | } | 255 | } |
127 | 257 | } | 256 | } |
128 | 258 | } | 257 | } |
129 | 259 | 258 | ||
132 | 260 | nux::LayoutPosition pos = (nux::LayoutPosition) indicator_pos; | 259 | layout_->AddView(view, 0, nux::eCenter, nux::eFull, 1.0, (nux::LayoutPosition) entry_pos); |
131 | 261 | layout_->AddView(view, 0, nux::eCenter, nux::eFull, 1.0, pos); | ||
133 | 262 | layout_->SetContentDistribution(nux::eStackRight); | 260 | layout_->SetContentDistribution(nux::eStackRight); |
134 | 263 | entries_[entry->id()] = view; | 261 | entries_[entry->id()] = view; |
135 | 264 | 262 | ||
136 | @@ -267,6 +265,14 @@ | |||
137 | 267 | QueueDraw(); | 265 | QueueDraw(); |
138 | 268 | 266 | ||
139 | 269 | on_indicator_updated.emit(view); | 267 | on_indicator_updated.emit(view); |
140 | 268 | |||
141 | 269 | return view; | ||
142 | 270 | } | ||
143 | 271 | |||
144 | 272 | void | ||
145 | 273 | PanelIndicatorsView::OnEntryAdded(indicator::Entry::Ptr const& entry) | ||
146 | 274 | { | ||
147 | 275 | AddEntry(entry); | ||
148 | 270 | } | 276 | } |
149 | 271 | 277 | ||
150 | 272 | void | 278 | void |
151 | @@ -279,28 +285,36 @@ | |||
152 | 279 | } | 285 | } |
153 | 280 | 286 | ||
154 | 281 | void | 287 | void |
156 | 282 | PanelIndicatorsView::OnEntryRemoved(std::string const& entry_id) | 288 | PanelIndicatorsView::RemoveEntry(std::string const& entry_id) |
157 | 283 | { | 289 | { |
158 | 284 | PanelIndicatorEntryView* view = entries_[entry_id]; | 290 | PanelIndicatorEntryView* view = entries_[entry_id]; |
159 | 285 | 291 | ||
160 | 286 | if (view) | 292 | if (view) |
161 | 287 | { | 293 | { |
162 | 288 | on_indicator_updated.emit(view); | ||
163 | 289 | layout_->RemoveChildObject(view); | 294 | layout_->RemoveChildObject(view); |
164 | 290 | entries_.erase(entry_id); | 295 | entries_.erase(entry_id); |
165 | 296 | on_indicator_updated.emit(view); | ||
166 | 291 | 297 | ||
167 | 292 | QueueRelayout(); | 298 | QueueRelayout(); |
168 | 293 | QueueDraw(); | 299 | QueueDraw(); |
169 | 294 | } | 300 | } |
170 | 295 | } | 301 | } |
171 | 296 | 302 | ||
173 | 297 | void PanelIndicatorsView::DashShown() | 303 | void |
174 | 304 | PanelIndicatorsView::OnEntryRemoved(std::string const& entry_id) | ||
175 | 305 | { | ||
176 | 306 | RemoveEntry(entry_id); | ||
177 | 307 | } | ||
178 | 308 | |||
179 | 309 | void | ||
180 | 310 | PanelIndicatorsView::DashShown() | ||
181 | 298 | { | 311 | { |
182 | 299 | for (auto entry: entries_) | 312 | for (auto entry: entries_) |
183 | 300 | entry.second->DashShown(); | 313 | entry.second->DashShown(); |
184 | 301 | } | 314 | } |
185 | 302 | 315 | ||
187 | 303 | void PanelIndicatorsView::DashHidden() | 316 | void |
188 | 317 | PanelIndicatorsView::DashHidden() | ||
189 | 304 | { | 318 | { |
190 | 305 | for (auto entry: entries_) | 319 | for (auto entry: entries_) |
191 | 306 | entry.second->DashHidden(); | 320 | entry.second->DashHidden(); |
192 | 307 | 321 | ||
193 | === modified file 'plugins/unityshell/src/PanelIndicatorsView.h' | |||
194 | --- plugins/unityshell/src/PanelIndicatorsView.h 2011-09-15 11:33:58 +0000 | |||
195 | +++ plugins/unityshell/src/PanelIndicatorsView.h 2011-09-25 12:09:24 +0000 | |||
196 | @@ -22,6 +22,7 @@ | |||
197 | 22 | #define PANEL_INDICATORS_VIEW_H | 22 | #define PANEL_INDICATORS_VIEW_H |
198 | 23 | 23 | ||
199 | 24 | #include <Nux/View.h> | 24 | #include <Nux/View.h> |
200 | 25 | #include <Nux/Layout.h> | ||
201 | 25 | 26 | ||
202 | 26 | #include <UnityCore/Indicator.h> | 27 | #include <UnityCore/Indicator.h> |
203 | 27 | 28 | ||
204 | @@ -41,6 +42,17 @@ | |||
205 | 41 | void AddIndicator(indicator::Indicator::Ptr const& indicator); | 42 | void AddIndicator(indicator::Indicator::Ptr const& indicator); |
206 | 42 | void RemoveIndicator(indicator::Indicator::Ptr const& indicator); | 43 | void RemoveIndicator(indicator::Indicator::Ptr const& indicator); |
207 | 43 | 44 | ||
208 | 45 | typedef enum { | ||
209 | 46 | AUTO = -1, | ||
210 | 47 | START = nux::NUX_LAYOUT_BEGIN, | ||
211 | 48 | END = nux::NUX_LAYOUT_END, | ||
212 | 49 | } IndicatorEntryPosition; | ||
213 | 50 | |||
214 | 51 | PanelIndicatorEntryView* AddEntry(indicator::Entry::Ptr const& entry, | ||
215 | 52 | int padding = -1, | ||
216 | 53 | IndicatorEntryPosition pos = AUTO); | ||
217 | 54 | void RemoveEntry(std::string const& entry_id); | ||
218 | 55 | |||
219 | 44 | bool OnPointerMoved(int x, int y); | 56 | bool OnPointerMoved(int x, int y); |
220 | 45 | bool ActivateEntry(std::string const& entry_id); | 57 | bool ActivateEntry(std::string const& entry_id); |
221 | 46 | bool ActivateIfSensitive(); | 58 | bool ActivateIfSensitive(); |
222 | @@ -51,7 +63,7 @@ | |||
223 | 51 | virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); | 63 | virtual void DrawContent(nux::GraphicsEngine& GfxContext, bool force_draw); |
224 | 52 | virtual void QueueDraw(); | 64 | virtual void QueueDraw(); |
225 | 53 | 65 | ||
227 | 54 | virtual void OnEntryAdded(indicator::Entry::Ptr const& proxy); | 66 | virtual void OnEntryAdded(indicator::Entry::Ptr const& entry); |
228 | 55 | virtual void OnEntryRefreshed(PanelIndicatorEntryView* view); | 67 | virtual void OnEntryRefreshed(PanelIndicatorEntryView* view); |
229 | 56 | virtual void OnEntryRemoved(std::string const& entry_id); | 68 | virtual void OnEntryRemoved(std::string const& entry_id); |
230 | 57 | 69 | ||
231 | 58 | 70 | ||
232 | === modified file 'plugins/unityshell/src/PanelMenuView.cpp' | |||
233 | --- plugins/unityshell/src/PanelMenuView.cpp 2011-09-19 03:03:53 +0000 | |||
234 | +++ plugins/unityshell/src/PanelMenuView.cpp 2011-09-25 12:09:24 +0000 | |||
235 | @@ -15,11 +15,11 @@ | |||
236 | 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/>. |
237 | 16 | * | 16 | * |
238 | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
239 | 18 | * Marco Trevisan <mail@3v1n0.net> | ||
240 | 18 | */ | 19 | */ |
241 | 19 | #include <glib.h> | 20 | #include <glib.h> |
242 | 20 | #include <pango/pangocairo.h> | 21 | #include <pango/pangocairo.h> |
243 | 21 | #include <gtk/gtk.h> | 22 | #include <gtk/gtk.h> |
244 | 22 | #include <X11/cursorfont.h> | ||
245 | 23 | 23 | ||
246 | 24 | #include <Nux/Nux.h> | 24 | #include <Nux/Nux.h> |
247 | 25 | #include <Nux/HLayout.h> | 25 | #include <Nux/HLayout.h> |
248 | @@ -64,7 +64,6 @@ | |||
249 | 64 | _title_layer(NULL), | 64 | _title_layer(NULL), |
250 | 65 | _util_cg(CAIRO_FORMAT_ARGB32, 1, 1), | 65 | _util_cg(CAIRO_FORMAT_ARGB32, 1, 1), |
251 | 66 | _gradient_texture(NULL), | 66 | _gradient_texture(NULL), |
252 | 67 | _title_tex(NULL), | ||
253 | 68 | _is_inside(false), | 67 | _is_inside(false), |
254 | 69 | _is_maximized(false), | 68 | _is_maximized(false), |
255 | 70 | _is_own_window(false), | 69 | _is_own_window(false), |
256 | @@ -77,15 +76,12 @@ | |||
257 | 77 | _monitor(0), | 76 | _monitor(0), |
258 | 78 | _active_xid(0), | 77 | _active_xid(0), |
259 | 79 | _active_moved_id(0), | 78 | _active_moved_id(0), |
260 | 79 | _update_show_now_id(0), | ||
261 | 80 | _place_shown_interest(0), | 80 | _place_shown_interest(0), |
262 | 81 | _place_hidden_interest(0) | 81 | _place_hidden_interest(0) |
263 | 82 | { | 82 | { |
264 | 83 | WindowManager* win_manager; | 83 | WindowManager* win_manager; |
265 | 84 | 84 | ||
266 | 85 | _matcher = bamf_matcher_get_default(); | ||
267 | 86 | _activate_window_changed_id = g_signal_connect(_matcher, "active-window-changed", | ||
268 | 87 | G_CALLBACK(on_active_window_changed), this); | ||
269 | 88 | |||
270 | 89 | // TODO: kill _menu_layout - should just use the _layout defined | 85 | // TODO: kill _menu_layout - should just use the _layout defined |
271 | 90 | // in the base class. | 86 | // in the base class. |
272 | 91 | _menu_layout = new nux::HLayout("", NUX_TRACKER_LOCATION); | 87 | _menu_layout = new nux::HLayout("", NUX_TRACKER_LOCATION); |
273 | @@ -96,6 +92,10 @@ | |||
274 | 96 | */ | 92 | */ |
275 | 97 | layout_ = _menu_layout; | 93 | layout_ = _menu_layout; |
276 | 98 | 94 | ||
277 | 95 | _matcher = bamf_matcher_get_default(); | ||
278 | 96 | _activate_window_changed_id = g_signal_connect(_matcher, "active-window-changed", | ||
279 | 97 | G_CALLBACK(on_active_window_changed), this); | ||
280 | 98 | |||
281 | 99 | _padding = padding; | 99 | _padding = padding; |
282 | 100 | _name_changed_callback_instance = NULL; | 100 | _name_changed_callback_instance = NULL; |
283 | 101 | _name_changed_callback_id = 0; | 101 | _name_changed_callback_id = 0; |
284 | @@ -109,23 +109,23 @@ | |||
285 | 109 | _window_buttons->restore_clicked.connect(sigc::mem_fun(this, &PanelMenuView::OnRestoreClicked)); | 109 | _window_buttons->restore_clicked.connect(sigc::mem_fun(this, &PanelMenuView::OnRestoreClicked)); |
286 | 110 | _window_buttons->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); | 110 | _window_buttons->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); |
287 | 111 | _window_buttons->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); | 111 | _window_buttons->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); |
289 | 112 | _window_buttons->mouse_move.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseMove)); | 112 | //_window_buttons->mouse_move.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseMove)); |
290 | 113 | 113 | ||
291 | 114 | _panel_titlebar_grab_area = new PanelTitlebarGrabArea(); | 114 | _panel_titlebar_grab_area = new PanelTitlebarGrabArea(); |
292 | 115 | _panel_titlebar_grab_area->SetParentObject(this); | 115 | _panel_titlebar_grab_area->SetParentObject(this); |
293 | 116 | _panel_titlebar_grab_area->SinkReference(); | 116 | _panel_titlebar_grab_area->SinkReference(); |
294 | 117 | _panel_titlebar_grab_area->mouse_down.connect(sigc::mem_fun(this, &PanelMenuView::OnMouseMiddleClicked)); | ||
295 | 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)); |
296 | 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)); |
297 | 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)); |
300 | 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)); |
299 | 121 | _panel_titlebar_grab_area->mouse_middleclick.connect(sigc::mem_fun(this, &PanelMenuView::OnMouseMiddleClicked)); | ||
301 | 122 | 122 | ||
302 | 123 | win_manager = WindowManager::Default(); | 123 | win_manager = WindowManager::Default(); |
303 | 124 | 124 | ||
304 | 125 | win_manager->window_minimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMinimized)); | 125 | win_manager->window_minimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMinimized)); |
305 | 126 | win_manager->window_unminimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowUnminimized)); | 126 | win_manager->window_unminimized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowUnminimized)); |
308 | 127 | win_manager->initiate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadInitiate)); | 127 | //win_manager->initiate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadInitiate)); |
309 | 128 | win_manager->terminate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadTerminate)); | 128 | //win_manager->terminate_spread.connect(sigc::mem_fun(this, &PanelMenuView::OnSpreadTerminate)); |
310 | 129 | 129 | ||
311 | 130 | win_manager->window_maximized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMaximized)); | 130 | win_manager->window_maximized.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowMaximized)); |
312 | 131 | win_manager->window_restored.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowRestored)); | 131 | win_manager->window_restored.connect(sigc::mem_fun(this, &PanelMenuView::OnWindowRestored)); |
313 | @@ -136,7 +136,7 @@ | |||
314 | 136 | 136 | ||
315 | 137 | mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); | 137 | mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); |
316 | 138 | mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); | 138 | mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); |
318 | 139 | mouse_move.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseMove)); | 139 | //mouse_move.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseMove)); |
319 | 140 | 140 | ||
320 | 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)); |
321 | 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)); |
322 | @@ -166,8 +166,6 @@ | |||
323 | 166 | 166 | ||
324 | 167 | if (_title_layer) | 167 | if (_title_layer) |
325 | 168 | delete _title_layer; | 168 | delete _title_layer; |
326 | 169 | if (_title_tex) | ||
327 | 170 | _title_tex->UnReference(); | ||
328 | 171 | 169 | ||
329 | 172 | _menu_layout->UnReference(); | 170 | _menu_layout->UnReference(); |
330 | 173 | _window_buttons->UnReference(); | 171 | _window_buttons->UnReference(); |
331 | @@ -345,11 +343,9 @@ | |||
332 | 345 | else | 343 | else |
333 | 346 | { | 344 | { |
334 | 347 | bool have_valid_entries = false; | 345 | bool have_valid_entries = false; |
338 | 348 | Entries::iterator it, eit = entries_.end(); | 346 | for (auto entry : entries_) |
336 | 349 | |||
337 | 350 | for (it = entries_.begin(); it != eit; ++it) | ||
339 | 351 | { | 347 | { |
341 | 352 | if (it->second->IsEntryValid()) | 348 | if (entry.second->IsEntryValid()) |
342 | 353 | { | 349 | { |
343 | 354 | have_valid_entries = true; | 350 | have_valid_entries = true; |
344 | 355 | break; | 351 | break; |
345 | @@ -408,12 +404,12 @@ | |||
346 | 408 | nux::TexCoordXForm texxform1; | 404 | nux::TexCoordXForm texxform1; |
347 | 409 | 405 | ||
348 | 410 | // Modulate the checkboard and the gradient texture | 406 | // Modulate the checkboard and the gradient texture |
350 | 411 | if (_title_tex) | 407 | if (_title_layer) |
351 | 412 | GfxContext.QRP_2TexMod(geo.x, geo.y, | 408 | GfxContext.QRP_2TexMod(geo.x, geo.y, |
352 | 413 | geo.width, geo.height, | 409 | geo.width, geo.height, |
353 | 414 | _gradient_texture, texxform0, | 410 | _gradient_texture, texxform0, |
354 | 415 | nux::color::White, | 411 | nux::color::White, |
356 | 416 | _title_tex->GetDeviceTexture(), | 412 | _title_layer->GetDeviceTexture(), |
357 | 417 | texxform1, | 413 | texxform1, |
358 | 418 | nux::color::White); | 414 | nux::color::White); |
359 | 419 | 415 | ||
360 | @@ -449,14 +445,16 @@ | |||
361 | 449 | if (!_is_own_window && !_places_showing && _we_control_active) | 445 | if (!_is_own_window && !_places_showing && _we_control_active) |
362 | 450 | { | 446 | { |
363 | 451 | if (_is_inside || _last_active_view || _show_now_activated) | 447 | if (_is_inside || _last_active_view || _show_now_activated) |
364 | 452 | layout_->ProcessDraw(GfxContext, force_draw); | ||
365 | 453 | } | ||
366 | 454 | |||
367 | 455 | if ((!_is_own_window && _we_control_active && _is_maximized && (_is_inside || _show_now_activated)) || | ||
368 | 456 | _places_showing) | ||
369 | 457 | { | 448 | { |
371 | 458 | _window_buttons->ProcessDraw(GfxContext, true); | 449 | _menu_layout->ProcessDraw(GfxContext, force_draw); |
372 | 459 | } | 450 | } |
373 | 451 | } | ||
374 | 452 | |||
375 | 453 | if ((!_is_own_window && _we_control_active && _is_maximized && | ||
376 | 454 | (_is_inside || _show_now_activated)) || _places_showing) | ||
377 | 455 | { | ||
378 | 456 | _window_buttons->ProcessDraw(GfxContext, true); | ||
379 | 457 | } | ||
380 | 460 | 458 | ||
381 | 461 | GfxContext.PopClippingRectangle(); | 459 | GfxContext.PopClippingRectangle(); |
382 | 462 | } | 460 | } |
383 | @@ -682,12 +680,7 @@ | |||
384 | 682 | nux::color::White, | 680 | nux::color::White, |
385 | 683 | true, | 681 | true, |
386 | 684 | rop); | 682 | rop); |
393 | 685 | 683 | texture2D->UnReference(); | |
388 | 686 | if (_title_tex) | ||
389 | 687 | _title_tex->UnReference(); | ||
390 | 688 | |||
391 | 689 | _title_tex = texture2D; | ||
392 | 690 | |||
394 | 691 | g_free(label); | 684 | g_free(label); |
395 | 692 | } | 685 | } |
396 | 693 | 686 | ||
397 | @@ -709,26 +702,26 @@ | |||
398 | 709 | FullRedraw(); | 702 | FullRedraw(); |
399 | 710 | } | 703 | } |
400 | 711 | 704 | ||
402 | 712 | void PanelMenuView::OnEntryAdded(unity::indicator::Entry::Ptr const& proxy) | 705 | void |
403 | 706 | PanelMenuView::OnEntryAdded(unity::indicator::Entry::Ptr const& entry) | ||
404 | 713 | { | 707 | { |
406 | 714 | PanelIndicatorEntryView* view = new PanelIndicatorEntryView(proxy, 6); | 708 | auto view = AddEntry(entry, 6, IndicatorEntryPosition::END); |
407 | 709 | |||
408 | 710 | entry->show_now_changed.connect(sigc::mem_fun(this, &PanelMenuView::UpdateShowNow)); | ||
409 | 711 | |||
410 | 715 | view->active_changed.connect(sigc::mem_fun(this, &PanelMenuView::OnActiveChanged)); | 712 | view->active_changed.connect(sigc::mem_fun(this, &PanelMenuView::OnActiveChanged)); |
411 | 716 | view->refreshed.connect(sigc::mem_fun(this, &PanelIndicatorsView::OnEntryRefreshed)); | ||
412 | 717 | proxy->show_now_changed.connect(sigc::mem_fun(this, &PanelMenuView::UpdateShowNow)); | ||
413 | 718 | |||
414 | 719 | _menu_layout->AddView(view, 0, nux::eCenter, nux::eFull, 1.0, nux::NUX_LAYOUT_END); | ||
415 | 720 | _menu_layout->SetContentDistribution(nux::eStackLeft); | ||
416 | 721 | |||
417 | 722 | entries_[proxy->id()] = view; | ||
418 | 723 | AddChild(view); | ||
419 | 724 | |||
420 | 725 | view->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); | 713 | view->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); |
421 | 726 | view->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); | 714 | view->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); |
427 | 727 | 715 | } | |
428 | 728 | QueueRelayout(); | 716 | |
429 | 729 | QueueDraw(); | 717 | void |
430 | 730 | 718 | PanelMenuView::AllMenusClosed() | |
431 | 731 | on_indicator_updated.emit(view); | 719 | { |
432 | 720 | auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); | ||
433 | 721 | _is_inside = GetAbsoluteGeometry().IsPointInside(mouse.x, mouse.y); | ||
434 | 722 | _last_active_view = NULL; | ||
435 | 723 | |||
436 | 724 | FullRedraw(); | ||
437 | 732 | } | 725 | } |
438 | 733 | 726 | ||
439 | 734 | void | 727 | void |
440 | @@ -815,7 +808,6 @@ | |||
441 | 815 | void | 808 | void |
442 | 816 | PanelMenuView::OnWindowMinimized(guint32 xid) | 809 | PanelMenuView::OnWindowMinimized(guint32 xid) |
443 | 817 | { | 810 | { |
444 | 818 | |||
445 | 819 | if (WindowManager::Default()->IsWindowMaximized(xid)) | 811 | if (WindowManager::Default()->IsWindowMaximized(xid)) |
446 | 820 | { | 812 | { |
447 | 821 | WindowManager::Default()->Decorate(xid); | 813 | WindowManager::Default()->Decorate(xid); |
448 | @@ -844,25 +836,32 @@ | |||
449 | 844 | PanelMenuView::OnWindowMaximized(guint xid) | 836 | PanelMenuView::OnWindowMaximized(guint xid) |
450 | 845 | { | 837 | { |
451 | 846 | BamfWindow* window; | 838 | BamfWindow* window; |
452 | 839 | bool updated = false; | ||
453 | 847 | 840 | ||
454 | 848 | window = bamf_matcher_get_active_window(_matcher); | 841 | window = bamf_matcher_get_active_window(_matcher); |
455 | 849 | if (BAMF_IS_WINDOW(window) && bamf_window_get_xid(window) == xid) | 842 | if (BAMF_IS_WINDOW(window) && bamf_window_get_xid(window) == xid) |
456 | 850 | { | 843 | { |
457 | 851 | _is_maximized = true; | 844 | _is_maximized = true; |
458 | 845 | |||
459 | 846 | // We need to update the _is_inside state in the case of maximization by grab | ||
460 | 847 | auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); | ||
461 | 848 | _is_inside = GetAbsoluteGeometry().IsPointInside(mouse.x, mouse.y); | ||
462 | 849 | updated = true; | ||
463 | 852 | } | 850 | } |
464 | 853 | 851 | ||
465 | 854 | // update the state of the window in the _decor_map | 852 | // update the state of the window in the _decor_map |
466 | 855 | _decor_map[xid] = WindowManager::Default()->IsWindowDecorated(xid); | 853 | _decor_map[xid] = WindowManager::Default()->IsWindowDecorated(xid); |
467 | 856 | 854 | ||
468 | 857 | if (_decor_map[xid]) | 855 | if (_decor_map[xid]) |
469 | 858 | { | ||
470 | 859 | WindowManager::Default()->Undecorate(xid); | 856 | WindowManager::Default()->Undecorate(xid); |
471 | 860 | } | ||
472 | 861 | 857 | ||
473 | 862 | _maximized_set.insert(xid); | 858 | _maximized_set.insert(xid); |
474 | 863 | 859 | ||
477 | 864 | Refresh(); | 860 | if (updated) |
478 | 865 | FullRedraw(); | 861 | { |
479 | 862 | Refresh(); | ||
480 | 863 | FullRedraw(); | ||
481 | 864 | } | ||
482 | 866 | } | 865 | } |
483 | 867 | 866 | ||
484 | 868 | void | 867 | void |
485 | @@ -870,6 +869,9 @@ | |||
486 | 870 | { | 869 | { |
487 | 871 | BamfWindow* window; | 870 | BamfWindow* window; |
488 | 872 | 871 | ||
489 | 872 | if (_maximized_set.find(xid) == _maximized_set.end()) | ||
490 | 873 | return; | ||
491 | 874 | |||
492 | 873 | window = bamf_matcher_get_active_window(_matcher); | 875 | window = bamf_matcher_get_active_window(_matcher); |
493 | 874 | if (BAMF_IS_WINDOW(window) && bamf_window_get_xid(window) == xid) | 876 | if (BAMF_IS_WINDOW(window) && bamf_window_get_xid(window) == xid) |
494 | 875 | { | 877 | { |
495 | @@ -878,9 +880,7 @@ | |||
496 | 878 | } | 880 | } |
497 | 879 | 881 | ||
498 | 880 | if (_decor_map[xid]) | 882 | if (_decor_map[xid]) |
499 | 881 | { | ||
500 | 882 | WindowManager::Default()->Decorate(xid); | 883 | WindowManager::Default()->Decorate(xid); |
501 | 883 | } | ||
502 | 884 | 884 | ||
503 | 885 | _maximized_set.erase(xid); | 885 | _maximized_set.erase(xid); |
504 | 886 | 886 | ||
505 | @@ -976,7 +976,7 @@ | |||
506 | 976 | nux::Geometry monitor = UScreen::GetDefault()->GetMonitorGeometry(_monitor); | 976 | nux::Geometry monitor = UScreen::GetDefault()->GetMonitorGeometry(_monitor); |
507 | 977 | 977 | ||
508 | 978 | // Find the front-most of the maximized windows we are controlling | 978 | // Find the front-most of the maximized windows we are controlling |
510 | 979 | foreach(guint32 xid, _maximized_set) | 979 | for (auto xid : _maximized_set) |
511 | 980 | { | 980 | { |
512 | 981 | // We can safely assume only the front-most is visible | 981 | // We can safely assume only the front-most is visible |
513 | 982 | if (WindowManager::Default()->IsWindowOnCurrentDesktop(xid) | 982 | if (WindowManager::Default()->IsWindowOnCurrentDesktop(xid) |
514 | @@ -994,37 +994,48 @@ | |||
515 | 994 | } | 994 | } |
516 | 995 | 995 | ||
517 | 996 | void | 996 | void |
519 | 997 | PanelMenuView::OnMaximizedGrabStart(int x, int y) | 997 | PanelMenuView::OnMaximizedGrabStart(int x, int y, unsigned long button_flags, unsigned long) |
520 | 998 | { | 998 | { |
521 | 999 | if (nux::GetEventButton(button_flags) != 1 || _places_showing) | ||
522 | 1000 | return; | ||
523 | 1001 | |||
524 | 999 | // When Start dragging the panelmenu of a maximized window, change cursor | 1002 | // When Start dragging the panelmenu of a maximized window, change cursor |
525 | 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. |
526 | 1001 | // | 1004 | // |
527 | 1002 | // This is a workaround to avoid that the grid plugin would be fired | 1005 | // This is a workaround to avoid that the grid plugin would be fired |
528 | 1003 | // showing the window shape preview effect. See bug #838923 | 1006 | // showing the window shape preview effect. See bug #838923 |
529 | 1004 | if (GetMaximizedWindow() != 0) | 1007 | if (GetMaximizedWindow() != 0) |
537 | 1005 | { | 1008 | _panel_titlebar_grab_area->SetGrabbed(true); |
531 | 1006 | Display* d = nux::GetGraphicsDisplay()->GetX11Display(); | ||
532 | 1007 | nux::BaseWindow *bw = static_cast<nux::BaseWindow*>(GetTopLevelViewWindow()); | ||
533 | 1008 | Cursor c = XCreateFontCursor(d, XC_fleur); | ||
534 | 1009 | XDefineCursor(d, bw->GetInputWindowId(), c); | ||
535 | 1010 | XFreeCursor(d, c); | ||
536 | 1011 | } | ||
538 | 1012 | } | 1009 | } |
539 | 1013 | 1010 | ||
540 | 1014 | void | 1011 | void |
542 | 1015 | PanelMenuView::OnMaximizedGrabMove(int x, int y, int, int, unsigned long, unsigned long) | 1012 | PanelMenuView::OnMaximizedGrabMove(int x, int y, int, int, unsigned long button_flags, unsigned long) |
543 | 1016 | { | 1013 | { |
544 | 1014 | // FIXME nux doesn't export it with drag event. | ||
545 | 1015 | // if (nux::GetEventButton(button_flags) != 1) | ||
546 | 1016 | // return; | ||
547 | 1017 | |||
548 | 1018 | // We use this, due to the problem above | ||
549 | 1019 | if (!_panel_titlebar_grab_area->IsGrabbed()) | ||
550 | 1020 | return; | ||
551 | 1021 | |||
552 | 1022 | auto panel = static_cast<nux::BaseWindow*>(GetTopLevelViewWindow()); | ||
553 | 1023 | |||
554 | 1024 | if (!panel) | ||
555 | 1025 | return; | ||
556 | 1026 | |||
557 | 1027 | x += _panel_titlebar_grab_area->GetAbsoluteX(); | ||
558 | 1028 | y += _panel_titlebar_grab_area->GetAbsoluteY(); | ||
559 | 1029 | |||
560 | 1017 | guint32 window_xid = GetMaximizedWindow(); | 1030 | guint32 window_xid = GetMaximizedWindow(); |
561 | 1018 | 1031 | ||
562 | 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. |
563 | 1020 | // | 1033 | // |
564 | 1021 | // This is a workaround to avoid that the grid plugin would be fired | 1034 | // This is a workaround to avoid that the grid plugin would be fired |
565 | 1022 | // showing the window shape preview effect. See bug #838923 | 1035 | // showing the window shape preview effect. See bug #838923 |
567 | 1023 | if (window_xid != 0 && !GetAbsoluteGeometry().IsPointInside(x, y)) | 1036 | if (window_xid != 0 && panel && !panel->GetAbsoluteGeometry().IsPointInside(x, y)) |
568 | 1024 | { | 1037 | { |
572 | 1025 | Display* d = nux::GetGraphicsDisplay()->GetX11Display(); | 1038 | _panel_titlebar_grab_area->SetGrabbed(false); |
570 | 1026 | nux::BaseWindow *bw = static_cast<nux::BaseWindow*>(GetTopLevelViewWindow()); | ||
571 | 1027 | XUndefineCursor(d, bw->GetInputWindowId()); | ||
573 | 1028 | 1039 | ||
574 | 1029 | WindowManager::Default()->Activate(window_xid); | 1040 | WindowManager::Default()->Activate(window_xid); |
575 | 1030 | _is_inside = true; | 1041 | _is_inside = true; |
576 | @@ -1038,15 +1049,25 @@ | |||
577 | 1038 | void | 1049 | void |
578 | 1039 | PanelMenuView::OnMaximizedGrabEnd(int x, int y, unsigned long, unsigned long) | 1050 | PanelMenuView::OnMaximizedGrabEnd(int x, int y, unsigned long, unsigned long) |
579 | 1040 | { | 1051 | { |
584 | 1041 | // Restore the window cursor to default. | 1052 | _panel_titlebar_grab_area->SetGrabbed(false); |
585 | 1042 | Display* d = nux::GetGraphicsDisplay()->GetX11Display(); | 1053 | |
586 | 1043 | nux::BaseWindow *bw = static_cast<nux::BaseWindow*>(GetTopLevelViewWindow()); | 1054 | x += _panel_titlebar_grab_area->GetAbsoluteX(); |
587 | 1044 | XUndefineCursor(d, bw->GetInputWindowId()); | 1055 | y += _panel_titlebar_grab_area->GetAbsoluteY(); |
588 | 1056 | _is_inside = GetAbsoluteGeometry().IsPointInside(x, y); | ||
589 | 1057 | |||
590 | 1058 | if (!_is_inside) | ||
591 | 1059 | _is_grabbed = false; | ||
592 | 1060 | |||
593 | 1061 | Refresh(); | ||
594 | 1062 | FullRedraw(); | ||
595 | 1045 | } | 1063 | } |
596 | 1046 | 1064 | ||
597 | 1047 | void | 1065 | void |
599 | 1048 | PanelMenuView::OnMouseDoubleClicked() | 1066 | PanelMenuView::OnMouseDoubleClicked(int x, int y, unsigned long button_flags, unsigned long) |
600 | 1049 | { | 1067 | { |
601 | 1068 | if (nux::GetEventButton(button_flags) != 1) | ||
602 | 1069 | return; | ||
603 | 1070 | |||
604 | 1050 | guint32 window_xid = GetMaximizedWindow(); | 1071 | guint32 window_xid = GetMaximizedWindow(); |
605 | 1051 | 1072 | ||
606 | 1052 | if (window_xid != 0) | 1073 | if (window_xid != 0) |
607 | @@ -1057,8 +1078,11 @@ | |||
608 | 1057 | } | 1078 | } |
609 | 1058 | 1079 | ||
610 | 1059 | void | 1080 | void |
612 | 1060 | PanelMenuView::OnMouseMiddleClicked() | 1081 | PanelMenuView::OnMouseMiddleClicked(int x, int y, unsigned long button_flags, unsigned long) |
613 | 1061 | { | 1082 | { |
614 | 1083 | if (nux::GetEventButton(button_flags) != 2) | ||
615 | 1084 | return; | ||
616 | 1085 | |||
617 | 1062 | guint32 window_xid = GetMaximizedWindow(); | 1086 | guint32 window_xid = GetMaximizedWindow(); |
618 | 1063 | 1087 | ||
619 | 1064 | if (window_xid != 0) | 1088 | if (window_xid != 0) |
620 | @@ -1120,23 +1144,58 @@ | |||
621 | 1120 | self->QueueDraw(); | 1144 | self->QueueDraw(); |
622 | 1121 | } | 1145 | } |
623 | 1122 | 1146 | ||
625 | 1123 | void PanelMenuView::UpdateShowNow(bool ignore) | 1147 | gboolean |
626 | 1148 | PanelMenuView::UpdateShowNowWithDelay(PanelMenuView *self) | ||
627 | 1124 | { | 1149 | { |
633 | 1125 | // NOTE: This is sub-optimal. We are getting a dbus event for every menu, | 1150 | bool active = false; |
629 | 1126 | // and every time that is setting the show now status of an indicator entry, | ||
630 | 1127 | // we are getting the event raised, and we are ignoring the status, and | ||
631 | 1128 | // looking through all the entries to see if any are shown. | ||
632 | 1129 | _show_now_activated = false; | ||
634 | 1130 | 1151 | ||
636 | 1131 | for (Entries::iterator it = entries_.begin(); it != entries_.end(); ++it) | 1152 | for (auto entry : self->entries_) |
637 | 1132 | { | 1153 | { |
641 | 1133 | PanelIndicatorEntryView* view = it->second; | 1154 | if (entry.second->GetShowNow()) |
642 | 1134 | if (view->GetShowNow()) { | 1155 | { |
643 | 1135 | _show_now_activated = true; | 1156 | active = true; |
644 | 1136 | break; | 1157 | break; |
645 | 1137 | } | 1158 | } |
646 | 1138 | } | 1159 | } |
648 | 1139 | QueueDraw(); | 1160 | |
649 | 1161 | self->_update_show_now_id = 0; | ||
650 | 1162 | |||
651 | 1163 | if (active) | ||
652 | 1164 | { | ||
653 | 1165 | self->_show_now_activated = true; | ||
654 | 1166 | self->QueueDraw(); | ||
655 | 1167 | } | ||
656 | 1168 | |||
657 | 1169 | return FALSE; | ||
658 | 1170 | } | ||
659 | 1171 | |||
660 | 1172 | void | ||
661 | 1173 | PanelMenuView::UpdateShowNow(bool status) | ||
662 | 1174 | { | ||
663 | 1175 | /* When we get a show now event, if we are requested to show the menus, | ||
664 | 1176 | * we take the last incoming event and we wait for small delay (to avoid the | ||
665 | 1177 | * Alt+Tab conflict) then we check if any menuitem has requested to show. | ||
666 | 1178 | * If the status is false, we just check that the menus entries are hidden | ||
667 | 1179 | * and we remove any eventual delayed request */ | ||
668 | 1180 | |||
669 | 1181 | if (!status && _show_now_activated) | ||
670 | 1182 | { | ||
671 | 1183 | _show_now_activated = false; | ||
672 | 1184 | QueueDraw(); | ||
673 | 1185 | } | ||
674 | 1186 | |||
675 | 1187 | if (_update_show_now_id != 0) | ||
676 | 1188 | { | ||
677 | 1189 | g_source_remove(_update_show_now_id); | ||
678 | 1190 | _update_show_now_id = 0; | ||
679 | 1191 | } | ||
680 | 1192 | |||
681 | 1193 | if (status && !_show_now_activated) | ||
682 | 1194 | { | ||
683 | 1195 | _update_show_now_id = g_timeout_add(180, (GSourceFunc) | ||
684 | 1196 | &PanelMenuView::UpdateShowNowWithDelay, | ||
685 | 1197 | this); | ||
686 | 1198 | } | ||
687 | 1140 | } | 1199 | } |
688 | 1141 | 1200 | ||
689 | 1142 | void | 1201 | void |
690 | @@ -1167,6 +1226,7 @@ | |||
691 | 1167 | _is_grabbed = false; | 1226 | _is_grabbed = false; |
692 | 1168 | else | 1227 | else |
693 | 1169 | _is_inside = true; | 1228 | _is_inside = true; |
694 | 1229 | |||
695 | 1170 | FullRedraw(); | 1230 | FullRedraw(); |
696 | 1171 | } | 1231 | } |
697 | 1172 | } | 1232 | } |
698 | 1173 | 1233 | ||
699 | === modified file 'plugins/unityshell/src/PanelMenuView.h' | |||
700 | --- plugins/unityshell/src/PanelMenuView.h 2011-09-03 02:47:41 +0000 | |||
701 | +++ plugins/unityshell/src/PanelMenuView.h 2011-09-25 12:09:24 +0000 | |||
702 | @@ -76,13 +76,14 @@ | |||
703 | 76 | 76 | ||
704 | 77 | guint32 GetMaximizedWindow(); | 77 | guint32 GetMaximizedWindow(); |
705 | 78 | 78 | ||
707 | 79 | void OnMaximizedGrabStart(int x, int y); | 79 | void OnMaximizedGrabStart(int, int, unsigned long, unsigned long); |
708 | 80 | void OnMaximizedGrabMove(int, int, int, int, unsigned long, unsigned long); | 80 | void OnMaximizedGrabMove(int, int, int, int, unsigned long, unsigned long); |
712 | 81 | void OnMaximizedGrabEnd(int x, int y, unsigned long, unsigned long); | 81 | void OnMaximizedGrabEnd(int, int, unsigned long, unsigned long); |
713 | 82 | void OnMouseDoubleClicked(); | 82 | void OnMouseDoubleClicked(int, int, unsigned long, unsigned long); |
714 | 83 | void OnMouseMiddleClicked(); | 83 | void OnMouseMiddleClicked(int, int, unsigned long, unsigned long); |
715 | 84 | 84 | ||
716 | 85 | void Refresh(); | 85 | void Refresh(); |
717 | 86 | void AllMenusClosed(); | ||
718 | 86 | 87 | ||
719 | 87 | void OnCloseClicked(); | 88 | void OnCloseClicked(); |
720 | 88 | void OnMinimizeClicked(); | 89 | void OnMinimizeClicked(); |
721 | @@ -101,7 +102,7 @@ | |||
722 | 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); |
723 | 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); |
724 | 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); |
726 | 104 | virtual void OnEntryAdded(unity::indicator::Entry::Ptr const& proxy); | 105 | virtual void OnEntryAdded(unity::indicator::Entry::Ptr const& entry); |
727 | 105 | 106 | ||
728 | 106 | private: | 107 | private: |
729 | 107 | gchar* GetActiveViewName(); | 108 | gchar* GetActiveViewName(); |
730 | @@ -109,15 +110,15 @@ | |||
731 | 109 | static void OnPlaceViewHidden(GVariant* data, PanelMenuView* self); | 110 | static void OnPlaceViewHidden(GVariant* data, PanelMenuView* self); |
732 | 110 | void UpdateShowNow(bool ignore); | 111 | void UpdateShowNow(bool ignore); |
733 | 111 | static gboolean UpdateActiveWindowPosition(PanelMenuView* self); | 112 | static gboolean UpdateActiveWindowPosition(PanelMenuView* self); |
734 | 113 | static gboolean UpdateShowNowWithDelay(PanelMenuView* self); | ||
735 | 112 | 114 | ||
736 | 113 | private: | 115 | private: |
737 | 114 | BamfMatcher* _matcher; | 116 | BamfMatcher* _matcher; |
738 | 115 | 117 | ||
740 | 116 | nux::AbstractPaintLayer* _title_layer; | 118 | nux::TextureLayer* _title_layer; |
741 | 117 | nux::HLayout* _menu_layout; | 119 | nux::HLayout* _menu_layout; |
742 | 118 | nux::CairoGraphics _util_cg; | 120 | nux::CairoGraphics _util_cg; |
743 | 119 | nux::ObjectPtr<nux::IOpenGLBaseTexture> _gradient_texture; | 121 | nux::ObjectPtr<nux::IOpenGLBaseTexture> _gradient_texture; |
744 | 120 | nux::BaseTexture* _title_tex; | ||
745 | 121 | 122 | ||
746 | 122 | bool _is_inside; | 123 | bool _is_inside; |
747 | 123 | bool _is_grabbed; | 124 | bool _is_grabbed; |
748 | @@ -144,6 +145,7 @@ | |||
749 | 144 | int _monitor; | 145 | int _monitor; |
750 | 145 | guint32 _active_xid; | 146 | guint32 _active_xid; |
751 | 146 | guint32 _active_moved_id; | 147 | guint32 _active_moved_id; |
752 | 148 | guint32 _update_show_now_id; | ||
753 | 147 | nux::Geometry _monitor_geo; | 149 | nux::Geometry _monitor_geo; |
754 | 148 | 150 | ||
755 | 149 | gulong _activate_window_changed_id; | 151 | gulong _activate_window_changed_id; |
756 | 150 | 152 | ||
757 | === modified file 'plugins/unityshell/src/PanelTitlebarGrabAreaView.cpp' | |||
758 | --- plugins/unityshell/src/PanelTitlebarGrabAreaView.cpp 2011-09-06 18:30:26 +0000 | |||
759 | +++ plugins/unityshell/src/PanelTitlebarGrabAreaView.cpp 2011-09-25 12:09:24 +0000 | |||
760 | @@ -1,3 +1,4 @@ | |||
761 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
762 | 1 | /* | 2 | /* |
763 | 2 | * Copyright (C) 2010 Canonical Ltd | 3 | * Copyright (C) 2010 Canonical Ltd |
764 | 3 | * | 4 | * |
765 | @@ -14,8 +15,9 @@ | |||
766 | 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/>. |
767 | 15 | * | 16 | * |
768 | 16 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
771 | 17 | * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com> | 18 | * Sam Spilsbury <sam.spilsbury@canonical.com> |
772 | 18 | * Authored by: Didier Roche <didier.roche@canonical.com> | 19 | * Didier Roche <didier.roche@canonical.com> |
773 | 20 | * Marco Trevisan (Treviño) <mail@3v1n0.net> | ||
774 | 19 | */ | 21 | */ |
775 | 20 | 22 | ||
776 | 21 | #include <Nux/Nux.h> | 23 | #include <Nux/Nux.h> |
777 | @@ -31,19 +33,13 @@ | |||
778 | 31 | #include <UnityCore/Variant.h> | 33 | #include <UnityCore/Variant.h> |
779 | 32 | 34 | ||
780 | 33 | #include <glib.h> | 35 | #include <glib.h> |
781 | 36 | #include <X11/cursorfont.h> | ||
782 | 34 | 37 | ||
783 | 35 | #define DELTA_MOUSE_DOUBLE_CLICK 500000000 | 38 | #define DELTA_MOUSE_DOUBLE_CLICK 500000000 |
784 | 36 | 39 | ||
785 | 37 | enum | ||
786 | 38 | { | ||
787 | 39 | BUTTON_CLOSE = 0, | ||
788 | 40 | BUTTON_MINIMISE, | ||
789 | 41 | BUTTON_UNMAXIMISE | ||
790 | 42 | }; | ||
791 | 43 | |||
792 | 44 | |||
793 | 45 | PanelTitlebarGrabArea::PanelTitlebarGrabArea() | 40 | PanelTitlebarGrabArea::PanelTitlebarGrabArea() |
794 | 46 | : InputArea(NUX_TRACKER_LOCATION) | 41 | : InputArea(NUX_TRACKER_LOCATION) |
795 | 42 | , _grab_cursor(None) | ||
796 | 47 | { | 43 | { |
797 | 48 | // FIXME: the two following functions should be used instead of the insane trick with fixed value. But nux is broken | 44 | // FIXME: the two following functions should be used instead of the insane trick with fixed value. But nux is broken |
798 | 49 | // right now and we need jay to focus on other things | 45 | // right now and we need jay to focus on other things |
799 | @@ -52,38 +48,44 @@ | |||
800 | 52 | InputArea::mouse_up.connect(sigc::mem_fun(this, &PanelTitlebarGrabArea::RecvMouseUp)); | 48 | InputArea::mouse_up.connect(sigc::mem_fun(this, &PanelTitlebarGrabArea::RecvMouseUp)); |
801 | 53 | _last_click_time.tv_sec = 0; | 49 | _last_click_time.tv_sec = 0; |
802 | 54 | _last_click_time.tv_nsec = 0; | 50 | _last_click_time.tv_nsec = 0; |
803 | 55 | |||
804 | 56 | // connect the *Click events before the *Down ones otherwise, weird race happens | ||
805 | 57 | InputArea::mouse_down.connect(sigc::mem_fun(this, &PanelTitlebarGrabArea::RecvMouseDown)); | ||
806 | 58 | } | 51 | } |
807 | 59 | 52 | ||
808 | 60 | 53 | ||
809 | 61 | PanelTitlebarGrabArea::~PanelTitlebarGrabArea() | 54 | PanelTitlebarGrabArea::~PanelTitlebarGrabArea() |
810 | 62 | { | 55 | { |
824 | 63 | } | 56 | if (_grab_cursor) |
825 | 64 | 57 | XFreeCursor(nux::GetGraphicsDisplay()->GetX11Display(), _grab_cursor); | |
826 | 65 | void PanelTitlebarGrabArea::RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags) | 58 | } |
827 | 66 | { | 59 | |
828 | 67 | int button = nux::GetEventButton(button_flags); | 60 | void PanelTitlebarGrabArea::SetGrabbed(bool enabled) |
829 | 68 | if (button == 1) | 61 | { |
830 | 69 | { | 62 | auto display = nux::GetGraphicsDisplay()->GetX11Display(); |
831 | 70 | mouse_down.emit(x, y); | 63 | auto panel_window = static_cast<nux::BaseWindow*>(GetTopLevelViewWindow()); |
832 | 71 | } | 64 | |
833 | 72 | else if (button == 2) | 65 | if (!panel_window || !display) |
834 | 73 | { | 66 | return; |
835 | 74 | mouse_middleclick.emit(); | 67 | |
836 | 75 | } | 68 | if (enabled && !_grab_cursor) |
837 | 69 | { | ||
838 | 70 | _grab_cursor = XCreateFontCursor(display, XC_fleur); | ||
839 | 71 | XDefineCursor(display, panel_window->GetInputWindowId(), _grab_cursor); | ||
840 | 72 | } | ||
841 | 73 | else if (!enabled && _grab_cursor) | ||
842 | 74 | { | ||
843 | 75 | XUndefineCursor(display, panel_window->GetInputWindowId()); | ||
844 | 76 | XFreeCursor(display, _grab_cursor); | ||
845 | 77 | _grab_cursor = None; | ||
846 | 78 | } | ||
847 | 79 | } | ||
848 | 80 | |||
849 | 81 | bool PanelTitlebarGrabArea::IsGrabbed() | ||
850 | 82 | { | ||
851 | 83 | return _grab_cursor != None; | ||
852 | 76 | } | 84 | } |
853 | 77 | 85 | ||
854 | 78 | void PanelTitlebarGrabArea::RecvMouseDoubleClick(int x, int y, unsigned long button_flags, unsigned long key_flags) | 86 | void PanelTitlebarGrabArea::RecvMouseDoubleClick(int x, int y, unsigned long button_flags, unsigned long key_flags) |
855 | 79 | { | 87 | { |
863 | 80 | int button = nux::GetEventButton(button_flags); | 88 | mouse_double_click.emit(x, y, button_flags, key_flags); |
857 | 81 | if (button == 1) | ||
858 | 82 | { | ||
859 | 83 | mouse_doubleleftclick.emit(); | ||
860 | 84 | return; | ||
861 | 85 | } | ||
862 | 86 | mouse_doubleclick.emit(); | ||
864 | 87 | } | 89 | } |
865 | 88 | 90 | ||
866 | 89 | // TODO: can be safely removed once OnMouseDoubleClick is fixed in nux | 91 | // TODO: can be safely removed once OnMouseDoubleClick is fixed in nux |
867 | 90 | 92 | ||
868 | === modified file 'plugins/unityshell/src/PanelTitlebarGrabAreaView.h' | |||
869 | --- plugins/unityshell/src/PanelTitlebarGrabAreaView.h 2011-07-21 14:59:25 +0000 | |||
870 | +++ plugins/unityshell/src/PanelTitlebarGrabAreaView.h 2011-09-25 12:09:24 +0000 | |||
871 | @@ -1,3 +1,4 @@ | |||
872 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
873 | 1 | /* | 2 | /* |
874 | 2 | * Copyright (C) 2010 Canonical Ltd | 3 | * Copyright (C) 2010 Canonical Ltd |
875 | 3 | * | 4 | * |
876 | @@ -14,8 +15,9 @@ | |||
877 | 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/>. |
878 | 15 | * | 16 | * |
879 | 16 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
882 | 17 | * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com> | 18 | * Sam Spilsbury <sam.spilsbury@canonical.com> |
883 | 18 | * Authored by: Didier Roche <didier.roche@canonical.com> | 19 | * Didier Roche <didier.roche@canonical.com> |
884 | 20 | * Marco Trevisan (Treviño) <mail@3v1n0.net> | ||
885 | 19 | */ | 21 | */ |
886 | 20 | 22 | ||
887 | 21 | #ifndef PANEL_TITLEBAR_GRAB_AREA_H | 23 | #ifndef PANEL_TITLEBAR_GRAB_AREA_H |
888 | @@ -38,23 +40,22 @@ | |||
889 | 38 | PanelTitlebarGrabArea(); | 40 | PanelTitlebarGrabArea(); |
890 | 39 | ~PanelTitlebarGrabArea(); | 41 | ~PanelTitlebarGrabArea(); |
891 | 40 | 42 | ||
896 | 41 | sigc::signal <void, int, int> mouse_down; | 43 | void SetGrabbed(bool enabled); |
897 | 42 | sigc::signal <void> mouse_middleclick; | 44 | bool IsGrabbed(); |
894 | 43 | sigc::signal <void> mouse_doubleclick; | ||
895 | 44 | sigc::signal <void> mouse_doubleleftclick; | ||
898 | 45 | 45 | ||
900 | 46 | protected: | 46 | private: |
901 | 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); |
902 | 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); |
903 | 49 | // TODO: can be safely removed once OnMouseDoubleClick is fixed in nux | 49 | // TODO: can be safely removed once OnMouseDoubleClick is fixed in nux |
904 | 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); |
905 | 51 | struct timespec time_diff(struct timespec start, struct timespec end); | 51 | struct timespec time_diff(struct timespec start, struct timespec end); |
906 | 52 | 52 | ||
907 | 53 | struct timespec _last_click_time; | ||
908 | 54 | |||
909 | 55 | const gchar* GetName(); | 53 | const gchar* GetName(); |
910 | 56 | const gchar* GetChildsName(); | 54 | const gchar* GetChildsName(); |
912 | 57 | void AddProperties(GVariantBuilder* builder); | 55 | void AddProperties(GVariantBuilder* builder); |
913 | 56 | |||
914 | 57 | struct timespec _last_click_time; | ||
915 | 58 | Cursor _grab_cursor; | ||
916 | 58 | }; | 59 | }; |
917 | 59 | 60 | ||
918 | 60 | #endif | 61 | #endif |
919 | 61 | 62 | ||
920 | === modified file 'plugins/unityshell/src/PanelView.cpp' | |||
921 | --- plugins/unityshell/src/PanelView.cpp 2011-09-20 16:23:55 +0000 | |||
922 | +++ plugins/unityshell/src/PanelView.cpp 2011-09-25 12:09:24 +0000 | |||
923 | @@ -190,7 +190,7 @@ | |||
924 | 190 | 190 | ||
925 | 191 | const gchar* PanelView::GetName() | 191 | const gchar* PanelView::GetName() |
926 | 192 | { | 192 | { |
928 | 193 | return "Panel"; | 193 | return "UnityPanel"; |
929 | 194 | } | 194 | } |
930 | 195 | 195 | ||
931 | 196 | const gchar* | 196 | const gchar* |
932 | @@ -459,6 +459,7 @@ | |||
933 | 459 | 459 | ||
934 | 460 | void PanelView::OnIndicatorViewUpdated(PanelIndicatorEntryView* view) | 460 | void PanelView::OnIndicatorViewUpdated(PanelIndicatorEntryView* view) |
935 | 461 | { | 461 | { |
936 | 462 | _needs_geo_sync = true; | ||
937 | 462 | ComputeChildLayout(); | 463 | ComputeChildLayout(); |
938 | 463 | } | 464 | } |
939 | 464 | 465 | ||
940 | @@ -488,12 +489,19 @@ | |||
941 | 488 | if (!ret) _indicators->ActivateEntry(entry_id); | 489 | if (!ret) _indicators->ActivateEntry(entry_id); |
942 | 489 | } | 490 | } |
943 | 490 | 491 | ||
950 | 491 | static gboolean track_menu_pointer(gpointer data) | 492 | void PanelView::TrackMenuPointer() |
951 | 492 | { | 493 | { |
952 | 493 | PanelView *self = (PanelView*)data; | 494 | auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); |
953 | 494 | gint x, y; | 495 | if (_tracked_pointer_pos != mouse) |
954 | 495 | gdk_display_get_pointer(gdk_display_get_default(), NULL, &x, &y, NULL); | 496 | { |
955 | 496 | self->OnMenuPointerMoved(x, y); | 497 | OnMenuPointerMoved(mouse.x, mouse.y); |
956 | 498 | _tracked_pointer_pos = mouse; | ||
957 | 499 | } | ||
958 | 500 | } | ||
959 | 501 | |||
960 | 502 | static gboolean track_menu_pointer(PanelView *self) | ||
961 | 503 | { | ||
962 | 504 | self->TrackMenuPointer(); | ||
963 | 497 | return TRUE; | 505 | return TRUE; |
964 | 498 | } | 506 | } |
965 | 499 | 507 | ||
966 | @@ -512,7 +520,7 @@ | |||
967 | 512 | // process. All the motion events will go to unity-panel-service while | 520 | // process. All the motion events will go to unity-panel-service while |
968 | 513 | // scrubbing because the active panel menu has (needs) the pointer grab. | 521 | // scrubbing because the active panel menu has (needs) the pointer grab. |
969 | 514 | // | 522 | // |
971 | 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); |
972 | 516 | } | 524 | } |
973 | 517 | else if (!active) | 525 | else if (!active) |
974 | 518 | { | 526 | { |
975 | @@ -521,6 +529,8 @@ | |||
976 | 521 | g_source_remove(_track_menu_pointer_id); | 529 | g_source_remove(_track_menu_pointer_id); |
977 | 522 | _track_menu_pointer_id = 0; | 530 | _track_menu_pointer_id = 0; |
978 | 523 | } | 531 | } |
979 | 532 | _menu_view->AllMenusClosed(); | ||
980 | 533 | _tracked_pointer_pos = {-1, -1}; | ||
981 | 524 | } | 534 | } |
982 | 525 | } | 535 | } |
983 | 526 | 536 | ||
984 | @@ -603,7 +613,8 @@ | |||
985 | 603 | _is_primary = primary; | 613 | _is_primary = primary; |
986 | 604 | } | 614 | } |
987 | 605 | 615 | ||
989 | 606 | void PanelView::SyncGeometries() | 616 | void |
990 | 617 | PanelView::SyncGeometries() | ||
991 | 607 | { | 618 | { |
992 | 608 | indicator::EntryLocationMap locations; | 619 | indicator::EntryLocationMap locations; |
993 | 609 | _menu_view->GetGeometryForSync(locations); | 620 | _menu_view->GetGeometryForSync(locations); |
994 | 610 | 621 | ||
995 | === modified file 'plugins/unityshell/src/PanelView.h' | |||
996 | --- plugins/unityshell/src/PanelView.h 2011-09-15 09:58:21 +0000 | |||
997 | +++ plugins/unityshell/src/PanelView.h 2011-09-25 12:09:24 +0000 | |||
998 | @@ -72,6 +72,8 @@ | |||
999 | 72 | void EndFirstMenuShow(); | 72 | void EndFirstMenuShow(); |
1000 | 73 | 73 | ||
1001 | 74 | void SetOpacity(float opacity); | 74 | void SetOpacity(float opacity); |
1002 | 75 | |||
1003 | 76 | void TrackMenuPointer(); | ||
1004 | 75 | 77 | ||
1005 | 76 | unsigned int GetTrayXid (); | 78 | unsigned int GetTrayXid (); |
1006 | 77 | 79 | ||
1007 | @@ -120,6 +122,7 @@ | |||
1008 | 120 | guint _handle_dash_shown; | 122 | guint _handle_dash_shown; |
1009 | 121 | guint _handle_bg_color_update; | 123 | guint _handle_bg_color_update; |
1010 | 122 | guint _track_menu_pointer_id; | 124 | guint _track_menu_pointer_id; |
1011 | 125 | nux::Point _tracked_pointer_pos; | ||
1012 | 123 | 126 | ||
1013 | 124 | std::vector<sigc::connection> _on_indicator_updated_connections; | 127 | std::vector<sigc::connection> _on_indicator_updated_connections; |
1014 | 125 | BackgroundEffectHelper bg_effect_helper_; | 128 | BackgroundEffectHelper bg_effect_helper_; |
1015 | 126 | 129 | ||
1016 | === modified file 'plugins/unityshell/src/PluginAdapter.cpp' | |||
1017 | --- plugins/unityshell/src/PluginAdapter.cpp 2011-09-21 03:40:33 +0000 | |||
1018 | +++ plugins/unityshell/src/PluginAdapter.cpp 2011-09-25 12:09:24 +0000 | |||
1019 | @@ -375,7 +375,36 @@ | |||
1020 | 375 | bool | 375 | bool |
1021 | 376 | PluginAdapter::IsWindowDecorated(guint32 xid) | 376 | PluginAdapter::IsWindowDecorated(guint32 xid) |
1022 | 377 | { | 377 | { |
1024 | 378 | Window win = (Window)xid; | 378 | Display* display = m_Screen->dpy(); |
1025 | 379 | Window win = xid; | ||
1026 | 380 | Atom hints_atom = None; | ||
1027 | 381 | MotifWmHints* hints = NULL; | ||
1028 | 382 | Atom type = None; | ||
1029 | 383 | gint format; | ||
1030 | 384 | gulong nitems; | ||
1031 | 385 | gulong bytes_after; | ||
1032 | 386 | bool ret = true; | ||
1033 | 387 | |||
1034 | 388 | hints_atom = XInternAtom(display, _XA_MOTIF_WM_HINTS, false); | ||
1035 | 389 | |||
1036 | 390 | XGetWindowProperty(display, win, hints_atom, 0, | ||
1037 | 391 | sizeof(MotifWmHints) / sizeof(long), False, | ||
1038 | 392 | hints_atom, &type, &format, &nitems, &bytes_after, | ||
1039 | 393 | (guchar**)&hints); | ||
1040 | 394 | |||
1041 | 395 | if (!hints) | ||
1042 | 396 | return ret; | ||
1043 | 397 | |||
1044 | 398 | if (type == hints_atom && format != 0 && hints->flags & MWM_HINTS_DECORATIONS) | ||
1045 | 399 | { | ||
1046 | 400 | ret = hints->decorations & (MwmDecorAll | MwmDecorTitle); | ||
1047 | 401 | } | ||
1048 | 402 | |||
1049 | 403 | XFree(hints); | ||
1050 | 404 | return ret; | ||
1051 | 405 | |||
1052 | 406 | /* FIXME compiz is too slow to update this value, and this could lead to | ||
1053 | 407 | * issues like the bug #838923, since the read value isn't valid anymore | ||
1054 | 379 | CompWindow* window; | 408 | CompWindow* window; |
1055 | 380 | 409 | ||
1056 | 381 | window = m_Screen->findWindow(win); | 410 | window = m_Screen->findWindow(win); |
1057 | @@ -386,6 +415,7 @@ | |||
1058 | 386 | return decor & (MwmDecorAll | MwmDecorTitle); | 415 | return decor & (MwmDecorAll | MwmDecorTitle); |
1059 | 387 | } | 416 | } |
1060 | 388 | return true; | 417 | return true; |
1061 | 418 | */ | ||
1062 | 389 | } | 419 | } |
1063 | 390 | 420 | ||
1064 | 391 | bool | 421 | bool |
1065 | @@ -419,6 +449,8 @@ | |||
1066 | 419 | { | 449 | { |
1067 | 420 | if (sibling->defaultViewport() == window_vp | 450 | if (sibling->defaultViewport() == window_vp |
1068 | 421 | && !sibling->minimized() | 451 | && !sibling->minimized() |
1069 | 452 | && sibling->isMapped() | ||
1070 | 453 | && sibling->isViewable() | ||
1071 | 422 | && (sibling->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE) | 454 | && (sibling->state() & MAXIMIZE_STATE) == MAXIMIZE_STATE) |
1072 | 423 | return true; | 455 | return true; |
1073 | 424 | } | 456 | } |
1074 | 425 | 457 | ||
1075 | === modified file 'plugins/unityshell/src/WindowButtons.cpp' | |||
1076 | --- plugins/unityshell/src/WindowButtons.cpp 2011-09-06 18:30:26 +0000 | |||
1077 | +++ plugins/unityshell/src/WindowButtons.cpp 2011-09-25 12:09:24 +0000 | |||
1078 | @@ -55,6 +55,7 @@ | |||
1079 | 55 | _prelight_dash_tex(NULL), | 55 | _prelight_dash_tex(NULL), |
1080 | 56 | _pressed_dash_tex(NULL), | 56 | _pressed_dash_tex(NULL), |
1081 | 57 | _dash_is_open(false), | 57 | _dash_is_open(false), |
1082 | 58 | _mouse_is_down(false), | ||
1083 | 58 | _place_shown_interest(0), | 59 | _place_shown_interest(0), |
1084 | 59 | _place_hidden_interest(0) | 60 | _place_hidden_interest(0) |
1085 | 60 | { | 61 | { |
1086 | @@ -69,6 +70,14 @@ | |||
1087 | 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, |
1088 | 70 | (UBusCallback)&WindowButton::OnPlaceViewHidden, | 71 | (UBusCallback)&WindowButton::OnPlaceViewHidden, |
1089 | 71 | this); | 72 | this); |
1090 | 73 | |||
1091 | 74 | /* FIXME HasMouseFocus() doesn't seem to work correctly, so we use this workaround */ | ||
1092 | 75 | mouse_down.connect([&_mouse_is_down](int, int, unsigned long, unsigned long) { | ||
1093 | 76 | _mouse_is_down = true; | ||
1094 | 77 | }); | ||
1095 | 78 | mouse_up.connect([&_mouse_is_down](int, int, unsigned long, unsigned long) { | ||
1096 | 79 | _mouse_is_down = false; | ||
1097 | 80 | }); | ||
1098 | 72 | } | 81 | } |
1099 | 73 | 82 | ||
1100 | 74 | ~WindowButton() | 83 | ~WindowButton() |
1101 | @@ -98,7 +107,8 @@ | |||
1102 | 98 | 107 | ||
1103 | 99 | if (_dash_is_open) | 108 | if (_dash_is_open) |
1104 | 100 | { | 109 | { |
1106 | 101 | if (HasMouseFocus() && IsMouseInside()) | 110 | //FIXME should use HasMouseFocus() |
1107 | 111 | if (_mouse_is_down && IsMouseInside()) | ||
1108 | 102 | tex = _pressed_dash_tex; | 112 | tex = _pressed_dash_tex; |
1109 | 103 | else if (IsMouseInside()) | 113 | else if (IsMouseInside()) |
1110 | 104 | tex = _prelight_dash_tex; | 114 | tex = _prelight_dash_tex; |
1111 | @@ -107,7 +117,8 @@ | |||
1112 | 107 | } | 117 | } |
1113 | 108 | else | 118 | else |
1114 | 109 | { | 119 | { |
1116 | 110 | if (HasMouseFocus() && IsMouseInside()) | 120 | //FIXME should use HasMouseFocus() |
1117 | 121 | if (_mouse_is_down && IsMouseInside()) | ||
1118 | 111 | tex = _pressed_tex; | 122 | tex = _pressed_tex; |
1119 | 112 | else if (IsMouseInside()) | 123 | else if (IsMouseInside()) |
1120 | 113 | tex = _prelight_tex; | 124 | tex = _prelight_tex; |
1121 | @@ -217,6 +228,7 @@ | |||
1122 | 217 | nux::BaseTexture* _prelight_dash_tex; | 228 | nux::BaseTexture* _prelight_dash_tex; |
1123 | 218 | nux::BaseTexture* _pressed_dash_tex; | 229 | nux::BaseTexture* _pressed_dash_tex; |
1124 | 219 | bool _dash_is_open; | 230 | bool _dash_is_open; |
1125 | 231 | bool _mouse_is_down; | ||
1126 | 220 | guint32 _place_shown_interest; | 232 | guint32 _place_shown_interest; |
1127 | 221 | guint32 _place_hidden_interest; | 233 | guint32 _place_hidden_interest; |
1128 | 222 | 234 | ||
1129 | 223 | 235 | ||
1130 | === modified file 'plugins/unityshell/src/WindowManager.cpp' | |||
1131 | --- plugins/unityshell/src/WindowManager.cpp 2011-09-19 16:36:21 +0000 | |||
1132 | +++ plugins/unityshell/src/WindowManager.cpp 2011-09-25 12:09:24 +0000 | |||
1133 | @@ -1,3 +1,4 @@ | |||
1134 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
1135 | 1 | /* | 2 | /* |
1136 | 2 | * Copyright (C) 2010 Canonical Ltd | 3 | * Copyright (C) 2010 Canonical Ltd |
1137 | 3 | * | 4 | * |
1138 | @@ -26,7 +27,7 @@ | |||
1139 | 26 | { | 27 | { |
1140 | 27 | return 0; | 28 | return 0; |
1141 | 28 | } | 29 | } |
1143 | 29 | 30 | ||
1144 | 30 | bool IsScreenGrabbed() | 31 | bool IsScreenGrabbed() |
1145 | 31 | { | 32 | { |
1146 | 32 | return false; | 33 | return false; |
1147 | @@ -181,6 +182,9 @@ | |||
1148 | 181 | void | 182 | void |
1149 | 182 | WindowManager::StartMove(guint32 xid, int x, int y) | 183 | WindowManager::StartMove(guint32 xid, int x, int y) |
1150 | 183 | { | 184 | { |
1151 | 185 | if (x < 0 || y < 0) | ||
1152 | 186 | return; | ||
1153 | 187 | |||
1154 | 184 | XEvent ev; | 188 | XEvent ev; |
1155 | 185 | Display* d = nux::GetGraphicsDisplay()->GetX11Display(); | 189 | Display* d = nux::GetGraphicsDisplay()->GetX11Display(); |
1156 | 186 | 190 | ||
1157 | 187 | 191 | ||
1158 | === modified file 'services/panel-service.c' | |||
1159 | --- services/panel-service.c 2011-09-08 11:53:46 +0000 | |||
1160 | +++ services/panel-service.c 2011-09-25 12:09:24 +0000 | |||
1161 | @@ -16,6 +16,7 @@ | |||
1162 | 16 | * | 16 | * |
1163 | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> | 17 | * Authored by: Neil Jagdish Patel <neil.patel@canonical.com> |
1164 | 18 | * Rodrigo Moya <rodrigo.moya@canonical.com> | 18 | * Rodrigo Moya <rodrigo.moya@canonical.com> |
1165 | 19 | * Marco Trevisan (Treviño) <mail@3v1n0.net> | ||
1166 | 19 | */ | 20 | */ |
1167 | 20 | 21 | ||
1168 | 21 | #if HAVE_CONFIG_H | 22 | #if HAVE_CONFIG_H |
1169 | @@ -47,8 +48,8 @@ | |||
1170 | 47 | struct _PanelServicePrivate | 48 | struct _PanelServicePrivate |
1171 | 48 | { | 49 | { |
1172 | 49 | GSList *indicators; | 50 | GSList *indicators; |
1173 | 50 | GHashTable *id2entry_hash; | ||
1174 | 51 | GHashTable *entry2indicator_hash; | 51 | GHashTable *entry2indicator_hash; |
1175 | 52 | GHashTable *entry2geometry_hash; | ||
1176 | 52 | 53 | ||
1177 | 53 | guint initial_sync_id; | 54 | guint initial_sync_id; |
1178 | 54 | gint32 timeouts[N_TIMEOUT_SLOTS]; | 55 | gint32 timeouts[N_TIMEOUT_SLOTS]; |
1179 | @@ -64,6 +65,9 @@ | |||
1180 | 64 | gint last_right; | 65 | gint last_right; |
1181 | 65 | gint last_bottom; | 66 | gint last_bottom; |
1182 | 66 | guint32 last_menu_button; | 67 | guint32 last_menu_button; |
1183 | 68 | |||
1184 | 69 | IndicatorObjectEntry *pressed_entry; | ||
1185 | 70 | gboolean use_event; | ||
1186 | 67 | }; | 71 | }; |
1187 | 68 | 72 | ||
1188 | 69 | /* Globals */ | 73 | /* Globals */ |
1189 | @@ -113,6 +117,7 @@ | |||
1190 | 113 | static void sort_indicators (PanelService *self); | 117 | static void sort_indicators (PanelService *self); |
1191 | 114 | 118 | ||
1192 | 115 | static void notify_object (IndicatorObject *object); | 119 | static void notify_object (IndicatorObject *object); |
1193 | 120 | static IndicatorObjectEntry *get_entry_at (PanelService *self, gint x, gint y); | ||
1194 | 116 | 121 | ||
1195 | 117 | static GdkFilterReturn event_filter (GdkXEvent *ev, | 122 | static GdkFilterReturn event_filter (GdkXEvent *ev, |
1196 | 118 | GdkEvent *gev, | 123 | GdkEvent *gev, |
1197 | @@ -128,8 +133,8 @@ | |||
1198 | 128 | PanelServicePrivate *priv = PANEL_SERVICE (object)->priv; | 133 | PanelServicePrivate *priv = PANEL_SERVICE (object)->priv; |
1199 | 129 | gint i; | 134 | gint i; |
1200 | 130 | 135 | ||
1201 | 131 | g_hash_table_destroy (priv->id2entry_hash); | ||
1202 | 132 | g_hash_table_destroy (priv->entry2indicator_hash); | 136 | g_hash_table_destroy (priv->entry2indicator_hash); |
1203 | 137 | g_hash_table_destroy (priv->entry2geometry_hash); | ||
1204 | 133 | 138 | ||
1205 | 134 | gdk_window_remove_filter (NULL, (GdkFilterFunc)event_filter, object); | 139 | gdk_window_remove_filter (NULL, (GdkFilterFunc)event_filter, object); |
1206 | 135 | 140 | ||
1207 | @@ -239,25 +244,83 @@ | |||
1208 | 239 | if (cookie->type == GenericEvent) | 244 | if (cookie->type == GenericEvent) |
1209 | 240 | { | 245 | { |
1210 | 241 | XIDeviceEvent *event = cookie->data; | 246 | XIDeviceEvent *event = cookie->data; |
1224 | 242 | 247 | if (!event) | |
1225 | 243 | if (event && event->evtype == XI_ButtonRelease && | 248 | return ret; |
1226 | 244 | priv->last_menu_button != 0) //FocusChange | 249 | |
1227 | 245 | { | 250 | if (event->evtype == XI_ButtonPress) |
1228 | 246 | if (event->root_x < priv->last_left || | 251 | { |
1229 | 247 | event->root_x > priv->last_right || | 252 | priv->pressed_entry = get_entry_at (self, event->root_x, event->root_y); |
1230 | 248 | event->root_y < priv->last_top || | 253 | priv->use_event = (priv->pressed_entry == NULL); |
1231 | 249 | event->root_y > priv->last_bottom) | 254 | } |
1232 | 250 | { | 255 | |
1233 | 251 | ret = GDK_FILTER_REMOVE; | 256 | if (event->evtype == XI_ButtonRelease) |
1234 | 252 | } | 257 | { |
1235 | 253 | 258 | if (priv->use_event) | |
1236 | 254 | priv->last_menu_button = 0; | 259 | { |
1237 | 260 | priv->use_event = FALSE; | ||
1238 | 261 | } | ||
1239 | 262 | else | ||
1240 | 263 | { | ||
1241 | 264 | IndicatorObjectEntry *entry; | ||
1242 | 265 | entry = get_entry_at (self, event->root_x, event->root_y); | ||
1243 | 266 | |||
1244 | 267 | if (entry) | ||
1245 | 268 | { | ||
1246 | 269 | if (entry != priv->pressed_entry) | ||
1247 | 270 | { | ||
1248 | 271 | ret = GDK_FILTER_REMOVE; | ||
1249 | 272 | priv->use_event = TRUE; | ||
1250 | 273 | } | ||
1251 | 274 | else if (priv->last_entry && entry != priv->last_entry) | ||
1252 | 275 | { | ||
1253 | 276 | /* If we were navigating over indicators using the keyboard | ||
1254 | 277 | * and now we click over the indicator under the mouse, we | ||
1255 | 278 | * must force it to show back again, not make it close */ | ||
1256 | 279 | gchar *entry_id = g_strdup_printf ("%p", entry); | ||
1257 | 280 | g_signal_emit (self, _service_signals[ENTRY_ACTIVATE_REQUEST], 0, entry_id); | ||
1258 | 281 | g_free (entry_id); | ||
1259 | 282 | } | ||
1260 | 283 | } | ||
1261 | 284 | } | ||
1262 | 255 | } | 285 | } |
1263 | 256 | } | 286 | } |
1264 | 257 | 287 | ||
1265 | 258 | return ret; | 288 | return ret; |
1266 | 259 | } | 289 | } |
1267 | 260 | 290 | ||
1268 | 291 | static IndicatorObjectEntry * | ||
1269 | 292 | get_entry_at (PanelService *self, gint x, gint y) | ||
1270 | 293 | { | ||
1271 | 294 | GHashTableIter iter; | ||
1272 | 295 | gpointer key, value; | ||
1273 | 296 | |||
1274 | 297 | g_hash_table_iter_init (&iter, self->priv->entry2geometry_hash); | ||
1275 | 298 | while (g_hash_table_iter_next (&iter, &key, &value)) | ||
1276 | 299 | { | ||
1277 | 300 | IndicatorObjectEntry *entry = key; | ||
1278 | 301 | GdkRectangle *geo = value; | ||
1279 | 302 | |||
1280 | 303 | if (x >= geo->x && x <= (geo->x + geo->width) && | ||
1281 | 304 | y >= geo->y && y <= (geo->y + geo->height)) | ||
1282 | 305 | { | ||
1283 | 306 | return entry; | ||
1284 | 307 | } | ||
1285 | 308 | } | ||
1286 | 309 | |||
1287 | 310 | return NULL; | ||
1288 | 311 | } | ||
1289 | 312 | |||
1290 | 313 | static IndicatorObjectEntry * | ||
1291 | 314 | get_entry_by_id (const gchar *entry_id) | ||
1292 | 315 | { | ||
1293 | 316 | IndicatorObjectEntry *entry; | ||
1294 | 317 | |||
1295 | 318 | if (sscanf (entry_id, "%p", &entry) == 1) | ||
1296 | 319 | return entry; | ||
1297 | 320 | |||
1298 | 321 | return NULL; | ||
1299 | 322 | } | ||
1300 | 323 | |||
1301 | 261 | static gboolean | 324 | static gboolean |
1302 | 262 | initial_resync (PanelService *self) | 325 | initial_resync (PanelService *self) |
1303 | 263 | { | 326 | { |
1304 | @@ -277,9 +340,9 @@ | |||
1305 | 277 | 340 | ||
1306 | 278 | gdk_window_add_filter (NULL, (GdkFilterFunc)event_filter, self); | 341 | gdk_window_add_filter (NULL, (GdkFilterFunc)event_filter, self); |
1307 | 279 | 342 | ||
1308 | 280 | priv->id2entry_hash = g_hash_table_new_full (g_str_hash, g_str_equal, | ||
1309 | 281 | g_free, NULL); | ||
1310 | 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); |
1311 | 344 | priv->entry2geometry_hash = g_hash_table_new_full (g_direct_hash, g_direct_equal, | ||
1312 | 345 | NULL, g_free); | ||
1313 | 283 | 346 | ||
1314 | 284 | suppress_signals = TRUE; | 347 | suppress_signals = TRUE; |
1315 | 285 | load_indicators (self); | 348 | load_indicators (self); |
1316 | @@ -315,10 +378,8 @@ | |||
1317 | 315 | { | 378 | { |
1318 | 316 | for (l = entries; l; l = l->next) | 379 | for (l = entries; l; l = l->next) |
1319 | 317 | { | 380 | { |
1320 | 318 | gchar *id = g_strdup_printf ("%p", l->data); | ||
1321 | 319 | g_hash_table_remove (self->priv->id2entry_hash, id); | ||
1322 | 320 | g_hash_table_remove (self->priv->entry2indicator_hash, l->data); | 381 | g_hash_table_remove (self->priv->entry2indicator_hash, l->data); |
1324 | 321 | g_free (id); | 382 | g_hash_table_remove (self->priv->entry2geometry_hash, l->data); |
1325 | 322 | } | 383 | } |
1326 | 323 | 384 | ||
1327 | 324 | g_list_free (entries); | 385 | g_list_free (entries); |
1328 | @@ -520,14 +581,11 @@ | |||
1329 | 520 | PanelService *self) | 581 | PanelService *self) |
1330 | 521 | { | 582 | { |
1331 | 522 | PanelServicePrivate *priv; | 583 | PanelServicePrivate *priv; |
1332 | 523 | gchar *id; | ||
1333 | 524 | 584 | ||
1334 | 525 | g_return_if_fail (PANEL_IS_SERVICE (self)); | 585 | g_return_if_fail (PANEL_IS_SERVICE (self)); |
1335 | 526 | g_return_if_fail (entry != NULL); | 586 | g_return_if_fail (entry != NULL); |
1336 | 527 | priv = self->priv; | 587 | priv = self->priv; |
1337 | 528 | 588 | ||
1338 | 529 | id = g_strdup_printf ("%p", entry); | ||
1339 | 530 | g_hash_table_insert (priv->id2entry_hash, id, entry); | ||
1340 | 531 | g_hash_table_insert (priv->entry2indicator_hash, entry, object); | 589 | g_hash_table_insert (priv->entry2indicator_hash, entry, object); |
1341 | 532 | 590 | ||
1342 | 533 | if (GTK_IS_LABEL (entry->label)) | 591 | if (GTK_IS_LABEL (entry->label)) |
1343 | @@ -576,17 +634,16 @@ | |||
1344 | 576 | PanelService *self) | 634 | PanelService *self) |
1345 | 577 | { | 635 | { |
1346 | 578 | PanelServicePrivate *priv; | 636 | PanelServicePrivate *priv; |
1347 | 579 | gchar *id; | ||
1348 | 580 | |||
1349 | 581 | g_return_if_fail (PANEL_IS_SERVICE (self)); | 637 | g_return_if_fail (PANEL_IS_SERVICE (self)); |
1350 | 582 | g_return_if_fail (entry != NULL); | 638 | g_return_if_fail (entry != NULL); |
1351 | 583 | 639 | ||
1352 | 584 | priv = self->priv; | 640 | priv = self->priv; |
1353 | 585 | 641 | ||
1354 | 586 | id = g_strdup_printf ("%p", entry); | ||
1355 | 587 | g_hash_table_remove (priv->entry2indicator_hash, entry); | 642 | g_hash_table_remove (priv->entry2indicator_hash, entry); |
1358 | 588 | g_hash_table_remove (priv->id2entry_hash, id); | 643 | /* Don't remove here the value from priv->entry2geometry_hash, this should |
1359 | 589 | g_free (id); | 644 | * be done in during the sync, to avoid false positive. |
1360 | 645 | * FIXME this in libappmenu.so to avoid to send an "entry-removed" signal | ||
1361 | 646 | * when switching the focus from a window to one of its dialog children */ | ||
1362 | 590 | 647 | ||
1363 | 591 | notify_object (object); | 648 | notify_object (object); |
1364 | 592 | } | 649 | } |
1365 | @@ -628,7 +685,7 @@ | |||
1366 | 628 | PanelService *self) | 685 | PanelService *self) |
1367 | 629 | { | 686 | { |
1368 | 630 | gchar *entry_id; | 687 | gchar *entry_id; |
1370 | 631 | 688 | ||
1371 | 632 | g_return_if_fail (PANEL_IS_SERVICE (self)); | 689 | g_return_if_fail (PANEL_IS_SERVICE (self)); |
1372 | 633 | if (entry == NULL) | 690 | if (entry == NULL) |
1373 | 634 | { | 691 | { |
1374 | @@ -637,7 +694,7 @@ | |||
1375 | 637 | } | 694 | } |
1376 | 638 | 695 | ||
1377 | 639 | entry_id = g_strdup_printf ("%p", entry); | 696 | entry_id = g_strdup_printf ("%p", entry); |
1379 | 640 | 697 | ||
1380 | 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); |
1381 | 642 | 699 | ||
1382 | 643 | g_free (entry_id); | 700 | g_free (entry_id); |
1383 | @@ -967,6 +1024,8 @@ | |||
1384 | 967 | priv->last_top = 0; | 1024 | priv->last_top = 0; |
1385 | 968 | priv->last_bottom = 0; | 1025 | priv->last_bottom = 0; |
1386 | 969 | 1026 | ||
1387 | 1027 | priv->pressed_entry = NULL; | ||
1388 | 1028 | |||
1389 | 970 | g_signal_emit (self, _service_signals[ENTRY_ACTIVATED], 0, ""); | 1029 | g_signal_emit (self, _service_signals[ENTRY_ACTIVATED], 0, ""); |
1390 | 971 | } | 1030 | } |
1391 | 972 | 1031 | ||
1392 | @@ -1045,9 +1104,32 @@ | |||
1393 | 1045 | gint height) | 1104 | gint height) |
1394 | 1046 | { | 1105 | { |
1395 | 1047 | PanelServicePrivate *priv = self->priv; | 1106 | PanelServicePrivate *priv = self->priv; |
1397 | 1048 | IndicatorObjectEntry *entry = g_hash_table_lookup (priv->id2entry_hash, entry_id); | 1107 | IndicatorObjectEntry *entry = get_entry_by_id (entry_id); |
1398 | 1049 | IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry); | 1108 | IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry); |
1399 | 1050 | 1109 | ||
1400 | 1110 | if (entry) | ||
1401 | 1111 | { | ||
1402 | 1112 | if (width < 0 || height < 0) | ||
1403 | 1113 | { | ||
1404 | 1114 | g_hash_table_remove (priv->entry2geometry_hash, entry); | ||
1405 | 1115 | } | ||
1406 | 1116 | else | ||
1407 | 1117 | { | ||
1408 | 1118 | GdkRectangle *geo = g_hash_table_lookup (priv->entry2geometry_hash, entry); | ||
1409 | 1119 | |||
1410 | 1120 | if (geo == NULL) | ||
1411 | 1121 | { | ||
1412 | 1122 | geo = g_new (GdkRectangle, 1); | ||
1413 | 1123 | g_hash_table_insert (priv->entry2geometry_hash, entry, geo); | ||
1414 | 1124 | } | ||
1415 | 1125 | |||
1416 | 1126 | geo->x = x; | ||
1417 | 1127 | geo->y = y; | ||
1418 | 1128 | geo->width = width; | ||
1419 | 1129 | geo->height = height; | ||
1420 | 1130 | } | ||
1421 | 1131 | } | ||
1422 | 1132 | |||
1423 | 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); |
1424 | 1052 | } | 1134 | } |
1425 | 1053 | 1135 | ||
1426 | @@ -1176,8 +1258,7 @@ | |||
1427 | 1176 | priv = self->priv; | 1258 | priv = self->priv; |
1428 | 1177 | 1259 | ||
1429 | 1178 | /* Not interested in up or down */ | 1260 | /* Not interested in up or down */ |
1432 | 1179 | if (direction == GTK_MENU_DIR_NEXT | 1261 | if (direction == GTK_MENU_DIR_NEXT || direction == GTK_MENU_DIR_PREV) |
1431 | 1180 | || direction == GTK_MENU_DIR_PREV) | ||
1433 | 1181 | return; | 1262 | return; |
1434 | 1182 | 1263 | ||
1435 | 1183 | /* We don't want to distrupt going into submenus */ | 1264 | /* We don't want to distrupt going into submenus */ |
1436 | @@ -1221,15 +1302,17 @@ | |||
1437 | 1221 | gint32 button) | 1302 | gint32 button) |
1438 | 1222 | { | 1303 | { |
1439 | 1223 | PanelServicePrivate *priv = self->priv; | 1304 | PanelServicePrivate *priv = self->priv; |
1441 | 1224 | IndicatorObjectEntry *entry = g_hash_table_lookup (priv->id2entry_hash, entry_id); | 1305 | IndicatorObjectEntry *entry = get_entry_by_id (entry_id); |
1442 | 1225 | IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry); | 1306 | IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry); |
1443 | 1226 | GtkWidget *last_menu; | 1307 | GtkWidget *last_menu; |
1444 | 1227 | 1308 | ||
1445 | 1309 | g_return_if_fail (entry); | ||
1446 | 1310 | |||
1447 | 1228 | if (priv->last_entry == entry) | 1311 | if (priv->last_entry == entry) |
1448 | 1229 | return; | 1312 | return; |
1449 | 1230 | 1313 | ||
1450 | 1231 | last_menu = GTK_WIDGET (priv->last_menu); | 1314 | last_menu = GTK_WIDGET (priv->last_menu); |
1452 | 1232 | 1315 | ||
1453 | 1233 | if (GTK_IS_MENU (priv->last_menu)) | 1316 | if (GTK_IS_MENU (priv->last_menu)) |
1454 | 1234 | { | 1317 | { |
1455 | 1235 | priv->last_x = 0; | 1318 | priv->last_x = 0; |
1456 | @@ -1247,6 +1330,8 @@ | |||
1457 | 1247 | 1330 | ||
1458 | 1248 | if (entry != NULL) | 1331 | if (entry != NULL) |
1459 | 1249 | { | 1332 | { |
1460 | 1333 | g_signal_emit (self, _service_signals[ENTRY_ACTIVATED], 0, entry_id); | ||
1461 | 1334 | |||
1462 | 1250 | if (GTK_IS_MENU (entry->menu)) | 1335 | if (GTK_IS_MENU (entry->menu)) |
1463 | 1251 | { | 1336 | { |
1464 | 1252 | priv->last_menu = entry->menu; | 1337 | priv->last_menu = entry->menu; |
1465 | @@ -1294,8 +1379,6 @@ | |||
1466 | 1294 | priv->last_top = 0; | 1379 | priv->last_top = 0; |
1467 | 1295 | priv->last_bottom = 0; | 1380 | priv->last_bottom = 0; |
1468 | 1296 | } | 1381 | } |
1469 | 1297 | |||
1470 | 1298 | g_signal_emit (self, _service_signals[ENTRY_ACTIVATED], 0, entry_id); | ||
1471 | 1299 | } | 1382 | } |
1472 | 1300 | 1383 | ||
1473 | 1301 | /* We popdown the old one last so we don't accidently send key focus back to the | 1384 | /* We popdown the old one last so we don't accidently send key focus back to the |
1474 | @@ -1312,7 +1395,9 @@ | |||
1475 | 1312 | guint32 timestamp) | 1395 | guint32 timestamp) |
1476 | 1313 | { | 1396 | { |
1477 | 1314 | PanelServicePrivate *priv = self->priv; | 1397 | PanelServicePrivate *priv = self->priv; |
1479 | 1315 | IndicatorObjectEntry *entry = g_hash_table_lookup (priv->id2entry_hash, entry_id); | 1398 | IndicatorObjectEntry *entry = get_entry_by_id (entry_id); |
1480 | 1399 | g_return_if_fail (entry); | ||
1481 | 1400 | |||
1482 | 1316 | IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry); | 1401 | IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry); |
1483 | 1317 | 1402 | ||
1484 | 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, |
1485 | @@ -1325,11 +1410,12 @@ | |||
1486 | 1325 | gint32 delta) | 1410 | gint32 delta) |
1487 | 1326 | { | 1411 | { |
1488 | 1327 | PanelServicePrivate *priv = self->priv; | 1412 | PanelServicePrivate *priv = self->priv; |
1490 | 1328 | IndicatorObjectEntry *entry = g_hash_table_lookup (priv->id2entry_hash, entry_id); | 1413 | IndicatorObjectEntry *entry = get_entry_by_id (entry_id); |
1491 | 1414 | g_return_if_fail (entry); | ||
1492 | 1415 | |||
1493 | 1329 | IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry); | 1416 | IndicatorObject *object = g_hash_table_lookup (priv->entry2indicator_hash, entry); |
1494 | 1330 | GdkScrollDirection direction = delta < 0 ? GDK_SCROLL_DOWN : GDK_SCROLL_UP; | 1417 | GdkScrollDirection direction = delta < 0 ? GDK_SCROLL_DOWN : GDK_SCROLL_UP; |
1495 | 1331 | 1418 | ||
1496 | 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, |
1497 | 1333 | abs(delta/120), direction); | 1420 | abs(delta/120), direction); |
1498 | 1334 | } | 1421 | } |
1499 | 1335 |
Has a merge conflict if you merge your other branch in first. Conflicts are non-trivial (at least for me to fix)