Commit graph

674 commits

Author SHA1 Message Date
Derek Foreman f0d39b2243
weston: Set CLOEXEC on stdin
We don't want to leak this into apps launched from the panel.

stdout and stderr are left for now because some things launched
by weston - such as weston-keyboard - share weston's log by
printing to those fds.

I'm singling out stdin because it's never needed by a child process
and because it's value is 0, which makes it easy to accidentally
do bad things to (commit 5c611d933f)

Signed-off-by: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-03-24 21:16:43 +01:00
Emmanuel Gil Peyrot 11ae2a3036 compositor-drm: pageflip timeout implementation
Weston will not repaint until previous update has been acked by a
pageflip event coming from the drm driver. However, some buggy drivers
won’t return those events or will stop sending them at some point and
Weston output repaints will completely freeze. To ease developers’ task
in testing their drivers, this patch makes compositor-drm use a timer
to detect cases where those pageflip events stop coming.

This timeout implementation is software only and includes basic
features usually found in a watchdog. We simply exit Weston gracefully
with a log message and an exit code when the timout is reached.

The timeout value can be set via weston.ini by adding a
pageflip-timeout=<MILLISECONDS> entry under [core]
section. Setting it to 0 disables the timeout feature.

v2:
- Made sure we would get both the pageflip and the vblank events before
  stopping the timer.
- Reordered the error and success cases in
  drm_output_pageflip_timer_create() to be more in line with the rest
  of the code.

v3:
- Reordered (de)arming of the timer with the code around it to avoid it
  being rearmed before the current dearming.
- Return the proper value for the dispatcher in the pageflip_timeout
  callback.
- Also display the output name in case the timer fires.

v4:
- Reordered a forgotten timer rearming after its drmModePageFlip().

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=83884
Signed-off-by: Frederic Plourde <frederic.plourde at collabora.co.uk>
Signed-off-by: Emmanuel Gil Peyrot <emmanuel.peyrot@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-03-07 16:42:40 +02:00
Daniel Stone f589dac2b0 screen-share: Use wl_list_for_each_safe on destroy
Destroying the shared seat removes the link from so->seat_list.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Acked-by: Bryce Harrington <bryce@osg.samsung.com>
2017-02-21 12:28:15 -08:00
Daniel Stone f81959e39d screen-share: Avoid NULL dereference
Don't try to dereference the seat if it's NULL.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
2017-02-21 12:27:08 -08:00
Armin Krezović e6b7136641
compositor: Improve xwayland warning message
And fix formatting.

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2017-02-09 21:51:30 +01:00
Ucan, Emre (ADITG/SW1) 1298073b5a systemd: fix Wincompatible-pointer-type
The parameter is passed in safe_strtoint function.
The function expects its parameters in int32_t
data type. Therefore, c compiler throws a
-Wincompatible-pointer-type warning.

This patch changes data type of the parameter
to int32_t.

Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-01-27 17:25:11 +02:00
Armin Krezović 605ac8e685 compositor-drm: Restore use-current-mode functionality
It got lost during the porting to the config API.

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-01-26 14:14:14 +00:00
Ben be9c7d8135 Remove dbus-launch from weston.desktop
Most display managers handle starting a dbus session daemon for you, so
it does not make sense to start our own. Without this patch, if you run
weston from gdm, programs cannot connect to the dbus session daemon.

Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-01-18 12:21:57 +00:00
Quentin Glidic 6d3887baec
weston: Add a specific option to load XWayland
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-01-17 18:25:01 +01:00
Quentin Glidic da01c1d105
weston: Make the shell entrypoint specific
This avoids loading a shell as a module, so we are sure to have only one
shell loaded at a time.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-01-17 18:24:58 +01:00
Quentin Glidic 8af2beccbd
weston: Properly namespace modules entrypoint
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-01-17 18:24:56 +01:00
Quentin Glidic 3d7ca3b9ea
libweston: Properly namespace modules entrypoint
Use different functions so we cannot load a libweston common module in
weston directly or the other way around.

Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2017-01-17 18:24:53 +01:00
Daniel Stone beb97e5f79 libweston: Make module loading safe against long paths
Avoid any buffer overflows here by checking we don't go over PATH_MAX
with stupid module names.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-11-30 10:27:51 +00:00
Quentin Glidic 46dc9b440b libweston: Move text_backend_* to weston.h
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-11-21 11:03:20 +00:00
Daniel Stone 97863d6f0d text-input: Clear out context->input pointer
If we destroy the text_input (e.g. due to surface deactivation) whilst
the IM manager (the client holding the input_method_context resource,
usually weston-keyboard) sends an event, we can hit a segfault in
text-backend. This is because we free the text_input structure, but
don't actually clear the context->input structure even when we send the
deactivate event.

This is clearly intended to be catered for, since context->input is
always checked for NULL before we relay any events.

This is enough to fix one cause of text-test failing, but it's
ultimately error-prone until we have a no-op test-shell; there is still
a race where weston-desktop-shell can launch weston-keyboard before
text-test manages to bind zwp_text_input_manager.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Maniphest Tasks: https://phabricator.freedesktop.org/T7615
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-11-18 15:42:42 +02:00
Daniel Díaz 75b7197f4e Add configuration option for no input device.
As it has been discussed in the past [1], running Weston
without any input device at launch might be beneficial for
some use cases.

Certainly, it's best for the vast majority of users (and
the project) to require an input device to be present, as
to avoid frustration and hassle, but for those brave souls
that so prefer, this patch lets them run without any input
device at all.

This introduces a simple configuration in weston.ini:
  [core]
  require-input=true

True is the default, so no behavioral change is introduced.

[1] https://lists.freedesktop.org/archives/wayland-devel/2015-November/025193.html

Signed-off-by: Daniel Díaz <daniel.diaz@linaro.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
2016-10-22 15:04:58 +01:00
Armin Krezović 2045016d8e
compositor-wayland: Convert fullscreen flag to bool
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2016-10-14 10:42:17 +02:00
Armin Krezović 7f1c0b8a35
compositor-wayland: Convert sprawl flag to boolean
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2016-10-10 13:42:59 +02:00
Armin Krezović 7e71b8755a
compositor-wayland: Convert use-pixman flag to boolean
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2016-10-10 13:41:18 +02:00
Armin Krezović c3d2f960d2 weston: Port X11 backend to new output handling API
This is a complete port of the X11 backend that
uses recently added output handling API for output
configuration.

- Output can be configured at runtime by passing the
  necessary configuration parameters, which can be
  filled in manually, obtained from the configuration
  file or obtained from the command line using
  previously added functionality. It is required that
  the scale and transform values are set using the
  previously added functionality.

- Output can be created at runtime using the output
  API. The output creation only creates a pending
  output, which needs to be configured the same way as
  mentioned above.

Same as before, a single output is created at runtime
using the default configuration or a configuration
parsed from the command line. The output-count
functionality is also preserved, which means more than
one output can be created initially, and more outputs can
be added at runtime using the output API.

v2:

 - Fix wet_configure_windowed_output_from_config() usage.
 - Call x11_output_disable() explicitly from
   x11_output_destroy().

v3:

 - Remove unneeded free().
 - Disallow calling x11_output_configure more than once.
 - Remove unneeded checks for output->name == NULL as that
   has been disallowed.
 - Use weston_compositor_add_pending_output().
 - Bump weston_x11_backend_config version to 2.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-10-05 14:59:09 +03:00
Armin Krezović 174448a91b weston: Port Wayland backend to new output handling API
This is a complete port of the Wayland backend that
uses the recently added output handling API for output
configuration.

- Output can be configured at runtime by passing the
  necessary configuration parameters, which can be
  filled in manually, obtained from the configuration
  file or obtained from the command line using
  previously added functionality. It is required that
  the scale and transform values are set using the
  previously added functionality.

- Output can be created at runtime using the output
  API. The output creation only creates a pending
  output, which needs to be configured the same way as
  mentioned above.

However, the backend can behave both as windowed backend
and as a backend that issues "hotplug" events, when
running under fullscreen shell or with --sprawl command
line option. The first case was covered by reusing
previously added functionality. The second case required
another API to be introduced and implemented into both
the backend and compositor for handling output setup.

After everything has been set, output needs to be
enabled manually using weston_output_enable().

v2:

 - Fix wet_configure_windowed_output_from_config() usage.
 - Call wayland_output_disable() explicitly from
   wayland_output_destroy().

v3:

 - Get rid of weston_wayland_output_api and rework output
   creation and configuration in case wayland backend is
   started with --sprawl or on fullscreen-shell.
 - Remove unneeded free().
 - Disallow calling wayland_output_configure more than once.
 - Remove unneeded checks for output->name == NULL as that
   has been disallowed.
 - Use weston_compositor_add_pending_output().

v4:

 - Drop unused fields from weston_wayland_backend_config
   and bump WESTON_WAYLAND_BACKEND_CONFIG_VERSION to 2.
 - Move output creation to backend itself when
   --fullscreen is used.
 - Prevent possible duplicated output names by assigning
   a different name to outputs created without any
   configuration specified.

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-10-05 14:54:12 +03:00
Armin Krezović 8f1dca1369 weston: Port RDP backend to new output handling API
This is a complete port of the RDP backend that uses
the recently added output handling API for output
configuration.

Output can be configured at runtime by passing the
necessary configuration parameters, which can be
filled in manually or obtained from the command line
using previously added functionality. It is required
that the scale and transform values are set using
the previously added functionality.

After everything has been set, output needs to be
enabled manually using weston_output_enable().

v2:

 - Rename output_configure() to output_set_size()
   in plugin API and describe it.
 - Manually fetch parsed_options from wet_compositor.
 - Call rdp_output_disable() explicitly from
   rdp_output_destroy().

v3:

 - Disallow calling rdp_output_set_size more than once.
 - Manually assign a hardcoded name to an output as that's
   now mandatory.
 - Use weston_compositor_add_pending_output().
 - Bump weston_rdp_backend_config version to 2.

Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-10-03 14:24:08 +03:00
Armin Krezović 7fb17756fc weston: Port headless backend to new output handling API
This is a complete port of the headless backend that
uses the recently added output handling API for output
configuration.

- Output can be configured at runtime by passing the
  necessary configuration parameters, which can be
  filled in manually, obtained from the configuration
  file or obtained from the command line using
  previously added functionality. It is required that
  the scale and transform values are set using the
  previously added functionality.

- Output can be created at runtime using the output
  API. The output creation only creates a pending
  output, which needs to be configured the same way as
  mentioned above.

After everything has been set, output needs to be
enabled manually using weston_output_enable().

Same as before, a single output is created at runtime
using the default configuration or a configuration
parsed from the command line. The no-outputs
functionality is also preserved, which means that no
output will be created initially, but more outputs can
be added at runtime using the output API.

New feature:

This patch also adds, as a bonus of using shared
functionality, support for setting options for outputs
created by this backend in the weston config file in
addition to setting them from the command line.

v2:

 - Fix wet_configure_windowed_output_from_config() usage.
 - Call headless_output_disable() explicitly from
   headless_output_destroy().

v3:

 - Add scale support to output width and height.
 - Use scaled values in calls to various functions which
   require width and height.
 - Disallow calling headless_output_configure more than once.
 - Remove unneeded checks for output->name == NULL as that
   has been disallowed.
 - Use weston_compositor_add_pending_output().
 - Bump weston_headless_backend_config version to 2.

Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-10-03 14:24:08 +03:00
Armin Krezović 6ba369dad4 weston: Port fbdev backend to new output handling API
This is a complete port of the fbdev backend that uses
the recently added output handling API for output
configuration.

It is required that the scale and transform values are
set using the previously added functionality.

After everything has been set, output needs to be
enabled manually using weston_output_enable().

v2:

 - Use weston_compositor_add_pending_output().
 - Bump weston_fbdev_backend_config version to 2.

Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-10-03 14:24:08 +03:00
Armin Krezović 083681325b weston: Port DRM backend to new output handling API
This is a complete port of the DRM backend that uses
the recently added output handling API for output
configuration.

Output can be configured at runtime by passing the
necessary configuration parameters, which can be
filled in manually or obtained from the configuration
file using previously added functionality. It is
required that the scale and transform values are set
using the previously added functionality.

After everything has been set, output needs to be
enabled manually using weston_output_enable().

v2:

 - Added missing drmModeFreeCrtc() to drm_output_enable()
   cleanup list in case of failure.
 - Split drm_backend_disable() into drm_backend_deinit()
   to accomodate for changes in the first patch in the
   series. Moved restoring original crtc to
   drm_output_destroy().

v3:

 - Moved origcrtc allocation to drm_output_set_mode().
 - Swapped connector_get_current_mode() and
   drm_output_add_mode() calls in drm_output_set_mode()
   to match current weston.
 - Moved crtc_allocator and connector_allocator update
   from drm_output_enable() to create_output_for_connector()
   to avoid problems when more than one monitor is connected
   at startup and crtc allocator wasn't updated before
   create_output_for_connector() was called second time,
   resulting in one screen being turned off.
 - Moved crtc_allocator and connector_allocator update from
   drm_output_deinit() to drm_output_destroy(), as it
   should not be called on drm_output_disable().
 - Use weston_compositor_add_pending_output().
 - Bump weston_drm_backend_config version to 2.

v4:

 - Reset output->original_crtc to NULL if drm_output_set_mode()
   fails.
 - Remove unneeded log message when disabling an output when a
   pageflip is pending.
 - Document that create_output_for_connector() takes ownership
   of the connector.
 - Free the connector if create output conditionals are not met
   in create_outputs() and update_outputs().

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-10-03 14:22:50 +03:00
Armin Krezović a3666d214f compositor: Implement output configuration using windowed_output_api
This implements output configuration for outputs which use
previously added weston_windowed_output_api. The function
takes an output that's to be configured, default configuration
that's to be set in case no configuration is specified in
the config file or on command line and optional third argument,
parsed_options, which will override defaults and options for
configuration if they are present.

This also introduces new compositor specific functions for
setting output's scale and transform from either hardcoded
default, config file option or command line option.

Pending output handling helpers have also been introduced.

v2:

 - Adapt to changes in previous patch.
 - Fix potential double free().
 - Remove redundant variables for scale and transform setting.
 - Drop parsed_options helper and parameter and use it directly
   in wet_configure_windowed_output_from_config().

v3:

 - Remove unneeded checks for output->name == NULL as that
   has been disallowed.
 - Stop printing mode if it's invalid, as it can be NULL.

Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-10-03 13:51:24 +03:00
Bryce Harrington 25a2bdd814 Switch to use safe_strtoint instead of strtol
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-08-06 18:19:22 -07:00
Bryce Harrington 913d7c15f7 Standardize error checking for strtol calls
This tightens up the strtol() error checking in several places where it
is used for parsing environment variables, and in the backlight
interface that is reading numbers from files under /sys/class/backlight.
All of these uses are expecting strings containing decimal numbers and
nothing else, so the error checking can all be tightened up and made
consistent with other strtol() calls.

