Enable backgrounds and panels to be shell surfaces

Prior to this commit all windows (e.g. shell surfaces) were handled the same
way in handle_view_created. Since backgrounds and panels have to be treated
differently, they could not be shell surfaces. This changes checks whether
a client is a background or a panel in handle_view_created and exists to
let them be dealt with elsewhere.
master
David Eklov 9 years ago
parent 2f54057623
commit 51204b33c1

@ -11,6 +11,8 @@ struct background_config {
wlc_resource surface; wlc_resource surface;
// we need the wl_resource of the surface in the destructor // we need the wl_resource of the surface in the destructor
struct wl_resource *wl_surface_res; struct wl_resource *wl_surface_res;
// used to determine if client is a background
struct wl_client *client;
}; };
struct panel_config { struct panel_config {
@ -21,6 +23,8 @@ struct panel_config {
// we need the wl_resource of the surface in the destructor // we need the wl_resource of the surface in the destructor
struct wl_resource *wl_surface_res; struct wl_resource *wl_surface_res;
enum desktop_shell_panel_position panel_position; enum desktop_shell_panel_position panel_position;
// used to determine if client is a panel
struct wl_client *client;
}; };
struct desktop_shell_state { struct desktop_shell_state {

@ -73,6 +73,7 @@ static void set_background(struct wl_client *client, struct wl_resource *resourc
} }
sway_log(L_DEBUG, "Setting surface %p as background for output %d", surface, (int)output); sway_log(L_DEBUG, "Setting surface %p as background for output %d", surface, (int)output);
struct background_config *config = malloc(sizeof(struct background_config)); struct background_config *config = malloc(sizeof(struct background_config));
config->client = client;
config->output = output; config->output = output;
config->surface = wlc_resource_from_wl_surface_resource(surface); config->surface = wlc_resource_from_wl_surface_resource(surface);
config->wl_surface_res = surface; config->wl_surface_res = surface;
@ -91,6 +92,7 @@ static void set_panel(struct wl_client *client, struct wl_resource *resource,
sway_log(L_DEBUG, "Setting surface %p as panel for output %d (wl_resource: %p)", surface, (int)output, resource); sway_log(L_DEBUG, "Setting surface %p as panel for output %d (wl_resource: %p)", surface, (int)output, resource);
struct panel_config *config = find_or_create_panel_config(resource); struct panel_config *config = find_or_create_panel_config(resource);
config->output = output; config->output = output;
config->client = client;
config->surface = wlc_resource_from_wl_surface_resource(surface); config->surface = wlc_resource_from_wl_surface_resource(surface);
config->wl_surface_res = surface; config->wl_surface_res = surface;
wl_resource_set_destructor(surface, panel_surface_destructor); wl_resource_set_destructor(surface, panel_surface_destructor);

@ -176,6 +176,28 @@ static void handle_output_focused(wlc_handle output, bool focus) {
} }
} }
static bool client_is_background(struct wl_client *client) {
int i;
for (i = 0; i < desktop_shell.backgrounds->length; i++) {
struct background_config *config = desktop_shell.backgrounds->items[i];
if (config->client == client) {
return true;
}
}
return false;
}
static bool client_is_panel(struct wl_client *client) {
int i;
for (i = 0; i < desktop_shell.panels->length; i++) {
struct panel_config *config = desktop_shell.panels->items[i];
if (config->client == client) {
return true;
}
}
return false;
}
static bool handle_view_created(wlc_handle handle) { static bool handle_view_created(wlc_handle handle) {
// if view is child of another view, the use that as focused container // if view is child of another view, the use that as focused container
wlc_handle parent = wlc_view_get_parent(handle); wlc_handle parent = wlc_view_get_parent(handle);
@ -186,6 +208,10 @@ static bool handle_view_created(wlc_handle handle) {
struct wl_client *client = wlc_view_get_wl_client(handle); struct wl_client *client = wlc_view_get_wl_client(handle);
pid_t pid; pid_t pid;
if (client_is_background(client) || client_is_panel(client)) {
return true;
}
// Get parent container, to add view in // Get parent container, to add view in
if (parent) { if (parent) {
focused = swayc_by_handle(parent); focused = swayc_by_handle(parent);

Loading…
Cancel
Save