Re: [RFC PATCH libinput] udev: add libinput_udev_rescan_devices()

2014-03-21 Thread Jonas Ådahl
On Fri, Mar 21, 2014 at 12:27:45AM -0400, Jasper St. Pierre wrote:
 So you're saying that every time we're suspended, we simply throw out the
 entire context and drop all the devices on the floor, as if you just
 unplugged all of them?

No, what I meant was possible was:

1. start
2. resume devices
3. create libinput context

...

4. suspend libinput context
5. pause devices

...

6. resume devices
7. resume libinput context

And I mean this instead of doing

1. start
2. create libinput context
3. resume devices
4. rescan for devices

...

5. suspend libinput context
6. pause devices

...

7. resume devices
8. resume libinput context
9. rescan for devices


Jonas

 
 I suppose I just never thought of that. On first though, I don't see
 anything wrong with that.
 
 If that's what we should do, should we remove libinput_suspend /
 libinput_resume then?
 
 
 On Mon, Mar 17, 2014 at 11:21 PM, Peter Hutterer
 peter.hutte...@who-t.netwrote:
 
  On Sat, Mar 15, 2014 at 07:59:29PM +0100, Jonas Ådahl wrote:
   On Thu, Mar 13, 2014 at 04:18:20PM +1000, Peter Hutterer wrote:
When a libinput context for a given seat is initialized, not all
  devices may
be available. Some or all devices may be paused by systemd-logind.
  Waiting for
a unplug event is not appropriate here as the devices are physically
available, just prevented from getting access.
   
Add a libinput_udev_rescan_devices() function that triggers a scan of
  all
devices on the current udev seat. Devices that do not exist on the
  seat are
added, devices that already exist on the seat but have been revoked are
removed.
   
Note that devices that have been physically removed are not removed,
  instead
we wait for the udev event to handle this for us.
   
Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
---
The idea here is basically to start a udev context as usual. If the
compositor doesn't have the session, open_restricted will fail. Once
  the
ResumeDevice signals are handled by the compositor it can ask libinput
  to
rescan the device list to add the ones that failed before (or remove
  revoked
ones).
   
Notes on why this approach:
* libinput_device_suspend()/resume() seems nicer at first but if a
  device
  fails to open, we don't have a libinput_device context. handling that
  would make the API complicated since we cannot guarantee that all
  libinput_device_* functions (specificall has_capability) work on all
  devices anymore.
* I suspect in the 90% case the the PauseDevice/ResumeDevice signals
  come in
  in a batch anyway, so the compositor should be able to optimise this
  to
  one single call
* this is a udev specific call, for the path backend the compositor
  can and
  should maintain the devices manually anyway
* EVIOCGVERSION was picked because it always succeeds, except after
  revoke
   
This is an RFC at this point, let me know if that approach works.
  Still need
to write tests and better evdev duplicate detection - right now there
  is a
race condition that could remove the wrong device.
  
   Hi,
  
   So what this patch is trying to solve is handling the following flow:
  
   * create libinput udev context
- some or all devices will fail to open due to being paused
   * devices are resumed
  
   What stops us from simply doing
  
   * devices are resumed
   * create libinput udev context
 
  Jasper? you can answer that better than me
 
   As you say, a compositor should be able to know when it should rescan,
   and in most cases (?) before this, we won't get a single device anyway
   so whats the point of creating earlier than that? For resuming after
   session switch I suppose we'd have the same problem, but this would then
   just work the same:
  
   * devices are resumed
   * resume libinput context
 
  the question here is: is there a use-case for a single device to be
  paused/resumed outside of the usual process? David?
 
  We're struggling with this in X but that's caused by a completely different
  problem and is rather orthogonal to this.
 
  Cheers,
 Peter
 
 
 src/evdev.c | 15 +++
 src/evdev.h |  2 ++
 src/libinput.h  | 21 +
 src/udev-seat.c | 46 +-
 4 files changed, 79 insertions(+), 5 deletions(-)
   
