Merge lp:~cimi/unity/unity.fix-836655_and_fix-838875 into lp:unity

Proposed by Andrea Cimitan on 2011-09-01
Status: Merged
Approved by: Neil J. Patel on 2011-09-02
Approved revision: 1473
Merged at revision: 1482
Proposed branch: lp:~cimi/unity/unity.fix-836655_and_fix-838875
Merge into: lp:unity
Diff against target: 313 lines (+177/-17)
3 files modified
plugins/unityshell/src/PanelMenuView.cpp (+6/-2)
plugins/unityshell/src/WindowButtons.cpp (+171/-14)
plugins/unityshell/src/WindowButtons.h (+0/-1)
To merge this branch: bzr merge lp:~cimi/unity/unity.fix-836655_and_fix-838875
Reviewer Review Type Date Requested Status
Neil J. Patel 2011-09-01 Pending
Review via email: mp+73699@code.launchpad.net

Description of the Change

Update assets and new behavior

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'plugins/unityshell/resources/close_dash.png'
2Binary files plugins/unityshell/resources/close_dash.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/close_dash.png 2011-09-01 17:04:25 +0000 differ
3=== added file 'plugins/unityshell/resources/close_dash_prelight.png'
4Binary files plugins/unityshell/resources/close_dash_prelight.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/close_dash_prelight.png 2011-09-01 17:04:25 +0000 differ
5=== added file 'plugins/unityshell/resources/close_dash_pressed.png'
6Binary files plugins/unityshell/resources/close_dash_pressed.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/close_dash_pressed.png 2011-09-01 17:04:25 +0000 differ
7=== added file 'plugins/unityshell/resources/maximize_dash.png'
8Binary files plugins/unityshell/resources/maximize_dash.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/maximize_dash.png 2011-09-01 17:04:25 +0000 differ
9=== added file 'plugins/unityshell/resources/maximize_dash_prelight.png'
10Binary files plugins/unityshell/resources/maximize_dash_prelight.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/maximize_dash_prelight.png 2011-09-01 17:04:25 +0000 differ
11=== added file 'plugins/unityshell/resources/maximize_dash_pressed.png'
12Binary files plugins/unityshell/resources/maximize_dash_pressed.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/maximize_dash_pressed.png 2011-09-01 17:04:25 +0000 differ
13=== added file 'plugins/unityshell/resources/minimize_dash.png'
14Binary files plugins/unityshell/resources/minimize_dash.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/minimize_dash.png 2011-09-01 17:04:25 +0000 differ
15=== added file 'plugins/unityshell/resources/minimize_dash_prelight.png'
16Binary files plugins/unityshell/resources/minimize_dash_prelight.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/minimize_dash_prelight.png 2011-09-01 17:04:25 +0000 differ
17=== added file 'plugins/unityshell/resources/minimize_dash_pressed.png'
18Binary files plugins/unityshell/resources/minimize_dash_pressed.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/minimize_dash_pressed.png 2011-09-01 17:04:25 +0000 differ
19=== added file 'plugins/unityshell/resources/unmaximize_dash.png'
20Binary files plugins/unityshell/resources/unmaximize_dash.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/unmaximize_dash.png 2011-09-01 17:04:25 +0000 differ
21=== added file 'plugins/unityshell/resources/unmaximize_dash_prelight.png'
22Binary files plugins/unityshell/resources/unmaximize_dash_prelight.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/unmaximize_dash_prelight.png 2011-09-01 17:04:25 +0000 differ
23=== added file 'plugins/unityshell/resources/unmaximize_dash_pressed.png'
24Binary files plugins/unityshell/resources/unmaximize_dash_pressed.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/unmaximize_dash_pressed.png 2011-09-01 17:04:25 +0000 differ
25=== modified file 'plugins/unityshell/src/PanelMenuView.cpp'
26--- plugins/unityshell/src/PanelMenuView.cpp 2011-08-25 18:25:25 +0000
27+++ plugins/unityshell/src/PanelMenuView.cpp 2011-09-01 17:04:25 +0000
28@@ -969,7 +969,8 @@
29 {
30 if (_places_showing)
31 {
32- DashSettings::GetDefault()->SetFormFactor(DashSettings::DESKTOP);
33+ // no action when dash is opened, LP bug #838875
34+ return;
35 }
36 else
37 {
38@@ -986,7 +987,10 @@
39 {
40 if (_places_showing)
41 {
42- DashSettings::GetDefault()->SetFormFactor(DashSettings::NETBOOK);
43+ if (DashSettings::GetDefault()->GetFormFactor() == DashSettings::DESKTOP)
44+ DashSettings::GetDefault()->SetFormFactor(DashSettings::NETBOOK);
45+ else
46+ DashSettings::GetDefault()->SetFormFactor(DashSettings::DESKTOP);
47 }
48 else
49 {
50
51=== modified file 'plugins/unityshell/src/WindowButtons.cpp'
52--- plugins/unityshell/src/WindowButtons.cpp 2011-08-19 15:17:30 +0000
53+++ plugins/unityshell/src/WindowButtons.cpp 2011-09-01 17:04:25 +0000
54@@ -16,6 +16,8 @@
55 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
56 */
57
58+#include "config.h"
59+
60 #include "Nux/Nux.h"
61 #include "Nux/HLayout.h"
62 #include "Nux/VLayout.h"
63@@ -28,9 +30,16 @@
64 #include <UnityCore/Variant.h>
65 #include "WindowButtons.h"
66
67-#include <glib.h>
68+#include "ubus-server.h"
69+#include "UBusMessages.h"
70
71+#include "DashSettings.h"
72 #include "PanelStyle.h"
73+
74+#include <UnityCore/GLibWrapper.h>
75+
76+using namespace unity;
77+
78 class WindowButton : public nux::Button
79 {
80 // A single window button
81@@ -40,10 +49,25 @@
82 _type(type),
83 _normal_tex(NULL),
84 _prelight_tex(NULL),
85- _pressed_tex(NULL)
86+ _pressed_tex(NULL),
87+ _normal_dash_tex(NULL),
88+ _prelight_dash_tex(NULL),
89+ _pressed_dash_tex(NULL),
90+ _dash_is_open(false),
91+ _place_shown_interest(0),
92+ _place_hidden_interest(0)
93 {
94 LoadImages();
95 PanelStyle::GetDefault()->changed.connect(sigc::mem_fun(this, &WindowButton::LoadImages));
96+ DashSettings::GetDefault()->changed.connect(sigc::mem_fun(this, &WindowButton::UpdateDashUnmaximize));
97+
98+ UBusServer* ubus = ubus_server_get_default();
99+ _place_shown_interest = ubus_server_register_interest(ubus, UBUS_PLACE_VIEW_SHOWN,
100+ (UBusCallback)&WindowButton::OnPlaceViewShown,
101+ this);
102+ _place_hidden_interest = ubus_server_register_interest(ubus, UBUS_PLACE_VIEW_HIDDEN,
103+ (UBusCallback)&WindowButton::OnPlaceViewHidden,
104+ this);
105 }
106
107 ~WindowButton()
108@@ -51,27 +75,42 @@
109 _normal_tex->UnReference();
110 _prelight_tex->UnReference();
111 _pressed_tex->UnReference();
112+ _normal_dash_tex->UnReference();
113+ _prelight_dash_tex->UnReference();
114+ _pressed_dash_tex->UnReference();
115+
116+ UBusServer* ubus = ubus_server_get_default();
117+ if (_place_shown_interest != 0)
118+ ubus_server_unregister_interest(ubus, _place_shown_interest);
119+ if (_place_hidden_interest != 0)
120+ ubus_server_unregister_interest(ubus, _place_hidden_interest);
121 }
122
123 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
124 {
125- nux::Geometry geo = GetGeometry();
126+ nux::Geometry geo = GetGeometry();
127 nux::BaseTexture* tex;
128 nux::TexCoordXForm texxform;
129
130 GfxContext.PushClippingRectangle(geo);
131
132- if (HasMouseFocus() && IsMouseInside())
133- {
134- tex = _pressed_tex;
135- }
136- else if (IsMouseInside())
137- {
138- tex = _prelight_tex;
139+ if (_dash_is_open)
140+ {
141+ if (HasMouseFocus() && IsMouseInside())
142+ tex = _pressed_dash_tex;
143+ else if (IsMouseInside())
144+ tex = _prelight_dash_tex;
145+ else
146+ tex = _normal_dash_tex;
147 }
148 else
149 {
150- tex = _normal_tex;
151+ if (HasMouseFocus() && IsMouseInside())
152+ tex = _pressed_tex;
153+ else if (IsMouseInside())
154+ tex = _prelight_tex;
155+ else
156+ tex = _normal_tex;
157 }
158
159 GfxContext.GetRenderStates().SetBlend(true);
160@@ -99,13 +138,70 @@
161 _prelight_tex->UnReference();
162 if (_pressed_tex)
163 _pressed_tex->UnReference();
164+ if (_normal_dash_tex)
165+ _normal_dash_tex->UnReference();
166+ if (_prelight_dash_tex)
167+ _prelight_dash_tex->UnReference();
168+ if (_pressed_dash_tex)
169+ _pressed_dash_tex->UnReference();
170
171 _normal_tex = style->GetWindowButton(_type, PanelStyle::WINDOW_STATE_NORMAL);
172 _prelight_tex = style->GetWindowButton(_type, PanelStyle::WINDOW_STATE_PRELIGHT);
173 _pressed_tex = style->GetWindowButton(_type, PanelStyle::WINDOW_STATE_PRESSED);
174-
175- if (_normal_tex)
176- SetMinMaxSize(_normal_tex->GetWidth(), _normal_tex->GetHeight());
177+ _normal_dash_tex = GetDashWindowButton(_type, PanelStyle::WINDOW_STATE_NORMAL);
178+ _prelight_dash_tex = GetDashWindowButton(_type, PanelStyle::WINDOW_STATE_PRELIGHT);
179+ _pressed_dash_tex = GetDashWindowButton(_type, PanelStyle::WINDOW_STATE_PRESSED);
180+
181+ if (_dash_is_open)
182+ {
183+ if (_normal_dash_tex)
184+ SetMinMaxSize(_normal_dash_tex->GetWidth(), _normal_dash_tex->GetHeight());
185+ }
186+ else
187+ {
188+ if (_normal_tex)
189+ SetMinMaxSize(_normal_tex->GetWidth(), _normal_tex->GetHeight());
190+ }
191+
192+ QueueDraw();
193+ }
194+
195+ void UpdateDashUnmaximize()
196+ {
197+ // only update the unmaximize button
198+ if (_type != PanelStyle::WINDOW_BUTTON_UNMAXIMIZE)
199+ return;
200+
201+ if (_normal_dash_tex)
202+ _normal_dash_tex->UnReference();
203+ if (_prelight_dash_tex)
204+ _prelight_dash_tex->UnReference();
205+ if (_pressed_dash_tex)
206+ _pressed_dash_tex->UnReference();
207+
208+ if (DashSettings::GetDefault()->GetFormFactor() == DashSettings::DESKTOP)
209+ {
210+ // get maximize buttons
211+ _normal_dash_tex = GetDashMaximizeWindowButton(PanelStyle::WINDOW_STATE_NORMAL);
212+ _prelight_dash_tex = GetDashMaximizeWindowButton(PanelStyle::WINDOW_STATE_PRELIGHT);
213+ _pressed_dash_tex = GetDashMaximizeWindowButton(PanelStyle::WINDOW_STATE_PRESSED);
214+ }
215+ else
216+ {
217+ // get unmaximize buttons
218+ _normal_dash_tex = GetDashWindowButton(_type, PanelStyle::WINDOW_STATE_NORMAL);
219+ _prelight_dash_tex = GetDashWindowButton(_type, PanelStyle::WINDOW_STATE_PRELIGHT);
220+ _pressed_dash_tex = GetDashWindowButton(_type, PanelStyle::WINDOW_STATE_PRESSED);
221+ }
222+
223+ // still check if the dash is really opened,
224+ // someone could change the form factor through dconf
225+ // when the dash is closed
226+ if (_dash_is_open)
227+ {
228+ if (_normal_dash_tex)
229+ SetMinMaxSize(_normal_dash_tex->GetWidth(), _normal_dash_tex->GetHeight());
230+ }
231
232 QueueDraw();
233 }
234@@ -115,6 +211,67 @@
235 nux::BaseTexture* _normal_tex;
236 nux::BaseTexture* _prelight_tex;
237 nux::BaseTexture* _pressed_tex;
238+ nux::BaseTexture* _normal_dash_tex;
239+ nux::BaseTexture* _prelight_dash_tex;
240+ nux::BaseTexture* _pressed_dash_tex;
241+ bool _dash_is_open;
242+ guint32 _place_shown_interest;
243+ guint32 _place_hidden_interest;
244+
245+ static void OnPlaceViewShown(GVariant* data, void* val)
246+ {
247+ WindowButton* self = (WindowButton*)val;
248+
249+ self->_dash_is_open = true;
250+ if (self->_normal_dash_tex)
251+ self->SetMinMaxSize(self->_normal_dash_tex->GetWidth(), self->_normal_dash_tex->GetHeight());
252+
253+ self->QueueDraw();
254+ }
255+
256+ static void OnPlaceViewHidden(GVariant* data, void* val)
257+ {
258+ WindowButton* self = (WindowButton*)val;
259+
260+ self->_dash_is_open = false;
261+ if (self->_normal_tex)
262+ self->SetMinMaxSize(self->_normal_tex->GetWidth(), self->_normal_tex->GetHeight());
263+
264+ self->QueueDraw();
265+ }
266+
267+ nux::BaseTexture* GetDashWindowButton(PanelStyle::WindowButtonType type, PanelStyle::WindowState state)
268+ {
269+ const char* names[] = { "close_dash", "minimize_dash", "unmaximize_dash" };
270+ const char* states[] = { "", "_prelight", "_pressed" };
271+
272+ std::ostringstream subpath;
273+ subpath << names[type] << states[state] << ".png";
274+
275+ glib::String filename(g_build_filename(PKGDATADIR, subpath.str().c_str(), NULL));
276+
277+ glib::Error error;
278+ glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file(filename.Value(), &error));
279+
280+ // not handling broken texture or missing files
281+ return nux::CreateTexture2DFromPixbuf(pixbuf, true);
282+ }
283+
284+ nux::BaseTexture* GetDashMaximizeWindowButton(PanelStyle::WindowState state)
285+ {
286+ const char* states[] = { "", "_prelight", "_pressed" };
287+
288+ std::ostringstream subpath;
289+ subpath << "maximize_dash" << states[state] << ".png";
290+
291+ glib::String filename(g_build_filename(PKGDATADIR, subpath.str().c_str(), NULL));
292+
293+ glib::Error error;
294+ glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file(filename.Value(), &error));
295+
296+ // not handling broken texture or missing files
297+ return nux::CreateTexture2DFromPixbuf(pixbuf, true);
298+ }
299 };
300
301
302
303=== modified file 'plugins/unityshell/src/WindowButtons.h'
304--- plugins/unityshell/src/WindowButtons.h 2011-08-10 18:42:00 +0000
305+++ plugins/unityshell/src/WindowButtons.h 2011-09-01 17:04:25 +0000
306@@ -44,7 +44,6 @@
307 const gchar* GetChildsName();
308 void AddProperties(GVariantBuilder* builder);
309
310-
311 private:
312 void OnCloseClicked(nux::View *view);
313 void OnMinimizeClicked(nux::View *view);