Nux

Merge lp:~azzar1/nux/fix-849175 into lp:nux/2.0

Proposed by Andrea Azzarone
Status: Merged
Approved by: Jay Taoko
Approved revision: 543
Merged at revision: 538
Proposed branch: lp:~azzar1/nux/fix-849175
Merge into: lp:nux/2.0
Diff against target: 159 lines (+76/-5)
4 files modified
Nux/TextEntry.cpp (+45/-4)
Nux/TextEntry.h (+6/-0)
configure.ac (+1/-1)
tests/manual-tests/text-entry.txt (+24/-0)
To merge this branch: bzr merge lp:~azzar1/nux/fix-849175
Reviewer Review Type Date Requested Status
Jay Taoko (community) Approve
Alex Launi (community) Needs Fixing
Review via email: mp+87952@code.launchpad.net

Description of the change

Changes the cursor when the mouse pointer is over the text entry area.

To post a comment you must log in.
lp:~azzar1/nux/fix-849175 updated
537. By Andrea Azzarone

Add an extra check.

538. By Andrea Azzarone

Fix bug #737719.

539. By Andrea Azzarone

Fixes.

540. By Andrea Azzarone

Ops.

Revision history for this message
Andrea Azzarone (azzar1) wrote :

Ready for review, later we can add a test.

Revision history for this message
Alex Launi (alexlauni) wrote :

Please add at least a manual test. It shouldn't be too difficult to write unit tests for this code as well, so please do.

review: Needs Fixing
Revision history for this message
Andrea Azzarone (azzar1) wrote :

> Please add at least a manual test. It shouldn't be too difficult to write unit
> tests for this code as well, so please do.

Manual test for the moment. nux::TextEntry doesn't provide the right interface to easly test it.

lp:~azzar1/nux/fix-849175 updated
541. By Andrea Azzarone

Add a manual test.

Revision history for this message
Jay Taoko (jaytaoko) :
review: Approve
lp:~azzar1/nux/fix-849175 updated
542. By Andrea Azzarone

Merge trunk.

543. By Andrea Azzarone

