shell: Don't make desktop_shell background a wl_shell_surface
We don't gain anything from taking a wl_shell_surface in desktop_surface.set_background, except making wl_shell_surface gratuitously dependent on wl_shell. In shell.c we can also handle backgrounds in their own background_configure function which simplifies the mapping and placement logic.
This commit is contained in:
+10
-9
@@ -718,10 +718,10 @@ static void
|
||||
desktop_shell_configure(void *data,
|
||||
struct desktop_shell *desktop_shell,
|
||||
uint32_t edges,
|
||||
struct wl_shell_surface *shell_surface,
|
||||
struct wl_surface *surface,
|
||||
int32_t width, int32_t height)
|
||||
{
|
||||
struct window *window = wl_shell_surface_get_user_data(shell_surface);
|
||||
struct window *window = wl_surface_get_user_data(surface);
|
||||
struct surface *s = window_get_user_data(window);
|
||||
|
||||
s->configure(data, desktop_shell, edges, window, width, height);
|
||||
@@ -758,9 +758,8 @@ background_create(struct desktop *desktop)
|
||||
memset(background, 0, sizeof *background);
|
||||
|
||||
background->base.configure = background_configure;
|
||||
background->window = window_create(desktop->display);
|
||||
background->window = window_create_custom(desktop->display);
|
||||
background->widget = window_add_widget(background->window, background);
|
||||
window_set_custom(background->window);
|
||||
window_set_user_data(background->window, background);
|
||||
widget_set_redraw_handler(background->widget, background_draw);
|
||||
|
||||
@@ -877,15 +876,17 @@ int main(int argc, char *argv[])
|
||||
global_handler, &desktop);
|
||||
|
||||
wl_list_for_each(output, &desktop.outputs, link) {
|
||||
struct wl_shell_surface *s;
|
||||
struct wl_shell_surface *shsurf;
|
||||
struct wl_surface *surface;
|
||||
|
||||
output->panel = panel_create(desktop.display);
|
||||
s = window_get_wl_shell_surface(output->panel->window);
|
||||
desktop_shell_set_panel(desktop.shell, output->output, s);
|
||||
shsurf = window_get_wl_shell_surface(output->panel->window);
|
||||
desktop_shell_set_panel(desktop.shell, output->output, shsurf);
|
||||
|
||||
output->background = background_create(&desktop);
|
||||
s = window_get_wl_shell_surface(output->background->window);
|
||||
desktop_shell_set_background(desktop.shell, output->output, s);
|
||||
surface = window_get_wl_surface(output->background->window);
|
||||
desktop_shell_set_background(desktop.shell,
|
||||
output->output, surface);
|
||||
}
|
||||
|
||||
busy_surface_create(&desktop);
|
||||
|
||||
+20
-7
@@ -2913,7 +2913,8 @@ static const struct wl_surface_listener surface_listener = {
|
||||
};
|
||||
|
||||
static struct window *
|
||||
window_create_internal(struct display *display, struct window *parent)
|
||||
window_create_internal(struct display *display,
|
||||
struct window *parent, int type)
|
||||
{
|
||||
struct window *window;
|
||||
|
||||
@@ -2926,7 +2927,7 @@ window_create_internal(struct display *display, struct window *parent)
|
||||
window->parent = parent;
|
||||
window->surface = wl_compositor_create_surface(display->compositor);
|
||||
wl_surface_add_listener(window->surface, &surface_listener, window);
|
||||
if (display->shell) {
|
||||
if (type != TYPE_CUSTOM && display->shell) {
|
||||
window->shell_surface =
|
||||
wl_shell_get_shell_surface(display->shell,
|
||||
window->surface);
|
||||
@@ -2940,7 +2941,7 @@ window_create_internal(struct display *display, struct window *parent)
|
||||
window->allocation.height = 0;
|
||||
window->saved_allocation = window->allocation;
|
||||
window->transparent = 1;
|
||||
window->type = TYPE_NONE;
|
||||
window->type = type;
|
||||
window->input_region = NULL;
|
||||
window->opaque_region = NULL;
|
||||
|
||||
@@ -2973,7 +2974,19 @@ window_create(struct display *display)
|
||||
{
|
||||
struct window *window;
|
||||
|
||||
window = window_create_internal(display, NULL);
|
||||
window = window_create_internal(display, NULL, TYPE_NONE);
|
||||
if (!window)
|
||||
return NULL;
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
struct window *
|
||||
window_create_custom(struct display *display)
|
||||
{
|
||||
struct window *window;
|
||||
|
||||
window = window_create_internal(display, NULL, TYPE_CUSTOM);
|
||||
if (!window)
|
||||
return NULL;
|
||||
|
||||
@@ -2986,11 +2999,11 @@ window_create_transient(struct display *display, struct window *parent,
|
||||
{
|
||||
struct window *window;
|
||||
|
||||
window = window_create_internal(parent->display, parent);
|
||||
window = window_create_internal(parent->display,
|
||||
parent, TYPE_TRANSIENT);
|
||||
if (!window)
|
||||
return NULL;
|
||||
|
||||
window->type = TYPE_TRANSIENT;
|
||||
window->x = x;
|
||||
window->y = y;
|
||||
|
||||
@@ -3123,7 +3136,7 @@ window_show_menu(struct display *display,
|
||||
if (!menu)
|
||||
return;
|
||||
|
||||
window = window_create_internal(parent->display, parent);
|
||||
window = window_create_internal(parent->display, parent, TYPE_MENU);
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
|
||||
@@ -201,6 +201,8 @@ window_create(struct display *display);
|
||||
struct window *
|
||||
window_create_transient(struct display *display, struct window *parent,
|
||||
int32_t x, int32_t y, uint32_t flags);
|
||||
struct window *
|
||||
window_create_custom(struct display *display);
|
||||
|
||||
typedef void (*menu_func_t)(struct window *window, int index, void *data);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user