This follows the error checking style used in Wayland
(c.f. wayland-client.c and scanner.c) and c.f. commit cbc05378.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-08-06 18:19:01 -07:00
Emil Velikov 7fe47f314b libweston: use new versioning scheme
Use the documented libweston-$major.so.0.$minor.$patch scheme.

An (almost) identical one is used by GLIB, GDK{2,3}, QT5, json-glib and
others.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2016-08-02 13:52:58 +03:00
Armin Krezović 78a36373f6 compositor: Extend compositor user data
This patch makes the compositor user data a structure
which can be expanded with new fields when necessary.

v2:

Don't export to_wet_compositor

Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-08-02 10:37:39 +03:00
Jussi Kukkonen 649bbce607 include stdint.h for int32_t/uint32_t
Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
2016-07-26 16:26:08 -07:00
Bryce Harrington a8d987d93c systemd: Also force base-10 for the strtol() call
This call is used to parse a time value expressed in usec's, which is
always decimal.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
2016-07-12 19:03:01 -07:00
Bryce Harrington 375759e636 Require base-10 for strtol() calls
The third arg to strtol() specifies the base to assume for the number.
When 0 is passed, as is currently done in option-parser.c, hexadecimal
and octal numbers are permitted and automatically detected and
converted.

This change is an expansion of f6051cbab8
to cover the remaining strtol() calls in Weston, where the routine is
being used to read fds and pids - which are always expressed in base-10.
It also changes the calls in config-parser, used by
weston_config_section_get_int(), which in turn is being used to read
scales, sizes, times, rates, and delays; these are all expressed in
base-10 numbers only.

The benefit of limiting this to base-10 is to eliminate surprises when
parsing numbers from the command line.  Also, by making the code
consistent with other usages of strtol, it may make it possible to
factor out the common code in the future.

Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-07-12 18:46:13 -07:00
Bryce Harrington 1dbdc0bd8a Include space in 'if ('
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2016-07-12 18:45:41 -07:00
Bryce Harrington cff0b1d80f xwayland: Cleanup error message on spawn failure Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-07 10:48:34 -07:00
Bryce Harrington 9335ca5c02 xwayland: Include missing config.h
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2016-07-07 10:48:19 -07:00
Giulio Camuffo 9c764df043 xwayland: make the plugin usable by libweston compositors
This patch follows a similar approach taken to detach the backends from
weston. But instead of passing a configuration struct when loading the
plugin, we use the plugin API registry to register an API, and to get it
in the compositor side.  This API allows to spawn the Xwayland process
in the compositor side, and to deal with signal handling.  A new
function is added in compositor.c to load and init the xwayland.so
plugin.

Also make sure to re-arm the SIGUSR1 when the X server quits.

Signed-off-by: Giulio Camuffo <giuliocamuffo@gmail.com>
[Pekka: moved xwayland/weston-xwayland.c -> compositor/xwayland.c]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2016-07-01 14:34:33 +03:00
Armin Krezović d84deeb173 compositor-headless: Support starting with zero outputs
This patch adds a new command line option which can be
used to tell headless backend not to create any
virtual outputs.

This will be used for output hotplug emulation, where
weston will start with no outputs available, and the
virtual output will be created at runtime.

v2:

- Use bool instead of int for the indicator flag
- Move final newspace to a separate line in command
  line options

Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Armin Krezović <krezovic.armin@gmail.com>
2016-06-27 13:17:05 +03:00
Pekka Paalanen 20436e206e main: log the command line
Write the command line to the log to aid debugging. It needs to be
copied before parsing, because parsing mutates argv.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
2016-06-23 18:14:36 +03:00
Pekka Paalanen 58f98c99f5 Move weston source to compositor/
This is the start of separating weston-the-compositor source files from
libweston source files.

This is moving all the files related to the 'weston' binary. Also the
CMS and systemd plugins are moved.

xwayland plugin is not moved, because it will be turned into a
libweston feature.

To avoid breaking the build, #includes for weston.h are fixed to use
compositor/weston.h. This serves as a reminder that such files may need
further attention: moving to the right directory, or maybe using the
proper -I flags instead.

v2: Move also screen-share.c, and add a note about weston-launch.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Yong Bakos <ybakos@humanoriented.com>
Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Tested-by: Benoit Gschwind <gschwind@gnu-log.net>
Acked-by: Benoit Gschwind <gschwind@gnu-log.net>
[Pekka: rebased]
2016-06-23 17:44:54 +03:00
Kristian Høgsberg 8334bc1ef9 Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.

1) Initially, we had one big repository with protocol code, sample
compositor and sample clients.  We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code.  At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message.  The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.

2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor.  Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example.  Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.

We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 11:04:04 -05:00
Kristian Høgsberg 4c61747a1f x11: Clear X11 selection when we can't bridge the data type 2011-12-29 14:16:42 -05:00
Kristian Høgsberg f258a310bf Fix WL_EVENT_WRITEABLE typo 2011-12-28 22:51:20 -05:00
Kristian Høgsberg 33f8670ee2 x11: Bridge Wayland selections to X11 CLIPBOARD selection
This is the other direction.  The selection bridge will grab the X11
CLIPBOARD selection on behalf of the Wayland client when it sets the
Wayland selection.  Right now only UTF-8 text is supported, but the
data types offered will be taken from the Wayland data source.
2011-12-28 22:42:09 -05:00
Kristian Høgsberg 0050fd7d8b x11: Handle BadWindow errors 2011-12-27 23:01:23 -05:00
Kristian Høgsberg facb558448 x11: Remove destroy listener when X11 window is destroyed 2011-12-27 22:47:51 -05:00
Kristian Høgsberg a42c128201 x11: Store interesting window properties, dump a few more things 2011-12-27 21:36:41 -05:00
Kristian Høgsberg 94110f7bb8 x11: Improvide debugging output a bit 2011-12-27 20:20:46 -05:00
Kristian Høgsberg 8b316f0255 x11: Remove a couple of done TODOs 2011-12-27 14:05:36 -05:00
Kristian Høgsberg 11d0512ce9 compositor: Pull in hash table from protocol
We use it in the X WM implementation, but we don't want it in the core
libraries.
2011-12-27 14:02:40 -05:00
Kristian Høgsberg e7aaec301a x11: Bridge X11 CLIPBOARD selection to Wayland clients 2011-12-27 13:50:04 -05:00
Kristian Høgsberg 09e2692403 compositor-x11: Use ARRAY_LENGTH macro from wayland-util.h 2011-12-23 13:33:45 -05:00
Kristian Høgsberg 03cb5cf9a7 compositor: Handle disappearing surfaces and input devices for touch 2011-12-22 14:47:44 -05:00
Kristian Høgsberg 558949b67b clients: Add simple-touch client for testing touch events. 2011-12-22 13:45:50 -05:00
Kristian Høgsberg 3937354eef evdev: Store positions for all touch points in the evdev device
We need to store all touchpoint positions so that if we just get an
ABS_MT_POSITION_X or Y event, we can pull the other coordinate from the
cache.  And we need this across invocations of evdev_input_device_data(),
so the accumulator approach doesn't work.

Instead, we go back to the approach of storing all this state in the
evdev device struct and we might as well just move the rel and abs state
there too.
2011-12-22 11:32:39 -05:00
Kristian Høgsberg 3543ff4f82 compositor: Send touch_up before clearing touch focus
Otherwise it never gets sent.
2011-12-22 11:32:39 -05:00
Tiago Vignatti 1f221fff71 compositor: Send out touch events accordingly
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-22 11:13:05 -05:00
Tiago Vignatti 22c6bcec9c evdev: Add ABS_MT_* support for direct touch devices
This adds ABS_MT_* support for direct touch devices and notifies
the compositor.  The compositor has a stub for now.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-22 11:13:04 -05:00
Kristian Høgsberg 773d13b543 compositor: Make surface picking not depend on an input device 2011-12-22 11:13:04 -05:00
Pekka Paalanen 3429a72597 compositor: fix uniform handling for fade_output()
fade_output() is strange in that it manufactures a wlsc_surface object
by hand, and then calls wlsc_surface_draw() on it.

