Commit graph

606 commits

Author SHA1 Message Date
emersion
75b10cd621
backend: support creating DRM and libinput via WLR_BACKENDS 2018-05-19 09:32:08 +01:00
emersion
007d83c6ee
backend: allow multiple backends in WLR_BACKENDS 2018-05-19 09:09:03 +01:00
emersion
52bd8aa716
backend/multi: disallow multiple renderers at the same time 2018-05-19 09:09:03 +01:00
emersion
a1631dd9ee
backend: add WLR_BACKEND env variable 2018-05-19 09:08:59 +01:00
Markus Ongyerth
6a46fcc6f2 recalculate cursor projection matrix on set_cursor
Updates the projection matrix for the cursor plane in the DRM backend,
when the cursor is set, so new cursor are uploaded with the correct
transformation.
2018-05-16 15:44:41 +02:00
emersion
198ad27bd5
backend/wayland: print output name in window title 2018-05-15 00:16:18 +01:00
emersion
0b58579564
Add support for discrete axis values 2018-05-12 13:34:58 +01:00
emersion
13098a18ea
Fix hardware cursors scale & transform 2018-05-09 19:58:18 +01:00
emersion
caf9f9022c
Merge pull request #936 from emersion/full-hardware-cursors
output: always use hardware cursors if available
2018-05-04 19:00:45 +01:00
morganamilo
6305e6327f
Fix typos in comments and strings 2018-05-03 21:59:43 +01:00
Guido Günther
1637053ef8 drm: only disable atomic modesetting when WLR_DRM_NO_ATOMIC == 1
Don't allow any value of the env var to disable atomic mode setting.
2018-05-03 15:37:37 +02:00
Guido Günther
545d54439d backend/wayland: don't transform pointer events
We do this in a backend independent way in wlr_cursor now.
2018-05-03 11:09:14 +02:00
Guido Günther
6f01c12b40 backend/x11: don't transform pointer events
We do this in a backend independent way in wlr_cursor now.
2018-05-03 11:09:14 +02:00
emersion
225d182765
output: always use hardware cursors if available
This changes the `wlr_output_impl.set_cursor` function to take a
`wlr_texture` instead of a byte buffer. This simplifies the
DRM and Wayland backends since they were creating textures from
the byte buffer anyway.

With this commit, performance should be improved when moving the
cursor since outputs don't need to be re-rendered anymore.
2018-05-01 21:38:04 +01:00
emersion
178ac8bffe
backend/{wayland,x11}: fix pointer coords for transformed outputs 2018-04-30 10:48:35 +01:00
emersion
62d7337d00
backend/x11: add one pointer per output 2018-04-29 14:46:29 +01:00
emersion
ddac792b61
backend/wayland: only set one pointer listener 2018-04-29 14:30:13 +01:00
emersion
9f8a7c8fc4
backend/wayland: create one virtual pointer per output 2018-04-29 14:30:13 +01:00
emersion
2551ef8871
input-device: add output_name field, populate it from libinput 2018-04-29 14:30:09 +01:00
emersion
f8e0a03451
backend/x11: correctly destroy input devices 2018-04-28 12:55:36 +01:00
emersion
79da4c175e
backend/headless: remove useless destructor 2018-04-28 12:48:05 +01:00
emersion
57c36ddcb3
backend/wayland: add proper error handling to wlr_wl_backend_create 2018-04-28 12:38:03 +01:00
Drew DeVault
fecb971518
Merge pull request #902 from emersion/various-memory-leaks
Various memory leaks
2018-04-26 11:34:49 +02:00
emersion
cd9f25711c
backend: destroy renderer when destroying backend 2018-04-25 23:53:43 +01:00
emersion
625a7a48dc
Don't use the wlr_ prefix for static functions 2018-04-25 23:51:00 +01:00
emersion
71ca45e2c0
Make sure we don't use others' prefixes 2018-04-25 23:24:58 +01:00
emersion
b0d99f5c67
Remove wlr_ prefix from local symbols 2018-04-25 23:00:46 +01:00
emersion
018b82c01e
render/egl: allow passing NULL to surface and image destructors 2018-04-25 08:28:48 +01:00
emersion
eaed6bd03b
render/egl: add wlr_egl_destroy_surface 2018-04-24 23:44:43 +01:00
Drew DeVault
dbdc63ddde
Merge pull request #873 from emersion/output-dont-emit-mode-twice
output: don't emit the mode event if it hasn't changed
2018-04-17 21:08:27 -04:00
emersion
94fa6c88f4
output: don't emit the mode event if it hasn't changed
This also fixes #535.
2018-04-18 00:15:25 +01:00
Uli Schlachter
e5ab12339f x11 backend: Expose events mean "needs swap"
When the X11 server sends an expose event, that means that "this
rectangle here (the event contains x,y,width,height) has undefined
contents on your window; please redraw that". This means that we need a
swap. However, so far the code does not actually enforce that a swap
happens.

