mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-01 16:55:59 +01:00
rootston: make roots_view embedded and remove unions
This commit is contained in:
parent
9f11bf571e
commit
9adcbabea4
10 changed files with 411 additions and 398 deletions
|
@ -9,91 +9,6 @@
|
||||||
#include <wlr/types/wlr_xdg_shell_v6.h>
|
#include <wlr/types/wlr_xdg_shell_v6.h>
|
||||||
#include <wlr/types/wlr_xdg_shell.h>
|
#include <wlr/types/wlr_xdg_shell.h>
|
||||||
|
|
||||||
struct roots_wl_shell_surface {
|
|
||||||
struct roots_view *view;
|
|
||||||
|
|
||||||
struct wl_listener destroy;
|
|
||||||
struct wl_listener new_popup;
|
|
||||||
struct wl_listener request_move;
|
|
||||||
struct wl_listener request_resize;
|
|
||||||
struct wl_listener request_maximize;
|
|
||||||
struct wl_listener request_fullscreen;
|
|
||||||
struct wl_listener set_state;
|
|
||||||
struct wl_listener set_title;
|
|
||||||
struct wl_listener set_class;
|
|
||||||
|
|
||||||
struct wl_listener surface_commit;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct roots_xdg_surface_v6 {
|
|
||||||
struct roots_view *view;
|
|
||||||
|
|
||||||
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;
|
|
||||||
struct wl_listener request_fullscreen;
|
|
||||||
struct wl_listener set_title;
|
|
||||||
struct wl_listener set_app_id;
|
|
||||||
|
|
||||||
struct wl_listener surface_commit;
|
|
||||||
|
|
||||||
uint32_t pending_move_resize_configure_serial;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct roots_xdg_toplevel_decoration;
|
|
||||||
|
|
||||||
struct roots_xdg_surface {
|
|
||||||
struct roots_view *view;
|
|
||||||
|
|
||||||
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;
|
|
||||||
struct wl_listener request_fullscreen;
|
|
||||||
struct wl_listener set_title;
|
|
||||||
struct wl_listener set_app_id;
|
|
||||||
|
|
||||||
|
|
||||||
struct wl_listener surface_commit;
|
|
||||||
|
|
||||||
uint32_t pending_move_resize_configure_serial;
|
|
||||||
|
|
||||||
struct roots_xdg_toplevel_decoration *xdg_toplevel_decoration;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct roots_xwayland_surface {
|
|
||||||
struct roots_view *view;
|
|
||||||
|
|
||||||
struct wl_listener destroy;
|
|
||||||
struct wl_listener request_configure;
|
|
||||||
struct wl_listener request_move;
|
|
||||||
struct wl_listener request_resize;
|
|
||||||
struct wl_listener request_maximize;
|
|
||||||
struct wl_listener request_fullscreen;
|
|
||||||
struct wl_listener map;
|
|
||||||
struct wl_listener unmap;
|
|
||||||
struct wl_listener set_title;
|
|
||||||
struct wl_listener set_class;
|
|
||||||
|
|
||||||
struct wl_listener surface_commit;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum roots_view_type {
|
|
||||||
ROOTS_WL_SHELL_VIEW,
|
|
||||||
ROOTS_XDG_SHELL_V6_VIEW,
|
|
||||||
ROOTS_XDG_SHELL_VIEW,
|
|
||||||
#if WLR_HAS_XWAYLAND
|
|
||||||
ROOTS_XWAYLAND_VIEW,
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
struct roots_view;
|
struct roots_view;
|
||||||
|
|
||||||
struct roots_view_interface {
|
struct roots_view_interface {
|
||||||
|
@ -108,7 +23,17 @@ struct roots_view_interface {
|
||||||
void (*destroy)(struct roots_view *view);
|
void (*destroy)(struct roots_view *view);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum roots_view_type {
|
||||||
|
ROOTS_WL_SHELL_VIEW,
|
||||||
|
ROOTS_XDG_SHELL_V6_VIEW,
|
||||||
|
ROOTS_XDG_SHELL_VIEW,
|
||||||
|
#if WLR_HAS_XWAYLAND
|
||||||
|
ROOTS_XWAYLAND_VIEW,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
struct roots_view {
|
struct roots_view {
|
||||||
|
enum roots_view_type type;
|
||||||
const struct roots_view_interface *impl;
|
const struct roots_view_interface *impl;
|
||||||
struct roots_desktop *desktop;
|
struct roots_desktop *desktop;
|
||||||
struct wl_list link; // roots_desktop::views
|
struct wl_list link; // roots_desktop::views
|
||||||
|
@ -135,25 +60,6 @@ struct roots_view {
|
||||||
uint32_t width, height;
|
uint32_t width, height;
|
||||||
} pending_move_resize;
|
} pending_move_resize;
|
||||||
|
|
||||||
// TODO: Something for roots-enforced width/height
|
|
||||||
enum roots_view_type type;
|
|
||||||
union {
|
|
||||||
struct wlr_wl_shell_surface *wl_shell_surface;
|
|
||||||
struct wlr_xdg_surface_v6 *xdg_surface_v6;
|
|
||||||
struct wlr_xdg_surface *xdg_surface;
|
|
||||||
#if WLR_HAS_XWAYLAND
|
|
||||||
struct wlr_xwayland_surface *xwayland_surface;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
union {
|
|
||||||
struct roots_wl_shell_surface *roots_wl_shell_surface;
|
|
||||||
struct roots_xdg_surface_v6 *roots_xdg_surface_v6;
|
|
||||||
struct roots_xdg_surface *roots_xdg_surface;
|
|
||||||
#if WLR_HAS_XWAYLAND
|
|
||||||
struct roots_xwayland_surface *roots_xwayland_surface;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
struct wlr_surface *wlr_surface;
|
struct wlr_surface *wlr_surface;
|
||||||
struct wl_list children; // roots_view_child::link
|
struct wl_list children; // roots_view_child::link
|
||||||
|
|
||||||
|
@ -170,6 +76,91 @@ struct roots_view {
|
||||||
} events;
|
} events;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct roots_wl_shell_surface {
|
||||||
|
struct roots_view view;
|
||||||
|
|
||||||
|
struct wlr_wl_shell_surface *wl_shell_surface;
|
||||||
|
|
||||||
|
struct wl_listener destroy;
|
||||||
|
struct wl_listener new_popup;
|
||||||
|
struct wl_listener request_move;
|
||||||
|
struct wl_listener request_resize;
|
||||||
|
struct wl_listener request_maximize;
|
||||||
|
struct wl_listener request_fullscreen;
|
||||||
|
struct wl_listener set_state;
|
||||||
|
struct wl_listener set_title;
|
||||||
|
struct wl_listener set_class;
|
||||||
|
|
||||||
|
struct wl_listener surface_commit;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct roots_xdg_surface_v6 {
|
||||||
|
struct roots_view view;
|
||||||
|
|
||||||
|
struct wlr_xdg_surface_v6 *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;
|
||||||
|
struct wl_listener request_fullscreen;
|
||||||
|
struct wl_listener set_title;
|
||||||
|
struct wl_listener set_app_id;
|
||||||
|
|
||||||
|
struct wl_listener surface_commit;
|
||||||
|
|
||||||
|
uint32_t pending_move_resize_configure_serial;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct roots_xdg_toplevel_decoration;
|
||||||
|
|
||||||
|
struct roots_xdg_surface {
|
||||||
|
struct roots_view view;
|
||||||
|
|
||||||
|
struct wlr_xdg_surface *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;
|
||||||
|
struct wl_listener request_fullscreen;
|
||||||
|
struct wl_listener set_title;
|
||||||
|
struct wl_listener set_app_id;
|
||||||
|
|
||||||
|
struct wl_listener surface_commit;
|
||||||
|
|
||||||
|
uint32_t pending_move_resize_configure_serial;
|
||||||
|
|
||||||
|
struct roots_xdg_toplevel_decoration *xdg_toplevel_decoration;
|
||||||
|
};
|
||||||
|
|
||||||
|
#if WLR_HAS_XWAYLAND
|
||||||
|
struct roots_xwayland_surface {
|
||||||
|
struct roots_view view;
|
||||||
|
|
||||||
|
struct wlr_xwayland_surface *xwayland_surface;
|
||||||
|
|
||||||
|
struct wl_listener destroy;
|
||||||
|
struct wl_listener request_configure;
|
||||||
|
struct wl_listener request_move;
|
||||||
|
struct wl_listener request_resize;
|
||||||
|
struct wl_listener request_maximize;
|
||||||
|
struct wl_listener request_fullscreen;
|
||||||
|
struct wl_listener map;
|
||||||
|
struct wl_listener unmap;
|
||||||
|
struct wl_listener set_title;
|
||||||
|
struct wl_listener set_class;
|
||||||
|
|
||||||
|
struct wl_listener surface_commit;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
struct roots_view_child;
|
struct roots_view_child;
|
||||||
|
|
||||||
struct roots_view_child_interface {
|
struct roots_view_child_interface {
|
||||||
|
@ -228,8 +219,8 @@ struct roots_xdg_toplevel_decoration {
|
||||||
struct wl_listener surface_commit;
|
struct wl_listener surface_commit;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct roots_view *view_create(struct roots_desktop *desktop,
|
void view_init(struct roots_view *view, const struct roots_view_interface *impl,
|
||||||
const struct roots_view_interface *impl);
|
enum roots_view_type type, struct roots_desktop *desktop);
|
||||||
void view_destroy(struct roots_view *view);
|
void view_destroy(struct roots_view *view);
|
||||||
void view_activate(struct roots_view *view, bool activate);
|
void view_activate(struct roots_view *view, bool activate);
|
||||||
void view_apply_damage(struct roots_view *view);
|
void view_apply_damage(struct roots_view *view);
|
||||||
|
@ -256,13 +247,19 @@ void view_close(struct roots_view *view);
|
||||||
bool view_center(struct roots_view *view);
|
bool view_center(struct roots_view *view);
|
||||||
void view_setup(struct roots_view *view);
|
void view_setup(struct roots_view *view);
|
||||||
void view_teardown(struct roots_view *view);
|
void view_teardown(struct roots_view *view);
|
||||||
|
|
||||||
void view_set_title(struct roots_view *view, const char *title);
|
void view_set_title(struct roots_view *view, const char *title);
|
||||||
void view_set_app_id(struct roots_view *view, const char *app_id);
|
void view_set_app_id(struct roots_view *view, const char *app_id);
|
||||||
void view_create_foreign_toplevel_handle(struct roots_view *view);
|
void view_create_foreign_toplevel_handle(struct roots_view *view);
|
||||||
|
|
||||||
void view_get_deco_box(const struct roots_view *view, struct wlr_box *box);
|
void view_get_deco_box(const struct roots_view *view, struct wlr_box *box);
|
||||||
|
|
||||||
|
struct roots_wl_shell_surface *roots_wl_shell_surface_from_view(
|
||||||
|
struct roots_view *view);
|
||||||
|
struct roots_xdg_surface *roots_xdg_surface_from_view(struct roots_view *view);
|
||||||
|
struct roots_xdg_surface_v6 *roots_xdg_surface_v6_from_view(
|
||||||
|
struct roots_view *view);
|
||||||
|
struct roots_xwayland_surface *roots_xwayland_surface_from_view(
|
||||||
|
struct roots_view *view);
|
||||||
|
|
||||||
enum roots_deco_part {
|
enum roots_deco_part {
|
||||||
ROOTS_DECO_PART_NONE = 0,
|
ROOTS_DECO_PART_NONE = 0,
|
||||||
ROOTS_DECO_PART_TOP_BORDER = (1 << 0),
|
ROOTS_DECO_PART_TOP_BORDER = (1 << 0),
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
#include "rootston/bindings.h"
|
#include "rootston/bindings.h"
|
||||||
|
#include "rootston/view.h"
|
||||||
|
|
||||||
static bool outputs_enabled = true;
|
static bool outputs_enabled = true;
|
||||||
|
|
||||||
|
@ -83,8 +84,10 @@ void execute_binding_command(struct roots_seat *seat,
|
||||||
} else if (strcmp(command, "toggle_decoration_mode") == 0) {
|
} else if (strcmp(command, "toggle_decoration_mode") == 0) {
|
||||||
struct roots_view *focus = roots_seat_get_focus(seat);
|
struct roots_view *focus = roots_seat_get_focus(seat);
|
||||||
if (focus != NULL && focus->type == ROOTS_XDG_SHELL_VIEW) {
|
if (focus != NULL && focus->type == ROOTS_XDG_SHELL_VIEW) {
|
||||||
|
struct roots_xdg_surface *xdg_surface =
|
||||||
|
roots_xdg_surface_from_view(focus);
|
||||||
struct roots_xdg_toplevel_decoration *decoration =
|
struct roots_xdg_toplevel_decoration *decoration =
|
||||||
focus->roots_xdg_surface->xdg_toplevel_decoration;
|
xdg_surface->xdg_toplevel_decoration;
|
||||||
if (decoration != NULL) {
|
if (decoration != NULL) {
|
||||||
enum wlr_xdg_toplevel_decoration_v1_mode mode =
|
enum wlr_xdg_toplevel_decoration_v1_mode mode =
|
||||||
decoration->wlr_decoration->current_mode;
|
decoration->wlr_decoration->current_mode;
|
||||||
|
|
|
@ -38,9 +38,12 @@
|
||||||
|
|
||||||
static bool view_at(struct roots_view *view, double lx, double ly,
|
static bool view_at(struct roots_view *view, double lx, double ly,
|
||||||
struct wlr_surface **surface, double *sx, double *sy) {
|
struct wlr_surface **surface, double *sx, double *sy) {
|
||||||
if (view->type == ROOTS_WL_SHELL_VIEW &&
|
if (view->type == ROOTS_WL_SHELL_VIEW) {
|
||||||
view->wl_shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_POPUP) {
|
struct wlr_wl_shell_surface *wl_shell_surface =
|
||||||
return false;
|
roots_wl_shell_surface_from_view(view)->wl_shell_surface;
|
||||||
|
if (wl_shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_POPUP) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (view->wlr_surface == NULL) {
|
if (view->wlr_surface == NULL) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -68,17 +71,23 @@ static bool view_at(struct roots_view *view, double lx, double ly,
|
||||||
double _sx, _sy;
|
double _sx, _sy;
|
||||||
struct wlr_surface *_surface = NULL;
|
struct wlr_surface *_surface = NULL;
|
||||||
switch (view->type) {
|
switch (view->type) {
|
||||||
case ROOTS_XDG_SHELL_V6_VIEW:
|
case ROOTS_XDG_SHELL_V6_VIEW:;
|
||||||
_surface = wlr_xdg_surface_v6_surface_at(view->xdg_surface_v6,
|
struct roots_xdg_surface_v6 *xdg_surface_v6 =
|
||||||
|
roots_xdg_surface_v6_from_view(view);
|
||||||
|
_surface = wlr_xdg_surface_v6_surface_at(xdg_surface_v6->xdg_surface_v6,
|
||||||
view_sx, view_sy, &_sx, &_sy);
|
view_sx, view_sy, &_sx, &_sy);
|
||||||
break;
|
break;
|
||||||
case ROOTS_XDG_SHELL_VIEW:
|
case ROOTS_XDG_SHELL_VIEW:;
|
||||||
_surface = wlr_xdg_surface_surface_at(view->xdg_surface,
|
struct roots_xdg_surface *xdg_surface =
|
||||||
|
roots_xdg_surface_from_view(view);
|
||||||
|
_surface = wlr_xdg_surface_surface_at(xdg_surface->xdg_surface,
|
||||||
view_sx, view_sy, &_sx, &_sy);
|
view_sx, view_sy, &_sx, &_sy);
|
||||||
break;
|
break;
|
||||||
case ROOTS_WL_SHELL_VIEW:
|
case ROOTS_WL_SHELL_VIEW:;
|
||||||
_surface = wlr_wl_shell_surface_surface_at(view->wl_shell_surface,
|
struct roots_wl_shell_surface *wl_shell_surface =
|
||||||
view_sx, view_sy, &_sx, &_sy);
|
roots_wl_shell_surface_from_view(view);
|
||||||
|
_surface = wlr_wl_shell_surface_surface_at(
|
||||||
|
wl_shell_surface->wl_shell_surface, view_sx, view_sy, &_sx, &_sy);
|
||||||
break;
|
break;
|
||||||
#if WLR_HAS_XWAYLAND
|
#if WLR_HAS_XWAYLAND
|
||||||
case ROOTS_XWAYLAND_VIEW:
|
case ROOTS_XWAYLAND_VIEW:
|
||||||
|
|
|
@ -43,8 +43,9 @@ struct layout_data {
|
||||||
float rotation;
|
float rotation;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void get_layout_position(struct layout_data *data, double *lx, double *ly,
|
static void get_layout_position(struct layout_data *data,
|
||||||
const struct wlr_surface *surface, int sx, int sy) {
|
double *lx, double *ly, const struct wlr_surface *surface,
|
||||||
|
int sx, int sy) {
|
||||||
double _sx = sx, _sy = sy;
|
double _sx = sx, _sy = sy;
|
||||||
rotate_child_position(&_sx, &_sy, surface->current.width,
|
rotate_child_position(&_sx, &_sy, surface->current.width,
|
||||||
surface->current.height, data->width, data->height, data->rotation);
|
surface->current.height, data->width, data->height, data->rotation);
|
||||||
|
@ -78,17 +79,23 @@ static void view_for_each_surface(struct roots_view *view,
|
||||||
layout_data->rotation = view->rotation;
|
layout_data->rotation = view->rotation;
|
||||||
|
|
||||||
switch (view->type) {
|
switch (view->type) {
|
||||||
case ROOTS_XDG_SHELL_V6_VIEW:
|
case ROOTS_XDG_SHELL_V6_VIEW:;
|
||||||
wlr_xdg_surface_v6_for_each_surface(view->xdg_surface_v6, iterator,
|
struct roots_xdg_surface_v6 *xdg_surface_v6 =
|
||||||
|
roots_xdg_surface_v6_from_view(view);
|
||||||
|
wlr_xdg_surface_v6_for_each_surface(xdg_surface_v6->xdg_surface_v6,
|
||||||
|
iterator, user_data);
|
||||||
|
break;
|
||||||
|
case ROOTS_XDG_SHELL_VIEW:;
|
||||||
|
struct roots_xdg_surface *xdg_surface =
|
||||||
|
roots_xdg_surface_from_view(view);
|
||||||
|
wlr_xdg_surface_for_each_surface(xdg_surface->xdg_surface, iterator,
|
||||||
user_data);
|
user_data);
|
||||||
break;
|
break;
|
||||||
case ROOTS_XDG_SHELL_VIEW:
|
case ROOTS_WL_SHELL_VIEW:;
|
||||||
wlr_xdg_surface_for_each_surface(view->xdg_surface, iterator,
|
struct roots_wl_shell_surface *wl_shell_surface =
|
||||||
user_data);
|
roots_wl_shell_surface_from_view(view);
|
||||||
break;
|
wlr_wl_shell_surface_for_each_surface(wl_shell_surface->wl_shell_surface,
|
||||||
case ROOTS_WL_SHELL_VIEW:
|
iterator, user_data);
|
||||||
wlr_wl_shell_surface_for_each_surface(view->wl_shell_surface, iterator,
|
|
||||||
user_data);
|
|
||||||
break;
|
break;
|
||||||
#if WLR_HAS_XWAYLAND
|
#if WLR_HAS_XWAYLAND
|
||||||
case ROOTS_XWAYLAND_VIEW:
|
case ROOTS_XWAYLAND_VIEW:
|
||||||
|
@ -165,7 +172,10 @@ static void output_for_each_surface(struct roots_output *output,
|
||||||
|
|
||||||
#if WLR_HAS_XWAYLAND
|
#if WLR_HAS_XWAYLAND
|
||||||
if (view->type == ROOTS_XWAYLAND_VIEW) {
|
if (view->type == ROOTS_XWAYLAND_VIEW) {
|
||||||
xwayland_children_for_each_surface(view->xwayland_surface,
|
struct roots_xwayland_surface *xwayland_surface =
|
||||||
|
roots_xwayland_surface_from_view(view);
|
||||||
|
xwayland_children_for_each_surface(
|
||||||
|
xwayland_surface->xwayland_surface,
|
||||||
iterator, layout_data, user_data);
|
iterator, layout_data, user_data);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -497,7 +507,10 @@ static void render_output(struct roots_output *output) {
|
||||||
// the fullscreen window's children so we have to traverse the tree.
|
// the fullscreen window's children so we have to traverse the tree.
|
||||||
#if WLR_HAS_XWAYLAND
|
#if WLR_HAS_XWAYLAND
|
||||||
if (view->type == ROOTS_XWAYLAND_VIEW) {
|
if (view->type == ROOTS_XWAYLAND_VIEW) {
|
||||||
xwayland_children_for_each_surface(view->xwayland_surface,
|
struct roots_xwayland_surface *xwayland_surface =
|
||||||
|
roots_xwayland_surface_from_view(view);
|
||||||
|
xwayland_children_for_each_surface(
|
||||||
|
xwayland_surface->xwayland_surface,
|
||||||
render_surface, &data.layout, &data);
|
render_surface, &data.layout, &data);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -568,9 +581,12 @@ static bool view_accept_damage(struct roots_output *output,
|
||||||
if (output->fullscreen_view->type == ROOTS_XWAYLAND_VIEW &&
|
if (output->fullscreen_view->type == ROOTS_XWAYLAND_VIEW &&
|
||||||
view->type == ROOTS_XWAYLAND_VIEW) {
|
view->type == ROOTS_XWAYLAND_VIEW) {
|
||||||
// Special case: accept damage from children
|
// Special case: accept damage from children
|
||||||
struct wlr_xwayland_surface *xsurface = view->xwayland_surface;
|
struct wlr_xwayland_surface *xsurface =
|
||||||
|
roots_xwayland_surface_from_view(view)->xwayland_surface;
|
||||||
|
struct wlr_xwayland_surface *fullscreen_xsurface =
|
||||||
|
roots_xwayland_surface_from_view(output->fullscreen_view)->xwayland_surface;
|
||||||
while (xsurface != NULL) {
|
while (xsurface != NULL) {
|
||||||
if (output->fullscreen_view->xwayland_surface == xsurface) {
|
if (fullscreen_xsurface == xsurface) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
xsurface = xsurface->parent;
|
xsurface = xsurface->parent;
|
||||||
|
|
|
@ -1293,9 +1293,12 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
|
||||||
bool unfullscreen = true;
|
bool unfullscreen = true;
|
||||||
|
|
||||||
#if WLR_HAS_XWAYLAND
|
#if WLR_HAS_XWAYLAND
|
||||||
if (view && view->type == ROOTS_XWAYLAND_VIEW &&
|
if (view && view->type == ROOTS_XWAYLAND_VIEW) {
|
||||||
view->xwayland_surface->override_redirect) {
|
struct roots_xwayland_surface *xwayland_surface =
|
||||||
unfullscreen = false;
|
roots_xwayland_surface_from_view(view);
|
||||||
|
if (xwayland_surface->xwayland_surface->override_redirect) {
|
||||||
|
unfullscreen = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1322,10 +1325,13 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WLR_HAS_XWAYLAND
|
#if WLR_HAS_XWAYLAND
|
||||||
if (view && view->type == ROOTS_XWAYLAND_VIEW &&
|
if (view && view->type == ROOTS_XWAYLAND_VIEW) {
|
||||||
!wlr_xwayland_or_surface_wants_focus(
|
struct roots_xwayland_surface *xwayland_surface =
|
||||||
view->xwayland_surface)) {
|
roots_xwayland_surface_from_view(view);
|
||||||
return;
|
if (!wlr_xwayland_or_surface_wants_focus(
|
||||||
|
xwayland_surface->xwayland_surface)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
struct roots_seat_view *seat_view = NULL;
|
struct roots_seat_view *seat_view = NULL;
|
||||||
|
|
|
@ -8,19 +8,35 @@
|
||||||
#include "rootston/server.h"
|
#include "rootston/server.h"
|
||||||
#include "rootston/view.h"
|
#include "rootston/view.h"
|
||||||
|
|
||||||
struct roots_view *view_create(struct roots_desktop *desktop,
|
void view_init(struct roots_view *view, const struct roots_view_interface *impl,
|
||||||
const struct roots_view_interface *impl) {
|
enum roots_view_type type, struct roots_desktop *desktop) {
|
||||||
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
assert(impl->destroy);
|
||||||
if (!view) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
view->impl = impl;
|
view->impl = impl;
|
||||||
|
view->type = type;
|
||||||
view->desktop = desktop;
|
view->desktop = desktop;
|
||||||
view->alpha = 1.0f;
|
view->alpha = 1.0f;
|
||||||
wl_signal_init(&view->events.unmap);
|
wl_signal_init(&view->events.unmap);
|
||||||
wl_signal_init(&view->events.destroy);
|
wl_signal_init(&view->events.destroy);
|
||||||
wl_list_init(&view->children);
|
wl_list_init(&view->children);
|
||||||
return view;
|
}
|
||||||
|
|
||||||
|
void view_destroy(struct roots_view *view) {
|
||||||
|
if (view == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wl_signal_emit(&view->events.destroy, view);
|
||||||
|
|
||||||
|
if (view->wlr_surface != NULL) {
|
||||||
|
view_unmap(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can happen if fullscreened while unmapped, and hasn't been mapped
|
||||||
|
if (view->fullscreen_output != NULL) {
|
||||||
|
view->fullscreen_output->fullscreen_view = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
view->impl->destroy(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_get_box(const struct roots_view *view, struct wlr_box *box) {
|
void view_get_box(const struct roots_view *view, struct wlr_box *box) {
|
||||||
|
@ -452,29 +468,6 @@ struct roots_subsurface *subsurface_create(struct roots_view *view,
|
||||||
return subsurface;
|
return subsurface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void view_destroy(struct roots_view *view) {
|
|
||||||
if (view == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_signal_emit(&view->events.destroy, view);
|
|
||||||
|
|
||||||
if (view->wlr_surface != NULL) {
|
|
||||||
view_unmap(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can happen if fullscreened while unmapped, and hasn't been mapped
|
|
||||||
if (view->fullscreen_output != NULL) {
|
|
||||||
view->fullscreen_output->fullscreen_view = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (view->impl->destroy) {
|
|
||||||
view->impl->destroy(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(view);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void view_handle_new_subsurface(struct wl_listener *listener,
|
static void view_handle_new_subsurface(struct wl_listener *listener,
|
||||||
void *data) {
|
void *data) {
|
||||||
struct roots_view *view = wl_container_of(listener, view, new_subsurface);
|
struct roots_view *view = wl_container_of(listener, view, new_subsurface);
|
||||||
|
|
|
@ -34,7 +34,7 @@ static void popup_handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
static void popup_handle_set_state(struct wl_listener *listener, void *data) {
|
static void popup_handle_set_state(struct wl_listener *listener, void *data) {
|
||||||
struct roots_wl_shell_popup *popup =
|
struct roots_wl_shell_popup *popup =
|
||||||
wl_container_of(listener, popup, set_state);
|
wl_container_of(listener, popup, set_state);
|
||||||
popup_destroy((struct roots_view_child *)popup);
|
view_child_destroy(&popup->view_child);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct roots_wl_shell_popup *popup_create(struct roots_view *view,
|
static struct roots_wl_shell_popup *popup_create(struct roots_view *view,
|
||||||
|
@ -68,21 +68,21 @@ static struct roots_wl_shell_popup *popup_create(struct roots_view *view,
|
||||||
|
|
||||||
|
|
||||||
static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
|
static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
|
||||||
assert(view->type == ROOTS_WL_SHELL_VIEW);
|
struct wlr_wl_shell_surface *surf =
|
||||||
struct wlr_wl_shell_surface *surf = view->wl_shell_surface;
|
roots_wl_shell_surface_from_view(view)->wl_shell_surface;
|
||||||
wlr_wl_shell_surface_configure(surf, WL_SHELL_SURFACE_RESIZE_NONE, width,
|
wlr_wl_shell_surface_configure(surf, WL_SHELL_SURFACE_RESIZE_NONE, width,
|
||||||
height);
|
height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close(struct roots_view *view) {
|
static void close(struct roots_view *view) {
|
||||||
assert(view->type == ROOTS_WL_SHELL_VIEW);
|
struct wlr_wl_shell_surface *surf =
|
||||||
struct wlr_wl_shell_surface *surf = view->wl_shell_surface;
|
roots_wl_shell_surface_from_view(view)->wl_shell_surface;
|
||||||
wl_client_destroy(surf->client);
|
wl_client_destroy(surf->client);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy(struct roots_view *view) {
|
static void destroy(struct roots_view *view) {
|
||||||
assert(view->type == ROOTS_WL_SHELL_VIEW);
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
struct roots_wl_shell_surface *roots_surface = view->roots_wl_shell_surface;
|
roots_wl_shell_surface_from_view(view);
|
||||||
wl_list_remove(&roots_surface->destroy.link);
|
wl_list_remove(&roots_surface->destroy.link);
|
||||||
wl_list_remove(&roots_surface->request_move.link);
|
wl_list_remove(&roots_surface->request_move.link);
|
||||||
wl_list_remove(&roots_surface->request_resize.link);
|
wl_list_remove(&roots_surface->request_resize.link);
|
||||||
|
@ -104,7 +104,7 @@ static const struct roots_view_interface view_impl = {
|
||||||
static void handle_request_move(struct wl_listener *listener, void *data) {
|
static void handle_request_move(struct wl_listener *listener, void *data) {
|
||||||
struct roots_wl_shell_surface *roots_surface =
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, request_move);
|
wl_container_of(listener, roots_surface, request_move);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
struct roots_input *input = view->desktop->server->input;
|
struct roots_input *input = view->desktop->server->input;
|
||||||
struct wlr_wl_shell_surface_move_event *e = data;
|
struct wlr_wl_shell_surface_move_event *e = data;
|
||||||
struct roots_seat *seat = input_seat_from_wlr_seat(input, e->seat->seat);
|
struct roots_seat *seat = input_seat_from_wlr_seat(input, e->seat->seat);
|
||||||
|
@ -117,7 +117,7 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
|
||||||
static void handle_request_resize(struct wl_listener *listener, void *data) {
|
static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
struct roots_wl_shell_surface *roots_surface =
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, request_resize);
|
wl_container_of(listener, roots_surface, request_resize);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
struct roots_input *input = view->desktop->server->input;
|
struct roots_input *input = view->desktop->server->input;
|
||||||
struct wlr_wl_shell_surface_resize_event *e = data;
|
struct wlr_wl_shell_surface_resize_event *e = data;
|
||||||
struct roots_seat *seat = input_seat_from_wlr_seat(input, e->seat->seat);
|
struct roots_seat *seat = input_seat_from_wlr_seat(input, e->seat->seat);
|
||||||
|
@ -131,7 +131,7 @@ static void handle_request_maximize(struct wl_listener *listener,
|
||||||
void *data) {
|
void *data) {
|
||||||
struct roots_wl_shell_surface *roots_surface =
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, request_maximize);
|
wl_container_of(listener, roots_surface, request_maximize);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
//struct wlr_wl_shell_surface_maximize_event *e = data;
|
//struct wlr_wl_shell_surface_maximize_event *e = data;
|
||||||
view_maximize(view, true);
|
view_maximize(view, true);
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ static void handle_request_fullscreen(struct wl_listener *listener,
|
||||||
void *data) {
|
void *data) {
|
||||||
struct roots_wl_shell_surface *roots_surface =
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, request_fullscreen);
|
wl_container_of(listener, roots_surface, request_fullscreen);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
struct wlr_wl_shell_surface_set_fullscreen_event *e = data;
|
struct wlr_wl_shell_surface_set_fullscreen_event *e = data;
|
||||||
view_set_fullscreen(view, true, e->output);
|
view_set_fullscreen(view, true, e->output);
|
||||||
}
|
}
|
||||||
|
@ -148,8 +148,8 @@ static void handle_request_fullscreen(struct wl_listener *listener,
|
||||||
static void handle_set_state(struct wl_listener *listener, void *data) {
|
static void handle_set_state(struct wl_listener *listener, void *data) {
|
||||||
struct roots_wl_shell_surface *roots_surface =
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, set_state);
|
wl_container_of(listener, roots_surface, set_state);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
struct wlr_wl_shell_surface *surface = view->wl_shell_surface;
|
struct wlr_wl_shell_surface *surface = roots_surface->wl_shell_surface;
|
||||||
if (view->maximized &&
|
if (view->maximized &&
|
||||||
surface->state != WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED) {
|
surface->state != WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED) {
|
||||||
view_maximize(view, false);
|
view_maximize(view, false);
|
||||||
|
@ -163,21 +163,21 @@ static void handle_set_state(struct wl_listener *listener, void *data) {
|
||||||
static void handle_set_title(struct wl_listener *listener, void *data) {
|
static void handle_set_title(struct wl_listener *listener, void *data) {
|
||||||
struct roots_wl_shell_surface *roots_surface =
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, set_state);
|
wl_container_of(listener, roots_surface, set_state);
|
||||||
view_set_title(roots_surface->view,
|
view_set_title(&roots_surface->view,
|
||||||
roots_surface->view->wl_shell_surface->title);
|
roots_surface->wl_shell_surface->title);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_set_class(struct wl_listener *listener, void *data) {
|
static void handle_set_class(struct wl_listener *listener, void *data) {
|
||||||
struct roots_wl_shell_surface *roots_surface =
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, set_state);
|
wl_container_of(listener, roots_surface, set_state);
|
||||||
view_set_app_id(roots_surface->view,
|
view_set_app_id(&roots_surface->view,
|
||||||
roots_surface->view->wl_shell_surface->class);
|
roots_surface->wl_shell_surface->class);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
||||||
struct roots_wl_shell_surface *roots_surface =
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, surface_commit);
|
wl_container_of(listener, roots_surface, surface_commit);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
struct wlr_surface *wlr_surface = view->wlr_surface;
|
struct wlr_surface *wlr_surface = view->wlr_surface;
|
||||||
|
|
||||||
view_apply_damage(view);
|
view_apply_damage(view);
|
||||||
|
@ -205,13 +205,13 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
|
||||||
struct roots_wl_shell_surface *roots_surface =
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, new_popup);
|
wl_container_of(listener, roots_surface, new_popup);
|
||||||
struct wlr_wl_shell_surface *wlr_wl_shell_surface = data;
|
struct wlr_wl_shell_surface *wlr_wl_shell_surface = data;
|
||||||
popup_create(roots_surface->view, wlr_wl_shell_surface);
|
popup_create(&roots_surface->view, wlr_wl_shell_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
struct roots_wl_shell_surface *roots_surface =
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, destroy);
|
wl_container_of(listener, roots_surface, destroy);
|
||||||
view_destroy(roots_surface->view);
|
view_destroy(&roots_surface->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
|
@ -233,6 +233,12 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
if (!roots_surface) {
|
if (!roots_surface) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view_init(&roots_surface->view, &view_impl, ROOTS_WL_SHELL_VIEW, desktop);
|
||||||
|
roots_surface->view.box.width = surface->surface->current.width;
|
||||||
|
roots_surface->view.box.height = surface->surface->current.height;
|
||||||
|
roots_surface->wl_shell_surface = surface;
|
||||||
|
|
||||||
roots_surface->destroy.notify = handle_destroy;
|
roots_surface->destroy.notify = handle_destroy;
|
||||||
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
|
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
|
||||||
roots_surface->new_popup.notify = handle_new_popup;
|
roots_surface->new_popup.notify = handle_new_popup;
|
||||||
|
@ -259,42 +265,40 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
roots_surface->surface_commit.notify = handle_surface_commit;
|
roots_surface->surface_commit.notify = handle_surface_commit;
|
||||||
wl_signal_add(&surface->surface->events.commit, &roots_surface->surface_commit);
|
wl_signal_add(&surface->surface->events.commit, &roots_surface->surface_commit);
|
||||||
|
|
||||||
struct roots_view *view = view_create(desktop, &view_impl);
|
view_map(&roots_surface->view, surface->surface);
|
||||||
if (!view) {
|
view_setup(&roots_surface->view);
|
||||||
free(roots_surface);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
view->type = ROOTS_WL_SHELL_VIEW;
|
|
||||||
view->box.width = surface->surface->current.width;
|
|
||||||
view->box.height = surface->surface->current.height;
|
|
||||||
|
|
||||||
view->wl_shell_surface = surface;
|
wlr_foreign_toplevel_handle_v1_set_title(roots_surface->view.toplevel_handle,
|
||||||
view->roots_wl_shell_surface = roots_surface;
|
surface->title ?: "none");
|
||||||
roots_surface->view = view;
|
wlr_foreign_toplevel_handle_v1_set_app_id(roots_surface->view.toplevel_handle,
|
||||||
|
surface->class ?: "none");
|
||||||
view_map(view, surface->surface);
|
|
||||||
view_setup(view);
|
|
||||||
|
|
||||||
wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle,
|
|
||||||
view->wl_shell_surface->title ?: "none");
|
|
||||||
wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle,
|
|
||||||
view->wl_shell_surface->class ?: "none");
|
|
||||||
|
|
||||||
if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) {
|
if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TRANSIENT) {
|
||||||
// We need to map it relative to the parent
|
// We need to map it relative to the parent
|
||||||
bool found = false;
|
bool found = false;
|
||||||
struct roots_view *parent;
|
struct roots_view *parent;
|
||||||
wl_list_for_each(parent, &desktop->views, link) {
|
wl_list_for_each(parent, &desktop->views, link) {
|
||||||
if (parent->type == ROOTS_WL_SHELL_VIEW &&
|
if (parent->type != ROOTS_WL_SHELL_VIEW) {
|
||||||
parent->wl_shell_surface == surface->parent) {
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct roots_wl_shell_surface *parent_surf =
|
||||||
|
roots_wl_shell_surface_from_view(parent);
|
||||||
|
if (parent_surf->wl_shell_surface == surface->parent) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (found) {
|
if (found) {
|
||||||
view_move(view,
|
view_move(&roots_surface->view,
|
||||||
parent->box.x + surface->transient_state->x,
|
parent->box.x + surface->transient_state->x,
|
||||||
parent->box.y + surface->transient_state->y);
|
parent->box.y + surface->transient_state->y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct roots_wl_shell_surface *roots_wl_shell_surface_from_view(
|
||||||
|
struct roots_view *view) {
|
||||||
|
assert(view->impl == &view_impl);
|
||||||
|
return (struct roots_wl_shell_surface *)view;
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "rootston/desktop.h"
|
#include "rootston/desktop.h"
|
||||||
#include "rootston/input.h"
|
#include "rootston/input.h"
|
||||||
#include "rootston/server.h"
|
#include "rootston/server.h"
|
||||||
|
#include "rootston/view.h"
|
||||||
|
|
||||||
static const struct roots_view_child_interface popup_impl;
|
static const struct roots_view_child_interface popup_impl;
|
||||||
|
|
||||||
|
@ -132,31 +133,31 @@ static struct roots_xdg_popup *popup_create(struct roots_view *view,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void get_size(const struct roots_view *view, struct wlr_box *box) {
|
static void get_size(struct roots_view *view, struct wlr_box *box) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_VIEW);
|
struct wlr_xdg_surface *xdg_surface =
|
||||||
struct wlr_xdg_surface *surface = view->xdg_surface;
|
roots_xdg_surface_from_view(view)->xdg_surface;
|
||||||
|
|
||||||
struct wlr_box geo_box;
|
struct wlr_box geo_box;
|
||||||
wlr_xdg_surface_get_geometry(surface, &geo_box);
|
wlr_xdg_surface_get_geometry(xdg_surface, &geo_box);
|
||||||
box->width = geo_box.width;
|
box->width = geo_box.width;
|
||||||
box->height = geo_box.height;
|
box->height = geo_box.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void activate(struct roots_view *view, bool active) {
|
static void activate(struct roots_view *view, bool active) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_VIEW);
|
struct wlr_xdg_surface *xdg_surface =
|
||||||
struct wlr_xdg_surface *surface = view->xdg_surface;
|
roots_xdg_surface_from_view(view)->xdg_surface;
|
||||||
if (surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
if (xdg_surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
||||||
wlr_xdg_toplevel_set_activated(surface, active);
|
wlr_xdg_toplevel_set_activated(xdg_surface, active);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void apply_size_constraints(struct wlr_xdg_surface *surface,
|
static void apply_size_constraints(struct wlr_xdg_surface *xdg_surface,
|
||||||
uint32_t width, uint32_t height, uint32_t *dest_width,
|
uint32_t width, uint32_t height, uint32_t *dest_width,
|
||||||
uint32_t *dest_height) {
|
uint32_t *dest_height) {
|
||||||
*dest_width = width;
|
*dest_width = width;
|
||||||
*dest_height = height;
|
*dest_height = height;
|
||||||
|
|
||||||
struct wlr_xdg_toplevel_state *state = &surface->toplevel->current;
|
struct wlr_xdg_toplevel_state *state = &xdg_surface->toplevel->current;
|
||||||
if (width < state->min_width) {
|
if (width < state->min_width) {
|
||||||
*dest_width = state->min_width;
|
*dest_width = state->min_width;
|
||||||
} else if (state->max_width > 0 &&
|
} else if (state->max_width > 0 &&
|
||||||
|
@ -172,26 +173,26 @@ static void apply_size_constraints(struct wlr_xdg_surface *surface,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
|
static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_VIEW);
|
struct wlr_xdg_surface *xdg_surface =
|
||||||
struct wlr_xdg_surface *surface = view->xdg_surface;
|
roots_xdg_surface_from_view(view)->xdg_surface;
|
||||||
if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t constrained_width, constrained_height;
|
uint32_t constrained_width, constrained_height;
|
||||||
apply_size_constraints(surface, width, height, &constrained_width,
|
apply_size_constraints(xdg_surface, width, height, &constrained_width,
|
||||||
&constrained_height);
|
&constrained_height);
|
||||||
|
|
||||||
wlr_xdg_toplevel_set_size(surface, constrained_width,
|
wlr_xdg_toplevel_set_size(xdg_surface, constrained_width,
|
||||||
constrained_height);
|
constrained_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void move_resize(struct roots_view *view, double x, double y,
|
static void move_resize(struct roots_view *view, double x, double y,
|
||||||
uint32_t width, uint32_t height) {
|
uint32_t width, uint32_t height) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_VIEW);
|
struct roots_xdg_surface *xdg_surface =
|
||||||
struct roots_xdg_surface *roots_surface = view->roots_xdg_surface;
|
roots_xdg_surface_from_view(view);
|
||||||
struct wlr_xdg_surface *surface = view->xdg_surface;
|
struct wlr_xdg_surface *wlr_xdg_surface = xdg_surface->xdg_surface;
|
||||||
if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
if (wlr_xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +200,7 @@ static void move_resize(struct roots_view *view, double x, double y,
|
||||||
bool update_y = y != view->box.y;
|
bool update_y = y != view->box.y;
|
||||||
|
|
||||||
uint32_t constrained_width, constrained_height;
|
uint32_t constrained_width, constrained_height;
|
||||||
apply_size_constraints(surface, width, height, &constrained_width,
|
apply_size_constraints(wlr_xdg_surface, width, height, &constrained_width,
|
||||||
&constrained_height);
|
&constrained_height);
|
||||||
|
|
||||||
if (update_x) {
|
if (update_x) {
|
||||||
|
@ -216,48 +217,48 @@ static void move_resize(struct roots_view *view, double x, double y,
|
||||||
view->pending_move_resize.width = constrained_width;
|
view->pending_move_resize.width = constrained_width;
|
||||||
view->pending_move_resize.height = constrained_height;
|
view->pending_move_resize.height = constrained_height;
|
||||||
|
|
||||||
uint32_t serial = wlr_xdg_toplevel_set_size(surface, constrained_width,
|
uint32_t serial = wlr_xdg_toplevel_set_size(wlr_xdg_surface,
|
||||||
constrained_height);
|
constrained_width, constrained_height);
|
||||||
if (serial > 0) {
|
if (serial > 0) {
|
||||||
roots_surface->pending_move_resize_configure_serial = serial;
|
xdg_surface->pending_move_resize_configure_serial = serial;
|
||||||
} else if (roots_surface->pending_move_resize_configure_serial == 0) {
|
} else if (xdg_surface->pending_move_resize_configure_serial == 0) {
|
||||||
view_update_position(view, x, y);
|
view_update_position(view, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void maximize(struct roots_view *view, bool maximized) {
|
static void maximize(struct roots_view *view, bool maximized) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_VIEW);
|
struct wlr_xdg_surface *xdg_surface =
|
||||||
struct wlr_xdg_surface *surface = view->xdg_surface;
|
roots_xdg_surface_from_view(view)->xdg_surface;
|
||||||
if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_xdg_toplevel_set_maximized(surface, maximized);
|
wlr_xdg_toplevel_set_maximized(xdg_surface, maximized);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_fullscreen(struct roots_view *view, bool fullscreen) {
|
static void set_fullscreen(struct roots_view *view, bool fullscreen) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_VIEW);
|
struct wlr_xdg_surface *xdg_surface =
|
||||||
struct wlr_xdg_surface *surface = view->xdg_surface;
|
roots_xdg_surface_from_view(view)->xdg_surface;
|
||||||
if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_xdg_toplevel_set_fullscreen(surface, fullscreen);
|
wlr_xdg_toplevel_set_fullscreen(xdg_surface, fullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close(struct roots_view *view) {
|
static void close(struct roots_view *view) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_VIEW);
|
struct wlr_xdg_surface *xdg_surface =
|
||||||
struct wlr_xdg_surface *surface = view->xdg_surface;
|
roots_xdg_surface_from_view(view)->xdg_surface;
|
||||||
struct wlr_xdg_popup *popup = NULL;
|
struct wlr_xdg_popup *popup = NULL;
|
||||||
wl_list_for_each(popup, &surface->popups, link) {
|
wl_list_for_each(popup, &xdg_surface->popups, link) {
|
||||||
wlr_xdg_popup_destroy(popup->base);
|
wlr_xdg_popup_destroy(popup->base);
|
||||||
}
|
}
|
||||||
wlr_xdg_toplevel_send_close(surface);
|
wlr_xdg_toplevel_send_close(xdg_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy(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 =
|
||||||
struct roots_xdg_surface *roots_xdg_surface = view->roots_xdg_surface;
|
roots_xdg_surface_from_view(view);
|
||||||
wl_list_remove(&roots_xdg_surface->surface_commit.link);
|
wl_list_remove(&roots_xdg_surface->surface_commit.link);
|
||||||
wl_list_remove(&roots_xdg_surface->destroy.link);
|
wl_list_remove(&roots_xdg_surface->destroy.link);
|
||||||
wl_list_remove(&roots_xdg_surface->new_popup.link);
|
wl_list_remove(&roots_xdg_surface->new_popup.link);
|
||||||
|
@ -269,7 +270,7 @@ static void destroy(struct roots_view *view) {
|
||||||
wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
|
wl_list_remove(&roots_xdg_surface->request_fullscreen.link);
|
||||||
wl_list_remove(&roots_xdg_surface->set_title.link);
|
wl_list_remove(&roots_xdg_surface->set_title.link);
|
||||||
wl_list_remove(&roots_xdg_surface->set_app_id.link);
|
wl_list_remove(&roots_xdg_surface->set_app_id.link);
|
||||||
roots_xdg_surface->view->xdg_surface->data = NULL;
|
roots_xdg_surface->xdg_surface->data = NULL;
|
||||||
free(roots_xdg_surface);
|
free(roots_xdg_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,7 +287,7 @@ static const struct roots_view_interface view_impl = {
|
||||||
static void handle_request_move(struct wl_listener *listener, void *data) {
|
static void handle_request_move(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface *roots_xdg_surface =
|
struct roots_xdg_surface *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, request_move);
|
wl_container_of(listener, roots_xdg_surface, request_move);
|
||||||
struct roots_view *view = roots_xdg_surface->view;
|
struct roots_view *view = &roots_xdg_surface->view;
|
||||||
struct roots_input *input = view->desktop->server->input;
|
struct roots_input *input = view->desktop->server->input;
|
||||||
struct wlr_xdg_toplevel_move_event *e = data;
|
struct wlr_xdg_toplevel_move_event *e = data;
|
||||||
struct roots_seat *seat = input_seat_from_wlr_seat(input, e->seat->seat);
|
struct roots_seat *seat = input_seat_from_wlr_seat(input, e->seat->seat);
|
||||||
|
@ -300,7 +301,7 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
|
||||||
static void handle_request_resize(struct wl_listener *listener, void *data) {
|
static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface *roots_xdg_surface =
|
struct roots_xdg_surface *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, request_resize);
|
wl_container_of(listener, roots_xdg_surface, request_resize);
|
||||||
struct roots_view *view = roots_xdg_surface->view;
|
struct roots_view *view = &roots_xdg_surface->view;
|
||||||
struct roots_input *input = view->desktop->server->input;
|
struct roots_input *input = view->desktop->server->input;
|
||||||
struct wlr_xdg_toplevel_resize_event *e = data;
|
struct wlr_xdg_toplevel_resize_event *e = data;
|
||||||
// TODO verify event serial
|
// TODO verify event serial
|
||||||
|
@ -315,8 +316,8 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
static void handle_request_maximize(struct wl_listener *listener, void *data) {
|
static void handle_request_maximize(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface *roots_xdg_surface =
|
struct roots_xdg_surface *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, request_maximize);
|
wl_container_of(listener, roots_xdg_surface, request_maximize);
|
||||||
struct roots_view *view = roots_xdg_surface->view;
|
struct roots_view *view = &roots_xdg_surface->view;
|
||||||
struct wlr_xdg_surface *surface = view->xdg_surface;
|
struct wlr_xdg_surface *surface = roots_xdg_surface->xdg_surface;
|
||||||
|
|
||||||
if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
||||||
return;
|
return;
|
||||||
|
@ -329,8 +330,8 @@ static void handle_request_fullscreen(struct wl_listener *listener,
|
||||||
void *data) {
|
void *data) {
|
||||||
struct roots_xdg_surface *roots_xdg_surface =
|
struct roots_xdg_surface *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, request_fullscreen);
|
wl_container_of(listener, roots_xdg_surface, request_fullscreen);
|
||||||
struct roots_view *view = roots_xdg_surface->view;
|
struct roots_view *view = &roots_xdg_surface->view;
|
||||||
struct wlr_xdg_surface *surface = view->xdg_surface;
|
struct wlr_xdg_surface *surface = roots_xdg_surface->xdg_surface;
|
||||||
struct wlr_xdg_toplevel_set_fullscreen_event *e = data;
|
struct wlr_xdg_toplevel_set_fullscreen_event *e = data;
|
||||||
|
|
||||||
if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
if (surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) {
|
||||||
|
@ -344,23 +345,23 @@ static void handle_set_title(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface *roots_xdg_surface =
|
struct roots_xdg_surface *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, set_title);
|
wl_container_of(listener, roots_xdg_surface, set_title);
|
||||||
|
|
||||||
view_set_title(roots_xdg_surface->view,
|
view_set_title(&roots_xdg_surface->view,
|
||||||
roots_xdg_surface->view->xdg_surface->toplevel->title);
|
roots_xdg_surface->xdg_surface->toplevel->title);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_set_app_id(struct wl_listener *listener, void *data) {
|
static void handle_set_app_id(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface *roots_xdg_surface =
|
struct roots_xdg_surface *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, set_app_id);
|
wl_container_of(listener, roots_xdg_surface, set_app_id);
|
||||||
|
|
||||||
view_set_app_id(roots_xdg_surface->view,
|
view_set_app_id(&roots_xdg_surface->view,
|
||||||
roots_xdg_surface->view->xdg_surface->toplevel->app_id);
|
roots_xdg_surface->xdg_surface->toplevel->app_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface *roots_surface =
|
struct roots_xdg_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, surface_commit);
|
wl_container_of(listener, roots_surface, surface_commit);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
struct wlr_xdg_surface *surface = view->xdg_surface;
|
struct wlr_xdg_surface *surface = roots_surface->xdg_surface;
|
||||||
|
|
||||||
if (!surface->mapped) {
|
if (!surface->mapped) {
|
||||||
return;
|
return;
|
||||||
|
@ -397,38 +398,38 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface *roots_xdg_surface =
|
struct roots_xdg_surface *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, new_popup);
|
wl_container_of(listener, roots_xdg_surface, new_popup);
|
||||||
struct wlr_xdg_popup *wlr_popup = data;
|
struct wlr_xdg_popup *wlr_popup = data;
|
||||||
popup_create(roots_xdg_surface->view, wlr_popup);
|
popup_create(&roots_xdg_surface->view, wlr_popup);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_map(struct wl_listener *listener, void *data) {
|
static void handle_map(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface *roots_xdg_surface =
|
struct roots_xdg_surface *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, map);
|
wl_container_of(listener, roots_xdg_surface, map);
|
||||||
struct roots_view *view = roots_xdg_surface->view;
|
struct roots_view *view = &roots_xdg_surface->view;
|
||||||
|
|
||||||
struct wlr_box box;
|
struct wlr_box box;
|
||||||
get_size(view, &box);
|
get_size(view, &box);
|
||||||
view->box.width = box.width;
|
view->box.width = box.width;
|
||||||
view->box.height = box.height;
|
view->box.height = box.height;
|
||||||
|
|
||||||
view_map(view, view->xdg_surface->surface);
|
view_map(view, roots_xdg_surface->xdg_surface->surface);
|
||||||
view_setup(view);
|
view_setup(view);
|
||||||
|
|
||||||
wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle,
|
wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle,
|
||||||
view->xdg_surface->toplevel->title ?: "none");
|
roots_xdg_surface->xdg_surface->toplevel->title ?: "none");
|
||||||
wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle,
|
wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle,
|
||||||
view->xdg_surface->toplevel->app_id ?: "none");
|
roots_xdg_surface->xdg_surface->toplevel->app_id ?: "none");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_unmap(struct wl_listener *listener, void *data) {
|
static void handle_unmap(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface *roots_xdg_surface =
|
struct roots_xdg_surface *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, unmap);
|
wl_container_of(listener, roots_xdg_surface, unmap);
|
||||||
view_unmap(roots_xdg_surface->view);
|
view_unmap(&roots_xdg_surface->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface *roots_xdg_surface =
|
struct roots_xdg_surface *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, destroy);
|
wl_container_of(listener, roots_xdg_surface, destroy);
|
||||||
view_destroy(roots_xdg_surface->view);
|
view_destroy(&roots_xdg_surface->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
|
@ -452,6 +453,11 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
if (!roots_surface) {
|
if (!roots_surface) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view_init(&roots_surface->view, &view_impl, ROOTS_XDG_SHELL_VIEW, desktop);
|
||||||
|
roots_surface->xdg_surface = surface;
|
||||||
|
surface->data = roots_surface;
|
||||||
|
|
||||||
roots_surface->surface_commit.notify = handle_surface_commit;
|
roots_surface->surface_commit.notify = handle_surface_commit;
|
||||||
wl_signal_add(&surface->surface->events.commit,
|
wl_signal_add(&surface->surface->events.commit,
|
||||||
&roots_surface->surface_commit);
|
&roots_surface->surface_commit);
|
||||||
|
@ -480,36 +486,16 @@ void handle_xdg_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
&roots_surface->set_app_id);
|
&roots_surface->set_app_id);
|
||||||
roots_surface->new_popup.notify = handle_new_popup;
|
roots_surface->new_popup.notify = handle_new_popup;
|
||||||
wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
|
wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
|
||||||
surface->data = roots_surface;
|
|
||||||
|
|
||||||
struct roots_view *view = view_create(desktop, &view_impl);
|
|
||||||
if (!view) {
|
|
||||||
free(roots_surface);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
view->type = ROOTS_XDG_SHELL_VIEW;
|
|
||||||
|
|
||||||
view->xdg_surface = surface;
|
|
||||||
view->roots_xdg_surface = roots_surface;
|
|
||||||
roots_surface->view = view;
|
|
||||||
|
|
||||||
if (surface->toplevel->client_pending.maximized) {
|
|
||||||
view_maximize(view, true);
|
|
||||||
}
|
|
||||||
if (surface->toplevel->client_pending.fullscreen) {
|
|
||||||
view_set_fullscreen(view, true, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void decoration_handle_destroy(struct wl_listener *listener,
|
static void decoration_handle_destroy(struct wl_listener *listener,
|
||||||
void *data) {
|
void *data) {
|
||||||
struct roots_xdg_toplevel_decoration *decoration =
|
struct roots_xdg_toplevel_decoration *decoration =
|
||||||
wl_container_of(listener, decoration, destroy);
|
wl_container_of(listener, decoration, destroy);
|
||||||
|
|
||||||
decoration->surface->xdg_toplevel_decoration = NULL;
|
decoration->surface->xdg_toplevel_decoration = NULL;
|
||||||
view_update_decorated(decoration->surface->view, false);
|
view_update_decorated(&decoration->surface->view, false);
|
||||||
wl_list_remove(&decoration->destroy.link);
|
wl_list_remove(&decoration->destroy.link);
|
||||||
wl_list_remove(&decoration->request_mode.link);
|
wl_list_remove(&decoration->request_mode.link);
|
||||||
wl_list_remove(&decoration->surface_commit.link);
|
wl_list_remove(&decoration->surface_commit.link);
|
||||||
|
@ -536,7 +522,7 @@ static void decoration_handle_surface_commit(struct wl_listener *listener,
|
||||||
|
|
||||||
bool decorated = decoration->wlr_decoration->current_mode ==
|
bool decorated = decoration->wlr_decoration->current_mode ==
|
||||||
WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
|
WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE;
|
||||||
view_update_decorated(decoration->surface->view, decorated);
|
view_update_decorated(&decoration->surface->view, decorated);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_xdg_toplevel_decoration(struct wl_listener *listener, void *data) {
|
void handle_xdg_toplevel_decoration(struct wl_listener *listener, void *data) {
|
||||||
|
@ -546,7 +532,7 @@ void handle_xdg_toplevel_decoration(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
struct roots_xdg_surface *xdg_surface = wlr_decoration->surface->data;
|
struct roots_xdg_surface *xdg_surface = wlr_decoration->surface->data;
|
||||||
assert(xdg_surface != NULL);
|
assert(xdg_surface != NULL);
|
||||||
struct wlr_xdg_surface *wlr_xdg_surface = xdg_surface->view->xdg_surface;
|
struct wlr_xdg_surface *wlr_xdg_surface = xdg_surface->xdg_surface;
|
||||||
|
|
||||||
struct roots_xdg_toplevel_decoration *decoration =
|
struct roots_xdg_toplevel_decoration *decoration =
|
||||||
calloc(1, sizeof(struct roots_xdg_toplevel_decoration));
|
calloc(1, sizeof(struct roots_xdg_toplevel_decoration));
|
||||||
|
@ -568,3 +554,8 @@ void handle_xdg_toplevel_decoration(struct wl_listener *listener, void *data) {
|
||||||
|
|
||||||
decoration_handle_request_mode(&decoration->request_mode, wlr_decoration);
|
decoration_handle_request_mode(&decoration->request_mode, wlr_decoration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct roots_xdg_surface *roots_xdg_surface_from_view(struct roots_view *view) {
|
||||||
|
assert(view->impl == &view_impl);
|
||||||
|
return (struct roots_xdg_surface *)view;
|
||||||
|
}
|
||||||
|
|
|
@ -132,9 +132,9 @@ static struct roots_xdg_popup_v6 *popup_create(struct roots_view *view,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void get_size(const struct roots_view *view, struct wlr_box *box) {
|
static void get_size(struct roots_view *view, struct wlr_box *box) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
struct wlr_xdg_surface_v6 *surface =
|
||||||
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
roots_xdg_surface_v6_from_view(view)->xdg_surface_v6;
|
||||||
|
|
||||||
struct wlr_box geo_box;
|
struct wlr_box geo_box;
|
||||||
wlr_xdg_surface_v6_get_geometry(surface, &geo_box);
|
wlr_xdg_surface_v6_get_geometry(surface, &geo_box);
|
||||||
|
@ -143,8 +143,8 @@ static void get_size(const struct roots_view *view, struct wlr_box *box) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void activate(struct roots_view *view, bool active) {
|
static void activate(struct roots_view *view, bool active) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
struct wlr_xdg_surface_v6 *surface =
|
||||||
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
roots_xdg_surface_v6_from_view(view)->xdg_surface_v6;
|
||||||
if (surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
if (surface->role == WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
||||||
wlr_xdg_toplevel_v6_set_activated(surface, active);
|
wlr_xdg_toplevel_v6_set_activated(surface, active);
|
||||||
}
|
}
|
||||||
|
@ -172,8 +172,8 @@ static void apply_size_constraints(struct wlr_xdg_surface_v6 *surface,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
|
static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
struct wlr_xdg_surface_v6 *surface =
|
||||||
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
roots_xdg_surface_v6_from_view(view)->xdg_surface_v6;
|
||||||
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -188,9 +188,9 @@ static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
|
||||||
|
|
||||||
static void move_resize(struct roots_view *view, double x, double y,
|
static void move_resize(struct roots_view *view, double x, double y,
|
||||||
uint32_t width, uint32_t height) {
|
uint32_t width, uint32_t height) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
struct roots_xdg_surface_v6 *roots_surface =
|
||||||
struct roots_xdg_surface_v6 *roots_surface = view->roots_xdg_surface_v6;
|
roots_xdg_surface_v6_from_view(view);
|
||||||
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
struct wlr_xdg_surface_v6 *surface = roots_surface->xdg_surface_v6;
|
||||||
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -226,8 +226,8 @@ static void move_resize(struct roots_view *view, double x, double y,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void maximize(struct roots_view *view, bool maximized) {
|
static void maximize(struct roots_view *view, bool maximized) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
struct wlr_xdg_surface_v6 *surface =
|
||||||
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
roots_xdg_surface_v6_from_view(view)->xdg_surface_v6;
|
||||||
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -236,8 +236,8 @@ static void maximize(struct roots_view *view, bool maximized) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_fullscreen(struct roots_view *view, bool fullscreen) {
|
static void set_fullscreen(struct roots_view *view, bool fullscreen) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
struct wlr_xdg_surface_v6 *surface =
|
||||||
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
roots_xdg_surface_v6_from_view(view)->xdg_surface_v6;
|
||||||
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -246,8 +246,8 @@ static void set_fullscreen(struct roots_view *view, bool fullscreen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close(struct roots_view *view) {
|
static void close(struct roots_view *view) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
struct wlr_xdg_surface_v6 *surface =
|
||||||
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
roots_xdg_surface_v6_from_view(view)->xdg_surface_v6;
|
||||||
struct wlr_xdg_popup_v6 *popup = NULL;
|
struct wlr_xdg_popup_v6 *popup = NULL;
|
||||||
wl_list_for_each(popup, &surface->popups, link) {
|
wl_list_for_each(popup, &surface->popups, link) {
|
||||||
wlr_xdg_surface_v6_send_close(popup->base);
|
wlr_xdg_surface_v6_send_close(popup->base);
|
||||||
|
@ -256,8 +256,8 @@ static void close(struct roots_view *view) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy(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 =
|
||||||
struct roots_xdg_surface_v6 *roots_xdg_surface = view->roots_xdg_surface_v6;
|
roots_xdg_surface_v6_from_view(view);
|
||||||
wl_list_remove(&roots_xdg_surface->surface_commit.link);
|
wl_list_remove(&roots_xdg_surface->surface_commit.link);
|
||||||
wl_list_remove(&roots_xdg_surface->destroy.link);
|
wl_list_remove(&roots_xdg_surface->destroy.link);
|
||||||
wl_list_remove(&roots_xdg_surface->new_popup.link);
|
wl_list_remove(&roots_xdg_surface->new_popup.link);
|
||||||
|
@ -285,7 +285,7 @@ static const struct roots_view_interface view_impl = {
|
||||||
static void handle_request_move(struct wl_listener *listener, void *data) {
|
static void handle_request_move(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, request_move);
|
wl_container_of(listener, roots_xdg_surface, request_move);
|
||||||
struct roots_view *view = roots_xdg_surface->view;
|
struct roots_view *view = &roots_xdg_surface->view;
|
||||||
struct roots_input *input = view->desktop->server->input;
|
struct roots_input *input = view->desktop->server->input;
|
||||||
struct wlr_xdg_toplevel_v6_move_event *e = data;
|
struct wlr_xdg_toplevel_v6_move_event *e = data;
|
||||||
struct roots_seat *seat = input_seat_from_wlr_seat(input, e->seat->seat);
|
struct roots_seat *seat = input_seat_from_wlr_seat(input, e->seat->seat);
|
||||||
|
@ -299,7 +299,7 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
|
||||||
static void handle_request_resize(struct wl_listener *listener, void *data) {
|
static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, request_resize);
|
wl_container_of(listener, roots_xdg_surface, request_resize);
|
||||||
struct roots_view *view = roots_xdg_surface->view;
|
struct roots_view *view = &roots_xdg_surface->view;
|
||||||
struct roots_input *input = view->desktop->server->input;
|
struct roots_input *input = view->desktop->server->input;
|
||||||
struct wlr_xdg_toplevel_v6_resize_event *e = data;
|
struct wlr_xdg_toplevel_v6_resize_event *e = data;
|
||||||
// TODO verify event serial
|
// TODO verify event serial
|
||||||
|
@ -314,8 +314,8 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
static void handle_request_maximize(struct wl_listener *listener, void *data) {
|
static void handle_request_maximize(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, request_maximize);
|
wl_container_of(listener, roots_xdg_surface, request_maximize);
|
||||||
struct roots_view *view = roots_xdg_surface->view;
|
struct roots_view *view = &roots_xdg_surface->view;
|
||||||
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
struct wlr_xdg_surface_v6 *surface = roots_xdg_surface->xdg_surface_v6;
|
||||||
|
|
||||||
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
||||||
return;
|
return;
|
||||||
|
@ -328,8 +328,8 @@ static void handle_request_fullscreen(struct wl_listener *listener,
|
||||||
void *data) {
|
void *data) {
|
||||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, request_fullscreen);
|
wl_container_of(listener, roots_xdg_surface, request_fullscreen);
|
||||||
struct roots_view *view = roots_xdg_surface->view;
|
struct roots_view *view = &roots_xdg_surface->view;
|
||||||
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
struct wlr_xdg_surface_v6 *surface = roots_xdg_surface->xdg_surface_v6;
|
||||||
struct wlr_xdg_toplevel_v6_set_fullscreen_event *e = data;
|
struct wlr_xdg_toplevel_v6_set_fullscreen_event *e = data;
|
||||||
|
|
||||||
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
||||||
|
@ -343,23 +343,23 @@ static void handle_set_title(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, set_title);
|
wl_container_of(listener, roots_xdg_surface, set_title);
|
||||||
|
|
||||||
view_set_title(roots_xdg_surface->view,
|
view_set_title(&roots_xdg_surface->view,
|
||||||
roots_xdg_surface->view->xdg_surface_v6->toplevel->title);
|
roots_xdg_surface->xdg_surface_v6->toplevel->title);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_set_app_id(struct wl_listener *listener, void *data) {
|
static void handle_set_app_id(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, set_app_id);
|
wl_container_of(listener, roots_xdg_surface, set_app_id);
|
||||||
|
|
||||||
view_set_app_id(roots_xdg_surface->view,
|
view_set_app_id(&roots_xdg_surface->view,
|
||||||
roots_xdg_surface->view->xdg_surface_v6->toplevel->app_id);
|
roots_xdg_surface->xdg_surface_v6->toplevel->app_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface_v6 *roots_surface =
|
struct roots_xdg_surface_v6 *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, surface_commit);
|
wl_container_of(listener, roots_surface, surface_commit);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
struct wlr_xdg_surface_v6 *surface = roots_surface->xdg_surface_v6;
|
||||||
|
|
||||||
if (!surface->mapped) {
|
if (!surface->mapped) {
|
||||||
return;
|
return;
|
||||||
|
@ -396,38 +396,38 @@ static void handle_new_popup(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, new_popup);
|
wl_container_of(listener, roots_xdg_surface, new_popup);
|
||||||
struct wlr_xdg_popup_v6 *wlr_popup = data;
|
struct wlr_xdg_popup_v6 *wlr_popup = data;
|
||||||
popup_create(roots_xdg_surface->view, wlr_popup);
|
popup_create(&roots_xdg_surface->view, wlr_popup);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_map(struct wl_listener *listener, void *data) {
|
static void handle_map(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, map);
|
wl_container_of(listener, roots_xdg_surface, map);
|
||||||
struct roots_view *view = roots_xdg_surface->view;
|
struct roots_view *view = &roots_xdg_surface->view;
|
||||||
|
|
||||||
struct wlr_box box;
|
struct wlr_box box;
|
||||||
get_size(view, &box);
|
get_size(view, &box);
|
||||||
view->box.width = box.width;
|
view->box.width = box.width;
|
||||||
view->box.height = box.height;
|
view->box.height = box.height;
|
||||||
|
|
||||||
view_map(view, view->xdg_surface_v6->surface);
|
view_map(view, roots_xdg_surface->xdg_surface_v6->surface);
|
||||||
view_setup(view);
|
view_setup(view);
|
||||||
|
|
||||||
wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle,
|
wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle,
|
||||||
view->xdg_surface_v6->toplevel->title ?: "none");
|
roots_xdg_surface->xdg_surface_v6->toplevel->title ?: "none");
|
||||||
wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle,
|
wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle,
|
||||||
view->xdg_surface_v6->toplevel->app_id ?: "none");
|
roots_xdg_surface->xdg_surface_v6->toplevel->app_id ?: "none");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_unmap(struct wl_listener *listener, void *data) {
|
static void handle_unmap(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, unmap);
|
wl_container_of(listener, roots_xdg_surface, unmap);
|
||||||
view_unmap(roots_xdg_surface->view);
|
view_unmap(&roots_xdg_surface->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
wl_container_of(listener, roots_xdg_surface, destroy);
|
wl_container_of(listener, roots_xdg_surface, destroy);
|
||||||
view_destroy(roots_xdg_surface->view);
|
view_destroy(&roots_xdg_surface->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
|
@ -451,6 +451,10 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
if (!roots_surface) {
|
if (!roots_surface) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view_init(&roots_surface->view, &view_impl, ROOTS_XDG_SHELL_V6_VIEW, desktop);
|
||||||
|
roots_surface->xdg_surface_v6 = surface;
|
||||||
|
|
||||||
roots_surface->surface_commit.notify = handle_surface_commit;
|
roots_surface->surface_commit.notify = handle_surface_commit;
|
||||||
wl_signal_add(&surface->surface->events.commit,
|
wl_signal_add(&surface->surface->events.commit,
|
||||||
&roots_surface->surface_commit);
|
&roots_surface->surface_commit);
|
||||||
|
@ -480,22 +484,10 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
&roots_surface->set_app_id);
|
&roots_surface->set_app_id);
|
||||||
roots_surface->new_popup.notify = handle_new_popup;
|
roots_surface->new_popup.notify = handle_new_popup;
|
||||||
wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
|
wl_signal_add(&surface->events.new_popup, &roots_surface->new_popup);
|
||||||
|
}
|
||||||
struct roots_view *view = view_create(desktop, &view_impl);
|
|
||||||
if (!view) {
|
struct roots_xdg_surface_v6 *roots_xdg_surface_v6_from_view(
|
||||||
free(roots_surface);
|
struct roots_view *view) {
|
||||||
return;
|
assert(view->impl == &view_impl);
|
||||||
}
|
return (struct roots_xdg_surface_v6 *)view;
|
||||||
view->type = ROOTS_XDG_SHELL_V6_VIEW;
|
|
||||||
|
|
||||||
view->xdg_surface_v6 = surface;
|
|
||||||
view->roots_xdg_surface_v6 = roots_surface;
|
|
||||||
roots_surface->view = view;
|
|
||||||
|
|
||||||
if (surface->toplevel->client_pending.maximized) {
|
|
||||||
view_maximize(view, true);
|
|
||||||
}
|
|
||||||
if (surface->toplevel->client_pending.fullscreen) {
|
|
||||||
view_set_fullscreen(view, true, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,14 @@
|
||||||
#include "rootston/server.h"
|
#include "rootston/server.h"
|
||||||
|
|
||||||
static void activate(struct roots_view *view, bool active) {
|
static void activate(struct roots_view *view, bool active) {
|
||||||
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
struct wlr_xwayland_surface *xwayland_surface =
|
||||||
wlr_xwayland_surface_activate(view->xwayland_surface, active);
|
roots_xwayland_surface_from_view(view)->xwayland_surface;
|
||||||
|
wlr_xwayland_surface_activate(xwayland_surface, active);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void move(struct roots_view *view, double x, double y) {
|
static void move(struct roots_view *view, double x, double y) {
|
||||||
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
struct wlr_xwayland_surface *xwayland_surface =
|
||||||
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
|
roots_xwayland_surface_from_view(view)->xwayland_surface;
|
||||||
view_update_position(view, x, y);
|
view_update_position(view, x, y);
|
||||||
wlr_xwayland_surface_configure(xwayland_surface, x, y,
|
wlr_xwayland_surface_configure(xwayland_surface, x, y,
|
||||||
xwayland_surface->width, xwayland_surface->height);
|
xwayland_surface->width, xwayland_surface->height);
|
||||||
|
@ -48,8 +49,8 @@ static void apply_size_constraints(
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
|
static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
|
||||||
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
struct wlr_xwayland_surface *xwayland_surface =
|
||||||
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
|
roots_xwayland_surface_from_view(view)->xwayland_surface;
|
||||||
|
|
||||||
uint32_t constrained_width, constrained_height;
|
uint32_t constrained_width, constrained_height;
|
||||||
apply_size_constraints(xwayland_surface, width, height, &constrained_width,
|
apply_size_constraints(xwayland_surface, width, height, &constrained_width,
|
||||||
|
@ -61,8 +62,8 @@ static void resize(struct roots_view *view, uint32_t width, uint32_t height) {
|
||||||
|
|
||||||
static void move_resize(struct roots_view *view, double x, double y,
|
static void move_resize(struct roots_view *view, double x, double y,
|
||||||
uint32_t width, uint32_t height) {
|
uint32_t width, uint32_t height) {
|
||||||
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
struct wlr_xwayland_surface *xwayland_surface =
|
||||||
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
|
roots_xwayland_surface_from_view(view)->xwayland_surface;
|
||||||
|
|
||||||
bool update_x = x != view->box.x;
|
bool update_x = x != view->box.x;
|
||||||
bool update_y = y != view->box.y;
|
bool update_y = y != view->box.y;
|
||||||
|
@ -90,25 +91,26 @@ static void move_resize(struct roots_view *view, double x, double y,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close(struct roots_view *view) {
|
static void close(struct roots_view *view) {
|
||||||
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
struct wlr_xwayland_surface *xwayland_surface =
|
||||||
wlr_xwayland_surface_close(view->xwayland_surface);
|
roots_xwayland_surface_from_view(view)->xwayland_surface;
|
||||||
|
wlr_xwayland_surface_close(xwayland_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void maximize(struct roots_view *view, bool maximized) {
|
static void maximize(struct roots_view *view, bool maximized) {
|
||||||
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
struct wlr_xwayland_surface *xwayland_surface =
|
||||||
|
roots_xwayland_surface_from_view(view)->xwayland_surface;
|
||||||
wlr_xwayland_surface_set_maximized(view->xwayland_surface, maximized);
|
wlr_xwayland_surface_set_maximized(xwayland_surface, maximized);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_fullscreen(struct roots_view *view, bool fullscreen) {
|
static void set_fullscreen(struct roots_view *view, bool fullscreen) {
|
||||||
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
struct wlr_xwayland_surface *xwayland_surface =
|
||||||
|
roots_xwayland_surface_from_view(view)->xwayland_surface;
|
||||||
wlr_xwayland_surface_set_fullscreen(view->xwayland_surface, fullscreen);
|
wlr_xwayland_surface_set_fullscreen(xwayland_surface, fullscreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy(struct roots_view *view) {
|
static void destroy(struct roots_view *view) {
|
||||||
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
struct roots_xwayland_surface *roots_surface =
|
||||||
struct roots_xwayland_surface *roots_surface = view->roots_xwayland_surface;
|
roots_xwayland_surface_from_view(view);
|
||||||
wl_list_remove(&roots_surface->destroy.link);
|
wl_list_remove(&roots_surface->destroy.link);
|
||||||
wl_list_remove(&roots_surface->request_configure.link);
|
wl_list_remove(&roots_surface->request_configure.link);
|
||||||
wl_list_remove(&roots_surface->request_move.link);
|
wl_list_remove(&roots_surface->request_move.link);
|
||||||
|
@ -135,17 +137,17 @@ static const struct roots_view_interface view_impl = {
|
||||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, destroy);
|
wl_container_of(listener, roots_surface, destroy);
|
||||||
view_destroy(roots_surface->view);
|
view_destroy(&roots_surface->view);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_request_configure(struct wl_listener *listener, void *data) {
|
static void handle_request_configure(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, request_configure);
|
wl_container_of(listener, roots_surface, request_configure);
|
||||||
struct wlr_xwayland_surface *xwayland_surface =
|
struct wlr_xwayland_surface *xwayland_surface =
|
||||||
roots_surface->view->xwayland_surface;
|
roots_surface->xwayland_surface;
|
||||||
struct wlr_xwayland_surface_configure_event *event = data;
|
struct wlr_xwayland_surface_configure_event *event = data;
|
||||||
|
|
||||||
view_update_position(roots_surface->view, event->x, event->y);
|
view_update_position(&roots_surface->view, event->x, event->y);
|
||||||
|
|
||||||
wlr_xwayland_surface_configure(xwayland_surface, event->x, event->y,
|
wlr_xwayland_surface_configure(xwayland_surface, event->x, event->y,
|
||||||
event->width, event->height);
|
event->width, event->height);
|
||||||
|
@ -167,7 +169,7 @@ static struct roots_seat *guess_seat_for_view(struct roots_view *view) {
|
||||||
static void handle_request_move(struct wl_listener *listener, void *data) {
|
static void handle_request_move(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, request_move);
|
wl_container_of(listener, roots_surface, request_move);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
struct roots_seat *seat = guess_seat_for_view(view);
|
struct roots_seat *seat = guess_seat_for_view(view);
|
||||||
|
|
||||||
if (!seat || seat->cursor->mode != ROOTS_CURSOR_PASSTHROUGH) {
|
if (!seat || seat->cursor->mode != ROOTS_CURSOR_PASSTHROUGH) {
|
||||||
|
@ -180,7 +182,7 @@ static void handle_request_move(struct wl_listener *listener, void *data) {
|
||||||
static void handle_request_resize(struct wl_listener *listener, void *data) {
|
static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, request_resize);
|
wl_container_of(listener, roots_surface, request_resize);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
struct roots_seat *seat = guess_seat_for_view(view);
|
struct roots_seat *seat = guess_seat_for_view(view);
|
||||||
struct wlr_xwayland_resize_event *e = data;
|
struct wlr_xwayland_resize_event *e = data;
|
||||||
|
|
||||||
|
@ -193,8 +195,9 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
static void handle_request_maximize(struct wl_listener *listener, void *data) {
|
static void handle_request_maximize(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, request_maximize);
|
wl_container_of(listener, roots_surface, request_maximize);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
|
struct wlr_xwayland_surface *xwayland_surface =
|
||||||
|
roots_surface->xwayland_surface;
|
||||||
|
|
||||||
bool maximized = xwayland_surface->maximized_vert &&
|
bool maximized = xwayland_surface->maximized_vert &&
|
||||||
xwayland_surface->maximized_horz;
|
xwayland_surface->maximized_horz;
|
||||||
|
@ -205,8 +208,9 @@ static void handle_request_fullscreen(struct wl_listener *listener,
|
||||||
void *data) {
|
void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, request_fullscreen);
|
wl_container_of(listener, roots_surface, request_fullscreen);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
|
struct wlr_xwayland_surface *xwayland_surface =
|
||||||
|
roots_surface->xwayland_surface;
|
||||||
|
|
||||||
view_set_fullscreen(view, xwayland_surface->fullscreen, NULL);
|
view_set_fullscreen(view, xwayland_surface->fullscreen, NULL);
|
||||||
}
|
}
|
||||||
|
@ -215,22 +219,22 @@ static void handle_set_title(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, set_title);
|
wl_container_of(listener, roots_surface, set_title);
|
||||||
|
|
||||||
view_set_title(roots_surface->view,
|
view_set_title(&roots_surface->view,
|
||||||
roots_surface->view->xwayland_surface->title);
|
roots_surface->xwayland_surface->title);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_set_class(struct wl_listener *listener, void *data) {
|
static void handle_set_class(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, set_class);
|
wl_container_of(listener, roots_surface, set_class);
|
||||||
|
|
||||||
view_set_app_id(roots_surface->view,
|
view_set_app_id(&roots_surface->view,
|
||||||
roots_surface->view->xwayland_surface->class);
|
roots_surface->xwayland_surface->class);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, surface_commit);
|
wl_container_of(listener, roots_surface, surface_commit);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
struct wlr_surface *wlr_surface = view->wlr_surface;
|
struct wlr_surface *wlr_surface = view->wlr_surface;
|
||||||
|
|
||||||
view_apply_damage(view);
|
view_apply_damage(view);
|
||||||
|
@ -258,7 +262,7 @@ static void handle_map(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, map);
|
wl_container_of(listener, roots_surface, map);
|
||||||
struct wlr_xwayland_surface *surface = data;
|
struct wlr_xwayland_surface *surface = data;
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
|
|
||||||
view->box.x = surface->x;
|
view->box.x = surface->x;
|
||||||
view->box.y = surface->y;
|
view->box.y = surface->y;
|
||||||
|
@ -281,9 +285,9 @@ static void handle_map(struct wl_listener *listener, void *data) {
|
||||||
view_setup(view);
|
view_setup(view);
|
||||||
|
|
||||||
wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle,
|
wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle,
|
||||||
view->xwayland_surface->title ?: "none");
|
roots_surface->xwayland_surface->title ?: "none");
|
||||||
wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle,
|
wlr_foreign_toplevel_handle_v1_set_app_id(view->toplevel_handle,
|
||||||
view->xwayland_surface->class ?: "none");
|
roots_surface->xwayland_surface->class ?: "none");
|
||||||
} else {
|
} else {
|
||||||
view_initial_focus(view);
|
view_initial_focus(view);
|
||||||
}
|
}
|
||||||
|
@ -292,7 +296,7 @@ static void handle_map(struct wl_listener *listener, void *data) {
|
||||||
static void handle_unmap(struct wl_listener *listener, void *data) {
|
static void handle_unmap(struct wl_listener *listener, void *data) {
|
||||||
struct roots_xwayland_surface *roots_surface =
|
struct roots_xwayland_surface *roots_surface =
|
||||||
wl_container_of(listener, roots_surface, unmap);
|
wl_container_of(listener, roots_surface, unmap);
|
||||||
struct roots_view *view = roots_surface->view;
|
struct roots_view *view = &roots_surface->view;
|
||||||
|
|
||||||
wl_list_remove(&roots_surface->surface_commit.link);
|
wl_list_remove(&roots_surface->surface_commit.link);
|
||||||
view_unmap(view);
|
view_unmap(view);
|
||||||
|
@ -313,6 +317,11 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view_init(&roots_surface->view, &view_impl, ROOTS_XWAYLAND_VIEW, desktop);
|
||||||
|
roots_surface->view.box.x = surface->x;
|
||||||
|
roots_surface->view.box.y = surface->y;
|
||||||
|
roots_surface->xwayland_surface = surface;
|
||||||
|
|
||||||
roots_surface->destroy.notify = handle_destroy;
|
roots_surface->destroy.notify = handle_destroy;
|
||||||
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
|
wl_signal_add(&surface->events.destroy, &roots_surface->destroy);
|
||||||
roots_surface->request_configure.notify = handle_request_configure;
|
roots_surface->request_configure.notify = handle_request_configure;
|
||||||
|
@ -338,17 +347,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||||
roots_surface->set_class.notify = handle_set_class;
|
roots_surface->set_class.notify = handle_set_class;
|
||||||
wl_signal_add(&surface->events.set_class,
|
wl_signal_add(&surface->events.set_class,
|
||||||
&roots_surface->set_class);
|
&roots_surface->set_class);
|
||||||
|
}
|
||||||
struct roots_view *view = view_create(desktop, &view_impl);
|
|
||||||
if (view == NULL) {
|
struct roots_xwayland_surface *roots_xwayland_surface_from_view(
|
||||||
free(roots_surface);
|
struct roots_view *view) {
|
||||||
return;
|
assert(view->impl == &view_impl);
|
||||||
}
|
return (struct roots_xwayland_surface *)view;
|
||||||
view->type = ROOTS_XWAYLAND_VIEW;
|
|
||||||
view->box.x = surface->x;
|
|
||||||
view->box.y = surface->y;
|
|
||||||
|
|
||||||
view->xwayland_surface = surface;
|
|
||||||
view->roots_xwayland_surface = roots_surface;
|
|
||||||
roots_surface->view = view;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue