Merge pull request #711 from emersion/map-unmap
Add map/unmap to xdg-shell
This commit is contained in:
commit
09413aa7f1
|
@ -73,14 +73,16 @@ struct roots_output *desktop_output_from_wlr_output(
|
|||
struct roots_view *desktop_view_at(struct roots_desktop *desktop, double lx,
|
||||
double ly, struct wlr_surface **surface, double *sx, double *sy);
|
||||
|
||||
void view_init(struct roots_view *view, struct roots_desktop *desktop);
|
||||
void view_finish(struct roots_view *view);
|
||||
struct roots_view *view_create(struct roots_desktop *desktop);
|
||||
void view_destroy(struct roots_view *view);
|
||||
void view_activate(struct roots_view *view, bool activate);
|
||||
void view_apply_damage(struct roots_view *view);
|
||||
void view_damage_whole(struct roots_view *view);
|
||||
void view_update_position(struct roots_view *view, double x, double y);
|
||||
void view_update_size(struct roots_view *view, uint32_t width, uint32_t height);
|
||||
void view_initial_focus(struct roots_view *view);
|
||||
void view_map(struct roots_view *view, struct wlr_surface *surface);
|
||||
void view_unmap(struct roots_view *view);
|
||||
|
||||
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data);
|
||||
void handle_xdg_shell_surface(struct wl_listener *listener, void *data);
|
||||
|
|
|
@ -39,6 +39,7 @@ struct roots_seat_view {
|
|||
|
||||
struct wl_list link; // roots_seat::views
|
||||
|
||||
struct wl_listener view_unmap;
|
||||
struct wl_listener view_destroy;
|
||||
};
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ struct roots_xdg_surface_v6 {
|
|||
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener new_popup;
|
||||
struct wl_listener map;
|
||||
struct wl_listener unmap;
|
||||
struct wl_listener request_move;
|
||||
struct wl_listener request_resize;
|
||||
struct wl_listener request_maximize;
|
||||
|
@ -42,6 +44,8 @@ struct roots_xdg_surface {
|
|||
|
||||
struct wl_listener destroy;
|
||||
struct wl_listener new_popup;
|
||||
struct wl_listener map;
|
||||
struct wl_listener unmap;
|
||||
struct wl_listener request_move;
|
||||
struct wl_listener request_resize;
|
||||
struct wl_listener request_maximize;
|
||||
|
@ -128,6 +132,7 @@ struct roots_view {
|
|||
struct wl_listener new_subsurface;
|
||||
|
||||
struct {
|
||||
struct wl_signal unmap;
|
||||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
|
@ -140,6 +145,7 @@ struct roots_view {
|
|||
void (*maximize)(struct roots_view *view, bool maximized);
|
||||
void (*set_fullscreen)(struct roots_view *view, bool fullscreen);
|
||||
void (*close)(struct roots_view *view);
|
||||
void (*destroy)(struct roots_view *view);
|
||||
};
|
||||
|
||||
struct roots_view_child {
|
||||
|
@ -181,7 +187,6 @@ struct roots_xdg_popup {
|
|||
struct wl_listener new_popup;
|
||||
};
|
||||
|
||||
struct roots_view *view_create();
|
||||
void view_get_box(const struct roots_view *view, struct wlr_box *box);
|
||||
void view_activate(struct roots_view *view, bool active);
|
||||
void view_move(struct roots_view *view, double x, double y);
|
||||
|
|
|
@ -62,19 +62,10 @@ enum wlr_xdg_surface_role {
|
|||
};
|
||||
|
||||
struct wlr_xdg_toplevel_state {
|
||||
bool maximized;
|
||||
bool fullscreen;
|
||||
bool resizing;
|
||||
bool activated;
|
||||
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
|
||||
uint32_t max_width;
|
||||
uint32_t max_height;
|
||||
|
||||
uint32_t min_width;
|
||||
uint32_t min_height;
|
||||
bool maximized, fullscreen, resizing, activated;
|
||||
uint32_t width, height;
|
||||
uint32_t max_width, max_height;
|
||||
uint32_t min_width, min_height;
|
||||
};
|
||||
|
||||
struct wlr_xdg_toplevel {
|
||||
|
@ -90,7 +81,8 @@ struct wlr_xdg_toplevel {
|
|||
struct wlr_xdg_surface_configure {
|
||||
struct wl_list link; // wlr_xdg_surface::configure_list
|
||||
uint32_t serial;
|
||||
struct wlr_xdg_toplevel_state state;
|
||||
|
||||
struct wlr_xdg_toplevel_state *toplevel_state;
|
||||
};
|
||||
|
||||
struct wlr_xdg_surface {
|
||||
|
@ -101,14 +93,13 @@ struct wlr_xdg_surface {
|
|||
enum wlr_xdg_surface_role role;
|
||||
|
||||
union {
|
||||
struct wlr_xdg_toplevel *toplevel_state;
|
||||
struct wlr_xdg_popup *popup_state;
|
||||
struct wlr_xdg_toplevel *toplevel;
|
||||
struct wlr_xdg_popup *popup;
|
||||
};
|
||||
|
||||
struct wl_list popups; // wlr_xdg_popup::link
|
||||
|
||||
bool configured;
|
||||
bool added;
|
||||
bool added, configured, mapped;
|
||||
uint32_t configure_serial;
|
||||
struct wl_event_source *configure_idle;
|
||||
uint32_t configure_next_serial;
|
||||
|
@ -118,8 +109,8 @@ struct wlr_xdg_surface {
|
|||
char *app_id;
|
||||
|
||||
bool has_next_geometry;
|
||||
struct wlr_box *next_geometry;
|
||||
struct wlr_box *geometry;
|
||||
struct wlr_box next_geometry;
|
||||
struct wlr_box geometry;
|
||||
|
||||
struct wl_listener surface_destroy_listener;
|
||||
|
||||
|
@ -127,6 +118,8 @@ struct wlr_xdg_surface {
|
|||
struct wl_signal destroy;
|
||||
struct wl_signal ping_timeout;
|
||||
struct wl_signal new_popup;
|
||||
struct wl_signal map;
|
||||
struct wl_signal unmap;
|
||||
|
||||
struct wl_signal request_maximize;
|
||||
struct wl_signal request_fullscreen;
|
||||
|
|
|
@ -62,19 +62,10 @@ enum wlr_xdg_surface_v6_role {
|
|||
};
|
||||
|
||||
struct wlr_xdg_toplevel_v6_state {
|
||||
bool maximized;
|
||||
bool fullscreen;
|
||||
bool resizing;
|
||||
bool activated;
|
||||
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
|
||||
uint32_t max_width;
|
||||
uint32_t max_height;
|
||||
|
||||
uint32_t min_width;
|
||||
uint32_t min_height;
|
||||
bool maximized, fullscreen, resizing, activated;
|
||||
uint32_t width, height;
|
||||
uint32_t max_width, max_height;
|
||||
uint32_t min_width, min_height;
|
||||
};
|
||||
|
||||
struct wlr_xdg_toplevel_v6 {
|
||||
|
@ -90,7 +81,8 @@ struct wlr_xdg_toplevel_v6 {
|
|||
struct wlr_xdg_surface_v6_configure {
|
||||
struct wl_list link; // wlr_xdg_surface_v6::configure_list
|
||||
uint32_t serial;
|
||||
struct wlr_xdg_toplevel_v6_state state;
|
||||
|
||||
struct wlr_xdg_toplevel_v6_state *toplevel_state;
|
||||
};
|
||||
|
||||
struct wlr_xdg_surface_v6 {
|
||||
|
@ -101,14 +93,13 @@ struct wlr_xdg_surface_v6 {
|
|||
enum wlr_xdg_surface_v6_role role;
|
||||
|
||||
union {
|
||||
struct wlr_xdg_toplevel_v6 *toplevel_state;
|
||||
struct wlr_xdg_popup_v6 *popup_state;
|
||||
struct wlr_xdg_toplevel_v6 *toplevel;
|
||||
struct wlr_xdg_popup_v6 *popup;
|
||||
};
|
||||
|
||||
struct wl_list popups; // wlr_xdg_popup_v6::link
|
||||
|
||||
bool configured;
|
||||
bool added;
|
||||
bool added, configured, mapped;
|
||||
uint32_t configure_serial;
|
||||
struct wl_event_source *configure_idle;
|
||||
uint32_t configure_next_serial;
|
||||
|
@ -118,8 +109,8 @@ struct wlr_xdg_surface_v6 {
|
|||
char *app_id;
|
||||
|
||||
bool has_next_geometry;
|
||||
struct wlr_box *next_geometry;
|
||||
struct wlr_box *geometry;
|
||||
struct wlr_box next_geometry;
|
||||
struct wlr_box geometry;
|
||||
|
||||
struct wl_listener surface_destroy_listener;
|
||||
|
||||
|
@ -127,6 +118,8 @@ struct wlr_xdg_surface_v6 {
|
|||
struct wl_signal destroy;
|
||||
struct wl_signal ping_timeout;
|
||||
struct wl_signal new_popup;
|
||||
struct wl_signal map;
|
||||
struct wl_signal unmap;
|
||||
|
||||
struct wl_signal request_maximize;
|
||||
struct wl_signal request_fullscreen;
|
||||
|
|
|
@ -24,13 +24,16 @@
|
|||
#include "rootston/view.h"
|
||||
#include "rootston/xcursor.h"
|
||||
|
||||
|
||||
struct roots_view *view_create() {
|
||||
struct roots_view *view_create(struct roots_desktop *desktop) {
|
||||
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
||||
if (!view) {
|
||||
return NULL;
|
||||
}
|
||||
view->desktop = desktop;
|
||||
view->alpha = 1.0f;
|
||||
wl_signal_init(&view->events.unmap);
|
||||
wl_signal_init(&view->events.destroy);
|
||||
wl_list_init(&view->children);
|
||||
return view;
|
||||
}
|
||||
|
||||
|
@ -53,7 +56,8 @@ void view_get_deco_box(const struct roots_view *view, struct wlr_box *box) {
|
|||
box->height += (view->border_width * 2 + view->titlebar_height);
|
||||
}
|
||||
|
||||
enum roots_deco_part view_get_deco_part(struct roots_view *view, double sx, double sy) {
|
||||
enum roots_deco_part view_get_deco_part(struct roots_view *view, double sx,
|
||||
double sy) {
|
||||
if (!view->decorated) {
|
||||
return ROOTS_DECO_PART_NONE;
|
||||
}
|
||||
|
@ -93,9 +97,15 @@ enum roots_deco_part view_get_deco_part(struct roots_view *view, double sx, doub
|
|||
static void view_update_output(const struct roots_view *view,
|
||||
const struct wlr_box *before) {
|
||||
struct roots_desktop *desktop = view->desktop;
|
||||
struct roots_output *output;
|
||||
|
||||
if (view->wlr_surface == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct wlr_box box;
|
||||
view_get_box(view, &box);
|
||||
|
||||
struct roots_output *output;
|
||||
wl_list_for_each(output, &desktop->outputs, link) {
|
||||
bool intersected = before != NULL && wlr_output_layout_intersects(
|
||||
desktop->layout, output->wlr_output, before);
|
||||
|
@ -403,20 +413,22 @@ struct roots_subsurface *subsurface_create(struct roots_view *view,
|
|||
return subsurface;
|
||||
}
|
||||
|
||||
void view_finish(struct roots_view *view) {
|
||||
view_damage_whole(view);
|
||||
void view_destroy(struct roots_view *view) {
|
||||
if (view == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
wl_signal_emit(&view->events.destroy, view);
|
||||
|
||||
wl_list_remove(&view->new_subsurface.link);
|
||||
|
||||
struct roots_view_child *child, *tmp;
|
||||
wl_list_for_each_safe(child, tmp, &view->children, link) {
|
||||
child->destroy(child);
|
||||
if (view->wlr_surface != NULL) {
|
||||
view_unmap(view);
|
||||
}
|
||||
|
||||
if (view->fullscreen_output) {
|
||||
view->fullscreen_output->fullscreen_view = NULL;
|
||||
if (view->destroy) {
|
||||
view->destroy(view);
|
||||
}
|
||||
|
||||
free(view);
|
||||
}
|
||||
|
||||
static void view_handle_new_subsurface(struct wl_listener *listener,
|
||||
|
@ -426,12 +438,10 @@ static void view_handle_new_subsurface(struct wl_listener *listener,
|
|||
subsurface_create(view, wlr_subsurface);
|
||||
}
|
||||
|
||||
void view_init(struct roots_view *view, struct roots_desktop *desktop) {
|
||||
assert(view->wlr_surface);
|
||||
void view_map(struct roots_view *view, struct wlr_surface *surface) {
|
||||
assert(view->wlr_surface == NULL);
|
||||
|
||||
view->desktop = desktop;
|
||||
wl_signal_init(&view->events.destroy);
|
||||
wl_list_init(&view->children);
|
||||
view->wlr_surface = surface;
|
||||
|
||||
struct wlr_subsurface *subsurface;
|
||||
wl_list_for_each(subsurface, &view->wlr_surface->subsurface_list,
|
||||
|
@ -443,9 +453,35 @@ void view_init(struct roots_view *view, struct roots_desktop *desktop) {
|
|||
wl_signal_add(&view->wlr_surface->events.new_subsurface,
|
||||
&view->new_subsurface);
|
||||
|
||||
wl_list_insert(&view->desktop->views, &view->link);
|
||||
view_damage_whole(view);
|
||||
}
|
||||
|
||||
void view_unmap(struct roots_view *view) {
|
||||
assert(view->wlr_surface != NULL);
|
||||
|
||||
wl_signal_emit(&view->events.unmap, view);
|
||||
|
||||
view_damage_whole(view);
|
||||
wl_list_remove(&view->link);
|
||||
|
||||
wl_list_remove(&view->new_subsurface.link);
|
||||
|
||||
struct roots_view_child *child, *tmp;
|
||||
wl_list_for_each_safe(child, tmp, &view->children, link) {
|
||||
child->destroy(child);
|
||||
}
|
||||
|
||||
if (view->fullscreen_output != NULL) {
|
||||
output_damage_whole(view->fullscreen_output);
|
||||
view->fullscreen_output->fullscreen_view = NULL;
|
||||
view->fullscreen_output = NULL;
|
||||
}
|
||||
|
||||
view->wlr_surface = NULL;
|
||||
view->width = view->height = 0;
|
||||
}
|
||||
|
||||
void view_initial_focus(struct roots_view *view) {
|
||||
struct roots_input *input = view->desktop->server->input;
|
||||
// TODO what seat gets focus? the one with the last input event?
|
||||
|
@ -458,7 +494,10 @@ void view_initial_focus(struct roots_view *view) {
|
|||
void view_setup(struct roots_view *view) {
|
||||
view_initial_focus(view);
|
||||
|
||||
view_center(view);
|
||||
if (view->fullscreen_output == NULL && !view->maximized) {
|
||||
view_center(view);
|
||||
}
|
||||
|
||||
view_update_output(view, NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -433,7 +433,8 @@ static void render_output(struct roots_output *output) {
|
|||
float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f};
|
||||
|
||||
// Check if we can delegate the fullscreen surface to the output
|
||||
if (output->fullscreen_view != NULL) {
|
||||
if (output->fullscreen_view != NULL &&
|
||||
output->fullscreen_view->wlr_surface != NULL) {
|
||||
struct roots_view *view = output->fullscreen_view;
|
||||
|
||||
// Make sure the view is centered on screen
|
||||
|
@ -501,7 +502,9 @@ static void render_output(struct roots_output *output) {
|
|||
goto renderer_end;
|
||||
}
|
||||
|
||||
view_for_each_surface(view, render_surface, &data);
|
||||
if (view->wlr_surface != NULL) {
|
||||
view_for_each_surface(view, render_surface, &data);
|
||||
}
|
||||
|
||||
// During normal rendering the xwayland window tree isn't traversed
|
||||
// because all windows are rendered. Here we only want to render
|
||||
|
@ -570,6 +573,9 @@ void output_damage_whole(struct roots_output *output) {
|
|||
|
||||
static bool view_accept_damage(struct roots_output *output,
|
||||
struct roots_view *view) {
|
||||
if (view->wlr_surface == NULL) {
|
||||
return false;
|
||||
}
|
||||
if (output->fullscreen_view == NULL) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -645,6 +645,7 @@ static void seat_view_destroy(struct roots_seat_view *seat_view) {
|
|||
seat->cursor->pointer_view = NULL;
|
||||
}
|
||||
|
||||
wl_list_remove(&seat_view->view_unmap.link);
|
||||
wl_list_remove(&seat_view->view_destroy.link);
|
||||
wl_list_remove(&seat_view->link);
|
||||
free(seat_view);
|
||||
|
@ -657,6 +658,12 @@ static void seat_view_destroy(struct roots_seat_view *seat_view) {
|
|||
}
|
||||
}
|
||||
|
||||
static void seat_view_handle_unmap(struct wl_listener *listener, void *data) {
|
||||
struct roots_seat_view *seat_view =
|
||||
wl_container_of(listener, seat_view, view_unmap);
|
||||
seat_view_destroy(seat_view);
|
||||
}
|
||||
|
||||
static void seat_view_handle_destroy(struct wl_listener *listener, void *data) {
|
||||
struct roots_seat_view *seat_view =
|
||||
wl_container_of(listener, seat_view, view_destroy);
|
||||
|
@ -675,6 +682,8 @@ static struct roots_seat_view *seat_add_view(struct roots_seat *seat,
|
|||
|
||||
wl_list_insert(seat->views.prev, &seat_view->link);
|
||||
|
||||
seat_view->view_unmap.notify = seat_view_handle_unmap;
|
||||
wl_signal_add(&view->events.unmap, &seat_view->view_unmap);
|
||||
seat_view->view_destroy.notify = seat_view_handle_destroy;
|
||||
wl_signal_add(&view->events.destroy, &seat_view->view_destroy);
|
||||
|
||||
|
|
|
@ -78,6 +78,19 @@ static void close(struct roots_view *view) {
|
|||
wl_client_destroy(surf->client);
|
||||
}
|
||||
|
||||
static void destroy(struct roots_view *view) {
|
||||
assert(view->type == ROOTS_WL_SHELL_VIEW);
|
||||
struct roots_wl_shell_surface *roots_surface = view->roots_wl_shell_surface;
|
||||
wl_list_remove(&roots_surface->destroy.link);
|
||||
wl_list_remove(&roots_surface->request_move.link);
|
||||
wl_list_remove(&roots_surface->request_resize.link);
|
||||
wl_list_remove(&roots_surface->request_maximize.link);
|
||||
wl_list_remove(&roots_surface->request_fullscreen.link);
|
||||
wl_list_remove(&roots_surface->set_state.link);
|
||||
wl_list_remove(&roots_surface->surface_commit.link);
|
||||
free(roots_surface);
|
||||
}
|
||||
|
||||
static void handle_request_move(struct wl_listener *listener, void *data) {
|
||||
struct roots_wl_shell_surface *roots_surface =
|
||||
wl_container_of(listener, roots_surface, request_move);
|
||||
|
@ -174,17 +187,7 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
|
|||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||
struct roots_wl_shell_surface *roots_surface =
|
||||
wl_container_of(listener, roots_surface, destroy);
|
||||
wl_list_remove(&roots_surface->destroy.link);
|
||||
wl_list_remove(&roots_surface->request_move.link);
|
||||
wl_list_remove(&roots_surface->request_resize.link);
|
||||
wl_list_remove(&roots_surface->request_maximize.link);
|
||||
wl_list_remove(&roots_surface->request_fullscreen.link);
|
||||
wl_list_remove(&roots_surface->set_state.link);
|
||||
wl_list_remove(&roots_surface->surface_commit.link);
|
||||
wl_list_remove(&roots_surface->view->link);
|
||||
view_finish(roots_surface->view);
|
||||
free(roots_surface->view);
|
||||
free(roots_surface);
|
||||
view_destroy(roots_surface->view);
|
||||
}
|
||||
|
||||
void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
||||
|
@ -227,7 +230,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
|||
roots_surface->surface_commit.notify = handle_surface_commit;
|
||||
wl_signal_add(&surface->surface->events.commit, &roots_surface->surface_commit);
|
||||
|
||||
struct roots_view *view = view_create();
|
||||
struct roots_view *view = view_create(desktop);
|
||||
if (!view) {
|
||||
free(roots_surface);
|
||||
return;
|
||||
|
@ -238,13 +241,12 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
|||
|
||||
view->wl_shell_surface = surface;
|
||||
view->roots_wl_shell_surface = roots_surface;
|
||||
view->wlr_surface = surface->surface;
|
||||
view->resize = resize;
|
||||
view->close = close;
|
||||
view->destroy = destroy;
|
||||
roots_surface->view = view;
|
||||
view_init(view, desktop);
|
||||
wl_list_insert(&desktop->views, &view->link);
|
||||
|
||||
view_map(view, surface->surface);
|
||||
view_setup(view);
|
||||
|
||||
if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) {
|
||||
|
|
|
@ -60,12 +60,14 @@ static void get_size(const struct roots_view *view, struct wlr_box *box) {
|
|||
assert(view->type == ROOTS_XDG_SHELL_VIEW);
|
||||
struct wlr_xdg_surface *surface = view->xdg_surface;
|
||||
|
||||
if (surface->geometry->width > 0 && surface->geometry->height > 0) {
|
||||
box->width = surface->geometry->width;
|
||||
box->height = surface->geometry->height;
|
||||
} else {
|
||||
if (surface->geometry.width > 0 && surface->geometry.height > 0) {
|
||||
box->width = surface->geometry.width;
|
||||
box->height = surface->geometry.height;
|
||||
} else if (view->wlr_surface != NULL) {
|
||||
box->width = view->wlr_surface->current->width;
|
||||
box->height = view->wlr_surface->current->height;
|
||||
} else {
|
||||
box->width = box->height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +85,7 @@ static void apply_size_constraints(struct wlr_xdg_surface *surface,
|
|||
*dest_width = width;
|
||||
*dest_height = height;
|
||||
|
||||
struct wlr_xdg_toplevel_state *state = &surface->toplevel_state->current;
|
||||
struct wlr_xdg_toplevel_state *state = &surface->toplevel->current;
|
||||
if (width < state->min_width) {
|
||||
*dest_width = state->min_width;
|
||||
} else if (state->max_width > 0 &&
|
||||
|
@ -180,6 +182,21 @@ static void close(struct roots_view *view) {
|
|||
}
|
||||
}
|
||||
|
||||
static void destroy(struct roots_view *view) {
|
||||
assert(view->type == ROOTS_XDG_SHELL_VIEW);
|
||||
struct roots_xdg_surface *roots_xdg_surface = view->roots_xdg_surface;
|
||||
wl_list_remove(&roots_xdg_surface->surface_commit.link);
|
||||
wl_list_remove(&roots_xdg_surface->destroy.link);
|
||||
wl_list_remove(&roots_xdg_surface->new_popup.link);
|
||||
wl_list_remove(&roots_xdg_surface->map.link);
|
||||
wl_list_remove(&roots_xdg_surface->unmap.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_move.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_resize.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_maximize.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
|
||||
free(roots_xdg_surface);
|
||||
}
|
||||
|
||||
static void handle_request_move(struct wl_listener *listener, void *data) {
|
||||
struct roots_xdg_surface *roots_xdg_surface =
|
||||
wl_container_of(listener, roots_xdg_surface, request_move);
|
||||
|
@ -219,7 +236,7 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) {
|
|||
return;
|
||||
}
|
||||
|
||||
view_maximize(view, surface->toplevel_state->next.maximized);
|
||||
view_maximize(view, surface->toplevel->next.maximized);
|
||||
}
|
||||
|
||||
static void handle_request_fullscreen(struct wl_listener *listener,
|
||||
|
@ -243,6 +260,10 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
|||
struct roots_view *view = roots_surface->view;
|
||||
struct wlr_xdg_surface *surface = view->xdg_surface;
|
||||
|
||||
if (!surface->mapped) {
|
||||
return;
|
||||
}
|
||||
|
||||
view_apply_damage(view);
|
||||
|
||||
struct wlr_box size;
|
||||
|
@ -277,20 +298,30 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
|
|||
popup_create(roots_xdg_surface->view, wlr_popup);
|
||||
}
|
||||
|
||||
static void handle_map(struct wl_listener *listener, void *data) {
|
||||
struct roots_xdg_surface *roots_xdg_surface =
|
||||
wl_container_of(listener, roots_xdg_surface, map);
|
||||
struct roots_view *view = roots_xdg_surface->view;
|
||||
|
||||
struct wlr_box box;
|
||||
get_size(view, &box);
|
||||
view->width = box.width;
|
||||
view->height = box.height;
|
||||
|
||||
view_map(view, view->xdg_surface->surface);
|
||||
view_setup(view);
|
||||
}
|
||||
|
||||
static void handle_unmap(struct wl_listener *listener, void *data) {
|
||||
struct roots_xdg_surface *roots_xdg_surface =
|
||||
wl_container_of(listener, roots_xdg_surface, unmap);
|
||||
view_unmap(roots_xdg_surface->view);
|
||||
}
|
||||
|
||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||
struct roots_xdg_surface *roots_xdg_surface =
|
||||
wl_container_of(listener, roots_xdg_surface, destroy);
|
||||
wl_list_remove(&roots_xdg_surface->surface_commit.link);
|
||||
wl_list_remove(&roots_xdg_surface->destroy.link);
|
||||
wl_list_remove(&roots_xdg_surface->new_popup.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_move.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_resize.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_maximize.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
|
||||
wl_list_remove(&roots_xdg_surface->view->link);
|
||||
view_finish(roots_xdg_surface->view);
|
||||
free(roots_xdg_surface->view);
|
||||
free(roots_xdg_surface);
|
||||
view_destroy(roots_xdg_surface->view);
|
||||
}
|
||||
|
||||
void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
||||
|
@ -319,6 +350,10 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
|||
&roots_surface->surface_commit);
|
||||
roots_surface->destroy.notify = handle_destroy;
|
||||
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
|
||||
roots_surface->map.notify = handle_map;
|
||||
wl_signal_add(&surface->events.map, &roots_surface->map);
|
||||
roots_surface->unmap.notify = handle_unmap;
|
||||
wl_signal_add(&surface->events.unmap, &roots_surface->unmap);
|
||||
roots_surface->request_move.notify = handle_request_move;
|
||||
wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
|
||||
roots_surface->request_resize.notify = handle_request_resize;
|
||||
|
@ -333,7 +368,7 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
|||
roots_surface->new_popup.notify = handle_new_popup;
|
||||
wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
|
||||
|
||||
struct roots_view *view = view_create();
|
||||
struct roots_view *view = view_create(desktop);
|
||||
if (!view) {
|
||||
free(roots_surface);
|
||||
return;
|
||||
|
@ -342,22 +377,19 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
|||
|
||||
view->xdg_surface = surface;
|
||||
view->roots_xdg_surface = roots_surface;
|
||||
view->wlr_surface = surface->surface;
|
||||
view->activate = activate;
|
||||
view->resize = resize;
|
||||
view->move_resize = move_resize;
|
||||
view->maximize = maximize;
|
||||
view->set_fullscreen = set_fullscreen;
|
||||
view->close = close;
|
||||
view->destroy = destroy;
|
||||
roots_surface->view = view;
|
||||
|
||||
struct wlr_box box;
|
||||
get_size(view, &box);
|
||||
view->width = box.width;
|
||||
view->height = box.height;
|
||||
|
||||
view_init(view, desktop);
|
||||
wl_list_insert(&desktop->views, &view->link);
|
||||
|
||||
view_setup(view);
|
||||
if (surface->toplevel->next.maximized) {
|
||||
view_maximize(view, true);
|
||||
}
|
||||
if (surface->toplevel->next.fullscreen) {
|
||||
view_set_fullscreen(view, true, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,12 +60,14 @@ static void get_size(const struct roots_view *view, struct wlr_box *box) {
|
|||
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
||||
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
||||
|
||||
if (surface->geometry->width > 0 && surface->geometry->height > 0) {
|
||||
box->width = surface->geometry->width;
|
||||
box->height = surface->geometry->height;
|
||||
} else {
|
||||
if (surface->geometry.width > 0 && surface->geometry.height > 0) {
|
||||
box->width = surface->geometry.width;
|
||||
box->height = surface->geometry.height;
|
||||
} else if (view->wlr_surface != NULL) {
|
||||
box->width = view->wlr_surface->current->width;
|
||||
box->height = view->wlr_surface->current->height;
|
||||
} else {
|
||||
box->width = box->height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +85,7 @@ static void apply_size_constraints(struct wlr_xdg_surface_v6 *surface,
|
|||
*dest_width = width;
|
||||
*dest_height = height;
|
||||
|
||||
struct wlr_xdg_toplevel_v6_state *state = &surface->toplevel_state->current;
|
||||
struct wlr_xdg_toplevel_v6_state *state = &surface->toplevel->current;
|
||||
if (width < state->min_width) {
|
||||
*dest_width = state->min_width;
|
||||
} else if (state->max_width > 0 &&
|
||||
|
@ -180,6 +182,21 @@ static void close(struct roots_view *view) {
|
|||
}
|
||||
}
|
||||
|
||||
static void destroy(struct roots_view *view) {
|
||||
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
||||
struct roots_xdg_surface_v6 *roots_xdg_surface = view->roots_xdg_surface_v6;
|
||||
wl_list_remove(&roots_xdg_surface->surface_commit.link);
|
||||
wl_list_remove(&roots_xdg_surface->destroy.link);
|
||||
wl_list_remove(&roots_xdg_surface->new_popup.link);
|
||||
wl_list_remove(&roots_xdg_surface->map.link);
|
||||
wl_list_remove(&roots_xdg_surface->unmap.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_move.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_resize.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_maximize.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
|
||||
free(roots_xdg_surface);
|
||||
}
|
||||
|
||||
static void handle_request_move(struct wl_listener *listener, void *data) {
|
||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||
wl_container_of(listener, roots_xdg_surface, request_move);
|
||||
|
@ -219,7 +236,7 @@ static void handle_request_maximize(struct wl_listener *listener, void *data) {
|
|||
return;
|
||||
}
|
||||
|
||||
view_maximize(view, surface->toplevel_state->next.maximized);
|
||||
view_maximize(view, surface->toplevel->next.maximized);
|
||||
}
|
||||
|
||||
static void handle_request_fullscreen(struct wl_listener *listener,
|
||||
|
@ -243,6 +260,10 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
|||
struct roots_view *view = roots_surface->view;
|
||||
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
||||
|
||||
if (!surface->mapped) {
|
||||
return;
|
||||
}
|
||||
|
||||
view_apply_damage(view);
|
||||
|
||||
struct wlr_box size;
|
||||
|
@ -277,20 +298,30 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
|
|||
popup_create(roots_xdg_surface->view, wlr_popup);
|
||||
}
|
||||
|
||||
static void handle_map(struct wl_listener *listener, void *data) {
|
||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||
wl_container_of(listener, roots_xdg_surface, map);
|
||||
struct roots_view *view = roots_xdg_surface->view;
|
||||
|
||||
struct wlr_box box;
|
||||
get_size(view, &box);
|
||||
view->width = box.width;
|
||||
view->height = box.height;
|
||||
|
||||
view_map(view, view->xdg_surface_v6->surface);
|
||||
view_setup(view);
|
||||
}
|
||||
|
||||
static void handle_unmap(struct wl_listener *listener, void *data) {
|
||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||
wl_container_of(listener, roots_xdg_surface, unmap);
|
||||
view_unmap(roots_xdg_surface->view);
|
||||
}
|
||||
|
||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||
wl_container_of(listener, roots_xdg_surface, destroy);
|
||||
wl_list_remove(&roots_xdg_surface->surface_commit.link);
|
||||
wl_list_remove(&roots_xdg_surface->destroy.link);
|
||||
wl_list_remove(&roots_xdg_surface->new_popup.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_move.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_resize.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_maximize.link);
|
||||
wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
|
||||
wl_list_remove(&roots_xdg_surface->view->link);
|
||||
view_finish(roots_xdg_surface->view);
|
||||
free(roots_xdg_surface->view);
|
||||
free(roots_xdg_surface);
|
||||
view_destroy(roots_xdg_surface->view);
|
||||
}
|
||||
|
||||
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||
|
@ -319,6 +350,10 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
|||
&roots_surface->surface_commit);
|
||||
roots_surface->destroy.notify = handle_destroy;
|
||||
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
|
||||
roots_surface->map.notify = handle_map;
|
||||
wl_signal_add(&surface->events.map, &roots_surface->map);
|
||||
roots_surface->unmap.notify = handle_unmap;
|
||||
wl_signal_add(&surface->events.unmap, &roots_surface->unmap);
|
||||
roots_surface->request_move.notify = handle_request_move;
|
||||
wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
|
||||
roots_surface->request_resize.notify = handle_request_resize;
|
||||
|
@ -333,7 +368,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
|||
roots_surface->new_popup.notify = handle_new_popup;
|
||||
wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
|
||||
|
||||
struct roots_view *view = view_create();
|
||||
struct roots_view *view = view_create(desktop);
|
||||
if (!view) {
|
||||
free(roots_surface);
|
||||
return;
|
||||
|
@ -342,22 +377,19 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
|||
|
||||
view->xdg_surface_v6 = surface;
|
||||
view->roots_xdg_surface_v6 = roots_surface;
|
||||
view->wlr_surface = surface->surface;
|
||||
view->activate = activate;
|
||||
view->resize = resize;
|
||||
view->move_resize = move_resize;
|
||||
view->maximize = maximize;
|
||||
view->set_fullscreen = set_fullscreen;
|
||||
view->close = close;
|
||||
view->destroy = destroy;
|
||||
roots_surface->view = view;
|
||||
|
||||
struct wlr_box box;
|
||||
get_size(view, &box);
|
||||
view->width = box.width;
|
||||
view->height = box.height;
|
||||
|
||||
view_init(view, desktop);
|
||||
wl_list_insert(&desktop->views, &view->link);
|
||||
|
||||
view_setup(view);
|
||||
if (surface->toplevel->next.maximized) {
|
||||
view_maximize(view, true);
|
||||
}
|
||||
if (surface->toplevel->next.fullscreen) {
|
||||
view_set_fullscreen(view, true, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,11 +106,9 @@ static void set_fullscreen(struct roots_view *view, bool fullscreen) {
|
|||
wlr_xwayland_surface_set_fullscreen(view->xwayland_surface, fullscreen);
|
||||
}
|
||||
|
||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||
struct roots_xwayland_surface *roots_surface =
|
||||
wl_container_of(listener, roots_surface, destroy);
|
||||
struct wlr_xwayland_surface *xwayland_surface =
|
||||
roots_surface->view->xwayland_surface;
|
||||
static void destroy(struct roots_view *view) {
|
||||
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
||||
struct roots_xwayland_surface *roots_surface = view->roots_xwayland_surface;
|
||||
wl_list_remove(&roots_surface->destroy.link);
|
||||
wl_list_remove(&roots_surface->request_configure.link);
|
||||
wl_list_remove(&roots_surface->request_move.link);
|
||||
|
@ -118,14 +116,15 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
|||
wl_list_remove(&roots_surface->request_maximize.link);
|
||||
wl_list_remove(&roots_surface->map_notify.link);
|
||||
wl_list_remove(&roots_surface->unmap_notify.link);
|
||||
if (xwayland_surface->mapped) {
|
||||
wl_list_remove(&roots_surface->view->link);
|
||||
}
|
||||
view_finish(roots_surface->view);
|
||||
free(roots_surface->view);
|
||||
free(roots_surface);
|
||||
}
|
||||
|
||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||
struct roots_xwayland_surface *roots_surface =
|
||||
wl_container_of(listener, roots_surface, destroy);
|
||||
view_destroy(roots_surface->view);
|
||||
}
|
||||
|
||||
static void handle_request_configure(struct wl_listener *listener, void *data) {
|
||||
struct roots_xwayland_surface *roots_surface =
|
||||
wl_container_of(listener, roots_surface, request_configure);
|
||||
|
@ -231,22 +230,13 @@ static void handle_map_notify(struct wl_listener *listener, void *data) {
|
|||
wl_container_of(listener, roots_surface, map_notify);
|
||||
struct wlr_xwayland_surface *xsurface = data;
|
||||
struct roots_view *view = roots_surface->view;
|
||||
struct roots_desktop *desktop = view->desktop;
|
||||
|
||||
view->wlr_surface = xsurface->surface;
|
||||
view->x = xsurface->x;
|
||||
view->y = xsurface->y;
|
||||
view->width = xsurface->surface->current->width;
|
||||
view->height = xsurface->surface->current->height;
|
||||
wl_list_insert(&desktop->views, &view->link);
|
||||
|
||||
struct wlr_subsurface *subsurface;
|
||||
wl_list_for_each(subsurface, &view->wlr_surface->subsurface_list,
|
||||
parent_link) {
|
||||
subsurface_create(view, subsurface);
|
||||
}
|
||||
|
||||
view_damage_whole(view);
|
||||
view_map(view, xsurface->surface);
|
||||
|
||||
roots_surface->surface_commit.notify = handle_surface_commit;
|
||||
wl_signal_add(&xsurface->surface->events.commit,
|
||||
|
@ -260,22 +250,7 @@ static void handle_unmap_notify(struct wl_listener *listener, void *data) {
|
|||
|
||||
wl_list_remove(&roots_surface->surface_commit.link);
|
||||
|
||||
view_damage_whole(view);
|
||||
|
||||
struct roots_view_child *child, *tmp;
|
||||
wl_list_for_each_safe(child, tmp, &view->children, link) {
|
||||
child->destroy(child);
|
||||
}
|
||||
|
||||
if (view->fullscreen_output != NULL) {
|
||||
output_damage_whole(view->fullscreen_output);
|
||||
view->fullscreen_output->fullscreen_view = NULL;
|
||||
view->fullscreen_output = NULL;
|
||||
}
|
||||
|
||||
view->wlr_surface = NULL;
|
||||
view->width = view->height = 0;
|
||||
wl_list_remove(&view->link);
|
||||
view_unmap(view);
|
||||
}
|
||||
|
||||
void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||
|
@ -317,7 +292,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
|||
wl_signal_add(&surface->surface->events.commit,
|
||||
&roots_surface->surface_commit);
|
||||
|
||||
struct roots_view *view = view_create();
|
||||
struct roots_view *view = view_create(desktop);
|
||||
if (view == NULL) {
|
||||
free(roots_surface);
|
||||
return;
|
||||
|
@ -330,7 +305,6 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
|||
|
||||
view->xwayland_surface = surface;
|
||||
view->roots_xwayland_surface = roots_surface;
|
||||
view->wlr_surface = surface->surface;
|
||||
view->activate = activate;
|
||||
view->resize = resize;
|
||||
view->move = move;
|
||||
|
@ -338,9 +312,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
|||
view->maximize = maximize;
|
||||
view->set_fullscreen = set_fullscreen;
|
||||
view->close = close;
|
||||
view->destroy = destroy;
|
||||
roots_surface->view = view;
|
||||
view_init(view, desktop);
|
||||
wl_list_insert(&desktop->views, &view->link);
|
||||
|
||||
view_map(view, surface->surface);
|
||||
|
||||
if (!surface->override_redirect) {
|
||||
if (surface->decorations == WLR_XWAYLAND_SURFACE_DECORATIONS_ALL) {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue