Coder Social home page Coder Social logo

wlc's Introduction

DEPRECATION NOTICE

wlc is officially deprecated. Interested users are encouraged to use wlroots instead.

FEATURES

Backends DRM, X11, Wayland
Renderers EGL, GLESv2
Buffer API GBM, EGL streams
TTY session logind, legacy (suid)
Input libinput, xkb
Monitor Multi-monitor, DPMS
Hotplugging udev
Xwayland Supported
Clipboard Partially working
Drag'n'Drop Not implemented

EXAMPLE

// For more functional example see example/example.c

#include <stdlib.h>
#include <wlc/wlc.h>

static bool
view_created(wlc_handle view)
{
   wlc_view_set_mask(view, wlc_output_get_mask(wlc_view_get_output(view)));
   wlc_view_bring_to_front(view);
   wlc_view_focus(view);
   return true;
}

static void
view_focus(wlc_handle view, bool focus)
{
   wlc_view_set_state(view, WLC_BIT_ACTIVATED, focus);
}

int
main(int argc, char *argv[])
{
   wlc_set_view_created_cb(view_created);
   wlc_set_view_focus_cb(view_focus);

   if (!wlc_init())
      return EXIT_FAILURE;

   wlc_run();
   return EXIT_SUCCESS;
}

ENV VARIABLES

wlc reads the following env variables.

WLC_DRM_DEVICE Device to use in DRM mode. (card0 default)
WLC_BUFFER_API Force buffer API to GBM or EGL.
WLC_SHM Set 1 to force EGL clients to use shared memory.
WLC_OUTPUTS Number of fake outputs in X11/Wayland mode.
WLC_XWAYLAND Set 0 to disable Xwayland.
WLC_LIBINPUT Set 1 to force libinput. (Even on X11/Wayland)
WLC_REPEAT_DELAY Keyboard repeat delay.
WLC_REPEAT_RATE Keyboard repeat rate.
WLC_DEBUG Enable debug channels (comma separated)

KEYBOARD LAYOUT

You can set your preferred keyboard layout using XKB_DEFAULT_LAYOUT.

See xkb documentation for more details.

RUNNING ON TTY

If you have logind, you don't have to do anything.

Without logind you need to suid your binary to root user. The permissions will be dropped runtime.

BUFFER API

wlc supports both GBM and EGL streams buffer APIs. The buffer API is auto-detected based on the driver used by the DRM device.

  • GBM is supported by most GPU drivers except the NVIDIA proprietary driver.
  • EGL is only supported by the NVIDIA proprietary. If you have a NVIDIA GPU using the proprietary driver you need to enable DRM KMS using the nvidia-drm.modeset=1 kernel parameter.

You can force a given buffer API by setting the WLC_BUFFER_API environment variable to GBM or EGL.

ISSUES

Submit issues on this repo if you are developing with wlc.

As a user of compositor, report issues to their corresponding issue trackers.

BUILDING

You will need following makedepends:

  • cmake
  • git

And the following depends:

  • pixman
  • wayland 1.7+
  • wayland-protocols 1.7+ [1]
  • libxkbcommon
  • udev
  • libinput
  • libx11 (X11-xcb, Xfixes)
  • libxcb (xcb-ewmh, xcb-composite, xcb-xkb, xcb-image, xcb-xfixes)
  • libgbm (usually provided by mesa in most distros)
  • libdrm
  • libEGL (GPU drivers and mesa provide this)
  • libGLESv2 (GPU drivers and mesa provide this)

1: Also bundled as submodule. To build from submodule use -DSOURCE_WLPROTO=ON.

And optionally:

  • dbus (for logind support)
  • systemd (for logind support)

For weston-terminal and other wayland clients for testing, you might also want to build weston from git.

You can build bootstrapped version of wlc with the following steps.

git submodule update --init --recursive # - initialize and fetch submodules
mkdir target && cd target               # - create build target directory
cmake -DCMAKE_BUILD_TYPE=Upstream ..    # - run CMake
make                                    # - compile

# You can now run (Ctrl-Esc to quit)
./example/example

PACKAGING

For now you can look at the AUR recipe for a example.

Releases are signed with B22DA89A and published on GitHub.

All 0.0.x releases are considered unstable.

CONTRIBUTING

See the CONTRIBUTING for more information.

BINDINGS

