Merge lp:~3v1n0/unity/spread-title-improved into lp:unity
- spread-title-improved
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Marco Trevisan (Treviño) |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2668 |
Proposed branch: | lp:~3v1n0/unity/spread-title-improved |
Merge into: | lp:unity |
Prerequisite: | lp:~renatofilho/unity/unity-lp876017-fixes |
Diff against target: |
1202 lines (+387/-393) 2 files modified
plugins/unityshell/src/unityshell.cpp (+366/-367) plugins/unityshell/src/unityshell.h (+21/-26) |
To merge this branch: | bzr merge lp:~3v1n0/unity/spread-title-improved |
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
jenkins (community) | continuous-integration | Needs Fixing | |
Renato Araujo Oliveira Filho (community) | Approve | ||
Review via email:
|
Commit message
UnityWindow: use smart pointers, use static close_icon (with dynamic state) and PanelStyle context
Description of the change
Improved the UnityWindow code used to handle the spread icons, I've changed the way we draw our fake decoration (I made it to be above the standard one) and added support for close button states (normal, prelighted and pressed).
Also, some code optimizations to avoid that shared resources are re-computed more than needed.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Renato Araujo Oliveira Filho (renatofilho) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Unity Merger (unity-merger) wrote : | # |
The prerequisite lp:~renatofilho/unity/unity-lp876017-fixes has not yet been merged into lp:unity.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Unity Merger (unity-merger) wrote : | # |
The prerequisite lp:~renatofilho/unity/unity-lp876017-fixes has not yet been merged into lp:unity.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Unity Merger (unity-merger) wrote : | # |
The prerequisite lp:~renatofilho/unity/unity-lp876017-fixes has not yet been merged into lp:unity.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
jenkins (martin-mrazik+qa) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Martin Mrazik (mrazik) wrote : | # |
There is a conflict:
Retrieving 'bzr+ssh:
Merging 'lp:unity' in to 'work'.
Warning: criss-cross merge encountered. See bzr help criss-cross.
Text conflict in plugins/
1 conflicts encountered.
bzr: ERROR: Conflicts from merge
Preview Diff
1 | === modified file 'plugins/unityshell/src/unityshell.cpp' |
2 | --- plugins/unityshell/src/unityshell.cpp 2012-09-06 17:46:48 +0000 |
3 | +++ plugins/unityshell/src/unityshell.cpp 2012-09-07 00:07:25 +0000 |
4 | @@ -83,9 +83,8 @@ |
5 | |
6 | UnityScreen* uScreen = 0; |
7 | |
8 | -static unsigned int CLOSE_ICON_SIZE = 19; |
9 | -static unsigned int CLOSE_ICON_SPACE = 5; |
10 | -static unsigned int SCALE_WINDOW_TITLE_SIZE = 28; |
11 | +const unsigned int SCALE_CLOSE_ICON_SIZE = 19; |
12 | +const unsigned int SCALE_ITEMS_PADDING = 5; |
13 | |
14 | void reset_glib_logging(); |
15 | void configure_logging(); |
16 | @@ -107,36 +106,6 @@ |
17 | } // namespace local |
18 | } // anon namespace |
19 | |
20 | -class WindowCairoContext |
21 | -{ |
22 | - public: |
23 | - typedef std::shared_ptr<WindowCairoContext> Ptr; |
24 | - |
25 | - Pixmap pixmap_; |
26 | - cairo_surface_t* surface_; |
27 | - GLTexture::List texture_; |
28 | - cairo_t *cr_; |
29 | - |
30 | - WindowCairoContext () |
31 | - : pixmap_ (0), surface_ (0), cr_ (0) |
32 | - { |
33 | - } |
34 | - |
35 | - ~WindowCairoContext () |
36 | - { |
37 | - if (cr_) |
38 | - cairo_destroy (cr_); |
39 | - |
40 | - if (surface_) |
41 | - cairo_surface_destroy (surface_); |
42 | - |
43 | - texture_.clear (); |
44 | - |
45 | - if (pixmap_) |
46 | - XFreePixmap (screen->dpy (), pixmap_); |
47 | - } |
48 | -}; |
49 | - |
50 | UnityScreen::UnityScreen(CompScreen* screen) |
51 | : BaseSwitchScreen (screen) |
52 | , PluginClassHandler <UnityScreen, CompScreen> (screen) |
53 | @@ -165,7 +134,7 @@ |
54 | , panel_texture_has_changed_(true) |
55 | , paint_panel_(false) |
56 | , scale_just_activated_(false) |
57 | - , highlighted_window_(0) |
58 | + , scale_highlighted_window_(0) |
59 | , minimize_speed_controller(new WindowMinimizeSpeedController()) |
60 | { |
61 | Timer timer; |
62 | @@ -423,9 +392,7 @@ |
63 | } |
64 | |
65 | panel::Style::Instance().changed.connect(sigc::mem_fun(this, &UnityScreen::OnPanelStyleChanged)); |
66 | - |
67 | - WindowManager::Default()->initiate_spread.connect(sigc::mem_fun(this, &UnityScreen::OnInitiateSpreed)); |
68 | - WindowManager::Default()->terminate_spread.connect(sigc::mem_fun(this, &UnityScreen::OnTerminateSpreed)); |
69 | + WindowManager::Default()->terminate_spread.connect([this] { scale_highlighted_window_ = 0; }); |
70 | |
71 | minimize_speed_controller->DurationChanged.connect( |
72 | sigc::mem_fun(this, &UnityScreen::OnMinimizeDurationChanged) |
73 | @@ -443,25 +410,6 @@ |
74 | reset_glib_logging(); |
75 | } |
76 | |
77 | -void UnityScreen::OnInitiateSpreed() |
78 | -{ |
79 | - for (CompWindow *w : screen->windows()) |
80 | - { |
81 | - UnityWindow *uw = UnityWindow::get(w); |
82 | - uw->InitiateSpreed(); |
83 | - } |
84 | -} |
85 | - |
86 | -void UnityScreen::OnTerminateSpreed() |
87 | -{ |
88 | - for (CompWindow *w : screen->windows()) |
89 | - { |
90 | - UnityWindow *uw = UnityWindow::get(w); |
91 | - uw->TerminateSpreed(); |
92 | - } |
93 | -} |
94 | - |
95 | - |
96 | void UnityScreen::initAltTabNextWindow() |
97 | { |
98 | KeyboardUtil key_util(screen->dpy()); |
99 | @@ -1118,8 +1066,8 @@ |
100 | void UnityWindow::enterShowDesktop () |
101 | { |
102 | if (!mShowdesktopHandler) |
103 | - mShowdesktopHandler = new ShowdesktopHandler (static_cast <ShowdesktopHandlerWindowInterface *> (this), |
104 | - static_cast <compiz::WindowInputRemoverLockAcquireInterface *> (this)); |
105 | + mShowdesktopHandler.reset(new ShowdesktopHandler(static_cast <ShowdesktopHandlerWindowInterface *>(this), |
106 | + static_cast <compiz::WindowInputRemoverLockAcquireInterface *>(this))); |
107 | |
108 | window->setShowDesktopMode (true); |
109 | mShowdesktopHandler->FadeOut (); |
110 | @@ -1240,15 +1188,14 @@ |
111 | return action; |
112 | } |
113 | |
114 | -void UnityWindow::DoAddDamage () |
115 | +void UnityWindow::DoAddDamage() |
116 | { |
117 | - cWindow->addDamage (); |
118 | + cWindow->addDamage(); |
119 | } |
120 | |
121 | void UnityWindow::DoDeleteHandler () |
122 | { |
123 | - delete mShowdesktopHandler; |
124 | - mShowdesktopHandler = NULL; |
125 | + mShowdesktopHandler.reset(); |
126 | |
127 | window->updateFrameRegion (); |
128 | } |
129 | @@ -1270,21 +1217,74 @@ |
130 | return PAINT_WINDOW_NO_CORE_INSTANCE_MASK; |
131 | } |
132 | |
133 | -void UnityWindow::handleEvent (XEvent *event) |
134 | +bool UnityWindow::handleEvent(XEvent *event) |
135 | { |
136 | - if (screen->XShape () && |
137 | - event->type == screen->shapeEvent () + ShapeNotify && |
138 | - !event->xany.send_event) |
139 | + bool handled = false; |
140 | + |
141 | + switch(event->type) |
142 | { |
143 | - if (mShowdesktopHandler) |
144 | - mShowdesktopHandler->HandleShapeEvent (); |
145 | + case MotionNotify: |
146 | + if (close_icon_state_ != panel::WindowState::PRESSED) |
147 | + { |
148 | + panel::WindowState old_state = close_icon_state_; |
149 | + |
150 | + if (close_button_geo_.IsPointInside(event->xmotion.x_root, event->xmotion.y_root)) |
151 | + { |
152 | + close_icon_state_ = panel::WindowState::PRELIGHT; |
153 | + } |
154 | + else |
155 | + { |
156 | + close_icon_state_ = panel::WindowState::NORMAL; |
157 | + } |
158 | + |
159 | + if (old_state != close_icon_state_) |
160 | + DoAddDamage(); |
161 | + } |
162 | + break; |
163 | + |
164 | + case ButtonPress: |
165 | + if (event->xbutton.button == Button1 && |
166 | + close_button_geo_.IsPointInside(event->xbutton.x_root, event->xbutton.y_root)) |
167 | + { |
168 | + close_icon_state_ = panel::WindowState::PRESSED; |
169 | + DoAddDamage(); |
170 | + handled = true; |
171 | + } |
172 | + break; |
173 | + |
174 | + case ButtonRelease: |
175 | + { |
176 | + bool was_pressed = (close_icon_state_ == panel::WindowState::PRESSED); |
177 | + |
178 | + if (close_icon_state_ != panel::WindowState::NORMAL) |
179 | + { |
180 | + close_icon_state_ = panel::WindowState::NORMAL; |
181 | + DoAddDamage(); |
182 | + } |
183 | + |
184 | + if (was_pressed) |
185 | + { |
186 | + if (close_button_geo_.IsPointInside(event->xbutton.x_root, event->xbutton.y_root)) |
187 | + window->close(0); |
188 | + |
189 | + handled = true; |
190 | + } |
191 | + } |
192 | + break; |
193 | + |
194 | + default: |
195 | + if (!event->xany.send_event && screen->XShape() && |
196 | + event->type == screen->shapeEvent() + ShapeNotify) |
197 | + { |
198 | + if (mShowdesktopHandler) |
199 | + { |
200 | + mShowdesktopHandler->HandleShapeEvent(); |
201 | + handled = true; |
202 | + } |
203 | + } |
204 | } |
205 | -} |
206 | |
207 | -CompRect |
208 | -UnityWindow::CloseButtonArea() |
209 | -{ |
210 | - return close_button_area_; |
211 | + return handled; |
212 | } |
213 | |
214 | bool UnityScreen::shellCouldBeHidden(CompOutput const& output) |
215 | @@ -1648,28 +1648,23 @@ |
216 | } |
217 | _key_nav_mode_requested = false; |
218 | break; |
219 | + case MotionNotify: |
220 | + if (scale_highlighted_window_ && PluginAdapter::Default()->IsScaleActive()) |
221 | + { |
222 | + if (CompWindow *w = screen->findWindow(scale_highlighted_window_)) |
223 | + skip_other_plugins = UnityWindow::get(w)->handleEvent(event); |
224 | + } |
225 | + break; |
226 | case ButtonPress: |
227 | if (super_keypressed_) |
228 | { |
229 | launcher_controller_->KeyNavTerminate(false); |
230 | EnableCancelAction(CancelActionTarget::LAUNCHER_SWITCHER, false); |
231 | } |
232 | - if (PluginAdapter::Default()->IsScaleActive() && |
233 | - event->xbutton.button == Button1 && |
234 | - highlighted_window_ != 0) |
235 | + if (scale_highlighted_window_ && PluginAdapter::Default()->IsScaleActive()) |
236 | { |
237 | - CompWindow *w = screen->findWindow(highlighted_window_); |
238 | - if (w) |
239 | - { |
240 | - UnityWindow *uw = UnityWindow::get(w); |
241 | - CompPoint pointer(pointerX, pointerY); |
242 | - if (uw->CloseButtonArea().contains(pointer)) |
243 | - { |
244 | - w->close(0); |
245 | - skip_other_plugins = true; |
246 | - } |
247 | - } |
248 | - |
249 | + if (CompWindow *w = screen->findWindow(scale_highlighted_window_)) |
250 | + skip_other_plugins = UnityWindow::get(w)->handleEvent(event); |
251 | } |
252 | |
253 | break; |
254 | @@ -1691,6 +1686,11 @@ |
255 | } |
256 | } |
257 | } |
258 | + else if (scale_highlighted_window_ && PluginAdapter::Default()->IsScaleActive()) |
259 | + { |
260 | + if (CompWindow *w = screen->findWindow(scale_highlighted_window_)) |
261 | + UnityWindow::get(w)->handleEvent(event); |
262 | + } |
263 | break; |
264 | case KeyPress: |
265 | { |
266 | @@ -1818,8 +1818,8 @@ |
267 | ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); |
268 | } |
269 | |
270 | - if (PluginAdapter::Default()->IsScaleActive() && |
271 | - g_strcmp0(plugin, "scale") == 0 && super_keypressed_) |
272 | + if (PluginAdapter::Default()->IsScaleActive() && g_strcmp0(plugin, "scale") == 0 && |
273 | + super_keypressed_) |
274 | { |
275 | scale_just_activated_ = true; |
276 | } |
277 | @@ -1914,7 +1914,7 @@ |
278 | CompOption::Vector& options) |
279 | { |
280 | /* In order to avoid too many events when keeping the keybinding pressed, |
281 | - * that would make the unity-panel-service go crazy (see bug #948522) |
282 | + * that would make the unity-panel-service to go crazy (see bug #948522) |
283 | * we need to filter them, just considering an event every 750 ms */ |
284 | int event_time = options[7].value().i(); // XEvent time in millisec |
285 | |
286 | @@ -3295,38 +3295,38 @@ |
287 | hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" (Hold)"), |
288 | _("Opens the Launcher, displays shortcuts."), |
289 | shortcut::COMPIZ_KEY_OPTION, |
290 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
291 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
292 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
293 | + COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
294 | |
295 | hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", "", |
296 | _("Opens Launcher keyboard navigation mode."), |
297 | shortcut::COMPIZ_KEY_OPTION, |
298 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
299 | - COMPIZ_UNITYSHELL_OPTION_KEYBOARD_FOCUS)); |
300 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
301 | + COMPIZ_UNITYSHELL_OPTION_KEYBOARD_FOCUS)); |
302 | |
303 | hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", "", |
304 | _("Switches applications via the Launcher."), |
305 | shortcut::COMPIZ_KEY_OPTION, |
306 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
307 | - COMPIZ_UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD)); |
308 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
309 | + COMPIZ_UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD)); |
310 | |
311 | hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" + 1 to 9"), |
312 | _("Same as clicking on a Launcher icon."), |
313 | shortcut::COMPIZ_KEY_OPTION, |
314 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
315 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
316 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
317 | + COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
318 | |
319 | hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", _(" + Shift + 1 to 9"), |
320 | _("Opens a new window in the app."), |
321 | shortcut::COMPIZ_KEY_OPTION, |
322 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
323 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
324 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
325 | + COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
326 | |
327 | hints_.push_back(std::make_shared<shortcut::Hint>(launcher, "", " + T", |
328 | _("Opens the Trash."), |
329 | shortcut::COMPIZ_KEY_OPTION, |
330 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
331 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
332 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
333 | + COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
334 | |
335 | |
336 | // Dash... |
337 | @@ -3335,32 +3335,32 @@ |
338 | hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", _(" (Tap)"), |
339 | _("Opens the Dash Home."), |
340 | shortcut::COMPIZ_KEY_OPTION, |
341 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
342 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
343 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
344 | + COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
345 | |
346 | hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + A", |
347 | _("Opens the Dash App Lens."), |
348 | shortcut::COMPIZ_KEY_OPTION, |
349 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
350 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
351 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
352 | + COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
353 | |
354 | hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + F", |
355 | _("Opens the Dash Files Lens."), |
356 | shortcut::COMPIZ_KEY_OPTION, |
357 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
358 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
359 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
360 | + COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
361 | |
362 | hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + M", |
363 | _("Opens the Dash Music Lens."), |
364 | shortcut::COMPIZ_KEY_OPTION, |
365 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
366 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
367 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
368 | + COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
369 | |
370 | hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", " + V", |
371 | _("Opens the Dash Video Lens."), |
372 | shortcut::COMPIZ_KEY_OPTION, |
373 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
374 | - COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
375 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
376 | + COMPIZ_UNITYSHELL_OPTION_SHOW_LAUNCHER)); |
377 | |
378 | hints_.push_back(std::make_shared<shortcut::Hint>(dash, "", "", |
379 | _("Switches between Lenses."), |
380 | @@ -3383,8 +3383,8 @@ |
381 | hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", _(" (Tap)"), |
382 | _("Opens the HUD."), |
383 | shortcut::COMPIZ_KEY_OPTION, |
384 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
385 | - COMPIZ_UNITYSHELL_OPTION_SHOW_HUD)); |
386 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
387 | + COMPIZ_UNITYSHELL_OPTION_SHOW_HUD)); |
388 | |
389 | hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", _(" (Hold)"), |
390 | _("Reveals the application menu."), |
391 | @@ -3394,8 +3394,8 @@ |
392 | hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", "", |
393 | _("Opens the indicator menu."), |
394 | shortcut::COMPIZ_KEY_OPTION, |
395 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
396 | - COMPIZ_UNITYSHELL_OPTION_PANEL_FIRST_MENU)); |
397 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
398 | + COMPIZ_UNITYSHELL_OPTION_PANEL_FIRST_MENU)); |
399 | |
400 | hints_.push_back(std::make_shared<shortcut::Hint>(menubar, "", "", |
401 | _("Moves focus between indicators."), |
402 | @@ -3408,14 +3408,14 @@ |
403 | hints_.push_back(std::make_shared<shortcut::Hint>(switching, "", "", |
404 | _("Switches between applications."), |
405 | shortcut::COMPIZ_KEY_OPTION, |
406 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
407 | - COMPIZ_UNITYSHELL_OPTION_ALT_TAB_FORWARD)); |
408 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
409 | + COMPIZ_UNITYSHELL_OPTION_ALT_TAB_FORWARD)); |
410 | |
411 | hints_.push_back(std::make_shared<shortcut::Hint>(switching, "", "", |
412 | _("Switches windows of current applications."), |
413 | shortcut::COMPIZ_KEY_OPTION, |
414 | - COMPIZ_UNITYSHELL_PLUGIN_NAME, |
415 | - COMPIZ_UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW)); |
416 | + COMPIZ_UNITYSHELL_PLUGIN_NAME, |
417 | + COMPIZ_UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW)); |
418 | |
419 | hints_.push_back(std::make_shared<shortcut::Hint>(switching, "", "", |
420 | _("Moves the focus."), |
421 | @@ -3428,20 +3428,20 @@ |
422 | hints_.push_back(std::make_shared<shortcut::Hint>(workspaces, "", "", |
423 | _("Switches between workspaces."), |
424 | shortcut::COMPIZ_KEY_OPTION, |
425 | - COMPIZ_EXPO_PLUGIN_NAME, |
426 | - COMPIZ_EXPO_OPTION_EXPO_KEY)); |
427 | + COMPIZ_EXPO_PLUGIN_NAME, |
428 | + COMPIZ_EXPO_OPTION_EXPO_KEY)); |
429 | |
430 | hints_.push_back(std::make_shared<shortcut::Hint>(workspaces, "", _(" + Arrow Keys"), |
431 | _("Switches workspaces."), |
432 | shortcut::COMPIZ_METAKEY_OPTION, |
433 | - COMPIZ_WALL_PLUGIN_NAME, |
434 | - COMPIZ_WALL_OPTION_LEFT_KEY)); |
435 | + COMPIZ_WALL_PLUGIN_NAME, |
436 | + COMPIZ_WALL_OPTION_LEFT_KEY)); |
437 | |
438 | hints_.push_back(std::make_shared<shortcut::Hint>(workspaces, "", _(" + Arrow Keys"), |
439 | _("Moves focused window to another workspace."), |
440 | shortcut::COMPIZ_METAKEY_OPTION, |
441 | - COMPIZ_WALL_PLUGIN_NAME, |
442 | - COMPIZ_WALL_OPTION_LEFT_WINDOW_KEY)); |
443 | + COMPIZ_WALL_PLUGIN_NAME, |
444 | + COMPIZ_WALL_OPTION_LEFT_WINDOW_KEY)); |
445 | |
446 | |
447 | // Windows |
448 | @@ -3450,44 +3450,44 @@ |
449 | hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
450 | _("Spreads all windows in the current workspace."), |
451 | shortcut::COMPIZ_KEY_OPTION, |
452 | - COMPIZ_SCALE_PLUGIN_NAME, |
453 | - COMPIZ_SCALE_OPTION_INITIATE_ALL_KEY)); |
454 | + COMPIZ_SCALE_PLUGIN_NAME, |
455 | + COMPIZ_SCALE_OPTION_INITIATE_ALL_KEY)); |
456 | |
457 | hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
458 | _("Minimises all windows."), |
459 | shortcut::COMPIZ_KEY_OPTION, |
460 | - COMPIZ_CORE_PLUGIN_NAME, |
461 | - COMPIZ_CORE_OPTION_SHOW_DESKTOP_KEY)); |
462 | + COMPIZ_CORE_PLUGIN_NAME, |
463 | + COMPIZ_CORE_OPTION_SHOW_DESKTOP_KEY)); |
464 | |
465 | hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
466 | _("Maximises the current window."), |
467 | shortcut::COMPIZ_KEY_OPTION, |
468 | - COMPIZ_CORE_PLUGIN_NAME, |
469 | - COMPIZ_CORE_OPTION_MAXIMIZE_WINDOW_KEY)); |
470 | + COMPIZ_CORE_PLUGIN_NAME, |
471 | + COMPIZ_CORE_OPTION_MAXIMIZE_WINDOW_KEY)); |
472 | |
473 | hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
474 | _("Restores or minimises the current window."), |
475 | shortcut::COMPIZ_KEY_OPTION, |
476 | - COMPIZ_CORE_PLUGIN_NAME, |
477 | - COMPIZ_CORE_OPTION_UNMAXIMIZE_WINDOW_KEY)); |
478 | + COMPIZ_CORE_PLUGIN_NAME, |
479 | + COMPIZ_CORE_OPTION_UNMAXIMIZE_WINDOW_KEY)); |
480 | |
481 | hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" or Right"), |
482 | _("Semi-maximise the current window."), |
483 | shortcut::COMPIZ_KEY_OPTION, |
484 | - COMPIZ_GRID_PLUGIN_NAME, |
485 | - COMPIZ_GRID_OPTION_PUT_LEFT_KEY)); |
486 | + COMPIZ_GRID_PLUGIN_NAME, |
487 | + COMPIZ_GRID_OPTION_PUT_LEFT_KEY)); |
488 | |
489 | hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
490 | _("Closes the current window."), |
491 | shortcut::COMPIZ_KEY_OPTION, |
492 | - COMPIZ_CORE_PLUGIN_NAME, |
493 | - COMPIZ_CORE_OPTION_CLOSE_WINDOW_KEY)); |
494 | + COMPIZ_CORE_PLUGIN_NAME, |
495 | + COMPIZ_CORE_OPTION_CLOSE_WINDOW_KEY)); |
496 | |
497 | hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
498 | _("Opens the window accessibility menu."), |
499 | shortcut::COMPIZ_KEY_OPTION, |
500 | - COMPIZ_CORE_PLUGIN_NAME, |
501 | - COMPIZ_CORE_OPTION_WINDOW_MENU_KEY)); |
502 | + COMPIZ_CORE_PLUGIN_NAME, |
503 | + COMPIZ_CORE_OPTION_WINDOW_MENU_KEY)); |
504 | |
505 | hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", "", |
506 | _("Places the window in corresponding position."), |
507 | @@ -3497,14 +3497,14 @@ |
508 | hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" Drag"), |
509 | _("Moves the window."), |
510 | shortcut::COMPIZ_MOUSE_OPTION, |
511 | - COMPIZ_MOVE_PLUGIN_NAME, |
512 | - COMPIZ_MOVE_OPTION_INITIATE_BUTTON)); |
513 | + COMPIZ_MOVE_PLUGIN_NAME, |
514 | + COMPIZ_MOVE_OPTION_INITIATE_BUTTON)); |
515 | |
516 | hints_.push_back(std::make_shared<shortcut::Hint>(windows, "", _(" Drag"), |
517 | _("Resizes the window."), |
518 | shortcut::COMPIZ_MOUSE_OPTION, |
519 | - COMPIZ_RESIZE_PLUGIN_NAME, |
520 | - COMPIZ_RESIZE_OPTION_INITIATE_BUTTON)); |
521 | + COMPIZ_RESIZE_PLUGIN_NAME, |
522 | + COMPIZ_RESIZE_OPTION_INITIATE_BUTTON)); |
523 | } |
524 | |
525 | void UnityScreen::InitGesturesSupport() |
526 | @@ -3534,14 +3534,61 @@ |
527 | } |
528 | |
529 | /* Window init */ |
530 | +GLTexture::List UnityWindow::close_normal_tex_; |
531 | +GLTexture::List UnityWindow::close_prelight_tex_; |
532 | +GLTexture::List UnityWindow::close_pressed_tex_; |
533 | + |
534 | +struct UnityWindow::CairoContext |
535 | +{ |
536 | + CairoContext(int width, int height) |
537 | + : pixmap_(XCreatePixmap(screen->dpy(), screen->root(), width, height, 32)) |
538 | + , texture_(GLTexture::bindPixmapToTexture(pixmap_, width, height, 32)) |
539 | + , surface_(nullptr) |
540 | + , cr_(nullptr) |
541 | + { |
542 | + Screen *xscreen = ScreenOfDisplay(screen->dpy(), screen->screenNum()); |
543 | + XRenderPictFormat* format = XRenderFindStandardFormat(screen->dpy(), PictStandardARGB32); |
544 | + |
545 | + if (texture_.empty()) |
546 | + return; |
547 | + |
548 | + surface_ = cairo_xlib_surface_create_with_xrender_format(screen->dpy(), pixmap_, |
549 | + xscreen, format, |
550 | + width, height); |
551 | + cr_ = cairo_create(surface_); |
552 | + |
553 | + // clear |
554 | + cairo_save(cr_); |
555 | + cairo_set_operator(cr_, CAIRO_OPERATOR_CLEAR); |
556 | + cairo_paint(cr_); |
557 | + cairo_restore(cr_); |
558 | + } |
559 | + |
560 | + ~CairoContext () |
561 | + { |
562 | + if (cr_) |
563 | + cairo_destroy(cr_); |
564 | + |
565 | + if (surface_) |
566 | + cairo_surface_destroy(surface_); |
567 | + |
568 | + texture_.clear(); |
569 | + |
570 | + if (pixmap_) |
571 | + XFreePixmap(screen->dpy (), pixmap_); |
572 | + } |
573 | + |
574 | + Pixmap pixmap_; |
575 | + GLTexture::List texture_; |
576 | + cairo_surface_t* surface_; |
577 | + cairo_t *cr_; |
578 | +}; |
579 | + |
580 | UnityWindow::UnityWindow(CompWindow* window) |
581 | : BaseSwitchWindow (dynamic_cast<BaseSwitchScreen *> (UnityScreen::get (screen)), window) |
582 | , PluginClassHandler<UnityWindow, CompWindow>(window) |
583 | , window(window) |
584 | , gWindow(GLWindow::get(window)) |
585 | - , mMinimizeHandler() |
586 | - , mShowdesktopHandler(nullptr) |
587 | - , window_header_style_(0) |
588 | { |
589 | WindowInterface::setHandler(window); |
590 | GLWindowInterface::setHandler(gWindow); |
591 | @@ -3588,6 +3635,9 @@ |
592 | } |
593 | } |
594 | } |
595 | + |
596 | + WindowManager::Default()->initiate_spread.connect(sigc::mem_fun(this, &UnityWindow::OnInitiateSpreed)); |
597 | + WindowManager::Default()->terminate_spread.connect(sigc::mem_fun(this, &UnityWindow::OnTerminateSpreed)); |
598 | } |
599 | |
600 | void |
601 | @@ -3629,54 +3679,15 @@ |
602 | } |
603 | } |
604 | |
605 | -std::shared_ptr<WindowCairoContext> |
606 | -UnityWindow::CreateCairoContext(float width, float height) |
607 | -{ |
608 | - XRenderPictFormat *format; |
609 | - Screen *xScreen; |
610 | - auto cContext = std::make_shared<WindowCairoContext>(); |
611 | - |
612 | - xScreen = ScreenOfDisplay(screen->dpy(), screen->screenNum()); |
613 | - |
614 | - format = XRenderFindStandardFormat(screen->dpy(), PictStandardARGB32); |
615 | - cContext->pixmap_ = XCreatePixmap(screen->dpy(), |
616 | - screen->root(), |
617 | - width, height, 32); |
618 | - |
619 | - cContext->texture_ = GLTexture::bindPixmapToTexture(cContext->pixmap_, |
620 | - width, height, |
621 | - 32); |
622 | - if (cContext->texture_.empty()) |
623 | - { |
624 | - return 0; |
625 | - } |
626 | - |
627 | - cContext->surface_ = cairo_xlib_surface_create_with_xrender_format(screen->dpy(), |
628 | - cContext->pixmap_, |
629 | - xScreen, |
630 | - format, |
631 | - width, |
632 | - height); |
633 | - cContext->cr_ = cairo_create(cContext->surface_); |
634 | - |
635 | - // clear |
636 | - cairo_save(cContext->cr_); |
637 | - cairo_set_operator(cContext->cr_, CAIRO_OPERATOR_CLEAR); |
638 | - cairo_paint(cContext->cr_); |
639 | - cairo_restore(cContext->cr_); |
640 | - |
641 | - return cContext; |
642 | -} |
643 | - |
644 | void |
645 | -UnityWindow::RenderText(WindowCairoContext *context, |
646 | +UnityWindow::RenderText(UnityWindow::CairoContext const& context, |
647 | float x, float y, |
648 | float maxWidth, float maxHeight) |
649 | { |
650 | panel::Style& style = panel::Style::Instance(); |
651 | std::string fontDescription(style.GetFontDescription(panel::PanelItem::TITLE)); |
652 | |
653 | - glib::Object<PangoLayout> layout(pango_cairo_create_layout(context->cr_)); |
654 | + glib::Object<PangoLayout> layout(pango_cairo_create_layout(context.cr_)); |
655 | std::shared_ptr<PangoFontDescription> font(pango_font_description_from_string(fontDescription.c_str()), |
656 | pango_font_description_free); |
657 | |
658 | @@ -3698,9 +3709,9 @@ |
659 | -1); |
660 | |
661 | /* update the size of the pango layout */ |
662 | - pango_cairo_update_layout(context->cr_, layout); |
663 | - cairo_set_operator(context->cr_, CAIRO_OPERATOR_OVER); |
664 | - cairo_set_source_rgba(context->cr_, |
665 | + pango_cairo_update_layout(context.cr_, layout); |
666 | + cairo_set_operator(context.cr_, CAIRO_OPERATOR_OVER); |
667 | + cairo_set_source_rgba(context.cr_, |
668 | 1.0, |
669 | 1.0, |
670 | 1.0, |
671 | @@ -3715,7 +3726,7 @@ |
672 | textHeight = lRect.height / PANGO_SCALE; |
673 | |
674 | y = ((maxHeight - textHeight) / 2.0) + y; |
675 | - cairo_translate(context->cr_, x, y); |
676 | + cairo_translate(context.cr_, x, y); |
677 | |
678 | if (textWidth > maxWidth) |
679 | { |
680 | @@ -3724,38 +3735,35 @@ |
681 | const int fadingPixels = 35; |
682 | const int fadingWidth = outPixels < fadingPixels ? outPixels : fadingPixels; |
683 | |
684 | - cairo_push_group(context->cr_); |
685 | - pango_cairo_show_layout(context->cr_, layout); |
686 | - cairo_pop_group_to_source(context->cr_); |
687 | + cairo_push_group(context.cr_); |
688 | + pango_cairo_show_layout(context.cr_, layout); |
689 | + cairo_pop_group_to_source(context.cr_); |
690 | |
691 | std::shared_ptr<cairo_pattern_t> linpat(cairo_pattern_create_linear(maxWidth - fadingWidth, |
692 | y, maxWidth, y), |
693 | cairo_pattern_destroy); |
694 | cairo_pattern_add_color_stop_rgba(linpat.get(), 0, 0, 0, 0, 1); |
695 | cairo_pattern_add_color_stop_rgba(linpat.get(), 1, 0, 0, 0, 0); |
696 | - cairo_mask(context->cr_, linpat.get()); |
697 | + cairo_mask(context.cr_, linpat.get()); |
698 | } |
699 | else |
700 | { |
701 | - pango_cairo_show_layout(context->cr_, layout); |
702 | + pango_cairo_show_layout(context.cr_, layout); |
703 | } |
704 | } |
705 | |
706 | void |
707 | -UnityWindow::DrawWindowDecoration(const GLWindowPaintAttrib& attrib, |
708 | - const GLMatrix& transform, |
709 | +UnityWindow::DrawWindowDecoration(GLWindowPaintAttrib const& attrib, |
710 | + GLMatrix const& transform, |
711 | unsigned int mask, |
712 | bool highlighted, |
713 | - float x, float y, float x2, float y2) |
714 | + int x, int y, unsigned width, unsigned height) |
715 | { |
716 | - const float width = x2 - x; |
717 | - const float height = y2 - y; |
718 | - |
719 | // Paint a fake window decoration |
720 | - WindowCairoContext::Ptr context(CreateCairoContext(width, height)); |
721 | + CairoContext context(width, height); |
722 | |
723 | - cairo_save(context->cr_); |
724 | - cairo_push_group(context->cr_); |
725 | + cairo_save(context.cr_); |
726 | + cairo_push_group(context.cr_); |
727 | |
728 | // Round window decoration top border |
729 | const double aspect = 1.0; |
730 | @@ -3763,192 +3771,186 @@ |
731 | const double radius = corner_radius / aspect; |
732 | const double degrees = M_PI / 180.0; |
733 | |
734 | - cairo_new_sub_path(context->cr_); |
735 | - |
736 | - cairo_arc(context->cr_, radius, radius, radius, 180 * degrees, 270 * degrees); |
737 | - cairo_arc(context->cr_, width - radius, radius, radius, -90 * degrees, 0 * degrees); |
738 | - cairo_line_to(context->cr_, width, height); |
739 | - cairo_line_to(context->cr_, 0, height); |
740 | - |
741 | - cairo_close_path(context->cr_); |
742 | - cairo_clip(context->cr_); |
743 | - |
744 | - // Draw window decoration abased on gtk style |
745 | - gtk_render_background(window_header_style_, context->cr_, 0, 0, width, height); |
746 | - gtk_render_frame(window_header_style_, context->cr_, 0, 0, width, height); |
747 | - |
748 | - cairo_pop_group_to_source(context->cr_); |
749 | - |
750 | - cairo_paint_with_alpha(context->cr_, 1.0); |
751 | - cairo_restore(context->cr_); |
752 | + cairo_new_sub_path(context.cr_); |
753 | + |
754 | + cairo_arc(context.cr_, radius, radius, radius, 180 * degrees, 270 * degrees); |
755 | + cairo_arc(context.cr_, width - radius, radius, radius, -90 * degrees, 0 * degrees); |
756 | + cairo_line_to(context.cr_, width, height); |
757 | + cairo_line_to(context.cr_, 0, height); |
758 | + |
759 | + cairo_close_path(context.cr_); |
760 | + cairo_clip(context.cr_); |
761 | + |
762 | + // Draw window decoration based on gtk style |
763 | + auto& style = panel::Style::Instance(); |
764 | + gtk_render_background(style.GetStyleContext(), context.cr_, 0, 0, width, height); |
765 | + gtk_render_frame(style.GetStyleContext(), context.cr_, 0, 0, width, height); |
766 | + |
767 | + cairo_pop_group_to_source(context.cr_); |
768 | + |
769 | + cairo_paint_with_alpha(context.cr_, 1.0); |
770 | + cairo_restore(context.cr_); |
771 | |
772 | if (highlighted) |
773 | { |
774 | // Draw windows title |
775 | - const float xText = CLOSE_ICON_SPACE * 2 + CLOSE_ICON_SIZE; |
776 | - RenderText(context.get(), |
777 | - xText, 0.0, |
778 | - width - xText, height); |
779 | + const float xText = SCALE_ITEMS_PADDING * 2 + SCALE_CLOSE_ICON_SIZE; |
780 | + RenderText(context, xText, 0.0, width - xText - SCALE_ITEMS_PADDING, height); |
781 | } |
782 | |
783 | mask |= PAINT_WINDOW_BLEND_MASK; |
784 | int maxWidth, maxHeight; |
785 | - foreach(GLTexture *icon, context->texture_) |
786 | - { |
787 | - DrawTexture(icon, attrib, transform, mask, |
788 | - x, y, |
789 | - maxWidth , maxHeight); |
790 | - } |
791 | -} |
792 | - |
793 | -void |
794 | -UnityWindow::PrepareHeaderStyle() |
795 | -{ |
796 | - if (!window_header_style_) |
797 | - { |
798 | - GtkWidgetPath* widget_path = gtk_widget_path_new(); |
799 | - gint pos = gtk_widget_path_append_type(widget_path, GTK_TYPE_WINDOW); |
800 | - gtk_widget_path_iter_set_name(widget_path, pos, "UnityPanelWidget"); |
801 | - |
802 | - window_header_style_ = glib::Object<GtkStyleContext>(gtk_style_context_new()); |
803 | - gtk_style_context_set_path(window_header_style_, widget_path); |
804 | - gtk_style_context_add_class(window_header_style_, "gnome-panel-menu-bar"); |
805 | - gtk_style_context_add_class(window_header_style_, "unity-panel"); |
806 | - |
807 | - // get close button |
808 | - panel::Style& style = panel::Style::Instance(); |
809 | - |
810 | - std::vector<std::string> files = style.GetWindowButtonFileNames(panel::WindowButtonType::CLOSE, |
811 | - panel::WindowState::NORMAL); |
812 | - |
813 | - CompString pName("unityshell"); |
814 | - foreach (std::string file, files) |
815 | - { |
816 | - CompString fileName(file.c_str ()); |
817 | - CompSize size(CLOSE_ICON_SIZE, CLOSE_ICON_SIZE); |
818 | - close_icon_ = GLTexture::readImageToTexture(fileName, |
819 | - pName, |
820 | - size); |
821 | - if (close_icon_.size() != 0) |
822 | - break; |
823 | - } |
824 | - |
825 | - if (close_icon_.size() == 0) |
826 | - { |
827 | - CompString fileName(PKGDATADIR"/close_dash.png"); |
828 | - CompSize size(CLOSE_ICON_SIZE, CLOSE_ICON_SIZE); |
829 | - close_icon_ = GLTexture::readImageToTexture(fileName, |
830 | - pName, |
831 | - size); |
832 | - } |
833 | - } |
834 | -} |
835 | - |
836 | -void |
837 | -UnityWindow::scalePaintDecoration(const GLWindowPaintAttrib& attrib, |
838 | - const GLMatrix& transform, |
839 | - const CompRegion& region, |
840 | - unsigned int mask) |
841 | -{ |
842 | - ScaleWindow *sWindow = ScaleWindow::get(window); |
843 | - if (!sWindow) |
844 | - return; |
845 | - |
846 | - sWindow->scalePaintDecoration(attrib, transform, region, mask); |
847 | - |
848 | - if (!sWindow->hasSlot()) // animation not finished |
849 | + |
850 | + for (GLTexture *icon : context.texture_) |
851 | + DrawTexture(icon, attrib, transform, mask, x, y, maxWidth , maxHeight); |
852 | +} |
853 | + |
854 | +void UnityWindow::LoadCloseIcon(panel::WindowState state, GLTexture::List& texture) |
855 | +{ |
856 | + if (!texture.empty()) |
857 | + return; |
858 | + |
859 | + auto& style = panel::Style::Instance(); |
860 | + auto const& files = style.GetWindowButtonFileNames(panel::WindowButtonType::CLOSE, state); |
861 | + |
862 | + CompString pName("unityshell"); |
863 | + for (std::string const& file : files) |
864 | + { |
865 | + CompString fileName(file.c_str()); |
866 | + CompSize size(SCALE_CLOSE_ICON_SIZE, SCALE_CLOSE_ICON_SIZE); |
867 | + texture = GLTexture::readImageToTexture(fileName, pName, size); |
868 | + if (!texture.empty()) |
869 | + break; |
870 | + } |
871 | + |
872 | + if (texture.empty()) |
873 | + { |
874 | + std::string suffix; |
875 | + if (state == panel::WindowState::PRELIGHT) |
876 | + suffix = "_prelight"; |
877 | + else if (state == panel::WindowState::PRESSED) |
878 | + suffix = "_pressed"; |
879 | + |
880 | + CompString fileName((PKGDATADIR"/close_dash" + suffix + ".png").c_str()); |
881 | + CompSize size(SCALE_CLOSE_ICON_SIZE, SCALE_CLOSE_ICON_SIZE); |
882 | + texture = GLTexture::readImageToTexture(fileName, pName, size); |
883 | + } |
884 | +} |
885 | + |
886 | +void UnityWindow::SetupScaleHeaderStyle() |
887 | +{ |
888 | + LoadCloseIcon(panel::WindowState::NORMAL, close_normal_tex_); |
889 | + LoadCloseIcon(panel::WindowState::PRELIGHT, close_prelight_tex_); |
890 | + LoadCloseIcon(panel::WindowState::PRESSED, close_pressed_tex_); |
891 | +} |
892 | + |
893 | +void UnityWindow::scalePaintDecoration(GLWindowPaintAttrib const& attrib, |
894 | + GLMatrix const& transform, |
895 | + CompRegion const& region, |
896 | + unsigned int mask) |
897 | +{ |
898 | + ScaleWindow *scale_win = ScaleWindow::get(window); |
899 | + if (!scale_win) |
900 | + return; |
901 | + |
902 | + scale_win->scalePaintDecoration(attrib, transform, region, mask); |
903 | + |
904 | + if (!scale_win->hasSlot()) // animation not finished |
905 | return; |
906 | |
907 | UnityScreen* us = UnityScreen::get(screen); |
908 | - const guint32 xid = window->id(); |
909 | - const bool highlighted = (us->highlighted_window_ == xid); |
910 | - GLWindowPaintAttrib sAttrib(attrib); |
911 | - sAttrib.opacity = OPAQUE; |
912 | - |
913 | - PrepareHeaderStyle(); |
914 | - |
915 | - ScalePosition pos = sWindow->getCurrentPosition(); |
916 | - int maxHeight, maxWidth; |
917 | - // Use "1" as margin to make sure to cover all originial decoration |
918 | - const float width = (window->width() * pos.scale) + 2; |
919 | - const float x = pos.x() + window->x() - 1; |
920 | - float y = pos.y() + window->y(); |
921 | - float decorationHeight = SCALE_WINDOW_TITLE_SIZE; |
922 | - |
923 | - // If window is decorated draw the decoration |
924 | - // otherwise draw a small bar over the window |
925 | - if (!highlighted) |
926 | - decorationHeight = SCALE_WINDOW_TITLE_SIZE * 0.30; |
927 | - |
928 | - DrawWindowDecoration(sAttrib, transform, mask, highlighted, |
929 | - x, y, |
930 | - x + width, y + decorationHeight); |
931 | + const bool highlighted = (us->scale_highlighted_window_ == window->id()); |
932 | + |
933 | + ScalePosition const& pos = scale_win->getCurrentPosition(); |
934 | + auto const& border_rect = window->borderRect(); |
935 | + auto const& deco_ext = window->border(); |
936 | + |
937 | + const unsigned decoration_height = deco_ext.top; |
938 | + unsigned width = (border_rect.width() + deco_ext.left + deco_ext.right) * pos.scale; |
939 | + unsigned height = decoration_height * pos.scale; |
940 | + int x = pos.x() + border_rect.x(); |
941 | + int y = pos.y() + border_rect.y() + decoration_height - height - 1; |
942 | + |
943 | + // If window is highlighted, we draw the decoration at full size |
944 | + if (highlighted) |
945 | + height = decoration_height; |
946 | + |
947 | + DrawWindowDecoration(attrib, transform, mask, highlighted, x, y, width, height); |
948 | |
949 | if (highlighted) |
950 | { |
951 | - const float iconX = x + CLOSE_ICON_SPACE; |
952 | - const float iconY = y + ((decorationHeight - CLOSE_ICON_SIZE) / 2.0); |
953 | - maxHeight = maxWidth = 0; |
954 | + x += SCALE_ITEMS_PADDING; |
955 | + y += (height - SCALE_CLOSE_ICON_SIZE) / 2.0f; |
956 | + int max_height = 0; |
957 | + int max_width = 0; |
958 | mask |= PAINT_WINDOW_BLEND_MASK; |
959 | |
960 | - foreach(GLTexture *icon, close_icon_) |
961 | + switch(close_icon_state_) |
962 | { |
963 | - DrawTexture(icon, sAttrib, transform, mask, |
964 | - iconX, iconY, |
965 | - maxWidth , maxHeight); |
966 | + case panel::WindowState::NORMAL: |
967 | + default: |
968 | + for (GLTexture *icon : close_normal_tex_) |
969 | + DrawTexture(icon, attrib, transform, mask, x, y, max_width , max_height); |
970 | + break; |
971 | + |
972 | + case panel::WindowState::PRELIGHT: |
973 | + for (GLTexture *icon : close_prelight_tex_) |
974 | + DrawTexture(icon, attrib, transform, mask, x, y, max_width , max_height); |
975 | + break; |
976 | + |
977 | + case panel::WindowState::PRESSED: |
978 | + for (GLTexture *icon : close_pressed_tex_) |
979 | + DrawTexture(icon, attrib, transform, mask, x, y, max_width , max_height); |
980 | + break; |
981 | } |
982 | |
983 | - close_button_area_ = CompRect(iconX, iconY, maxWidth, maxHeight); |
984 | + close_button_geo_.Set(x, y, max_height, max_width); |
985 | } |
986 | - else |
987 | + else if (!close_button_geo_.IsNull()) |
988 | { |
989 | - close_button_area_ = CompRect(); |
990 | + close_button_geo_.Set(0, 0, 0, 0); |
991 | } |
992 | } |
993 | |
994 | -void |
995 | -UnityWindow::scaleSelectWindow () |
996 | +void UnityWindow::scaleSelectWindow() |
997 | { |
998 | + ScaleWindow::get(window)->scaleSelectWindow(); |
999 | + |
1000 | UnityScreen* us = UnityScreen::get(screen); |
1001 | |
1002 | - if (us->highlighted_window_ != window->id ()) |
1003 | - { |
1004 | - CompositeWindow *cWindow = CompositeWindow::get(window); |
1005 | - if (cWindow) |
1006 | - cWindow->addDamage(); |
1007 | - |
1008 | - cWindow = 0; |
1009 | - CompWindow *old_window = screen->findWindow(us->highlighted_window_); |
1010 | - if (old_window) |
1011 | - cWindow = CompositeWindow::get(old_window); |
1012 | - |
1013 | - if (cWindow) |
1014 | - cWindow->addDamage(); |
1015 | - |
1016 | - us->highlighted_window_ = window->id(); |
1017 | - } |
1018 | - |
1019 | - ScaleWindow *sWindow = ScaleWindow::get(window); |
1020 | - if (sWindow) |
1021 | - sWindow->scaleSelectWindow(); |
1022 | -} |
1023 | - |
1024 | -void UnityWindow::InitiateSpreed() |
1025 | -{ |
1026 | - WindowManager *wm = WindowManager::Default(); |
1027 | - const guint32 xid = window->id(); |
1028 | - has_original_decoration_ = wm->IsWindowDecorated(xid) && |
1029 | - !wm->IsWindowMaximized(xid); |
1030 | - if (has_original_decoration_) |
1031 | + if (us->scale_highlighted_window_ != window->id()) |
1032 | + us->scale_highlighted_window_ = window->id(); |
1033 | +} |
1034 | + |
1035 | +void UnityWindow::OnInitiateSpreed() |
1036 | +{ |
1037 | + auto const windows = screen->windows(); |
1038 | + if (std::find(windows.begin(), windows.end(), window) == windows.end()) |
1039 | + return; |
1040 | + |
1041 | + close_icon_state_ = panel::WindowState::NORMAL; |
1042 | + SetupScaleHeaderStyle(); |
1043 | + |
1044 | + WindowManager *wm = WindowManager::Default(); |
1045 | + Window xid = window->id(); |
1046 | + |
1047 | + if (wm->IsWindowDecorated(xid)) |
1048 | + wm->Decorate(xid); |
1049 | +} |
1050 | + |
1051 | +void UnityWindow::OnTerminateSpreed() |
1052 | +{ |
1053 | + auto const windows = screen->windows(); |
1054 | + if (std::find(windows.begin(), windows.end(), window) == windows.end()) |
1055 | + return; |
1056 | + |
1057 | + WindowManager *wm = WindowManager::Default(); |
1058 | + Window xid = window->id(); |
1059 | + |
1060 | + if (wm->IsWindowDecorated(xid) && wm->IsWindowMaximized(xid)) |
1061 | wm->Undecorate(xid); |
1062 | } |
1063 | |
1064 | -void UnityWindow::TerminateSpreed() |
1065 | -{ |
1066 | - if (has_original_decoration_) |
1067 | - WindowManager::Default()->Decorate(window->id()); |
1068 | -} |
1069 | - |
1070 | UnityWindow::~UnityWindow() |
1071 | { |
1072 | UnityScreen* us = UnityScreen::get(screen); |
1073 | @@ -3969,13 +3971,10 @@ |
1074 | |
1075 | ShowdesktopHandler::animating_windows.remove (static_cast <ShowdesktopHandlerWindowInterface *> (this)); |
1076 | |
1077 | - if (mShowdesktopHandler) |
1078 | - delete mShowdesktopHandler; |
1079 | - |
1080 | if (window->state () & CompWindowStateFullscreenMask) |
1081 | UnityScreen::get (screen)->fullscreen_windows_.remove(window); |
1082 | |
1083 | - PluginAdapter::Default ()->OnWindowClosed (window); |
1084 | + PluginAdapter::Default ()->OnWindowClosed(window); |
1085 | } |
1086 | |
1087 | /* vtable init */ |
1088 | |
1089 | === modified file 'plugins/unityshell/src/unityshell.h' |
1090 | --- plugins/unityshell/src/unityshell.h 2012-09-04 15:26:06 +0000 |
1091 | +++ plugins/unityshell/src/unityshell.h 2012-09-07 00:07:25 +0000 |
1092 | @@ -71,8 +71,6 @@ |
1093 | namespace unity |
1094 | { |
1095 | |
1096 | -class WindowCairoContext; |
1097 | - |
1098 | /* base screen class */ |
1099 | class UnityScreen : |
1100 | public unity::debug::Introspectable, |
1101 | @@ -250,9 +248,6 @@ |
1102 | |
1103 | void InitGesturesSupport(); |
1104 | |
1105 | - void OnInitiateSpreed(); |
1106 | - void OnTerminateSpreed(); |
1107 | - |
1108 | nux::animation::TickSource tick_source_; |
1109 | nux::animation::AnimationController animation_controller_; |
1110 | |
1111 | @@ -350,7 +345,7 @@ |
1112 | glib::SourceManager sources_; |
1113 | unity::ThumbnailGenerator thumb_generator; |
1114 | |
1115 | - Window highlighted_window_; |
1116 | + Window scale_highlighted_window_; |
1117 | |
1118 | WindowMinimizeSpeedController* minimize_speed_controller; |
1119 | friend class UnityWindow; |
1120 | @@ -420,15 +415,12 @@ |
1121 | void leaveShowDesktop (); |
1122 | bool HandleAnimations (unsigned int ms); |
1123 | |
1124 | - void handleEvent (XEvent *event); |
1125 | - |
1126 | - CompRect CloseButtonArea(); |
1127 | + bool handleEvent(XEvent *event); |
1128 | |
1129 | typedef compiz::CompizMinimizedWindowHandler<UnityScreen, UnityWindow> |
1130 | UnityMinimizedHandler; |
1131 | std::unique_ptr <UnityMinimizedHandler> mMinimizeHandler; |
1132 | - |
1133 | - ShowdesktopHandler *mShowdesktopHandler; |
1134 | + std::unique_ptr <ShowdesktopHandler> mShowdesktopHandler; |
1135 | |
1136 | //! Emited when CompWindowNotifyBeforeDestroy is received |
1137 | sigc::signal<void> being_destroyed; |
1138 | @@ -439,10 +431,9 @@ |
1139 | const CompRegion &, |
1140 | unsigned int); |
1141 | |
1142 | - void InitiateSpreed(); |
1143 | - void TerminateSpreed(); |
1144 | - |
1145 | private: |
1146 | + struct CairoContext; |
1147 | + |
1148 | void DoEnableFocus (); |
1149 | void DoDisableFocus (); |
1150 | |
1151 | @@ -462,6 +453,9 @@ |
1152 | void DoShow (); |
1153 | void DoNotifyShown (); |
1154 | |
1155 | + void OnInitiateSpreed(); |
1156 | + void OnTerminateSpreed(); |
1157 | + |
1158 | void DoAddDamage (); |
1159 | ShowdesktopHandlerWindowInterface::PostPaintAction DoHandleAnimations (unsigned int ms); |
1160 | |
1161 | @@ -473,30 +467,31 @@ |
1162 | |
1163 | compiz::WindowInputRemoverLock::Ptr GetInputRemover (); |
1164 | |
1165 | - void DrawWindowDecoration(const GLWindowPaintAttrib& attrib, |
1166 | - const GLMatrix& transform, |
1167 | + void DrawWindowDecoration(GLWindowPaintAttrib const& attrib, |
1168 | + GLMatrix const& transform, |
1169 | unsigned int mask, |
1170 | bool highlighted, |
1171 | - float x, float y, float x2, float y2); |
1172 | + int x, int y, unsigned width, unsigned height); |
1173 | void DrawTexture(GLTexture *icon, |
1174 | const GLWindowPaintAttrib& attrib, |
1175 | const GLMatrix& transform, |
1176 | unsigned int mask, |
1177 | float x, float y, |
1178 | int &maxWidth, int &maxHeight); |
1179 | - void RenderText(WindowCairoContext *context, |
1180 | + void RenderText(CairoContext const& context, |
1181 | float x, float y, |
1182 | float maxWidth, float maxHeight); |
1183 | - void PrepareHeaderStyle(); |
1184 | - std::shared_ptr<WindowCairoContext> CreateCairoContext(float width, float height); |
1185 | - |
1186 | + |
1187 | + void SetupScaleHeaderStyle(); |
1188 | + void LoadCloseIcon(panel::WindowState state, GLTexture::List& texture); |
1189 | + |
1190 | + static GLTexture::List close_normal_tex_; |
1191 | + static GLTexture::List close_prelight_tex_; |
1192 | + static GLTexture::List close_pressed_tex_; |
1193 | compiz::WindowInputRemoverLock::Weak input_remover_; |
1194 | + panel::WindowState close_icon_state_; |
1195 | + nux::Geometry close_button_geo_; |
1196 | glib::Source::UniquePtr focus_desktop_timeout_; |
1197 | - |
1198 | - GLTexture::List close_icon_; |
1199 | - CompRect close_button_area_; |
1200 | - glib::Object<GtkStyleContext> window_header_style_; |
1201 | - bool has_original_decoration_; |
1202 | }; |
1203 | |
1204 |
looks ok for me.