Commit Graph

725 Commits

Author SHA1 Message Date
emersion 37de179013 backend/drm: fix zero-length VLAs 2018-10-07 13:04:52 +02:00
emersion 776008da69 backend/drm: properly handle GPUs without CRTCs 2018-10-07 12:59:00 +02:00
emersion ba91422747 output: don't trigger a frame immediately in schedule_frame
This desynchronizes our rendering loop with the vblank cycle.

In case a compositor doesn't swap buffers but schedules a frame,
emitting a frame event immediately enters a busy-loop.

Instead, ask the backend to send a frame when appropriate. On
Wayland we can just register a frame callback on our surface. On
DRM we can do a no-op pageflip.

Fixes #617
Fixes swaywm/sway#2748
2018-10-05 16:18:37 +02:00
emersion eac7c2ad2f output: add presentation refresh prediction 2018-10-04 22:00:24 +02:00
emersion b0635bf3e7 Rename get_present_clock to get_presentation clock, use it 2018-10-04 22:00:22 +02:00
emersion 54e1287f30 backend: add get_present_clock 2018-10-04 21:58:17 +02:00
emersion 26b9d6dbb1 output: send present event from all backends 2018-10-04 21:56:38 +02:00
emersion 78389fe722 output: add present event 2018-10-04 21:56:38 +02:00
emersion f5a147b739 backend/drm: add support for the link-status property 2018-10-04 21:54:27 +02:00
Drew DeVault 841d04db99
Merge pull request #1262 from nyorain/session_fix
Improve session handling
2018-10-04 17:36:39 +02:00
nyorain b4d46aa9c2 Use sd_bus_get_property_trivial & remove numbering 2018-10-04 14:04:06 +02:00
emersion 7ab37bf152 backend/drm: update EDID manufacturers database 2018-10-04 10:58:45 +02:00
emersion e88db9a3fb backend/drm: reset gamma table on VT switch 2018-10-03 10:53:35 +02:00
emersion 2beb68007e output: make gamma size a size_t and gamma table const 2018-10-03 10:36:33 +02:00
emersion 79dd9ba151 backend/drm: don't free connector immediately
When a pageflip is pending, we'll get a DRM event for the connector
in the future. We don't want to free the connector immediately
otherwise we'll use-after-free in the pageflip handler.

This commit adds a new state, "DISAPPEARED". This asks the pageflip
handler to destroy the output after it's done pageflipping.
2018-09-28 10:00:40 +02:00
nyorain 7b52388424 Rework session handling
Sessions can now be retrieved from a backend in a more general manner.
Multi-backend gets back its `session` field that contains the session
if one was created, removing the interfacing from multi backend with the
drm backend directly. This adds the possibility to use sessions even
without the drm backend.

It additionally fixes the bug that 2 session objects got created when
WLR_BACKENDS were set to "libinput,drm".

To allow vt switching without drm backend (and drm fd) on logind, start
listening to PropertiesChanged signals from dbus and parse the session
"Active" property when no master fd was created (this does not change
current drm backend behaviour in any way).
2018-09-24 23:35:09 +02:00
sghctoma 9383e1f76c Apply multiseat fixes to FreeBSD direct backend
This commit applies the multiseat fixes that are part of PR #1063 (
commits 964e0a50 and 47895d2) to the FreeBSD direct backend.
2018-09-21 15:02:32 +02:00
Ryan Dwyer 691a63d66b Introduce wlr_multi_for_each_backend 2018-09-19 21:53:51 +10:00
emersion 139a905924 backend/drm: add assertions 2018-09-18 11:06:01 +02:00
emersion 02231554c8 backend/x11: add assertions 2018-09-18 11:06:01 +02:00
emersion e98cb7c5ab backend/wayland: add assertions 2018-09-18 11:06:01 +02:00
emersion 07ea98dab9 backend/session: add assertions 2018-09-18 11:06:01 +02:00
emersion 6c05f17a25 backend/multi: add assertions 2018-09-18 11:06:01 +02:00
emersion 7bcf0d9599 backend/libinput: add assertions 2018-09-18 11:05:55 +02:00
emersion bc34486c04 backend/headless: add assertions 2018-09-18 11:01:53 +02:00
random human 572dfcdba7
Add support for WLR_SESSION env variable
Valid values are "logind"/"systemd" and "direct". If WLR_SESSION is set,
only its value is potentially tried; it will not try any other option.
2018-09-18 05:06:32 +05:30
emersion f8a50e4fe7 backend/drm: steal CRTCs from disabled outputs
This commit allows outputs that need a CRTC to steal it from
user-disabled outputs. Note that in the case there are enough
CRTCs, disabled outputs don't loose it (so there's no modeset
and plane initialization needed after DPMS). CRTC allocation
still prefers to keep the old configuration, even if that means
allocating an extra CRTC to a disabled output.