Valgrind complained, that wlsc_surface_draw() accesses uninitialised
data: wlsc_surface::alpha. fade_output() forgets to set it.

Initialise surface.alpha in fade_output(). Specifically, set it to
compositor->current_alpha to deliberatly avoid the gluniform1f() call in
wlsc_surface_draw().

fade_output() binds a different GL shader program than
wlsc_surface_draw() expects. This program does not have a uniform called
"alpha", and the uniform location given in glUniform1f() is not for
this program anyway. A hint of that is the runtime error:
Mesa: User error: GL_INVALID_OPERATION in glUniform(type mismatch)

Fixing this seems to get rid of half a thousand of Valgrind errors, and
of course the Mesa user error.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-20 10:59:39 -05:00
Kristian Høgsberg 2a25cd4ffa compositor: Remove shell->activate callback
It's all internal to the shell plugin now.
2011-12-19 15:21:40 -05:00
Kristian Høgsberg e1a850e5b0 compositor: Move click-to-focus and ctrl-alt-bs bindings to shell.c 2011-12-19 15:21:39 -05:00
Kristian Høgsberg f47d8fe88c compositor: Move binding code to util.c 2011-12-19 15:21:30 -05:00
Kristian Høgsberg 2bd5b6376c compositor: Consolidate code for finding and running bindings 2011-12-19 14:59:57 -05:00
Kristian Høgsberg 5a5f0077be compositor: Make click to activate behavior a binding 2011-12-19 14:54:11 -05:00
Kristian Høgsberg 42e40ae6dd x11: Ignore FocusOut with mode = NotifyUngrab
Not sure why we get these, but it happens for Alt-click to move a window
(metacity binding) and messes up the idle inhibit counter.
FocusOut event as a result of ungrabbing doesn't really make sense and
fortunately we can safely ignore them.
2011-12-19 14:36:52 -05:00
Tiago Vignatti ce03ec3fbe evdev: new header file for the driver
Besides the new header file, there's also a change in the main evdev creation
procedure for a more suggestive name (evdev_input_add_devices ->
evdev_input_create). There's no real functional changes in this commit.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-19 01:14:03 +02:00
Tiago Vignatti 6e2d5f14e8 compositor-drm: remove/add evdev devices when vt switches
Reported-by: Ran Benite <ran234@gmail.com>
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-19 01:08:16 +02:00
Tiago Vignatti 9e2be08418 compositor: first destroy backend routines and then display
I caught this when an evdev device fd was trying to trigger the main event
loop, which was already free'd and causing an invalid read.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-19 01:07:52 +02:00
Tiago Vignatti c349e1d0b0 compositor-drm: destroy evdev driver properly when finishing compositor
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-19 01:07:37 +02:00
Tiago Vignatti 0db1d5f551 evdev: use a separate function for adding devices
Adds new function evdev_add_devices for adding udev devices. No
functional changes.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-19 01:00:35 +02:00
Tiago Vignatti b303a1d3fc compositor: use wl_list_for_each_safe when destroying output
Was causing an invalid read when the output is in fact destroyed. That's only
visible (segfault on my machine) on drm compositor because it's the only
backend trying to finish correct the compositor.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-18 22:27:40 +02:00
Juan Zhao 7bb92f0c03 Activate toplevel fullscreen and menu surfaces
Activate the toplevel, fullscrren and menu surfaces during mapping,
so that the launched applications can get the keyboard focus without
clicking on that window.
2011-12-15 11:31:51 -05:00
Kristian Høgsberg ef458246b0 desktop-shell: Animate surface opacity in zoom animation as well 2011-12-15 11:24:25 -05:00
Kristian Høgsberg 541e5557ac compositor: Implement surface global alpha
Just a small tweak to the shader and we can control the overall surface alpha.
2011-12-15 11:15:12 -05:00
Kristian Høgsberg cd9ac1da5f compositor: Remove server side cursors
We always expect the clients to set the cursor and attaching a NULL buffer
hides the cursor.  The cursor starts out hidden.
2011-12-15 09:15:08 -05:00
Pekka Paalanen 7296e7984f compositor: let shell override idle time
Move idle_time variable to struct wlsc_compositor, so that a shell
plugin can change it. Also store the original value from the command
line.

Add "duration" option to the desktop-shell screensaver config. This is
the time the screensaver will be visible, after idle timeout triggers
another time and blanks the screen.

Now you can have different delays to lock the screen, and switch off the
screen while a screensaver is running.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 13:50:35 +02:00
Pekka Paalanen e955f1edd1 shell: use desktop-shell ini file for screensaver path
Read the same configuration file in the shell plugin (desktop-shell) as
the desktop-shell client does.

Add a new section "screensaver", where "path" defines the path of the
idle animation client to be executed. Not defining "path" disables the
animation.

Idle animations are not in use by default. It must be configured in
wayland-desktop-shell.ini or launched manually.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 13:45:49 +02:00
Pekka Paalanen 18027e517a shell: automatic exec and kill of wscreensaver
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 13:45:33 +02:00
Pekka Paalanen bce2d3f9a7 compositor: add IDLE state
Add WLSC_COMPOSITOR_IDLE state to the possible compositor internal
states, and fix the drm backend to restore the previous state instead of
forcing ACTIVE.

Normally, the compositor only uses the ACTIVE and SLEEPING states. The
IDLE state is another active state, reserved for the shell, when the
shell wants to have unlock() calls on activity, but the compositor cannot
be SLEEPING.

Use the IDLE state to fix exposing the unlock dialog while a screensaver
is animating. Without this fix, is it impossible to activate the unlock
dialog without waiting for a second idle timeout that really puts the
compositor into SLEEPING.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 13:44:29 +02:00
Pekka Paalanen af0e34ce36 shell: center the unlock dialog
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 13:43:49 +02:00
Pekka Paalanen 2e097ee42a compositor: fix re-fading
Reorder code in fade_frame() to that if shell->lock() calls
wlsc_compositor_wake(), the fade animation will run again.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 13:43:42 +02:00
Pekka Paalanen baeb6a1dc1 shell: let screensaver wake up the compositor
Screensavers become visible the first time only after the compositor has
gone to sleep state. Therefore, to see screensaver in the start, wake up
the compositor. After a second idle timeout, the compositor will stay
sleeping.

We could also not apply this patch. It would mean the screensavers would
be visible only with the unlock dialog, and not become visible
automatically.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 12:56:15 +02:00
Pekka Paalanen 77346a66ec shell: implement screensaver surface type
Implement the basics of screensaver surface management. Exec'ing and
killing the screensaver client is punted for later.

When a surface registered as a screensaver is mapped, it stays hidden
if the screen is not locked, or it is added to the compositor visible
surfaces list if the screen is locked.

The map() is restructured to set initial position first, and stacking
next. This allows SHELL_SURFACE_SCREENSAVER share positioning with
SHELL_SURFACE_FULLSCREEN, while show_screensaver() does its own
wlsc_surface_configure() call.

Also fix centering to the given fullscreen output, not the first output.

