mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-11-27 06:59:46 -05:00
Add close command, add close for xwayland
This commit is contained in:
parent
8ff548cdba
commit
972e9dbd1b
6 changed files with 28 additions and 8 deletions
|
|
@ -133,6 +133,7 @@ static void set_view_focus(struct roots_input *input,
|
|||
if (!view) {
|
||||
return;
|
||||
}
|
||||
input->last_active_view = view;
|
||||
|
||||
size_t index = 0;
|
||||
for (size_t i = 0; i < desktop->views->length; ++i) {
|
||||
|
|
|
|||
|
|
@ -58,6 +58,12 @@ void view_resize(struct roots_view *view, uint32_t width, uint32_t height) {
|
|||
}
|
||||
}
|
||||
|
||||
void view_close(struct roots_view *view) {
|
||||
if (view->close) {
|
||||
view->close(view);
|
||||
}
|
||||
}
|
||||
|
||||
static struct wlr_subsurface *subsurface_at(struct wlr_surface *surface,
|
||||
double sx, double sy, double *sub_x, double *sub_y) {
|
||||
struct wlr_subsurface *subsurface;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ static void keyboard_binding_execute(struct roots_keyboard *keyboard,
|
|||
struct roots_server *server = keyboard->input->server;
|
||||
if (strcmp(command, "exit") == 0) {
|
||||
wl_display_terminate(server->wl_display);
|
||||
} else if (strcmp(command, "close") == 0) {
|
||||
if (keyboard->input->last_active_view != NULL) {
|
||||
view_close(keyboard->input->last_active_view);
|
||||
}
|
||||
} else if (strncmp(exec_prefix, command, strlen(exec_prefix)) == 0) {
|
||||
const char *shell_cmd = command + strlen(exec_prefix);
|
||||
pid_t pid = fork();
|
||||
|
|
|
|||
|
|
@ -9,13 +9,6 @@
|
|||
#include "rootston/desktop.h"
|
||||
#include "rootston/server.h"
|
||||
|
||||
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 = view->xwayland_surface;
|
||||
wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface,
|
||||
xwayland_surface->x, xwayland_surface->y, width, height);
|
||||
}
|
||||
|
||||
static void handle_destroy(struct wl_listener *listener, void *data) {
|
||||
struct roots_xwayland_surface *roots_surface =
|
||||
wl_container_of(listener, roots_surface, destroy);
|
||||
|
|
@ -39,6 +32,7 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
|
||||
static void activate(struct roots_view *view, bool active) {
|
||||
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
||||
if (active) {
|
||||
wlr_xwayland_surface_activate(view->desktop->xwayland,
|
||||
view->xwayland_surface);
|
||||
|
|
@ -47,6 +41,18 @@ static void activate(struct roots_view *view, bool active) {
|
|||
}
|
||||
}
|
||||
|
||||
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 = view->xwayland_surface;
|
||||
wlr_xwayland_surface_configure(view->desktop->xwayland, xwayland_surface,
|
||||
xwayland_surface->x, xwayland_surface->y, width, height);
|
||||
}
|
||||
|
||||
static void close(struct roots_view *view) {
|
||||
assert(view->type == ROOTS_XWAYLAND_VIEW);
|
||||
wlr_xwayland_surface_close(view->desktop->xwayland, view->xwayland_surface);
|
||||
}
|
||||
|
||||
void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
||||
struct roots_desktop *desktop =
|
||||
wl_container_of(listener, desktop, xwayland_surface);
|
||||
|
|
@ -82,6 +88,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
|
|||
view->desktop = desktop;
|
||||
view->activate = activate;
|
||||
view->resize = resize;
|
||||
view->close = close;
|
||||
roots_surface->view = view;
|
||||
list_add(desktop->views, view);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue