Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chase wlroots xdg-shell refactor #6664

Merged
merged 1 commit into from
Feb 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions sway/desktop/xdg_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ static uint32_t configure(struct sway_view *view, double lx, double ly,
if (xdg_shell_view == NULL) {
return 0;
}
return wlr_xdg_toplevel_set_size(view->wlr_xdg_surface, width, height);
return wlr_xdg_toplevel_set_size(view->wlr_xdg_surface->toplevel,
width, height);
}

static void set_activated(struct sway_view *view, bool activated) {
Expand All @@ -157,7 +158,7 @@ static void set_activated(struct sway_view *view, bool activated) {
}
struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
wlr_xdg_toplevel_set_activated(surface, activated);
wlr_xdg_toplevel_set_activated(surface->toplevel, activated);
}
}

Expand All @@ -171,23 +172,23 @@ static void set_tiled(struct sway_view *view, bool tiled) {
edges = WLR_EDGE_LEFT | WLR_EDGE_RIGHT | WLR_EDGE_TOP |
WLR_EDGE_BOTTOM;
}
wlr_xdg_toplevel_set_tiled(surface, edges);
wlr_xdg_toplevel_set_tiled(surface->toplevel, edges);
}

static void set_fullscreen(struct sway_view *view, bool fullscreen) {
if (xdg_shell_view_from_view(view) == NULL) {
return;
}
struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
wlr_xdg_toplevel_set_fullscreen(surface, fullscreen);
wlr_xdg_toplevel_set_fullscreen(surface->toplevel, fullscreen);
}

static void set_resizing(struct sway_view *view, bool resizing) {
if (xdg_shell_view_from_view(view) == NULL) {
return;
}
struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
wlr_xdg_toplevel_set_resizing(surface, resizing);
wlr_xdg_toplevel_set_resizing(surface->toplevel, resizing);
}

static bool wants_floating(struct sway_view *view) {
Expand Down Expand Up @@ -222,12 +223,12 @@ static bool is_transient_for(struct sway_view *child,
if (xdg_shell_view_from_view(child) == NULL) {
return false;
}
struct wlr_xdg_surface *surface = child->wlr_xdg_surface;
while (surface && surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
if (surface->toplevel->parent == ancestor->wlr_xdg_surface) {
struct wlr_xdg_toplevel *toplevel = child->wlr_xdg_surface->toplevel;
while (toplevel) {
if (toplevel->parent == ancestor->wlr_xdg_surface->toplevel) {
return true;
}
surface = surface->toplevel->parent;
toplevel = toplevel->parent;
}
return false;
}
Expand All @@ -239,14 +240,14 @@ static void _close(struct sway_view *view) {
struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL
&& surface->toplevel) {
wlr_xdg_toplevel_send_close(surface);
wlr_xdg_toplevel_send_close(surface->toplevel);
}
}

static void close_popups(struct sway_view *view) {
struct wlr_xdg_popup *popup, *tmp;
wl_list_for_each_safe(popup, tmp, &view->wlr_xdg_surface->popups, link) {
wlr_xdg_popup_destroy(popup->base);
wlr_xdg_popup_destroy(popup);
}
}

Expand Down Expand Up @@ -337,7 +338,6 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
static void handle_request_fullscreen(struct wl_listener *listener, void *data) {
struct sway_xdg_shell_view *xdg_shell_view =
wl_container_of(listener, xdg_shell_view, request_fullscreen);
struct wlr_xdg_toplevel_set_fullscreen_event *e = data;
struct wlr_xdg_surface *xdg_surface =
xdg_shell_view->view.wlr_xdg_surface;
struct sway_view *view = &xdg_shell_view->view;
Expand All @@ -352,8 +352,9 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
}

struct sway_container *container = view->container;
if (e->fullscreen && e->output && e->output->data) {
struct sway_output *output = e->output->data;
struct wlr_xdg_toplevel_requested *req = &xdg_surface->toplevel->requested;
if (req->fullscreen && req->fullscreen_output && req->fullscreen_output->data) {
struct sway_output *output = req->fullscreen_output->data;
struct sway_workspace *ws = output_get_active_workspace(output);
if (ws && !container_is_scratchpad_hidden(container) &&
container->pending.workspace != ws) {
Expand All @@ -365,7 +366,7 @@ static void handle_request_fullscreen(struct wl_listener *listener, void *data)
}
}

container_set_fullscreen(container, e->fullscreen);
container_set_fullscreen(container, req->fullscreen);

arrange_root();
transaction_commit_dirty();
Expand Down