diff --git a/doc/ROADMAP.md b/doc/ROADMAP.md index 3816cea3..aff702fd 100644 --- a/doc/ROADMAP.md +++ b/doc/ROADMAP.md @@ -30,7 +30,7 @@ See the [Detailed Feature List](FEATURES.md) for details. * Settings to specify output, layer and anchor for dock, clip and icon area. * Behaviour * [done] Fix issue of `wlmdock` not updating contents initially and automatically. - * Use exclusive zone + width to not overlap with other layer elements. + * [done] Use exclusive zone + width to not overlap with other layer elements. * `wlmaker` respects exclusive zone from dock(s) when determining maximizing extents. * Fixes * [done] Resolve leaks, as reported by valgrind. diff --git a/examples/example_layer_surface.c b/examples/example_layer_surface.c index 6a6a07a4..b59e7bf2 100644 --- a/examples/example_layer_surface.c +++ b/examples/example_layer_surface.c @@ -102,7 +102,10 @@ static bool _callback(bs_gfxbuf_t *gfxbuf_ptr, void *ud_ptr) /* ------------------------------------------------------------------------- */ /** Handles configure events. */ -static void _handle_configure(void *ud_ptr, uint32_t width, uint32_t height) +static void _handle_configure( + void *ud_ptr, + __UNUSED__ uint32_t width, + __UNUSED__ uint32_t height) { wlmcl_layer_surface_t *layer_surface_ptr = ud_ptr; if (NULL != dblbuf_ptr) { @@ -112,8 +115,8 @@ static void _handle_configure(void *ud_ptr, uint32_t width, uint32_t height) wlmcl_client_attributes(wlclient_ptr)->app_id_ptr, wlmcl_layer_surface_wl_surface(layer_surface_ptr), wlmcl_client_attributes(wlclient_ptr)->wl_shm_ptr, - width, - height); + 100, + 300); if (NULL == dblbuf_ptr) { bs_log(BS_FATAL, "Failed wlmcl_dblbuf_create."); return; @@ -136,12 +139,17 @@ int main(__UNUSED__ int argc, __UNUSED__ char **argv) wlmcl_layer_surface_t *layer_surface_ptr = wlmcl_layer_surface_create( wlclient_ptr, ZWLR_LAYER_SHELL_V1_LAYER_TOP, - "wlmdock-panel", + "example_layer_surface"); + + zwlr_layer_surface_v1_set_size( + wlmcl_layer_surface_wlr_layer_surface(layer_surface_ptr), + 100, 300); + zwlr_layer_surface_v1_set_anchor( + wlmcl_layer_surface_wlr_layer_surface(layer_surface_ptr), ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | - ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM, - 100, - 300); + ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM); + wl_surface_commit(wlmcl_layer_surface_wl_surface(layer_surface_ptr)); if (NULL != layer_surface_ptr) { // Register configure callback diff --git a/src/dock/subcompositor.c b/src/dock/subcompositor.c index 672e1354..a85cc390 100644 --- a/src/dock/subcompositor.c +++ b/src/dock/subcompositor.c @@ -385,8 +385,9 @@ void _wlmdock_subcompositor_request_size( return; } - wlmcl_layer_surface_request_size( - subcompositor_ptr->layer_surface_ptr, + zwlr_layer_surface_v1_set_size( + wlmcl_layer_surface_wlr_layer_surface( + subcompositor_ptr->layer_surface_ptr), box.width, box.height); } diff --git a/src/dock/wlmdock.c b/src/dock/wlmdock.c index d58f116e..d238205f 100644 --- a/src/dock/wlmdock.c +++ b/src/dock/wlmdock.c @@ -329,16 +329,28 @@ wlmdock_t *_wlmdock_create( dock_ptr->layer_surface_ptr = wlmcl_layer_surface_create( dock_ptr->client_ptr, ZWLR_LAYER_SHELL_V1_LAYER_TOP, - "wlmdock", - positioning.anchor | positioning.edge, - 64, - 64); + "wlmdock"); if (NULL == dock_ptr->layer_surface_ptr) { bs_log(BS_ERROR, "Failed to create client layer surface."); _wlmdock_destroy(dock_ptr); return NULL; } - wlmcl_layer_surface_set_exclusive_zone(dock_ptr->layer_surface_ptr, 64); + + // Configure. + zwlr_layer_surface_v1_set_size( + wlmcl_layer_surface_wlr_layer_surface(dock_ptr->layer_surface_ptr), + 64, 64); + zwlr_layer_surface_v1_set_anchor( + wlmcl_layer_surface_wlr_layer_surface(dock_ptr->layer_surface_ptr), + positioning.anchor | positioning.edge); + zwlr_layer_surface_v1_set_exclusive_zone( + wlmcl_layer_surface_wlr_layer_surface(dock_ptr->layer_surface_ptr), + 64); + zwlr_layer_surface_v1_set_exclusive_edge( + wlmcl_layer_surface_wlr_layer_surface(dock_ptr->layer_surface_ptr), + positioning.edge); + wl_surface_commit( + wlmcl_layer_surface_wl_surface(dock_ptr->layer_surface_ptr)); // 3. Setup local Wayland server display and event loops. dock_ptr->local_display_ptr = wl_display_create(); diff --git a/src/layer_panel.c b/src/layer_panel.c index 5b91a505..3192914f 100644 --- a/src/layer_panel.c +++ b/src/layer_panel.c @@ -432,10 +432,6 @@ void _wlmaker_layer_panel_handle_surface_commit( struct wlr_layer_surface_v1_state *state_ptr = &layer_panel_ptr->wlr_layer_surface_v1_ptr->pending; - // FIXME: add exclusive_edge, and committed with EXCLUSIVE_EDGE - bs_log(BS_ERROR, "FIXME: committed %"PRIx32", exclusive edge %"PRIx32, - state_ptr->committed, state_ptr->exclusive_edge); - wlmtk_panel_positioning_t pos = { .anchor = state_ptr->anchor, .desired_width = state_ptr->desired_width, @@ -446,7 +442,8 @@ void _wlmaker_layer_panel_handle_surface_commit( .margin_right = state_ptr->margin.right, .margin_bottom = state_ptr->margin.bottom, - .exclusive_zone = state_ptr->exclusive_zone + .exclusive_zone = state_ptr->exclusive_zone, + .exclusive_edge = state_ptr->exclusive_edge, }; // Sanity check 'exclusive edge' setting. If it's set. diff --git a/src/toolkit/dock.c b/src/toolkit/dock.c index 0c329bc4..79a5b3d8 100644 --- a/src/toolkit/dock.c +++ b/src/toolkit/dock.c @@ -314,6 +314,7 @@ bool _wlmtk_dock_positioning( // the entire height. Go with a one-tile dimension, as long as there's // no tiles yet. panel_positioning_ptr->desired_height = BS_MAX(box.height, 1); + panel_positioning_ptr->exclusive_zone = BS_MAX(box.width, 1); break; case WLR_EDGE_TOP: @@ -334,6 +335,7 @@ bool _wlmtk_dock_positioning( // the entire width. Go with a one-tile dimension, as long as there's // no tiles yet. panel_positioning_ptr->desired_width = BS_MAX(box.width, 1); + panel_positioning_ptr->exclusive_zone = BS_MAX(box.height, 1); break; default: @@ -342,6 +344,7 @@ bool _wlmtk_dock_positioning( return false; } + panel_positioning_ptr->exclusive_edge = dock_ptr->dock_positioning.edge; return true; } diff --git a/src/wlclient/layer_surface.c b/src/wlclient/layer_surface.c index cb1bd080..fc69c4ca 100644 --- a/src/wlclient/layer_surface.c +++ b/src/wlclient/layer_surface.c @@ -43,16 +43,15 @@ struct _wlmcl_layer_surface_t { /** Layer-shell surface wrapping `wl_surface_ptr`. */ struct zwlr_layer_surface_v1 *layer_surface_ptr; - /** Width of the layer surface. */ - uint32_t width; - /** Height of the layer surface. */ - uint32_t height; - + /** The configured width of the layer surface. */ + uint32_t configured_width; + /** The configured height of the layer surface. */ + uint32_t configured_height; /** Whether the surface has been configured. */ bool configured; /** Callback for input configure. */ - void (*configure_callback)(void *ud_ptr, uint32_t width, uint32_t height); + void (*configure_callback)(void *ud_ptr, uint32_t width, uint32_t height); /** Client-provided argument to configure_callback. */ void *configure_callback_ud_ptr; }; @@ -89,10 +88,7 @@ bool wlmcl_layer_shell_supported(wlmcl_client_t *wlclient_ptr) wlmcl_layer_surface_t *wlmcl_layer_surface_create( wlmcl_client_t *wlclient_ptr, uint32_t layer, - const char *namespace_ptr, - uint32_t anchor, - uint32_t width, - uint32_t height) + const char *namespace_ptr) { if (!wlmcl_layer_shell_supported(wlclient_ptr)) { bs_log(BS_ERROR, "Layer shell is not supported."); @@ -103,8 +99,6 @@ wlmcl_layer_surface_t *wlmcl_layer_surface_create( 1, sizeof(wlmcl_layer_surface_t)); if (NULL == layer_surface_ptr) return NULL; layer_surface_ptr->wlclient_ptr = wlclient_ptr; - layer_surface_ptr->width = width; - layer_surface_ptr->height = height; layer_surface_ptr->wl_surface_ptr = wl_compositor_create_surface( wlmcl_client_attributes(wlclient_ptr)->wl_compositor_ptr); @@ -127,11 +121,6 @@ wlmcl_layer_surface_t *wlmcl_layer_surface_create( return NULL; } - zwlr_layer_surface_v1_set_size( - layer_surface_ptr->layer_surface_ptr, width, height); - zwlr_layer_surface_v1_set_anchor( - layer_surface_ptr->layer_surface_ptr, anchor); - if (0 != zwlr_layer_surface_v1_add_listener( layer_surface_ptr->layer_surface_ptr, &_wlmcl_layer_surface_listener, @@ -141,8 +130,6 @@ wlmcl_layer_surface_t *wlmcl_layer_surface_create( return NULL; } - wl_surface_commit(layer_surface_ptr->wl_surface_ptr); - return layer_surface_ptr; } @@ -156,8 +143,6 @@ void wlmcl_layer_surface_destroy(wlmcl_layer_surface_t *layer_surface_ptr) layer_surface_ptr->layer_surface_ptr = NULL; } - - if (NULL != layer_surface_ptr->wl_surface_ptr) { wl_surface_destroy(layer_surface_ptr->wl_surface_ptr); layer_surface_ptr->wl_surface_ptr = NULL; @@ -167,44 +152,17 @@ void wlmcl_layer_surface_destroy(wlmcl_layer_surface_t *layer_surface_ptr) } /* ------------------------------------------------------------------------- */ -void wlmcl_layer_surface_request_size( - wlmcl_layer_surface_t *layer_surface_ptr, - uint32_t width, - uint32_t height) -{ - zwlr_layer_surface_v1_set_size( - layer_surface_ptr->layer_surface_ptr, width, height); - wl_surface_commit(layer_surface_ptr->wl_surface_ptr); -} - -/* ------------------------------------------------------------------------- */ -void wlmcl_layer_surface_set_margin( - wlmcl_layer_surface_t *layer_surface_ptr, - int32_t top, - int32_t right, - int32_t bottom, - int32_t left) -{ - zwlr_layer_surface_v1_set_margin( - layer_surface_ptr->layer_surface_ptr, top, right, bottom, left); - wl_surface_commit(layer_surface_ptr->wl_surface_ptr); -} - -/* ------------------------------------------------------------------------- */ -void wlmcl_layer_surface_set_exclusive_zone( - wlmcl_layer_surface_t *layer_surface_ptr, - int32_t pixels) +struct wl_surface *wlmcl_layer_surface_wl_surface( + wlmcl_layer_surface_t *layer_surface_ptr) { - zwlr_layer_surface_v1_set_exclusive_zone( - layer_surface_ptr->layer_surface_ptr, pixels); - wl_surface_commit(layer_surface_ptr->wl_surface_ptr); + return layer_surface_ptr->wl_surface_ptr; } - /* ------------------------------------------------------------------------- */ -struct wl_surface *wlmcl_layer_surface_wl_surface(wlmcl_layer_surface_t *layer_surface_ptr) +struct zwlr_layer_surface_v1 *wlmcl_layer_surface_wlr_layer_surface( + wlmcl_layer_surface_t *layer_surface_ptr) { - return layer_surface_ptr->wl_surface_ptr; + return layer_surface_ptr->layer_surface_ptr; } /* ------------------------------------------------------------------------- */ @@ -216,7 +174,10 @@ void wlmcl_layer_surface_register_configure_callback( layer_surface_ptr->configure_callback = callback; layer_surface_ptr->configure_callback_ud_ptr = ud_ptr; if (layer_surface_ptr->configured && NULL != callback) { - callback(ud_ptr, layer_surface_ptr->width, layer_surface_ptr->height); + callback( + ud_ptr, + layer_surface_ptr->configured_width, + layer_surface_ptr->configured_height); } } @@ -245,16 +206,9 @@ void _wlmcl_layer_surface_handle_configure( zwlr_layer_surface_v1_ack_configure(layer_surface_ptr, serial); - if (width == 0 || height == 0) { - // Client should decide. We keep our current width/height. - width = layer_surface_ptr_->width; - height = layer_surface_ptr_->height; - } - - layer_surface_ptr_->width = width; - layer_surface_ptr_->height = height; + layer_surface_ptr_->configured_width = width; + layer_surface_ptr_->configured_height = height; layer_surface_ptr_->configured = true; - if (NULL != layer_surface_ptr_->configure_callback) { layer_surface_ptr_->configure_callback( layer_surface_ptr_->configure_callback_ud_ptr, diff --git a/src/wlclient/layer_surface.h b/src/wlclient/layer_surface.h index 7109e98f..a3fd24ca 100644 --- a/src/wlclient/layer_surface.h +++ b/src/wlclient/layer_surface.h @@ -47,21 +47,13 @@ bool wlmcl_layer_shell_supported(wlmcl_client_t *wlclient_ptr); * @param wlclient_ptr * @param layer One of zwlr_layer_shell_v1_layer. * @param namespace_ptr Namespace string. - * @param anchor Bitwise OR of zwlr_layer_surface_v1_anchor. - * @param width Initial requested width in pixels. 0 to let the - * compositor decide (requires opposite anchors). - * @param height Initial requested height in pixels. 0 to let the - * compositor decide (requires opposite anchors). * * @return State of the layer surface or NULL on error. */ wlmcl_layer_surface_t *wlmcl_layer_surface_create( wlmcl_client_t *wlclient_ptr, uint32_t layer, - const char *namespace_ptr, - uint32_t anchor, - uint32_t width, - uint32_t height); + const char *namespace_ptr); /** * Destroys the layer surface. @@ -70,61 +62,17 @@ wlmcl_layer_surface_t *wlmcl_layer_surface_create( */ void wlmcl_layer_surface_destroy(wlmcl_layer_surface_t *layer_surface_ptr); -/** - * Requests the specified size for the layer surface. - * - * @param layer_surface_ptr - * @param width Requested width in pixels. 0 to let the - * compositor decide. - * @param height Requested height in pixels. 0 to let the - * compositor decide. - */ -void wlmcl_layer_surface_request_size( - wlmcl_layer_surface_t *layer_surface_ptr, - uint32_t width, - uint32_t height); - -/** - * Sets the margins of the layer surface from its anchor points. - * - * @param layer_surface_ptr - * @param top - * @param right - * @param bottom - * @param left - */ -void wlmcl_layer_surface_set_margin( - wlmcl_layer_surface_t *layer_surface_ptr, - int32_t top, - int32_t right, - int32_t bottom, - int32_t left); - -/** - * Sets the exclusive zone of the layer surface. - * - * @param layer_surface_ptr - * @param pixels The exclusive zone in pixels. Positive value - * reserves space to avoid occlusion by other (e.g. - * maximized) windows. 0 disables exclusive zone. - * -1 requests other windows be allowed to overlap. - */ -void wlmcl_layer_surface_set_exclusive_zone( - wlmcl_layer_surface_t *layer_surface_ptr, - int32_t pixels); - -/** - * Returns the underlying Wayland surface of the layer surface. - * - * @param layer_surface_ptr - * - * @return The wl_surface pointer. - */ +/** @return @ref wlmcl_layer_surface_t::wl_surface_ptr. */ struct wl_surface *wlmcl_layer_surface_wl_surface( wlmcl_layer_surface_t *layer_surface_ptr); +/** @return @ref wlmcl_layer_surface_t::layer_surface_ptr. */ +struct zwlr_layer_surface_v1 *wlmcl_layer_surface_wlr_layer_surface( + wlmcl_layer_surface_t *layer_surface_ptr); + /** - * Registers the callback to notify when the layer surface size/layout is determined or updated. + * Registers the callback to notify when the layer surface size/layout is + * determined or updated. * * @param layer_surface_ptr * @param callback diff --git a/src/wlclient/wlclient.c b/src/wlclient/wlclient.c index aee17839..f07f9797 100644 --- a/src/wlclient/wlclient.c +++ b/src/wlclient/wlclient.c @@ -284,7 +284,7 @@ static const object_t objects[] = { offsetof(struct wlmcl_client_attributes, icon_manager_ptr), NULL }, { &ext_input_observation_manager_v1_interface, 1, offsetof(struct wlmcl_client_attributes, input_observation_manager_ptr), NULL }, - { &zwlr_layer_shell_v1_interface, 4, + { &zwlr_layer_shell_v1_interface, 5, offsetof(struct wlmcl_client_attributes, layer_shell_ptr), NULL }, { &wl_compositor_interface, 4, offsetof(struct wlmcl_client_attributes, wl_compositor_ptr), NULL }, diff --git a/src/wlmaker.c b/src/wlmaker.c index 1c6a7257..d6ad8b45 100644 --- a/src/wlmaker.c +++ b/src/wlmaker.c @@ -363,10 +363,10 @@ int main(__UNUSED__ int argc, __UNUSED__ const char **argv) } } - dock_ptr = wlmaker_dock_create( - server_ptr, state_dict_ptr, &style); clip_ptr = wlmaker_clip_create( server_ptr, state_dict_ptr, &style); + dock_ptr = wlmaker_dock_create( + server_ptr, state_dict_ptr, &style); task_list_ptr = wlmaker_task_list_create( server_ptr, &style.task_list); if (NULL == dock_ptr || NULL == clip_ptr || NULL == task_list_ptr) {