Skip to content
Open
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
17 changes: 15 additions & 2 deletions libswc/panel.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct panel {
struct screen_modifier modifier;
uint32_t edge;
uint32_t offset, strut_size;
uint32_t y_offset;
bool docked;
};

Expand All @@ -58,11 +59,11 @@ update_position(struct panel *panel)
switch (panel->edge) {
case SWC_PANEL_EDGE_TOP:
x = screen->x + panel->offset;
y = screen->y;
y = screen->y + panel->y_offset;
break;
case SWC_PANEL_EDGE_BOTTOM:
x = screen->x + panel->offset;
y = screen->y + screen->height - view->height;
y = screen->y + screen->height - view->height - panel->y_offset;
break;
case SWC_PANEL_EDGE_LEFT:
x = screen->x;
Expand Down Expand Up @@ -133,6 +134,16 @@ set_offset(struct wl_client *client, struct wl_resource *resource, uint32_t offs
update_position(panel);
}

static void
set_y_offset(struct wl_client *client, struct wl_resource *resource, uint32_t offset)
{
struct panel *panel = wl_resource_get_user_data(resource);

panel->y_offset = offset;
if (panel->docked)
update_position(panel);
}

static void
set_strut(struct wl_client *client, struct wl_resource *resource, uint32_t size, uint32_t begin, uint32_t end)
{
Expand All @@ -146,6 +157,7 @@ set_strut(struct wl_client *client, struct wl_resource *resource, uint32_t size,
static const struct swc_panel_interface panel_impl = {
.dock = dock,
.set_offset = set_offset,
.set_y_offset = set_y_offset,
.set_strut = set_strut,
};

Expand Down Expand Up @@ -242,6 +254,7 @@ panel_new(struct wl_client *client, uint32_t version, uint32_t id, struct surfac
panel->modifier.modify = &modify;
panel->screen = NULL;
panel->offset = 0;
panel->y_offset = 0;
panel->strut_size = 0;
panel->docked = false;
wl_list_insert(&panel->view->base.handlers, &panel->view_handler.link);
Expand Down
7 changes: 5 additions & 2 deletions protocol/swc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
</request>
</interface>

<interface name="swc_panel" version="1">
<interface name="swc_panel" version="2">
<enum name="edge">
<entry name="top" value="0" />
<entry name="bottom" value="1" />
Expand All @@ -56,6 +56,10 @@
<arg name="offset" type="uint" />
</request>

<request name="set_y_offset">
<arg name="offset" type="uint" />
</request>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking we could just deprecate and rename set_offset, and add a new request that handles both edge and side offset.

In any case, the behavior we introduce here should be consistent and easily explained. As proposed, we have something like

  • Top: offset is from left, y_offset is from top.
  • Bottom: offset is from left, y_offset is from bottom.
  • Left: offset is from bottom, y_offset doesn't do anything.
  • Right: offset is from bottom, y_offset doesn't do anything.

Though also I think we're in agreement that we should just use layer shell, so maybe it's not worth worrying to much about this.


<request name="set_strut">
<arg name="size" type="uint" />
<arg name="begin" type="uint" />
Expand All @@ -67,4 +71,3 @@
</event>
</interface>
</protocol>