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
1=== modified file 'src/Launcher.cpp'
2--- src/Launcher.cpp 2011-03-01 11:25:44 +0000
3+++ src/Launcher.cpp 2011-03-07 14:23:15 +0000
4@@ -1348,6 +1348,8 @@
5
6 void Launcher::StartKeyShowLauncher ()
7 {
8+ bool was_hidden = _hidden;
9+
10 _super_show_launcher = true;
11 QueueDraw ();
12 SetTimeStruct (&_times[TIME_TAP_SUPER], NULL, SUPER_TAP_DURATION);
13@@ -1355,6 +1357,10 @@
14 g_source_remove (_redraw_handle);
15 _redraw_handle = g_timeout_add (SUPER_TAP_DURATION, &Launcher::DrawLauncherTimeout, this);
16 EnsureHiddenState ();
17+
18+ // don't lock on mouseover state to avoid locking it the pointer was already there but not moved
19+ if (was_hidden)
20+ _mouseover_launcher_locked = false;
21 }
22
23 void Launcher::EndKeyShowLauncher ()
24@@ -1434,7 +1440,7 @@
25 {
26 if (hidden == _hidden)
27 return;
28-
29+
30 // auto lock/unlock the launcher depending on the state switch
31 if (hidden)
32 {
33@@ -1507,7 +1513,7 @@
34 if (!window || !(window->type () & intersect_types) || !window->isMapped () || !window->isViewable ())
35 return false;
36
37- if (CompRegion (window->inputRect ()).intersects (CompRect (geo.x, geo.y, geo.width, geo.height)))
38+ if (CompRegion (window->serverInputRect ()).intersects (CompRect (geo.x, geo.y, geo.width, geo.height)))
39 return true;
40
41 return false;
42@@ -2651,16 +2657,34 @@
43 EnsureAnimation ();
44 }
45
46-void
47+gboolean
48 Launcher::CheckSuperShortcutPressed (unsigned int key_sym,
49 unsigned long key_code,
50 unsigned long key_state)
51 {
52- if (_super_show_launcher)
53+ if (!_super_show_launcher)
54+ return false;
55+
56+ LauncherModel::iterator it;
57+ int i;
58+
59+ // Shortcut to start launcher icons. Only relies on Keycode, ignore modifier
60+ for (it = _model->begin (), i = 0; it != _model->end (); it++, i++)
61 {
62- RecvKeyPressed (key_sym, key_code, key_state);
63- QueueDraw ();
64+ if (XKeysymToKeycode (screen->dpy (), (*it)->GetShortcut ()) == key_code)
65+ {
66+ if (g_ascii_isdigit ((gchar) (*it)->GetShortcut ()) && (key_state & ShiftMask))
67+ (*it)->OpenInstance ();
68+ else
69+ (*it)->Activate ();
70+ // disable the "tap on super" check
71+ _times[TIME_TAP_SUPER].tv_sec = 0;
72+ _times[TIME_TAP_SUPER].tv_nsec = 0;
73+ return true;
74+ }
75 }
76+
77+ return false;
78 }
79
80 void
81@@ -2749,26 +2773,7 @@
82 leaveKeyNavMode (false);
83 break;
84
85- // Shortcut to start launcher icons. Only relies on Keycode, ignore modifier
86 default:
87- {
88- if (_super_show_launcher && !TapOnSuper ())
89- {
90- int i;
91- for (it = _model->begin (), i = 0; it != _model->end (); it++, i++)
92- {
93- if (XKeysymToKeycode (screen->dpy (), (*it)->GetShortcut ()) == key_code)
94- {
95- if (g_ascii_isdigit ((gchar) (*it)->GetShortcut ()) && (key_state & ShiftMask))
96- (*it)->OpenInstance ();
97- else
98- (*it)->Activate ();
99- }
100- }
101- }
102-
103-
104- }
105 break;
106 }
107 }
108@@ -2796,9 +2801,16 @@
109 return;
110
111 LauncherIcon* launcher_icon = 0;
112+ bool should_lock_launcher = false;
113
114- if (_mouse_inside_launcher)
115+ if (_mouse_inside_launcher) {
116 launcher_icon = MouseIconIntersection (_mouse_position.x, _mouse_position.y);
117+ // indicate if the mouse should relock the launcher or not (it doesn't explicitely lock the launcher
118+ // when it's entering the launcher. This is for the case: Super reveals the launcher, mouse doesn't move)
119+ if (_icon_under_mouse && !_hidden)
120+ should_lock_launcher = true;
121+ }
122+
123
124 if (_icon_under_mouse && (_icon_under_mouse != launcher_icon))
125 {
126@@ -2812,8 +2824,8 @@
127 launcher_icon->MouseEnter.emit ();
128 launcher_icon->_mouse_inside = true;
129 _icon_under_mouse = launcher_icon;
130- // reset trigger has the mouse moved to another item (only if the launcher is supposed to be seen)
131- if (!_hidden)
132+ // reset trigger only when in right context
133+ if (should_lock_launcher)
134 _mouseover_launcher_locked = true;
135 }
136 }
137
138=== modified file 'src/Launcher.h'
139--- src/Launcher.h 2011-03-01 11:25:44 +0000
140+++ src/Launcher.h 2011-03-07 14:23:15 +0000
141@@ -127,7 +127,7 @@
142 void SetAutoHideAnimation (AutoHideAnimation animation);
143 AutoHideAnimation GetAutoHideAnimation ();
144
145- void CheckSuperShortcutPressed (unsigned int key_sym, unsigned long key_code, unsigned long key_state);
146+ gboolean CheckSuperShortcutPressed (unsigned int key_sym, unsigned long key_code, unsigned long key_state);
147
148 nux::BaseWindow* GetParent () { return _parent; };
149
150
151=== modified file 'src/unityshell.cpp'
152--- src/unityshell.cpp 2011-03-01 09:41:36 +0000
153+++ src/unityshell.cpp 2011-03-07 14:23:15 +0000
154@@ -181,6 +181,8 @@
155 void
156 UnityScreen::handleEvent (XEvent *event)
157 {
158+ bool skip_other_plugins = false;
159+
160 switch (event->type)
161 {
162 case FocusIn:
163@@ -193,13 +195,15 @@
164 case KeyPress:
165 KeySym key_sym;
166 if (XLookupString (&(event->xkey), NULL, 0, &key_sym, 0) > 0)
167- launcher->CheckSuperShortcutPressed (key_sym, event->xkey.keycode, event->xkey.state);
168+ skip_other_plugins = launcher->CheckSuperShortcutPressed (key_sym, event->xkey.keycode, event->xkey.state);
169 break;
170 }
171
172- screen->handleEvent (event);
173+ // avoid further propagation (key conflict for instance)
174+ if (!skip_other_plugins)
175+ screen->handleEvent (event);
176
177- if (screen->otherGrabExist ("deco", "move", "wall", "switcher", NULL))
178+ if (!skip_other_plugins && screen->otherGrabExist ("deco", "move", "wall", "switcher", NULL))
179 {
180 wt->ProcessForeignEvent (event, NULL);
181 }