Abi change.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/TextEntry.cpp'
2--- Nux/TextEntry.cpp 2012-01-04 00:10:39 +0000
3+++ Nux/TextEntry.cpp 2012-01-19 19:43:25 +0000
4@@ -1,5 +1,3 @@
5-
6-
7 /*
8 Copyright 2008 Google Inc.
9
10@@ -30,6 +28,10 @@
11
12 #include "TextEntry.h"
13
14+#if defined(NUX_OS_LINUX)
15+#include <X11/cursorfont.h>
16+#endif
17+
18 namespace nux
19 {
20 static const int kInnerBorderX = 2;
21@@ -147,9 +149,11 @@
22 , font_dpi_(96.0)
23 , _text_color(color::White)
24 , align_(CairoGraphics::ALIGN_LEFT)
25+#if defined(NUX_OS_LINUX)
26+ , caret_cursor_(None)
27+#endif
28 , text_input_mode_(false)
29 , key_nav_mode_(false)
30-
31 {
32 cairo_font_options_set_antialias(font_options_, CAIRO_ANTIALIAS_SUBPIXEL);
33 cairo_font_options_set_hint_style(font_options_, CAIRO_HINT_STYLE_FULL);
34@@ -160,6 +164,8 @@
35 mouse_drag.connect(sigc::mem_fun(this, &TextEntry::RecvMouseDrag));
36 mouse_up.connect(sigc::mem_fun(this, &TextEntry::RecvMouseUp));
37 mouse_double_click.connect(sigc::mem_fun(this, &TextEntry::RecvMouseDoubleClick));
38+ mouse_enter.connect(sigc::mem_fun(this, &TextEntry::RecvMouseEnter));
39+ mouse_leave.connect(sigc::mem_fun(this, &TextEntry::RecvMouseLeave));
40
41 key_down.connect(sigc::mem_fun(this, &TextEntry::RecvKeyEvent));
42
43@@ -212,7 +218,7 @@
44
45 void TextEntry::ProcessMouseEvent(int event_type, int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
46 {
47- if (GetEventButton(button_flags) != 1)
48+ if (GetEventButton(button_flags) != 1 && event_type != NUX_MOUSE_MOVE)
49 return;
50
51 //ResetImContext();
52@@ -444,6 +450,41 @@
53 {
54 ProcessMouseEvent(NUX_MOUSE_MOVE, x, y, dx, dy, button_flags, key_flags);
55 }
56+
57+ void TextEntry::RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags)
58+ {
59+#if defined(NUX_OS_LINUX)
60+ if (caret_cursor_ == None)
61+ {
62+ Display* display = nux::GetGraphicsDisplay()->GetX11Display();
63+ nux::BaseWindow* window = static_cast<nux::BaseWindow*>(GetTopLevelViewWindow());
64+
65+ if (display && window)
66+ {
67+ caret_cursor_ = XCreateFontCursor(display, XC_xterm);
68+ XDefineCursor(display, window->GetInputWindowId(), caret_cursor_);
69+ }
70+ }
71+#endif
72+ }
73+
74+ void TextEntry::RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags)
75+ {
76+#if defined(NUX_OS_LINUX)
77+ if (caret_cursor_ != None)
78+ {
79+ Display* display = nux::GetGraphicsDisplay()->GetX11Display();
80+ nux::BaseWindow* window = static_cast<nux::BaseWindow*>(GetTopLevelViewWindow());
81+
82+ if (display && window)
83+ {
84+ XUndefineCursor(display, window->GetInputWindowId());
85+ XFreeCursor(display, caret_cursor_);
86+ caret_cursor_ = None;
87+ }
88+ }
89+#endif
90+ }
91
92 void TextEntry::RecvKeyEvent(
93 unsigned long eventType , /*event type*/
94
95=== modified file 'Nux/TextEntry.h'
96--- Nux/TextEntry.h 2012-01-04 00:10:39 +0000
97+++ Nux/TextEntry.h 2012-01-19 19:43:25 +0000
98@@ -94,6 +94,8 @@
99 void RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
100 void RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
101 void RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags);
102+ void RecvMouseEnter(int x, int y, unsigned long button_flags, unsigned long key_flags);
103+ void RecvMouseLeave(int x, int y, unsigned long button_flags, unsigned long key_flags);
104 void RecvKeyEvent(
105 unsigned long eventType , /*event type*/
106 unsigned long keysym , /*event keysym*/
107@@ -380,6 +382,10 @@
108 Color _text_color;
109
110 CairoGraphics::Alignment align_;
111+
112+#if defined(NUX_OS_LINUX)
113+ Cursor caret_cursor_;
114+#endif
115
116 std::list<Rect> last_selection_region_;
117 std::list<Rect> selection_region_;
118
119=== modified file 'configure.ac'
120--- configure.ac 2012-01-18 21:08:29 +0000
121+++ configure.ac 2012-01-19 19:43:25 +0000
122@@ -22,7 +22,7 @@
123 # The number format is : year/month/day
124 # e.g.: december 5th, 2011 is: 20111205
125 # So far there is no provision for more than one break in a day.
126-m4_define([nux_abi_version], [20120118.01])
127+m4_define([nux_abi_version], [20120119.01])
128
129 m4_define([nux_version],
130 [nux_major_version.nux_minor_version.nux_micro_version])
131
132=== added file 'tests/manual-tests/text-entry.txt'
133--- tests/manual-tests/text-entry.txt 1970-01-01 00:00:00 +0000
134+++ tests/manual-tests/text-entry.txt 2012-01-19 19:43:25 +0000
135@@ -0,0 +1,24 @@
136+Text Entry - Mouse cursor
137+-----------
138+This test makes sure that the mouse pointer changes when it is inside a
139+text entry area.
140+
141+#. Make sure you're running Unity 3d;
142+#. Press Super
143+#. Move the cursor on dash text entry.
144+
145+Outcome
146+ The caret mouse cursor should be shown.
147+
148+
149+Text Entry - Drag
150+-----------
151+This test makes sure that the drag inside the dash works well.
152+
153+#. Make sure you're running Unity 3d;
154+#. Press Super
155+#. Type something inside dash search bar.
156+#. Use mouse drag to select part of the test.
157+
158+Outcome
159+ It should work.

Subscribers

People subscribed via source and target branches

to all changes: