mirror of
https://github.com/swaywm/sway.git
synced 2024-11-29 03:11:27 +00:00
progress on panel protocol
This commit is contained in:
parent
b7fe2a95ca
commit
aea0d45c9d
|
@ -27,6 +27,9 @@ struct panel_config {
|
|||
struct wl_client *client;
|
||||
// wlc handle for this panel's surface, not set until panel is created
|
||||
wlc_handle handle;
|
||||
|
||||
enum desktop_shell_hide_modes hide_mode;
|
||||
enum desktop_shell_hide_state hide;
|
||||
};
|
||||
|
||||
struct desktop_shell_state {
|
||||
|
|
|
@ -117,6 +117,32 @@
|
|||
<arg name="position" type="uint"/>
|
||||
</request>
|
||||
|
||||
<!-- Bar Hiding additions -->
|
||||
<enum name="hide_modes">
|
||||
<entry name="hide" value="0"/>
|
||||
<entry name="show" value="1"/>
|
||||
</enum>
|
||||
|
||||
<enum name="hide_state">
|
||||
<entry name="hide" value="0"/>
|
||||
<entry name="show" value="1"/>
|
||||
</enum>
|
||||
<request name="set_panel_hide_mode" since="3">
|
||||
<description summary="set panel hide mode">
|
||||
Tell the shell whether or not panel is in hide mode
|
||||
i.e. whether to allocate a fixed amount of space
|
||||
for the panel (hide mode false) or not (hide mode true)
|
||||
</description>
|
||||
<arg name="mode" type="uint"/>
|
||||
</request>
|
||||
|
||||
<request name="set_panel_hide" since="3">
|
||||
<description summary="set if panel is currently hidden">
|
||||
Tell the shell whether or not panel is currently hidden
|
||||
</description>
|
||||
<arg name="mode" type="uint"/>
|
||||
</request>
|
||||
|
||||
</interface>
|
||||
|
||||
<interface name="screensaver" version="1">
|
||||
|
|
|
@ -133,6 +133,34 @@ static void set_panel(struct wl_client *client, struct wl_resource *resource,
|
|||
wlc_output_schedule_render(config->output);
|
||||
}
|
||||
|
||||
static void set_panel_hide_mode(struct wl_client *client, struct wl_resource *resource,
|
||||
uint32_t mode) {
|
||||
struct panel_config *config = find_or_create_panel_config(resource);
|
||||
config->hide_mode = mode;
|
||||
if (mode == 0) {
|
||||
wlc_view_set_mask(wlc_handle_from_wl_surface_resource(config->wl_surface_res), false);
|
||||
} else {
|
||||
wlc_view_set_mask(wlc_handle_from_wl_surface_resource(config->wl_surface_res), true);
|
||||
}
|
||||
arrange_windows(&root_container, -1, -1);
|
||||
wlc_output_schedule_render(config->output);
|
||||
}
|
||||
|
||||
static void set_panel_hide(struct wl_client *client, struct wl_resource *resource,
|
||||
uint32_t hide) {
|
||||
sway_log(L_ERROR, "Attempting to find panel %p", resource);
|
||||
struct panel_config *config = find_or_create_panel_config(resource);
|
||||
config->hide = hide;
|
||||
if (hide == 0) {
|
||||
sway_log(L_ERROR, "Hiding panel %p", resource);
|
||||
wlc_view_set_mask(wlc_handle_from_wl_surface_resource(config->wl_surface_res), false);
|
||||
} else if (hide == 1) {
|
||||
sway_log(L_ERROR, "Showing panel %p", resource);
|
||||
wlc_view_set_mask(wlc_handle_from_wl_surface_resource(config->wl_surface_res), true);
|
||||
}
|
||||
wlc_output_schedule_render(config->output);
|
||||
}
|
||||
|
||||
static void desktop_set_lock_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) {
|
||||
sway_log(L_ERROR, "desktop_set_lock_surface is not currently supported");
|
||||
}
|
||||
|
@ -169,7 +197,9 @@ static struct desktop_shell_interface desktop_shell_implementation = {
|
|||
.unlock = desktop_unlock,
|
||||
.set_grab_surface = set_grab_surface,
|
||||
.desktop_ready = desktop_ready,
|
||||
.set_panel_position = set_panel_position
|
||||
.set_panel_position = set_panel_position,
|
||||
.set_panel_hide_mode = set_panel_hide_mode,
|
||||
.set_panel_hide = set_panel_hide
|
||||
};
|
||||
|
||||
static void desktop_shell_bind(struct wl_client *client, void *data,
|
||||
|
|
|
@ -1006,6 +1006,7 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
|
|||
if (config->output == output->handle) {
|
||||
struct wlc_size size = *wlc_surface_get_size(config->surface);
|
||||
sway_log(L_DEBUG, "-> Found panel for this workspace: %ux%u, position: %u", size.w, size.h, config->panel_position);
|
||||
if (config->hide_mode == DESKTOP_SHELL_HIDE_MODES_SHOW) {
|
||||
switch (config->panel_position) {
|
||||
case DESKTOP_SHELL_PANEL_POSITION_TOP:
|
||||
y += size.h; height -= size.h;
|
||||
|
@ -1022,6 +1023,7 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int gap = swayc_gap(container);
|
||||
x = container->x = x + gap;
|
||||
y = container->y = y + gap;
|
||||
|
|
|
@ -163,6 +163,15 @@ void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id) {
|
|||
output->output, bar_output->window->surface);
|
||||
desktop_shell_set_panel_position(bar_output->registry->desktop_shell,
|
||||
bar->config->position);
|
||||
switch (bar->config->display_mode) {
|
||||
case MODE_HIDE:
|
||||
case MODE_INVISIBLE:
|
||||
desktop_shell_set_panel_hide_mode(bar_output->registry->desktop_shell, DESKTOP_SHELL_HIDE_MODES_HIDE);
|
||||
break;
|
||||
case MODE_DOCK:
|
||||
desktop_shell_set_panel_hide_mode(bar_output->registry->desktop_shell, DESKTOP_SHELL_HIDE_MODES_SHOW);
|
||||
break;
|
||||
}
|
||||
|
||||
window_make_shell(bar_output->window);
|
||||
|
||||
|
|
|
@ -383,6 +383,7 @@ bool handle_ipc_event(struct bar *bar) {
|
|||
break;
|
||||
}
|
||||
case IPC_EVENT_MODIFIER: {
|
||||
if (bar->config->display_mode == MODE_HIDE) {
|
||||
json_object *result = json_tokener_parse(resp->payload);
|
||||
if (!result) {
|
||||
free_ipc_response(resp);
|
||||
|
@ -394,8 +395,21 @@ bool handle_ipc_event(struct bar *bar) {
|
|||
const char *change = json_object_get_string(json_change);
|
||||
if (strcmp(change, "pressed") == 0) {
|
||||
bar->config->hidden_state = BAR_SHOW;
|
||||
sway_log(L_ERROR, "Showing bar on %d outputs", bar->outputs->length);
|
||||
int i;
|
||||
for (i = 0; i < bar->outputs->length; ++i) {
|
||||
struct output *bar_output = bar->outputs->items[i];
|
||||
sway_log(L_ERROR, "showing bar on input %d, with registry %p", i, bar_output->registry);
|
||||
desktop_shell_set_panel_hide(bar_output->registry->desktop_shell, DESKTOP_SHELL_HIDE_STATE_SHOW);
|
||||
}
|
||||
} else { //must be "released"
|
||||
bar->config->hidden_state = BAR_HIDDEN;
|
||||
sway_log(L_ERROR, "Hiding bar");
|
||||
int i;
|
||||
for (i = 0; i < bar->outputs->length; ++i) {
|
||||
struct output *bar_output = bar->outputs->items[i];
|
||||
desktop_shell_set_panel_hide(bar_output->registry->desktop_shell, DESKTOP_SHELL_HIDE_STATE_HIDE);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -405,6 +419,7 @@ bool handle_ipc_event(struct bar *bar) {
|
|||
json_object_put(result);
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
free_ipc_response(resp);
|
||||
return false;
|
||||
|
|
|
@ -286,10 +286,6 @@ void render(struct output *output, struct config *config, struct status_line *li
|
|||
cairo_set_operator(cairo, CAIRO_OPERATOR_CLEAR);
|
||||
cairo_paint(cairo);
|
||||
cairo_restore(cairo);
|
||||
// Could also be done by always rendering then conditionally clearing and drawing alpha
|
||||
// That may be preferable down the line
|
||||
if (!(config->display_mode == MODE_HIDE) || config->hidden_state == BAR_SHOW) {
|
||||
|
||||
cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
|
||||
|
||||
// Background
|
||||
|
@ -343,11 +339,6 @@ void render(struct output *output, struct config *config, struct status_line *li
|
|||
if (config->mode && config->binding_mode_indicator) {
|
||||
render_binding_mode_indicator(window, config, x);
|
||||
}
|
||||
} else {
|
||||
cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
|
||||
cairo_set_source_u32(cairo, 0x00000000);
|
||||
cairo_paint(cairo);
|
||||
}
|
||||
}
|
||||
|
||||
void set_window_height(struct window *window, int height) {
|
||||
|
|
Loading…
Reference in a new issue