wio

a wayland wm stylised after plan9 rio - forked from git.sr.ht/~srcmpwn/wio
git clone git://src.gearsix.net/wio
Log | Files | Refs | Atom | Submodules | README | LICENSE

commit f4c39278780c8a02d863f6b3feb27bfcf9d649e3
parent 31b742e473b15a2087be740d1de28bc2afd47a4d
Author: gearsix <gearsix@tuta.io>
Date:   Mon, 27 Sep 2021 12:35:26 +0100

compiles against wlroots 0.14.1 (2021-09-27)

Squashed commit of the following:

commit 5310212baca5aa637bc9e8ce7304094c375b1ef6
Author: gearsix <gearsix@tuta.io>
Date:   Mon Sep 27 12:32:11 2021 +0100

    another breaking refactor from wlroots, client_pending -> pending.

commit 653ce7cd3a792f7a5b4057866cace2815a2c5661
Author: gearsix <gearsix@tuta.io>
Date:   Mon Sep 27 12:31:44 2021 +0100

    added wlroots as a submodule

commit ca0b6adb259d5e58ec919b8cb104b84cf6e11edd
Author: gearsix <gearsix@tuta.io>
Date:   Mon Sep 27 12:08:27 2021 +0100

    wlr_gtk_primary_selection doesn't seem to exist?

    Just commented out the #include and function call and everything builds
    and works fine..?
    I couldn't find any trace of this header file anywhere, will need to
    investigate if developing this further.

commit c45d34710cf86129178c0a30312229466f0122d8
Author: gearsix <gearsix@tuta.io>
Date:   Mon Sep 27 12:07:49 2021 +0100

    see last 2 commits

commit 7b4ec5540a48cf52af0a5a1931dd2f36b9264859
Author: gearsix <gearsix@tuta.io>
Date:   Wed Sep 8 23:14:40 2021 +0100

    updated wlr_layer_surface_v1_close() to ...destroy()

commit daf1b19e81cb1a48a917809d4a39e3119ea0af7b
Author: gearsix <gearsix@tuta.io>
Date:   Wed Sep 8 23:09:22 2021 +0100

    fixed wlr_texture_get_size() - doesn't exist anymore

commit a1fecba400d411a058fdf3e1b6b5cdb628a41bd1
Author: Michael Weiss <dev.primeos@gmail.com>
Date:   Fri May 28 18:36:54 2021 +0200

    Fix the build with wlroots 0.13

    Based on https://github.com/swaywm/wlroots/releases/tag/0.13.0.
    wlr-layer-shell-unstable-v1.xml is copied from wlroots 0.13 for the
    changed type of keyboard_interactivity.

    Relevant wlroots changes:
    - Stop using wl_shm_format (#2744): the renderer functions take
      DRM_FORMAT_* values instead of WL_SHM_FORMAT_*. Make sure you don't
      have any remaining WL_SHM_FORMAT_* enum values in your compositor.
    - Remove wlr_create_renderer_func_t (#2561)
      - wlr_backend_autocreate, wlr_drm_backend_create,
        wlr_headless_backend_create, wlr_wl_backend_create,
        wlr_x11_backend_create no longer take a wlr_renderer_create_func_t
        parameter
    - Keyboard interactivity options (#2555):
      - wlr_layer_surface_v1_state.keyboard_interactivity has now the type
        enum zwlr_layer_surface_v1_keyboard_interactivity to reflect
        protocol changes.

commit 849d0c4cd28cef954843536e5f389a40992a5e6b
Author: Willy Goiffon <contact@z3bra.org>
Date:   Mon Nov 16 10:02:05 2020 +0100

    Enable output to start from VT

    This fixes #17, where the compositor fails to run when started from a
    bare VT.

commit 5f8f5a692d414663e20850fffdc981b98ba8e0bb
Author: gearsix <gearsix@tuta.io>
Date:   Wed Sep 8 22:14:03 2021 +0100

    updated wlr_box include

Diffstat:
A.gitmodules | 3+++
Minclude/server.h | 2+-
Mlayers.c | 10+++++-----
Mmain.c | 11++++++-----
Mmeson.build | 4+++-
Moutput.c | 13+++++++++----
Mprotocols/wlr-layer-shell-unstable-v1.xml | 139+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
Asubprojects/wlroots | 1+
8 files changed, 150 insertions(+), 33 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "subprojects/wlroots"] + path = subprojects/wlroots + url = git@github.com:swaywm/wlroots.git diff --git a/include/server.h b/include/server.h @@ -4,7 +4,7 @@ #include <wayland-server.h> #include <wlr/backend.h> #include <wlr/render/wlr_renderer.h> -#include <wlr/types/wlr_box.h> +#include <wlr/util/box.h> #include <wlr/types/wlr_cursor.h> #include <wlr/types/wlr_seat.h> #include <wlr/types/wlr_keyboard.h> diff --git a/layers.c b/layers.c @@ -135,7 +135,7 @@ static void arrange_layer(struct wlr_output *output, } if (box.width < 0 || box.height < 0) { // TODO: Bubble up a protocol error? - wlr_layer_surface_v1_close(layer); + wlr_layer_surface_v1_destroy(layer); continue; } @@ -209,7 +209,7 @@ static void handle_output_destroy(struct wl_listener *listener, void *data) { wl_container_of(listener, layer, output_destroy); layer->layer_surface->output = NULL; wl_list_remove(&layer->output_destroy.link); - wlr_layer_surface_v1_close(layer->layer_surface); + wlr_layer_surface_v1_destroy(layer->layer_surface); } static void handle_surface_commit(struct wl_listener *listener, void *data) { @@ -275,11 +275,11 @@ void server_new_layer_surface(struct wl_listener *listener, void *data) { // TODO: popups // TODO: Listen for subsurfaces - wl_list_insert(&output->layers[layer_surface->client_pending.layer], &wio_surface->link); - // Temporarily set the layer's current state to client_pending + wl_list_insert(&output->layers[layer_surface->pending.layer], &wio_surface->link); + // Temporarily set the layer's current state to pending // So that we can easily arrange it struct wlr_layer_surface_v1_state old_state = layer_surface->current; - layer_surface->current = layer_surface->client_pending; + layer_surface->current = layer_surface->pending; arrange_layers(output); layer_surface->current = old_state; } diff --git a/main.c b/main.c @@ -1,6 +1,7 @@ #define _POSIX_C_SOURCE 200809L #include <assert.h> #include <cairo/cairo.h> +#include <drm_fourcc.h> #include <getopt.h> #include <stdlib.h> #include <string.h> @@ -14,7 +15,7 @@ #include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_export_dmabuf_v1.h> #include <wlr/types/wlr_gamma_control_v1.h> -#include <wlr/types/wlr_gtk_primary_selection.h> +//#include <wlr/types/wlr_gtk_primary_selection.h> #include <wlr/types/wlr_layer_shell_v1.h> #include <wlr/types/wlr_primary_selection_v1.h> #include <wlr/types/wlr_screencopy_v1.h> @@ -49,7 +50,7 @@ static void gen_menu_textures(struct wio_server *server) { cairo_surface_flush(surf); unsigned char *data = cairo_image_surface_get_data(surf); server->menu.inactive_textures[i] = wlr_texture_from_pixels(renderer, - WL_SHM_FORMAT_ARGB8888, + DRM_FORMAT_ARGB8888, cairo_image_surface_get_stride(surf), extents.width + 2, extents.height + 2, data); } @@ -66,7 +67,7 @@ static void gen_menu_textures(struct wio_server *server) { cairo_surface_flush(surf); unsigned char *data = cairo_image_surface_get_data(surf); server->menu.active_textures[i] = wlr_texture_from_pixels(renderer, - WL_SHM_FORMAT_ARGB8888, + DRM_FORMAT_ARGB8888, cairo_image_surface_get_stride(surf), extents.width + 2, extents.height + 2, data); } @@ -152,7 +153,7 @@ int main(int argc, char **argv) { } server.wl_display = wl_display_create(); - server.backend = wlr_backend_autocreate(server.wl_display, NULL); + server.backend = wlr_backend_autocreate(server.wl_display); server.renderer = wlr_backend_get_renderer(server.backend); wlr_renderer_init_wl_display(server.renderer, server.wl_display); @@ -165,7 +166,7 @@ int main(int argc, char **argv) { wlr_primary_selection_v1_device_manager_create(server.wl_display); wlr_gamma_control_manager_v1_create(server.wl_display); - wlr_gtk_primary_selection_device_manager_create(server.wl_display); +// wlr_gtk_primary_selection_device_manager_create(server.wl_display); wl_list_init(&server.outputs); server.new_output.notify = server_new_output; diff --git a/meson.build b/meson.build @@ -32,10 +32,11 @@ wlroots_proj = subproject( if wlroots_proj.found() wlroots = wlroots_proj.get_variable('wlroots') else - wlroots = dependency('wlroots') + wlroots = dependency('wlroots', version: '>=0.13.0') endif cairo = dependency('cairo') +drm = dependency('libdrm') math = cc.find_library('m') wayland_server = dependency('wayland-server') wayland_protos = dependency('wayland-protocols') @@ -59,6 +60,7 @@ executable( include_directories: [wio_inc], dependencies: [ cairo, + drm, math, server_protos, wayland_server, diff --git a/output.c b/output.c @@ -72,8 +72,8 @@ static void render_menu(struct wio_output *output) { int width, height; // Assumes inactive/active textures are the same size // (they probably are) - wlr_texture_get_size( - server->menu.inactive_textures[i], &width, &height); + width = server->menu.inactive_textures[i]->width; + height = server->menu.inactive_textures[i]->height; width /= scale, height /= scale; text_height += height + margin; if (width >= text_width) { @@ -138,7 +138,8 @@ static void render_menu(struct wio_output *output) { for (size_t i = 0; i < ntextures; ++i) { int width, height; struct wlr_texture *texture = server->menu.inactive_textures[i]; - wlr_texture_get_size(texture, &width, &height); + width = texture->width; + height = texture->height; width /= scale, height /= scale; struct wlr_box box = { 0 }; box.x = ox - scale /* fudge */; @@ -152,7 +153,8 @@ static void render_menu(struct wio_output *output) { wlr_render_rect(renderer, &box, menu_selected, output->wlr_output->transform_matrix); } else { - wlr_texture_get_size(texture, &width, &height); + width = texture->width; + height = texture->height; width /= scale, height /= scale; } box.x = (ox + (text_width / 2 - width / 2)) * scale; @@ -437,14 +439,17 @@ void server_new_output(struct wl_listener *listener, void *data) { if (config->transform) { wlr_output_set_transform(wlr_output, config->transform); } + wlr_output_enable(wlr_output, true); } else { struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output); if (mode) { wlr_output_set_mode(wlr_output, mode); } + wlr_output_enable(wlr_output, true); wlr_output_layout_add_auto(server->output_layout, wlr_output); } + wlr_output_commit(wlr_output); wlr_output_create_global(wlr_output); } diff --git a/protocols/wlr-layer-shell-unstable-v1.xml b/protocols/wlr-layer-shell-unstable-v1.xml @@ -25,7 +25,7 @@ THIS SOFTWARE. </copyright> - <interface name="zwlr_layer_shell_v1" version="1"> + <interface name="zwlr_layer_shell_v1" version="4"> <description summary="create surfaces that are layers of the desktop"> Clients can use this interface to assign the surface_layer role to wl_surfaces. Such surfaces are assigned to a "layer" of the output and @@ -47,6 +47,12 @@ or manipulate a buffer prior to the first layer_surface.configure call must also be treated as errors. + After creating a layer_surface object and setting it up, the client + must perform an initial commit without any buffer attached. + The compositor will reply with a layer_surface.configure event. + The client must acknowledge it and is then allowed to attach a buffer + to map the surface. + You may pass NULL for output to allow the compositor to decide which output to use. Generally this will be the one that the user most recently interacted with. @@ -82,17 +88,35 @@ <entry name="top" value="2"/> <entry name="overlay" value="3"/> </enum> + + <!-- Version 3 additions --> + + <request name="destroy" type="destructor" since="3"> + <description summary="destroy the layer_shell object"> + This request indicates that the client will not use the layer_shell + object any more. Objects that have been created through this instance + are not affected. + </description> + </request> </interface> - <interface name="zwlr_layer_surface_v1" version="1"> + <interface name="zwlr_layer_surface_v1" version="4"> <description summary="layer metadata interface"> An interface that may be implemented by a wl_surface, for surfaces that are designed to be rendered as a layer of a stacked desktop-like environment. - Layer surface state (size, anchor, exclusive zone, margin, interactivity) - is double-buffered, and will be applied at the time wl_surface.commit of - the corresponding wl_surface is called. + Layer surface state (layer, size, anchor, exclusive zone, + margin, interactivity) is double-buffered, and will be applied at the + time wl_surface.commit of the corresponding wl_surface is called. + + Attaching a null buffer to a layer surface unmaps it. + + Unmapping a layer_surface means that the surface cannot be shown by the + compositor until it is explicitly mapped again. The layer_surface + returns to the state it had right after layer_shell.get_layer_surface. + The client can re-map the surface by performing a commit without any + buffer attached, waiting for a configure event and handling it as usual. </description> <request name="set_size"> @@ -127,14 +151,19 @@ <request name="set_exclusive_zone"> <description summary="configures the exclusive geometry of this surface"> - Requests that the compositor avoids occluding an area of the surface - with other surfaces. The compositor's use of this information is + Requests that the compositor avoids occluding an area with other + surfaces. The compositor's use of this information is implementation-dependent - do not assume that this region will not actually be occluded. - A positive value is only meaningful if the surface is anchored to an - edge, rather than a corner. The zone is the number of surface-local - coordinates from the edge that is considered exclusive. + A positive value is only meaningful if the surface is anchored to one + edge or an edge and both perpendicular edges. If the surface is not + anchored, anchored to only two perpendicular edges (a corner), anchored + to only two parallel edges or anchored to all edges, a positive value + will be treated the same as zero. + + A positive zone is the distance from the edge in surface-local + coordinates to consider exclusive. Surfaces that do not wish to have an exclusive zone may instead specify how they should interact with surfaces that do. If set to zero, the @@ -174,21 +203,85 @@ <arg name="left" type="int"/> </request> + <enum name="keyboard_interactivity"> + <description summary="types of keyboard interaction possible for a layer shell surface"> + Types of keyboard interaction possible for layer shell surfaces. The + rationale for this is twofold: (1) some applications are not interested + in keyboard events and not allowing them to be focused can improve the + desktop experience; (2) some applications will want to take exclusive + keyboard focus. + </description> + + <entry name="none" value="0"> + <description summary="no keyboard focus is possible"> + This value indicates that this surface is not interested in keyboard + events and the compositor should never assign it the keyboard focus. + + This is the default value, set for newly created layer shell surfaces. + + This is useful for e.g. desktop widgets that display information or + only have interaction with non-keyboard input devices. + </description> + </entry> + <entry name="exclusive" value="1"> + <description summary="request exclusive keyboard focus"> + Request exclusive keyboard focus if this surface is above the shell surface layer. + + For the top and overlay layers, the seat will always give + exclusive keyboard focus to the top-most layer which has keyboard + interactivity set to exclusive. If this layer contains multiple + surfaces with keyboard interactivity set to exclusive, the compositor + determines the one receiving keyboard events in an implementation- + defined manner. In this case, no guarantee is made when this surface + will receive keyboard focus (if ever). + + For the bottom and background layers, the compositor is allowed to use + normal focus semantics. + + This setting is mainly intended for applications that need to ensure + they receive all keyboard events, such as a lock screen or a password + prompt. + </description> + </entry> + <entry name="on_demand" value="2" since="4"> + <description summary="request regular keyboard focus semantics"> + This requests the compositor to allow this surface to be focused and + unfocused by the user in an implementation-defined manner. The user + should be able to unfocus this surface even regardless of the layer + it is on. + + Typically, the compositor will want to use its normal mechanism to + manage keyboard focus between layer shell surfaces with this setting + and regular toplevels on the desktop layer (e.g. click to focus). + Nevertheless, it is possible for a compositor to require a special + interaction to focus or unfocus layer shell surfaces (e.g. requiring + a click even if focus follows the mouse normally, or providing a + keybinding to switch focus between layers). + + This setting is mainly intended for desktop shell components (e.g. + panels) that allow keyboard interaction. Using this option can allow + implementing a desktop shell that can be fully usable without the + mouse. + </description> + </entry> + </enum> + <request name="set_keyboard_interactivity"> <description summary="requests keyboard events"> - Set to 1 to request that the seat send keyboard events to this layer - surface. For layers below the shell surface layer, the seat will use - normal focus semantics. For layers above the shell surface layers, the - seat will always give exclusive keyboard focus to the top-most layer - which has keyboard interactivity set to true. + Set how keyboard events are delivered to this surface. By default, + layer shell surfaces do not receive keyboard events; this request can + be used to change this. + + This setting is inherited by child surfaces set by the get_popup + request. Layer surfaces receive pointer, touch, and tablet events normally. If you do not want to receive them, set the input region on your surface to an empty region. - Events is double-buffered, see wl_surface.commit. + Keyboard interactivity is double-buffered, see wl_surface.commit. </description> - <arg name="keyboard_interactivity" type="uint"/> + <arg name="keyboard_interactivity" type="uint" enum="keyboard_interactivity"/> </request> <request name="get_popup"> @@ -273,6 +366,7 @@ <entry name="invalid_surface_state" value="0" summary="provided surface state is invalid"/> <entry name="invalid_size" value="1" summary="size is invalid"/> <entry name="invalid_anchor" value="2" summary="anchor bitfield is invalid"/> + <entry name="invalid_keyboard_interactivity" value="3" summary="keyboard interactivity is invalid"/> </enum> <enum name="anchor" bitfield="true"> @@ -281,5 +375,16 @@ <entry name="left" value="4" summary="the left edge of the anchor rectangle"/> <entry name="right" value="8" summary="the right edge of the anchor rectangle"/> </enum> + + <!-- Version 2 additions --> + + <request name="set_layer" since="2"> + <description summary="change the layer of the surface"> + Change the layer that the surface is rendered on. + + Layer is double-buffered, see wl_surface.commit. + </description> + <arg name="layer" type="uint" enum="zwlr_layer_shell_v1.layer" summary="layer to move this surface to"/> + </request> </interface> </protocol> diff --git a/subprojects/wlroots b/subprojects/wlroots @@ -0,0 +1 @@ +Subproject commit d96d2f5f23e1096ed70dbbf286d5f9480957f667