summaryrefslogtreecommitdiff
diff options
authorMarco Trevisan (TreviƱo) <mail@3v1n0.net>2013-02-04 19:15:24 +0000
committerTarmac <>2013-02-04 19:15:24 +0000
commitedc08ff481b13c001cc617340fdc65ea125c6db4 (patch)
tree2518a1881bd749af9c1eb261ed4677dc7db0b874
parentfbdc9691961332333fd686ec5d61aeb883e13580 (diff)
parent300cc9381ea3ebdbb511a1996cc53de6ffd2a1de (diff)
Hud/DashView: use the global window-close key combination to close the overlays.
Approved by Andrea Azzarone. (bzr r3121)
-rw-r--r--dash/DashView.cpp13
-rw-r--r--hud/HudView.cpp11
-rw-r--r--tests/autopilot/unity/tests/test_switcher.py8
3 files changed, 19 insertions, 13 deletions
diff --git a/dash/DashView.cpp b/dash/DashView.cpp
index 360ef81d8..7969354fa 100644
--- a/dash/DashView.cpp
+++ b/dash/DashView.cpp
@@ -38,6 +38,7 @@
#include "unity-shared/PanelStyle.h"
#include "unity-shared/UBusMessages.h"
#include "unity-shared/UnitySettings.h"
+#include "unity-shared/WindowManager.h"
namespace unity
{
@@ -1592,15 +1593,15 @@ nux::Area* DashView::FindKeyFocusArea(unsigned int key_symbol,
// Not sure if Enter should be a navigation key
direction = KEY_NAV_ENTER;
break;
- case NUX_VK_F4:
- // Maybe we should not do it here, but it needs to be checked where
- // we are able to know if alt is pressed.
- if (special_keys_state == NUX_STATE_ALT)
+ default:
+ auto const& close_key = WindowManager::Default().close_window_key();
+
+ if (close_key.first == special_keys_state && close_key.second == x11_key_code)
{
ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST);
+ return nullptr;
}
- break;
- default:
+
direction = KEY_NAV_NONE;
}
diff --git a/hud/HudView.cpp b/hud/HudView.cpp
index a5d91a571..e0c08c72a 100644
--- a/hud/HudView.cpp
+++ b/hud/HudView.cpp
@@ -32,6 +32,7 @@
#include "unity-shared/UBusMessages.h"
#include "unity-shared/DashStyle.h"
+#include "unity-shared/WindowManager.h"
namespace unity
{
@@ -648,13 +649,15 @@ nux::Area* View::FindKeyFocusArea(unsigned int event_type,
// Not sure if Enter should be a navigation key
direction = nux::KEY_NAV_ENTER;
break;
- case NUX_VK_F4:
- if (special_keys_state == nux::NUX_STATE_ALT)
+ default:
+ auto const& close_key = WindowManager::Default().close_window_key();
+
+ if (close_key.first == special_keys_state && close_key.second == x11_key_code)
{
ubus.SendMessage(UBUS_HUD_CLOSE_REQUEST);
+ return nullptr;
}
- break;
- default:
+
direction = nux::KEY_NAV_NONE;
break;
}
diff --git a/tests/autopilot/unity/tests/test_switcher.py b/tests/autopilot/unity/tests/test_switcher.py
index cdb78e2a1..7347052b3 100644
--- a/tests/autopilot/unity/tests/test_switcher.py
+++ b/tests/autopilot/unity/tests/test_switcher.py
@@ -233,15 +233,17 @@ class SwitcherTests(SwitcherTestCase):
self.addCleanup(self.switcher.terminate)
self.assertThat(self.switcher.controller.monitor, Eventually(Equals(monitor)))
- def test_switcher_alt_f4_is_disabled(self):
- """Tests that alt+f4 does not work while switcher is active."""
+ def test_alt_f4_closes_switcher(self):
+ """Tests that alt+f4 should close the switcher when active."""
win = self.start_app_window("Text Editor")
- self.switcher.initiate(SwitcherMode.DETAIL)
+ self.switcher.initiate()
self.addCleanup(self.switcher.terminate)
+ self.assertThat(self.switcher.visible, Eventually(Equals(True)))
self.keyboard.press_and_release("Alt+F4")
+ self.assertThat(self.switcher.visible, Eventually(Equals(False)))
# Need the sleep to allow the window time to close, for jenkins!
sleep(10)
self.assertProperty(win, is_valid=True)