For example, start rootston, switch to another workspace and then switch
back. The rootston window will not be redrawn (before commit
52b058c2a3, it would just be fully white; after that commit it will
show whatever was visible on the old workspace). This is because the
drawing code concludes that nothing needs to be done. However, in fact a
swap is necessary.

This reverts commit e79d924588, because its optimisation is already
done now: wlr_output_update_needs_swap() emits a signal, which is
handled by wlr_output_damage with a call to wlr_output_schedule_frame().
This function does nothing if a frame is already pending. Thus, the
optimisation from commit e79d924588 now happens implicitly.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-04-15 11:41:09 +02:00
Uli Schlachter
e79d924588 x11 backend: Ignore expose if frame is pending
When resizing rootston with the mouse, the result is really slow. One
can see that rootston needs quite a while for drawing the newly visible
area. This is because every single expose event is handled on its own
and causes (apparently) a full repaint or at least a swap.

This commit improves things by only causing a new frame if none is
pending already.

With this change, there is almost no delay in rootston drawing the newly
visible area.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-04-15 11:07:31 +02:00
Uli Schlachter
52b058c2a3 x11 backend: Do not set a back pixel on windows
Before this commit, the x11 server would fill any exposed area with
white before the wlroots x11 backend got a chance to do anything. This
was e.g. visible when running rootston and resizing the window: When the
window becomes larger, the new area is filled with black.