CRTC reallocation now happen when enabling/disabling an output as
well as when trying to modeset. When enabling an output without a
CRTC, we realloc to try to steal a CRTC from a disabled output
(that doesn't really need the CRTC). When disabling an output, we
try to give our CRTC to an output that needs one. Modesetting is
similar to enabling.

A new DRM connector field has been added: `desired_enabled`.
Outputs without CRTCs get automatically disabled. This field keeps
track of the state desired by the user, allowing to automatically
re-enable outputs when a CRTC becomes free.

This required some changes to the allocation algorithm. Previously,
the algorithm tried to keep the previous configuration even if a
new configuration with a better score was possible (it only changed
configuration when the old one didn't work anymore). This is now
changed and the old configuration (still preferred) is only
retained without considering new possibilities when it's perfect
(all outputs have CRTCs).

User-disabled outputs now have `possible_crtcs` set to 0, meaning
they can only retain a previous CRTC (not acquire a new one). The
allocation algorithm has been updated to do not bump the score
when assigning a CRTC to a disabled output.
2018-09-15 08:37:33 +02:00
emersion cb293f09e7 output: make wlr_output_enable return a bool 2018-09-14 18:18:07 +02:00
Drew DeVault ca331c0468
Merge pull request #1235 from emersion/dealloc-unused-crtcs
backend/drm: de-allocate unused CRTCs
2018-09-10 21:51:36 -04:00
Drew DeVault 7ba50469e0
Merge pull request #1205 from sghctoma/fix-freebsd-direct-session
Add drmSetMaster and drmDropMaster calls to FreeBSD direct session
2018-09-10 21:11:22 -04:00
emersion 1fcecd68df backend/drm: de-allocate unused CRTCs
They can be re-used by another output after a subsequent hotplug.
2018-09-10 18:46:30 +02:00
mntmn e1c91884fb fix cursor loss w/ legacy drm and software cursor (tested on etnaviv) 2018-09-10 17:30:26 +02:00
sghctoma ba5df0d21d Fix build failure on non-FreeBSD systems
Accidentally included the FreeBSD-specific dev/evdev/input.h file on
other systems too. This commit fixes that.
2018-09-07 17:44:48 +02:00
sghctoma 7a5d3c4d3b Implement device type discovery using ioctl calls
This commit implements device type discovery by calling two ioctls
(DRM_IOCTL_VERSION and EVIOCGVERSION) on the device. These iocts are
specific to drm and input devices respectively, therefore we can
determine the device type based on which one returns an error.
2018-09-07 16:37:25 +02:00
sghctoma bbeed1bd31 Merge remote-tracking branch 'upstream/master' into fix-freebsd-direct-session 2018-09-07 15:45:20 +02:00
emersion 8a6bdc193d backend/drm: damage outputs when switching CRTCs 2018-09-04 23:10:37 +02:00
emersion 1342393632 backend/drm: cosmetic enhancements 2018-09-04 23:08:45 +02:00
emersion 5b13b8a12c backend/drm: consider continue not using resources
Fixes #1230
2018-09-04 22:57:09 +02:00
emersion fb94f03b43 backend/drm: prevent use of uninitialized data 2018-09-04 22:50:59 +02:00
emersion d605b2ea07 backend/drm: remove unused if 2018-09-04 22:49:54 +02:00
emersion 017cfb0b86 backend/drm: log when de-allocating CRTC 2018-09-04 19:44:44 +02:00
emersion b877daded1 backend/drm: better hotplug handling
This commit handles better situations in which the number of
connected outputs is greater than the number of available CRTCs.
It'll enable as many outputs as possible, and transfer CRTCs to
outputs that need one on unplug.

This changes CRTC and plane reallocation to happen after scanning
DRM connectors instead of on modeset.

This cleanups CRTCs and planes on unplug to allow them to be
re-used for other outputs.

On modeset, if an output doesn't have a CRTC, the desired mode is
saved and used later when the output gains a CRTC.

Future work includes giving priority to enabled outputs over
disabled ones for CRTC allocation. This requires the compositor to
know about all outputs (even outputs without CRTCs) to properly
modeset outputs enabled in the compositor config file and disable
outputs disabled in the config file.
2018-09-04 15:09:07 +02:00
sghctoma d948bffd3e Activate last active VT after compositor exit
The VT the compositor was started from was not activated after exiting
the compositor, which resulted in arriving on a blank VT. This commit
fixes that by introducing a new field in direct_session struct that
stores the last active VT so that it can be activated in
direct_session_destroy.
2018-09-02 20:28:06 +02:00
sghctoma 3b2b8c1844 Merge remote-tracking branch 'upstream/master' into fix-freebsd-direct-session 2018-09-02 18:32:31 +02:00
random human 7bc2657984
Free unused pointer in x11/backend.c 2018-09-02 20:52:09 +05:30
emersion 95d05acda5 backend/drm: fix invalid VLA size in scan_drm_connectors
I failed to see this issue with Valgrind because of the +1.
2018-09-02 10:11:23 +02:00
emersion ef88df2142 backend/drm: emit new_output after scanning connectors
This prevents receiving modesetting requests from the compositor
while we don't have the whole picture (ie. while we haven't yet
scanned all connectors).

This also makes connectors without CRTCs disabled (they can't be
enabled yet even if some CRTCs are free'd -- this is future work).
2018-09-02 01:03:20 +02:00
emersion e84f01168d backend/drm: allow disabling outputs in NEEDS_MODESET state
This correctly frees CRTCs when disabling outputs without setting
a mode.
2018-09-01 23:43:16 +02:00
random human 8589ae19de Fix bugs listed by clang's static analyzer
A few pedantic changes and unused variables (1-4), and genuine bugs (5,
6).

The reports with the corresponding files and lines numbers are as
follows.

1. backend/libinput/tablet_pad.c@31,44,57
"Allocator sizeof operand mismatch"
"Result of 'calloc' is converted to a pointer of type 'unsigned int',
which is incompatible with sizeof operand type 'int'"

2. types/tablet_v2/wlr_tablet_v2_pad.c@371
"Allocator sizeof operand mismatch"
"Result of 'calloc' is converted to a pointer of type 'uint32_t', which
is incompatible with sizeof operand type 'int'"

3. types/wlr_cursor.c@335
"Dead initialization"
"Value stored to 'dx'/'dy' during its initialization is never read"

4. rootston/xdg_shell.c@510
"Dead initialization"
"Value stored to 'desktop' during its initialization is never read"

5. types/tablet_v2/wlr_tablet_v2_pad.c@475
"Dereference of null pointer"
"Access to field 'strips' results in a dereference of a null pointer
(loaded from field 'current_client')"

The boolean logic was incorrect (c.f. the check in the following
function).

6. examples/idle.c@163,174,182
"Uninitialized argument value"
"1st function call argument is an uninitialized value"

If close_timeout != 0, but simulate_activity_timeout >= close_timeout,
the program would segfault at pthread_cancel(t1).
2018-08-31 19:41:18 +02:00
sghctoma 2bd6fbf20e Fix that major(st_rdev) have no meaning on FreeBSD
The major device number does not indicate the device type on FreeBSD,
and AFAIK the only way to differentiate between DRM, input, and other
devices is checking the fd path. This commit implements that.

The drmDropmaster and drmSetmaster calls are necessary, because the
implicit drop (that should occur when the DRM fd is closed) seems not
to be working in some scenarios (e.g. if you have a tmux session
running - maybe the fd is retained somehow by tmux?). This is a
problem, because once you exit the compositor, you can't start it (or
any other program that wants to be DRM master) again until you close
all your tmux sessions.
2018-08-30 11:15:39 +02:00
Drew DeVault 633663cdde Use legacy modesetting for gamma control
It doesn't look like there's any motion on a fix from the AMDGPU side,
and using the legacy interface for this isn't so bad.
2018-08-29 23:05:38 +02:00
Alexander Bakker 221d412824 Init the new destroy signals added by #1200 2018-08-27 18:21:36 +02:00
Alexander Bakker 20db29779e Add destroy signals to types that are destroyed by wl_display_destroy 2018-08-26 23:23:12 +02:00
Scott Anderson fd3fa760d3 Revert "Revert "Merge pull request #1194 from ascent12/meson_feature""
This reverts commit 9c886f20b9.
2018-08-24 19:35:02 +12:00
Drew DeVault 9c886f20b9 Revert "Merge pull request #1194 from ascent12/meson_feature"
This breaks wlroots when used as a meson subproject.

This reverts commit dea311992e, reversing
changes made to 6db9c4b746.
2018-08-23 21:00:58 -04:00
Scott Anderson 784c20c82f Use new options for X11 backend and Xwayland 2018-08-22 20:27:37 +12:00
Scott Anderson 94ed2fc7bb Use feature options for libcap/logind
We now use a combo choice between systemd/elogind as they are mutually
exclusive anyway.
2018-08-22 19:53:00 +12:00
emersion 7a3f7b3c8a backend/drm: add support for DRM_MODE_CONNECTOR_DPI 2018-08-21 13:05:38 +01:00
emersion d66d33f5a2
Merge pull request #1188 from emersion/freebsd-fixes
Fix build on FreeBSD
2018-08-16 11:02:21 +01:00
emersion f86f1daf9a Fix build on FreeBSD 2018-08-16 10:54:45 +01:00
sdilts 8e7df5eb88 Fix xcb_create_window parameters
Set the window width and height, not the location of the window.
2018-08-10 18:05:34 -06:00
sdilts da79fef5f7 Add guard for changing the size of X11 backend windows
Events that set the window to either a width or height of zero are now
ignored and logged.
2018-08-09 22:09:48 -06:00
sdilts 55cca6deaa Set default output size for X11 backend
Fixes issue #1170
Also set the created window size to match the output size.
2018-08-09 22:05:18 -06:00
Ilia Bozhinov cb42e16f64 session: load GPU devices even if they have zero crtcs/connectors/encoders
On some systems (most notably laptops with two GPUs) there are GPUs that
don't have attached outputs. However, we still want to load those GPUs
because they could still be used by the compositor for rendering.
2018-08-08 07:34:12 +03:00
Scott Anderson 2d8f53affd Check for DRM prime
This will indicate the user properly when multi-GPU is not supported by
their GPU driver.
2018-08-05 18:25:25 +12:00
Scott Anderson 1a2b3445dc Remove unused data from gbm_bo userdata
These aren't used anymore and crashes when the gbm_bo tries to get
destroyed (e.g. on hotplug).
2018-08-04 17:02:53 +12:00
Scott Anderson 4bee710c30 Fix hardware cursor on secondary GPU
Create rendering resources on parent GPU, so that we can sample the
passed in texture properly. The cursor buffer needs to remain on the
same GPU.
2018-08-04 15:08:28 +12:00
Mariusz Bialonczyk e547e55be0 multi-gpu: do not flip screens on secondary GPU
All screens on secondary GPU in multiple GPU configurations
was flipped 180.

The flipped screens was always on secondary card (the primary card
was always correct).

Tested on nouveau with:
WLR_DRM_DEVICES=/dev/dri/card1:/dev/dri/card2
WLR_DRM_DEVICES=/dev/dri/card2:/dev/dri/card1

The commit is fixing this problem. Now all screens are "normal".
2018-08-03 07:43:22 +02:00
Mariusz Bialonczyk 15dacebc36 multi-backend: do not expose internal renderers
backend_get_renderer() is now returning the renderer of the primary GPU, instead
of its own renderer, since that's the thing which actually does all of the "real"
rendering

wlr_multi_backend_add() is now adding all subbackends (otherwise only one GPU
is handled).

credits: @ascent12
2018-08-03 07:43:22 +02:00
emersion 364afced3e backend/drm: remove unnecessary casts 2018-08-02 23:33:59 +01:00
emersion 2ebecb6727 backend/drm: allow to pass empty gamma ramp to reset it 2018-08-02 23:33:59 +01:00
emersion a149c2370a Implement wlr-gamma-control-unstable-v1 2018-08-02 23:33:04 +01:00
Drew DeVault 4b096fc114 Revert "Merge pull request #1153 from emersion/include-config"
This reverts commit ef0a6ea4d2, reversing
changes made to 8d03bc9178.
2018-07-21 09:44:20 -04:00
emersion 41094a7df5 Always include config.h 2018-07-21 13:08:23 +01:00
Markus Ongyerth 36955204cf Remove last remnant of tool_tool in libinput 2018-07-14 09:49:58 +02:00
Markus Ongyerth d9e978e1b3 rename wlr_tablet_tool to wlr_tablet
The previous naming was based on the input-device capability names from
libinput.
With code that uses the libinput_tablet_tool and mapping into tablet-v2,
this is confusing, so the name is changed to follow the names used in
the protocol.
2018-07-14 09:49:58 +02:00
Markus Ongyerth 48e2cba9b6 Handle relative motion for mouse tools 2018-07-14 09:48:57 +02:00
Markus Ongyerth 3be916f9b8 Add asserts and rename destroy function in libinput backend 2018-07-14 09:48:57 +02:00
Markus Ongyerth 0c9a26828a Use wlr_list for paths, and improve inert resource handling 2018-07-14 09:43:17 +02:00
Markus Ongyerth adba68a3c1 Use tablet_tool impl in libinput backend 2018-07-14 09:43:16 +02:00
Markus Ongyerth 31cec36b74 1st feedback pass
Rename make_ functions to _create
Implement set_cursor and set_feedback
2018-07-14 09:43:16 +02:00
Markus Ongyerth 599f84f736 Fix borked rebase 2018-07-14 09:40:39 +02:00
Markus Ongyerth 5c7a37f309 Add tool buttons 2018-07-14 09:40:39 +02:00
Markus Ongyerth 391eef6ea9 Propagate most axis events to clients 2018-07-14 09:40:39 +02:00
Markus Ongyerth f375246657 Implement basic tablet_pad handling (bound to keyboard focus) 2018-07-14 09:40:39 +02:00
Markus Ongyerth e235f7d336 Basic tablet_v2 object lifetime 2018-07-14 09:40:39 +02:00
Markus Ongyerth 77bac448cc storage commit #2 2018-07-14 09:40:39 +02:00
Markus Ongyerth 000b305ecc backend/libinput: Manage tablet tool livetimes
This adds the management code to manage tablet tools lifetimes from
libinput.
It follows the suggestion made in the tablet-unstable-v2.xml to destroy
tablet_tools once all tablets that it got into contact with were removed
from the system. This is implemented via a refcount.

If a tool is *not* unique, it will be destroyed on proximity out. This
is libinput specific and mentioned in libinput docs that tools will not
be found again, so we shouldn't keep a reference to them.
Also they can't be on other tablets as well, because they cannot be
tracked.

The naming in this commit is a bit off (to not break things).
The wlr names stay the same, tablet_tool is the libinput_device with
capaiblity LIBINPUT_DEVICE_CAP_TABLET_TOOL which is more akin to
"tablet" in the tablet-unstable-v2 protocol.
The struct that corresponds to the tablet_tool in tablet-unstable-v2 is
called tablet_tool_tool, a rename should be done at some point in the
future.
2018-07-14 09:40:39 +02:00
Guido Günther 40fe252c2d x11: make sure event source is drained
Otherwise running under Xvfb will not deliver any events. This results
in e.g. weston-info reporting a 0x0 window size (which results in all
sorts of problems).
2018-07-11 17:34:43 +02:00
Guido Günther 8515b7c65b x11: use correct type for events in wl_event_loop_add_fd 2018-07-11 17:30:45 +02:00
Guido Günther e463b49166 x11: Check if xcb_configure_window worked
So far we did not check for any errors
2018-07-11 17:29:41 +02:00
emersion 7cbef15206
util: add wlr_ prefix to log symbols 2018-07-09 22:49:54 +01:00
Drew DeVault be54278207
Merge pull request #1095 from agx/output-add-mode
Allow to add additional modes to outputs
2018-07-07 08:58:17 -07:00
Guido Günther 8d72090afe drm: Allow to add additional modes
This allows to add additional modes to the list of available video modes
using VESA Coordinated Video Timing information.

Closes #1080
2018-07-07 14:51:39 +02:00
Drew DeVault 07209d062c
Merge pull request #1104 from VincentVanlaer/logind-fd-leak
Close fd's obtained from logind
2018-06-30 17:49:45 -07:00
Vincent Vanlaer ece58514b4 Close fd's obtained from logind 2018-07-01 02:22:57 +02:00
emersion 2b9cbaddf3
screencopy: add support for frame flags 2018-06-30 22:18:03 +01:00
Dominique Martinet 0c2a64df18 headless add_input_device: fix leak on error
Found through static analysis
2018-06-30 20:46:58 +09:00
Dominique Martinet e5348ad7d3 backend autocreate: fix leak when WLR_BACKENDS is set
Found through static analysis
2018-06-30 11:45:57 +09:00
Dominique Martinet 1940c6bbd9 wayland backend: fix width/height == 0 check
We cannot handle just one of the two being NULL later down the road
(e.g. divide by zero in matrix projection code),
just ignore any such configure request.

Found through static analysis
2018-06-30 11:38:21 +09:00