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
=== modified file 'plugins/unityshell/src/unityshell.cpp'
--- plugins/unityshell/src/unityshell.cpp 2015-10-16 08:45:44 +0000
+++ plugins/unityshell/src/unityshell.cpp 2015-10-28 09:25:56 +0000
@@ -381,6 +381,8 @@
381 optionSetPanelFirstMenuInitiate(boost::bind(&UnityScreen::showPanelFirstMenuKeyInitiate, this, _1, _2, _3));381 optionSetPanelFirstMenuInitiate(boost::bind(&UnityScreen::showPanelFirstMenuKeyInitiate, this, _1, _2, _3));
382 optionSetPanelFirstMenuTerminate(boost::bind(&UnityScreen::showPanelFirstMenuKeyTerminate, this, _1, _2, _3));382 optionSetPanelFirstMenuTerminate(boost::bind(&UnityScreen::showPanelFirstMenuKeyTerminate, this, _1, _2, _3));
383 optionSetPanelFirstMenuNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));383 optionSetPanelFirstMenuNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
384 optionSetSpreadAppWindowsInitiate(boost::bind(&UnityScreen::spreadAppWindowsInitiate, this, _1, _2, _3));
385 optionSetSpreadAppWindowsAnywhereInitiate(boost::bind(&UnityScreen::spreadAppWindowsAnywhereInitiate, this, _1, _2, _3));
384 optionSetAutomaximizeValueNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));386 optionSetAutomaximizeValueNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
385 optionSetDashTapDurationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));387 optionSetDashTapDurationNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
386 optionSetAltTabTimeoutNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));388 optionSetAltTabTimeoutNotify(boost::bind(&UnityScreen::optionChanged, this, _1, _2));
@@ -2106,7 +2108,7 @@
2106 action->setState(action->state() | CompAction::StateTermKey);2108 action->setState(action->state() | CompAction::StateTermKey);
21072109
2108 super_keypressed_ = true;2110 super_keypressed_ = true;
2109 int when = options[7].value().i(); // XEvent time in millisec2111 int when = CompOption::getIntOptionNamed(options, "time");
2110 launcher_controller_->HandleLauncherKeyPress(when);2112 launcher_controller_->HandleLauncherKeyPress(when);
2111 EnsureSuperKeybindings ();2113 EnsureSuperKeybindings ();
21122114
@@ -2138,7 +2140,7 @@
2138 bool was_tap = state & CompAction::StateTermTapped;2140 bool was_tap = state & CompAction::StateTermTapped;
2139 bool tap_handled = false;2141 bool tap_handled = false;
2140 LOG_DEBUG(logger) << "Super released: " << (was_tap ? "tapped" : "released");2142 LOG_DEBUG(logger) << "Super released: " << (was_tap ? "tapped" : "released");
2141 int when = options[7].value().i(); // XEvent time in millisec2143 int when = CompOption::getIntOptionNamed(options, "time");
21422144
2143 // hack...if the scale just wasn't activated AND the 'when' time is within time to start the2145 // hack...if the scale just wasn't activated AND the 'when' time is within time to start the
2144 // dash then assume was_tap is also true, since the ScalePlugin doesn't accept that state...2146 // dash then assume was_tap is also true, since the ScalePlugin doesn't accept that state...
@@ -2209,7 +2211,7 @@
2209 /* In order to avoid too many events when keeping the keybinding pressed,2211 /* In order to avoid too many events when keeping the keybinding pressed,
2210 * that would make the unity-panel-service to go crazy (see bug #948522)2212 * that would make the unity-panel-service to go crazy (see bug #948522)
2211 * we need to filter them, just considering an event every 750 ms */2213 * we need to filter them, just considering an event every 750 ms */
2212 int event_time = options[7].value().i(); // XEvent time in millisec2214 int event_time = CompOption::getIntOptionNamed(options, "time");
22132215
2214 if (event_time - first_menu_keypress_time_ < 750)2216 if (event_time - first_menu_keypress_time_ < 750)
2215 {2217 {
@@ -2279,6 +2281,38 @@
2279 return true;2281 return true;
2280}2282}
22812283
2284void UnityScreen::SpreadAppWindows(bool anywhere)
2285{
2286 if (ApplicationPtr const& active_app = ApplicationManager::Default().GetActiveApplication())
2287 {
2288 std::vector<Window> windows;
2289
2290 for (auto& window : active_app->GetWindows())
2291 {
2292 if (anywhere || WM.IsWindowOnCurrentDesktop(window->window_id()))
2293 windows.push_back(window->window_id());
2294 }
2295
2296 WM.ScaleWindowGroup(windows, 0, true);
2297 }
2298}
2299
2300bool UnityScreen::spreadAppWindowsInitiate(CompAction* action,
2301 CompAction::State state,
2302 CompOption::Vector& options)
2303{
2304 SpreadAppWindows(false);
2305 return true;
2306}
2307
2308bool UnityScreen::spreadAppWindowsAnywhereInitiate(CompAction* action,
2309 CompAction::State state,
2310 CompOption::Vector& options)
2311{
2312 SpreadAppWindows(true);
2313 return true;
2314}
2315
2282bool UnityScreen::setKeyboardFocusKeyInitiate(CompAction* action,2316bool UnityScreen::setKeyboardFocusKeyInitiate(CompAction* action,
2283 CompAction::State state,2317 CompAction::State state,
2284 CompOption::Vector& options)2318 CompOption::Vector& options)
@@ -2632,7 +2666,7 @@
2632 // to receive the Terminate event2666 // to receive the Terminate event
2633 if (state & CompAction::StateInitKey)2667 if (state & CompAction::StateInitKey)
2634 action->setState(action->state() | CompAction::StateTermKey);2668 action->setState(action->state() | CompAction::StateTermKey);
2635 hud_keypress_time_ = options[7].value().i(); // XEvent time in millisec2669 hud_keypress_time_ = CompOption::getIntOptionNamed(options, "time");
26362670
2637 // pass key through2671 // pass key through
2638 return false;2672 return false;
@@ -2653,7 +2687,7 @@
2653 if (!(state & CompAction::StateTermTapped))2687 if (!(state & CompAction::StateTermTapped))
2654 return false;2688 return false;
26552689
2656 int release_time = options[7].value().i(); // XEvent time in millisec2690 int release_time = CompOption::getIntOptionNamed(options, "time");
2657 int tap_duration = release_time - hud_keypress_time_;2691 int tap_duration = release_time - hud_keypress_time_;
2658 if (tap_duration > local::ALT_TAP_DURATION)2692 if (tap_duration > local::ALT_TAP_DURATION)
2659 {2693 {
@@ -3886,9 +3920,9 @@
3886 screen->removeAction(&action);3920 screen->removeAction(&action);
38873921
3888 // We notify that super/alt have been released, to avoid to leave unity in inconsistent state3922 // We notify that super/alt have been released, to avoid to leave unity in inconsistent state
3889 CompOption::Vector options(8);3923 CompOption::Vector options(1);
3890 options[7].setName("time", CompOption::TypeInt);3924 options.back().setName("time", CompOption::TypeInt);
3891 options[7].value().set<int>(screen->getCurrentTime());3925 options.back().value().set<int>(screen->getCurrentTime());
38923926
3893 showLauncherKeyTerminate(&optionGetShowLauncher(), CompAction::StateTermKey, options);3927 showLauncherKeyTerminate(&optionGetShowLauncher(), CompAction::StateTermKey, options);
3894 showMenuBarTerminate(&optionGetShowMenuBar(), CompAction::StateTermKey, options);3928 showMenuBarTerminate(&optionGetShowMenuBar(), CompAction::StateTermKey, options);
38953929
=== modified file 'plugins/unityshell/src/unityshell.h'
--- plugins/unityshell/src/unityshell.h 2015-05-12 13:10:07 +0000
+++ plugins/unityshell/src/unityshell.h 2015-10-28 09:25:56 +0000
@@ -185,6 +185,8 @@
185185
186 bool executeCommand(CompAction* action, CompAction::State state, CompOption::Vector& options);186 bool executeCommand(CompAction* action, CompAction::State state, CompOption::Vector& options);
187 bool showDesktopKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);187 bool showDesktopKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
188 bool spreadAppWindowsInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
189 bool spreadAppWindowsAnywhereInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
188 bool setKeyboardFocusKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);190 bool setKeyboardFocusKeyInitiate(CompAction* action, CompAction::State state, CompOption::Vector& options);
189191
190 bool altTabInitiateCommon(CompAction* action, switcher::ShowMode mode);192 bool altTabInitiateCommon(CompAction* action, switcher::ShowMode mode);
@@ -318,6 +320,7 @@
318 void DamageBlurUpdateRegion(nux::Geometry const&);320 void DamageBlurUpdateRegion(nux::Geometry const&);
319321
320 void ShowFirstRunHints();322 void ShowFirstRunHints();
323 void SpreadAppWindows(bool anywhere);
321324
322 std::unique_ptr<na::TickSource> tick_source_;325 std::unique_ptr<na::TickSource> tick_source_;
323 std::unique_ptr<na::AnimationController> animation_controller_;326 std::unique_ptr<na::AnimationController> animation_controller_;
324327
=== modified file 'plugins/unityshell/unityshell.xml.in'
--- plugins/unityshell/unityshell.xml.in 2015-05-12 13:09:57 +0000
+++ plugins/unityshell/unityshell.xml.in 2015-10-28 09:25:56 +0000
@@ -87,6 +87,18 @@
87 <default>&lt;Alt&gt;F10</default>87 <default>&lt;Alt&gt;F10</default>
88 </option>88 </option>
8989
90 <option name="spread_app_windows" type="key">
91 <_short>Key to spread the current application windows</_short>
92 <_long>Initiate the window Spread for the current application windows.</_long>
93 <default>&lt;Control&gt;&lt;Super&gt;w</default>
94 </option>
95
96 <option name="spread_app_windows_anywhere" type="key">
97 <_short>Key to spread the current application windows in any workspace</_short>
98 <_long>Initiate the window Spread for the current application windows, for the all the windows.</_long>
99 <default>&lt;Control&gt;&lt;Super&gt;&lt;Shift&gt;w</default>
100 </option>
101
90 <option name="panel_opacity" type="float">102 <option name="panel_opacity" type="float">
91 <_short>Panel Opacity</_short>103 <_short>Panel Opacity</_short>
92 <_long>The opacity of the Panel background.</_long>104 <_long>The opacity of the Panel background.</_long>
93105
=== modified file 'shortcuts/CompizShortcutModeller.cpp'
--- shortcuts/CompizShortcutModeller.cpp 2014-09-10 17:19:16 +0000
+++ shortcuts/CompizShortcutModeller.cpp 2015-10-28 09:25:56 +0000
@@ -68,6 +68,8 @@
68 const std::string UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD = "launcher_switcher_forward";68 const std::string UNITYSHELL_OPTION_LAUNCHER_SWITCHER_FORWARD = "launcher_switcher_forward";
69 const std::string UNITYSHELL_OPTION_SHOW_HUD = "show_hud";69 const std::string UNITYSHELL_OPTION_SHOW_HUD = "show_hud";
70 const std::string UNITYSHELL_OPTION_PANEL_FIRST_MENU = "panel_first_menu";70 const std::string UNITYSHELL_OPTION_PANEL_FIRST_MENU = "panel_first_menu";
71 const std::string UNITYSHELL_OPTION_SPREAD_APP_WINDOWS = "spread_app_windows";
72 const std::string UNITYSHELL_OPTION_SPREAD_APP_WINDOWS_ANYWHERE = "spread_app_windows_anywhere";
71 const std::string UNITYSHELL_OPTION_ALT_TAB_FORWARD = "alt_tab_forward";73 const std::string UNITYSHELL_OPTION_ALT_TAB_FORWARD = "alt_tab_forward";
72 const std::string UNITYSHELL_OPTION_ALT_TAB_FORWARD_ALL = "alt_tab_forward_all";74 const std::string UNITYSHELL_OPTION_ALT_TAB_FORWARD_ALL = "alt_tab_forward_all";
73 const std::string UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW = "alt_tab_next_window";75 const std::string UNITYSHELL_OPTION_ALT_TAB_NEXT_WINDOW = "alt_tab_next_window";
@@ -316,6 +318,23 @@
316 }318 }
317319
318 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",320 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
321 (ws_enabled ?
322 _("Spreads all windows of the focused application in the current workspace.") :
323 _("Spreads all windows of the focused application.")),
324 shortcut::OptionType::COMPIZ_KEY,
325 UNITYSHELL_PLUGIN_NAME,
326 UNITYSHELL_OPTION_SPREAD_APP_WINDOWS));
327
328 if (ws_enabled)
329 {
330 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
331 _("Spreads all windows of the focused application in all the workspaces."),
332 shortcut::OptionType::COMPIZ_KEY,
333 UNITYSHELL_PLUGIN_NAME,
334 UNITYSHELL_OPTION_SPREAD_APP_WINDOWS_ANYWHERE));
335 }
336
337 hints.push_back(std::make_shared<shortcut::Hint>(windows, "", "",
319 _("Minimises all windows."),338 _("Minimises all windows."),
320 shortcut::OptionType::COMPIZ_KEY,339 shortcut::OptionType::COMPIZ_KEY,
321 CORE_PLUGIN_NAME,340 CORE_PLUGIN_NAME,
322341
=== modified file 'unity-shared/GnomeKeyGrabber.cpp'
--- unity-shared/GnomeKeyGrabber.cpp 2015-10-01 03:52:09 +0000
+++ unity-shared/GnomeKeyGrabber.cpp 2015-10-28 09:25:56 +0000
@@ -64,11 +64,6 @@
64std::string const DBUS_NAME = "com.canonical.Unity.Test.GnomeKeyGrabber";64std::string const DBUS_NAME = "com.canonical.Unity.Test.GnomeKeyGrabber";
65}65}
6666
67namespace
68{
69inline int compiz_event_timestamp(CompOption::Vector& options) { return options[7].value().i(); }
70}
71
72GnomeGrabber::Impl::Impl(bool test_mode)67GnomeGrabber::Impl::Impl(bool test_mode)
73 : screen_(screen)68 : screen_(screen)
74 , shell_server_(test_mode ? testing::DBUS_NAME : shell::DBUS_NAME)69 , shell_server_(test_mode ? testing::DBUS_NAME : shell::DBUS_NAME)
@@ -224,7 +219,7 @@
224 action.setState(CompAction::StateInitKey);219 action.setState(CompAction::StateInitKey);
225 action.setInitiate([this, action_id](CompAction* action, CompAction::State state, CompOption::Vector& options) {220 action.setInitiate([this, action_id](CompAction* action, CompAction::State state, CompOption::Vector& options) {
226 LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\"";221 LOG_DEBUG(logger) << "pressed \"" << action->keyToString() << "\"";
227 ActivateDBusAction(*action, action_id, 0, compiz_event_timestamp(options));222 ActivateDBusAction(*action, action_id, 0, CompOption::getIntOptionNamed(options, "time"));
228 return true;223 return true;
229 });224 });
230 }225 }
@@ -239,7 +234,7 @@
239 if (state & CompAction::StateTermTapped)234 if (state & CompAction::StateTermTapped)
240 {235 {
241 LOG_DEBUG(logger) << "tapped \"" << key << "\"";236 LOG_DEBUG(logger) << "tapped \"" << key << "\"";
242 ActivateDBusAction(*action, action_id, 0, compiz_event_timestamp(options));237 ActivateDBusAction(*action, action_id, 0, CompOption::getIntOptionNamed(options, "time"));
243 return true;238 return true;
244 }239 }
245240