By just not setting a back pixel value, this commit gets rid of this
behaviour.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-04-15 11:07:31 +02:00
Uli Schlachter
98f8ec6a08 x11_handle_input_event: Remove return value
handle_x11_event() and x11_handle_input_event() react to different kinds
of events, so it does not make much of a difference if
x11_handle_input_event() signals if it handled an event or not.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-04-15 10:33:53 +02:00
Uli Schlachter
3728abd1fc handle_x11_event: Remove return value
This function always returns "false", so its return type can simply be
changed to void.

Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-04-15 10:32:30 +02:00
emersion
d2ebbd103c
backend: remove wlr_backend_get_egl 2018-04-08 11:00:56 -04:00
emersion
03563b61a8
backend/{x11,headless}: use default if supplied refresh is invalid 2018-04-05 22:48:00 -04:00
Tancredi Orlando
68ad7e5092 Add ifdef to build without X11 2018-04-04 19:59:47 +02:00
emersion
2d6bbf12f8
backend/{x11,headless}: fix refresh rate 2018-04-03 22:54:01 -04:00
Drew DeVault
2ecce27dd5
Merge pull request #807 from swaywm/input-inhibit
Input inhibit
2018-04-03 15:58:47 -04:00
Drew DeVault
56deff41b6 Implement input inhibit in rootston 2018-04-03 15:09:53 -04:00
emersion
9609985f29
backend/x11: fix cursor position when receiving configure event 2018-04-03 13:32:24 -04:00
emersion
60f07ee321
backend/x11: fix WLR_HAS_XCB_XKB always undefined 2018-04-03 13:12:52 -04:00
Drew DeVault
8b37e8f67a
Merge pull request #792 from emersion/x11-backend-blank-cursor
backend/x11: hide cursor
2018-04-02 10:21:07 -04:00
Drew DeVault
b60e31e5c0
Merge pull request #794 from emersion/renderer-untie-backend
Untie wlr_backend from wlr_renderer
2018-03-31 21:31:15 -04:00
emersion
a2391a6047
Fix cursor transform on DRM backend 2018-03-31 20:55:31 -04:00
emersion
33a2eb4b77
Untie wlr_backend from wlr_renderer 2018-03-31 18:49:43 -04:00
emersion
37aae0b2cd
backend/x11: flush after destroying window
Otherwise the destroy message is kept buffered and never reaches
the X11 server. Thanks X11.
2018-03-31 13:28:50 -04:00
emersion
7b88ace557
backend/x11: hide cursor 2018-03-31 12:10:43 -04:00
emersion
5111f7df84
backend/x11: fix extra output 2018-03-30 23:51:20 -04:00
emersion
f37e8c5b6e
backend/wayland: cleanup input transform code 2018-03-30 23:51:20 -04:00
emersion
aa6ae710f7
backend/x11: fix input events 2018-03-30 23:51:19 -04:00
emersion
0a7a8cbd1c
backend/x11: add WLR_X11_OUTPUTS support 2018-03-30 23:51:19 -04:00
emersion
d4f7ced6e2
backend/x11: refactor, prepare support for multiple outputs 2018-03-30 23:51:16 -04:00
emersion
5dd022da13
Merge pull request #765 from swaywm/transformed-events
Use libinput transformed events instead of width_mm/height_mm
2018-03-28 14:11:39 -04:00
Drew DeVault
3813121fef Fix wayland output absolute input handling 2018-03-28 14:04:23 -04:00
Drew DeVault
52d621e097
Merge pull request #763 from emersion/x11-backend-kbd-modifiers
backend/x11: correctly update keyboard modifiers
2018-03-28 12:51:08 -04:00
Drew DeVault
ac219cbda6 Remove width_mm from tablet events 2018-03-28 12:05:37 -04:00
Drew DeVault
324b9d910d Remove width_mm from wlr_touch events 2018-03-28 11:04:40 -04:00
Drew DeVault
a35a5786b0 Remove width_mm from wlr_pointer events 2018-03-28 10:46:50 -04:00
emersion
f033f717a2
backend/x11: make xcb-xkb optional, remove global state 2018-03-28 00:26:15 -04:00
Tony Crisci
330ee08126
Merge pull request #744 from emersion/texture-redesign
Redesign wlr_texture
2018-03-28 00:14:57 -04:00
emersion
8d1b5c7600
backend/x11: correctly update keyboard modifiers 2018-03-28 00:04:32 -04:00
Dominique Martinet
a0b52a0dff Fix x11 backend
Need to include wlr/config.h before using the various WLR_HAS_xxx defines
2018-03-27 09:20:21 +02:00
Drew DeVault
b1c4f01bad
Merge pull request #713 from ManDay/master
Make X11 fully optional
2018-03-26 23:20:46 -04:00
Drew DeVault
706f77e3c7 Address review feedback 2018-03-26 23:15:21 -04:00
emersion
adf4fb08dd
Merge branch 'master' into texture-redesign 2018-03-26 19:13:13 -04:00
emersion
3bda7e2ef8
Use DRM_FORMAT_MOD_LINEAR instead of a hardcoded constant 2018-03-26 12:00:08 -04:00
Uli Schlachter
c7f8b28d8d Fix use-after-free in x11 backend during shutdown
The xcb_connection_t instance that is used here comes from
XGetXCBConnection(), is created by XOpenDisplay(), and is owned by the
returned Display*. Calling xcb_disconnect() directly on it leads to
various use-after-frees during shutdown, as reported by valgrind. The
first one of the about 30 errors is:

    Invalid read of size 4
       at 0x71F2051: xcb_take_socket (in /usr/lib64/libxcb.so.1.1.0)
       by 0x78551DD: ??? (in /usr/lib64/libX11.so.6.3.0)
       by 0x7855A14: _XFlush (in /usr/lib64/libX11.so.6.3.0)
       by 0x7858504: _XGetRequest (in /usr/lib64/libX11.so.6.3.0)
       by 0x7838966: XFreeGC (in /usr/lib64/libX11.so.6.3.0)
       by 0x783238B: XCloseDisplay (in /usr/lib64/libX11.so.6.3.0)
       by 0x4E680C2: wlr_x11_backend_destroy (backend.c:333)
       by 0x4E57E94: wlr_backend_destroy (backend.c:39)
       by 0x4E629FB: multi_backend_destroy (backend.c:47)
       by 0x4E62B5A: handle_display_destroy (backend.c:90)
       by 0x50B7E9F: ??? (in /usr/lib64/libwayland-server.so.0.1.0)
       by 0x50B8476: wl_display_destroy (in /usr/lib64/libwayland-server.so.0.1.0)
     Address 0xc14dda0 is 0 bytes inside a block of size 21,152 free'd
       at 0x4C2DD18: free (vg_replace_malloc.c:530)
       by 0x4E680A5: wlr_x11_backend_destroy (backend.c:330)
       by 0x4E57E94: wlr_backend_destroy (backend.c:39)
       by 0x4E629FB: multi_backend_destroy (backend.c:47)
       by 0x4E62B5A: handle_display_destroy (backend.c:90)
       by 0x50B7E9F: ??? (in /usr/lib64/libwayland-server.so.0.1.0)
       by 0x50B8476: wl_display_destroy (in /usr/lib64/libwayland-server.so.0.1.0)
       by 0x40C54E: main (main.c:84)
     Block was alloc'd at
       at 0x4C2EA1E: calloc (vg_replace_malloc.c:711)
       by 0x71F0C60: xcb_connect_to_fd (in /usr/lib64/libxcb.so.1.1.0)
       by 0x71F4BD4: xcb_connect_to_display_with_auth_info (in /usr/lib64/libxcb.so.1.1.0)
       by 0x7854AA1: _XConnectXCB (in /usr/lib64/libX11.so.6.3.0)
       by 0x7845481: XOpenDisplay (in /usr/lib64/libX11.so.6.3.0)
       by 0x4E681B6: wlr_x11_backend_create (backend.c:376)
       by 0x4E580EE: wlr_backend_autocreate (backend.c:99)
       by 0x40C27D: main (main.c:35)

