summaryrefslogtreecommitdiffstats
path: root/sway/extensions.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2015-11-18 22:14:57 -0500
committerLibravatar Drew DeVault <sir@cmpwn.com>2015-11-18 22:14:57 -0500
commit65b8a5c3ce023584cdc5dd84394ea1101c9f23e9 (patch)
tree81d7520a1766cdb27be960f25c85d7ead22337c7 /sway/extensions.c
parentBasic support for extensions in server and clients (diff)
downloadsway-65b8a5c3ce023584cdc5dd84394ea1101c9f23e9.tar.gz
sway-65b8a5c3ce023584cdc5dd84394ea1101c9f23e9.tar.zst
sway-65b8a5c3ce023584cdc5dd84394ea1101c9f23e9.zip
Add background handling
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.
Diffstat (limited to 'sway/extensions.c')
-rw-r--r--sway/extensions.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/sway/extensions.c b/sway/extensions.c
index a37ceaa8..5ef8a0ff 100644
--- a/sway/extensions.c
+++ b/sway/extensions.c
@@ -2,14 +2,26 @@
2#include <wlc/wlc-wayland.h> 2#include <wlc/wlc-wayland.h>
3#include "wayland-desktop-shell-server-protocol.h" 3#include "wayland-desktop-shell-server-protocol.h"
4#include "log.h" 4#include "log.h"
5#include "extensions.h"
6
7struct desktop_shell_state desktop_shell;
5 8
6static void set_background(struct wl_client *client, struct wl_resource *resource, 9static void set_background(struct wl_client *client, struct wl_resource *resource,
7 struct wl_resource *output, struct wl_resource *surface) { 10 struct wl_resource *_output, struct wl_resource *_surface) {
8 sway_log(L_DEBUG, "Surface requesting background for output"); 11 wlc_handle output = wlc_handle_from_wl_output_resource(_output);
12 wlc_handle surface = wlc_handle_from_wl_surface_resource(_surface);
13 sway_log(L_DEBUG, "Setting surface %d as background for output %d", (int)surface, (int)output);
14 if (!output || !surface) {
15 return;
16 }
17 struct background_config *config = malloc(sizeof(struct background_config));
18 config->output = output;
19 config->surface = surface;
20 list_add(desktop_shell.backgrounds, config);
9} 21}
10 22
11static struct desktop_shell_interface desktop_shell_implementation = { 23static struct desktop_shell_interface desktop_shell_implementation = {
12 .set_background = set_background, 24 .set_background = set_background
13}; 25};
14 26
15static void desktop_shell_bind(struct wl_client *client, void *data, 27static void desktop_shell_bind(struct wl_client *client, void *data,
@@ -29,4 +41,5 @@ static void desktop_shell_bind(struct wl_client *client, void *data,
29 41
30void register_extensions(void) { 42void register_extensions(void) {
31 wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 1, NULL, desktop_shell_bind); 43 wl_global_create(wlc_get_wl_display(), &desktop_shell_interface, 1, NULL, desktop_shell_bind);
44 desktop_shell.backgrounds = create_list();
32} 45}