• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2.. _contributing:
3
4==============================================================================
5Contributing to libinput
6==============================================================================
7
8
9So you want to contribute to libinput? Great! We'd love to help you be a part
10of our community. Here is some important information to help you.
11
12.. contents::
13    :local:
14
15------------------------------------------------------------------------------
16Code of Conduct
17------------------------------------------------------------------------------
18
19As a freedesktop.org project, libinput follows the `freedesktop.org
20Contributor Covenant <https://www.freedesktop.org/wiki/CodeOfConduct>`_.
21
22Please conduct yourself in a respectful and civilised manner when
23interacting with community members on mailing lists, IRC, or bug trackers.
24The community represents the project as a whole, and abusive or bullying
25behaviour is not tolerated by the project.
26
27------------------------------------------------------------------------------
28Contact
29------------------------------------------------------------------------------
30
31Questions can be asked on ``#wayland-devel`` on freenode or on the
32`wayland-devel@lists.freedesktop.org
33<https://lists.freedesktop.org/mailman/listinfo/wayland-devel>`_ mailing
34list.
35
36For IRC, ping user ``whot`` (Peter Hutterer, the libinput maintainer) though
37note that he lives on UTC+10 and thus the rest of the world is out of sync
38by default ;)
39
40For anything that appears to be device specific and/or related to a new
41feature, just file `an issue in our issue tracker
42<https://gitlab.freedesktop.org/libinput/libinput/issues>`_. It's usually the
43most efficient way to get answers.
44
45------------------------------------------------------------------------------
46What to work on?
47------------------------------------------------------------------------------
48
49If you don't already know what you want to improve or fix with libinput,
50then a good way of finding something is to search for the ``help needed``
51tag in our `issue tracker <https://gitlab.freedesktop.org/libinput/libinput/issues?label_name%5B%5D=help+needed>`_.
52These are issues that have been triaged to some degree and deemed to be a
53possible future feature to libinput.
54
55.. note:: Some of these issue may require specific hardware to reproduce.
56
57Another good place to help out with is the documentation. For anything you
58find in these pages that isn't clear enough please feel free to reword it
59and add what is missing.
60
61------------------------------------------------------------------------------
62Getting the code
63------------------------------------------------------------------------------
64
65The :ref:`building_libinput` have all the details but the short solution
66will be:
67
68::
69
70     $> git clone https://gitlab.freedesktop.org/libinput/libinput
71     $> cd libinput
72     $> meson --prefix=/usr builddir/
73     $> ninja -C builddir/
74     $> sudo ninja -C builddir/ install
75
76You can omit the last step if you only want to test locally.
77
78------------------------------------------------------------------------------
79Working on the code
80------------------------------------------------------------------------------
81
82libinput has a roughly three-parts architecture:
83
84-  the front-end code which handles the ``libinput_some_function()`` API calls in ``libinput.c``
85-  the generic evdev interface handling which maps those API calls to the
86   backend calls (``evdev.c``).
87- there are device-specific backends which do most of the actual work -
88  ``evdev-mt-touchpad.c`` is the one for touchpads for example.
89
90In general, things that only affect the internal workings of a device only
91get implemented in the device-specific backend. You only need to touch the
92API when you are adding configuration options. For more details, please read
93the :ref:`architecture` document. There's also a `blog post describing the
94building blocks
95<https://who-t.blogspot.com/2019/03/libinputs-internal-building-blocks.html>`_
96that may help to understand how it all fits together.
97
98Documentation is in ``/doc/api`` for the doxygen-generated API documentation.
99These are extracted from the libinput source code directly. The
100documentation you're reading right now is in ``/doc/user`` and generated with
101sphinx. Simply running ``ninja -C builddir`` will rebuild it and the final
102product ends up in ``builddir/Documentation``.
103
104------------------------------------------------------------------------------
105Testing the code
106------------------------------------------------------------------------------
107
108libinput provides a bunch of :ref:`tools` to debug any changes - without
109having to install libinput.
110
111The two most useful ones are :ref:`libinput debug-events
112<libinput-debug-events>` and :ref:`libinput debug-gui <libinput-debug-gui>`.
113Both tools can be run from the build directory directly and are great for
114quick test iterations::
115
116  $> sudo ./builddir/libinput-debug-events --verbose
117  $> sudo ./builddir/libinput-debug-gui --verbose
118
119The former provides purely textual output and is useful for verifying event
120streams from buttons, etc. The latter is particularly useful when you are
121trying to debug pointer movement or placement. ``libinput debug-gui`` will
122also visualize the raw data from the device so you can compare pointer
123behavior with what comes from the kernel.
124
125These tools create a new libinput context and will not affect your session's
126behavior. Only once you've installed libinput and restarted your session
127will your changes affect the X server/Wayland compositor.
128
129Once everything seems to be correct, it's time to run the
130:ref:`test-suite`::
131
132  $> sudo ./builddir/libinput-test-suite
133
134This test suite can take test names etc. as arguments, have a look at
135:ref:`test-suite` for more info. There are a bunch of other tests that are
136run by the CI on merge requests, you can run those locally with ::
137
138  $> sudo ninja -C builddir check
139
140So it always pays to run that before submitting. This will also run the code
141through valgrind and pick up any memory leaks.
142
143------------------------------------------------------------------------------
144Submitting Code
145------------------------------------------------------------------------------
146
147Any patches should be sent via a Merge Request (see the `GitLab docs
148<https://docs.gitlab.com/ce/gitlab-basics/add-merge-request.htm>`_)
149in the `libinput GitLab instance hosted by freedesktop.org
150<https://gitlab.freedesktop.org/libinput/libinput>`_.
151
152To submit a merge request, you need to
153
154- `Register an account <https://gitlab.freedesktop.org/users/sign_in>`_ in
155  the freedesktop.org GitLab instance.
156- `Fork libinput <https://gitlab.freedesktop.org/libinput/libinput/forks/new>`_
157  into your username's namespace
158- Get libinput's main repository: ::
159
160    git clone https://gitlab.freedesktop.org/libinput/libinput.git
161
162- Add the forked git repository to your remotes (replace ``USERNAME``
163  with your username): ::
164
165    cd /path/to/libinput.git
166    git remote add gitlab git@gitlab.freedesktop.org:USERNAME/libinput.git
167    git fetch gitlab
168
169- Push your changes to your fork: ::
170
171    git push gitlab BRANCHNAME
172
173- Submit a merge request. The URL for a merge request is: ::
174
175    https://gitlab.freedesktop.org/USERNAME/libinput/merge_requests
176
177  Select your branch name to merge and ``libinput/libinput`` ``master`` as target branch.
178
179------------------------------------------------------------------------------
180Commit History
181------------------------------------------------------------------------------
182
183libinput strives to have a
184`linear, 'recipe' style history <http://www.bitsnbites.eu/git-history-work-log-vs-recipe/>`_
185This means that every commit should be small, digestible, stand-alone, and
186functional. Rather than a purely chronological commit history like this: ::
187
188	doc: final docs for view transforms
189	fix tests when disabled, redo broken doc formatting
190	better transformed-view iteration (thanks Hannah!)
191	try to catch more cases in tests
192	tests: add new spline test
193	fix compilation on splines
194	doc: notes on reticulating splines
195	compositor: add spline reticulation for view transforms
196
197We aim to have a clean history which only reflects the final state, broken up
198into functional groupings: ::
199
200	compositor: add spline reticulation for view transforms
201	compositor: new iterator for view transforms
202	tests: add view-transform correctness tests
203	doc: fix Doxygen formatting for view transforms
204
205This ensures that the final patch series only contains the final state,
206without the changes and missteps taken along the development process.
207
208The first line of a commit message should contain a prefix indicating
209what part is affected by the patch followed by one sentence that
210describes the change. For example: ::
211
212	touchpad: add software button behavior
213	fallback: disable button debouncing on device foo
214
215If in doubt what prefix to use, look at other commits that change the
216same file(s) as the patch being sent.
217
218------------------------------------------------------------------------------
219Commit Messages
220------------------------------------------------------------------------------
221
222Commit messages **must** contain a **Signed-off-by** line with your name
223and email address. An example is: ::
224
225    A description of this commit, and it's great work.
226
227    Signed-off-by: Claire Someone <name@domain>
228
229If you're not the patch's original author, you should
230also gather S-o-b's by them (and/or whomever gave the patch to you.) The
231significance of this is that it certifies that you created the patch, that
232it was created under an appropriate open source license, or provided to you
233under those terms. This lets us indicate a chain of responsibility for the
234copyright status of the code. An example is: ::
235
236    A description of this commit, and it's great work.
237
238    Signed-off-by: Claire Someone <name@domain>
239    Signed-off-by: Ferris Crab <name@domain>
240
241When you re-send patches, revised or not, it would be very good to document the
242changes compared to the previous revision in the commit message and/or the
243merge request. If you have already received Reviewed-by or Acked-by tags, you
244should evaluate whether they still apply and include them in the respective
245commit messages. Otherwise the tags may be lost, reviewers miss the credit they
246deserve, and the patches may cause redundant review effort.
247
248For further reading, please see
249`'on commit messages' <http://who-t.blogspot.de/2009/12/on-commit-messages.html>`_
250as a general guideline on what commit messages should contain.
251
252------------------------------------------------------------------------------
253Coding Style
254------------------------------------------------------------------------------
255
256Please see the `CODING_STYLE.md
257<https://gitlab.freedesktop.org/libinput/libinput/blob/master/CODING_STYLE.md>`_
258document in the source tree.
259
260------------------------------------------------------------------------------
261Tracking patches and follow-ups
262------------------------------------------------------------------------------
263
264Once submitted to GitLab, your patches will be reviewed by the libinput
265development team on GitLab. Review may be entirely positive and result in your
266code landing instantly, in which case, great! You're done. However, we may ask
267you to make some revisions: fixing some bugs we've noticed, working to a
268slightly different design, or adding documentation and tests.
269
270If you do get asked to revise the patches, please bear in mind the notes above.
271You should use ``git rebase -i`` to make revisions, so that your patches
272follow the clear linear split documented above. Following that split makes
273it easier for reviewers to understand your work, and to verify that the code
274you're submitting is correct.
275
276A common request is to split single large patch into multiple patches. This can
277happen, for example, if when adding a new feature you notice a bug in
278libinput's core which you need to fix to progress. Separating these changes
279into separate commits will allow us to verify and land the bugfix quickly,
280pushing part of your work for the good of everyone, whilst revision and
281discussion continues on the larger feature part. It also allows us to direct
282you towards reviewers who best understand the different areas you are
283working on.
284
285When you have made any requested changes, please rebase the commits, verify
286that they still individually look good, then force-push your new branch to
287GitLab. This will update the merge request and notify everyone subscribed to
288your merge request, so they can review it again.
289
290There are also many GitLab CLI clients, if you prefer to avoid the web
291interface. It may be difficult to follow review comments without using the
292web interface though, so we do recommend using this to go through the review
293process, even if you use other clients to track the list of available
294patches.
295
296