Another bug fix: previously configure() would call
wlsc_surface_configure() unconditionally, which assigns an output to
the surface. While the compositor is locked, if an application resizes
its window, we hit configure() and assign an output while the surface is
not in compositor->surface_list. This leads to invalid memory access on
the next call to wlsc_surface_damage_below(). Fix this by not calling
wlsc_surface_configure() for surfaces that are not visible.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 12:51:01 +02:00
Pekka Paalanen 9826223a1b shell: handle surface type reassignment
So far nothing prevented a client for registering a surface as one type
and then as another type. With some special types, this would lead to
corrupted wl_lists.

Add a function, that either resets the surface type or posts an error to
the client. In case of an error, the set type operation must be aborted.

Change the type name SHELL_SURFACE_NORMAL to SHELL_SURFACE_NONE, as
there is nothing normal in the "none" type which just means uninitialised.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 12:27:47 +02:00
Pekka Paalanen 6e16811e5e protocol: add screensaver interface
Add the screensaver interface to the desktop-shell protocol file. Also
add stubs for it in the compositor, and make wscreensaver to bind to the
screensaver interface. Wscreensaver gets a new option --demo to retain
the current behaviour as a regular wayland client.

When a screensaver application starts, it should bind to the screensaver
interface, enumerate all outputs, create a surface per output, and
register those surfaces via screensaver::set_surface request. Then it
continues with the usual animation loop, waiting for frame events. The
compositor will decide, when the given screensaver surfaces are
displayed. A screensaver application should respond to outputs coming
and going away by creating and destroying surfaces.

The compositor is supposed to activate a screensaver by exec'ing it, and
stop the screensaver by killing the client process. Only one client may
be bound to the screensaver interface at a time. If there already is a
client, the compositor could either kill it first, or not exec a new
one.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-14 11:17:00 +02:00
Tiago Vignatti 12c05b74ad evdev: run flush_motion only when needed
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-12 13:00:03 +02:00
Tiago Vignatti 1c2bcb182b evdev: send old valuator inside event frame when the other is missing
when a motion is being performed on ts device, only one axis can be sent
through the evdev bytestream whereas the other could be omitted. For instance:

   -------------- SYN_REPORT ------------
   type 3 (EV_ABS), code 53 (ABS_MT_POSITION_X), value 22208
   type 3 (EV_ABS), code 58 (ABS_MT_PRESSURE), value 631
   type 3 (EV_ABS), code 0 (ABS_X), value 22208
   -------------- SYN_REPORT ------------

on such case we'd have to send the compositor the old value of Y. Commit
f547bd36 introduced this bug cause it was sending zeroed coordinate and not
the old one.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-12 13:00:03 +02:00
David Herrmann d7c4551562 compositor-drm: Catch errors in create_output_for_connector
We do not handle errors of gbm-buffer-creation and drm-mode-setting in
create_output_for_connectors. Correctly catch these now and free memory on error
to avoid memory leaks.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-08 13:31:00 -05:00
David Herrmann 0f0d54e5c5 compositor-drm: Free output on error in create_output_for_connector
We currently simply return -1 on error in create_output_for_connector. This
correctly frees the output and all modes when we fail to avoid memory leaks.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-08 13:30:23 -05:00
David Herrmann eb8bed5c73 compositor-drm: Fix memory leak in create_output_for_connector
We do not free the encoder structure on failure. Fix that.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-08 13:30:05 -05:00
David Herrmann 7551cff986 compositor-drm: Fix memory leak in update_outputs
We need to correctly free every connector we retrieve. We currently loose them
if they are not connected.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-08 13:29:40 -05:00
Tiago Vignatti a3a7162b11 compositor-x11: convert (some) of X11 buttons to linux input
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-12-08 13:20:40 -05:00
Pekka Paalanen 01e7b006db shell: fix set_transient
In the wl_shell_surface migration, I forgot to correct one cast in
shell_surface_set_transient(). 'parent_resource' is not a (struct
wlsc_surface *) but (struct shell_surface *).

This bug corrupts a wlsc_surface::output field, which later (in my
experiments) leads to a segmentation fault in surface_frame().

Fix the casts.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-08 13:00:26 -05:00
Kristian Høgsberg bde5e9fc00 Remove stale comment 2011-12-08 10:24:25 -05:00
Kristian Høgsberg d42b0c94c3 compositor: Use dup instead of fcntl to get a non-CLOEXEC fd
One less syscall and error path to check, and feels like a cleaner approach.
The commit adds two lines, but that's because we actually handle the
potential error now.
2011-12-08 10:19:52 -05:00
Pekka Paalanen 9b32ed34de Update .gitignores
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-08 11:36:36 +02:00
Pekka Paalanen c47ddfd852 compositor: reset signal mask for children
The signal mask is inherited over fork() and exec(), we need to
explicitly reset it.

This allows the children to receive the signals the compositor itself
has blocked, for example SIGINT and SIGTERM.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-08 10:44:56 +02:00
Pekka Paalanen 409ef0a5c8 compositor: refactor client forking code
shell.c and tablet-shell.c had almost the same code for forking their
special shell client. Generalise this code and put it into
wlsc_client_launch() in compositor.c.

Improve error cleanup and reporting in wlsc_client_launch().

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-08 10:42:00 +02:00
David Herrmann 7172d9e22d compositor-tty: Fix ioctl error handling
(!x < 0) is always false and doesn't make sense here. Looks like a typo so
remove the negation.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-12-05 09:48:42 -05:00
Kristian Høgsberg 4bfb82adf7 compositor: Move a few more utils to util.c 2011-12-04 15:47:16 -05:00
Kristian Høgsberg 2f88a40c57 desktop-shell: Animate surface mapping 2011-12-04 15:32:59 -05:00
Kristian Høgsberg 698c058e2a compositor: Split the animation code out of tablet-shell
Upside: we can now reuse this.  Downside: we now have a util.c file.
2011-12-04 15:30:47 -05:00
Pekka Paalanen f32f1fc743 shell: forbid multiple wl_shell_surface objects
Do not allow multiple wl_shell_surface objects to be created for a
wl_surface object.

Multiple shell_surface objects would confuse the compositor as they
contain separate instances of the shell-private data.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-04 14:56:06 -05:00
Pekka Paalanen 4622967586 shell: rename shell_create_shell_surface
Leftovers from an intermediate patch set, the proper function name is
shell_get_shell_surface. Cosmetic change.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-04 14:55:53 -05:00
Pekka Paalanen 92a0dc455a shell: check for missing wl_shell_surface
get_shell_surface() returns NULL, if the client has not created or has
destroyed the wl_shell_surface object.

All but one use of get_shell_surface() just retrieve the surface type,
so just fall back to SHELL_SURFACE_NORMAL there.

Resize hot-key binding really needs the wl_shell_surface object, as that
is the only way to send configure events. For surfaces without a
wl_shell_surface, simply do not resize them.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-04 14:55:19 -05:00
Pekka Paalanen ec2b32f49b compositor: eliminate wlsc_surface::shell_priv
Remove shell_priv member from wlsc_surface, and replace it by a search
through the wl_surface destroy_listener_list.

This technique avoids any "extension" members in the wlsc_surface
structure.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-04 14:54:40 -05:00
Pekka Paalanen 068ae944db desktop-shell: update protocol and client to wl_shell_surface
Change desktop-shell protocol to use wl_shell_surface instead of
wl_surface.

Adapt the desktop-shell client and the shell plugin.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-04 14:54:34 -05:00
Pekka Paalanen 9d1613eb4a wl_shell_surface adaptation
Protocol changes in Wayland core introduced a new interface
wl_shell_surface, and moved all wl_shell surface methods into it. Adapt
the compositor and its Wayland backend, shell plugin, and all clients to
the new interface.

