summaryrefslogtreecommitdiff
path: root/plugins
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2014-02-13 00:37:24 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2014-02-13 00:37:24 +0100
commitbaedf29c1bbbd2dbf986e8a3cce5ca73c5c72b74 (patch)
tree185d7f20eef923d63cb47b1c107e5034d70bbbde /plugins
parentb4091cde53defbdd94636b3176e1cb9c6794ce63 (diff)
parent20d39cf1b0f1c2d6d87507a1db77903028843419 (diff)
Merging with lp:~3v1n0/unity/menu-manager
(bzr r3566.5.391)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/unityshell/src/unityshell.cpp68
-rw-r--r--plugins/unityshell/src/unityshell.h7
-rw-r--r--plugins/unityshell/unityshell.xml.in8
3 files changed, 65 insertions, 18 deletions
diff --git a/plugins/unityshell/src/unityshell.cpp b/plugins/unityshell/src/unityshell.cpp
index bf3e055e7..c84b9b1e4 100644
--- a/plugins/unityshell/src/unityshell.cpp
+++ b/plugins/unityshell/src/unityshell.cpp
@@ -25,8 +25,9 @@
#include <Nux/BaseWindow.h>
#include <Nux/WindowCompositor.h>
-#include <UnityCore/ScopeProxyInterface.h>
+#include <UnityCore/DBusIndicators.h>
#include <UnityCore/GnomeSessionManager.h>
+#include <UnityCore/ScopeProxyInterface.h>
#include "CompizUtils.h"
#include "BaseWindowRaiserImp.h"
@@ -50,6 +51,7 @@
#include "launcher/XdndManagerImp.h"
#include "launcher/XdndStartStopNotifierImp.h"
#include "CompizShortcutModeller.h"
+#include "GnomeKeyGrabber.h"
#include "decorations/DecorationsDataPool.h"
#include "decorations/DecorationsManager.h"
@@ -122,7 +124,7 @@ inline nux::Geometry NuxGeometryFromCompRect(CompRect const& rect)
return nux::Geometry(rect.x(), rect.y(), rect.width(), rect.height());
}
-inline nux::Color NuxColorFromCompizColor(unsigned short * color)
+inline nux::Color NuxColorFromCompizColor(unsigned short* color)
{
return nux::Color(color[0]/65535.0f, color[1]/65535.0f, color[2]/65535.0f, color[3]/65535.0f);
}
@@ -147,6 +149,7 @@ UnityScreen::UnityScreen(CompScreen* screen)
, screen(screen)
, cScreen(CompositeScreen::get(screen))
, gScreen(GLScreen::get(screen))
+ , menus_(std::make_shared<menu::Manager>(std::make_shared<indicator::DBusIndicators>(), std::make_shared<key::GnomeGrabber>()))
, deco_manager_(std::make_shared<decoration::Manager>())
, debugger_(this)
, needsRelayout(false)
@@ -298,6 +301,8 @@ UnityScreen::UnityScreen(CompScreen* screen)
wt->Run(NULL);
uScreen = this;
+ optionSetShowMenuBarInitiate(boost::bind(&UnityScreen::showMenuBarInitiate, this, _1, _2, _3));
+ optionSetShowMenuBarTerminate(boost::bind(&UnityScreen::showMenuBarTerminate, this, _1, _2, _3));
optionSetLockScreenInitiate(boost::bind(&UnityScreen::LockScreenInitiate, this, _1, _2, _3));
optionSetOverrideDecorationThemeNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
optionSetShadowXOffsetNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
@@ -1930,6 +1935,32 @@ void UnityScreen::handleCompizEvent(const char* plugin,
screen->handleCompizEvent(plugin, event, option);
}
+bool UnityScreen::showMenuBarInitiate(CompAction* action,
+ CompAction::State state,
+ CompOption::Vector& options)
+{
+ if (state & CompAction::StateInitKey)
+ {
+ action->setState(action->state() | CompAction::StateTermKey);
+ menus_->show_menus = true;
+ }
+
+ return false;
+}
+
+bool UnityScreen::showMenuBarTerminate(CompAction* action,
+ CompAction::State state,
+ CompOption::Vector& options)
+{
+ if (state & CompAction::StateTermKey)
+ {
+ action->setState(action->state() & ~CompAction::StateTermKey);
+ menus_->show_menus = false;
+ }
+
+ return false;
+}
+
bool UnityScreen::showLauncherKeyInitiate(CompAction* action,
CompAction::State state,
CompOption::Vector& options)
@@ -2033,7 +2064,7 @@ bool UnityScreen::showPanelFirstMenuKeyInitiate(CompAction* action,
* the menus entries after that a menu has been shown and hidden via the
* keyboard and the Alt key is still pressed */
action->setState(action->state() | CompAction::StateTermKey);
- panel_controller_->FirstMenuShow();
+ menus_->open_first.emit();
return true;
}
@@ -3324,15 +3355,19 @@ void UnityScreen::optionChanged(CompOption* opt, UnityshellOptions::Options num)
panel_controller_->SetOpacityMaximizedToggle(optionGetPanelOpacityMaximizedToggle());
break;
case UnityshellOptions::MenusFadein:
+ menus_->fadein = optionGetMenusFadein();
+ break;
case UnityshellOptions::MenusFadeout:
+ menus_->fadeout = optionGetMenusFadeout();
+ break;
case UnityshellOptions::MenusDiscoveryFadein:
+ menus_->discovery_fadein = optionGetMenusDiscoveryFadein();
+ break;
case UnityshellOptions::MenusDiscoveryFadeout:
+ menus_->discovery_fadeout = optionGetMenusDiscoveryFadeout();
+ break;
case UnityshellOptions::MenusDiscoveryDuration:
- panel_controller_->SetMenuShowTimings(optionGetMenusFadein(),
- optionGetMenusFadeout(),
- optionGetMenusDiscoveryDuration(),
- optionGetMenusDiscoveryFadein(),
- optionGetMenusDiscoveryFadeout());
+ menus_->discovery = optionGetMenusDiscoveryDuration();
break;
case UnityshellOptions::LauncherOpacity:
launcher_options->background_alpha = optionGetLauncherOpacity();
@@ -3525,13 +3560,8 @@ void UnityScreen::initLauncher()
/* Setup panel */
timer.Reset();
- panel_controller_ = std::make_shared<panel::Controller>(edge_barriers);
+ panel_controller_ = std::make_shared<panel::Controller>(menus_, edge_barriers);
AddChild(panel_controller_.get());
- panel_controller_->SetMenuShowTimings(optionGetMenusFadein(),
- optionGetMenusFadeout(),
- optionGetMenusDiscoveryDuration(),
- optionGetMenusDiscoveryFadein(),
- optionGetMenusDiscoveryFadeout());
LOG_INFO(logger) << "initLauncher-Panel " << timer.ElapsedSeconds() << "s";
/* Setup Places */
@@ -3609,17 +3639,21 @@ void UnityScreen::InitGesturesSupport()
gestures_sub_windows_->Activate();
}
+CompAction::Vector& UnityScreen::getActions()
+{
+ return menus_->KeyGrabber()->GetActions();
+}
+
/* Window init */
namespace
{
-bool WindowHasInconsistentShapeRects (Display *d,
- Window w)
+bool WindowHasInconsistentShapeRects(Display *d, Window w)
{
int n;
Atom *atoms = XListProperties(d, w, &n);
- Atom unity_shape_rects_atom = XInternAtom (d, "_UNITY_SAVED_WINDOW_SHAPE", FALSE);
bool has_inconsistent_shape = false;
+ static Atom unity_shape_rects_atom = XInternAtom(d, "_UNITY_SAVED_WINDOW_SHAPE", False);
for (int i = 0; i < n; ++i)
if (atoms[i] == unity_shape_rects_atom)
diff --git a/plugins/unityshell/src/unityshell.h b/plugins/unityshell/src/unityshell.h
index 78ed59b73..bbb94ece4 100644
--- a/plugins/unityshell/src/unityshell.h
+++ b/plugins/unityshell/src/unityshell.h
@@ -69,6 +69,7 @@
#include "UnityshellPrivate.h"
#include "UnityShowdesktopHandler.h"
#include "ThumbnailGenerator.h"
+#include "MenuManager.h"
#include "compizminimizedwindowhandler.h"
#include "BGHash.h"
@@ -106,6 +107,7 @@ class UnityScreen :
public GLScreenInterface,
public BaseSwitchScreen,
public PluginClassHandler <UnityScreen, CompScreen>,
+ public CompAction::Container,
public UnityshellOptions
{
public:
@@ -165,6 +167,8 @@ public:
void enterShowDesktopMode ();
void leaveShowDesktopMode (CompWindow *w);
+ bool showMenuBarInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
+ bool showMenuBarTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options);
bool showLauncherKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
bool showLauncherKeyTerminate(CompAction* action, CompAction::State state, CompOption::Vector& options);
bool showPanelFirstMenuKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
@@ -225,6 +229,8 @@ public:
ui::LayoutWindow::Ptr GetSwitcherDetailLayoutWindow(Window window) const;
+ CompAction::Vector& getActions();
+
protected:
std::string GetName() const;
void AddProperties(debug::IntrospectionData&);
@@ -307,6 +313,7 @@ private:
/* The window thread should be the last thing removed, as c++ does it in reverse order */
std::unique_ptr<nux::WindowThread> wt;
+ menu::Manager::Ptr menus_;
std::shared_ptr<decoration::Manager> deco_manager_;
/* These must stay below the window thread, please keep the order */
diff --git a/plugins/unityshell/unityshell.xml.in b/plugins/unityshell/unityshell.xml.in
index 592468e44..ac484f319 100644
--- a/plugins/unityshell/unityshell.xml.in
+++ b/plugins/unityshell/unityshell.xml.in
@@ -50,6 +50,12 @@
<group>
<_short>General</_short>
+ <option name="show_menu_bar" type="key">
+ <_short>Key to show the menu bar while pressed</_short>
+ <_long>Reveals the global menu bar while pressed.</_long>
+ <default>&lt;Alt&gt;</default>
+ </option>
+
<option name="lock_screen" type="key">
<_short>Key to lock the screen.</_short>
<_long>Pressing this key will lock the current session.</_long>
@@ -57,7 +63,7 @@
</option>
<option name="show_hud" type="key">
- <_short>Key to show the HUD</_short>
+ <_short>Key to show the HUD when tapped</_short>
<_long>A tap on this key summons the HUD.</_long>
<default>&lt;Alt&gt;</default>
</option>