diff --git a/src/evdev.c b/src/evdev.c
index ba7c8b3..018fbb1 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -790,3 +790,18 @@ evdev_device_destroy(struct evdev_device *device)
free(device-sysname);
free(device);
 }
+
+int
+evdev_device_is_alive(struct evdev_device *device)
+{
+   int rc;
+   int version;
+
+   rc = ioctl(device-fd, EVIOCGVERSION, version);
+
+   if (rc  0  errno != ENODEV)
+   log_info(evdev: %s failed with errno %d (%s)\n,
+__func__, errno, 

Re: [RFC PATCH libinput] udev: add libinput_udev_rescan_devices()

2014-03-21 Thread David Herrmann
Hi

On Fri, Mar 21, 2014 at 6:14 AM, Peter Hutterer
peter.hutte...@who-t.net wrote:
 On Fri, Mar 21, 2014 at 12:27:45AM -0400, Jasper St. Pierre wrote:
 So you're saying that every time we're suspended, we simply throw out the
 entire context and drop all the devices on the floor, as if you just
 unplugged all of them?

 fwiw, this is effectively what happens internally anyway, you get removed
 events for every device on suspend, and added events on resume for those
 still there.

 I suppose I just never thought of that. On first though, I don't see
 anything wrong with that.

 If that's what we should do, should we remove libinput_suspend /
 libinput_resume then?

 libinput_suspend/resume only tear down the devices, but not anything
 else. there isn't much global state that's kept across suspend/resume yet
 (seats are one example though) but the biggest difference is that that you
 can't use _any_ object around after libinput_destroy(). suspend/resume
 keeps them alive until you unref them.

Just to verify the assumptions: Yes, the kernel throws away the whole
context, but in user-space you can try to keep your devices around and
just resync them on resume. At least that's what I did. And use the
real udev-events to decide when the device has really gone away.

Thanks
David
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH libinput 3/3] Expand documentation for libinput_udev_create_for_seat

2014-03-21 Thread Jonas Ådahl
On Fri, Mar 21, 2014 at 02:13:22PM +1000, Peter Hutterer wrote:
 Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
 ---
  src/libinput.h | 6 ++
  1 file changed, 6 insertions(+)
 
 diff --git a/src/libinput.h b/src/libinput.h
 index d6bf9f8..3e09871 100644
 --- a/src/libinput.h
 +++ b/src/libinput.h
 @@ -691,6 +691,12 @@ struct libinput_interface {
   * the given seat ID. New devices or devices removed will appear as events
   * during libinput_dispatch.
   *
 + * libinput_udev_create_for_seat() fails for internal values only. No

What does internal values mean? It fails for invalid input, OOM, libudev
errors, etc, but how is that relevant? Maybe its enough to just say that
this call will not fail even if no input devices are successfully added,
and that if not supported, or if failed to open, devices will be ignored
until next resume.

Jonas

 + * guarantee is made that a device is available once the call finishes, and
 + * only devices handled by libinput are avialable. Devices that cannot be
 + * opened in @ref libinput_interface::open_restricted or do not match
 + * libinput requirements are ignored.
 + *
   * @param interface The callback interface
   * @param user_data Caller-specific data passed to the various callback
   * interfaces.
 -- 
 1.8.5.3
 
 ___
 wayland-devel mailing list
 wayland-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/wayland-devel
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


Re: [PATCH libinput 2/3] udev: factor out device_removed handling

2014-03-21 Thread Jonas Ådahl
On Fri, Mar 21, 2014 at 02:13:21PM +1000, Peter Hutterer wrote:
 No functional changes
 
 Signed-off-by: Peter Hutterer peter.hutte...@who-t.net
 ---
 I needed this for the rescan patch but it makes the calls more symmetrical,
 so we might as well push it independently.

Reviewed-by: Jonas Ådahl jad...@gmail.com on all 3 patches, with some
comments inline in this one and the documentation patch.


Jonas

 
  src/udev-seat.c | 41 +++--
  1 file changed, 23 insertions(+), 18 deletions(-)
 
 diff --git a/src/udev-seat.c b/src/udev-seat.c
 index e622de2..366c92b 100644
 --- a/src/udev-seat.c
 +++ b/src/udev-seat.c
 @@ -116,6 +116,26 @@ device_added(struct udev_device *udev_device, struct 
 udev_input *input)
   return 0;
  }
  
 +static void
 +device_removed(struct udev_device *udev_device, struct udev_input *input)
 +{
 + const char *devnode;
 + struct evdev_device *device, *next;
 + struct udev_seat *seat;
 +
 + devnode = udev_device_get_devnode(udev_device);
 + list_for_each(seat, input-base.seat_list, base.link) {
 + list_for_each_safe(device, next,
 + seat-base.devices_list, base.link)

Indentation is off here now. While it was not like that to begin with,
here should actually be braces as well.

 + if (!strcmp(device-devnode, devnode)) {
 + log_info(input device %s, %s removed\n,
 + device-devname, 
 device-devnode);

And here as well.

 + evdev_device_remove(device);
 + break;
 + }
 + }
 +}
 +
  static int
  udev_input_add_devices(struct udev_input *input, struct udev *udev)
  {
 @@ -155,10 +175,7 @@ evdev_udev_handler(void *data)
  {
   struct udev_input *input = data;
   struct udev_device *udev_device;
 - struct evdev_device *device, *next;
   const char *action;
 - const char *devnode;
 - struct udev_seat *seat;
  
   udev_device = udev_monitor_receive_device(input-udev_monitor);
   if (!udev_device)
 @@ -171,22 +188,10 @@ evdev_udev_handler(void *data)
   if (strncmp(event, udev_device_get_sysname(udev_device), 5) != 0)
   goto out;
  
 - if (!strcmp(action, add)) {
 + if (!strcmp(action, add))
   device_added(udev_device, input);
 - }
 - else if (!strcmp(action, remove)) {
 - devnode = udev_device_get_devnode(udev_device);
 - list_for_each(seat, input-base.seat_list, base.link) {
 - list_for_each_safe(device, next,
 -seat-base.devices_list, base.link)
 - if (!strcmp(device-devnode, devnode)) {
 - log_info(input device %s, %s 
 removed\n,
 -  device-devname, 
 device-devnode);
 - evdev_device_remove(device);
 - break;
 - }
 - }
 - }
 + else if (!strcmp(action, remove))
 + device_removed(udev_device, input);
  
  out:
   udev_device_unref(udev_device);
 -- 
 1.8.5.3
 
 ___
 wayland-devel mailing list
 wayland-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/wayland-devel
___
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel


ANNOUNCE: New Wayland live CD

2014-03-21 Thread nerdopolis
Hi.


I am announcing new ISOs for my Wayland Live CD, which is named after my 
favorite celebrity.


You can find the new ISOs here:
https://sourceforge.net/projects/rebeccablackos/files/2014-03-21/

Once again, the larger ISO is only larger because it has more development 
headers, binaries with all the symbols, and more software installed to compile 
and download source. The smaller ISO has no other reductions in the user 
experience.

Also please note that all of my checkinstall built packages have the -rbos 
suffix, and mostly reside in /opt. So Wayland master is provided by the 
wayland-rbos package, NOT the libwayland package that comes from the system 
repos for example. 

Except there are small changes that I made for backporting a few things for the 
release
DIFF of the changes to the SVN: http://pastebin.com/sDfA2izd

They currently contain:
  * Wayland Master
  * Weston Master 
  * Wayland enabled Clutter
  * Wayland enabled SDL
  * Wayland enabled GTK
  * Wayland enabled QT
  * Wayland enabled EFL/Elementary
  * Wayland enabled mplayer
  * Wayland enabled gstreamer
  * Orbital for Wayland (selectable at login)   
https://github.com/giucam/orbital
  * Hawaii for Wayland (selectable at login) https://github.com/mauios
  * KDE Frameworks Wayland programs 
  * Native Calligra Wayland programs
  * Wayland enabled Gnome-shell (selectable at login) *Does not work on 
Virtualbox, except it can run nested
  * A graphical utility for configuring udev for weston multiseat/multi pointer
  * A rudimentary but functional Wayland login manager written in Bash, that 
supports user switching and session selection. 
  * Wayland enabled Enlightenment E19 *Does not work on Virtualbox
  *hardcoded screen size
  * SWC tiling Wayland server (use super+enter for terminal, and super+r for 
dmenu) *Does not work on Virtualbox, and does not run nested. Only tested on 
Intel (selectable at login)   https://github.com/michaelforney/swc
  * Menu options to run Gnome Shell Wayland, Enlightenment e19 Wayland, 
Orbital, SWC, and Hawaii desktops as nested sessions. 

-
  More security on KMS supported cards, and will be more secure on FB, once bug 
https://bugs.freedesktop.org/show_bug.cgi?id=73782 is fixed and I remove the 
setfacls from waylandloginmanager, by relying on udev's UACCESS attribute, 
instead of global ACLs

  Waylandloginmanager's loginmanagerdisplay weston instance, as well as all 
Zenity dialogs for the waylandloginmanager run as the daemom user, instead of 
root.

  Waylandloginmanager has been improved to support entering a custom user name, 
if it doesn't appear from the user list, the user list shows the real names, 
the control fifo is write only for a standard user, so that they can't read the 
FIFO before the loginmanger, and a seperate FIFO for registering session 
information is root only, so that it can't be filled with fake data.  

  Waylandloginmanager now handles the cancel button being pressed in the Zenity 
dialogs

  Waylandloginmanager now doesn't allow the user to flood with multiple 
login/info dialogs open at a time by mistake, or by a malicious program sending 
a command to the FIFO repeatedly to try to create a low memory condition.

  Waylandloginmanager now reads the loginmanager_control FIFO with a maximum 
read size, so that a local user can't cause it to eat memory and crash by 
filling it with /dev/zero, however under a unit test, I was able to crash a 
bash process reading a FIFO, by filling it up with /dev/random. I don't know 
how to reproduce it, but it could be a bug in bash, and I don't know if the 
bash process can be exploited with this bug.

  Waylandloginmanager now has a Weston independent dialog for user actions, 
without the mandatory launchers in the panel, (even though they are still 
currently configured).

  Usability fixes.

  Wayland/Weston 1.4+

  SWC

  More native KDE applications
  
  mutter-wayland has been built to a recent revision, GTK is backported to the 
3.11.0 tag for now (because later versions use XDG_Shell, which isn't yet 
supported by all sessions or servers.

  Contains the latest KDE Frameworks, which allows many KDE applications to run 
as native Wayland clients

-

***There is no password for the Live Session User (beccaholic), while autologin 
is enabled when starting as a live CD, if you get prompted for a password when 
starting a second login session, the password field is blank***
If you choose to install, the live session user does not get added, and instead 
the login becomes the default username and password that is configured at the 
installation wizard

In order for Enlightenment to start, you need to pass wlminputinsecure to the 
kernel command line. This argument is picked up by the Waylandloginmanager, and 
grant all plugdev (default) users permissions to the devices in /dev/input/* at 
all times. This allows local users to eavesdrop on these files, (which is the 
users input), but it's a temporary 

Re: ANNOUNCE: New Wayland live CD

2014-03-21 Thread nerdopolis
On Friday, March 21, 2014 08:35:40 PM nerdopolis wrote:
 Hi.
 
 
 I am announcing new ISOs for my Wayland Live CD, which is named after my 
 favorite celebrity.
 
 
 You can find the new ISOs here:
 https://sourceforge.net/projects/rebeccablackos/files/2014-03-21/
 
 Once again, the larger ISO is only larger because it has more development 
 headers, binaries with all the symbols, and more software installed to 
 compile and download source. The smaller ISO has no other reductions in the 
 user experience.
 
 Also please note that all of my checkinstall built packages have the -rbos 
 suffix, and mostly reside in /opt. So Wayland master is provided by the 
 wayland-rbos package, NOT the libwayland package that comes from the system 
 repos for example. 
 
 Except there are small changes that I made for backporting a few things for 
 the release
 DIFF of the changes to the SVN: http://pastebin.com/sDfA2izd
 
 They currently contain:
   * Wayland Master
   * Weston Master 
   * Wayland enabled Clutter
   * Wayland enabled SDL
   * Wayland enabled GTK
   * Wayland enabled QT
   * Wayland enabled EFL/Elementary
   * Wayland enabled mplayer
   * Wayland enabled gstreamer
   * Orbital for Wayland (selectable at login) 
 https://github.com/giucam/orbital
   * Hawaii for Wayland (selectable at login)   https://github.com/mauios
   * KDE Frameworks Wayland programs 
   * Native Calligra Wayland programs
   * Wayland enabled Gnome-shell (selectable at login) *Does not work on 
 Virtualbox, except it can run nested
   * A graphical utility for configuring udev for weston multiseat/multi 
 pointer
   * A rudimentary but functional Wayland login manager written in Bash, that 
 supports user switching and session selection. 
   * Wayland enabled Enlightenment E19 *Does not work on Virtualbox
   *hardcoded screen size
   * SWC tiling Wayland server (use super+enter for terminal, and super+r for 
 dmenu) *Does not work on Virtualbox, and does not run nested. Only tested on 
 Intel (selectable at login) https://github.com/michaelforney/swc
   * Menu options to run Gnome Shell Wayland, Enlightenment e19 Wayland, 
 Orbital, SWC, and Hawaii desktops as nested sessions. 
 
 -
   More security on KMS supported cards, and will be more secure on FB, once 
 bug https://bugs.freedesktop.org/show_bug.cgi?id=73782 is fixed and I remove 
 the setfacls from waylandloginmanager, by relying on udev's UACCESS 
 attribute, instead of global ACLs
 
   Waylandloginmanager's loginmanagerdisplay weston instance, as well as all 
 Zenity dialogs for the waylandloginmanager run as the daemom user, instead of 
 root.
 
   Waylandloginmanager has been improved to support entering a custom user 
 name, if it doesn't appear from the user list, the user list shows the real 
 names, the control fifo is write only for a standard user, so that they can't 
 read the FIFO before the loginmanger, and a seperate FIFO for registering 
 session information is root only, so that it can't be filled with fake data.  
 
   Waylandloginmanager now handles the cancel button being pressed in the 
 Zenity dialogs
 
   Waylandloginmanager now doesn't allow the user to flood with multiple 
 login/info dialogs open at a time by mistake, or by a malicious program 
 sending a command to the FIFO repeatedly to try to create a low memory 
 condition.
 
   Waylandloginmanager now reads the loginmanager_control FIFO with a maximum 
 read size, so that a local user can't cause it to eat memory and crash by 
 filling it with /dev/zero, however under a unit test, I was able to crash a 
 bash process reading a FIFO, by filling it up with /dev/random. I don't know 
 how to reproduce it, but it could be a bug in bash, and I don't know if the 
 bash process can be exploited with this bug.
 
   Waylandloginmanager now has a Weston independent dialog for user actions, 
 without the mandatory launchers in the panel, (even though they are still 
 currently configured).
 
   Usability fixes.
 
   Wayland/Weston 1.4+
 
   SWC
 
   More native KDE applications
   
   mutter-wayland has been built to a recent revision, GTK is backported to 
 the 3.11.0 tag for now (because later versions use XDG_Shell, which isn't yet 
 supported by all sessions or servers.
 
   Contains the latest KDE Frameworks, which allows many KDE applications to 
 run as native Wayland clients
 
 -
 
 ***There is no password for the Live Session User (beccaholic), while 
 autologin is enabled when starting as a live CD, if you get prompted for a 
 password when starting a second login session, the password field is blank***
 If you choose to install, the live session user does not get added, and 
 instead the login becomes the default username and password that is 
 configured at the installation wizard
 
 In order for Enlightenment to start, you need to pass wlminputinsecure to the 
 kernel command line. This argument is picked up by the Waylandloginmanager, 
 and grant all plugdev (default) users