mirror of
https://github.com/swaywm/sway.git
synced 2025-11-17 06:59:48 -05:00
Support desktop shell panels in compositor
This commit is contained in:
parent
60e76cf932
commit
e59cffcea2
5 changed files with 130 additions and 22 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include <wlc/wlc.h>
|
||||
#include <wlc/wlc-wayland.h>
|
||||
#include "wayland-desktop-shell-server-protocol.h"
|
||||
#include "layout.h"
|
||||
#include "log.h"
|
||||
#include "extensions.h"
|
||||
|
||||
|
|
@ -20,13 +21,55 @@ static void set_background(struct wl_client *client, struct wl_resource *resourc
|
|||
list_add(desktop_shell.backgrounds, config);
|
||||
}
|
||||
|
||||
static void set_panel(struct wl_client *client, struct wl_resource *resource,
|
||||
struct wl_resource *_output, struct wl_resource *surface) {
|
||||
wlc_handle output = wlc_handle_from_wl_output_resource(_output);
|
||||
if (!output) {
|
||||
return;
|
||||
}
|
||||
sway_log(L_DEBUG, "Setting surface %p as panel for output %d", surface, (int)output);
|
||||
struct panel_config *config = malloc(sizeof(struct panel_config));
|
||||
config->output = output;
|
||||
config->surface = wlc_resource_from_wl_surface_resource(surface);
|
||||
list_add(desktop_shell.panels, config);
|
||||
desktop_shell.panel_size = *wlc_surface_get_size(config->surface);
|
||||
arrange_windows(&root_container, -1, -1);
|
||||
}
|
||||
|
||||
static void 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");
|
||||
}
|
||||
|
||||
static void unlock(struct wl_client *client, struct wl_resource *resource) {
|
||||
sway_log(L_ERROR, "desktop_unlock is not currently supported");
|
||||
}
|
||||
|
||||
static void set_grab_surface(struct wl_client *client, struct wl_resource *resource, struct wl_resource *surface) {
|
||||
sway_log(L_ERROR, "desktop_set_grab_surface is not currently supported");
|
||||
}
|
||||
|
||||
static void desktop_ready(struct wl_client *client, struct wl_resource *resource) {
|
||||
// nop
|
||||
}
|
||||
|
||||
static void set_panel_position(struct wl_client *client, struct wl_resource *resource, uint32_t position) {
|
||||
desktop_shell.panel_position = position;
|
||||
arrange_windows(&root_container, -1, -1);
|
||||
}
|
||||
|
||||
static struct desktop_shell_interface desktop_shell_implementation = {
|
||||
.set_background = set_background
|
||||
.set_background = set_background,
|
||||
.set_panel = set_panel,
|
||||
.set_lock_surface = set_lock_surface,
|
||||
.unlock = unlock,
|
||||
.set_grab_surface = set_grab_surface,
|
||||
.desktop_ready = desktop_ready,
|
||||
.set_panel_position = set_panel_position
|
||||
};
|
||||
|
||||
static void desktop_shell_bind(struct wl_client *client, void *data,
|
||||
unsigned int version, unsigned int id) {
|
||||
if (version > 1) {
|
||||
if (version > 3) {
|
||||
// Unsupported version
|
||||
return;
|
||||
}
|
||||
|
|
@ -40,6 +83,8 @@ static void desktop_shell_bind(struct wl_client *client, void *data,
|
|||
}
|
||||
|
||||
void register_extensions(void) {
|
||||
wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 1, NULL, desktop_shell_bind);
|
||||
wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 3, NULL, desktop_shell_bind);
|
||||
desktop_shell.backgrounds = create_list();
|
||||
desktop_shell.panels = create_list();
|
||||
desktop_shell.panel_position = DESKTOP_SHELL_PANEL_POSITION_BOTTOM;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue