Merge lp:~azzar1/unity/fix-939517 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Didier Roche-Tolomelli
Approved revision: no longer in the source branch.
Merged at revision: 2100
Proposed branch: lp:~azzar1/unity/fix-939517
Merge into: lp:unity
Diff against target: 130 lines (+51/-2)
7 files modified
plugins/unityshell/src/AbstractShortcutHint.h (+1/-0)
plugins/unityshell/src/MockShortcutHint.h (+1/-0)
plugins/unityshell/src/ShortcutHint.cpp (+29/-0)
plugins/unityshell/src/ShortcutHintPrivate.cpp (+9/-0)
plugins/unityshell/src/ShortcutHintPrivate.h (+1/-0)
plugins/unityshell/src/unityshell.cpp (+2/-2)
tests/test_shortcut_private.cpp (+8/-0)
To merge this branch: bzr merge lp:~azzar1/unity/fix-939517
Reviewer Review Type Date Requested Status
Mirco Müller (community) Approve
Review via email: mp+94947@code.launchpad.net

Commit message

= The Problem =

The shortcut overlay uses hardcoded value for switching ws.

= The Fix =

Add a new type of shortcut option COMPIZ_METAKEY_OPTION.

= Testing =

Added.

To post a comment you must log in.
Revision history for this message
Mirco Müller (macslow) wrote :

Code looks ok, unity compiles and runs, test is provided and passes... approved.

review: Approve
Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/429/console reported an error when processing this lp:~andyrock/unity/fix-939517 branch.
Not merging it.