Depends on the Wayland core commit "protocol: introduce wl_shell_surface"

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-04 14:54:26 -05:00
Kristian Høgsberg 865f9b87c9 evdev: Silence warning 2011-12-02 06:39:13 -05:00
Pekka Paalanen fe34083023 shell: fix resume_desktop for zero clients
Fix two bugs:

- if there are no backgrounds at all, the background pointer would have
  been bogus. Lead to a segfault.

- if the hidden_surface_list is empty, wl_list_insert_list() would
  corrupt the list. Lead to a hang in pick_surface().

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-02 06:31:07 -05:00
Pekka Paalanen 65c74cb18b compositor: add a comment about wlsc_surface::output
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-12-02 06:31:07 -05:00
Kristian Høgsberg 6336e46e15 tablet-shell: Add a stub tablet-shell client
For a start, this is just to we can run and test the corresponding
compositor plugin and keep it from bit-rotting.
2011-11-26 17:37:54 -05:00
Kristian Høgsberg 47fe08aad5 Implement the new dnd/selection protocol
The new protocol splits dnd/selection from wl_shell and allows us to move
the implementation out of shell.c.
2011-11-23 16:20:28 -05:00
Benjamin Franzke f02bb64d62 shell: Unmap old backgrounds/panels when setting new ones 2011-11-23 20:46:40 +01:00
Benjamin Franzke d0f79ab5ab desktop-shell: Make panel and background output dependent 2011-11-23 20:17:54 +01:00
Kristian Høgsberg d2abb83634 compositor: Move more shell.c state into the new shell_surface 2011-11-23 10:53:08 -05:00
Kristian Høgsberg f6def545bc Merge remote-tracking branch 'pq/shell-priv' 2011-11-23 10:40:11 -05:00
Kristian Høgsberg a8873120c4 compositor: The compositor is now jiust a regular global object
We have to provide our own bind callback and add a wlsc_compositor pointer
to wlsc_input_device, but on the whole it's nice cleanup.
2011-11-23 10:39:34 -05:00
Kristian Høgsberg 6b5fc3bac0 compositor: Remove a couple of unused #defines 2011-11-23 10:17:41 -05:00
Kristian Høgsberg 558350a692 compositor: Remove unused resource field from wlsc_output 2011-11-23 10:17:15 -05:00
Pekka Paalanen 57da4a822e shell: introduce shell_surface_purpose
Enumerate the different surface purposes for the shell: background, panel,
lock surface, and normal (other) surfaces.

Instead of testing wlsc_surface pointers against known pointers, check
the purpose field.

This change will ease implementing per-output background, panel, etc.
when the number of "known" surface pointers grows dynamically.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-23 16:43:43 +02:00
Pekka Paalanen 56cdea96f0 shell: add private surface struct
Add a pointer to wlsc_surface for shell-private data. This is a
temporary solution.

Add struct shell_surface, where you can add any shell-private data
members related to a wlsc_surface. The getter function takes care of
creating the private data if it does not exist yet.

Not used anywhere yet.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-23 16:14:12 +02:00
Kristian Høgsberg 2584cb5890 compositor: Set output for cursor surface so damage_below works 2011-11-22 19:47:57 -05:00
Kristian Høgsberg db0fa54b5a Simplify evdev_flush_motion() a tiny bit 2011-11-22 19:24:25 -05:00
Kristian Høgsberg f127715ce2 Merge remote-tracking branch 'vignatti/evdev' 2011-11-22 19:21:34 -05:00
Kristian Høgsberg c5241f5b73 Never include wayland-util.h directly
And fix a missing "" to <> conversion for wayland-client.h include.
2011-11-22 09:35:14 -05:00
Pekka Paalanen 50719bce2a Fix inconsistent #include style
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-22 09:27:03 -05:00
Tiago Vignatti f547bd36e6 evdev: fetch absolute coordinates inside flush_motion only
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-11-22 12:05:22 +02:00
Tiago Vignatti 5c900ce08d evdev: remove useless field from device structure
We'll want to enhance later the driver regarding the tool being used, but for
now just remove unused bits.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-11-21 23:47:26 +02:00
Tiago Vignatti 80885e16b3 evdev: reset accumulator inside evdev_flush_motion
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-11-21 23:45:30 +02:00
Tiago Vignatti a52b2e4b20 evdev: use a separate structure to denote accumulated motion events
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-11-21 23:45:05 +02:00
Tiago Vignatti a157fc11a9 evdev: use a separate struct for abs information
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-11-21 23:42:33 +02:00
Tiago Vignatti 280b8a6a3b tty: fix command line parsing
revert typo from evdev commit 8b568806.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-11-21 18:07:18 +02:00
Kristian Høgsberg 8b568806aa evdev: Reset accumulate values when we flush motion events
Otherwise we end up reporting all motion events twice.
2011-11-18 10:42:34 -05:00
Kristian Høgsberg eccef6aadd compositor: Queue buffer.release instead of sending immediately 2011-11-18 09:52:57 -05:00
Tiago Vignatti 52e158d46b evdev: fix order of events being sent to the compositor
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-11-18 15:00:34 +02:00
Tiago Vignatti 8755ff9de7 evdev: remove signed value checks
Very likely that 2.4 kernels won't be used with Wayland compositor so the
check for signal value is pretty much useless.

It's okay to change e->value inside evdev_process_absolute_motion_touchpad
given it's not used later on, and I also rather not touch this snip because it
will be changed when multi-touch support arrives.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-11-18 13:44:17 +02:00
Pekka Paalanen 2ca8630aab shell: fix handle_lock_surface_destroy()
A copy & paste bug, that resulted setting to NULL something else than
shell->lock_surface when that surface was destroyed.

The symptom: let compositor lock down, unlock it, let it lock down
again, and the unlock dialog is never requested again. This bug was
triggered by the previous fix "shell: fix compositor wakeup while
locked".

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-16 08:52:26 -05:00
Pekka Paalanen d81c216db1 shell: fix compositor wakeup while locked
Compositor is locked, woken up, unlock dialog is shown; if the
compositor does to sleep again, before being unlocked, it will never
wake up again, because unlock() becomes a no-op, yet it should wake the
compositor up.

Fix this by letting unlock() to wake up the compositor, if lock surface
is present.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-16 08:52:07 -05:00
Pekka Paalanen d3dd6e1752 shell: fix lock surface mapping
When the lock surface was map()'d while the compositor was locked,
wlsc_surface_configure() was never called for the lock surface. Hence,
the surface->output was NULL, and the 'frame' event was never sent,
causing desktop-shell to loop in dri2_swap_buffers().

Fix this by calling wlsc_surface_configure() for the lock surface
always in map().

Additionally, adjust the comments in map() to make it more readable.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-16 08:51:31 -05:00
Kristian Høgsberg 1ec0c31596 compositor: Hide surfaces by setting surface->output to NULL
This way we can still use surface->link when a surface is not in
the main compositor surface list and don't need the hidden_surface
wrapper object.  Also, setting surface->output to NULL will block
the surface frame callback until we put the surface back into the
main list.  This has the effect of blocking animations while a surface
isn't visible.
2011-11-15 16:43:25 -05:00
Pekka Paalanen f0fc70d72f compositor: implement screen locking
When the compositor is locked, all surfaces are moved from the
compositor's list to a private list in the shell plugin. This prevents
any of those surfaces from being visible or receiving input. All new
surfaces will be moved to the private list, too.

The background surface is an exception, it is left to the compositor's
list, so the background will be painted. It is assumed that the
background surface does not allow any actions while being locked.