Normally, one would expect this to crash during XCloseDisplay() when
xcb_disconnect() is called again and frees the same data again (glibc would
detect a double free). However, XCloseDisplay() tries to clean up some internal
caches first for which it has to send requests to the X11 server (e.g. the
XFreeGC() above). This fails since the file descriptor was already closed,
which causes an IO error. Xlib's _XDefaultIOError() handles this by printing an
error message and calling exit(1).

Thus, the only symptom of this problem was compositors exiting
mid-shutdown and printing an error message:

    XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
          after 6 requests (6 known processed) with 0 events remaining.

Fixes: https://github.com/swaywm/wlroots/issues/745
Signed-off-by: Uli Schlachter <psychon@znc.in>
2018-03-26 10:48:30 +02:00
emersion
c63d94483b
Redesign wlr_texture
- Textures are now immutable (apart from those created from raw
  pixels), no more invalid textures
- Move all wl_drm stuff in wlr_renderer
- Most of wlr_texture fields are now private
- Remove some duplicated DMA-BUF code in the DRM backend
- Add more assertions
- Stride is now always given as bytes rather than pixels
- Drop wl_shm functions

Fun fact: this patch has been written 10,000 meters up in the air.
2018-03-24 23:48:32 -04:00
Cedric Sodhi
51141dd11e Minor corrections 2018-03-23 10:28:36 +01:00
emersion
a854c2f246
Merge branch 'master' into gles2-renderer-redesign 2018-03-23 00:55:55 +01:00
Drew DeVault
ef3769851f
Merge pull request #740 from emersion/egl-debug
render/egl: use EGL_KHR_debug
2018-03-22 18:54:21 -04:00
Dominique Martinet
d5e14ab247 wayland backend: fix use-after free on output destroy
==12021==ERROR: AddressSanitizer: heap-use-after-free on address 0x617000015698 at pc 0x7f1a9abe1c09 bp 0x7ffe9068f6b0 sp 0x7ffe9068f6a0
WRITE of size 4 at 0x617000015698 thread T0
    #0 0x7f1a9abe1c08 in pointer_handle_leave ../backend/wayland/wl_seat.c:40
    #1 0x7f1a96ae7d1d in ffi_call_unix64 (/lib64/libffi.so.6+0x5d1d)
    #2 0x7f1a96ae768e in ffi_call (/lib64/libffi.so.6+0x568e)
    #3 0x7f1a988e0d8a  (/lib64/libwayland-client.so.0+0x8d8a)
    #4 0x7f1a988dd927  (/lib64/libwayland-client.so.0+0x5927)
    #5 0x7f1a988debe3 in wl_display_dispatch_queue_pending (/lib64/libwayland-client.so.0+0x6be3)
    #6 0x7f1a9abdd6d6 in dispatch_events ../backend/wayland/backend.c:28
    #7 0x7f1a9a968c11 in wl_event_loop_dispatch (/lib64/libwayland-server.so.0+0x9c11)
    #8 0x7f1a9a967449 in wl_display_run (/lib64/libwayland-server.so.0+0x8449)
    #9 0x418dff in main ../rootston/main.c:81
    #10 0x7f1a99b5ef29 in __libc_start_main (/lib64/libc.so.6+0x20f29)
    #11 0x4057c9 in _start (/home/shared/wayland/wlroots/build/rootston/rootston+0x4057c9)

0x617000015698 is located 664 bytes inside of 696-byte region [0x617000015400,0x6170000156b8)
freed by thread T0 here:
    #0 0x7f1a9af754b8 in __interceptor_free (/lib64/libasan.so.4+0xde4b8)
    #1 0x7f1a9abe01ee in wlr_wl_output_destroy ../backend/wayland/output.c:194
    #2 0x7f1a9ac12918 in wlr_output_destroy ../types/wlr_output.c:299
    #3 0x7f1a9abe061b in xdg_toplevel_handle_close ../backend/wayland/output.c:255
    #4 0x7f1a96ae7d1d in ffi_call_unix64 (/lib64/libffi.so.6+0x5d1d)
    #5 0x7f1a96ae768e in ffi_call (/lib64/libffi.so.6+0x568e)
    #6 0x7f1a988e0d8a  (/lib64/libwayland-client.so.0+0x8d8a)
    #7 0x7f1a988dd927  (/lib64/libwayland-client.so.0+0x5927)
    #8 0x7f1a988debe3 in wl_display_dispatch_queue_pending (/lib64/libwayland-client.so.0+0x6be3)
    #9 0x7f1a9abdd6d6 in dispatch_events ../backend/wayland/backend.c:28
    #10 0x7f1a9a968c11 in wl_event_loop_dispatch (/lib64/libwayland-server.so.0+0x9c11)
    #11 0x7f1a9a967449 in wl_display_run (/lib64/libwayland-server.so.0+0x8449)
    #12 0x418dff in main ../rootston/main.c:81
    #13 0x7f1a99b5ef29 in __libc_start_main (/lib64/libc.so.6+0x20f29)
    #14 0x4057c9 in _start (/home/shared/wayland/wlroots/build/rootston/rootston+0x4057c9)

previously allocated by thread T0 here:
    #0 0x7f1a9af75a38 in __interceptor_calloc (/lib64/libasan.so.4+0xdea38)
    #1 0x7f1a9abe0703 in wlr_wl_output_create ../backend/wayland/output.c:272
    #2 0x7f1a9abdd8eb in wlr_wl_backend_start ../backend/wayland/backend.c:55
    #3 0x7f1a9abbeb49 in wlr_backend_start ../backend/backend.c:28
    #4 0x7f1a9abd8ce1 in multi_backend_start ../backend/multi/backend.c:24
    #5 0x7f1a9abbeb49 in wlr_backend_start ../backend/backend.c:28
    #6 0x418c32 in main ../rootston/main.c:58
    #7 0x7f1a99b5ef29 in __libc_start_main (/lib64/libc.so.6+0x20f29)
    #8 0x4057c9 in _start (/home/shared/wayland/wlroots/build/rootston/rootston+0x4057c9)
