Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 15 additions & 7 deletions examples/example_layer_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/dock/subcompositor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
22 changes: 17 additions & 5 deletions src/dock/wlmdock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 2 additions & 5 deletions src/layer_panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions src/toolkit/dock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -342,6 +344,7 @@ bool _wlmtk_dock_positioning(
return false;
}

panel_positioning_ptr->exclusive_edge = dock_ptr->dock_positioning.edge;
return true;
}

Expand Down
82 changes: 18 additions & 64 deletions src/wlclient/layer_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -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.");
Expand All @@ -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);
Expand All @@ -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,
Expand All @@ -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;
}

Expand All @@ -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;
Expand All @@ -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;
}

/* ------------------------------------------------------------------------- */
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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,
Expand Down
68 changes: 8 additions & 60 deletions src/wlclient/layer_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down
Loading
Loading