Merge lp:~didrocks/unity/misc-launcher-fix into lp:unity

Proposed by Didier Roche-Tolomelli
Status: Merged
Approved by: Gord Allott
Approved revision: no longer in the source branch.
Merged at revision: 922
Proposed branch: lp:~didrocks/unity/misc-launcher-fix
Merge into: lp:unity
Diff against target: 181 lines (+48/-32)
3 files modified
src/Launcher.cpp (+40/-28)
src/Launcher.h (+1/-1)
src/unityshell.cpp (+7/-3)
To merge this branch: bzr merge lp:~didrocks/unity/misc-launcher-fix
Reviewer Review Type Date Requested Status
Gord Allott Pending
Review via email: mp+52418@code.launchpad.net

Description of the change

* don't lock the launcher on launcher reveal if the mouse didn't move (LP:
#727746)

 * enable using shortcut even if keybinding isn't shown. Disable tap on super in
this case (LP: #727580). Also, if a unity shortcut is triggered, don't let other
plugins using it (LP: #729166)

 * Get the lastest X server status, not the cached one which can be racy (LP:
#718054)

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Launcher.cpp'
--- src/Launcher.cpp 2011-03-01 11:25:44 +0000
+++ src/Launcher.cpp 2011-03-07 14:23:15 +0000
@@ -1348,6 +1348,8 @@
13481348
1349void Launcher::StartKeyShowLauncher ()1349void Launcher::StartKeyShowLauncher ()
1350{1350{
1351 bool was_hidden = _hidden;
1352
1351 _super_show_launcher = true;1353 _super_show_launcher = true;
1352 QueueDraw ();1354 QueueDraw ();
1353 SetTimeStruct (&_times[TIME_TAP_SUPER], NULL, SUPER_TAP_DURATION);1355 SetTimeStruct (&_times[TIME_TAP_SUPER], NULL, SUPER_TAP_DURATION);
@@ -1355,6 +1357,10 @@
1355 g_source_remove (_redraw_handle);1357 g_source_remove (_redraw_handle);
1356 _redraw_handle = g_timeout_add (SUPER_TAP_DURATION, &Launcher::DrawLauncherTimeout, this);1358 _redraw_handle = g_timeout_add (SUPER_TAP_DURATION, &Launcher::DrawLauncherTimeout, this);
1357 EnsureHiddenState ();1359 EnsureHiddenState ();
1360
1361 // don't lock on mouseover state to avoid locking it the pointer was already there but not moved
1362 if (was_hidden)
1363 _mouseover_launcher_locked = false;
1358}1364}
13591365
1360void Launcher::EndKeyShowLauncher ()1366void Launcher::EndKeyShowLauncher ()
@@ -1434,7 +1440,7 @@
1434{1440{
1435 if (hidden == _hidden)1441 if (hidden == _hidden)
1436 return;1442 return;
14371443
1438 // auto lock/unlock the launcher depending on the state switch1444 // auto lock/unlock the launcher depending on the state switch
1439 if (hidden)1445 if (hidden)
1440 {1446 {
@@ -1507,7 +1513,7 @@
1507 if (!window || !(window->type () & intersect_types) || !window->isMapped () || !window->isViewable ())1513 if (!window || !(window->type () & intersect_types) || !window->isMapped () || !window->isViewable ())
1508 return false;1514 return false;
15091515
1510 if (CompRegion (window->inputRect ()).intersects (CompRect (geo.x, geo.y, geo.width, geo.height)))1516 if (CompRegion (window->serverInputRect ()).intersects (CompRect (geo.x, geo.y, geo.width, geo.height)))
1511 return true;1517 return true;
15121518
1513 return false;1519 return false;
@@ -2651,16 +2657,34 @@
2651 EnsureAnimation ();2657 EnsureAnimation ();
2652}2658}
26532659
2654void2660gboolean
2655Launcher::CheckSuperShortcutPressed (unsigned int key_sym,2661Launcher::CheckSuperShortcutPressed (unsigned int key_sym,
2656 unsigned long key_code,2662 unsigned long key_code,
2657 unsigned long key_state)2663 unsigned long key_state)
2658{2664{
2659 if (_super_show_launcher)2665 if (!_super_show_launcher)
2666 return false;
2667
2668 LauncherModel::iterator it;
2669 int i;
2670
2671 // Shortcut to start launcher icons. Only relies on Keycode, ignore modifier
2672 for (it = _model->begin (), i = 0; it != _model->end (); it++, i++)
2660 {2673 {
2661 RecvKeyPressed (key_sym, key_code, key_state);2674 if (XKeysymToKeycode (screen->dpy (), (*it)->GetShortcut ()) == key_code)
2662 QueueDraw ();2675 {
2676 if (g_ascii_isdigit ((gchar) (*it)->GetShortcut ()) && (key_state & ShiftMask))
2677 (*it)->OpenInstance ();
2678 else
2679 (*it)->Activate ();
2680 // disable the "tap on super" check
2681 _times[TIME_TAP_SUPER].tv_sec = 0;
2682 _times[TIME_TAP_SUPER].tv_nsec = 0;
2683 return true;
2684 }
2663 }2685 }
2686
2687 return false;
2664}2688}
26652689
2666void2690void
@@ -2749,26 +2773,7 @@
2749 leaveKeyNavMode (false);2773 leaveKeyNavMode (false);
2750 break;2774 break;
2751 2775
2752 // Shortcut to start launcher icons. Only relies on Keycode, ignore modifier
2753 default:2776 default:
2754 {
2755 if (_super_show_launcher && !TapOnSuper ())
2756 {
2757 int i;
2758 for (it = _model->begin (), i = 0; it != _model->end (); it++, i++)
2759 {
2760 if (XKeysymToKeycode (screen->dpy (), (*it)->GetShortcut ()) == key_code)
2761 {
2762 if (g_ascii_isdigit ((gchar) (*it)->GetShortcut ()) && (key_state & ShiftMask))
2763 (*it)->OpenInstance ();
2764 else
2765 (*it)->Activate ();
2766 }
2767 }
2768 }
2769
2770
2771 }
2772 break;2777 break;
2773 }2778 }
2774}2779}
@@ -2796,9 +2801,16 @@
2796 return;2801 return;
27972802
2798 LauncherIcon* launcher_icon = 0;2803 LauncherIcon* launcher_icon = 0;
2804 bool should_lock_launcher = false;
27992805
2800 if (_mouse_inside_launcher)2806 if (_mouse_inside_launcher) {
2801 launcher_icon = MouseIconIntersection (_mouse_position.x, _mouse_position.y);2807 launcher_icon = MouseIconIntersection (_mouse_position.x, _mouse_position.y);
2808 // indicate if the mouse should relock the launcher or not (it doesn't explicitely lock the launcher
2809 // when it's entering the launcher. This is for the case: Super reveals the launcher, mouse doesn't move)
2810 if (_icon_under_mouse && !_hidden)
2811 should_lock_launcher = true;
2812 }
2813
28022814
2803 if (_icon_under_mouse && (_icon_under_mouse != launcher_icon))2815 if (_icon_under_mouse && (_icon_under_mouse != launcher_icon))
2804 {2816 {
@@ -2812,8 +2824,8 @@
2812 launcher_icon->MouseEnter.emit ();2824 launcher_icon->MouseEnter.emit ();
2813 launcher_icon->_mouse_inside = true;2825 launcher_icon->_mouse_inside = true;
2814 _icon_under_mouse = launcher_icon;2826 _icon_under_mouse = launcher_icon;
2815 // reset trigger has the mouse moved to another item (only if the launcher is supposed to be seen)2827 // reset trigger only when in right context
2816 if (!_hidden)2828 if (should_lock_launcher)
2817 _mouseover_launcher_locked = true;2829 _mouseover_launcher_locked = true;
2818 }2830 }
2819}2831}
28202832
=== modified file 'src/Launcher.h'
--- src/Launcher.h 2011-03-01 11:25:44 +0000
+++ src/Launcher.h 2011-03-07 14:23:15 +0000
@@ -127,7 +127,7 @@
127 void SetAutoHideAnimation (AutoHideAnimation animation);127 void SetAutoHideAnimation (AutoHideAnimation animation);
128 AutoHideAnimation GetAutoHideAnimation ();128 AutoHideAnimation GetAutoHideAnimation ();
129 129
130 void CheckSuperShortcutPressed (unsigned int key_sym, unsigned long key_code, unsigned long key_state);130 gboolean CheckSuperShortcutPressed (unsigned int key_sym, unsigned long key_code, unsigned long key_state);
131 131
132 nux::BaseWindow* GetParent () { return _parent; };132 nux::BaseWindow* GetParent () { return _parent; };
133133
134134
=== modified file 'src/unityshell.cpp'
--- src/unityshell.cpp 2011-03-01 09:41:36 +0000
+++ src/unityshell.cpp 2011-03-07 14:23:15 +0000
@@ -181,6 +181,8 @@
181void181void
182UnityScreen::handleEvent (XEvent *event)182UnityScreen::handleEvent (XEvent *event)
183{183{
184 bool skip_other_plugins = false;
185
184 switch (event->type)186 switch (event->type)
185 {187 {
186 case FocusIn:188 case FocusIn:
@@ -193,13 +195,15 @@
193 case KeyPress:195 case KeyPress:
194 KeySym key_sym;196 KeySym key_sym;
195 if (XLookupString (&(event->xkey), NULL, 0, &key_sym, 0) > 0)197 if (XLookupString (&(event->xkey), NULL, 0, &key_sym, 0) > 0)
196 launcher->CheckSuperShortcutPressed (key_sym, event->xkey.keycode, event->xkey.state);198 skip_other_plugins = launcher->CheckSuperShortcutPressed (key_sym, event->xkey.keycode, event->xkey.state);
197 break;199 break;
198 }200 }
199201
200 screen->handleEvent (event);202 // avoid further propagation (key conflict for instance)
203 if (!skip_other_plugins)
204 screen->handleEvent (event);
201205
202 if (screen->otherGrabExist ("deco", "move", "wall", "switcher", NULL))206 if (!skip_other_plugins && screen->otherGrabExist ("deco", "move", "wall", "switcher", NULL))
203 {207 {
204 wt->ProcessForeignEvent (event, NULL);208 wt->ProcessForeignEvent (event, NULL);
205 }209 }