remove warnings and add autofocus
This commit is contained in:
@@ -5,6 +5,7 @@ proto:
|
||||
|
||||
compile: proto
|
||||
gcc -o absinthe src/* \
|
||||
-Wall -Wextra \
|
||||
-DXWAYLAND \
|
||||
-I./ -I./include -DWLR_USE_UNSTABLE $(shell pkg-config wlroots-0.20 --libs --cflags) -lwayland-server -lxkbcommon \
|
||||
-O3 \
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
#include "types.h"
|
||||
|
||||
void focus_toplevel(struct absinthe_toplevel *toplevel);
|
||||
struct absinthe_toplevel *focus_get_topmost(struct absinthe_server *server);
|
||||
void focus_next(struct absinthe_server *server);
|
||||
void focus_prev(struct absinthe_server *server);
|
||||
|
||||
+3
-1
@@ -24,6 +24,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
enum absinthe_cursor_mode {
|
||||
ABSINTHE_CURSOR_PASSTHROUGH,
|
||||
ABSINTHE_CURSOR_MOVE,
|
||||
@@ -95,7 +97,7 @@ struct absinthe_server {
|
||||
|
||||
enum absinthe_cursor_mode cursor_mode;
|
||||
struct wlr_box grabbed_geometry;
|
||||
uint32_t grab_x, grab_y;
|
||||
int32_t grab_x, grab_y;
|
||||
enum absinthe_cursor_resize_corner cursor_resize_corner;
|
||||
|
||||
struct wl_list toplevels;
|
||||
|
||||
+14
-2
@@ -8,6 +8,7 @@
|
||||
#include "absinthe-toplevel.h"
|
||||
#include "output.h"
|
||||
#include "layout.h"
|
||||
#include "focus.h"
|
||||
|
||||
bool absinthe_toplevel_is_unmanaged(struct absinthe_toplevel *toplevel)
|
||||
{
|
||||
@@ -44,11 +45,12 @@ struct wlr_surface *absinthe_toplevel_surface(struct absinthe_toplevel *toplevel
|
||||
|
||||
void absinthe_toplevel_map(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, map);
|
||||
|
||||
toplevel->scene_tree = wlr_scene_tree_create(&toplevel->server->scene->tree);
|
||||
toplevel->scene_tree->node.data = toplevel;
|
||||
wlr_scene_node_set_enabled(&toplevel->scene_tree->node, false);
|
||||
wlr_scene_node_set_enabled(&toplevel->scene_tree->node, absinthe_toplevel_is_unmanaged(toplevel));
|
||||
|
||||
toplevel->tiled = true;
|
||||
|
||||
@@ -91,14 +93,18 @@ void absinthe_toplevel_map(struct wl_listener *listener, void *data)
|
||||
wl_list_insert(&toplevel->server->focus_stack, &toplevel->flink);
|
||||
|
||||
layout_arrange(toplevel->output);
|
||||
focus_toplevel(focus_get_topmost(toplevel->server));
|
||||
}
|
||||
|
||||
void absinthe_toplevel_unmap(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, unmap);
|
||||
|
||||
if (toplevel == toplevel->server->focused_toplevel)
|
||||
if (toplevel == toplevel->server->focused_toplevel) {
|
||||
toplevel->server->focused_toplevel = NULL;
|
||||
toplevel->server->seat->keyboard_state.focused_surface = NULL;
|
||||
}
|
||||
|
||||
wl_list_remove(&toplevel->link);
|
||||
wl_list_remove(&toplevel->flink);
|
||||
@@ -106,10 +112,12 @@ void absinthe_toplevel_unmap(struct wl_listener *listener, void *data)
|
||||
wlr_scene_node_destroy(&toplevel->scene_tree->node);
|
||||
|
||||
layout_arrange(toplevel->output);
|
||||
focus_next(toplevel->server);
|
||||
}
|
||||
|
||||
void absinthe_toplevel_destroy(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, destroy);
|
||||
|
||||
#ifdef XWAYLAND
|
||||
@@ -138,6 +146,7 @@ void absinthe_toplevel_destroy(struct wl_listener *listener, void *data)
|
||||
|
||||
void absinthe_toplevel_request_move(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
||||
if (toplevel->toplevel.xdg->base->initialized)
|
||||
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
|
||||
@@ -145,6 +154,7 @@ void absinthe_toplevel_request_move(struct wl_listener *listener, void *data)
|
||||
|
||||
void absinthe_toplevel_request_resize(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
||||
if (toplevel->toplevel.xdg->base->initialized)
|
||||
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
|
||||
@@ -152,6 +162,7 @@ void absinthe_toplevel_request_resize(struct wl_listener *listener, void *data)
|
||||
|
||||
void absinthe_toplevel_request_maximize(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_maximize);
|
||||
if (toplevel->toplevel.xdg->base->initialized)
|
||||
wlr_xdg_surface_schedule_configure(toplevel->toplevel.xdg->base);
|
||||
@@ -159,6 +170,7 @@ void absinthe_toplevel_request_maximize(struct wl_listener *listener, void *data
|
||||
|
||||
void absinthe_toplevel_request_fullscreen(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, request_fullscreen);
|
||||
absinthe_toplevel_set_fullscreen(toplevel, toplevel->toplevel.xdg->requested.fullscreen);
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ static void apply_resize(struct absinthe_toplevel *toplevel, struct wlr_box *new
|
||||
|
||||
int32_t max_width = toplevel->toplevel.xdg->current.max_width;
|
||||
int32_t max_height = toplevel->toplevel.xdg->current.max_height;
|
||||
bool resize = false;
|
||||
|
||||
if (max_width == 0)
|
||||
max_width = 10000;
|
||||
@@ -127,7 +126,6 @@ void process_cursor_motion(struct absinthe_server *server, uint32_t time)
|
||||
double sx, sy;
|
||||
struct wlr_seat *seat = server->seat;
|
||||
struct wlr_surface *surface = NULL;
|
||||
struct absinthe_toplevel *toplevel = absinthe_toplevel_at(server, server->cursor->x, server->cursor->y, &surface, &sx, &sy);
|
||||
|
||||
if (server->cursor_mode == ABSINTHE_CURSOR_MOVE) {
|
||||
process_cursor_move(server);
|
||||
|
||||
+11
-1
@@ -29,6 +29,10 @@ void focus_toplevel(struct absinthe_toplevel *toplevel)
|
||||
wlr_xdg_toplevel_set_activated(prev_toplevel, false);
|
||||
absinthe_toplevel_set_border_color(prev_toplevel->base->data, unfocused_border_color);
|
||||
}
|
||||
|
||||
struct wlr_xwayland_surface *prev_xwayland_surface = wlr_xwayland_surface_try_from_wlr_surface(prev_surface);
|
||||
if (prev_xwayland_surface)
|
||||
absinthe_toplevel_set_border_color(prev_surface->data, unfocused_border_color);
|
||||
}
|
||||
|
||||
toplevel->server->focused_toplevel = toplevel;
|
||||
@@ -45,7 +49,7 @@ void focus_toplevel(struct absinthe_toplevel *toplevel)
|
||||
wlr_seat_keyboard_notify_enter(seat, surface, keyboard->keycodes, keyboard->num_keycodes, &keyboard->modifiers);
|
||||
}
|
||||
|
||||
static struct absinthe_toplevel *focus_get_topmost(struct absinthe_server *server)
|
||||
struct absinthe_toplevel *focus_get_topmost(struct absinthe_server *server)
|
||||
{
|
||||
struct absinthe_toplevel *toplevel;
|
||||
wl_list_for_each(toplevel, &server->focus_stack, flink) {
|
||||
@@ -58,6 +62,9 @@ static struct absinthe_toplevel *focus_get_topmost(struct absinthe_server *serve
|
||||
void focus_next(struct absinthe_server *server)
|
||||
{
|
||||
struct absinthe_toplevel *toplevel = focus_get_topmost(server);
|
||||
if (!toplevel)
|
||||
return;
|
||||
|
||||
struct absinthe_toplevel *next;
|
||||
wl_list_for_each(next, &toplevel->link, link) {
|
||||
if (&next->link == &toplevel->server->toplevels)
|
||||
@@ -70,6 +77,9 @@ void focus_next(struct absinthe_server *server)
|
||||
void focus_prev(struct absinthe_server *server)
|
||||
{
|
||||
struct absinthe_toplevel *toplevel = focus_get_topmost(server);
|
||||
if (!toplevel)
|
||||
return;
|
||||
|
||||
struct absinthe_toplevel *prev;
|
||||
wl_list_for_each_reverse(prev, &toplevel->link, link) {
|
||||
if (&prev->link == &toplevel->server->toplevels)
|
||||
|
||||
+3
-1
@@ -13,6 +13,7 @@
|
||||
|
||||
void keyboard_handle_modifiers(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_keyboard *keyboard = wl_container_of(listener, keyboard, modifiers);
|
||||
|
||||
wlr_seat_set_keyboard(keyboard->server->seat, keyboard->wlr_keyboard);
|
||||
@@ -27,7 +28,7 @@ static bool keyboard_handle_keybind(struct absinthe_server *server, xkb_keysym_t
|
||||
break;
|
||||
case XKB_KEY_Return:
|
||||
if (fork() == 0)
|
||||
execl("/bin/sh", "sh", "-c", "ghostty", NULL);
|
||||
execl("/bin/sh", "sh", "-c", "foot", NULL);
|
||||
break;
|
||||
case XKB_KEY_r:
|
||||
if (fork() == 0)
|
||||
@@ -98,6 +99,7 @@ void keyboard_handle_key(struct wl_listener *listener, void *data)
|
||||
|
||||
void keyboard_handle_destroy(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_keyboard *keyboard = wl_container_of(listener, keyboard, modifiers);
|
||||
|
||||
wl_list_remove(&keyboard->modifiers.link);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "absinthe-toplevel.h"
|
||||
#include "focus.h"
|
||||
#include "types.h"
|
||||
|
||||
void layout_arrange(struct absinthe_output *output)
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
#include "seat.h"
|
||||
#include "output.h"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(void)
|
||||
{
|
||||
wlr_log_init(WLR_DEBUG, NULL);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
void output_frame(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_output *output = wl_container_of(listener, output, frame);
|
||||
struct wlr_scene *scene = output->server->scene;
|
||||
|
||||
@@ -34,6 +35,7 @@ void output_request_state(struct wl_listener *listener, void *data)
|
||||
|
||||
void output_destroy(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_output *output = wl_container_of(listener, output, request_state);
|
||||
|
||||
wl_list_remove(&output->frame.link);
|
||||
@@ -45,6 +47,7 @@ void output_destroy(struct wl_listener *listener, void *data)
|
||||
|
||||
void outputs_update(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_server *server = wl_container_of(listener, server, output_layout_change);
|
||||
struct absinthe_output *output;
|
||||
wl_list_for_each(output, &server->outputs, link) {
|
||||
|
||||
@@ -116,6 +116,7 @@ void server_new_xdg_popup(struct wl_listener *listener, void *data)
|
||||
|
||||
void server_new_xdg_decoration(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(listener);
|
||||
struct wlr_xdg_toplevel_decoration_v1 *xdg_decoration = data;
|
||||
struct absinthe_toplevel *toplevel = xdg_decoration->toplevel->base->data;
|
||||
toplevel->decoration = xdg_decoration;
|
||||
@@ -132,6 +133,7 @@ void server_new_xdg_decoration(struct wl_listener *listener, void *data)
|
||||
#ifdef XWAYLAND
|
||||
void server_xwayland_ready(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_server *server = wl_container_of(listener, server, xwayland_ready);
|
||||
|
||||
wlr_xwayland_set_seat(server->xwayland, server->seat);
|
||||
@@ -273,6 +275,7 @@ void server_cursor_axis(struct wl_listener *listener, void *data)
|
||||
|
||||
void server_cursor_frame(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_server *server = wl_container_of(listener, server, cursor_frame);
|
||||
wlr_seat_pointer_notify_frame(server->seat);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
void xdg_decoration_request_mode(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, decoration_request_mode);
|
||||
if (toplevel->toplevel.xdg->base->initialized)
|
||||
wlr_xdg_toplevel_decoration_v1_set_mode(toplevel->decoration, WLR_XDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
@@ -11,6 +12,7 @@ void xdg_decoration_request_mode(struct wl_listener *listener, void *data)
|
||||
|
||||
void xdg_decoration_destroy(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, decoration_destroy);
|
||||
|
||||
wl_list_remove(&toplevel->decoration_request_mode.link);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
void xdg_popup_commit(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_popup *popup = wl_container_of(listener, popup, commit);
|
||||
|
||||
if (popup->xdg_popup->base->initial_commit)
|
||||
@@ -14,6 +15,7 @@ void xdg_popup_commit(struct wl_listener *listener, void *data)
|
||||
|
||||
void xdg_popup_destroy(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_popup *popup = wl_container_of(listener, popup, destroy);
|
||||
|
||||
wl_list_remove(&popup->commit.link);
|
||||
|
||||
+1
-2
@@ -12,10 +12,9 @@
|
||||
|
||||
void xdg_toplevel_commit(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, commit);
|
||||
|
||||
int32_t borders_width = 2 * toplevel->border_width;
|
||||
|
||||
if (toplevel->toplevel.xdg->base->initial_commit) {
|
||||
wlr_xdg_toplevel_set_activated(toplevel->toplevel.xdg, false);
|
||||
|
||||
|
||||
+9
-1
@@ -7,6 +7,7 @@
|
||||
|
||||
void xwayland_activate(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, xwayland_activate);
|
||||
|
||||
if (!absinthe_toplevel_is_unmanaged(toplevel))
|
||||
@@ -15,6 +16,7 @@ void xwayland_activate(struct wl_listener *listener, void *data)
|
||||
|
||||
void xwayland_associate(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, xwayland_associate);
|
||||
|
||||
toplevel->map.notify = absinthe_toplevel_map;
|
||||
@@ -25,6 +27,7 @@ void xwayland_associate(struct wl_listener *listener, void *data)
|
||||
|
||||
void xwayland_dissociate(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, xwayland_dissociate);
|
||||
|
||||
wl_list_remove(&toplevel->map.link);
|
||||
@@ -33,6 +36,7 @@ void xwayland_dissociate(struct wl_listener *listener, void *data)
|
||||
|
||||
void xwayland_configure(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(data);
|
||||
struct absinthe_toplevel *toplevel = wl_container_of(listener, toplevel, xwayland_configure);
|
||||
struct wlr_xwayland_surface_configure_event *event = data;
|
||||
|
||||
@@ -49,6 +53,10 @@ void xwayland_configure(struct wl_listener *listener, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
void xwayland_set_hints(struct wl_listener *listener, void *data) {}
|
||||
void xwayland_set_hints(struct wl_listener *listener, void *data)
|
||||
{
|
||||
UNUSED(listener);
|
||||
UNUSED(data);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user