mirror of
https://github.com/wizbright/waybox.git
synced 2025-10-29 05:40:20 -04:00
react to wlroots changes
This commit is contained in:
parent
bed7e244c2
commit
4cee7c4014
10 changed files with 38 additions and 36 deletions
|
|
@ -31,7 +31,7 @@ struct wb_output {
|
||||||
struct wb_view {
|
struct wb_view {
|
||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
struct wb_server *server;
|
struct wb_server *server;
|
||||||
struct wlr_xdg_surface *xdg_surface;
|
struct wlr_xdg_toplevel *xdg_toplevel;
|
||||||
|
|
||||||
struct wlr_xdg_toplevel_decoration_v1 *decoration;
|
struct wlr_xdg_toplevel_decoration_v1 *decoration;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@
|
||||||
#include <wlr/types/wlr_matrix.h>
|
#include <wlr/types/wlr_matrix.h>
|
||||||
#include <wlr/types/wlr_gamma_control_v1.h>
|
#include <wlr/types/wlr_gamma_control_v1.h>
|
||||||
#include <wlr/types/wlr_output_layout.h>
|
#include <wlr/types/wlr_output_layout.h>
|
||||||
|
#include <wlr/types/wlr_subcompositor.h>
|
||||||
#include <wlr/types/wlr_xdg_shell.h>
|
#include <wlr/types/wlr_xdg_shell.h>
|
||||||
#include <wlr/util/log.h>
|
#include <wlr/util/log.h>
|
||||||
|
|
||||||
|
|
@ -40,6 +41,7 @@ struct wb_server {
|
||||||
struct wlr_compositor *compositor;
|
struct wlr_compositor *compositor;
|
||||||
struct wlr_output_layout *output_layout;
|
struct wlr_output_layout *output_layout;
|
||||||
struct wlr_renderer *renderer;
|
struct wlr_renderer *renderer;
|
||||||
|
struct wlr_subcompositor *subcompositor;
|
||||||
|
|
||||||
struct wb_config *config;
|
struct wb_config *config;
|
||||||
char *config_file;
|
char *config_file;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ cc = meson.get_compiler('c')
|
||||||
inc_dir = include_directories('include')
|
inc_dir = include_directories('include')
|
||||||
|
|
||||||
libxml2 = dependency('libxml-2.0')
|
libxml2 = dependency('libxml-2.0')
|
||||||
wlroots = dependency('wlroots', version: '>=0.15.0')
|
wlroots = dependency('wlroots', version: '>=0.16.0')
|
||||||
wayland_server = dependency('wayland-server', version: '>=1.15')
|
wayland_server = dependency('wayland-server', version: '>=1.15')
|
||||||
wayland_protos = dependency('wayland-protocols', version: '>=1.17')
|
wayland_protos = dependency('wayland-protocols', version: '>=1.17')
|
||||||
xkbcommon = dependency('xkbcommon')
|
xkbcommon = dependency('xkbcommon')
|
||||||
|
|
|
||||||
|
|
@ -41,13 +41,13 @@ static void process_cursor_resize(struct wb_server *server) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_box geo_box;
|
struct wlr_box geo_box;
|
||||||
wlr_xdg_surface_get_geometry(view->xdg_surface, &geo_box);
|
wlr_xdg_surface_get_geometry(view->xdg_toplevel->base, &geo_box);
|
||||||
view->x = new_left - geo_box.x;
|
view->x = new_left - geo_box.x;
|
||||||
view->y = new_top - geo_box.y;
|
view->y = new_top - geo_box.y;
|
||||||
|
|
||||||
int new_width = new_right - new_left;
|
int new_width = new_right - new_left;
|
||||||
int new_height = new_bottom - new_top;
|
int new_height = new_bottom - new_top;
|
||||||
wlr_xdg_toplevel_set_size(view->xdg_surface, new_width, new_height);
|
wlr_xdg_toplevel_set_size(view->xdg_toplevel, new_width, new_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void process_cursor_motion(struct wb_server *server, uint32_t time) {
|
static void process_cursor_motion(struct wb_server *server, uint32_t time) {
|
||||||
|
|
|
||||||
|
|
@ -201,7 +201,7 @@ void arrange_layers(struct wb_output *output) {
|
||||||
{
|
{
|
||||||
struct wb_view *view =
|
struct wb_view *view =
|
||||||
wl_container_of(output->server->views.next, view, link);
|
wl_container_of(output->server->views.next, view, link);
|
||||||
focus_view(view, view->xdg_surface->surface);
|
focus_view(view, view->xdg_toplevel->base->surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,18 +31,18 @@ int main(int argc, char **argv) {
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
if (!strcmp("--debug", argv[i]) || !strcmp("-v", argv[i])) {
|
if (strcmp("--debug", argv[i]) == 0 || strcmp("-v", argv[i]) == 0) {
|
||||||
debuglevel = WLR_INFO;
|
debuglevel = WLR_INFO;
|
||||||
} else if ((!strcmp("--startup", argv[i]) || !strcmp("-s", argv[i]))) {
|
} else if (strcmp("--startup", argv[i]) == 0 || strcmp("-s", argv[i]) == 0) {
|
||||||
if (i < argc - 1) {
|
if (i < argc - 1) {
|
||||||
startup_cmd = argv[i + 1];
|
startup_cmd = argv[i + 1];
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, _("%s requires an argument\n"), argv[i]);
|
fprintf(stderr, _("%s requires an argument\n"), argv[i]);
|
||||||
}
|
}
|
||||||
} else if (!strcmp("--version", argv[i]) || !strcmp("-V", argv[i])) {
|
} else if (strcmp("--version", argv[i]) == 0 || strcmp("-V", argv[i]) == 0) {
|
||||||
printf(PACKAGE_NAME " " PACKAGE_VERSION "\n");
|
printf(PACKAGE_NAME " " PACKAGE_VERSION "\n");
|
||||||
return 0;
|
return 0;
|
||||||
} else if (!strcmp("--help", argv[i]) || !strcmp("-h", argv[i])) {
|
} else if (strcmp("--help", argv[i]) == 0 || strcmp("-h", argv[i]) == 0) {
|
||||||
show_help(argv[0]);
|
show_help(argv[0]);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (strcmp("--config-file", argv[i]) == 0) {
|
} else if (strcmp("--config-file", argv[i]) == 0) {
|
||||||
|
|
@ -51,7 +51,7 @@ int main(int argc, char **argv) {
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, _("%s requires an argument\n"), argv[i]);
|
fprintf(stderr, _("%s requires an argument\n"), argv[i]);
|
||||||
}
|
}
|
||||||
} else if (!strcmp("--sm-disable", argv[i])) {
|
} else if (strcmp("--sm-disable", argv[i]) == 0) {
|
||||||
fprintf(stderr, _("%s hasn't been implemented yet.\n"), argv[i]);
|
fprintf(stderr, _("%s hasn't been implemented yet.\n"), argv[i]);
|
||||||
if (i == argc - 1) {
|
if (i == argc - 1) {
|
||||||
fprintf(stderr, _("%s requires an argument\n"), argv[i]);
|
fprintf(stderr, _("%s requires an argument\n"), argv[i]);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ static void render_surface(struct wlr_surface *surface,
|
||||||
* means. You don't have to worry about this, wlroots takes care of it. */
|
* means. You don't have to worry about this, wlroots takes care of it. */
|
||||||
struct wlr_texture *texture = wlr_surface_get_texture(surface);
|
struct wlr_texture *texture = wlr_surface_get_texture(surface);
|
||||||
if (texture == NULL) {
|
if (texture == NULL) {
|
||||||
wlr_log(WLR_ERROR, "%s: %s", _("Couldn't get a surface texture"));
|
wlr_log(WLR_ERROR, "%s", _("Couldn't get a surface texture"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,7 +139,7 @@ void output_frame_notify(struct wl_listener *listener, void *data) {
|
||||||
.when = &now,
|
.when = &now,
|
||||||
};
|
};
|
||||||
|
|
||||||
wlr_xdg_surface_for_each_surface(view->xdg_surface,
|
wlr_xdg_surface_for_each_surface(view->xdg_toplevel->base,
|
||||||
render_surface, &rdata);
|
render_surface, &rdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ static bool cycle_views(struct wb_server *server) {
|
||||||
server->views.prev, current_view, link);
|
server->views.prev, current_view, link);
|
||||||
struct wb_view *prev_view = wl_container_of(
|
struct wb_view *prev_view = wl_container_of(
|
||||||
server->views.next, prev_view, link);
|
server->views.next, prev_view, link);
|
||||||
focus_view(current_view, current_view->xdg_surface->surface);
|
focus_view(current_view, current_view->xdg_toplevel->base->surface);
|
||||||
/* Move the current view to the beginning of the list */
|
/* Move the current view to the beginning of the list */
|
||||||
wl_list_remove(¤t_view->link);
|
wl_list_remove(¤t_view->link);
|
||||||
wl_list_insert(&server->views, ¤t_view->link);
|
wl_list_insert(&server->views, ¤t_view->link);
|
||||||
|
|
@ -28,7 +28,7 @@ static bool cycle_views_reverse(struct wb_server *server) {
|
||||||
server->views.next, current_view, link);
|
server->views.next, current_view, link);
|
||||||
struct wb_view *next_view = wl_container_of(
|
struct wb_view *next_view = wl_container_of(
|
||||||
current_view->link.next, next_view, link);
|
current_view->link.next, next_view, link);
|
||||||
focus_view(next_view, next_view->xdg_surface->surface);
|
focus_view(next_view, next_view->xdg_toplevel->base->surface);
|
||||||
/* Move the previous view to the end of the list */
|
/* Move the previous view to the end of the list */
|
||||||
wl_list_remove(¤t_view->link);
|
wl_list_remove(¤t_view->link);
|
||||||
wl_list_insert(server->views.prev, ¤t_view->link);
|
wl_list_insert(server->views.prev, ¤t_view->link);
|
||||||
|
|
@ -71,7 +71,7 @@ static bool handle_keybinding(struct wb_server *server, xkb_keysym_t sym, uint32
|
||||||
else if ((strcmp("Close", key_binding->action) == 0)) {
|
else if ((strcmp("Close", key_binding->action) == 0)) {
|
||||||
struct wb_view *current_view = wl_container_of(
|
struct wb_view *current_view = wl_container_of(
|
||||||
server->views.next, current_view, link);
|
server->views.next, current_view, link);
|
||||||
wlr_xdg_toplevel_send_close(current_view->xdg_surface);
|
wlr_xdg_toplevel_send_close(current_view->xdg_toplevel);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if ((strcmp("Execute", key_binding->action) == 0)) {
|
else if ((strcmp("Execute", key_binding->action) == 0)) {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ bool wb_create_backend(struct wb_server* server) {
|
||||||
|
|
||||||
server->compositor = wlr_compositor_create(server->wl_display,
|
server->compositor = wlr_compositor_create(server->wl_display,
|
||||||
server->renderer);
|
server->renderer);
|
||||||
|
server->subcompositor = wlr_subcompositor_create(server->wl_display);
|
||||||
server->output_layout = wlr_output_layout_create();
|
server->output_layout = wlr_output_layout_create();
|
||||||
server->seat = wb_seat_create(server);
|
server->seat = wb_seat_create(server);
|
||||||
server->cursor = wb_cursor_create(server);
|
server->cursor = wb_cursor_create(server);
|
||||||
|
|
|
||||||
|
|
@ -24,20 +24,20 @@ void focus_view(struct wb_view *view, struct wlr_surface *surface) {
|
||||||
*/
|
*/
|
||||||
struct wlr_xdg_surface *previous = wlr_xdg_surface_from_wlr_surface(
|
struct wlr_xdg_surface *previous = wlr_xdg_surface_from_wlr_surface(
|
||||||
seat->keyboard_state.focused_surface);
|
seat->keyboard_state.focused_surface);
|
||||||
wlr_xdg_toplevel_set_activated(previous, false);
|
wlr_xdg_toplevel_set_activated(previous->toplevel, false);
|
||||||
}
|
}
|
||||||
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
|
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat);
|
||||||
/* Move the view to the front */
|
/* Move the view to the front */
|
||||||
wl_list_remove(&view->link);
|
wl_list_remove(&view->link);
|
||||||
wl_list_insert(&server->views, &view->link);
|
wl_list_insert(&server->views, &view->link);
|
||||||
/* Activate the new surface */
|
/* Activate the new surface */
|
||||||
wlr_xdg_toplevel_set_activated(view->xdg_surface, true);
|
wlr_xdg_toplevel_set_activated(view->xdg_toplevel, true);
|
||||||
/*
|
/*
|
||||||
* Tell the seat to have the keyboard enter this surface. wlroots will keep
|
* Tell the seat to have the keyboard enter this surface. wlroots will keep
|
||||||
* track of this and automatically send key events to the appropriate
|
* track of this and automatically send key events to the appropriate
|
||||||
* clients without additional work on your part.
|
* clients without additional work on your part.
|
||||||
*/
|
*/
|
||||||
wlr_seat_keyboard_notify_enter(seat, view->xdg_surface->surface,
|
wlr_seat_keyboard_notify_enter(seat, view->xdg_toplevel->base->surface,
|
||||||
keyboard->keycodes, keyboard->num_keycodes, &keyboard->modifiers);
|
keyboard->keycodes, keyboard->num_keycodes, &keyboard->modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@ static void xdg_surface_ack_configure(struct wl_listener *listener, void *data)
|
||||||
* return a negative y value, which can be used to determine the
|
* return a negative y value, which can be used to determine the
|
||||||
* size of the CSD titlebar. */
|
* size of the CSD titlebar. */
|
||||||
struct wlr_box geo_box;
|
struct wlr_box geo_box;
|
||||||
wlr_xdg_surface_get_geometry(view->xdg_surface, &geo_box);
|
wlr_xdg_surface_get_geometry(view->xdg_toplevel->base, &geo_box);
|
||||||
if (geo_box.y < 0)
|
if (geo_box.y < 0)
|
||||||
{
|
{
|
||||||
view->y = geo_box.y * -1;
|
view->y = geo_box.y * -1;
|
||||||
|
|
@ -64,7 +64,7 @@ static void xdg_surface_ack_configure(struct wl_listener *listener, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set size here, so the view->y value will be known */
|
/* Set size here, so the view->y value will be known */
|
||||||
wlr_xdg_toplevel_set_size(view->xdg_surface, geo_box.width - view->x, geo_box.height - view->y);
|
wlr_xdg_toplevel_set_size(view->xdg_toplevel, geo_box.width - view->x, geo_box.height - view->y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@ static void xdg_surface_map(struct wl_listener *listener, void *data) {
|
||||||
/* Called when the surface is mapped, or ready to display on-screen. */
|
/* Called when the surface is mapped, or ready to display on-screen. */
|
||||||
struct wb_view *view = wl_container_of(listener, view, map);
|
struct wb_view *view = wl_container_of(listener, view, map);
|
||||||
view->mapped = true;
|
view->mapped = true;
|
||||||
focus_view(view, view->xdg_surface->surface);
|
focus_view(view, view->xdg_toplevel->base->surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_surface_unmap(struct wl_listener *listener, void *data) {
|
static void xdg_surface_unmap(struct wl_listener *listener, void *data) {
|
||||||
|
|
@ -80,21 +80,21 @@ static void xdg_surface_unmap(struct wl_listener *listener, void *data) {
|
||||||
struct wb_view *view = wl_container_of(listener, view, unmap);
|
struct wb_view *view = wl_container_of(listener, view, unmap);
|
||||||
view->mapped = false;
|
view->mapped = false;
|
||||||
|
|
||||||
struct wb_view *current_view = (struct wb_view *) view->server->views.next;
|
struct wb_view *current_view = wl_container_of(view->server->views.next, current_view, link);
|
||||||
struct wb_view *next_view = (struct wb_view *) current_view->link.next;
|
struct wb_view *next_view = wl_container_of(current_view->link.next, next_view, link);
|
||||||
|
|
||||||
/* If the current view is mapped, focus it. */
|
/* If the current view is mapped, focus it. */
|
||||||
if (current_view->mapped) {
|
if (current_view->mapped) {
|
||||||
wlr_log(WLR_INFO, "%s: %s", _("Focusing current view"),
|
wlr_log(WLR_INFO, "%s: %s", _("Focusing current view"),
|
||||||
current_view->xdg_surface->toplevel->app_id);
|
current_view->xdg_toplevel->app_id);
|
||||||
focus_view(current_view, current_view->xdg_surface->surface);
|
focus_view(current_view, current_view->xdg_toplevel->base->surface);
|
||||||
}
|
}
|
||||||
/* Otherwise, focus the next view, if any. */
|
/* Otherwise, focus the next view, if any. */
|
||||||
else if (next_view->xdg_surface->surface &&
|
else if (next_view->xdg_toplevel->base->surface &&
|
||||||
wlr_surface_is_xdg_surface(next_view->xdg_surface->surface)) {
|
wlr_surface_is_xdg_surface(next_view->xdg_toplevel->base->surface)) {
|
||||||
wlr_log(WLR_INFO, "%s: %s", _("Focusing next view"),
|
wlr_log(WLR_INFO, "%s: %s", _("Focusing next view"),
|
||||||
next_view->xdg_surface->toplevel->app_id);
|
next_view->xdg_toplevel->app_id);
|
||||||
focus_view(next_view, next_view->xdg_surface->surface);
|
focus_view(next_view, next_view->xdg_toplevel->base->surface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -113,7 +113,7 @@ static void begin_interactive(struct wb_view *view,
|
||||||
struct wb_server *server = view->server;
|
struct wb_server *server = view->server;
|
||||||
struct wlr_surface *focused_surface =
|
struct wlr_surface *focused_surface =
|
||||||
server->seat->seat->pointer_state.focused_surface;
|
server->seat->seat->pointer_state.focused_surface;
|
||||||
if (view->xdg_surface->surface != wlr_surface_get_root_surface(focused_surface)) {
|
if (view->xdg_toplevel->base->surface != wlr_surface_get_root_surface(focused_surface)) {
|
||||||
/* Deny move/resize requests from unfocused clients. */
|
/* Deny move/resize requests from unfocused clients. */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +125,7 @@ static void begin_interactive(struct wb_view *view,
|
||||||
server->grab_y = server->cursor->cursor->y - view->y;
|
server->grab_y = server->cursor->cursor->y - view->y;
|
||||||
} else if (mode == WB_CURSOR_RESIZE) {
|
} else if (mode == WB_CURSOR_RESIZE) {
|
||||||
struct wlr_box geo_box;
|
struct wlr_box geo_box;
|
||||||
wlr_xdg_surface_get_geometry(view->xdg_surface, &geo_box);
|
wlr_xdg_surface_get_geometry(view->xdg_toplevel->base, &geo_box);
|
||||||
|
|
||||||
double border_x = (view->x + geo_box.x) + ((edges & WLR_EDGE_RIGHT) ? geo_box.width : 0);
|
double border_x = (view->x + geo_box.x) + ((edges & WLR_EDGE_RIGHT) ? geo_box.width : 0);
|
||||||
double border_y = (view->y + geo_box.y) + ((edges & WLR_EDGE_BOTTOM) ? geo_box.height : 0);
|
double border_y = (view->y + geo_box.y) + ((edges & WLR_EDGE_BOTTOM) ? geo_box.height : 0);
|
||||||
|
|
@ -173,7 +173,7 @@ static void handle_new_xdg_surface(struct wl_listener *listener, void *data) {
|
||||||
struct wb_view *view =
|
struct wb_view *view =
|
||||||
calloc(1, sizeof(struct wb_view));
|
calloc(1, sizeof(struct wb_view));
|
||||||
view->server = server;
|
view->server = server;
|
||||||
view->xdg_surface = xdg_surface;
|
view->xdg_toplevel = xdg_surface->toplevel;
|
||||||
|
|
||||||
/* Listen to the various events it can emit */
|
/* Listen to the various events it can emit */
|
||||||
view->ack_configure.notify = xdg_surface_ack_configure;
|
view->ack_configure.notify = xdg_surface_ack_configure;
|
||||||
|
|
@ -185,11 +185,10 @@ static void handle_new_xdg_surface(struct wl_listener *listener, void *data) {
|
||||||
view->destroy.notify = xdg_surface_destroy;
|
view->destroy.notify = xdg_surface_destroy;
|
||||||
wl_signal_add(&xdg_surface->events.destroy, &view->destroy);
|
wl_signal_add(&xdg_surface->events.destroy, &view->destroy);
|
||||||
|
|
||||||
struct wlr_xdg_toplevel *toplevel = xdg_surface->toplevel;
|
|
||||||
view->request_move.notify = xdg_toplevel_request_move;
|
view->request_move.notify = xdg_toplevel_request_move;
|
||||||
wl_signal_add(&toplevel->events.request_move, &view->request_move);
|
wl_signal_add(&view->xdg_toplevel->events.request_move, &view->request_move);
|
||||||
view->request_resize.notify = xdg_toplevel_request_resize;
|
view->request_resize.notify = xdg_toplevel_request_resize;
|
||||||
wl_signal_add(&toplevel->events.request_resize, &view->request_resize);
|
wl_signal_add(&view->xdg_toplevel->events.request_resize, &view->request_resize);
|
||||||
|
|
||||||
/* Add it to the list of views. */
|
/* Add it to the list of views. */
|
||||||
wl_list_insert(&server->views, &view->link);
|
wl_list_insert(&server->views, &view->link);
|
||||||
|
|
@ -211,7 +210,7 @@ bool view_at(struct wb_view *view,
|
||||||
double _sx, _sy;
|
double _sx, _sy;
|
||||||
struct wlr_surface *_surface = NULL;
|
struct wlr_surface *_surface = NULL;
|
||||||
_surface = wlr_xdg_surface_surface_at(
|
_surface = wlr_xdg_surface_surface_at(
|
||||||
view->xdg_surface, view_sx, view_sy, &_sx, &_sy);
|
view->xdg_toplevel->base, view_sx, view_sy, &_sx, &_sy);
|
||||||
|
|
||||||
if (_surface != NULL) {
|
if (_surface != NULL) {
|
||||||
*sx = _sx;
|
*sx = _sx;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue