mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-29 16:05:59 +01:00
Merge pull request #390 from emersion/rootston-maximize
Maximize views in rootston
This commit is contained in:
commit
e6babc07a0
11 changed files with 220 additions and 47 deletions
|
@ -11,9 +11,10 @@ struct roots_wl_shell_surface {
|
||||||
|
|
||||||
// TODO: Maybe destroy listener should go in roots_view
|
// TODO: Maybe destroy listener should go in roots_view
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
struct wl_listener ping_timeout;
|
|
||||||
struct wl_listener request_move;
|
struct wl_listener request_move;
|
||||||
struct wl_listener request_resize;
|
struct wl_listener request_resize;
|
||||||
|
struct wl_listener request_set_maximized;
|
||||||
|
struct wl_listener set_state;
|
||||||
|
|
||||||
struct wl_listener surface_commit;
|
struct wl_listener surface_commit;
|
||||||
};
|
};
|
||||||
|
@ -26,6 +27,7 @@ struct roots_xdg_surface_v6 {
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
struct wl_listener request_move;
|
struct wl_listener request_move;
|
||||||
struct wl_listener request_resize;
|
struct wl_listener request_resize;
|
||||||
|
struct wl_listener request_maximize;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct roots_xwayland_surface {
|
struct roots_xwayland_surface {
|
||||||
|
@ -36,6 +38,7 @@ struct roots_xwayland_surface {
|
||||||
struct wl_listener request_configure;
|
struct wl_listener request_configure;
|
||||||
struct wl_listener request_move;
|
struct wl_listener request_move;
|
||||||
struct wl_listener request_resize;
|
struct wl_listener request_resize;
|
||||||
|
struct wl_listener request_maximize;
|
||||||
struct wl_listener map_notify;
|
struct wl_listener map_notify;
|
||||||
struct wl_listener unmap_notify;
|
struct wl_listener unmap_notify;
|
||||||
};
|
};
|
||||||
|
@ -48,8 +51,17 @@ enum roots_view_type {
|
||||||
|
|
||||||
struct roots_view {
|
struct roots_view {
|
||||||
struct roots_desktop *desktop;
|
struct roots_desktop *desktop;
|
||||||
|
|
||||||
double x, y;
|
double x, y;
|
||||||
float rotation;
|
float rotation;
|
||||||
|
|
||||||
|
bool maximized;
|
||||||
|
struct {
|
||||||
|
double x, y;
|
||||||
|
uint32_t width, height;
|
||||||
|
float rotation;
|
||||||
|
} saved;
|
||||||
|
|
||||||
// TODO: Something for roots-enforced width/height
|
// TODO: Something for roots-enforced width/height
|
||||||
enum roots_view_type type;
|
enum roots_view_type type;
|
||||||
union {
|
union {
|
||||||
|
@ -67,6 +79,7 @@ struct roots_view {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
struct wlr_surface *wlr_surface;
|
struct wlr_surface *wlr_surface;
|
||||||
|
|
||||||
// TODO: This would probably be better as a field that's updated on a
|
// TODO: This would probably be better as a field that's updated on a
|
||||||
// configure event from the xdg_shell
|
// configure event from the xdg_shell
|
||||||
// If not then this should follow the typical type/impl pattern we use
|
// If not then this should follow the typical type/impl pattern we use
|
||||||
|
@ -77,6 +90,7 @@ struct roots_view {
|
||||||
void (*resize)(struct roots_view *view, uint32_t width, uint32_t height);
|
void (*resize)(struct roots_view *view, uint32_t width, uint32_t height);
|
||||||
void (*move_resize)(struct roots_view *view, double x, double y,
|
void (*move_resize)(struct roots_view *view, double x, double y,
|
||||||
uint32_t width, uint32_t height);
|
uint32_t width, uint32_t height);
|
||||||
|
void (*maximize)(struct roots_view *view, bool maximized);
|
||||||
void (*close)(struct roots_view *view);
|
void (*close)(struct roots_view *view);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -86,6 +100,7 @@ void view_move(struct roots_view *view, double x, double y);
|
||||||
void view_resize(struct roots_view *view, uint32_t width, uint32_t height);
|
void view_resize(struct roots_view *view, uint32_t width, uint32_t height);
|
||||||
void view_move_resize(struct roots_view *view, double x, double y,
|
void view_move_resize(struct roots_view *view, double x, double y,
|
||||||
uint32_t width, uint32_t height);
|
uint32_t width, uint32_t height);
|
||||||
|
void view_maximize(struct roots_view *view, bool maximized);
|
||||||
void view_close(struct roots_view *view);
|
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);
|
||||||
|
|
|
@ -42,6 +42,8 @@ struct wlr_wl_shell_popup_grab {
|
||||||
enum wlr_wl_shell_surface_state {
|
enum wlr_wl_shell_surface_state {
|
||||||
WLR_WL_SHELL_SURFACE_STATE_NONE,
|
WLR_WL_SHELL_SURFACE_STATE_NONE,
|
||||||
WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL,
|
WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL,
|
||||||
|
WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED,
|
||||||
|
WLR_WL_SHELL_SURFACE_STATE_FULLSCREEN,
|
||||||
WLR_WL_SHELL_SURFACE_STATE_TRANSIENT,
|
WLR_WL_SHELL_SURFACE_STATE_TRANSIENT,
|
||||||
WLR_WL_SHELL_SURFACE_STATE_POPUP,
|
WLR_WL_SHELL_SURFACE_STATE_POPUP,
|
||||||
};
|
};
|
||||||
|
|
|
@ -126,6 +126,8 @@ struct wlr_xdg_surface_v6 {
|
||||||
struct wl_signal ack_configure;
|
struct wl_signal ack_configure;
|
||||||
struct wl_signal ping_timeout;
|
struct wl_signal ping_timeout;
|
||||||
|
|
||||||
|
struct wl_signal request_maximize;
|
||||||
|
struct wl_signal request_fullscreen;
|
||||||
struct wl_signal request_minimize;
|
struct wl_signal request_minimize;
|
||||||
struct wl_signal request_move;
|
struct wl_signal request_move;
|
||||||
struct wl_signal request_resize;
|
struct wl_signal request_resize;
|
||||||
|
|
|
@ -42,8 +42,15 @@ void view_begin_move(struct roots_input *input, struct wlr_cursor *cursor,
|
||||||
input->mode = ROOTS_CURSOR_MOVE;
|
input->mode = ROOTS_CURSOR_MOVE;
|
||||||
input->offs_x = cursor->x;
|
input->offs_x = cursor->x;
|
||||||
input->offs_y = cursor->y;
|
input->offs_y = cursor->y;
|
||||||
input->view_x = view->x;
|
if (view->maximized) {
|
||||||
input->view_y = view->y;
|
input->view_x = view->saved.x;
|
||||||
|
input->view_y = view->saved.y;
|
||||||
|
} else {
|
||||||
|
input->view_x = view->x;
|
||||||
|
input->view_y = view->y;
|
||||||
|
}
|
||||||
|
|
||||||
|
view_maximize(view, false);
|
||||||
wlr_seat_pointer_clear_focus(input->wl_seat);
|
wlr_seat_pointer_clear_focus(input->wl_seat);
|
||||||
|
|
||||||
struct wlr_xcursor *xcursor = get_move_xcursor(input->xcursor_theme);
|
struct wlr_xcursor *xcursor = get_move_xcursor(input->xcursor_theme);
|
||||||
|
@ -57,13 +64,22 @@ void view_begin_resize(struct roots_input *input, struct wlr_cursor *cursor,
|
||||||
input->mode = ROOTS_CURSOR_RESIZE;
|
input->mode = ROOTS_CURSOR_RESIZE;
|
||||||
input->offs_x = cursor->x;
|
input->offs_x = cursor->x;
|
||||||
input->offs_y = cursor->y;
|
input->offs_y = cursor->y;
|
||||||
input->view_x = view->x;
|
if (view->maximized) {
|
||||||
input->view_y = view->y;
|
input->view_x = view->saved.x;
|
||||||
struct wlr_box size;
|
input->view_y = view->saved.y;
|
||||||
view_get_size(view, &size);
|
input->view_width = view->saved.width;
|
||||||
input->view_width = size.width;
|
input->view_height = view->saved.height;
|
||||||
input->view_height = size.height;
|
} else {
|
||||||
|
input->view_x = view->x;
|
||||||
|
input->view_y = view->y;
|
||||||
|
struct wlr_box size;
|
||||||
|
view_get_size(view, &size);
|
||||||
|
input->view_width = size.width;
|
||||||
|
input->view_height = size.height;
|
||||||
|
}
|
||||||
input->resize_edges = edges;
|
input->resize_edges = edges;
|
||||||
|
|
||||||
|
view_maximize(view, false);
|
||||||
wlr_seat_pointer_clear_focus(input->wl_seat);
|
wlr_seat_pointer_clear_focus(input->wl_seat);
|
||||||
|
|
||||||
struct wlr_xcursor *xcursor = get_resize_xcursor(input->xcursor_theme, edges);
|
struct wlr_xcursor *xcursor = get_resize_xcursor(input->xcursor_theme, edges);
|
||||||
|
@ -78,6 +94,8 @@ void view_begin_rotate(struct roots_input *input, struct wlr_cursor *cursor,
|
||||||
input->offs_x = cursor->x;
|
input->offs_x = cursor->x;
|
||||||
input->offs_y = cursor->y;
|
input->offs_y = cursor->y;
|
||||||
input->view_rotation = view->rotation;
|
input->view_rotation = view->rotation;
|
||||||
|
|
||||||
|
view_maximize(view, false);
|
||||||
wlr_seat_pointer_clear_focus(input->wl_seat);
|
wlr_seat_pointer_clear_focus(input->wl_seat);
|
||||||
|
|
||||||
struct wlr_xcursor *xcursor = get_rotate_xcursor(input->xcursor_theme);
|
struct wlr_xcursor *xcursor = get_rotate_xcursor(input->xcursor_theme);
|
||||||
|
@ -102,7 +120,8 @@ void cursor_update_position(struct roots_input *input, uint32_t time) {
|
||||||
set_compositor_cursor = view_client != input->cursor_client;
|
set_compositor_cursor = view_client != input->cursor_client;
|
||||||
}
|
}
|
||||||
if (set_compositor_cursor) {
|
if (set_compositor_cursor) {
|
||||||
struct wlr_xcursor *xcursor = get_default_xcursor(input->xcursor_theme);
|
struct wlr_xcursor *xcursor =
|
||||||
|
get_default_xcursor(input->xcursor_theme);
|
||||||
cursor_set_xcursor_image(input, xcursor->images[0]);
|
cursor_set_xcursor_image(input, xcursor->images[0]);
|
||||||
input->cursor_client = NULL;
|
input->cursor_client = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,50 @@ void view_move_resize(struct roots_view *view, double x, double y,
|
||||||
view_resize(view, width, height);
|
view_resize(view, width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void view_maximize(struct roots_view *view, bool maximized) {
|
||||||
|
if (view->maximized == maximized) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view->maximize) {
|
||||||
|
view->maximize(view, maximized);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!view->maximized && maximized) {
|
||||||
|
struct wlr_box view_box;
|
||||||
|
view_get_size(view, &view_box);
|
||||||
|
|
||||||
|
view->maximized = true;
|
||||||
|
view->saved.x = view->x;
|
||||||
|
view->saved.y = view->y;
|
||||||
|
view->saved.rotation = view->rotation;
|
||||||
|
view->saved.width = view_box.width;
|
||||||
|
view->saved.height = view_box.height;
|
||||||
|
|
||||||
|
double output_x, output_y;
|
||||||
|
wlr_output_layout_closest_point(view->desktop->layout, NULL,
|
||||||
|
view->x + (double)view_box.width/2,
|
||||||
|
view->y + (double)view_box.height/2,
|
||||||
|
&output_x, &output_y);
|
||||||
|
struct wlr_output *output = wlr_output_layout_output_at(
|
||||||
|
view->desktop->layout, output_x, output_y);
|
||||||
|
struct wlr_box *output_box =
|
||||||
|
wlr_output_layout_get_box(view->desktop->layout, output);
|
||||||
|
|
||||||
|
view_move_resize(view, output_box->x, output_box->y, output_box->width,
|
||||||
|
output_box->height);
|
||||||
|
view->rotation = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (view->maximized && !maximized) {
|
||||||
|
view->maximized = false;
|
||||||
|
|
||||||
|
view_move_resize(view, view->saved.x, view->saved.y, view->saved.width,
|
||||||
|
view->saved.height);
|
||||||
|
view->rotation = view->saved.rotation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void view_close(struct roots_view *view) {
|
void view_close(struct roots_view *view) {
|
||||||
if (view->close) {
|
if (view->close) {
|
||||||
view->close(view);
|
view->close(view);
|
||||||
|
|
|
@ -49,6 +49,26 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
view_begin_resize(input, event->cursor, view, e->edges);
|
view_begin_resize(input, event->cursor, view, e->edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_request_set_maximized(struct wl_listener *listener,
|
||||||
|
void *data) {
|
||||||
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
|
wl_container_of(listener, roots_surface, request_set_maximized);
|
||||||
|
struct roots_view *view = roots_surface->view;
|
||||||
|
//struct wlr_wl_shell_surface_set_maximized_event *e = data;
|
||||||
|
view_maximize(view, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void handle_set_state(struct wl_listener *listener, void *data) {
|
||||||
|
struct roots_wl_shell_surface *roots_surface =
|
||||||
|
wl_container_of(listener, roots_surface, set_state);
|
||||||
|
struct roots_view *view = roots_surface->view;
|
||||||
|
struct wlr_wl_shell_surface *surface = view->wl_shell_surface;
|
||||||
|
if (view->maximized &&
|
||||||
|
surface->state != WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED) {
|
||||||
|
view_maximize(view, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
static void handle_surface_commit(struct wl_listener *listener, void *data) {
|
||||||
// TODO do we need to do anything here?
|
// TODO do we need to do anything here?
|
||||||
}
|
}
|
||||||
|
@ -60,6 +80,9 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
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);
|
||||||
|
wl_list_remove(&roots_surface->request_set_maximized.link);
|
||||||
|
wl_list_remove(&roots_surface->set_state.link);
|
||||||
|
wl_list_remove(&roots_surface->surface_commit.link);
|
||||||
view_destroy(roots_surface->view);
|
view_destroy(roots_surface->view);
|
||||||
free(roots_surface);
|
free(roots_surface);
|
||||||
}
|
}
|
||||||
|
@ -93,6 +116,11 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) {
|
||||||
roots_surface->request_resize.notify = handle_request_resize;
|
roots_surface->request_resize.notify = handle_request_resize;
|
||||||
wl_signal_add(&surface->events.request_resize,
|
wl_signal_add(&surface->events.request_resize,
|
||||||
&roots_surface->request_resize);
|
&roots_surface->request_resize);
|
||||||
|
roots_surface->request_set_maximized.notify = handle_request_set_maximized;
|
||||||
|
wl_signal_add(&surface->events.request_set_maximized,
|
||||||
|
&roots_surface->request_set_maximized);
|
||||||
|
roots_surface->set_state.notify = handle_set_state;
|
||||||
|
wl_signal_add(&surface->events.set_state, &roots_surface->set_state);
|
||||||
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);
|
||||||
|
|
|
@ -84,6 +84,16 @@ static void move_resize(struct roots_view *view, double x, double y,
|
||||||
wlr_xdg_toplevel_v6_set_size(surf, contrained_width, contrained_height);
|
wlr_xdg_toplevel_v6_set_size(surf, contrained_width, contrained_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void maximize(struct roots_view *view, bool maximized) {
|
||||||
|
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
||||||
|
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
||||||
|
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wlr_xdg_toplevel_v6_set_maximized(surface, maximized);
|
||||||
|
}
|
||||||
|
|
||||||
static void close(struct roots_view *view) {
|
static void close(struct roots_view *view) {
|
||||||
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
assert(view->type == ROOTS_XDG_SHELL_V6_VIEW);
|
||||||
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
|
struct wlr_xdg_surface_v6 *surf = view->xdg_surface_v6;
|
||||||
|
@ -118,8 +128,25 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
view_begin_resize(input, event->cursor, view, e->edges);
|
view_begin_resize(input, event->cursor, view, e->edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_request_maximize(struct wl_listener *listener, void *data) {
|
||||||
|
struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
|
wl_container_of(listener, roots_xdg_surface, request_maximize);
|
||||||
|
struct roots_view *view = roots_xdg_surface->view;
|
||||||
|
struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
||||||
|
|
||||||
|
if (surface->role != WLR_XDG_SURFACE_V6_ROLE_TOPLEVEL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
view_maximize(view, surface->toplevel_state->next.maximized);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_commit(struct wl_listener *listener, void *data) {
|
static void handle_commit(struct wl_listener *listener, void *data) {
|
||||||
// TODO is there anything we need to do here?
|
//struct roots_xdg_surface_v6 *roots_xdg_surface =
|
||||||
|
// wl_container_of(listener, roots_xdg_surface, commit);
|
||||||
|
//struct roots_view *view = roots_xdg_surface->view;
|
||||||
|
//struct wlr_xdg_surface_v6 *surface = view->xdg_surface_v6;
|
||||||
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||||
|
@ -164,6 +191,9 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
roots_surface->request_resize.notify = handle_request_resize;
|
roots_surface->request_resize.notify = handle_request_resize;
|
||||||
wl_signal_add(&surface->events.request_resize,
|
wl_signal_add(&surface->events.request_resize,
|
||||||
&roots_surface->request_resize);
|
&roots_surface->request_resize);
|
||||||
|
roots_surface->request_maximize.notify = handle_request_maximize;
|
||||||
|
wl_signal_add(&surface->events.request_maximize,
|
||||||
|
&roots_surface->request_maximize);
|
||||||
|
|
||||||
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
||||||
if (!view) {
|
if (!view) {
|
||||||
|
@ -178,6 +208,7 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
|
||||||
view->activate = activate;
|
view->activate = activate;
|
||||||
view->resize = resize;
|
view->resize = resize;
|
||||||
view->move_resize = move_resize;
|
view->move_resize = move_resize;
|
||||||
|
view->maximize = maximize;
|
||||||
view->close = close;
|
view->close = close;
|
||||||
view->desktop = desktop;
|
view->desktop = desktop;
|
||||||
roots_surface->view = view;
|
roots_surface->view = view;
|
||||||
|
|
|
@ -85,11 +85,22 @@ static void close(struct roots_view *view) {
|
||||||
wlr_xwayland_surface_close(view->desktop->xwayland, view->xwayland_surface);
|
wlr_xwayland_surface_close(view->desktop->xwayland, view->xwayland_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void maximize(struct roots_view *view, bool maximized) {
|
||||||
|
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
||||||
|
|
||||||
|
wlr_xwayland_surface_set_maximized(view->desktop->xwayland,
|
||||||
|
view->xwayland_surface, maximized);
|
||||||
|
}
|
||||||
|
|
||||||
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_teardown(roots_surface->view);
|
view_teardown(roots_surface->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_move.link);
|
||||||
|
wl_list_remove(&roots_surface->request_resize.link);
|
||||||
|
wl_list_remove(&roots_surface->request_maximize.link);
|
||||||
wl_list_remove(&roots_surface->map_notify.link);
|
wl_list_remove(&roots_surface->map_notify.link);
|
||||||
wl_list_remove(&roots_surface->unmap_notify.link);
|
wl_list_remove(&roots_surface->unmap_notify.link);
|
||||||
view_destroy(roots_surface->view);
|
view_destroy(roots_surface->view);
|
||||||
|
@ -161,6 +172,17 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
|
||||||
view_begin_resize(input, cursor, view, e->edges);
|
view_begin_resize(input, cursor, view, e->edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_request_maximize(struct wl_listener *listener, void *data) {
|
||||||
|
struct roots_xwayland_surface *roots_surface =
|
||||||
|
wl_container_of(listener, roots_surface, request_maximize);
|
||||||
|
struct roots_view *view = roots_surface->view;
|
||||||
|
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
|
||||||
|
|
||||||
|
bool maximized = xwayland_surface->maximized_vert &&
|
||||||
|
xwayland_surface->maximized_horz;
|
||||||
|
view_maximize(view, maximized);
|
||||||
|
}
|
||||||
|
|
||||||
static void handle_map_notify(struct wl_listener *listener, void *data) {
|
static void handle_map_notify(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_notify);
|
wl_container_of(listener, roots_surface, map_notify);
|
||||||
|
@ -202,24 +224,24 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||||
if (roots_surface == NULL) {
|
if (roots_surface == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
wl_signal_add(&surface->events.request_configure,
|
wl_signal_add(&surface->events.request_configure,
|
||||||
&roots_surface->request_configure);
|
&roots_surface->request_configure);
|
||||||
|
|
||||||
roots_surface->map_notify.notify = handle_map_notify;
|
roots_surface->map_notify.notify = handle_map_notify;
|
||||||
wl_signal_add(&surface->events.map_notify, &roots_surface->map_notify);
|
wl_signal_add(&surface->events.map_notify, &roots_surface->map_notify);
|
||||||
|
|
||||||
roots_surface->unmap_notify.notify = handle_unmap_notify;
|
roots_surface->unmap_notify.notify = handle_unmap_notify;
|
||||||
wl_signal_add(&surface->events.unmap_notify, &roots_surface->unmap_notify);
|
wl_signal_add(&surface->events.unmap_notify, &roots_surface->unmap_notify);
|
||||||
|
|
||||||
roots_surface->request_move.notify = handle_request_move;
|
roots_surface->request_move.notify = handle_request_move;
|
||||||
wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
|
wl_signal_add(&surface->events.request_move, &roots_surface->request_move);
|
||||||
|
|
||||||
roots_surface->request_resize.notify = handle_request_resize;
|
roots_surface->request_resize.notify = handle_request_resize;
|
||||||
wl_signal_add(&surface->events.request_resize, &roots_surface->request_resize);
|
wl_signal_add(&surface->events.request_resize,
|
||||||
|
&roots_surface->request_resize);
|
||||||
|
roots_surface->request_maximize.notify = handle_request_maximize;
|
||||||
|
wl_signal_add(&surface->events.request_maximize,
|
||||||
|
&roots_surface->request_maximize);
|
||||||
|
|
||||||
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
struct roots_view *view = calloc(1, sizeof(struct roots_view));
|
||||||
if (view == NULL) {
|
if (view == NULL) {
|
||||||
|
@ -237,6 +259,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||||
view->resize = resize;
|
view->resize = resize;
|
||||||
view->move = move;
|
view->move = move;
|
||||||
view->move_resize = move_resize;
|
view->move_resize = move_resize;
|
||||||
|
view->maximize = maximize;
|
||||||
view->close = close;
|
view->close = close;
|
||||||
roots_surface->view = view;
|
roots_surface->view = view;
|
||||||
wlr_list_add(desktop->views, view);
|
wlr_list_add(desktop->views, view);
|
||||||
|
|
|
@ -171,7 +171,6 @@ static void shell_surface_destroy_popup_state(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void shell_surface_protocol_resize(struct wl_client *client,
|
static void shell_surface_protocol_resize(struct wl_client *client,
|
||||||
struct wl_resource *resource, struct wl_resource *seat_resource,
|
struct wl_resource *resource, struct wl_resource *seat_resource,
|
||||||
uint32_t serial, enum wl_shell_surface_resize edges) {
|
uint32_t serial, enum wl_shell_surface_resize edges) {
|
||||||
|
@ -287,9 +286,8 @@ static void shell_surface_protocol_set_fullscreen(struct wl_client *client,
|
||||||
output = wl_resource_get_user_data(output_resource);
|
output = wl_resource_get_user_data(output_resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL) {
|
shell_surface_set_state(surface, WLR_WL_SHELL_SURFACE_STATE_FULLSCREEN,
|
||||||
return;
|
NULL, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_wl_shell_surface_set_fullscreen_event *event =
|
struct wlr_wl_shell_surface_set_fullscreen_event *event =
|
||||||
calloc(1, sizeof(struct wlr_wl_shell_surface_set_fullscreen_event));
|
calloc(1, sizeof(struct wlr_wl_shell_surface_set_fullscreen_event));
|
||||||
|
@ -377,9 +375,8 @@ static void shell_surface_protocol_set_maximized(struct wl_client *client,
|
||||||
output = wl_resource_get_user_data(output_resource);
|
output = wl_resource_get_user_data(output_resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL) {
|
shell_surface_set_state(surface, WLR_WL_SHELL_SURFACE_STATE_MAXIMIZED,
|
||||||
return;
|
NULL, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
struct wlr_wl_shell_surface_set_maximized_event *event =
|
struct wlr_wl_shell_surface_set_maximized_event *event =
|
||||||
calloc(1, sizeof(struct wlr_wl_shell_surface_set_maximized_event));
|
calloc(1, sizeof(struct wlr_wl_shell_surface_set_maximized_event));
|
||||||
|
|
|
@ -664,24 +664,28 @@ static void xdg_toplevel_protocol_set_maximized(struct wl_client *client,
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
||||||
surface->toplevel_state->next.maximized = true;
|
surface->toplevel_state->next.maximized = true;
|
||||||
|
wl_signal_emit(&surface->events.request_maximize, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_toplevel_protocol_unset_maximized(struct wl_client *client,
|
static void xdg_toplevel_protocol_unset_maximized(struct wl_client *client,
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
||||||
surface->toplevel_state->next.maximized = false;
|
surface->toplevel_state->next.maximized = false;
|
||||||
|
wl_signal_emit(&surface->events.request_maximize, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client,
|
static void xdg_toplevel_protocol_set_fullscreen(struct wl_client *client,
|
||||||
struct wl_resource *resource, struct wl_resource *output_resource) {
|
struct wl_resource *resource, struct wl_resource *output_resource) {
|
||||||
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
||||||
surface->toplevel_state->next.fullscreen = true;
|
surface->toplevel_state->next.fullscreen = true;
|
||||||
|
wl_signal_emit(&surface->events.request_fullscreen, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client,
|
static void xdg_toplevel_protocol_unset_fullscreen(struct wl_client *client,
|
||||||
struct wl_resource *resource) {
|
struct wl_resource *resource) {
|
||||||
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
struct wlr_xdg_surface_v6 *surface = wl_resource_get_user_data(resource);
|
||||||
surface->toplevel_state->next.fullscreen = false;
|
surface->toplevel_state->next.fullscreen = false;
|
||||||
|
wl_signal_emit(&surface->events.request_fullscreen, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_toplevel_protocol_set_minimized(struct wl_client *client,
|
static void xdg_toplevel_protocol_set_minimized(struct wl_client *client,
|
||||||
|
@ -1143,6 +1147,8 @@ static void xdg_shell_get_xdg_surface(struct wl_client *wl_client,
|
||||||
wl_list_init(&surface->configure_list);
|
wl_list_init(&surface->configure_list);
|
||||||
wl_list_init(&surface->popups);
|
wl_list_init(&surface->popups);
|
||||||
|
|
||||||
|
wl_signal_init(&surface->events.request_maximize);
|
||||||
|
wl_signal_init(&surface->events.request_fullscreen);
|
||||||
wl_signal_init(&surface->events.request_minimize);
|
wl_signal_init(&surface->events.request_minimize);
|
||||||
wl_signal_init(&surface->events.request_move);
|
wl_signal_init(&surface->events.request_move);
|
||||||
wl_signal_init(&surface->events.request_resize);
|
wl_signal_init(&surface->events.request_resize);
|
||||||
|
|
|
@ -823,41 +823,47 @@ static void xwm_handle_net_wm_state_message(struct wlr_xwm *xwm,
|
||||||
if (!xsurface) {
|
if (!xsurface) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (client_message->format != 32) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int maximized = xsurface_is_maximized(xsurface);
|
bool fullscreen = xsurface->fullscreen;
|
||||||
|
bool maximized = xsurface_is_maximized(xsurface);
|
||||||
|
|
||||||
uint32_t action = client_message->data.data32[0];
|
uint32_t action = client_message->data.data32[0];
|
||||||
uint32_t property = client_message->data.data32[1];
|
for (size_t i = 0; i < 2; ++i) {
|
||||||
|
uint32_t property = client_message->data.data32[1 + i];
|
||||||
|
|
||||||
if (property == xwm->atoms[_NET_WM_STATE_FULLSCREEN] &&
|
if (property == xwm->atoms[_NET_WM_STATE_FULLSCREEN] &&
|
||||||
update_state(action, &xsurface->fullscreen)) {
|
update_state(action, &xsurface->fullscreen)) {
|
||||||
xsurface_set_net_wm_state(xsurface);
|
xsurface_set_net_wm_state(xsurface);
|
||||||
|
} else if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT] &&
|
||||||
|
update_state(action, &xsurface->maximized_vert)) {
|
||||||
|
xsurface_set_net_wm_state(xsurface);
|
||||||
|
} else if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ] &&
|
||||||
|
update_state(action, &xsurface->maximized_horz)) {
|
||||||
|
xsurface_set_net_wm_state(xsurface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// client_message->data.data32[3] is the source indication
|
||||||
|
// all other values are set to 0
|
||||||
|
|
||||||
|
if (fullscreen != xsurface->fullscreen) {
|
||||||
if (xsurface->fullscreen) {
|
if (xsurface->fullscreen) {
|
||||||
xsurface->saved_width = xsurface->width;
|
xsurface->saved_width = xsurface->width;
|
||||||
xsurface->saved_height = xsurface->height;
|
xsurface->saved_height = xsurface->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
wl_signal_emit(&xsurface->events.request_fullscreen, xsurface);
|
wl_signal_emit(&xsurface->events.request_fullscreen, xsurface);
|
||||||
} else {
|
}
|
||||||
if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT] &&
|
|
||||||
update_state(action, &xsurface->maximized_vert)) {
|
if (maximized != xsurface_is_maximized(xsurface)) {
|
||||||
xsurface_set_net_wm_state(xsurface);
|
if (xsurface_is_maximized(xsurface)) {
|
||||||
|
xsurface->saved_width = xsurface->width;
|
||||||
|
xsurface->saved_height = xsurface->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property == xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ] &&
|
wl_signal_emit(&xsurface->events.request_maximize, xsurface);
|
||||||
update_state(action, &xsurface->maximized_horz)) {
|
|
||||||
xsurface_set_net_wm_state(xsurface);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maximized != xsurface_is_maximized(xsurface)) {
|
|
||||||
if (xsurface_is_maximized(xsurface)) {
|
|
||||||
xsurface->saved_width = xsurface->width;
|
|
||||||
xsurface->saved_height = xsurface->height;
|
|
||||||
}
|
|
||||||
|
|
||||||
wl_signal_emit(&xsurface->events.request_maximize, xsurface);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1310,8 +1316,8 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) {
|
||||||
xwm->atoms[_NET_ACTIVE_WINDOW],
|
xwm->atoms[_NET_ACTIVE_WINDOW],
|
||||||
xwm->atoms[_NET_WM_MOVERESIZE],
|
xwm->atoms[_NET_WM_MOVERESIZE],
|
||||||
xwm->atoms[_NET_WM_STATE_FULLSCREEN],
|
xwm->atoms[_NET_WM_STATE_FULLSCREEN],
|
||||||
xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ],
|
|
||||||
xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT],
|
xwm->atoms[_NET_WM_STATE_MAXIMIZED_VERT],
|
||||||
|
xwm->atoms[_NET_WM_STATE_MAXIMIZED_HORZ],
|
||||||
};
|
};
|
||||||
xcb_change_property(xwm->xcb_conn,
|
xcb_change_property(xwm->xcb_conn,
|
||||||
XCB_PROP_MODE_REPLACE,
|
XCB_PROP_MODE_REPLACE,
|
||||||
|
|
Loading…
Reference in a new issue