Merge lp:~3v1n0/unity/spread-app-windows into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 4034
Proposed branch: lp:~3v1n0/unity/spread-app-windows
Merge into: lp:unity
Diff against target: 223 lines (+78/-15)
5 files modified
plugins/unityshell/src/unityshell.cpp (+42/-8)
plugins/unityshell/src/unityshell.h (+3/-0)
plugins/unityshell/unityshell.xml.in (+12/-0)
shortcuts/CompizShortcutModeller.cpp (+19/-0)
unity-shared/GnomeKeyGrabber.cpp (+2/-7)
To merge this branch: bzr merge lp:~3v1n0/unity/spread-app-windows
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+275967@code.launchpad.net

Commit message

UnityScreen: add SpreadAppWindows option and trigger it on Super+Ctrl+[Shift]+W

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Andrea Azzarone (azzar1) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/unityshell/src/unityshell.cpp'
2--- plugins/unityshell/src/unityshell.cpp 2015-10-16 08:45:44 +0000
3+++ plugins/unityshell/src/unityshell.cpp 2015-10-28 09:25:56 +0000
4@@ -381,6 +381,8 @@
5 optionSetPanelFirstMenuInitiate(boost::bind(&UnityScreen::showPanelFirstMenuKeyInitiate, this, _1, _2, _3));
6 optionSetPanelFirstMenuTerminate(boost::bind(&UnityScreen::showPanelFirstMenuKeyTerminate, this, _1, _2, _3));
7 optionSetPanelFirstMenuNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
8+ optionSetSpreadAppWindowsInitiate(boost::bind(&UnityScreen::spreadAppWindowsInitiate, this, _1, _2, _3));
9+ optionSetSpreadAppWindowsAnywhereInitiate(boost::bind(&UnityScreen::spreadAppWindowsAnywhereInitiate, this, _1, _2, _3));
10 optionSetAutomaximizeValueNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
11 optionSetDashTapDurationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
12 optionSetAltTabTimeoutNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
13@@ -2106,7 +2108,7 @@
14 action->setState(action->state() | CompAction::StateTermKey);
15
16 super_keypressed_ = true;
17- int when = options[7].value().i(); // XEvent time in millisec
18+ int when = CompOption::getIntOptionNamed(options, "time");
19 launcher_controller_->HandleLauncherKeyPress(when);
20 EnsureSuperKeybindings ();
21
22@@ -2138,7 +2140,7 @@
23 bool was_tap = state & CompAction::StateTermTapped;
24 bool tap_handled = false;
25 LOG_DEBUG(logger) << "Super released: " << (was_tap ? "tapped" : "released");
26- int when = options[7].value().i(); // XEvent time in millisec
27+ int when = CompOption::getIntOptionNamed(options, "time");
28
29 // hack...if the scale just wasn't activated AND the 'when' time is within time to start the
30 // dash then assume was_tap is also true, since the ScalePlugin doesn't accept that state...
31@@ -2209,7 +2211,7 @@
32 /* In order to avoid too many events when keeping the keybinding pressed,
33 * that would make the unity-panel-service to go crazy (see bug #948522)
34 * we need to filter them, just considering an event every 750 ms */
35- int event_time = options[7].value().i(); // XEvent time in millisec
36+ int event_time = CompOption::getIntOptionNamed(options, "time");
37
38 if (event_time - first_menu_keypress_time_ < 750)
39 {
40@@ -2279,6 +2281,38 @@
41 return true;
42 }
43
44+void UnityScreen::SpreadAppWindows(bool anywhere)
45+{
46+ if (ApplicationPtr const& active_app = ApplicationManager::Default().GetActiveApplication())
47+ {
48+ std::vector<Window> windows;
49+
50+ for (auto& window : active_app->GetWindows())
51+ {
52+ if (anywhere || WM.IsWindowOnCurrentDesktop(window->window_id()))
53+ windows.push_back(window->window_id());
54+ }
55+
56+ WM.ScaleWindowGroup(windows, 0, true);
57+ }
58+}
59+
60+bool UnityScreen::spreadAppWindowsInitiate(CompAction* action,
61+ CompAction::State state,
62+ CompOption::Vector& options)
63+{
64+ SpreadAppWindows(false);
65+ return true;
66+}
67+
68+bool UnityScreen::spreadAppWindowsAnywhereInitiate(CompAction* action,
69+ CompAction::State state,
70+ CompOption::Vector& options)
71+{
72+ SpreadAppWindows(true);
73+ return true;
74+}
75+
76 bool UnityScreen::setKeyboardFocusKeyInitiate(CompAction* action,
77 CompAction::State state,
78 CompOption::Vector& options)
79@@ -2632,7 +2666,7 @@
80 // to receive the Terminate event
81 if (state & CompAction::StateInitKey)
82 action->setState(action->state() | CompAction::StateTermKey);
83- hud_keypress_time_ = options[7].value().i(); // XEvent time in millisec
84+ hud_keypress_time_ = CompOption::getIntOptionNamed(options, "time");
85
86 // pass key through
87 return false;
88@@ -2653,7 +2687,7 @@
89 if (!(state & CompAction::StateTermTapped))
90 return false;
91
92- int release_time = options[7].value().i(); // XEvent time in millisec
93+ int release_time = CompOption::getIntOptionNamed(options, "time");
94 int tap_duration = release_time - hud_keypress_time_;
95 if (tap_duration > local::ALT_TAP_DURATION)
96 {
97@@ -3886,9 +3920,9 @@
98 screen->removeAction(&action);
99
100 // We notify that super/alt have been released, to avoid to leave unity in inconsistent state
101- CompOption::Vector options(8);
102- options[7].setName("time", CompOption::TypeInt);
103- options[7].value().set<int>(screen->getCurrentTime());
104+ CompOption::Vector options(1);
105+ options.back().setName("time", CompOption::TypeInt);
106+ options.back().value().set<int>(screen->getCurrentTime());
107
108 showLauncherKeyTerminate(&optionGetShowLauncher(), CompAction::StateTermKey, options);
109 showMenuBarTerminate(&optionGetShowMenuBar(), CompAction::StateTermKey, options);
110
111=== modified file 'plugins/unityshell/src/unityshell.h'
112--- plugins/unityshell/src/unityshell.h 2015-05-12 13:10:07 +0000
113+++ plugins/unityshell/src/unityshell.h 2015-10-28 09:25:56 +0000
114@@ -185,6 +185,8 @@
115
116 bool executeCommand(CompAction* action, CompAction::State state, CompOption::Vector& options);
117 bool showDesktopKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
118+ bool spreadAppWindowsInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
119+ bool spreadAppWindowsAnywhereInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
120 bool setKeyboardFocusKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
121
122 bool altTabInitiateCommon(CompAction* action, switcher::ShowMode mode);
123@@ -318,6 +320,7 @@
124 void DamageBlurUpdateRegion(nux::Geometry const&);
125
126 void ShowFirstRunHints();
127+ void SpreadAppWindows(bool anywhere);
128
129 std::unique_ptr<na::TickSource> tick_source_;
130 std::unique_ptr<na::AnimationController> animation_controller_;
131
132=== modified file 'plugins/unityshell/unityshell.xml.in'
133--- plugins/unityshell/unityshell.xml.in 2015-05-12 13:09:57 +0000
134+++ plugins/unityshell/unityshell.xml.in 2015-10-28 09:25:56 +0000
135@@ -87,6 +87,18 @@
136 <default>&lt;Alt&gt;F10</default>
137 </option>
138
139+ <option name="spread_app_windows" type="key">
140+ <_short>Key to spread the current application windows</_short>
141+ <_long>Initiate the window Spread for the current application windows.</_long>
142+ <default>&lt;Control&gt;&lt;Super&gt;w</default>
143+ </option>
144+
145+ <option name="spread_app_windows_anywhere" type="key">
146+ <_short>Key to spread the current application windows in any workspace</_short>
147+ <_long>Initiate the window Spread for the current application windows, for the all the windows.</_long>
148+ <default>&lt;Control&gt;&lt;Super&gt;&lt;Shift&gt;w</default>
149+ </option>
150+
151 <option name="panel_opacity" type="float">
152 <_short>Panel Opacity</_short>
153 <_long>The opacity of the Panel background.</_long>
154
155=== modified file 'shortcuts/CompizShortcutModeller.cpp'
156--- shortcuts/CompizShortcutModeller.cpp 2014-09-10 17:19:16 +0000
157+++ shortcuts/CompizShortcutModeller.cpp 2015-10-28 09:25:56 +0000
158@@ -68,6 +68,8 @@
159 const std::string UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD = "launcher_switcher_forward";
160 const std::string UNITYSHELL_OPTION_SHOW_HUD = "show_hud";
161 const std::string UNITYSHELL_OPTION_PANEL_FIRST_MENU = "panel_first_menu";
162+ const std::string UNITYSHELL_OPTION_SPREAD_APP_WINDOWS = "spread_app_windows";
163+ const std::string UNITYSHELL_OPTION_SPREAD_APP_WINDOWS_ANYWHERE = "spread_app_windows_anywhere";
164 const std::string UNITYSHELL_OPTION_ALT_TAB_FORWARD = "alt_tab_forward";
165 const std::string UNITYSHELL_OPTION_ALT_TAB_FORWARD_ALL = "alt_tab_forward_all";
166 const std::string UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW = "alt_tab_next_window";
167@@ -316,6 +318,23 @@
168 }
169
170 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
171+ (ws_enabled ?
172+ _("Spreads all windows of the focused application in the current workspace.") :
173+ _("Spreads all windows of the focused application.")),
174+ shortcut::OptionType::COMPIZ_KEY,
175+ UNITYSHELL_PLUGIN_NAME,
176+ UNITYSHELL_OPTION_SPREAD_APP_WINDOWS));
177+
178+ if (ws_enabled)
179+ {
180+ hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
181+ _("Spreads all windows of the focused application in all the workspaces."),
182+ shortcut::OptionType::COMPIZ_KEY,
183+ UNITYSHELL_PLUGIN_NAME,
184+ UNITYSHELL_OPTION_SPREAD_APP_WINDOWS_ANYWHERE));
185+ }
186+
187+ hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
188 _("Minimises all windows."),
189 shortcut::OptionType::COMPIZ_KEY,
190 CORE_PLUGIN_NAME,
191
192=== modified file 'unity-shared/GnomeKeyGrabber.cpp'
193--- unity-shared/GnomeKeyGrabber.cpp 2015-10-01 03:52:09 +0000
194+++ unity-shared/GnomeKeyGrabber.cpp 2015-10-28 09:25:56 +0000
195@@ -64,11 +64,6 @@
196 std::string const DBUS_NAME = "com.canonical.Unity.Test.GnomeKeyGrabber";
197 }
198
199-namespace
200-{
201-inline int compiz_event_timestamp(CompOption::Vector& options) { return options[7].value().i(); }
202-}
203-
204 GnomeGrabber::Impl::Impl(bool test_mode)
205 : screen_(screen)
206 , shell_server_(test_mode ? testing::DBUS_NAME : shell::DBUS_NAME)
207@@ -224,7 +219,7 @@
208 action.setState(CompAction::StateInitKey);
209 action.setInitiate([this, action_id](CompAction* action, CompAction::State state, CompOption::Vector& options) {
210 LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\"";
211- ActivateDBusAction(*action, action_id, 0, compiz_event_timestamp(options));
212+ ActivateDBusAction(*action, action_id, 0, CompOption::getIntOptionNamed(options, "time"));
213 return true;
214 });
215 }
216@@ -239,7 +234,7 @@
217 if (state & CompAction::StateTermTapped)
218 {
219 LOG_DEBUG(logger) << "tapped \"" << key << "\"";
220- ActivateDBusAction(*action, action_id, 0, compiz_event_timestamp(options));
221+ ActivateDBusAction(*action, action_id, 0, CompOption::getIntOptionNamed(options, "time"));
222 return true;
223 }
224