When desktop-shell announces a lock surface (an unlock dialog), it is
added to the compositor's list, so the user can interact with it.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 16:43:24 -05:00
Pekka Paalanen d503a0b318 compositor: check wlsc_surface::link before accessing neighbors
Check that wlsc_surface::link is part of a list before assuming it is
part of the compositor->surface_list list.

The shell plugin may want to remove a surface from the compositor's
surface list to hide it. Note, that the shell plugin cannot use
wlsc_surface::link for its own purposes.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 16:43:24 -05:00
Pekka Paalanen ebc598ebf0 compositor: fix repaint on first wakeup
wlsc_compositor_fade() ends up in wlsc_compositor_schedule_repaint(),
which is a no-op if compositor is SLEEPING.

On wakeup, first set status to ACTIVE, then call wlsc_compositor_fade()
to start and actually show the animation.

Before, fade was called first, which reset the animation, but did not
cause a repaint. The following wakeup (any input event) would then cause
a repaint, showing the animation from the middle or end of it.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 14:21:46 -05:00
Pekka Paalanen 2841111025 compositor: remove idle_inhibit optimization
With the idle_inhibit optimization, wlsc_compositor_wake() is a no-op if
idle_inhibit > 0.

When the shell is waking up the compositor from SLEEPING state as an
indirect response to input activity, it does not work. The call path is:
notify_key() / notify_button()
	wlsc_compositor_idle_inhibit()
		wlsc_compositor_activity()
			shell->unlock()
				send prepare_lock_surface event
	idle_inhibit++

and when the desktop-shell client responds to the event:

desktop_shell_set_lock_surface() / desktop_shell_unlock()
	wlsc_compositor_wake()
		no-op, because idle_inhibit > 0

Fix this by removing the idle_inhibit check from wlsc_compositor_wake().
The optimization did not work for pointer motion while no keys pressed,
anyway, so the performance hit is probably unobservable.

Now the compositor wakes up also on key or button press.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 14:21:05 -05:00
Kristian Høgsberg af867cc2f7 compositor: let the shell wake up the compositor
When compositor enters SLEEPING state, the shell plugin goes locked. If
compositor wakes up itself, it will fade in while the shell may not yet
have a lock surface to show.

Fix this by assigning wake-up to be called from the shell, if the
compositor is SLEEPING. The shell may wait for the lock surface request,
and only then wake up the compositor. The compositor will fade in
directly to the lock screen.

krh: original patch for compositor.c
ppaalanen: integration and shell.c changes

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 14:19:32 -05:00
Pekka Paalanen 9ef3e012d6 desktop-shell: screen locking protocol
Add protocol and functions for supporting screen locking, triggered by
activity timeout.

After activity timeout, compositor starts the fade to black, and then
enters SLEEPING state. At that point it calls lock() in the shell
plugin.

When input events trigger a wakeup, unlock() in the shell plugin is
called. This sends prepare_lock_surface event to the desktop-shell
client. The screen stays locked while the compositor starts fade-in.

At this point, desktop-shell client usually creates a surface for the
unlocking GUI (e.g. a password prompt), and sends it with the
set_lock_surface request. The compositor supposedly shows and allows
interaction only with the given lock surface (not yet implemented).

When desktop-shell has authenticated the user, or instead of issuing
set_lock_surface, it sends the unlock request. Upon receiving the unlock
request, the shell plugin unlocks the screen.

If desktop-shell client dies, the screen is unlocked automatically.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 14:18:50 -05:00
Kristian Høgsberg 496433b541 compositor: Hold on to surface.frame requests until we assign an output
We can't just throw away the callback, so hold on to the requests until
we have an output for the surface.
2011-11-15 13:50:21 -05:00
Kristian Høgsberg 3164c946ac compositor: Drop unused wlsc_output field 'background' 2011-11-15 11:57:54 -05:00
Pekka Paalanen 8c19645e69 compositor: fix destroy_frame_callback()
Pass the correct pointer to free().

This is just a cosmetic change, because 'resource' happens to be the
first member in wlsc_frame_callback.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-15 09:06:09 -05:00
Kristian Høgsberg 64f1c3fd52 De-brand the tablet shell
Drop the MeeGo part of the name.
2011-11-14 15:57:59 -05:00
Kristian Høgsberg c4693c4ab4 Install desktop-shell in $prefix/libexec 2011-11-14 14:57:17 -05:00
Kristian Høgsberg d826404472 compositor: Drop redundant compositor->damage
This is the same as the damage of the top-level surface so just use that.
There's a problem that if we change the stacking, the damage layering breaks,
but that's a problem we already have.
2011-11-11 11:48:15 -05:00
Kristian Høgsberg 46770139bc shell: Set initial toplevel position in map callback 2011-11-09 12:40:08 -05:00
Kristian Høgsberg 32e24cc628 compositor: Split shell->attach into map and configure
The shell module only needs to deal with attach when it's either the initial
attach or when the attach changes the size of the surface.  In case of
initial attach, the shell needs to pick a position for the surface and a
place in the surface stack.  We split this case out as a new shell->map
callback.  The other case is split into the shell->configure callback,
where the shell may adjust the surface position or reject the new size.
2011-11-09 12:07:35 -05:00
David Herrmann 63ff706c0e compositor-drm: Fix setting O_CLOEXEC
The third parameter of open() is for file-creation modes. File flags are passed
in the second paramater.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
2011-11-05 22:04:03 -04:00
Pekka Paalanen bbe605241d compositor: only authorized client can bind desktop_shell
Check, that only the desktop-shell client spawned by the compositor
(desktop-shell plugin) is allowed to bind to desktop_shell interface.
Other clients will receive an error like:

  wl_display@1.error(desktop_shell@20, 0,
  "permission to bind desktop_shell denied")

The error has the proper object id and interface type.

Note: desktop-shell cannot be started manually anymore, it has to be
started by the compositor automatically.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-03 15:16:39 -04:00
Pekka Paalanen 6cd281a023 desktop-shell: launch from the compositor
Fork and exec desktop-shell in the compositor. This is a way to create
an authenticated client. Later, the desktop-shell interface will be
reserved for this client only.

For exec to work, the compositor should be started from the
wayland-demos' root directory.

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-11-03 15:16:19 -04:00
Ander Conselvan de Oliveira ef7c8d9ddf compositor-*: check for surfaceless_gles2 instead of surfaceless_opengl
All the compositors are using GLES2 so check for the appropriate
surfaceless extension.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2011-11-01 11:18:39 -04:00
Kristian Høgsberg d3ef7be781 compositor: Tweak fade spring to not overshoot 2011-10-29 15:04:42 -04:00
Kristian Høgsberg 06a670f2e7 compositor-x11: Call finish_frame from a timer callback
The repaint logic breaks when finish_frame is called from the present
callback.  Ideally we should throttle to vsync (or even better, the
compositor repaint cycle, but hey, X is X), but this goes a long way.
2011-10-29 14:39:13 -04:00
Kristian Høgsberg 3ff589df78 compositor: Make spring model always use the same time step 2011-10-29 13:41:18 -04:00
Kristian Høgsberg ff298d9834 compositor: Clear cursor buffer in create_sprite_from_png() 2011-10-28 20:41:28 -04:00
Ander Conselvan de Oliveira 0de0aafa7f composior: fix tiny cursor bug with drm compositor
The drm compositor always creates a 64x64 bo for the cursor image
regardless of the size of the actual cursor. When the fade animation
kicks in it disables the hardware cursor so that it is rendered as a
regular surface. This surface is rendered to a 32x32 region but using
a 64x64 texture so the cursor gets scaled down.

