mirror of
https://github.com/gwenhael-le-moine/sway-patched-tray-menu.git
synced 2025-01-18 22:26:12 +01:00
65b8a5c3ce
This does not work as expected. I think the problem is on the wlc side. Please review, @Cloudef. To reproduce the issues: 1. Run sway 2. Open terminal in sway 3. Run swaybg swaybg will create a surface and ask to have it set as the background, but wlc_handle_from_wl_surface_resource will return 0. If the swaybg surface is a shell surface, then it works - but wlc complains about the pointer type and segfaults as soon as the pre-render hook tries to draw the background.
45 lines
1.5 KiB
C
45 lines
1.5 KiB
C
#include <wlc/wlc.h>
|
|
#include <wlc/wlc-wayland.h>
|
|
#include "wayland-desktop-shell-server-protocol.h"
|
|
#include "log.h"
|
|
#include "extensions.h"
|
|
|
|
struct desktop_shell_state desktop_shell;
|
|
|
|
static void set_background(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);
|
|
wlc_handle surface = wlc_handle_from_wl_surface_resource(_surface);
|
|
sway_log(L_DEBUG, "Setting surface %d as background for output %d", (int)surface, (int)output);
|
|
if (!output || !surface) {
|
|
return;
|
|
}
|
|
struct background_config *config = malloc(sizeof(struct background_config));
|
|
config->output = output;
|
|
config->surface = surface;
|
|
list_add(desktop_shell.backgrounds, config);
|
|
}
|
|
|
|
static struct desktop_shell_interface desktop_shell_implementation = {
|
|
.set_background = set_background
|
|
};
|
|
|
|
static void desktop_shell_bind(struct wl_client *client, void *data,
|
|
unsigned int version, unsigned int id) {
|
|
if (version > 1) {
|
|
// Unsupported version
|
|
return;
|
|
}
|
|
|
|
struct wl_resource *resource = wl_resource_create(client, &desktop_shell_interface, version, id);
|
|
if (!resource) {
|
|
wl_client_post_no_memory(client);
|
|
}
|
|
|
|
wl_resource_set_implementation(resource, &desktop_shell_implementation, NULL, NULL);
|
|
}
|
|
|
|
void register_extensions(void) {
|
|
wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 1, NULL, desktop_shell_bind);
|
|
desktop_shell.backgrounds = create_list();
|
|
}
|