SOFTWARE USING WLC

  • orbment - Modular Wayland compositor
  • ocaml-loliwm - Translation of loliwm to OCaml
  • sway - i3-compatible window manager for Wayland
  • way-cooler - customizeable window manager written in Rust
  • fireplace - Modular wayland window manager written in Rust

SIMILAR SOFTWARE

  • ewlc - A separately maintained fork of wlc
  • swc - A library for making a simple Wayland compositor
  • libwlb - A Wayland back-end library
  • libweston - Weston as a library

wlc's People

Contributors

ammen99 avatar aomader avatar ascent12 avatar cloudef avatar crondog avatar ddevault avatar deathlyfrantic avatar drakulix avatar dudemanguy avatar earnestly avatar enerccio avatar fluxchief avatar hummer12007 avatar johalun avatar jwrdegoede avatar kozec avatar l-as avatar ljrk0 avatar lkundrak avatar mikkeloscar avatar nyorain avatar sardemff7 avatar sce avatar snirkimmington avatar stebalien avatar timidger avatar valpackett avatar vially avatar xerpi avatar yohanesu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wlc's Issues

Confusing cmake message when xcb libs are not found

Suppose I don't have libxcb-composite0-dev installed, I get:

CMake Error at /usr/share/cmake-3.0/Modules/FindPackageHandleStandardArgs.cmake:136 (message):
  Could NOT find XCB (missing: XCB_LIBRARIES)
Call Stack (most recent call first):
  /usr/share/cmake-3.0/Modules/FindPackageHandleStandardArgs.cmake:343 (_FPHSA_FAILURE_MESSAGE)
  CMake/FindXCB.cmake:23 (find_package_handle_standard_args)
  src/CMakeLists.txt:68 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/aengelen/dev/wlc/CMakeFiles/CMakeOutput.log".

Changing XCB_LIBRARIES to ${XCB_LIBRARIES} in CMake/FindXCB.cmake gives a more enlightening error, but my cmake skills are too limited to determine whether that makes any sense :)

SIGFPE crash in virtualbox

Hi
I have Arch linux running in VirtualBox. I can't get the hardware rendering to work properly so for now I am using software rendering. Weston works fine under X using SHM. However, if I run the wlc example under X I get this error (regardless if set WLC_SHM=1 or not):

wlc: Work done, dropping permissions and checking communication
wlc: Activating tty
created output (1)
wlc: Xwayland :1 -rootless -terminate -listen 14 -listen 15 -wm 19
libEGL warning: DRI2: failed to authenticate
wlc: EGL context is double buffered
wlc: EGL version: 1.4 (DRI2)
wlc: EGL vendor: Mesa Project
wlc: EGL client APIs: OpenGL OpenGL_ES OpenGL_ES2 OpenGL_ES3 
wlc: EGL context (RGB888)
wlc: GLES2 renderer initialized
wlc: Set new bsurface to output (1)
wlc: Added output (1)
wlc: become active
wlc: SIGFPE signal received
#7  0x00007fc2c6a9bff1 in ?? ()
#8  0x3f0000003f000000 in ?? ()
#9  0x3f0000003f000000 in ?? ()
#10 0x3fa2f9833fa2f983 in ?? ()
#11 0x3fa2f9833fa2f983 in ?? ()
#12 0x0000000400000004 in ?? ()
#13 0x0000000400000004 in ?? ()
#14 0x3f8000003f800000 in ?? ()
#15 0x3f8000003f800000 in ?? ()
#16 0x0000000200000002 in ?? ()
#17 0x0000000200000002 in ?? ()
#18 0xb3222169b3222169 in ?? ()
#19 0xb3222169b3222169 in ?? ()
#20 0xfffffffefffffffe in ?? ()
#21 0xfffffffefffffffe in ?? ()
#22 0xbe2aaaa3be2aaaa3 in ?? ()
#23 0xbe2aaaa3be2aaaa3 in ?? ()
#24 0xb97da000b97da000 in ?? ()
#25 0xb97da000b97da000 in ?? ()
#26 0x7fffffff7fffffff in ?? ()
#27 0x7fffffff7fffffff in ?? ()
#28 0x8000000080000000 in ?? ()
#29 0x8000000080000000 in ?? ()
#30 0x7fc000007fc00000 in ?? ()
#31 0x7fc000007fc00000 in ?? ()
#32 0x403851eb403851eb in ?? ()
#33 0x403851eb403851eb in ?? ()
#34 0xb94ca1f9b94ca1f9 in ?? ()
#35 0xb94ca1f9b94ca1f9 in ?? ()
#36 0xbf800000bf800000 in ?? ()
#37 0xbf800000bf800000 in ?? ()
#38 0x000000019975df00 in ?? ()
#39 0xc108af6500000000 in ?? ()
#40 0x0000000000000001 in ?? ()
#41 0x0000000000cd5340 in ?? ()
#42 0x0000000000ce4270 in ?? ()
#43 0x00007fc2c108af65 in ?? () from /usr/lib/xorg/modules/dri/swrast_dri.so
#44 0x00007fc2c137bb7c in ?? () from /usr/lib/xorg/modules/dri/swrast_dri.so
#45 0x00000000000000ce in ?? ()
#46 0x0000000000000d00 in ?? ()
#47 0x0000000000cd2980 in ?? ()
#48 0x0000000000cd5340 in ?? ()
#49 0x00007fc2c108b0bd in ?? () from /usr/lib/xorg/modules/dri/swrast_dri.so
#50 0x00007fc2c1079e31 in ?? () from /usr/lib/xorg/modules/dri/swrast_dri.so
#51 0x00007fc2c0f7da5f in ?? () from /usr/lib/xorg/modules/dri/swrast_dri.so
#52 0x00000000000008e2 in ?? ()
#53 0xffffffffff600001 in ?? ()
#54 0x0000000c00000000 in ?? ()
#55 0xffffffffff600001 in ?? ()
#56 0xfce00000fe200000 in ?? ()
#57 0x0000000001e00000 in ?? ()
#58 0x0000000001473a2d in ?? ()
#59 0x0000000000000009 in ?? ()
#60 0x00007ffd3cc73f30 in ?? ()
#61 0x00007fc2c671c140 in ?? () from /home/mirama/Development/wlc/target/src/libwlc.so.0
#62 0x00007ffd3cc73e54 in ?? ()
#63 0x00007ffd3cc73f20 in ?? ()
#64 0x0000000000c840e0 in ?? ()
#65 0x0000000000000022 in ?? ()
#66 0x0000000000000000 in ?? ()
[mirama@JVM target]$ wlc: Parent exit (513)
wlc: Cleanup wlc

Use floating point instead of int for dragging windows

Hey there, nice project.
Looks quite nice already(loliwm)
I was just playing around a little bit with it, and found an issue while moving a window. If moving the cursor slowly while dragging a window, it wont move(I think because delta values under 0 are cut to 0), also after moving a window a lot, the cursor seems to go other ways than the window, it kinda drifts away. My experience says, that it is a float to int typecast issue(had some similar issues playing with touch and android).

Make fails with Error 2

$ uname -a
Linux itsuka 3.14.14-gentoo-gnu #5 SMP Wed Nov 5 21:39:53 EST 2014 x86_64 Intel(R) Core(TM)2 Duo CPU P8600 @ 2.40GHz GenuineIntel GNU/Linux

$ make
[ 2%] Generating wayland-xdg-shell-protocol.c
[ 5%] Generating wayland-xdg-shell-server-protocol.h
Scanning dependencies of target wlc
[ 8%] Building C object src/CMakeFiles/wlc.dir/compositor/buffer.c.o
[ 11%] Building C object src/CMakeFiles/wlc.dir/compositor/callback.c.o
[ 14%] Building C object src/CMakeFiles/wlc.dir/compositor/client.c.o
[ 17%] Building C object src/CMakeFiles/wlc.dir/compositor/compositor.c.o
[ 20%] Building C object src/CMakeFiles/wlc.dir/compositor/data.c.o
[ 22%] Building C object src/CMakeFiles/wlc.dir/compositor/output.c.o
/home/kotori/wlc/src/compositor/output.c: In function ‘wl_output_bind’:
/home/kotori/wlc/src/compositor/output.c:79:19: error: ‘WL_OUTPUT_SCALE_SINCE_VERSION’ undeclared (first use in this function)
/home/kotori/wlc/src/compositor/output.c:79:19: note: each undeclared identifier is reported only once for each function it appears in
/home/kotori/wlc/src/compositor/output.c:96:19: error: ‘WL_OUTPUT_DONE_SINCE_VERSION’ undeclared (first use in this function)
src/CMakeFiles/wlc.dir/build.make:182: recipe for target 'src/CMakeFiles/wlc.dir/compositor/output.c.o' failed
make[2]: *** [src/CMakeFiles/wlc.dir/compositor/output.c.o] Error 1
CMakeFiles/Makefile2:78: recipe for target 'src/CMakeFiles/wlc.dir/all' failed
make[1]: *** [src/CMakeFiles/wlc.dir/all] Error 2
Makefile:116: recipe for target 'all' failed
make: *** [all] Error 2

Support multiple "cards"

Currently wlc is hardcoded to card0, but multiple cards is possiblity and even render nodes.
It should also be possible to have outputs tied to cards instead of whole drm system, this would allow multiple GPUs used with multiple outputs.

logind support

Support logind. Drops the need for SUID on logind enabled systems, saner VT switching and DRM management, etc.

Fallback modeset

If there is no mode with CURRENT flag check, try PREFERRED mode, and lastly the biggest resolution available.

Sometimes some drivers never have CURRENT check (though this may be driver bug), we still want to fallback instead of assert.

Document how to contribute

Include information on which tasks to start contributing from. What kind of things are expected from contributions, and include configuration for uncrustify (or astyle) and additionally explain code styling briefly for those who don't want to use the tools.

Control what key gets sent to the client

I'm not sure if it's possible for wlc to handle this, but I'd like to give my users the ability to remap keys (i.e. switch caps lock and escape). Can keyboard.key be called with pointers to the key info instead of values?

Create tty switch event handler

Right now, outputs which are sleeping will be woken up again when the tty is switched. A handler for the tty switch event would prevent this.

Won't run under vmware with hardware rendering.

This patch for drm.c will fix it.

286c286
<       if (drm.api.drmModeSetCrtc(drm.fd, dsurface->encoder->crtc_id, fb->fd, 0, 0, &dsurface->connector->connector_id, 1, &dsurface->connector->modes[o->active.mode]))

---
>       if (drm.api.drmModeSetCrtc(drm.fd, dsurface->crtc->crtc_id, fb->fd, 0, 0, &dsurface->connector->connector_id, 1, &dsurface->connector->modes[o->active.mode]))
292c292
<    if (drm.api.drmModePageFlip(drm.fd, dsurface->encoder->crtc_id, fb->fd, DRM_MODE_PAGE_FLIP_EVENT, bsurface))

---
>    if (drm.api.drmModePageFlip(drm.fd, dsurface->crtc->crtc_id, fb->fd, DRM_MODE_PAGE_FLIP_EVENT, bsurface))
375c375
<       if (encoder->encoder_id == connector->encoder_id)

