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

Proposed by Andrea Cimitan
Status: Merged
Approved by: Neil J. Patel
Approved revision: no longer in the source branch.
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 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
=== added file 'plugins/unityshell/resources/close_dash.png'
0Binary 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 differ0Binary 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
=== added file 'plugins/unityshell/resources/close_dash_prelight.png'
1Binary 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 differ1Binary 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
=== added file 'plugins/unityshell/resources/close_dash_pressed.png'
2Binary 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 differ2Binary 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
=== added file 'plugins/unityshell/resources/maximize_dash.png'
3Binary 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 differ3Binary 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
=== added file 'plugins/unityshell/resources/maximize_dash_prelight.png'
4Binary 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 differ4Binary 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
=== added file 'plugins/unityshell/resources/maximize_dash_pressed.png'
5Binary 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 differ5Binary 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
=== added file 'plugins/unityshell/resources/minimize_dash.png'
6Binary 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 differ6Binary 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
=== added file 'plugins/unityshell/resources/minimize_dash_prelight.png'
7Binary 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 differ7Binary 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
=== added file 'plugins/unityshell/resources/minimize_dash_pressed.png'
8Binary 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 differ8Binary 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
=== added file 'plugins/unityshell/resources/unmaximize_dash.png'
9Binary 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 differ9Binary 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
=== added file 'plugins/unityshell/resources/unmaximize_dash_prelight.png'
10Binary 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 differ10Binary 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
=== added file 'plugins/unityshell/resources/unmaximize_dash_pressed.png'
11Binary 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 differ11Binary 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
=== modified file 'plugins/unityshell/src/PanelMenuView.cpp'
--- plugins/unityshell/src/PanelMenuView.cpp 2011-08-25 18:25:25 +0000
+++ plugins/unityshell/src/PanelMenuView.cpp 2011-09-01 17:04:25 +0000
@@ -969,7 +969,8 @@
969{969{
970 if (_places_showing)970 if (_places_showing)
971 {971 {
972 DashSettings::GetDefault()->SetFormFactor(DashSettings::DESKTOP);972 // no action when dash is opened, LP bug #838875
973 return;
973 }974 }
974 else975 else
975 {976 {
@@ -986,7 +987,10 @@
986{987{
987 if (_places_showing)988 if (_places_showing)
988 {989 {
989 DashSettings::GetDefault()->SetFormFactor(DashSettings::NETBOOK);990 if (DashSettings::GetDefault()->GetFormFactor() == DashSettings::DESKTOP)
991 DashSettings::GetDefault()->SetFormFactor(DashSettings::NETBOOK);
992 else
993 DashSettings::GetDefault()->SetFormFactor(DashSettings::DESKTOP);
990 }994 }
991 else995 else
992 {996 {
993997
=== modified file 'plugins/unityshell/src/WindowButtons.cpp'
--- plugins/unityshell/src/WindowButtons.cpp 2011-08-19 15:17:30 +0000
+++ plugins/unityshell/src/WindowButtons.cpp 2011-09-01 17:04:25 +0000
@@ -16,6 +16,8 @@
16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>16 * Authored by: Neil Jagdish Patel <neil.patel@canonical.com>
17 */17 */
1818
19#include "config.h"
20
19#include "Nux/Nux.h"21#include "Nux/Nux.h"
20#include "Nux/HLayout.h"22#include "Nux/HLayout.h"
21#include "Nux/VLayout.h"23#include "Nux/VLayout.h"
@@ -28,9 +30,16 @@
28#include <UnityCore/Variant.h>30#include <UnityCore/Variant.h>
29#include "WindowButtons.h"31#include "WindowButtons.h"
3032
31#include <glib.h>33#include "ubus-server.h"
34#include "UBusMessages.h"
3235
36#include "DashSettings.h"
33#include "PanelStyle.h"37#include "PanelStyle.h"
38
39#include <UnityCore/GLibWrapper.h>
40
41using namespace unity;
42
34class WindowButton : public nux::Button43class WindowButton : public nux::Button
35{44{
36 // A single window button45 // A single window button
@@ -40,10 +49,25 @@
40 _type(type),49 _type(type),
41 _normal_tex(NULL),50 _normal_tex(NULL),
42 _prelight_tex(NULL),51 _prelight_tex(NULL),
43 _pressed_tex(NULL)52 _pressed_tex(NULL),
53 _normal_dash_tex(NULL),
54 _prelight_dash_tex(NULL),
55 _pressed_dash_tex(NULL),
56 _dash_is_open(false),
57 _place_shown_interest(0),
58 _place_hidden_interest(0)
44 {59 {
45 LoadImages();60 LoadImages();
46 PanelStyle::GetDefault()->changed.connect(sigc::mem_fun(this, &WindowButton::LoadImages));61 PanelStyle::GetDefault()->changed.connect(sigc::mem_fun(this, &WindowButton::LoadImages));
62 DashSettings::GetDefault()->changed.connect(sigc::mem_fun(this, &WindowButton::UpdateDashUnmaximize));
63
64 UBusServer* ubus = ubus_server_get_default();
65 _place_shown_interest = ubus_server_register_interest(ubus, UBUS_PLACE_VIEW_SHOWN,
66 (UBusCallback)&WindowButton::OnPlaceViewShown,
67 this);
68 _place_hidden_interest = ubus_server_register_interest(ubus, UBUS_PLACE_VIEW_HIDDEN,
69 (UBusCallback)&WindowButton::OnPlaceViewHidden,
70 this);
47 }71 }
4872
49 ~WindowButton()73 ~WindowButton()
@@ -51,27 +75,42 @@
51 _normal_tex->UnReference();75 _normal_tex->UnReference();
52 _prelight_tex->UnReference();76 _prelight_tex->UnReference();
53 _pressed_tex->UnReference();77 _pressed_tex->UnReference();
78 _normal_dash_tex->UnReference();
79 _prelight_dash_tex->UnReference();
80 _pressed_dash_tex->UnReference();
81
82 UBusServer* ubus = ubus_server_get_default();
83 if (_place_shown_interest != 0)
84 ubus_server_unregister_interest(ubus, _place_shown_interest);
85 if (_place_hidden_interest != 0)
86 ubus_server_unregister_interest(ubus, _place_hidden_interest);
54 }87 }
5588
56 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw)89 void Draw(nux::GraphicsEngine& GfxContext, bool force_draw)
57 {90 {
58 nux::Geometry geo = GetGeometry();91 nux::Geometry geo = GetGeometry();
59 nux::BaseTexture* tex;92 nux::BaseTexture* tex;
60 nux::TexCoordXForm texxform;93 nux::TexCoordXForm texxform;
6194
62 GfxContext.PushClippingRectangle(geo);95 GfxContext.PushClippingRectangle(geo);
6396
64 if (HasMouseFocus() && IsMouseInside())97 if (_dash_is_open)
65 {98 {
66 tex = _pressed_tex;99 if (HasMouseFocus() && IsMouseInside())
67 }100 tex = _pressed_dash_tex;
68 else if (IsMouseInside())101 else if (IsMouseInside())
69 {102 tex = _prelight_dash_tex;
70 tex = _prelight_tex;103 else
104 tex = _normal_dash_tex;
71 }105 }
72 else106 else
73 {107 {
74 tex = _normal_tex;108 if (HasMouseFocus() && IsMouseInside())
109 tex = _pressed_tex;
110 else if (IsMouseInside())
111 tex = _prelight_tex;
112 else
113 tex = _normal_tex;
75 }114 }
76115
77 GfxContext.GetRenderStates().SetBlend(true);116 GfxContext.GetRenderStates().SetBlend(true);
@@ -99,13 +138,70 @@
99 _prelight_tex->UnReference();138 _prelight_tex->UnReference();
100 if (_pressed_tex)139 if (_pressed_tex)
101 _pressed_tex->UnReference();140 _pressed_tex->UnReference();
141 if (_normal_dash_tex)
142 _normal_dash_tex->UnReference();
143 if (_prelight_dash_tex)
144 _prelight_dash_tex->UnReference();
145 if (_pressed_dash_tex)
146 _pressed_dash_tex->UnReference();
102147
103 _normal_tex = style->GetWindowButton(_type, PanelStyle::WINDOW_STATE_NORMAL);148 _normal_tex = style->GetWindowButton(_type, PanelStyle::WINDOW_STATE_NORMAL);
104 _prelight_tex = style->GetWindowButton(_type, PanelStyle::WINDOW_STATE_PRELIGHT);149 _prelight_tex = style->GetWindowButton(_type, PanelStyle::WINDOW_STATE_PRELIGHT);
105 _pressed_tex = style->GetWindowButton(_type, PanelStyle::WINDOW_STATE_PRESSED);150 _pressed_tex = style->GetWindowButton(_type, PanelStyle::WINDOW_STATE_PRESSED);
106151 _normal_dash_tex = GetDashWindowButton(_type, PanelStyle::WINDOW_STATE_NORMAL);
107 if (_normal_tex)152 _prelight_dash_tex = GetDashWindowButton(_type, PanelStyle::WINDOW_STATE_PRELIGHT);
108 SetMinMaxSize(_normal_tex->GetWidth(), _normal_tex->GetHeight());153 _pressed_dash_tex = GetDashWindowButton(_type, PanelStyle::WINDOW_STATE_PRESSED);
154
155 if (_dash_is_open)
156 {
157 if (_normal_dash_tex)
158 SetMinMaxSize(_normal_dash_tex->GetWidth(), _normal_dash_tex->GetHeight());
159 }
160 else
161 {
162 if (_normal_tex)
163 SetMinMaxSize(_normal_tex->GetWidth(), _normal_tex->GetHeight());
164 }
165
166 QueueDraw();
167 }
168
169 void UpdateDashUnmaximize()
170 {
171 // only update the unmaximize button
172 if (_type != PanelStyle::WINDOW_BUTTON_UNMAXIMIZE)
173 return;
174
175 if (_normal_dash_tex)
176 _normal_dash_tex->UnReference();
177 if (_prelight_dash_tex)
178 _prelight_dash_tex->UnReference();
179 if (_pressed_dash_tex)
180 _pressed_dash_tex->UnReference();
181
182 if (DashSettings::GetDefault()->GetFormFactor() == DashSettings::DESKTOP)
183 {
184 // get maximize buttons
185 _normal_dash_tex = GetDashMaximizeWindowButton(PanelStyle::WINDOW_STATE_NORMAL);
186 _prelight_dash_tex = GetDashMaximizeWindowButton(PanelStyle::WINDOW_STATE_PRELIGHT);
187 _pressed_dash_tex = GetDashMaximizeWindowButton(PanelStyle::WINDOW_STATE_PRESSED);
188 }
189 else
190 {
191 // get unmaximize buttons
192 _normal_dash_tex = GetDashWindowButton(_type, PanelStyle::WINDOW_STATE_NORMAL);
193 _prelight_dash_tex = GetDashWindowButton(_type, PanelStyle::WINDOW_STATE_PRELIGHT);
194 _pressed_dash_tex = GetDashWindowButton(_type, PanelStyle::WINDOW_STATE_PRESSED);
195 }
196
197 // still check if the dash is really opened,
198 // someone could change the form factor through dconf
199 // when the dash is closed
200 if (_dash_is_open)
201 {
202 if (_normal_dash_tex)
203 SetMinMaxSize(_normal_dash_tex->GetWidth(), _normal_dash_tex->GetHeight());
204 }
109205
110 QueueDraw();206 QueueDraw();
111 }207 }
@@ -115,6 +211,67 @@
115 nux::BaseTexture* _normal_tex;211 nux::BaseTexture* _normal_tex;
116 nux::BaseTexture* _prelight_tex;212 nux::BaseTexture* _prelight_tex;
117 nux::BaseTexture* _pressed_tex;213 nux::BaseTexture* _pressed_tex;
214 nux::BaseTexture* _normal_dash_tex;
215 nux::BaseTexture* _prelight_dash_tex;
216 nux::BaseTexture* _pressed_dash_tex;
217 bool _dash_is_open;
218 guint32 _place_shown_interest;
219 guint32 _place_hidden_interest;
220
221 static void OnPlaceViewShown(GVariant* data, void* val)
222 {
223 WindowButton* self = (WindowButton*)val;
224
225 self->_dash_is_open = true;
226 if (self->_normal_dash_tex)
227 self->SetMinMaxSize(self->_normal_dash_tex->GetWidth(), self->_normal_dash_tex->GetHeight());
228
229 self->QueueDraw();
230 }
231
232 static void OnPlaceViewHidden(GVariant* data, void* val)
233 {
234 WindowButton* self = (WindowButton*)val;
235
236 self->_dash_is_open = false;
237 if (self->_normal_tex)
238 self->SetMinMaxSize(self->_normal_tex->GetWidth(), self->_normal_tex->GetHeight());
239
240 self->QueueDraw();
241 }
242
243 nux::BaseTexture* GetDashWindowButton(PanelStyle::WindowButtonType type, PanelStyle::WindowState state)
244 {
245 const char* names[] = { "close_dash", "minimize_dash", "unmaximize_dash" };
246 const char* states[] = { "", "_prelight", "_pressed" };
247
248 std::ostringstream subpath;
249 subpath << names[type] << states[state] << ".png";
250
251 glib::String filename(g_build_filename(PKGDATADIR, subpath.str().c_str(), NULL));
252
253 glib::Error error;
254 glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file(filename.Value(), &error));
255
256 // not handling broken texture or missing files
257 return nux::CreateTexture2DFromPixbuf(pixbuf, true);
258 }
259
260 nux::BaseTexture* GetDashMaximizeWindowButton(PanelStyle::WindowState state)
261 {
262 const char* states[] = { "", "_prelight", "_pressed" };
263
264 std::ostringstream subpath;
265 subpath << "maximize_dash" << states[state] << ".png";
266
267 glib::String filename(g_build_filename(PKGDATADIR, subpath.str().c_str(), NULL));
268
269 glib::Error error;
270 glib::Object<GdkPixbuf> pixbuf(gdk_pixbuf_new_from_file(filename.Value(), &error));
271
272 // not handling broken texture or missing files
273 return nux::CreateTexture2DFromPixbuf(pixbuf, true);
274 }
118};275};
119276
120277
121278
=== modified file 'plugins/unityshell/src/WindowButtons.h'
--- plugins/unityshell/src/WindowButtons.h 2011-08-10 18:42:00 +0000
+++ plugins/unityshell/src/WindowButtons.h 2011-09-01 17:04:25 +0000
@@ -44,7 +44,6 @@
44 const gchar* GetChildsName();44 const gchar* GetChildsName();
45 void AddProperties(GVariantBuilder* builder);45 void AddProperties(GVariantBuilder* builder);
4646
47
48private:47private:
49 void OnCloseClicked(nux::View *view);48 void OnCloseClicked(nux::View *view);
50 void OnMinimizeClicked(nux::View *view);49 void OnMinimizeClicked(nux::View *view);