2018-03-22 21:27:49 +01:00
Dominique Martinet
b0c2bbebd1 x11 backend: fix various leaks
- xcb_query_pointer_reply return value needs to be freed
 - call XCloseDisplay
 - remove wl event_source
2018-03-22 21:25:41 +01:00
emersion
60bfe0a6aa
backend/drm: remove remaining raw GL call
This makes the hardware cursor code a less efficient. Can be
fixed with a GLES3 renderer.
2018-03-21 11:34:08 +01:00
emersion
b1f93bc5cc
render/egl: use EGL_KHR_debug 2018-03-21 10:42:43 +01:00
emersion
3581573bdc
render/gles2: make wlr_renderer_begin take viewport size
This allows raw GL calls outside wlr_renderer to be removed.
2018-03-21 07:37:09 +01:00
emersion
c41de2d1be
render: split render.h into wlr_renderer.h and wlr_texture.h 2018-03-19 23:16:29 +01:00
emersion
6227da96b1
backend/drm: don't hardcode matrix 2018-03-18 11:34:23 +01:00
emersion
7894fca224
matrix: rename wlr_matrix_texture to wlr_matrix_projection 2018-03-15 21:26:45 +01:00
emersion
876f07e9f1
renderer: replace wlr_texture_get_matrix by wlr_render_texture 2018-03-15 19:31:02 +01:00
emersion
824a95ad19
matrix: use 2D matrices 2018-03-15 15:33:58 +01:00
emersion
d26b67cb06
matrix: unify API, don't use array pointers 2018-03-15 11:10:56 +01:00
emersion
b6a3f240c7
matrix: move to types/ 2018-03-15 09:11:27 +01:00
Tony Crisci
efa9eeb5d5
Merge pull request #716 from emersion/fix-cursor-hotspot-update
Fix cursor hotspot update
2018-03-12 21:50:07 -04:00
emersion
d24f868bbe
backend/drm: fix cursor hotspot not updated 2018-03-12 19:34:43 +01:00
emersion
7cdad5cde4
Merge pull request #710 from emersion/dont-move-hidden-cursors
output: don't move hidden cursors
2018-03-12 14:25:20 +01:00
emersion
92ca4ad474
backend/drm: refactor wlr_drm_connector_set_cursor 2018-03-11 11:40:03 +01:00
Cedric Sodhi
ebdabc2030 Make X11 fully optional
Make X11 Backend (in addition to XWayland) optional and small bug fix on XWayland includes.
2018-03-09 15:17:15 +01:00
Drew DeVault
bfc0e95d2c Add mode support to libinput backend
And extend tablet example with tilt and ring support
2018-03-07 20:57:55 -05:00
Scott Anderson
3c9fc7c68e Add const to x11 and input interfaces 2018-03-06 21:16:18 +13:00
Scott Anderson
902d6cc240 Use xcb atoms properly 2018-03-06 21:15:47 +13:00
Markus Ongyerth
2cea430488 prevent current_mode null on output_enable(false)
The current mode was set to NULL to abuse it as state variable
persisting DRM suspend/resume, this results resulted in a segfault on
normal DPMS cycle.

This reverts that change and uses the wlr_output enabled variable, which
also persists and makes more sense.
2018-03-01 15:48:25 +01:00
Markus Ongyerth
a65ef8ea86 restore dpms state on drm resume
If there is no current mode, set outputs to dpms off in drm resume.
Sets current mode to null on disable to ensure this can be checked.
2018-02-26 18:12:51 +01:00
Drew DeVault
3296365ce5
Merge pull request #659 from agx/alpha
Make wlr_render_with_matrix use alpha
2018-02-25 13:16:35 -05:00
Guido Günther
d08792bfff Add alpha to wlr_render_with_matrix
so we can use the alpha channel to e.g. blend in textures
2018-02-25 13:47:48 +01:00
Drew DeVault
7da653bbb4
Merge pull request #669 from acrisci/headless-output-frame-timer
destroy frame timer in headless output
2018-02-25 00:26:32 -05:00
Tony Crisci
721e4ec55f remove frame timer from headless output 2018-02-24 22:32:57 -05:00