---
>       //if (encoder->encoder_id == connector->encoder_id)
408c408
<       if (!(crtc = drm.api.drmModeGetCrtc(drm.fd, encoder->crtc_id))) {

---
>       if (!(crtc = drm.api.drmModeGetCrtc(drm.fd, resources->crtcs[encoder->crtc_id]))) {

Compilation fails: src/compositor/seat/data.c:109:4: error: unknown field ‘release’ specified in initializer

aengelen@yinka ~/dev/wlc % make
[  2%] Building C object lib/chck/CMakeFiles/chck_wlc.dir/src/chck/pool/pool.c.o
[  4%] Building C object lib/chck/CMakeFiles/chck_wlc.dir/src/chck/lut/lut.c.o
[  7%] Building C object lib/chck/CMakeFiles/chck_wlc.dir/src/chck/string/string.c.o
Linking C static library libchck_wlc.a
[  7%] Built target chck_wlc
[  9%] Building C object src/CMakeFiles/wlc.dir/compositor/compositor.c.o
[ 11%] Building C object src/CMakeFiles/wlc.dir/compositor/output.c.o
[ 14%] Building C object src/CMakeFiles/wlc.dir/compositor/seat/data.c.o
/home/aengelen/dev/wlc/src/compositor/seat/data.c:109:4: error: unknown field ‘release’ specified in initializer
    .release = wlc_cb_resource_destructor
    ^
/home/aengelen/dev/wlc/src/compositor/seat/data.c:110:1: warning: excess elements in struct initializer
 };
 ^
/home/aengelen/dev/wlc/src/compositor/seat/data.c:110:1: warning: (near initialization for ‘wl_data_device_implementation’)
src/CMakeFiles/wlc.dir/build.make:110: recipe for target 'src/CMakeFiles/wlc.dir/compositor/seat/data.c.o' failed
make[2]: *** [src/CMakeFiles/wlc.dir/compositor/seat/data.c.o] Error 1
CMakeFiles/Makefile2:1008: recipe for target 'src/CMakeFiles/wlc.dir/all' failed
make[1]: *** [src/CMakeFiles/wlc.dir/all] Error 2
Makefile:117: recipe for target 'all' failed
make: *** [all] Error 2

Provide animation API

Easings, timings, conflict handling and such coupled with custom drawing. Of course we want wobbly windows and desktop cubes. Having this API in wlc allows render loop to be efficient as possible.

Consider using ragel to generate state machine for wlc

wlc's main job is mainly abstracting away various backends and APIs (x11, drm, libinput, udev, etc...), but it also has lots of manual code for state (when view should be drawn, what is the state of view, when to commit, damages, etc...) which could probably be abstracted as a state machine.

I'm not yet sure how this idea would work, but if ragel is up to the task, all the "moving parts" in wlc are easily graphed and generated, and debugging is easier. It also would increase reliability, that is, wlc works as described in state machine.

Expose DPMS

Currently wlc handles display power management, but this task should be moved outside.

Xwayland surfaces do not always set cursor

When moving cursor to Xwayland client, they do not seem to request surface and thus you get invisible cursor.

Seeing this reproducable in weston seems to hint to bug in Xwayland.

issue

Consider using handles instead of pointers for resources

This makes sense due to uncontrolled environment where dangling pointers are real problem. Handles would be simple indexes. This gives additional bonus that the underlying memory management could be optimized for iterations.

Get rid of wl_lists

Linked lists are not very efficient and can easily cause access to dangling pointers or otherwise bad memory regions.

Use chck data structures instead. #2 is related,

Fix geometry requests

When creating a new view, the geometry request handler is run before the view created handler. The ordering should be swapped around so that the client program can properly handle the geometry request.

Provide printf specifier for wlc_handle

I think it would be useful to define something among the lines of WLC_HANDLE_FORMAT to an appropriate printf format specifier. The usage and use case is the same as the format specifier defines provided by inttypes.h (POSIX).

I'd choose among these candidates: PRIoPTR, PRIuPTR, PRIxPTR and PRIXPTR (from inttypes.h).

I don't think octal representation is useful for the handle.

There could also be more fine-grained control as something like WLC_HANDLE_FORMAT_U, WLC_HANDLE_FORMAT_x and WLC_HANDLE_FORMAT_X for decimal, hexadecimal with lower case letter and hexadecimal with upper case letters.

Documentation

It would be nice to have documentation syntax in code so we can generate for example man pages for wlc API. Doxygen has been used before, but it may be worth to resee what are the options nowadays.

Infinite loop in XWayland initialisation

If there is a normal XServer running on $DISPLAY=:0.0, the following loop will not terminate; if the normal XServer is instead running on $DISPLAY=:1.0, the loop will terminate and XWayland will be loaded correctly:

for (lock_fd = -1; dpy <= 32 && lock_fd < 0; ++dpy) {
snprintf(lock_name, sizeof(lock_name), lock_fmt, dpy);
if ((lock_fd = open(lock_name, O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0444)) >= 0)
break;
if ((lock_fd = open(lock_name, O_RDONLY)) < 0)
continue;
char pid[12];
memset(pid, 0, sizeof(pid));
ssize_t bytes = read(lock_fd, pid, sizeof(pid) - 1);
close(lock_fd);
lock_fd = -1;
if (bytes != sizeof(pid) -1)
continue;
char *end;
pid_t owner = strtol(pid, &end, 10);
if (end == pid + 10 && kill(owner, 0) != 0) {
unlink(lock_name);
snprintf(lock_name, sizeof(lock_name), socket_fmt, dpy);
unlink(lock_name);
dpy -= 1;
continue;
}
}

UPDATE1: The infinite loop happens because after continuing the loop after the decrease in

dpy -= 1;
wlc reaches the same line once more.

UPDATE2: It seems to me that

if (end == pid + 10 && kill(owner, 0) != 0) {
should read "kill(owner, 0) == 0)" instead of "kill(owner, 0) != 0)", since wlc should try to use this display only if killing the XServer was successfull, not if the XServer is still running.

Provide function to convert key to xkb keysym

This is better interface than exposing keysym in wlc_interface function. Sometimes you may not want to build the keysym with all the modifiers applied, thus function would make this more flexible.

Write tests for interface callbacks

Make sure nothing is called on wlc_init.

Make sure they are called on correct order, eg. view.request.geometry before view.created is not valid.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.