Merge lp:~3v1n0/unity/switcher-no-inputwin-5.0 into lp:unity/5.0

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 2419
Proposed branch: lp:~3v1n0/unity/switcher-no-inputwin-5.0
Merge into: lp:unity/5.0
Diff against target: 574 lines (+185/-78)
11 files modified
plugins/unityshell/src/DashView.cpp (+14/-9)
plugins/unityshell/src/HudView.cpp (+13/-0)
plugins/unityshell/src/IconRenderer.cpp (+36/-10)
plugins/unityshell/src/SwitcherController.cpp (+7/-5)
plugins/unityshell/src/SwitcherController.h (+0/-1)
plugins/unityshell/src/SwitcherModel.h (+2/-2)
plugins/unityshell/src/WindowManager.h (+4/-0)
plugins/unityshell/src/unityshell.cpp (+86/-46)
plugins/unityshell/src/unityshell.h (+5/-5)
tests/autopilot/autopilot/tests/test_dash.py (+9/-0)
tests/autopilot/autopilot/tests/test_hud.py (+9/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/switcher-no-inputwin-5.0
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
Review via email: mp+160253@code.launchpad.net

Commit message

SwitcherController: use again the SwitcherView as non-input window

Otherwise it could only lead to focusing troubles.
Added utilities to manage the WindowManager default close-window keybinding and using
it in our views.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

Sweet, looks good to me!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'plugins/unityshell/resources/launcher_pip_large_ltr.png'
0Binary files plugins/unityshell/resources/launcher_pip_large_ltr.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/launcher_pip_large_ltr.png 2013-04-23 02:51:28 +0000 differ0Binary files plugins/unityshell/resources/launcher_pip_large_ltr.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/launcher_pip_large_ltr.png 2013-04-23 02:51:28 +0000 differ
=== added file 'plugins/unityshell/resources/launcher_pip_large_rtl.png'
1Binary files plugins/unityshell/resources/launcher_pip_large_rtl.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/launcher_pip_large_rtl.png 2013-04-23 02:51:28 +0000 differ1Binary files plugins/unityshell/resources/launcher_pip_large_rtl.png 1970-01-01 00:00:00 +0000 and plugins/unityshell/resources/launcher_pip_large_rtl.png 2013-04-23 02:51:28 +0000 differ
=== modified file 'plugins/unityshell/src/DashView.cpp'
--- plugins/unityshell/src/DashView.cpp 2012-06-28 08:49:20 +0000
+++ plugins/unityshell/src/DashView.cpp 2013-04-23 02:51:28 +0000
@@ -33,6 +33,7 @@
33#include "DashSettings.h"33#include "DashSettings.h"
34#include "UBusMessages.h"34#include "UBusMessages.h"
35#include "KeyboardUtil.h"35#include "KeyboardUtil.h"
36#include "WindowManager.h"
3637
37namespace unity38namespace unity
38{39{
@@ -494,7 +495,7 @@
494 });495 });
495496
496 // global search done is handled by the home lens, no need to connect to it497 // global search done is handled by the home lens, no need to connect to it
497 // BUT, we will special case global search finished coming from 498 // BUT, we will special case global search finished coming from
498 // the applications lens, because we want to be able to launch applications499 // the applications lens, because we want to be able to launch applications
499 // immediately without waiting for the search finished signal which will500 // immediately without waiting for the search finished signal which will
500 // be delayed by all the lenses we're searching501 // be delayed by all the lenses we're searching
@@ -808,6 +809,10 @@
808 unsigned long x11_key_code,809 unsigned long x11_key_code,
809 unsigned long special_keys_state)810 unsigned long special_keys_state)
810{811{
812 // Only care about states of Alt, Ctrl, Super, Shift, not the lock keys
813 special_keys_state &= (nux::NUX_STATE_ALT | nux::NUX_STATE_CTRL |
814 nux::NUX_STATE_SUPER | nux::NUX_STATE_SHIFT);
815
811 // Do what nux::View does, but if the event isn't a key navigation,816 // Do what nux::View does, but if the event isn't a key navigation,
812 // designate the text entry to process it.817 // designate the text entry to process it.
813818
@@ -841,15 +846,15 @@
841 // Not sure if Enter should be a navigation key846 // Not sure if Enter should be a navigation key
842 direction = KEY_NAV_ENTER;847 direction = KEY_NAV_ENTER;
843 break;848 break;
844 case NUX_VK_F4:
845 // Maybe we should not do it here, but it needs to be checked where
846 // we are able to know if alt is pressed.
847 if (special_keys_state & NUX_STATE_ALT)
848 {
849 ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST);
850 }
851 break;
852 default:849 default:
850 auto const& close_key = WindowManager::Default()->close_window_key();
851
852 if (close_key.first == special_keys_state && close_key.second == x11_key_code)
853 {
854 ubus_manager_.SendMessage(UBUS_PLACE_VIEW_CLOSE_REQUEST);
855 return nullptr;
856 }
857
853 direction = KEY_NAV_NONE;858 direction = KEY_NAV_NONE;
854 }859 }
855860
856861
=== modified file 'plugins/unityshell/src/HudView.cpp'
--- plugins/unityshell/src/HudView.cpp 2012-08-20 14:52:48 +0000
+++ plugins/unityshell/src/HudView.cpp 2013-04-23 02:51:28 +0000
@@ -29,6 +29,7 @@
2929
30#include "UBusMessages.h"30#include "UBusMessages.h"
31#include "DashStyle.h"31#include "DashStyle.h"
32#include "WindowManager.h"
3233
33namespace unity34namespace unity
34{35{
@@ -563,6 +564,10 @@
563 unsigned long x11_key_code,564 unsigned long x11_key_code,
564 unsigned long special_keys_state)565 unsigned long special_keys_state)
565{566{
567 // Only care about states of Alt, Ctrl, Super, Shift, not the lock keys
568 special_keys_state &= (nux::NUX_STATE_ALT | nux::NUX_STATE_CTRL |
569 nux::NUX_STATE_SUPER | nux::NUX_STATE_SHIFT);
570
566 nux::KeyNavDirection direction = nux::KEY_NAV_NONE;571 nux::KeyNavDirection direction = nux::KEY_NAV_NONE;
567 switch (x11_key_code)572 switch (x11_key_code)
568 {573 {
@@ -590,6 +595,14 @@
590 direction = nux::KEY_NAV_ENTER;595 direction = nux::KEY_NAV_ENTER;
591 break;596 break;
592 default:597 default:
598 auto const& close_key = WindowManager::Default()->close_window_key();
599
600 if (close_key.first == special_keys_state && close_key.second == x11_key_code)
601 {
602 ubus.SendMessage(UBUS_HUD_CLOSE_REQUEST);
603 return nullptr;
604 }
605
593 direction = nux::KEY_NAV_NONE;606 direction = nux::KEY_NAV_NONE;
594 break;607 break;
595 }608 }
596609
=== modified file 'plugins/unityshell/src/IconRenderer.cpp'
--- plugins/unityshell/src/IconRenderer.cpp 2012-10-17 17:46:12 +0000
+++ plugins/unityshell/src/IconRenderer.cpp 2013-04-23 02:51:28 +0000
@@ -188,6 +188,8 @@
188nux::BaseTexture* progress_bar_fill = 0;188nux::BaseTexture* progress_bar_fill = 0;
189nux::BaseTexture* pip_ltr = 0;189nux::BaseTexture* pip_ltr = 0;
190nux::BaseTexture* pip_rtl = 0;190nux::BaseTexture* pip_rtl = 0;
191nux::BaseTexture* large_pip_ltr = 0;
192nux::BaseTexture* large_pip_rtl = 0;
191nux::BaseTexture* arrow_ltr = 0;193nux::BaseTexture* arrow_ltr = 0;
192nux::BaseTexture* arrow_rtl = 0;194nux::BaseTexture* arrow_rtl = 0;
193nux::BaseTexture* arrow_empty_ltr = 0;195nux::BaseTexture* arrow_empty_ltr = 0;
@@ -871,8 +873,8 @@
871 if (running > 0)873 if (running > 0)
872 {874 {
873 int scale = 1;875 int scale = 1;
874
875 int markerX;876 int markerX;
877
876 if (pip_style == OUTSIDE_TILE)878 if (pip_style == OUTSIDE_TILE)
877 {879 {
878 markerX = geo.x;880 markerX = geo.x;
@@ -880,8 +882,7 @@
880 else882 else
881 {883 {
882 auto bounds = arg.icon->GetTransform(ui::IconTextureSource::TRANSFORM_TILE, monitor);884 auto bounds = arg.icon->GetTransform(ui::IconTextureSource::TRANSFORM_TILE, monitor);
883 markerX = bounds[0].x + 2;885 markerX = bounds[0].x + 1;
884 scale = 2;
885 }886 }
886887
887 nux::TexCoordXForm texxform;888 nux::TexCoordXForm texxform;
@@ -902,26 +903,47 @@
902903
903 if (!arg.running_on_viewport)904 if (!arg.running_on_viewport)
904 {905 {
906 scale = (pip_style == OUTSIDE_TILE) ? 1 : 2;
905 markers[0] = markerCenter;907 markers[0] = markerCenter;
906 texture = local::arrow_empty_ltr;908 texture = local::arrow_empty_ltr;
907 }909 }
908 else if (running == 1)910 else if (running == 1)
909 {911 {
912 scale = (pip_style == OUTSIDE_TILE) ? 1 : 2;
910 markers[0] = markerCenter;913 markers[0] = markerCenter;
911 texture = local::arrow_ltr;914 texture = local::arrow_ltr;
912 }915 }
913 else if (running == 2)916 else if (running == 2)
914 {917 {
915 markers[0] = markerCenter - 2 * scale;918 if (pip_style == OUTSIDE_TILE)
916 markers[1] = markerCenter + 2 * scale;919 {
917 texture = local::pip_ltr;920 texture = local::pip_ltr;
921 markers[0] = markerCenter - 2;
922 markers[1] = markerCenter + 2;
923 }
924 else
925 {
926 texture = local::large_pip_ltr;
927 markers[0] = markerCenter - 4;
928 markers[1] = markerCenter + 4;
929 }
918 }930 }
919 else931 else
920 {932 {
921 markers[0] = markerCenter - 4 * scale;933 if (pip_style == OUTSIDE_TILE)
922 markers[1] = markerCenter;934 {
923 markers[2] = markerCenter + 4 * scale;935 texture = local::pip_ltr;
924 texture = local::pip_ltr;936 markers[0] = markerCenter - 4;
937 markers[1] = markerCenter;
938 markers[2] = markerCenter + 4;
939 }
940 else
941 {
942 texture = local::large_pip_ltr;
943 markers[0] = markerCenter - 8;
944 markers[1] = markerCenter;
945 markers[2] = markerCenter + 8;
946 }
925 }947 }
926948
927949
@@ -1218,10 +1240,12 @@
1218 squircle_shine = load_texture(PKGDATADIR"/squircle_shine_54.png");1240 squircle_shine = load_texture(PKGDATADIR"/squircle_shine_54.png");
12191241
1220 pip_ltr = load_texture(PKGDATADIR"/launcher_pip_ltr.png");1242 pip_ltr = load_texture(PKGDATADIR"/launcher_pip_ltr.png");
1243 large_pip_ltr = load_texture(PKGDATADIR"/launcher_pip_large_ltr.png");
1221 arrow_ltr = load_texture(PKGDATADIR"/launcher_arrow_ltr.png");1244 arrow_ltr = load_texture(PKGDATADIR"/launcher_arrow_ltr.png");
1222 arrow_empty_ltr = load_texture(PKGDATADIR"/launcher_arrow_outline_ltr.png");1245 arrow_empty_ltr = load_texture(PKGDATADIR"/launcher_arrow_outline_ltr.png");
12231246
1224 pip_rtl = load_texture(PKGDATADIR"/launcher_pip_rtl.png");1247 pip_rtl = load_texture(PKGDATADIR"/launcher_pip_rtl.png");
1248 large_pip_rtl = load_texture(PKGDATADIR"/launcher_pip_large_rt.png");
1225 arrow_rtl = load_texture(PKGDATADIR"/launcher_arrow_rtl.png");1249 arrow_rtl = load_texture(PKGDATADIR"/launcher_arrow_rtl.png");
1226 arrow_empty_rtl = load_texture(PKGDATADIR"/launcher_arrow_outline_rtl.png");1250 arrow_empty_rtl = load_texture(PKGDATADIR"/launcher_arrow_outline_rtl.png");
12271251
@@ -1248,6 +1272,8 @@
1248 progress_bar_fill->UnReference();1272 progress_bar_fill->UnReference();
1249 pip_ltr->UnReference();1273 pip_ltr->UnReference();
1250 pip_rtl->UnReference();1274 pip_rtl->UnReference();
1275 large_pip_ltr->UnReference();
1276 large_pip_rtl->UnReference();
1251 arrow_ltr->UnReference();1277 arrow_ltr->UnReference();
1252 arrow_rtl->UnReference();1278 arrow_rtl->UnReference();
1253 arrow_empty_ltr->UnReference();1279 arrow_empty_ltr->UnReference();
12541280
=== modified file 'plugins/unityshell/src/SwitcherController.cpp'
--- plugins/unityshell/src/SwitcherController.cpp 2012-06-25 23:18:15 +0000
+++ plugins/unityshell/src/SwitcherController.cpp 2013-04-23 02:51:28 +0000
@@ -40,7 +40,7 @@
40}40}
4141
42Controller::Controller(unsigned int load_timeout)42Controller::Controller(unsigned int load_timeout)
43 : timeout_length(75)43 : timeout_length(50)
44 , detail_on_timeout(true)44 , detail_on_timeout(true)
45 , detail_timeout_length(500)45 , detail_timeout_length(500)
46 , initial_detail_timeout_length(1500)46 , initial_detail_timeout_length(1500)
@@ -91,12 +91,15 @@
91void Controller::Show(ShowMode show, SortMode sort, bool reverse,91void Controller::Show(ShowMode show, SortMode sort, bool reverse,
92 std::vector<AbstractLauncherIcon::Ptr> results)92 std::vector<AbstractLauncherIcon::Ptr> results)
93{93{
94 if (results.empty() || visible_)
95 return;
96
94 if (sort == SortMode::FOCUS_ORDER)97 if (sort == SortMode::FOCUS_ORDER)
95 {98 {
96 std::sort(results.begin(), results.end(), CompareSwitcherItemsPriority);99 std::sort(results.begin(), results.end(), CompareSwitcherItemsPriority);
97 }100 }
98101
99 model_.reset(new SwitcherModel(results));102 model_ = std::make_shared<SwitcherModel>(results);
100 AddChild(model_.get());103 AddChild(model_.get());
101 model_->selection_changed.connect(sigc::mem_fun(this, &Controller::OnModelSelectionChanged));104 model_->selection_changed.connect(sigc::mem_fun(this, &Controller::OnModelSelectionChanged));
102 model_->only_detail_on_viewport = (show == ShowMode::CURRENT_VIEWPORT);105 model_->only_detail_on_viewport = (show == ShowMode::CURRENT_VIEWPORT);
@@ -192,7 +195,8 @@
192195
193 ubus_manager_.SendMessage(UBUS_SWITCHER_START);196 ubus_manager_.SendMessage(UBUS_SWITCHER_START);
194197
195 if (view_window_) {198 if (view_window_)
199 {
196 view_window_->ShowWindow(true);200 view_window_->ShowWindow(true);
197 view_window_->PushToFront();201 view_window_->PushToFront();
198 view_window_->SetOpacity(1.0f);202 view_window_->SetOpacity(1.0f);
@@ -218,7 +222,6 @@
218 view_window_->SetLayout(main_layout_);222 view_window_->SetLayout(main_layout_);
219 view_window_->SetBackgroundColor(nux::Color(0x00000000));223 view_window_->SetBackgroundColor(nux::Color(0x00000000));
220 view_window_->SetGeometry(workarea_);224 view_window_->SetGeometry(workarea_);
221 view_window_->EnableInputWindow(true, "Switcher", false, false);
222 }225 }
223}226}
224227
@@ -303,7 +306,6 @@
303 view_window_->SetOpacity(0.0f);306 view_window_->SetOpacity(0.0f);
304 view_window_->ShowWindow(false);307 view_window_->ShowWindow(false);
305 view_window_->PushToBack();308 view_window_->PushToBack();
306 view_window_->EnableInputWindow(false);
307 }309 }
308310
309 if (show_timer_)311 if (show_timer_)
310312
=== modified file 'plugins/unityshell/src/SwitcherController.h'
--- plugins/unityshell/src/SwitcherController.h 2012-06-25 23:18:15 +0000
+++ plugins/unityshell/src/SwitcherController.h 2013-04-23 02:51:28 +0000
@@ -29,7 +29,6 @@
29#include "SwitcherView.h"29#include "SwitcherView.h"
30#include "UBusWrapper.h"30#include "UBusWrapper.h"
3131
32#include <boost/shared_ptr.hpp>
33#include <sigc++/sigc++.h>32#include <sigc++/sigc++.h>
3433
35#include <Nux/Nux.h>34#include <Nux/Nux.h>
3635
=== modified file 'plugins/unityshell/src/SwitcherModel.h'
--- plugins/unityshell/src/SwitcherModel.h 2012-08-15 18:26:01 +0000
+++ plugins/unityshell/src/SwitcherModel.h 2013-04-23 02:51:28 +0000
@@ -27,7 +27,7 @@
2727
28#include "Introspectable.h"28#include "Introspectable.h"
2929
30#include <boost/shared_ptr.hpp>30#include <memory>
31#include <sigc++/sigc++.h>31#include <sigc++/sigc++.h>
3232
33namespace unity33namespace unity
@@ -39,7 +39,7 @@
39{39{
4040
41public:41public:
42 typedef boost::shared_ptr<SwitcherModel> Ptr;42 typedef std::shared_ptr<SwitcherModel> Ptr;
4343
44 typedef std::vector<launcher::AbstractLauncherIcon::Ptr> Base;44 typedef std::vector<launcher::AbstractLauncherIcon::Ptr> Base;
45 typedef Base::iterator iterator;45 typedef Base::iterator iterator;
4646
=== modified file 'plugins/unityshell/src/WindowManager.h'
--- plugins/unityshell/src/WindowManager.h 2013-03-18 21:20:01 +0000
+++ plugins/unityshell/src/WindowManager.h 2013-04-23 02:51:28 +0000
@@ -20,6 +20,7 @@
20#define WINDOW_MANAGER_H20#define WINDOW_MANAGER_H
2121
22#include <Nux/Nux.h>22#include <Nux/Nux.h>
23#include <NuxCore/Property.h>
23#include <gdk/gdkx.h>24#include <gdk/gdkx.h>
24#include <core/core.h>25#include <core/core.h>
2526
@@ -110,6 +111,9 @@
110 virtual bool saveInputFocus() = 0;111 virtual bool saveInputFocus() = 0;
111 virtual bool restoreInputFocus() = 0;112 virtual bool restoreInputFocus() = 0;
112113
114 // Nux Modifiers, Nux Keycode (= X11 KeySym)
115 nux::Property<std::pair<unsigned, unsigned>> close_window_key;
116
113 // Signals117 // Signals
114 sigc::signal<void, guint32> window_mapped;118 sigc::signal<void, guint32> window_mapped;
115 sigc::signal<void, guint32> window_unmapped;119 sigc::signal<void, guint32> window_unmapped;
116120
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2013-04-04 18:37:52 +0000
+++ plugins/unityshell/src/unityshell.cpp 2013-04-23 02:51:28 +0000
@@ -351,12 +351,6 @@
351 ubus_manager_.RegisterInterest(UBUS_LAUNCHER_END_KEY_SWTICHER,351 ubus_manager_.RegisterInterest(UBUS_LAUNCHER_END_KEY_SWTICHER,
352 sigc::mem_fun(this, &UnityScreen::OnLauncherEndKeyNav));352 sigc::mem_fun(this, &UnityScreen::OnLauncherEndKeyNav));
353353
354 ubus_manager_.RegisterInterest(UBUS_SWITCHER_START,
355 sigc::mem_fun(this, &UnityScreen::OnSwitcherStart));
356
357 ubus_manager_.RegisterInterest(UBUS_SWITCHER_END,
358 sigc::mem_fun(this, &UnityScreen::OnSwitcherEnd));
359
360 g_idle_add_full (G_PRIORITY_DEFAULT, &UnityScreen::initPluginActions, this, NULL);354 g_idle_add_full (G_PRIORITY_DEFAULT, &UnityScreen::initPluginActions, this, NULL);
361 super_keypressed_ = false;355 super_keypressed_ = false;
362356
@@ -944,7 +938,7 @@
944 {938 {
945 /* Create a new keybinding for the Escape key and the current modifiers,939 /* Create a new keybinding for the Escape key and the current modifiers,
946 * compiz will take of the ref-counting of the repeated actions */940 * compiz will take of the ref-counting of the repeated actions */
947 KeyCode escape = XKeysymToKeycode(screen->dpy(), XStringToKeysym("Escape"));941 KeyCode escape = XKeysymToKeycode(screen->dpy(), XK_Escape);
948 CompAction::KeyBinding binding(escape, modifiers);942 CompAction::KeyBinding binding(escape, modifiers);
949943
950 CompActionPtr &escape_action = _escape_actions[target];944 CompActionPtr &escape_action = _escape_actions[target];
@@ -1604,6 +1598,16 @@
1604 break;1598 break;
1605 }1599 }
1606 }1600 }
1601 else if (switcher_controller_->Visible())
1602 {
1603 auto const& close_key = PluginAdapter::Default()->close_window_key();
1604
1605 if (key_sym == close_key.second && XModifiersToNux(event->xkey.state) == close_key.first)
1606 {
1607 switcher_controller_->Hide(false);
1608 skip_other_plugins = true;
1609 }
1610 }
16071611
1608 if (result > 0)1612 if (result > 0)
1609 {1613 {
@@ -1673,10 +1677,9 @@
1673 }1677 }
16741678
1675 if (!skip_other_plugins &&1679 if (!skip_other_plugins &&
1676 screen->otherGrabExist("deco", "move", "switcher", "resize", NULL) &&1680 screen->otherGrabExist("deco", "move", "switcher", "resize", "unity-switcher", nullptr))
1677 !switcher_controller_->Visible())
1678 {1681 {
1679 wt->ProcessForeignEvent(event, NULL);1682 wt->ProcessForeignEvent(event, nullptr);
1680 }1683 }
1681}1684}
16821685
@@ -2105,41 +2108,10 @@
21052108
2106void UnityScreen::OnLauncherEndKeyNav(GVariant* data)2109void UnityScreen::OnLauncherEndKeyNav(GVariant* data)
2107{2110{
2108 RestoreWindow(data);
2109}
2110
2111void UnityScreen::OnSwitcherStart(GVariant* data)
2112{
2113 if (switcher_controller_->Visible())
2114 {
2115 newFocusedWindow = screen->findWindow(switcher_controller_->GetSwitcherInputWindowId());
2116
2117 if (switcher_controller_->GetSwitcherInputWindowId() != screen->activeWindow())
2118 PluginAdapter::Default()->saveInputFocus();
2119
2120 if (newFocusedWindow)
2121 newFocusedWindow->moveInputFocusTo();
2122 }
2123}
2124
2125void UnityScreen::OnSwitcherEnd(GVariant* data)
2126{
2127 RestoreWindow(data);
2128}
2129
2130void UnityScreen::RestoreWindow(GVariant* data)
2131{
2132 bool preserve_focus = false;
2133
2134 if (data)
2135 {
2136 preserve_focus = g_variant_get_boolean(data);
2137 }
2138
2139 // Return input-focus to previously focused window (before key-nav-mode was2111 // Return input-focus to previously focused window (before key-nav-mode was
2140 // entered)2112 // entered)
2141 if (preserve_focus)2113 if (data && g_variant_get_boolean(data))
2142 PluginAdapter::Default ()->restoreInputFocus ();2114 PluginAdapter::Default()->restoreInputFocus();
2143}2115}
21442116
2145bool UnityScreen::ShowHud()2117bool UnityScreen::ShowHud()
@@ -2226,9 +2198,70 @@
2226 return ShowHud();2198 return ShowHud();
2227}2199}
22282200
2201unsigned UnityScreen::CompizModifiersToNux(unsigned input) const
2202{
2203 unsigned modifiers = 0;
2204
2205 if (input & CompAltMask)
2206 {
2207 input &= ~CompAltMask;
2208 input |= Mod1Mask;
2209 }
2210
2211 if (modifiers & CompSuperMask)
2212 {
2213 input &= ~CompSuperMask;
2214 input |= Mod4Mask;
2215 }
2216
2217 return XModifiersToNux(input);
2218}
2219
2220unsigned UnityScreen::XModifiersToNux(unsigned input) const
2221{
2222 unsigned modifiers = 0;
2223
2224 if (input & Mod1Mask)
2225 modifiers |= nux::KEY_MODIFIER_ALT;
2226
2227 if (input & ShiftMask)
2228 modifiers |= nux::KEY_MODIFIER_SHIFT;
2229
2230 if (input & ControlMask)
2231 modifiers |= nux::KEY_MODIFIER_CTRL;
2232
2233 if (input & Mod4Mask)
2234 modifiers |= nux::KEY_MODIFIER_SUPER;
2235
2236 return modifiers;
2237}
2238
2239void UnityScreen::UpdateCloseWindowKey(CompAction::KeyBinding const& keybind)
2240{
2241 KeySym keysym = XkbKeycodeToKeysym(screen->dpy(), keybind.keycode(), 0, 0);
2242 unsigned modifiers = CompizModifiersToNux(keybind.modifiers());
2243
2244 WindowManager::Default()->close_window_key = std::make_pair(modifiers, keysym);
2245}
2246
2229gboolean UnityScreen::initPluginActions(gpointer data)2247gboolean UnityScreen::initPluginActions(gpointer data)
2230{2248{
2231 CompPlugin* p = CompPlugin::find("expo");2249 CompPlugin* p = CompPlugin::find("core");
2250 auto self = static_cast<UnityScreen*>(data);
2251
2252 if (p)
2253 {
2254 for (CompOption& option : p->vTable->getOptions())
2255 {
2256 if (option.name() == "close_window_key")
2257 {
2258 self->UpdateCloseWindowKey(option.value().action().key());
2259 break;
2260 }
2261 }
2262 }
2263
2264 p = CompPlugin::find("expo");
22322265
2233 if (p)2266 if (p)
2234 {2267 {
@@ -2995,9 +3028,16 @@
2995 bool status = screen->setOptionForPlugin(plugin, name, v);3028 bool status = screen->setOptionForPlugin(plugin, name, v);
2996 if (status)3029 if (status)
2997 {3030 {
2998 if (strcmp(plugin, "core") == 0 && strcmp(name, "hsize") == 0)3031 if (strcmp(plugin, "core") == 0)
2999 {3032 {
3000 launcher_controller_->UpdateNumWorkspaces(screen->vpSize().width() * screen->vpSize().height());3033 if (strcmp(name, "hsize") == 0 || strcmp(name, "vsize") == 0)
3034 {
3035 launcher_controller_->UpdateNumWorkspaces(screen->vpSize().width() * screen->vpSize().height());
3036 }
3037 else if (strcmp(name, "close_window_key") == 0)
3038 {
3039 UpdateCloseWindowKey(v.action().key());
3040 }
3001 }3041 }
3002 }3042 }
3003 return status;3043 return status;
30043044
=== modified file 'plugins/unityshell/src/unityshell.h'
--- plugins/unityshell/src/unityshell.h 2013-04-04 18:18:50 +0000
+++ plugins/unityshell/src/unityshell.h 2013-04-23 02:51:28 +0000
@@ -232,15 +232,15 @@
232 void OnLauncherStartKeyNav(GVariant* data);232 void OnLauncherStartKeyNav(GVariant* data);
233 void OnLauncherEndKeyNav(GVariant* data);233 void OnLauncherEndKeyNav(GVariant* data);
234234
235 void OnSwitcherStart(GVariant* data);
236 void OnSwitcherEnd(GVariant* data);
237
238 void RestoreWindow(GVariant* data);
239
240 void InitHints();235 void InitHints();
241236
242 void OnPanelStyleChanged();237 void OnPanelStyleChanged();
243238
239 unsigned CompizModifiersToNux(unsigned input) const;
240 unsigned XModifiersToNux(unsigned input) const;
241
242 void UpdateCloseWindowKey(CompAction::KeyBinding const&);
243
244 dash::Settings dash_settings_;244 dash::Settings dash_settings_;
245 dash::Style dash_style_;245 dash::Style dash_style_;
246 panel::Style panel_style_;246 panel::Style panel_style_;
247247
=== modified file 'tests/autopilot/autopilot/tests/test_dash.py'
--- tests/autopilot/autopilot/tests/test_dash.py 2012-06-27 01:19:32 +0000
+++ tests/autopilot/autopilot/tests/test_dash.py 2013-04-23 02:51:28 +0000
@@ -60,6 +60,15 @@
60 self.keyboard.press_and_release("Alt+F4")60 self.keyboard.press_and_release("Alt+F4")
61 self.assertThat(self.dash.visible, Eventually(Equals(False)))61 self.assertThat(self.dash.visible, Eventually(Equals(False)))
6262
63 def test_alt_f4_close_dash_with_capslock_on(self):
64 """Dash must close on Alt+F4 even when the capslock is turned on."""
65 self.keyboard.press_and_release("Caps_Lock")
66 self.addCleanup(self.keyboard.press_and_release, "Caps_Lock")
67
68 self.dash.ensure_visible()
69 self.keyboard.press_and_release("Alt+F4")
70 self.assertThat(self.dash.visible, Eventually(Equals(False)))
71
63 def test_dash_closes_on_spread(self):72 def test_dash_closes_on_spread(self):
64 """This test shows that when the spread is initiated, the dash closes."""73 """This test shows that when the spread is initiated, the dash closes."""
65 self.dash.ensure_visible()74 self.dash.ensure_visible()
6675
=== modified file 'tests/autopilot/autopilot/tests/test_hud.py'
--- tests/autopilot/autopilot/tests/test_hud.py 2012-06-25 22:02:54 +0000
+++ tests/autopilot/autopilot/tests/test_hud.py 2013-04-23 02:51:28 +0000
@@ -266,6 +266,15 @@
266266
267 self.assertThat(self.hud.visible, Eventually(Equals(False)))267 self.assertThat(self.hud.visible, Eventually(Equals(False)))
268268
269 def test_alt_f4_close_hud_with_capslock_on(self):
270 """Hud must close on Alt+F4 even when the capslock is turned on."""
271 self.keyboard.press_and_release("Caps_Lock")
272 self.addCleanup(self.keyboard.press_and_release, "Caps_Lock")
273
274 self.hud.ensure_visible()
275 self.keyboard.press_and_release("Alt+F4")
276 self.assertThat(self.hud.visible, Eventually(Equals(False)))
277
269278
270class HudLauncherInteractionsTests(HudTestsBase):279class HudLauncherInteractionsTests(HudTestsBase):
271280

Subscribers

People subscribed via source and target branches