Fix this by making create_cursor_image return the actual size of the
image created to the compositor.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2011-10-28 14:36:28 -04:00
Casey Dahlin fb39963cc9 Update .gitignores 2011-10-28 13:32:17 -04:00
Tiago Vignatti ac9cfd3065 evdev: Simplify error path for device creation
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-10-28 13:15:25 -04:00
Tiago Vignatti d9f7d1f0c5 evdev: Delete unused fields from evdev_input_device
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-10-28 13:09:42 -04:00
Tiago Vignatti ac2dc6aafe evdev: Add hotplug support
Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-10-28 13:05:06 -04:00
Ander Conselvan de Oliveira 9a38a0a191 compositor: page flip away from a client buffer if it's destroyed
If the current or pending scanout buffer is destroyed, the client frame
will remain being displayed until something else causes a repaint to be
scheduled.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2011-10-28 12:43:47 -04:00
Kristian Høgsberg ac5098f11a Merge remote-tracking branch 'robster/rob/pointer-fixes' 2011-10-25 09:07:12 -04:00
Rob Bradford 1d72447d9b compositor: Report an error if we cannot the load the pointer image files 2011-10-25 13:43:44 +01:00
Rob Bradford d354711fc7 compositor: Don't try and use a NULL sprite for the device pointer
If loading the pointer images to the sprites fails then do not try and use
those NULL sprites for the pointer.
2011-10-25 13:38:31 +01:00
Kristian Høgsberg 2459694ab2 compositor: Clean up resource destroy callback handling 2011-10-24 17:51:02 -04:00
Pekka Paalanen 02ebfb1276 compositor: fix drag segfault
Without this fix, the dnd demo would make the demo compositor crash in
shell.c:drag_offer() because resource->data is NULL.

Initialise resource->data in shell_create_drag().

Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
2011-10-24 15:35:09 -04:00
Ander Conselvan de Oliveira 02924bc0b6 compositor: fix whitespace error in wlsc_output_set_cursor
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2011-10-24 15:32:16 -04:00
Ander Conselvan de Oliveira 22e22a55be compositor: don't schedule idle_repaint from calls to repaint
wlsc_output_repaint may call wlsc_surface_damage indirectly through
wlsc_output_set_cursor. If this happens in the call made from repaint,
one ends up with repaint being called from both idle_repaint and
wlsc_output_finish_frame.

Fix this by setting output->repaint_scheduled to 1 before calling
wlsc_output_repaint in the function repaint.

[krh] Edited to just only clear repaint_scheduled, when we no longer have
a repaint scheduled.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2011-10-24 15:32:16 -04:00
Kristian Høgsberg a4b7e20392 drm: Only add an output once we've successfully initialized it 2011-10-24 15:32:13 -04:00
Kristian Høgsberg 53e79898a4 drm: Remove unneccesary drm_output_prepare_render() call 2011-10-24 13:25:24 -04:00
Kristian Høgsberg 9c46ff1a1e drm: Specify depth as 24 when creating the KMS FB
At least intel kms rejects depth 32 now, and 24 is want we want.
2011-10-24 13:25:24 -04:00
Kristian Høgsberg 191454e6c2 compositor: Rename scanout surfaces
Let's call the surface that's about to be pageflipped 'pending' and the
one we're currently showing 'scanout'.
2011-10-24 13:25:17 -04:00
Ander Conselvan de Oliveira f1621d2945 compositor: don't release the front buffer after page flip
On repaint, wlsc_output_repaint will replace output->scanout_buffer with
the new front buffer and then output->present() will cause this buffer
to be displayed. When wlsc_output_finish_frame is called, the
compositor will send a release buffer event for output->scanout_buffer
which is actually the front buffer now.

This patch changes this code to release the previous scanout_buffer
instead of the front buffer on wlsc_output_finish_frame.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2011-10-24 11:59:11 -04:00
Ander Conselvan de Oliveira 3b19966f19 compositor: move setup of scanout surface out of wlsc_output_repaint
Move this to a separate function to better accommodate changes in the
following commit.

Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
2011-10-24 11:59:11 -04:00
Kristian Høgsberg cbd06f94d1 compositor: Silence a couple of valgrind warnings 2011-10-12 16:29:31 -04:00
Kristian Høgsberg 32ff1f5012 compositor: Dont repick for grabbed surfaces 2011-10-12 00:36:54 -04:00
Kristian Høgsberg dcef9ca23c x11: Fix last-minute edit bug 2011-10-12 00:01:18 -04:00
Kristian Høgsberg d6e5525a20 x11: Manage xserver focus better 2011-10-11 23:41:17 -04:00
Kristian Høgsberg 707e10fa75 x11: Handle a few more window property atoms 2011-10-11 23:13:30 -04:00
Kristian Høgsberg a6ef0993e8 x11: Truncate property string to property length 2011-10-11 22:46:01 -04:00
Kristian Høgsberg f0d9116fc8 x11: Add a destroy listener for X11 surfaces 2011-10-11 22:44:23 -04:00
Kristian Høgsberg d2baf1fe5f compositor: Repick focus surface as surfaces come and go 2011-10-11 22:22:27 -04:00
Kristian Høgsberg 293af264af x11: Use compositor time, not X event time
X event time is not compatible with wlsc_compositor_get_time().
2011-10-11 17:23:02 -04:00
Benjamin Franzke 02dee2caad compositor-drm: Fix invalid usage of udev ressources
The reference returned by udev_list_entry_get_name is
only valid until udev_enumerate_unref is called.
Call unref after the last usage of such.
2011-10-07 10:00:11 +02:00
Benjamin Franzke a764ee5158 compositor-drm: Enumerate only cards with name card*
To exclude /dev/dri/controlD* from the enumeration.
2011-10-07 09:57:50 +02:00
Benjamin Franzke 439d98697a compositor-drm: Be patient when output creation fails
Do not fail if e.g. only one of 3 connectors cant be enabled.
Could be that we just have not enough crtcs available.
2011-10-07 09:56:54 +02:00
Benjamin Franzke c18366d1e9 compositor-openwfd: Fix tty assignment in backend_init 2011-10-07 08:33:08 +02:00
Kristian Høgsberg 96aa7da24a Change remaining GPLv2 headers to MIT
The files in question are copyright Benjamin Franzke (who agrees),
Intel Corporation, Red Hat and myself.  On behalf of Red Hat,
Richard Fontana says:

   "Therefore, to the extent that Red Hat, Inc. has any copyright
    interest in the files you cited as of this date (compositor-drm.c,
    compositor.c, compositor.h, screenshooter.c in
    http://cgit.freedesktop.org/wayland/wayland-demos/tree/compositor),
    Red Hat hereby elects to apply the CC0 1.0 Universal Public Domain
    Dedication to such copyrighted material.  See:
    http://creativecommons.org/publicdomain/zero/1.0/legalcode .

    Thanks,
    Richard E. Fontana
    Open Source Licensing and Patent Counsel
    Red Hat, Inc."
2011-09-19 17:29:24 -04:00
Tiago Vignatti 37f27d59cd xserver: check whether pointer exists when exiting
At initialization, if it fails in binding the socket or creating the
lock file then the pointer will be already freed and will result a
segfault when quiting the compositor.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
2011-09-08 18:27:31 -04:00
Kristian Høgsberg a4a42f0ab5 shell: Reject moving or resizing toplevel windows 2011-09-08 16:56:57 -04:00
Kristian Høgsberg 9c4eecb5c0 Rename motion_grab to implicit_grab
Let's just use the same terms as X.
2011-09-06 18:13:14 -04:00