Merge lp:~azzar1/unity/dont-focus-me-on-mouse-down2 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Mirco Müller
Approved revision: 1807
Merged at revision: 1815
Proposed branch: lp:~azzar1/unity/dont-focus-me-on-mouse-down2
Merge into: lp:unity
Diff against target: 128 lines (+43/-19)
4 files modified
manual-tests/Dash.txt (+25/-0)
plugins/unityshell/src/PlacesTile.cpp (+2/-0)
plugins/unityshell/src/ResultViewGrid.cpp (+15/-19)
plugins/unityshell/src/StaticCairoText.cpp (+1/-0)
To merge this branch: bzr merge lp:~azzar1/unity/dont-focus-me-on-mouse-down2
Reviewer Review Type Date Requested Status
Mirco Müller (community) Approve
Review via email: mp+87297@code.launchpad.net

Description of the change

This branch depends on https://code.launchpad.net/~andyrock/nux/please-dont-focus-me-on-mouse-down.

Read the manual test to learn how to test it.

It replaces https://code.launchpad.net/~andyrock/unity/dont-focus-me-on-mouse-down/+merge/86176 because it had some problems with gettext.

To post a comment you must log in.
1806. By Andrea Azzarone

Ops.

1807. By Andrea Azzarone

Ops, sigh...

Revision history for this message
Mirco Müller (macslow) wrote :

Good, working as expected.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'manual-tests/Dash.txt'
2--- manual-tests/Dash.txt 2011-11-28 20:53:45 +0000
3+++ manual-tests/Dash.txt 2012-01-02 22:41:39 +0000
4@@ -10,4 +10,29 @@
5 Outcome
6 The dash disappears, and gedit is run. If nothing happens or the first
7 command is run (in this case gcc), this test failed.
8+
9+
10+Category headers focus
11+----------------------
12+This test makes sure that clicking on a category headers doesn't focus it.
13+
14+#. Open the apps lens.
15+#. Click on the dash search bar to make sure that the search bar has the focus.
16+#. Click on a category header to expand/collapse a category
17+
18+Outcome
19+ The category should expand/collaspe and the search bar still has the focus.
20+
21+
22+Drag and drop dash icons
23+----------------------------
24+This test makes sure that.
25+
26+#. Open the apps lens.
27+#. Drag a dash icon.
28+#. Now drop it inside the dash but on another icon or on a blank space.
29+
30+Outcome
31+ The dropped icon should not have the keyboard focus and should not remain
32+ enlightened.
33
34
35=== modified file 'plugins/unityshell/src/PlacesTile.cpp'
36--- plugins/unityshell/src/PlacesTile.cpp 2011-11-07 19:05:57 +0000
37+++ plugins/unityshell/src/PlacesTile.cpp 2012-01-02 22:41:39 +0000
38@@ -41,6 +41,8 @@
39 _last_width(0),
40 _last_height(0)
41 {
42+ SetAcceptKeyNavFocusOnMouseDown(false);
43+
44 mouse_down.connect(sigc::mem_fun(this, &PlacesTile::RecvMouseDown));
45 mouse_up.connect(sigc::mem_fun(this, &PlacesTile::RecvMouseUp));
46 mouse_click.connect(sigc::mem_fun(this, &PlacesTile::RecvMouseClick));
47
48=== modified file 'plugins/unityshell/src/ResultViewGrid.cpp'
49--- plugins/unityshell/src/ResultViewGrid.cpp 2011-11-22 11:58:34 +0000
50+++ plugins/unityshell/src/ResultViewGrid.cpp 2012-01-02 22:41:39 +0000
51@@ -62,6 +62,8 @@
52 , mouse_last_x_(-1)
53 , mouse_last_y_(-1)
54 {
55+ SetAcceptKeyNavFocusOnMouseDown(false);
56+
57 auto needredraw_lambda = [&](int value)
58 {
59 NeedRedraw();
60@@ -82,13 +84,6 @@
61 last_mouse_down_y_ = y;
62 uint index = GetIndexAtPosition(x, y);
63 mouse_over_index_ = index;
64- if (index >= 0 && index < results_.size())
65- {
66- // we got a click on a button so activate it
67- Result result = results_[index];
68- selected_index_ = index;
69- focused_uri_ = result.uri;
70- }
71 });
72
73 mouse_leave.connect([&](int x, int y, unsigned long mouse_state, unsigned long button_state)
74@@ -500,22 +495,10 @@
75 {
76 if (selected_index_ < 0)
77 {
78- if (mouse_over_index_ >= 0 && mouse_over_index_ < static_cast<int>(results_.size()))
79- {
80- // to hack around nux, nux sends the keynavfocuschange event before
81- // mouse clicks, so when mouse click happens we have already scrolled away
82- // because the keynav focus changed
83- focused_uri_ = results_[mouse_over_index_].uri;
84- selected_index_ = mouse_over_index_;
85- }
86- else
87- {
88 focused_uri_ = results_.front().uri;
89 selected_index_ = 0;
90- }
91 }
92
93-
94 int items_per_row = GetItemsPerRow();
95 int focused_x = (renderer_->width + horizontal_spacing) * (selected_index_ % items_per_row);
96 int focused_y = (renderer_->height + vertical_spacing) * (selected_index_ / items_per_row);
97@@ -886,6 +869,19 @@
98 last_mouse_down_y_ = -1;
99 current_drag_uri_.clear();
100 current_drag_icon_name_.clear();
101+
102+ // We need this because the drag can start in a ResultViewGrid and can
103+ // end in another ResultViewGrid
104+ EmitMouseLeaveSignal(0, 0, 0, 0);
105+
106+ // We need an extra mouse motion to highlight the icon under the mouse
107+ // as soon as dnd finish
108+ Display* display = nux::GetGraphicsDisplay()->GetX11Display();
109+ if (display)
110+ {
111+ XWarpPointer(display, None, None, 0, 0, 0, 0, 0, 0);
112+ XSync(display, 0);
113+ }
114 }
115
116 int
117
118=== modified file 'plugins/unityshell/src/StaticCairoText.cpp'
119--- plugins/unityshell/src/StaticCairoText.cpp 2011-11-22 00:32:27 +0000
120+++ plugins/unityshell/src/StaticCairoText.cpp 2012-01-02 22:41:39 +0000
121@@ -63,6 +63,7 @@
122 _fontstring = NULL;
123
124 _accept_key_nav_focus = false;
125+ SetAcceptKeyNavFocusOnMouseDown(false);
126 }
127
128 StaticCairoText::~StaticCairoText()