Revision history for this message
Unity Merger (unity-merger) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/automerge-unity/450/console reported an error when processing this lp:~andyrock/unity/fix-939517 branch.
Not merging it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/AbstractShortcutHint.h'
2--- plugins/unityshell/src/AbstractShortcutHint.h 2011-12-19 22:02:10 +0000
3+++ plugins/unityshell/src/AbstractShortcutHint.h 2012-02-28 12:15:23 +0000
4@@ -33,6 +33,7 @@
5 enum OptionType
6 {
7 COMPIZ_KEY_OPTION = 0,
8+ COMPIZ_METAKEY_OPTION,
9 COMPIZ_MOUSE_OPTION,
10 HARDCODED_OPTION
11 /* GSETTINGS_OPTION,
12
13=== modified file 'plugins/unityshell/src/MockShortcutHint.h'
14--- plugins/unityshell/src/MockShortcutHint.h 2011-12-19 22:02:10 +0000
15+++ plugins/unityshell/src/MockShortcutHint.h 2012-02-28 12:15:23 +0000
16@@ -52,6 +52,7 @@
17 {
18 case COMPIZ_MOUSE_OPTION:
19 case COMPIZ_KEY_OPTION:
20+ case COMPIZ_METAKEY_OPTION:
21 value = arg1() + "-" + arg2();
22 shortkey = prefix() + value() + postfix();
23 return true;
24
25=== modified file 'plugins/unityshell/src/ShortcutHint.cpp'
26--- plugins/unityshell/src/ShortcutHint.cpp 2011-12-19 22:02:10 +0000
27+++ plugins/unityshell/src/ShortcutHint.cpp 2012-02-28 12:15:23 +0000
28@@ -118,6 +118,35 @@
29
30 break;
31 }
32+ case COMPIZ_METAKEY_OPTION:
33+ {
34+ // Arg1 = Plugin name
35+ // Arg2 = key Option name
36+ CompPlugin* p = CompPlugin::find(arg1().c_str());
37+
38+ if (!p)
39+ return false;
40+
41+ foreach (CompOption &opt, p->vTable->getOptions())
42+ {
43+ if (opt.name() == arg2())
44+ {
45+ std::string temp(impl::GetMetaKey(opt.value().action().keyToString()));
46+ temp = impl::FixShortcutFormat(temp);
47+ temp = impl::ProperCase(temp);
48+
49+ if (value() != temp)
50+ {
51+ value = temp;
52+ shortkey = prefix() + value() + postfix();
53+ }
54+
55+ return true;
56+ }
57+ }
58+
59+ break;
60+ }
61 case HARDCODED_OPTION:
62 if (value != arg1())
63 {
64
65=== modified file 'plugins/unityshell/src/ShortcutHintPrivate.cpp'
66--- plugins/unityshell/src/ShortcutHintPrivate.cpp 2012-02-18 11:47:22 +0000
67+++ plugins/unityshell/src/ShortcutHintPrivate.cpp 2012-02-28 12:15:23 +0000
68@@ -29,6 +29,15 @@
69 namespace impl
70 {
71
72+std::string GetMetaKey(std::string const& scut)
73+{
74+ size_t index = scut.find_last_of( ">");
75+ if (index >= 0)
76+ return std::string(scut.begin(), scut.begin() + index + 1);
77+ else
78+ return "";
79+}
80+
81 std::string FixShortcutFormat(std::string const& scut)
82 {
83 std::string ret(scut.begin(), scut.end() - 1);
84
85=== modified file 'plugins/unityshell/src/ShortcutHintPrivate.h'
86--- plugins/unityshell/src/ShortcutHintPrivate.h 2011-12-19 22:02:10 +0000
87+++ plugins/unityshell/src/ShortcutHintPrivate.h 2012-02-28 12:15:23 +0000
88@@ -28,6 +28,7 @@
89 namespace impl
90 {
91
92+std::string GetMetaKey(std::string const& scut);
93 std::string FixShortcutFormat(std::string const& scut);
94 std::string FixMouseShortcut(std::string const& scut);
95 std::string ProperCase(std::string const& str);
96
97=== modified file 'plugins/unityshell/src/unityshell.cpp'
98--- plugins/unityshell/src/unityshell.cpp 2012-02-28 08:29:22 +0000
99+++ plugins/unityshell/src/unityshell.cpp 2012-02-28 12:15:23 +0000
100@@ -2641,8 +2641,8 @@
101 // Workspaces
102 std::string const workspaces = _("Workspaces");
103 hints_.push_back(new shortcut::Hint(workspaces, "", "", _("Spread workspaces."), shortcut::COMPIZ_KEY_OPTION, "expo", "expo_key"));
104- hints_.push_back(new shortcut::Hint(workspaces, "", "", _("Switch workspaces."), shortcut::HARDCODED_OPTION, _("Control + Alt + Cursor Keys")));
105- hints_.push_back(new shortcut::Hint(workspaces, "", "", _("Move focused window to different workspace."), shortcut::HARDCODED_OPTION, _("Control + Alt + Shift + Cursor Keys")));
106+ hints_.push_back(new shortcut::Hint(workspaces, "", _(" + Cursor Keys"), _("Switch workspaces."), shortcut::COMPIZ_METAKEY_OPTION, "wall", "left_key"));
107+ hints_.push_back(new shortcut::Hint(workspaces, "", _(" + Cursor Keys"), _("Move focused window to different workspace."), shortcut::COMPIZ_METAKEY_OPTION, "wall", "left_window_key"));
108
109 // Windows
110 std::string const windows = _("Windows");
111
112=== modified file 'tests/test_shortcut_private.cpp'
113--- tests/test_shortcut_private.cpp 2011-12-19 22:15:05 +0000
114+++ tests/test_shortcut_private.cpp 2012-02-28 12:15:23 +0000
115@@ -68,7 +68,15 @@
116 EXPECT_EQ(FixMouseShortcut("Super<Button1>"), "Super<Left Mouse>");
117 EXPECT_EQ(FixMouseShortcut("Super<Button2>"), "Super<Middle Mouse>");
118 EXPECT_EQ(FixMouseShortcut("Super<Button3>"), "Super<Right Mouse>");
119+}
120
121+TEST(TestShortcutHintPrivate, TestGetMetaKey)
122+{
123+ EXPECT_EQ(GetMetaKey("<Super>"), "<Super>");
124+ EXPECT_EQ(GetMetaKey("<Super><Alt>"), "<Super><Alt>");
125+ EXPECT_EQ(GetMetaKey("<Super>A"), "<Super>");
126+ EXPECT_EQ(GetMetaKey("<Super><Alt>A"), "<Super><Alt>");
127+ EXPECT_EQ(GetMetaKey("ABC"), "");
128 }
129
130 } // anonymouse namespace