diff -Nru phoc-0.23.0/debian/changelog phoc-0.24.0/debian/changelog --- phoc-0.23.0/debian/changelog 2023-01-14 11:55:55.000000000 +0000 +++ phoc-0.24.0/debian/changelog 2023-02-01 16:22:09.000000000 +0000 @@ -1,3 +1,9 @@ +phoc (0.24.0-1) unstable; urgency=medium + + * New upstream release + + -- Guido Günther Wed, 01 Feb 2023 17:22:09 +0100 + phoc (0.23.0-1) unstable; urgency=medium * New upstream release diff -Nru phoc-0.23.0/doc/gettingstarted.md phoc-0.24.0/doc/gettingstarted.md --- phoc-0.23.0/doc/gettingstarted.md 1970-01-01 00:00:00.000000000 +0000 +++ phoc-0.24.0/doc/gettingstarted.md 2023-01-31 11:36:25.000000000 +0000 @@ -0,0 +1,69 @@ +Title: Getting started with Phoc development +Slug: gettingstarted + +# Getting started with Phosh development + +## Overview +Phoc is a [Wayland](https://wayland.freedesktop.org/) based on the +[wlroots](https://gitlab.freedesktop.org/wlroots) library. It's often +used as a compositor for +[phosh](https://gitlab.gnome.org/World/Phosh/phosh) but works +perfectly well on it's own. + +## Running + +After +[building](https://gitlab.gnome.org/World/Phosh/phosh/-/blob/main/README.md) +phoc it can be run in several ways. + +### Running nested + +The easiest way is to run it nested within another graphical session. The +supplied run script is able to detect that: + + _build/run -E gnome-terminal + +This will launch phoc with either the X11 or Wayland backend rendering +everything within a window in your current graphical session. The `-E` +option specifies a program to be started by phoc, in this case we use +gnome-terminal but any other application that opens a window will do. + +### Running on hardware + +The simplest way is to log into a terminal and use the same invocation as +above: + + _build/run -E gnome-terminal + +The script will notice that neither `$DISPLAY` nor `$WAYLAND_DISPLAY` is set +and hence use the DRM backend. + +Sometimes it isn't easy to get to a virtual terminal and also have keyboard +input (e.g. on a mobile phone). To help with that there's a systemd unit. +This will start phoc on a tty for the user with uid `1000`: + + cp _build/data/phoc-dev.service /etc/systemd/system/ + systemctl daemon-reload + systemctl start phoc-dev + +Make sure you stop other graphical session and display managers first. +If you want to override some settings (e.g. a different user id to run phoc +with) put these in `/etc/systemd/system/phoc-dev.service.d/override.conf`). + +The systemd unit makes sure it picks up phoc from the freshly built source tree +so whenever you made any changes it's enough to invoke: + + systemctl restart phoc-dev + +to run your modified version. Note that the systemd unit doesn't launch phoc +directly but via a small shell wrapper at `_build/data/phoc-dev` which is another +good place to make some temporary changes like setting `PHOC_DEBUG` or +`G_MESSAGES_DEBUG`. + +To start an appplication in the running phoc run: + + WAYLAND_DISPLAY=wayland-0 gnome-terminal + +Make sure you do this as the same user phoc runs with (uid 1000 by default). If + +Note that the systemd unit is not meant for development purposes only. diff -Nru phoc-0.23.0/doc/meson.build phoc-0.24.0/doc/meson.build --- phoc-0.23.0/doc/meson.build 2023-01-14 11:21:21.000000000 +0000 +++ phoc-0.24.0/doc/meson.build 2023-01-31 11:36:25.000000000 +0000 @@ -1,7 +1,12 @@ if get_option('gtk_doc') +expand_content_md_files = [ + 'gettingstarted.md', +] + toml_data = configuration_data() toml_data.set('VERSION', meson.project_version()) +toml_data.set('CONTENT_FILES', '",\n "'.join(expand_content_md_files)) phoc_toml = configure_file( input: 'phoc.toml.in', @@ -32,6 +37,7 @@ '--content-dir=@0@'.format(meson.current_source_dir()), '@INPUT1@', ], + depend_files: [ expand_content_md_files ], build_by_default: true, install: true, install_dir: docs_dir, diff -Nru phoc-0.23.0/doc/phoc.toml.in phoc-0.24.0/doc/phoc.toml.in --- phoc-0.23.0/doc/phoc.toml.in 2023-01-14 11:21:21.000000000 +0000 +++ phoc-0.24.0/doc/phoc.toml.in 2023-01-31 11:36:25.000000000 +0000 @@ -28,3 +28,8 @@ # The format for links, using "filename" and "line" for the format file_format = "{filename}#L{line}" +[extra] +content_files = [ + "@CONTENT_FILES@", +] + diff -Nru phoc-0.23.0/meson.build phoc-0.24.0/meson.build --- phoc-0.23.0/meson.build 2023-01-14 11:21:21.000000000 +0000 +++ phoc-0.24.0/meson.build 2023-01-31 11:36:25.000000000 +0000 @@ -1,5 +1,5 @@ project('phoc', 'c', - version: '0.23.0', + version: '0.24.0', license: 'GPLv3+', meson_version: '>= 0.54.0', default_options: [ diff -Nru phoc-0.23.0/NEWS phoc-0.24.0/NEWS --- phoc-0.23.0/NEWS 2023-01-14 11:21:21.000000000 +0000 +++ phoc-0.24.0/NEWS 2023-01-31 11:36:25.000000000 +0000 @@ -1,6 +1,11 @@ -phosh 0.23.0 ------------- -Released Janyary 2023 +phoc 0.24.0 +----------- +Released January 2023 +* LayerSurface(effects) robustness + +phoc 0.23.0 +----------- +Released January 2023 * Fix pixman renderer * Contributors: Guido Günther diff -Nru phoc-0.23.0/protocols/phoc-layer-shell-effects-unstable-v1.xml phoc-0.24.0/protocols/phoc-layer-shell-effects-unstable-v1.xml --- phoc-0.23.0/protocols/phoc-layer-shell-effects-unstable-v1.xml 2023-01-14 11:21:21.000000000 +0000 +++ phoc-0.24.0/protocols/phoc-layer-shell-effects-unstable-v1.xml 2023-01-31 11:36:25.000000000 +0000 @@ -122,7 +122,7 @@ Drag-mode is double-buffered, see wl_surface.commit. - + diff -Nru phoc-0.23.0/src/layer_shell.c phoc-0.24.0/src/layer_shell.c --- phoc-0.23.0/src/layer_shell.c 2023-01-14 11:21:21.000000000 +0000 +++ phoc-0.24.0/src/layer_shell.c 2023-01-31 11:36:25.000000000 +0000 @@ -233,7 +233,7 @@ /// Adjusts keyboard properties static void -change_osk (PhocLayerSurface *osk, struct wl_list layer_surfaces, bool force_overlay) +change_osk (PhocLayerSurface *osk, bool force_overlay) { if (force_overlay && osk->layer != ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY) osk->layer = ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY; @@ -271,7 +271,7 @@ break; } } - change_osk (osk, output->layer_surfaces, osk_force_overlay); + change_osk (osk, osk_force_overlay); } // Arrange exclusive surfaces from top->bottom @@ -293,6 +293,22 @@ // Arrange non-exlusive surfaces from top->bottom for (size_t i = 0; i < G_N_ELEMENTS(layers); ++i) arrange_layer (output, seats, layers[i], &usable_area, false); + + if (G_UNLIKELY (server->debug_flags & PHOC_SERVER_DEBUG_FLAG_LAYER_SHELL)) { + PhocLayerSurface *layer_surface; + g_message ("Dumping layers:"); + wl_list_for_each (layer_surface, &output->layer_surfaces, link) { + g_message ("layer-surface: %-20s, l: %d, m: %d, cm: %4d,%4d,%4d,%4d, e: %4d", + layer_surface->layer_surface->namespace, + layer_surface->layer, + layer_surface->mapped, + layer_surface->layer_surface->current.margin.top, + layer_surface->layer_surface->current.margin.right, + layer_surface->layer_surface->current.margin.bottom, + layer_surface->layer_surface->current.margin.left, + layer_surface->layer_surface->current.exclusive_zone); + } + } } void diff -Nru phoc-0.23.0/src/layer-shell-effects.c phoc-0.24.0/src/layer-shell-effects.c --- phoc-0.23.0/src/layer-shell-effects.c 2023-01-14 11:21:21.000000000 +0000 +++ phoc-0.24.0/src/layer-shell-effects.c 2023-01-31 11:36:25.000000000 +0000 @@ -122,11 +122,13 @@ PhocDraggableLayerSurface *drag_surface = wl_resource_get_user_data (resource); g_assert (drag_surface); - g_assert (PHOC_IS_LAYER_SURFACE (drag_surface->layer_surface)); g_debug ("Draggable Layer surface margins for %p: %d,%d", drag_surface, margin_folded, margin_unfolded); + if (drag_surface->layer_surface == NULL) + return; + if (margin_unfolded <= margin_folded) { wl_resource_post_error (resource, ZPHOC_LAYER_SHELL_EFFECTS_V1_ERROR_BAD_MARGIN, "unfolded margin (%d) <= folded marign (%d)", @@ -160,7 +162,11 @@ { PhocDraggableLayerSurface *drag_surface = wl_resource_get_user_data (resource); - g_assert (PHOC_IS_LAYER_SURFACE (drag_surface->layer_surface)); + g_assert (drag_surface); + g_debug ("Draggable Layer surface exclusive for %p: %u", drag_surface, exclusive); + if (drag_surface->layer_surface == NULL) + return; + drag_surface->pending.exclusive = exclusive; } @@ -173,10 +179,12 @@ PhocDraggableLayerSurface *drag_surface = wl_resource_get_user_data (resource); double threshold; - g_assert (PHOC_IS_LAYER_SURFACE (drag_surface->layer_surface)); - + g_assert (drag_surface); threshold = wl_fixed_to_double (threshold_f); g_debug ("Draggable Layer surface threshold for %p: %f", drag_surface, threshold); + if (drag_surface->layer_surface == NULL) + return; + threshold = (threshold < 1.0) ? threshold : 1.0; threshold = (threshold > 0.0) ? threshold : 0.0; @@ -191,8 +199,10 @@ { PhocDraggableLayerSurface *drag_surface = wl_resource_get_user_data (resource); - g_assert (PHOC_IS_LAYER_SURFACE (drag_surface->layer_surface)); + g_assert (drag_surface); g_debug ("Draggable Layer surface drag-mode for %p: %d", drag_surface, drag_mode); + if (drag_surface->layer_surface == NULL) + return; drag_surface->pending.drag_mode = drag_mode; } @@ -205,8 +215,10 @@ { PhocDraggableLayerSurface *drag_surface = wl_resource_get_user_data (resource); - g_assert (PHOC_IS_LAYER_SURFACE (drag_surface->layer_surface)); + g_assert (drag_surface); g_debug ("Draggable Layer surface drag-handle for %p: %d", drag_surface, drag_handle); + if (drag_surface->layer_surface == NULL) + return; drag_surface->pending.drag_handle = drag_handle; } @@ -220,7 +232,9 @@ PhocDraggableLayerSurface *drag_surface = wl_resource_get_user_data (resource); PhocAnimDir dir; - g_assert (drag_surface->layer_surface); + g_assert (drag_surface); + if (drag_surface->layer_surface == NULL) + return; switch (state) { case ZPHOC_DRAGGABLE_LAYER_SURFACE_V1_DRAG_END_STATE_FOLDED: @@ -271,6 +285,7 @@ layer_shell_effects = PHOC_LAYER_SHELL_EFFECTS (drag_surface->layer_shell_effects); g_assert (PHOC_IS_LAYER_SHELL_EFFECTS (layer_shell_effects)); + /* End any ongoing animations */ if (drag_surface->drag.anim_id && drag_surface->layer_surface) { phoc_animatable_remove_frame_callback (PHOC_ANIMATABLE (drag_surface->layer_surface), drag_surface->drag.anim_id); @@ -286,6 +301,7 @@ layer_shell_effects->drag_surfaces = g_slist_remove (layer_shell_effects->drag_surfaces, drag_surface); + drag_surface->layer_surface = NULL; wl_resource_set_user_data (drag_surface->resource, NULL); g_free (drag_surface); } @@ -316,10 +332,12 @@ PhocDraggableLayerSurface *drag_surface = wl_container_of(listener, drag_surface, layer_surface_handle_destroy); - /* Remove from the hash table as long as we have a valid layer_surface */ + /* Drop the gone layer-surface form the layer-surface -> drag-surface mapping */ layer_shell_effects = PHOC_LAYER_SHELL_EFFECTS (drag_surface->layer_shell_effects); g_hash_table_remove (layer_shell_effects->drag_surfaces_by_layer_sufrace, drag_surface->layer_surface); + + /* The layer-surface is unusable for us now */ drag_surface->layer_surface = NULL; } @@ -329,10 +347,10 @@ { PhocDraggableLayerSurface *drag_surface = wl_container_of(listener, drag_surface, surface_handle_commit); - PhocLayerSurface *layer = drag_surface->layer_surface; + PhocLayerSurface *wlr_layer_surface = drag_surface->layer_surface; gboolean changed = FALSE; - if (layer == NULL) + if (wlr_layer_surface == NULL) return; if (drag_surface->current.folded != drag_surface->pending.folded) { @@ -354,13 +372,13 @@ /* TODO: cancel related gestures on drag mode changes */ /* Keep in sync with layer surface geometry changes */ - if (memcmp (&drag_surface->geo, &layer->geo, sizeof (drag_surface->geo)) == 0) + if (memcmp (&drag_surface->geo, &wlr_layer_surface->geo, sizeof (drag_surface->geo)) == 0) return; g_debug ("Geometry changed %d,%d %dx%d", - layer->geo.x, layer->geo.y, - layer->geo.width, layer->geo.height); - drag_surface->geo = layer->geo; + wlr_layer_surface->geo.x, wlr_layer_surface->geo.y, + wlr_layer_surface->geo.width, wlr_layer_surface->geo.height); + drag_surface->geo = wlr_layer_surface->geo; } @@ -407,9 +425,9 @@ "Layer surface not yet committed"); return; } - drag_surface->layer_surface = PHOC_LAYER_SURFACE (wlr_layer_surface->data); - g_assert (PHOC_IS_LAYER_SURFACE (drag_surface->layer_surface)); + g_assert (PHOC_IS_LAYER_SURFACE (wlr_layer_surface->data)); + drag_surface->layer_surface = PHOC_LAYER_SURFACE (wlr_layer_surface->data); drag_surface->surface_handle_commit.notify = surface_handle_commit; wl_signal_add (&wlr_surface->events.commit, &drag_surface->surface_handle_commit); @@ -512,35 +530,35 @@ static void apply_margin (PhocDraggableLayerSurface *drag_surface, double margin) { - struct wlr_layer_surface_v1 *layer = drag_surface->layer_surface->layer_surface; + struct wlr_layer_surface_v1 *wlr_layer_surface = drag_surface->layer_surface->layer_surface; /* The client is not supposed to update margin or exclusive zone so * keep current and pending in sync */ g_debug ("%s: margin: %f %f", __func__, drag_surface->drag.anim_t, margin); - switch (layer->current.anchor) { + switch (wlr_layer_surface->current.anchor) { case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_TOP: - layer->current.margin.top = (int32_t)margin; + wlr_layer_surface->current.margin.top = (int32_t)margin; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_BOTTOM: - layer->current.margin.bottom = (int32_t)margin; + wlr_layer_surface->current.margin.bottom = (int32_t)margin; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_LEFT: - layer->current.margin.left = (int32_t)margin; + wlr_layer_surface->current.margin.left = (int32_t)margin; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_RIGHT: - layer->current.margin.right = (int32_t)margin; + wlr_layer_surface->current.margin.right = (int32_t)margin; break; default: g_assert_not_reached (); break; } - layer->current.exclusive_zone = -margin + drag_surface->current.exclusive; + wlr_layer_surface->current.exclusive_zone = -margin + drag_surface->current.exclusive; - layer->pending.margin.top = layer->current.margin.top; - layer->pending.margin.bottom = layer->current.margin.bottom; - layer->pending.margin.left = layer->current.margin.left; - layer->pending.margin.right = layer->current.margin.right; - layer->pending.exclusive_zone = layer->current.exclusive_zone; + wlr_layer_surface->pending.margin.top = wlr_layer_surface->current.margin.top; + wlr_layer_surface->pending.margin.bottom = wlr_layer_surface->current.margin.bottom; + wlr_layer_surface->pending.margin.left = wlr_layer_surface->current.margin.left; + wlr_layer_surface->pending.margin.right = wlr_layer_surface->current.margin.right; + wlr_layer_surface->pending.exclusive_zone = wlr_layer_surface->current.exclusive_zone; } @@ -556,33 +574,38 @@ on_output_frame_callback (PhocAnimatable *animatable, guint64 last_frame, gpointer user_data) { - PhocLayerSurface *layer_surface = PHOC_LAYER_SURFACE (animatable); PhocDraggableLayerSurface *drag_surface = user_data; + PhocLayerSurface *layer_surface; PhocOutput *output; - struct wlr_layer_surface_v1 *layer = layer_surface->layer_surface; + struct wlr_layer_surface_v1 *wlr_layer_surface; double margin, distance; bool done; - g_assert (PHOC_IS_LAYER_SURFACE (layer_surface)); g_assert (drag_surface); + g_assert (PHOC_IS_LAYER_SURFACE (animatable)); + + layer_surface = PHOC_LAYER_SURFACE (animatable); + g_assert (layer_surface == drag_surface->layer_surface); + g_assert (drag_surface->state == PHOC_DRAGGABLE_SURFACE_STATE_ANIMATING); + wlr_layer_surface = drag_surface->layer_surface->layer_surface; output = phoc_layer_surface_get_output (layer_surface); if (output == NULL) return G_SOURCE_REMOVE; - switch (layer->current.anchor) { + switch (wlr_layer_surface->current.anchor) { case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_TOP: - margin = (int32_t)layer->current.margin.top; + margin = (int32_t)wlr_layer_surface->current.margin.top; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_BOTTOM: - margin = (int32_t)layer->current.margin.bottom; + margin = (int32_t)wlr_layer_surface->current.margin.bottom; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_LEFT: - margin = (int32_t)layer->current.margin.left; + margin = (int32_t)wlr_layer_surface->current.margin.left; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_RIGHT: - margin = (int32_t)layer->current.margin.right; + margin = (int32_t)wlr_layer_surface->current.margin.right; break; default: g_assert_not_reached (); @@ -641,25 +664,31 @@ void phoc_draggable_layer_surface_slide (PhocDraggableLayerSurface *drag_surface, PhocAnimDir anim_dir) { - struct wlr_layer_surface_v1 *layer = drag_surface->layer_surface->layer_surface; + struct wlr_layer_surface_v1 *wlr_layer_surface; double margin; - struct wlr_output *wlr_output = layer->output; + struct wlr_output *wlr_output; + + if (drag_surface->layer_surface == NULL) + return; + + wlr_layer_surface = drag_surface->layer_surface->layer_surface; + wlr_output = wlr_layer_surface->output; if (wlr_output == NULL) return; - switch (layer->current.anchor) { + switch (wlr_layer_surface->current.anchor) { case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_TOP: - margin = (double)(int32_t)layer->current.margin.top; + margin = (double)(int32_t)wlr_layer_surface->current.margin.top; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_BOTTOM: - margin = (double)(int32_t)layer->current.margin.bottom; + margin = (double)(int32_t)wlr_layer_surface->current.margin.bottom; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_LEFT: - margin = (double)(int32_t)layer->current.margin.left; + margin = (double)(int32_t)wlr_layer_surface->current.margin.left; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_RIGHT: - margin = (double)(int32_t)layer->current.margin.right; + margin = (double)(int32_t)wlr_layer_surface->current.margin.right; break; default: g_assert_not_reached (); @@ -711,8 +740,8 @@ double off_x, double off_y) { - struct wlr_layer_surface_v1 *layer = drag_surface->layer_surface->layer_surface; - struct wlr_output *wlr_output = layer->output; + struct wlr_layer_surface_v1 *wlr_layer_surface = drag_surface->layer_surface->layer_surface; + struct wlr_output *wlr_output = wlr_layer_surface->output; PhocOutput *output; uint32_t *target; int32_t margin = 0; @@ -720,21 +749,21 @@ output = PHOC_OUTPUT (wlr_output->data); g_assert (PHOC_IS_OUTPUT (output)); - switch (layer->current.anchor) { + switch (wlr_layer_surface->current.anchor) { case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_TOP: - target = &layer->current.margin.top; + target = &wlr_layer_surface->current.margin.top; margin = drag_surface->drag.start_margin + off_y; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_BOTTOM: - target = &layer->current.margin.bottom; + target = &wlr_layer_surface->current.margin.bottom; margin = drag_surface->drag.start_margin - off_y; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_LEFT: - target = &layer->current.margin.left; + target = &wlr_layer_surface->current.margin.left; margin = drag_surface->drag.start_margin + off_x; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_RIGHT: - target = &layer->current.margin.right; + target = &wlr_layer_surface->current.margin.right; margin = drag_surface->drag.start_margin - off_x; break; default: @@ -751,13 +780,13 @@ margin = drag_surface->current.folded; *target = margin; - layer->current.exclusive_zone = -margin + drag_surface->current.exclusive; + wlr_layer_surface->current.exclusive_zone = -margin + drag_surface->current.exclusive; - layer->pending.margin.top = layer->current.margin.top; - layer->pending.margin.bottom = layer->current.margin.bottom; - layer->pending.margin.left = layer->current.margin.left; - layer->pending.margin.right = layer->current.margin.right; - layer->pending.exclusive_zone = layer->current.exclusive_zone; + wlr_layer_surface->pending.margin.top = wlr_layer_surface->current.margin.top; + wlr_layer_surface->pending.margin.bottom = wlr_layer_surface->current.margin.bottom; + wlr_layer_surface->pending.margin.left = wlr_layer_surface->current.margin.left; + wlr_layer_surface->pending.margin.right = wlr_layer_surface->current.margin.right; + wlr_layer_surface->pending.exclusive_zone = wlr_layer_surface->current.exclusive_zone; zphoc_draggable_layer_surface_v1_send_dragged (drag_surface->resource, margin); phoc_layer_shell_arrange (output); @@ -773,8 +802,8 @@ phoc_draggable_layer_surface_drag_start (PhocDraggableLayerSurface *drag_surface, double lx, double ly) { PhocServer *server = phoc_server_get_default (); - struct wlr_layer_surface_v1 *layer = drag_surface->layer_surface->layer_surface; - struct wlr_box *output_box = wlr_output_layout_get_box (server->desktop->layout, layer->output); + struct wlr_layer_surface_v1 *wlr_layer_surface = drag_surface->layer_surface->layer_surface; + struct wlr_box *output_box = wlr_output_layout_get_box (server->desktop->layout, wlr_layer_surface->output); double sx = lx - drag_surface->geo.x - output_box->x; double sy = ly - drag_surface->geo.y - output_box->y; bool is_handle = false; @@ -783,21 +812,21 @@ if (drag_surface->current.drag_mode == ZPHOC_DRAGGABLE_LAYER_SURFACE_V1_DRAG_MODE_NONE) return PHOC_DRAGGABLE_SURFACE_STATE_REJECTED; - switch (layer->current.anchor) { + switch (wlr_layer_surface->current.anchor) { case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_TOP: - start_margin = (int32_t)layer->current.margin.top; + start_margin = (int32_t)wlr_layer_surface->current.margin.top; is_handle = sy > drag_surface->current.drag_handle; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_BOTTOM: - start_margin = (int32_t)layer->current.margin.bottom; + start_margin = (int32_t)wlr_layer_surface->current.margin.bottom; is_handle = sy < drag_surface->current.drag_handle; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_LEFT: - start_margin = (int32_t)layer->current.margin.left; + start_margin = (int32_t)wlr_layer_surface->current.margin.left; is_handle = sx > drag_surface->current.drag_handle; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_RIGHT: - start_margin = (int32_t)layer->current.margin.right; + start_margin = (int32_t)wlr_layer_surface->current.margin.right; is_handle = sx < drag_surface->current.drag_handle; break; default: @@ -839,9 +868,9 @@ static gboolean phoc_draggable_surface_is_vertical (PhocDraggableLayerSurface *drag_surface) { - struct wlr_layer_surface_v1 *layer = drag_surface->layer_surface->layer_surface; + struct wlr_layer_surface_v1 *wlr_layer_surface = drag_surface->layer_surface->layer_surface; - switch (layer->current.anchor) { + switch (wlr_layer_surface->current.anchor) { case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_TOP: case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_BOTTOM: return TRUE; @@ -859,8 +888,8 @@ double off_x, double off_y) { - struct wlr_layer_surface_v1 *layer = drag_surface->layer_surface->layer_surface; - struct wlr_output *wlr_output = layer->output; + struct wlr_layer_surface_v1 *wlr_layer_surface = drag_surface->layer_surface->layer_surface; + struct wlr_output *wlr_output = wlr_layer_surface->output; bool accept; if (drag_surface->state != PHOC_DRAGGABLE_SURFACE_STATE_PENDING && @@ -895,18 +924,18 @@ return drag_surface->state; } - switch (layer->current.anchor) { + switch (wlr_layer_surface->current.anchor) { case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_TOP: - accept = (layer->current.margin.top == drag_surface->current.unfolded) ? off_y < 0 : true; + accept = (wlr_layer_surface->current.margin.top == drag_surface->current.unfolded) ? off_y < 0 : true; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_BOTTOM: - accept = (layer->current.margin.bottom == drag_surface->current.unfolded) ? off_y > 0 : true; + accept = (wlr_layer_surface->current.margin.bottom == drag_surface->current.unfolded) ? off_y > 0 : true; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_LEFT: - accept = (layer->current.margin.left == drag_surface->current.unfolded) ? off_x < 0 : true; + accept = (wlr_layer_surface->current.margin.left == drag_surface->current.unfolded) ? off_x < 0 : true; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_RIGHT: - accept = (layer->current.margin.right == drag_surface->current.unfolded) ? off_x > 0 : true; + accept = (wlr_layer_surface->current.margin.right == drag_surface->current.unfolded) ? off_x > 0 : true; break; default: g_assert_not_reached (); @@ -931,7 +960,7 @@ int distance, start; int max_distance = ABS (drag_surface->current.folded - drag_surface->current.unfolded); float threshold = max_distance * drag_surface->current.threshold; - struct wlr_layer_surface_v1 *layer = drag_surface->layer_surface->layer_surface; + struct wlr_layer_surface_v1 *wlr_layer_surface = drag_surface->layer_surface->layer_surface; switch (drag_surface->drag.last_state) { case ZPHOC_DRAGGABLE_LAYER_SURFACE_V1_DRAG_END_STATE_FOLDED: @@ -944,18 +973,18 @@ g_return_val_if_reached (FALSE); } - switch (layer->current.anchor) { + switch (wlr_layer_surface->current.anchor) { case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_TOP: - distance = (int32_t)layer->current.margin.top - start; + distance = (int32_t)wlr_layer_surface->current.margin.top - start; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_BOTTOM: - distance = (int32_t)layer->current.margin.bottom - start; + distance = (int32_t)wlr_layer_surface->current.margin.bottom - start; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_LEFT: - distance = (int32_t)layer->current.margin.left - start; + distance = (int32_t)wlr_layer_surface->current.margin.left - start; break; case PHOC_LAYER_SHELL_EFFECT_DRAG_FROM_RIGHT: - distance = (int32_t)layer->current.margin.right - start; + distance = (int32_t)wlr_layer_surface->current.margin.right - start; break; default: g_assert_not_reached (); @@ -973,8 +1002,8 @@ { PhocOutput *output; PhocAnimDir dir; - struct wlr_layer_surface_v1 *layer = drag_surface->layer_surface->layer_surface; - struct wlr_output *wlr_output = layer->output; + struct wlr_layer_surface_v1 *wlr_layer_surface = drag_surface->layer_surface->layer_surface; + struct wlr_output *wlr_output = wlr_layer_surface->output; if (!wlr_output) return; diff -Nru phoc-0.23.0/src/layer-surface.c phoc-0.24.0/src/layer-surface.c --- phoc-0.23.0/src/layer-surface.c 2023-01-14 11:21:21.000000000 +0000 +++ phoc-0.24.0/src/layer-surface.c 2023-01-31 11:36:25.000000000 +0000 @@ -119,6 +119,7 @@ phoc_layer_surface_finalize (GObject *object) { PhocLayerSurface *self = PHOC_LAYER_SURFACE (object); + PhocOutput *output = phoc_layer_surface_get_output (self); if (self->layer_surface->mapped) phoc_layer_surface_unmap (self); @@ -128,10 +129,9 @@ wl_list_remove (&self->map.link); wl_list_remove (&self->unmap.link); wl_list_remove (&self->surface_commit.link); - if (self->layer_surface->output) { - PhocOutput *output = phoc_layer_surface_get_output (self); - + if (output) { g_assert (PHOC_IS_OUTPUT (output)); + phoc_output_remove_frame_callbacks_by_animatable (output, PHOC_ANIMATABLE (self)); wl_list_remove (&self->output_destroy.link); phoc_layer_shell_arrange (output); phoc_layer_shell_update_focus (); diff -Nru phoc-0.23.0/src/layer-surface.h phoc-0.24.0/src/layer-surface.h --- phoc-0.23.0/src/layer-surface.h 2023-01-14 11:21:21.000000000 +0000 +++ phoc-0.24.0/src/layer-surface.h 2023-01-31 11:36:25.000000000 +0000 @@ -28,7 +28,7 @@ GObject parent; struct wlr_layer_surface_v1 *layer_surface; - struct wl_list link; // PhocOutput::layers[current] + struct wl_list link; // PhocOutput::layer_surfaces struct wl_listener destroy; struct wl_listener map; diff -Nru phoc-0.23.0/src/main.c phoc-0.24.0/src/main.c --- phoc-0.23.0/src/main.c 2023-01-14 11:21:21.000000000 +0000 +++ phoc-0.24.0/src/main.c 2023-01-31 11:36:25.000000000 +0000 @@ -74,6 +74,9 @@ { .key = "touch-points", .value = PHOC_SERVER_DEBUG_FLAG_TOUCH_POINTS, }, + { .key = "layer-shell", + .value = PHOC_SERVER_DEBUG_FLAG_LAYER_SHELL, + }, }; diff -Nru phoc-0.23.0/src/output.c phoc-0.24.0/src/output.c --- phoc-0.23.0/src/output.c 2023-01-14 11:21:21.000000000 +0000 +++ phoc-0.24.0/src/output.c 2023-01-31 11:36:25.000000000 +0000 @@ -1288,6 +1288,32 @@ } +/** + * phoc_output_remove_frame_callbacks_by_animatable: + * @self: The output to remove the frame callbacks from + * @animatable: The animatable to remove + * + * Remove all frame callbacks for the given #PhocAnimatable. + */ +void +phoc_output_remove_frame_callbacks_by_animatable (PhocOutput *self, PhocAnimatable *animatable) +{ + PhocOutputPrivate *priv; + + g_assert (PHOC_IS_OUTPUT (self)); + priv = phoc_output_get_instance_private (self); + + for (GSList *elem = priv->frame_callbacks; elem; elem = elem->next) { + PhocOutputFrameCallbackInfo *cb_info = elem->data; + + if (cb_info->animatable == animatable) { + phoc_output_frame_callback_info_free (cb_info); + priv->frame_callbacks = g_slist_delete_link (priv->frame_callbacks, elem); + } + } +} + + bool phoc_output_has_frame_callbacks (PhocOutput *self) { diff -Nru phoc-0.23.0/src/output.h phoc-0.24.0/src/output.h --- phoc-0.23.0/src/output.h 2023-01-14 11:21:21.000000000 +0000 +++ phoc-0.24.0/src/output.h 2023-01-31 11:36:25.000000000 +0000 @@ -38,7 +38,7 @@ struct wl_list link; // PhocDesktop::outputs PhocView *fullscreen_view; - struct wl_list layer_surfaces; // layer_surface::link + struct wl_list layer_surfaces; // PhocLayerSurface::link struct wlr_output_damage *damage; GList *debug_touch_points; @@ -135,6 +135,8 @@ GDestroyNotify notify); void phoc_output_remove_frame_callback (PhocOutput *self, guint id); +void phoc_output_remove_frame_callbacks_by_animatable (PhocOutput *self, + PhocAnimatable *animatable); bool phoc_output_has_frame_callbacks (PhocOutput *self); void phoc_output_lower_shield (PhocOutput *self); diff -Nru phoc-0.23.0/src/server.h phoc-0.24.0/src/server.h --- phoc-0.23.0/src/server.h 2023-01-14 11:21:21.000000000 +0000 +++ phoc-0.24.0/src/server.h 2023-01-31 11:36:25.000000000 +0000 @@ -24,16 +24,17 @@ * PHOC_SHELL_FLAG_SHELL_MODE: Expect a shell to attach */ typedef enum _PhocServerFlags { - PHOC_SERVER_FLAG_NONE = 0, + PHOC_SERVER_FLAG_NONE = 0, PHOC_SERVER_FLAG_SHELL_MODE = 1 << 0, } PhocServerFlags; typedef enum _PhocServerDebugFlags { - PHOC_SERVER_DEBUG_FLAG_NONE = 0, - PHOC_SERVER_DEBUG_FLAG_AUTO_MAXIMIZE = 1 << 0, + PHOC_SERVER_DEBUG_FLAG_NONE = 0, + PHOC_SERVER_DEBUG_FLAG_AUTO_MAXIMIZE = 1 << 0, PHOC_SERVER_DEBUG_FLAG_DAMAGE_TRACKING = 1 << 1, - PHOC_SERVER_DEBUG_FLAG_NO_QUIT = 1 << 2, - PHOC_SERVER_DEBUG_FLAG_TOUCH_POINTS = 1 << 3, + PHOC_SERVER_DEBUG_FLAG_NO_QUIT = 1 << 2, + PHOC_SERVER_DEBUG_FLAG_TOUCH_POINTS = 1 << 3, + PHOC_SERVER_DEBUG_FLAG_LAYER_SHELL = 1 << 4, } PhocServerDebugFlags; /**