Merge lp:~3v1n0/unity/lim-panel into lp:unity
- lim-panel
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merge reported by: | Marco Trevisan (Treviño) | ||||||||
Merged at revision: | not available | ||||||||
Proposed branch: | lp:~3v1n0/unity/lim-panel | ||||||||
Merge into: | lp:unity | ||||||||
Prerequisite: | lp:~3v1n0/unity/lim | ||||||||
Diff against target: |
1212 lines (+729/-37) 14 files modified
UnityCore/AppmenuIndicator.cpp (+47/-5) UnityCore/AppmenuIndicator.h (+17/-3) plugins/unityshell/src/PanelIndicatorAppmenuView.cpp (+238/-0) plugins/unityshell/src/PanelIndicatorAppmenuView.h (+68/-0) plugins/unityshell/src/PanelIndicatorEntryView.cpp (+25/-6) plugins/unityshell/src/PanelIndicatorEntryView.h (+1/-0) plugins/unityshell/src/PanelIndicatorsView.cpp (+11/-0) plugins/unityshell/src/PanelIndicatorsView.h (+2/-0) plugins/unityshell/src/PanelMenuView.cpp (+240/-20) plugins/unityshell/src/PanelMenuView.h (+9/-0) plugins/unityshell/src/PanelStyle.cpp (+1/-0) plugins/unityshell/src/PanelStyle.h (+1/-0) plugins/unityshell/src/unityshell.cpp (+3/-2) tests/test_indicator_appmenu.cpp (+66/-1) |
||||||||
To merge this branch: | bzr merge lp:~3v1n0/unity/lim-panel | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sam Spilsbury | Pending | ||
Review via email: mp+92710@code.launchpad.net |
Commit message
Description of the change
UI work for the Locally Integrated Menus support for the unity panel.
I've made some code improvements and rewrite to PanelStyle, PanelMenuView, PanelIndicatorE
Using the integrated menu, the appmenu-indicator is also capable of being dragged down, middle-clicked and double-clicked exactly like the PanelTitlebarGr
Updated 17/02:
Fixed also bug #934680, added some new features to WindowManager, some of them imported from lp:~3v1n0/unity/super-arrows-shortcuts:
GetWindowSavedG
MoveResizeWindow: the name should say what it does ;)
GetWorkAreaGeom
RestoreAt: restores a window and move it at the given x, y position
keeping the standard geometry.
Michal Hruby (mhr3) wrote : | # |
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
> 8 +BuilderWrapper& BuilderWrapper:
> 9 +{
> 10 + g_variant_
> g_variant_
>
> long is 32-bit on i386, if you really need 64bit value this should be changed
> to "long long".
Right. I've added wrappers for long long too, anyway I'm keeping the variant as a gint64 also for long int, to make sure it's working also on 64bit...
Sam Spilsbury (smspillaz) wrote : | # |
"The diff has been truncated for viewing. "
Try to avoid doing too much rewriting in any one branch :)
466 PanelIndicatorE
467 {
468 - on_indicator_
469 - on_indicator_
470 - on_panelstyle_
471 - g_signal_
472 - if (texture_layer_)
473 - delete texture_layer_;
474 + // Nothing to do...
475 }
The empty destructor's definition can be removed (unless its virtual)
+ if (!wm->IsExpoAct
490 + {
This probably doesn't make sense living where it is. The Panel views should block all clicks if if the screen is grabbed by compiz period (eg, add a wrapper method in WindowManager around CompScreen:
3181 + /* FIXME, this can be removed when window_unmapped WindowManager signal
3182 + * will emit the proper xid */
3183 + Window xid = bamf_window_
3184 + OnWindowUnmappe
Can you explain this? It could be emitting the frame xid, and that needs to be fixed there :)
nvm found it
3391 + // FIXME: compiz doesn't give us a valid xid (is always 0 on unmap)
3392 + // we need to do this again on BamfView closed signal.
Great. I'll fix that in compiz then. (This is probably the case when the window is destroyed and the xid is changed to zero, and then the unmap signal happens)
The window management stuff looks great.
Marco Trevisan (Treviño) (3v1n0) wrote : | # |
> "The diff has been truncated for viewing. "
>
> Try to avoid doing too much rewriting in any one branch :)
Yes, I know, but things often come in mind when doing it, and as I'm touching a lot of panel stuff, I'd prefer to keep all here.
You can just use bzr send lp:unity -o branch-changes.diff to check them locally ;)
> The empty destructor's definition can be removed (unless its virtual)
>
> + if (!wm->IsExpoAct
> 490 + {
>
> This probably doesn't make sense living where it is. The Panel views should
> block all clicks if if the screen is grabbed by compiz period (eg, add a
> wrapper method in WindowManager around CompScreen:
Well, if the dash grab isn't considered by that, I could try to do it.
> 3391 + // FIXME: compiz doesn't give us a valid xid (is always 0 on unmap)
> 3392 + // we need to do this again on BamfView closed signal.
>
> Great. I'll fix that in compiz then. (This is probably the case when the
> window is destroyed and the xid is changed to zero, and then the unmap signal
> happens)
Let me know when your fix will be landed, so we can remove this.
> The window management stuff looks great.
Cool! ;)
Preview Diff
1 | === modified file 'UnityCore/AppmenuIndicator.cpp' | |||
2 | --- UnityCore/AppmenuIndicator.cpp 2012-03-29 12:06:35 +0000 | |||
3 | +++ UnityCore/AppmenuIndicator.cpp 2012-04-18 08:58:24 +0000 | |||
4 | @@ -24,13 +24,55 @@ | |||
5 | 24 | namespace indicator | 24 | namespace indicator |
6 | 25 | { | 25 | { |
7 | 26 | 26 | ||
8 | 27 | namespace | ||
9 | 28 | { | ||
10 | 29 | const std::string SETTING_NAME("com.canonical.indicator.appmenu"); | ||
11 | 30 | const std::string SETTING_KEY("menu-mode"); | ||
12 | 31 | } | ||
13 | 32 | |||
14 | 27 | AppmenuIndicator::AppmenuIndicator(std::string const& name) | 33 | AppmenuIndicator::AppmenuIndicator(std::string const& name) |
15 | 28 | : Indicator(name) | 34 | : Indicator(name) |
21 | 29 | {} | 35 | , gsettings_(g_settings_new(SETTING_NAME.c_str())) |
22 | 30 | 36 | , integrated_(false) | |
23 | 31 | void AppmenuIndicator::ShowAppmenu(unsigned int xid, int x, int y, unsigned int timestamp) const | 37 | { |
24 | 32 | { | 38 | setting_changed_.Connect(gsettings_, "changed::menu-mode", [&] (GSettings*, gchar*) { |
25 | 33 | on_show_appmenu.emit(xid, x, y, timestamp); | 39 | CheckSettingValue(); |
26 | 40 | }); | ||
27 | 41 | |||
28 | 42 | CheckSettingValue(); | ||
29 | 43 | } | ||
30 | 44 | |||
31 | 45 | bool AppmenuIndicator::ShowAppmenu(unsigned int xid, int x, int y, unsigned int timestamp) const | ||
32 | 46 | { | ||
33 | 47 | if (integrated_) | ||
34 | 48 | { | ||
35 | 49 | on_show_appmenu.emit(xid, x, y, timestamp); | ||
36 | 50 | return true; | ||
37 | 51 | } | ||
38 | 52 | |||
39 | 53 | return false; | ||
40 | 54 | } | ||
41 | 55 | |||
42 | 56 | bool AppmenuIndicator::IsIntegrated() const | ||
43 | 57 | { | ||
44 | 58 | return integrated_; | ||
45 | 59 | } | ||
46 | 60 | |||
47 | 61 | void AppmenuIndicator::CheckSettingValue() | ||
48 | 62 | { | ||
49 | 63 | glib::String menu_mode(g_settings_get_string(gsettings_, SETTING_KEY.c_str())); | ||
50 | 64 | bool integrated_menus = false; | ||
51 | 65 | |||
52 | 66 | if (menu_mode.Str() == "locally-integrated") | ||
53 | 67 | { | ||
54 | 68 | integrated_menus = true; | ||
55 | 69 | } | ||
56 | 70 | |||
57 | 71 | if (integrated_menus != integrated_) | ||
58 | 72 | { | ||
59 | 73 | integrated_ = integrated_menus; | ||
60 | 74 | integrated_changed.emit(integrated_); | ||
61 | 75 | } | ||
62 | 34 | } | 76 | } |
63 | 35 | 77 | ||
64 | 36 | } // namespace indicator | 78 | } // namespace indicator |
65 | 37 | 79 | ||
66 | === modified file 'UnityCore/AppmenuIndicator.h' | |||
67 | --- UnityCore/AppmenuIndicator.h 2012-03-29 12:06:35 +0000 | |||
68 | +++ UnityCore/AppmenuIndicator.h 2012-04-18 08:58:24 +0000 | |||
69 | @@ -21,6 +21,10 @@ | |||
70 | 21 | #define UNITY_APPMENU_INDICATOR_H | 21 | #define UNITY_APPMENU_INDICATOR_H |
71 | 22 | 22 | ||
72 | 23 | #include "Indicator.h" | 23 | #include "Indicator.h" |
73 | 24 | #include "GLibWrapper.h" | ||
74 | 25 | #include "GLibSignal.h" | ||
75 | 26 | |||
76 | 27 | #include <gio/gio.h> | ||
77 | 24 | 28 | ||
78 | 25 | namespace unity | 29 | namespace unity |
79 | 26 | { | 30 | { |
80 | @@ -33,12 +37,22 @@ | |||
81 | 33 | AppmenuIndicator(std::string const& name); | 37 | AppmenuIndicator(std::string const& name); |
82 | 34 | 38 | ||
83 | 35 | virtual bool IsAppmenu() const { return true; } | 39 | virtual bool IsAppmenu() const { return true; } |
87 | 36 | 40 | bool IsIntegrated() const; | |
88 | 37 | void ShowAppmenu(unsigned int xid, int x, int y, unsigned int timestamp) const; | 41 | |
89 | 38 | 42 | bool ShowAppmenu(unsigned int xid, int x, int y, unsigned int timestamp) const; | |
90 | 43 | |||
91 | 44 | sigc::signal<void, bool> integrated_changed; | ||
92 | 39 | sigc::signal<void, unsigned int, int, int, unsigned int> on_show_appmenu; | 45 | sigc::signal<void, unsigned int, int, int, unsigned int> on_show_appmenu; |
93 | 46 | |||
94 | 47 | private: | ||
95 | 48 | void CheckSettingValue(); | ||
96 | 49 | |||
97 | 50 | glib::Object<GSettings> gsettings_; | ||
98 | 51 | glib::Signal<void, GSettings*, gchar*> setting_changed_; | ||
99 | 52 | bool integrated_; | ||
100 | 40 | }; | 53 | }; |
101 | 41 | 54 | ||
102 | 55 | |||
103 | 42 | } | 56 | } |
104 | 43 | } | 57 | } |
105 | 44 | 58 | ||
106 | 45 | 59 | ||
107 | === added file 'plugins/unityshell/src/PanelIndicatorAppmenuView.cpp' | |||
108 | --- plugins/unityshell/src/PanelIndicatorAppmenuView.cpp 1970-01-01 00:00:00 +0000 | |||
109 | +++ plugins/unityshell/src/PanelIndicatorAppmenuView.cpp 2012-04-18 08:58:24 +0000 | |||
110 | @@ -0,0 +1,238 @@ | |||
111 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
112 | 2 | /* | ||
113 | 3 | * Copyright (C) 2012 Canonical Ltd | ||
114 | 4 | * | ||
115 | 5 | * This program is free software: you can redistribute it and/or modify | ||
116 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
117 | 7 | * published by the Free Software Foundation. | ||
118 | 8 | * | ||
119 | 9 | * This program is distributed in the hope that it will be useful, | ||
120 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
121 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
122 | 12 | * GNU General Public License for more details. | ||
123 | 13 | * | ||
124 | 14 | * You should have received a copy of the GNU General Public License | ||
125 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
126 | 16 | * | ||
127 | 17 | * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
128 | 18 | */ | ||
129 | 19 | |||
130 | 20 | #include <UnityCore/Variant.h> | ||
131 | 21 | #include <UnityCore/GLibWrapper.h> | ||
132 | 22 | #include <libbamf/libbamf.h> | ||
133 | 23 | |||
134 | 24 | #include "PanelIndicatorAppmenuView.h" | ||
135 | 25 | #include "WindowManager.h" | ||
136 | 26 | #include "PanelStyle.h" | ||
137 | 27 | |||
138 | 28 | namespace unity | ||
139 | 29 | { | ||
140 | 30 | namespace | ||
141 | 31 | { | ||
142 | 32 | const std::string MENU_ATOM = "_UBUNTU_APPMENU_UNIQUE_NAME"; | ||
143 | 33 | } | ||
144 | 34 | |||
145 | 35 | using namespace indicator; | ||
146 | 36 | |||
147 | 37 | PanelIndicatorAppmenuView::PanelIndicatorAppmenuView(Entry::Ptr const& proxy) | ||
148 | 38 | : PanelIndicatorEntryView(proxy, 0, APPMENU) | ||
149 | 39 | , xid_(0) | ||
150 | 40 | , has_menu_(false) | ||
151 | 41 | { | ||
152 | 42 | spacing_ = 2; | ||
153 | 43 | right_padding_ = 7; | ||
154 | 44 | SetVisible(false); | ||
155 | 45 | } | ||
156 | 46 | |||
157 | 47 | void PanelIndicatorAppmenuView::GetGeometryForSync(EntryLocationMap& locations) | ||
158 | 48 | { | ||
159 | 49 | if (!IsFocused()) | ||
160 | 50 | return; | ||
161 | 51 | |||
162 | 52 | PanelIndicatorEntryView::GetGeometryForSync(locations); | ||
163 | 53 | } | ||
164 | 54 | |||
165 | 55 | void PanelIndicatorAppmenuView::Activate(int button) | ||
166 | 56 | { | ||
167 | 57 | /* If the button is 0, the entry is activated using a keyboard shortcut, | ||
168 | 58 | * so we need to check the fucus status of the entry */ | ||
169 | 59 | if (button != 0 || (button == 0 && IsFocused())) | ||
170 | 60 | { | ||
171 | 61 | SetActiveState(true, 1); | ||
172 | 62 | } | ||
173 | 63 | } | ||
174 | 64 | |||
175 | 65 | void PanelIndicatorAppmenuView::ShowMenu(int button) | ||
176 | 66 | { | ||
177 | 67 | if (xid_ && has_menu_) | ||
178 | 68 | { | ||
179 | 69 | WindowManager::Default()->Raise(xid_); | ||
180 | 70 | WindowManager::Default()->Activate(xid_); | ||
181 | 71 | |||
182 | 72 | proxy_->ShowMenu(xid_, | ||
183 | 73 | GetAbsoluteX(), | ||
184 | 74 | GetAbsoluteY() + panel::Style::Instance().panel_height, | ||
185 | 75 | button, | ||
186 | 76 | time(nullptr)); | ||
187 | 77 | } | ||
188 | 78 | } | ||
189 | 79 | |||
190 | 80 | std::string PanelIndicatorAppmenuView::GetLabel() | ||
191 | 81 | { | ||
192 | 82 | glib::String escaped(g_markup_escape_text(label_.c_str(), -1)); | ||
193 | 83 | |||
194 | 84 | std::ostringstream bold_label; | ||
195 | 85 | bold_label << "<b>" << escaped.Str() << "</b>"; | ||
196 | 86 | |||
197 | 87 | return bold_label.str(); | ||
198 | 88 | } | ||
199 | 89 | |||
200 | 90 | bool PanelIndicatorAppmenuView::IsLabelSensitive() const | ||
201 | 91 | { | ||
202 | 92 | return (!label_.empty() && has_menu_); | ||
203 | 93 | } | ||
204 | 94 | |||
205 | 95 | bool PanelIndicatorAppmenuView::IsLabelVisible() const | ||
206 | 96 | { | ||
207 | 97 | return !label_.empty(); | ||
208 | 98 | } | ||
209 | 99 | |||
210 | 100 | bool PanelIndicatorAppmenuView::IsIconSensitive() const | ||
211 | 101 | { | ||
212 | 102 | return has_menu_; | ||
213 | 103 | } | ||
214 | 104 | |||
215 | 105 | bool PanelIndicatorAppmenuView::IsIconVisible() const | ||
216 | 106 | { | ||
217 | 107 | return has_menu_; | ||
218 | 108 | } | ||
219 | 109 | |||
220 | 110 | void PanelIndicatorAppmenuView::SetLabel(std::string const& label) | ||
221 | 111 | { | ||
222 | 112 | if (label_ != label) | ||
223 | 113 | { | ||
224 | 114 | label_ = label; | ||
225 | 115 | SetVisible(!label_.empty()); | ||
226 | 116 | Refresh(); | ||
227 | 117 | } | ||
228 | 118 | } | ||
229 | 119 | |||
230 | 120 | void PanelIndicatorAppmenuView::SetControlledWindow(Window xid) | ||
231 | 121 | { | ||
232 | 122 | if (xid_ != xid) | ||
233 | 123 | { | ||
234 | 124 | xid_ = xid; | ||
235 | 125 | SetVisible(xid_ != 0); | ||
236 | 126 | CheckWindowMenu(); | ||
237 | 127 | } | ||
238 | 128 | } | ||
239 | 129 | |||
240 | 130 | bool PanelIndicatorAppmenuView::CheckWindowMenu() | ||
241 | 131 | { | ||
242 | 132 | /* FIXME this is a temporary workaround */ | ||
243 | 133 | has_menu_ = true; | ||
244 | 134 | glib::Object<BamfMatcher> matcher(bamf_matcher_get_default()); | ||
245 | 135 | BamfWindow *win = bamf_matcher_get_active_window(matcher); | ||
246 | 136 | |||
247 | 137 | if (BAMF_IS_WINDOW(win)) | ||
248 | 138 | { | ||
249 | 139 | if (xid_ == bamf_window_get_xid(win)) | ||
250 | 140 | { | ||
251 | 141 | has_menu_ = proxy_->image_sensitive(); | ||
252 | 142 | } | ||
253 | 143 | } | ||
254 | 144 | |||
255 | 145 | /* FIXME re-enable this when all the clients will support the APPMENU atom. | ||
256 | 146 | has_menu_ = false; | ||
257 | 147 | |||
258 | 148 | if (!xid_) | ||
259 | 149 | return false; | ||
260 | 150 | |||
261 | 151 | glib::Object<BamfMatcher> matcher(bamf_matcher_get_default()); | ||
262 | 152 | |||
263 | 153 | GList* windows = bamf_matcher_get_windows(matcher); | ||
264 | 154 | |||
265 | 155 | for (GList* l = windows; l; l = l->next) | ||
266 | 156 | { | ||
267 | 157 | if (BAMF_IS_WINDOW(l->data)) | ||
268 | 158 | { | ||
269 | 159 | auto window = static_cast<BamfWindow*>(l->data); | ||
270 | 160 | |||
271 | 161 | if (bamf_window_get_xid(window) == xid_) | ||
272 | 162 | { | ||
273 | 163 | glib::String property(bamf_window_get_utf8_prop(window, MENU_ATOM.c_str())); | ||
274 | 164 | has_menu_ = bool(property); | ||
275 | 165 | break; | ||
276 | 166 | } | ||
277 | 167 | } | ||
278 | 168 | } | ||
279 | 169 | |||
280 | 170 | g_list_free(windows);*/ | ||
281 | 171 | |||
282 | 172 | return has_menu_; | ||
283 | 173 | } | ||
284 | 174 | |||
285 | 175 | void PanelIndicatorAppmenuView::DrawEntryPrelight(cairo_t* cr, unsigned int width, unsigned int height) | ||
286 | 176 | { | ||
287 | 177 | nux::Rect const& geo = proxy_->geometry(); | ||
288 | 178 | |||
289 | 179 | if (geo == nux::Geometry()) | ||
290 | 180 | return; | ||
291 | 181 | |||
292 | 182 | GtkStyleContext* style_context = panel::Style::Instance().GetStyleContext(); | ||
293 | 183 | int flair_width = std::min(geo.width, GetMinimumWidth()); | ||
294 | 184 | |||
295 | 185 | cairo_translate (cr, geo.x - GetAbsoluteX(), geo.y - height); | ||
296 | 186 | |||
297 | 187 | gtk_style_context_save(style_context); | ||
298 | 188 | |||
299 | 189 | GtkWidgetPath* widget_path = gtk_widget_path_new(); | ||
300 | 190 | gtk_widget_path_iter_set_name(widget_path, -1 , "UnityPanelWidget"); | ||
301 | 191 | gtk_widget_path_append_type(widget_path, GTK_TYPE_MENU_BAR); | ||
302 | 192 | gtk_widget_path_append_type(widget_path, GTK_TYPE_MENU_ITEM); | ||
303 | 193 | |||
304 | 194 | gtk_style_context_set_path(style_context, widget_path); | ||
305 | 195 | gtk_style_context_add_class(style_context, GTK_STYLE_CLASS_MENUBAR); | ||
306 | 196 | gtk_style_context_add_class(style_context, GTK_STYLE_CLASS_MENUITEM); | ||
307 | 197 | gtk_style_context_set_state(style_context, GTK_STATE_FLAG_PRELIGHT); | ||
308 | 198 | |||
309 | 199 | cairo_save(cr); | ||
310 | 200 | cairo_push_group(cr); | ||
311 | 201 | |||
312 | 202 | gtk_render_background(style_context, cr, 0, 0, flair_width, height); | ||
313 | 203 | gtk_render_frame(style_context, cr, 0, 0, flair_width, height); | ||
314 | 204 | |||
315 | 205 | cairo_pattern_t* pat = cairo_pop_group(cr); | ||
316 | 206 | cairo_pattern_t* mask = cairo_pattern_create_linear(0, 0, 0, height); | ||
317 | 207 | cairo_pattern_add_color_stop_rgba(mask, 0.0f, 0, 0, 0, 0.0f); | ||
318 | 208 | cairo_pattern_add_color_stop_rgba(mask, 0.6f, 0, 0, 0, 0.0f); | ||
319 | 209 | cairo_pattern_add_color_stop_rgba(mask, 1.0f, 0, 0, 0, 1.0f); | ||
320 | 210 | |||
321 | 211 | cairo_rectangle(cr, 0, 0, flair_width, height); | ||
322 | 212 | cairo_set_source(cr, pat); | ||
323 | 213 | cairo_mask(cr, mask); | ||
324 | 214 | |||
325 | 215 | cairo_pattern_destroy(pat); | ||
326 | 216 | cairo_pattern_destroy(mask); | ||
327 | 217 | cairo_restore(cr); | ||
328 | 218 | |||
329 | 219 | gtk_widget_path_free(widget_path); | ||
330 | 220 | |||
331 | 221 | gtk_style_context_restore(style_context); | ||
332 | 222 | } | ||
333 | 223 | |||
334 | 224 | std::string PanelIndicatorAppmenuView::GetName() const | ||
335 | 225 | { | ||
336 | 226 | return "Appmenu"; | ||
337 | 227 | } | ||
338 | 228 | |||
339 | 229 | void PanelIndicatorAppmenuView::AddProperties(GVariantBuilder* builder) | ||
340 | 230 | { | ||
341 | 231 | PanelIndicatorEntryView::AddProperties(builder); | ||
342 | 232 | |||
343 | 233 | variant::BuilderWrapper(builder) | ||
344 | 234 | .add("controlled-window", xid_) | ||
345 | 235 | .add("has_menu", has_menu_); | ||
346 | 236 | } | ||
347 | 237 | |||
348 | 238 | } // NAMESPACE | ||
349 | 0 | 239 | ||
350 | === added file 'plugins/unityshell/src/PanelIndicatorAppmenuView.h' | |||
351 | --- plugins/unityshell/src/PanelIndicatorAppmenuView.h 1970-01-01 00:00:00 +0000 | |||
352 | +++ plugins/unityshell/src/PanelIndicatorAppmenuView.h 2012-04-18 08:58:24 +0000 | |||
353 | @@ -0,0 +1,68 @@ | |||
354 | 1 | // -*- Mode: C++; indent-tabs-mode: nil; tab-width: 2 -*- | ||
355 | 2 | /* | ||
356 | 3 | * Copyright (C) 2012 Canonical Ltd | ||
357 | 4 | * | ||
358 | 5 | * This program is free software: you can redistribute it and/or modify | ||
359 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
360 | 7 | * published by the Free Software Foundation. | ||
361 | 8 | * | ||
362 | 9 | * This program is distributed in the hope that it will be useful, | ||
363 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
364 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
365 | 12 | * GNU General Public License for more details. | ||
366 | 13 | * | ||
367 | 14 | * You should have received a copy of the GNU General Public License | ||
368 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
369 | 16 | * | ||
370 | 17 | * Authored by: Marco Trevisan (Treviño) <3v1n0@ubuntu.com> | ||
371 | 18 | */ | ||
372 | 19 | |||
373 | 20 | #ifndef PANEL_INDICATOR_APPMENU_VIEW_H | ||
374 | 21 | #define PANEL_INDICATOR_APPMENU_VIEW_H | ||
375 | 22 | |||
376 | 23 | #include <Nux/Nux.h> | ||
377 | 24 | #include <Nux/BaseWindow.h> | ||
378 | 25 | |||
379 | 26 | #include "PanelIndicatorEntryView.h" | ||
380 | 27 | |||
381 | 28 | namespace unity | ||
382 | 29 | { | ||
383 | 30 | using indicator::Entry; | ||
384 | 31 | |||
385 | 32 | class PanelIndicatorAppmenuView : public PanelIndicatorEntryView | ||
386 | 33 | { | ||
387 | 34 | public: | ||
388 | 35 | PanelIndicatorAppmenuView(Entry::Ptr const& proxy); | ||
389 | 36 | |||
390 | 37 | std::string GetLabel(); | ||
391 | 38 | void SetLabel(std::string const& label); | ||
392 | 39 | bool IsLabelVisible() const; | ||
393 | 40 | bool IsLabelSensitive() const; | ||
394 | 41 | |||
395 | 42 | bool IsIconVisible() const; | ||
396 | 43 | bool IsIconSensitive() const; | ||
397 | 44 | |||
398 | 45 | void GetGeometryForSync(indicator::EntryLocationMap& locations); | ||
399 | 46 | |||
400 | 47 | void SetControlledWindow(Window xid); | ||
401 | 48 | |||
402 | 49 | void Activate(int button = 1); | ||
403 | 50 | |||
404 | 51 | protected: | ||
405 | 52 | std::string GetName() const; | ||
406 | 53 | void AddProperties(GVariantBuilder* builder); | ||
407 | 54 | |||
408 | 55 | void ShowMenu(int button); | ||
409 | 56 | void DrawEntryPrelight(cairo_t* cr, unsigned int w, unsigned int h); | ||
410 | 57 | |||
411 | 58 | private: | ||
412 | 59 | bool CheckWindowMenu(); | ||
413 | 60 | |||
414 | 61 | Window xid_; | ||
415 | 62 | bool has_menu_; | ||
416 | 63 | std::string label_; | ||
417 | 64 | }; | ||
418 | 65 | |||
419 | 66 | } | ||
420 | 67 | |||
421 | 68 | #endif // PANEL_INDICATOR_APPMENU_VIEW_H | ||
422 | 0 | 69 | ||
423 | === modified file 'plugins/unityshell/src/PanelIndicatorEntryView.cpp' | |||
424 | --- plugins/unityshell/src/PanelIndicatorEntryView.cpp 2012-04-10 01:30:04 +0000 | |||
425 | +++ plugins/unityshell/src/PanelIndicatorEntryView.cpp 2012-04-18 08:58:24 +0000 | |||
426 | @@ -72,7 +72,7 @@ | |||
427 | 72 | 72 | ||
428 | 73 | InputArea::SetAcceptMouseWheelEvent(true); | 73 | InputArea::SetAcceptMouseWheelEvent(true); |
429 | 74 | 74 | ||
431 | 75 | if (type_ != MENU) | 75 | if (type_ != MENU && type_ != APPMENU) |
432 | 76 | InputArea::mouse_wheel.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::OnMouseWheel)); | 76 | InputArea::mouse_wheel.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::OnMouseWheel)); |
433 | 77 | 77 | ||
434 | 78 | panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::Refresh)); | 78 | panel::Style::Instance().changed.connect(sigc::mem_fun(this, &PanelIndicatorEntryView::Refresh)); |
435 | @@ -275,7 +275,7 @@ | |||
436 | 275 | { | 275 | { |
437 | 276 | gtk_style_context_set_state(style_context, GTK_STATE_FLAG_BACKDROP); | 276 | gtk_style_context_set_state(style_context, GTK_STATE_FLAG_BACKDROP); |
438 | 277 | } | 277 | } |
440 | 278 | else if (IsActive()) | 278 | else if (IsActive() && type_ != APPMENU) |
441 | 279 | { | 279 | { |
442 | 280 | gtk_style_context_set_state(style_context, GTK_STATE_FLAG_PRELIGHT); | 280 | gtk_style_context_set_state(style_context, GTK_STATE_FLAG_PRELIGHT); |
443 | 281 | } | 281 | } |
444 | @@ -344,7 +344,7 @@ | |||
445 | 344 | { | 344 | { |
446 | 345 | gtk_style_context_set_state(style_context, GTK_STATE_FLAG_BACKDROP); | 345 | gtk_style_context_set_state(style_context, GTK_STATE_FLAG_BACKDROP); |
447 | 346 | } | 346 | } |
449 | 347 | else if (IsActive()) | 347 | else if (IsActive() && type_ != APPMENU) |
450 | 348 | { | 348 | { |
451 | 349 | gtk_style_context_set_state(style_context, GTK_STATE_FLAG_PRELIGHT); | 349 | gtk_style_context_set_state(style_context, GTK_STATE_FLAG_PRELIGHT); |
452 | 350 | } | 350 | } |
453 | @@ -358,7 +358,10 @@ | |||
454 | 358 | { | 358 | { |
455 | 359 | cairo_pattern_t* linpat; | 359 | cairo_pattern_t* linpat; |
456 | 360 | int out_pixels = text_width - text_space; | 360 | int out_pixels = text_width - text_space; |
458 | 361 | const int fading_pixels = 15; | 361 | int fading_pixels = 20; |
459 | 362 | |||
460 | 363 | if (type_ == APPMENU) | ||
461 | 364 | fading_pixels = 35; | ||
462 | 362 | 365 | ||
463 | 363 | int fading_width = out_pixels < fading_pixels ? out_pixels : fading_pixels; | 366 | int fading_width = out_pixels < fading_pixels ? out_pixels : fading_pixels; |
464 | 364 | 367 | ||
465 | @@ -448,6 +451,15 @@ | |||
466 | 448 | PangoFontDescription* desc = nullptr; | 451 | PangoFontDescription* desc = nullptr; |
467 | 449 | PanelItem panel_item = (type_ == MENU) ? PanelItem::MENU : PanelItem::INDICATOR; | 452 | PanelItem panel_item = (type_ == MENU) ? PanelItem::MENU : PanelItem::INDICATOR; |
468 | 450 | 453 | ||
469 | 454 | if (type_ == MENU) | ||
470 | 455 | { | ||
471 | 456 | panel_item = PanelItem::INDICATOR; | ||
472 | 457 | } | ||
473 | 458 | else if (type_ == APPMENU) | ||
474 | 459 | { | ||
475 | 460 | panel_item = PanelItem::TITLE; | ||
476 | 461 | } | ||
477 | 462 | |||
478 | 451 | Style& panel_style = Style::Instance(); | 463 | Style& panel_style = Style::Instance(); |
479 | 452 | std::string const& font_description = panel_style.GetFontDescription(panel_item); | 464 | std::string const& font_description = panel_style.GetFontDescription(panel_item); |
480 | 453 | int dpi = panel_style.GetTextDPI(); | 465 | int dpi = panel_style.GetTextDPI(); |
481 | @@ -475,8 +487,15 @@ | |||
482 | 475 | 487 | ||
483 | 476 | pango_layout_set_font_description(layout, desc); | 488 | pango_layout_set_font_description(layout, desc); |
484 | 477 | 489 | ||
487 | 478 | boost::erase_all(label, "_"); | 490 | if (type_ == APPMENU) |
488 | 479 | pango_layout_set_text(layout, label.c_str(), -1); | 491 | { |
489 | 492 | pango_layout_set_markup(layout, label.c_str(), -1); | ||
490 | 493 | } | ||
491 | 494 | else | ||
492 | 495 | { | ||
493 | 496 | boost::erase_all(label, "_"); | ||
494 | 497 | pango_layout_set_text(layout, label.c_str(), -1); | ||
495 | 498 | } | ||
496 | 480 | 499 | ||
497 | 481 | cxt = pango_layout_get_context(layout); | 500 | cxt = pango_layout_get_context(layout); |
498 | 482 | pango_cairo_context_set_font_options(cxt, gdk_screen_get_font_options(screen)); | 501 | pango_cairo_context_set_font_options(cxt, gdk_screen_get_font_options(screen)); |
499 | 483 | 502 | ||
500 | === modified file 'plugins/unityshell/src/PanelIndicatorEntryView.h' | |||
501 | --- plugins/unityshell/src/PanelIndicatorEntryView.h 2012-04-10 00:30:33 +0000 | |||
502 | +++ plugins/unityshell/src/PanelIndicatorEntryView.h 2012-04-18 08:58:24 +0000 | |||
503 | @@ -43,6 +43,7 @@ | |||
504 | 43 | enum IndicatorEntryType { | 43 | enum IndicatorEntryType { |
505 | 44 | INDICATOR, | 44 | INDICATOR, |
506 | 45 | MENU, | 45 | MENU, |
507 | 46 | APPMENU, | ||
508 | 46 | OTHER | 47 | OTHER |
509 | 47 | }; | 48 | }; |
510 | 48 | 49 | ||
511 | 49 | 50 | ||
512 | === modified file 'plugins/unityshell/src/PanelIndicatorsView.cpp' | |||
513 | --- plugins/unityshell/src/PanelIndicatorsView.cpp 2012-04-03 16:01:38 +0000 | |||
514 | +++ plugins/unityshell/src/PanelIndicatorsView.cpp 2012-04-18 08:58:24 +0000 | |||
515 | @@ -111,6 +111,17 @@ | |||
516 | 111 | return indicators_; | 111 | return indicators_; |
517 | 112 | } | 112 | } |
518 | 113 | 113 | ||
519 | 114 | bool | ||
520 | 115 | PanelIndicatorsView::IsAppmenu() | ||
521 | 116 | { | ||
522 | 117 | if (indicators_.size() == 1 && indicators_[0]->IsAppmenu()) | ||
523 | 118 | { | ||
524 | 119 | return true; | ||
525 | 120 | } | ||
526 | 121 | |||
527 | 122 | return false; | ||
528 | 123 | } | ||
529 | 124 | |||
530 | 114 | void | 125 | void |
531 | 115 | PanelIndicatorsView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) | 126 | PanelIndicatorsView::Draw(nux::GraphicsEngine& GfxContext, bool force_draw) |
532 | 116 | { | 127 | { |
533 | 117 | 128 | ||
534 | === modified file 'plugins/unityshell/src/PanelIndicatorsView.h' | |||
535 | --- plugins/unityshell/src/PanelIndicatorsView.h 2012-04-02 10:25:16 +0000 | |||
536 | +++ plugins/unityshell/src/PanelIndicatorsView.h 2012-04-18 08:58:24 +0000 | |||
537 | @@ -66,6 +66,8 @@ | |||
538 | 66 | void SetOpacity(double opacity); | 66 | void SetOpacity(double opacity); |
539 | 67 | double GetOpacity(); | 67 | double GetOpacity(); |
540 | 68 | 68 | ||
541 | 69 | bool IsAppmenu(); | ||
542 | 70 | |||
543 | 69 | void SetMaximumEntriesWidth(int max_width); | 71 | void SetMaximumEntriesWidth(int max_width); |
544 | 70 | void GetGeometryForSync(indicator::EntryLocationMap& locations); | 72 | void GetGeometryForSync(indicator::EntryLocationMap& locations); |
545 | 71 | 73 | ||
546 | 72 | 74 | ||
547 | === modified file 'plugins/unityshell/src/PanelMenuView.cpp' | |||
548 | --- plugins/unityshell/src/PanelMenuView.cpp 2012-04-16 12:12:05 +0000 | |||
549 | +++ plugins/unityshell/src/PanelMenuView.cpp 2012-04-18 08:58:24 +0000 | |||
550 | @@ -29,6 +29,7 @@ | |||
551 | 29 | #include "UScreen.h" | 29 | #include "UScreen.h" |
552 | 30 | 30 | ||
553 | 31 | #include <UnityCore/Variant.h> | 31 | #include <UnityCore/Variant.h> |
554 | 32 | #include <UnityCore/AppmenuIndicator.h> | ||
555 | 32 | 33 | ||
556 | 33 | #include <glib/gi18n-lib.h> | 34 | #include <glib/gi18n-lib.h> |
557 | 34 | 35 | ||
558 | @@ -51,9 +52,11 @@ | |||
559 | 51 | 52 | ||
560 | 52 | PanelMenuView::PanelMenuView() | 53 | PanelMenuView::PanelMenuView() |
561 | 53 | : _matcher(bamf_matcher_get_default()), | 54 | : _matcher(bamf_matcher_get_default()), |
562 | 55 | _is_integrated(false), | ||
563 | 54 | _is_inside(false), | 56 | _is_inside(false), |
564 | 55 | _is_grabbed(false), | 57 | _is_grabbed(false), |
565 | 56 | _is_maximized(false), | 58 | _is_maximized(false), |
566 | 59 | _integrated_menu(nullptr), | ||
567 | 57 | _last_active_view(nullptr), | 60 | _last_active_view(nullptr), |
568 | 58 | _new_application(nullptr), | 61 | _new_application(nullptr), |
569 | 59 | _overlay_showing(false), | 62 | _overlay_showing(false), |
570 | @@ -181,6 +184,7 @@ | |||
571 | 181 | _fade_out_animator.animation_updated.clear(); | 184 | _fade_out_animator.animation_updated.clear(); |
572 | 182 | _fade_out_animator.animation_ended.clear(); | 185 | _fade_out_animator.animation_ended.clear(); |
573 | 183 | _style_changed_connection.disconnect(); | 186 | _style_changed_connection.disconnect(); |
574 | 187 | _mode_changed_connection.disconnect(); | ||
575 | 184 | 188 | ||
576 | 185 | if (_active_moved_id) | 189 | if (_active_moved_id) |
577 | 186 | g_source_remove(_active_moved_id); | 190 | g_source_remove(_active_moved_id); |
578 | @@ -207,6 +211,40 @@ | |||
579 | 207 | QueueDraw(); | 211 | QueueDraw(); |
580 | 208 | } | 212 | } |
581 | 209 | 213 | ||
582 | 214 | void PanelMenuView::SetIntegrated(bool integrated) | ||
583 | 215 | { | ||
584 | 216 | if (_is_integrated == integrated) | ||
585 | 217 | return; | ||
586 | 218 | |||
587 | 219 | _is_integrated = integrated; | ||
588 | 220 | panel::Style::Instance().integrated_menus = _is_integrated; | ||
589 | 221 | |||
590 | 222 | if (!_is_integrated) | ||
591 | 223 | { | ||
592 | 224 | auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); | ||
593 | 225 | _is_inside = GetAbsoluteGeometry().IsInside(mouse); | ||
594 | 226 | |||
595 | 227 | _window_buttons->SetFocusedState(true); | ||
596 | 228 | _window_buttons->SetControlledWindow(_is_maximized ? _active_xid : 0); | ||
597 | 229 | |||
598 | 230 | _integrated_menu = nullptr; | ||
599 | 231 | } | ||
600 | 232 | else | ||
601 | 233 | { | ||
602 | 234 | Window maximized = GetMaximizedWindow(); | ||
603 | 235 | _window_buttons->SetFocusedState(maximized == _active_xid); | ||
604 | 236 | _window_buttons->SetControlledWindow(maximized); | ||
605 | 237 | } | ||
606 | 238 | |||
607 | 239 | Refresh(true); | ||
608 | 240 | FullRedraw(); | ||
609 | 241 | } | ||
610 | 242 | |||
611 | 243 | bool PanelMenuView::IsIntegrated() const | ||
612 | 244 | { | ||
613 | 245 | return _is_integrated; | ||
614 | 246 | } | ||
615 | 247 | |||
616 | 210 | void PanelMenuView::AddIndicator(indicator::Indicator::Ptr const& indicator) | 248 | void PanelMenuView::AddIndicator(indicator::Indicator::Ptr const& indicator) |
617 | 211 | { | 249 | { |
618 | 212 | if (!GetIndicators().empty()) | 250 | if (!GetIndicators().empty()) |
619 | @@ -216,6 +254,27 @@ | |||
620 | 216 | } | 254 | } |
621 | 217 | 255 | ||
622 | 218 | PanelIndicatorsView::AddIndicator(indicator); | 256 | PanelIndicatorsView::AddIndicator(indicator); |
623 | 257 | |||
624 | 258 | if (indicator->IsAppmenu()) | ||
625 | 259 | { | ||
626 | 260 | auto appmenuindicator = dynamic_cast<indicator::AppmenuIndicator*>(indicator.get()); | ||
627 | 261 | |||
628 | 262 | if (appmenuindicator) | ||
629 | 263 | { | ||
630 | 264 | SetIntegrated(appmenuindicator->IsIntegrated()); | ||
631 | 265 | |||
632 | 266 | _mode_changed_connection = | ||
633 | 267 | appmenuindicator->integrated_changed.connect(sigc::mem_fun(this, &PanelMenuView::SetIntegrated)); | ||
634 | 268 | } | ||
635 | 269 | } | ||
636 | 270 | } | ||
637 | 271 | |||
638 | 272 | void PanelMenuView::RemoveIndicator(indicator::Indicator::Ptr const& indicator) | ||
639 | 273 | { | ||
640 | 274 | PanelIndicatorsView::RemoveIndicator(indicator); | ||
641 | 275 | |||
642 | 276 | if (indicator->IsAppmenu()) | ||
643 | 277 | _mode_changed_connection.disconnect(); | ||
644 | 219 | } | 278 | } |
645 | 220 | 279 | ||
646 | 221 | void PanelMenuView::SetMenuShowTimings(int fadein, int fadeout, int discovery, | 280 | void PanelMenuView::SetMenuShowTimings(int fadein, int fadeout, int discovery, |
647 | @@ -271,7 +330,7 @@ | |||
648 | 271 | return _titlebar_grab_area; | 330 | return _titlebar_grab_area; |
649 | 272 | } | 331 | } |
650 | 273 | 332 | ||
652 | 274 | if (_is_maximized) | 333 | if (_is_maximized || (_is_integrated && GetMaximizedWindow())) |
653 | 275 | { | 334 | { |
654 | 276 | if (_window_buttons) | 335 | if (_window_buttons) |
655 | 277 | { | 336 | { |
656 | @@ -284,6 +343,18 @@ | |||
657 | 284 | { | 343 | { |
658 | 285 | found_area = _titlebar_grab_area->FindAreaUnderMouse(mouse_position, event_type); | 344 | found_area = _titlebar_grab_area->FindAreaUnderMouse(mouse_position, event_type); |
659 | 286 | NUX_RETURN_VALUE_IF_NOTNULL(found_area, found_area); | 345 | NUX_RETURN_VALUE_IF_NOTNULL(found_area, found_area); |
660 | 346 | |||
661 | 347 | /* When the integrated menus are enabled, that area must act both like an | ||
662 | 348 | * indicator-entry view and like a panel-grab-area, so not to re-implement | ||
663 | 349 | * what we have done into PanelTitleGrabAreaView inside PanelIndicatorAppmenuView | ||
664 | 350 | * we can just redirect the input events directed to the integrated menus | ||
665 | 351 | * to the grab_area, then we just have to use few tricks when we get the | ||
666 | 352 | * signals back from the grab-area to check where they really were */ | ||
667 | 353 | if (_is_integrated && _integrated_menu) | ||
668 | 354 | { | ||
669 | 355 | if (_integrated_menu->GetAbsoluteGeometry().IsInside(mouse_position)) | ||
670 | 356 | return _titlebar_grab_area; | ||
671 | 357 | } | ||
672 | 287 | } | 358 | } |
673 | 288 | 359 | ||
674 | 289 | return PanelIndicatorsView::FindAreaUnderMouse(mouse_position, event_type); | 360 | return PanelIndicatorsView::FindAreaUnderMouse(mouse_position, event_type); |
675 | @@ -338,6 +409,16 @@ | |||
676 | 338 | auto wm = WindowManager::Default(); | 409 | auto wm = WindowManager::Default(); |
677 | 339 | bool screen_grabbed = (wm->IsExpoActive() || wm->IsScaleActive()); | 410 | bool screen_grabbed = (wm->IsExpoActive() || wm->IsScaleActive()); |
678 | 340 | 411 | ||
679 | 412 | if (_is_integrated && _integrated_menu) | ||
680 | 413 | { | ||
681 | 414 | if (!_overlay_showing && !screen_grabbed) | ||
682 | 415 | { | ||
683 | 416 | return (GetMaximizedWindow() != 0); | ||
684 | 417 | } | ||
685 | 418 | |||
686 | 419 | return false; | ||
687 | 420 | } | ||
688 | 421 | |||
689 | 341 | if (_we_control_active && !_overlay_showing && !screen_grabbed && | 422 | if (_we_control_active && !_overlay_showing && !screen_grabbed && |
690 | 342 | !_switcher_showing && !_launcher_keynav) | 423 | !_switcher_showing && !_launcher_keynav) |
691 | 343 | { | 424 | { |
692 | @@ -358,6 +439,16 @@ | |||
693 | 358 | if (_overlay_showing) | 439 | if (_overlay_showing) |
694 | 359 | return true; | 440 | return true; |
695 | 360 | 441 | ||
696 | 442 | if (_is_integrated) | ||
697 | 443 | { | ||
698 | 444 | if (!screen_grabbed) | ||
699 | 445 | { | ||
700 | 446 | return (GetMaximizedWindow() != 0); | ||
701 | 447 | } | ||
702 | 448 | |||
703 | 449 | return false; | ||
704 | 450 | } | ||
705 | 451 | |||
706 | 361 | if (_we_control_active && _is_maximized && !screen_grabbed && | 452 | if (_we_control_active && _is_maximized && !screen_grabbed && |
707 | 362 | !_launcher_keynav && !_switcher_showing) | 453 | !_launcher_keynav && !_switcher_showing) |
708 | 363 | { | 454 | { |
709 | @@ -528,7 +619,8 @@ | |||
710 | 528 | { | 619 | { |
711 | 529 | double title_opacity = 0.0f; | 620 | double title_opacity = 0.0f; |
712 | 530 | 621 | ||
714 | 531 | if (_we_control_active && _window_buttons->GetOpacity() == 0.0 && | 622 | if ((_we_control_active || (_is_integrated && !draw_menus)) && |
715 | 623 | _window_buttons->GetOpacity() == 0.0 && | ||
716 | 532 | (!has_menu || (has_menu && GetOpacity() == 0.0))) | 624 | (!has_menu || (has_menu && GetOpacity() == 0.0))) |
717 | 533 | { | 625 | { |
718 | 534 | title_opacity = 1.0f; | 626 | title_opacity = 1.0f; |
719 | @@ -610,7 +702,7 @@ | |||
720 | 610 | 702 | ||
721 | 611 | _fade_in_animator.Stop(); | 703 | _fade_in_animator.Stop(); |
722 | 612 | 704 | ||
724 | 613 | if (!_new_app_menu_shown) | 705 | if (_is_integrated || !_new_app_menu_shown) |
725 | 614 | { | 706 | { |
726 | 615 | _fade_out_animator.Start(1.0f - GetOpacity()); | 707 | _fade_out_animator.Start(1.0f - GetOpacity()); |
727 | 616 | } | 708 | } |
728 | @@ -711,6 +803,36 @@ | |||
729 | 711 | return label; | 803 | return label; |
730 | 712 | } | 804 | } |
731 | 713 | 805 | ||
732 | 806 | std::string PanelMenuView::GetMaximizedViewName(bool use_appname) const | ||
733 | 807 | { | ||
734 | 808 | Window maximized = GetMaximizedWindow(); | ||
735 | 809 | BamfWindow* window = nullptr; | ||
736 | 810 | std::string label; | ||
737 | 811 | |||
738 | 812 | window = GetBamfWindowForXid(maximized); | ||
739 | 813 | |||
740 | 814 | if (BAMF_IS_WINDOW(window) && IsWindowUnderOurControl(maximized)) | ||
741 | 815 | { | ||
742 | 816 | BamfView* view = reinterpret_cast<BamfView*>(window); | ||
743 | 817 | label = glib::String(bamf_view_get_name(view)).Str(); | ||
744 | 818 | |||
745 | 819 | if (use_appname || label.empty()) | ||
746 | 820 | { | ||
747 | 821 | BamfApplication* app = bamf_matcher_get_application_for_window(_matcher, window); | ||
748 | 822 | |||
749 | 823 | if (BAMF_IS_APPLICATION(app)) | ||
750 | 824 | view = reinterpret_cast<BamfView*>(app); | ||
751 | 825 | |||
752 | 826 | label = glib::String(bamf_view_get_name(view)).Str(); | ||
753 | 827 | } | ||
754 | 828 | } | ||
755 | 829 | |||
756 | 830 | if (label.empty() && _is_integrated && !DrawMenus() && _integrated_menu) | ||
757 | 831 | label = _desktop_name; | ||
758 | 832 | |||
759 | 833 | return label; | ||
760 | 834 | } | ||
761 | 835 | |||
762 | 714 | void PanelMenuView::DrawTitle(cairo_t *cr_real, nux::Geometry const& geo, std::string const& label) const | 836 | void PanelMenuView::DrawTitle(cairo_t *cr_real, nux::Geometry const& geo, std::string const& label) const |
763 | 715 | { | 837 | { |
764 | 716 | using namespace panel; | 838 | using namespace panel; |
765 | @@ -829,13 +951,34 @@ | |||
766 | 829 | { | 951 | { |
767 | 830 | new_title = ""; | 952 | new_title = ""; |
768 | 831 | } | 953 | } |
769 | 954 | else if (_is_integrated) | ||
770 | 955 | { | ||
771 | 956 | Window maximized = GetMaximizedWindow(); | ||
772 | 957 | new_title = GetMaximizedViewName(); | ||
773 | 958 | |||
774 | 959 | _window_buttons->SetControlledWindow(maximized); | ||
775 | 960 | _window_buttons->SetFocusedState(_active_xid == maximized); | ||
776 | 961 | |||
777 | 962 | if (_integrated_menu) | ||
778 | 963 | { | ||
779 | 964 | _integrated_menu->SetControlledWindow(maximized); | ||
780 | 965 | |||
781 | 966 | if (DrawMenus()) | ||
782 | 967 | { | ||
783 | 968 | _integrated_menu->SetLabel(new_title); | ||
784 | 969 | _integrated_menu->SetFocusedState(_active_xid == maximized); | ||
785 | 970 | |||
786 | 971 | return; | ||
787 | 972 | } | ||
788 | 973 | } | ||
789 | 974 | } | ||
790 | 832 | else if (!_switcher_showing && !_launcher_keynav) | 975 | else if (!_switcher_showing && !_launcher_keynav) |
791 | 833 | { | 976 | { |
792 | 834 | new_title = GetActiveViewName(); | 977 | new_title = GetActiveViewName(); |
793 | 835 | _window_buttons->SetControlledWindow(_active_xid); | 978 | _window_buttons->SetControlledWindow(_active_xid); |
794 | 836 | } | 979 | } |
795 | 837 | 980 | ||
797 | 838 | if (!_switcher_showing && !_launcher_keynav) | 981 | if ((!_switcher_showing && !_launcher_keynav) || _is_integrated) |
798 | 839 | { | 982 | { |
799 | 840 | if (_panel_title != new_title) | 983 | if (_panel_title != new_title) |
800 | 841 | { | 984 | { |
801 | @@ -894,9 +1037,23 @@ | |||
802 | 894 | { | 1037 | { |
803 | 895 | PanelIndicatorEntryView* view; | 1038 | PanelIndicatorEntryView* view; |
804 | 896 | 1039 | ||
808 | 897 | view = new PanelIndicatorEntryView(entry, MENU_ENTRIES_PADDING, IndicatorEntryType::MENU); | 1040 | if (!_is_integrated) |
809 | 898 | view->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); | 1041 | { |
810 | 899 | view->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); | 1042 | view = new PanelIndicatorEntryView(entry, MENU_ENTRIES_PADDING, IndicatorEntryType::MENU); |
811 | 1043 | view->mouse_enter.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseEnter)); | ||
812 | 1044 | view->mouse_leave.connect(sigc::mem_fun(this, &PanelMenuView::OnPanelViewMouseLeave)); | ||
813 | 1045 | } | ||
814 | 1046 | else | ||
815 | 1047 | { | ||
816 | 1048 | if (_integrated_menu) | ||
817 | 1049 | { | ||
818 | 1050 | LOG_ERROR(logger) << "Another integrated menu has already been defined, this shouldn't happen!"; | ||
819 | 1051 | } | ||
820 | 1052 | |||
821 | 1053 | _integrated_menu = new PanelIndicatorAppmenuView(entry); | ||
822 | 1054 | view = _integrated_menu; | ||
823 | 1055 | Refresh(); | ||
824 | 1056 | } | ||
825 | 900 | 1057 | ||
826 | 901 | entry->show_now_changed.connect(sigc::mem_fun(this, &PanelMenuView::UpdateShowNow)); | 1058 | entry->show_now_changed.connect(sigc::mem_fun(this, &PanelMenuView::UpdateShowNow)); |
827 | 902 | view->active_changed.connect(sigc::mem_fun(this, &PanelMenuView::OnActiveChanged)); | 1059 | view->active_changed.connect(sigc::mem_fun(this, &PanelMenuView::OnActiveChanged)); |
828 | @@ -904,13 +1061,24 @@ | |||
829 | 904 | AddEntryView(view, IndicatorEntryPosition::END); | 1061 | AddEntryView(view, IndicatorEntryPosition::END); |
830 | 905 | } | 1062 | } |
831 | 906 | 1063 | ||
832 | 1064 | void PanelMenuView::OnEntryRemoved(std::string const& entry_id) | ||
833 | 1065 | { | ||
834 | 1066 | if (_integrated_menu && _integrated_menu->GetEntryID() == entry_id) | ||
835 | 1067 | _integrated_menu = nullptr; | ||
836 | 1068 | |||
837 | 1069 | RemoveEntry(entry_id); | ||
838 | 1070 | } | ||
839 | 1071 | |||
840 | 907 | void PanelMenuView::NotifyAllMenusClosed() | 1072 | void PanelMenuView::NotifyAllMenusClosed() |
841 | 908 | { | 1073 | { |
842 | 909 | _last_active_view = nullptr; | 1074 | _last_active_view = nullptr; |
843 | 910 | 1075 | ||
847 | 911 | auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); | 1076 | if (!_is_integrated) |
848 | 912 | _is_inside = GetAbsoluteGeometry().IsInside(mouse); | 1077 | { |
849 | 913 | FullRedraw(); | 1078 | auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); |
850 | 1079 | _is_inside = GetAbsoluteGeometry().IsInside(mouse); | ||
851 | 1080 | FullRedraw(); | ||
852 | 1081 | } | ||
853 | 914 | } | 1082 | } |
854 | 915 | 1083 | ||
855 | 916 | void PanelMenuView::OnNameChanged(BamfView* bamf_view, gchar* new_name, gchar* old_name) | 1084 | void PanelMenuView::OnNameChanged(BamfView* bamf_view, gchar* new_name, gchar* old_name) |
856 | @@ -1009,7 +1177,7 @@ | |||
857 | 1009 | BamfApplication* old_app, | 1177 | BamfApplication* old_app, |
858 | 1010 | BamfApplication* new_app) | 1178 | BamfApplication* new_app) |
859 | 1011 | { | 1179 | { |
861 | 1012 | if (BAMF_IS_APPLICATION(new_app)) | 1180 | if (BAMF_IS_APPLICATION(new_app) && !_is_integrated) |
862 | 1013 | { | 1181 | { |
863 | 1014 | if (std::find(_new_apps.begin(), _new_apps.end(), new_app) != _new_apps.end()) | 1182 | if (std::find(_new_apps.begin(), _new_apps.end(), new_app) != _new_apps.end()) |
864 | 1015 | { | 1183 | { |
865 | @@ -1097,7 +1265,10 @@ | |||
866 | 1097 | _view_name_changed_signal.Connect(new_view, "name-changed", | 1265 | _view_name_changed_signal.Connect(new_view, "name-changed", |
867 | 1098 | sigc::mem_fun(this, &PanelMenuView::OnNameChanged)); | 1266 | sigc::mem_fun(this, &PanelMenuView::OnNameChanged)); |
868 | 1099 | 1267 | ||
870 | 1100 | _window_buttons->SetControlledWindow(_is_maximized ? _active_xid : 0); | 1268 | if (!_is_integrated) |
871 | 1269 | { | ||
872 | 1270 | _window_buttons->SetControlledWindow(_is_maximized ? _active_xid : 0); | ||
873 | 1271 | } | ||
874 | 1101 | } | 1272 | } |
875 | 1102 | 1273 | ||
876 | 1103 | Refresh(); | 1274 | Refresh(); |
877 | @@ -1213,9 +1384,12 @@ | |||
878 | 1213 | 1384 | ||
879 | 1214 | if (is_active) | 1385 | if (is_active) |
880 | 1215 | { | 1386 | { |
884 | 1216 | // We need to update the _is_inside state in the case of maximization by grab | 1387 | if (!_is_integrated) |
885 | 1217 | auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); | 1388 | { |
886 | 1218 | _is_inside = GetAbsoluteGeometry().IsInside(mouse); | 1389 | // We need to update the _is_inside state in the case of maximization by grab |
887 | 1390 | auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); | ||
888 | 1391 | _is_inside = GetAbsoluteGeometry().IsInside(mouse); | ||
889 | 1392 | } | ||
890 | 1219 | 1393 | ||
891 | 1220 | _is_maximized = true; | 1394 | _is_maximized = true; |
892 | 1221 | updated = true; | 1395 | updated = true; |
893 | @@ -1229,7 +1403,7 @@ | |||
894 | 1229 | 1403 | ||
895 | 1230 | _maximized_set.insert(xid); | 1404 | _maximized_set.insert(xid); |
896 | 1231 | 1405 | ||
898 | 1232 | if (updated) | 1406 | if (updated || _is_integrated) |
899 | 1233 | { | 1407 | { |
900 | 1234 | Refresh(); | 1408 | Refresh(); |
901 | 1235 | FullRedraw(); | 1409 | FullRedraw(); |
902 | @@ -1410,6 +1584,23 @@ | |||
903 | 1410 | { | 1584 | { |
904 | 1411 | WindowManager::Default()->Activate(maximized); | 1585 | WindowManager::Default()->Activate(maximized); |
905 | 1412 | } | 1586 | } |
906 | 1587 | |||
907 | 1588 | /* If the user clicked over the integrated_menu we need to adjust | ||
908 | 1589 | * the coordinates we got, because they're relative to the grab area, | ||
909 | 1590 | * but due to the workaround we used, the point clicked could be | ||
910 | 1591 | * also in the integrated-menu geometry, so we can easiliy set them | ||
911 | 1592 | * correctly to check where we are and to eventually activate the | ||
912 | 1593 | * integrated menu */ | ||
913 | 1594 | if (_is_integrated && _integrated_menu) | ||
914 | 1595 | { | ||
915 | 1596 | x += _titlebar_grab_area->GetAbsoluteX(); | ||
916 | 1597 | y += _titlebar_grab_area->GetAbsoluteY(); | ||
917 | 1598 | |||
918 | 1599 | if (_integrated_menu->GetAbsoluteGeometry().IsPointInside(x, y)) | ||
919 | 1600 | { | ||
920 | 1601 | _integrated_menu->Activate(); | ||
921 | 1602 | } | ||
922 | 1603 | } | ||
923 | 1413 | } | 1604 | } |
924 | 1414 | 1605 | ||
925 | 1415 | void PanelMenuView::OnMaximizedRestore(int x, int y) | 1606 | void PanelMenuView::OnMaximizedRestore(int x, int y) |
926 | @@ -1468,6 +1659,17 @@ | |||
927 | 1468 | x += _titlebar_grab_area->GetAbsoluteX(); | 1659 | x += _titlebar_grab_area->GetAbsoluteX(); |
928 | 1469 | y += _titlebar_grab_area->GetAbsoluteY(); | 1660 | y += _titlebar_grab_area->GetAbsoluteY(); |
929 | 1470 | 1661 | ||
930 | 1662 | /* If the user clicked over the integrated_menu we need to adjust | ||
931 | 1663 | * the coordinates again, because they are still relative to the grab area */ | ||
932 | 1664 | if (_is_integrated && _integrated_menu) | ||
933 | 1665 | { | ||
934 | 1666 | if (_integrated_menu->GetAbsoluteGeometry().IsPointInside(x, y)) | ||
935 | 1667 | { | ||
936 | 1668 | x += _integrated_menu->GetAbsoluteX(); | ||
937 | 1669 | y += _integrated_menu->GetAbsoluteY(); | ||
938 | 1670 | } | ||
939 | 1671 | } | ||
940 | 1672 | |||
941 | 1471 | Window maximized = GetMaximizedWindow(); | 1673 | Window maximized = GetMaximizedWindow(); |
942 | 1472 | 1674 | ||
943 | 1473 | /* When the drag goes out from the Panel, start the real movement. | 1675 | /* When the drag goes out from the Panel, start the real movement. |
944 | @@ -1543,6 +1745,7 @@ | |||
945 | 1543 | PanelIndicatorsView::AddProperties(builder); | 1745 | PanelIndicatorsView::AddProperties(builder); |
946 | 1544 | 1746 | ||
947 | 1545 | variant::BuilderWrapper(builder) | 1747 | variant::BuilderWrapper(builder) |
948 | 1748 | .add("integrated", _is_integrated) | ||
949 | 1546 | .add("mouse_inside", _is_inside) | 1749 | .add("mouse_inside", _is_inside) |
950 | 1547 | .add("grabbed", _is_grabbed) | 1750 | .add("grabbed", _is_grabbed) |
951 | 1548 | .add("active_win_maximized", _is_maximized) | 1751 | .add("active_win_maximized", _is_maximized) |
952 | @@ -1574,7 +1777,7 @@ | |||
953 | 1574 | 1777 | ||
954 | 1575 | _switcher_showing = switcher_shown; | 1778 | _switcher_showing = switcher_shown; |
955 | 1576 | 1779 | ||
957 | 1577 | if (!_switcher_showing) | 1780 | if (!_switcher_showing && !_is_integrated) |
958 | 1578 | { | 1781 | { |
959 | 1579 | auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); | 1782 | auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); |
960 | 1580 | _is_inside = GetAbsoluteGeometry().IsInside(mouse); | 1783 | _is_inside = GetAbsoluteGeometry().IsInside(mouse); |
961 | @@ -1619,8 +1822,11 @@ | |||
962 | 1619 | 1822 | ||
963 | 1620 | _launcher_keynav = false; | 1823 | _launcher_keynav = false; |
964 | 1621 | 1824 | ||
967 | 1622 | auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); | 1825 | if (!_is_integrated) |
968 | 1623 | _is_inside = GetAbsoluteGeometry().IsInside(mouse); | 1826 | { |
969 | 1827 | auto mouse = nux::GetGraphicsDisplay()->GetMouseScreenCoord(); | ||
970 | 1828 | _is_inside = GetAbsoluteGeometry().IsInside(mouse); | ||
971 | 1829 | } | ||
972 | 1624 | 1830 | ||
973 | 1625 | Refresh(); | 1831 | Refresh(); |
974 | 1626 | QueueDraw(); | 1832 | QueueDraw(); |
975 | @@ -1670,6 +1876,9 @@ | |||
976 | 1670 | * If the status is false, we just check that the menus entries are hidden | 1876 | * If the status is false, we just check that the menus entries are hidden |
977 | 1671 | * and we remove any eventual delayed request */ | 1877 | * and we remove any eventual delayed request */ |
978 | 1672 | 1878 | ||
979 | 1879 | if (_is_integrated) | ||
980 | 1880 | return; | ||
981 | 1881 | |||
982 | 1673 | if (!status && _show_now_activated) | 1882 | if (!status && _show_now_activated) |
983 | 1674 | { | 1883 | { |
984 | 1675 | _show_now_activated = false; | 1884 | _show_now_activated = false; |
985 | @@ -1726,7 +1935,18 @@ | |||
986 | 1726 | } | 1935 | } |
987 | 1727 | 1936 | ||
988 | 1728 | Window maximized = GetMaximizedWindow(); | 1937 | Window maximized = GetMaximizedWindow(); |
990 | 1729 | Window buttons_win = (maximized == _active_xid) ? maximized : 0; | 1938 | Window buttons_win = 0; |
991 | 1939 | |||
992 | 1940 | if (_is_integrated) | ||
993 | 1941 | { | ||
994 | 1942 | buttons_win = maximized; | ||
995 | 1943 | _window_buttons->SetFocusedState(maximized == _active_xid); | ||
996 | 1944 | } | ||
997 | 1945 | else | ||
998 | 1946 | { | ||
999 | 1947 | buttons_win = (maximized == _active_xid) ? maximized : 0; | ||
1000 | 1948 | _window_buttons->SetControlledWindow(buttons_win); | ||
1001 | 1949 | } | ||
1002 | 1730 | 1950 | ||
1003 | 1731 | _window_buttons->SetMonitor(_monitor); | 1951 | _window_buttons->SetMonitor(_monitor); |
1004 | 1732 | _window_buttons->SetControlledWindow(buttons_win); | 1952 | _window_buttons->SetControlledWindow(buttons_win); |
1005 | 1733 | 1953 | ||
1006 | === modified file 'plugins/unityshell/src/PanelMenuView.h' | |||
1007 | --- plugins/unityshell/src/PanelMenuView.h 2012-04-09 13:13:16 +0000 | |||
1008 | +++ plugins/unityshell/src/PanelMenuView.h 2012-04-18 08:58:24 +0000 | |||
1009 | @@ -28,6 +28,7 @@ | |||
1010 | 28 | #include "PanelIndicatorsView.h" | 28 | #include "PanelIndicatorsView.h" |
1011 | 29 | #include "StaticCairoText.h" | 29 | #include "StaticCairoText.h" |
1012 | 30 | #include "WindowButtons.h" | 30 | #include "WindowButtons.h" |
1013 | 31 | #include "PanelIndicatorAppmenuView.h" | ||
1014 | 31 | #include "PanelTitlebarGrabAreaView.h" | 32 | #include "PanelTitlebarGrabAreaView.h" |
1015 | 32 | #include "PluginAdapter.h" | 33 | #include "PluginAdapter.h" |
1016 | 33 | #include "Animator.h" | 34 | #include "Animator.h" |
1017 | @@ -47,14 +48,17 @@ | |||
1018 | 47 | 48 | ||
1019 | 48 | void SetMousePosition(int x, int y); | 49 | void SetMousePosition(int x, int y); |
1020 | 49 | void SetMonitor(int monitor); | 50 | void SetMonitor(int monitor); |
1021 | 51 | void SetIntegrated(bool integrated); | ||
1022 | 50 | 52 | ||
1023 | 51 | Window GetTopWindow() const; | 53 | Window GetTopWindow() const; |
1024 | 52 | Window GetMaximizedWindow() const; | 54 | Window GetMaximizedWindow() const; |
1025 | 53 | bool GetControlsActive() const; | 55 | bool GetControlsActive() const; |
1026 | 56 | bool IsIntegrated() const; | ||
1027 | 54 | 57 | ||
1028 | 55 | void NotifyAllMenusClosed(); | 58 | void NotifyAllMenusClosed(); |
1029 | 56 | 59 | ||
1030 | 57 | virtual void AddIndicator(indicator::Indicator::Ptr const& indicator); | 60 | virtual void AddIndicator(indicator::Indicator::Ptr const& indicator); |
1031 | 61 | virtual void RemoveIndicator(indicator::Indicator::Ptr const& indicator); | ||
1032 | 58 | 62 | ||
1033 | 59 | virtual void OverlayShown(); | 63 | virtual void OverlayShown(); |
1034 | 60 | virtual void OverlayHidden(); | 64 | virtual void OverlayHidden(); |
1035 | @@ -69,6 +73,7 @@ | |||
1036 | 69 | virtual nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, | 73 | virtual nux::Area* FindAreaUnderMouse(const nux::Point& mouse_position, |
1037 | 70 | nux::NuxEventType event_type); | 74 | nux::NuxEventType event_type); |
1038 | 71 | virtual void OnEntryAdded(indicator::Entry::Ptr const& entry); | 75 | virtual void OnEntryAdded(indicator::Entry::Ptr const& entry); |
1039 | 76 | virtual void OnEntryRemoved(std::string const& entry_id); | ||
1040 | 72 | 77 | ||
1041 | 73 | private: | 78 | private: |
1042 | 74 | void OnActiveChanged(PanelIndicatorEntryView* view, bool is_active); | 79 | void OnActiveChanged(PanelIndicatorEntryView* view, bool is_active); |
1043 | @@ -110,6 +115,7 @@ | |||
1044 | 110 | 115 | ||
1045 | 111 | BamfWindow* GetBamfWindowForXid(Window xid) const; | 116 | BamfWindow* GetBamfWindowForXid(Window xid) const; |
1046 | 112 | 117 | ||
1047 | 118 | std::string GetMaximizedViewName(bool use_appname = false) const; | ||
1048 | 113 | std::string GetActiveViewName(bool use_appname = false) const; | 119 | std::string GetActiveViewName(bool use_appname = false) const; |
1049 | 114 | 120 | ||
1050 | 115 | void OnSwitcherShown(GVariant* data); | 121 | void OnSwitcherShown(GVariant* data); |
1051 | @@ -141,10 +147,12 @@ | |||
1052 | 141 | nux::ObjectPtr<nux::BaseTexture> _title_texture; | 147 | nux::ObjectPtr<nux::BaseTexture> _title_texture; |
1053 | 142 | nux::ObjectPtr<nux::IOpenGLBaseTexture> _gradient_texture; | 148 | nux::ObjectPtr<nux::IOpenGLBaseTexture> _gradient_texture; |
1054 | 143 | 149 | ||
1055 | 150 | bool _is_integrated; | ||
1056 | 144 | bool _is_inside; | 151 | bool _is_inside; |
1057 | 145 | bool _is_grabbed; | 152 | bool _is_grabbed; |
1058 | 146 | bool _is_maximized; | 153 | bool _is_maximized; |
1059 | 147 | 154 | ||
1060 | 155 | PanelIndicatorAppmenuView* _integrated_menu; | ||
1061 | 148 | PanelIndicatorEntryView* _last_active_view; | 156 | PanelIndicatorEntryView* _last_active_view; |
1062 | 149 | WindowButtons* _window_buttons; | 157 | WindowButtons* _window_buttons; |
1063 | 150 | PanelTitlebarGrabArea* _titlebar_grab_area; | 158 | PanelTitlebarGrabArea* _titlebar_grab_area; |
1064 | @@ -178,6 +186,7 @@ | |||
1065 | 178 | glib::Signal<void, BamfMatcher*, BamfApplication*, BamfApplication*> _active_app_changed_signal; | 186 | glib::Signal<void, BamfMatcher*, BamfApplication*, BamfApplication*> _active_app_changed_signal; |
1066 | 179 | glib::Signal<void, BamfView*, gchar*, gchar*> _view_name_changed_signal; | 187 | glib::Signal<void, BamfView*, gchar*, gchar*> _view_name_changed_signal; |
1067 | 180 | sigc::connection _style_changed_connection; | 188 | sigc::connection _style_changed_connection; |
1068 | 189 | sigc::connection _mode_changed_connection; | ||
1069 | 181 | 190 | ||
1070 | 182 | UBusManager _ubus_manager; | 191 | UBusManager _ubus_manager; |
1071 | 183 | 192 | ||
1072 | 184 | 193 | ||
1073 | === modified file 'plugins/unityshell/src/PanelStyle.cpp' | |||
1074 | --- plugins/unityshell/src/PanelStyle.cpp 2012-04-02 09:34:58 +0000 | |||
1075 | +++ plugins/unityshell/src/PanelStyle.cpp 2012-04-18 08:58:24 +0000 | |||
1076 | @@ -61,6 +61,7 @@ | |||
1077 | 61 | 61 | ||
1078 | 62 | Style::Style() | 62 | Style::Style() |
1079 | 63 | : panel_height(24) | 63 | : panel_height(24) |
1080 | 64 | , integrated_menus(false) | ||
1081 | 64 | , _style_context(gtk_style_context_new()) | 65 | , _style_context(gtk_style_context_new()) |
1082 | 65 | { | 66 | { |
1083 | 66 | if (style_instance) | 67 | if (style_instance) |
1084 | 67 | 68 | ||
1085 | === modified file 'plugins/unityshell/src/PanelStyle.h' | |||
1086 | --- plugins/unityshell/src/PanelStyle.h 2012-03-30 13:01:12 +0000 | |||
1087 | +++ plugins/unityshell/src/PanelStyle.h 2012-04-18 08:58:24 +0000 | |||
1088 | @@ -77,6 +77,7 @@ | |||
1089 | 77 | int GetTextDPI(); | 77 | int GetTextDPI(); |
1090 | 78 | 78 | ||
1091 | 79 | nux::Property<int> panel_height; | 79 | nux::Property<int> panel_height; |
1092 | 80 | nux::Property<bool> integrated_menus; | ||
1093 | 80 | 81 | ||
1094 | 81 | sigc::signal<void> changed; | 82 | sigc::signal<void> changed; |
1095 | 82 | 83 | ||
1096 | 83 | 84 | ||
1097 | === modified file 'plugins/unityshell/src/unityshell.cpp' | |||
1098 | --- plugins/unityshell/src/unityshell.cpp 2012-04-15 10:44:39 +0000 | |||
1099 | +++ plugins/unityshell/src/unityshell.cpp 2012-04-18 08:58:24 +0000 | |||
1100 | @@ -2259,14 +2259,15 @@ | |||
1101 | 2259 | uScreen->setPanelShadowMatrix(matrix); | 2259 | uScreen->setPanelShadowMatrix(matrix); |
1102 | 2260 | 2260 | ||
1103 | 2261 | Window active_window = screen->activeWindow(); | 2261 | Window active_window = screen->activeWindow(); |
1105 | 2262 | if (window->id() == active_window && window->type() != CompWindowTypeDesktopMask) | 2262 | bool integrated_menus = panel::Style::Instance().integrated_menus; |
1106 | 2263 | if (window->id() == active_window && window->type() != CompWindowTypeDesktopMask && !integrated_menus) | ||
1107 | 2263 | { | 2264 | { |
1108 | 2264 | uScreen->paintPanelShadow(matrix); | 2265 | uScreen->paintPanelShadow(matrix); |
1109 | 2265 | } | 2266 | } |
1110 | 2266 | 2267 | ||
1111 | 2267 | bool ret = gWindow->glDraw(matrix, attrib, region, mask); | 2268 | bool ret = gWindow->glDraw(matrix, attrib, region, mask); |
1112 | 2268 | 2269 | ||
1114 | 2269 | if ((active_window == 0 || active_window == window->id()) && | 2270 | if ((active_window == 0 || active_window == window->id() || integrated_menus) && |
1115 | 2270 | (window->type() == CompWindowTypeDesktopMask)) | 2271 | (window->type() == CompWindowTypeDesktopMask)) |
1116 | 2271 | { | 2272 | { |
1117 | 2272 | uScreen->paintPanelShadow(matrix); | 2273 | uScreen->paintPanelShadow(matrix); |
1118 | 2273 | 2274 | ||
1119 | === modified file 'tests/test_indicator_appmenu.cpp' | |||
1120 | --- tests/test_indicator_appmenu.cpp 2012-03-29 12:06:35 +0000 | |||
1121 | +++ tests/test_indicator_appmenu.cpp 2012-04-18 08:58:24 +0000 | |||
1122 | @@ -30,16 +30,74 @@ | |||
1123 | 30 | 30 | ||
1124 | 31 | TEST(TestAppmenuIndicator, Construction) | 31 | TEST(TestAppmenuIndicator, Construction) |
1125 | 32 | { | 32 | { |
1126 | 33 | g_setenv("GSETTINGS_BACKEND", "memory", true); | ||
1127 | 34 | |||
1128 | 33 | AppmenuIndicator indicator("indicator-appmenu"); | 35 | AppmenuIndicator indicator("indicator-appmenu"); |
1129 | 34 | 36 | ||
1130 | 35 | EXPECT_EQ(indicator.name(), "indicator-appmenu"); | 37 | EXPECT_EQ(indicator.name(), "indicator-appmenu"); |
1131 | 36 | EXPECT_TRUE(indicator.IsAppmenu()); | 38 | EXPECT_TRUE(indicator.IsAppmenu()); |
1132 | 39 | EXPECT_FALSE(indicator.IsIntegrated()); | ||
1133 | 40 | } | ||
1134 | 41 | |||
1135 | 42 | TEST(TestAppmenuIndicator, ConstructionIntegrated) | ||
1136 | 43 | { | ||
1137 | 44 | g_setenv("GSETTINGS_BACKEND", "memory", true); | ||
1138 | 45 | |||
1139 | 46 | glib::Object<GSettings> gsettings(g_settings_new("com.canonical.indicator.appmenu")); | ||
1140 | 47 | g_settings_set_string(gsettings, "menu-mode", "locally-integrated"); | ||
1141 | 48 | |||
1142 | 49 | AppmenuIndicator indicator("indicator-appmenu-integrated"); | ||
1143 | 50 | |||
1144 | 51 | EXPECT_EQ(indicator.name(), "indicator-appmenu-integrated"); | ||
1145 | 52 | EXPECT_TRUE(indicator.IsAppmenu()); | ||
1146 | 53 | EXPECT_TRUE(indicator.IsIntegrated()); | ||
1147 | 54 | } | ||
1148 | 55 | |||
1149 | 56 | TEST(TestAppmenuIndicator, IntegratedValue) | ||
1150 | 57 | { | ||
1151 | 58 | g_setenv("GSETTINGS_BACKEND", "memory", true); | ||
1152 | 59 | |||
1153 | 60 | glib::Object<GSettings> gsettings(g_settings_new("com.canonical.indicator.appmenu")); | ||
1154 | 61 | g_settings_set_string(gsettings, "menu-mode", "global"); | ||
1155 | 62 | |||
1156 | 63 | AppmenuIndicator indicator("indicator-appmenu"); | ||
1157 | 64 | EXPECT_FALSE(indicator.IsIntegrated()); | ||
1158 | 65 | |||
1159 | 66 | bool integrated_changed = false; | ||
1160 | 67 | bool integrated_value = false; | ||
1161 | 68 | indicator.integrated_changed.connect([&] (bool new_value) { | ||
1162 | 69 | integrated_changed = true; | ||
1163 | 70 | integrated_value = new_value; | ||
1164 | 71 | }); | ||
1165 | 72 | |||
1166 | 73 | g_settings_set_string(gsettings, "menu-mode", "locally-integrated"); | ||
1167 | 74 | EXPECT_TRUE(integrated_changed); | ||
1168 | 75 | EXPECT_TRUE(integrated_value); | ||
1169 | 76 | EXPECT_TRUE(indicator.IsIntegrated()); | ||
1170 | 77 | |||
1171 | 78 | integrated_changed = false; | ||
1172 | 79 | g_settings_set_string(gsettings, "menu-mode", "locally-integrated"); | ||
1173 | 80 | EXPECT_FALSE(integrated_changed); | ||
1174 | 81 | EXPECT_TRUE(integrated_value); | ||
1175 | 82 | EXPECT_TRUE(indicator.IsIntegrated()); | ||
1176 | 83 | |||
1177 | 84 | integrated_changed = false; | ||
1178 | 85 | g_settings_set_string(gsettings, "menu-mode", "global"); | ||
1179 | 86 | EXPECT_TRUE(integrated_changed); | ||
1180 | 87 | EXPECT_FALSE(integrated_value); | ||
1181 | 88 | EXPECT_FALSE(indicator.IsIntegrated()); | ||
1182 | 37 | } | 89 | } |
1183 | 38 | 90 | ||
1184 | 39 | TEST(TestAppmenuIndicator, ShowAppmenu) | 91 | TEST(TestAppmenuIndicator, ShowAppmenu) |
1185 | 40 | { | 92 | { |
1186 | 93 | g_setenv("GSETTINGS_BACKEND", "memory", true); | ||
1187 | 94 | |||
1188 | 95 | glib::Object<GSettings> gsettings(g_settings_new("com.canonical.indicator.appmenu")); | ||
1189 | 96 | g_settings_set_string(gsettings, "menu-mode", "global"); | ||
1190 | 97 | |||
1191 | 41 | AppmenuIndicator indicator("indicator-appmenu"); | 98 | AppmenuIndicator indicator("indicator-appmenu"); |
1192 | 42 | 99 | ||
1193 | 100 | bool ret; | ||
1194 | 43 | bool signal_emitted = false; | 101 | bool signal_emitted = false; |
1195 | 44 | int show_x, show_y; | 102 | int show_x, show_y; |
1196 | 45 | unsigned int show_xid, show_timestamp; | 103 | unsigned int show_xid, show_timestamp; |
1197 | @@ -54,7 +112,14 @@ | |||
1198 | 54 | show_timestamp = timestamp; | 112 | show_timestamp = timestamp; |
1199 | 55 | }); | 113 | }); |
1200 | 56 | 114 | ||
1202 | 57 | indicator.ShowAppmenu(123456789, 50, 100, 1328308554); | 115 | ret = indicator.ShowAppmenu(123456789, 50, 100, 1328063758); |
1203 | 116 | EXPECT_FALSE(ret); | ||
1204 | 117 | EXPECT_FALSE(signal_emitted); | ||
1205 | 118 | |||
1206 | 119 | g_settings_set_string(gsettings, "menu-mode", "locally-integrated"); | ||
1207 | 120 | |||
1208 | 121 | ret = indicator.ShowAppmenu(123456789, 50, 100, 1328308554); | ||
1209 | 122 | EXPECT_TRUE(ret); | ||
1210 | 58 | EXPECT_TRUE(signal_emitted); | 123 | EXPECT_TRUE(signal_emitted); |
1211 | 59 | 124 | ||
1212 | 60 | EXPECT_EQ(show_xid, 123456789); | 125 | EXPECT_EQ(show_xid, 123456789); |
8 +BuilderWrapper& BuilderWrapper: :add(char const* name, long int value) builder_ add(builder_ , "{sv}", name, g_variant_ new_int64( value)) ;
9 +{
10 + g_variant_
long is 32-bit on i386, if you really need 64bit value this should be changed to "long long".