diff options
| author | Daniel van Vugt <daniel.van.vugt@canonical.com> | 2012-10-11 09:44:15 +0800 |
|---|---|---|
| committer | Daniel van Vugt <daniel.van.vugt@canonical.com> | 2012-10-11 09:44:15 +0800 |
| commit | 9c952849f6d376d34813b7dd947ba9669e8044e1 (patch) | |
| tree | c64654751edbc051d7ae30040b52f30a050a3f59 /plugins | |
| parent | 266d4f37d83d34452713ba8425b82e128f525dc3 (diff) | |
| parent | abcfeecdf865969ea560e734789f7b4bb0c22b63 (diff) | |
Merge latest lp:unity and fix a conflict
(bzr r2769.5.3)
Diffstat (limited to 'plugins')
| -rw-r--r-- | plugins/unityshell/resources/album_missing_preview.png | bin | 1750 -> 2836 bytes | |||
| -rw-r--r-- | plugins/unityshell/src/WindowGestureTarget.cpp | 5 | ||||
| -rw-r--r-- | plugins/unityshell/src/compizminimizedwindowhandler.h | 4 | ||||
| -rw-r--r-- | plugins/unityshell/src/glow_texture.h | 204 | ||||
| -rw-r--r-- | plugins/unityshell/src/unity-launcher-accessible.cpp | 29 | ||||
| -rw-r--r-- | plugins/unityshell/src/unity-switcher-accessible.cpp | 18 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.cpp | 409 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell.h | 15 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell_glow.cpp | 396 | ||||
| -rw-r--r-- | plugins/unityshell/src/unityshell_glow.h | 71 | ||||
| -rw-r--r-- | plugins/unityshell/unityshell.xml.in | 1 |
11 files changed, 953 insertions, 199 deletions
diff --git a/plugins/unityshell/resources/album_missing_preview.png b/plugins/unityshell/resources/album_missing_preview.png Binary files differindex 2cd95245e..5d4716569 100644 --- a/plugins/unityshell/resources/album_missing_preview.png +++ b/plugins/unityshell/resources/album_missing_preview.png diff --git a/plugins/unityshell/src/WindowGestureTarget.cpp b/plugins/unityshell/src/WindowGestureTarget.cpp index 8bcaa7b40..beeb7830f 100644 --- a/plugins/unityshell/src/WindowGestureTarget.cpp +++ b/plugins/unityshell/src/WindowGestureTarget.cpp @@ -25,6 +25,7 @@ #include <Nux/Nux.h> // otherwise unityshell.h inclusion will cause failures #include "unityshell.h" +// To make the gesture tests pass, this has to be a local include. #include "PluginAdapter.h" using namespace nux; @@ -67,7 +68,7 @@ GestureDeliveryRequest WindowGestureTarget::GestureEvent(const nux::GestureEvent switch (event.type) { case nux::EVENT_GESTURE_BEGIN: - PluginAdapter::Default()->ShowGrabHandles(window_, false); + PluginAdapter::Default().ShowGrabHandles(window_, false); break; case EVENT_GESTURE_UPDATE: if (event.GetGestureClasses() & PINCH_GESTURE) @@ -91,7 +92,7 @@ GestureDeliveryRequest WindowGestureTarget::GestureEvent(const nux::GestureEvent EndWindowMove(event); started_window_move_ = false; } - PluginAdapter::Default()->ShowGrabHandles(window_, true); + PluginAdapter::Default().ShowGrabHandles(window_, true); break; }; diff --git a/plugins/unityshell/src/compizminimizedwindowhandler.h b/plugins/unityshell/src/compizminimizedwindowhandler.h index 4befd16f0..d2b90926e 100644 --- a/plugins/unityshell/src/compizminimizedwindowhandler.h +++ b/plugins/unityshell/src/compizminimizedwindowhandler.h @@ -154,7 +154,7 @@ compiz::CompizMinimizedWindowHandler<Screen, Window>::minimize () { CompWindow *win = screen->findWindow (w); - if (win) + if (win && win->isMapped()) { Window *w = Window::get (win); if (!w->mMinimizeHandler) @@ -235,7 +235,7 @@ compiz::CompizMinimizedWindowHandler<Screen, Window>::unminimize() { CompWindow *win = screen->findWindow (w); - if (win) + if (win && win->isMapped()) { Window *w = Window::get (win); if (w && w->mMinimizeHandler) diff --git a/plugins/unityshell/src/glow_texture.h b/plugins/unityshell/src/glow_texture.h new file mode 100644 index 000000000..7303b6708 --- /dev/null +++ b/plugins/unityshell/src/glow_texture.h @@ -0,0 +1,204 @@ +/** + * + * + * Copyright : (C) 2006-2010 by Patrick Niklaus, Roi Cohen, + * Danny Baumann, Sam Spilsbury + * Authors: Patrick Niklaus <patrick.niklaus@googlemail.com> + * Roi Cohen <roico.beryl@gmail.com> + * Danny Baumann <maniac@opencompositing.org> + * Sam Spilsbury <smspillaz@gmail.com> + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + **/ + +#ifndef UNITY_TEXTURE_GLOW_H +#define UNITY_TEXTURE_GLOW_H + +namespace unity +{ +namespace texture +{ + +/* + * glowTex + */ + +const unsigned GLOW_SIZE = 32; +const int GLOW_OFFSET = 21; +const char GLOW[4097] = { + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\6\377" + "\377\377\6\377\377\377\6\377\377\377\6\377\377\377\6\377\377\377\6\377\377" + "\377\6\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377\6\377\377\377\6\377\377" + "\377\6\377\377\377\6\377\377\377\6\377\377\377\6\377\377\377\6\377\377\377" + "\6\377\377\377\6\377\377\377\6\377\377\377\6\377\377\377\6\377\377\377\6" + "\377\377\377\14\377\377\377\14\377\377\377\14\377\377\377\14\377\377\377" + "\14\377\377\377\14\377\377\377\14\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377\6\377\377\377\6\377\377\377\14" + "\377\377\377\14\377\377\377\22\377\377\377\22\377\377\377\22\377\377\377" + "\27\377\377\377\27\377\377\377\27\377\377\377\27\377\377\377\27\377\377\377" + "\27\377\377\377\27\377\377\377\27\377\377\377\27\377\377\377\27\377\377\377" + "\35\377\377\377\35\377\377\377\35\377\377\377\35\377\377\377\35\377\377\377" + "\35\377\377\377\35\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377" + "\377\6\377\377\377\6\377\377\377\14\377\377\377\22\377\377\377\27\377\377" + "\377\27\377\377\377\35\377\377\377#\377\377\377'\377\377\377'\377\377\377" + "+\377\377\377+\377\377\377+\377\377\377+\377\377\377+\377\377\377+\377\377" + "\377+\377\377\377+\377\377\377+\377\377\3771\377\377\3771\377\377\3771\377" + "\377\3771\377\377\3771\377\377\3771\377\377\3771\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377\14\377\377\377\22\377\377\377" + "\27\377\377\377\35\377\377\377#\377\377\377+\377\377\3771\377\377\3776\377" + "\377\377<\377\377\377>\377\377\377C\377\377\377I\377\377\377I\377\377\377" + "I\377\377\377I\377\377\377I\377\377\377I\377\377\377I\377\377\377I\377\377" + "\377L\377\377\377L\377\377\377L\377\377\377L\377\377\377L\377\377\377L\377" + "\377\377L\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377\14\377" + "\377\377\22\377\377\377\27\377\377\377#\377\377\377+\377\377\3776\377\377" + "\377C\377\377\377L\377\377\377U\377\377\377]\377\377\377`\377\377\377d\377" + "\377\377h\377\377\377k\377\377\377k\377\377\377k\377\377\377k\377\377\377" + "k\377\377\377k\377\377\377k\377\377\377p\377\377\377p\377\377\377p\377\377" + "\377p\377\377\377p\377\377\377p\377\377\377p\0\0\0\0\0\0\0\0\0\0\0\0\377" + "\377\377\6\377\377\377\14\377\377\377\22\314\314\314\35\377\377\377'\377" + "\377\3771\377\377\377>\357\357\357P\377\377\377]\363\363\363k\365\365\365" + "v\365\365\365|\377\377\377\202\367\367\367\210\367\367\367\214\367\367\367" + "\216\367\367\367\221\367\367\367\221\367\367\367\221\367\367\367\221\367" + "\367\367\221\367\367\367\221\367\367\367\224\367\367\367\224\367\367\367" + "\224\367\367\367\224\367\367\367\224\367\367\367\224\367\367\367\224\0\0" + "\0\0\0\0\0\0\377\377\377\6\377\377\377\6\377\377\377\22\377\377\377\27\377" + "\377\377'\377\377\3776\377\377\377I\377\377\377Y\377\377\377k\376\376\376" + "y\377\377\377\210\377\377\377\224\377\377\377\235\377\377\377\245\377\377" + "\377\253\377\377\377\255\377\377\377\262\377\377\377\262\377\377\377\263" + "\377\377\377\263\377\377\377\263\377\377\377\263\377\377\377\263\377\377" + "\377\266\377\377\377\266\377\377\377\266\377\377\377\266\377\377\377\266" + "\377\377\377\266\377\377\377\266\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377" + "\14\377\377\377\27\377\377\377#\377\377\3771\377\377\377I\377\377\377]\377" + "\377\377r\377\377\377\205\377\377\377\231\377\377\377\247\377\377\377\263" + "\377\377\377\275\377\377\377\304\377\377\377\310\377\377\377\313\377\377" + "\377\316\377\377\377\320\377\377\377\320\377\377\377\320\377\377\377\320" + "\377\377\377\320\377\377\377\320\377\377\377\322\377\377\377\322\377\377" + "\377\322\377\377\377\322\377\377\377\322\377\377\377\322\377\377\377\322" + "\0\0\0\0\377\377\377\6\377\377\377\6\377\377\377\22\377\377\377\35\377\377" + "\377+\377\377\377>\377\377\377Y\377\377\377r\377\377\377\210\376\376\376" + "\237\377\377\377\262\377\377\377\302\377\377\377\313\377\377\377\324\377" + "\377\377\332\376\376\376\336\377\377\377\341\377\377\377\342\377\377\377" + "\344\377\377\377\344\377\377\377\344\377\377\377\344\377\377\377\344\377" + "\377\377\344\377\377\377\345\377\377\377\345\377\377\377\345\377\377\377" + "\345\377\377\377\345\377\377\377\345\377\377\377\345\0\0\0\0\377\377\377" + "\6\377\377\377\14\377\377\377\27\377\377\377#\377\377\3776\377\377\377P\377" + "\377\377k\377\377\377\205\376\376\376\237\372\372\372\266\377\377\377\307" + "\373\373\373\325\373\373\373\337\374\374\374\345\374\374\374\352\374\374" + "\374\355\374\374\374\357\374\374\374\360\374\374\374\361\374\374\374\361" + "\374\374\374\362\374\374\374\362\374\374\374\362\374\374\374\362\374\374" + "\374\362\374\374\374\362\374\374\374\362\374\374\374\362\374\374\374\362" + "\374\374\374\362\374\374\374\362\0\0\0\0\377\377\377\6\377\377\377\14\377" + "\377\377\35\377\377\377+\377\377\377C\377\377\377]\377\377\377|\377\377\377" + "\231\377\377\377\263\377\377\377\307\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377" + "\377\377\6\377\377\377\22\324\324\324#\377\377\3771\377\377\377L\363\363" + "\363k\377\377\377\210\377\377\377\247\377\377\377\302\377\377\377\325\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377\14\377\377\377\22\377\377" + "\377#\377\377\377<\377\377\377U\377\377\377v\377\377\377\226\377\377\377" + "\263\377\377\377\315\377\377\377\337\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377" + "\6\377\377\377\14\377\377\377\27\377\377\377'\377\377\377>\377\377\377]\377" + "\377\377|\370\370\370\237\377\377\377\275\373\373\373\325\377\377\377\345" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377\14\377\377\377\27\377" + "\377\377+\377\377\377C\377\377\377`\377\377\377\202\377\377\377\247\377\377" + "\377\304\377\377\377\332\377\377\377\352\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377" + "\377\6\377\377\377\14\377\377\377\27\377\377\377+\377\377\377C\377\377\377" + "d\377\377\377\210\377\377\377\253\377\377\377\310\376\376\376\336\374\374" + "\374\355\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377\14\377\377\377" + "\35\377\377\377+\377\377\377I\377\377\377h\377\377\377\214\377\377\377\260" + "\377\377\377\313\374\374\374\342\374\374\374\357\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\377\377\377\6\377\377\377\14\377\377\377\35\342\342\3421\377\377\377I\377" + "\377\377k\377\377\377\216\377\377\377\262\377\377\377\316\374\374\374\344" + "\377\377\377\360\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377\14\377" + "\377\377\35\377\377\3771\377\377\377L\377\377\377k\377\377\377\221\377\377" + "\377\263\377\377\377\320\377\377\377\344\377\377\377\361\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\377\377\377\6\377\377\377\14\377\377\377\35\377\377\3771\377\377" + "\377L\377\377\377k\377\377\377\221\377\377\377\263\377\377\377\320\377\377" + "\377\344\374\374\374\362\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377" + "\14\377\377\377\35\377\377\3771\377\377\377L\364\364\364p\377\377\377\221" + "\372\372\372\266\377\377\377\320\374\374\374\345\377\377\377\362\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377\14\377\377\377\35\377\377\377" + "1\377\377\377L\377\377\377p\377\377\377\221\377\377\377\266\373\373\373\322" + "\377\377\377\345\377\377\377\362\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\6\377" + "\377\377\14\377\377\377\35\377\377\3771\377\377\377L\377\377\377p\377\377" + "\377\221\377\377\377\266\373\373\373\322\377\377\377\345\377\377\377\362" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377\14\377\377\377\35\377" + "\377\3771\377\377\377L\377\377\377p\377\377\377\221\377\377\377\266\373\373" + "\373\322\377\377\377\345\377\377\377\362\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377" + "\377\6\377\377\377\14\377\377\377\35\377\377\3771\377\377\377L\377\377\377" + "p\367\367\367\224\377\377\377\266\377\377\377\322\377\377\377\345\374\374" + "\374\362\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377\14\377\377\377" + "\35\377\377\3771\377\377\377L\377\377\377p\367\367\367\224\377\377\377\266" + "\377\377\377\322\377\377\377\345\374\374\374\362\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\377\377\377\6\377\377\377\14\377\377\377\35\377\377\3771\377\377\377L\377" + "\377\377p\367\367\367\224\377\377\377\266\377\377\377\322\377\377\377\345" + "\374\374\374\362\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377\14\377" + "\377\377\35\377\377\3771\377\377\377L\377\377\377p\367\367\367\224\377\377" + "\377\266\377\377\377\322\377\377\377\345\374\374\374\362\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\377\377\377\6\377\377\377\14\377\377\377\35\377\377\3771\377\377" + "\377L\377\377\377p\367\367\367\224\377\377\377\266\377\377\377\322\377\377" + "\377\345\374\374\374\362\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377" + "\14\377\377\377\35\377\377\3771\377\377\377L\377\377\377p\367\367\367\224" + "\377\377\377\266\377\377\377\322\377\377\377\345\374\374\374\362\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\377\377\377\6\377\377\377\14\377\377\377\35\377\377\377" + "1\377\377\377L\377\377\377p\367\367\367\224\377\377\377\266\377\377\377\322" + "\377\377\377\345\374\374\374\362\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0" + "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", +}; + +} // Namespace texture +} // Namespace unity + +#endif diff --git a/plugins/unityshell/src/unity-launcher-accessible.cpp b/plugins/unityshell/src/unity-launcher-accessible.cpp index 4cb4301ae..2764a9d83 100644 --- a/plugins/unityshell/src/unity-launcher-accessible.cpp +++ b/plugins/unityshell/src/unity-launcher-accessible.cpp @@ -63,9 +63,9 @@ static gboolean unity_launcher_accessible_is_child_selected(AtkSelection* sele gint i); /* private */ -static void on_selection_change_cb(AbstractLauncherIcon::Ptr selection, UnityLauncherAccessible* launcher_accessible); -static void on_icon_added_cb(AbstractLauncherIcon::Ptr icon, UnityLauncherAccessible* self); -static void on_icon_removed_cb(AbstractLauncherIcon::Ptr icon, UnityLauncherAccessible* self); +static void on_selection_change_cb(AbstractLauncherIcon::Ptr const& selection, UnityLauncherAccessible* launcher_accessible); +static void on_icon_added_cb(AbstractLauncherIcon::Ptr const& icon, UnityLauncherAccessible* self); +static void on_icon_removed_cb(AbstractLauncherIcon::Ptr const& icon, UnityLauncherAccessible* self); static void on_order_change_cb(UnityLauncherAccessible* self); static void update_children_index(UnityLauncherAccessible* self); @@ -287,7 +287,6 @@ unity_launcher_accessible_ref_selection(AtkSelection* selection, gint i) { Launcher* launcher = NULL; - AbstractLauncherIcon::Ptr selected_icon; nux::Object* nux_object = NULL; AtkObject* accessible_selected = NULL; @@ -300,7 +299,7 @@ unity_launcher_accessible_ref_selection(AtkSelection* selection, return 0; launcher = dynamic_cast<Launcher*>(nux_object); - selected_icon = launcher->GetSelectedMenuIcon(); + AbstractLauncherIcon::Ptr const& selected_icon = launcher->GetSelectedMenuIcon(); if (selected_icon) { @@ -315,7 +314,6 @@ static gint unity_launcher_accessible_get_selection_count(AtkSelection* selection) { Launcher* launcher = NULL; - AbstractLauncherIcon::Ptr selected_icon; nux::Object* nux_object = NULL; g_return_val_if_fail(UNITY_IS_LAUNCHER_ACCESSIBLE(selection), 0); @@ -325,9 +323,8 @@ unity_launcher_accessible_get_selection_count(AtkSelection* selection) return 0; launcher = dynamic_cast<Launcher*>(nux_object); - selected_icon = launcher->GetSelectedMenuIcon(); - if (!selected_icon) + if (!launcher->GetSelectedMenuIcon()) return 0; else return 1; @@ -338,9 +335,6 @@ unity_launcher_accessible_is_child_selected(AtkSelection* selection, gint i) { Launcher* launcher = NULL; - AbstractLauncherIcon::Ptr icon; - AbstractLauncherIcon::Ptr selected_icon; - LauncherModel::Ptr launcher_model; LauncherModel::iterator it; nux::Object* nux_object = NULL; @@ -351,28 +345,27 @@ unity_launcher_accessible_is_child_selected(AtkSelection* selection, return 0; launcher = dynamic_cast<Launcher*>(nux_object); - launcher_model = launcher->GetModel(); + LauncherModel::Ptr const& launcher_model = launcher->GetModel(); it = launcher_model->begin(); std::advance(it, i); - icon = *it; - selected_icon = launcher->GetSelectedMenuIcon(); + AbstractLauncherIcon::Ptr const& selected_icon = launcher->GetSelectedMenuIcon(); - if (selected_icon == icon) + if (selected_icon == *it) return TRUE; else return FALSE; } /* private */ -static void on_selection_change_cb(AbstractLauncherIcon::Ptr selection, UnityLauncherAccessible* launcher_accessible) +static void on_selection_change_cb(AbstractLauncherIcon::Ptr const& selection, UnityLauncherAccessible* launcher_accessible) { g_signal_emit_by_name(ATK_OBJECT(launcher_accessible), "selection-changed"); } static void -on_icon_added_cb(AbstractLauncherIcon::Ptr icon, +on_icon_added_cb(AbstractLauncherIcon::Ptr const& icon, UnityLauncherAccessible* self) { AtkObject* icon_accessible = NULL; @@ -397,7 +390,7 @@ on_icon_added_cb(AbstractLauncherIcon::Ptr icon, } static void -on_icon_removed_cb(AbstractLauncherIcon::Ptr icon, +on_icon_removed_cb(AbstractLauncherIcon::Ptr const& icon, UnityLauncherAccessible* self) { AtkObject* icon_accessible = NULL; diff --git a/plugins/unityshell/src/unity-switcher-accessible.cpp b/plugins/unityshell/src/unity-switcher-accessible.cpp index 189e7d703..ab83d6477 100644 --- a/plugins/unityshell/src/unity-switcher-accessible.cpp +++ b/plugins/unityshell/src/unity-switcher-accessible.cpp @@ -64,7 +64,7 @@ static gboolean unity_switcher_accessible_is_child_selected(AtkSelection* sele static gboolean unity_switcher_accessible_check_pending_notification(NuxAreaAccessible* self); /* private */ -static void on_selection_changed_cb(AbstractLauncherIcon::Ptr icon, +static void on_selection_changed_cb(AbstractLauncherIcon::Ptr const& icon, UnitySwitcherAccessible* switcher_accessible); static void create_children(UnitySwitcherAccessible* self); @@ -311,7 +311,6 @@ unity_switcher_accessible_get_selection_count(AtkSelection* selection) { SwitcherView* switcher = NULL; SwitcherModel::Ptr switcher_model; - AbstractLauncherIcon::Ptr selected_icon; nux::Object* nux_object = NULL; g_return_val_if_fail(UNITY_IS_SWITCHER_ACCESSIBLE(selection), 0); @@ -323,9 +322,7 @@ unity_switcher_accessible_get_selection_count(AtkSelection* selection) switcher = dynamic_cast<SwitcherView*>(nux_object); switcher_model = switcher->GetModel(); - selected_icon = switcher_model->Selection(); - - if (!selected_icon) + if (!switcher_model->Selection()) return 0; else return 1; @@ -377,7 +374,7 @@ unity_switcher_accessible_check_pending_notification(NuxAreaAccessible* self) /* private */ static void -on_selection_changed_cb(AbstractLauncherIcon::Ptr icon, +on_selection_changed_cb(AbstractLauncherIcon::Ptr const& icon, UnitySwitcherAccessible* switcher_accessible) { g_signal_emit_by_name(ATK_OBJECT(switcher_accessible), "selection-changed"); @@ -389,9 +386,7 @@ create_children(UnitySwitcherAccessible* self) gint index = 0; nux::Object* nux_object = NULL; SwitcherView* switcher = NULL; - SwitcherModel::Ptr switcher_model; SwitcherModel::iterator it; - AbstractLauncherIcon::Ptr child; AtkObject* child_accessible = NULL; nux_object = nux_object_accessible_get_object(NUX_OBJECT_ACCESSIBLE(self)); @@ -399,14 +394,13 @@ create_children(UnitySwitcherAccessible* self) return; switcher = dynamic_cast<SwitcherView*>(nux_object); - switcher_model = switcher->GetModel(); + SwitcherModel::Ptr const& switcher_model = switcher->GetModel(); - if (switcher_model == NULL) + if (!switcher_model) return; - for (it = switcher_model->begin(); it != switcher_model->end(); ++it) + for (AbstractLauncherIcon::Ptr const& child : *switcher_model) { - child = *it; child_accessible = unity_launcher_icon_accessible_new(child.GetPointer()); atk_object_set_parent(child_accessible, ATK_OBJECT(self)); self->priv->children = g_slist_append(self->priv->children, diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp index ba555036f..a71c40e8d 100644 --- a/plugins/unityshell/src/unityshell.cpp +++ b/plugins/unityshell/src/unityshell.cpp @@ -36,7 +36,8 @@ #include "QuicklistManager.h" #include "StartupNotifyService.h" #include "Timer.h" -#include "KeyboardUtil.h" +#include "XKeyboardUtil.h" +#include "glow_texture.h" #include "unityshell.h" #include "BackgroundEffectHelper.h" #include "UnityGestureBroker.h" @@ -74,7 +75,6 @@ namespace unity using namespace launcher; using launcher::AbstractLauncherIcon; using launcher::Launcher; -using ui::KeyboardUtil; using ui::LayoutWindow; using ui::LayoutWindowList; using util::Timer; @@ -104,6 +104,19 @@ const unsigned int SCROLL_UP_BUTTON = 7; const std::string RELAYOUT_TIMEOUT = "relayout-timeout"; } // namespace local + +namespace scale +{ +namespace decoration +{ +const unsigned CLOSE_SIZE = 19; +const unsigned ITEMS_PADDING = 5; +const unsigned RADIUS = 8; +const unsigned GLOW = 30; +const nux::Color GLOW_COLOR(221, 72, 20); +} // decoration namespace +} // scale namespace + } // anon namespace UnityScreen::UnityScreen(CompScreen* screen) @@ -200,6 +213,18 @@ UnityScreen::UnityScreen(CompScreen* screen) failed = true; } } + + //In case of software rendering then enable lowgfx mode. + std::string renderer = ANSI_TO_TCHAR(NUX_REINTERPRET_CAST(const char *, glGetString(GL_RENDERER))); + + if (renderer.find("Software Rasterizer") != std::string::npos || + renderer.find("Mesa X11") != std::string::npos || + renderer.find("LLVM") != std::string::npos || + renderer.find("on softpipe") != std::string::npos || + (getenv("UNITY_LOW_GFX_MODE") != NULL && atoi(getenv("UNITY_LOW_GFX_MODE")) == 1)) + { + Settings::Instance().SetLowGfxMode(true); + } #endif if (!failed) @@ -216,8 +241,7 @@ UnityScreen::UnityScreen(CompScreen* screen) GLScreenInterface::setHandler(gScreen); PluginAdapter::Initialize(screen); - WindowManager::SetDefault(PluginAdapter::Default()); - AddChild(PluginAdapter::Default()); + AddChild(&WindowManager::Default()); StartupNotifyService::Default()->SetSnDisplay(screen->snDisplay(), screen->screenNum()); @@ -397,9 +421,9 @@ UnityScreen::~UnityScreen() void UnityScreen::initAltTabNextWindow() { - KeyboardUtil key_util(screen->dpy()); - guint above_tab_keycode = key_util.GetKeycodeAboveKeySymbol (XStringToKeysym("Tab")); - KeySym above_tab_keysym = XkbKeycodeToKeysym (screen->dpy(), above_tab_keycode, 0, 0); + Display* display = screen->dpy(); + KeySym tab_keysym = XStringToKeysym("Tab"); + KeySym above_tab_keysym = keyboard::get_key_above_key_symbol(display, tab_keysym); if (above_tab_keysym != NoSymbol) { @@ -435,7 +459,7 @@ void UnityScreen::initAltTabNextWindow() } else { - printf ("Could not find key above tab!\n"); + LOG_WARN(logger) << "Could not find key above tab!"; } } @@ -536,10 +560,13 @@ void UnityScreen::setPanelShadowMatrix(const GLMatrix& matrix) void UnityScreen::paintPanelShadow(const CompRegion& clip) { + if (panel_controller_->opacity() == 0.0f) + return; + if (sources_.GetSource(local::RELAYOUT_TIMEOUT)) return; - if (PluginAdapter::Default()->IsExpoActive()) + if (WindowManager::Default().IsExpoActive()) return; CompOutput* output = _last_output; @@ -564,22 +591,6 @@ void UnityScreen::paintPanelShadow(const CompRegion& clip) panelShadowPainted |= redraw; - const CompRect& bounds(redraw.boundingRect()); - - // Sub-rectangle of the shadow needing redrawing: - float x1 = bounds.x1(); - float y1 = bounds.y1(); - float x2 = bounds.x2(); - float y2 = bounds.y2(); - - // Texture coordinates of the above rectangle: - float tx1 = (x1 - shadowX) / shadowWidth; - float ty1 = (y1 - shadowY) / shadowHeight; - float tx2 = (x2 - shadowX) / shadowWidth; - float ty2 = (y2 - shadowY) / shadowHeight; - - nuxPrologue(); - // compiz doesn't use the same method of tracking monitors as our toolkit // we need to make sure we properly associate with the right monitor int current_monitor = -1; @@ -595,8 +606,14 @@ void UnityScreen::paintPanelShadow(const CompRegion& clip) i++; } - if (!(launcher_controller_->IsOverlayOpen() && current_monitor == overlay_monitor_) - && panel_controller_->opacity() > 0.0f) + if (launcher_controller_->IsOverlayOpen() && current_monitor == overlay_monitor_) + return; + + nuxPrologue(); + + const CompRect::vector& rects = redraw.rects(); + + for (auto const& r : rects) { foreach(GLTexture * tex, _shadow_texture) { @@ -618,6 +635,18 @@ void UnityScreen::paintPanelShadow(const CompRegion& clip) (GLushort)(panel_controller_->opacity() * 0xFFFF) }; + // Sub-rectangle of the shadow needing redrawing: + float x1 = r.x1(); + float y1 = r.y1(); + float x2 = r.x2(); + float y2 = r.y2(); + + // Texture coordinates of the above rectangle: + float tx1 = (x1 - shadowX) / shadowWidth; + float ty1 = (y1 - shadowY) / shadowHeight; + float tx2 = (x2 - shadowX) / shadowWidth; + float ty2 = (y2 - shadowY) / shadowHeight; + vertexData = { x1, y1, 0, x1, y2, 0, @@ -668,7 +697,7 @@ void UnityScreen::OnPanelStyleChanged() // Reload the windows themed textures UnityWindow::CleanupSharedTextures(); - if (WindowManager::Default()->IsScaleActive()) + if (WindowManager::Default().IsScaleActive()) { UnityWindow::SetupSharedTextures(); @@ -817,7 +846,7 @@ bool UnityScreen::forcePaintOnTop () { return !allowWindowPaint || ((switcher_controller_->Visible() || - PluginAdapter::Default()->IsExpoActive()) + WindowManager::Default().IsExpoActive()) && !fullscreen_windows_.empty () && (!(screen->grabbed () && !screen->otherGrabExist (NULL)))); } @@ -882,7 +911,7 @@ void UnityScreen::enterShowDesktopMode () w->moveInputFocusTo(); } - PluginAdapter::Default()->OnShowDesktop(); + PluginAdapter::Default().OnShowDesktop(); /* Disable the focus handler as we will report that * minimized windows can be focused which will @@ -921,7 +950,7 @@ void UnityScreen::leaveShowDesktopMode (CompWindow *w) } } - PluginAdapter::Default()->OnLeaveDesktop(); + PluginAdapter::Default().OnLeaveDesktop(); screen->leaveShowDesktopMode (w); } @@ -1465,16 +1494,16 @@ void UnityScreen::nuxDamageCompiz() void UnityScreen::handleEvent(XEvent* event) { bool skip_other_plugins = false; - auto wm = PluginAdapter::Default(); + PluginAdapter& wm = PluginAdapter::Default(); switch (event->type) { case FocusIn: case FocusOut: if (event->xfocus.mode == NotifyGrab) - wm->OnScreenGrabbed(); + wm.OnScreenGrabbed(); else if (event->xfocus.mode == NotifyUngrab) - wm->OnScreenUngrabbed(); + wm.OnScreenUngrabbed(); if (_key_nav_mode_requested) { @@ -1489,7 +1518,7 @@ void UnityScreen::handleEvent(XEvent* event) _key_nav_mode_requested = false; break; case MotionNotify: - if (wm->IsScaleActive()) + if (wm.IsScaleActive()) { ScaleScreen* ss = ScaleScreen::get(screen); if (CompWindow *w = screen->findWindow(ss->getSelectedWindow())) @@ -1502,20 +1531,23 @@ void UnityScreen::handleEvent(XEvent* event) launcher_controller_->KeyNavTerminate(false); EnableCancelAction(CancelActionTarget::LAUNCHER_SWITCHER, false); } - if (wm->IsScaleActive()) + if (wm.IsScaleActive()) { ScaleScreen* ss = ScaleScreen::get(screen); if (CompWindow *w = screen->findWindow(ss->getSelectedWindow())) skip_other_plugins = UnityWindow::get(w)->handleEvent(event); } - if (dash_controller_->IsVisible()) { nux::Point pt(event->xbutton.x_root, event->xbutton.y_root); - nux::Geometry dash_geo = dash_controller_->GetInputWindowGeometry(); + nux::Geometry const& dash_geo = dash_controller_->GetInputWindowGeometry(); + + Window dash_xid = dash_controller_->window()->GetInputWindowId(); + Window top_xid = wm.GetTopWindowAbove(dash_xid); + nux::Geometry const& on_top_geo = wm.GetWindowGeometry(top_xid); - if (!dash_geo.IsInside(pt) && !DoesPointIntersectUnityGeos(pt)) + if (!dash_geo.IsInside(pt) && !DoesPointIntersectUnityGeos(pt) && !on_top_geo.IsInside(pt)) { dash_controller_->HideDash(false); } @@ -1524,9 +1556,13 @@ void UnityScreen::handleEvent(XEvent* event) if (hud_controller_->IsVisible()) { nux::Point pt(event->xbutton.x_root, event->xbutton.y_root); - nux::Geometry hud_geo = hud_controller_->GetInputWindowGeometry(); + nux::Geometry const& hud_geo = hud_controller_->GetInputWindowGeometry(); - if (!hud_geo.IsInside(pt) && !DoesPointIntersectUnityGeos(pt)) + Window hud_xid = hud_controller_->window()->GetInputWindowId(); + Window top_xid = wm.GetTopWindowAbove(hud_xid); + nux::Geometry const& on_top_geo = wm.GetWindowGeometry(top_xid); + + if (!hud_geo.IsInside(pt) && !DoesPointIntersectUnityGeos(pt) && !on_top_geo.IsInside(pt)) { hud_controller_->HideHud(false); } @@ -1550,7 +1586,7 @@ void UnityScreen::handleEvent(XEvent* event) } } } - else if (wm->IsScaleActive()) + else if (wm.IsScaleActive()) { ScaleScreen* ss = ScaleScreen::get(screen); if (CompWindow *w = screen->findWindow(ss->getSelectedWindow())) @@ -1650,11 +1686,11 @@ void UnityScreen::handleEvent(XEvent* event) case PropertyNotify: if (event->xproperty.atom == Atoms::mwmHints) { - PluginAdapter::Default ()->NotifyNewDecorationState(event->xproperty.window); + PluginAdapter::Default().NotifyNewDecorationState(event->xproperty.window); } break; case MapRequest: - ShowdesktopHandler::AllowLeaveShowdesktopMode (event->xmaprequest.window); + ShowdesktopHandler::AllowLeaveShowdesktopMode(event->xmaprequest.window); break; } @@ -1676,7 +1712,8 @@ void UnityScreen::handleCompizEvent(const char* plugin, const char* event, CompOption::Vector& option) { - PluginAdapter::Default()->NotifyCompizEvent(plugin, event, option); + PluginAdapter& adapter = PluginAdapter::Default(); + adapter.NotifyCompizEvent(plugin, event, option); compiz::CompizMinimizedWindowHandler<UnityScreen, UnityWindow>::handleCompizEvent (plugin, event, option); if (launcher_controller_->IsOverlayOpen() && g_strcmp0(event, "start_viewport_switch") == 0) @@ -1684,7 +1721,7 @@ void UnityScreen::handleCompizEvent(const char* plugin, ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST); } - if (PluginAdapter::Default()->IsScaleActive() && g_strcmp0(plugin, "scale") == 0 && + if (adapter.IsScaleActive() && g_strcmp0(plugin, "scale") == 0 && super_keypressed_) { scale_just_activated_ = true; @@ -1739,9 +1776,11 @@ bool UnityScreen::showLauncherKeyTerminate(CompAction* action, // hack...if the scale just wasn't activated AND the 'when' time is within time to start the // dash then assume was_tap is also true, since the ScalePlugin doesn't accept that state... - if (PluginAdapter::Default()->IsScaleActive() && !scale_just_activated_ && launcher_controller_->AboutToShowDash(true, when)) + PluginAdapter& adapter = PluginAdapter::Default(); + if (adapter.IsScaleActive() && !scale_just_activated_ && + launcher_controller_->AboutToShowDash(true, when)) { - PluginAdapter::Default()->TerminateScale(); + adapter.TerminateScale(); was_tap = true; } else if (scale_just_activated_) @@ -1816,9 +1855,10 @@ void UnityScreen::SendExecuteCommand() hud_controller_->HideHud(); } - if (PluginAdapter::Default()->IsScaleActive()) + PluginAdapter& adapter = PluginAdapter::Default(); + if (adapter.IsScaleActive()) { - PluginAdapter::Default()->TerminateScale(); + adapter.TerminateScale(); } ubus_manager_.SendMessage(UBUS_PLACE_ENTRY_ACTIVATE_REQUEST, @@ -1946,7 +1986,7 @@ bool UnityScreen::altTabForwardAllInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options) { - if (WindowManager::Default()->IsWallActive()) + if (WindowManager::Default().IsWallActive()) return false; else if (switcher_controller_->Visible()) switcher_controller_->Next(); @@ -2121,7 +2161,7 @@ void UnityScreen::RestoreWindow(GVariant* data) // Return input-focus to previously focused window (before key-nav-mode was // entered) if (preserve_focus) - PluginAdapter::Default ()->restoreInputFocus (); + PluginAdapter::Default().RestoreInputFocus (); } bool UnityScreen::SaveInputThenFocus(const guint xid) @@ -2131,7 +2171,7 @@ bool UnityScreen::SaveInputThenFocus(const guint xid) // check if currently focused window isn't it self if (xid != screen->activeWindow()) - PluginAdapter::Default()->saveInputFocus(); + PluginAdapter::Default().SaveInputFocus(); // set input-focus on window if (newFocusedWindow) @@ -2231,57 +2271,66 @@ bool UnityScreen::ShowHudTerminate(CompAction* action, bool UnityScreen::initPluginActions() { CompPlugin* p = CompPlugin::find("expo"); - + PluginAdapter& adapter = PluginAdapter::Default(); if (p) { - MultiActionList expoActions(0); + MultiActionList expoActions; - foreach(CompOption & option, p->vTable->getOptions()) + for (CompOption& option : p->vTable->getOptions()) { - if (option.name() == "expo_key" || - option.name() == "expo_button" || - option.name() == "expo_edge") + std::string const& option_name = option.name(); + + if (!expoActions.HasPrimary() && + (option_name == "expo_key" || + option_name == "expo_button" || + option_name == "expo_edge")) { CompAction* action = &option.value().action(); - expoActions.AddNewAction(action, false); - break; + expoActions.AddNewAction(option_name, action, true); + } + else if (option_name == "exit_button") + { + CompAction* action = &option.value().action(); + expoActions.AddNewAction(option_name, action, false); } } - PluginAdapter::Default()->SetExpoAction(expoActions); + adapter.SetExpoAction(expoActions); } p = CompPlugin::find("scale"); if (p) { - MultiActionList scaleActions(0); + MultiActionList scaleActions; - foreach(CompOption & option, p->vTable->getOptions()) + for (CompOption& option : p->vTable->getOptions()) { - if (option.name() == "initiate_all_key" || - option.name() == "initiate_all_edge" || - option.name() == "initiate_key" || - option.name() == "initiate_button" || - option.name() == "initiate_edge" || - option.name() == "initiate_group_key" || - option.name() == "initiate_group_button" || - option.name() == "initiate_group_edge" || - option.name() == "initiate_output_key" || - option.name() == "initiate_output_button" || - option.name() == "initiate_output_edge") + std::string const& option_name = option.name(); + + if (option_name == "initiate_all_key" || + option_name == "initiate_all_edge" || + option_name == "initiate_key" || + option_name == "initiate_button" || + option_name == "initiate_edge" || + option_name == "initiate_group_key" || + option_name == "initiate_group_button" || + option_name == "initiate_group_edge" || + option_name == "initiate_output_key" || + option_name == "initiate_output_button" || + option_name == "initiate_output_edge") { CompAction* action = &option.value().action(); - scaleActions.AddNewAction(action, false); + scaleActions.AddNewAction(option_name, action, false); } - else if (option.name() == "initiate_all_button") + else if (option_name == "initiate_all_button") { CompAction* action = &option.value().action(); - scaleActions.AddNewAction(action, true); + scaleActions.AddNewAction(option_name, action, true); } } - PluginAdapter::Default()->SetScaleAction(scaleActions); + adapter.SetScaleAction(scaleActions); } p = CompPlugin::find("unitymtgrabhandles"); @@ -2291,11 +2340,11 @@ bool UnityScreen::initPluginActions() foreach(CompOption & option, p->vTable->getOptions()) { if (option.name() == "show_handles_key") - PluginAdapter::Default()->SetShowHandlesAction(&option.value().action()); + adapter.SetShowHandlesAction(&option.value().action()); else if (option.name() == "hide_handles_key") - PluginAdapter::Default()->SetHideHandlesAction(&option.value().action()); + adapter.SetHideHandlesAction(&option.value().action()); else if (option.name() == "toggle_handles_key") - PluginAdapter::Default()->SetToggleHandlesAction(&option.value().action()); + adapter.SetToggleHandlesAction(&option.value().action()); } } @@ -2426,6 +2475,15 @@ bool UnityWindow::glPaint(const GLWindowPaintAttrib& attrib, } } + if (WindowManager::Default().IsScaleActive() && ScaleScreen::get(screen)->getSelectedWindow() == window->id()) + { + nux::Geometry scaled_geo = GetScaledGeometry(); + int inside_glow = scale::decoration::RADIUS/4; + scaled_geo.Expand(-inside_glow, -inside_glow); + glow::Quads const& quads = computeGlowQuads(scaled_geo, glow_texture_, scale::decoration::GLOW); + paintGlow(matrix, attrib, region, quads, glow_texture_, scale::decoration::GLOW_COLOR, mask); + } + return gWindow->glPaint(wAttrib, matrix, region, mask); } @@ -2448,7 +2506,7 @@ bool UnityWindow::glDraw(const GLMatrix& matrix, if (uScreen->doShellRepaint && !uScreen->paint_panel_ && window->type() == CompWindowTypeNormalMask) { guint32 id = window->id(); - bool maximized = WindowManager::Default()->IsWindowMaximized(id); + bool maximized = WindowManager::Default().IsWindowMaximized(id); bool on_current = window->onCurrentDesktop(); bool override_redirect = window->overrideRedirect(); bool managed = window->managed(); @@ -2492,7 +2550,6 @@ bool UnityWindow::glDraw(const GLMatrix& matrix, uScreen->paintPanelShadow(region); } - return ret; } @@ -2594,7 +2651,7 @@ UnityWindow::minimized () /* Called whenever a window is mapped, unmapped, minimized etc */ void UnityWindow::windowNotify(CompWindowNotify n) { - PluginAdapter::Default()->Notify(window, n); + PluginAdapter::Default().Notify(window, n); switch (n) { @@ -2695,7 +2752,7 @@ void UnityWindow::stateChangeNotify(unsigned int lastState) !(window->state () & CompWindowStateFullscreenMask)) UnityScreen::get (screen)->fullscreen_windows_.remove(window); - PluginAdapter::Default()->NotifyStateChange(window, window->state(), lastState); + PluginAdapter::Default().NotifyStateChange(window, window->state(), lastState); window->stateChangeNotify(lastState); } @@ -2715,13 +2772,13 @@ void UnityWindow::updateFrameRegion(CompRegion ®ion) void UnityWindow::moveNotify(int x, int y, bool immediate) { - PluginAdapter::Default()->NotifyMoved(window, x, y); + PluginAdapter::Default().NotifyMoved(window, x, y); window->moveNotify(x, y, immediate); } void UnityWindow::resizeNotify(int x, int y, int w, int h) { - PluginAdapter::Default()->NotifyResized(window, x, y, w, h); + PluginAdapter::Default().NotifyResized(window, x, y, w, h); window->resizeNotify(x, y, w, h); } @@ -2779,7 +2836,7 @@ CompPoint UnityWindow::tryNotIntersectUI(CompPoint& pos) bool UnityWindow::place(CompPoint& pos) { - bool was_maximized = PluginAdapter::Default ()->MaximizeIfBigEnough(window); + bool was_maximized = PluginAdapter::Default().MaximizeIfBigEnough(window); if (!was_maximized) { @@ -2921,12 +2978,12 @@ void UnityScreen::optionChanged(CompOption* opt, UnityshellOptions::Options num) BackgroundEffectHelper::blur_type = (unity::BlurType)optionGetDashBlurExperimental(); break; case UnityshellOptions::AutomaximizeValue: - PluginAdapter::Default()->SetCoverageAreaBeforeAutomaximize(optionGetAutomaximizeValue() / 100.0f); + PluginAdapter::Default().SetCoverageAreaBeforeAutomaximize(optionGetAutomaximizeValue() / 100.0f); break; case UnityshellOptions::AltTabTimeout: switcher_controller_->detail_on_timeout = optionGetAltTabTimeout(); case UnityshellOptions::AltTabBiasViewport: - PluginAdapter::Default()->bias_active_to_viewport = optionGetAltTabBiasViewport(); + PluginAdapter::Default().bias_active_to_viewport = optionGetAltTabBiasViewport(); break; case UnityshellOptions::DisableShowDesktop: switcher_controller_->SetShowDesktopDisabled(optionGetDisableShowDesktop()); @@ -3401,43 +3458,53 @@ void UnityScreen::InitGesturesSupport() GLTexture::List UnityWindow::close_normal_tex_; GLTexture::List UnityWindow::close_prelight_tex_; GLTexture::List UnityWindow::close_pressed_tex_; +GLTexture::List UnityWindow::glow_texture_; -namespace scale +struct UnityWindow::PixmapTexture { -namespace decoration -{ -const unsigned CLOSE_SIZE = 19; -const unsigned ITEMS_PADDING = 5; -const unsigned RADIUS = 8; -} -} + PixmapTexture(unsigned width, unsigned height) + : w_(width) + , h_(height) + , pixmap_(XCreatePixmap(screen->dpy(), screen->root(), w_, h_, 32)) + , texture_(GLTexture::bindPixmapToTexture(pixmap_, w_, h_, 32)) + {} + + ~PixmapTexture() + { + texture_.clear(); + + if (pixmap_) + XFreePixmap(screen->dpy(), pixmap_); + } + + unsigned w_; + unsigned h_; + Pixmap pixmap_; + GLTexture::List texture_; +}; struct UnityWindow::CairoContext { CairoContext(unsigned width, unsigned height) : w_(width) , h_(height) - , pixmap_(XCreatePixmap(screen->dpy(), screen->root(), w_, h_, 32)) - , texture_(GLTexture::bindPixmapToTexture(pixmap_, w_, h_, 32)) + , pixmap_texture_(std::make_shared<PixmapTexture>(w_, h_)) , surface_(nullptr) , cr_(nullptr) { - Screen *xscreen = ScreenOfDisplay(screen->dpy(), screen->screenNum()); - XRenderPictFormat* format = XRenderFindStandardFormat(screen->dpy(), PictStandardARGB32); - - if (texture_.empty()) - return; - - surface_ = cairo_xlib_surface_create_with_xrender_format(screen->dpy(), pixmap_, - xscreen, format, - width, height); - cr_ = cairo_create(surface_); - - // clear - cairo_save(cr_); - cairo_set_operator(cr_, CAIRO_OPERATOR_CLEAR); - cairo_paint(cr_); - cairo_restore(cr_); + Screen *xscreen = ScreenOfDisplay(screen->dpy(), screen->screenNum()); + XRenderPictFormat* format = XRenderFindStandardFormat(screen->dpy(), PictStandardARGB32); + surface_ = cairo_xlib_surface_create_with_xrender_format(screen->dpy(), + pixmap_texture_->pixmap_, + xscreen, format, + w_, h_); + cr_ = cairo_create(surface_); + + // clear + cairo_save(cr_); + cairo_set_operator(cr_, CAIRO_OPERATOR_CLEAR); + cairo_paint(cr_); + cairo_restore(cr_); } ~CairoContext() @@ -3447,15 +3514,11 @@ struct UnityWindow::CairoContext if (surface_) cairo_surface_destroy(surface_); - - if (pixmap_) - XFreePixmap(screen->dpy(), pixmap_); } unsigned w_; unsigned h_; - Pixmap pixmap_; - GLTexture::List texture_; + PixmapTexturePtr pixmap_texture_; cairo_surface_t* surface_; cairo_t *cr_; }; @@ -3511,22 +3574,23 @@ UnityWindow::UnityWindow(CompWindow* window) } } } - - WindowManager::Default()->initiate_spread.connect(sigc::mem_fun(this, &UnityWindow::OnInitiateSpread)); - WindowManager::Default()->terminate_spread.connect(sigc::mem_fun(this, &UnityWindow::OnTerminateSpread)); + WindowManager& wm = WindowManager::Default(); + wm.initiate_spread.connect(sigc::mem_fun(this, &UnityWindow::OnInitiateSpread)); + wm.terminate_spread.connect(sigc::mem_fun(this, &UnityWindow::OnTerminateSpread)); } + void UnityWindow::AddProperties(GVariantBuilder* builder) { Window xid = window->id(); auto const& swins = ScaleScreen::get(screen)->getWindows(); bool scaled = std::find(swins.begin(), swins.end(), ScaleWindow::get(window)) != swins.end(); - auto wm = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); variant::BuilderWrapper(builder) - .add(scaled ? GetScaledGeometry() : wm->GetWindowGeometry(xid)) + .add(scaled ? GetScaledGeometry() : wm.GetWindowGeometry(xid)) .add("xid", xid) - .add("title", wm->GetWindowName(xid)) + .add("title", wm.GetWindowName(xid)) .add("scaled", scaled) .add("scaled_close_x", close_button_geo_.x) .add("scaled_close_y", close_button_geo_.y) @@ -3540,8 +3604,12 @@ std::string UnityWindow::GetName() const } -void UnityWindow::DrawTexture(GLTexture::List const& textures, GLWindowPaintAttrib const& attrib, - GLMatrix const& transform, unsigned int mask, int x, int y, double scale) +void UnityWindow::DrawTexture(GLTexture::List const& textures, + GLWindowPaintAttrib const& attrib, + GLMatrix const& transform, + unsigned int mask, + int x, int y, + double scale) { for (auto const& texture : textures) { @@ -3615,7 +3683,7 @@ void UnityWindow::RenderText(CairoContext const& context, int x, int y, int widt pango_cairo_context_set_resolution(pango_ctx, dpi / static_cast<float>(PANGO_SCALE)); pango_layout_context_changed(layout); - decoration_title_ = WindowManager::Default()->GetWindowName(window->id()); + decoration_title_ = WindowManager::Default().GetWindowName(window->id()); pango_layout_set_height(layout, height); pango_layout_set_width(layout, -1); //avoid wrap lines pango_layout_set_auto_dir(layout, false); @@ -3671,16 +3739,16 @@ void UnityWindow::RenderText(CairoContext const& context, int x, int y, int widt void UnityWindow::BuildDecorationTexture() { - if (!decoration_tex_.empty()) + if (decoration_tex_) return; auto const& border_extents = window->border(); - if (WindowManager::Default()->IsWindowDecorated(window->id()) && border_extents.top > 0) + if (WindowManager::Default().IsWindowDecorated(window->id()) && border_extents.top > 0) { - CairoContext context(window->borderRect().width(), border_extents.top); + CairoContext context(window->borderRect().width(), window->border().top); RenderDecoration(context); - decoration_tex_ = context.texture_; + decoration_tex_ = context.pixmap_texture_; } } @@ -3689,10 +3757,10 @@ void UnityWindow::LoadCloseIcon(panel::WindowState state, GLTexture::List& textu if (!texture.empty()) return; + CompString plugin("unityshell"); auto& style = panel::Style::Instance(); auto const& files = style.GetWindowButtonFileNames(panel::WindowButtonType::CLOSE, state); - CompString plugin("unityshell"); for (std::string const& file : files) { CompString file_name = file; @@ -3721,6 +3789,12 @@ void UnityWindow::SetupSharedTextures() LoadCloseIcon(panel::WindowState::NORMAL, close_normal_tex_); LoadCloseIcon(panel::WindowState::PRELIGHT, close_prelight_tex_); LoadCloseIcon(panel::WindowState::PRESSED, close_pressed_tex_); + + if (glow_texture_.empty()) + { + CompSize size(texture::GLOW_SIZE, texture::GLOW_SIZE); + glow_texture_ = GLTexture::imageDataToTexture(texture::GLOW, size, GL_RGBA, GL_UNSIGNED_BYTE); + } } void UnityWindow::CleanupSharedTextures() @@ -3728,12 +3802,13 @@ void UnityWindow::CleanupSharedTextures() close_normal_tex_.clear(); close_prelight_tex_.clear(); close_pressed_tex_.clear(); + glow_texture_.clear(); } void UnityWindow::CleanupCachedTextures() { - decoration_tex_.clear(); - decoration_selected_tex_.clear(); + decoration_tex_.reset(); + decoration_selected_tex_.reset(); decoration_title_.clear(); } @@ -3742,7 +3817,7 @@ void UnityWindow::scalePaintDecoration(GLWindowPaintAttrib const& attrib, CompRegion const& region, unsigned int mask) { - ScaleWindow *scale_win = ScaleWindow::get(window); + ScaleWindow* scale_win = ScaleWindow::get(window); scale_win->scalePaintDecoration(attrib, transform, region, mask); if (!scale_win->hasSlot()) // animation not finished @@ -3766,39 +3841,48 @@ void UnityWindow::scalePaintDecoration(GLWindowPaintAttrib const& attrib, if (!highlighted) { BuildDecorationTexture(); - DrawTexture(decoration_tex_, attrib, transform, mask, x, y, pos.scale); + + if (decoration_tex_) + DrawTexture(decoration_tex_->texture_, attrib, transform, mask, x, y, pos.scale); + close_button_geo_.Set(0, 0, 0, 0); } else { auto const& decoration_extents = window->border(); - int width = scaled_geo.width; - int height = decoration_extents.top; + unsigned width = scaled_geo.width; + unsigned height = decoration_extents.top; bool redraw_decoration = true; - if (!decoration_selected_tex_.empty()) + if (decoration_selected_tex_) { - GLTexture* texture = decoration_selected_tex_.front(); - - if (texture->width() == width && texture->height() == height) + if (decoration_selected_tex_->w_ == width && decoration_selected_tex_->h_ == height) { - if (decoration_title_ == WindowManager::Default()->GetWindowName(window->id())) + if (decoration_title_ == WindowManager::Default().GetWindowName(window->id())) redraw_decoration = false; } } if (redraw_decoration) { - CairoContext context(width, height); - RenderDecoration(context, pos.scale); + if (width != 0 && height != 0) + { + CairoContext context(width, height); + RenderDecoration(context, pos.scale); - // Draw window title - int text_x = scale::decoration::ITEMS_PADDING * 2 + scale::decoration::CLOSE_SIZE; - RenderText(context, text_x, 0.0, width - scale::decoration::ITEMS_PADDING, height); - decoration_selected_tex_ = context.texture_; + // Draw window title + int text_x = scale::decoration::ITEMS_PADDING * 2 + scale::decoration::CLOSE_SIZE; + RenderText(context, text_x, 0.0, width - scale::decoration::ITEMS_PADDING, height); + decoration_selected_tex_ = context.pixmap_texture_; + } + else + { + decoration_selected_tex_.reset(); + } } - DrawTexture(decoration_selected_tex_, attrib, transform, mask, x, y); + if (decoration_selected_tex_) + DrawTexture(decoration_selected_tex_->texture_, attrib, transform, mask, x, y); x += scale::decoration::ITEMS_PADDING; y += (height - scale::decoration::CLOSE_SIZE) / 2.0f; @@ -3825,7 +3909,7 @@ void UnityWindow::scalePaintDecoration(GLWindowPaintAttrib const& attrib, nux::Geometry UnityWindow::GetScaledGeometry() { - ScaleWindow *scale_win = ScaleWindow::get(window); + ScaleWindow* scale_win = ScaleWindow::get(window); ScalePosition const& pos = scale_win->getCurrentPosition(); auto const& border_rect = window->borderRect(); @@ -3845,20 +3929,20 @@ void UnityWindow::OnInitiateSpread() middle_clicked_ = false; SetupSharedTextures(); - WindowManager *wm = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); Window xid = window->id(); - if (wm->IsWindowDecorated(xid)) - wm->Decorate(xid); + if (wm.IsWindowDecorated(xid)) + wm.Decorate(xid); } void UnityWindow::OnTerminateSpread() { - WindowManager *wm = WindowManager::Default(); + WindowManager& wm = WindowManager::Default(); Window xid = window->id(); - if (wm->IsWindowDecorated(xid) && wm->IsWindowMaximized(xid)) - wm->Undecorate(xid); + if (wm.IsWindowDecorated(xid) && wm.IsWindowMaximized(xid)) + wm.Undecorate(xid); CleanupCachedTextures(); } @@ -3886,9 +3970,10 @@ UnityWindow::~UnityWindow() if (window->state () & CompWindowStateFullscreenMask) UnityScreen::get (screen)->fullscreen_windows_.remove(window); - PluginAdapter::Default ()->OnWindowClosed(window); + PluginAdapter::Default().OnWindowClosed(window); } + /* vtable init */ bool UnityPluginVTable::init() { diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h index bbb07d5c9..506888535 100644 --- a/plugins/unityshell/src/unityshell.h +++ b/plugins/unityshell/src/unityshell.h @@ -64,6 +64,8 @@ #include "HudController.h" #include "WindowMinimizeSpeedController.h" +#include "unityshell_glow.h" + namespace unity { @@ -407,6 +409,8 @@ protected: private: typedef compiz::CompizMinimizedWindowHandler<UnityScreen, UnityWindow> UnityMinimizedHandler; + struct PixmapTexture; + typedef std::shared_ptr<PixmapTexture> PixmapTexturePtr; struct CairoContext; void DoEnableFocus (); @@ -445,7 +449,11 @@ private: void RenderDecoration(CairoContext const&, double aspect = 1.0f); void RenderText(CairoContext const&, int x, int y, int width, int height); void DrawTexture(GLTexture::List const& textures, GLWindowPaintAttrib const&, - GLMatrix const&, unsigned mask, int x, int y, double scale = 1.0f); + GLMatrix const&, unsigned mask, int x, int y, double aspect = 1.0f); + + glow::Quads computeGlowQuads(nux::Geometry const& geo, GLTexture::List const& texture, int glow_size); + void paintGlow(GLMatrix const&, GLWindowPaintAttrib const&, CompRegion const&, + glow::Quads const&, GLTexture::List const&, nux::Color const&, unsigned mask); void BuildDecorationTexture(); void CleanupCachedTextures(); @@ -461,8 +469,9 @@ private: static GLTexture::List close_normal_tex_; static GLTexture::List close_prelight_tex_; static GLTexture::List close_pressed_tex_; - GLTexture::List decoration_tex_; - GLTexture::List decoration_selected_tex_; + static GLTexture::List glow_texture_; + PixmapTexturePtr decoration_tex_; + PixmapTexturePtr decoration_selected_tex_; std::string decoration_title_; compiz::WindowInputRemoverLock::Weak input_remover_; panel::WindowState close_icon_state_; diff --git a/plugins/unityshell/src/unityshell_glow.cpp b/plugins/unityshell/src/unityshell_glow.cpp new file mode 100644 index 000000000..004ac54b0 --- /dev/null +++ b/plugins/unityshell/src/unityshell_glow.cpp @@ -0,0 +1,396 @@ +/** + * Copyright : (C) 2006-2012 by Patrick Niklaus, Roi Cohen, + * Danny Baumann, Sam Spilsbury + * Authors: Patrick Niklaus <patrick.niklaus@googlemail.com> + * Roi Cohen <roico.beryl@gmail.com> + * Danny Baumann <maniac@opencompositing.org> + * Sam Spilsbury <smspillaz@gmail.com> + * Marco Trevisan <marco.trevisan@canonical.com> + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + **/ + +#include <Nux/Nux.h> +#include "unityshell.h" +#include "glow_texture.h" +#include "unityshell_glow.h" + +namespace unity +{ + +/* + * UnityWindow::paintGlow + * + * Takes our glow texture, stretches the appropriate positions in the glow texture, + * adds those geometries (so plugins like wobby and deform this texture correctly) + * and then draws the glow texture with this geometry (plugins like wobbly and friends + * will automatically deform the texture based on our set geometry) + */ + +void +UnityWindow::paintGlow(GLMatrix const& transform, GLWindowPaintAttrib const& attrib, + CompRegion const& paintRegion, glow::Quads const& glow_quads, + GLTexture::List const& outline_texture, nux::Color const& color, + unsigned mask) +{ + GLushort colorData[4]; + colorData[0] = color.red * 0xffff; + colorData[1] = color.green * 0xffff; + colorData[2] = color.blue * 0xffff; + colorData[3] = color.alpha * 0xffff; + + gWindow->vertexBuffer()->begin (); + + /* There are 8 glow parts of the glow texture which we wish to paint + * separately with different transformations + */ + for (unsigned i = 0; i < unsigned(glow::QuadPos::LAST); ++i) + { + /* Using precalculated quads here */ + glow::Quads::Quad const& quad = glow_quads[static_cast<glow::QuadPos>(i)]; + CompRegion reg(quad.box); + + if (reg.boundingRect().x1() < reg.boundingRect().x2() && + reg.boundingRect().y1() < reg.boundingRect().y2()) + { + GLTexture::MatrixList matl; + reg = CompRegion(reg.boundingRect().x1(), reg.boundingRect().y1(), + reg.boundingRect().width(), reg.boundingRect().height()); + + matl.push_back(quad.matrix); + + /* Add color data for all 6 vertices of the quad */ + for (int n = 0; n < 6; n++) + gWindow->vertexBuffer()->addColors(1, colorData); + + gWindow->glAddGeometry(matl, reg, reg); + } + } + + if (gWindow->vertexBuffer()->end()) + { + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + /* we use PAINT_WINDOW_TRANSFORMED_MASK here to force + the usage of a good texture filter */ + for (GLTexture *tex : outline_texture) + { + mask |= PAINT_WINDOW_BLEND_MASK | PAINT_WINDOW_TRANSLUCENT_MASK | PAINT_WINDOW_TRANSFORMED_MASK; + gWindow->glDrawTexture(tex, transform, attrib, mask); + } + + glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + GLScreen::get(screen)->setTexEnvMode (GL_REPLACE); + } +} + +/* + * UnityWindow::computeGlowQuads + * + * This function computures the matrix transformation required for each + * part of the glow texture which we wish to stretch to some rectangular + * dimentions + * + * There are eight quads different parts of the texture which we wish to + * paint here, the 4 sides and four corners, eg: + * + * ------------------ + * | 1 | 4 | 6 | + * ------------- ------------------ + * | 1 | 4 | 6 | | | | | + * ------------- | | | | + * | 2 | n | 7 | -> | 2 | n | 7 | + * ------------- | | | | + * | 3 | 5 | 8 | | | | | + * ------------- ------------------ + * | 3 | 5 | 8 | + * ------------------ + * + * In this example here, 2, 4, 5 and 7 are stretched, and the matrices for + * each quad rect adjusted accordingly for it's size compared to the original + * texture size. + * + * When we are adjusting the matrices here, the initial size of each corner has + * a size of of "1.0f", so according to 2x2 matrix rules, + * while you will see here that matrix->xx is (1 / glowSize) + * where glowSize is the size the user specifies they want their glow to extend. + * (likewise, matrix->yy is adjusted similarly for corners and for top/bottom) + * + * matrix->x0 and matrix->y0 here are set to be the top left edge of the rect + * adjusted by the matrix scale factor (matrix->xx and matrix->yy) + * + */ +glow::Quads UnityWindow::computeGlowQuads(nux::Geometry const& geo, GLTexture::List const& texture, int glow_size) +{ + glow::Quads glow_quads; + + if (texture.empty()) + return glow_quads; + + int x1, x2, y1, y2; + int glow_offset; + GLTexture::Matrix const& matrix = texture.front()->matrix(); + + CompRect *box; + GLTexture::Matrix *quadMatrix; + + glow_offset = (glow_size * texture::GLOW_OFFSET / texture::GLOW_SIZE) + 1; + + /* Top left corner */ + box = &glow_quads[glow::QuadPos::TOPLEFT].box; + glow_quads[glow::QuadPos::TOPLEFT].matrix = matrix; + quadMatrix = &glow_quads[glow::QuadPos::TOPLEFT].matrix; + + /* Set the desired rect dimentions + * for the part of the glow we are painting */ + + x1 = geo.x - glow_size + glow_offset; + y1 = geo.y - glow_size + glow_offset; + + /* 2x2 Matrix here, adjust both x and y scale factors + * and the x and y position + * + * Scaling both parts of the texture in a positive direction + * here (left to right top to bottom) + * + * The base position (x0 and y0) here requires us to move backwards + * on the x and y dimentions by the calculated rect dimentions + * multiplied by the scale factors + */ + + quadMatrix->xx = 1.0f / glow_size; + quadMatrix->yy = 1.0f / glow_size; + quadMatrix->x0 = -(x1 * quadMatrix->xx); + quadMatrix->y0 = -(y1 * quadMatrix->yy); + + x2 = std::min<int>(geo.x + glow_offset, geo.x + (geo.width / 2)); + y2 = std::min<int>(geo.y + glow_offset, geo.y + (geo.height / 2)); + + box->setGeometry(x1, y1, x2 - x1, y2 - y1); + + /* Top right corner */ + box = &glow_quads[glow::QuadPos::TOPRIGHT].box; + glow_quads[glow::QuadPos::TOPRIGHT].matrix = matrix; + quadMatrix = &glow_quads[glow::QuadPos::TOPRIGHT].matrix; + + /* Set the desired rect dimentions + * for the part of the glow we are painting */ + + x1 = geo.x + geo.width - glow_offset; + y1 = geo.y - glow_size + glow_offset; + x2 = geo.x + geo.width + glow_size - glow_offset; + + /* + * 2x2 Matrix here, adjust both x and y scale factors + * and the x and y position + * + * Scaling the y part of the texture in a positive direction + * and the x part in a negative direction here + * (right to left top to bottom) + * + * The base position (x0 and y0) here requires us to move backwards + * on the y dimention and forwards on x by the calculated rect dimentions + * multiplied by the scale factors (since we are moving forward on x we + * need the inverse of that which is 1 - x1 * xx + */ + + quadMatrix->xx = -1.0f / glow_size; + quadMatrix->yy = 1.0f / glow_size; + quadMatrix->x0 = 1.0 - (x1 * quadMatrix->xx); + quadMatrix->y0 = -(y1 * quadMatrix->yy); + + x1 = std::max<int>(geo.x + geo.width - glow_offset, geo.x + (geo.width / 2)); + y2 = std::min<int>(geo.y + glow_offset, geo.y + (geo.height / 2)); + + box->setGeometry(x1, y1, x2 - x1, y2 - y1); + + /* Bottom left corner */ + box = &glow_quads[glow::QuadPos::BOTTOMLEFT].box; + glow_quads[glow::QuadPos::BOTTOMLEFT].matrix = matrix; + quadMatrix = &glow_quads[glow::QuadPos::BOTTOMLEFT].matrix; + + x1 = geo.x - glow_size + glow_offset; + y1 = geo.y + geo.height - glow_offset; + x2 = geo.x + glow_offset; + y2 = geo.y + geo.height + glow_size - glow_offset; + + /* 2x2 Matrix here, adjust both x and y scale factors + * and the x and y position + * + * Scaling the x part of the texture in a positive direction + * and the y part in a negative direction here + * (left to right bottom to top) + * + * The base position (x0 and y0) here requires us to move backwards + * on the x dimention and forwards on y by the calculated rect dimentions + * multiplied by the scale factors (since we are moving forward on x we + * need the inverse of that which is 1 - y1 * yy + */ + + quadMatrix->xx = 1.0f / glow_size; + quadMatrix->yy = -1.0f / glow_size; + quadMatrix->x0 = -(x1 * quadMatrix->xx); + quadMatrix->y0 = 1.0f - (y1 * quadMatrix->yy); + + y1 = std::max<int>(geo.y + geo.height - glow_offset, geo.y + (geo.height / 2)); + x2 = std::min<int>(geo.x + glow_offset, geo.x + (geo.width / 2)); + + box->setGeometry(x1, y1, x2 - x1, y2 - y1); + + /* Bottom right corner */ + box = &glow_quads[glow::QuadPos::BOTTOMRIGHT].box; + glow_quads[glow::QuadPos::BOTTOMRIGHT].matrix = matrix; + quadMatrix = &glow_quads[glow::QuadPos::BOTTOMRIGHT].matrix; + + x1 = geo.x + geo.width - glow_offset; + y1 = geo.y + geo.height - glow_offset; + x2 = geo.x + geo.width + glow_size - glow_offset; + y2 = geo.y + geo.height + glow_size - glow_offset; + + /* 2x2 Matrix here, adjust both x and y scale factors + * and the x and y position + * + * Scaling the both parts of the texture in a negative direction + * (right to left bottom to top) + * + * The base position (x0 and y0) here requires us to move forwards + * on both dimentions by the calculated rect dimentions + * multiplied by the scale factors + */ + + quadMatrix->xx = -1.0f / glow_size; + quadMatrix->yy = -1.0f / glow_size; + quadMatrix->x0 = 1.0 - (x1 * quadMatrix->xx); + quadMatrix->y0 = 1.0 - (y1 * quadMatrix->yy); + + x1 = std::max<int>(geo.x + geo.width - glow_offset, geo.x + (geo.width / 2)); + y1 = std::max<int>(geo.y + geo.height - glow_offset, geo.y + (geo.height / 2)); + + box->setGeometry(x1, y1, x2 - x1, y2 - y1); + + /* Top edge */ + box = &glow_quads[glow::QuadPos::TOP].box; + glow_quads[glow::QuadPos::TOP].matrix = matrix; + quadMatrix = &glow_quads[glow::QuadPos::TOP].matrix; + + x1 = geo.x + glow_offset; + y1 = geo.y - glow_size + glow_offset; + x2 = geo.x + geo.width - glow_offset; + y2 = geo.y + glow_offset; + + /* 2x2 Matrix here, adjust both x and y scale factors + * and the x and y position + * + * No need to scale the x part of the texture here, but we + * are scaling on the y part in a positive direciton + * + * The base position (y0) here requires us to move backwards + * on the x dimention and forwards on y by the calculated rect dimentions + * multiplied by the scale factors + */ + + quadMatrix->xx = 0.0f; + quadMatrix->yy = 1.0f / glow_size; + quadMatrix->x0 = 1.0; + quadMatrix->y0 = -(y1 * quadMatrix->yy); + + box->setGeometry(x1, y1, x2 - x1, y2 - y1); + + /* Bottom edge */ + box = &glow_quads[glow::QuadPos::BOTTOM].box; + glow_quads[glow::QuadPos::BOTTOM].matrix = matrix; + quadMatrix = &glow_quads[glow::QuadPos::BOTTOM].matrix; + + x1 = geo.x + glow_offset; + y1 = geo.y + geo.height - glow_offset; + x2 = geo.x + geo.width - glow_offset; + y2 = geo.y + geo.height + glow_size - glow_offset; + + /* 2x2 Matrix here, adjust both x and y scale factors + * and the x and y position + * + * No need to scale the x part of the texture here, but we + * are scaling on the y part in a negative direciton + * + * The base position (y0) here requires us to move forwards + * on y by the calculated rect dimentions + * multiplied by the scale factors + */ + + quadMatrix->xx = 0.0f; + quadMatrix->yy = -1.0f / glow_size; + quadMatrix->x0 = 1.0; + quadMatrix->y0 = 1.0 - (y1 * quadMatrix->yy); + + box->setGeometry(x1, y1, x2 - x1, y2 - y1); + + /* Left edge */ + box = &glow_quads[glow::QuadPos::LEFT].box; + glow_quads[glow::QuadPos::LEFT].matrix = matrix; + quadMatrix = &glow_quads[glow::QuadPos::LEFT].matrix; + + x1 = geo.x - glow_size + glow_offset; + y1 = geo.y + glow_offset; + x2 = geo.x + glow_offset; + y2 = geo.y + geo.height - glow_offset; + + /* 2x2 Matrix here, adjust both x and y scale factors + * and the x and y position + * + * No need to scale the y part of the texture here, but we + * are scaling on the x part in a positive direciton + * + * The base position (x0) here requires us to move backwards + * on x by the calculated rect dimentions + * multiplied by the scale factors + */ + + quadMatrix->xx = 1.0f / glow_size; + quadMatrix->yy = 0.0f; + quadMatrix->x0 = -(x1 * quadMatrix->xx); + quadMatrix->y0 = 1.0; + + box->setGeometry(x1, y1, x2 - x1, y2 - y1); + + /* Right edge */ + box = &glow_quads[glow::QuadPos::RIGHT].box; + glow_quads[glow::QuadPos::RIGHT].matrix = matrix; + quadMatrix = &glow_quads[glow::QuadPos::RIGHT].matrix; + + x1 = geo.x + geo.width - glow_offset; + y1 = geo.y + glow_offset; + x2 = geo.x + geo.width + glow_size - glow_offset; + y2 = geo.y + geo.height - glow_offset; + + /* 2x2 Matrix here, adjust both x and y scale factors + * and the x and y position + * + * No need to scale the y part of the texture here, but we + * are scaling on the x part in a negative direciton + * + * The base position (x0) here requires us to move forwards + * on x by the calculated rect dimentions + * multiplied by the scale factors + */ + + quadMatrix->xx = -1.0f / glow_size; + quadMatrix->yy = 0.0f; + quadMatrix->x0 = 1.0 - (x1 * quadMatrix->xx); + quadMatrix->y0 = 1.0; + + box->setGeometry(x1, y1, x2 - x1, y2 - y1); + + return glow_quads; +} + +} // Unity namespace diff --git a/plugins/unityshell/src/unityshell_glow.h b/plugins/unityshell/src/unityshell_glow.h new file mode 100644 index 000000000..b4ae79d1f --- /dev/null +++ b/plugins/unityshell/src/unityshell_glow.h @@ -0,0 +1,71 @@ +/** + * Copyright : (C) 2006-2012 by Patrick Niklaus, Roi Cohen, + * Danny Baumann, Sam Spilsbury + * Authors: Patrick Niklaus <patrick.niklaus@googlemail.com> + * Roi Cohen <roico.beryl@gmail.com> + * Danny Baumann <maniac@opencompositing.org> + * Sam Spilsbury <smspillaz@gmail.com> + * Marco Trevisan <marco.trevisan@canonical.com> + * + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + **/ + +#ifndef _UNITYSHELL_GLOW_H +#define _UNITYSHELL_GLOW_H + +#include <core/core.h> +#include <opengl/opengl.h> + +namespace unity +{ +namespace glow +{ + +enum class QuadPos +{ + TOPLEFT = 0, + TOPRIGHT, + BOTTOMLEFT, + BOTTOMRIGHT, + TOP, + BOTTOM, + LEFT, + RIGHT, + LAST +}; + +struct Quads +{ +/* Each glow quad contains a 2x2 scale + positional matrix + * (the 3rd column is not used since that is for matrix skew + * operations which we do not care about) + * and also a CompRect which describes the size and position of + * the quad on the glow + */ + struct Quad + { + CompRect box; + GLTexture::Matrix matrix; + }; + + Quad& operator[](QuadPos position) { return inner_vector_[unsigned(position)]; } + Quad const& operator[](QuadPos position) const { return inner_vector_[unsigned(position)]; } + +private: + Quad inner_vector_[unsigned(QuadPos::LAST)]; +}; + +} // namespace glow +} // namepsace unity + +#endif diff --git a/plugins/unityshell/unityshell.xml.in b/plugins/unityshell/unityshell.xml.in index abaa07cba..1d10b8768 100644 --- a/plugins/unityshell/unityshell.xml.in +++ b/plugins/unityshell/unityshell.xml.in @@ -79,6 +79,7 @@ <option name="show_launcher" type="key"> <_short>Key to show the launcher</_short> <_long>Make the launcher appear with that key</_long> + <tap_detection>false</tap_detection> <default><Super></default> </option> <option name="keyboard_focus" type="key"> |
